diff --git a/src/proto_alpha/bin_sc_rollup_node/commitment.ml b/src/proto_alpha/bin_sc_rollup_node/commitment.ml index 756fd0712e366571e3f5cd6009f21fc0b697755d..85f5a3c75959216898feca16a4172dd5d765c807 100644 --- a/src/proto_alpha/bin_sc_rollup_node/commitment.ml +++ b/src/proto_alpha/bin_sc_rollup_node/commitment.ml @@ -120,20 +120,20 @@ let next_commitment_level (module Last_commitment_level : Mutable_level_store) (Raw_level.to_int32 last_commitment_level) sc_rollup_commitment_period -let last_commitment_hash (module Last_commitment_level : Mutable_level_store) - store = +let last_commitment_hash ~genesis_info + (module Last_commitment_level : Mutable_level_store) store = let open Lwt_syntax in let+ last_commitment = last_commitment (module Last_commitment_level) store in match last_commitment with | Some commitment -> Sc_rollup.Commitment.hash commitment - | None -> Sc_rollup.Commitment.Hash.zero + | None -> genesis_info.Sc_rollup.Commitment.commitment_hash -let must_store_commitment ~origination_level current_level store = +let must_store_commitment ~genesis_info current_level store = let open Lwt_result_syntax in let+ next_commitment_level = next_commitment_level (module Store.Last_stored_commitment_level) - ~origination_level + ~origination_level:genesis_info.Sc_rollup.Commitment.level store in Raw_level.equal current_level next_commitment_level @@ -159,15 +159,15 @@ let update_last_stored_commitment store (commitment : Sc_rollup.Commitment.t) = module Make (PVM : Pvm.S) : Commitment_sig.S with module PVM = PVM = struct module PVM = PVM - let build_commitment ~origination_level store block_hash = + let build_commitment ~genesis_info store block_hash = let open Lwt_result_syntax in let lsc = (module Store.Last_stored_commitment_level : Mutable_level_store) in - let*! predecessor = last_commitment_hash lsc store in + let*! predecessor = last_commitment_hash ~genesis_info lsc store in let* inbox_level = Lwt.map Environment.wrap_tzresult - @@ next_commitment_level ~origination_level lsc store + @@ next_commitment_level ~origination_level:genesis_info.level lsc store in let*! pvm_state = Store.PVMState.find store block_hash in let* compressed_state = @@ -214,16 +214,16 @@ module Make (PVM : Pvm.S) : Commitment_sig.S with module PVM = PVM = struct compressed_state; } - let store_commitment_if_necessary ~origination_level store current_level - block_hash = + let store_commitment_if_necessary ~genesis_info store current_level block_hash + = let open Lwt_result_syntax in let* must_store_commitment = Lwt.map Environment.wrap_tzresult - @@ must_store_commitment ~origination_level current_level store + @@ must_store_commitment ~genesis_info current_level store in if must_store_commitment then let*! () = Commitment_event.compute_commitment block_hash current_level in - let* commitment = build_commitment ~origination_level store block_hash in + let* commitment = build_commitment ~genesis_info store block_hash in let*! () = update_last_stored_commitment store commitment in return_unit else return_unit @@ -238,9 +238,9 @@ module Make (PVM : Pvm.S) : Commitment_sig.S with module PVM = PVM = struct Layer1.(Head {level; hash}) = let open Lwt_result_syntax in let current_level = Raw_level.of_int32_exn level in - let origination_level = node_ctxt.initial_level in + let genesis_info = node_ctxt.genesis_info in let* () = update_ticks_and_messages store hash in - store_commitment_if_necessary ~origination_level store current_level hash + store_commitment_if_necessary ~genesis_info store current_level hash let sync_last_cemented_commitment_hash_with_level ({cctxt; rollup_address; _} : Node_context.t) store = @@ -333,7 +333,7 @@ module Make (PVM : Pvm.S) : Commitment_sig.S with module PVM = PVM = struct let publish_commitment node_ctxt store = let open Lwt_result_syntax in let open Node_context in - let origination_level = node_ctxt.initial_level in + let origination_level = node_ctxt.genesis_info.level in (* Check level of next publishable commitment and avoid publishing if it is on or before the last cemented commitment. *) @@ -424,13 +424,13 @@ module Make (PVM : Pvm.S) : Commitment_sig.S with module PVM = PVM = struct (* TODO: https://gitlab.com/tezos/tezos/-/issues/3008 Use the injector to cement commitments. *) let cement_commitment_if_possible - ({Node_context.initial_level = origination_level; _} as node_ctxt) store + ({Node_context.genesis_info; _} as node_ctxt) store (Layer1.Head {level = head_level; _}) = let open Lwt_result_syntax in let* next_level_to_cement = Lwt.map Environment.wrap_tzresult @@ next_commitment_level - ~origination_level + ~origination_level:genesis_info.level (module Store.Last_cemented_commitment_level) store in diff --git a/src/proto_alpha/bin_sc_rollup_node/inbox.ml b/src/proto_alpha/bin_sc_rollup_node/inbox.ml index d07955e84a58431ccb13fea65c7bc0fd1a641dc7..4b151a218bb88834ee7204d4391ddd2d4073d68c 100644 --- a/src/proto_alpha/bin_sc_rollup_node/inbox.ml +++ b/src/proto_alpha/bin_sc_rollup_node/inbox.ml @@ -55,7 +55,10 @@ module State = struct Fortunately this case will only ever be called once when dealing with the rollup origination block. After that we would always find an inbox. *) - Store.Inbox.empty store node_ctxt.rollup_address node_ctxt.initial_level + Store.Inbox.empty + store + node_ctxt.rollup_address + node_ctxt.genesis_info.level | Some inbox -> return inbox let history_of_hash store block_hash = diff --git a/src/proto_alpha/bin_sc_rollup_node/interpreter.ml b/src/proto_alpha/bin_sc_rollup_node/interpreter.ml index d5aef675ca8de345985a9fc7a4812b818ee4173c..38c15746e6a667a27c5bd4f6e7a3602f93193968 100644 --- a/src/proto_alpha/bin_sc_rollup_node/interpreter.ml +++ b/src/proto_alpha/bin_sc_rollup_node/interpreter.ml @@ -81,8 +81,9 @@ module Make (PVM : Pvm.S) : S = struct (node_ctxt.cctxt#chain, node_ctxt.cctxt#block) node_ctxt.rollup_address in - let*! initial_state = PVM.initial_state store boot_sector in - return initial_state + let*! state = PVM.initial_state store in + let*! state = PVM.install_boot_sector state boot_sector in + return state | Some predecessor_state -> return predecessor_state in diff --git a/src/proto_alpha/bin_sc_rollup_node/layer1.ml b/src/proto_alpha/bin_sc_rollup_node/layer1.ml index ae5132da1e61ea73bd6ed81e189a13bbf4cbe232..972f20766bf03f2e316e44b2f1d6510adad075bc 100644 --- a/src/proto_alpha/bin_sc_rollup_node/layer1.ml +++ b/src/proto_alpha/bin_sc_rollup_node/layer1.ml @@ -381,13 +381,13 @@ type info = {origination_level : int32} let gather_info (cctxt : Protocol_client_context.full) sc_rollup_address = let open Lwt_result_syntax in - let* origination_level = - RPC.Sc_rollup.initial_level + let* genesis_info = + RPC.Sc_rollup.genesis_info cctxt (cctxt#chain, cctxt#block) sc_rollup_address in - return {origination_level = Raw_level.to_int32 origination_level} + return {origination_level = Raw_level.to_int32 genesis_info.level} (** [discard_pre_origination_blocks info chain_events] filters [chain_events] in order to discard all heads that occur before the SC rollup origination. *) 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 9653ed574a731c6851e97488428779967ad2c85b..b25641218895043433782bcafd693bcddf1a8b18 100644 --- a/src/proto_alpha/bin_sc_rollup_node/node_context.ml +++ b/src/proto_alpha/bin_sc_rollup_node/node_context.ml @@ -31,7 +31,7 @@ type t = { l1_ctxt : Layer1.t; rollup_address : Sc_rollup.t; operator : Signature.Public_key_hash.t; - initial_level : Raw_level.t; + genesis_info : Sc_rollup.Commitment.genesis_info; block_finality_time : int; kind : Sc_rollup.Kind.t; fee_parameter : Injection.fee_parameter; @@ -45,8 +45,8 @@ let get_operator_keys node_ctxt = let init (cctxt : Protocol_client_context.full) l1_ctxt rollup_address operator fee_parameter = let open Lwt_result_syntax in - let* initial_level = - Plugin.RPC.Sc_rollup.initial_level + let* genesis_info = + Plugin.RPC.Sc_rollup.genesis_info cctxt (cctxt#chain, cctxt#block) rollup_address @@ -59,7 +59,7 @@ let init (cctxt : Protocol_client_context.full) l1_ctxt rollup_address operator l1_ctxt; rollup_address; operator; - initial_level; + genesis_info; kind; block_finality_time = 2; fee_parameter; 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 17a1975ad66b96ddff6271ff919049868e58d483..bc651abf27255d8f03b04460ebc8ab4b8702d96e 100644 --- a/src/proto_alpha/bin_sc_rollup_node/node_context.mli +++ b/src/proto_alpha/bin_sc_rollup_node/node_context.mli @@ -37,8 +37,8 @@ type t = { (** Smart contract rollup tracked by the rollup node. *) operator : Signature.Public_key_hash.t; (** Address of the rollup node operator. *) - initial_level : Raw_level.t; - (** Origination level of the smart contract rollup. *) + genesis_info : Sc_rollup.Commitment.genesis_info; + (** Origination information of the smart contract rollup. *) block_finality_time : int; (** Deterministic block finality time for the layer 1 protocol. *) kind : Sc_rollup.Kind.t; (** Kind of the smart contract rollup. *) diff --git a/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml index 6af08b3235c9f1ad29b4bdf996475240213d7174..de3d0f7670b9f671462fad2218dcac8e446bd834 100644 --- a/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/sc_rollup_benchmarks.ml @@ -222,13 +222,22 @@ module Sc_rollup_add_external_messages_benchmark = struct Michelson_v1_parser.parse_expression "unit" in let parameters_ty = Alpha_context.Script.lazy_expr expanded in - let+ rollup, _size, ctxt = + let boot_sector = "" in + let kind = Sc_rollups.Kind.Example_arith in + let*! genesis_commitment = + Sc_rollup_helpers.genesis_commitment_raw + ~boot_sector + ~origination_level:(Raw_context.current_level ctxt).level + kind + in + let+ rollup, _size, _genesis_hash, ctxt = Lwt.map Environment.wrap_tzresult @@ Sc_rollup_storage.originate ctxt - ~kind:Example_arith - ~boot_sector:"" + ~kind + ~boot_sector ~parameters_ty + ~genesis_commitment in (rollup, ctxt) in diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index 65c526da7b73c73374f1ef51867146075db9e8a0..f7596935b731a3da4fa615119809cf97e10773c6 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -1139,13 +1139,16 @@ let transfer_ticket (cctxt : #full) ~chain ~block ?confirmations ?dry_run let sc_rollup_originate (cctxt : #full) ~chain ~block ?confirmations ?dry_run ?verbose_signing ?simulation ?fee ?gas_limit ?storage_limit ?counter ~source ~kind ~boot_sector ~parameters_ty ~src_pk ~src_sk ~fee_parameter () = + Client_proto_rollups.ScRollup.origination_proof_exn ~boot_sector kind + >>= fun origination_proof -> let op = Annotated_manager_operation.Single_manager (Injection.prepare_manager_operation ~fee:(Limit.of_option fee) ~gas_limit:(Limit.of_option gas_limit) ~storage_limit:(Limit.of_option storage_limit) - (Sc_rollup_originate {kind; boot_sector; parameters_ty})) + (Sc_rollup_originate + {kind; boot_sector; origination_proof; parameters_ty})) in Injection.inject_manager_operation cctxt diff --git a/src/proto_alpha/lib_client/client_proto_rollups.ml b/src/proto_alpha/lib_client/client_proto_rollups.ml index cb7c96b8abbf44e81c2dd691c9045439eeb8fa43..cd1bb4ded72879251a3e8de1ce50d208f3af8059 100644 --- a/src/proto_alpha/lib_client/client_proto_rollups.ml +++ b/src/proto_alpha/lib_client/client_proto_rollups.ml @@ -24,6 +24,7 @@ (*****************************************************************************) open Protocol +open Alpha_context module TxRollupEntity = struct include Alpha_context.Tx_rollup (* t, Compare, encoding *) @@ -41,3 +42,111 @@ module TxRollupEntity = struct end module TxRollupAlias = Client_aliases.Alias (TxRollupEntity) + +module ScRollup = struct + module In_memory_context = struct + open Tezos_context_memory + + module Tree = struct + include Context.Tree + + type tree = Context.tree + + type t = Context.t + + type key = string list + + type value = bytes + end + + type tree = Tree.tree + + type proof = Context.Proof.tree Context.Proof.t + + let hash_tree _ = assert false + + let verify_proof p f = + Lwt.map Result.to_option (Context.verify_tree_proof p f) + + let produce_proof context state step = + let open Lwt_syntax in + let* context = Context.add_tree context [] state in + let* h = Context.commit ~time:Time.Protocol.epoch context in + let index = Context.index context in + let* context = Context.checkout_exn index h in + match Tree.kinded_key state with + | Some k -> + let index = Context.index context in + let* p = Context.produce_tree_proof index k step in + return (Some p) + | None -> return None + + let kinded_hash_to_state_hash = function + | `Value hash | `Node hash -> + Sc_rollup.State_hash.context_hash_to_state_hash hash + + let proof_before proof = + kinded_hash_to_state_hash proof.Context.Proof.before + + let proof_after proof = kinded_hash_to_state_hash proof.Context.Proof.after + + let proof_encoding = + Tezos_context_helpers.Merkle_proof_encoding.V1.Tree32.tree_proof_encoding + end + + module Arith_pvm : + Sc_rollup.PVM.S + with type context = In_memory_context.Tree.t + and type state = In_memory_context.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t + Sc_rollup.ArithPVM.proof = + Sc_rollup.ArithPVM.Make (In_memory_context) + + module Wasm_pvm : + Sc_rollup.PVM.S + with type context = In_memory_context.Tree.t + and type state = In_memory_context.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t + Sc_rollup.Wasm_2_0_0PVM.proof = + Sc_rollup.Wasm_2_0_0PVM.Make (In_memory_context) + + let origination_proof_exn ~boot_sector kind = + let aux = function + | Sc_rollup.Kind.Example_arith -> + let open Lwt_result_syntax in + let context = Tezos_context_memory.make_empty_context () in + let* proof = + Arith_pvm.produce_origination_proof context boot_sector + in + return + (Sc_rollup.Arith_pvm_with_proof + (module struct + include Arith_pvm + + let proof = proof + end)) + | Sc_rollup.Kind.Wasm_2_0_0 -> + let open Lwt_result_syntax in + let context = Tezos_context_memory.make_empty_context () in + let* proof = Wasm_pvm.produce_origination_proof context boot_sector in + return + (Sc_rollup.Wasm_2_0_0_pvm_with_proof + (module struct + include Wasm_pvm + + let proof = proof + end)) + in + let open Lwt_syntax in + let* res = aux kind in + match res with + | Ok res -> Lwt.return res + | Error _ -> + raise + (Invalid_argument + "origination_proof_exn: could not produce an origination proof") +end diff --git a/src/proto_alpha/lib_client/client_proto_rollups.mli b/src/proto_alpha/lib_client/client_proto_rollups.mli index ca9eda8b02ea9c40f977dec1f6d95733ddb4e934..8c15bb1a5bc24ecc53e41583253d43c61b3c2b10 100644 --- a/src/proto_alpha/lib_client/client_proto_rollups.mli +++ b/src/proto_alpha/lib_client/client_proto_rollups.mli @@ -24,6 +24,12 @@ (*****************************************************************************) open Protocol +open Alpha_context module TxRollupAlias : Client_aliases.Alias with type t = Alpha_context.Tx_rollup.t + +module ScRollup : sig + val origination_proof_exn : + boot_sector:string -> Sc_rollup.Kind.t -> Sc_rollup.wrapped_proof Lwt.t +end diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index 56ab154b1309ab91797d72fed17243e218786130..b4427a0d05d65d4a0fb673f729ef9498a764ca32 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -275,7 +275,8 @@ let pp_manager_operation_content (type kind) source ppf Format.fprintf ppf "Transfer tickets:@,From: %a" Contract.pp source | Dal_publish_slot_header {slot} -> Format.fprintf ppf "@[Publish slot %a@]" Dal.Slot.pp slot - | Sc_rollup_originate {kind; boot_sector; parameters_ty} -> + | Sc_rollup_originate + {kind; boot_sector; origination_proof = _; parameters_ty} -> let (module R : Sc_rollup.PVM.S) = Sc_rollup.Kind.pvm_of kind in Format.fprintf ppf @@ -657,10 +658,16 @@ let pp_manager_operation_contents_result ppf op_result = in let pp_sc_rollup_originate_result (Sc_rollup_originate_result - {address; consumed_gas; size; balance_updates}) = + {address; genesis_commitment_hash; consumed_gas; size; balance_updates}) + = pp_consumed_gas ppf consumed_gas ; pp_storage_size ppf size ; Format.fprintf ppf "@,Address: %a" Sc_rollup.Address.pp address ; + Format.fprintf + ppf + "@,Genesis commitment hash: %a" + Sc_rollup.Commitment.Hash.pp + genesis_commitment_hash ; pp_balance_updates ppf balance_updates in let pp_sc_rollup_add_messages_result diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index 17d1f91634f6aae969eb05914c6d0bb42c1e537f..bd7cf98b67b6f59fbca179f97ad9a14cda023d84 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -2541,7 +2541,7 @@ let commands_rw () = "Only implicit accounts can originate smart-contract rollups" | Implicit source -> Client_keys.get_key cctxt source >>=? fun (_, src_pk, src_sk) -> - let (module R : Sc_rollup.PVM.S) = pvm in + let (module R : Alpha_context.Sc_rollup.PVM.S) = pvm in let Michelson_v1_parser.{expanded; _} = parameters_ty in let parameters_ty = Script.lazy_expr expanded in boot_sector pvm >>=? fun boot_sector -> diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index b50281b9a827183f7fa68eed6cd97ffbf181867d..97ca7c540e24c89a11706e0bea034b9030fccc5a 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -1820,12 +1820,14 @@ module Sc_rollup = struct ~output:Sc_rollup.Inbox.encoding RPC_path.(path /: Sc_rollup.Address.rpc_arg / "inbox") - let initial_level = + let genesis_info = RPC_service.get_service - ~description:"Initial level for a smart-contract rollup" + ~description: + "Genesis information (level and commitment hash) for a \ + smart-contract rollup" ~query:RPC_query.empty - ~output:Raw_level.encoding - RPC_path.(path /: Sc_rollup.Address.rpc_arg / "initial_level") + ~output:Sc_rollup.Commitment.genesis_info_encoding + RPC_path.(path /: Sc_rollup.Address.rpc_arg / "genesis_info") let last_cemented_commitment_hash_with_level = RPC_service.get_service @@ -1937,10 +1939,10 @@ module Sc_rollup = struct Alpha_context.Sc_rollup.kind ctxt address >|=? Option.some (* TODO: https://gitlab.com/tezos/tezos/-/issues/2688 *) - let register_initial_level () = - Registration.register1 ~chunked:true S.initial_level + let register_genesis_info () = + Registration.register1 ~chunked:true S.genesis_info @@ fun ctxt address () () -> - Alpha_context.Sc_rollup.initial_level ctxt address + Alpha_context.Sc_rollup.genesis_info ctxt address let register_boot_sector () = Registration.register1 ~chunked:true S.boot_sector @@ -2018,7 +2020,7 @@ module Sc_rollup = struct let register () = register_kind () ; register_inbox () ; - register_initial_level () ; + register_genesis_info () ; register_boot_sector () ; register_last_cemented_commitment_hash_with_level () ; register_staked_on_commitment () ; @@ -2030,8 +2032,8 @@ module Sc_rollup = struct let list ctxt block = RPC_context.make_call0 S.root ctxt block () () - let initial_level ctxt block sc_rollup_address = - RPC_context.make_call1 S.initial_level ctxt block sc_rollup_address () () + let genesis_info ctxt block sc_rollup_address = + RPC_context.make_call1 S.genesis_info ctxt block sc_rollup_address () () let last_cemented_commitment_hash_with_level ctxt block sc_rollup_address = RPC_context.make_call1 diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 5528ca53e526fa0b970f1de8218c1e8344df8f28..01c3d3225d8faeca0bf13ff5d95f0b7848510029 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3025,7 +3025,9 @@ module Sc_rollup : sig val state_hash : state -> hash Lwt.t - val initial_state : context -> string -> state Lwt.t + val initial_state : context -> state Lwt.t + + val install_boot_sector : state -> string -> state Lwt.t val is_input_state : state -> input_request Lwt.t @@ -3038,6 +3040,11 @@ module Sc_rollup : sig val produce_proof : context -> input option -> state -> (proof, error) result Lwt.t + val verify_origination_proof : proof -> string -> bool Lwt.t + + val produce_origination_proof : + context -> string -> (proof, error) result Lwt.t + type output_proof val output_proof_encoding : output_proof Data_encoding.t @@ -3102,8 +3109,18 @@ module Sc_rollup : sig (proof * 'a) option Lwt.t end + type 'a proof = { + tree_proof : 'a; + given : input option; + requested : input_request; + } + module Make (C : P) : sig - include PVM.S with type context = C.Tree.t and type state = C.tree + include + PVM.S + with type context = C.Tree.t + and type state = C.tree + and type proof = C.proof proof val get_tick : state -> Tick.t Lwt.t @@ -3111,6 +3128,14 @@ module Sc_rollup : sig val get_status : state -> status Lwt.t end + + val reference_initial_state_hash : State_hash.t + + module ProtocolImplementation : + PVM.S + with type context = Context.t + and type state = Context.tree + and type proof = Context.Proof.tree Context.Proof.t proof end module Wasm_2_0_0PVM : sig @@ -3166,11 +3191,21 @@ module Sc_rollup : sig with type context = Context.t and type state = Context.tree and type proof = Context.Proof.tree Context.Proof.t proof + + val reference_initial_state_hash : State_hash.t end - module Number_of_messages : Bounded.Int32.S + module Number_of_messages : sig + include Bounded.Int32.S - module Number_of_ticks : Bounded.Int32.S + val zero : t + end + + module Number_of_ticks : sig + include Bounded.Int32.S + + val zero : t + end module Commitment : sig module Hash : S.HASH @@ -3189,6 +3224,13 @@ module Sc_rollup : sig val hash : t -> Hash.t + val genesis_commitment : + origination_level:Raw_level.t -> genesis_state_hash:State_hash.t -> t + + type genesis_info = {level : Raw_level.t; commitment_hash : Hash.t} + + val genesis_info_encoding : genesis_info Data_encoding.t + val get_commitment : context -> rollup -> Hash.t -> (t * context) tzresult Lwt.t @@ -3201,7 +3243,8 @@ module Sc_rollup : sig kind:Kind.t -> boot_sector:string -> parameters_ty:Script.lazy_expr -> - (t * Z.t * context) tzresult Lwt.t + genesis_commitment:Commitment.t -> + (t * Z.t * Commitment.Hash.t * context) tzresult Lwt.t val parameters_type : context -> t -> (Script.lazy_expr option * context) tzresult Lwt.t @@ -3222,10 +3265,14 @@ module Sc_rollup : sig | Unencodable of (module PVM_with_proof) | Arith_pvm_with_proof of (module PVM_with_proof - with type proof = Sc_rollup_arith.ProtocolImplementation.proof) + with type proof = ArithPVM.ProtocolImplementation.proof) | Wasm_2_0_0_pvm_with_proof of (module PVM_with_proof - with type proof = Sc_rollup_wasm.V2_0_0.ProtocolImplementation.proof) + with type proof = Wasm_2_0_0PVM.ProtocolImplementation.proof) + + val wrapped_proof_kind_exn : wrapped_proof -> Kind.t + + val wrapped_proof_module : wrapped_proof -> (module PVM_with_proof) module Proof : sig type t = {pvm_step : wrapped_proof; inbox : Inbox.proof option} @@ -3238,6 +3285,8 @@ module Sc_rollup : sig val state : state end + type error += Sc_rollup_proof_check of string + val produce : (module PVM_with_context_and_state) -> Inbox.inbox_context -> @@ -3394,7 +3443,7 @@ module Sc_rollup : sig val list : context -> t list tzresult Lwt.t - val initial_level : context -> t -> Raw_level.t tzresult Lwt.t + val genesis_info : context -> rollup -> Commitment.genesis_info tzresult Lwt.t val get_boot_sector : context -> t -> string tzresult Lwt.t @@ -3870,6 +3919,7 @@ and _ manager_operation = | Sc_rollup_originate : { kind : Sc_rollup.Kind.t; boot_sector : string; + origination_proof : Sc_rollup.wrapped_proof; parameters_ty : Script.lazy_expr; } -> Kind.sc_rollup_originate manager_operation diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 3df346352b62d6cc014039a534f90a0720339783..365be4acd51b50be2bcc0758b9500d126b069145 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -1798,13 +1798,24 @@ let apply_external_manager_operation_content : let consumed_gas = Gas.consumed ~since:ctxt_before_op ~until:ctxt in let result = Dal_publish_slot_header_result {consumed_gas} in return (ctxt, result, []) - | Sc_rollup_originate {kind; boot_sector; parameters_ty} -> - Sc_rollup_operations.originate ctxt ~kind ~boot_sector ~parameters_ty - >>=? fun ({address; size}, ctxt) -> + | Sc_rollup_originate {kind; boot_sector; origination_proof; parameters_ty} -> + Sc_rollup_operations.originate + ctxt + ~kind + ~boot_sector + ~origination_proof + ~parameters_ty + >>=? fun ({address; size; genesis_commitment_hash}, ctxt) -> let consumed_gas = Gas.consumed ~since:ctxt_before_op ~until:ctxt in let result = Sc_rollup_originate_result - {address; consumed_gas; size; balance_updates = []} + { + address; + genesis_commitment_hash; + consumed_gas; + size; + balance_updates = []; + } in return (ctxt, result, []) | Sc_rollup_add_messages {rollup; messages} -> diff --git a/src/proto_alpha/lib_protocol/apply_results.ml b/src/proto_alpha/lib_protocol/apply_results.ml index d8d4b8276a2a5d169d2c911be7fbb0e8e10b11b6..1c3b6bdf02eb1355c61c7ea48120a4d65a6d1d84 100644 --- a/src/proto_alpha/lib_protocol/apply_results.ml +++ b/src/proto_alpha/lib_protocol/apply_results.ml @@ -124,6 +124,7 @@ type _ successful_manager_operation_result = | Sc_rollup_originate_result : { balance_updates : Receipt.balance_updates; address : Sc_rollup.Address.t; + genesis_commitment_hash : Sc_rollup.Commitment.Hash.t; consumed_gas : Gas.Arith.fp; size : Z.t; } @@ -744,9 +745,10 @@ module Manager_result = struct make ~op_case:Operation.Encoding.Manager_operations.sc_rollup_originate_case ~encoding: - (obj4 + (obj5 (req "balance_updates" Receipt.balance_updates_encoding) (req "address" Sc_rollup.Address.encoding) + (req "genesis_commitment_hash" Sc_rollup.Commitment.Hash.encoding) (dft "consumed_milligas" Gas.Arith.n_fp_encoding Gas.Arith.zero) (req "size" z)) ~select:(function @@ -755,12 +757,33 @@ module Manager_result = struct | _ -> None) ~proj:(function | Sc_rollup_originate_result - {balance_updates; address; consumed_gas; size} -> - (balance_updates, address, consumed_gas, size)) + { + balance_updates; + address; + genesis_commitment_hash; + consumed_gas; + size; + } -> + ( balance_updates, + address, + genesis_commitment_hash, + consumed_gas, + size )) ~kind:Kind.Sc_rollup_originate_manager_kind - ~inj:(fun (balance_updates, address, consumed_gas, size) -> + ~inj: + (fun ( balance_updates, + address, + genesis_commitment_hash, + consumed_gas, + size ) -> Sc_rollup_originate_result - {balance_updates; address; consumed_gas; size}) + { + balance_updates; + address; + genesis_commitment_hash; + consumed_gas; + size; + }) let sc_rollup_add_messages_case = make diff --git a/src/proto_alpha/lib_protocol/apply_results.mli b/src/proto_alpha/lib_protocol/apply_results.mli index 08f47c7c7cbbcf182b62c40f576e4ce0eda3aa6a..ec7cd4a0289cae8d8bcaab8049e22075c0f02aad 100644 --- a/src/proto_alpha/lib_protocol/apply_results.mli +++ b/src/proto_alpha/lib_protocol/apply_results.mli @@ -220,6 +220,7 @@ and _ successful_manager_operation_result = | Sc_rollup_originate_result : { balance_updates : Receipt.balance_updates; address : Sc_rollup.Address.t; + genesis_commitment_hash : Sc_rollup.Commitment.Hash.t; consumed_gas : Gas.Arith.fp; size : Z.t; } diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index 2d20b1b566b356b969ed356538e96458edc74b9d..a402132cf700545537f8c6d406268a2b2868219f 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -412,6 +412,7 @@ and _ manager_operation = | Sc_rollup_originate : { kind : Sc_rollups.Kind.t; boot_sector : string; + origination_proof : Sc_rollups.wrapped_proof; parameters_ty : Script_repr.lazy_expr; } -> Kind.sc_rollup_originate manager_operation @@ -1013,20 +1014,23 @@ module Encoding = struct tag = sc_rollup_operation_origination_tag; name = "sc_rollup_originate"; encoding = - obj3 + obj4 (req "kind" Sc_rollups.Kind.encoding) (req "boot_sector" Data_encoding.string) + (req "origination_proof" Sc_rollups.wrapped_proof_encoding) (req "parameters_ty" Script_repr.lazy_expr_encoding); select = (function | Manager (Sc_rollup_originate _ as op) -> Some op | _ -> None); proj = (function - | Sc_rollup_originate {kind; boot_sector; parameters_ty} -> - (kind, boot_sector, parameters_ty)); + | Sc_rollup_originate + {kind; boot_sector; origination_proof; parameters_ty} -> + (kind, boot_sector, origination_proof, parameters_ty)); inj = - (fun (kind, boot_sector, parameters_ty) -> - Sc_rollup_originate {kind; boot_sector; parameters_ty}); + (fun (kind, boot_sector, origination_proof, parameters_ty) -> + Sc_rollup_originate + {kind; boot_sector; origination_proof; parameters_ty}); } let[@coq_axiom_with_reason "gadt"] dal_publish_slot_header_case = diff --git a/src/proto_alpha/lib_protocol/operation_repr.mli b/src/proto_alpha/lib_protocol/operation_repr.mli index bc9cc3838d59b4c19eb02013fcc33b095902d880..155fe27b0c0b33e9dd5a82eae671d122eb9c0d02 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.mli +++ b/src/proto_alpha/lib_protocol/operation_repr.mli @@ -480,6 +480,7 @@ and _ manager_operation = | Sc_rollup_originate : { kind : Sc_rollups.Kind.t; boot_sector : string; + origination_proof : Sc_rollups.wrapped_proof; parameters_ty : Script_repr.lazy_expr; } -> Kind.sc_rollup_originate manager_operation diff --git a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.ml b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.ml index b0f31b34aed2ee813fde2ffd4e5ce9049658c65c..9652723225818fb9b2eba6cf733684b124f847c2 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.ml @@ -154,7 +154,9 @@ module type S = sig val state_hash : state -> hash Lwt.t - val initial_state : context -> string -> state Lwt.t + val initial_state : context -> state Lwt.t + + val install_boot_sector : state -> string -> state Lwt.t val is_input_state : state -> input_request Lwt.t @@ -167,6 +169,11 @@ module type S = sig val produce_proof : context -> input option -> state -> (proof, error) result Lwt.t + val verify_origination_proof : proof -> string -> bool Lwt.t + + val produce_origination_proof : + context -> string -> (proof, error) result Lwt.t + type output_proof val output_proof_encoding : output_proof Data_encoding.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.mli b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.mli index 2a16da0aaae59d9c3f3ef03118bdb0ac73e41fff..30089681791aabfd8c0c1e8cf1340f7616024156 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.mli @@ -104,9 +104,16 @@ val pp_output : Format.formatter -> output -> unit module type S = sig (** The state of the PVM denotes a state of the rollup. - We classify states into two categories: "internal states" do not require - any external information to be executed while "input states" are waiting - for some information from the inbox to be executable. *) + The life cycle of the PVM is as follows. It starts its execution + from an {!initial_state}. The initial state is specialized at + origination with a [boot_sector], using the + {!install_boot_sector} function. The resulting state is call the + “genesis” of the rollup. + + Afterwards, we classify states into two categories: "internal + states" do not require any external information to be executed + while "input states" are waiting for some information from the + inbox to be executable. *) type state (** A state is initialized in a given context. A [context] @@ -193,12 +200,17 @@ module type S = sig (** [state_hash state] returns a compressed representation of [state]. *) val state_hash : state -> hash Lwt.t - (** [initial_state context boot_sector] is the initial state of the PVM, - which is a pure function of [boot_sector]. + (** [initial_state context] is the initial state of the PVM, before + its specialization with a given [boot_sector]. The [context] argument is required for technical reasons and does not impact the result. *) - val initial_state : context -> string -> state Lwt.t + val initial_state : context -> state Lwt.t + + (** [install_boot_sector state boot_sector] specializes the initial + [state] of a PVM using a dedicated [boot_sector], submitted at + the origination of the rollup. *) + val install_boot_sector : state -> string -> state Lwt.t (** [is_input_state state] returns the input expectations of the [state]---does it need input, and if so, how far through the inbox @@ -228,6 +240,17 @@ module type S = sig val produce_proof : context -> input option -> state -> (proof, error) result Lwt.t + (** [verify_origination_proof proof boot_sector] verifies a proof + supposedly generated by [produce_origination_proof]. *) + val verify_origination_proof : proof -> string -> bool Lwt.t + + (** [produce_origination_proof context boot_sector] produces a proof + [p] covering the specialization of a PVM, from the + [initial_state] up to the genesis state wherein the + [boot_sector] has been installed. *) + val produce_origination_proof : + context -> string -> (proof, error) result Lwt.t + (** The following type is inhabited by the proofs that a given [output] is part of the outbox of a given [state]. *) type output_proof diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index acad3966734dae661452298a39844bdb7d9787d1..fe11af685a2c286fc02e9ded5e18419d811494f3 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -26,6 +26,33 @@ open Sc_rollup_repr module PS = Sc_rollup_PVM_sem +(* + This is the state hash of reference that both the prover of the node + and the verifier of the protocol {!ProtocolImplementation} have to + agree on (if they do, it means they are using the same tree + structure). + + We have to hard-code this value because the Arith PVM uses Irmin as + its Merkle proof verification backend, and the economic protocol + cannot create an empty Irmin context. Such a context is required to + create an empty tree, itself required to create the initial state of + the Arith PVM. + + Utlimately, the value of this constant is decided by the prover of + reference (the only need is for it to be compatible with + {!ProtocolImplementation}.) + + Its value is the result of the following snippet + + {| + let*! state = Prover.initial_state context in + Prover.state_hash state + |} +*) +let reference_initial_state_hash = + State_hash.of_b58check_exn + "scs11cXwQJJ5dkpEQGq3x2MJm3cM73cbEkHJqo5eDSoRpHUPyEQLB4" + module type P = sig module Tree : Context.TREE with type key = string list and type value = bytes @@ -87,29 +114,37 @@ module type S = sig val get_is_stuck : state -> string option Lwt.t end +type 'a proof = { + tree_proof : 'a; + given : Sc_rollup_PVM_sem.input option; + requested : Sc_rollup_PVM_sem.input_request; +} + +let proof_encoding : 'a Data_encoding.t -> 'a proof Data_encoding.t = + fun encoding -> + let open Data_encoding in + conv + (fun {tree_proof; given; requested} -> (tree_proof, given, requested)) + (fun (tree_proof, given, requested) -> {tree_proof; given; requested}) + (obj3 + (req "tree_proof" encoding) + (req "given" (option PS.input_encoding)) + (req "requested" PS.input_request_encoding)) + module Make (Context : P) : - S with type context = Context.Tree.t and type state = Context.tree = struct + S + with type context = Context.Tree.t + and type state = Context.tree + and type proof = Context.proof proof = struct module Tree = Context.Tree type context = Context.Tree.t type hash = State_hash.t - type proof = { - tree_proof : Context.proof; - given : PS.input option; - requested : PS.input_request; - } + type nonrec proof = Context.proof proof - let proof_encoding = - let open Data_encoding in - conv - (fun {tree_proof; given; requested} -> (tree_proof, given, requested)) - (fun (tree_proof, given, requested) -> {tree_proof; given; requested}) - (obj3 - (req "tree_proof" Context.proof_encoding) - (req "given" (option PS.input_encoding)) - (req "requested" PS.input_request_encoding)) + let proof_encoding = proof_encoding Context.proof_encoding let proof_start_state p = Context.proof_before p.tree_proof @@ -727,11 +762,10 @@ module Make (Context : P) : open Monad - let initial_state ctxt boot_sector = + let initial_state ctxt = let state = Tree.empty ctxt in let m = let open Monad.Syntax in - let* () = Boot_sector.set boot_sector in let* () = Status.set Halted in return () in @@ -739,19 +773,19 @@ module Make (Context : P) : let* state, _ = run m state in return state - let state_hash state = + let install_boot_sector state boot_sector = let m = let open Monad.Syntax in - let* status = Status.get in - match status with - | Halted -> return State_hash.zero - | _ -> return @@ State_hash.context_hash_to_state_hash (Tree.hash state) + let* () = Boot_sector.set boot_sector in + return () in let open Lwt_syntax in - let* state = Monad.run m state in - match state with - | _, Some hash -> return hash - | _ -> (* Hash computation always succeeds. *) assert false + let* state, _ = run m state in + return state + + let state_hash state = + let context_hash = Tree.hash state in + Lwt.return @@ State_hash.context_hash_to_state_hash context_hash let boot = let open Monad.Syntax in @@ -1068,6 +1102,32 @@ module Make (Context : P) : return {tree_proof; given = input_given; requested} | None -> fail Arith_proof_production_failed + let verify_origination_proof proof boot_sector = + let open Lwt_syntax in + let before = Context.proof_before proof.tree_proof in + if State_hash.(before <> reference_initial_state_hash) then return false + else + let* result = + Context.verify_proof proof.tree_proof (fun state -> + let* state = install_boot_sector state boot_sector in + return (state, ())) + in + match result with None -> return false | Some (_, ()) -> return true + + let produce_origination_proof context boot_sector = + let open Lwt_result_syntax in + let*! state = initial_state context in + let*! result = + Context.produce_proof context state (fun state -> + let open Lwt_syntax in + let* state = install_boot_sector state boot_sector in + return (state, ())) + in + match result with + | Some (tree_proof, ()) -> + return {tree_proof; given = None; requested = No_input_required} + | None -> fail Arith_proof_production_failed + (* TEMPORARY: The following definitions will be extended in a future commit. *) type output_proof = { diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.mli b/src/proto_alpha/lib_protocol/sc_rollup_arith.mli index fc3819d7358faf736340685bf974a8d095842e01..0c79c48654e9fc5593a6c4353b9d18e39e3e647e 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.mli @@ -126,8 +126,23 @@ module type S = sig val get_is_stuck : state -> string option Lwt.t end +type 'a proof = { + tree_proof : 'a; + given : Sc_rollup_PVM_sem.input option; + requested : Sc_rollup_PVM_sem.input_request; +} + module ProtocolImplementation : - S with type context = Context.t and type state = Context.tree + S + with type context = Context.t + and type state = Context.tree + and type proof = Context.Proof.tree Context.Proof.t proof + +(** This is the state hash of reference that both the prover of the + node and the verifier of the protocol {!ProtocolImplementation} + have to agree on (if they do, it means they are using the same + tree structure). *) +val reference_initial_state_hash : Sc_rollup_repr.State_hash.t module type P = sig module Tree : Context.TREE with type key = string list and type value = bytes @@ -152,4 +167,7 @@ module type P = sig end module Make (Context : P) : - S with type context = Context.Tree.t and type state = Context.tree + S + with type context = Context.Tree.t + and type state = Context.tree + and type proof = Context.proof proof diff --git a/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.ml index c336167752d53e1b2e30323dd9b8cc1c8fb34099..6b5c40e0762caf6545e2b23f97dd3b3569920bf1 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.ml @@ -124,6 +124,30 @@ module V1 = struct Data_encoding.Binary.to_bytes_exn encoding commitment in Hash.hash_bytes [commitment_bytes] + + (* For [number_of_messages] and [number_of_ticks] min_value is equal to zero. *) + let genesis_commitment ~origination_level ~genesis_state_hash = + let open Sc_rollup_repr in + let number_of_messages = Number_of_messages.zero in + let number_of_ticks = Number_of_ticks.zero in + { + compressed_state = genesis_state_hash; + inbox_level = origination_level; + predecessor = Hash.zero; + number_of_messages; + number_of_ticks; + } + + type genesis_info = {level : Raw_level_repr.t; commitment_hash : Hash.t} + + let genesis_info_encoding = + let open Data_encoding in + conv + (fun {level; commitment_hash} -> (level, commitment_hash)) + (fun (level, commitment_hash) -> {level; commitment_hash}) + (obj2 + (req "level" Raw_level_repr.encoding) + (req "commitment_hash" Hash.encoding)) end type versioned = V1 of V1.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.mli index 67a140795fa9d00f13109d51480e86227af6455c..f7eb05201b516df4551679ac538a1c781935221e 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.mli @@ -69,6 +69,35 @@ module V1 : sig val encoding : t Data_encoding.t val hash : t -> Hash.t + + (** [genesis_commitment ~origination_level ~genesis_state_hash] is the + commitment that the protocol "publish" and "cement" when originating a new + rollup. Each rollup have a different [genesis_commitment] because the + [compressed_state] is computed after the boot sector is set. It has the + following values: + + {ul {li [compressed_state] = [genesis_state_hash]} + {li [inbox_level] = [origination_level]} + {li [predecessor] = {!Hash.zero}} + {li [number_of_messages] = {!Sc_rollup_repr.Number_of_messages.min_value}} + {li [number_of_ticks] = {!Sc_rollup_repr.Number_of_ticks.min_value}}} + + where {!Sc_rollup_repr.Number_of_messages.min_value} and + {!Sc_rollup_repr.Number_of_ticks.min_value} are equal to [zero]. + + See {!Sc_rollup_storage.originate} for the usage. *) + val genesis_commitment : + origination_level:Raw_level_repr.t -> + genesis_state_hash:Sc_rollup_repr.State_hash.t -> + t + + (** The genesis of a rollup is characterized by the Tezos level of + the rollup origination, and the hash of the commitment computed + by the protocol to specialize the PVM initial state with the + provided boot sector. *) + type genesis_info = {level : Raw_level_repr.t; commitment_hash : Hash.t} + + val genesis_info_encoding : genesis_info Data_encoding.t end (** Versioning, see {!Sc_rollup_data_version_sig.S} for more information. *) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_commitment_storage.ml b/src/proto_alpha/lib_protocol/sc_rollup_commitment_storage.ml index 6d883a86f19ce79cd7566f981942023774663098..6a01a12ebdbb951ed98eb781f1285bedfca81837 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_commitment_storage.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_commitment_storage.ml @@ -52,14 +52,10 @@ let get_commitment ctxt rollup commitment = let last_cemented_commitment_hash_with_level ctxt rollup = let open Lwt_tzresult_syntax in let* commitment_hash, ctxt = last_cemented_commitment ctxt rollup in - if Commitment_hash.(commitment_hash = zero) then - let+ initial_level = Storage.Sc_rollup.Initial_level.get ctxt rollup in - (commitment_hash, initial_level, ctxt) - else - let+ {inbox_level; _}, ctxt = - get_commitment_unsafe ctxt rollup commitment_hash - in - (commitment_hash, inbox_level, ctxt) + let+ {inbox_level; _}, ctxt = + get_commitment_unsafe ctxt rollup commitment_hash + in + (commitment_hash, inbox_level, ctxt) let set_commitment_added ctxt rollup node new_value = let open Lwt_tzresult_syntax in 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 993841019a8aa4cc9f21ac08ee2b23de0ea592ce..5bbc4a3e7b632c60c43f1daa947f7d7f73f22e28 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_storage.ml @@ -110,7 +110,8 @@ let add_messages ctxt rollup messages = in let* () = assert_inbox_nb_messages_in_commitment_period inbox num_messages in let inbox_level = Sc_rollup_inbox_repr.inbox_level inbox in - let* origination_level = Storage.Sc_rollup.Initial_level.get ctxt rollup in + let* genesis_info = Storage.Sc_rollup.Genesis_info.get ctxt rollup in + let origination_level = genesis_info.level in let levels = Int32.sub (Raw_level_repr.to_int32 inbox_level) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_operations.ml b/src/proto_alpha/lib_protocol/sc_rollup_operations.ml index 607bd36b690e52c76fad2e5616962fddbbdf7a3b..0547464cc672c0bf3e96c7691063c6d42bc75b2a 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_operations.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_operations.ml @@ -80,7 +80,11 @@ let () = (function Sc_rollup_invalid_outbox_level -> Some () | _ -> None) (fun () -> Sc_rollup_invalid_outbox_level) -type origination_result = {address : Sc_rollup.Address.t; size : Z.t} +type origination_result = { + address : Sc_rollup.Address.t; + size : Z.t; + genesis_commitment_hash : Sc_rollup.Commitment.Hash.t; +} type 'ret continuation = unit -> 'ret tzresult @@ -168,7 +172,30 @@ let validate_untyped_parameters_ty ctxt parameters_ty = (* Check that the type is valid for rollups. *) validate_parameters_ty ctxt arg_type -let originate ctxt ~kind ~boot_sector ~parameters_ty = +let check_origination_proof kind boot_sector origination_proof = + let open Lwt_tzresult_syntax in + let (module PVM) = Sc_rollup.wrapped_proof_module origination_proof in + let kind' = Sc_rollup.wrapped_proof_kind_exn origination_proof in + let* () = + fail_when + Compare.String.( + Sc_rollup.Kind.name_of kind <> Sc_rollup.Kind.name_of kind') + (Sc_rollup_proof_repr.Sc_rollup_proof_check "incorrect kind proof") + in + let*! is_valid = PVM.verify_origination_proof PVM.proof boot_sector in + let* () = + fail_when + (not is_valid) + (Sc_rollup_proof_repr.Sc_rollup_proof_check "invalid origination proof") + in + match PVM.(proof_stop_state proof) with + | Some genesis_hash -> return genesis_hash + | None -> + fail + (Sc_rollup_proof_repr.Sc_rollup_proof_check + "invalid origination proof: cannot compute genesis hash") + +let originate ctxt ~kind ~boot_sector ~origination_proof ~parameters_ty = let open Lwt_tzresult_syntax in let*? ctxt = let open Tzresult_syntax in @@ -180,10 +207,23 @@ let originate ctxt ~kind ~boot_sector ~parameters_ty = in validate_untyped_parameters_ty ctxt parameters_ty in - let+ address, size, ctxt = - Sc_rollup.originate ctxt ~kind ~boot_sector ~parameters_ty + let* genesis_hash = + check_origination_proof kind boot_sector origination_proof + in + let genesis_commitment = + Sc_rollup.Commitment.genesis_commitment + ~genesis_state_hash:genesis_hash + ~origination_level:(Level.current ctxt).level + in + let+ address, size, genesis_commitment_hash, ctxt = + Sc_rollup.originate + ctxt + ~kind + ~boot_sector + ~parameters_ty + ~genesis_commitment in - ({address; size}, ctxt) + ({address; size; genesis_commitment_hash}, ctxt) let to_transaction_operation ctxt ~source (Sc_rollup_management_protocol.Transaction diff --git a/src/proto_alpha/lib_protocol/sc_rollup_operations.mli b/src/proto_alpha/lib_protocol/sc_rollup_operations.mli index 7eb6c5afea885331529f29b72d8a3db0832685de..319210109fda864d87a7eb841f43db02b4958465 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_operations.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_operations.mli @@ -38,15 +38,36 @@ type execute_outbox_message_result = { operations : Script_typed_ir.packed_internal_operation list; } -type origination_result = {address : Sc_rollup.Address.t; size : Z.t} +type origination_result = { + address : Sc_rollup.Address.t; + size : Z.t; + genesis_commitment_hash : Sc_rollup.Commitment.Hash.t; +} + +(** [originate context ~kind ~boot_sector ~origination_proof + ~parameters_ty] adds a new rollup running in a given [kind] + initialized with a [boot_sector] and to accept smart contract + calls of type [parameters_ty]. + + [origination_proof], which covers the specialization of the PVM + initial state with the [boot_sector], is used by the protocol to + compute the genesis commitment, after its correctness has been + checked. + + {b Note:} The need to provide an [origination_proof] is motivated + by technical limitations of Irmin (as of June, 2022), that + requires a context to get an empty tree. As soon as this + limitation is lifted, then we can drop the [origination_proof] + argument. -(** [originate context ~kind ~boot_sector ~parameters_ty] adds a new rollup - running in a given [kind], initialized with a [boot_sector], and whose - expected signature/interface is [parameters_ty]. *) + Returns an error if [origination_proof] is invalid ({i e.g.}, it + does not target the expected PVM). +*) val originate : context -> kind:Sc_rollup.Kind.t -> boot_sector:string -> + origination_proof:Sc_rollup.wrapped_proof -> parameters_ty:Script_repr.lazy_expr -> (origination_result * context) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml index 85fe421af9e4591a61b9c6c59c64164770e6fe29..a114fc9fb5f56edc2a434bfb9783996ccc8122c7 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml @@ -61,6 +61,17 @@ let cut_at_level level input = type error += Sc_rollup_proof_check of string +let () = + register_error_kind + `Permanent + ~id:"Sc_rollup_proof_check" + ~title:"Invalid proof" + ~description:"An invalid proof has been submitted" + ~pp:(fun fmt msg -> Format.fprintf fmt "Invalid proof: %s" msg) + Data_encoding.(obj1 @@ req "reason" string) + (function Sc_rollup_proof_check msg -> Some msg | _ -> None) + (fun msg -> Sc_rollup_proof_check msg) + let proof_error reason = let open Lwt_tzresult_syntax in fail (Sc_rollup_proof_check reason) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli index 2abb1f91753e4683604211c42d4f25ea597be44a..06e271dd67a759435458d45b8bb6e4acf3623ccf 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli @@ -62,6 +62,8 @@ type t = { inbox : Sc_rollup_inbox_repr.proof option; } +type error += Sc_rollup_proof_check of string + val encoding : t Data_encoding.t val pp : Format.formatter -> t -> unit diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml index 3181cbfd570ae61e3ab909ac8fb00da208178179..c33418510602a76bf37202b6d8f8eaa61caa3d0e 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml @@ -209,17 +209,31 @@ module Index = struct let compare = Address.compare end -module Number_of_messages = Bounded.Int32.Make (struct - let min_int = 0l +module Number_of_messages = struct + include Bounded.Int32.Make (struct + let min_int = 0l + + let max_int = 4096l + (* TODO: check this is reasonable. + See https://gitlab.com/tezos/tezos/-/issues/2373 + *) + end) + + let zero = + match of_int32 0l with + | Some zero -> zero + | None -> assert false (* unreachable case, since [min_int = 0l] *) +end - let max_int = 4096l - (* TODO: check this is reasonable. - See https://gitlab.com/tezos/tezos/-/issues/2373 - *) -end) +module Number_of_ticks = struct + include Bounded.Int32.Make (struct + let min_int = 0l -module Number_of_ticks = Bounded.Int32.Make (struct - let min_int = 0l + let max_int = Int32.max_int + end) - let max_int = Int32.max_int -end) + let zero = + match of_int32 0l with + | Some zero -> zero + | None -> assert false (* unreachable case, since [min_int = 0l] *) +end diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_repr.mli index 88722d89d342e77b9dd347648bf60c26ee45d105..54822fd22e3dba9d1f62728384417cc4daba9d83 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.mli @@ -82,14 +82,22 @@ end dispute. See also {!Commitment_repr.}. *) -module Number_of_messages : Bounded.Int32.S +module Number_of_messages : sig + include Bounded.Int32.S + + val zero : t +end (** Number of ticks computed by a single commitment. This represents a claim about the state of the PVM, which can be disputed as part of a commitment dispute. See also {!Commitment_repr.}. *) -module Number_of_ticks : Bounded.Int32.S +module Number_of_ticks : sig + include Bounded.Int32.S + + val zero : t +end (** A smart contract rollup is identified by its address. *) type t = Address.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_stake_storage.ml b/src/proto_alpha/lib_protocol/sc_rollup_stake_storage.ml index 129b2f8d8c7a87c1b8c27445b5de3d1aa81bbcd7..54b3b33d0720afdc78ee109ec994d45c72e315e7 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_stake_storage.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_stake_storage.ml @@ -117,16 +117,8 @@ let withdraw_stake ctxt rollup staker = let assert_commitment_not_too_far_ahead ctxt rollup lcc commitment = let open Lwt_tzresult_syntax in - let* ctxt, min_level = - if Commitment_hash.(lcc = zero) then - let* level = Store.Initial_level.get ctxt rollup in - return (ctxt, level) - else - let* lcc, ctxt = - Commitment_storage.get_commitment_unsafe ctxt rollup lcc - in - return (ctxt, Commitment.(lcc.inbox_level)) - in + let* lcc, ctxt = Commitment_storage.get_commitment_unsafe ctxt rollup lcc in + let min_level = Commitment.(lcc.inbox_level) in let max_level = Commitment.(commitment.inbox_level) in let* () = fail_when @@ -145,16 +137,10 @@ let assert_commitment_not_too_far_ahead ctxt rollup lcc commitment = let assert_commitment_period ctxt rollup commitment = let open Lwt_tzresult_syntax in let pred_hash = Commitment.(commitment.predecessor) in - let* ctxt, pred_level = - if Commitment_hash.(pred_hash = zero) then - let* level = Store.Initial_level.get ctxt rollup in - return (ctxt, level) - else - let* pred, ctxt = - Commitment_storage.get_commitment_unsafe ctxt rollup pred_hash - in - return (ctxt, Commitment.(pred.inbox_level)) + let* pred, ctxt = + Commitment_storage.get_commitment_unsafe ctxt rollup pred_hash in + let pred_level = Commitment.(pred.inbox_level) in (* We want to check the following inequalities on [commitment.inbox_level], [commitment.predecessor.inbox_level] and the constant [sc_rollup_commitment_period]. diff --git a/src/proto_alpha/lib_protocol/sc_rollup_storage.ml b/src/proto_alpha/lib_protocol/sc_rollup_storage.ml index a18abfafbea6fe66a95affdc87c54d9a61af96b7..87d067fc2657c99bb8bffb842bf473e535022536 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_storage.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_storage.ml @@ -29,21 +29,61 @@ module Store = Storage.Sc_rollup module Commitment = Sc_rollup_commitment_repr module Commitment_hash = Commitment.Hash -let originate ctxt ~kind ~boot_sector ~parameters_ty = - Raw_context.increment_origination_nonce ctxt >>?= fun (ctxt, nonce) -> +let originate ctxt ~kind ~boot_sector ~parameters_ty ~genesis_commitment = + let open Lwt_tzresult_syntax in + let genesis_commitment_hash = + Sc_rollup_commitment_repr.hash genesis_commitment + in + let*? ctxt, nonce = Raw_context.increment_origination_nonce ctxt in let level = Raw_context.current_level ctxt in - Sc_rollup_repr.Address.from_nonce nonce >>?= fun address -> - Store.PVM_kind.add ctxt address kind >>= fun ctxt -> - Store.Initial_level.add ctxt address level.level >>= fun ctxt -> - Store.Boot_sector.add ctxt address boot_sector >>= fun ctxt -> - Store.Parameters_type.add ctxt address parameters_ty - >>=? fun (ctxt, param_ty_size_diff, _added) -> - Sc_rollup_inbox_repr.empty (Raw_context.recover ctxt) address level.level - >>= fun inbox -> - Store.Inbox.init ctxt address inbox >>=? fun (ctxt, inbox_size_diff) -> - Store.Last_cemented_commitment.init ctxt address Commitment_hash.zero - >>=? fun (ctxt, lcc_size_diff) -> - Store.Staker_count.init ctxt address 0l >>=? fun (ctxt, stakers_size_diff) -> + let*? address = Sc_rollup_repr.Address.from_nonce nonce in + let*! ctxt = Store.PVM_kind.add ctxt address kind in + let*! ctxt = + Store.Genesis_info.add + ctxt + address + {commitment_hash = genesis_commitment_hash; level = level.level} + in + let*! ctxt = Store.Boot_sector.add ctxt address boot_sector in + let* ctxt, param_ty_size_diff, _added = + Store.Parameters_type.add ctxt address parameters_ty + in + let*! inbox = + Sc_rollup_inbox_repr.empty (Raw_context.recover ctxt) address level.level + in + let* ctxt, inbox_size_diff = Store.Inbox.init ctxt address inbox in + let* ctxt, lcc_size_diff = + Store.Last_cemented_commitment.init ctxt address genesis_commitment_hash + in + let* ctxt, commitment_size_diff, _was_bound = + Store.Commitments.add + (ctxt, address) + genesis_commitment_hash + genesis_commitment + in + (* This store [Store.Commitment_added] is going to be used to look this + bootstrap commitment. This commitment is added here so the + [sc_rollup_state_storage.deallocate] function does not have to handle a + edge case. *) + let* ctxt, commitment_added_size_diff, _commitment_existed = + Store.Commitment_added.add + (ctxt, address) + genesis_commitment_hash + level.level + in + (* This store [Store.Commitment_added] is going to be used to look this + bootstrap commitment. This commitment is added here so the + [sc_rollup_state_storage.deallocate] function does not have to handle a + edge case. + + There is no staker for the genesis_commitment. *) + let* ctxt, commitment_staker_count_size_diff, _commitment_staker_existed = + Store.Commitment_stake_count.add + (ctxt, address) + genesis_commitment_hash + Int32.zero + in + let* ctxt, stakers_size_diff = Store.Staker_count.init ctxt address 0l in let addresses_size = 2 * Sc_rollup_repr.Address.size in let stored_kind_size = 2 (* because tag_size of kind encoding is 16bits. *) in let boot_sector_size = @@ -53,10 +93,11 @@ let originate ctxt ~kind ~boot_sector ~parameters_ty = let size = Z.of_int (origination_size + stored_kind_size + boot_sector_size + addresses_size - + inbox_size_diff + lcc_size_diff + stakers_size_diff + param_ty_size_diff - ) + + inbox_size_diff + lcc_size_diff + commitment_size_diff + + commitment_added_size_diff + commitment_staker_count_size_diff + + stakers_size_diff + param_ty_size_diff) in - return (address, size, ctxt) + return (address, size, genesis_commitment_hash, ctxt) let kind ctxt address = let open Lwt_tzresult_syntax in @@ -65,14 +106,17 @@ let kind ctxt address = | Some k -> return k | None -> fail (Sc_rollup_errors.Sc_rollup_does_not_exist address) -let list ctxt = Store.PVM_kind.keys ctxt >|= Result.return +let list ctxt = + let open Lwt_syntax in + let+ res = Store.PVM_kind.keys ctxt in + Result.return res -let initial_level ctxt rollup = +let genesis_info ctxt rollup = let open Lwt_tzresult_syntax in - let* level = Store.Initial_level.find ctxt rollup in - match level with + let* genesis_info = Store.Genesis_info.find ctxt rollup in + match genesis_info with | None -> fail (Sc_rollup_does_not_exist rollup) - | Some level -> return level + | Some genesis_info -> return genesis_info let get_boot_sector ctxt rollup = let open Lwt_tzresult_syntax in @@ -152,7 +196,7 @@ module Dal_slot = struct let open Lwt_tzresult_syntax in let* _slot_index = fail_if_slot_index_invalid ctxt slot_index in (* Check if the rollup exists by looking for the initial level *) - let* _initial_level = initial_level ctxt rollup in + let* _initial_level = genesis_info ctxt rollup in let {Level_repr.level; _} = Raw_context.current_level ctxt in let* subscribed_slots = subscribed_slots_at_level ctxt rollup level in let*? slot_already_subscribed = @@ -189,7 +233,7 @@ module Dal_slot = struct in let open Lwt_tzresult_syntax in (* Check if the rollup exists by looking for the initial level *) - let* _initial_level = initial_level ctxt rollup in + let* _initial_level = genesis_info ctxt rollup in let* subscribed_slots = subscribed_slots_at_level ctxt rollup level in let*? result = to_dal_slot_index_list subscribed_slots in return result diff --git a/src/proto_alpha/lib_protocol/sc_rollup_storage.mli b/src/proto_alpha/lib_protocol/sc_rollup_storage.mli index 31a2d37d123076304d3ee6eecf3a2f86b7443533..b1c16dbb21c208e6df9c752c565bd1ee6e5fe95d 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_storage.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_storage.mli @@ -36,7 +36,13 @@ val originate : kind:Sc_rollups.Kind.t -> boot_sector:string -> parameters_ty:Script_repr.lazy_expr -> - (Sc_rollup_repr.Address.t * Z.t * Raw_context.t) tzresult Lwt.t + genesis_commitment:Sc_rollup_commitment_repr.t -> + (Sc_rollup_repr.Address.t + * Z.t + * Sc_rollup_commitment_repr.Hash.t + * Raw_context.t) + tzresult + Lwt.t (** [kind context address] returns the kind of the given rollup [address] iff [address] is an existing rollup. Fails with an [Sc_rollup_does_not_exist] @@ -45,10 +51,12 @@ val kind : Raw_context.t -> Sc_rollup_repr.t -> Sc_rollups.Kind.t tzresult Lwt.t val list : Raw_context.t -> Sc_rollup_repr.t list tzresult Lwt.t -(** [initial_level ctxt sc_rollup] returns the level at which a [sc_rollup] was - originated. *) -val initial_level : - Raw_context.t -> Sc_rollup_repr.t -> Raw_level_repr.t tzresult Lwt.t +(** [genesis_info ctxt sc_rollup] returns the level at which a [sc_rollup] was + originated, and its genesis commitment hash. *) +val genesis_info : + Raw_context.t -> + Sc_rollup_repr.t -> + Sc_rollup_commitment_repr.genesis_info tzresult Lwt.t (** [get_boot_sector ctxt sc_rollup] retrieves the boot sector for [sc_rollup]. *) val get_boot_sector : Raw_context.t -> Sc_rollup_repr.t -> string tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index 18b844d3df65831757ad16c1d91bb7dece2cf1bf..bbdf77cc7ce5a3288f25d04ba3dffd2f75037449 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -25,6 +25,33 @@ (*****************************************************************************) module V2_0_0 = struct + (* + This is the state hash of reference that both the prover of the + node and the verifier of the protocol {!ProtocolImplementation} + have to agree on (if they do, it means they are using the same + tree structure). + + We have to hard-code this value because the Wasm PVM uses Irmin as + its Merkle proof verification backend, and the economic protocol + cannot create an empty Irmin context. Such a context is required to + create an empty tree, itself required to create the initial state of + the Wasm PVM. + + Utlimately, the value of this constant is decided by the prover of + reference (the only need is for it to be compatible with + {!ProtocolImplementation}.) + + Its value is the result of the following snippet + + {| + let*! state = Prover.initial_state context in + Prover.state_hash state + |} + *) + let reference_initial_state_hash = + Sc_rollup_repr.State_hash.of_b58check_exn + "scs11pDQTn37TBnWgQAiCPdMAcQPiXARjg9ZZVmLx26sZwxeSxovE5" + open Sc_rollup_repr module PS = Sc_rollup_PVM_sem @@ -177,22 +204,18 @@ module V2_0_0 = struct open Monad - let initial_state ctxt boot_sector = + let initial_state ctxt = let open Lwt_syntax in let state = Tree.empty ctxt in let* state = Tree.add state ["wasm-version"] (Bytes.of_string "2.0.0") in - let* state = - Tree.add state ["boot-sector"] (Bytes.of_string boot_sector) - in Lwt.return state + let install_boot_sector state boot_sector = + Tree.add state ["boot-sector"] (Bytes.of_string boot_sector) + let state_hash state = - let m = - return @@ State_hash.context_hash_to_state_hash (Tree.hash state) - in - let open Lwt_syntax in - let* state = Monad.run m state in - match state with _, hash -> return hash + let context_hash = Tree.hash state in + Lwt.return @@ State_hash.context_hash_to_state_hash context_hash let result_of m state = let open Lwt_syntax in @@ -311,6 +334,32 @@ module V2_0_0 = struct return {tree_proof; given = input_given; requested} | None -> fail WASM_proof_production_failed + let verify_origination_proof proof boot_sector = + let open Lwt_syntax in + let before = Context.proof_before proof.tree_proof in + if State_hash.(before <> reference_initial_state_hash) then return false + else + let* result = + Context.verify_proof proof.tree_proof (fun state -> + let* state = install_boot_sector state boot_sector in + return (state, ())) + in + match result with None -> return false | Some (_, ()) -> return true + + let produce_origination_proof context boot_sector = + let open Lwt_result_syntax in + let*! state = initial_state context in + let*! result = + Context.produce_proof context state (fun state -> + let open Lwt_syntax in + let* state = install_boot_sector state boot_sector in + return (state, ())) + in + match result with + | Some (tree_proof, ()) -> + return {tree_proof; given = None; requested = No_input_required} + | None -> fail WASM_proof_production_failed + type output_proof = { output_proof : Context.proof; output_proof_state : hash; diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli index cdd9b1f83cc2473301ac3d6e132e3154222e5195..5fc1f7d26a084972d7461163409311043f9042ad 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli @@ -101,4 +101,10 @@ module V2_0_0 : sig with type context = Context.t and type state = Context.tree and type proof = Context.Proof.tree Context.Proof.t proof + + (** This is the state hash of reference that both the prover of the + node and the verifier of the protocol {!ProtocolImplementation} + have to agree on (if they do, it means they are using the same + tree structure). *) + val reference_initial_state_hash : Sc_rollup_repr.State_hash.t end diff --git a/src/proto_alpha/lib_protocol/sc_rollups.ml b/src/proto_alpha/lib_protocol/sc_rollups.ml index f8dc13c41824c8167dfe47b44186ca2d110e484c..69d3a3adf66bea246c8dd23fe7c58bcdfd319189 100644 --- a/src/proto_alpha/lib_protocol/sc_rollups.ml +++ b/src/proto_alpha/lib_protocol/sc_rollups.ml @@ -148,6 +148,12 @@ let wrapped_proof_module p = include P end : PVM_with_proof) +let wrapped_proof_kind_exn : wrapped_proof -> Kind.t = function + | Unencodable _ -> + raise (Invalid_argument "wrapped_proof_kind_exn: Unencodable") + | Arith_pvm_with_proof _ -> Kind.Example_arith + | Wasm_2_0_0_pvm_with_proof _ -> Kind.Wasm_2_0_0 + let wrapped_proof_encoding = let open Data_encoding in let encoding = diff --git a/src/proto_alpha/lib_protocol/sc_rollups.mli b/src/proto_alpha/lib_protocol/sc_rollups.mli index 81ec833da0ab9a2c24de9c31fdae6993452e374c..373bb8a9059346585d3c600aefe75053e85a63a1 100644 --- a/src/proto_alpha/lib_protocol/sc_rollups.mli +++ b/src/proto_alpha/lib_protocol/sc_rollups.mli @@ -108,6 +108,12 @@ val wrapped_proof_module : wrapped_proof -> (module PVM_with_proof) val wrapped_proof_encoding : wrapped_proof Data_encoding.t +(** [wrapped_proof_kind_exn p] returns the kind of the PVM capable of + interpreting [p]. Raises {!Invalid_argument} iff [p] is an + {!Unencodable} proof (which cannot happen if [p] is constructed by + [wrapped_proof_encoding]). *) +val wrapped_proof_kind_exn : wrapped_proof -> Kind.t + (** Wrap a PVM module with proof into a [wrapped_proof]. This matches on the [name] in the module---if that is recognisable as a [Kind], this function will encode and decode to coerce the proof to a proof in diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 8fa50071d3eb6e57bab5030811302de16ce40d1a..68b2e06da7600d7120a1a345f024d124d47a6ccc 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -1623,15 +1623,15 @@ module Sc_rollup = struct let encoding = Script_repr.lazy_expr_encoding end) - module Initial_level = + module Genesis_info = Indexed_context.Make_map (struct - let name = ["initial_level"] + let name = ["genesis_info"] end) (struct - type t = Raw_level_repr.t + type t = Sc_rollup_commitment_repr.genesis_info - let encoding = Raw_level_repr.encoding + let encoding = Sc_rollup_commitment_repr.genesis_info_encoding end) module Inbox_versioned = diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index 46ebdad44d5f5364f5a614bf373e8acda044d9bf..717c6818ab2d7c559eb3c495feac6c615cf62e98 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -715,10 +715,10 @@ module Sc_rollup : sig and type value = Script_repr.lazy_expr and type t := Raw_context.t - module Initial_level : + module Genesis_info : Indexed_data_storage with type key = Sc_rollup_repr.t - and type value = Raw_level_repr.t + and type value = Sc_rollup_commitment_repr.genesis_info and type t := Raw_context.t module Inbox : diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index be21de4af4f215fd2c79338c3e10927b91efc27e..fe5a94cc60e62cd346e1bdb01e9200ce019b981d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -374,6 +374,16 @@ module Sc_rollup = struct sc_rollup () () + + let commitment ctxt sc_rollup hash = + Environment.RPC_context.make_call2 + Plugin.RPC.Sc_rollup.S.commitment + rpc_ctxt + ctxt + sc_rollup + hash + () + () end type (_, _) tup = diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 9e796caed477cc1c17be2e51af23023486bda1c2..0f589b66ae622445f18830593f7794759eb56bcc 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -215,6 +215,12 @@ end module Sc_rollup : sig val inbox : t -> Sc_rollup.t -> Sc_rollup.Inbox.t tzresult Lwt.t + + val commitment : + t -> + Sc_rollup.t -> + Sc_rollup.Commitment.Hash.t -> + Sc_rollup.Commitment.t tzresult Lwt.t end type (_, _) tup = diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index 051501b69fc5c0a30776acd33cda889bb85be429..b06aa3c76c1ad4244e2a6c0bca4f2150a13e3e4d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -779,7 +779,11 @@ let originated_sc_rollup op = Sc_rollup.Internal_for_tests.originated_sc_rollup nonce let sc_rollup_origination ?force_reveal ?counter ?fee ?gas_limit ?storage_limit - ctxt (src : Contract.t) kind boot_sector parameters_ty = + ?origination_proof ctxt (src : Contract.t) kind boot_sector parameters_ty = + (match origination_proof with + | None -> Sc_rollup_helpers.origination_proof ~boot_sector kind + | Some origination_proof -> Lwt.return origination_proof) + >>= fun origination_proof -> manager_operation ?force_reveal ?counter @@ -788,7 +792,7 @@ let sc_rollup_origination ?force_reveal ?counter ?fee ?gas_limit ?storage_limit ?storage_limit ~source:src ctxt - (Sc_rollup_originate {kind; boot_sector; parameters_ty}) + (Sc_rollup_originate {kind; boot_sector; origination_proof; parameters_ty}) >>=? fun to_sign_op -> Context.Contract.manager ctxt src >|=? fun account -> let op = sign account.sk ctxt to_sign_op in diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.mli b/src/proto_alpha/lib_protocol/test/helpers/op.mli index cf6badaa56d0f5bc037db87678a92de9a87e80d9..951547cd2ab9595a04c08e9d0b40bbdd72c021fd 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/op.mli @@ -520,6 +520,7 @@ val sc_rollup_origination : ?fee:Tez.t -> ?gas_limit:gas_limit -> ?storage_limit:counter -> + ?origination_proof:Sc_rollup.wrapped_proof -> Context.t -> Contract.t -> Sc_rollup.Kind.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 f006848927b906dde103ca1fc469d3cc88dd7fb7..0f40744132e76f724b1a37eb213020d76d1f06c3 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 @@ -32,17 +32,141 @@ let originated_rollup op = in Contract.Internal_for_tests.originated_contract nonce -(** Returns a block in which a rollup originated. *) -let originate_rollup src b baker kind boot_sector parameters_ty = - Op.sc_rollup_origination - (B b) - src - ~fee:(Test_tez.of_int 10) - kind - boot_sector - parameters_ty - >>=? fun (operation, _) -> - Incremental.begin_construction ~policy:Block.(By_account baker) b - >>=? fun incr -> - Incremental.add_operation incr operation >>=? fun incr -> - Incremental.finalize_block incr >|=? fun b -> b +module In_memory_context = struct + open Tezos_context_memory + + module Tree = struct + include Context.Tree + + type tree = Context.tree + + type t = Context.t + + type key = string list + + type value = bytes + end + + type tree = Tree.tree + + type proof = Context.Proof.tree Context.Proof.t + + let hash_tree _ = assert false + + let verify_proof p f = + Lwt.map Result.to_option (Context.verify_tree_proof p f) + + let produce_proof context state step = + let open Lwt_syntax in + let* context = Context.add_tree context [] state in + let* h = Context.commit ~time:Time.Protocol.epoch context in + let index = Context.index context in + let* context = Context.checkout_exn index h in + match Tree.kinded_key state with + | Some k -> + let index = Context.index context in + let* p = Context.produce_tree_proof index k step in + return (Some p) + | None -> return None + + let kinded_hash_to_state_hash = function + | `Value hash | `Node hash -> + Sc_rollup.State_hash.context_hash_to_state_hash hash + + let proof_before proof = kinded_hash_to_state_hash proof.Context.Proof.before + + let proof_after proof = kinded_hash_to_state_hash proof.Context.Proof.after + + let proof_encoding = + Tezos_context_helpers.Merkle_proof_encoding.V1.Tree32.tree_proof_encoding +end + +module Arith_pvm : + Sc_rollup.PVM.S + with type context = In_memory_context.Tree.t + and type state = In_memory_context.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t + Sc_rollup.ArithPVM.proof = + Sc_rollup.ArithPVM.Make (In_memory_context) + +module Wasm_pvm : + Sc_rollup.PVM.S + with type context = In_memory_context.Tree.t + and type state = In_memory_context.tree + and type proof = + Tezos_context_memory.Context.Proof.tree + Tezos_context_memory.Context.Proof.t + Sc_rollup.Wasm_2_0_0PVM.proof = + Sc_rollup.Wasm_2_0_0PVM.Make (In_memory_context) + +let origination_proof ~boot_sector = function + | Sc_rollup.Kind.Example_arith -> + let open Lwt_syntax in + let context = Tezos_context_memory.make_empty_context () in + let* proof = Arith_pvm.produce_origination_proof context boot_sector in + let proof = WithExceptions.Result.get_ok ~loc:__LOC__ proof in + return + (Sc_rollup.Arith_pvm_with_proof + (module struct + include Arith_pvm + + let proof = proof + end)) + | Sc_rollup.Kind.Wasm_2_0_0 -> + let open Lwt_syntax in + let context = Tezos_context_memory.make_empty_context () in + let* proof = Wasm_pvm.produce_origination_proof context boot_sector in + let proof = WithExceptions.Result.get_ok ~loc:__LOC__ proof in + return + (Sc_rollup.Wasm_2_0_0_pvm_with_proof + (module struct + include Wasm_pvm + + let proof = proof + end)) + +let genesis_commitment ~boot_sector ~origination_level = function + | Sc_rollup.Kind.Example_arith -> + let open Lwt_syntax in + let context = Tezos_context_memory.make_empty_context () in + let* proof = Arith_pvm.produce_origination_proof context boot_sector in + let proof = WithExceptions.Result.get_ok ~loc:__LOC__ proof in + let genesis_state_hash = + WithExceptions.Option.get ~loc:__LOC__ + @@ Arith_pvm.proof_stop_state proof + in + return + Sc_rollup.Commitment.( + genesis_commitment ~origination_level ~genesis_state_hash) + | Sc_rollup.Kind.Wasm_2_0_0 -> + let open Lwt_syntax in + let context = Tezos_context_memory.make_empty_context () in + let* proof = Wasm_pvm.produce_origination_proof context boot_sector in + let proof = WithExceptions.Result.get_ok ~loc:__LOC__ proof in + let genesis_state_hash = + WithExceptions.Option.get ~loc:__LOC__ + @@ Wasm_pvm.proof_stop_state proof + in + return + Sc_rollup.Commitment.( + genesis_commitment ~origination_level ~genesis_state_hash) + +let genesis_commitment_raw ~boot_sector ~origination_level kind = + let open Lwt_syntax in + let origination_level = + Raw_level_repr.to_int32 origination_level + |> Alpha_context.Raw_level.of_int32_exn + in + let kind = + match kind with + | Sc_rollups.Kind.Example_arith -> Sc_rollup.Kind.Example_arith + | Sc_rollups.Kind.Wasm_2_0_0 -> Sc_rollup.Kind.Wasm_2_0_0 + in + let* res = genesis_commitment ~boot_sector ~origination_level kind in + let res = + Data_encoding.Binary.to_bytes_exn Sc_rollup.Commitment.encoding res + |> Data_encoding.Binary.of_bytes_exn Sc_rollup_commitment_repr.encoding + in + return res 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 c3286cc863d860ae9e537d144b20b9092e0e1c86..c4633205897baaa1322764e8ea8f0651a62a7929 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 @@ -131,14 +131,16 @@ let test_sc_rollups_all_well_defined () = all_names_are_valid () (** Initializes the context and originates a SCORU. *) -let sc_originate block contract parameters_ty = +let sc_originate ?(boot_sector = "") ?origination_proof block contract + parameters_ty = let kind = Sc_rollup.Kind.Example_arith in let* operation, rollup = Op.sc_rollup_origination + ?origination_proof (B block) contract kind - "" + boot_sector (Script.lazy_expr @@ Expr.from_string parameters_ty) in let* incr = Incremental.begin_construction block in @@ -147,12 +149,15 @@ let sc_originate block contract parameters_ty = return (block, rollup) (** Initializes the context and originates a SCORU. *) -let init_and_originate ?sc_rollup_challenge_window_in_blocks tup parameters_ty = +let init_and_originate ?boot_sector ?origination_proof + ?sc_rollup_challenge_window_in_blocks tup parameters_ty = let* block, contracts = context_init ?sc_rollup_challenge_window_in_blocks tup in let contract = Context.tup_hd tup contracts in - let* block, rollup = sc_originate block contract parameters_ty in + let* block, rollup = + sc_originate ?boot_sector ?origination_proof block contract parameters_ty + in return (block, contracts, rollup) let number_of_messages_exn n = @@ -167,10 +172,15 @@ let number_of_ticks_exn n = let dummy_commitment ctxt rollup = let ctxt = Incremental.alpha_ctxt ctxt in - let*! root_level = Sc_rollup.initial_level ctxt rollup in - let root_level = - match root_level with Ok v -> v | Error _ -> assert false + let* genesis_info = + Sc_rollup.genesis_info ctxt rollup >|= Environment.wrap_tzresult + in + let predecessor = genesis_info.commitment_hash in + let* {compressed_state; _}, ctxt = + Sc_rollup.Commitment.get_commitment ctxt rollup genesis_info.commitment_hash + >|= Environment.wrap_tzresult in + let root_level = genesis_info.level in let inbox_level = let commitment_freq = Constants_storage.sc_rollup_commitment_period_in_blocks @@ -182,11 +192,11 @@ let dummy_commitment ctxt rollup = return Sc_rollup.Commitment. { - predecessor = Sc_rollup.Commitment.Hash.zero; + predecessor; inbox_level; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 3000l; - compressed_state = Sc_rollup.State_hash.zero; + compressed_state; } (* Verify that parameters and unparsed parameters match. *) @@ -737,6 +747,48 @@ let test_originating_with_invalid_types () = (* Operation fails with a different error as it's not "passable". *) assert_fails ~loc:__LOC__ (sc_originate block contract "operation") +let test_originating_with_invalid_boot_sector_proof () = + let*! origination_proof = + Sc_rollup_helpers.origination_proof + ~boot_sector:"a boot sector" + Sc_rollup.Kind.Example_arith + in + let*! res = + init_and_originate + ~boot_sector:"another boot sector" + ~origination_proof + Context.T1 + "unit" + in + match res with + | Error + (Environment.Ecoproto_error (Sc_rollup.Proof.Sc_rollup_proof_check _ as e) + :: _) -> + Assert.test_error_encodings e ; + return_unit + | _ -> failwith "It should have failed with [Sc_rollup_proof_check]" + +let test_originating_with_invalid_kind_proof () = + let*! origination_proof = + Sc_rollup_helpers.origination_proof + ~boot_sector:"a boot sector" + Sc_rollup.Kind.Wasm_2_0_0 + in + let*! res = + init_and_originate + ~boot_sector:"a boot sector" + ~origination_proof + Context.T1 + "unit" + in + match res with + | Error + (Environment.Ecoproto_error (Sc_rollup.Proof.Sc_rollup_proof_check _ as e) + :: _) -> + Assert.test_error_encodings e ; + return_unit + | _ -> failwith "It should have failed with [Sc_rollup_proof_check]" + let assert_equal_expr ~loc e1 e2 = let s1 = Format.asprintf "%a" Michelson_v1_printer.print_expr e1 in let s2 = Format.asprintf "%a" Michelson_v1_printer.print_expr e2 in @@ -1369,6 +1421,14 @@ let tests = "originating with invalid types" `Quick test_originating_with_invalid_types; + Tztest.tztest + "originating with invalid boot sector proof" + `Quick + test_originating_with_invalid_boot_sector_proof; + Tztest.tztest + "originating with invalid kind proof" + `Quick + test_originating_with_invalid_kind_proof; Tztest.tztest "originating with valid type" `Quick diff --git a/src/proto_alpha/lib_protocol/test/integration/test_sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/test/integration/test_sc_rollup_wasm.ml index 31a3c14115dbe349bf4ac3f0ff4ddd5edb07440e..4c250a82041c46f33d69c042af005eaf28ef2c6d 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_sc_rollup_wasm.ml @@ -113,7 +113,8 @@ let should_boot () = let open Lwt_result_syntax in let*! index = Context_binary.init "/tmp" in let context = Context_binary.empty index in - let*! s = Prover.initial_state context "" in + let*! s = Prover.initial_state context in + let*! s = Prover.install_boot_sector s "" in let*! s = Prover.eval s in let*! p_res = Prover.produce_proof context None s in match p_res with diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_refutation_game.ml b/src/proto_alpha/lib_protocol/test/pbt/test_refutation_game.ml index eaf8eaae9efd602fe52c561094501e271977e11d..f96dd2e1b94c5165073f5cac1c7f6de93bb5aba6 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_refutation_game.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_refutation_game.ml @@ -230,15 +230,18 @@ end) : TestPVM with type state = int = struct let proof_input_requested _ = No_input_required - let state_hash (x : state) = - return - (State_hash.context_hash_to_state_hash - @@ Context_hash.hash_string [Int.to_string x]) + let state_hash_ (x : state) = + State_hash.context_hash_to_state_hash + @@ Context_hash.hash_string [Int.to_string x] + + let state_hash (x : state) = return (state_hash_ x) let is_input_state x = if x >= P.target then return Initial else return No_input_required - let initial_state _ _ = return P.target + let initial_state _ = return 0 + + let install_boot_sector _ _ = return P.target let set_input _ s = return s @@ -262,6 +265,11 @@ end) : TestPVM with type state = int = struct let produce_proof _ _ _ = Stdlib.failwith "Dummy PVM can't produce proof" + let verify_origination_proof proof _ = return proof.valid + + let produce_origination_proof _ _ = + Stdlib.failwith "Dummy PVM can't produce proof" + type output_proof = unit let output_proof_encoding = Data_encoding.unit @@ -310,11 +318,15 @@ end) : TestPVM with type state = string * int list = struct let proof_input_requested _ = No_input_required - let state_hash (x : state) = - return @@ State_hash.context_hash_to_state_hash + let state_hash_ x = + State_hash.context_hash_to_state_hash @@ Context_hash.hash_string [to_string x] - let initial_state _ _ = return ("hello", P.initial_prog) + let state_hash (x : state) = return @@ state_hash_ x + + let initial_state _ = return ("", []) + + let install_boot_sector _ _ = return ("hello", P.initial_prog) let is_input_state (_, c) = match c with [] -> return Initial | _ -> return No_input_required @@ -349,6 +361,11 @@ end) : TestPVM with type state = string * int list = struct let produce_proof _ _ _ = Stdlib.failwith "Dummy PVM can't produce proof" + let verify_origination_proof proof _ = return proof.valid + + let produce_origination_proof _ _ = + Stdlib.failwith "Dummy PVM can't produce proof" + type output_proof = unit let output_proof_encoding = Data_encoding.unit @@ -426,7 +443,9 @@ end) : TestPVM = struct let default_state = let promise = - let* boot = initial_state init_context "" >>= eval in + let* boot = initial_state init_context in + let* boot = install_boot_sector boot "" in + let* boot = eval boot in let input = { inbox_level = Raw_level.root; @@ -459,7 +478,8 @@ end) : TestPVM = struct match proof_opt with Ok proof -> return proof | Error _ -> assert false let make_invalid_proof _ _ = - let* state = initial_state init_context "foooobaaar" in + let* state = initial_state init_context in + let* state = install_boot_sector state "foooobaaar" in let* proof_opt = produce_proof init_context None state in match proof_opt with Ok proof -> return proof | Error _ -> assert false end diff --git a/src/proto_alpha/lib_protocol/test/unit/main.ml b/src/proto_alpha/lib_protocol/test/unit/main.ml index b99d723fcd8cca9fdcd10fc23d9e773e45d2650f..7f2c2362427418624599040fef323c970b3fa179 100644 --- a/src/proto_alpha/lib_protocol/test/unit/main.ml +++ b/src/proto_alpha/lib_protocol/test/unit/main.ml @@ -73,6 +73,7 @@ let () = Unit_test.spec "tx rollup l2" Test_tx_rollup_l2.tests; Unit_test.spec "tx rollup l2 apply" Test_tx_rollup_l2_apply.tests; Unit_test.spec "liquidity baking" Test_liquidity_baking_repr.tests; + Unit_test.spec "sc rollup wasm" Test_sc_rollup_wasm.tests; Unit_test.spec "sc rollup arith" Test_sc_rollup_arith.tests; Unit_test.spec "merkle list" Test_merkle_list.tests; Unit_test.spec "sc rollup inbox" Test_sc_rollup_inbox.tests; diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml index b8f9158ca0b6b2974a2f2634073368af72b1e110..ee0e39cc9e5757b970fff181aaca4f5b9ad9b835 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml @@ -106,7 +106,8 @@ let setup boot_sector f = let open Lwt_syntax in let* index = Context_binary.init "/tmp" in let ctxt = Context_binary.empty index in - let* state = initial_state ctxt boot_sector in + let* state = initial_state ctxt in + let* state = install_boot_sector state boot_sector in f ctxt state let pre_boot boot_sector f = @@ -426,6 +427,22 @@ let test_invalid_outbox_level () = ] |> List.iter_es (test_output_messages_proofs ~valid:false ~inbox_level) +let test_initial_state_hash_arith_pvm () = + let open Alpha_context in + let open Lwt_result_syntax in + let context = Tezos_context_memory.make_empty_context () in + let*! state = Sc_rollup_helpers.Arith_pvm.initial_state context in + let*! hash = Sc_rollup_helpers.Arith_pvm.state_hash state in + let expected = Sc_rollup.ArithPVM.reference_initial_state_hash in + if Sc_rollup.State_hash.(hash = expected) then return_unit + else + failwith + "incorrect hash, expected %a, got %a" + Sc_rollup.State_hash.pp + expected + Sc_rollup.State_hash.pp + hash + let tests = [ Tztest.tztest "PreBoot" `Quick test_preboot; @@ -436,4 +453,8 @@ let tests = Tztest.tztest "Valid output messages" `Quick test_valid_output_messages; Tztest.tztest "Invalid output messages" `Quick test_invalid_output_messages; Tztest.tztest "Invalid outbox level" `Quick test_invalid_outbox_level; + Tztest.tztest + "Initial state hash for Arith" + `Quick + test_initial_state_hash_arith_pvm; ] diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_game.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_game.ml index 2dfb5925b37d996f7037d6564f16a71ffb03cfba..94e9c511abd50b115827761e63db13c6f1beec96 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_game.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_game.ml @@ -93,7 +93,7 @@ let init_refutation ?size ?init_tick start_hash = } let two_stakers_in_conflict () = - let* ctxt, rollup, refuter, defender = + let* ctxt, rollup, genesis_hash, refuter, defender = T.originate_rollup_and_deposit_with_two_stakers () in let hash1 = hash_string "foo" in @@ -102,7 +102,7 @@ let two_stakers_in_conflict () = let parent_commit = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = T.valid_inbox_level ctxt 1l; number_of_messages = T.number_of_messages_exn 5l; number_of_ticks = T.number_of_ticks_exn 152231l; @@ -214,7 +214,7 @@ let test_single_valid_game_move () = [false] and then to [true]) in order to create the tests described above. *) let staker_injectivity_gen ~refuter2_plays = (* Create the defender and the two refuters. *) - let+ ctxt, rollup, refuter1, refuter2, defender = + let+ ctxt, rollup, genesis_hash, refuter1, refuter2, defender = T.originate_rollup_and_deposit_with_three_stakers () in let res = @@ -234,7 +234,7 @@ let staker_injectivity_gen ~refuter2_plays = let commit1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = T.valid_inbox_level ctxt 1l; number_of_messages = T.number_of_messages_exn 5l; number_of_ticks = T.number_of_ticks_exn 152231l; diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml index 3558afea81ad3c00dd143800b2f98bf4d121be39..6b010c74b61d4edbae15cfd2e6a0c3680fb4f500 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_storage.ml @@ -80,28 +80,37 @@ let new_context () = mint_tez_for ctxt "tz1Ke2h7sDdakHJQh8WX4Z372du1KChsksyU" let new_sc_rollup ctxt = - let+ rollup, _size, ctxt = + let+ rollup, _size, genesis_hash, ctxt = let {Michelson_v1_parser.expanded; _}, _ = Michelson_v1_parser.parse_expression "unit" in let parameters_ty = Alpha_context.Script.lazy_expr expanded in + let boot_sector = "" in + let kind = Sc_rollups.Kind.Example_arith in + let*! genesis_commitment = + Sc_rollup_helpers.genesis_commitment_raw + ~boot_sector + ~origination_level:(Raw_context.current_level ctxt).level + kind + in Sc_rollup_storage.originate ctxt - ~kind:Example_arith - ~boot_sector:"" + ~kind + ~boot_sector ~parameters_ty + ~genesis_commitment in - (rollup, ctxt) + (rollup, genesis_hash, ctxt) let new_context_with_stakers_and_rollup nb_stakers = let* ctxt, stakers = new_context_with_stakers nb_stakers in - let+ rollup, ctxt = lift @@ new_sc_rollup ctxt in - (ctxt, rollup, stakers) + let+ rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in + (ctxt, rollup, genesis_hash, stakers) let new_context_with_rollup () = let* ctxt = new_context () in - let+ rollup, ctxt = lift @@ new_sc_rollup ctxt in - (ctxt, rollup) + let+ rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in + (ctxt, rollup, genesis_hash) let equal_tez ~loc = Assert.equal ~loc Tez_repr.( = ) "Tez aren't equal" Tez_repr.pp @@ -149,28 +158,30 @@ let deposit_stake_and_check_balances ctxt rollup staker = (** Originate a rollup with [nb_stakers] stakers and make a deposit to the initial LCC. *) let originate_rollup_and_deposit_with_n_stakers nb_stakers = - let* ctxt, rollup, stakers = new_context_with_stakers_and_rollup nb_stakers in + let* ctxt, rollup, genesis_hash, stakers = + new_context_with_stakers_and_rollup nb_stakers + in let deposit ctxt staker = deposit_stake_and_check_balances ctxt rollup staker in let+ ctxt = List.fold_left_es deposit ctxt stakers in - (ctxt, rollup, stakers) + (ctxt, rollup, genesis_hash, stakers) (** Originate a rollup with one staker and make a deposit to the initial LCC. *) let originate_rollup_and_deposit_with_one_staker () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in let+ ctxt = deposit_stake_and_check_balances ctxt rollup staker in - (ctxt, rollup, staker) + (ctxt, rollup, genesis_hash, staker) (** Originate a rollup with two stakers and make a deposit to the initial LCC. *) let originate_rollup_and_deposit_with_two_stakers () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker1 = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -179,14 +190,17 @@ let originate_rollup_and_deposit_with_two_stakers () = in let* ctxt = deposit_stake_and_check_balances ctxt rollup staker1 in let+ ctxt = deposit_stake_and_check_balances ctxt rollup staker2 in - (ctxt, rollup, staker1, staker2) + (ctxt, rollup, genesis_hash, staker1, staker2) (** Originate a rollup with three stakers and make a deposit to the initial LCC. *) let originate_rollup_and_deposit_with_three_stakers () = - let+ ctxt, rollup, stakers = originate_rollup_and_deposit_with_n_stakers 3 in + let+ ctxt, rollup, genesis_hash, stakers = + originate_rollup_and_deposit_with_n_stakers 3 + in match stakers with - | [staker1; staker2; staker3] -> (ctxt, rollup, staker1, staker2, staker3) + | [staker1; staker2; staker3] -> + (ctxt, rollup, genesis_hash, staker1, staker2, staker3) | _ -> assert false (** Trivial assertion. @@ -242,8 +256,23 @@ let test_deposit_to_missing_rollup () = rollup Sc_rollup_repr.Staker.zero) +let test_last_cemented_commitment_hash_with_level_when_genesis () = + let* ctxt = new_context () in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in + let* c1, inbox_level, ctxt = + lift + @@ Sc_rollup_commitment_storage.last_cemented_commitment_hash_with_level + ctxt + rollup + in + let* () = assert_commitment_hash_equal ~loc:__LOC__ ctxt genesis_hash c1 in + Assert.equal_int32 + ~loc:__LOC__ + (Raw_level_repr.to_int32 (Raw_context.current_level ctxt).level) + (Raw_level_repr.to_int32 inbox_level) + let test_deposit_by_underfunded_staker () = - let* ctxt, sc_rollup = new_context_with_rollup () in + let* ctxt, sc_rollup, _genesis_hash = new_context_with_rollup () in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1hhNZvjed6McQQLWtR7MRzPHpgSFZTXxdW" in @@ -279,14 +308,14 @@ let test_deposit_by_underfunded_staker () = {staker; sc_rollup; staker_balance; min_expected_balance = stake}) let test_initial_state_is_pre_boot () = - let* ctxt, rollup = new_context_with_rollup () in + let* ctxt, rollup, genesis_hash = new_context_with_rollup () in let* lcc, ctxt = lift @@ Sc_rollup_commitment_storage.last_cemented_commitment ctxt rollup in - assert_commitment_hash_equal ~loc:__LOC__ ctxt lcc Commitment_repr.Hash.zero + assert_commitment_hash_equal ~loc:__LOC__ ctxt lcc genesis_hash let test_deposit_to_existing_rollup () = - let* ctxt, _rollup, _staker = + let* ctxt, _rollup, _genesis_hash, _staker = originate_rollup_and_deposit_with_one_staker () in assert_true ctxt @@ -314,7 +343,9 @@ let remove_staker_and_check_balances ctxt rollup staker = ctxt') let test_removing_staker_from_lcc_fails () = - let* ctxt, rollup, staker = originate_rollup_and_deposit_with_one_staker () in + let* ctxt, rollup, _genesis_hash, staker = + originate_rollup_and_deposit_with_one_staker () + in assert_fails_with ~loc:__LOC__ (Sc_rollup_stake_storage.remove_staker ctxt rollup staker) @@ -339,7 +370,7 @@ let withdraw_stake_and_check_balances ctxt rollup staker = let test_deposit_then_withdraw () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" @@ -357,7 +388,7 @@ let test_withdrawal_from_missing_rollup () = let test_withdraw_when_not_staked () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" @@ -369,7 +400,7 @@ let test_withdraw_when_not_staked () = let test_withdrawing_twice () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Signature.Public_key_hash.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" @@ -407,7 +438,7 @@ let valid_inbox_level ctxt = let test_deposit_then_refine () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -415,11 +446,12 @@ let test_deposit_then_refine () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; - compressed_state = Sc_rollup_repr.State_hash.zero; + compressed_state = + Sc_rollup_repr.State_hash.zero (* genesis.compressed_state; *); } in let* _node, _level, ctxt = @@ -434,7 +466,7 @@ let test_deposit_then_refine () = let test_deposit_then_refine_bad_inbox () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -442,7 +474,7 @@ let test_deposit_then_refine_bad_inbox () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = Raw_level_repr.of_int32_exn 22l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -461,7 +493,7 @@ let test_deposit_then_refine_bad_inbox () = let test_publish () = let* ctxt = new_context () in lift - @@ let* rollup, ctxt = new_sc_rollup ctxt in + @@ let* rollup, genesis_hash, ctxt = new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" @@ -469,7 +501,7 @@ let test_publish () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 5l; number_of_ticks = number_of_ticks_exn 152231l; @@ -482,13 +514,13 @@ let test_publish () = assert_true ctxt let test_publish_returns_oldest_publish_level () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 5l; number_of_ticks = number_of_ticks_exn 152231l; @@ -519,7 +551,7 @@ let test_publish_returns_oldest_publish_level () = (Raw_level_repr.to_int32 level2) let test_withdraw_and_cement () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let challenge_window = @@ -528,7 +560,7 @@ let test_withdraw_and_cement () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -551,14 +583,14 @@ let test_withdraw_and_cement () = assert_true ctxt let test_refine_commitment_different_stakers () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -594,14 +626,14 @@ let test_refine_commitment_different_stakers () = assert_true ctxt let test_refine_stake_twice_different_stakers () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -627,11 +659,13 @@ let test_refine_stake_twice_different_stakers () = assert_true ctxt let test_refine_stake_twice_same_staker () = - let* ctxt, rollup, staker = originate_rollup_and_deposit_with_one_staker () in + let* ctxt, rollup, genesis_hash, staker = + originate_rollup_and_deposit_with_one_staker () + in let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -657,7 +691,7 @@ let test_refine_stake_twice_same_staker () = let test_deposit_then_publish () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -665,7 +699,7 @@ let test_deposit_then_publish () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 5l; number_of_ticks = number_of_ticks_exn 152231l; @@ -704,7 +738,7 @@ let test_cement () = let challenge_window = Constants_storage.sc_rollup_challenge_window_in_blocks ctxt in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -712,7 +746,7 @@ let test_cement () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -741,7 +775,9 @@ let test_cement () = as we deallocate the old LCC when a new LCC is cemented. *) let test_cement_three_commitments () = - let* ctxt, rollup, staker = originate_rollup_and_deposit_with_one_staker () in + let* ctxt, rollup, genesis_hash, staker = + originate_rollup_and_deposit_with_one_staker () + in let level = valid_inbox_level ctxt in let challenge_window = Constants_storage.sc_rollup_challenge_window_in_blocks ctxt @@ -751,7 +787,7 @@ let test_cement_three_commitments () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -810,7 +846,7 @@ let test_cement_then_remove () = let challenge_window = Constants_storage.sc_rollup_challenge_window_in_blocks ctxt in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -818,7 +854,7 @@ let test_cement_then_remove () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -847,7 +883,7 @@ let test_cement_consumes_available_messages () = let challenge_window = Constants_storage.sc_rollup_challenge_window_in_blocks ctxt in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -865,7 +901,7 @@ let test_cement_consumes_available_messages () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 1l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -905,7 +941,7 @@ let test_cement_unknown_commitment_fails () = let challenge_window = Constants_storage.sc_rollup_challenge_window_in_blocks ctxt in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -924,7 +960,7 @@ let test_cement_with_zero_stakers_fails () = let challenge_window = Constants_storage.sc_rollup_challenge_window_in_blocks ctxt in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -932,7 +968,7 @@ let test_cement_with_zero_stakers_fails () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -960,7 +996,7 @@ let test_cement_fail_too_recent () = let challenge_window = Constants_storage.sc_rollup_challenge_window_in_blocks ctxt in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -968,7 +1004,7 @@ let test_cement_fail_too_recent () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1001,13 +1037,13 @@ let test_cement_fail_too_recent () = assert_true ctxt let test_cement_deadline_uses_oldest_add_time () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1045,7 +1081,7 @@ let test_last_cemented_commitment_hash_with_level () = let challenge_window = Constants_storage.sc_rollup_challenge_window_in_blocks ctxt in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -1054,7 +1090,7 @@ let test_last_cemented_commitment_hash_with_level () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1087,7 +1123,7 @@ let test_last_cemented_commitment_hash_with_level () = let test_withdrawal_fails_when_not_staked_on_lcc () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -1095,7 +1131,7 @@ let test_withdrawal_fails_when_not_staked_on_lcc () = let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1115,25 +1151,26 @@ let test_withdrawal_fails_when_not_staked_on_lcc () = (Sc_rollup_stake_storage.withdraw_stake ctxt rollup staker) Sc_rollup_errors.Sc_rollup_not_staked_on_lcc -let test_initial_level_of_rollup () = +let test_genesis_info_of_rollup () = let* ctxt = new_context () in let level_before_rollup = (Raw_context.current_level ctxt).level in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let ctxt = Raw_context.Internal_for_tests.add_level ctxt 10 in - let* initial_level = lift @@ Sc_rollup_storage.initial_level ctxt rollup in + let* genesis_info = lift @@ Sc_rollup_storage.genesis_info ctxt rollup in + let initial_level = genesis_info.level in Assert.equal_int32 ~loc:__LOC__ (Raw_level_repr.to_int32 level_before_rollup) (Raw_level_repr.to_int32 initial_level) let test_stake_on_existing_node () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1158,14 +1195,14 @@ let test_stake_on_existing_node () = assert_true ctxt let test_cement_with_two_stakers () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1208,14 +1245,14 @@ let test_cement_with_two_stakers () = assert_true ctxt let test_can_remove_staker () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1259,14 +1296,14 @@ let test_can_remove_staker () = assert_true ctxt let test_can_remove_staker2 () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1310,14 +1347,14 @@ let test_can_remove_staker2 () = assert_true ctxt let test_removed_staker_can_not_withdraw () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1359,14 +1396,14 @@ let test_removed_staker_can_not_withdraw () = Sc_rollup_errors.Sc_rollup_not_staked let test_no_cement_on_conflict () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1384,7 +1421,7 @@ let test_no_cement_on_conflict () = let commitment2 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 44l; @@ -1412,13 +1449,13 @@ let test_no_cement_on_conflict () = LCC <- [c1] *) let test_no_cement_with_one_staker_at_zero_commitment () = - let* ctxt, rollup, staker1, _staker2 = + let* ctxt, rollup, genesis_hash, staker1, _staker2 = originate_rollup_and_deposit_with_two_stakers () in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1443,14 +1480,14 @@ let test_no_cement_with_one_staker_at_zero_commitment () = Sc_rollup_errors.Sc_rollup_disputed let test_non_cemented_parent () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1493,14 +1530,14 @@ let test_non_cemented_parent () = Sc_rollup_errors.Sc_rollup_parent_not_lcc let test_finds_conflict_point_at_lcc () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1518,7 +1555,7 @@ let test_finds_conflict_point_at_lcc () = let commitment2 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 55l; @@ -1544,14 +1581,14 @@ let test_finds_conflict_point_at_lcc () = assert_commitment_hash_equal ~loc:__LOC__ ctxt left.hash c1 let test_finds_conflict_point_beneath_lcc () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1614,14 +1651,14 @@ let test_finds_conflict_point_beneath_lcc () = assert_commitment_hash_equal ~loc:__LOC__ ctxt right.hash c3 let test_conflict_point_is_first_point_of_disagreement () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1704,7 +1741,7 @@ let test_conflict_point_is_first_point_of_disagreement () = let test_conflict_point_computation_fits_in_gas_limit () = (* Worst case of conflict point computation: two branches of maximum length rooted just after the LCC. *) - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in @@ -1719,7 +1756,7 @@ let test_conflict_point_computation_fits_in_gas_limit () = let root_commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 1l; number_of_ticks = number_of_ticks_exn 1l; @@ -1798,13 +1835,13 @@ let test_conflict_point_computation_fits_in_gas_limit () = assert_commitment_hash_equal ~loc:__LOC__ ctxt right.hash branch_2.(0) let test_no_conflict_point_one_staker_at_lcc_preboot () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1829,7 +1866,7 @@ let test_no_conflict_point_one_staker_at_lcc_preboot () = Sc_rollup_errors.Sc_rollup_no_conflict let test_no_conflict_point_both_stakers_at_lcc_preboot () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, _genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in assert_fails_with @@ -1842,14 +1879,14 @@ let test_no_conflict_point_both_stakers_at_lcc_preboot () = Sc_rollup_errors.Sc_rollup_no_conflict let test_no_conflict_point_one_staker_at_lcc () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1899,13 +1936,13 @@ let test_no_conflict_point_one_staker_at_lcc () = Sc_rollup_errors.Sc_rollup_no_conflict let test_no_conflict_point_both_stakers_at_lcc () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1946,7 +1983,7 @@ let test_no_conflict_point_both_stakers_at_lcc () = let test_staker_cannot_backtrack () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let staker = Sc_rollup_repr.Staker.of_b58check_exn "tz1SdKt9kjPp1HRQFkBmXtBhgMfvdgFhSjmG" in @@ -1955,7 +1992,7 @@ let test_staker_cannot_backtrack () = let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -1998,14 +2035,14 @@ let test_staker_cannot_backtrack () = Sc_rollup_errors.Sc_rollup_staker_backtracked let test_staker_cannot_change_branch () = - let* ctxt, rollup, staker1, staker2 = + let* ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -2148,7 +2185,7 @@ let test_get_commitment_of_missing_rollup () = let test_get_missing_commitment () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let commitment_hash = Commitment_repr.Hash.zero in assert_fails_with ~loc:__LOC__ @@ -2162,18 +2199,18 @@ let test_remove_staker_from_missing_rollup () = rollup Sc_rollup_repr.Staker.zero) -let test_initial_level_of_missing_rollup () = - assert_fails_with_missing_rollup ~loc:__LOC__ Sc_rollup_storage.initial_level +let test_genesis_info_of_missing_rollup () = + assert_fails_with_missing_rollup ~loc:__LOC__ Sc_rollup_storage.genesis_info let test_concurrent_refinement_point_of_conflict () = - let* before_ctxt, rollup, staker1, staker2 = + let* before_ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let level = valid_inbox_level before_ctxt in let commitment1 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -2183,7 +2220,7 @@ let test_concurrent_refinement_point_of_conflict () = let commitment2 = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = level 1l; number_of_messages = number_of_messages_exn 10l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -2238,13 +2275,13 @@ let test_concurrent_refinement_point_of_conflict () = assert_commitment_hash_equal ~loc:__LOC__ ctxt c2.hash c2'.hash let test_concurrent_refinement_cement () = - let* before_ctxt, rollup, staker1, staker2 = + let* before_ctxt, rollup, genesis_hash, staker1, staker2 = originate_rollup_and_deposit_with_two_stakers () in let commitment = Commitment_repr. { - predecessor = Commitment_repr.Hash.zero; + predecessor = genesis_hash; inbox_level = valid_inbox_level before_ctxt 1l; number_of_messages = number_of_messages_exn 3l; number_of_ticks = number_of_ticks_exn 1232909l; @@ -2318,7 +2355,7 @@ let test_carbonated_memory_inbox_retrieval () = let ctxt = set_gas_limit ctxt (Gas_limit_repr.Arith.integral_of_int_exn 20_000) in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let*? _, ctxt' = Environment.wrap_tzresult @@ Sc_rollup_in_memory_inbox.current_messages ctxt rollup @@ -2341,7 +2378,7 @@ let test_carbonated_memory_inbox_set_messages () = let ctxt = set_gas_limit ctxt (Gas_limit_repr.Arith.integral_of_int_exn 20_000) in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let* inbox, ctxt = lift @@ Sc_rollup_inbox_storage.inbox ctxt rollup in let*? current_messages, ctxt = Environment.wrap_tzresult @@ -2377,7 +2414,7 @@ let test_carbonated_memory_inbox_set_messages () = let test_limit_on_number_of_messages_during_commitment_period with_gap () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let commitment_period = Constants_storage.sc_rollup_commitment_period_in_blocks ctxt in @@ -2448,7 +2485,7 @@ let assert_is_already_applied ~loc ctxt rollup level message_index = (** Test outbox for applied messages. *) let test_storage_outbox () = let* ctxt = new_context () in - let* rollup1, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup1, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let level1 = 100 in (* Test that is-applied is false for non-recorded messages. *) let* _size_diff, ctxt = lift @@ record ctxt rollup1 level1 1 in @@ -2468,7 +2505,7 @@ let test_storage_outbox () = let* () = assert_is_already_applied ~loc:__LOC__ ctxt rollup1 level2 47 in let* () = assert_is_already_applied ~loc:__LOC__ ctxt rollup1 level1 1 in (* Record for a new rollup. *) - let* rollup2, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup2, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let* _size_diff, ctxt = lift @@ record ctxt rollup2 level1 1 in let* _size_diff, ctxt = lift @@ record ctxt rollup2 level1 3 in let* () = assert_is_already_applied ~loc:__LOC__ ctxt rollup2 level1 1 in @@ -2479,7 +2516,7 @@ let test_storage_outbox () = let test_storage_outbox_exceed_limits () = let level = 1234 in let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in (* Assert that recording a message index that exceeds max outbox messages per level fails. *) let* () = @@ -2531,7 +2568,7 @@ let test_storage_outbox_size_diff () = It depends on [sc_rollup_max_outbox_messages_per_level]. *) let max_size_diff = 19 in let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let level = 15 in let max_message_index = Constants_storage.sc_rollup_max_outbox_messages_per_level ctxt - 1 @@ -2568,7 +2605,7 @@ let test_storage_outbox_size_diff () = let test_subscribe_slot_to_rollup () = let* ctxt = new_context () in let level = (Raw_context.current_level ctxt).level in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let slot_index = dal_slot_index_of_int_exn 0 in let* index, subscribed_level, _ctxt = lift @@ Sc_rollup_storage.Dal_slot.subscribe ctxt rollup ~slot_index @@ -2586,7 +2623,7 @@ let test_subscribe_slot_to_rollup () = let test_subscribe_slot_twice_at_same_level () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let slot_index = dal_slot_index_of_int_exn 0 in let* _index, _subscribed_level, ctxt = lift @@ Sc_rollup_storage.Dal_slot.subscribe ctxt rollup ~slot_index @@ -2598,7 +2635,7 @@ let test_subscribe_slot_twice_at_same_level () = let test_subscribe_slot_twice_at_different_levels () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let slot_index = dal_slot_index_of_int_exn 0 in let ctxt = Raw_context.Internal_for_tests.add_level ctxt 10 in let* _index, _subscribed_level, ctxt = @@ -2611,7 +2648,7 @@ let test_subscribe_slot_twice_at_different_levels () = let test_subscribe_different_slots_at_same_level () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let slot_0 = dal_slot_index_of_int_exn 0 in let slot_1 = dal_slot_index_of_int_exn 1 in let* _, _, ctxt = @@ -2624,7 +2661,7 @@ let test_subscribe_different_slots_at_same_level () = let test_subscribe_different_slots_at_different_levels () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let slot_0 = dal_slot_index_of_int_exn 0 in let slot_1 = dal_slot_index_of_int_exn 1 in let* _, _, ctxt = @@ -2653,7 +2690,7 @@ let test_subscribe_to_slot_with_index_out_of_bounds () = @@ Raw_context.patch_constants ctxt (fun constants -> {constants with dal = {constants.dal with number_of_slots}}) in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let out_of_bounds_index = dal_slot_index_of_int_exn number_of_slots in let maximum = dal_slot_index_of_int_exn (number_of_slots - 1) in assert_fails_with @@ -2667,7 +2704,7 @@ let test_subscribe_to_slot_with_index_out_of_bounds () = let test_subscribed_slots_no_entries () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let current_level = (Raw_context.current_level ctxt).level in let* subscribed_slots = lift @@ -2687,7 +2724,7 @@ let test_subscribed_slots_no_entries () = let test_subscribed_slots_returns_overall_slot_subscriptions () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let slot_0 = dal_slot_index_of_int_exn 0 in let slot_1 = dal_slot_index_of_int_exn 1 in let* _, _, ctxt = @@ -2716,7 +2753,7 @@ let test_subscribed_slots_returns_overall_slot_subscriptions () = let test_subscribed_slots_no_entry_at_current_level () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let slot_0 = dal_slot_index_of_int_exn 0 in let slot_1 = dal_slot_index_of_int_exn 1 in let* _, _, ctxt = @@ -2746,7 +2783,7 @@ let test_subscribed_slots_no_entry_at_current_level () = let test_subscribed_slots_at_level_past_context_level () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let slot_0 = dal_slot_index_of_int_exn 0 in let slot_1 = dal_slot_index_of_int_exn 1 in let* _, _, ctxt = @@ -2773,7 +2810,7 @@ let test_subscribed_slots_at_level_past_context_level () = let test_subscribed_slots_entries_at_future_level () = let* ctxt = new_context () in - let* rollup, ctxt = lift @@ new_sc_rollup ctxt in + let* rollup, _genesis_hash, ctxt = lift @@ new_sc_rollup ctxt in let slot_0 = dal_slot_index_of_int_exn 0 in let slot_1 = dal_slot_index_of_int_exn 1 in let slot_2 = dal_slot_index_of_int_exn 2 in @@ -2877,7 +2914,7 @@ let tests = Tztest.tztest "initial_level returns correct level" `Quick - test_initial_level_of_rollup; + test_genesis_info_of_rollup; Tztest.tztest "rollup starts in pre-boot state" `Quick @@ -3013,7 +3050,7 @@ let tests = Tztest.tztest "initial level of missing rollup fails" `Quick - test_initial_level_of_missing_rollup; + test_genesis_info_of_missing_rollup; Tztest.tztest "Refinement operations are commutative (point of conflict)" `Quick @@ -3102,6 +3139,10 @@ let tests = "Fetching slot subscriptions of missing rollup fails" `Quick test_subscribed_slots_of_missing_rollup; + Tztest.tztest + "Originating a rollup creates a genesis commitment" + `Quick + test_last_cemented_commitment_hash_with_level_when_genesis; ] (* FIXME: https://gitlab.com/tezos/tezos/-/issues/2460 diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_wasm.ml new file mode 100644 index 0000000000000000000000000000000000000000..07cd4db6d0f90407497ce945e397c8a8fe26c4d4 --- /dev/null +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_wasm.ml @@ -0,0 +1,60 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2022 Trili Tech, *) +(* *) +(* Permission is hereby granted, free of charge, to any person obtaining a *) +(* copy of this software and associated documentation files (the "Software"),*) +(* to deal in the Software without restriction, including without limitation *) +(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) +(* and/or sell copies of the Software, and to permit persons to whom the *) +(* Software is furnished to do so, subject to the following conditions: *) +(* *) +(* The above copyright notice and this permission notice shall be included *) +(* in all copies or substantial portions of the Software. *) +(* *) +(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) +(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) +(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) +(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) +(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) +(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) +(* DEALINGS IN THE SOFTWARE. *) +(* *) +(*****************************************************************************) + +(** Testing + ------- + Component: Rollup layer 1 logic + Invocation: dune exec \ + src/proto_alpha/lib_protocol/test/unit/main.exe \ + -- test "^\[Unit\] sc rollup wasm$" + Subject: Unit test for the Wasm PVM +*) + +open Protocol +open Alpha_context + +let test_initial_state_hash_wasm_pvm () = + let open Lwt_result_syntax in + let context = Tezos_context_memory.make_empty_context () in + let*! state = Sc_rollup_helpers.Wasm_pvm.initial_state context in + let*! hash = Sc_rollup_helpers.Wasm_pvm.state_hash state in + let expected = Sc_rollup.Wasm_2_0_0PVM.reference_initial_state_hash in + if Sc_rollup.State_hash.(hash = expected) then return_unit + else + failwith + "incorrect hash, expected %a, got %a" + Sc_rollup.State_hash.pp + expected + Sc_rollup.State_hash.pp + hash + +let tests = + [ + Tztest.tztest + "initial state hash for Wasm" + `Quick + test_initial_state_hash_wasm_pvm; + ] diff --git a/tezt/lib_tezos/RPC.ml b/tezt/lib_tezos/RPC.ml index 26b750275dfd832f6ae9cdd9e3acc9136cf2fefb..205e8fa5505e5a2a419eaa9352bf3ba9fba6abef 100644 --- a/tezt/lib_tezos/RPC.ml +++ b/tezt/lib_tezos/RPC.ml @@ -322,8 +322,8 @@ module Sc_rollup = struct let get_inbox ?(chain = "main") ?(block = "head") sc_rollup_address = make GET (path ~chain ~block sc_rollup_address @ ["inbox"]) Fun.id - let get_initial_level ?(chain = "main") ?(block = "head") sc_rollup_address = - make GET (path ~chain ~block sc_rollup_address @ ["initial_level"]) Fun.id + let get_genesis_info ?(chain = "main") ?(block = "head") sc_rollup_address = + make GET (path ~chain ~block sc_rollup_address @ ["genesis_info"]) Fun.id let get_boot_sector ?(chain = "main") ?(block = "head") sc_rollup_address = make GET (path ~chain ~block sc_rollup_address @ ["boot_sector"]) Fun.id diff --git a/tezt/lib_tezos/RPC.mli b/tezt/lib_tezos/RPC.mli index 9ec7e38bd4dbf1b53d0dd9a9d99b98b97247b49e..c0a4e36576b0c7f05e9ddb42a2fb981c508ad2ca 100644 --- a/tezt/lib_tezos/RPC.mli +++ b/tezt/lib_tezos/RPC.mli @@ -352,8 +352,8 @@ module Sc_rollup : sig (** RPC: [GET chain/[chain]/blocks/[block]/context/sc_rollup//inbox] *) val get_inbox : ?chain:string -> ?block:string -> string -> JSON.t t - (** RPC: [GET chain/[chain]/blocks/[block]/context/sc_rollup//initial_level] *) - val get_initial_level : ?chain:string -> ?block:string -> string -> JSON.t t + (** RPC: [GET chain/[chain]/blocks/[block]/context/sc_rollup//genesis_info] *) + val get_genesis_info : ?chain:string -> ?block:string -> string -> JSON.t t (** RPC: [GET chain/[chain]/blocks/[block]/context/sc_rollup//boot_sector] *) val get_boot_sector : ?chain:string -> ?block:string -> string -> JSON.t t diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml index c560597c4a7ed1c57eac93884c35281d85c47769..71a5dc1be392949708ef4f467a619ec308cbf53f 100644 --- a/tezt/tests/dal.ml +++ b/tezt/tests/dal.ml @@ -334,11 +334,11 @@ let rollup_node_subscribes_to_dal_slots _protocol sc_rollup_node 5. Execute a client command to subscribe the rollup to dal slot 1, bake one level 6. Fetch the list of subscribed slots, determine that it contains slots 0 and 1 *) - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in - let init_level = init_level |> JSON.as_int in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in let* () = Sc_rollup_node.run sc_rollup_node in let sc_rollup_client = Sc_rollup_client.create sc_rollup_node in let* level = Sc_rollup_node.wait_for_level sc_rollup_node init_level in diff --git a/tezt/tests/expected/dal.ml/Alpha- Testing data availability layer functionality (feature_flag_is_disabled).out b/tezt/tests/expected/dal.ml/Alpha- Testing data availability layer functionality (feature_flag_is_disabled).out index b51b2faf44b9b993d2f18c5ab57fc600a16e0df1..9798ff186439c5b9e2256d9f9f6533a25b0a19fe 100644 --- a/tezt/tests/expected/dal.ml/Alpha- Testing data availability layer functionality (feature_flag_is_disabled).out +++ b/tezt/tests/expected/dal.ml/Alpha- Testing data availability layer functionality (feature_flag_is_disabled).out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,19 +12,20 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 diff --git a/tezt/tests/expected/dal.ml/Alpha- Testing data availability layer functionality (rollup_node_dal_subscript.out b/tezt/tests/expected/dal.ml/Alpha- Testing data availability layer functionality (rollup_node_dal_subscript.out index 14cc36fdd5a052f9925ac014e3f6d3c3cc5d45ad..480104ebff8bfdc7aa6e673f51240d67c9b5cc6e 100644 --- a/tezt/tests/expected/dal.ml/Alpha- Testing data availability layer functionality (rollup_node_dal_subscript.out +++ b/tezt/tests/expected/dal.ml/Alpha- Testing data availability layer functionality (rollup_node_dal_subscript.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,25 +12,27 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-sc-rollup-client-alpha rpc get /global/dal/slots [] diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- configuration of a smart contract optimistic rollup node.out b/tezt/tests/expected/sc_rollup.ml/Alpha- configuration of a smart contract optimistic rollup node.out index b51b2faf44b9b993d2f18c5ab57fc600a16e0df1..9798ff186439c5b9e2256d9f9f6533a25b0a19fe 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- configuration of a smart contract optimistic rollup node.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- configuration of a smart contract optimistic rollup node.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,19 +12,20 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- consecutive commitments.out b/tezt/tests/expected/sc_rollup.ml/Alpha- consecutive commitments.out index 08252632eae5d9d46b1587b09ef1f21ca69c38cf..0ea5d7784185518ea26afdbda4a448fcfb518d1d 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- consecutive commitments.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- consecutive commitments.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,26 +12,27 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none publish commitment from '[PUBLIC_KEY_HASH]' for sc rollup '[SC_ROLLUP_HASH]' with compressed state scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf at inbox level 32 and predecessor '[SC_ROLLUP_COMMITMENT_HASH]' and number of messages 0 and number of ticks 0 Node is bootstrapped. -Estimated gas: 5330.832 units (will add 100 for safety) +Estimated gas: 6251.140 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' @@ -42,13 +43,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000885 + Fee to the baker: ꜩ0.000977 Expected counter: 2 - Gas limit: 5431 + Gas limit: 6352 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000885 - payload fees(the block proposer) ....... +ꜩ0.000885 + [PUBLIC_KEY_HASH] ... -ꜩ0.000977 + payload fees(the block proposer) ....... +ꜩ0.000977 Publish commitment SCORU Commitment: compressed_state: scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf inbox_level: 32 @@ -56,7 +57,7 @@ This sequence of operations was run: number_of_messages: 0 number_of_ticks: 0 in the smart contract rollup at address [SC_ROLLUP_HASH] This smart contract rollup commitment publishing was successfully applied - Consumed gas: 5330.832 + Consumed gas: 6251.140 Hash of commit: [SC_ROLLUP_COMMITMENT_HASH] Commitment published at level: 3 Balance updates: @@ -66,7 +67,7 @@ This sequence of operations was run: ./tezos-client --wait none publish commitment from '[PUBLIC_KEY_HASH]' for sc rollup '[SC_ROLLUP_HASH]' with compressed state scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf at inbox level 62 and predecessor '[SC_ROLLUP_COMMITMENT_HASH]' and number of messages 0 and number of ticks 0 Node is bootstrapped. -Estimated gas: 4019.750 units (will add 100 for safety) +Estimated gas: 4479.904 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' @@ -77,13 +78,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000753 + Fee to the baker: ꜩ0.000799 Expected counter: 3 - Gas limit: 4120 + Gas limit: 4580 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000753 - payload fees(the block proposer) ....... +ꜩ0.000753 + [PUBLIC_KEY_HASH] ... -ꜩ0.000799 + payload fees(the block proposer) ....... +ꜩ0.000799 Publish commitment SCORU Commitment: compressed_state: scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf inbox_level: 62 @@ -91,7 +92,7 @@ This sequence of operations was run: number_of_messages: 0 number_of_ticks: 0 in the smart contract rollup at address [SC_ROLLUP_HASH] This smart contract rollup commitment publishing was successfully applied - Consumed gas: 4019.750 + Consumed gas: 4479.904 Hash of commit: [SC_ROLLUP_COMMITMENT_HASH] Commitment published at level: 4 diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- ensure boot sector is used.out b/tezt/tests/expected/sc_rollup.ml/Alpha- ensure boot sector is used.out index 67eca71bacbcd8c096e5f0faaa3b375347574832..b1d7feb01ce8568d82ef58a1eda2e2fc0817684b 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- ensure boot sector is used.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- ensure boot sector is used.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with '10 10 10 + +' --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6553 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6638 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,25 +12,27 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.00044 + Fee to the baker: ꜩ0.000626 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6573 bytes + Gas limit: 2610 + Storage limit: 6658 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.00044 - payload fees(the block proposer) ....... +ꜩ0.00044 + [PUBLIC_KEY_HASH] ... -ꜩ0.000626 + payload fees(the block proposer) ....... +ꜩ0.000626 Originate smart contract rollup of kind arith and type unit with boot sector '10 10 10 + +' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6553 bytes + Consumed gas: 2509.140 + Storage size: 6638 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63825 - storage fees ........................... +ꜩ1.63825 + [PUBLIC_KEY_HASH] ... -ꜩ1.6595 + storage fees ........................... +ꜩ1.6595 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-client --wait none send sc rollup message 'text:["3130202b"]' from bootstrap1 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -76,8 +78,8 @@ This sequence of operations was run: ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with 31 --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6543 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6628 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -87,25 +89,27 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.00043 + Fee to the baker: ꜩ0.000616 Expected counter: 3 - Gas limit: 1901 - Storage limit: 6563 bytes + Gas limit: 2610 + Storage limit: 6648 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.00043 - payload fees(the block proposer) ....... +ꜩ0.00043 + [PUBLIC_KEY_HASH] ... -ꜩ0.000616 + payload fees(the block proposer) ....... +ꜩ0.000616 Originate smart contract rollup of kind arith and type unit with boot sector '31' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6543 bytes + Consumed gas: 2509.140 + Storage size: 6628 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63575 - storage fees ........................... +ꜩ1.63575 + [PUBLIC_KEY_HASH] ... -ꜩ1.657 + storage fees ........................... +ꜩ1.657 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -4 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 4, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-client --wait none send sc rollup message 'text:["3130202b"]' from bootstrap1 to '[SC_ROLLUP_HASH]' Node is bootstrapped. diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- get initial level of a sc rollup.out b/tezt/tests/expected/sc_rollup.ml/Alpha- get genesis info of a sc rollup.out similarity index 60% rename from tezt/tests/expected/sc_rollup.ml/Alpha- get initial level of a sc rollup.out rename to tezt/tests/expected/sc_rollup.ml/Alpha- get genesis info of a sc rollup.out index b51b2faf44b9b993d2f18c5ab57fc600a16e0df1..9798ff186439c5b9e2256d9f9f6533a25b0a19fe 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- get initial level of a sc rollup.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- get genesis info of a sc rollup.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,19 +12,20 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- get last cemented commitment hash and inbox level of a sc rollup.out b/tezt/tests/expected/sc_rollup.ml/Alpha- get last cemented commitment hash and inbox level of a sc rollup.out index b51b2faf44b9b993d2f18c5ab57fc600a16e0df1..9798ff186439c5b9e2256d9f9f6533a25b0a19fe 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- get last cemented commitment hash and inbox level of a sc rollup.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- get last cemented commitment hash and inbox level of a sc rollup.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,19 +12,20 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- getting a smart-contract rollup address through the client.out b/tezt/tests/expected/sc_rollup.ml/Alpha- getting a smart-contract rollup address through the client.out index b51b2faf44b9b993d2f18c5ab57fc600a16e0df1..9798ff186439c5b9e2256d9f9f6533a25b0a19fe 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- getting a smart-contract rollup address through the client.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- getting a smart-contract rollup address through the client.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,19 +12,20 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- list originated rollups.out b/tezt/tests/expected/sc_rollup.ml/Alpha- list originated rollups.out index c72944ce975e9a271919b3fd3cd8c65de9ce6d8c..cbb1b08bc764287c0094149fe24e9cbdf7c54856 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- list originated rollups.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- list originated rollups.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,27 +12,28 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -42,27 +43,28 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 2 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -72,27 +74,28 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 3 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -102,27 +105,28 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 4 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -132,27 +136,28 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 5 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -162,27 +167,28 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 6 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -192,27 +198,28 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 7 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -222,27 +229,28 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 8 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -252,27 +260,28 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 9 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -282,19 +291,20 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 10 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- node advances PVM state with messages.out b/tezt/tests/expected/sc_rollup.ml/Alpha- node advances PVM state with messages.out index 100a5555155379176b938ffcd1b78263154cbb2b..4e62d6091938ee535d96211038249a240bbd4f8b 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- node advances PVM state with messages.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- node advances PVM state with messages.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,28 +12,30 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-sc-rollup-client-alpha rpc get /global/state_hash -"scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf" +"scs139rUcWoTB9MbNUEaWYn5RswKF7G2uENnRPq7Q9ByQRMahtB2NA" ./tezos-sc-rollup-client-alpha rpc get /global/total_ticks "0" diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- node boots into the initial state.out b/tezt/tests/expected/sc_rollup.ml/Alpha- node boots into the initial state.out index baae16482468d88eb863785ecf0646162a465dac..f0c9fe0f9e38f693ef1615af127ba3051b4606fb 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- node boots into the initial state.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- node boots into the initial state.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,25 +12,27 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-sc-rollup-client-alpha rpc get /global/total_ticks "0" diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (commitm.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (commitm.out index 3053a54d81177ddf11fb510ad66c6e5fa11f1f92..ba1719f0d98c952a27d8c22da212f272ecb449b1 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (commitm.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (commitm.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,25 +12,27 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-client --wait none send sc rollup message 'text:["CAFEBABE"]' from bootstrap1 to '[SC_ROLLUP_HASH]' Node is bootstrapped. diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (first_p.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (first_p.out index 15e8f3e4981137435b753bdaaae8f982753fcdc6..bf92e7d3f5d17af9c82074b173a78ba01ecfdd57 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (first_p.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (first_p.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,30 +12,32 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-sc-rollup-client-alpha rpc get /local/last_published_commitment { "commitment": { "compressed_state": - "scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf", + "scs139rUcWoTB9MbNUEaWYn5RswKF7G2uENnRPq7Q9ByQRMahtB2NA", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", "number_of_messages": 0, "number_of_ticks": 0 }, @@ -45,7 +47,7 @@ This sequence of operations was run: ./tezos-sc-rollup-client-alpha rpc get /local/last_published_commitment { "commitment": { "compressed_state": - "scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf", + "scs139rUcWoTB9MbNUEaWYn5RswKF7G2uENnRPq7Q9ByQRMahtB2NA", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", "number_of_messages": 0, "number_of_ticks": 0 }, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (handles.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (handles.out index 69f68065c141e3c4977a290ed30f3bedd81b5863..6823a6f431487f51ebf2105b690deaa21507449b 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (handles.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (handles.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,25 +12,27 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-client --wait none send sc rollup message 'text:["CAFEBABE"]' from bootstrap1 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -74,7 +76,7 @@ This sequence of operations was run: ./tezos-sc-rollup-client-alpha rpc get /global/last_stored_commitment { "commitment": { "compressed_state": - "scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf", + "scs139rUcWoTB9MbNUEaWYn5RswKF7G2uENnRPq7Q9ByQRMahtB2NA", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", "number_of_messages": 0, "number_of_ticks": 0 }, @@ -83,7 +85,7 @@ This sequence of operations was run: ./tezos-sc-rollup-client-alpha rpc get /local/last_published_commitment { "commitment": { "compressed_state": - "scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf", + "scs139rUcWoTB9MbNUEaWYn5RswKF7G2uENnRPq7Q9ByQRMahtB2NA", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", "number_of_messages": 0, "number_of_ticks": 0 }, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (message.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (message.out index dbfa923f799ca2fb2b2a144e324cb7067d2f7d3d..17bab608f6443805ec28a587fa074ba704bc2b7f 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (message.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (message.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,25 +12,27 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-client --wait none send sc rollup message 'text:["CAFEBABE"]' from bootstrap1 to '[SC_ROLLUP_HASH]' Node is bootstrapped. diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (no_comm.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (no_comm.out index b5e029aed80a8d390cfad4e28e5b6c1f3eeb493e..14cb7219f274f4fe42d111363e4fe5aa6b2e1395 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (no_comm.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (no_comm.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,30 +12,32 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-sc-rollup-client-alpha rpc get /global/last_stored_commitment { "commitment": { "compressed_state": - "scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf", + "scs139rUcWoTB9MbNUEaWYn5RswKF7G2uENnRPq7Q9ByQRMahtB2NA", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", "number_of_messages": 0, "number_of_ticks": 0 }, @@ -44,7 +46,7 @@ This sequence of operations was run: ./tezos-sc-rollup-client-alpha rpc get /local/last_published_commitment { "commitment": { "compressed_state": - "scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf", + "scs139rUcWoTB9MbNUEaWYn5RswKF7G2uENnRPq7Q9ByQRMahtB2NA", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", "number_of_messages": 0, "number_of_ticks": 0 }, @@ -130,7 +132,7 @@ Error: ./tezos-client --wait none cement commitment '[SC_ROLLUP_COMMITMENT_HASH]' from bootstrap1 for sc rollup '[SC_ROLLUP_HASH]' Node is bootstrapped. -Estimated gas: 3451.204 units (will add 100 for safety) +Estimated gas: 4051.204 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' @@ -141,16 +143,16 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000653 + Fee to the baker: ꜩ0.000713 Expected counter: 3 - Gas limit: 3552 + Gas limit: 4152 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000653 - payload fees(the block proposer) ....... +ꜩ0.000653 + [PUBLIC_KEY_HASH] ... -ꜩ0.000713 + payload fees(the block proposer) ....... +ꜩ0.000713 Cement the commitment [SC_ROLLUP_COMMITMENT_HASH] in the smart contract rollup at address [SC_ROLLUP_HASH] This smart contract rollup commitment cementing was successfully applied - Consumed gas: 3451.204 + Consumed gas: 4051.204 ./tezos-client rpc get /chains/main/blocks/head/context/constants @@ -246,7 +248,7 @@ null ./tezos-sc-rollup-client-alpha rpc get /global/last_stored_commitment { "commitment": { "compressed_state": - "scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf", + "scs139rUcWoTB9MbNUEaWYn5RswKF7G2uENnRPq7Q9ByQRMahtB2NA", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", "number_of_messages": 0, "number_of_ticks": 0 }, @@ -255,7 +257,7 @@ null ./tezos-sc-rollup-client-alpha rpc get /local/last_published_commitment { "commitment": { "compressed_state": - "scs11VNjWyZw4Tgbvsom8epQbox86S2CKkE1UAZkXMM7Pj8MQMLzMf", + "scs139rUcWoTB9MbNUEaWYn5RswKF7G2uENnRPq7Q9ByQRMahtB2NA", "inbox_level": 62, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", "number_of_messages": 0, "number_of_ticks": 0 }, diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (non_fin.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (non_fin.out index f809bb3c24156294ef0c115e664210ab606c9e79..70f4c4a8356969f310d6c0b9bc309cefb2237c01 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (non_fin.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct handling of commitments in the rollup node (non_fin.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,25 +12,27 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 -./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/initial_level' -2 +./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' +{ "level": 2, + "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-client --wait none send sc rollup message 'text:["CAFEBABE"]' from bootstrap1 to '[SC_ROLLUP_HASH]' Node is bootstrapped. diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (basic).out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (basic).out index 5b94039f58b315dd36795046245990232ad1eb1a..3eb1c0e29e7676d3d95518a05d2bb321990b39d0 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (basic).out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (basic).out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,21 +12,22 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none send sc rollup message 'text:["CAFEBABE"]' from bootstrap1 to '[SC_ROLLUP_HASH]' diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (handles_ch.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (handles_ch.out index 1c33f218383c34567a73575df8d2e7fcb9d6e995..0e23162d10a0c87e3e87ec786bff0d80544744c7 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (handles_ch.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (handles_ch.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,21 +12,22 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none send sc rollup message 'text:["CAFEBABE"]' from bootstrap1 to '[SC_ROLLUP_HASH]' diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (stops).out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (stops).out index 613b265903009d929adbfa62a2acdeda548ea455..3548d615c5498b613cc53eaa63888b7cce6b5124 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (stops).out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (stops).out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,21 +12,22 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none send sc rollup message 'text:["CAFEBABE"]' from bootstrap1 to '[SC_ROLLUP_HASH]' diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (too_many_m.out b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (too_many_m.out index fb7f2264f52129f84c9ca959c518688e77fa46be..9d957bd08d7e38445eba2f56ac2cf6313e215929 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (too_many_m.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- observing the correct maintenance of inbox in the rollup node (too_many_m.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,21 +12,22 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none send sc rollup message 'text:["CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE","CAFEBABE"]' from bootstrap1 to '[SC_ROLLUP_HASH]' diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- originate with boot sector.out b/tezt/tests/expected/sc_rollup.ml/Alpha- originate with boot sector.out index 7cebd8de367425534b4a8de0ced550fee42cc40a..2ac15fc82e5fb01876044f6007735c7ba39d1481 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- originate with boot sector.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- originate with boot sector.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with '10 10 10 + +' --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6553 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6638 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,21 +12,22 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.00044 + Fee to the baker: ꜩ0.000626 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6573 bytes + Gas limit: 2610 + Storage limit: 6658 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.00044 - payload fees(the block proposer) ....... +ꜩ0.00044 + [PUBLIC_KEY_HASH] ... -ꜩ0.000626 + payload fees(the block proposer) ....... +ꜩ0.000626 Originate smart contract rollup of kind arith and type unit with boot sector '10 10 10 + +' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6553 bytes + Consumed gas: 2509.140 + Storage size: 6638 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63825 - storage fees ........................... +ꜩ1.63825 + [PUBLIC_KEY_HASH] ... -ꜩ1.6595 + storage fees ........................... +ꜩ1.6595 ./tezos-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/boot_sector' diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- origination of a SCORU executes without error.out b/tezt/tests/expected/sc_rollup.ml/Alpha- origination of a SCORU executes without error.out index b51b2faf44b9b993d2f18c5ab57fc600a16e0df1..9798ff186439c5b9e2256d9f9f6533a25b0a19fe 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- origination of a SCORU executes without error.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- origination of a SCORU executes without error.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,19 +12,20 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- pushing messages in the inbox - check inbox size.out b/tezt/tests/expected/sc_rollup.ml/Alpha- pushing messages in the inbox - check inbox size.out index 40f0a9beec9fb1b00d5ac4650a573d669992a145..9d1236c74f06d3971d02e547dd7677cd62de0157 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- pushing messages in the inbox - check inbox size.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- pushing messages in the inbox - check inbox size.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,21 +12,22 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none send sc rollup message 'text:["CAFEBABE"]' from bootstrap1 to '[SC_ROLLUP_HASH]' diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- pushing messages in the inbox - current messages hash.out b/tezt/tests/expected/sc_rollup.ml/Alpha- pushing messages in the inbox - current messages hash.out index 848b9881474c5d9ff5721e83c82a5de693ece0ef..d91d280e1b389f6c8ad21e15a3a24fdfce7adc3b 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- pushing messages in the inbox - current messages hash.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- pushing messages in the inbox - current messages hash.out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from '[PUBLIC_KEY_HASH]' of kind arith of type unit booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 1800.800 units (will add 100 for safety) -Estimated storage: 6541 bytes added (will add 20 for safety) +Estimated gas: 2509.140 units (will add 100 for safety) +Estimated storage: 6626 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,21 +12,22 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000428 + Fee to the baker: ꜩ0.000614 Expected counter: 1 - Gas limit: 1901 - Storage limit: 6561 bytes + Gas limit: 2610 + Storage limit: 6646 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000428 - payload fees(the block proposer) ....... +ꜩ0.000428 + [PUBLIC_KEY_HASH] ... -ꜩ0.000614 + payload fees(the block proposer) ....... +ꜩ0.000614 Originate smart contract rollup of kind arith and type unit with boot sector '' This smart contract rollup origination was successfully applied - Consumed gas: 1800.800 - Storage size: 6541 bytes + Consumed gas: 2509.140 + Storage size: 6626 bytes Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.63525 - storage fees ........................... +ꜩ1.63525 + [PUBLIC_KEY_HASH] ... -ꜩ1.6565 + storage fees ........................... +ꜩ1.6565 ./tezos-client --wait none send sc rollup message 'text:["hello, message number 0", "hello, message number 1", "hello, message number 2", "hello, message number 3", "hello, message number 4"]' from bootstrap1 to '[SC_ROLLUP_HASH]' diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 5622e90a16f5311af269e35b02c4c46b4b3f0805..4b86ffd010befe28b5da5fd5d37f0102ffa4c7b0 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -412,11 +412,11 @@ let test_rollup_client_gets_address = We can fetch the level when a smart contract rollup was originated from the context. *) -let test_rollup_get_initial_level = +let test_rollup_get_genesis_info = regression_test ~__FILE__ - ~tags:["initial_level"] - "get initial level of a sc rollup" + ~tags:["genesis_info"] + "get genesis info of a sc rollup" (fun protocol -> setup ~protocol @@ fun node client bootstrap -> let* current_level = RPC.get_current_level client in @@ -424,14 +424,14 @@ let test_rollup_get_initial_level = (* Bake 10 blocks to be sure that the initial level of rollup is different from the current level. *) let* _ = repeat 10 (fun () -> Client.bake_for_and_wait client) in - let* initial_level = + let* genesis_info = RPC.Client.call client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in (* 1 Block for activating alpha + 1 block for originating the rollup the rollup initial level should be 2 *) Check.( - (JSON.as_int initial_level + (JSON.(genesis_info |-> "level" |> as_int) = JSON.as_int (JSON.get "level" current_level) + 1) int ~error_msg:"expected value %L, got %R") ; @@ -465,12 +465,15 @@ let test_rollup_get_last_cemented_commitment_hash_with_level = let* hash, level = last_cemented_commitment_hash_with_level ~sc_rollup_address client in - (* The hardcoded value of `Sc_rollup.Commitment.zero` is - "scc12XhSULdV8bAav21e99VYLTpqAjTd7NU8Mn4zFdKPSA8auMbggG". *) + let* genesis_info = + RPC.Client.call client + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address + in + let genesis_hash = + JSON.(genesis_info |-> "commitment_hash" |> as_string) + in Check.( - (hash = "scc12XhSULdV8bAav21e99VYLTpqAjTd7NU8Mn4zFdKPSA8auMbggG") - string - ~error_msg:"expected value %L, got %R") ; + (hash = genesis_hash) string ~error_msg:"expected value %L, got %R") ; (* The level of the last cemented commitment should correspond to the rollup origination level. *) Check.( @@ -934,11 +937,11 @@ let test_rollup_list = *) let test_rollup_node_boots_into_initial_state = let go client sc_rollup_address sc_rollup_node = - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in - let init_level = init_level |> JSON.as_int in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in let* () = Sc_rollup_node.run sc_rollup_node in let sc_rollup_client = Sc_rollup_client.create sc_rollup_node in @@ -981,11 +984,11 @@ let test_rollup_node_boots_into_initial_state = *) let test_rollup_node_advances_pvm_state = let go client sc_rollup_address sc_rollup_node = - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in - let init_level = init_level |> JSON.as_int in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in let* () = Sc_rollup_node.run sc_rollup_node in let sc_rollup_client = Sc_rollup_client.create sc_rollup_node in @@ -1142,12 +1145,12 @@ let commitment_stored _protocol sc_rollup_node sc_rollup_address _node client = `init_level + sc_rollup_commitment_period_in_blocks + levels_to_finalise`. *) - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in - let init_level = init_level |> JSON.as_int in let* levels_to_commitment = get_sc_rollup_commitment_period_in_blocks client in @@ -1218,12 +1221,12 @@ let commitment_not_stored_if_non_final _protocol sc_rollup_node levels_to_finalise`. At the level before, the commitment will not be neither stored nor published. *) - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in - let init_level = init_level |> JSON.as_int in let* levels_to_commitment = get_sc_rollup_commitment_period_in_blocks client in @@ -1277,12 +1280,12 @@ let commitments_messages_reset _protocol sc_rollup_node sc_rollup_address _node `block_finality_time` empty levels are baked which ensures that two commitments are stored and published by the rollup node. *) - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in - let init_level = init_level |> JSON.as_int in let* levels_to_commitment = get_sc_rollup_commitment_period_in_blocks client in @@ -1353,12 +1356,12 @@ let commitments_reorgs protocol sc_rollup_node sc_rollup_address node client = publishes the commitment. The final commitment should have no messages and no ticks. *) - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in - let init_level = init_level |> JSON.as_int in let* levels_to_commitment = get_sc_rollup_commitment_period_in_blocks client in @@ -1526,12 +1529,12 @@ let commitment_before_lcc_not_published _protocol sc_rollup_node let commitment_period = constants.commitment_period_in_blocks in let challenge_window = constants.challenge_window_in_blocks in (* Rollup node 1 processes messages, produces and publishes two commitments. *) - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in - let init_level = init_level |> JSON.as_int in let* () = Sc_rollup_node.run sc_rollup_node in let sc_rollup_client = Sc_rollup_client.create sc_rollup_node in let* level = Sc_rollup_node.wait_for_level sc_rollup_node init_level in @@ -1691,12 +1694,12 @@ let commitment_before_lcc_not_published _protocol sc_rollup_node let first_published_level_is_global _protocol sc_rollup_node sc_rollup_address node client = (* Rollup node 1 processes messages, produces and publishes two commitments. *) - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in let* commitment_period = get_sc_rollup_commitment_period_in_blocks client in - let init_level = init_level |> JSON.as_int in let* () = Sc_rollup_node.run sc_rollup_node in let sc_rollup_client = Sc_rollup_client.create sc_rollup_node in let* level = Sc_rollup_node.wait_for_level sc_rollup_node init_level in @@ -1816,11 +1819,11 @@ let test_rollup_origination_boot_sector = *) let test_rollup_node_uses_boot_sector = let go_boot client sc_rollup_address sc_rollup_node = - let* init_level = + let* genesis_info = RPC.Client.call ~hooks client - @@ RPC.Sc_rollup.get_initial_level sc_rollup_address + @@ RPC.Sc_rollup.get_genesis_info sc_rollup_address in - let init_level = init_level |> JSON.as_int in + let init_level = JSON.(genesis_info |-> "level" |> as_int) in let* () = Sc_rollup_node.run sc_rollup_node in @@ -2038,7 +2041,7 @@ let register ~protocols = test_rollup_node_running protocols ; test_rollup_client_gets_address protocols ; test_rollup_list protocols ; - test_rollup_get_initial_level protocols ; + test_rollup_get_genesis_info protocols ; test_rollup_get_last_cemented_commitment_hash_with_level protocols ; test_rollup_inbox_size protocols ; test_rollup_inbox_current_messages_hash protocols ;