From 09ca517c7c7837366e8d20738aeb752984271d11 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 2 May 2023 09:34:48 +0200 Subject: [PATCH 1/2] SCORU/Node: rely on cementation metadata for commitment The cementation operation cements the next possible commitment irrespective of the provided commitment hash for protocols >= Nairobi following https://gitlab.com/tezos/tezos/-/merge_requests/7316. We also ignore it in the rollup node. --- .../lib_sc_rollup_node/daemon.ml | 14 ++++++++------ src/proto_alpha/lib_sc_rollup_node/daemon.ml | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon.ml b/src/proto_017_PtNairob/lib_sc_rollup_node/daemon.ml index e0bdbdac1fbc..5dfc35cbff02 100644 --- a/src/proto_017_PtNairob/lib_sc_rollup_node/daemon.ml +++ b/src/proto_017_PtNairob/lib_sc_rollup_node/daemon.ml @@ -155,8 +155,8 @@ module Make (PVM : Pvm.S) = struct rollup their_commitment their_commitment_hash - | Sc_rollup_cement {commitment; _}, Sc_rollup_cement_result {inbox_level; _} - -> + | ( Sc_rollup_cement _, + Sc_rollup_cement_result {inbox_level; commitment_hash; _} ) -> (* Cemented commitment ---------------------------------------------- *) let* inbox_block = Node_context.get_l2_block_by_level @@ -169,20 +169,22 @@ module Make (PVM : Pvm.S) = struct (Option.equal Sc_rollup.Commitment.Hash.( = ) inbox_block.header.commitment_hash - (Some commitment)) + (Some commitment_hash)) (Sc_rollup_node_errors.Disagree_with_cemented { inbox_level; ours = inbox_block.header.commitment_hash; - on_l1 = commitment; + on_l1 = commitment_hash; }) in let lcc = Reference.get node_ctxt.lcc in let*! () = if Raw_level.(inbox_level > lcc.level) then ( - Reference.set node_ctxt.lcc {commitment; level = inbox_level} ; + Reference.set + node_ctxt.lcc + {commitment = commitment_hash; level = inbox_level} ; Commitment_event.last_cemented_commitment_updated - commitment + commitment_hash inbox_level) else Lwt.return_unit in diff --git a/src/proto_alpha/lib_sc_rollup_node/daemon.ml b/src/proto_alpha/lib_sc_rollup_node/daemon.ml index 4fa33b9e0b4f..d795b32847e7 100644 --- a/src/proto_alpha/lib_sc_rollup_node/daemon.ml +++ b/src/proto_alpha/lib_sc_rollup_node/daemon.ml @@ -155,8 +155,8 @@ module Make (PVM : Pvm.S) = struct rollup their_commitment their_commitment_hash - | Sc_rollup_cement {commitment; _}, Sc_rollup_cement_result {inbox_level; _} - -> + | ( Sc_rollup_cement _, + Sc_rollup_cement_result {inbox_level; commitment_hash; _} ) -> (* Cemented commitment ---------------------------------------------- *) let* inbox_block = Node_context.get_l2_block_by_level @@ -169,20 +169,22 @@ module Make (PVM : Pvm.S) = struct (Option.equal Sc_rollup.Commitment.Hash.( = ) inbox_block.header.commitment_hash - (Some commitment)) + (Some commitment_hash)) (Sc_rollup_node_errors.Disagree_with_cemented { inbox_level; ours = inbox_block.header.commitment_hash; - on_l1 = commitment; + on_l1 = commitment_hash; }) in let lcc = Reference.get node_ctxt.lcc in let*! () = if Raw_level.(inbox_level > lcc.level) then ( - Reference.set node_ctxt.lcc {commitment; level = inbox_level} ; + Reference.set + node_ctxt.lcc + {commitment = commitment_hash; level = inbox_level} ; Commitment_event.last_cemented_commitment_updated - commitment + commitment_hash inbox_level) else Lwt.return_unit in -- GitLab From 1fbd43cec7e432b807a636f2aaff54e0992e12be Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 2 May 2023 17:44:40 +0200 Subject: [PATCH 2/2] Test: ensure rollup node ignores cementation commitment hash --- tezt/tests/sc_rollup.ml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index edbb7c45d1d9..33fa101e9048 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -2763,6 +2763,42 @@ let test_consecutive_commitments _protocol _rollup_node _rollup_client sc_rollup in unit +let test_cement_ignore_commitment ~kind = + let commitment_period = 3 in + let challenge_window = 3 in + test_commitment_scenario + ~commitment_period + ~challenge_window + ~kind + ~variant:"cement_ignore_commitment" + @@ fun protocol _sc_rollup_node _sc_rollup_client sc_rollup node client -> + let sc_rollup_node = + Sc_rollup_node.create + ~protocol + Custom + node + ~base_dir:(Client.base_dir client) + ~operators:[("publish", Constant.bootstrap1.alias)] + (* Don't cement commitments *) + in + let* () = + Sc_rollup_node.run ~event_level:`Debug sc_rollup_node sc_rollup [] + in + let* _level = Sc_rollup_node.wait_sync ~timeout:3. sc_rollup_node in + let* _level = bake_until_lpc_updated client sc_rollup_node in + let* _level = Sc_rollup_node.wait_sync ~timeout:10. sc_rollup_node in + let* () = bake_levels challenge_window client in + let* _level = Sc_rollup_node.wait_sync ~timeout:10. sc_rollup_node in + let* () = + let hash = + (* zero commitment hash *) + "src12UJzB8mg7yU6nWPzicH7ofJbFjyJEbHvwtZdfRXi8DQHNp1LY8" + in + cement_commitment client ~sc_rollup ~hash + in + let* _level = Sc_rollup_node.wait_sync ~timeout:10. sc_rollup_node in + unit + (* Refutation game scenarios ------------------------- *) @@ -5168,6 +5204,7 @@ let register ~kind ~protocols = test_consecutive_commitments protocols ~kind ; + test_cement_ignore_commitment ~kind [Nairobi; Alpha] ; (* TODO: https://gitlab.com/tezos/tezos/-/issues/4373 Uncomment this test as soon as the issue done. test_reinject_failed_commitment protocols ~kind ; *) -- GitLab