From 73aa73cf0466581fdebe20d1d46a9aa042923156 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 17 Nov 2025 07:45:09 +0100 Subject: [PATCH 1/2] DAL/Rollups: Use page_content instead of pages in refutation games --- .../refutation_game_helpers.ml | 55 +++++++------------ 1 file changed, 20 insertions(+), 35 deletions(-) diff --git a/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml index 3673c1d22b2f..24ed9d920035 100644 --- a/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml @@ -38,7 +38,7 @@ open Alpha_context slot are not saved to the store, the function returns a failure in the error monad. *) let page_info_from_pvm_state constants (node_ctxt : _ Node_context.t) - ~inbox_level (dal_params : Dal.parameters) start_state = + ~inbox_level start_state = let open Lwt_result_syntax in let is_reveal_enabled = match constants.Rollup_constants.sc_rollup.reveal_activation_level with @@ -73,46 +73,32 @@ let page_info_from_pvm_state constants (node_ctxt : _ Node_context.t) match input_request with | Sc_rollup.(Needs_reveal (Request_dal_page page_id)) -> ( let Dal.Page.{slot_id; page_index} = page_id in - let* pages = - Dal_pages_request.slot_pages + let* page_content_opt = + Dal_pages_request.page_content constants.Rollup_constants.dal ~dal_activation_level ~dal_attested_slots_validity_lag ~inbox_level node_ctxt - slot_id + page_id in - match pages with + match page_content_opt with | None -> return_none (* The slot is not confirmed. *) - | Some pages -> ( - let pages_per_slot = dal_params.slot_size / dal_params.page_size in - (* check invariant that pages' length is correct. *) - (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/4031 - It's better to do the check when the slots are saved into disk. *) - (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/3997 - This check is not resilient to dal parameters change. *) - match List.nth_opt pages page_index with - | Some content -> - let* page_proof = - let dal_cctxt = - WithExceptions.Option.get ~loc:__LOC__ node_ctxt.dal_cctxt - in - let Dal.Slot.Header.{published_level; index} = slot_id in - Dal_node_client.get_slot_page_proof - dal_cctxt - { - slot_level = published_level |> Raw_level.to_int32; - slot_index = index |> Alpha_context.Dal.Slot_index.to_int; - } - page_index - in - return_some (content, page_proof) - | None -> - failwith - "Page index %d too big or negative.\n\ - Number of pages in a slot is %d." - page_index - pages_per_slot)) + | Some content -> + let* page_proof = + let dal_cctxt = + WithExceptions.Option.get ~loc:__LOC__ node_ctxt.dal_cctxt + in + let Dal.Slot.Header.{published_level; index} = slot_id in + Dal_node_client.get_slot_page_proof + dal_cctxt + { + slot_level = published_level |> Raw_level.to_int32; + slot_index = index |> Alpha_context.Dal.Slot_index.to_int; + } + page_index + in + return_some (content, page_proof)) | _ -> return_none let metadata (node_ctxt : _ Node_context.t) = @@ -179,7 +165,6 @@ let generate_proof (node_ctxt : _ Node_context.t) constants ~inbox_level:game.inbox_level node_ctxt - dal_parameters start_state in let module P = struct -- GitLab From aff6c9b5a69d2b816f27c92fe79b5a8a4fb7708a Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 17 Nov 2025 07:37:55 +0100 Subject: [PATCH 2/2] DAL/Rollups: simplify the interface of dal_pages_request.ml --- .../lib_sc_rollup_node/dal_pages_request.ml | 50 ------------------- .../lib_sc_rollup_node/dal_pages_request.mli | 40 ++++++--------- 2 files changed, 14 insertions(+), 76 deletions(-) diff --git a/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.ml b/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.ml index 888a1298e2d3..4b5d16ceb3de 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.ml +++ b/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.ml @@ -285,43 +285,6 @@ let get_dal_node cctxt_opt = let*! err = tzfail No_dal_node_provided in Environment.wrap_tzresult err |> Lwt.return -let slot_pages_int - (dal_constants : Octez_smart_rollup.Rollup_constants.dal_constants) - ~dal_activation_level ~inbox_level node_ctxt slot_id - ~dal_attested_slots_validity_lag = - let open Lwt_result_syntax in - let Node_context.{genesis_info = {level = origination_level; _}; l1_ctxt; _} = - node_ctxt - in - let* chain_id = Layer1.get_chain_id l1_ctxt in - let* dal_cctxt = get_dal_node node_ctxt.dal_cctxt in - let Dal.Slot.Header.{published_level; index} = slot_id in - let* status = - get_slot_header_attestation_info dal_cctxt ~published_level ~index - in - match status with - | `Attested attestation_lag -> - if - not - @@ slot_id_is_valid - chain_id - ~dal_attestation_lag:attestation_lag - ~number_of_slots:dal_constants.number_of_slots - ~dal_activation_level - ~origination_level - ~inbox_level - ~dal_attested_slots_validity_lag - slot_id - then return_none - else - let index = Sc_rollup_proto_types.Dal.Slot_index.to_octez index in - let* pages = - download_confirmed_slot_pages dal_cctxt ~published_level ~index - in - return (Some pages) - | `Unattested | `Unpublished -> return_none - | `Waiting_attestation -> attestation_status_not_final published_level index - let page_content_int (dal_constants : Octez_smart_rollup.Rollup_constants.dal_constants) ~dal_activation_level ~inbox_level node_ctxt page_id @@ -383,16 +346,3 @@ let page_content node_ctxt page_id ~dal_attested_slots_validity_lag - -let slot_pages - (dal_constants : Octez_smart_rollup.Rollup_constants.dal_constants) - ~dal_activation_level ~inbox_level node_ctxt slot_id - ~dal_attested_slots_validity_lag = - with_errors_logging ~inbox_level slot_id - @@ slot_pages_int - dal_constants - ~dal_activation_level - ~inbox_level - node_ctxt - slot_id - ~dal_attested_slots_validity_lag diff --git a/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.mli b/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.mli index 18b1b9abd5ef..21e8ff47f28b 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.mli +++ b/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.mli @@ -26,46 +26,34 @@ open Protocol open Alpha_context -(* TODO: https://gitlab.com/tezos/tezos/-/issues/7070 +(** Access DAL page contents for a rollup. - Rework the interface of dal_pages_request.mli (see the issue for details). *) - -(** Access DAL slots and page contents. - - This module exposes helpers to retrieve DAL slot/page data for a rollup, + This module exposes helpers to retrieve DAL page data for a rollup, while validating import conditions against the DAL attestation lag and the - rollup's context. It queries a DAL node to obtain the slot status and, when - appropriate, to download page contents. *) + rollup's context. It queries a DAL node to obtain the status of the page's + slot and, when appropriate, to download the page content. *) + +(** Retrieve the content of a single DAL page. -(** Retrieve the pages of the given slot. + The function queries the DAL node for the attestation status of the page's + slot: - The function queries the DAL node for the slot's attestation status: - If the slot is [Attested lag], the function checks that importing the slot at [inbox_level] is valid given: - the DAL activation level, - the rollup origination level, - the attested slots validity lag, and - index bounds (number of slots). - If valid, it downloads and returns [Some pages]; otherwise returns [None]. + If valid, it downloads and returns [Some content]; otherwise returns + [None]. + - If the slot is [Unattested] or [Unpublished], returns [None]. + - If the status is [Waiting_attestation], the function returns an error ([Dal_attestation_status_not_final]). - The returned pages, when present, satisfy: - - pages are ordered by increasing page index within the slot, - - the list length equals the expected number of pages for the slot. *) -val slot_pages : - Octez_smart_rollup.Rollup_constants.dal_constants -> - dal_activation_level:Raw_level.t option -> - inbox_level:int32 -> - _ Node_context.t -> - Dal.slot_id -> - dal_attested_slots_validity_lag:int -> - Dal.Page.content list option tzresult Lwt.t - -(** Retrieve the content of a single page. - - Same as {!slot_pages}, but for a single page. *) + When present, the returned content corresponds to the page index carried by + the given [Dal.Page.t]. *) val page_content : Octez_smart_rollup.Rollup_constants.dal_constants -> dal_activation_level:Raw_level.t option -> -- GitLab