diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index c0b74ce2ef6e88f5e7da76501733131c013a56da..634598caf311ff82001f41ea8d3f4bca21f10d6c 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -21,6 +21,8 @@ It requires protocol environment V12, compared to V11 for Oxford. Smart Rollups ------------- +- The unnecessary initial PVM state hash and its associated RPC are removed. (MR :gl:`!12345`) + Zero Knowledge Rollups (ongoing) -------------------------------- diff --git a/src/lib_smart_rollup_node/protocol_plugin_sig.ml b/src/lib_smart_rollup_node/protocol_plugin_sig.ml index 5591e63f9712c9339586e065553b6c10935ce397..771e211eea1561536c4f9d45f5bc9895a7c51fbb 100644 --- a/src/lib_smart_rollup_node/protocol_plugin_sig.ml +++ b/src/lib_smart_rollup_node/protocol_plugin_sig.ml @@ -223,10 +223,6 @@ end (** Protocol specific functions for processing L1 blocks. *) module type L1_PROCESSING = sig - (** Ensure that the initial state hash of the PVM as defined by the rollup - node matches the one of the PVM on the L1 node. *) - val check_pvm_initial_state_hash : _ Node_context.t -> unit tzresult Lwt.t - (** React to L1 operations included in a block of the chain. When [catching_up] is true, the process block is in the past and the failure condition of the process differs (e.g. if it detects a diff --git a/src/lib_smart_rollup_node/rollup_node_daemon.ml b/src/lib_smart_rollup_node/rollup_node_daemon.ml index 0c06abc83cb37c8bfc05433838a3f75ef1f88d0d..346722055b46ab622a3624b8fca36750c5e8bd00 100644 --- a/src/lib_smart_rollup_node/rollup_node_daemon.ml +++ b/src/lib_smart_rollup_node/rollup_node_daemon.ml @@ -726,7 +726,6 @@ let run ~data_dir ~irmin_cache_size ~index_buffer_size ?log_kernel_debug_file current_protocol configuration in - let* () = Plugin.L1_processing.check_pvm_initial_state_hash node_ctxt in let dir = Rpc_directory.directory node_ctxt in let* rpc_server = Rpc_server.start configuration dir in let state = {node_ctxt; rpc_server; configuration; plugin} in diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index b50dc53262d2c1029386d6e36c6aaa16caf05722..f86965d505022018b503ee52c9e6e7f32a376ea1 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -2579,13 +2579,6 @@ module Sc_rollup = struct ~output:Sc_rollup.Kind.encoding RPC_path.(path_sc_rollup / "kind") - let initial_pvm_state_hash = - RPC_service.get_service - ~description:"Initial PVM state hash of smart rollup" - ~query:RPC_query.empty - ~output:Sc_rollup.State_hash.encoding - RPC_path.(path_sc_rollup / "initial_pvm_state_hash") - let genesis_info = RPC_service.get_service ~description: @@ -2818,19 +2811,6 @@ module Sc_rollup = struct let+ _ctxt, kind = Alpha_context.Sc_rollup.kind ctxt address in Some kind - let register_initial_pvm_state_hash () = - let open Lwt_result_syntax in - Registration.opt_register1 ~chunked:true S.initial_pvm_state_hash - @@ fun ctxt address () () -> - let+ _ctxt, kind = Alpha_context.Sc_rollup.kind ctxt address in - match kind with - | Sc_rollup.Kind.Example_arith -> - Some Sc_rollup.ArithPVM.reference_initial_state_hash - | Sc_rollup.Kind.Wasm_2_0_0 -> - Some Sc_rollup.Wasm_2_0_0PVM.reference_initial_state_hash - | Sc_rollup.Kind.Riscv -> - Some Sc_rollup.Riscv_PVM.reference_initial_state_hash - (* TODO: https://gitlab.com/tezos/tezos/-/issues/2688 *) let register_genesis_info () = let open Lwt_result_syntax in @@ -3022,7 +3002,6 @@ module Sc_rollup = struct register_timeout () ; register_timeout_reached () ; register_can_be_cemented () ; - register_initial_pvm_state_hash () ; register_ticket_balance () let list ctxt block = RPC_context.make_call0 S.root ctxt block () () @@ -3108,15 +3087,6 @@ module Sc_rollup = struct () () - let initial_pvm_state_hash ctxt block sc_rollup_address = - RPC_context.make_call1 - S.initial_pvm_state_hash - ctxt - block - sc_rollup_address - () - () - let can_be_cemented ctxt block sc_rollup_address commitment_hash = RPC_context.make_call2 S.can_be_cemented diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 577910cfdf18bbf3c262e4fbea89ece0452a3521..1c89fde24c93864756678ff4e77c547d0b1c4c56 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3595,8 +3595,6 @@ module Sc_rollup : sig val get_outbox : Raw_level.t -> state -> output list Lwt.t end - val reference_initial_state_hash : State_hash.t - module Protocol_implementation : PVM.S with type context = Context.t @@ -3651,13 +3649,9 @@ module Sc_rollup : sig with type context = Context.t and type state = Context.tree and type proof = Context.Proof.tree Context.Proof.t - - val reference_initial_state_hash : State_hash.t end module Riscv_PVM : sig - val reference_initial_state_hash : State_hash.t - module Protocol_implementation : PVM.S with type context = unit diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index ecf0ca07716a141063852598773b9a7735b0f3da..6962e7fec37de0cec4318b5ce7ebe74bb7a4bda4 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -26,33 +26,6 @@ open Sc_rollup_repr module PS = Sc_rollup_PVM_sig -(* - This is the state hash of reference that both the prover of the node - and the verifier of the protocol {!Protocol_implementation} have to - agree on (if they do, it means they are using the same tree - structure). - - We have to hard-code this value because the Arith PVM uses Irmin as - its Merkle proof verification backend, and the economic protocol - cannot create an empty Irmin context. Such a context is required to - create an empty tree, itself required to create the initial state of - the Arith PVM. - - Utlimately, the value of this constant is decided by the prover of - reference (the only need is for it to be compatible with - {!Protocol_implementation}.) - - Its value is the result of the following snippet - - {| - let*! state = Prover.initial_state ~empty in - Prover.state_hash state - |} -*) -let reference_initial_state_hash = - State_hash.of_b58check_exn - "srs11Z9V76SGd97kGmDQXV8tEF67C48GMy77RuaHdF1kWLk6UTmMfj" - type error += | Arith_proof_production_failed | Arith_output_proof_production_failed diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.mli b/src/proto_alpha/lib_protocol/sc_rollup_arith.mli index 9bd8f8da76b281bc34ecf199e7c3e8c4f8fd4821..aba54e9723aca09e61ebf6bb8af944e931a8cde3 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.mli @@ -159,12 +159,6 @@ module Protocol_implementation : and type state = Context.tree and type proof = Context.Proof.tree Context.Proof.t -(** This is the state hash of reference that both the prover of the - node and the verifier of the protocol {!Protocol_implementation} - have to agree on (if they do, it means they are using the same - tree structure). *) -val reference_initial_state_hash : Sc_rollup_repr.State_hash.t - module Make (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : S with type context = Context.Tree.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_riscv.ml b/src/proto_alpha/lib_protocol/sc_rollup_riscv.ml index 104e8d841b3f02b52fe3446a07f4a3cd25159d85..14490b1b993df5dba66810f7ac042239b662159b 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_riscv.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_riscv.ml @@ -45,8 +45,6 @@ let state_hash state = [Data_encoding.Binary.to_bytes_exn minimal_state_encoding state] |> Context_hash.hash_bytes |> State_hash.context_hash_to_state_hash -let reference_initial_state_hash = state_hash (make_empty_state ()) - module type S = sig include PS.S diff --git a/src/proto_alpha/lib_protocol/sc_rollup_riscv.mli b/src/proto_alpha/lib_protocol/sc_rollup_riscv.mli index 5a09a9bd96fbcb02ea6613a049756e16d696a884..1116a7650e90e1a92fcb2ad26c71a531f405cae0 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_riscv.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_riscv.mli @@ -32,5 +32,3 @@ module Protocol_implementation : with type context = unit and type state = minimal_state and type proof = void - -val reference_initial_state_hash : Sc_rollup_repr.State_hash.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index ba8850e7c6f1fb7ecdc0c1b3f51d84786ca5aed2..596dcd71783bf100bd7534e9ad3fa49dadccb683 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -129,33 +129,6 @@ module V2_0_0 = struct requesting the [well_known_reveal_hash] preimage *) Reveal_raw_data well_known_reveal_hash - (* - This is the state hash of reference that both the prover of the - node and the verifier of the protocol {!Protocol_implementation} - have to agree on (if they do, it means they are using the same - tree structure). - - We have to hard-code this value because the Wasm PVM uses Irmin as - its Merkle proof verification backend, and the economic protocol - cannot create an empty Irmin context. Such a context is required to - create an empty tree, itself required to create the initial state of - the Wasm PVM. - - Utlimately, the value of this constant is decided by the prover of - reference (the only need is for it to be compatible with - {!Protocol_implementation}.) - - Its value is the result of the following snippet - - {| - let*! state = Prover.initial_state context in - Prover.state_hash state - |} - *) - let reference_initial_state_hash = - Sc_rollup_repr.State_hash.of_b58check_exn - "srs127FAyj2NkJYtN8RE8yPieBGpakvAH8MgwzRPUM4UnsCKB24rrA" - open Sc_rollup_repr module PS = Sc_rollup_PVM_sig diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli index e8d2e831415fae4a0c624d8910f73ae30b840951..ce70d78eb88dcc94438554ed23ba03dab5364b5b 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli @@ -82,12 +82,6 @@ module V2_0_0 : sig and type state = Context.tree and type proof = Context.Proof.tree Context.Proof.t - (** This is the state hash of reference that both the prover of the - node and the verifier of the protocol {!Protocol_implementation} - have to agree on (if they do, it means they are using the same - tree structure). *) - val reference_initial_state_hash : Sc_rollup_repr.State_hash.t - (** Number of ticks between snapshotable states, chosen low enough to maintain refutability. diff --git a/src/proto_alpha/lib_protocol/sc_rollups.ml b/src/proto_alpha/lib_protocol/sc_rollups.ml index 125b5648c7f893cbda735b8e51c331642505f917..037a1c54e7adc8e1fc96bd5092301814910cba24 100644 --- a/src/proto_alpha/lib_protocol/sc_rollups.ml +++ b/src/proto_alpha/lib_protocol/sc_rollups.ml @@ -90,11 +90,6 @@ module Kind = struct let riscv_pvm = PVM.Packed (module Sc_rollup_riscv.Protocol_implementation) - let reference_initial_state_hash_of = function - | Example_arith -> Sc_rollup_arith.reference_initial_state_hash - | Wasm_2_0_0 -> Sc_rollup_wasm.V2_0_0.reference_initial_state_hash - | Riscv -> Sc_rollup_riscv.reference_initial_state_hash - let pvm_of = function | Example_arith -> example_arith_pvm | Wasm_2_0_0 -> wasm_2_0_0_pvm @@ -112,9 +107,5 @@ let genesis_state_hash_of ~boot_sector kind = let (module Machine) = Kind.no_proof_machine_of kind in let empty = Sc_rollup_machine_no_proofs.empty_tree () in let* tree = Machine.initial_state ~empty in - let* initial_hash = Machine.state_hash tree in - assert ( - Sc_rollup_repr.State_hash.( - initial_hash = Kind.reference_initial_state_hash_of kind)) ; let* tree = Machine.install_boot_sector tree boot_sector in Machine.state_hash tree diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml index 8c4ba40872ed9f3b6160ad3b076f24bc902c83b2..d4fe147d6ff42749000e95c81bf567450dc7bf53 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml @@ -551,22 +551,6 @@ let test_invalid_outbox_level () = ] |> List.iter_es (test_output_messages_proofs ~valid:false ~inbox_level) -let test_initial_state_hash_arith_pvm () = - let open Alpha_context in - let open Lwt_result_syntax in - let empty = Sc_rollup_helpers.Arith_pvm.make_empty_state () in - let*! state = Sc_rollup_helpers.Arith_pvm.initial_state ~empty in - let*! hash = Sc_rollup_helpers.Arith_pvm.state_hash state in - let expected = Sc_rollup.ArithPVM.reference_initial_state_hash in - if Sc_rollup.State_hash.(hash = expected) then return_unit - else - failwith - "incorrect hash, expected %a, got %a" - Sc_rollup.State_hash.pp - expected - Sc_rollup.State_hash.pp - hash - let dummy_internal_transfer address = let open Lwt_result_wrap_syntax in let open Alpha_context.Sc_rollup in @@ -780,10 +764,6 @@ let tests = Tztest.tztest "Valid output messages" `Quick test_valid_output_messages; Tztest.tztest "Invalid output messages" `Quick test_invalid_output_messages; Tztest.tztest "Invalid outbox level" `Quick test_invalid_outbox_level; - Tztest.tztest - "Initial state hash for Arith" - `Quick - test_initial_state_hash_arith_pvm; Tztest.tztest "Filter internal message" `Quick test_filter_internal_message; Tztest.tztest "Reveal below threshold" 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 dc01789b87f241cd009d9776f7fd957763a61140..be0312e6bf1c876f885e188ff0e8a604c101e537 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 @@ -89,37 +89,6 @@ end module Full_Wasm = Sc_rollup_wasm.V2_0_0.Make (Environment.Wasm_2_0_0.Make) (Wasm_context) -let test_initial_state_hash_wasm_pvm () = - let open Alpha_context in - let open Lwt_result_syntax in - let empty = Sc_rollup_helpers.Wasm_pvm.make_empty_state () in - let*! state = Sc_rollup_helpers.Wasm_pvm.initial_state ~empty 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_initial_state_hash_wasm_machine () = - let open Lwt_result_syntax in - let open Sc_rollup_machine_no_proofs in - let*! state = Wasm.initial_state ~empty:(empty_tree ()) in - let*! hash = Wasm.state_hash state in - let expected = Sc_rollup_wasm.V2_0_0.reference_initial_state_hash in - if Sc_rollup_repr.State_hash.(hash = expected) then return_unit - else - failwith - "incorrect hash, expected %a, got %a" - Sc_rollup_repr.State_hash.pp - expected - Sc_rollup_repr.State_hash.pp - hash - let test_metadata_size () = let address = Sc_rollup_repr.Address.of_bytes_exn (Bytes.make 20 '\000') in let metadata = @@ -443,14 +412,6 @@ let test_reveal_host_function_can_request_dal_pages () = let tests = [ - Tztest.tztest - "initial state hash for Wasm" - `Quick - test_initial_state_hash_wasm_pvm; - Tztest.tztest - "initial state hash for Wasm machine" - `Quick - test_initial_state_hash_wasm_machine; Tztest.tztest "size of a rollup metadata" `Quick test_metadata_size; Tztest.tztest "l1 input kind" `Quick test_l1_input_kind; Tztest.tztest "output proofs" `Quick test_output; diff --git a/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml b/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml index a1106f5a0b6ef44b05714596bc4602dbd6054cab..005eea524114577d650661dfc48b8e68f819a2db 100644 --- a/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.ml @@ -29,32 +29,6 @@ open Protocol open Alpha_context open Apply_results -let check_pvm_initial_state_hash {Node_context.cctxt; config; kind; _} = - let open Lwt_result_syntax in - let module PVM = (val Pvm.of_kind kind) in - let* l1_reference_initial_state_hash = - RPC.Sc_rollup.initial_pvm_state_hash - (new Protocol_client_context.wrap_full cctxt) - (cctxt#chain, cctxt#block) - config.sc_rollup_address - in - let*! s = PVM.initial_state ~empty:(PVM.State.empty ()) in - let*! l2_initial_state_hash = PVM.state_hash s in - let l1_reference_initial_state_hash = - Sc_rollup_proto_types.State_hash.to_octez l1_reference_initial_state_hash - in - let l2_initial_state_hash = - Sc_rollup_proto_types.State_hash.to_octez l2_initial_state_hash - in - fail_unless - Octez_smart_rollup.State_hash.( - l1_reference_initial_state_hash = l2_initial_state_hash) - (Sc_rollup_node_errors.Wrong_initial_pvm_state - { - initial_state_hash = l2_initial_state_hash; - expected_state_hash = l1_reference_initial_state_hash; - }) - (** Returns [Some c] if [their_commitment] is refutable where [c] is our commitment for the same inbox level. *) let is_refutable_commitment node_ctxt diff --git a/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.mli b/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.mli index af7d9135f34996027b79c8c639b4bbdabe2c0184..0df410c38bc7f3ab0232b3c666376fe46b25f21b 100644 --- a/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.mli +++ b/src/proto_alpha/lib_sc_rollup_node/daemon_helpers.mli @@ -25,10 +25,6 @@ (* *) (*****************************************************************************) -(** Ensure that the initial state hash of the PVM as defined by the rollup node - matches the one of the PVM on the L1 node. *) -val check_pvm_initial_state_hash : _ Node_context.t -> unit tzresult Lwt.t - (** React to L1 operations included in a block of the chain. *) val process_l1_block_operations : catching_up:bool -> Node_context.rw -> Layer1.header -> unit tzresult Lwt.t