From 2285d8c44f44c13f6d5bac024594fb8dda07cd85 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Fri, 15 Jul 2022 11:04:32 +0200 Subject: [PATCH 1/4] Proto/Scoru: more conversions of (req X (option Y)) to (opt X Y) --- src/proto_alpha/lib_protocol/sc_rollup_arith.ml | 2 +- src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml | 2 +- src/proto_alpha/lib_protocol/sc_rollup_wasm.ml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index c9d93a38836b..e069a051e2f2 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -128,7 +128,7 @@ let proof_encoding : 'a Data_encoding.t -> 'a proof Data_encoding.t = (fun (tree_proof, given, requested) -> {tree_proof; given; requested}) (obj3 (req "tree_proof" encoding) - (req "given" (option PS.input_encoding)) + (opt "given" PS.input_encoding) (req "requested" PS.input_request_encoding)) module Make (Context : P) : 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 27852f366b43..067176c20e30 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml @@ -36,7 +36,7 @@ let encoding = (fun (pvm_step, inbox) -> {pvm_step; inbox}) (obj2 (req "pvm_step" Sc_rollups.wrapped_proof_encoding) - (req "inbox" (option Sc_rollup_inbox_repr.serialized_proof_encoding))) + (opt "inbox" Sc_rollup_inbox_repr.serialized_proof_encoding)) let pp ppf _ = Format.fprintf ppf "Refutation game proof" diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index 13861ab41e94..0f069fe94ad1 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -114,7 +114,7 @@ module V2_0_0 = struct (fun (tree_proof, given, requested) -> {tree_proof; given; requested}) (obj3 (req "tree_proof" e) - (req "given" (option PS.input_encoding)) + (opt "given" PS.input_encoding) (req "requested" PS.input_request_encoding)) module Make (Context : P) : -- GitLab From b1e16b29992485587219a80b332e2f5531765bcd Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Tue, 12 Jul 2022 18:02:47 +0200 Subject: [PATCH 2/4] Proto/Scoru: improve input_request_encoding in JSON --- src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.ml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.ml b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.ml index aa4e9018e7c6..61f7e01a9b9d 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sem.ml @@ -63,22 +63,26 @@ let input_request_encoding = case ~title:"No_input_required" (Tag 0) - (obj1 (req "no_input_required" unit)) + (obj1 (req "kind" (constant "no_input_required"))) (function No_input_required -> Some () | _ -> None) (fun () -> No_input_required); case ~title:"Initial" (Tag 1) - (obj1 (req "initial" unit)) + (obj1 (req "kind" (constant "initial"))) (function Initial -> Some () | _ -> None) (fun () -> Initial); case ~title:"First_after" (Tag 2) - (obj2 (req "level" Raw_level_repr.encoding) (req "counter" n)) + (obj3 + (req "kind" (constant "first_after")) + (req "level" Raw_level_repr.encoding) + (req "counter" n)) (function - | First_after (level, counter) -> Some (level, counter) | _ -> None) - (fun (level, counter) -> First_after (level, counter)); + | First_after (level, counter) -> Some ((), level, counter) + | _ -> None) + (fun ((), level, counter) -> First_after (level, counter)); ] let pp_input_request fmt request = -- GitLab From cdc1d67773ccf9a4d14dd0bcfe37b28df39edc59 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Wed, 13 Jul 2022 08:16:40 +0200 Subject: [PATCH 3/4] Tezt/Scoru: add helper function for originating rollups --- tezt/tests/sc_rollup.ml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 515e83dec053..6bb7a60dbc5a 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -146,6 +146,19 @@ let sc_rollup_node_rpc sc_node service = type test = {variant : string; tags : string list; description : string} +(** This helper injects an SC rollup origination via tezos-client. Then it +bakes to include the origination in a block. It returns the address of the +originated rollup *) +let originate_sc_rollup ?(hooks = hooks) ?(burn_cap = Tez.(of_int 9999999)) + ?(src = "bootstrap1") ?(kind = "arith") ?(parameters_ty = "string") + ?(boot_sector = "") client = + let* sc_rollup = + Client.Sc_rollup.( + originate ~hooks ~burn_cap ~src ~kind ~parameters_ty ~boot_sector client) + in + let* () = Client.bake_for_and_wait client in + return sc_rollup + let with_fresh_rollup f tezos_node tezos_client bootstrap1_key = let* sc_rollup = Client.Sc_rollup.originate -- GitLab From d44ae5014a5d81bcb8e609457d7b71555b29fd13 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Wed, 13 Jul 2022 08:42:16 +0200 Subject: [PATCH 4/4] Tezt/scoru: factorize code of scoru origination & bake --- tezt/tests/sc_rollup.ml | 56 +++++++---------------------------------- 1 file changed, 9 insertions(+), 47 deletions(-) diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 6bb7a60dbc5a..de11b46e8f49 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -147,8 +147,8 @@ let sc_rollup_node_rpc sc_node service = type test = {variant : string; tags : string list; description : string} (** This helper injects an SC rollup origination via tezos-client. Then it -bakes to include the origination in a block. It returns the address of the -originated rollup *) + bakes to include the origination in a block. It returns the address of the + originated rollup *) let originate_sc_rollup ?(hooks = hooks) ?(burn_cap = Tez.(of_int 9999999)) ?(src = "bootstrap1") ?(kind = "arith") ?(parameters_ty = "string") ?(boot_sector = "") client = @@ -160,23 +160,13 @@ let originate_sc_rollup ?(hooks = hooks) ?(burn_cap = Tez.(of_int 9999999)) return sc_rollup let with_fresh_rollup f tezos_node tezos_client bootstrap1_key = - let* sc_rollup = - Client.Sc_rollup.originate - ~hooks - ~burn_cap:Tez.(of_int 9999999) - ~src:bootstrap1_key - ~kind:"arith" - ~boot_sector:"" - ~parameters_ty:"string" - tezos_client - in + let* sc_rollup = originate_sc_rollup ~src:bootstrap1_key tezos_client in let sc_rollup_node = Sc_rollup_node.create tezos_node tezos_client ~operator_pkh:bootstrap1_key in let* configuration_filename = Sc_rollup_node.config_init sc_rollup_node sc_rollup in - let* () = Client.bake_for_and_wait tezos_client in f sc_rollup sc_rollup_node configuration_filename (* TODO: https://gitlab.com/tezos/tezos/-/issues/2933 @@ -277,34 +267,17 @@ let test_origination = "origination of a SCORU executes without error" (fun protocol -> setup ~protocol @@ fun _node client bootstrap1_key -> - let* _sc_rollup = - Client.Sc_rollup.originate - ~hooks - ~burn_cap:Tez.(of_int 9999999) - ~src:bootstrap1_key - ~kind:"arith" - ~parameters_ty:"string" - ~boot_sector:"" - client - in - Client.bake_for_and_wait client) + let* _sc_rollup = originate_sc_rollup ~src:bootstrap1_key client in + unit) (* Configuration of a rollup node ------------------------------ A rollup node has a configuration file that must be initialized. *) -let with_fresh_rollup ?(boot_sector = "") f tezos_node tezos_client - bootstrap1_key = +let with_fresh_rollup ?boot_sector f tezos_node tezos_client bootstrap1_key = let* sc_rollup = - Client.Sc_rollup.originate - ~hooks - ~burn_cap:Tez.(of_int 9999999) - ~src:bootstrap1_key - ~kind:"arith" - ~parameters_ty:"string" - ~boot_sector - tezos_client + originate_sc_rollup ~src:bootstrap1_key ?boot_sector tezos_client in let sc_rollup_node = Sc_rollup_node.create tezos_node tezos_client ~operator_pkh:bootstrap1_key @@ -312,7 +285,6 @@ let with_fresh_rollup ?(boot_sector = "") f tezos_node tezos_client let* configuration_filename = Sc_rollup_node.config_init sc_rollup_node sc_rollup in - let* () = Client.bake_for_and_wait tezos_client in f sc_rollup sc_rollup_node configuration_filename let with_fresh_rollups n f node client bootstrap1 = @@ -1966,20 +1938,10 @@ let test_consecutive_commitments = "consecutive commitments" (fun protocol -> setup ~protocol @@ fun _node client bootstrap1_key -> - let* sc_rollup = - Client.Sc_rollup.originate - ~hooks - ~burn_cap:Tez.(of_int 9999999) - ~src:bootstrap1_key - ~kind:"arith" - ~parameters_ty:"string" - ~boot_sector:"" - client - in - let operator = Constant.bootstrap1.public_key_hash in let* inbox_level = Client.level client in + let* sc_rollup = originate_sc_rollup ~src:bootstrap1_key client in + let operator = Constant.bootstrap1.public_key_hash in let* {commitment_period_in_blocks; _} = get_sc_rollup_constants client in - let* () = Client.bake_for_and_wait client in (* As we did no publish any commitment yet, this is supposed to fail. *) let*? process = RPC.Client.spawn client -- GitLab