From 382c63fe8a171666525cee2cfdcf0a675bd21fba Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:08:21 +0100 Subject: [PATCH 01/11] Proto/Alpha: unplug DAL data of the rollup from refutations --- .../refutation_game_helpers.ml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 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 737e263e18e0..3c2ab6357406 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 @@ -153,31 +153,22 @@ let generate_proof (node_ctxt : _ Node_context.t) let snapshot_level_int32 = (Octez_smart_rollup.Inbox.Skip_list.content game.inbox_snapshot).level in - let get_snapshot_head () = - let+ hash = Node_context.hash_of_level node_ctxt snapshot_level_int32 in - Layer1.{hash; level = snapshot_level_int32} - in let* context = let* start_hash = Node_context.hash_of_level node_ctxt game.inbox_level in let+ context = Node_context.checkout_context node_ctxt start_hash in Context.index context in let* dal_slots_history = - if Node_context.dal_supported node_ctxt then - let* snapshot_head = get_snapshot_head () in - Dal_slots_tracker.slots_history_of_hash node_ctxt snapshot_head - else return Dal.Slots_history.genesis + (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3805 *) + return Dal.Slots_history.genesis in let* dal_slots_history_cache_view = + (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3805 *) let* dal_slots_history_cache = - if Node_context.dal_supported node_ctxt then - let* snapshot_head = get_snapshot_head () in - Dal_slots_tracker.slots_history_cache_of_hash node_ctxt snapshot_head - else return (Dal.Slots_history.History_cache.empty ~capacity:0L) + return (Dal.Slots_history.History_cache.empty ~capacity:0L) in Dal.Slots_history.History_cache.view dal_slots_history_cache |> return in - (* We fetch the value of protocol constants at block snapshot level where the game started. *) let* constants = -- GitLab From baff657dca8b6c398b4f867cf066ac3198338f5b Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:08:41 +0100 Subject: [PATCH 02/11] Proto/ParisA: unplug DAL data of the rollup from refutations --- .../refutation_game_helpers.ml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/proto_019_PtParisA/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_019_PtParisA/lib_sc_rollup_node/refutation_game_helpers.ml index 737e263e18e0..d7d7c95472a2 100644 --- a/src/proto_019_PtParisA/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_019_PtParisA/lib_sc_rollup_node/refutation_game_helpers.ml @@ -153,27 +153,19 @@ let generate_proof (node_ctxt : _ Node_context.t) let snapshot_level_int32 = (Octez_smart_rollup.Inbox.Skip_list.content game.inbox_snapshot).level in - let get_snapshot_head () = - let+ hash = Node_context.hash_of_level node_ctxt snapshot_level_int32 in - Layer1.{hash; level = snapshot_level_int32} - in let* context = let* start_hash = Node_context.hash_of_level node_ctxt game.inbox_level in let+ context = Node_context.checkout_context node_ctxt start_hash in Context.index context in let* dal_slots_history = - if Node_context.dal_supported node_ctxt then - let* snapshot_head = get_snapshot_head () in - Dal_slots_tracker.slots_history_of_hash node_ctxt snapshot_head - else return Dal.Slots_history.genesis + (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3805 *) + return Dal.Slots_history.genesis in let* dal_slots_history_cache_view = + (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3805 *) let* dal_slots_history_cache = - if Node_context.dal_supported node_ctxt then - let* snapshot_head = get_snapshot_head () in - Dal_slots_tracker.slots_history_cache_of_hash node_ctxt snapshot_head - else return (Dal.Slots_history.History_cache.empty ~capacity:0L) + return (Dal.Slots_history.History_cache.empty ~capacity:0L) in Dal.Slots_history.History_cache.view dal_slots_history_cache |> return in -- GitLab From 3245ee25dab050a356c461a703e5b0531da3cd07 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:10:01 +0100 Subject: [PATCH 03/11] Proto/Oxford: unplug DAL data of the rollup from refutations --- .../refutation_game_helpers.ml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game_helpers.ml index 632dd31c0bf8..f1aa146fab75 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/refutation_game_helpers.ml @@ -136,26 +136,18 @@ let generate_proof (node_ctxt : _ Node_context.t) let snapshot_level_int32 = (Octez_smart_rollup.Inbox.Skip_list.content game.inbox_snapshot).level in - let get_snapshot_head () = - let+ hash = Node_context.hash_of_level node_ctxt snapshot_level_int32 in - Layer1.{hash; level = snapshot_level_int32} - in let* context = let* start_hash = Node_context.hash_of_level node_ctxt game.inbox_level in let+ context = Node_context.checkout_context node_ctxt start_hash in Context.index context in let* dal_slots_history = - if Node_context.dal_supported node_ctxt then - let* snapshot_head = get_snapshot_head () in - Dal_slots_tracker.slots_history_of_hash node_ctxt snapshot_head - else return Dal.Slots_history.genesis + (* DAL is not activated in Oxford *) + return Dal.Slots_history.genesis in let* dal_slots_history_cache = - if Node_context.dal_supported node_ctxt then - let* snapshot_head = get_snapshot_head () in - Dal_slots_tracker.slots_history_cache_of_hash node_ctxt snapshot_head - else return (Dal.Slots_history.History_cache.empty ~capacity:0L) + (* DAL is not activated in Oxford *) + return (Dal.Slots_history.History_cache.empty ~capacity:0L) in (* We fetch the value of protocol constants at block snapshot level where the game started. *) -- GitLab From 0d9ac3bd274ab278facb8d6d31d3881cd14c0e75 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:10:11 +0100 Subject: [PATCH 04/11] Proto/Nairobi: unplug DAL data of the rollup from refutations --- .../refutation_game_helpers.ml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game_helpers.ml index 6d032fcc38f9..c7eb44163e33 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/refutation_game_helpers.ml @@ -122,26 +122,18 @@ let generate_proof (node_ctxt : _ Node_context.t) let snapshot_level_int32 = (Octez_smart_rollup.Inbox.Skip_list.content game.inbox_snapshot).level in - let get_snapshot_head () = - let+ hash = Node_context.hash_of_level node_ctxt snapshot_level_int32 in - Layer1.{hash; level = snapshot_level_int32} - in let* context = let* start_hash = Node_context.hash_of_level node_ctxt game.inbox_level in let+ context = Node_context.checkout_context node_ctxt start_hash in Context.index context in let* dal_slots_history = - if Node_context.dal_supported node_ctxt then - let* snapshot_head = get_snapshot_head () in - Dal_slots_tracker.slots_history_of_hash node_ctxt snapshot_head - else return Dal.Slots_history.genesis + (* DAL is not activated in Nairobi *) + return Dal.Slots_history.genesis in let* dal_slots_history_cache = - if Node_context.dal_supported node_ctxt then - let* snapshot_head = get_snapshot_head () in - Dal_slots_tracker.slots_history_cache_of_hash node_ctxt snapshot_head - else return (Dal.Slots_history.History_cache.empty ~capacity:0L) + (* DAL is not activated in Nairobi *) + return (Dal.Slots_history.History_cache.empty ~capacity:0L) in (* We fetch the value of protocol constants at block snapshot level where the game started. *) -- GitLab From 19fa6b7b4dbd8ebadc79daaff4c9fa06645964aa Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:10:45 +0100 Subject: [PATCH 05/11] Proto/Alpha: don't index data about DAL skip lists in rollup node --- .../lib_sc_rollup_node/dal_slots_tracker.ml | 189 +----------------- .../lib_sc_rollup_node/dal_slots_tracker.mli | 14 -- 2 files changed, 5 insertions(+), 198 deletions(-) diff --git a/src/proto_alpha/lib_sc_rollup_node/dal_slots_tracker.ml b/src/proto_alpha/lib_sc_rollup_node/dal_slots_tracker.ml index 13054196d66b..eb4198d69171 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dal_slots_tracker.ml +++ b/src/proto_alpha/lib_sc_rollup_node/dal_slots_tracker.ml @@ -173,177 +173,6 @@ let download_and_save_slots constants (node_context : _ Node_context.t) return_unit) confirmed -module Confirmed_slots_history = struct - (** [confirmed_slots_with_headers constants node_ctxt confirmations_info] returns the - headers of confirmed slot indexes for the block with hash - [confirmations_info.published_block_hash]. *) - let confirmed_slots_with_headers constants node_ctxt - {published_block_hash; confirmed_slots_indexes; _} = - let open Lwt_result_syntax in - let*? relevant_slots_indexes = - Environment.wrap_tzresult - @@ to_slot_index_list constants confirmed_slots_indexes - in - List.map_ep - (fun slot_index -> - let+ h = - Node_context.get_slot_header - node_ctxt - ~published_in_block_hash:published_block_hash - slot_index - in - Sc_rollup_proto_types.Dal.Slot_header.of_octez - ~number_of_slots:constants.dal.number_of_slots - h) - relevant_slots_indexes - - let read_slots_history_from_l1 _constants {Node_context.cctxt; _} block = - let open Lwt_result_syntax in - (* We return the empty Slots_history if DAL is not enabled. *) - let* slots_list_opt = - RPC.Dal.dal_confirmed_slots_history - (new Protocol_client_context.wrap_full cctxt) - (cctxt#chain, `Hash (block, 0)) - in - return @@ Option.value slots_list_opt ~default:Dal.Slots_history.genesis - - (** Depending on the rollup's origination level and on the DAL's attestation - lag, the rollup node should start processing confirmed slots and update its - slots_history and slots_history's cache entries in the store after - [origination_level + attestation_lag] blocks. This function checks if - that level is reached or not. *) - let should_process_dal_slots constants node_ctxt block_level = - let open Node_context in - let lag = Int32.of_int constants.Rollup_constants.dal.attestation_lag in - let block_level = Raw_level.to_int32 block_level in - let genesis_level = node_ctxt.genesis_info.level in - Int32.(block_level >= add lag genesis_level) - - let dal_entry_of_block_hash node_ctxt - Layer1.{hash = block_hash; level = block_level} ~entry_kind ~find ~default - = - let open Lwt_result_syntax in - let* confirmed_slots_history_opt = find node_ctxt block_hash in - let* constants = - Protocol_plugins.get_constants_of_level node_ctxt block_level - in - let block_level = Raw_level.of_int32_exn block_level in - let should_process_dal_slots = - should_process_dal_slots constants node_ctxt block_level - in - match (confirmed_slots_history_opt, should_process_dal_slots) with - | Some confirmed_dal_slots, true -> return confirmed_dal_slots - | None, false -> default constants node_ctxt block_hash - | Some _confirmed_dal_slots, false -> - failwith - "The confirmed DAL %S for block hash %a (level = %a) is not expected \ - to be found in the store, but is exists." - entry_kind - Block_hash.pp - block_hash - Raw_level.pp - block_level - | None, true -> - failwith - "The confirmed DAL %S for block hash %a (level = %a) is expected to \ - be found in the store, but is missing." - entry_kind - Block_hash.pp - block_hash - Raw_level.pp - block_level - - let slots_history_of_hash node_ctxt block = - let find node_ctxt block = - let open Lwt_result_syntax in - let+ hist = Node_context.find_confirmed_slots_history node_ctxt block in - Option.map Sc_rollup_proto_types.Dal.Slot_history.of_octez hist - in - dal_entry_of_block_hash - node_ctxt - block - ~entry_kind:"slots history" - ~find - ~default:read_slots_history_from_l1 - - let slots_history_cache_of_hash node_ctxt block = - let open Lwt_result_syntax in - let find node_ctxt block = - let+ hist = Node_context.find_confirmed_slots_histories node_ctxt block in - Option.map Sc_rollup_proto_types.Dal.Slot_history_cache.of_octez hist - in - dal_entry_of_block_hash - node_ctxt - block - ~entry_kind:"slots history cache" - ~find - ~default:(fun constants _node_ctxt _block -> - let num_slots = constants.Rollup_constants.dal.number_of_slots in - (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/3788 - Put an accurate value for capacity. The value - `num_slots * 60000` below is chosen based on: - - The number of remembered L1 inboxes in their corresponding - cache (60000), - - The (max) number of slots (num_slots) that could be attested - per L1 block, - - The way the Slots_history.t skip list is implemented (one slot - per cell). *) - return - @@ Dal.Slots_history.History_cache.empty - ~capacity:(Int64.of_int @@ (num_slots * 60000))) - - let update constants node_ctxt Layer1.({hash = head_hash; _} as head) - confirmation_info = - let open Lwt_result_syntax in - let* slots_to_save = - confirmed_slots_with_headers constants node_ctxt confirmation_info - in - let slots_to_save = - let open Dal in - List.fast_sort - (fun Slot.Header.{id = {index = a; _}; _} {id = {index = b; _}; _} -> - Slot_index.compare a b) - slots_to_save - in - let* pred = Node_context.get_predecessor node_ctxt head in - let* slots_history = slots_history_of_hash node_ctxt pred in - let* slots_cache = slots_history_cache_of_hash node_ctxt pred in - let* level = - Node_context.level_of_hash - node_ctxt - confirmation_info.published_block_hash - in - let*? level = Raw_level.of_int32 level |> Environment.wrap_tzresult in - let*? slots_history, slots_cache = - Dal.Slots_history.add_confirmed_slot_headers - ~number_of_slots:constants.dal.number_of_slots - slots_history - slots_cache - level - slots_to_save - |> Environment.wrap_tzresult - in - (* The value of [slots_history] computed here is supposed to be equal to the - one computed stored for block [head_hash] on L1, we basically re-do the - computation here because we need to build/maintain the [slots_cache] - bounded cache in case we need it for refutation game. *) - (* TODO/DAL: https://gitlab.com/tezos/tezos/-/issues/3856 - Attempt to improve this process. *) - let* () = - Node_context.save_confirmed_slots_history - node_ctxt - head_hash - (Sc_rollup_proto_types.Dal.Slot_history.to_octez slots_history) - in - let* () = - Node_context.save_confirmed_slots_histories - node_ctxt - head_hash - (Sc_rollup_proto_types.Dal.Slot_history_cache.to_octez slots_cache) - in - return () -end - let process_head node_ctxt (Layer1.{hash = head_hash; level} as head) = let open Lwt_result_syntax in let* constants = Protocol_plugins.get_constants_of_level node_ctxt level in @@ -351,16 +180,8 @@ let process_head node_ctxt (Layer1.{hash = head_hash; level} as head) = match confirmation_info with | None -> return_unit | Some confirmation_info -> - let* () = - download_and_save_slots - ~current_block_hash:head_hash - constants - node_ctxt - confirmation_info - in - Confirmed_slots_history.update constants node_ctxt head confirmation_info - -let slots_history_of_hash = Confirmed_slots_history.slots_history_of_hash - -let slots_history_cache_of_hash = - Confirmed_slots_history.slots_history_cache_of_hash + download_and_save_slots + ~current_block_hash:head_hash + constants + node_ctxt + confirmation_info diff --git a/src/proto_alpha/lib_sc_rollup_node/dal_slots_tracker.mli b/src/proto_alpha/lib_sc_rollup_node/dal_slots_tracker.mli index 42828705e639..f3b90f08e278 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dal_slots_tracker.mli +++ b/src/proto_alpha/lib_sc_rollup_node/dal_slots_tracker.mli @@ -39,17 +39,3 @@ [Store.Dal_confirmed_slots].} } *) val process_head : Node_context.rw -> Layer1.head -> unit tzresult Lwt.t - -(** [slots_history_of_hash node_ctxt block_hash] returns the DAL confirmed slots - history at the end of the given [block_hash] validation. *) -val slots_history_of_hash : - _ Node_context.t -> - Layer1.head -> - Protocol.Alpha_context.Dal.Slots_history.t tzresult Lwt.t - -(** [slots_history_cache_of_hash node_ctxt block_hash] returns the DAL confirmed - slots history cache at the end of the given [block_hash] validation. *) -val slots_history_cache_of_hash : - _ Node_context.t -> - Layer1.head -> - Protocol.Alpha_context.Dal.Slots_history.History_cache.t tzresult Lwt.t -- GitLab From c6ea4af593324b333a7f4a7cb625a07c553e8318 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:10:55 +0100 Subject: [PATCH 06/11] Proto/Paris: don't index data about DAL skip lists in rollup node --- .../lib_sc_rollup_node/dal_slots_tracker.ml | 189 +----------------- .../lib_sc_rollup_node/dal_slots_tracker.mli | 14 -- 2 files changed, 5 insertions(+), 198 deletions(-) diff --git a/src/proto_019_PtParisA/lib_sc_rollup_node/dal_slots_tracker.ml b/src/proto_019_PtParisA/lib_sc_rollup_node/dal_slots_tracker.ml index 13054196d66b..eb4198d69171 100644 --- a/src/proto_019_PtParisA/lib_sc_rollup_node/dal_slots_tracker.ml +++ b/src/proto_019_PtParisA/lib_sc_rollup_node/dal_slots_tracker.ml @@ -173,177 +173,6 @@ let download_and_save_slots constants (node_context : _ Node_context.t) return_unit) confirmed -module Confirmed_slots_history = struct - (** [confirmed_slots_with_headers constants node_ctxt confirmations_info] returns the - headers of confirmed slot indexes for the block with hash - [confirmations_info.published_block_hash]. *) - let confirmed_slots_with_headers constants node_ctxt - {published_block_hash; confirmed_slots_indexes; _} = - let open Lwt_result_syntax in - let*? relevant_slots_indexes = - Environment.wrap_tzresult - @@ to_slot_index_list constants confirmed_slots_indexes - in - List.map_ep - (fun slot_index -> - let+ h = - Node_context.get_slot_header - node_ctxt - ~published_in_block_hash:published_block_hash - slot_index - in - Sc_rollup_proto_types.Dal.Slot_header.of_octez - ~number_of_slots:constants.dal.number_of_slots - h) - relevant_slots_indexes - - let read_slots_history_from_l1 _constants {Node_context.cctxt; _} block = - let open Lwt_result_syntax in - (* We return the empty Slots_history if DAL is not enabled. *) - let* slots_list_opt = - RPC.Dal.dal_confirmed_slots_history - (new Protocol_client_context.wrap_full cctxt) - (cctxt#chain, `Hash (block, 0)) - in - return @@ Option.value slots_list_opt ~default:Dal.Slots_history.genesis - - (** Depending on the rollup's origination level and on the DAL's attestation - lag, the rollup node should start processing confirmed slots and update its - slots_history and slots_history's cache entries in the store after - [origination_level + attestation_lag] blocks. This function checks if - that level is reached or not. *) - let should_process_dal_slots constants node_ctxt block_level = - let open Node_context in - let lag = Int32.of_int constants.Rollup_constants.dal.attestation_lag in - let block_level = Raw_level.to_int32 block_level in - let genesis_level = node_ctxt.genesis_info.level in - Int32.(block_level >= add lag genesis_level) - - let dal_entry_of_block_hash node_ctxt - Layer1.{hash = block_hash; level = block_level} ~entry_kind ~find ~default - = - let open Lwt_result_syntax in - let* confirmed_slots_history_opt = find node_ctxt block_hash in - let* constants = - Protocol_plugins.get_constants_of_level node_ctxt block_level - in - let block_level = Raw_level.of_int32_exn block_level in - let should_process_dal_slots = - should_process_dal_slots constants node_ctxt block_level - in - match (confirmed_slots_history_opt, should_process_dal_slots) with - | Some confirmed_dal_slots, true -> return confirmed_dal_slots - | None, false -> default constants node_ctxt block_hash - | Some _confirmed_dal_slots, false -> - failwith - "The confirmed DAL %S for block hash %a (level = %a) is not expected \ - to be found in the store, but is exists." - entry_kind - Block_hash.pp - block_hash - Raw_level.pp - block_level - | None, true -> - failwith - "The confirmed DAL %S for block hash %a (level = %a) is expected to \ - be found in the store, but is missing." - entry_kind - Block_hash.pp - block_hash - Raw_level.pp - block_level - - let slots_history_of_hash node_ctxt block = - let find node_ctxt block = - let open Lwt_result_syntax in - let+ hist = Node_context.find_confirmed_slots_history node_ctxt block in - Option.map Sc_rollup_proto_types.Dal.Slot_history.of_octez hist - in - dal_entry_of_block_hash - node_ctxt - block - ~entry_kind:"slots history" - ~find - ~default:read_slots_history_from_l1 - - let slots_history_cache_of_hash node_ctxt block = - let open Lwt_result_syntax in - let find node_ctxt block = - let+ hist = Node_context.find_confirmed_slots_histories node_ctxt block in - Option.map Sc_rollup_proto_types.Dal.Slot_history_cache.of_octez hist - in - dal_entry_of_block_hash - node_ctxt - block - ~entry_kind:"slots history cache" - ~find - ~default:(fun constants _node_ctxt _block -> - let num_slots = constants.Rollup_constants.dal.number_of_slots in - (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/3788 - Put an accurate value for capacity. The value - `num_slots * 60000` below is chosen based on: - - The number of remembered L1 inboxes in their corresponding - cache (60000), - - The (max) number of slots (num_slots) that could be attested - per L1 block, - - The way the Slots_history.t skip list is implemented (one slot - per cell). *) - return - @@ Dal.Slots_history.History_cache.empty - ~capacity:(Int64.of_int @@ (num_slots * 60000))) - - let update constants node_ctxt Layer1.({hash = head_hash; _} as head) - confirmation_info = - let open Lwt_result_syntax in - let* slots_to_save = - confirmed_slots_with_headers constants node_ctxt confirmation_info - in - let slots_to_save = - let open Dal in - List.fast_sort - (fun Slot.Header.{id = {index = a; _}; _} {id = {index = b; _}; _} -> - Slot_index.compare a b) - slots_to_save - in - let* pred = Node_context.get_predecessor node_ctxt head in - let* slots_history = slots_history_of_hash node_ctxt pred in - let* slots_cache = slots_history_cache_of_hash node_ctxt pred in - let* level = - Node_context.level_of_hash - node_ctxt - confirmation_info.published_block_hash - in - let*? level = Raw_level.of_int32 level |> Environment.wrap_tzresult in - let*? slots_history, slots_cache = - Dal.Slots_history.add_confirmed_slot_headers - ~number_of_slots:constants.dal.number_of_slots - slots_history - slots_cache - level - slots_to_save - |> Environment.wrap_tzresult - in - (* The value of [slots_history] computed here is supposed to be equal to the - one computed stored for block [head_hash] on L1, we basically re-do the - computation here because we need to build/maintain the [slots_cache] - bounded cache in case we need it for refutation game. *) - (* TODO/DAL: https://gitlab.com/tezos/tezos/-/issues/3856 - Attempt to improve this process. *) - let* () = - Node_context.save_confirmed_slots_history - node_ctxt - head_hash - (Sc_rollup_proto_types.Dal.Slot_history.to_octez slots_history) - in - let* () = - Node_context.save_confirmed_slots_histories - node_ctxt - head_hash - (Sc_rollup_proto_types.Dal.Slot_history_cache.to_octez slots_cache) - in - return () -end - let process_head node_ctxt (Layer1.{hash = head_hash; level} as head) = let open Lwt_result_syntax in let* constants = Protocol_plugins.get_constants_of_level node_ctxt level in @@ -351,16 +180,8 @@ let process_head node_ctxt (Layer1.{hash = head_hash; level} as head) = match confirmation_info with | None -> return_unit | Some confirmation_info -> - let* () = - download_and_save_slots - ~current_block_hash:head_hash - constants - node_ctxt - confirmation_info - in - Confirmed_slots_history.update constants node_ctxt head confirmation_info - -let slots_history_of_hash = Confirmed_slots_history.slots_history_of_hash - -let slots_history_cache_of_hash = - Confirmed_slots_history.slots_history_cache_of_hash + download_and_save_slots + ~current_block_hash:head_hash + constants + node_ctxt + confirmation_info diff --git a/src/proto_019_PtParisA/lib_sc_rollup_node/dal_slots_tracker.mli b/src/proto_019_PtParisA/lib_sc_rollup_node/dal_slots_tracker.mli index 42828705e639..f3b90f08e278 100644 --- a/src/proto_019_PtParisA/lib_sc_rollup_node/dal_slots_tracker.mli +++ b/src/proto_019_PtParisA/lib_sc_rollup_node/dal_slots_tracker.mli @@ -39,17 +39,3 @@ [Store.Dal_confirmed_slots].} } *) val process_head : Node_context.rw -> Layer1.head -> unit tzresult Lwt.t - -(** [slots_history_of_hash node_ctxt block_hash] returns the DAL confirmed slots - history at the end of the given [block_hash] validation. *) -val slots_history_of_hash : - _ Node_context.t -> - Layer1.head -> - Protocol.Alpha_context.Dal.Slots_history.t tzresult Lwt.t - -(** [slots_history_cache_of_hash node_ctxt block_hash] returns the DAL confirmed - slots history cache at the end of the given [block_hash] validation. *) -val slots_history_cache_of_hash : - _ Node_context.t -> - Layer1.head -> - Protocol.Alpha_context.Dal.Slots_history.History_cache.t tzresult Lwt.t -- GitLab From 20c5d4eae7762524b3f6705bbbe7911354cc6ffb Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:11:08 +0100 Subject: [PATCH 07/11] Proto/Oxford: don't index data about DAL skip lists in rollup node --- .../lib_sc_rollup_node/dal_slots_tracker.ml | 181 +----------------- .../lib_sc_rollup_node/dal_slots_tracker.mli | 14 -- 2 files changed, 5 insertions(+), 190 deletions(-) diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/dal_slots_tracker.ml b/src/proto_018_Proxford/lib_sc_rollup_node/dal_slots_tracker.ml index ba7676a6bfeb..702743cadd0f 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/dal_slots_tracker.ml +++ b/src/proto_018_Proxford/lib_sc_rollup_node/dal_slots_tracker.ml @@ -177,169 +177,6 @@ let download_and_save_slots constants (node_context : _ Node_context.t) return_unit) confirmed -module Confirmed_slots_history = struct - (** [confirmed_slots_with_headers constants node_ctxt confirmations_info] returns the - headers of confirmed slot indexes for the block with hash - [confirmations_info.published_block_hash]. *) - let confirmed_slots_with_headers constants node_ctxt - {published_block_hash; confirmed_slots_indexes; _} = - let open Lwt_result_syntax in - let*? relevant_slots_indexes = - Environment.wrap_tzresult - @@ to_slot_index_list constants confirmed_slots_indexes - in - List.map_ep - (fun slot_index -> - let+ h = - Node_context.get_slot_header - node_ctxt - ~published_in_block_hash:published_block_hash - slot_index - in - Sc_rollup_proto_types.Dal.Slot_header.of_octez - ~number_of_slots:constants.dal.number_of_slots - h) - relevant_slots_indexes - - let read_slots_history_from_l1 _constants {Node_context.cctxt; _} block = - let open Lwt_result_syntax in - (* We return the empty Slots_history if DAL is not enabled. *) - let* slots_list_opt = - RPC.Dal.dal_confirmed_slots_history - (new Protocol_client_context.wrap_full cctxt) - (cctxt#chain, `Hash (block, 0)) - in - return @@ Option.value slots_list_opt ~default:Dal.Slots_history.genesis - - (** Depending on the rollup's origination level and on the DAL's attestation - lag, the rollup node should start processing confirmed slots and update its - slots_history and slots_history's cache entries in the store after - [origination_level + attestation_lag] blocks. This function checks if - that level is reached or not. *) - let should_process_dal_slots constants node_ctxt block_level = - let open Node_context in - let lag = Int32.of_int constants.Rollup_constants.dal.attestation_lag in - let block_level = Raw_level.to_int32 block_level in - let genesis_level = node_ctxt.genesis_info.level in - Int32.(block_level >= add lag genesis_level) - - let dal_entry_of_block_hash node_ctxt - Layer1.{hash = block_hash; level = block_level} ~entry_kind ~find ~default - = - let open Lwt_result_syntax in - let* confirmed_slots_history_opt = find node_ctxt block_hash in - let* constants = - Protocol_plugins.get_constants_of_level node_ctxt block_level - in - let block_level = Raw_level.of_int32_exn block_level in - let should_process_dal_slots = - should_process_dal_slots constants node_ctxt block_level - in - match (confirmed_slots_history_opt, should_process_dal_slots) with - | Some confirmed_dal_slots, true -> return confirmed_dal_slots - | None, false -> default constants node_ctxt block_hash - | Some _confirmed_dal_slots, false -> - failwith - "The confirmed DAL %S for block hash %a (level = %a) is not expected \ - to be found in the store, but is exists." - entry_kind - Block_hash.pp - block_hash - Raw_level.pp - block_level - | None, true -> - failwith - "The confirmed DAL %S for block hash %a (level = %a) is expected to \ - be found in the store, but is missing." - entry_kind - Block_hash.pp - block_hash - Raw_level.pp - block_level - - let slots_history_of_hash node_ctxt block = - let find node_ctxt block = - let open Lwt_result_syntax in - let+ hist = Node_context.find_confirmed_slots_history node_ctxt block in - Option.map Sc_rollup_proto_types.Dal.Slot_history.of_octez hist - in - dal_entry_of_block_hash - node_ctxt - block - ~entry_kind:"slots history" - ~find - ~default:read_slots_history_from_l1 - - let slots_history_cache_of_hash node_ctxt block = - let find node_ctxt block = - let open Lwt_result_syntax in - let+ hist = Node_context.find_confirmed_slots_histories node_ctxt block in - Option.map Sc_rollup_proto_types.Dal.Slot_history_cache.of_octez hist - in - dal_entry_of_block_hash - node_ctxt - block - ~entry_kind:"slots history cache" - ~find - ~default:(fun constants _node_ctxt _block -> - let num_slots = constants.Rollup_constants.dal.number_of_slots in - (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/3788 - Put an accurate value for capacity. The value - `num_slots * 60000` below is chosen based on: - - The number of remembered L1 inboxes in their corresponding - cache (60000), - - The (max) number of slots (num_slots) that could be attested - per L1 block, - - The way the Slots_history.t skip list is implemented (one slot - per cell). *) - return - @@ Dal.Slots_history.History_cache.empty - ~capacity:(Int64.of_int @@ (num_slots * 60000))) - - let update constants node_ctxt Layer1.({hash = head_hash; _} as head) - confirmation_info = - let open Lwt_result_syntax in - let* slots_to_save = - confirmed_slots_with_headers constants node_ctxt confirmation_info - in - let slots_to_save = - let open Dal in - List.fast_sort - (fun Slot.Header.{id = {index = a; _}; _} {id = {index = b; _}; _} -> - Slot_index.compare a b) - slots_to_save - in - let* pred = Node_context.get_predecessor node_ctxt head in - let* slots_history = slots_history_of_hash node_ctxt pred in - let* slots_cache = slots_history_cache_of_hash node_ctxt pred in - let*? slots_history, slots_cache = - Dal.Slots_history.add_confirmed_slot_headers - slots_history - slots_cache - slots_to_save - |> Environment.wrap_tzresult - in - (* The value of [slots_history] computed here is supposed to be equal to the - one computed stored for block [head_hash] on L1, we basically re-do the - computation here because we need to build/maintain the [slots_cache] - bounded cache in case we need it for refutation game. *) - (* TODO/DAL: https://gitlab.com/tezos/tezos/-/issues/3856 - Attempt to improve this process. *) - let* () = - Node_context.save_confirmed_slots_history - node_ctxt - head_hash - (Sc_rollup_proto_types.Dal.Slot_history.to_octez slots_history) - in - let* () = - Node_context.save_confirmed_slots_histories - node_ctxt - head_hash - (Sc_rollup_proto_types.Dal.Slot_history_cache.to_octez slots_cache) - in - return () -end - let process_head node_ctxt (Layer1.{hash = head_hash; level} as head) = let open Lwt_result_syntax in let* constants = Protocol_plugins.get_constants_of_level node_ctxt level in @@ -347,16 +184,8 @@ let process_head node_ctxt (Layer1.{hash = head_hash; level} as head) = match confirmation_info with | None -> return_unit | Some confirmation_info -> - let* () = - download_and_save_slots - ~current_block_hash:head_hash - constants - node_ctxt - confirmation_info - in - Confirmed_slots_history.update constants node_ctxt head confirmation_info - -let slots_history_of_hash = Confirmed_slots_history.slots_history_of_hash - -let slots_history_cache_of_hash = - Confirmed_slots_history.slots_history_cache_of_hash + download_and_save_slots + ~current_block_hash:head_hash + constants + node_ctxt + confirmation_info diff --git a/src/proto_018_Proxford/lib_sc_rollup_node/dal_slots_tracker.mli b/src/proto_018_Proxford/lib_sc_rollup_node/dal_slots_tracker.mli index 42828705e639..f3b90f08e278 100644 --- a/src/proto_018_Proxford/lib_sc_rollup_node/dal_slots_tracker.mli +++ b/src/proto_018_Proxford/lib_sc_rollup_node/dal_slots_tracker.mli @@ -39,17 +39,3 @@ [Store.Dal_confirmed_slots].} } *) val process_head : Node_context.rw -> Layer1.head -> unit tzresult Lwt.t - -(** [slots_history_of_hash node_ctxt block_hash] returns the DAL confirmed slots - history at the end of the given [block_hash] validation. *) -val slots_history_of_hash : - _ Node_context.t -> - Layer1.head -> - Protocol.Alpha_context.Dal.Slots_history.t tzresult Lwt.t - -(** [slots_history_cache_of_hash node_ctxt block_hash] returns the DAL confirmed - slots history cache at the end of the given [block_hash] validation. *) -val slots_history_cache_of_hash : - _ Node_context.t -> - Layer1.head -> - Protocol.Alpha_context.Dal.Slots_history.History_cache.t tzresult Lwt.t -- GitLab From 383d1a02653948e8d8cda6d166ea4defe028a5ee Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:11:15 +0100 Subject: [PATCH 08/11] Proto/Nairobi: don't index data about DAL skip lists in rollup node --- .../lib_sc_rollup_node/dal_slots_tracker.ml | 179 +----------------- .../lib_sc_rollup_node/dal_slots_tracker.mli | 14 -- 2 files changed, 5 insertions(+), 188 deletions(-) diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/dal_slots_tracker.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/dal_slots_tracker.ml index 9413217988da..f9f03db9a6c0 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/dal_slots_tracker.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/dal_slots_tracker.ml @@ -175,167 +175,6 @@ let download_and_save_slots constants (node_context : _ Node_context.t) return_unit) confirmed -module Confirmed_slots_history = struct - (** [confirmed_slots_with_headers constants node_ctxt confirmations_info] returns the - headers of confirmed slot indexes for the block with hash - [confirmations_info.published_block_hash]. *) - let confirmed_slots_with_headers constants node_ctxt - {published_block_hash; confirmed_slots_indexes; _} = - let open Lwt_result_syntax in - let*? relevant_slots_indexes = - Environment.wrap_tzresult - @@ to_slot_index_list constants confirmed_slots_indexes - in - List.map_ep - (fun slot_index -> - let+ h = - Node_context.get_slot_header - node_ctxt - ~published_in_block_hash:published_block_hash - slot_index - in - Sc_rollup_proto_types.Dal.Slot_header.of_octez h) - relevant_slots_indexes - - let read_slots_history_from_l1 _constants {Node_context.cctxt; _} block = - let open Lwt_result_syntax in - (* We return the empty Slots_history if DAL is not enabled. *) - let* slots_list_opt = - RPC.Dal.dal_confirmed_slots_history - (new Protocol_client_context.wrap_full cctxt) - (cctxt#chain, `Hash (block, 0)) - in - return @@ Option.value slots_list_opt ~default:Dal.Slots_history.genesis - - (** Depending on the rollup's origination level and on the DAL's endorsement - lag, the rollup node should start processing confirmed slots and update its - slots_history and slots_history's cache entries in the store after - [origination_level + attestation_lag] blocks. This function checks if - that level is reached or not. *) - let should_process_dal_slots constants node_ctxt block_level = - let open Node_context in - let lag = Int32.of_int constants.Rollup_constants.dal.attestation_lag in - let block_level = Raw_level.to_int32 block_level in - let genesis_level = node_ctxt.genesis_info.level in - Int32.(block_level >= add lag genesis_level) - - let dal_entry_of_block_hash node_ctxt - Layer1.{hash = block_hash; level = block_level} ~entry_kind ~find ~default - = - let open Lwt_result_syntax in - let* confirmed_slots_history_opt = find node_ctxt block_hash in - let* constants = - Protocol_plugins.get_constants_of_level node_ctxt block_level - in - let block_level = Raw_level.of_int32_exn block_level in - let should_process_dal_slots = - should_process_dal_slots constants node_ctxt block_level - in - match (confirmed_slots_history_opt, should_process_dal_slots) with - | Some confirmed_dal_slots, true -> return confirmed_dal_slots - | None, false -> default constants node_ctxt block_hash - | Some _confirmed_dal_slots, false -> - failwith - "The confirmed DAL %S for block hash %a (level = %a) is not expected \ - to be found in the store, but is exists." - entry_kind - Block_hash.pp - block_hash - Raw_level.pp - block_level - | None, true -> - failwith - "The confirmed DAL %S for block hash %a (level = %a) is expected to \ - be found in the store, but is missing." - entry_kind - Block_hash.pp - block_hash - Raw_level.pp - block_level - - let slots_history_of_hash node_ctxt block = - let find node_ctxt block = - let open Lwt_result_syntax in - let+ hist = Node_context.find_confirmed_slots_history node_ctxt block in - Option.map Sc_rollup_proto_types.Dal.Slot_history.of_octez hist - in - dal_entry_of_block_hash - node_ctxt - block - ~entry_kind:"slots history" - ~find - ~default:read_slots_history_from_l1 - - let slots_history_cache_of_hash node_ctxt block = - let find node_ctxt block = - let open Lwt_result_syntax in - let+ hist = Node_context.find_confirmed_slots_histories node_ctxt block in - Option.map Sc_rollup_proto_types.Dal.Slot_history_cache.of_octez hist - in - dal_entry_of_block_hash - node_ctxt - block - ~entry_kind:"slots history cache" - ~find - ~default:(fun constants _node_ctxt _block -> - let num_slots = constants.Rollup_constants.dal.number_of_slots in - (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/3788 - Put an accurate value for capacity. The value - `num_slots * 60000` below is chosen based on: - - The number of remembered L1 inboxes in their corresponding - cache (60000), - - The (max) number of slots (num_slots) that could be attested - per L1 block, - - The way the Slots_history.t skip list is implemented (one slot - per cell). *) - return - @@ Dal.Slots_history.History_cache.empty - ~capacity:(Int64.of_int @@ (num_slots * 60000))) - - let update constants node_ctxt Layer1.({hash = head_hash; _} as head) - confirmation_info = - let open Lwt_result_syntax in - let* slots_to_save = - confirmed_slots_with_headers constants node_ctxt confirmation_info - in - let slots_to_save = - let open Dal in - List.fast_sort - (fun Slot.Header.{id = {index = a; _}; _} {id = {index = b; _}; _} -> - Slot_index.compare a b) - slots_to_save - in - let* pred = Node_context.get_predecessor node_ctxt head in - let* slots_history = slots_history_of_hash node_ctxt pred in - let* slots_cache = slots_history_cache_of_hash node_ctxt pred in - let*? slots_history, slots_cache = - Dal.Slots_history.add_confirmed_slot_headers - slots_history - slots_cache - slots_to_save - |> Environment.wrap_tzresult - in - (* The value of [slots_history] computed here is supposed to be equal to the - one computed stored for block [head_hash] on L1, we basically re-do the - computation here because we need to build/maintain the [slots_cache] - bounded cache in case we need it for refutation game. *) - (* TODO/DAL: https://gitlab.com/tezos/tezos/-/issues/3856 - Attempt to improve this process. *) - let* () = - Node_context.save_confirmed_slots_history - node_ctxt - head_hash - (Sc_rollup_proto_types.Dal.Slot_history.to_octez slots_history) - in - let* () = - Node_context.save_confirmed_slots_histories - node_ctxt - head_hash - (Sc_rollup_proto_types.Dal.Slot_history_cache.to_octez slots_cache) - in - return () -end - let process_head node_ctxt (Layer1.{hash = head_hash; level} as head) = let open Lwt_result_syntax in let* constants = Protocol_plugins.get_constants_of_level node_ctxt level in @@ -343,16 +182,8 @@ let process_head node_ctxt (Layer1.{hash = head_hash; level} as head) = match confirmation_info with | None -> return_unit | Some confirmation_info -> - let* () = - download_and_save_slots - ~current_block_hash:head_hash - constants - node_ctxt - confirmation_info - in - Confirmed_slots_history.update constants node_ctxt head confirmation_info - -let slots_history_of_hash = Confirmed_slots_history.slots_history_of_hash - -let slots_history_cache_of_hash = - Confirmed_slots_history.slots_history_cache_of_hash + download_and_save_slots + ~current_block_hash:head_hash + constants + node_ctxt + confirmation_info diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/dal_slots_tracker.mli b/src/proto_017_PtNairob/lib_sc_rollup_node/dal_slots_tracker.mli index c05672d93a0e..0979c9950f36 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/dal_slots_tracker.mli +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/dal_slots_tracker.mli @@ -39,17 +39,3 @@ [Store.Dal_confirmed_slots].} } *) val process_head : Node_context.rw -> Layer1.head -> unit tzresult Lwt.t - -(** [slots_history_of_hash node_ctxt block_hash] returns the DAL confirmed slots - history at the end of the given [block_hash] validation. *) -val slots_history_of_hash : - _ Node_context.t -> - Layer1.head -> - Protocol.Alpha_context.Dal.Slots_history.t tzresult Lwt.t - -(** [slots_history_cache_of_hash node_ctxt block_hash] returns the DAL confirmed - slots history cache at the end of the given [block_hash] validation. *) -val slots_history_cache_of_hash : - _ Node_context.t -> - Layer1.head -> - Protocol.Alpha_context.Dal.Slots_history.History_cache.t tzresult Lwt.t -- GitLab From a4ce863aebb74ba2aa5b34b2ccaa6ff17680dd99 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:21:15 +0100 Subject: [PATCH 09/11] Rollup node: remove unused functions from node context --- src/lib_smart_rollup_node/node_context.ml | 12 ------------ src/lib_smart_rollup_node/node_context.mli | 12 ------------ 2 files changed, 24 deletions(-) diff --git a/src/lib_smart_rollup_node/node_context.ml b/src/lib_smart_rollup_node/node_context.ml index 6dfe937ed5e2..e89d9fd546b3 100644 --- a/src/lib_smart_rollup_node/node_context.ml +++ b/src/lib_smart_rollup_node/node_context.ml @@ -910,18 +910,6 @@ let save_slot_status {store; _} current_block_hash slot_index status = ~secondary_key:slot_index status -let find_confirmed_slots_history {store; _} block = - Store.Dal_confirmed_slots_history.find store.irmin_store block - -let save_confirmed_slots_history {store; _} block hist = - Store.Dal_confirmed_slots_history.add store.irmin_store block hist - -let find_confirmed_slots_histories {store; _} block = - Store.Dal_confirmed_slots_histories.find store.irmin_store block - -let save_confirmed_slots_histories {store; _} block hist = - Store.Dal_confirmed_slots_histories.add store.irmin_store block hist - let get_gc_levels node_ctxt = let open Lwt_result_syntax in let+ gc_levels = Store.Gc_levels.read node_ctxt.store.gc_levels in diff --git a/src/lib_smart_rollup_node/node_context.mli b/src/lib_smart_rollup_node/node_context.mli index b60b9fb8a17a..1dc7dbe7c7cb 100644 --- a/src/lib_smart_rollup_node/node_context.mli +++ b/src/lib_smart_rollup_node/node_context.mli @@ -528,18 +528,6 @@ val save_slot_status : (* TODO: https://gitlab.com/tezos/tezos/-/issues/4636 Missing docstrings. *) -val find_confirmed_slots_history : - _ t -> Block_hash.t -> Dal.Slot_history.t option tzresult Lwt.t - -val save_confirmed_slots_history : - rw -> Block_hash.t -> Dal.Slot_history.t -> unit tzresult Lwt.t - -val find_confirmed_slots_histories : - _ t -> Block_hash.t -> Dal.Slot_history_cache.t option tzresult Lwt.t - -val save_confirmed_slots_histories : - rw -> Block_hash.t -> Dal.Slot_history_cache.t -> unit tzresult Lwt.t - (** [gc node_ctxt level] triggers garbage collection for the node in accordance with [node_ctxt.config.gc_parameters]. Upon completion, all data for L2 levels lower than [level] will be removed. *) -- GitLab From 1117702fa94787ce5681c61aadc909fff4246d2c Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:24:30 +0100 Subject: [PATCH 10/11] Rollup node: remove DAL related skip lists structures that are not used --- src/lib_smart_rollup_node/store_v0.ml | 42 ---------------------- src/lib_smart_rollup_node/store_v0.mli | 14 -------- src/lib_smart_rollup_node/store_v2.ml | 48 -------------------------- src/lib_smart_rollup_node/store_v2.mli | 14 -------- 4 files changed, 118 deletions(-) diff --git a/src/lib_smart_rollup_node/store_v0.ml b/src/lib_smart_rollup_node/store_v0.ml index 0eb7540279ba..a44a6a59cead 100644 --- a/src/lib_smart_rollup_node/store_v0.ml +++ b/src/lib_smart_rollup_node/store_v0.ml @@ -341,48 +341,6 @@ module Dal_slots_headers = the block where they have been published. *) -(** Confirmed DAL slots history. See documentation of - {!Dal_slot_repr.Slots_history} for more details. *) -module Dal_confirmed_slots_history = - Irmin_store.Make_append_only_map - (struct - let path = ["dal"; "confirmed_slots_history"] - end) - (struct - type key = Block_hash.t - - let to_path_representation = Block_hash.to_b58check - end) - (struct - type value = Octez_smart_rollup.Dal.Slot_history.t - - let name = "dal_slot_histories" - - let encoding = Octez_smart_rollup.Dal.Slot_history.V1.encoding - end) - -(** Confirmed DAL slots histories cache. See documentation of - {!Dal_slot_repr.Slots_history} for more details. *) -module Dal_confirmed_slots_histories = - (* TODO: https://gitlab.com/tezos/tezos/-/issues/4390 - Store single history points in map instead of whole history. *) - Irmin_store.Make_append_only_map - (struct - let path = ["dal"; "confirmed_slots_histories_cache"] - end) - (struct - type key = Block_hash.t - - let to_path_representation = Block_hash.to_b58check - end) - (struct - type value = Octez_smart_rollup.Dal.Slot_history_cache.t - - let name = "dal_slot_histories" - - let encoding = Octez_smart_rollup.Dal.Slot_history_cache.V1.encoding - end) - type 'a store = { l2_blocks : 'a L2_blocks.t; messages : 'a Messages.t; diff --git a/src/lib_smart_rollup_node/store_v0.mli b/src/lib_smart_rollup_node/store_v0.mli index 97c6848ee2ff..3a436f6ea0ab 100644 --- a/src/lib_smart_rollup_node/store_v0.mli +++ b/src/lib_smart_rollup_node/store_v0.mli @@ -106,20 +106,6 @@ module Dal_slots_headers : and type value := Dal.Slot_header.V1.t and type 'a store := 'a Irmin_store.t -module Dal_confirmed_slots_history : - Store_sigs.Append_only_map - with type key := Block_hash.t - and type value := Dal.Slot_history.V1.t - and type 'a store := 'a Irmin_store.t - -(** Confirmed DAL slots histories cache. See documentation of - {!Dal_slot_repr.Slots_history} for more details. *) -module Dal_confirmed_slots_histories : - Store_sigs.Append_only_map - with type key := Block_hash.t - and type value := Dal.Slot_history_cache.V1.t - and type 'a store := 'a Irmin_store.t - (** [Dal_slot_pages] is a [Store_utils.Nested_map] used to store the contents of dal slots fetched by the rollup node, as a list of pages. The values of this storage module have type `string list`. A value of the form diff --git a/src/lib_smart_rollup_node/store_v2.ml b/src/lib_smart_rollup_node/store_v2.ml index d1c5f725254f..570f413f19d0 100644 --- a/src/lib_smart_rollup_node/store_v2.ml +++ b/src/lib_smart_rollup_node/store_v2.ml @@ -187,54 +187,6 @@ module Dal_slots_headers = Octez_smart_rollup.Dal.Slot_header.versioned_encoding end) -(** Versioned Confirmed DAL slots history *) -module Dal_confirmed_slots_history = - Irmin_store.Make_append_only_map - (struct - let path = ["dal"; "confirmed_slots_history"] - end) - (struct - type key = Block_hash.t - - let to_path_representation = Block_hash.to_b58check - end) - (struct - type value = Octez_smart_rollup.Dal.Slot_history.t - - let name = "dal_slot_histories" - - let encoding = - Data_encoding.conv - Octez_smart_rollup.Dal.Slot_history.to_versioned - Octez_smart_rollup.Dal.Slot_history.of_versioned - Octez_smart_rollup.Dal.Slot_history.versioned_encoding - end) - -(** Versioned Confirmed DAL slots histories cache. *) -module Dal_confirmed_slots_histories = - (* TODO: https://gitlab.com/tezos/tezos/-/issues/4390 - Store single history points in map instead of whole history. *) - Irmin_store.Make_append_only_map - (struct - let path = ["dal"; "confirmed_slots_histories_cache"] - end) - (struct - type key = Block_hash.t - - let to_path_representation = Block_hash.to_b58check - end) - (struct - type value = Octez_smart_rollup.Dal.Slot_history_cache.t - - let name = "dal_slot_histories" - - let encoding = - Data_encoding.conv - Octez_smart_rollup.Dal.Slot_history_cache.to_versioned - Octez_smart_rollup.Dal.Slot_history_cache.of_versioned - Octez_smart_rollup.Dal.Slot_history_cache.versioned_encoding - end) - module Protocols = struct type level = First_known of int32 | Activation_level of int32 diff --git a/src/lib_smart_rollup_node/store_v2.mli b/src/lib_smart_rollup_node/store_v2.mli index e643f896402b..2baadd3c89a3 100644 --- a/src/lib_smart_rollup_node/store_v2.mli +++ b/src/lib_smart_rollup_node/store_v2.mli @@ -76,20 +76,6 @@ module Dal_slots_headers : and type value := Dal.Slot_header.t and type 'a store := 'a Irmin_store.t -module Dal_confirmed_slots_history : - Store_sigs.Append_only_map - with type key := Block_hash.t - and type value := Dal.Slot_history.t - and type 'a store := 'a Irmin_store.t - -(** Confirmed DAL slots histories cache. See documentation of - {!Dal_slot_repr.Slots_history} for more details. *) -module Dal_confirmed_slots_histories : - Store_sigs.Append_only_map - with type key := Block_hash.t - and type value := Dal.Slot_history_cache.t - and type 'a store := 'a Irmin_store.t - module Protocols : sig type level = First_known of int32 | Activation_level of int32 -- GitLab From 6826620dc1f943b5ea71a5ea55a0456101d63d21 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 11 Mar 2024 17:27:07 +0100 Subject: [PATCH 11/11] Rollup/Node: remove unused module Dal_slot_pages --- src/lib_smart_rollup_node/store_v0.ml | 34 ------------------- src/lib_smart_rollup_node/store_v0.mli | 13 ------- .../lib_sc_rollup_node/dal_pages_request.mli | 4 +++ 3 files changed, 4 insertions(+), 47 deletions(-) diff --git a/src/lib_smart_rollup_node/store_v0.ml b/src/lib_smart_rollup_node/store_v0.ml index a44a6a59cead..2ad68841f832 100644 --- a/src/lib_smart_rollup_node/store_v0.ml +++ b/src/lib_smart_rollup_node/store_v0.ml @@ -229,40 +229,6 @@ module Levels_to_hashes = end)) (Tezos_store_shared.Block_key) -(* Published slot headers per block hash, - stored as a list of bindings from `Dal_slot_index.t` - to `Dal.Slot.t`. The encoding function converts this - list into a `Dal.Slot_index.t`-indexed map. *) -module Dal_slot_pages = - Irmin_store.Make_nested_map - (struct - let path = ["dal"; "slot_pages"] - end) - (struct - type key = Block_hash.t - - let to_path_representation = Block_hash.to_b58check - end) - (struct - type key = - Octez_smart_rollup.Dal.Slot_index.t - * Octez_smart_rollup.Dal.Page_index.t - - let encoding = - Data_encoding.(tup2 Dal.Slot_index.encoding Dal.Page_index.encoding) - - let compare = Stdlib.compare - - let name = "slot_index" - end) - (struct - type value = bytes - - let encoding = Data_encoding.(bytes' Hex) - - let name = "slot_pages" - end) - (** stores slots whose data have been considered and pages stored to disk (if they are confirmed). *) module Dal_processed_slots = diff --git a/src/lib_smart_rollup_node/store_v0.mli b/src/lib_smart_rollup_node/store_v0.mli index 3a436f6ea0ab..98a2160b0f30 100644 --- a/src/lib_smart_rollup_node/store_v0.mli +++ b/src/lib_smart_rollup_node/store_v0.mli @@ -106,19 +106,6 @@ module Dal_slots_headers : and type value := Dal.Slot_header.V1.t and type 'a store := 'a Irmin_store.t -(** [Dal_slot_pages] is a [Store_utils.Nested_map] used to store the contents - of dal slots fetched by the rollup node, as a list of pages. The values of - this storage module have type `string list`. A value of the form - [page_contents] refers to a page of a slot that has been confirmed, and - whose contents are [page_contents]. -*) -module Dal_slot_pages : - Store_sigs.Nested_map - with type primary_key := Block_hash.t - and type secondary_key := Dal.Slot_index.t * Dal.Page_index.t - and type value := bytes - and type 'a store := 'a Irmin_store.t - (** [Dal_processed_slots] is a [Store_utils.Nested_map] used to store the processing status of dal slots content fetched by the rollup node. The values of this storage module have type `[`Confirmed | `Unconfirmed]`, depending on 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 e365e98fb5b8..17d384fed0c2 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,6 +26,10 @@ open Protocol open Alpha_context +(* TODO: https://gitlab.com/tezos/tezos/-/issues/7070 + + Rework the interface of dal_pages_request.mli (see the issue for details). *) + (** Access DAL slots and pages content. This module is a wrapper on top of {!Store.Dal_slot_pages} module to -- GitLab