From 116ca44a8918d0fa4685abc4f60271e6d84f1275 Mon Sep 17 00:00:00 2001 From: Thomas Letan Date: Tue, 29 Nov 2022 20:11:04 +0100 Subject: [PATCH] Proto: Fix the WASM PVM requests an unknown preimage for invalid hashes Prior to this patch, the PVM defaults to ask for the preimage of the zeroed hash, which is unknown as far as we know. We change its behavior to request the preimage of a well known hash, so that rollup whose kernel asks for an invalid hash could continue to progress. --- src/proto_alpha/lib_protocol/alpha_context.mli | 4 ++++ src/proto_alpha/lib_protocol/sc_rollup_wasm.ml | 12 ++++++++---- src/proto_alpha/lib_protocol/sc_rollup_wasm.mli | 8 ++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 3509c29afeb6..2202f1272718 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3659,6 +3659,10 @@ module Sc_rollup : sig module Wasm_2_0_0PVM : sig val ticks_per_snapshot : Z.t + val well_known_reveal_preimage : string + + val well_known_reveal_hash : Sc_rollup_reveal_hash.t + module type P = sig module Tree : Context.TREE with type key = string list and type value = bytes diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index 30ed9608c2a0..f4876f2c3852 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -83,6 +83,13 @@ let () = module V2_0_0 = struct let ticks_per_snapshot = Z.of_int64 11_000_000_000L + let well_known_reveal_preimage = "" + + let well_known_reveal_hash = + Sc_rollup_reveal_hash.hash_string + ~scheme:Blake2B + [well_known_reveal_preimage] + (* This is the state hash of reference that both the prover of the node and the verifier of the protocol {!Protocol_implementation} @@ -303,10 +310,7 @@ module V2_0_0 = struct | None -> (* In case of an invalid hash, the rollup is blocked. Any commitment will be invalid. *) - Waiting_for_reveal - (Reveal_raw_data - (Sc_rollup_reveal_hash.zero - ~scheme:Sc_rollup_reveal_hash.Blake2B))) + Waiting_for_reveal (Reveal_raw_data well_known_reveal_hash)) | Reveal_required Wasm_2_0_0.Reveal_metadata -> Waiting_for_reveal Reveal_metadata diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli index 35f7ef51753e..6d6ce03abab1 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli @@ -124,4 +124,12 @@ module V2_0_0 : sig see #3590 for more pointers *) val ticks_per_snapshot : Z.t + + (** The hash requested by the WASM PVM if it cannot decode the input + provided by the WASM kernel, that is, if the bytes value cannot + be decoded with {!Sc_rollup_reveal_hash.encoding}. *) + val well_known_reveal_hash : Sc_rollup_reveal_hash.t + + (** The preimage of {!well_known_reveal_hash}. *) + val well_known_reveal_preimage : string end -- GitLab