From e9f533e58406d2c02fc7604d531773e3e69d3bb2 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 17 Jul 2023 13:40:10 +0200 Subject: [PATCH 1/3] alpha/baker: introduce attest for command and depreciate endorse for command --- .../lib_delegate/baking_commands.ml | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/proto_alpha/lib_delegate/baking_commands.ml b/src/proto_alpha/lib_delegate/baking_commands.ml index fc68cac09f6b..6c084307eba8 100644 --- a/src/proto_alpha/lib_delegate/baking_commands.ml +++ b/src/proto_alpha/lib_delegate/baking_commands.ml @@ -120,13 +120,13 @@ let force_apply_switch_arg = ~doc:"Force the baker to not only validate but also apply operations." () -let endorsement_force_switch_arg = +let attestation_force_switch_arg = Tezos_clic.switch ~long:"force" ~short:'f' ~doc: "Disable consistency, injection and double signature checks for \ - (pre)endorsements." + (pre)attestations." () let do_not_monitor_node_mempool_arg = @@ -222,7 +222,7 @@ let sources_param = (Client_keys.Public_key_hash.source_param ~name:"baker" ~desc: - "name of the delegate owning the endorsement/baking right or name of \ + "name of the delegate owning the attestation/baking right or name of \ the consensus key signing on the delegate's behalf") let endpoint_arg = @@ -398,16 +398,36 @@ let delegate_commands () : Protocol_client_context.full Tezos_clic.command list delegates); command ~group - ~desc:"Forge and inject an endorsement operation." - (args1 endorsement_force_switch_arg) + ~desc:"Forge and inject an attestation operation." + (args1 attestation_force_switch_arg) + (prefixes ["attest"; "for"] @@ sources_param) + (fun force pkhs cctxt -> + get_delegates cctxt pkhs >>=? fun delegates -> + Baking_lib.endorse ~force cctxt delegates); + command + ~group + ~desc: + "Deprecated, use **attest for** instead. Forge and inject an \ + attestation operation." + (args1 attestation_force_switch_arg) (prefixes ["endorse"; "for"] @@ sources_param) (fun force pkhs cctxt -> get_delegates cctxt pkhs >>=? fun delegates -> Baking_lib.endorse ~force cctxt delegates); command ~group - ~desc:"Forge and inject a preendorsement operation." - (args1 endorsement_force_switch_arg) + ~desc:"Forge and inject a preattestation operation." + (args1 attestation_force_switch_arg) + (prefixes ["preattest"; "for"] @@ sources_param) + (fun force pkhs cctxt -> + get_delegates cctxt pkhs >>=? fun delegates -> + Baking_lib.preendorse ~force cctxt delegates); + command + ~group + ~desc: + "Deprecated, use **preattest for** instead. Forge and inject a \ + preattestation operation." + (args1 attestation_force_switch_arg) (prefixes ["preendorse"; "for"] @@ sources_param) (fun force pkhs cctxt -> get_delegates cctxt pkhs >>=? fun delegates -> -- GitLab From c5c23e72202a74d9c64f3de0c0bfc8004c5feb48 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 17 Jul 2023 13:58:28 +0200 Subject: [PATCH 2/3] tezt/lib_tezos: use attest for for recent protocol --- tezt/lib_tezos/client.ml | 39 ++++++++++++++++++++------------ tezt/lib_tezos/client.mli | 18 ++++++++------- tezt/tests/RPC_test.ml | 2 +- tezt/tests/double_consensus.ml | 8 +++---- tezt/tests/prevalidator.ml | 10 ++++---- tezt/tests/protocol_migration.ml | 18 +++++++++++---- tezt/tests/tenderbake.ml | 8 +++---- 7 files changed, 63 insertions(+), 40 deletions(-) diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index 4f845d80920d..1d3b02501ec0 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -807,29 +807,40 @@ let bake_for_and_wait ?endpoint ?protocol ?keys ?minimal_fees let* _lvl = Node.wait_for_level node (level_before + 1) in unit -(* Handle endorsing and preendorsing similarly *) -type tenderbake_action = Preendorse | Endorse | Propose +(* Handle attesting and preattesting similarly *) +type tenderbake_action = Preattest | Attest | Propose -let tenderbake_action_to_string = function - | Preendorse -> "preendorse" - | Endorse -> "endorse" +let tenderbake_action_to_string ~use_legacy_attestation_name = function + | Preattest -> + if use_legacy_attestation_name then "preendorse" else "preattest" + | Attest -> if use_legacy_attestation_name then "endorse" else "attest" | Propose -> "propose" let spawn_tenderbake_action_for ~tenderbake_action ?endpoint ?protocol ?(key = [Constant.bootstrap1.alias]) ?(minimal_timestamp = false) ?(force = false) client = + let use_legacy_attestation_name = + match protocol with + | None -> false + | Some protocol -> Protocol.(number protocol < 018) + in spawn_command ?endpoint client (optional_arg "protocol" Protocol.hash protocol - @ [tenderbake_action_to_string tenderbake_action; "for"] + @ [ + tenderbake_action_to_string + ~use_legacy_attestation_name + tenderbake_action; + "for"; + ] @ key @ (if minimal_timestamp then ["--minimal-timestamp"] else []) @ if force then ["--force"] else []) -let spawn_endorse_for ?endpoint ?protocol ?key ?force client = +let spawn_attest_for ?endpoint ?protocol ?key ?force client = spawn_tenderbake_action_for - ~tenderbake_action:Endorse + ~tenderbake_action:Attest ~minimal_timestamp:false ?endpoint ?protocol @@ -837,9 +848,9 @@ let spawn_endorse_for ?endpoint ?protocol ?key ?force client = ?force client -let spawn_preendorse_for ?endpoint ?protocol ?key ?force client = +let spawn_preattest_for ?endpoint ?protocol ?key ?force client = spawn_tenderbake_action_for - ~tenderbake_action:Preendorse + ~tenderbake_action:Preattest ~minimal_timestamp:false ?endpoint ?protocol @@ -858,11 +869,11 @@ let spawn_propose_for ?endpoint ?minimal_timestamp ?protocol ?key ?force client ?force client -let endorse_for ?endpoint ?protocol ?key ?force client = - spawn_endorse_for ?endpoint ?protocol ?key ?force client |> Process.check +let attest_for ?endpoint ?protocol ?key ?force client = + spawn_attest_for ?endpoint ?protocol ?key ?force client |> Process.check -let preendorse_for ?endpoint ?protocol ?key ?force client = - spawn_preendorse_for ?endpoint ?protocol ?key ?force client |> Process.check +let preattest_for ?endpoint ?protocol ?key ?force client = + spawn_preattest_for ?endpoint ?protocol ?key ?force client |> Process.check let propose_for ?endpoint ?(minimal_timestamp = true) ?protocol ?key ?force client = diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index 587fca1ea26d..f832cbc7d160 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -572,10 +572,11 @@ val spawn_bake_for : t -> Process.t -(** Run [octez-client endorse for]. +(** Run [octez-client attest for]. Run [octez-client endorse for] for protocol + older than 018. Default [key] is {!Constant.bootstrap1.alias}. *) -val endorse_for : +val attest_for : ?endpoint:endpoint -> ?protocol:Protocol.t -> ?key:string list -> @@ -583,8 +584,8 @@ val endorse_for : t -> unit Lwt.t -(** Same as [endorse_for], but do not wait for the process to exit. *) -val spawn_endorse_for : +(** Same as [attest_for], but do not wait for the process to exit. *) +val spawn_attest_for : ?endpoint:endpoint -> ?protocol:Protocol.t -> ?key:string list -> @@ -592,10 +593,11 @@ val spawn_endorse_for : t -> Process.t -(** Run [octez-client preendorse for]. +(** Run [octez-client preattest for]. Run [octez-client preendorse for] for + protocol older than 018. Default [key] is {!Constant.bootstrap1.alias}. *) -val preendorse_for : +val preattest_for : ?endpoint:endpoint -> ?protocol:Protocol.t -> ?key:string list -> @@ -603,8 +605,8 @@ val preendorse_for : t -> unit Lwt.t -(** Same as [preendorse_for], but do not wait for the process to exit. *) -val spawn_preendorse_for : +(** Same as [preattest_for], but do not wait for the process to exit. *) +val spawn_preattest_for : ?endpoint:endpoint -> ?protocol:Protocol.t -> ?key:string list -> diff --git a/tezt/tests/RPC_test.ml b/tezt/tests/RPC_test.ml index 430801a13483..10f4f3cf21de 100644 --- a/tezt/tests/RPC_test.ml +++ b/tezt/tests/RPC_test.ml @@ -814,7 +814,7 @@ let test_mempool _test_mode_tag protocol ?endpoint client = let* _ = bake_empty_block ?endpoint client in (* Outdated operation after the second empty baking. *) - let* () = Client.endorse_for ~protocol ~force:true client in + let* () = Client.attest_for ~protocol ~force:true client in let* _ = bake_empty_block ?endpoint client in let monitor_path = diff --git a/tezt/tests/double_consensus.ml b/tezt/tests/double_consensus.ml index ac833ddf77cf..6b8479d54448 100644 --- a/tezt/tests/double_consensus.ml +++ b/tezt/tests/double_consensus.ml @@ -148,13 +148,13 @@ let double_consensus_wrong_slot unit let attest_utils = - ( Client.endorse_for, + ( Client.attest_for, Operation.Consensus.attestation ~use_legacy_name:true, double_attestation_waiter, get_consensus_operation_name ) let preattest_utils = - ( Client.preendorse_for, + ( Client.preattest_for, Operation.Consensus.preattestation ~use_legacy_name:true, double_preattestation_waiter, fun protocol -> sf "pre%s" (get_consensus_operation_name protocol) ) @@ -322,7 +322,7 @@ let operation_too_old = Log.info "Inject valid attestation." ; let waiter = Node.wait_for_request ~request:`Inject node in let* () = - Client.endorse_for + Client.attest_for ~protocol ~force:true ~key:[Constant.bootstrap1.alias] @@ -386,7 +386,7 @@ let operation_too_far_in_future = Log.info "Inject valid attestation." ; let waiter = Node.wait_for_request ~request:`Inject node in let* () = - Client.endorse_for + Client.attest_for ~protocol ~force:true ~key:[Constant.bootstrap1.alias] diff --git a/tezt/tests/prevalidator.ml b/tezt/tests/prevalidator.ml index 87e25cb44e52..9941e642c9ca 100644 --- a/tezt/tests/prevalidator.ml +++ b/tezt/tests/prevalidator.ml @@ -198,7 +198,7 @@ module Revamped = struct Check.((mempool = mempool_after_empty_block) Mempool.typ ~error_msg) ; log_step 6 "Inject endorsement operations." ; - let* () = Client.endorse_for client ~protocol ~force:true in + let* () = Client.attest_for client ~protocol ~force:true in let* mempool_with_endorsement = Mempool.get_mempool client in log_step 7 "Check endorsement is validated." ; @@ -1220,7 +1220,7 @@ module Revamped = struct log_step 3 "Endorse with bootstrap1." ; let* _ = - Client.endorse_for + Client.attest_for ~protocol ~key:[Constant.bootstrap1.alias] ~force:true @@ -1229,7 +1229,7 @@ module Revamped = struct log_step 3 "Endorse with bootstrap2." ; let* _ = - Client.endorse_for + Client.attest_for ~protocol ~key:[Constant.bootstrap2.alias] ~force:true @@ -2386,7 +2386,7 @@ let propagation_future_endorsement = bytes representing this endorsement, called future1 from now on." ; let* () = Node_event_level.bake_wait_log node_1 client_1 in let injection_waiter = wait_for_injection node_1 in - let* () = Client.endorse_for client_1 ~force:true ~protocol in + let* () = Client.attest_for client_1 ~force:true ~protocol in let* () = injection_waiter in let* bytes_future1, oph_future1 = get_endorsement_as_bytes client_1 in log_step @@ -2396,7 +2396,7 @@ let propagation_future_endorsement = the hash and bytes representing this endorsement, called future2." ; let* () = Node_event_level.bake_wait_log node_1 client_1 in let injection_waiter2 = wait_for_injection node_1 in - let* () = Client.endorse_for client_1 ~force:true ~protocol in + let* () = Client.attest_for client_1 ~force:true ~protocol in let* () = injection_waiter2 in let* bytes_future2, oph_future2 = get_endorsement_as_bytes client_1 in log_step 5 "Inject both endorsements in node_2." ; diff --git a/tezt/tests/protocol_migration.ml b/tezt/tests/protocol_migration.ml index 095d0cd90408..305d560c507d 100644 --- a/tezt/tests/protocol_migration.ml +++ b/tezt/tests/protocol_migration.ml @@ -198,9 +198,19 @@ let test_migration_with_snapshots ~migrate_from ~migrate_to = let level_before = Node.get_level node0 in let* () = Client.propose_for ~key:[baker.alias] client0 in let* () = - Client.preendorse_for ~key:all_bootstrap_keys ~force:true client0 + Client.preattest_for + ~protocol:migrate_to + ~key:all_bootstrap_keys + ~force:true + client0 + in + let* () = + Client.attest_for + ~protocol:migrate_to + ~key:all_bootstrap_keys + ~force:true + client0 in - let* () = Client.endorse_for ~key:all_bootstrap_keys ~force:true client0 in let* level_after = Node.wait_for_level node0 (level_before + 1) in Log.debug "Manually baked to level %d" level_after ; unit @@ -562,14 +572,14 @@ let test_forked_migration_manual ?(migration_level = 4) ~force:true in let* () = - Client.preendorse_for + Client.preattest_for ~protocol:migrate_from ~key:all_bootstrap_keys client_2 ~force:true in let* () = - Client.endorse_for + Client.attest_for ~key:all_bootstrap_keys client_2 ~protocol:migrate_from diff --git a/tezt/tests/tenderbake.ml b/tezt/tests/tenderbake.ml index bce5f67abe9f..f7e6ddae70fe 100644 --- a/tezt/tests/tenderbake.ml +++ b/tezt/tests/tenderbake.ml @@ -72,10 +72,10 @@ let endorsers = ] let endorse endpoint protocol client endorsers = - Client.endorse_for ~endpoint ~protocol ~key:endorsers ~force:true client + Client.attest_for ~endpoint ~protocol ~key:endorsers ~force:true client let preendorse endpoint protocol client preendorsers = - Client.preendorse_for ~endpoint ~protocol ~key:preendorsers ~force:true client + Client.preattest_for ~endpoint ~protocol ~key:preendorsers ~force:true client let test_bake_two = Protocol.register_test @@ -249,7 +249,7 @@ let test_manual_bake = Constant.bootstrap4.alias; ] in - let* () = Client.preendorse_for ~key:endorsers ~force:true client in + let* () = Client.preattest_for ~protocol ~key:endorsers ~force:true client in let giver = "bootstrap1" in Log.info "Transfer from giver %s to recipient %s" giver recipient.alias ; @@ -275,7 +275,7 @@ let test_manual_bake = Log.info "Transfer injected with operation hash %s" operation_hash ; Log.info "Endorse" ; - let* () = Client.endorse_for ~key:endorsers ~force:true client in + let* () = Client.attest_for ~protocol ~key:endorsers ~force:true client in Log.info "Test that %s is pending" operation_hash ; let* pending_ops = -- GitLab From 7a14562351a27a98af50280e01cb5af89ee9d034 Mon Sep 17 00:00:00 2001 From: Albin Coquereau Date: Mon, 17 Jul 2023 14:09:25 +0200 Subject: [PATCH 3/3] changes: add entry for client attest for command --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 8e774331890a..c1120f778291 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -230,6 +230,9 @@ Client ``double preattesation evidence``, ``lost endorsing rewards`` become ``lost attesting rewards``. (MR :gl:`!9232`) +- Add ``attest for`` and ``preattest for`` commands. ``endorse for`` and + ``preendorse for`` are now deprecated. (MR :gl:`!9494`) + Baker ----- -- GitLab