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 aa4e9018e7c6a8be538ae85da339459bb3fe83bf..61f7e01a9b9dd90bc438c59925bf2bdf1580bab6 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 = diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index c9d93a38836b3058efbd5b7c07c2a1f882463ba7..e069a051e2f2e8b5be3727c3863577c991d25402 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 27852f366b438abd03d96c2612b4a3fed2fe859a..067176c20e3055f35dc608f5b402d2e88f9b9323 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 13861ab41e9413a3223c5d7ce0c109ed190b82be..0f069fe94ad1fa359dac0f9e40a78e06538c0aea 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) : diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 515e83dec0532127ac4c337c10c6b8290eecc47f..de11b46e8f49a6436a04370cf7f5e67c35a08413 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -146,24 +146,27 @@ let sc_rollup_node_rpc sc_node service = type test = {variant : string; tags : string list; description : string} -let with_fresh_rollup f tezos_node tezos_client bootstrap1_key = +(** 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:Tez.(of_int 9999999) - ~src:bootstrap1_key - ~kind:"arith" - ~boot_sector:"" - ~parameters_ty:"string" - tezos_client + 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 = 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 @@ -264,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 @@ -299,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 = @@ -1953,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