From 09586de160b86291a756218ee5dbbcb91c73913b Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Wed, 1 Mar 2023 14:25:41 +0100 Subject: [PATCH] Proto: Inject an internal message when migrating to proto_alpha This patch introduces a new kind of internal message, intended to be injected by the economic protocol when a protocol migration happens. The purpose is twofold: 1. allow kernels to know a protocol upgrade happened, and 2. allow the PVM to upgrade itself to new functionalities when it happens. This patch only deals with purpose 1., that is the injection of the message, already allowing kernels to interpret it as they see fit. Co-authored-by: Valentin Chaboche --- src/bin_wasm_debugger/messages.ml | 2 + src/proto_alpha/lib_protocol/alpha_context.ml | 21 +++++++++- .../lib_protocol/alpha_context.mli | 4 ++ src/proto_alpha/lib_protocol/init_storage.ml | 6 ++- src/proto_alpha/lib_protocol/raw_context.ml | 3 ++ src/proto_alpha/lib_protocol/raw_context.mli | 5 +++ .../lib_protocol/sc_rollup_arith.ml | 3 ++ .../lib_protocol/sc_rollup_costs.ml | 1 + .../sc_rollup_inbox_message_repr.ml | 7 ++++ .../sc_rollup_inbox_message_repr.mli | 1 + .../lib_protocol/sc_rollup_inbox_repr.ml | 42 +++++++++++++++---- .../lib_protocol/sc_rollup_inbox_repr.mli | 18 ++++++-- .../lib_protocol/sc_rollup_inbox_storage.ml | 37 +++++++++++++++- .../lib_protocol/sc_rollup_inbox_storage.mli | 3 ++ .../test/helpers/sc_rollup_helpers.ml | 36 +++++++++++++++- .../integration/operations/test_sc_rollup.ml | 29 +++++++++++-- .../test/unit/test_sc_rollup_inbox.ml | 1 + .../test/unit/test_sc_rollup_inbox_legacy.ml | 2 + src/proto_alpha/lib_sc_rollup_node/inbox.ml | 8 ++++ .../lib_sc_rollup_node/interpreter.ml | 3 ++ 20 files changed, 213 insertions(+), 19 deletions(-) diff --git a/src/bin_wasm_debugger/messages.ml b/src/bin_wasm_debugger/messages.ml index a326e4d8b347..9909acb1bd87 100644 --- a/src/bin_wasm_debugger/messages.ml +++ b/src/bin_wasm_debugger/messages.ml @@ -128,6 +128,8 @@ let pp_input ppf bytes = Data_encoding.Json.pp ppf json | Internal Start_of_level -> Format.fprintf ppf "Start_of_level" | Internal End_of_level -> Format.fprintf ppf "End_of_level" + | Internal (Protocol_migration proto) -> + Format.fprintf ppf "Protocol_migration %s" proto | Internal (Info_per_level {predecessor_timestamp; predecessor}) -> Format.fprintf ppf diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 50f528dfd383..99ee157fa42a 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -61,7 +61,14 @@ module Sc_rollup = struct include Sc_rollup_PVM_sig module ArithPVM = Sc_rollup_arith module Wasm_2_0_0PVM = Sc_rollup_wasm.V2_0_0 - module Inbox_message = Sc_rollup_inbox_message_repr + + module Inbox_message = struct + include Sc_rollup_inbox_message_repr + + let protocol_migration_internal_message = + Raw_context.protocol_migration_internal_message + end + module Inbox_merkelized_payload_hashes = Sc_rollup_inbox_merkelized_payload_hashes_repr @@ -74,6 +81,18 @@ module Sc_rollup = struct include Sc_rollup_inbox_repr include Sc_rollup_inbox_storage + let genesis = + genesis + ~protocol_migration_message: + Inbox_message.protocol_migration_internal_message + + let add_all_messages ~first_block = + add_all_messages + ~protocol_migration_message: + (if first_block then + Some Inbox_message.protocol_migration_internal_message + else None) + module Internal_for_tests = struct include Sc_rollup_inbox_repr.Internal_for_tests end diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 94c182405d1a..28d625f8e15a 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3264,6 +3264,9 @@ module Sc_rollup : sig predecessor_timestamp : Time.t; predecessor : Block_hash.t; } + | Protocol_migration of string + + val protocol_migration_internal_message : internal_inbox_message type t = Internal of internal_inbox_message | External of string @@ -3425,6 +3428,7 @@ module Sc_rollup : sig val serialized_proof_encoding : serialized_proof Data_encoding.t val add_all_messages : + first_block:bool -> predecessor_timestamp:Time.t -> predecessor:Block_hash.t -> History.t -> diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index c2f2f61a0ae4..2e740d10f93e 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -167,7 +167,11 @@ let prepare_first_block _chain_id ctxt ~typecheck ~level ~timestamp ~predecessor if that is done, do not set Storage.Tenderbake.First_level_of_protocol. *) Raw_level_repr.of_int32 level >>?= fun level -> Storage.Tenderbake.First_level_of_protocol.update ctxt level - >>=? fun ctxt -> return (ctxt, [])) + >>=? fun ctxt -> + (* This needs to be kept in the migration code for every + protocol, except Genesis. *) + Sc_rollup_inbox_storage.add_protocol_migration ctxt >>= fun ctxt -> + return (ctxt, [])) >>=? fun (ctxt, balance_updates) -> List.fold_right_es patch_script Legacy_script_patches.addresses_to_patch ctxt >>=? fun ctxt -> diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index dce767337123..374d81801ff0 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -667,6 +667,9 @@ let version_value = "alpha_current" let version = "v1" +let protocol_migration_internal_message = + Sc_rollup_inbox_message_repr.Protocol_migration version_value + let cycle_eras_key = [version; "cycle_eras"] let constants_key = [version; "constants"] diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index 3c0574913311..e8056a82633d 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -73,6 +73,11 @@ type t type root = t +(** The internal message to be injected into the smart rollups’ shared + inbox when validating the very first block of this protocol. *) +val protocol_migration_internal_message : + Sc_rollup_inbox_message_repr.internal_inbox_message + (** Retrieves the state of the database and gives its abstract view. It also returns wether this is the first block validated with this version of the protocol. *) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index a5e092037309..ecee5fbd526e 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -1135,6 +1135,9 @@ module Make (Context : P) : return (Some payload) | _ -> return None) | _ -> return None) + | Ok (Internal (Protocol_migration _)) -> + let* () = incr_internal_message_counter in + return None | Ok (Internal Start_of_level) -> let* () = incr_internal_message_counter in return None diff --git a/src/proto_alpha/lib_protocol/sc_rollup_costs.ml b/src/proto_alpha/lib_protocol/sc_rollup_costs.ml index b27173883458..32d8bc9a8253 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_costs.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_costs.ml @@ -81,6 +81,7 @@ let cost_serialize_internal_inbox_message + Constants.cost_decoding_key_hash_optimized) | Start_of_level -> Saturation_repr.zero | End_of_level -> Saturation_repr.zero + | Protocol_migration _ -> Saturation_repr.zero | Info_per_level _ -> Saturation_repr.zero (* Derived from benchmark in diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.ml index 4a92f1951def..5475e6805c21 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.ml @@ -67,6 +67,7 @@ type internal_inbox_message = predecessor_timestamp : Time.t; predecessor : Block_hash.t; } + | Protocol_migration of string let internal_inbox_message_encoding = let open Data_encoding in @@ -113,6 +114,12 @@ let internal_inbox_message_encoding = | _ -> None) (fun ((), predecessor_timestamp, predecessor) -> Info_per_level {predecessor_timestamp; predecessor}); + case + (Tag 4) + ~title:"Protocol_migration" + (obj2 (kind "protocol_migration") (req "protocol" (string Hex))) + (function Protocol_migration proto -> Some ((), proto) | _ -> None) + (fun ((), proto) -> Protocol_migration proto); ] type t = Internal of internal_inbox_message | External of string diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.mli index f4865b885d4d..edf1d07f2e6d 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_message_repr.mli @@ -68,6 +68,7 @@ type internal_inbox_message = predecessor : Block_hash.t; (** Predecessor of the block this message is pushed. *) } + | Protocol_migration of string (** A type representing messages from Layer 1 to Layer 2. Internal ones are originated from Layer 1 smart-contracts and external ones are messages from diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml index f6e4a6a4f9bd..3bceac9e32b5 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml @@ -765,18 +765,33 @@ let finalize_inbox_level_no_history inbox witness = in return inbox -let add_all_messages ~predecessor_timestamp ~predecessor history inbox messages - = +let add_all_messages ~protocol_migration_message ~predecessor_timestamp + ~predecessor history inbox messages = let open Result_syntax in let* payloads = List.map_e Sc_rollup_inbox_message_repr.serialize messages in + let is_first_block = Option.is_some protocol_migration_message in let payloads_history = (* Must remember every [payloads] and internal messages pushed by the protocol: SOL/Info_per_level/EOL. *) - let capacity = List.length payloads + 3 |> Int64.of_int in + let capacity = + (List.length payloads + 3 + if is_first_block then 1 else 0) + |> Int64.of_int + in Sc_rollup_inbox_merkelized_payload_hashes_repr.History.empty ~capacity in - (* Add [SOL] and [Info_per_level]. *) + (* Add [SOL], possibly [Protocol_migration], and [Info_per_level]. *) let* payloads_history, witness = init_witness payloads_history in + let* payloads_history, witness = + match protocol_migration_message with + | Some protocol_migration_message -> + let* message = + Sc_rollup_inbox_message_repr.serialize + (Internal protocol_migration_message) + in + add_message message payloads_history witness + | None -> return (payloads_history, witness) + in + let* payloads_history, witness = add_info_per_level ~predecessor_timestamp @@ -799,22 +814,35 @@ let add_all_messages ~predecessor_timestamp ~predecessor history inbox messages let messages = let open Sc_rollup_inbox_message_repr in let sol = Internal Start_of_level in + let migration = + Option.fold + ~none:[] + ~some:(fun x -> [Internal x]) + protocol_migration_message + in let info_per_level = Internal (Info_per_level {predecessor_timestamp; predecessor}) in let eol = Internal End_of_level in - [sol; info_per_level] @ messages @ [eol] + [sol] @ migration @ [info_per_level] @ messages @ [eol] in return (payloads_history, history, inbox, witness, messages) -let genesis ~predecessor_timestamp ~predecessor level = +let genesis ~protocol_migration_message ~predecessor_timestamp ~predecessor + level = let open Result_syntax in let no_payloads_history = Sc_rollup_inbox_merkelized_payload_hashes_repr.History.no_history in - (* 1. Add [SOL] and [Info_per_level]. *) + (* 1. Add [SOL], [Protocol_migration], and [Info_per_level]. *) let witness = init_witness_no_history in + let* protocol_migration = + Sc_rollup_inbox_message_repr.serialize (Internal protocol_migration_message) + in + let* _payloads_history, witness = + add_protocol_internal_message protocol_migration no_payloads_history witness + in let* witness = add_info_per_level_no_history ~predecessor_timestamp ~predecessor witness in diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli index 789a10b7988b..412d5c593709 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli @@ -234,8 +234,13 @@ val serialized_proof_encoding : serialized_proof Data_encoding.t Adds the messages pushed by the protocol and returns a list of messages including them. The caller will need to execute this list of messages, otherwise, it might miss some internal inputs. - *) + + The expected value of [protocol_migration_message] is either [Some + Raw_context.protocol_migration_internal_message] (during the first + block of this protocol) or [None]. *) val add_all_messages : + protocol_migration_message: + Sc_rollup_inbox_message_repr.internal_inbox_message option -> predecessor_timestamp:Time.t -> predecessor:Block_hash.t -> History.t -> @@ -333,10 +338,15 @@ val add_info_per_level_no_history : val finalize_inbox_level_no_history : t -> Sc_rollup_inbox_merkelized_payload_hashes_repr.t -> t tzresult -(** [genesis ~timestamp ~predecessor level] initializes the inbox at some - given [level] with: [SOL], [Info_per_level {timestamp; predecessor}] and - [EOL] inside. *) +(** [genesis ~protocol_migration_message ~timestamp ~predecessor + level] initializes the inbox at some given [level] with: [SOL], + [protocol_migration_message], [Info_per_level {timestamp; + predecessor}] and [EOL] inside. + + The expected value of [protocol_migration_message] is + [Raw_context.protocol_migration_internal_message]. *) val genesis : + protocol_migration_message:Sc_rollup_inbox_message_repr.internal_inbox_message -> predecessor_timestamp:Time.t -> predecessor:Block_hash.t -> Raw_level_repr.t -> diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.ml index 3d9ddd974672..d41e28ad6c9d 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.ml @@ -140,6 +140,36 @@ let finalize_inbox_level ctxt = err) ; return ctxt +let add_protocol_migration ctxt = + let open Lwt_syntax in + let res = + let open Result_syntax in + let witness = Raw_context.Sc_rollup_in_memory_inbox.current_messages ctxt in + let* protocol_migration = + Sc_rollup_inbox_message_repr.serialize + (Internal Raw_context.protocol_migration_internal_message) + in + let+ witness = + Sc_rollup_inbox_repr.add_messages_no_history [protocol_migration] witness + in + Raw_context.Sc_rollup_in_memory_inbox.set_current_messages ctxt witness + in + match res with + | Ok ctxt -> return ctxt + | Error err -> + (* As a protection, we backtrack the [ctxt] if adding the info per level + failed. This way, we cannot make [begin_application], + [begin_partial_application] and [begin_full_construction] fail. *) + Logging.( + log + Fatal + "Adding [Protocol_migration] failed because of %a, the context is \ + backtracked. Smart rollups inbox might be inconsistent, this \ + behavior is undefined and its consequence is unexplored." + pp_trace + err) ; + return ctxt + let add_info_per_level ~predecessor ctxt = let open Lwt_syntax in let* res = @@ -180,7 +210,12 @@ let init_inbox ~predecessor ctxt = let ({level; _} : Level_repr.t) = Raw_context.current_level ctxt in let predecessor_timestamp = Raw_context.predecessor_timestamp ctxt in let*? inbox = - Sc_rollup_inbox_repr.genesis ~predecessor_timestamp ~predecessor level + Sc_rollup_inbox_repr.genesis + ~protocol_migration_message: + Raw_context.protocol_migration_internal_message + ~predecessor_timestamp + ~predecessor + level in let* ctxt = Store.Inbox.init ctxt inbox in return ctxt diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.mli b/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.mli index b1a67842b7e1..c557c100eb7b 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.mli @@ -52,6 +52,9 @@ val add_deposit : val init_inbox : predecessor:Block_hash.t -> Raw_context.t -> Raw_context.t Lwt.t +(** Adds the [Protocol_migration] in the in-memory inbox level witness. *) +val add_protocol_migration : Raw_context.t -> Raw_context.t Lwt.t + (** Adds the [Info_per_level] in the in-memory inbox level witness. *) val add_info_per_level : predecessor:Block_hash.t -> Raw_context.t -> Raw_context.t Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml index 3f7a802b304f..7a74aea5cd70 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml @@ -259,11 +259,22 @@ let make_eol ~inbox_level ~message_counter = let payload = make_internal_inbox_message End_of_level in make_input ~inbox_level ~message_counter payload -let make_info_per_level ~inbox_level ~predecessor_timestamp ~predecessor = +let make_info_per_level ~during_migration ~inbox_level ~predecessor_timestamp + ~predecessor = let payload = make_internal_inbox_message (Info_per_level {predecessor_timestamp; predecessor}) in + make_input + ~inbox_level + ~message_counter:(if during_migration then Z.of_int 2 else Z.one) + payload + +let make_protocol_migration ~inbox_level = + let payload = + make_internal_inbox_message + Sc_rollup.Inbox_message.protocol_migration_internal_message + in make_input ~inbox_level ~message_counter:Z.one payload (** Message is the combination of a [message] and its associated [input]. @@ -348,7 +359,11 @@ let make_inputs predecessor_timestamp predecessor messages inbox_level = let sol = make_sol ~inbox_level in (* Info_per_level is at index 1. *) let info_per_level = - make_info_per_level ~inbox_level ~predecessor_timestamp ~predecessor + make_info_per_level + ~during_migration:false + ~inbox_level + ~predecessor_timestamp + ~predecessor in (* External inputs start at index 2. *) let external_inputs = @@ -606,6 +621,8 @@ let dumb_init level = let dumb_init_repr level = WithExceptions.Result.get_ok ~loc:__LOC__ @@ Sc_rollup_inbox_repr.genesis + ~protocol_migration_message: + Raw_context.protocol_migration_internal_message ~predecessor_timestamp:Time.Protocol.epoch ~predecessor:Block_hash.zero level @@ -658,6 +675,20 @@ module Node_inbox = struct in let history = Sc_rollup.Inbox.History.empty ~capacity:10000L in let payloads_histories = Payloads_histories.empty in + let* payloads_history, history, _inbox, _payloads, _messages = + Environment.wrap_tzresult + @@ Sc_rollup.Inbox.add_all_messages + ~first_block:true + ~predecessor_timestamp:genesis_predecessor_timestamp + ~predecessor:genesis_predecessor + history + inbox + [] + in + let witness_hash = Sc_rollup.Inbox.current_witness inbox in + let payloads_histories = + Payloads_histories.add witness_hash payloads_history payloads_histories + in return {inbox; history; payloads_histories} let fill_inbox node_inbox payloads_per_levels = @@ -682,6 +713,7 @@ module Node_inbox = struct let* payloads_history, history, inbox, witness, _messages = Environment.wrap_tzresult @@ Sc_rollup.Inbox.add_all_messages + ~first_block:false ~predecessor_timestamp ~predecessor history diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml index d29b254dc044..9506db9435c3 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml @@ -2661,10 +2661,23 @@ let test_automatically_added_internal_messages () = (Some sol) in - let assert_ipl ~snapshot ~full_history_inbox ~level_info ~inbox_level = + let assert_protocol_migration ~snapshot ~full_history_inbox ~inbox_level = + let protocol_migration = + Sc_rollup_helpers.make_protocol_migration ~inbox_level + in + assert_input_included + ~snapshot + ~full_history_inbox + (inbox_level, Z.one) + (Some protocol_migration) + in + + let assert_ipl ~during_migration ~snapshot ~full_history_inbox ~level_info + ~inbox_level = let predecessor_timestamp, predecessor = level_info in let info_per_level = Sc_rollup_helpers.make_info_per_level + ~during_migration ~inbox_level ~predecessor_timestamp ~predecessor @@ -2672,7 +2685,7 @@ let test_automatically_added_internal_messages () = assert_input_included ~snapshot ~full_history_inbox - (inbox_level, Z.one) + (inbox_level, if during_migration then Z.of_int 2 else Z.one) (Some info_per_level) in @@ -2732,8 +2745,16 @@ let test_automatically_added_internal_messages () = let* () = assert_sol ~__LOC__ ~snapshot ~full_history_inbox ~inbox_level:level_zero in + let* () = + assert_protocol_migration + ~__LOC__ + ~snapshot + ~full_history_inbox + ~inbox_level:level_zero + in let* () = assert_ipl + ~during_migration:true ~__LOC__ ~snapshot ~full_history_inbox @@ -2746,7 +2767,7 @@ let test_automatically_added_internal_messages () = ~snapshot ~full_history_inbox ~inbox_level:level_zero - ~message_counter:(Z.of_int 2) + ~message_counter:(Z.of_int 3) in (* Assertions about level 1. *) @@ -2756,6 +2777,7 @@ let test_automatically_added_internal_messages () = let* () = assert_ipl ~__LOC__ + ~during_migration:false ~snapshot ~full_history_inbox ~inbox_level:level_one @@ -2777,6 +2799,7 @@ let test_automatically_added_internal_messages () = let* () = assert_ipl ~__LOC__ + ~during_migration:false ~snapshot ~full_history_inbox ~inbox_level:level_two diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_inbox.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_inbox.ml index 98ba277b0fd4..cacea812d52f 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_inbox.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_inbox.ml @@ -793,6 +793,7 @@ let test_messages_are_correctly_added_in_history let*? payloads_history, _history, _inbox, witness, messages = Environment.wrap_tzresult @@ Inbox.add_all_messages + ~first_block:false ~predecessor_timestamp ~predecessor (Inbox.History.empty ~capacity:0L) diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_inbox_legacy.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_inbox_legacy.ml index db2a373ff777..806254e26352 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_inbox_legacy.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_inbox_legacy.ml @@ -78,6 +78,7 @@ let populate_inboxes level history inbox inboxes list_of_messages = let* payloads_history, history, inbox, witness, _messages = Environment.wrap_tzresult @@ add_all_messages + ~protocol_migration_message:None ~predecessor_timestamp:Time.Protocol.epoch ~predecessor:Block_hash.zero history @@ -149,6 +150,7 @@ let setup_node_inbox_with_messages list_of_messages f = let*? payloads_history, history, inbox, witness, _messages = Environment.wrap_tzresult @@ add_all_messages + ~protocol_migration_message:None ~predecessor_timestamp:Time.Protocol.epoch ~predecessor:Block_hash.zero history diff --git a/src/proto_alpha/lib_sc_rollup_node/inbox.ml b/src/proto_alpha/lib_sc_rollup_node/inbox.ml index fc92ac73074d..9eb3213911b3 100644 --- a/src/proto_alpha/lib_sc_rollup_node/inbox.ml +++ b/src/proto_alpha/lib_sc_rollup_node/inbox.ml @@ -104,7 +104,11 @@ let add_messages ~predecessor_timestamp ~predecessor inbox messages = inbox, witness, messages_with_protocol_internal_messages ) = + (* TODO: https://gitlab.com/tezos/tezos/-/issues/4918 Inject + [Protocol_migration (Proto_017)] when migrating to proto_alpha + (N after next snapshot). *) Sc_rollup.Inbox.add_all_messages + ~first_block:false ~predecessor_timestamp ~predecessor no_history @@ -211,7 +215,11 @@ let payloads_history_of_messages ~predecessor ~predecessor_timestamp messages = _inbox, _witness, _messages_with_protocol_internal_messages ) = + (* TODO: https://gitlab.com/tezos/tezos/-/issues/4918 Inject + [Protocol_migration (Proto_017)] when migrating to proto_alpha + (N after next snapshot). *) Sc_rollup.Inbox.add_all_messages + ~first_block:false ~predecessor_timestamp ~predecessor (Sc_rollup.Inbox.History.empty ~capacity:0L) diff --git a/src/proto_alpha/lib_sc_rollup_node/interpreter.ml b/src/proto_alpha/lib_sc_rollup_node/interpreter.ml index 8de11af5eddb..9442e3bd1fef 100644 --- a/src/proto_alpha/lib_sc_rollup_node/interpreter.ml +++ b/src/proto_alpha/lib_sc_rollup_node/interpreter.ml @@ -203,6 +203,9 @@ module Make (PVM : Pvm.S) : S with module PVM = PVM = struct let* {predecessor; predecessor_timestamp; messages} = Node_context.get_messages node_ctxt block.header.inbox_witness in + (* TODO: https://gitlab.com/tezos/tezos/-/issues/4918 Inject + [Protocol_migration (Proto_017)] when migrating to proto_alpha + (N after next snapshot). *) let messages = Sc_rollup.Inbox_message.Internal Start_of_level :: Internal (Info_per_level {predecessor; predecessor_timestamp}) -- GitLab