From 1858ca67c1867b89ca8cdd7582515781789f91bc Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Fri, 16 Dec 2022 17:58:51 +0100 Subject: [PATCH 1/2] SCORU/Node: Store DAL information only when DAL is enabled in protocol --- src/proto_alpha/bin_sc_rollup_node/daemon.ml | 6 +++++- src/proto_alpha/bin_sc_rollup_node/node_context.ml | 3 +++ src/proto_alpha/bin_sc_rollup_node/node_context.mli | 3 +++ src/proto_alpha/bin_sc_rollup_node/refutation_game.ml | 8 ++++++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/bin_sc_rollup_node/daemon.ml b/src/proto_alpha/bin_sc_rollup_node/daemon.ml index 42fb42f03144..e6ea1aca6944 100644 --- a/src/proto_alpha/bin_sc_rollup_node/daemon.ml +++ b/src/proto_alpha/bin_sc_rollup_node/daemon.ml @@ -79,6 +79,7 @@ module Make (PVM : Pvm.S) = struct tzfail (Sc_rollup_node_errors.Lost_game (loser, reason, slashed_amount)) | Dal_publish_slot_header _, Dal_publish_slot_header_result {slot_header; _} -> + assert (Node_context.dal_enabled node_ctxt) ; let*! () = Store.Dal_slots_headers.add node_ctxt.store @@ -192,7 +193,10 @@ module Make (PVM : Pvm.S) = struct let open Lwt_result_syntax in let*! () = Daemon_event.head_processing hash level ~finalized:false in let* ctxt = Inbox.process_head node_ctxt head in - let* () = Dal_slots_tracker.process_head node_ctxt head in + let* () = + when_ (Node_context.dal_enabled node_ctxt) @@ fun () -> + Dal_slots_tracker.process_head node_ctxt head + in let*! () = State.set_block_level_and_hash node_ctxt.store head in let* () = process_l1_block_operations ~finalized:false node_ctxt head in (* Avoid storing and publishing commitments if the head is not final. *) diff --git a/src/proto_alpha/bin_sc_rollup_node/node_context.ml b/src/proto_alpha/bin_sc_rollup_node/node_context.ml index 8d97a3d27eba..3b977dd7c24d 100644 --- a/src/proto_alpha/bin_sc_rollup_node/node_context.ml +++ b/src/proto_alpha/bin_sc_rollup_node/node_context.ml @@ -113,6 +113,9 @@ let metadata node_ctxt = let origination_level = node_ctxt.genesis_info.Sc_rollup.Commitment.level in Sc_rollup.Metadata.{address; origination_level} +let dal_enabled node_ctxt = + node_ctxt.protocol_constants.parametric.dal.feature_enable + let readonly (node_ctxt : _ t) = { node_ctxt with diff --git a/src/proto_alpha/bin_sc_rollup_node/node_context.mli b/src/proto_alpha/bin_sc_rollup_node/node_context.mli index 13dfca4d3c1d..08cf5d4e09ed 100644 --- a/src/proto_alpha/bin_sc_rollup_node/node_context.mli +++ b/src/proto_alpha/bin_sc_rollup_node/node_context.mli @@ -112,6 +112,9 @@ val checkout_context : stored in [node_ctxt]. *) val metadata : _ t -> Sc_rollup.Metadata.t +(** Returns [true] if the DAL is enabled for the current protocol. *) +val dal_enabled : _ t -> bool + (** [readonly node_ctxt] returns a read only version of the node context [node_ctxt]. *) val readonly : _ t -> ro diff --git a/src/proto_alpha/bin_sc_rollup_node/refutation_game.ml b/src/proto_alpha/bin_sc_rollup_node/refutation_game.ml index 16a596ad89f9..39811449f422 100644 --- a/src/proto_alpha/bin_sc_rollup_node/refutation_game.ml +++ b/src/proto_alpha/bin_sc_rollup_node/refutation_game.ml @@ -179,10 +179,14 @@ module Make (Interpreter : Interpreter.S) : let snapshot_ctxt_index = Context.index snapshot_ctxt in let snapshot = Sc_rollup.Inbox.take_snapshot snapshot_inbox in let* dal_slots_history = - Dal_slots_tracker.slots_history_of_hash node_ctxt snapshot_head + if Node_context.dal_enabled node_ctxt then + Dal_slots_tracker.slots_history_of_hash node_ctxt snapshot_head + else return Dal.Slots_history.genesis in let* dal_slots_history_cache = - Dal_slots_tracker.slots_history_cache_of_hash node_ctxt snapshot_head + if Node_context.dal_enabled node_ctxt then + Dal_slots_tracker.slots_history_cache_of_hash node_ctxt snapshot_head + else return (Dal.Slots_history.History_cache.empty ~capacity:0L) in (* We fetch the value of protocol constants at block snapshot_hash where the game started. *) -- GitLab From 5af9e25c079c84e9d9917694dc134e474ba3a9d7 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Fri, 16 Dec 2022 17:58:51 +0100 Subject: [PATCH 2/2] SCORU/Node/016: Store DAL information only when DAL is enabled in protocol --- src/proto_016_PtMumbai/bin_sc_rollup_node/daemon.ml | 6 +++++- src/proto_016_PtMumbai/bin_sc_rollup_node/node_context.ml | 3 +++ .../bin_sc_rollup_node/node_context.mli | 3 +++ .../bin_sc_rollup_node/refutation_game.ml | 8 ++++++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/proto_016_PtMumbai/bin_sc_rollup_node/daemon.ml b/src/proto_016_PtMumbai/bin_sc_rollup_node/daemon.ml index 4ed068c1ed3c..66e6d02f7432 100644 --- a/src/proto_016_PtMumbai/bin_sc_rollup_node/daemon.ml +++ b/src/proto_016_PtMumbai/bin_sc_rollup_node/daemon.ml @@ -78,6 +78,7 @@ module Make (PVM : Pvm.S) = struct in tzfail (Sc_rollup_node_errors.Lost_game (loser, reason, slashed_amount)) | Dal_publish_slot_header slot_header, Dal_publish_slot_header_result _ -> + assert (Node_context.dal_enabled node_ctxt) ; let {Dal.Slot.Header.header = {id = {index; _}; _}; _} = slot_header in let*! () = Store.Dal_slots_headers.add @@ -192,7 +193,10 @@ module Make (PVM : Pvm.S) = struct let open Lwt_result_syntax in let*! () = Daemon_event.head_processing hash level ~finalized:false in let* ctxt = Inbox.process_head node_ctxt head in - let* () = Dal_slots_tracker.process_head node_ctxt head in + let* () = + when_ (Node_context.dal_enabled node_ctxt) @@ fun () -> + Dal_slots_tracker.process_head node_ctxt head + in let*! () = State.set_block_level_and_hash node_ctxt.store head in let* () = process_l1_block_operations ~finalized:false node_ctxt head in (* Avoid storing and publishing commitments if the head is not final. *) diff --git a/src/proto_016_PtMumbai/bin_sc_rollup_node/node_context.ml b/src/proto_016_PtMumbai/bin_sc_rollup_node/node_context.ml index 8d97a3d27eba..3b977dd7c24d 100644 --- a/src/proto_016_PtMumbai/bin_sc_rollup_node/node_context.ml +++ b/src/proto_016_PtMumbai/bin_sc_rollup_node/node_context.ml @@ -113,6 +113,9 @@ let metadata node_ctxt = let origination_level = node_ctxt.genesis_info.Sc_rollup.Commitment.level in Sc_rollup.Metadata.{address; origination_level} +let dal_enabled node_ctxt = + node_ctxt.protocol_constants.parametric.dal.feature_enable + let readonly (node_ctxt : _ t) = { node_ctxt with diff --git a/src/proto_016_PtMumbai/bin_sc_rollup_node/node_context.mli b/src/proto_016_PtMumbai/bin_sc_rollup_node/node_context.mli index 13dfca4d3c1d..08cf5d4e09ed 100644 --- a/src/proto_016_PtMumbai/bin_sc_rollup_node/node_context.mli +++ b/src/proto_016_PtMumbai/bin_sc_rollup_node/node_context.mli @@ -112,6 +112,9 @@ val checkout_context : stored in [node_ctxt]. *) val metadata : _ t -> Sc_rollup.Metadata.t +(** Returns [true] if the DAL is enabled for the current protocol. *) +val dal_enabled : _ t -> bool + (** [readonly node_ctxt] returns a read only version of the node context [node_ctxt]. *) val readonly : _ t -> ro diff --git a/src/proto_016_PtMumbai/bin_sc_rollup_node/refutation_game.ml b/src/proto_016_PtMumbai/bin_sc_rollup_node/refutation_game.ml index 8e1e87dfd3a9..b3288fe54428 100644 --- a/src/proto_016_PtMumbai/bin_sc_rollup_node/refutation_game.ml +++ b/src/proto_016_PtMumbai/bin_sc_rollup_node/refutation_game.ml @@ -179,10 +179,14 @@ module Make (Interpreter : Interpreter.S) : let snapshot_ctxt_index = Context.index snapshot_ctxt in let snapshot = Sc_rollup.Inbox.take_snapshot snapshot_inbox in let* dal_slots_history = - Dal_slots_tracker.slots_history_of_hash node_ctxt snapshot_head + if Node_context.dal_enabled node_ctxt then + Dal_slots_tracker.slots_history_of_hash node_ctxt snapshot_head + else return Dal.Slots_history.genesis in let* dal_slots_history_cache = - Dal_slots_tracker.slots_history_cache_of_hash node_ctxt snapshot_head + if Node_context.dal_enabled node_ctxt then + Dal_slots_tracker.slots_history_cache_of_hash node_ctxt snapshot_head + else return (Dal.Slots_history.History_cache.empty ~capacity:0L) in (* We fetch the value of protocol constants at block snapshot_hash where the game started. *) -- GitLab