From 45434995a1eb6ad4670a62c564eb31b913ff1247 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 4 Jul 2022 09:47:38 +0200 Subject: [PATCH 1/5] Proto/Scoru: improve error title & description --- src/proto_alpha/lib_protocol/sc_rollup_errors.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_errors.ml b/src/proto_alpha/lib_protocol/sc_rollup_errors.ml index e5dc0c84f84b..0e66e086f536 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_errors.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_errors.ml @@ -256,11 +256,11 @@ let () = Data_encoding.empty (function Sc_rollup_not_staked_on_lcc -> Some () | _ -> None) (fun () -> Sc_rollup_not_staked_on_lcc) ; - let description = "Parent is not cemented." in + let description = "Parent is not the last cemented commitment." in register_error_kind `Temporary ~id:"Sc_rollup_parent_not_lcc" - ~title:"Parent not cemented" + ~title:"Parent is not the last cemented commitment" ~description ~pp:(fun ppf () -> Format.fprintf ppf "%s" description) Data_encoding.empty -- GitLab From 0a141eccbdeb046c79e738db3f04f4342b3b4fa7 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Mon, 4 Jul 2022 17:27:35 +0200 Subject: [PATCH 2/5] Proto/Scoru. encodings: replace (req X (option Y)) with (opt X Y) --- src/proto_alpha/lib_protocol/operation_repr.ml | 4 +--- src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index 7800df44295d..5fcefe0170e9 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -1112,9 +1112,7 @@ module Encoding = struct obj3 (req "rollup" Sc_rollup_repr.encoding) (req "opponent" Sc_rollup_repr.Staker.encoding) - (req - "refutation" - (option Sc_rollup_game_repr.refutation_encoding)); + (opt "refutation" Sc_rollup_game_repr.refutation_encoding); select = (function | Manager (Sc_rollup_refute _ as op) -> Some op | _ -> None); diff --git a/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml index 03b63228744c..6109671ffb0a 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml @@ -109,7 +109,7 @@ module V1 = struct (fun {state_hash; tick} -> (state_hash, tick)) (fun (state_hash, tick) -> {state_hash; tick}) (obj2 - (req "state" (option State_hash.encoding)) + (opt "state" State_hash.encoding) (req "tick" Sc_rollup_tick_repr.encoding))) let encoding = -- GitLab From 6f7e4010b2545569d7f9c97d70ef9009f63d0701 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Thu, 7 Jul 2022 22:15:12 +0100 Subject: [PATCH 3/5] Tezt/lib_tezos: make cement_commitment command return Process --- tezt/lib_tezos/client.ml | 24 ++++++++++++------------ tezt/lib_tezos/client.mli | 13 +------------ tezt/tests/sc_rollup.ml | 2 +- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index 7e5c35567947..b48b946ddc9f 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -1705,20 +1705,20 @@ module Sc_rollup = struct let parse process = Process.check process in {value = process; run = parse} - let spawn_cement_commitment ?hooks ?(wait = "none") ?burn_cap ~hash ~src ~dst - client = - spawn_command - ?hooks - client - (["--wait"; wait] - @ ["cement"; "commitment"; hash; "from"; src; "for"; "sc"; "rollup"; dst] - @ optional_arg "burn-cap" Tez.to_string burn_cap) - - let cement_commitment ?hooks ?wait ?burn_cap ~hash ~src ~dst client = + let cement_commitment ?hooks ?(wait = "none") ?burn_cap ~hash ~src ~dst client + = let process = - spawn_cement_commitment ?hooks ?wait ?burn_cap ~hash ~src ~dst client + spawn_command + ?hooks + client + (["--wait"; wait] + @ [ + "cement"; "commitment"; hash; "from"; src; "for"; "sc"; "rollup"; dst; + ] + @ optional_arg "burn-cap" Tez.to_string burn_cap) in - Process.check process + let parse process = Process.check process in + {value = process; run = parse} let submit_recover_bond ?(wait = "none") ?burn_cap ?storage_limit ?fee ?hooks ~rollup ~src client = diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index 298417903ac3..68267fa3fe00 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -1280,18 +1280,7 @@ module Sc_rollup : sig src:string -> dst:string -> t -> - unit Lwt.t - - (** Same as [cement_commitment], but do not wait for the process to exit. *) - val spawn_cement_commitment : - ?hooks:Process.hooks -> - ?wait:string -> - ?burn_cap:Tez.t -> - hash:string -> - src:string -> - dst:string -> - t -> - Process.t + unit Runnable.process (** Run [tezos-client submit sc rollup recover bond to from ]. *) val submit_recover_bond : diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 88eb31b37057..b2141eabcebd 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -213,7 +213,7 @@ let first_published_at_level (_hash, (_ : Sc_rollup_client.commitment), level) = let predecessor (_hash, {Sc_rollup_client.predecessor; _}, _level) = predecessor let cement_commitment client ~sc_rollup ~hash = - let* () = + let*! () = Client.Sc_rollup.cement_commitment ~hooks ~src:"bootstrap1" -- GitLab From ad8a07f8a9261bba715da00cda34a171404a5e32 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Fri, 8 Jul 2022 11:38:30 +0100 Subject: [PATCH 4/5] Tezt/Scoru: make function publish_dummy_commitment more generic --- tezt/tests/sc_rollup.ml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index b2141eabcebd..cafe1a8c82d3 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -1906,16 +1906,16 @@ let test_rollup_client_list_keys = pp maybe_keys) -let publish_dummy_commitment ~inbox_level ~predecessor ~sc_rollup ~src client = +let publish_dummy_commitment ?(number_of_ticks = 1) ~inbox_level ~predecessor + ~sc_rollup ~src client = let commitment : Sc_rollup_client.commitment = { compressed_state = Constant.sc_rollup_compressed_state; inbox_level; predecessor; - number_of_ticks = 1; + number_of_ticks; } in - let*! () = publish_commitment ~src ~commitment client sc_rollup in Client.bake_for_and_wait client -- GitLab From 3379bebb8d3a2b94ff1117709ebf66cb4a1c5997 Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Thu, 7 Jul 2022 22:16:28 +0100 Subject: [PATCH 5/5] Tezt/Scoru: more generic cement_commitment helper --- tezt/tests/sc_rollup.ml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index cafe1a8c82d3..bc6531344dc9 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -212,16 +212,17 @@ let first_published_at_level (_hash, (_ : Sc_rollup_client.commitment), level) = let predecessor (_hash, {Sc_rollup_client.predecessor; _}, _level) = predecessor -let cement_commitment client ~sc_rollup ~hash = - let*! () = - Client.Sc_rollup.cement_commitment - ~hooks - ~src:"bootstrap1" - ~dst:sc_rollup - ~hash - client - in - Client.bake_for_and_wait client +let cement_commitment ?(src = "bootstrap1") ?fail ~sc_rollup ~hash client = + let p = + Client.Sc_rollup.cement_commitment ~hooks ~dst:sc_rollup ~src ~hash client + in + match fail with + | None -> + let*! () = p in + Client.bake_for_and_wait client + | Some failure -> + let*? process = p in + Process.check_error ~msg:(rex failure) process let publish_commitment ?(src = Constant.bootstrap1.public_key_hash) ~commitment client sc_rollup = -- GitLab