From 3cba040caf407bd3033de4c344a401f3f26ddd48 Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Fri, 14 Oct 2022 14:45:00 +0200 Subject: [PATCH] Proto,WASM: Remove the Gather_floppies layer This layer is now redundant with the capability to update the kernel code. --- src/lib_protocol_environment/sigs/v8.ml | 2 + .../sigs/v8/wasm_2_0_0.mli | 2 + src/lib_scoru_wasm/durable.mli | 6 +- src/lib_scoru_wasm/gather_floppies.ml | 457 ----------------- src/lib_scoru_wasm/gather_floppies.mli | 81 --- src/lib_scoru_wasm/test/helpers/wasm_utils.ml | 13 +- .../test/test_fixed_nb_ticks.ml | 26 +- .../test/test_gather_floppies.ml | 240 --------- src/lib_scoru_wasm/test/test_get_set.ml | 37 +- src/lib_scoru_wasm/test/test_scoru_wasm.ml | 1 - src/lib_scoru_wasm/wasm_pvm.ml | 14 +- src/lib_scoru_wasm/wasm_pvm.mli | 2 +- src/lib_scoru_wasm/wasm_pvm_sig.ml | 5 + .../lib_protocol/test/integration/main.ml | 1 - .../test/integration/test_sc_rollup_wasm.ml | 477 ------------------ .../lib_protocol/test/unit/main.ml | 1 - .../test/unit/test_sc_rollup_wasm.ml | 85 ---- .../lib_protocol/sc_rollup_wasm.ml | 5 +- .../test/integration/test_sc_rollup_wasm.ml | 249 +-------- .../test/unit/test_sc_rollup_wasm.ml | 36 +- tezt/long_tests/sc_rollup.ml | 5 +- ..._0 - node boots into the initial state.out | 2 +- ...with kernel - no_parse_bad_fingerprint.out | 62 +-- ...0 - runs with kernel - no_parse_random.out | 62 +-- tezt/tests/sc_rollup.ml | 7 +- 25 files changed, 106 insertions(+), 1772 deletions(-) delete mode 100644 src/lib_scoru_wasm/gather_floppies.ml delete mode 100644 src/lib_scoru_wasm/gather_floppies.mli delete mode 100644 src/lib_scoru_wasm/test/test_gather_floppies.ml delete mode 100644 src/proto_015_PtLimaPt/lib_protocol/test/integration/test_sc_rollup_wasm.ml delete mode 100644 src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_wasm.ml diff --git a/src/lib_protocol_environment/sigs/v8.ml b/src/lib_protocol_environment/sigs/v8.ml index 88224440817f..437849e1af1c 100644 --- a/src/lib_protocol_environment/sigs/v8.ml +++ b/src/lib_protocol_environment/sigs/v8.ml @@ -11784,6 +11784,8 @@ type info = { module Make (Tree : Context.TREE with type key = string list and type value = bytes) : sig + val install_boot_sector : string -> Tree.tree -> Tree.tree Lwt.t + val compute_step : Tree.tree -> Tree.tree Lwt.t val set_input_step : input -> string -> Tree.tree -> Tree.tree Lwt.t diff --git a/src/lib_protocol_environment/sigs/v8/wasm_2_0_0.mli b/src/lib_protocol_environment/sigs/v8/wasm_2_0_0.mli index 942c6ba615e5..91d480db0a64 100644 --- a/src/lib_protocol_environment/sigs/v8/wasm_2_0_0.mli +++ b/src/lib_protocol_environment/sigs/v8/wasm_2_0_0.mli @@ -46,6 +46,8 @@ type info = { module Make (Tree : Context.TREE with type key = string list and type value = bytes) : sig + val install_boot_sector : string -> Tree.tree -> Tree.tree Lwt.t + val compute_step : Tree.tree -> Tree.tree Lwt.t val set_input_step : input -> string -> Tree.tree -> Tree.tree Lwt.t diff --git a/src/lib_scoru_wasm/durable.mli b/src/lib_scoru_wasm/durable.mli index 3c0a67744d63..23ce520055a0 100644 --- a/src/lib_scoru_wasm/durable.mli +++ b/src/lib_scoru_wasm/durable.mli @@ -75,18 +75,18 @@ val find_value : val find_value_exn : t -> key -> Tezos_lazy_containers.Chunked_byte_vector.t Lwt.t -(** [copy_tree_exn tree from_key to_key] produces a new tree in which a copy of +(** [copy_tree_exn tree from_key to_key] produces a new tree in which a copy of the entire subtree at from_key is copied to to_key.*) val copy_tree_exn : t -> key -> key -> t Lwt.t -(** [move_tree_exn tree from_key to_key] produces a new tree in which +(** [move_tree_exn tree from_key to_key] produces a new tree in which the entire subtree at from_key is moved to to_key.*) val move_tree_exn : t -> key -> key -> t Lwt.t (** [count_subtrees durable key] returns the number of subtrees under [key]. *) val count_subtrees : t -> key -> int Lwt.t -(** [subtree_name_at durable key n] returns the name of the n_th subtree +(** [subtree_name_at durable key n] returns the name of the n_th subtree under [key]. *) val subtree_name_at : t -> key -> int -> string Lwt.t diff --git a/src/lib_scoru_wasm/gather_floppies.ml b/src/lib_scoru_wasm/gather_floppies.ml deleted file mode 100644 index 121f29ca74df..000000000000 --- a/src/lib_scoru_wasm/gather_floppies.ml +++ /dev/null @@ -1,457 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 TriliTech *) -(* *) -(* 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. *) -(* *) -(*****************************************************************************) - -open Wasm_pvm_sig -open Wasm_pvm_state -open Tezos_lazy_containers - -(** FIXME: https://gitlab.com/tezos/tezos/-/issues/3361 - Increase the SCORU message size limit, and bump value to be 4,096. *) -let chunk_size = 4_000 - -exception Compute_step_expected_input - -exception Set_input_step_expected_compute_step - -exception Encoding_error of Data_encoding.Binary.write_error - -type internal_status = - | Gathering_floppies of Tezos_crypto.Signature.Public_key.t - | Not_gathering_floppies - -let internal_status_encoding = - let open Data_encoding in - union - [ - case - (Tag 0) - ~title:"Gathering_floppies" - (obj2 - (req "kind" (constant "gathering_floppies")) - (req "public_key" Tezos_crypto.Signature.Public_key.encoding)) - (function Gathering_floppies pk -> Some ((), pk) | _ -> None) - (fun ((), pk) -> Gathering_floppies pk); - case - (Tag 1) - ~title:"Not_gathering_floppies" - (obj1 (req "kind" (constant "Not_gathering_floppies"))) - (function Not_gathering_floppies -> Some () | _ -> None) - (fun () -> Not_gathering_floppies); - ] - -type chunk = bytes - -let chunk_encoding = Data_encoding.Bounded.bytes chunk_size - -type floppy = {chunk : chunk; signature : Tezos_crypto.Signature.t} - -let floppy_encoding = - Data_encoding.( - conv - (fun {chunk; signature} -> (chunk, signature)) - (fun (chunk, signature) -> {chunk; signature}) - (obj2 - (req "chunk" chunk_encoding) - (req "signature" Tezos_crypto.Signature.encoding))) - -(* Encoding for message in "boot sector" *) -type origination_message = - | Complete_kernel of bytes - | Incomplete_kernel of chunk * Tezos_crypto.Signature.Public_key.t - -let origination_message_encoding = - let open Data_encoding in - union - [ - case - ~title:"complete" - (Tag 0) - (obj1 @@ req "complete_kernel" bytes) - (function Complete_kernel s -> Some s | _ -> None) - (fun s -> Complete_kernel s); - case - ~title:"incomplete" - (Tag 1) - (obj2 - (req "first_chunk" chunk_encoding) - (req "public_key" Tezos_crypto.Signature.Public_key.encoding)) - (function Incomplete_kernel (s, pk) -> Some (s, pk) | _ -> None) - (fun (s, pk) -> Incomplete_kernel (s, pk)); - ] - -(* STORAGE KEYS *) - -module type S = sig - include Wasm_pvm_sig.S - - module Internal_for_tests : sig - include Wasm_pvm_sig.Internal_for_tests with type tree := tree - - val get_internal_status : tree -> internal_status option Lwt.t - - val initial_tree_from_boot_sector : empty_tree:tree -> string -> tree Lwt.t - end -end - -module Make - (T : Tezos_tree_encoding.TREE) - (Wasm : Wasm_pvm_sig.S with type tree = T.tree) : - S with type tree = T.tree = struct - type tree = Wasm.tree - - module Tree_encoding_runner = Tezos_tree_encoding.Runner.Make (T) - - (** The tick state of the [Gathering_floppies] instrumentation. *) - type state = { - internal_status : internal_status; - (** The instrumented PVM is either in the process of gathering - floppies, or is done with this pre-boot step. *) - last_input_info : input_info option; - (** This field is updated after each [read_input] step to - reflect the progression of the PVM. *) - kernel : Chunked_byte_vector.t; - (** The kernel being incrementally loaded into memory. *) - internal_tick : Z.t; - (** A counter updated after each small step execution of the - PVM. *) - } - - let boot_sector_merklizer : string Tezos_tree_encoding.t = - Tezos_tree_encoding.(value ["boot-sector"] Data_encoding.string) - - let state_merklizer : state Tezos_tree_encoding.t = - let open Tezos_tree_encoding in - conv - (fun (internal_status, last_input_info, internal_tick, kernel) -> - {internal_status; last_input_info; internal_tick; kernel}) - (fun {internal_status; last_input_info; internal_tick; kernel} -> - (internal_status, last_input_info, internal_tick, kernel)) - @@ tup4 - ~flatten:true - (value ["gather-floppies"; "status"] internal_status_encoding) - (value ["gather-floppies"; "last-input-info"] - @@ Data_encoding.option input_info_encoding) - (value ["gather-floppies"; "internal-tick"] Data_encoding.n) - (scope ["durable"; "kernel"; "boot.wasm"; "_"] chunked_byte_vector) - - (** [increment_ticks state] increments the number of ticks as stored - in [state], or set it to [1] in case it has not been initialized - yet. *) - let increment_ticks state = - {state with internal_tick = Z.succ state.internal_tick} - - type status = - | Halted of string - (** The PVM has not started yet, meaning the boot sector is - still to be interpreted as an [origination_message]. *) - | Running of state - (** The boot sector has been correctly interpreted, and the - PVM is running as expected. *) - | Broken of {current_tick : Z.t} - (** The boot sector was not a correctly encoded - [originatiom_message], causing the PVM to enter a broken - state. *) - - (** [broken_merklizer] is a partial schema to be used to encode the - number of ticks of the PVM when it is stuck. - - It only tries to fetch the current tick (with the same key as - the one used in [state_merklizer]. *) - let broken_merklizer = - Tezos_tree_encoding.value - ["gather-floppies"; "internal-tick"] - Data_encoding.n - - (** [read_state tree] fetches the current state of the PVM from - [tree]. *) - let read_state tree = - let open Lwt_syntax in - Lwt.catch - (fun () -> - (* First, we try to interpret [tree] as a [state]. *) - let+ state = Tree_encoding_runner.decode state_merklizer tree in - Running state) - (fun _exn -> - Lwt.catch - (fun () -> - (* If it fails, it means the PVM may be stuck. *) - let+ current_tick = - Tree_encoding_runner.decode broken_merklizer tree - in - Broken {current_tick}) - (fun _exn -> - (* In case both previous attempts have failed, it means - this is probably the very first tick of the PVM. *) - let+ boot_sector = - Tree_encoding_runner.decode boot_sector_merklizer tree - in - Halted boot_sector)) - - (* PROCESS MESSAGES *) - - (** [origination_kernel_loading_step boot_sector] implements the - tick consisting in initializing the [state] of the PVM from the - [boot_sector] supplied at origination time, or [None] iff - [boot_sector] cannot be decoded as a valid - [origination_message]. *) - let origination_kernel_loading_step boot_sector = - let boot_sector = - Data_encoding.Binary.of_string_opt - origination_message_encoding - boot_sector - in - match boot_sector with - | Some (Complete_kernel kernel) -> - let kernel = Chunked_byte_vector.of_bytes kernel in - Some - { - internal_status = Not_gathering_floppies; - last_input_info = None; - internal_tick = Z.one; - kernel; - } - | Some (Incomplete_kernel (chunk, _pk)) when Bytes.length chunk < chunk_size - -> - let kernel = Chunked_byte_vector.of_bytes chunk in - Some - { - internal_status = Not_gathering_floppies; - last_input_info = None; - internal_tick = Z.one; - kernel; - } - | Some (Incomplete_kernel (chunk, pk)) -> - let kernel = Chunked_byte_vector.of_bytes chunk in - Some - { - internal_status = Gathering_floppies pk; - last_input_info = None; - internal_tick = Z.one; - kernel; - } - | None -> None - - let read_floppy message = - let message_len = String.length message in - if 0 < message_len then - (* It is safe to read the very first character stored in - [message], that is [String.get] will not raise an exception. *) - match - ( String.get message 0, - Data_encoding.Binary.read floppy_encoding message 1 (message_len - 1) - ) - with - | '\001', Ok (_offset, floppy) -> Some floppy - | '\001', Error _error -> None - | _, _ -> None - else (* [message] is empty, that is it is not a valid input. *) - None - - (** [process_input_step input message state] interprets the incoming - [message] as part of the input tick characterized by - [input_info], and computes a new state for the instrumented PVM. - - It is expected that the instrumented PVM is expected to gather - floppies, that is [exists pk. state.status = Gathering_floppies - pk]. - - If the chunk encoded in [message] is not strictly equal to - {!chunk_size}, the instrumented PVM will consider the kernel to - be completed, and switch to [Not_gathering_floppies]. *) - let process_input_step input message state = - let open Lwt_syntax in - match state.internal_status with - | Gathering_floppies pk -> ( - match read_floppy message with - | Some {chunk; signature} -> - let state = {state with last_input_info = Some input} in - let offset = Chunked_byte_vector.length state.kernel in - let len = Bytes.length chunk in - if Tezos_crypto.Signature.check pk signature chunk then - let* () = - if 0 < len then ( - Chunked_byte_vector.grow state.kernel (Int64.of_int len) ; - Chunked_byte_vector.store_bytes state.kernel offset chunk) - else return_unit - in - return - { - state with - internal_status = - (if len < chunk_size then Not_gathering_floppies - else state.internal_status); - } - else - (* The incoming message does not come with a correct - signature: we ignore it. *) - return state - | None -> - (* [message] is empty, that is it is not a valid input. *) - return state) - | Not_gathering_floppies -> raise (Invalid_argument "process_input_step") - - (* Encapsulated WASM *) - - (** [compute_step_gen wasm_step tree] instruments [wasm_step] to check the - current status of the PVM. [wasm_step] must be a function that from a step - computes another step. - - {ul - {li If the state has not yet been initialized, it means it is - the very first step of the rollup, and we interpret the - [origination_message] that was provided at origination - time.} - {li If the status is [Gathering_floppies], then the PVM is - expected to receive the next kernel chunk, and - [compute_step] raises an exception.} - {li If the status is [Not_gathering_floppies], then the PVM - pre-boot has ended, the kernel has been provided, and - [wasm_step] is called.}} *) - let compute_step_gen wasm_step tree = - let open Lwt_syntax in - let* state = read_state tree in - match state with - | Broken {current_tick} -> - let+ result = - Tree_encoding_runner.encode - broken_merklizer - (Z.succ current_tick) - tree - in - (result, 1L) - | Halted origination_message -> - let+ result = - match origination_kernel_loading_step origination_message with - | Some state -> Tree_encoding_runner.encode state_merklizer state tree - | None -> - (* We could not interpret [origination_message], - meaning the PVM is stuck. *) - Tree_encoding_runner.encode broken_merklizer Z.one tree - in - (result, 1L) - | Running state -> ( - let state = increment_ticks state in - match state.internal_status with - | Gathering_floppies _ -> raise Compute_step_expected_input - | Not_gathering_floppies -> wasm_step tree) - - let compute_step tree = - Lwt.map fst @@ compute_step_gen (Wasm.compute_step_many ~max_steps:1L) tree - - (** [set_input_step input message tree] instruments - [Wasm.set_input_step] to interpret incoming input messages as - floppies (that is, a kernel chunk and a signature) when the PVM - status is [Gathering_floppies]. - - When the status is [Not_gathering_floppies] the pre-boot phase - has ended and [Wasm.set_input_step] is called. If the status has - not yet been initialized, this function raises an exception, as - the origination message has yet to be interpreted. *) - let set_input_step input message tree = - let open Lwt_syntax in - let* state = read_state tree in - match state with - | Halted _ | Broken _ -> raise Set_input_step_expected_compute_step - | Running state -> ( - let state = increment_ticks state in - match state.internal_status with - | Gathering_floppies _ -> - let* state = process_input_step input message state in - Tree_encoding_runner.encode state_merklizer state tree - | Not_gathering_floppies -> Wasm.set_input_step input message tree) - - let reveal_step = Wasm.reveal_step - - let get_output = Wasm.get_output - - let get_info tree = - let open Lwt_syntax in - let* state = read_state tree in - match state with - | Broken {current_tick} -> - return - { - current_tick; - last_input_read = None; - input_request = No_input_required; - } - | Halted _ -> - return - { - current_tick = Z.zero; - last_input_read = None; - input_request = No_input_required; - } - | Running state -> ( - match state.internal_status with - | Gathering_floppies _ -> - return - { - current_tick = state.internal_tick; - last_input_read = state.last_input_info; - input_request = Input_required; - } - | Not_gathering_floppies -> - let* inner_info = Wasm.get_info tree in - return - { - inner_info with - current_tick = - (* We consider [Wasm] as a black box. In particular, we - don’t know where [Wasm] is storing the number of - internal ticks it has interpreted, hence the need to - add both tick counters (the one introduced by our - instrumentation, and the one maintained by - [Wasm]). *) - Z.(add inner_info.current_tick state.internal_tick); - last_input_read = - Option.fold - ~none:state.last_input_info - ~some:(fun x -> Some x) - inner_info.last_input_read; - }) - - let compute_step_many ~max_steps = - compute_step_gen (Wasm.compute_step_many ~max_steps) - - module Internal_for_benchmark = Wasm.Internal_for_benchmark - - module Internal_for_tests = struct - include Wasm.Internal_for_tests - - let get_internal_status tree = - let open Lwt_syntax in - let+ state = read_state tree in - match state with Running state -> Some state.internal_status | _ -> None - - let initial_tree_from_boot_sector ~empty_tree boot_sector = - match origination_kernel_loading_step boot_sector with - | Some state -> - Tree_encoding_runner.encode state_merklizer state empty_tree - | None -> - raise - (Invalid_argument "initial_tree_from_boot_sector: wrong boot sector") - end -end diff --git a/src/lib_scoru_wasm/gather_floppies.mli b/src/lib_scoru_wasm/gather_floppies.mli deleted file mode 100644 index ce031d34ded5..000000000000 --- a/src/lib_scoru_wasm/gather_floppies.mli +++ /dev/null @@ -1,81 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 TriliTech *) -(* *) -(* 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. *) -(* *) -(*****************************************************************************) - -(** Raised when [compute_step] was called when the floppy gathering module - expected input. *) -exception Compute_step_expected_input - -(** Raised when the floppy gathering module wasn't expecting input, but input - was given using [set_input_step]. A [compute_step] is needed right after - origination. *) -exception Set_input_step_expected_compute_step - -(** Generic internal error. Some data in storage had errornous encoding. *) -exception Encoding_error of Data_encoding.Binary.write_error - -(** The instrumented PVM is either in a pre-boot state - ([Gathering_floppies]), or in its regular functioning state - ([Not_gathering_floppies]). *) -type internal_status = - | Gathering_floppies of Tezos_crypto.Signature.Public_key.t - | Not_gathering_floppies - -val internal_status_encoding : internal_status Data_encoding.t - -type chunk = bytes - -val chunk_size : int - -val chunk_encoding : chunk Data_encoding.t - -type floppy = {chunk : chunk; signature : Tezos_crypto.Signature.t} - -val floppy_encoding : floppy Data_encoding.t - -type origination_message = - | Complete_kernel of bytes - | Incomplete_kernel of chunk * Tezos_crypto.Signature.Public_key.t - -val origination_message_encoding : origination_message Data_encoding.t - -module type S = sig - include Wasm_pvm_sig.S - - module Internal_for_tests : sig - include Wasm_pvm_sig.Internal_for_tests with type tree := tree - - val get_internal_status : tree -> internal_status option Lwt.t - - val initial_tree_from_boot_sector : empty_tree:tree -> string -> tree Lwt.t - end -end - -(** [Make] encapsulates a WASM PVM to give it the ability to load a kernel - image as either a complete kernel in the origination message or a kernel - image divided into chunks and provided via both origination- and inbox- - messages. *) -module Make - (T : Tezos_tree_encoding.TREE) - (Wasm : Wasm_pvm_sig.S with type tree = T.tree) : S with type tree = T.tree diff --git a/src/lib_scoru_wasm/test/helpers/wasm_utils.ml b/src/lib_scoru_wasm/test/helpers/wasm_utils.ml index 24311ab5f13b..404fc8a10af6 100644 --- a/src/lib_scoru_wasm/test/helpers/wasm_utils.ml +++ b/src/lib_scoru_wasm/test/helpers/wasm_utils.ml @@ -47,17 +47,8 @@ let initial_tree ?(max_tick = default_max_tick) let open Lwt.Syntax in let max_tick_Z = Z.of_int64 max_tick in let* empty_tree = empty_tree () in - let* code = if from_binary then Lwt.return code else wat2wasm code in - let boot_sector = - Data_encoding.Binary.to_string_exn - Gather_floppies.origination_message_encoding - (Gather_floppies.Complete_kernel (String.to_bytes code)) - in - let* tree = - Wasm.Internal_for_tests.initial_tree_from_boot_sector - ~empty_tree - boot_sector - in + let* boot_sector = if from_binary then Lwt.return code else wat2wasm code in + let* tree = Wasm.install_boot_sector boot_sector empty_tree in let* tree = Wasm.Internal_for_tests.set_max_nb_ticks max_tick_Z tree in Wasm.Internal_for_tests.set_maximum_reboots_per_input max_reboots tree diff --git a/src/lib_scoru_wasm/test/test_fixed_nb_ticks.ml b/src/lib_scoru_wasm/test/test_fixed_nb_ticks.ml index dea8440af3f1..9b325b44e04c 100644 --- a/src/lib_scoru_wasm/test/test_fixed_nb_ticks.ml +++ b/src/lib_scoru_wasm/test/test_fixed_nb_ticks.ml @@ -57,8 +57,6 @@ let noop_module = ) |} -let origination_tick = Z.one - let snapshot_tick = Z.one let input_tick = Z.one @@ -69,9 +67,8 @@ let test_looping_kernel () = (* This module loops indefinitely. *) let*! loop_module_tree = initial_tree ~max_tick:max_nb_ticks loop_module in - let*! tree_snapshotted = eval_until_input_requested loop_module_tree in let*! tree_with_dummy_input = - set_input_step "dummy_input" 0 tree_snapshotted + set_input_step "dummy_input" 0 loop_module_tree in let* stuck, _ = eval_until_stuck tree_with_dummy_input in match stuck with @@ -95,8 +92,7 @@ let test_noop_kernel () = let*! tree = eval_until_input_requested tree_with_dummy_input in let*! info = Wasm.get_info tree in (* off-by-one introduced by Gather_floppies*) - return - (assert (Z.(info.current_tick = of_int64 max_nb_ticks + origination_tick))) + return (assert (Z.(info.current_tick = of_int64 max_nb_ticks))) let test_stuck_in_decode_kernel () = let open Lwt_result_syntax in @@ -107,21 +103,17 @@ let test_stuck_in_decode_kernel () = (* This module does a noop. *) let*! noop_module_tree = initial_tree ~max_tick:max_nb_ticks noop_module in - (* Eval until snapshot, which shouldn't take any tick since the default state - is Snapshot. *) - let*! tree_snapshotted = eval_until_input_requested noop_module_tree in (* Adds one input tick, part of the maximum number of ticks per toplevel call. *) let*! tree_with_dummy_input = - set_input_step "dummy_input" 0 tree_snapshotted + set_input_step "dummy_input" 0 noop_module_tree in (* Eval one tick *) let* stuck, tree = eval_until_stuck tree_with_dummy_input in assert (stuck = Too_many_ticks) ; let*! info = Wasm.get_info tree in (* off-by-one introduced by Gather_floppies*) - return - (assert (Z.(info.current_tick = of_int64 max_nb_ticks + origination_tick))) + return (assert (Z.(info.current_tick = of_int64 max_nb_ticks))) let test_stuck_in_init_kernel () = let open Lwt_result_syntax in @@ -129,13 +121,10 @@ let test_stuck_in_init_kernel () = (* This module does a noop. *) let*! noop_module_tree = initial_tree ~max_tick:max_nb_ticks noop_module in - (* Eval until snapshot, which shouldn't take any tick since the default state - is Snapshot. *) - let*! tree_snapshotted = eval_until_input_requested noop_module_tree in (* Adds one input tick, part of the maximum number of ticks per toplevel call. *) let*! tree_with_dummy_input = - set_input_step "dummy_input" 0 tree_snapshotted + set_input_step "dummy_input" 0 noop_module_tree in (* go to first Init step *) let*! tree = eval_until_init tree_with_dummy_input in @@ -144,7 +133,7 @@ let test_stuck_in_init_kernel () = (* set maximum to next tick and eval one more time *) let*! info = Wasm.get_info tree in - let new_max_nb_ticks = info.current_tick in + let new_max_nb_ticks = Z.succ info.current_tick in let*! tree = Wasm.Internal_for_tests.set_max_nb_ticks new_max_nb_ticks tree in let*! tree = Wasm.compute_step tree in @@ -152,8 +141,7 @@ let test_stuck_in_init_kernel () = let*! info = Wasm.get_info tree in let*! stuck = Wasm.Internal_for_tests.is_stuck tree in assert (stuck = Some Too_many_ticks) ; - (* off-by-one introduced by Gather_floppies*) - return (assert (Z.(info.current_tick = new_max_nb_ticks + origination_tick))) + return (assert (info.current_tick = new_max_nb_ticks)) let tests = [ diff --git a/src/lib_scoru_wasm/test/test_gather_floppies.ml b/src/lib_scoru_wasm/test/test_gather_floppies.ml deleted file mode 100644 index 904d0349ff2d..000000000000 --- a/src/lib_scoru_wasm/test/test_gather_floppies.ml +++ /dev/null @@ -1,240 +0,0 @@ -(*****************************************************************************) -(* *) -(* Open Source License *) -(* Copyright (c) 2022 Nomadic Labs *) -(* Copyright (c) 2022 TriliTech *) -(* *) -(* 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: Gather_floppies - Invocation: dune exec src/lib_scoru_wasm/test/test_scoru_wasm.exe \ - -- test "^Gather floppies$" - Subject: Gather floppies tests -*) - -open Tztest -open Tezos_scoru_wasm -open Test_encodings_util -open Wasm_utils - -(* [account ()] returns a new account usable to sign floppies. *) -let account () = - let _pkh, pk, sk = Tezos_crypto.Signature.generate_key () in - (pk, sk) - -(* Corresponds to `Constants_repr.sc_rollup_message_size_limit` in the - protocol. *) -let sc_rollup_message_size_limit = 4096 - -(* [fake_inbox_message_encoding] simulates an external message from the rollup - inbox. *) -let fake_inbox_message_encoding = - let open Data_encoding in - check_size - sc_rollup_message_size_limit - (union - [ - case - (Tag 1) - ~title:"External" - Variable.string - (function `External msg -> Some msg) - (fun msg -> `External msg); - ]) - -(* [set_floppy_input_step chunk sk counter tree] encodes a [chunk] as a valid - input from the rollup perspective, by signing it with [sk], and setting it as - next input in [tree] with the given message [counter], at inbox level [0]. *) -let set_floppy_input_step chunk sk counter tree = - let signature = Tezos_crypto.Signature.sign sk chunk in - let input = - Data_encoding.Binary.to_string_exn Gather_floppies.floppy_encoding - @@ Gather_floppies.{chunk; signature} - in - let encoded_input = - Data_encoding.Binary.to_string_exn fake_inbox_message_encoding - @@ `External input - in - let input_info = - Wasm_pvm_state. - { - inbox_level = - Option.value_f ~default:(fun () -> assert false) - @@ Tezos_base.Bounded.Non_negative_int32.of_value 0l; - message_counter = Z.of_int counter; - } - in - Wasm.set_input_step input_info encoded_input tree - -(* Extracted from - src/proto_alpha/lib_protocol/test/integration/test_sc_rollup_wasm.ml *) -let make_chunks kernel pk = - let chunk_size = Gather_floppies.chunk_size in - let initial_chunk, rem_chunks = - let split_chunk s = - let len = String.length s in - let size = min len chunk_size in - let chunk = String.sub s 0 size in - let rest = - if len > chunk_size then Some (String.sub s size @@ (len - size)) - else None - in - (chunk, rest) - in - let rec do_chunks chunks left = - match left with - | None -> chunks - | Some left -> - let chunk, rest = split_chunk left in - (do_chunks [@tailcall]) (chunk :: chunks) rest - in - let initial, rest = split_chunk kernel in - (initial, List.rev @@ do_chunks [] rest) - in - let initial_chunk = - Data_encoding.Binary.to_string_exn - Gather_floppies.origination_message_encoding - @@ Incomplete_kernel (Bytes.of_string initial_chunk, pk) - in - let chunks = - rem_chunks - |> List.take_n (List.length rem_chunks - 1) - |> List.map Bytes.of_string - in - let final_chunk = Bytes.of_string @@ List.last "" rem_chunks in - let final_chunk_size = Bytes.length final_chunk in - (initial_chunk, chunks, final_chunk, final_chunk_size) - -(* [initial_tree ~max_tick initial_chunck] builds a tree out of an encoded - initial chunk. *) -let initial_tree ?(max_tick = 100000L) initial_chunk = - let open Lwt.Syntax in - let max_tick_Z = Z.of_int64 max_tick in - let* empty_tree = empty_tree () in - let* tree = - Wasm.Internal_for_tests.initial_tree_from_boot_sector - ~empty_tree - initial_chunk - in - Wasm.Internal_for_tests.set_max_nb_ticks max_tick_Z tree - -let pp_internal_status ppf = function - | Gather_floppies.Gathering_floppies pk -> - Format.fprintf ppf "Gathering_floppies %a" Signature.Public_key.pp pk - | Not_gathering_floppies -> Format.fprintf ppf "Not_gathering_floppies" - -(* [check_gathering_status expected_status tree] checks the current status of `Gather_floppies` - against the given [expected_status]. *) -let check_gathering_status expected_status tree = - let open Lwt_result_syntax in - let*! internal_status = Wasm.Internal_for_tests.get_internal_status tree in - match (internal_status, expected_status) with - | None, _ -> failwith "Gathering floppies has failed" - | Some (Gathering_floppies pk), Gather_floppies.Gathering_floppies pk' -> - if not (Signature.Public_key.equal pk pk') then failwith "" - else return_unit - | Some Not_gathering_floppies, Not_gathering_floppies -> return_unit - | Some status, _ -> - failwith - "Unexpected gathering status %a, expected %a" - pp_internal_status - status - pp_internal_status - expected_status - -(* [init_tree_with_floppies kernel] builds a tree out of a kernel by chunkifying - it, and install each of them one by one as would the rollup do. *) -let init_tree_with_floppies ?(max_steps = Wasm_utils.default_max_tick) kernel = - let open Lwt_result_syntax in - let pk, sk = account () in - let initial_chunk, chunks, final_chunk, _final_chunk_size = - make_chunks kernel pk - in - let*! tree = initial_tree initial_chunk in - (* This forces it to go through `Gather_floppies.compute_step_many if need be, - but it actually shouldn't. *) - let*! tree = eval_until_input_requested ~max_steps tree in - let set_input (tree, counter) chunk = - let*! info = Wasm.get_info tree in - if info.input_request = Wasm_pvm_state.Input_required then - let*! tree = set_floppy_input_step chunk sk counter tree in - let+ () = check_gathering_status (Gathering_floppies pk) tree in - (tree, succ counter) - else return (tree, counter) - in - let* tree, counter = List.fold_left_es set_input (tree, 0) chunks in - let*! tree = set_floppy_input_step final_chunk sk counter tree in - return tree - -let test_gather_floppies_until_first_PVM_input kernel = - let open Lwt_result_syntax in - let* tree = init_tree_with_floppies kernel in - check_gathering_status Not_gathering_floppies tree - -let test_gather_floppies_and_compute ~max_steps kernel = - let open Lwt_result_syntax in - let* tree = init_tree_with_floppies ~max_steps kernel in - (* Make the first ticks of the WASM PVM (parsing of origination - message, snapshot,n parsing and init of the kernel), to switch it to - “Input_requested” mode. *) - let*! tree_snapshotted = eval_until_input_requested tree in - (* Feeding it with one input *) - let*! tree_with_input = set_input_step "test" 0 tree_snapshotted in - (* running until waiting for next input *) - let*! tree = eval_until_input_requested tree_with_input in - let*! state_after_first_message = - Wasm.Internal_for_tests.get_tick_state tree - in - (* The kernel is expected to fail, then ths PVM should be in stuck state, and - have failed during the evaluation when evaluating a `Unreachable` - instruction. *) - assert ( - is_stuck - ~step:`Eval - ~reason:"unreachable executed" - state_after_first_message) ; - return_unit - -(* Tests are using `unreachable.wasm`, which is 9842 Bytes long, hence contained - in 3 chunks. *) -let tests = - [ - tztest - "Test unreachable kernel until first PVM input" - `Quick - (test_with_kernel - Kernels.unreachable_kernel - test_gather_floppies_until_first_PVM_input); - tztest - "Test unreachable kernel with a PVM input, one step at a time" - `Quick - (test_with_kernel - Kernels.unreachable_kernel - (test_gather_floppies_and_compute ~max_steps:1L)); - tztest - "Test unreachable kernel with a PVM input, 10_000 steps at a time" - `Quick - (test_with_kernel - Kernels.unreachable_kernel - (test_gather_floppies_and_compute ~max_steps:10_000L)); - ] diff --git a/src/lib_scoru_wasm/test/test_get_set.ml b/src/lib_scoru_wasm/test/test_get_set.ml index bc248673e16d..f22978cf26af 100644 --- a/src/lib_scoru_wasm/test/test_get_set.ml +++ b/src/lib_scoru_wasm/test/test_get_set.ml @@ -65,11 +65,6 @@ module Tree_encoding_runner = Tezos_tree_encoding.Runner.Make (Tree) let current_tick_encoding = Tezos_tree_encoding.value ["wasm"; "current_tick"] Data_encoding.n -let floppy_encoding = - Tezos_tree_encoding.value - ["gather-floppies"; "status"] - Gather_floppies.internal_status_encoding - let inp_encoding = Tezos_tree_encoding.value ["input"; "0"; "1"] Data_encoding.string @@ -82,30 +77,8 @@ let zero = ~loc:__LOC__ (Bounded.Non_negative_int32.of_value 0l) -(** Artificial initialization. Under normal circumstances the changes in - [current_tick], [gather_floppies] and [status] will be done by the other - PVM operations. for example the [origination_kernel_loading_step] in - Gather_floppies will initialize both the [current_tick] and the - [gather_floppies] *) let initialise_tree () = - let open Lwt_syntax in - let* empty_tree = empty_tree () in - let boot_sector = - Data_encoding.Binary.to_string_exn - Gather_floppies.origination_message_encoding - (Complete_kernel (Bytes.of_string "some boot sector")) - in - let* tree = - Wasm.Internal_for_tests.initial_tree_from_boot_sector - ~empty_tree - boot_sector - in - - let* tree = Tree_encoding_runner.encode current_tick_encoding Z.zero tree in - Tree_encoding_runner.encode - floppy_encoding - Gather_floppies.Not_gathering_floppies - tree + Wasm_utils.initial_tree ~from_binary:true "arbitrary boot sector" let make_inbox_info ~inbox_level ~message_counter = Wasm_pvm_state. @@ -154,7 +127,7 @@ let test_get_info () = Some (make_inbox_info ~inbox_level ~message_counter) in { - current_tick = Z.one; + current_tick = Z.zero; last_input_read; input_request = Input_required @@ -211,11 +184,7 @@ let test_set_input () = let last_input_read = Some (make_inbox_info ~inbox_level:5 ~message_counter:10) in - { - current_tick = Z.(succ one); - last_input_read; - input_request = No_input_required; - } + {current_tick = Z.one; last_input_read; input_request = No_input_required} in let* actual_info = Wasm.get_info tree in assert (actual_info = expected_info) ; diff --git a/src/lib_scoru_wasm/test/test_scoru_wasm.ml b/src/lib_scoru_wasm/test/test_scoru_wasm.ml index 6b7595d999bd..ac721436e3c8 100644 --- a/src/lib_scoru_wasm/test/test_scoru_wasm.ml +++ b/src/lib_scoru_wasm/test/test_scoru_wasm.ml @@ -47,6 +47,5 @@ let () = ("Max nb of ticks", Test_fixed_nb_ticks.tests); ("Hash correspondence", Test_hash_consistency.tests); ("Reveal", Test_reveal.tests); - ("Gather floppies", Test_gather_floppies.tests); ] |> Lwt_main.run diff --git a/src/lib_scoru_wasm/wasm_pvm.ml b/src/lib_scoru_wasm/wasm_pvm.ml index 7fd58d61fc60..f43c9c35e077 100644 --- a/src/lib_scoru_wasm/wasm_pvm.ml +++ b/src/lib_scoru_wasm/wasm_pvm.ml @@ -168,7 +168,7 @@ let pvm_state_encoding = Data_encoding.n)) module Make (T : Tezos_tree_encoding.TREE) : - Gather_floppies.S with type tree = T.tree = struct + Wasm_pvm_sig.S with type tree = T.tree = struct module Raw = struct type tree = T.tree @@ -387,7 +387,7 @@ module Make (T : Tezos_tree_encoding.TREE) : | Restarting | Failing -> maximum_reboots_per_input | Starting | Running -> reboot_counter - (** [compute_step_inner pvm_state] does one computation step on [pvm_state]. + (** [compute_step_inner pvm_state] does one computation step on [pvm_state]. Returns the new state. *) let compute_step_inner pvm_state = @@ -459,6 +459,14 @@ module Make (T : Tezos_tree_encoding.TREE) : let* tree = T.remove tree ["wasm"] in Tree_encoding_runner.encode pvm_state_encoding pvm_state tree + let install_boot_sector bs tree = + let bs = Tezos_lazy_containers.Chunked_byte_vector.of_string bs in + Tree_encoding_runner.encode + Tezos_tree_encoding.( + scope ["durable"; "kernel"; "boot.wasm"; "_"] chunked_byte_vector) + bs + tree + let compute_step_many_until_pvm_state ?(max_steps = 1L) should_continue = let open Lwt.Syntax in assert (max_steps > 0L) ; @@ -729,5 +737,5 @@ module Make (T : Tezos_tree_encoding.TREE) : end end - include Gather_floppies.Make (T) (Raw) + include Raw end diff --git a/src/lib_scoru_wasm/wasm_pvm.mli b/src/lib_scoru_wasm/wasm_pvm.mli index ba58b5c35e71..05c46374d396 100644 --- a/src/lib_scoru_wasm/wasm_pvm.mli +++ b/src/lib_scoru_wasm/wasm_pvm.mli @@ -25,4 +25,4 @@ (*****************************************************************************) module Make (T : Tezos_tree_encoding.TREE) : - Gather_floppies.S with type tree = T.tree + Wasm_pvm_sig.S with type tree = T.tree diff --git a/src/lib_scoru_wasm/wasm_pvm_sig.ml b/src/lib_scoru_wasm/wasm_pvm_sig.ml index d1ca47fcd75c..94cc3ee2e8f4 100644 --- a/src/lib_scoru_wasm/wasm_pvm_sig.ml +++ b/src/lib_scoru_wasm/wasm_pvm_sig.ml @@ -108,6 +108,11 @@ end module type S = sig type tree + (** [install_boot_sector payload tree] installs the [payload] passed + as an argument in [tree] so that it is interpreted as the kernel + to be used by the PVM. *) + val install_boot_sector : string -> tree -> tree Lwt.t + (** [compute_step_many ~max_steps tree] forwards the VM by at most [max_step] compute tick, yielding if it reaches the maximum number of ticks for a toplevel kernel call. If the VM is expecting input, it gets stuck. If the diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/main.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/main.ml index cc4b5cd0f515..e8dc7b74eb26 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/main.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/integration/main.ml @@ -40,6 +40,5 @@ let () = ("storage tests", Test_storage_functions.tests); ("token movements", Test_token.tests); ("frozen bonds", Test_frozen_bonds.tests); - ("sc rollup wasm", Test_sc_rollup_wasm.tests); ] |> Lwt_main.run diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_sc_rollup_wasm.ml b/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_sc_rollup_wasm.ml deleted file mode 100644 index cdf4309b4d08..000000000000 --- a/src/proto_015_PtLimaPt/lib_protocol/test/integration/test_sc_rollup_wasm.ml +++ /dev/null @@ -1,477 +0,0 @@ -(*****************************************************************************) -(* *) -(* 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: sc rollup wasm - Invocation: dune exec \ - src/proto_alpha/lib_protocol/test/integration/main.exe \ - -- test "^sc rollup wasm$" - Subject: Test the WASM 2.0 PVM. -*) - -open Protocol -open Alpha_context -module Context_binary = Tezos_context_memory.Context_binary - -module Tree : - Environment.Context.TREE - with type t = Context_binary.t - and type tree = Context_binary.tree - and type key = string list - and type value = bytes = struct - type t = Context_binary.t - - type tree = Context_binary.tree - - type key = Context_binary.key - - type value = Context_binary.value - - include Context_binary.Tree -end - -module WASM_P : - Protocol.Alpha_context.Sc_rollup.Wasm_2_0_0PVM.P - with type Tree.t = Context_binary.t - and type Tree.tree = Context_binary.tree - and type Tree.key = string list - and type Tree.value = bytes - and type proof = Context_binary.Proof.tree Context_binary.Proof.t = struct - module Tree = Tree - - type tree = Tree.tree - - type proof = Context_binary.Proof.tree Context_binary.Proof.t - - let proof_encoding = - Tezos_context_merkle_proof_encoding.Merkle_proof_encoding.V2.Tree2 - .tree_proof_encoding - - let kinded_hash_to_state_hash : - Context_binary.Proof.kinded_hash -> Sc_rollup.State_hash.t = 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_binary.Proof.before - - let proof_after proof = - kinded_hash_to_state_hash proof.Context_binary.Proof.after - - let produce_proof context tree step = - let open Lwt_syntax in - let* context = Context_binary.add_tree context [] tree in - let _hash = Context_binary.commit ~time:Time.Protocol.epoch context in - let index = Context_binary.index context in - match Context_binary.Tree.kinded_key tree with - | Some k -> - let* p = Context_binary.produce_tree_proof index k step in - return (Some p) - | None -> - Stdlib.failwith - "produce_proof: internal error, [kinded_key] returned [None]" - - let verify_proof proof step = - let open Lwt_syntax in - let* result = Context_binary.verify_tree_proof proof step in - match result with - | Ok v -> return (Some v) - | Error _ -> - (* We skip the error analysis here since proof verification is not a - job for the rollup node. *) - return None -end - -module Verifier = Alpha_context.Sc_rollup.Wasm_2_0_0PVM.Protocol_implementation - -module Prover = - Alpha_context.Sc_rollup.Wasm_2_0_0PVM.Make - (Environment.Wasm_2_0_0.Make) - (WASM_P) -(* Helpers *) - -(* FIXME: https://gitlab.com/tezos/tezos/-/issues/2198 - SCORU system should expose a constant upper bound for proof size. - One suggestion for this constant is 16KB. Unfortunately, the proof - that are generated in “realistic” scenarios are still too big. - - If #2198 is addressed, and a constant is added to the protocol to - limit the maximum size of a valid SCORU proof, then the value here - should reflect that. *) -let proof_size_limit = 16 * 1024 - -let check_proof_size ~loc context input_opt s = - let open Lwt_result_syntax in - let*! proof = Prover.produce_proof context input_opt s in - match proof with - | Error _ -> Stdlib.failwith "missing proof" - | Ok proof -> - let bytes = - Data_encoding.Binary.to_bytes_exn Prover.proof_encoding proof - in - Assert.leq_int ~loc (Bytes.length bytes) proof_size_limit - -(* Like [eval] but also checks the proof size. *) -let checked_eval ~loc context s = - let open Lwt_result_syntax in - let* () = check_proof_size ~loc context None s in - let*! s = Prover.eval s in - return s - -(* Like [set_input] but also checks the proof size. *) -let checked_set_input ~loc context input s = - let open Lwt_result_syntax in - let* () = check_proof_size ~loc context (Some input) s in - let*! s = Prover.set_input input s in - return s - -let complete_boot_sector sector : - Tezos_scoru_wasm.Gather_floppies.origination_message = - Complete_kernel sector - -let incomplete_boot_sector sector Account.{pk; _} : - Tezos_scoru_wasm.Gather_floppies.origination_message = - Incomplete_kernel (Bytes.of_string sector, pk) - -let find tree key encoding = - let open Lwt.Syntax in - Format.printf "f %s\n" (String.concat "/" key) ; - let+ value = Context_binary.Tree.find tree key in - match value with - | Some bytes -> - Format.printf "v %S\n" (Bytes.to_string bytes) ; - Some (Data_encoding.Binary.of_bytes_exn encoding bytes) - | None -> None - -let find_status tree = - find - tree - ["gather-floppies"; "status"] - Tezos_scoru_wasm.Gather_floppies.internal_status_encoding - -let get_chunks_count tree = - let open Lwt.Syntax in - let+ len = - find - tree - ["durable"; "kernel"; "boot.wasm"; "_"; "length"] - Data_encoding.int64 - in - Option.fold ~none:0 ~some:Int64.to_int len - -let check_status tree expected = - let open Lwt.Syntax in - let* status = find_status tree in - match (status, expected) with - | Some status, Some expected -> - assert (status = expected) ; - Lwt.return () - | None, None -> Lwt.return () - | _, _ -> assert false - -let check_chunks_count tree expected = - let open Lwt.Syntax in - let* count = get_chunks_count tree in - if count = expected then Lwt_result.return () - else failwith "wrong chunks counter, expected %d, got %d" expected count - -let operator () = - match Account.generate_accounts 1 with - | [(account, _, _)] -> account - | _ -> assert false - -let should_boot_complete_boot_sector boot_sector () = - let open Tezos_scoru_wasm.Gather_floppies in - let open Lwt_result_syntax in - let*! index = Context_binary.init "/tmp" in - let context = Context_binary.empty index in - (* The number of chunks necessary to store the kernel. *) - let boot_sector_len = - match boot_sector with - | Complete_kernel bytes | Incomplete_kernel (bytes, _) -> Bytes.length bytes - in - let boot_sector = - Data_encoding.Binary.to_string_exn origination_message_encoding boot_sector - in - (* We create a new PVM, and install the boot sector. *) - let*! s = Prover.initial_state context in - let*! s = Prover.install_boot_sector s boot_sector in - (* After this first step, the PVM has just loaded the boot sector in - "/boot-sector", and nothing more. As a consequence, most of the - step of the [Gather_floppies] instrumentation is not set. *) - let*! () = check_status s None in - let* () = check_chunks_count s 0 in - (* At this step, the [eval] function of the PVM will interpret the - origination message encoded in [boot_sector]. *) - let* s = checked_eval ~loc:__LOC__ context s in - (* We expect that the WASM does not expect more floppies, and that - the kernel as been correctly splitted into several chunks. *) - let*! () = check_status s (Some Not_gathering_floppies) in - let* () = check_chunks_count s boot_sector_len in - return_unit - -let arbitrary_input i payload = - match Sc_rollup.Inbox_message.serialize (External payload) with - | Ok payload -> - Sc_rollup.Inbox_message - { - inbox_level = Raw_level.of_int32_exn 0l; - message_counter = Z.of_int i; - payload; - } - | Error err -> - Format.printf "%a@," Environment.Error_monad.pp_trace err ; - assert false - -let floppy_input i operator chunk = - let signature = Signature.sign operator.Account.sk chunk in - let floppy = Tezos_scoru_wasm.Gather_floppies.{chunk; signature} in - arbitrary_input - i - (Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm.Gather_floppies.floppy_encoding - floppy) - -let should_interpret_empty_chunk () = - let open Lwt_result_syntax in - let op = operator () in - let chunk_size = Tezos_scoru_wasm.Gather_floppies.chunk_size in - let origination_message = - Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm__Gather_floppies.origination_message_encoding - @@ incomplete_boot_sector (String.make chunk_size 'a') op - in - let chunk = Bytes.empty in - let correct_input = floppy_input 0 op chunk in - - (* Init the PVM *) - let*! index = Context_binary.init "/tmp" in - let context = Context_binary.empty index in - let*! s = Prover.initial_state context in - let*! s = Prover.install_boot_sector s origination_message in - (* Intererptation of the origination message *) - let* s = checked_eval ~loc:__LOC__ context s in - let*! () = check_status s (Some (Gathering_floppies op.pk)) in - let* () = check_chunks_count s chunk_size in - (* Try to interpret the empty input (correctly signed) *) - let*! s = Prover.set_input correct_input s in - let*! () = check_status s (Some Not_gathering_floppies) in - (* We still have 1 chunk. *) - let* () = check_chunks_count s chunk_size in - return_unit - -let should_refuse_chunks_with_incorrect_signature () = - let open Lwt_result_syntax in - let good_op = operator () in - let bad_op = operator () in - let chunk_size = Tezos_scoru_wasm.Gather_floppies.chunk_size in - let origination_message = - Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm__Gather_floppies.origination_message_encoding - @@ incomplete_boot_sector (String.make chunk_size 'a') good_op - in - let chunk = Bytes.make chunk_size 'b' in - let incorrect_input = floppy_input 0 bad_op chunk in - let correct_input = floppy_input 0 good_op chunk in - - (* Init the PVM *) - let*! index = Context_binary.init "/tmp" in - let context = Context_binary.empty index in - let*! s = Prover.initial_state context in - let*! s = Prover.install_boot_sector s origination_message in - (* Intererptation of the origination message *) - let* s = checked_eval ~loc:__LOC__ context s in - let*! () = check_status s (Some (Gathering_floppies good_op.pk)) in - let* () = check_chunks_count s chunk_size in - (* Try to interpret the incorrect input (badly signed) *) - let* s = checked_set_input ~loc:__LOC__ context incorrect_input s in - let*! () = check_status s (Some (Gathering_floppies good_op.pk)) in - (* We still have 1 chunk. *) - let* () = check_chunks_count s chunk_size in - (* Try to interpret the correct input (correctly signed) *) - let* s = checked_set_input ~loc:__LOC__ context correct_input s in - let*! () = check_status s (Some (Gathering_floppies good_op.pk)) in - (* We now have 2 chunks. *) - let* () = check_chunks_count s (2 * chunk_size) in - return_unit - -let should_boot_incomplete_boot_sector kernel () = - let open Lwt_result_syntax in - let operator = operator () in - let chunk_size = Tezos_scoru_wasm.Gather_floppies.chunk_size in - let initial_chunk, rem_chunks = - let split_chunk s = - let len = String.length s in - let size = min len chunk_size in - let chunk = String.sub s 0 size in - let rest = - if len > chunk_size then Some (String.sub s size @@ (len - size)) - else None - in - (chunk, rest) - in - let rec do_chunks chunks left = - match left with - | None -> chunks - | Some left -> - let chunk, rest = split_chunk left in - (do_chunks [@tailcall]) (chunk :: chunks) rest - in - let initial, rest = split_chunk kernel in - (initial, List.rev @@ do_chunks [] rest) - in - let initial_chunk = - Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm__Gather_floppies.origination_message_encoding - @@ incomplete_boot_sector initial_chunk operator - in - let chunks = - rem_chunks - |> List.take_n (List.length rem_chunks - 1) - |> List.map Bytes.of_string - in - let final_chunk = Bytes.of_string @@ List.last "" rem_chunks in - let final_chunk_size = Bytes.length final_chunk 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.install_boot_sector s initial_chunk in - let* () = check_proof_size ~loc:__LOC__ context None s in - let*! () = check_status s None in - let* () = check_chunks_count s 0 in - (* First tick, to interpret the boot sector. One chunk have been - provided, and the PVM expects more chunk to come. *) - let* s = checked_eval ~loc:__LOC__ context s in - let*! () = check_status s (Some (Gathering_floppies operator.pk)) in - let* () = check_chunks_count s chunk_size in - (* Then, installing the additional chunks. *) - let* s = - List.fold_left_i_es - (fun i s chunk -> - (* We are installing the [i+2]th chunk ([i] starts at 0, and - the first chunk is not part of the list). *) - let input = floppy_input i operator chunk in - let* s = checked_set_input ~loc:__LOC__ context input s in - (* We have [i+2] chunks. *) - let* () = check_chunks_count s ((i + 2) * chunk_size) in - return s) - s - chunks - in - (* Up until the very last one, where the status of the PVM change. *) - let len = List.length chunks in - let input = floppy_input len operator final_chunk in - let* s = checked_set_input ~loc:__LOC__ context input s in - let*! () = check_status s (Some Not_gathering_floppies) in - let* () = - check_chunks_count s (((len + 1) * chunk_size) + final_chunk_size) - in - return_unit - -(* Read the chosen `wasm_kernel` into memory. *) -let read_kernel name = - let open Tezt.Base in - let kernel_file = - project_root // Filename.dirname __FILE__ // "wasm_kernel" - // (name ^ ".wasm") - in - read_file kernel_file - -(* Kernel with allocation & simple computation only. - 9863 bytes long - will be split into 3 chunks. *) -let computation_kernel () = read_kernel "computation" - -let rec eval_until_set_input context s = - let open Lwt_result_syntax in - let*! info = Prover.get_status s in - match info with - | Computing -> - let* s = checked_eval ~loc:__LOC__ context s in - eval_until_set_input context s - | Waiting_for_input_message -> return s - -let should_boot_computation_kernel () = - let open Lwt_result_syntax in - let boot_sector = - Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm.Gather_floppies.origination_message_encoding - (complete_boot_sector (String.to_bytes (computation_kernel ()))) - in - let*! index = Context_binary.init "/tmp" in - let context = Context_binary.empty index in - let*! s = Prover.initial_state context in - (* sets a reasonable nb-of-tick limit to limit test running time *) - let*! s = - Tree.add - s - ["pvm"; "max_nb_ticks"] - (Data_encoding.Binary.to_bytes_exn Data_encoding.n (Z.of_int 50_000)) - in - let*! s = Prover.install_boot_sector s boot_sector in - (* installing the boot kernel *) - let* s = checked_eval ~loc:__LOC__ context s in - (* Make the first ticks of the WASM PVM (parsing of origination - message, parsing and init of the kernel), to switch it to - “waiting for input” mode. *) - let* s = eval_until_set_input context s in - (* Feeding it with one input *) - let* s = - checked_set_input ~loc:__LOC__ context (arbitrary_input 0 "test") s - in - (* running until waiting for input *) - let* _s = eval_until_set_input context s in - return_unit - -let tests = - [ - Tztest.tztest "should boot a complete boot sector" `Quick - @@ should_boot_complete_boot_sector - (complete_boot_sector (Bytes.of_string @@ computation_kernel ())); - ( Tztest.tztest "should boot an incomplete but too small boot sector" `Quick - @@ fun () -> - let operator = operator () in - should_boot_complete_boot_sector - (incomplete_boot_sector "\x00asm\x01\x00\x00\x00" operator) - () ); - Tztest.tztest - "should boot an incomplete boot sector with floppies" - `Quick - (should_boot_incomplete_boot_sector @@ computation_kernel ()); - Tztest.tztest - "should interpret an empty chunk as EOF" - `Quick - should_interpret_empty_chunk; - Tztest.tztest - "should refuse chunks with an incorrect signature" - `Quick - should_refuse_chunks_with_incorrect_signature; - Tztest.tztest - "should boot a valid kernel until reading inputs" - `Quick - should_boot_computation_kernel; - ] diff --git a/src/proto_015_PtLimaPt/lib_protocol/test/unit/main.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/main.ml index b6bbb3489739..b22d7eb3aa62 100644 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/main.ml +++ b/src/proto_015_PtLimaPt/lib_protocol/test/unit/main.ml @@ -73,7 +73,6 @@ 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_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_wasm.ml b/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_wasm.ml deleted file mode 100644 index 0630ecc37e0d..000000000000 --- a/src/proto_015_PtLimaPt/lib_protocol/test/unit/test_sc_rollup_wasm.ml +++ /dev/null @@ -1,85 +0,0 @@ -(*****************************************************************************) -(* *) -(* 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 test_incomplete_kernel_chunk_limit () = - let open Lwt_result_syntax in - let operator = - match Account.generate_accounts 1 with - | [(account, _, _)] -> account - | _ -> assert false - in - let chunk_size = Tezos_scoru_wasm.Gather_floppies.chunk_size in - let chunk_too_big = Bytes.make (chunk_size + 10) 'a' in - let signature = Signature.sign operator.Account.sk chunk_too_big in - let floppy = - Tezos_scoru_wasm.Gather_floppies.{chunk = chunk_too_big; signature} - in - match - Data_encoding.Binary.to_string_opt - Tezos_scoru_wasm.Gather_floppies.floppy_encoding - floppy - with - | None -> return_unit - | Some _ -> failwith "encoding of a floppy with a chunk too large should fail" - -let tests = - [ - Tztest.tztest - "initial state hash for Wasm" - `Quick - test_initial_state_hash_wasm_pvm; - Tztest.tztest - "encoding of a floppy with a chunk too large should fail" - `Quick - test_incomplete_kernel_chunk_limit; - ] diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index e2ab200a4aed..65d990edf40b 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -201,10 +201,7 @@ module V2_0_0 = struct Lwt.return state let install_boot_sector state boot_sector = - Tree.add - state - ["boot-sector"] - Data_encoding.(Binary.to_bytes_exn string boot_sector) + WASM_machine.install_boot_sector boot_sector state let state_hash state = let context_hash = Tree.hash state in 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 44a75733d174..46369c9f3f80 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 @@ -149,14 +149,6 @@ let checked_set_input ~loc context input s = let*! s = Prover.set_input input s in return s -let complete_boot_sector sector : - Tezos_scoru_wasm.Gather_floppies.origination_message = - Complete_kernel sector - -let incomplete_boot_sector sector Account.{pk; _} : - Tezos_scoru_wasm.Gather_floppies.origination_message = - Incomplete_kernel (Bytes.of_string sector, pk) - let find tree key encoding = let open Lwt.Syntax in Format.printf "f %s\n" (String.concat "/" key) ; @@ -167,70 +159,8 @@ let find tree key encoding = Some (Data_encoding.Binary.of_bytes_exn encoding bytes) | None -> None -let find_status tree = - find - tree - ["gather-floppies"; "status"] - Tezos_scoru_wasm.Gather_floppies.internal_status_encoding - -let get_chunks_count tree = - let open Lwt.Syntax in - let+ len = - find - tree - ["durable"; "kernel"; "boot.wasm"; "_"; "length"] - Data_encoding.int64 - in - Option.fold ~none:0 ~some:Int64.to_int len - -let check_status tree expected = - let open Lwt.Syntax in - let* status = find_status tree in - match (status, expected) with - | Some status, Some expected -> - assert (status = expected) ; - Lwt.return () - | None, None -> Lwt.return () - | _, _ -> assert false - -let check_chunks_count tree expected = - let open Lwt.Syntax in - let* count = get_chunks_count tree in - if count = expected then Lwt_result.return () - else failwith "wrong chunks counter, expected %d, got %d" expected count - let operator = Account.new_account -let should_boot_complete_boot_sector boot_sector () = - let open Tezos_scoru_wasm.Gather_floppies in - let open Lwt_result_syntax in - let*! index = Context_binary.init "/tmp" in - let context = Context_binary.empty index in - (* The number of chunks necessary to store the kernel. *) - let boot_sector_len = - match boot_sector with - | Complete_kernel bytes | Incomplete_kernel (bytes, _) -> Bytes.length bytes - in - let boot_sector = - Data_encoding.Binary.to_string_exn origination_message_encoding boot_sector - in - (* We create a new PVM, and install the boot sector. *) - let*! s = Prover.initial_state context in - let*! s = Prover.install_boot_sector s boot_sector in - (* After this first step, the PVM has just loaded the boot sector in - "/boot-sector", and nothing more. As a consequence, most of the - step of the [Gather_floppies] instrumentation is not set. *) - let*! () = check_status s None in - let* () = check_chunks_count s 0 in - (* At this step, the [eval] function of the PVM will interpret the - origination message encoded in [boot_sector]. *) - let* s = checked_eval ~loc:__LOC__ context s in - (* We expect that the WASM does not expect more floppies, and that - the kernel as been correctly splitted into several chunks. *) - let*! () = check_status s (Some Not_gathering_floppies) in - let* () = check_chunks_count s boot_sector_len in - return_unit - let arbitrary_input i payload = match Sc_rollup.Inbox_message.serialize (External payload) with | Ok payload -> @@ -244,152 +174,6 @@ let arbitrary_input i payload = Format.printf "%a@," Environment.Error_monad.pp_trace err ; assert false -let floppy_input i operator chunk = - let signature = Signature.sign operator.Account.sk chunk in - let floppy = Tezos_scoru_wasm.Gather_floppies.{chunk; signature} in - arbitrary_input - i - (Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm.Gather_floppies.floppy_encoding - floppy) - -let should_interpret_empty_chunk () = - let open Lwt_result_syntax in - let op = operator () in - let chunk_size = Tezos_scoru_wasm.Gather_floppies.chunk_size in - let origination_message = - Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm__Gather_floppies.origination_message_encoding - @@ incomplete_boot_sector (String.make chunk_size 'a') op - in - let chunk = Bytes.empty in - let correct_input = floppy_input 0 op chunk in - - (* Init the PVM *) - let*! index = Context_binary.init "/tmp" in - let context = Context_binary.empty index in - let*! s = Prover.initial_state context in - let*! s = Prover.install_boot_sector s origination_message in - (* Intererptation of the origination message *) - let* s = checked_eval ~loc:__LOC__ context s in - let*! () = check_status s (Some (Gathering_floppies op.pk)) in - let* () = check_chunks_count s chunk_size in - (* Try to interpret the empty input (correctly signed) *) - let*! s = Prover.set_input correct_input s in - let*! () = check_status s (Some Not_gathering_floppies) in - (* We still have 1 chunk. *) - let* () = check_chunks_count s chunk_size in - return_unit - -let should_refuse_chunks_with_incorrect_signature () = - let open Lwt_result_syntax in - let good_op = operator () in - let bad_op = operator () in - let chunk_size = Tezos_scoru_wasm.Gather_floppies.chunk_size in - let origination_message = - Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm__Gather_floppies.origination_message_encoding - @@ incomplete_boot_sector (String.make chunk_size 'a') good_op - in - let chunk = Bytes.make chunk_size 'b' in - let incorrect_input = floppy_input 0 bad_op chunk in - let correct_input = floppy_input 0 good_op chunk in - - (* Init the PVM *) - let*! index = Context_binary.init "/tmp" in - let context = Context_binary.empty index in - let*! s = Prover.initial_state context in - let*! s = Prover.install_boot_sector s origination_message in - (* Intererptation of the origination message *) - let* s = checked_eval ~loc:__LOC__ context s in - let*! () = check_status s (Some (Gathering_floppies good_op.pk)) in - let* () = check_chunks_count s chunk_size in - (* Try to interpret the incorrect input (badly signed) *) - let* s = checked_set_input ~loc:__LOC__ context incorrect_input s in - let*! () = check_status s (Some (Gathering_floppies good_op.pk)) in - (* We still have 1 chunk. *) - let* () = check_chunks_count s chunk_size in - (* Try to interpret the correct input (correctly signed) *) - let* s = checked_set_input ~loc:__LOC__ context correct_input s in - let*! () = check_status s (Some (Gathering_floppies good_op.pk)) in - (* We now have 2 chunks. *) - let* () = check_chunks_count s (2 * chunk_size) in - return_unit - -let should_boot_incomplete_boot_sector kernel () = - let open Lwt_result_syntax in - let operator = operator () in - let chunk_size = Tezos_scoru_wasm.Gather_floppies.chunk_size in - let initial_chunk, rem_chunks = - let split_chunk s = - let len = String.length s in - let size = min len chunk_size in - let chunk = String.sub s 0 size in - let rest = - if len > chunk_size then Some (String.sub s size @@ (len - size)) - else None - in - (chunk, rest) - in - let rec do_chunks chunks left = - match left with - | None -> chunks - | Some left -> - let chunk, rest = split_chunk left in - (do_chunks [@tailcall]) (chunk :: chunks) rest - in - let initial, rest = split_chunk kernel in - (initial, List.rev @@ do_chunks [] rest) - in - let initial_chunk = - Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm__Gather_floppies.origination_message_encoding - @@ incomplete_boot_sector initial_chunk operator - in - let chunks = - rem_chunks - |> List.take_n (List.length rem_chunks - 1) - |> List.map Bytes.of_string - in - let final_chunk = Bytes.of_string @@ List.last "" rem_chunks in - let final_chunk_size = Bytes.length final_chunk 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.install_boot_sector s initial_chunk in - let* () = check_proof_size ~loc:__LOC__ context None s in - let*! () = check_status s None in - let* () = check_chunks_count s 0 in - (* First tick, to interpret the boot sector. One chunk have been - provided, and the PVM expects more chunk to come. *) - let* s = checked_eval ~loc:__LOC__ context s in - let*! () = check_status s (Some (Gathering_floppies operator.pk)) in - let* () = check_chunks_count s chunk_size in - (* Then, installing the additional chunks. *) - let* s = - List.fold_left_i_es - (fun i s chunk -> - (* We are installing the [i+2]th chunk ([i] starts at 0, and - the first chunk is not part of the list). *) - let input = floppy_input i operator chunk in - let* s = checked_set_input ~loc:__LOC__ context input s in - (* We have [i+2] chunks. *) - let* () = check_chunks_count s ((i + 2) * chunk_size) in - return s) - s - chunks - in - (* Up until the very last one, where the status of the PVM change. *) - let len = List.length chunks in - let input = floppy_input len operator final_chunk in - let* s = checked_set_input ~loc:__LOC__ context input s in - let*! () = check_status s (Some Not_gathering_floppies) in - let* () = - check_chunks_count s (((len + 1) * chunk_size) + final_chunk_size) - in - return_unit - (* Read the chosen `wasm_kernel` into memory. *) let read_kernel name = let open Tezt.Base in @@ -414,11 +198,7 @@ let rec eval_until_set_input context s = let should_boot_computation_kernel () = let open Lwt_result_syntax in - let boot_sector = - Data_encoding.Binary.to_string_exn - Tezos_scoru_wasm.Gather_floppies.origination_message_encoding - (complete_boot_sector (String.to_bytes (computation_kernel ()))) - in + let boot_sector = computation_kernel () in let*! index = Context_binary.init "/tmp" in let context = Context_binary.empty index in let*! s = Prover.initial_state context in @@ -430,12 +210,6 @@ let should_boot_computation_kernel () = (Data_encoding.Binary.to_bytes_exn Data_encoding.n (Z.of_int 50_000)) in let*! s = Prover.install_boot_sector s boot_sector in - (* installing the boot kernel *) - let* s = checked_eval ~loc:__LOC__ context s in - (* Make the first ticks of the WASM PVM (parsing of origination - message, parsing and init of the kernel), to switch it to - “waiting for input” mode. *) - let* s = eval_until_set_input context s in (* Feeding it with one input *) let* s = checked_set_input ~loc:__LOC__ context (arbitrary_input 0 "test") s @@ -446,27 +220,6 @@ let should_boot_computation_kernel () = let tests = [ - Tztest.tztest "should boot a complete boot sector" `Quick - @@ should_boot_complete_boot_sector - (complete_boot_sector (Bytes.of_string @@ computation_kernel ())); - ( Tztest.tztest "should boot an incomplete but too small boot sector" `Quick - @@ fun () -> - let operator = operator () in - should_boot_complete_boot_sector - (incomplete_boot_sector "\x00asm\x01\x00\x00\x00" operator) - () ); - Tztest.tztest - "should boot an incomplete boot sector with floppies" - `Quick - (should_boot_incomplete_boot_sector @@ computation_kernel ()); - Tztest.tztest - "should interpret an empty chunk as EOF" - `Quick - should_interpret_empty_chunk; - Tztest.tztest - "should refuse chunks with an incorrect signature" - `Quick - should_refuse_chunks_with_incorrect_signature; Tztest.tztest "should boot a valid kernel until reading inputs" `Quick 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 index a805ac17e900..31e6bdaba3ca 100644 --- 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 @@ -38,7 +38,6 @@ open Tezos_micheline.Micheline open Michelson_v1_primitives open Tezos_webassembly_interpreter module Context = Tezos_context_memory.Context_binary -open Tezos_scoru_wasm open Wasm_utils module Proof_encoding = @@ -105,23 +104,6 @@ let test_initial_state_hash_wasm_pvm () = Sc_rollup.State_hash.pp hash -let test_incomplete_kernel_chunk_limit () = - let open Lwt_result_syntax in - let operator = Account.new_account () in - let chunk_size = Tezos_scoru_wasm.Gather_floppies.chunk_size in - let chunk_too_big = Bytes.make (chunk_size + 10) 'a' in - let signature = Signature.sign operator.Account.sk chunk_too_big in - let floppy = - Tezos_scoru_wasm.Gather_floppies.{chunk = chunk_too_big; signature} - in - match - Data_encoding.Binary.to_string_opt - Tezos_scoru_wasm.Gather_floppies.floppy_encoding - floppy - with - | None -> return_unit - | Some _ -> failwith "encoding of a floppy with a chunk too large should fail" - let test_metadata_size () = let address = Sc_rollup_repr.Address.of_bytes_exn (Bytes.make 20 '\000') in let metadata = @@ -207,21 +189,11 @@ let test_output () = let parsed = match parsed.it with Script.Textual m -> m | _ -> assert false in - let*! code = Encode.encode parsed in - let boot_sector = - Data_encoding.Binary.to_string_exn - Gather_floppies.origination_message_encoding - (Gather_floppies.Complete_kernel (String.to_bytes code)) - in - let*! tree = - Wasm.Internal_for_tests.initial_tree_from_boot_sector - ~empty_tree - boot_sector - in + let*! boot_sector = Encode.encode parsed in + let*! tree = Wasm.install_boot_sector boot_sector empty_tree in let*! tree = Wasm.Internal_for_tests.set_max_nb_ticks (Z.of_int64 50_000_000L) tree in - let*! tree = eval_until_input_requested tree in let transactions = make_transactions () in let out = Sc_rollup_outbox_message_repr.(Atomic_transaction_batch {transactions}) @@ -266,10 +238,6 @@ let tests = "initial state hash for Wasm" `Quick test_initial_state_hash_wasm_pvm; - Tztest.tztest - "encoding of a floppy with a chunk too large should fail" - `Quick - test_incomplete_kernel_chunk_limit; Tztest.tztest "size of a rollup metadata" `Quick test_metadata_size; Tztest.tztest "test output proofs" `Quick test_output; ] diff --git a/tezt/long_tests/sc_rollup.ml b/tezt/long_tests/sc_rollup.ml index 4ec2def7381c..a97ff92fc09f 100644 --- a/tezt/long_tests/sc_rollup.ml +++ b/tezt/long_tests/sc_rollup.ml @@ -54,16 +54,13 @@ let hex_encode (input : string) : string = the kernel must fit into a single Tezos operation. *) let read_kernel name : string = - let module G = Tezos_scoru_wasm.Gather_floppies in let open Tezt.Base in let kernel_file = project_root // Filename.dirname __FILE__ // "../../src/proto_alpha/lib_protocol/test/integration/wasm_kernel" // (name ^ ".wasm") in - hex_encode - @@ Data_encoding.Binary.to_string_exn G.origination_message_encoding - @@ G.Complete_kernel (Bytes.of_string @@ read_file kernel_file) + hex_encode (read_file kernel_file) type sc_rollup_constants = { origination_size : int; diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node boots into the initial state.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node boots into the initial state.out index d63a901877b0..c898d686502e 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node boots into the initial state.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node boots into the initial state.out @@ -41,4 +41,4 @@ This sequence of operations was run: "0" ./octez-sc-rollup-client-alpha rpc get /global/block/head/status -"Computing" +"Waiting for input message" diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - runs with kernel - no_parse_bad_fingerprint.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - runs with kernel - no_parse_bad_fingerprint.out index cf60e2419354..ed05deb07164 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - runs with kernel - no_parse_bad_fingerprint.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - runs with kernel - no_parse_bad_fingerprint.out @@ -1,8 +1,8 @@ -./octez-client --wait none originate sc rollup from bootstrap1 of kind wasm_2_0_0 of type string booting with 00000026870061206d01000000014a0c60027f7f017f60027f7f0060037f7f7f017f60000060017f0060037f7f7f0060047f7f7f7f017f60047f7f7f7f0060017f017f60057f7f7f7f7f017f60017f017e60057f7f7f7f7f00034746030400050601000506040700080902070407000803080404040507010a0a0004050008010104010101010b010200000101010301010004020501020a0000080808000b00020204050170011d1d05030100110619037f01418080c0000b7f0041948cc0000b7f0041a08cc0000b073304066d656d6f727902000b6b65726e656c5f6e65787400000a5f5f646174615f656e6403010b5f5f686561705f6261736503020922010041010b1c013c090a0b0c1112131023171c161d18262728292c2d2e35413d363b0afa4646860201057f23808080800041106b22002480808080001094808080000240024041002802e083c080000d004100417f3602e083c080000240024041002802e483c080002201450d00200128020041016a210241002802ec83c08000210341002802e883c0800021040c010b410441041082808080002201450d0241002104410020013602e483c080002001410036020041012102410121030b20012002360200410020033602e883c080004100200420036a3602ec83c08000410041002802e083c0800041016a3602e083c08000200041106a2480808080000f0b41b480c080004110200041086a41c480c0800041a480c0800010c280808000000b4104410410b180808000000b02000b1301017f20002001108680808000210220020f0b0f002000200120021087808080000f0b1701017f2000200120022003108880808000210420040f0b0d002000200110b4808080000f0b120041f083c0800020002001108e808080000b140041f083c08000200020012002108f808080000b4501017f024041f083c0800020032002108e808080002204450d002004200020032001200120034b1b10c5808080001a41f083c08000200020012002108f808080000b20040b02000b7701017f02400240200241027422022003410374418080016a2203200220034b1b418780046a220441107640002203417f470d0041012102410021030c010b20034110742203420037030041002102200341003602082003200320044180807c716a4102723602000b20002003360204200020023602000b05004180040b040041010bef0401087f024020022802002205450d002001417f6a210620004102742107410020016b21080340200541086a2109024002402005280208220a4101710d00200521010c010b03402009200a417e71360200024002402005280204220a417c7122090d00410021010c010b4100200920092d00004101711b21010b02402005280200220b417c71220c450d004100200c200b4102711b220b450d00200b200b2802044103712009723602042005280204220a417c7121090b02402009450d00200920092802004103712005280200417c71723602002005280204210a0b2005200a41037136020420052005280200220941037136020002402009410271450d00200120012802004102723602000b20022001360200200141086a2109200121052001280208220a4101710d000b0b02402001280200417c71220a200141086a22056b2007490d00024002402005200320002004280210118080808000004102746a41086a200a20076b200871220a4d0d0020062005710d0220022009280200417c7136020020012001280200410172360200200121050c010b200a4100360200200a41786a2205420037020020052001280200417c7136020002402001280200220a417c71220b450d004100200b200a4102711b220a450d00200a200a2802044103712005723602040b2005200528020441037120017236020420092009280200417e71360200200120012802002209410371200572220a3602000240024020094102710d00200528020021010c010b2001200a417d713602002005200528020041027222013602000b200520014101723602000b200541086a0f0b20022001280208220536020020050d000b0b41000bac0301037f23808080800041106b22032480808080000240024020010d00200221010c010b200141036a220441027621050240200241054f0d002005417f6a220141ff014b0d00200320003602082003200020014102746a41046a41002001418002491b220028020036020c0240200520022003410c6a200341086a41ec80c08000108d8080800022010d002003200341086a200520021091808080004100210120032802000d0020032802042201200328020c3602082003200136020c200520022003410c6a200341086a41ec80c08000108d8080800021010b2000200328020c3602000c010b2003200028020036020c0240200520022003410c6a41d480c0800041d480c08000108d8080800022010d0002402004417c7122012002410374418080016a2204200120044b1b418780046a220441107640002201417f470d00410021010c010b20014110742201200328020c360208200141003602042001200120044180807c716a4102723602002003200136020c200520022003410c6a41d480c0800041d480c08000108d8080800021010b2000200328020c3602000b200341106a24808080800020010be60501067f23808080800041106b220424808080800002402001450d002002450d000240200341054f0d00200241036a410276417f6a220341ff014b0d0020014100360200200141786a22022002280200417e713602002004200036020c200020034102746a41046a22002802002103024002402004410c6a109380808000450d00024002402001417c6a2205280200417c712206450d00200628020022074101710d0002400240024020022802002208417c7122010d00200621090c010b200621094100200120084102711b2208450d002008200828020441037120067236020420052802002201417c712209450d012002280200417c712101200928020021070b20092001200741037172360200200528020021010b200520014103713602002002200228020022014103713602002001410271450d01200620062802004102723602000c010b20022802002206417c712205450d014100200520064102711b2206450d0120062d00004101710d0120012006280208417c71360200200620024101723602080b200321020c010b200120033602000b200020023602000c010b20014100360200200141786a220220022802002203417e71360200200028020021050240024002402001417c6a2207280200417c712206450d00200628020022094101710d000240024002402003417c7122010d00200621080c010b200621084100200120034102711b2203450d002003200328020441037120067236020420072802002201417c712208450d012002280200417c712101200828020021090b20082001200941037172360200200728020021010b200720014103713602002002200228020022014103713602002001410271450d01200620062802004102723602000c010b2003417c712206450d014100200620034102711b2203450d0120032d00004101710d0120012003280208417c71360200200320024101723602080b200020053602000c010b20012005360200200020023602000b200441106a2480808080000b02000b960201027f23808080800041106b220424808080800020042001280200220528020036020c024002400240200241026a220220026c220241801020024180104b1b220141042004410c6a418481c08000418481c08000108d808080002202450d002005200428020c3602000c010b2004418481c0800020014104108a80808000024002402004280200450d002005200428020c3602000c010b20042802042202200428020c3602082004200236020c200141042004410c6a418481c08000418481c08000108d8080800021022005200428020c36020020020d010b410121010c010b200242003702042002200220014102746a410272360200410021010b2000200236020420002001360200200441106a2480808080000b040020010b040041000b02000b040000000b02000b2a01017f0240200041046a2802002201450d0020002802002200450d002000200141011083808080000b0b2a01017f024020002802042201450d00200041086a2802002200450d002001200041011083808080000b0bdb0101027f23808080800041206b22032480808080000240200120026a22022001490d00200041046a280200220441017422012002200120024b1b22014108200141084b1b2101024002402004450d00200341106a41086a410136020020032004360214200320002802003602100c010b200341003602100b200320014101200341106a109a8080800002402003280200450d00200341086a2802002200450d012003280204200010b180808000000b20032802042102200041046a200136020020002002360200200341206a2480808080000f0b10b280808000000bb50101027f0240024002400240024002400240024002402002450d004101210420014100480d0120032802002205450d02200328020422030d0520010d03200221030c040b20002001360204410121040b410021010c060b20010d00200221030c010b2001200210828080800021030b2003450d010c020b200520032002200110848080800022030d010b20002001360204200221010c010b20002003360204410021040b20002004360200200041086a20013602000bdb0101037f23808080800041206b22022480808080000240200141016a22032001490d00200041046a280200220441017422012003200120034b1b22014108200141084b1b2101024002402004450d00200241106a41086a410136020020022004360214200220002802003602100c010b200241003602100b200220014101200241106a109a8080800002402002280200450d00200241086a2802002200450d012002280204200010b180808000000b20022802042103200041046a200136020020002003360200200241206a2480808080000f0b10b280808000000b0c0042f6e2f8b1f2e1afe7050b0d0042d1ae98c49983b2f7847f0bf70201037f23808080800041106b220224808080800002400240024002402001418001490d002002410036020c20014180104f0d0120022001413f71418001723a000d2002200141067641c001723a000c410221010c020b024020002802082203200041046a280200470d0020002003109b80808000200028020821030b2000200341016a360208200028020020036a20013a00000c020b0240200141808004490d0020022001413f71418001723a000f2002200141127641f001723a000c20022001410676413f71418001723a000e20022001410c76413f71418001723a000d410421010c010b20022001413f71418001723a000e20022001410c7641e001723a000c20022001410676413f71418001723a000d410321010b0240200041046a280200200041086a220428020022036b20014f0d00200020032001109980808000200428020021030b200028020020036a2002410c6a200110c5808080001a2004200320016a3602000b200241106a24808080800041000b180020002802002000280204200028020810a080808000000bbf0101027f23808080800041106b2203248080808000200041146a28020021040240024002400240200041046a2802000e020001030b20040d02419c81c080002100410021040c010b20040d01200028020022002802042104200028020021000b2003200436020420032000360200200341b882c08000200110be808080002002200110c08080800010aa80808000000b2003410036020420032000360200200341a482c08000200110be808080002002200110c08080800010aa80808000000b1c00024020000d00419c81c08000412b200110b880808000000b20000b2000024020000d00419c81c08000412b41f481c0800010b880808000000b20000b02000b2501017f2000200141002802f48bc080002202418b8080800020021b1181808080000000000b5901037f23808080800041106b2201248080808000200010bf8080800041e481c0800010a1808080002102200010be8080800010a28080800021032001200236020820012000360204200120033602002001109f80808000000bb10202047f017e23808080800041306b2202248080808000200141046a2103024020012802040d0020012802002104200241086a41086a22054100360200200242013703082002200241086a360214200241186a41106a200441106a290200370300200241186a41086a200441086a29020037030020022004290200370318200241146a41cc82c08000200241186a10ba808080001a200341086a2005280200360200200320022903083702000b200241186a41086a2204200341086a2802003602002001410c6a41003602002003290200210620014201370204200220063703180240410c410410828080800022010d00410c410410b180808000000b20012002290318370200200141086a20042802003602002000418482c0800036020420002001360200200241306a2480808080000bc80101037f23808080800041306b2202248080808000200141046a2103024020012802040d0020012802002101200241086a41086a22044100360200200242013703082002200241086a360214200241186a41106a200141106a290200370300200241186a41086a200141086a29020037030020022001290200370318200241146a41cc82c08000200241186a10ba808080001a200341086a2004280200360200200320022903083702000b2000418482c0800036020420002003360200200241306a2480808080000b4e01027f200128020421022001280200210302404108410410828080800022010d004108410410b180808000000b20012002360204200120033602002000419482c08000360204200020013602000b14002000419482c08000360204200020013602000bab0201037f23808080800041206b220524808080800041012106410041002802848cc08000220741016a3602848cc080000240024041002d00888cc08000450d0041002802908cc0800041016a21060c010b410041013a00888cc080000b410020063602908cc080000240024020074100480d00200641024b0d00200520043a0018200520033602142005200236021041002802f88bc080002207417f4c0d004100200741016a22073602f88bc08000024041002802808cc080002202450d0041002802fc8bc08000210720052000200128021011818080800000200520052903003703082007200541086a20022802141181808080000041002802f88bc0800021070b41002007417f6a3602f88bc08000200641014b0d0020040d010b00000b2000200110ab80808000000b3101017f23808080800041106b22022480808080002002200136020c20022000360208200241086a1095808080001a00000b5801027f02402000280200220341046a280200200341086a220428020022006b20024f0d00200320002002109980808000200428020021000b200328020020006a2001200210c5808080001a2004200020026a36020041000b120020002802002001109e808080001a41000b7401017f23808080800041206b220224808080800020022000280200360204200241086a41106a200141106a290200370300200241086a41086a200141086a29020037030020022001290200370308200241046a41cc82c08000200241086a10ba808080002101200241206a24808080800020010b0d002000200110b080808000000b0d0020002001108580808000000b0d002000200110b380808000000b4e01017f23808080800041206b22002480808080002000411c6a41003602002000418083c080003602182000420137020c2000419483c08000360208200041086a419c83c0800010b980808000000b0d002000200110af80808000000b0d002000200110a480808000000b0d0020002802001a037f0c000b0b02000bd80701067f20002802102103024002400240024002400240200028020822044101460d0020034101470d010b20034101470d03200120026a2105200041146a28020022060d0141002107200121080c020b2000280218200120022000411c6a28020028020c1182808080000021030c030b41002107200121080340200822032005460d020240024020032c00002208417f4c0d00200341016a21080c010b0240200841604f0d00200341026a21080c010b0240200841704f0d00200341036a21080c010b20032d0002413f7141067420032d0001413f71410c747220032d0003413f7172200841ff0171411274418080f0007172418080c400460d03200341046a21080b200720036b20086a21072006417f6a22060d000b0b20082005460d00024020082c00002203417f4a0d0020034160490d0020034170490d0020082d0002413f7141067420082d0001413f71410c747220082d0003413f7172200341ff0171411274418080f0007172418080c400460d010b02400240024020070d00410021080c010b024020072002490d00410021032002210820072002460d010c020b4100210320072108200120076a2c00004140480d010b20082107200121030b2007200220031b21022003200120031b21010b024020040d002000280218200120022000411c6a28020028020c118280808000000f0b2000410c6a28020021050240024020024110490d002001200210c38080800021080c010b024020020d00410021080c010b20024103712107024002402002417f6a41034f0d0041002108200121030c010b2002417c71210641002108200121030340200820032c000041bf7f4a6a200341016a2c000041bf7f4a6a200341026a2c000041bf7f4a6a200341036a2c000041bf7f4a6a2108200341046a21032006417c6a22060d000b0b2007450d000340200820032c000041bf7f4a6a2108200341016a21032007417f6a22070d000b0b0240200520084d0d0041002103200520086b22072106024002400240410020002d0020220820084103461b4103710e03020001020b41002106200721030c010b20074101762103200741016a41017621060b200341016a21032000411c6a28020021072000280204210820002802182100024003402003417f6a2203450d0120002008200728021011808080800000450d000b41010f0b410121032008418080c400460d01200020012002200728020c118280808000000d01410021030340024020062003470d0020062006490f0b200341016a210320002008200728021011808080800000450d000b2003417f6a2006490f0b2000280218200120022000411c6a28020028020c118280808000000f0b20030b5401017f23808080800041206b2203248080808000200341146a4100360200200341ac83c08000360210200342013702042003200136021c200320003602182003200341186a3602002003200210b980808000000b4c01017f23808080800041206b2202248080808000200241013a00182002200136021420022000360210200241bc83c0800036020c200241ac83c08000360208200241086a10a580808000000bbd05010a7f23808080800041306b2203248080808000200341246a2001360200200341033a0028200342808080808004370308200320003602204100210420034100360218200341003602100240024002400240200228020822050d00200241146a2802002206450d0120022802002101200228021021002006417f6a41ffffffff017141016a2204210603400240200141046a2802002207450d00200328022020012802002007200328022428020c118280808000000d040b2000280200200341086a200041046a280200118080808000000d03200041086a2100200141086a21012006417f6a22060d000c020b0b2002410c6a2802002200450d00200041057421082000417f6a41ffffff3f7141016a2104200228020021014100210603400240200141046a2802002200450d00200328022020012802002000200328022428020c118280808000000d030b2003200520066a2200411c6a2d00003a00282003200041046a290200422089370308200041186a28020021092002280210210a4100210b41002107024002400240200041146a2802000e03010002010b2009410374210c41002107200a200c6a220c280204419880808000470d01200c28020028020021090b410121070b2003200936021420032007360210200041106a28020021070240024002402000410c6a2802000e03010002010b20074103742109200a20096a2209280204419880808000470d01200928020028020021070b4101210b0b2003200736021c2003200b360218200a20002802004103746a2200280200200341086a2000280204118080808000000d02200141086a21012008200641206a2206470d000b0b4100210020042002280204492201450d012003280220200228020020044103746a410020011b22012802002001280204200328022428020c11828080800000450d010b410121000b200341306a24808080800020000b0c004281b8aa93f5f3e5ec140b2100200128021841ac83c08000410e2001411c6a28020028020c118280808000000b140020012000280200200028020410b7808080000b070020002802080b0700200028020c0b070020002d00100b180020002802002001200028020428020c118080808000000b930101017f23808080800041c0006b22052480808080002005200136020c2005200036020820052003360214200520023602102005412c6a41023602002005413c6a4199808080003602002005420237021c200541d083c080003602182005419a808080003602342005200541306a3602282005200541106a3602382005200541086a360230200541186a200410b980808000000ba30801097f02400240200041036a417c71220220006b220320014b0d00200341044b0d00200120036b22044104490d0020044103712105410021064100210102402003450d00200341037121070240024020022000417f736a41034f0d0041002101200021020c010b2003417c71210841002101200021020340200120022c000041bf7f4a6a200241016a2c000041bf7f4a6a200241026a2c000041bf7f4a6a200241036a2c000041bf7f4a6a2101200241046a21022008417c6a22080d000b0b2007450d000340200120022c000041bf7f4a6a2101200241016a21022007417f6a22070d000b0b200020036a210002402005450d0020002004417c716a22022c000041bf7f4a210620054101460d00200620022c000141bf7f4a6a210620054102460d00200620022c000241bf7f4a6a21060b20044102762103200620016a21080340200021062003450d02200341c001200341c001491b220441037121052004410274210902400240200441fc0171220a41027422000d00410021020c010b200620006a2107410021022006210003402000410c6a2802002201417f73410776200141067672418182840871200041086a2802002201417f73410776200141067672418182840871200041046a2802002201417f7341077620014106767241818284087120002802002201417f7341077620014106767241818284087120026a6a6a6a2102200041106a22002007470d000b0b200620096a2100200320046b2103200241087641ff81fc0771200241ff81fc07716a418180046c41107620086a21082005450d000b2006200a4102746a2100200541ffffffff036a220441ffffffff0371220241016a2201410371210302400240200241034f0d00410021020c010b200141fcffffff077121014100210203402000410c6a2802002207417f73410776200741067672418182840871200041086a2802002207417f73410776200741067672418182840871200041046a2802002207417f7341077620074106767241818284087120002802002207417f7341077620074106767241818284087120026a6a6a6a2102200041106a21002001417c6a22010d000b0b02402003450d00200441818080807c6a2101034020002802002207417f7341077620074106767241818284087120026a2102200041046a21002001417f6a22010d000b0b200241087641ff81fc0771200241ff81fc07716a418180046c41107620086a0f0b024020010d0041000f0b20014103712102024002402001417f6a41034f0d00410021080c010b2001417c712101410021080340200820002c000041bf7f4a6a200041016a2c000041bf7f4a6a200041026a2c000041bf7f4a6a200041036a2c000041bf7f4a6a2108200041046a21002001417c6a22010d000b0b2002450d000340200820002c000041bf7f4a6a2108200041016a21002002417f6a22020d000b0b20080bc10201087f024002402002410f4b0d00200021030c010b2000410020006b41037122046a210502402004450d0020002103200121060340200320062d00003a0000200641016a2106200341016a22032005490d000b0b2005200220046b2207417c7122086a210302400240200120046a2209410371450d0020084101480d012009410374220641187121022009417c71220a41046a2101410020066b4118712104200a28020021060340200520062002762001280200220620047472360200200141046a2101200541046a22052003490d000c020b0b20084101480d0020092101034020052001280200360200200141046a2101200541046a22052003490d000b0b20074103712102200920086a21010b02402002450d00200320026a21050340200320012d00003a0000200141016a2101200341016a22032005490d000b0b20000b0e0020002001200210c4808080000b0bea030100418080c0000be0032f7573722f7372632f6b65726e656c5f656e7472792f7372632f63616368652e7273000000001000220000001300000020000000616c726561647920626f72726f776564010000000000000001000000020000000300000000000000010000000400000005000000060000000300000004000000040000000700000008000000090000000a000000000000000100000004000000050000000600000063616c6c656420604f7074696f6e3a3a756e77726170282960206f6e206120604e6f6e65602076616c75656c6962726172792f7374642f7372632f70616e69636b696e672e727300c70010001c000000460200001f000000c70010001c000000470200001e0000000c0000000c000000040000000d0000000e00000008000000040000000f00000010000000100000000400000011000000120000000e000000080000000400000013000000140000000e00000004000000040000001500000016000000170000006c6962726172792f616c6c6f632f7372632f7261775f7665632e72736361706163697479206f766572666c6f770000008001100011000000640110001c0000000602000005000000426f72726f774d75744572726f7200001b00000000000000010000001c0000003a200000ac01100000000000cc01100002000000 --burn-cap 9999999 +./octez-client --wait none originate sc rollup from bootstrap1 of kind wasm_2_0_0 of type string booting with 0061206d01000000014a0c60027f7f017f60027f7f0060037f7f7f017f60000060017f0060037f7f7f0060047f7f7f7f017f60047f7f7f7f0060017f017f60057f7f7f7f7f017f60017f017e60057f7f7f7f7f00034746030400050601000506040700080902070407000803080404040507010a0a0004050008010104010101010b010200000101010301010004020501020a0000080808000b00020204050170011d1d05030100110619037f01418080c0000b7f0041948cc0000b7f0041a08cc0000b073304066d656d6f727902000b6b65726e656c5f6e65787400000a5f5f646174615f656e6403010b5f5f686561705f6261736503020922010041010b1c013c090a0b0c1112131023171c161d18262728292c2d2e35413d363b0afa4646860201057f23808080800041106b22002480808080001094808080000240024041002802e083c080000d004100417f3602e083c080000240024041002802e483c080002201450d00200128020041016a210241002802ec83c08000210341002802e883c0800021040c010b410441041082808080002201450d0241002104410020013602e483c080002001410036020041012102410121030b20012002360200410020033602e883c080004100200420036a3602ec83c08000410041002802e083c0800041016a3602e083c08000200041106a2480808080000f0b41b480c080004110200041086a41c480c0800041a480c0800010c280808000000b4104410410b180808000000b02000b1301017f20002001108680808000210220020f0b0f002000200120021087808080000f0b1701017f2000200120022003108880808000210420040f0b0d002000200110b4808080000f0b120041f083c0800020002001108e808080000b140041f083c08000200020012002108f808080000b4501017f024041f083c0800020032002108e808080002204450d002004200020032001200120034b1b10c5808080001a41f083c08000200020012002108f808080000b20040b02000b7701017f02400240200241027422022003410374418080016a2203200220034b1b418780046a220441107640002203417f470d0041012102410021030c010b20034110742203420037030041002102200341003602082003200320044180807c716a4102723602000b20002003360204200020023602000b05004180040b040041010bef0401087f024020022802002205450d002001417f6a210620004102742107410020016b21080340200541086a2109024002402005280208220a4101710d00200521010c010b03402009200a417e71360200024002402005280204220a417c7122090d00410021010c010b4100200920092d00004101711b21010b02402005280200220b417c71220c450d004100200c200b4102711b220b450d00200b200b2802044103712009723602042005280204220a417c7121090b02402009450d00200920092802004103712005280200417c71723602002005280204210a0b2005200a41037136020420052005280200220941037136020002402009410271450d00200120012802004102723602000b20022001360200200141086a2109200121052001280208220a4101710d000b0b02402001280200417c71220a200141086a22056b2007490d00024002402005200320002004280210118080808000004102746a41086a200a20076b200871220a4d0d0020062005710d0220022009280200417c7136020020012001280200410172360200200121050c010b200a4100360200200a41786a2205420037020020052001280200417c7136020002402001280200220a417c71220b450d004100200b200a4102711b220a450d00200a200a2802044103712005723602040b2005200528020441037120017236020420092009280200417e71360200200120012802002209410371200572220a3602000240024020094102710d00200528020021010c010b2001200a417d713602002005200528020041027222013602000b200520014101723602000b200541086a0f0b20022001280208220536020020050d000b0b41000bac0301037f23808080800041106b22032480808080000240024020010d00200221010c010b200141036a220441027621050240200241054f0d002005417f6a220141ff014b0d00200320003602082003200020014102746a41046a41002001418002491b220028020036020c0240200520022003410c6a200341086a41ec80c08000108d8080800022010d002003200341086a200520021091808080004100210120032802000d0020032802042201200328020c3602082003200136020c200520022003410c6a200341086a41ec80c08000108d8080800021010b2000200328020c3602000c010b2003200028020036020c0240200520022003410c6a41d480c0800041d480c08000108d8080800022010d0002402004417c7122012002410374418080016a2204200120044b1b418780046a220441107640002201417f470d00410021010c010b20014110742201200328020c360208200141003602042001200120044180807c716a4102723602002003200136020c200520022003410c6a41d480c0800041d480c08000108d8080800021010b2000200328020c3602000b200341106a24808080800020010be60501067f23808080800041106b220424808080800002402001450d002002450d000240200341054f0d00200241036a410276417f6a220341ff014b0d0020014100360200200141786a22022002280200417e713602002004200036020c200020034102746a41046a22002802002103024002402004410c6a109380808000450d00024002402001417c6a2205280200417c712206450d00200628020022074101710d0002400240024020022802002208417c7122010d00200621090c010b200621094100200120084102711b2208450d002008200828020441037120067236020420052802002201417c712209450d012002280200417c712101200928020021070b20092001200741037172360200200528020021010b200520014103713602002002200228020022014103713602002001410271450d01200620062802004102723602000c010b20022802002206417c712205450d014100200520064102711b2206450d0120062d00004101710d0120012006280208417c71360200200620024101723602080b200321020c010b200120033602000b200020023602000c010b20014100360200200141786a220220022802002203417e71360200200028020021050240024002402001417c6a2207280200417c712206450d00200628020022094101710d000240024002402003417c7122010d00200621080c010b200621084100200120034102711b2203450d002003200328020441037120067236020420072802002201417c712208450d012002280200417c712101200828020021090b20082001200941037172360200200728020021010b200720014103713602002002200228020022014103713602002001410271450d01200620062802004102723602000c010b2003417c712206450d014100200620034102711b2203450d0120032d00004101710d0120012003280208417c71360200200320024101723602080b200020053602000c010b20012005360200200020023602000b200441106a2480808080000b02000b960201027f23808080800041106b220424808080800020042001280200220528020036020c024002400240200241026a220220026c220241801020024180104b1b220141042004410c6a418481c08000418481c08000108d808080002202450d002005200428020c3602000c010b2004418481c0800020014104108a80808000024002402004280200450d002005200428020c3602000c010b20042802042202200428020c3602082004200236020c200141042004410c6a418481c08000418481c08000108d8080800021022005200428020c36020020020d010b410121010c010b200242003702042002200220014102746a410272360200410021010b2000200236020420002001360200200441106a2480808080000b040020010b040041000b02000b040000000b02000b2a01017f0240200041046a2802002201450d0020002802002200450d002000200141011083808080000b0b2a01017f024020002802042201450d00200041086a2802002200450d002001200041011083808080000b0bdb0101027f23808080800041206b22032480808080000240200120026a22022001490d00200041046a280200220441017422012002200120024b1b22014108200141084b1b2101024002402004450d00200341106a41086a410136020020032004360214200320002802003602100c010b200341003602100b200320014101200341106a109a8080800002402003280200450d00200341086a2802002200450d012003280204200010b180808000000b20032802042102200041046a200136020020002002360200200341206a2480808080000f0b10b280808000000bb50101027f0240024002400240024002400240024002402002450d004101210420014100480d0120032802002205450d02200328020422030d0520010d03200221030c040b20002001360204410121040b410021010c060b20010d00200221030c010b2001200210828080800021030b2003450d010c020b200520032002200110848080800022030d010b20002001360204200221010c010b20002003360204410021040b20002004360200200041086a20013602000bdb0101037f23808080800041206b22022480808080000240200141016a22032001490d00200041046a280200220441017422012003200120034b1b22014108200141084b1b2101024002402004450d00200241106a41086a410136020020022004360214200220002802003602100c010b200241003602100b200220014101200241106a109a8080800002402002280200450d00200241086a2802002200450d012002280204200010b180808000000b20022802042103200041046a200136020020002003360200200241206a2480808080000f0b10b280808000000b0c0042f6e2f8b1f2e1afe7050b0d0042d1ae98c49983b2f7847f0bf70201037f23808080800041106b220224808080800002400240024002402001418001490d002002410036020c20014180104f0d0120022001413f71418001723a000d2002200141067641c001723a000c410221010c020b024020002802082203200041046a280200470d0020002003109b80808000200028020821030b2000200341016a360208200028020020036a20013a00000c020b0240200141808004490d0020022001413f71418001723a000f2002200141127641f001723a000c20022001410676413f71418001723a000e20022001410c76413f71418001723a000d410421010c010b20022001413f71418001723a000e20022001410c7641e001723a000c20022001410676413f71418001723a000d410321010b0240200041046a280200200041086a220428020022036b20014f0d00200020032001109980808000200428020021030b200028020020036a2002410c6a200110c5808080001a2004200320016a3602000b200241106a24808080800041000b180020002802002000280204200028020810a080808000000bbf0101027f23808080800041106b2203248080808000200041146a28020021040240024002400240200041046a2802000e020001030b20040d02419c81c080002100410021040c010b20040d01200028020022002802042104200028020021000b2003200436020420032000360200200341b882c08000200110be808080002002200110c08080800010aa80808000000b2003410036020420032000360200200341a482c08000200110be808080002002200110c08080800010aa80808000000b1c00024020000d00419c81c08000412b200110b880808000000b20000b2000024020000d00419c81c08000412b41f481c0800010b880808000000b20000b02000b2501017f2000200141002802f48bc080002202418b8080800020021b1181808080000000000b5901037f23808080800041106b2201248080808000200010bf8080800041e481c0800010a1808080002102200010be8080800010a28080800021032001200236020820012000360204200120033602002001109f80808000000bb10202047f017e23808080800041306b2202248080808000200141046a2103024020012802040d0020012802002104200241086a41086a22054100360200200242013703082002200241086a360214200241186a41106a200441106a290200370300200241186a41086a200441086a29020037030020022004290200370318200241146a41cc82c08000200241186a10ba808080001a200341086a2005280200360200200320022903083702000b200241186a41086a2204200341086a2802003602002001410c6a41003602002003290200210620014201370204200220063703180240410c410410828080800022010d00410c410410b180808000000b20012002290318370200200141086a20042802003602002000418482c0800036020420002001360200200241306a2480808080000bc80101037f23808080800041306b2202248080808000200141046a2103024020012802040d0020012802002101200241086a41086a22044100360200200242013703082002200241086a360214200241186a41106a200141106a290200370300200241186a41086a200141086a29020037030020022001290200370318200241146a41cc82c08000200241186a10ba808080001a200341086a2004280200360200200320022903083702000b2000418482c0800036020420002003360200200241306a2480808080000b4e01027f200128020421022001280200210302404108410410828080800022010d004108410410b180808000000b20012002360204200120033602002000419482c08000360204200020013602000b14002000419482c08000360204200020013602000bab0201037f23808080800041206b220524808080800041012106410041002802848cc08000220741016a3602848cc080000240024041002d00888cc08000450d0041002802908cc0800041016a21060c010b410041013a00888cc080000b410020063602908cc080000240024020074100480d00200641024b0d00200520043a0018200520033602142005200236021041002802f88bc080002207417f4c0d004100200741016a22073602f88bc08000024041002802808cc080002202450d0041002802fc8bc08000210720052000200128021011818080800000200520052903003703082007200541086a20022802141181808080000041002802f88bc0800021070b41002007417f6a3602f88bc08000200641014b0d0020040d010b00000b2000200110ab80808000000b3101017f23808080800041106b22022480808080002002200136020c20022000360208200241086a1095808080001a00000b5801027f02402000280200220341046a280200200341086a220428020022006b20024f0d00200320002002109980808000200428020021000b200328020020006a2001200210c5808080001a2004200020026a36020041000b120020002802002001109e808080001a41000b7401017f23808080800041206b220224808080800020022000280200360204200241086a41106a200141106a290200370300200241086a41086a200141086a29020037030020022001290200370308200241046a41cc82c08000200241086a10ba808080002101200241206a24808080800020010b0d002000200110b080808000000b0d0020002001108580808000000b0d002000200110b380808000000b4e01017f23808080800041206b22002480808080002000411c6a41003602002000418083c080003602182000420137020c2000419483c08000360208200041086a419c83c0800010b980808000000b0d002000200110af80808000000b0d002000200110a480808000000b0d0020002802001a037f0c000b0b02000bd80701067f20002802102103024002400240024002400240200028020822044101460d0020034101470d010b20034101470d03200120026a2105200041146a28020022060d0141002107200121080c020b2000280218200120022000411c6a28020028020c1182808080000021030c030b41002107200121080340200822032005460d020240024020032c00002208417f4c0d00200341016a21080c010b0240200841604f0d00200341026a21080c010b0240200841704f0d00200341036a21080c010b20032d0002413f7141067420032d0001413f71410c747220032d0003413f7172200841ff0171411274418080f0007172418080c400460d03200341046a21080b200720036b20086a21072006417f6a22060d000b0b20082005460d00024020082c00002203417f4a0d0020034160490d0020034170490d0020082d0002413f7141067420082d0001413f71410c747220082d0003413f7172200341ff0171411274418080f0007172418080c400460d010b02400240024020070d00410021080c010b024020072002490d00410021032002210820072002460d010c020b4100210320072108200120076a2c00004140480d010b20082107200121030b2007200220031b21022003200120031b21010b024020040d002000280218200120022000411c6a28020028020c118280808000000f0b2000410c6a28020021050240024020024110490d002001200210c38080800021080c010b024020020d00410021080c010b20024103712107024002402002417f6a41034f0d0041002108200121030c010b2002417c71210641002108200121030340200820032c000041bf7f4a6a200341016a2c000041bf7f4a6a200341026a2c000041bf7f4a6a200341036a2c000041bf7f4a6a2108200341046a21032006417c6a22060d000b0b2007450d000340200820032c000041bf7f4a6a2108200341016a21032007417f6a22070d000b0b0240200520084d0d0041002103200520086b22072106024002400240410020002d0020220820084103461b4103710e03020001020b41002106200721030c010b20074101762103200741016a41017621060b200341016a21032000411c6a28020021072000280204210820002802182100024003402003417f6a2203450d0120002008200728021011808080800000450d000b41010f0b410121032008418080c400460d01200020012002200728020c118280808000000d01410021030340024020062003470d0020062006490f0b200341016a210320002008200728021011808080800000450d000b2003417f6a2006490f0b2000280218200120022000411c6a28020028020c118280808000000f0b20030b5401017f23808080800041206b2203248080808000200341146a4100360200200341ac83c08000360210200342013702042003200136021c200320003602182003200341186a3602002003200210b980808000000b4c01017f23808080800041206b2202248080808000200241013a00182002200136021420022000360210200241bc83c0800036020c200241ac83c08000360208200241086a10a580808000000bbd05010a7f23808080800041306b2203248080808000200341246a2001360200200341033a0028200342808080808004370308200320003602204100210420034100360218200341003602100240024002400240200228020822050d00200241146a2802002206450d0120022802002101200228021021002006417f6a41ffffffff017141016a2204210603400240200141046a2802002207450d00200328022020012802002007200328022428020c118280808000000d040b2000280200200341086a200041046a280200118080808000000d03200041086a2100200141086a21012006417f6a22060d000c020b0b2002410c6a2802002200450d00200041057421082000417f6a41ffffff3f7141016a2104200228020021014100210603400240200141046a2802002200450d00200328022020012802002000200328022428020c118280808000000d030b2003200520066a2200411c6a2d00003a00282003200041046a290200422089370308200041186a28020021092002280210210a4100210b41002107024002400240200041146a2802000e03010002010b2009410374210c41002107200a200c6a220c280204419880808000470d01200c28020028020021090b410121070b2003200936021420032007360210200041106a28020021070240024002402000410c6a2802000e03010002010b20074103742109200a20096a2209280204419880808000470d01200928020028020021070b4101210b0b2003200736021c2003200b360218200a20002802004103746a2200280200200341086a2000280204118080808000000d02200141086a21012008200641206a2206470d000b0b4100210020042002280204492201450d012003280220200228020020044103746a410020011b22012802002001280204200328022428020c11828080800000450d010b410121000b200341306a24808080800020000b0c004281b8aa93f5f3e5ec140b2100200128021841ac83c08000410e2001411c6a28020028020c118280808000000b140020012000280200200028020410b7808080000b070020002802080b0700200028020c0b070020002d00100b180020002802002001200028020428020c118080808000000b930101017f23808080800041c0006b22052480808080002005200136020c2005200036020820052003360214200520023602102005412c6a41023602002005413c6a4199808080003602002005420237021c200541d083c080003602182005419a808080003602342005200541306a3602282005200541106a3602382005200541086a360230200541186a200410b980808000000ba30801097f02400240200041036a417c71220220006b220320014b0d00200341044b0d00200120036b22044104490d0020044103712105410021064100210102402003450d00200341037121070240024020022000417f736a41034f0d0041002101200021020c010b2003417c71210841002101200021020340200120022c000041bf7f4a6a200241016a2c000041bf7f4a6a200241026a2c000041bf7f4a6a200241036a2c000041bf7f4a6a2101200241046a21022008417c6a22080d000b0b2007450d000340200120022c000041bf7f4a6a2101200241016a21022007417f6a22070d000b0b200020036a210002402005450d0020002004417c716a22022c000041bf7f4a210620054101460d00200620022c000141bf7f4a6a210620054102460d00200620022c000241bf7f4a6a21060b20044102762103200620016a21080340200021062003450d02200341c001200341c001491b220441037121052004410274210902400240200441fc0171220a41027422000d00410021020c010b200620006a2107410021022006210003402000410c6a2802002201417f73410776200141067672418182840871200041086a2802002201417f73410776200141067672418182840871200041046a2802002201417f7341077620014106767241818284087120002802002201417f7341077620014106767241818284087120026a6a6a6a2102200041106a22002007470d000b0b200620096a2100200320046b2103200241087641ff81fc0771200241ff81fc07716a418180046c41107620086a21082005450d000b2006200a4102746a2100200541ffffffff036a220441ffffffff0371220241016a2201410371210302400240200241034f0d00410021020c010b200141fcffffff077121014100210203402000410c6a2802002207417f73410776200741067672418182840871200041086a2802002207417f73410776200741067672418182840871200041046a2802002207417f7341077620074106767241818284087120002802002207417f7341077620074106767241818284087120026a6a6a6a2102200041106a21002001417c6a22010d000b0b02402003450d00200441818080807c6a2101034020002802002207417f7341077620074106767241818284087120026a2102200041046a21002001417f6a22010d000b0b200241087641ff81fc0771200241ff81fc07716a418180046c41107620086a0f0b024020010d0041000f0b20014103712102024002402001417f6a41034f0d00410021080c010b2001417c712101410021080340200820002c000041bf7f4a6a200041016a2c000041bf7f4a6a200041026a2c000041bf7f4a6a200041036a2c000041bf7f4a6a2108200041046a21002001417c6a22010d000b0b2002450d000340200820002c000041bf7f4a6a2108200041016a21002002417f6a22020d000b0b20080bc10201087f024002402002410f4b0d00200021030c010b2000410020006b41037122046a210502402004450d0020002103200121060340200320062d00003a0000200641016a2106200341016a22032005490d000b0b2005200220046b2207417c7122086a210302400240200120046a2209410371450d0020084101480d012009410374220641187121022009417c71220a41046a2101410020066b4118712104200a28020021060340200520062002762001280200220620047472360200200141046a2101200541046a22052003490d000c020b0b20084101480d0020092101034020052001280200360200200141046a2101200541046a22052003490d000b0b20074103712102200920086a21010b02402002450d00200320026a21050340200320012d00003a0000200141016a2101200341016a22032005490d000b0b20000b0e0020002001200210c4808080000b0bea030100418080c0000be0032f7573722f7372632f6b65726e656c5f656e7472792f7372632f63616368652e7273000000001000220000001300000020000000616c726561647920626f72726f776564010000000000000001000000020000000300000000000000010000000400000005000000060000000300000004000000040000000700000008000000090000000a000000000000000100000004000000050000000600000063616c6c656420604f7074696f6e3a3a756e77726170282960206f6e206120604e6f6e65602076616c75656c6962726172792f7374642f7372632f70616e69636b696e672e727300c70010001c000000460200001f000000c70010001c000000470200001e0000000c0000000c000000040000000d0000000e00000008000000040000000f00000010000000100000000400000011000000120000000e000000080000000400000013000000140000000e00000004000000040000001500000016000000170000006c6962726172792f616c6c6f632f7372632f7261775f7665632e72736361706163697479206f766572666c6f770000008001100011000000640110001c0000000602000005000000426f72726f774d75744572726f7200001b00000000000000010000001c0000003a200000ac01100000000000cc01100002000000 --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 3149.921 units (will add 100 for safety) -Estimated storage: 16523 bytes added (will add 20 for safety) +Estimated gas: 3149.901 units (will add 100 for safety) +Estimated storage: 16518 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,25 @@ 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.010548 + Fee to the baker: ꜩ0.010543 Expected counter: 1 Gas limit: 3250 - Storage limit: 16543 bytes + Storage limit: 16538 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.010548 - payload fees(the block proposer) ....... +ꜩ0.010548 + [PUBLIC_KEY_HASH] ... -ꜩ0.010543 + payload fees(the block proposer) ....... +ꜩ0.010543 Smart contract rollup origination: Kind: wasm_2_0_0 Parameter type: string - Boot sector Blake2B hash: '02f090940e7f6e43a72fad668964a90749b1aa887bd653d224950a12a9484906' + Boot sector Blake2B hash: '635f85c032f98c9a9bd7d58a0669213131dd23152eeb7d9d8ae2c354e140d9af' This smart contract rollup origination was successfully applied - Consumed gas: 3149.921 - Storage size: 16523 bytes + Consumed gas: 3149.901 + Storage size: 16518 bytes Address: [SC_ROLLUP_HASH] Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ4.13075 - storage fees ........................... +ꜩ4.13075 + [PUBLIC_KEY_HASH] ... -ꜩ4.1295 + storage fees ........................... +ꜩ4.1295 ./octez-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' @@ -86,13 +86,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"3" +"2" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"3" +"2" ./octez-client --wait none send sc rollup message '["2 8 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -138,13 +138,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"4" +"3" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"4" +"3" ./octez-client --wait none send sc rollup message '["3 10 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -190,13 +190,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"5" +"4" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"5" +"4" ./octez-client --wait none send sc rollup message '["4 12 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -243,13 +243,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"6" +"5" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"6" +"5" ./octez-client --wait none send sc rollup message '["5 14 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -296,13 +296,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"7" +"6" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"7" +"6" ./octez-client --wait none send sc rollup message '["6 16 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -349,13 +349,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"8" +"7" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"8" +"7" ./octez-client --wait none send sc rollup message '["7 18 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -402,13 +402,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"9" +"8" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"9" +"8" ./octez-client --wait none send sc rollup message '["8 20 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -456,13 +456,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"10" +"9" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"10" +"9" ./octez-client --wait none send sc rollup message '["9 22 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -510,13 +510,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"11" +"10" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"11" +"10" ./octez-client --wait none send sc rollup message '["10 24 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -564,4 +564,4 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"12" +"11" diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - runs with kernel - no_parse_random.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - runs with kernel - no_parse_random.out index c7c868ff1cb8..6fec830b313f 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - runs with kernel - no_parse_random.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - runs with kernel - no_parse_random.out @@ -1,8 +1,8 @@ -./octez-client --wait none originate sc rollup from bootstrap1 of kind wasm_2_0_0 of type string booting with 000000001eb9a332ba40d043f6cfaf28686153801e5069e1c839abfb20aa1907672634 --burn-cap 9999999 +./octez-client --wait none originate sc rollup from bootstrap1 of kind wasm_2_0_0 of type string booting with b9a332ba40d043f6cfaf28686153801e5069e1c839abfb20aa1907672634 --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 3110.589 units (will add 100 for safety) -Estimated storage: 6690 bytes added (will add 20 for safety) +Estimated gas: 3110.569 units (will add 100 for safety) +Estimated storage: 6685 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,25 @@ 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.000711 + Fee to the baker: ꜩ0.000706 Expected counter: 1 Gas limit: 3211 - Storage limit: 6710 bytes + Storage limit: 6705 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000711 - payload fees(the block proposer) ....... +ꜩ0.000711 + [PUBLIC_KEY_HASH] ... -ꜩ0.000706 + payload fees(the block proposer) ....... +ꜩ0.000706 Smart contract rollup origination: Kind: wasm_2_0_0 Parameter type: string - Boot sector Blake2B hash: 'f2f205be728ea7f3dd7bc8c602e40c9aa7eced3d5e7a1ad3a6467d378bae4a91' + Boot sector Blake2B hash: 'b491e02fbca4128384e6a38f7e3fef6b534b4cdfa63cc1d8d7964399d165a030' This smart contract rollup origination was successfully applied - Consumed gas: 3110.589 - Storage size: 6690 bytes + Consumed gas: 3110.569 + Storage size: 6685 bytes Address: [SC_ROLLUP_HASH] Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.6725 - storage fees ........................... +ꜩ1.6725 + [PUBLIC_KEY_HASH] ... -ꜩ1.67125 + storage fees ........................... +ꜩ1.67125 ./octez-client rpc get '/chains/main/blocks/head/context/sc_rollup/[SC_ROLLUP_HASH]/genesis_info' @@ -86,13 +86,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"3" +"2" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"3" +"2" ./octez-client --wait none send sc rollup message '["2 8 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -138,13 +138,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"4" +"3" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"4" +"3" ./octez-client --wait none send sc rollup message '["3 10 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -190,13 +190,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"5" +"4" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"5" +"4" ./octez-client --wait none send sc rollup message '["4 12 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -243,13 +243,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"6" +"5" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"6" +"5" ./octez-client --wait none send sc rollup message '["5 14 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -296,13 +296,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"7" +"6" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"7" +"6" ./octez-client --wait none send sc rollup message '["6 16 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -349,13 +349,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"8" +"7" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"8" +"7" ./octez-client --wait none send sc rollup message '["7 18 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -402,13 +402,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"9" +"8" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"9" +"8" ./octez-client --wait none send sc rollup message '["8 20 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -456,13 +456,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"10" +"9" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"10" +"9" ./octez-client --wait none send sc rollup message '["9 22 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -510,13 +510,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"11" +"10" ./octez-sc-rollup-client-alpha rpc get /global/block/head/state_hash "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"11" +"10" ./octez-client --wait none send sc rollup message '["10 24 + value"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. @@ -564,4 +564,4 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"12" +"11" diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index b8ce52e6c40d..7970960310db 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -54,16 +54,13 @@ let hex_encode (input : string) : string = the kernel must fit into a single Tezos operation. *) let read_kernel name : string = - let module G = Tezos_scoru_wasm.Gather_floppies in let open Tezt.Base in let kernel_file = project_root // Filename.dirname __FILE__ // "../../src/proto_alpha/lib_protocol/test/integration/wasm_kernel" // (name ^ ".wasm") in - hex_encode - @@ Data_encoding.Binary.to_string_exn G.origination_message_encoding - @@ G.Complete_kernel (Bytes.of_string @@ read_file kernel_file) + hex_encode (read_file kernel_file) (* Number of levels needed to process a head as finalized. This value should be the same as `node_context.block_finality_time`, where `node_context` is @@ -998,7 +995,7 @@ let test_rollup_node_boots_into_initial_state ~kind = let expected_status = match kind with | "arith" -> "Halted" - | "wasm_2_0_0" -> "Computing" + | "wasm_2_0_0" -> "Waiting for input message" | _ -> raise (Invalid_argument kind) in Check.(status = expected_status) -- GitLab