diff --git a/.gitlab/ci/opam-ci.yml b/.gitlab/ci/opam-ci.yml index 7c0f5a32d280875d9ac5e1292005db6464449a8f..980f0dddca53e44a29e1c1e526ca05d27eac7085 100644 --- a/.gitlab/ci/opam-ci.yml +++ b/.gitlab/ci/opam-ci.yml @@ -937,7 +937,7 @@ opam:tezos-expect-helper: opam:tezos-hacl: extends: - .opam_template - - .rules_template__trigger_opam_batch_6 + - .rules_template__trigger_opam_batch_7 variables: package: tezos-hacl @@ -1438,6 +1438,13 @@ opam:tezos-scoru-wasm: variables: package: tezos-scoru-wasm +opam:tezos-scoru-wasm-fast: + extends: + - .opam_template + - .rules_template__trigger_opam_batch_6 + variables: + package: tezos-scoru-wasm-fast + opam:tezos-shell: extends: - .opam_template diff --git a/dune-project b/dune-project index 9b4d42dce0f8a439b807ac1017e308d633d95db1..4386de9b5e8db85e8b5e444deaf4fab3790aa664 100644 --- a/dune-project +++ b/dune-project @@ -186,6 +186,7 @@ (package (name tezos-sc-rollup-alpha)) (package (name tezos-scoru-wasm)) (package (name tezos-scoru-wasm-benchmark)(allow_empty)) +(package (name tezos-scoru-wasm-fast)) (package (name tezos-scoru-wasm-test)(allow_empty)) (package (name tezos-scoru-wasm-test-helpers)(allow_empty)) (package (name tezos-shell)) diff --git a/manifest/main.ml b/manifest/main.ml index 9b2a454dde7029e734894539aa1271be5c3cfe0d..f1113e0fb3aaabc51af1bf18e9f651897eaa5100 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -1577,7 +1577,7 @@ let _octez_p2p_tests = ]; ]) -let _octez_wasmer = +let octez_wasmer = public_lib "tezos-wasmer" ~path:"src/lib_wasmer" @@ -1615,6 +1615,21 @@ let octez_scoru_wasm = data_encoding; ] +let octez_scoru_wasm_fast = + public_lib + "tezos-scoru-wasm-fast" + ~path:"src/lib_scoru_wasm/fast" + ~synopsis:"WASM functionality for SCORU Fast Execution" + ~deps: + [ + octez_base |> open_ ~m:"TzPervasives"; + tree_encoding; + octez_webassembly_interpreter; + lazy_containers; + octez_scoru_wasm; + octez_wasmer; + ] + let octez_context_encoding = public_lib "tezos-context.encoding" @@ -3206,6 +3221,7 @@ let octez_scoru_wasm_tests_helpers = octez_base_test_helpers |> open_; octez_test_helpers; octez_scoru_wasm; + octez_scoru_wasm_fast; qcheck_alcotest; alcotest_lwt; tezt_lib; @@ -4762,7 +4778,7 @@ module Protocol = Protocol ringo; ringo_lwt; injector |> if_some |> open_; - octez_scoru_wasm; + octez_scoru_wasm_fast; octez_crypto_dal |> if_ N.(number >= 016) |> open_; ] in diff --git a/opam/octez-sc-rollup-node-alpha.opam b/opam/octez-sc-rollup-node-alpha.opam index 4800d6b99fb0cbb96980fea2facd4be0ecd55470..b22f5090fc351231ba2fcbb737f37dd2e5dd01f5 100644 --- a/opam/octez-sc-rollup-node-alpha.opam +++ b/opam/octez-sc-rollup-node-alpha.opam @@ -34,7 +34,7 @@ depends: [ "ringo" { >= "0.9" } "ringo-lwt" { >= "0.9" } "tezos-injector-alpha" - "tezos-scoru-wasm" + "tezos-scoru-wasm-fast" "tezos-crypto-dal" ] build: [ diff --git a/opam/tezos-scoru-wasm-fast.opam b/opam/tezos-scoru-wasm-fast.opam new file mode 100644 index 0000000000000000000000000000000000000000..4366b64570fc10718d36e91083b7034c67cb65da --- /dev/null +++ b/opam/tezos-scoru-wasm-fast.opam @@ -0,0 +1,24 @@ +# This file was automatically generated, do not edit. +# Edit file manifest/main.ml instead. +opam-version: "2.0" +maintainer: "contact@tezos.com" +authors: ["Tezos devteam"] +homepage: "https://www.tezos.com/" +bug-reports: "https://gitlab.com/tezos/tezos/issues" +dev-repo: "git+https://gitlab.com/tezos/tezos.git" +license: "MIT" +depends: [ + "dune" { >= "3.0" } + "tezos-base" + "tezos-tree-encoding" + "tezos-webassembly-interpreter" + "tezos-lazy-containers" + "tezos-scoru-wasm" + "tezos-wasmer" +] +build: [ + ["rm" "-r" "vendors"] + ["dune" "build" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} +] +synopsis: "WASM functionality for SCORU Fast Execution" diff --git a/opam/tezos-scoru-wasm-test-helpers.opam b/opam/tezos-scoru-wasm-test-helpers.opam index 8452670e9fbb54bcb2b4c2cce3a4a6f03f0459e1..02c7da4c7f90d82cb4d503e8a27c70ff84cbb0aa 100644 --- a/opam/tezos-scoru-wasm-test-helpers.opam +++ b/opam/tezos-scoru-wasm-test-helpers.opam @@ -17,6 +17,7 @@ depends: [ "tezos-base-test-helpers" "tezos-test-helpers" "tezos-scoru-wasm" + "tezos-scoru-wasm-fast" "qcheck-alcotest" { >= "0.18" } "alcotest-lwt" { >= "1.5.0" } "tezt" diff --git a/src/lib_scoru_wasm/fast/dune b/src/lib_scoru_wasm/fast/dune new file mode 100644 index 0000000000000000000000000000000000000000..7dbd84507089bc0b30bbfd29095e37e0a1df2869 --- /dev/null +++ b/src/lib_scoru_wasm/fast/dune @@ -0,0 +1,17 @@ +; This file was automatically generated, do not edit. +; Edit file manifest/main.ml instead. + +(library + (name tezos_scoru_wasm_fast) + (public_name tezos-scoru-wasm-fast) + (instrumentation (backend bisect_ppx)) + (libraries + tezos-base + tezos-tree-encoding + tezos-webassembly-interpreter + tezos-lazy-containers + tezos-scoru-wasm + tezos-wasmer) + (flags + (:standard) + -open Tezos_base.TzPervasives)) diff --git a/src/lib_scoru_wasm/fast/exec.ml b/src/lib_scoru_wasm/fast/exec.ml new file mode 100644 index 0000000000000000000000000000000000000000..fd23640409aac79338ca1c2e53c82f3fd8212dce --- /dev/null +++ b/src/lib_scoru_wasm/fast/exec.ml @@ -0,0 +1,307 @@ +(*****************************************************************************) +(* *) +(* 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 Tezos_scoru_wasm +module Wasmer = Tezos_wasmer +module Lazy_containers = Tezos_lazy_containers + +let kernel_key = Durable.key_of_string_exn "/kernel/boot.wasm" + +let store = + (* TODO: Making this global is potentially not a great idea. Maybe lazy? *) + let engine = Wasmer.Engine.create Wasmer.Config.{compiler = SINGLEPASS} in + Wasmer.Store.create engine + +let load_kernel durable = + let open Lwt.Syntax in + let* kernel = Durable.find_value_exn durable kernel_key in + let+ kernel = Lazy_containers.Chunked_byte_vector.to_string kernel in + Wasmer.Module.(create store Binary kernel) + +let to_ref_memory mem = + let open Wasmer.Memory in + let get_chunk page_id = + let start_address = + Int64.mul page_id Lazy_containers.Chunked_byte_vector.Chunk.size + in + let body = + Bytes.init + (Int64.to_int Lazy_containers.Chunked_byte_vector.Chunk.size) + (fun i -> + Wasmer.Memory.get mem Int64.(add start_address (of_int i) |> to_int) + |> Unsigned.UInt8.to_int |> Char.chr) + in + Lwt.return (Lazy_containers.Chunked_byte_vector.Chunk.of_bytes body) + in + let length = Wasmer.Memory.length mem |> Int64.of_int in + let chunked = Lazy_containers.Chunked_byte_vector.create ~get_chunk length in + let min = Unsigned.UInt32.to_int32 mem.min in + let max = Option.map Unsigned.UInt32.to_int32 mem.max in + Tezos_webassembly_interpreter.( + Partial_memory.of_chunks (MemoryType {min; max}) chunked) + +let commit_memory mem partial_memory = + let chunks = + Lazy_containers.Chunked_byte_vector.loaded_chunks + (Tezos_webassembly_interpreter.Partial_memory.content partial_memory) + in + List.iter + (fun (chunk_id, chunk) -> + let start = + Int64.mul chunk_id Lazy_containers.Chunked_byte_vector.Chunk.size + in + let body = Lazy_containers.Chunked_byte_vector.Chunk.to_bytes chunk in + Bytes.iteri + (fun i char -> + let addr = Int64.(add start (of_int i) |> to_int) in + Wasmer.Memory.set mem addr (Char.code char |> Unsigned.UInt8.of_int)) + body) + chunks + +let compute durable (buffers : Tezos_webassembly_interpreter.Eval.buffers) = + let open Lwt.Syntax in + let* module_ = load_kernel durable in + + let main_mem = ref None in + let retrieve_mem () = + match !main_mem with Some x -> x () | None -> assert false + in + let with_mem f = + let mem = retrieve_mem () in + let ref_mem = to_ref_memory mem in + let+ value = f ref_mem in + commit_memory mem ref_mem ; + value + in + + let durable_ref = ref durable in + + let host_funcs = + let open Wasmer in + let read_input = + fn + (i32 @-> i32 @-> i32 @-> i32 @-> returning1 i32) + (fun level_offset id_offset dst max_bytes -> + with_mem @@ fun memory -> + Host_funcs.Aux.read_input + ~input_buffer:buffers.input + ~output_buffer:buffers.output + ~memory + ~level_offset + ~id_offset + ~dst + ~max_bytes) + in + let write_output = + fn + (i32 @-> i32 @-> returning1 i32) + (fun src num_bytes -> + with_mem @@ fun memory -> + Host_funcs.Aux.write_output + ~output_buffer:buffers.output + ~memory + ~src + ~num_bytes) + in + let store_has = + fn + (i32 @-> i32 @-> returning1 i32) + (fun key_offset key_length -> + with_mem @@ fun memory -> + let+ result = + Host_funcs.Aux.store_has + ~durable:!durable_ref + ~memory + ~key_offset + ~key_length + in + result) + in + let store_list_size = + fn + (i32 @-> i32 @-> returning1 i64) + (fun key_offset key_length -> + with_mem @@ fun memory -> + let+ durable, result = + Host_funcs.Aux.store_list_size + ~durable:!durable_ref + ~memory + ~key_offset + ~key_length + in + durable_ref := durable ; + result) + in + let store_delete = + fn + (i32 @-> i32 @-> returning nothing) + (fun key_offset key_length -> + with_mem @@ fun memory -> + let+ durable, result = + Host_funcs.Aux.store_delete + ~durable:!durable_ref + ~memory + ~key_offset + ~key_length + in + durable_ref := durable ; + (* XXX: This function shall return an int32 but the kernel doesn't + expect that yet. *) + ignore (result : int32)) + in + let write_debug = + fn + (i32 @-> i32 @-> returning nothing) + (fun key_offset key_length -> + let mem = retrieve_mem () in + let str = + String.init (Int32.to_int key_length) (fun i -> + Wasmer.Memory.get mem (Int32.to_int key_offset + i) + |> Unsigned.UInt8.to_int |> Char.chr) + in + Printf.printf "DEBUG: %s\n" str ; + Lwt.return ()) + in + let store_copy = + fn + (i32 @-> i32 @-> i32 @-> i32 @-> returning1 i32) + (fun from_key_offset from_key_length to_key_offset to_key_length -> + with_mem @@ fun memory -> + let+ durable, result = + Host_funcs.Aux.store_copy + ~durable:!durable_ref + ~memory + ~from_key_offset + ~from_key_length + ~to_key_offset + ~to_key_length + in + durable_ref := durable ; + result) + in + let store_move = + fn + (i32 @-> i32 @-> i32 @-> i32 @-> returning1 i32) + (fun from_key_offset from_key_length to_key_offset to_key_length -> + with_mem @@ fun memory -> + let+ durable, result = + Host_funcs.Aux.store_move + ~durable:!durable_ref + ~memory + ~from_key_offset + ~from_key_length + ~to_key_offset + ~to_key_length + in + durable_ref := durable ; + result) + in + let store_read = + fn + (i32 @-> i32 @-> i32 @-> i32 @-> i32 @-> returning1 i32) + (fun key_offset key_length value_offset dest max_bytes -> + with_mem @@ fun memory -> + Host_funcs.Aux.store_read + ~durable:!durable_ref + ~memory + ~key_offset + ~key_length + ~value_offset + ~dest + ~max_bytes) + in + let store_write = + fn + (i32 @-> i32 @-> i32 @-> i32 @-> i32 @-> returning1 i32) + (fun key_offset key_length value_offset src num_bytes -> + with_mem @@ fun memory -> + let+ durable, ret = + Host_funcs.Aux.store_write + ~durable:!durable_ref + ~memory + ~key_offset + ~key_length + ~value_offset + ~src + ~num_bytes + in + durable_ref := durable ; + ret) + in + let store_get_nth_key = + fn + (i32 @-> i32 @-> i64 @-> i32 @-> i32 @-> returning1 i32) + (fun key_offset key_length index dst max_size -> + with_mem @@ fun memory -> + Host_funcs.Aux.store_get_nth_key + ~durable:!durable_ref + ~memory + ~key_offset + ~key_length + ~index + ~dst + ~max_size) + in + let store_value_size = + fn + (i32 @-> i32 @-> returning1 i32) + (fun key_offset key_length -> + with_mem @@ fun memory -> + Host_funcs.Aux.store_value_size + ~durable:!durable_ref + ~memory + ~key_offset + ~key_length) + in + [ + ("rollup_safe_core", "read_input", read_input); + ("rollup_safe_core", "write_output", write_output); + ("rollup_safe_core", "write_debug", write_debug); + ("rollup_safe_core", "store_has", store_has); + ("rollup_safe_core", "store_list_size", store_list_size); + ("rollup_safe_core", "store_value_size", store_value_size); + ("rollup_safe_core", "store_delete", store_delete); + ("rollup_safe_core", "store_copy", store_copy); + ("rollup_safe_core", "store_move", store_move); + ("rollup_safe_core", "store_read", store_read); + ("rollup_safe_core", "store_write", store_write); + ("rollup_safe_core", "store_get_nth_key", store_get_nth_key); + ] + in + + let* instance = Wasmer.Instance.create store module_ host_funcs in + + let exports = Wasmer.Exports.from_instance instance in + let kernel_next = + Wasmer.(Exports.fn exports "kernel_next" (producer nothing)) + in + + main_mem := Some (fun () -> Wasmer.Exports.mem0 exports) ; + + let* () = kernel_next () in + + Wasmer.Instance.delete instance ; + Wasmer.Module.delete module_ ; + Lwt.return !durable_ref diff --git a/src/lib_scoru_wasm/fast/pvm.ml b/src/lib_scoru_wasm/fast/pvm.ml new file mode 100644 index 0000000000000000000000000000000000000000..f6dcf9e599cd8ea94fd02148c17ea88a9267e0eb --- /dev/null +++ b/src/lib_scoru_wasm/fast/pvm.ml @@ -0,0 +1,26 @@ +(*****************************************************************************) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +module Make = Tezos_scoru_wasm.Wasm_pvm.Make_pvm (Vm) diff --git a/src/lib_scoru_wasm/fast/vm.ml b/src/lib_scoru_wasm/fast/vm.ml new file mode 100644 index 0000000000000000000000000000000000000000..12e29175c0fc3fc5423671dc58433394d346f1b2 --- /dev/null +++ b/src/lib_scoru_wasm/fast/vm.ml @@ -0,0 +1,109 @@ +(*****************************************************************************) +(* *) +(* 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 Tezos_scoru_wasm +open Wasm_pvm_state.Internal_state + +include (Wasm_vm : Wasm_vm_sig.S) + +let compute_until_start ~max_steps pvm_state = + Wasm_vm.compute_step_many_until + ~max_steps + (fun pvm_state -> + match pvm_state.tick_state with + | Start -> Lwt.return false + | _ -> Wasm_vm.should_compute pvm_state) + pvm_state + +module Internal_for_tests = struct + let run_counter = ref Z.zero + + let record_successful_run () = run_counter := Z.succ !run_counter + + let get_successful_runs () = !run_counter +end + +let rec compute_step_many ~max_steps pvm_state = + let open Lwt.Syntax in + assert (max_steps > 0L) ; + let eligible_for_fast_exec = + Z.Compare.(Z.of_int64 max_steps >= pvm_state.max_nb_ticks) + in + if eligible_for_fast_exec then + let goto_start_and_retry () = + let* pvm_state, ticks = compute_until_start ~max_steps pvm_state in + let max_steps = Int64.sub max_steps ticks in + let* may_compute_more = Wasm_vm.should_compute pvm_state in + if may_compute_more && max_steps > 0L then + (* TODO: Make tail recursive! *) + let+ pvm_state, more_ticks = compute_step_many ~max_steps pvm_state in + (pvm_state, Int64.add ticks more_ticks) + else Lwt.return (pvm_state, ticks) + in + let go_like_the_wind () = + (* First we must clear any remainder of a reboot flag. *) + let durable = pvm_state.durable in + let* has_reboot_flag = Wasm_vm.has_reboot_flag durable in + let* durable = + if has_reboot_flag then + Durable.(delete durable Constants.reboot_flag_key) + else Lwt.return durable + in + (* Execute! *) + (* TODO: Call multiple times? *) + let* durable = Exec.compute durable pvm_state.buffers in + (* Compute the new tick counter. *) + let ticks = Z.pred pvm_state.max_nb_ticks in + let current_tick = Z.add pvm_state.current_tick ticks in + (* Figure out reboot. *) + let+ status = Wasm_vm.mark_for_reboot pvm_state.reboot_counter durable in + let tick_state = + if status = Failing then Stuck Too_many_reboots else Snapshot + in + let reboot_counter = Wasm_vm.next_reboot_counter pvm_state status in + (* Assemble state *) + let pvm_state = + { + pvm_state with + durable; + current_tick; + tick_state; + reboot_counter; + last_top_level_call = current_tick; + } + in + Internal_for_tests.record_successful_run () ; + (pvm_state, Z.to_int64 ticks) + in + match pvm_state.tick_state with + | Start -> + Lwt.catch go_like_the_wind (fun _ -> + Tezos_scoru_wasm.Wasm_vm.compute_step_many ~max_steps pvm_state) + | _ -> goto_start_and_retry () + else + (* The number of ticks we're asked to do is lower than the maximum number + of ticks for a top-level cycle. Fast Execution cannot be applied in this + case. *) + Tezos_scoru_wasm.Wasm_vm.compute_step_many ~max_steps pvm_state diff --git a/src/lib_scoru_wasm/fast/vm.mli b/src/lib_scoru_wasm/fast/vm.mli new file mode 100644 index 0000000000000000000000000000000000000000..7643d849bba6e021346beb4bb895dc9b72a08f46 --- /dev/null +++ b/src/lib_scoru_wasm/fast/vm.mli @@ -0,0 +1,30 @@ +(*****************************************************************************) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +include Tezos_scoru_wasm.Wasm_vm_sig.S + +module Internal_for_tests : sig + val get_successful_runs : unit -> Z.t +end diff --git a/src/lib_scoru_wasm/test/helpers/dune b/src/lib_scoru_wasm/test/helpers/dune index 61d7cef1fd59cfb05c70a742be40fbb90a6cf01f..6c6822a4c78294179ccb3b614a7c9c35653cc9a1 100644 --- a/src/lib_scoru_wasm/test/helpers/dune +++ b/src/lib_scoru_wasm/test/helpers/dune @@ -13,6 +13,7 @@ tezos-base-test-helpers tezos-test-helpers tezos-scoru-wasm + tezos-scoru-wasm-fast qcheck-alcotest alcotest-lwt tezt diff --git a/src/lib_scoru_wasm/test/helpers/wasm_utils.ml b/src/lib_scoru_wasm/test/helpers/wasm_utils.ml index b70726029ffde833a76486dd1ca29714367fba47..546b85517e0be82089b27666f90dd2444589f796 100644 --- a/src/lib_scoru_wasm/test/helpers/wasm_utils.ml +++ b/src/lib_scoru_wasm/test/helpers/wasm_utils.ml @@ -28,6 +28,7 @@ open Tezos_scoru_wasm open Test_encodings_util open Tezos_lazy_containers module Wasm = Wasm_pvm.Make (Tree) +module Wasm_fast = Tezos_scoru_wasm_fast.Pvm.Make (Tree) let parse_module code = let def = Parse.string_to_module code in @@ -65,13 +66,17 @@ let eval_until_stuck ?(max_steps = 20000L) tree = in go max_steps tree -let rec eval_until_input_requested ?(max_steps = Int64.max_int) tree = +let rec eval_until_input_requested ?(fast_exec = false) + ?(max_steps = Int64.max_int) tree = let open Lwt_syntax in + let run = + if fast_exec then Wasm_fast.compute_step_many else Wasm.compute_step_many + in let* info = Wasm.get_info tree in match info.input_request with | No_input_required -> - let* tree, _ = Wasm.compute_step_many ~max_steps tree in - eval_until_input_requested tree + let* tree, _ = run ~max_steps tree in + eval_until_input_requested ~fast_exec ~max_steps tree | Input_required | Reveal_required _ -> return tree let rec eval_until_init tree = @@ -100,7 +105,8 @@ let set_input_step message message_counter tree = let pp_state fmt state = let pp_s s = Format.fprintf fmt "%s" s in match state with - | Wasm_pvm_state.Internal_state.Decode _ -> pp_s "Decode" + | Wasm_pvm_state.Internal_state.Start -> pp_s "Start" + | Decode _ -> pp_s "Decode" | Eval _ -> pp_s "Eval" | Stuck e -> Format.fprintf fmt "Stuck (%a)" Test_wasm_pvm_encodings.pp_error_state e diff --git a/src/lib_scoru_wasm/test/test_fast.ml b/src/lib_scoru_wasm/test/test_fast.ml new file mode 100644 index 0000000000000000000000000000000000000000..981764dfc434c97c383263279e4c4e696c306718 --- /dev/null +++ b/src/lib_scoru_wasm/test/test_fast.ml @@ -0,0 +1,170 @@ +(*****************************************************************************) +(* *) +(* 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 Tztest + +let apply_fast counter tree = + let open Lwt.Syntax in + let run_counter_before = + Tezos_scoru_wasm_fast.Vm.Internal_for_tests.get_successful_runs () + in + let+ tree = + Wasm_utils.eval_until_input_requested + ~fast_exec:true + ~max_steps:Int64.max_int + tree + in + (if counter > 0 then + (* Assert that the FE actual ran. We must consider that before the first + message is inserted, FE is unlikely to run. *) + let run_counter_after = + Tezos_scoru_wasm_fast.Vm.Internal_for_tests.get_successful_runs () + in + assert (Z.Compare.(run_counter_after > run_counter_before))) ; + tree + +let apply_slow = + Wasm_utils.eval_until_input_requested + ~fast_exec:false + ~max_steps:Int64.max_int + +let test_against_both ~from_binary ~kernel ~messages = + let open Lwt.Syntax in + let rec go_in_parallel counter messages start_tree = + let* slow_tree = apply_slow start_tree in + let* fast_tree = apply_fast counter start_tree in + + let fast_hash = Tezos_context_memory.Context_binary.Tree.hash fast_tree in + let slow_hash = Tezos_context_memory.Context_binary.Tree.hash slow_tree in + assert (Context_hash.(slow_hash = fast_hash)) ; + + let* stuck = Wasm_utils.Wasm.Internal_for_tests.is_stuck fast_tree in + assert (Option.is_none stuck) ; + match messages with + | [] -> Lwt.return_unit + | message :: messages -> + let* tree = Wasm_utils.set_input_step message counter fast_tree in + go_in_parallel (succ counter) messages tree + in + + let* tree = + Wasm_utils.initial_tree ~max_tick:Int64.max_int ~from_binary kernel + in + let* () = go_in_parallel 0 messages tree in + + Lwt_result_syntax.return_unit + +let test_computation = + Wasm_utils.test_with_kernel "computation" (fun kernel -> + (* Providing 4 empty messages basically means calling the kernel + entrypoint 4 times. *) + test_against_both ~from_binary:true ~kernel ~messages:[""; ""; ""; ""]) + +let test_store_read_write () = + let kernel = + {| + (module + (import + "rollup_safe_core" + "write_debug" + (func $write_debug (param i32 i32)) + ) + + (import + "rollup_safe_core" + "store_write" + (func $store_write (param i32 i32 i32 i32 i32) (result i32)) + ) + + (import + "rollup_safe_core" + "store_read" + (func $store_read (param i32 i32 i32 i32 i32) (result i32)) + ) + + (memory 1) + (export "memory" (memory 0)) + + (data (i32.const 0) "Hello World") + (data (i32.const 100) "/foo") + + (func (export "kernel_next") (local $n i64) + (call $write_debug (i32.const 0) (i32.const 5)) + (call $write_debug (i32.const 6) (i32.const 5)) + (call $write_debug (i32.const 0) (i32.const 11)) + + ;; Write the initial value to the durable store + (call $store_write + (i32.const 100) (i32.const 4) ;; Key + (i32.const 0) ;; Offset to write + (i32.const 1000) (i32.const 4) ;; Bytes to write + ) + (drop) + + ;; Set the loop counter + (local.set $n (i64.const 100)) + + (loop + ;; Read from store to memory + (call $store_read + (i32.const 100) (i32.const 4) ;; Key + (i32.const 0) ;; Offset to write + (i32.const 1000) (i32.const 4) ;; Bytes to write + ) + (drop) + + ;; Increment the value in memory + (i32.store + (i32.const 1000) + (i32.add + (i32.load (i32.const 1000)) + (i32.const 1))) + + ;; Write value from memory to durable store + (call $store_write + (i32.const 100) (i32.const 4) + (i32.const 0) + (i32.const 1000) (i32.const 4) + ) + (drop) + + ;; Decrement loop counter + (local.set $n (i64.sub (local.get $n) (i64.const 1))) + + ;; Check if we ought to loop again + (i32.eq (i32.const 0) (i64.eq (local.get $n) (i64.const 0))) + (br_if 0) + ) + ) +) + |} + in + test_against_both ~from_binary:false ~kernel ~messages:(List.repeat 100 "") + +let tests = + [ + tztest "Computation kernel" `Quick test_computation; + tztest "Store read/write kernel" `Quick test_store_read_write; + ] diff --git a/src/lib_scoru_wasm/test/test_scoru_wasm.ml b/src/lib_scoru_wasm/test/test_scoru_wasm.ml index ac721436e3c89206cd4f896a105cfd88ef2b1d26..623001feedb5c0802853d672ec962a41d12f7c4d 100644 --- a/src/lib_scoru_wasm/test/test_scoru_wasm.ml +++ b/src/lib_scoru_wasm/test/test_scoru_wasm.ml @@ -47,5 +47,6 @@ let () = ("Max nb of ticks", Test_fixed_nb_ticks.tests); ("Hash correspondence", Test_hash_consistency.tests); ("Reveal", Test_reveal.tests); + ("Fast Execution", Test_fast.tests); ] |> Lwt_main.run diff --git a/src/lib_scoru_wasm/test/test_wasm_pvm.ml b/src/lib_scoru_wasm/test/test_wasm_pvm.ml index 05985a6ed10a9e723e5f5f22ee1f1353e68f5596..43254187a73ee708b5bddc31817a3db4fc4d13b1 100644 --- a/src/lib_scoru_wasm/test/test_wasm_pvm.ml +++ b/src/lib_scoru_wasm/test/test_wasm_pvm.ml @@ -547,7 +547,7 @@ let test_snapshotable_state () = let*! tree = set_input_step "test" 1 tree in let*! state = Wasm.Internal_for_tests.get_tick_state tree in match state with - | Decode _ -> return_unit + | Start -> return_unit | _ -> failwith "Unexpected state after set_input_step: %a" diff --git a/src/lib_scoru_wasm/test/wasm_kernels/computation.wasm b/src/lib_scoru_wasm/test/wasm_kernels/computation.wasm new file mode 100644 index 0000000000000000000000000000000000000000..da2df75b0e18b30e75d76eb42438c28f1d2c6148 Binary files /dev/null and b/src/lib_scoru_wasm/test/wasm_kernels/computation.wasm differ diff --git a/src/lib_scoru_wasm/wasm_pvm.ml b/src/lib_scoru_wasm/wasm_pvm.ml index b1adf912ff211182aac0a96c7c645cc7e62c5673..0d49ca78f1509484ff3e5f0dd68354fa6ab19c03 100644 --- a/src/lib_scoru_wasm/wasm_pvm.ml +++ b/src/lib_scoru_wasm/wasm_pvm.ml @@ -34,6 +34,11 @@ let tick_state_encoding = ~default:(fun () -> Snapshot) (value [] Data_encoding.string) [ + case + "start" + (return ()) + (function Start -> Some () | _ -> None) + (fun () -> Start); case "decode" Parsing.Decode.encoding @@ -171,145 +176,143 @@ let pvm_state_encoding = ["pvm"; "maximum_reboots_per_input"] Data_encoding.n)) -module Make (T : Tezos_tree_encoding.TREE) : +module Make_pvm (Wasm_vm : Wasm_vm_sig.S) (T : Tezos_tree_encoding.TREE) : Wasm_pvm_sig.S with type tree = T.tree = struct - module Raw = struct - type tree = T.tree + type tree = T.tree - module Tree_encoding_runner = Tezos_tree_encoding.Runner.Make (T) + module Tree_encoding_runner = Tezos_tree_encoding.Runner.Make (T) - let decode tree = Tree_encoding_runner.decode pvm_state_encoding tree + let decode tree = Tree_encoding_runner.decode pvm_state_encoding tree - let encode pvm_state tree = - let open Lwt.Syntax in - (* {{Note tick state clean-up}} + let encode pvm_state tree = + let open Lwt.Syntax in + (* {{Note tick state clean-up}} - The "wasm" directory in the Irmin tree of the PVM is used to - maintain a lot of information across tick, but as of now, it - was never cleaned up. It meant that the tree would become - crowded with data that were no longer needed. + The "wasm" directory in the Irmin tree of the PVM is used to + maintain a lot of information across tick, but as of now, it + was never cleaned up. It meant that the tree would become + crowded with data that were no longer needed. - It turns out it is very simple to clean up, thanks to subtree - move. Because we keep in the lazy-containers the original - subtree, and we inject it prior to updating read keys, the - tree-encoding library does not rely on the input tree at - encoding time. + It turns out it is very simple to clean up, thanks to subtree + move. Because we keep in the lazy-containers the original + subtree, and we inject it prior to updating read keys, the + tree-encoding library does not rely on the input tree at + encoding time. - With this, we gain an additional 5% of proof size in the - worst tick of the computation.wasm kernel. *) - let* tree = T.remove tree ["wasm"] in - Tree_encoding_runner.encode pvm_state_encoding pvm_state tree + With this, we gain an additional 5% of proof size in the + worst tick of the computation.wasm kernel. *) + 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 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 ~max_steps tree = - let open Lwt.Syntax in - let* pvm_state = decode tree in - let* pvm_state, executed_ticks = - Wasm_vm.compute_step_many ~max_steps pvm_state - in - let+ tree = encode pvm_state tree in - (tree, executed_ticks) + let compute_step_many ~max_steps tree = + let open Lwt.Syntax in + let* pvm_state = decode tree in + let* pvm_state, executed_ticks = + Wasm_vm.compute_step_many ~max_steps pvm_state + in + let+ tree = encode pvm_state tree in + (tree, executed_ticks) - let compute_step tree = - let open Lwt.Syntax in - let* initial_state = decode tree in - let* final_state = Wasm_vm.compute_step initial_state in - encode final_state tree + let compute_step tree = + let open Lwt.Syntax in + let* initial_state = decode tree in + let* final_state = Wasm_vm.compute_step initial_state in + encode final_state tree - let get_output output_info tree = - let open Lwt_syntax in - let* candidate = - Tree_encoding_runner.decode - (Tezos_tree_encoding.option durable_buffers_encoding) - tree - in - Lwt.catch - (fun () -> - match candidate with - | Some {output; _} -> - let+ result = Wasm_vm.get_output output_info output in - Some result - | None -> Lwt.return None) - (fun _ -> Lwt.return None) + let get_output output_info tree = + let open Lwt_syntax in + let* candidate = + Tree_encoding_runner.decode + (Tezos_tree_encoding.option durable_buffers_encoding) + tree + in + Lwt.catch + (fun () -> + match candidate with + | Some {output; _} -> + let+ result = Wasm_vm.get_output output_info output in + Some result + | None -> Lwt.return None) + (fun _ -> Lwt.return None) - let get_info tree = - let open Lwt_syntax in - let* pvm_state = decode tree in - Wasm_vm.get_info pvm_state + let get_info tree = + let open Lwt_syntax in + let* pvm_state = decode tree in + Wasm_vm.get_info pvm_state - let set_input_step input_info message tree = - let open Lwt_syntax in - let* pvm_state = decode tree in - let* pvm_state = Wasm_vm.set_input_step input_info message pvm_state in - encode pvm_state tree + let set_input_step input_info message tree = + let open Lwt_syntax in + let* pvm_state = decode tree in + let* pvm_state = Wasm_vm.set_input_step input_info message pvm_state in + encode pvm_state tree - let reveal_step payload tree = - let open Lwt_syntax in - let* pvm_state = decode tree in - let* pvm_state = Wasm_vm.reveal_step payload pvm_state in - encode pvm_state tree + let reveal_step payload tree = + let open Lwt_syntax in + let* pvm_state = decode tree in + let* pvm_state = Wasm_vm.reveal_step payload pvm_state in + encode pvm_state tree - module Internal_for_tests = struct - let get_tick_state tree = - let open Lwt_syntax in - let+ pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in - pvm_state.tick_state + module Internal_for_tests = struct + let get_tick_state tree = + let open Lwt_syntax in + let+ pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in + pvm_state.tick_state - let get_module_instance_exn tree = - let open Lwt_syntax in - let* pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in - match pvm_state.tick_state with - | Eval config -> - Wasm.Instance.ModuleMap.get - Constants.wasm_main_module_name - config.module_reg - | _ -> raise (Invalid_argument "get_module_instance") + let get_module_instance_exn tree = + let open Lwt_syntax in + let* pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in + match pvm_state.tick_state with + | Eval config -> + Wasm.Instance.ModuleMap.get + Constants.wasm_main_module_name + config.module_reg + | _ -> raise (Invalid_argument "get_module_instance") - let is_stuck tree = - let open Lwt.Syntax in - let* pvm = Tree_encoding_runner.decode pvm_state_encoding tree in - match pvm.tick_state with - | Stuck error -> Lwt.return_some error - | _ -> Lwt.return_none + let is_stuck tree = + let open Lwt.Syntax in + let* pvm = Tree_encoding_runner.decode pvm_state_encoding tree in + match pvm.tick_state with + | Stuck error -> Lwt.return_some error + | _ -> Lwt.return_none - let set_max_nb_ticks n tree = - let open Lwt_syntax in - let* pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in - let pvm_state = {pvm_state with max_nb_ticks = n} in - Tree_encoding_runner.encode pvm_state_encoding pvm_state tree + let set_max_nb_ticks n tree = + let open Lwt_syntax in + let* pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in + let pvm_state = {pvm_state with max_nb_ticks = n} in + Tree_encoding_runner.encode pvm_state_encoding pvm_state tree - let set_maximum_reboots_per_input n tree = - let open Lwt_syntax in - let* pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in - let pvm_state = {pvm_state with maximum_reboots_per_input = n} in - Tree_encoding_runner.encode pvm_state_encoding pvm_state tree + let set_maximum_reboots_per_input n tree = + let open Lwt_syntax in + let* pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in + let pvm_state = {pvm_state with maximum_reboots_per_input = n} in + Tree_encoding_runner.encode pvm_state_encoding pvm_state tree - let reset_reboot_counter tree = - let open Lwt_syntax in - let* pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in - let pvm_state = - {pvm_state with reboot_counter = pvm_state.maximum_reboots_per_input} - in - Tree_encoding_runner.encode pvm_state_encoding pvm_state tree + let reset_reboot_counter tree = + let open Lwt_syntax in + let* pvm_state = Tree_encoding_runner.decode pvm_state_encoding tree in + let pvm_state = + {pvm_state with reboot_counter = pvm_state.maximum_reboots_per_input} + in + Tree_encoding_runner.encode pvm_state_encoding pvm_state tree - let get_output_buffer tree = - let open Lwt.Syntax in - let+ pvm = Tree_encoding_runner.decode pvm_state_encoding tree in - pvm.buffers.output + let get_output_buffer tree = + let open Lwt.Syntax in + let+ pvm = Tree_encoding_runner.decode pvm_state_encoding tree in + pvm.buffers.output - let get_input_buffer tree = - let open Lwt.Syntax in - let+ pvm = Tree_encoding_runner.decode pvm_state_encoding tree in - pvm.buffers.input - end + let get_input_buffer tree = + let open Lwt.Syntax in + let+ pvm = Tree_encoding_runner.decode pvm_state_encoding tree in + pvm.buffers.input end - - include Raw end + +module Make = Make_pvm (Wasm_vm) diff --git a/src/lib_scoru_wasm/wasm_pvm.mli b/src/lib_scoru_wasm/wasm_pvm.mli index 5cf75212f13bc88ebd7d505f88702b9fa48dcda6..203d16c188f878e46c0371c154598441bdfe6f2c 100644 --- a/src/lib_scoru_wasm/wasm_pvm.mli +++ b/src/lib_scoru_wasm/wasm_pvm.mli @@ -32,3 +32,5 @@ val durable_buffers_encoding : module Make (T : Tezos_tree_encoding.TREE) : Wasm_pvm_sig.S with type tree = T.tree + +module Make_pvm (Wasm_vm : Wasm_vm_sig.S) : module type of Make diff --git a/src/lib_scoru_wasm/wasm_pvm_state.ml b/src/lib_scoru_wasm/wasm_pvm_state.ml index 213c90462630630aa9dd2ba5fc111252e91b478a..eeb4a2cb19aa349f3be1cc3f1cf4e7a72b1c9c9b 100644 --- a/src/lib_scoru_wasm/wasm_pvm_state.ml +++ b/src/lib_scoru_wasm/wasm_pvm_state.ml @@ -67,6 +67,7 @@ type info = { For use in lib_scoru_wasm only. *) module Internal_state = struct type tick_state = + | Start | Decode of Tezos_webassembly_interpreter.Decode.decode_kont | Link of { ast_module : Tezos_webassembly_interpreter.Ast.module_; diff --git a/src/lib_scoru_wasm/wasm_vm.ml b/src/lib_scoru_wasm/wasm_vm.ml index 7fe4337b85b95d19ba3e16e5d3b4239c2578128f..46c7dd9b0aeab470613b08b06d398b5950f12fc6 100644 --- a/src/lib_scoru_wasm/wasm_vm.ml +++ b/src/lib_scoru_wasm/wasm_vm.ml @@ -79,7 +79,7 @@ let unsafe_next_tick_state ({buffers; durable; tick_state; _} as pvm_state) = let* has_reboot_flag = has_reboot_flag durable in if has_reboot_flag then let* durable = Durable.(delete durable Constants.reboot_flag_key) in - return ~durable (initial_boot_state ()) + return ~durable Start else return ~status:Failing @@ -97,6 +97,7 @@ let unsafe_next_tick_state ({buffers; durable; tick_state; _} as pvm_state) = | _ when is_time_for_snapshot pvm_state -> (* Execution took too many ticks *) return ~status:Failing (Stuck Too_many_ticks) + | Start -> return (initial_boot_state ()) | Decode {module_kont = MKStop ast_module; _} -> return (Link @@ -212,7 +213,8 @@ let next_tick_state pvm_state = | Link _ -> Link_error error.Wasm_pvm_errors.raw_exception | Init _ -> Init_error error | Eval _ -> Eval_error error - | Stuck _ | Snapshot | Padding -> Unknown_error error.raw_exception) + | Start | Stuck _ | Snapshot | Padding -> + Unknown_error error.raw_exception) | `Unknown raw_exception -> Unknown_error raw_exception in Lwt.return (pvm_state.durable, Stuck wasm_error, Failing) @@ -337,7 +339,11 @@ let set_input_step input_info message pvm_state = (* TODO: https://gitlab.com/tezos/tezos/-/issues/3157 The goal is to read a complete inbox. *) (* Go back to decoding *) - initial_boot_state () + Start + | Start -> + Lwt.return + (Stuck + (Wasm_pvm_errors.invalid_state "No input required during start")) | Decode _ -> Lwt.return (Stuck @@ -371,6 +377,9 @@ let reveal_step payload pvm_state = | Eval {config; module_reg} -> let* config = Eval.reveal_step module_reg payload config in return (Eval {config; module_reg}) + | Start -> + return + (Stuck (Wasm_pvm_errors.invalid_state "No reveal expected during start")) | Decode _ -> return (Stuck diff --git a/src/lib_scoru_wasm/wasm_vm.mli b/src/lib_scoru_wasm/wasm_vm.mli index f2335c29e289705aa21cebe909b9e53c57f6a0d7..6d4f43eee4733517869f0a0bfdb242b58b14b950 100644 --- a/src/lib_scoru_wasm/wasm_vm.mli +++ b/src/lib_scoru_wasm/wasm_vm.mli @@ -46,3 +46,11 @@ val compute_step_many_until : (pvm_state * int64) Lwt.t val eval_has_finished : tick_state -> bool + +val should_compute : pvm_state -> bool Lwt.t + +val has_reboot_flag : Durable.t -> bool Lwt.t + +val mark_for_reboot : Z.t -> Durable.t -> computation_status Lwt.t + +val next_reboot_counter : pvm_state -> computation_status -> Z.t diff --git a/src/proto_alpha/bin_sc_rollup_node/dune b/src/proto_alpha/bin_sc_rollup_node/dune index f1b2012a4dc7342c5861dd08b26244d9e0860675..cecf581350b2e51e6f28964d383507dd4b9762d7 100644 --- a/src/proto_alpha/bin_sc_rollup_node/dune +++ b/src/proto_alpha/bin_sc_rollup_node/dune @@ -35,7 +35,7 @@ ringo ringo-lwt tezos-injector-alpha - tezos-scoru-wasm + tezos-scoru-wasm-fast tezos-crypto-dal) (link_flags (:standard) diff --git a/src/proto_alpha/bin_sc_rollup_node/wasm_2_0_0_pvm.ml b/src/proto_alpha/bin_sc_rollup_node/wasm_2_0_0_pvm.ml index ce756990da53ec044a97ce65e8ba8e765c01f81f..92dde90354fc96501c2217d4e7cba6c78d99f63d 100644 --- a/src/proto_alpha/bin_sc_rollup_node/wasm_2_0_0_pvm.ml +++ b/src/proto_alpha/bin_sc_rollup_node/wasm_2_0_0_pvm.ml @@ -52,7 +52,7 @@ module type TreeS = module Make_backend (Tree : TreeS) = struct type Tezos_lazy_containers.Lazy_map.tree += PVM_tree of Tree.tree - include Tezos_scoru_wasm.Wasm_pvm.Make (struct + include Tezos_scoru_wasm_fast.Pvm.Make (struct include Tree let select = function diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node advances PVM state with internal messages.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node advances PVM state with internal messages.out index c4ed906436d68e978f835d653bf4ce1d7322be24..47a24ef31cb7d646daaa0e3a2b4b4c0376ee8a64 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node advances PVM state with internal messages.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node advances PVM state with internal messages.out @@ -41,118 +41,118 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"3" +"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 -"6" +"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 -"6" +"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 -"9" +"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 -"9" +"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 -"12" +"13" ./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 -"12" +"13" ./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 -"15" +"16" ./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 -"15" +"16" ./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 -"18" +"19" ./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 -"18" +"19" ./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 -"21" +"22" ./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 -"21" +"22" ./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 -"24" +"25" ./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 -"24" +"25" ./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 -"27" +"28" ./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 -"27" +"28" ./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 -"30" +"31" ./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 -"30" +"31" ./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 -"33" +"34" diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node advances PVM state with messages.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node advances PVM state with messages.out index 60fbb7f5e96e118ab3859234b7234873afe193ce..a482518914b73d7693a4ac2968bb2708640be389 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node advances PVM state with messages.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - node advances PVM state with messages.out @@ -84,13 +84,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" +"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 -"4" +"5" ./octez-client --wait none send sc rollup message '["2 8 + value"]' from bootstrap2 Node is bootstrapped. @@ -133,13 +133,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" +"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 -"7" +"8" ./octez-client --wait none send sc rollup message '["3 10 + value"]' from bootstrap2 Node is bootstrapped. @@ -183,13 +183,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" +"11" ./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" +"11" ./octez-client --wait none send sc rollup message '["4 12 + value"]' from bootstrap2 Node is bootstrapped. @@ -233,13 +233,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"13" +"14" ./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 -"13" +"14" ./octez-client --wait none send sc rollup message '["5 14 + value"]' from bootstrap2 Node is bootstrapped. @@ -283,13 +283,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"16" +"17" ./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 -"16" +"17" ./octez-client --wait none send sc rollup message '["6 16 + value"]' from bootstrap2 Node is bootstrapped. @@ -333,13 +333,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"19" +"20" ./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 -"19" +"20" ./octez-client --wait none send sc rollup message '["7 18 + value"]' from bootstrap2 Node is bootstrapped. @@ -384,13 +384,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"22" +"23" ./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 -"22" +"23" ./octez-client --wait none send sc rollup message '["8 20 + value"]' from bootstrap2 Node is bootstrapped. @@ -436,13 +436,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"25" +"26" ./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 -"25" +"26" ./octez-client --wait none send sc rollup message '["9 22 + value"]' from bootstrap2 Node is bootstrapped. @@ -488,13 +488,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"28" +"29" ./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 -"28" +"29" ./octez-client --wait none send sc rollup message '["10 24 + value"]' from bootstrap2 Node is bootstrapped. @@ -540,4 +540,4 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"31" +"32" diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (batcher_does_.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (batcher_does_.out index 99353541a0b90990b30231758a9b722118120fca..36652ca54d2298e0c6ec217dcbf716c5986630b4 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (batcher_does_.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (batcher_does_.out @@ -2500,7 +2500,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (commitment_is.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (commitment_is.out index 1d6f815d0b6fd3eab34db290dc0f8418cddaeba7..9da08a8daea0ca7aa98e1bc87a052978109ec7e7 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (commitment_is.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (commitment_is.out @@ -1244,7 +1244,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./octez-sc-rollup-client-alpha rpc get /local/last_published_commitment @@ -1253,6 +1253,6 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (first_publish.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (first_publish.out index 075be6be0e53cdfbf7d0efe89a1395b02c265a3a..f55b029fb9ed1ce8b031a2ecc72a2447a66e8f94 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (first_publish.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (first_publish.out @@ -43,7 +43,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "61" }, + "number_of_ticks": "62" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./octez-sc-rollup-client-alpha rpc get /local/last_published_commitment @@ -52,7 +52,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "61" }, + "number_of_ticks": "62" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } @@ -62,6 +62,6 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "61" }, + "number_of_ticks": "62" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (handles_chain.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (handles_chain.out index ed8c52752a527a35cc7124b57435d011fad15c1a..ab7a2415c7b9096d958182d4df1628822247014b 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (handles_chain.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (handles_chain.out @@ -84,7 +84,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "61" }, + "number_of_ticks": "62" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./octez-sc-rollup-client-alpha rpc get /local/last_published_commitment @@ -93,5 +93,5 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "61" }, + "number_of_ticks": "62" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (maintenance_p.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (maintenance_p.out index 98f627d38414afdcfc065f56446fcc3df174dca0..5a5d0855260a0c5ebfedd4083a83b2d2443f6f90 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (maintenance_p.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (maintenance_p.out @@ -2500,7 +2500,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } @@ -2510,6 +2510,6 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out index 932b34f358e8a44cb856ecc5714142ff634ed6d3..5dd1e00bcbabefeb85bb71252e349438ddf6b440 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (no_commitment.out @@ -43,7 +43,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "61" }, + "number_of_ticks": "62" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./octez-sc-rollup-client-alpha rpc get /local/last_published_commitment @@ -52,7 +52,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "61" }, + "number_of_ticks": "62" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./octez-client rpc get /chains/main/blocks/head/context/constants @@ -266,7 +266,7 @@ null "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "61" }, + "number_of_ticks": "62" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./octez-sc-rollup-client-alpha rpc get /local/last_published_commitment diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (node_use_prot.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (node_use_prot.out index 317cd9ddcbb1dbb1c299b90b4221191752aa3edc..4a33675c26772bbf6ff62f5f509fa47d8fc43f7d 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (node_use_prot.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (node_use_prot.out @@ -629,7 +629,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 17, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "151" }, + "number_of_ticks": "152" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./octez-sc-rollup-client-alpha rpc get /local/last_published_commitment @@ -638,6 +638,6 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 17, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "151" }, + "number_of_ticks": "152" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 20 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (observer_does.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (observer_does.out index 99353541a0b90990b30231758a9b722118120fca..36652ca54d2298e0c6ec217dcbf716c5986630b4 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (observer_does.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (observer_does.out @@ -2500,7 +2500,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (operator_publ.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (operator_publ.out index 98f627d38414afdcfc065f56446fcc3df174dca0..5a5d0855260a0c5ebfedd4083a83b2d2443f6f90 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (operator_publ.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (operator_publ.out @@ -2500,7 +2500,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } @@ -2510,6 +2510,6 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (robust_to_fai.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (robust_to_fai.out index 7b82ed1546638383dee8b5eaab4973722dc99dd2..319de75ee79605b57e4abf33b84292bea7362312 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (robust_to_fai.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - rollup node - correct handling of commitments (robust_to_fai.out @@ -1244,7 +1244,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./octez-sc-rollup-client-alpha rpc get /global/last_stored_commitment @@ -1253,5 +1253,5 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "526" }, + "number_of_ticks": "527" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } 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 4a9220cd9e40011ebc5cc9112bf934443d096bc8..a6a95c862aeeeb146982d500adf9601c2eccc88f 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 @@ -84,13 +84,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" +"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 -"4" +"5" ./octez-client --wait none send sc rollup message '["2 8 + value"]' from bootstrap2 Node is bootstrapped. @@ -133,13 +133,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" +"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 -"7" +"8" ./octez-client --wait none send sc rollup message '["3 10 + value"]' from bootstrap2 Node is bootstrapped. @@ -183,13 +183,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" +"11" ./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" +"11" ./octez-client --wait none send sc rollup message '["4 12 + value"]' from bootstrap2 Node is bootstrapped. @@ -233,13 +233,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"13" +"14" ./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 -"13" +"14" ./octez-client --wait none send sc rollup message '["5 14 + value"]' from bootstrap2 Node is bootstrapped. @@ -283,13 +283,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"16" +"17" ./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 -"16" +"17" ./octez-client --wait none send sc rollup message '["6 16 + value"]' from bootstrap2 Node is bootstrapped. @@ -333,13 +333,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"19" +"20" ./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 -"19" +"20" ./octez-client --wait none send sc rollup message '["7 18 + value"]' from bootstrap2 Node is bootstrapped. @@ -384,13 +384,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"22" +"23" ./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 -"22" +"23" ./octez-client --wait none send sc rollup message '["8 20 + value"]' from bootstrap2 Node is bootstrapped. @@ -436,13 +436,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"25" +"26" ./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 -"25" +"26" ./octez-client --wait none send sc rollup message '["9 22 + value"]' from bootstrap2 Node is bootstrapped. @@ -488,13 +488,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"28" +"29" ./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 -"28" +"29" ./octez-client --wait none send sc rollup message '["10 24 + value"]' from bootstrap2 Node is bootstrapped. @@ -540,4 +540,4 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"31" +"32" 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 ee74787d490e3b994490132da073427d7de1be87..cbcf08a8c3fe8f2897018a6699a6e49873cc4566 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 @@ -84,13 +84,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" +"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 -"4" +"5" ./octez-client --wait none send sc rollup message '["2 8 + value"]' from bootstrap2 Node is bootstrapped. @@ -133,13 +133,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" +"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 -"7" +"8" ./octez-client --wait none send sc rollup message '["3 10 + value"]' from bootstrap2 Node is bootstrapped. @@ -183,13 +183,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" +"11" ./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" +"11" ./octez-client --wait none send sc rollup message '["4 12 + value"]' from bootstrap2 Node is bootstrapped. @@ -233,13 +233,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"13" +"14" ./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 -"13" +"14" ./octez-client --wait none send sc rollup message '["5 14 + value"]' from bootstrap2 Node is bootstrapped. @@ -283,13 +283,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"16" +"17" ./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 -"16" +"17" ./octez-client --wait none send sc rollup message '["6 16 + value"]' from bootstrap2 Node is bootstrapped. @@ -333,13 +333,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"19" +"20" ./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 -"19" +"20" ./octez-client --wait none send sc rollup message '["7 18 + value"]' from bootstrap2 Node is bootstrapped. @@ -384,13 +384,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"22" +"23" ./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 -"22" +"23" ./octez-client --wait none send sc rollup message '["8 20 + value"]' from bootstrap2 Node is bootstrapped. @@ -436,13 +436,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"25" +"26" ./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 -"25" +"26" ./octez-client --wait none send sc rollup message '["9 22 + value"]' from bootstrap2 Node is bootstrapped. @@ -488,13 +488,13 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"28" +"29" ./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 -"28" +"29" ./octez-client --wait none send sc rollup message '["10 24 + value"]' from bootstrap2 Node is bootstrapped. @@ -540,4 +540,4 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]" ./octez-sc-rollup-client-alpha rpc get /global/block/head/total_ticks -"31" +"32" diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 01b9b5a3f0fa64920e9219ad2a520022d8a206c1..d5f7eed5f76221da19d38e170234980a13b5fc4a 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -1612,7 +1612,7 @@ let commitments_reorgs ~kind protocol sc_rollup_node sc_rollup node client = let additional_ticks = match kind with | "arith" -> 1 (* boot sector *) + 1 (* metadata *) - | "wasm_2_0_0" -> 1 (* boot_sector *) + | "wasm_2_0_0" -> 1 (* boot_sector *) + 1 (* moving through start state *) | _ -> assert false in Check.(