From 9f97d4cc6f102b28f5991eceff7bde23ee5f46b2 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Tue, 18 Oct 2022 16:07:30 +0100 Subject: [PATCH 1/4] Proto: Hash for reveal preimage input --- src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml index f7de6e932631..a1148d8db4c1 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml @@ -165,6 +165,20 @@ module Input_hash = let size = Some 20 end) +module Reveal_hash = + Blake2B.Make + (Base58) + (struct + let name = "Sc_rollup_reveal_data_hash" + + let title = "A smart contract rollup reveal hash" + + let b58check_prefix = + "\003\250\187\088\008" (* "scrh1(55)" decoded from Base58. *) + + let size = Some 32 + end) + type reveal = Reveal_raw_data of Input_hash.t | Reveal_metadata let reveal_encoding = -- GitLab From fb310e4bb82c36128d822f7cf02d11a4e4df7354 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Tue, 18 Oct 2022 16:33:47 +0100 Subject: [PATCH 2/4] Proto/Rollup node: Use Reveal_hash for reveal inputs --- .../bin_sc_rollup_node/main_sc_rollup_node_alpha.ml | 2 +- src/proto_alpha/bin_sc_rollup_node/reveals.ml | 6 +++--- src/proto_alpha/bin_sc_rollup_node/reveals.mli | 4 ++-- .../bin_sc_rollup_node/sc_rollup_node_errors.ml | 6 +++--- src/proto_alpha/bin_sc_rollup_node/wasm_2_0_0_pvm.ml | 2 +- src/proto_alpha/lib_protocol/alpha_context.mli | 6 ++++-- src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml | 8 ++++---- src/proto_alpha/lib_protocol/sc_rollup_arith.ml | 8 ++++---- src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml | 6 +++--- src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli | 2 +- src/proto_alpha/lib_protocol/sc_rollup_wasm.ml | 4 ++-- 11 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml b/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml index acd01d233166..da350f1edd4b 100644 --- a/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml +++ b/src/proto_alpha/bin_sc_rollup_node/main_sc_rollup_node_alpha.ml @@ -305,7 +305,7 @@ let import_command = (prefixes ["import"] @@ stop) (fun (data_dir, filename, pvm_name) cctxt -> let hash = Reveals.import ~data_dir ~filename ~pvm_name in - cctxt#message "%a" Protocol.Alpha_context.Sc_rollup.Input_hash.pp hash + cctxt#message "%a" Protocol.Alpha_context.Sc_rollup.Reveal_hash.pp hash >>= return) let sc_rollup_commands () = diff --git a/src/proto_alpha/bin_sc_rollup_node/reveals.ml b/src/proto_alpha/bin_sc_rollup_node/reveals.ml index 72ace672c762..16c487c76b5f 100644 --- a/src/proto_alpha/bin_sc_rollup_node/reveals.ml +++ b/src/proto_alpha/bin_sc_rollup_node/reveals.ml @@ -36,7 +36,7 @@ let save_string filename s = let path data_dir pvm_name hash = let hash = - Format.asprintf "%a" Protocol.Alpha_context.Sc_rollup.Input_hash.pp hash + Format.asprintf "%a" Protocol.Alpha_context.Sc_rollup.Reveal_hash.pp hash in Filename.(concat (concat data_dir pvm_name) hash) @@ -119,9 +119,9 @@ module Arith = struct let cell = match successor_hash with | None -> chunk - | Some h -> Format.asprintf "%s hash:%a" chunk Input_hash.pp h + | Some h -> Format.asprintf "%s hash:%a" chunk Reveal_hash.pp h in - let hash = Input_hash.hash_string [cell] in + let hash = Reveal_hash.hash_string [cell] in aux (Some hash) ((cell, hash) :: linked_chunks) rev_chunks in aux None [] rev_chunks diff --git a/src/proto_alpha/bin_sc_rollup_node/reveals.mli b/src/proto_alpha/bin_sc_rollup_node/reveals.mli index 5cfe123ebc29..d2ad0657cd61 100644 --- a/src/proto_alpha/bin_sc_rollup_node/reveals.mli +++ b/src/proto_alpha/bin_sc_rollup_node/reveals.mli @@ -56,7 +56,7 @@ open Protocol.Alpha_context val get : data_dir:string -> pvm_name:string -> - hash:Sc_rollup.Input_hash.t -> + hash:Sc_rollup.Reveal_hash.t -> string option (** [import ~data_dir ~pvm_name ~filename] turns the content of ~filename @@ -66,4 +66,4 @@ val import : data_dir:string -> pvm_name:string -> filename:string -> - Sc_rollup.Input_hash.t + Sc_rollup.Reveal_hash.t diff --git a/src/proto_alpha/bin_sc_rollup_node/sc_rollup_node_errors.ml b/src/proto_alpha/bin_sc_rollup_node/sc_rollup_node_errors.ml index aaeedf9d2d5e..47b23d17967a 100644 --- a/src/proto_alpha/bin_sc_rollup_node/sc_rollup_node_errors.ml +++ b/src/proto_alpha/bin_sc_rollup_node/sc_rollup_node_errors.ml @@ -40,7 +40,7 @@ type error += } | Missing_PVM_state of Block_hash.t * Int32.t | Cannot_checkout_context of Block_hash.t * string option - | Cannot_retrieve_reveal of Sc_rollup.Input_hash.t + | Cannot_retrieve_reveal of Sc_rollup.Reveal_hash.t type error += | Lost_game of @@ -245,8 +245,8 @@ let () = Format.fprintf ppf "The node cannot retrieve a reveal for hash %a" - Sc_rollup.Input_hash.pp + Sc_rollup.Reveal_hash.pp hash) - Data_encoding.(obj1 (req "hash" Sc_rollup.Input_hash.encoding)) + Data_encoding.(obj1 (req "hash" Sc_rollup.Reveal_hash.encoding)) (function Cannot_retrieve_reveal hash -> Some hash | _ -> None) (fun hash -> Cannot_retrieve_reveal hash) 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 db78f4667fdf..a0cabf7e2445 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 @@ -72,7 +72,7 @@ module Impl : Pvm.S = struct | Waiting_for_reveal (Sc_rollup.Reveal_raw_data hash) -> Format.asprintf "Waiting for preimage reveal %a" - Sc_rollup.Input_hash.pp + Sc_rollup.Reveal_hash.pp hash | Waiting_for_reveal Sc_rollup.Reveal_metadata -> "Waiting for metadata" | Computing -> "Computing" diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 3edb2b9998d9..18a61fc944b2 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3040,7 +3040,9 @@ module Sc_rollup : sig module Input_hash : S.HASH - type reveal = Reveal_raw_data of Input_hash.t | Reveal_metadata + module Reveal_hash : S.HASH + + type reveal = Reveal_raw_data of Reveal_hash.t | Reveal_metadata type input_request = | No_input_required @@ -3560,7 +3562,7 @@ module Sc_rollup : sig val proof_encoding : proof Data_encoding.t - val reveal : Input_hash.t -> string option + val reveal : Reveal_hash.t -> string option module Inbox_with_history : sig include Inbox.Merkelized_operations with type inbox_context = context diff --git a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml index a1148d8db4c1..4901c41c290a 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml @@ -179,7 +179,7 @@ module Reveal_hash = let size = Some 32 end) -type reveal = Reveal_raw_data of Input_hash.t | Reveal_metadata +type reveal = Reveal_raw_data of Reveal_hash.t | Reveal_metadata let reveal_encoding = let open Data_encoding in @@ -189,7 +189,7 @@ let reveal_encoding = (Tag 0) (obj2 (req "reveal_kind" (constant "reveal_raw_data")) - (req "input_hash" Input_hash.encoding)) + (req "input_hash" Reveal_hash.encoding)) (function Reveal_raw_data s -> Some ((), s) | _ -> None) (fun ((), s) -> Reveal_raw_data s) and case_metadata = @@ -260,7 +260,7 @@ let input_request_encoding = ] let pp_reveal fmt = function - | Reveal_raw_data hash -> Input_hash.pp fmt hash + | Reveal_raw_data hash -> Reveal_hash.pp fmt hash | Reveal_metadata -> Format.pp_print_string fmt "Reveal metadata" (** [pp_input_request fmt i] pretty prints the given input [i] to the formatter @@ -282,7 +282,7 @@ let pp_input_request fmt request = let reveal_equal p1 p2 = match (p1, p2) with - | Reveal_raw_data h1, Reveal_raw_data h2 -> Input_hash.equal h1 h2 + | Reveal_raw_data h1, Reveal_raw_data h2 -> Reveal_hash.equal h1 h2 | Reveal_raw_data _, _ -> false | Reveal_metadata, Reveal_metadata -> true | Reveal_metadata, _ -> false diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index 2449001859ca..e7a540cc8304 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -602,18 +602,18 @@ module Make (Context : P) : end) module Required_reveal = Make_var (struct - type t = PS.Input_hash.t option + type t = PS.Reveal_hash.t option let initial = None - let encoding = Data_encoding.option PS.Input_hash.encoding + let encoding = Data_encoding.option PS.Reveal_hash.encoding let name = "required_pre_image_hash" let pp fmt v = match v with | None -> Format.fprintf fmt "" - | Some h -> PS.Input_hash.pp fmt h + | Some h -> PS.Reveal_hash.pp fmt h end) module Metadata = Make_var (struct @@ -1175,7 +1175,7 @@ module Make (Context : P) : if Compare.Int.(len > 5) && Compare.String.(String.sub x 0 5 = "hash:") then let hash = String.sub x 5 (len - 5) in - match PS.Input_hash.of_b58check_opt hash with + match PS.Reveal_hash.of_b58check_opt hash with | None -> stop_evaluating false | Some hash -> let* () = Required_reveal.set (Some hash) in diff --git a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml index 525a7a498b50..cea27435f58c 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml @@ -196,9 +196,9 @@ let valid ~metadata snapshot commit_level ~pvm_name proof = input request." | ( Some (Reveal_proof (Raw_data_proof data)), Needs_reveal (Reveal_raw_data expected_hash) ) -> - let data_hash = Sc_rollup_PVM_sig.Input_hash.hash_string [data] in + let data_hash = Sc_rollup_PVM_sig.Reveal_hash.hash_string [data] in check - (Sc_rollup_PVM_sig.Input_hash.equal data_hash expected_hash) + (Sc_rollup_PVM_sig.Reveal_hash.equal data_hash expected_hash) "Invalid reveal" | Some (Reveal_proof Metadata_proof), Needs_reveal Reveal_metadata -> return_unit @@ -215,7 +215,7 @@ module type PVM_with_context_and_state = sig val proof_encoding : proof Data_encoding.t - val reveal : Sc_rollup_PVM_sig.Input_hash.t -> string option + val reveal : Sc_rollup_PVM_sig.Reveal_hash.t -> string option module Inbox_with_history : sig include diff --git a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli index 5cb09c8f578c..e5704f6d51fc 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.mli @@ -133,7 +133,7 @@ module type PVM_with_context_and_state = sig val proof_encoding : proof Data_encoding.t - val reveal : Sc_rollup_PVM_sig.Input_hash.t -> string option + val reveal : Sc_rollup_PVM_sig.Reveal_hash.t -> string option module Inbox_with_history : sig include diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index 65d990edf40b..3042eddf94e4 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -237,14 +237,14 @@ module V2_0_0 = struct | Input_required -> Waiting_for_input_message | Reveal_required (Wasm_2_0_0.Reveal_raw_data hash) -> ( match - Input_hash.of_bytes_opt + Reveal_hash.of_bytes_opt (Bytes.of_string (Wasm_2_0_0.input_hash_to_string hash)) with | Some hash -> Waiting_for_reveal (Reveal_raw_data hash) | None -> (* In case of an invalid hash, the rollup is blocked. Any commitment will be invalid. *) - Waiting_for_reveal (Reveal_raw_data Input_hash.zero)) + Waiting_for_reveal (Reveal_raw_data Reveal_hash.zero)) | Reveal_required Wasm_2_0_0.Reveal_metadata -> Waiting_for_reveal Reveal_metadata -- GitLab From 0d9cdae3b51b03515b36f7bb5242979f8e0491b3 Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Tue, 18 Oct 2022 17:13:35 +0100 Subject: [PATCH 3/4] Environment: rename input_hash to reveal_hash --- src/lib_protocol_environment/environment_V8.ml | 12 ++++++------ src/lib_protocol_environment/environment_V8.mli | 4 ++-- src/lib_protocol_environment/sigs/v8.ml | 6 +++--- src/lib_protocol_environment/sigs/v8/wasm_2_0_0.mli | 6 +++--- src/lib_scoru_wasm/host_funcs.ml | 2 +- src/lib_scoru_wasm/test/helpers/ast_generators.ml | 2 +- src/lib_scoru_wasm/test/helpers/ast_printer.ml | 2 +- src/lib_scoru_wasm/test/test_reveal.ml | 2 +- src/lib_scoru_wasm/wasm_encoding.ml | 8 ++++---- src/lib_scoru_wasm/wasm_pvm_state.ml | 8 ++++---- src/lib_webassembly/exec/reveal.ml | 12 ++++++------ src/lib_webassembly/exec/reveal.mli | 12 ++++++------ src/proto_alpha/lib_protocol/sc_rollup_wasm.ml | 2 +- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/lib_protocol_environment/environment_V8.ml b/src/lib_protocol_environment/environment_V8.ml index 5057161c3ff4..f93c160394e9 100644 --- a/src/lib_protocol_environment/environment_V8.ml +++ b/src/lib_protocol_environment/environment_V8.ml @@ -107,8 +107,8 @@ module type T = sig Tezos_base.Bounded.Non_negative_int32.t and type Wasm_2_0_0.input = Tezos_scoru_wasm.Wasm_pvm_state.input_info and type Wasm_2_0_0.output = Tezos_scoru_wasm.Wasm_pvm_state.output_info - and type Wasm_2_0_0.input_hash = - Tezos_scoru_wasm.Wasm_pvm_state.input_hash + and type Wasm_2_0_0.reveal_hash = + Tezos_scoru_wasm.Wasm_pvm_state.reveal_hash and type Wasm_2_0_0.reveal = Tezos_scoru_wasm.Wasm_pvm_state.reveal and type Wasm_2_0_0.input_request = Tezos_scoru_wasm.Wasm_pvm_state.input_request @@ -1055,13 +1055,13 @@ struct message_index : Z.t; } - type input_hash = Tezos_scoru_wasm.Wasm_pvm_state.input_hash + type reveal_hash = Tezos_scoru_wasm.Wasm_pvm_state.reveal_hash - let input_hash_to_string = - Tezos_scoru_wasm.Wasm_pvm_state.input_hash_to_string + let reveal_hash_to_string = + Tezos_scoru_wasm.Wasm_pvm_state.reveal_hash_to_string type reveal = Tezos_scoru_wasm.Wasm_pvm_state.reveal = - | Reveal_raw_data of input_hash + | Reveal_raw_data of reveal_hash | Reveal_metadata type input_request = Tezos_scoru_wasm.Wasm_pvm_state.input_request = diff --git a/src/lib_protocol_environment/environment_V8.mli b/src/lib_protocol_environment/environment_V8.mli index d6eaafc9b6b6..d63ee476d6dc 100644 --- a/src/lib_protocol_environment/environment_V8.mli +++ b/src/lib_protocol_environment/environment_V8.mli @@ -107,8 +107,8 @@ module type T = sig Tezos_base.Bounded.Non_negative_int32.t and type Wasm_2_0_0.input = Tezos_scoru_wasm.Wasm_pvm_state.input_info and type Wasm_2_0_0.output = Tezos_scoru_wasm.Wasm_pvm_state.output_info - and type Wasm_2_0_0.input_hash = - Tezos_scoru_wasm.Wasm_pvm_state.input_hash + and type Wasm_2_0_0.reveal_hash = + Tezos_scoru_wasm.Wasm_pvm_state.reveal_hash and type Wasm_2_0_0.reveal = Tezos_scoru_wasm.Wasm_pvm_state.reveal and type Wasm_2_0_0.input_request = Tezos_scoru_wasm.Wasm_pvm_state.input_request diff --git a/src/lib_protocol_environment/sigs/v8.ml b/src/lib_protocol_environment/sigs/v8.ml index 437849e1af1c..40ed1bd693f8 100644 --- a/src/lib_protocol_environment/sigs/v8.ml +++ b/src/lib_protocol_environment/sigs/v8.ml @@ -11765,11 +11765,11 @@ type input = {inbox_level : Bounded.Non_negative_int32.t; message_counter : Z.t} type output = {outbox_level : Bounded.Non_negative_int32.t; message_index : Z.t} -type input_hash +type reveal_hash -val input_hash_to_string : input_hash -> string +val reveal_hash_to_string : reveal_hash -> string -type reveal = Reveal_raw_data of input_hash | Reveal_metadata +type reveal = Reveal_raw_data of reveal_hash | Reveal_metadata type input_request = | No_input_required diff --git a/src/lib_protocol_environment/sigs/v8/wasm_2_0_0.mli b/src/lib_protocol_environment/sigs/v8/wasm_2_0_0.mli index 91d480db0a64..1a7dfd7ef23e 100644 --- a/src/lib_protocol_environment/sigs/v8/wasm_2_0_0.mli +++ b/src/lib_protocol_environment/sigs/v8/wasm_2_0_0.mli @@ -27,11 +27,11 @@ type input = {inbox_level : Bounded.Non_negative_int32.t; message_counter : Z.t} type output = {outbox_level : Bounded.Non_negative_int32.t; message_index : Z.t} -type input_hash +type reveal_hash -val input_hash_to_string : input_hash -> string +val reveal_hash_to_string : reveal_hash -> string -type reveal = Reveal_raw_data of input_hash | Reveal_metadata +type reveal = Reveal_raw_data of reveal_hash | Reveal_metadata type input_request = | No_input_required diff --git a/src/lib_scoru_wasm/host_funcs.ml b/src/lib_scoru_wasm/host_funcs.ml index 284af2b3f938..fd459ba2ffaa 100644 --- a/src/lib_scoru_wasm/host_funcs.ml +++ b/src/lib_scoru_wasm/host_funcs.ml @@ -727,7 +727,7 @@ let reveal_preimage_parse_args memories args = | Values.[Num (I32 hash_addr); Num (I32 base); Num (I32 max_bytes)] -> let* memory = retrieve_memory memories in let+ hash = Memory.load_bytes memory hash_addr 32 in - ( Reveal.(Reveal_raw_data (input_hash_from_string_exn hash)), + ( Reveal.(Reveal_raw_data (reveal_hash_from_string_exn hash)), Host_funcs.{base; max_bytes} ) | _ -> raise Bad_input diff --git a/src/lib_scoru_wasm/test/helpers/ast_generators.ml b/src/lib_scoru_wasm/test/helpers/ast_generators.ml index 50d44962f332..242849bc9eb7 100644 --- a/src/lib_scoru_wasm/test/helpers/ast_generators.ml +++ b/src/lib_scoru_wasm/test/helpers/ast_generators.ml @@ -763,7 +763,7 @@ let inv_concat_gen ~module_reg = Eval.Inv_concat {arity; vs; instructions; inst; func; concat_kont} let inv_reveal_tick ~module_reg = - let* hash = Reveal.input_hash_from_string_exn <$> string_size (pure 32) in + let* hash = Reveal.reveal_hash_from_string_exn <$> string_size (pure 32) in let* base_destination = Int32.of_int <$> small_nat in let* max_bytes = Int32.of_int <$> small_nat in let* vs = small_vector_gen value_gen in diff --git a/src/lib_scoru_wasm/test/helpers/ast_printer.ml b/src/lib_scoru_wasm/test/helpers/ast_printer.ml index 235f23b3a987..5879fa0601b9 100644 --- a/src/lib_scoru_wasm/test/helpers/ast_printer.ml +++ b/src/lib_scoru_wasm/test/helpers/ast_printer.ml @@ -429,7 +429,7 @@ let pp_reveal out = function Format.fprintf out "Reveal_raw_data (%s)" - (Reveal.input_hash_to_string hash) + (Reveal.reveal_hash_to_string hash) | Reveal_metadata -> Format.fprintf out "Reveal_metadata" let pp_invoke_step_kont out = function diff --git a/src/lib_scoru_wasm/test/test_reveal.ml b/src/lib_scoru_wasm/test/test_reveal.ml index 9864dc5e79b9..53387652ba5e 100644 --- a/src/lib_scoru_wasm/test/test_reveal.ml +++ b/src/lib_scoru_wasm/test/test_reveal.ml @@ -108,7 +108,7 @@ let test_reveal_preimage_gen preimage max_bytes = preimage. Since the memory is left blank, we are looking for the zero hash *) let zero_hash = - Reveal.input_hash_from_string_exn (String.make 32 '\000') + Reveal.reveal_hash_from_string_exn (String.make 32 '\000') in assert (hash = zero_hash) ; return_unit diff --git a/src/lib_scoru_wasm/wasm_encoding.ml b/src/lib_scoru_wasm/wasm_encoding.ml index 1bcd78b0fb0a..c62f96806bbe 100644 --- a/src/lib_scoru_wasm/wasm_encoding.ml +++ b/src/lib_scoru_wasm/wasm_encoding.ml @@ -987,10 +987,10 @@ let packed_frame_stack_encoding = (scope ["frame"] frame_encoding) (scope ["label_kont"] packed_label_kont_encoding)) -let input_hash_encoding = +let reveal_hash_encoding = conv - Reveal.input_hash_from_string_exn - Reveal.input_hash_to_string + Reveal.reveal_hash_from_string_exn + Reveal.reveal_hash_to_string (value [] (Data_encoding.Fixed.string 32)) let reveal_encoding = @@ -999,7 +999,7 @@ let reveal_encoding = [ case "Reveal_raw_data" - input_hash_encoding + reveal_hash_encoding (function Reveal.Reveal_raw_data hash -> Some hash | _ -> None) (fun hash -> Reveal_raw_data hash); case diff --git a/src/lib_scoru_wasm/wasm_pvm_state.ml b/src/lib_scoru_wasm/wasm_pvm_state.ml index f20b9d8baa13..7208380d92d9 100644 --- a/src/lib_scoru_wasm/wasm_pvm_state.ml +++ b/src/lib_scoru_wasm/wasm_pvm_state.ml @@ -38,13 +38,13 @@ type output_info = { message_index : Z.t; (** The index of the message in the outbox. *) } -type input_hash = Tezos_webassembly_interpreter.Reveal.input_hash +type reveal_hash = Tezos_webassembly_interpreter.Reveal.reveal_hash -let input_hash_to_string = - Tezos_webassembly_interpreter.Reveal.input_hash_to_string +let reveal_hash_to_string = + Tezos_webassembly_interpreter.Reveal.reveal_hash_to_string type reveal = Tezos_webassembly_interpreter.Reveal.reveal = - | Reveal_raw_data of Tezos_webassembly_interpreter.Reveal.input_hash + | Reveal_raw_data of Tezos_webassembly_interpreter.Reveal.reveal_hash | Reveal_metadata (** Represents the state of input requests. *) diff --git a/src/lib_webassembly/exec/reveal.ml b/src/lib_webassembly/exec/reveal.ml index 995a96c58180..8eb7ba7d9433 100644 --- a/src/lib_webassembly/exec/reveal.ml +++ b/src/lib_webassembly/exec/reveal.ml @@ -1,10 +1,10 @@ -exception Invalid_input_hash +exception Invalid_reveal_hash -type input_hash = string +type reveal_hash = string -let input_hash_from_string_exn str = - if String.length str = 32 then str else raise Invalid_input_hash +let reveal_hash_from_string_exn str = + if String.length str = 32 then str else raise Invalid_reveal_hash -let input_hash_to_string hash = hash +let reveal_hash_to_string hash = hash -type reveal = Reveal_raw_data of input_hash | Reveal_metadata +type reveal = Reveal_raw_data of reveal_hash | Reveal_metadata diff --git a/src/lib_webassembly/exec/reveal.mli b/src/lib_webassembly/exec/reveal.mli index ffa1002a8f24..46da2dbea084 100644 --- a/src/lib_webassembly/exec/reveal.mli +++ b/src/lib_webassembly/exec/reveal.mli @@ -1,10 +1,10 @@ -exception Invalid_input_hash +exception Invalid_reveal_hash -type input_hash +type reveal_hash -(** @raise Invalid_input_hash *) -val input_hash_from_string_exn : string -> input_hash +(** @raise Invalid_reveal_hash *) +val reveal_hash_from_string_exn : string -> reveal_hash -val input_hash_to_string : input_hash -> string +val reveal_hash_to_string : reveal_hash -> string -type reveal = Reveal_raw_data of input_hash | Reveal_metadata +type reveal = Reveal_raw_data of reveal_hash | Reveal_metadata diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index 3042eddf94e4..8ae8f7b517aa 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -238,7 +238,7 @@ module V2_0_0 = struct | Reveal_required (Wasm_2_0_0.Reveal_raw_data hash) -> ( match Reveal_hash.of_bytes_opt - (Bytes.of_string (Wasm_2_0_0.input_hash_to_string hash)) + (Bytes.of_string (Wasm_2_0_0.reveal_hash_to_string hash)) with | Some hash -> Waiting_for_reveal (Reveal_raw_data hash) | None -> -- GitLab From 20431e25d59eb2f8137d60c71d24d1981da9e2de Mon Sep 17 00:00:00 2001 From: Andrea Cerone Date: Tue, 18 Oct 2022 16:55:17 +0100 Subject: [PATCH 4/4] Tezt: reset regressions --- ...ode - correct handling of commitments (arith).out | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (arith).out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (arith).out index c9fd53896a05..efc4548d6e49 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (arith).out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (arith).out @@ -37,9 +37,9 @@ This sequence of operations was run: { "level": 2, "commitment_hash": "[SC_ROLLUP_COMMITMENT_HASH]" } -./octez-client --wait none send sc rollup message 'text:["hash:scd1C1PeCnVMC9jDsDjzEW1Ez9GWS97TLJLxA\n"]' from bootstrap2 to '[SC_ROLLUP_HASH]' +./octez-client --wait none send sc rollup message 'text:["hash:scrh12kkMqK9bHNXruyMnrcFsfyBqdBwdsZqjrVm6fYahM4tWRXKANu\n"]' from bootstrap2 to '[SC_ROLLUP_HASH]' Node is bootstrapped. -Estimated gas: 1877.317 units (will add 100 for safety) +Estimated gas: 1877.623 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' @@ -50,17 +50,17 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000514 + Fee to the baker: ꜩ0.000532 Expected counter: 1 Gas limit: 1978 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000514 - payload fees(the block proposer) ....... +ꜩ0.000514 + [PUBLIC_KEY_HASH] ... -ꜩ0.000532 + payload fees(the block proposer) ....... +ꜩ0.000532 Smart contract rollup messages submission: Address: [SC_ROLLUP_HASH] This smart contract rollup messages submission was successfully applied - Consumed gas: 1877.445 + Consumed gas: 1877.751 Resulting inbox state: { rollup = [SC_ROLLUP_HASH] level = 3 current messages hash = [SC_ROLLUP_INBOX_HASH] -- GitLab