From 4fc321d602f367a42aba2acb350afb3c301ded7b Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Fri, 25 Oct 2024 17:20:10 +0200 Subject: [PATCH 1/2] Proto/RPC: add an RPC to fetch activation level of current protocol This information is needed when checking produced proofs in smart rollups (see next commit) --- src/proto_alpha/lib_plugin/RPC.ml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index 9f62c42cf03c..7917238a2667 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -2383,6 +2383,31 @@ module Big_map = struct unparsing_mode end +module Protocol = struct + module S = struct + let path : RPC_context.t RPC_path.context = + RPC_path.(open_root / "context" / "protocol") + + let first_level = + let output = Raw_level.encoding in + RPC_service.get_service + ~description: + "Returns the level at which the current protocol was activated." + ~query:RPC_query.empty + ~output + RPC_path.(path / "first_level") + end + + let register_first_level () = + Registration.register0 ~chunked:false S.first_level (fun context () () -> + Alpha_context.First_level_of_protocol.get context) + + let register () = register_first_level () + + let first_level ctxt block = + RPC_context.make_call0 S.first_level ctxt block () () +end + module Sc_rollup = struct open Data_encoding @@ -4066,6 +4091,7 @@ let register () = Baking_rights.register () ; Attestation_rights.register () ; Validators.register () ; + Protocol.register () ; Sc_rollup.register () ; Dal.register () ; Registration.register0 ~chunked:false S.current_level (fun ctxt q () -> -- GitLab From 291b087bae145efd1a4ee04c3e3033e175d101f0 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Sun, 27 Oct 2024 19:25:31 +0100 Subject: [PATCH 2/2] Rollups/DAL: use the right protocol_activation_level in refutation games simulation Fixes https://gitlab.com/tezos/tezos/-/issues/7579 --- .../lib_sc_rollup_node/refutation_game_helpers.ml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 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 3ed84c30fea9..ab875943730a 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 @@ -291,14 +291,15 @@ let generate_proof (node_ctxt : _ Node_context.t) |> Environment.wrap_tzresult in let unserialized_proof = {proof with pvm_step} in + let Node_context.{cctxt; _} = node_ctxt in + let* protocol_activation_level = + Plugin.RPC.Protocol.first_level + (new Protocol_client_context.wrap_full cctxt) + (cctxt#chain, `Head 0) + in let*! result = - (* ADAL/FIXME: https://gitlab.com/tezos/tezos/-/issues/7579 - - Provide the right [protocol_activation_level] here once the RPC that - reads it from [Storage.Tenderbake.First_level_of_protocol] is - implemented. *) Sc_rollup.Proof.valid - ~protocol_activation_level:Raw_level.root + ~protocol_activation_level ~metadata snapshot (Raw_level.of_int32_exn game.inbox_level) -- GitLab