From 58ab099bdf32485a725b5654aff2b56297754395 Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Thu, 8 Jun 2023 17:12:00 +0200 Subject: [PATCH] Proto: Make Alpha use the latest PVM revision --- docs/protocols/alpha.rst | 4 +++ .../environment_V10.ml | 2 +- src/lib_protocol_environment/sigs/v10.ml | 2 +- .../sigs/v10/wasm_2_0_0.mli | 2 +- .../test/test_protocol_migration.ml | 35 ++++++++++++------- src/lib_scoru_wasm/wasm_vm.ml | 3 +- .../lib_protocol/sc_rollup_wasm.ml | 4 +-- ..._0 - RPC API should work and be stable.out | 2 +- tezt/tests/sc_rollup.ml | 3 +- 9 files changed, 37 insertions(+), 20 deletions(-) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 208bdc385e5c..93ee416f1b79 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -37,6 +37,10 @@ Smart Rollups Now:: ./octez-client cement commitment from for smart rollup +- Enable the latest version of the WASM PVM (``2.0.0-r2``). Existing smart + rollups will see their PVM automatically upgrade, and newly originated smart + rollups will use this version directly (MR :gl:`!9051`) + Zero Knowledge Rollups (ongoing) -------------------------------- diff --git a/src/lib_protocol_environment/environment_V10.ml b/src/lib_protocol_environment/environment_V10.ml index 69e248bacb95..b8572734c7f7 100644 --- a/src/lib_protocol_environment/environment_V10.ml +++ b/src/lib_protocol_environment/environment_V10.ml @@ -1157,7 +1157,7 @@ struct type version = Tezos_scoru_wasm.Wasm_pvm_state.version - let v1 = Tezos_scoru_wasm.Wasm_pvm_state.V1 + let v2 = Tezos_scoru_wasm.Wasm_pvm_state.V2 module Make (Tree : Context.TREE with type key = string list and type value = bytes) = diff --git a/src/lib_protocol_environment/sigs/v10.ml b/src/lib_protocol_environment/sigs/v10.ml index 3944900bfe6c..63c301469623 100644 --- a/src/lib_protocol_environment/sigs/v10.ml +++ b/src/lib_protocol_environment/sigs/v10.ml @@ -12077,7 +12077,7 @@ end type version -val v1 : version +val v2 : version type input = {inbox_level : Bounded.Non_negative_int32.t; message_counter : Z.t} diff --git a/src/lib_protocol_environment/sigs/v10/wasm_2_0_0.mli b/src/lib_protocol_environment/sigs/v10/wasm_2_0_0.mli index 0ecc4afac5d5..9d1c18977328 100644 --- a/src/lib_protocol_environment/sigs/v10/wasm_2_0_0.mli +++ b/src/lib_protocol_environment/sigs/v10/wasm_2_0_0.mli @@ -25,7 +25,7 @@ type version -val v1 : version +val v2 : version type input = {inbox_level : Bounded.Non_negative_int32.t; message_counter : Z.t} diff --git a/src/lib_scoru_wasm/test/test_protocol_migration.ml b/src/lib_scoru_wasm/test/test_protocol_migration.ml index 7bba5f0872c3..37f255c45f7e 100644 --- a/src/lib_scoru_wasm/test/test_protocol_migration.ml +++ b/src/lib_scoru_wasm/test/test_protocol_migration.ml @@ -42,29 +42,40 @@ let noop_module = nop)) |} -let test_protocol_migration_message () = +let test_protocol_migration_message ~from_version ~to_version + ~after_protocol_activation:protocol () = let open Lwt_syntax in - let* tree = initial_tree ~version:V0 noop_module in + let* tree = initial_tree ~version:from_version noop_module in let* tree = eval_until_input_requested tree in let* version = Wasm.get_wasm_version tree in - assert (version = V0) ; + assert (version = from_version) ; let* tree = set_empty_inbox_step 0l tree in let* tree = eval_until_input_requested tree in let* version = Wasm.get_wasm_version tree in - assert (version = V0) ; - let* tree = set_empty_inbox_step ~migrate_to:Proto_alpha 0l tree in + assert (version = from_version) ; + let* tree = set_empty_inbox_step ~migrate_to:protocol 0l tree in let* tree = eval_until_input_requested tree in let* version = Wasm.get_wasm_version tree in - assert (version = V1) ; + assert (version = to_version) ; Lwt_result_syntax.return_unit +let proto_name : Tezos_scoru_wasm.Pvm_input_kind.protocol -> string = function + | Nairobi -> "Nairobi" + | Proto_alpha -> "Proto_alpha" + let tests = - [ - tztest - "protocol migration message handling by the WASM PVM" - `Quick - test_protocol_migration_message; - ] + List.map + (fun (from_version, to_version, protocol) -> + tztest + (sf + "protocol migration message handling by the WASM PVM (%s)" + (proto_name protocol)) + `Quick + (test_protocol_migration_message + ~from_version + ~to_version + ~after_protocol_activation:protocol)) + [(V0, V1, Nairobi); (V1, V2, Proto_alpha)] let () = Alcotest_lwt.run diff --git a/src/lib_scoru_wasm/wasm_vm.ml b/src/lib_scoru_wasm/wasm_vm.ml index 254e6fc3d739..3f8106475555 100644 --- a/src/lib_scoru_wasm/wasm_vm.ml +++ b/src/lib_scoru_wasm/wasm_vm.ml @@ -28,7 +28,8 @@ open Wasm_pvm_state.Internal_state let version_for_protocol : Pvm_input_kind.protocol -> Wasm_pvm_state.version = function - | Nairobi | Proto_alpha -> V1 + | Nairobi -> V1 + | Proto_alpha -> V2 let link_finished (ast : Wasm.Ast.module_) offset = offset >= Wasm.Ast.Vector.num_elements ast.it.imports diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index ce63d02be725..3be72d6007b3 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -81,7 +81,7 @@ let () = (fun () -> WASM_invalid_dissection_distribution) module V2_0_0 = struct - let current_version = Wasm_2_0_0.v1 + let current_version = Wasm_2_0_0.v2 let ticks_per_snapshot = Z.of_int64 11_000_000_000L @@ -121,7 +121,7 @@ module V2_0_0 = struct *) let reference_initial_state_hash = Sc_rollup_repr.State_hash.of_b58check_exn - "srs129wuRkckJpSyDhsqSvzE3qSVnvJZ7nD93r3b6oiBtPxa9LMBHu" + "srs11qkRe5cbDBixB2fuumn4tfkvQcxUSuFXa94Lv5c6kdzzfpM9UF" open Sc_rollup_repr module PS = Sc_rollup_PVM_sig diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - RPC API should work and be stable.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - RPC API should work and be stable.out index 9f577510d67b..374d4e62cfa3 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - RPC API should work and be stable.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - RPC API should work and be stable.out @@ -251,7 +251,7 @@ Smart rollup [SMART_ROLLUP_HASH] memorized as "rollup" null ./octez-smart-rollup-client-alpha rpc get '/global/block/head/durable/wasm_2_0_0/value?key=/readonly/wasm_version' -"322e302e302d7231" +"322e302e302d7232" ./octez-smart-rollup-client-alpha rpc get '/global/block/head/durable/wasm_2_0_0/length?key=/readonly/wasm_version' "8" diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 4f57b3ace8ed..62b71bf36678 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -41,7 +41,8 @@ open Sc_rollup_helpers *) let default_wasm_pvm_revision = function - | Protocol.Nairobi | Protocol.Alpha -> "2.0.0-r1" + | Protocol.Alpha -> "2.0.0-r2" + | Protocol.Nairobi -> "2.0.0-r1" | Protocol.Mumbai -> "2.0.0" let assert_some_client_command cmd ~__LOC__ ?hooks client = -- GitLab