From f231be40c947cc651305858456dc4ddbc4930923 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Thu, 1 May 2025 16:49:07 +0100 Subject: [PATCH 1/2] Baker: Add --with-accuser option --- src/lib_agnostic_baker/configuration.ml | 49 ++++++++++++------- src/lib_agnostic_baker/configuration.mli | 10 +++- .../lib_agnostic_baker/baker_args_parser.ml | 6 ++- .../lib_agnostic_baker/baker_args_parser.mli | 2 + .../lib_delegate/baking_commands.ml | 44 ++++++++++++++++- .../lib_delegate/baking_commands.mli | 4 +- .../lib_delegate/baking_events.ml | 17 +++++++ .../lib_agnostic_baker/baker_args_parser.ml | 6 ++- .../lib_agnostic_baker/baker_args_parser.mli | 2 + .../lib_delegate/baking_commands.ml | 44 ++++++++++++++++- .../lib_delegate/baking_commands.mli | 4 +- .../lib_delegate/baking_events.ml | 17 +++++++ .../lib_agnostic_baker/baker_args_parser.ml | 6 ++- .../lib_agnostic_baker/baker_args_parser.mli | 2 + .../lib_delegate/baking_commands.ml | 44 ++++++++++++++++- .../lib_delegate/baking_commands.mli | 4 +- src/proto_alpha/lib_delegate/baking_events.ml | 17 +++++++ 17 files changed, 247 insertions(+), 31 deletions(-) diff --git a/src/lib_agnostic_baker/configuration.ml b/src/lib_agnostic_baker/configuration.ml index d0a9667f630d..dd1083aa886d 100644 --- a/src/lib_agnostic_baker/configuration.ml +++ b/src/lib_agnostic_baker/configuration.ml @@ -345,8 +345,30 @@ let remote_calls_timeout_arg = try return (Q.of_string s) with _ -> failwith "remote-calls-timeout expected int or float.")) +let with_accuser_arg : + (bool, Tezos_client_base.Client_context.full) Tezos_clic.arg = + Tezos_clic.switch + ~long:"with-accuser" + ~doc:"If this flag is set, the accuser runs together with the baker." + () + +let preserved_levels_arg = + let open Lwt_result_syntax in + Tezos_clic.default_arg + ~long:"preserved-levels" + ~placeholder:"threshold" + ~doc:"Number of effective levels kept in the accuser's memory" + ~default:"200" + (Tezos_clic.parameter + (fun (_cctxt : Tezos_client_base.Client_context.full) s -> + try + let preserved_levels = int_of_string s in + if preserved_levels < 0 then tzfail (Bad_preserved_levels s) + else return preserved_levels + with _ -> tzfail (Bad_preserved_levels s))) + let baker_args = - Tezos_clic.args17 + Tezos_clic.args19 pidfile_arg node_version_check_bypass_arg node_version_allowed_arg @@ -364,6 +386,8 @@ let baker_args = state_recorder_switch_arg pre_emptive_forge_time_arg remote_calls_timeout_arg + with_accuser_arg + preserved_levels_arg let directory_parameter = let open Lwt_result_syntax in @@ -381,21 +405,6 @@ let sources_param = "name of the delegate owning the attestation/baking right or name of \ the consensus key signing on the delegate's behalf") -let preserved_levels_arg = - let open Lwt_result_syntax in - Tezos_clic.default_arg - ~long:"preserved-levels" - ~placeholder:"threshold" - ~doc:"Number of effective levels kept in the accuser's memory" - ~default:"200" - (Tezos_clic.parameter - (fun (_cctxt : Tezos_client_base.Client_context.full) s -> - try - let preserved_levels = int_of_string s in - if preserved_levels < 0 then tzfail (Bad_preserved_levels s) - else return preserved_levels - with _ -> tzfail (Bad_preserved_levels s))) - type t = { pidfile : string option; node_version_check_bypass : bool; @@ -414,6 +423,8 @@ type t = { state_recorder : bool; pre_emptive_forge_time : Q.t option; remote_calls_timeout : Q.t option; + with_accuser : bool; + preserved_levels : int; } (** Create the configuration from the given arguments. *) @@ -434,7 +445,9 @@ let create_config without_dal, state_recorder, pre_emptive_forge_time, - remote_calls_timeout ) = + remote_calls_timeout, + with_accuser, + preserved_levels ) = { pidfile; node_version_check_bypass; @@ -453,4 +466,6 @@ let create_config state_recorder; pre_emptive_forge_time; remote_calls_timeout; + with_accuser; + preserved_levels; } diff --git a/src/lib_agnostic_baker/configuration.mli b/src/lib_agnostic_baker/configuration.mli index 32e77234a5bd..23e215415c13 100644 --- a/src/lib_agnostic_baker/configuration.mli +++ b/src/lib_agnostic_baker/configuration.mli @@ -37,7 +37,9 @@ val baker_args : * bool * bool * Q.t option - * Q.t option, + * Q.t option + * bool + * int, Tezos_client_base.Client_context.full ) Tezos_clic.options @@ -72,6 +74,8 @@ type t = { state_recorder : bool; pre_emptive_forge_time : Q.t option; remote_calls_timeout : Q.t option; + with_accuser : bool; + preserved_levels : int; } val create_config : @@ -91,5 +95,7 @@ val create_config : * bool * bool * Q.t option - * Q.t option -> + * Q.t option + * bool + * int -> t diff --git a/src/proto_021_PsQuebec/lib_agnostic_baker/baker_args_parser.ml b/src/proto_021_PsQuebec/lib_agnostic_baker/baker_args_parser.ml index 764f7803957a..9ce014e0533b 100644 --- a/src/proto_021_PsQuebec/lib_agnostic_baker/baker_args_parser.ml +++ b/src/proto_021_PsQuebec/lib_agnostic_baker/baker_args_parser.ml @@ -55,6 +55,8 @@ let parse_configuration state_recorder; pre_emptive_forge_time; remote_calls_timeout; + with_accuser; + preserved_levels; } = ( pidfile, node_version_check_bypass, @@ -72,7 +74,9 @@ let parse_configuration without_dal, parse_state_recorder state_recorder, pre_emptive_forge_time, - remote_calls_timeout ) + remote_calls_timeout, + with_accuser, + preserved_levels ) let parse_baking_mode baking_mode = match baking_mode with diff --git a/src/proto_021_PsQuebec/lib_agnostic_baker/baker_args_parser.mli b/src/proto_021_PsQuebec/lib_agnostic_baker/baker_args_parser.mli index cd2af5efebd5..01d062a4ac47 100644 --- a/src/proto_021_PsQuebec/lib_agnostic_baker/baker_args_parser.mli +++ b/src/proto_021_PsQuebec/lib_agnostic_baker/baker_args_parser.mli @@ -34,6 +34,8 @@ val parse_configuration : * Baking_configuration.state_recorder_config * Q.t option * Q.t option + * bool + * int (** [parse_baking_mode baking_mode] maps a optional value to a [Local] or [Remote] baking mode option. *) diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_commands.ml b/src/proto_021_PsQuebec/lib_delegate/baking_commands.ml index da310b94a93f..3d039ff2feaa 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_commands.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_commands.ml @@ -669,6 +669,12 @@ let remote_calls_timeout_arg = try return (Q.of_string s) with _ -> failwith "remote-calls-timeout expected int or float.")) +let with_accuser_arg = + Tezos_clic.switch + ~long:"with-accuser" + ~doc:"If this flag is set, the accuser runs together with the baker." + () + let lookup_default_vote_file_path (cctxt : Protocol_client_context.full) = let open Lwt_syntax in let default_filename = Per_block_vote_file.default_vote_json_filename in @@ -714,7 +720,7 @@ let check_dal_node without_dal dal_node_rpc_ctxt = type baking_mode = Local of {local_data_dir_path : string} | Remote let baker_args = - Tezos_clic.args17 + Tezos_clic.args19 pidfile_arg node_version_check_bypass_arg node_version_allowed_arg @@ -732,6 +738,34 @@ let baker_args = state_recorder_switch_arg pre_emptive_forge_time_arg remote_calls_timeout_arg + with_accuser_arg + preserved_levels_arg + +let start_async_accuser cctxt ~preserved_levels ~keep_alive = + let open Lwt_syntax in + let accuser = + let* r = + Client_daemon.Accuser.run + cctxt + ~chain:cctxt#chain + ~preserved_levels + ~keep_alive + in + match r with + | Ok () -> + let* () = Events.(emit accuser_finished) () in + Lwt.return_unit + | Error errs -> + let* () = + Events.( + emit + accuser_error + (Format.asprintf "%a@." Error_monad.pp_print_trace errs)) + in + Lwt.return_unit + in + Lwt.async (fun () -> accuser) ; + return_unit let run_baker ?(recommend_agnostic_baker = true) ( pidfile, @@ -750,7 +784,9 @@ let run_baker ?(recommend_agnostic_baker = true) without_dal, state_recorder, pre_emptive_forge_time, - remote_calls_timeout ) baking_mode sources cctxt = + remote_calls_timeout, + with_accuser, + preserved_levels ) baking_mode sources cctxt = let open Lwt_result_syntax in may_lock_pidfile pidfile @@ fun () -> let*! () = @@ -786,6 +822,10 @@ let run_baker ?(recommend_agnostic_baker = true) | Local {local_data_dir_path} -> Some local_data_dir_path | Remote -> None in + let*! () = + if with_accuser then start_async_accuser cctxt ~preserved_levels ~keep_alive + else Lwt.return_unit + in Client_daemon.Baker.run cctxt ~minimal_fees diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_commands.mli b/src/proto_021_PsQuebec/lib_delegate/baking_commands.mli index a733adf942a3..f667e3634d9f 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_commands.mli +++ b/src/proto_021_PsQuebec/lib_delegate/baking_commands.mli @@ -43,7 +43,9 @@ val run_baker : * bool * Baking_configuration.state_recorder_config * Q.t option - * Q.t option -> + * Q.t option + * bool + * int -> baking_mode -> Environment.Signature.public_key_hash list -> Protocol_client_context.full -> diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_events.ml b/src/proto_021_PsQuebec/lib_delegate/baking_events.ml index e8be873ba04e..f5def3d9061c 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_events.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_events.ml @@ -134,6 +134,23 @@ module Commands = struct instead of `octez-baker-`, as it automatically handles \ protocol switches." () + + let accuser_finished = + declare_0 + ~section + ~level:Warning + ~name:"accuser_finished" + ~msg:"Accuser exited cleanly, continuing running the baker." + () + + let accuser_error = + declare_1 + ~section + ~level:Error + ~name:"accuser_error" + ~msg:"Accuser crashed with error {error}. Continuing running the baker." + ~pp1:Format.pp_print_string + ("error", Data_encoding.string) end module State_transitions = struct diff --git a/src/proto_022_PsRiotum/lib_agnostic_baker/baker_args_parser.ml b/src/proto_022_PsRiotum/lib_agnostic_baker/baker_args_parser.ml index 764f7803957a..9ce014e0533b 100644 --- a/src/proto_022_PsRiotum/lib_agnostic_baker/baker_args_parser.ml +++ b/src/proto_022_PsRiotum/lib_agnostic_baker/baker_args_parser.ml @@ -55,6 +55,8 @@ let parse_configuration state_recorder; pre_emptive_forge_time; remote_calls_timeout; + with_accuser; + preserved_levels; } = ( pidfile, node_version_check_bypass, @@ -72,7 +74,9 @@ let parse_configuration without_dal, parse_state_recorder state_recorder, pre_emptive_forge_time, - remote_calls_timeout ) + remote_calls_timeout, + with_accuser, + preserved_levels ) let parse_baking_mode baking_mode = match baking_mode with diff --git a/src/proto_022_PsRiotum/lib_agnostic_baker/baker_args_parser.mli b/src/proto_022_PsRiotum/lib_agnostic_baker/baker_args_parser.mli index cd2af5efebd5..01d062a4ac47 100644 --- a/src/proto_022_PsRiotum/lib_agnostic_baker/baker_args_parser.mli +++ b/src/proto_022_PsRiotum/lib_agnostic_baker/baker_args_parser.mli @@ -34,6 +34,8 @@ val parse_configuration : * Baking_configuration.state_recorder_config * Q.t option * Q.t option + * bool + * int (** [parse_baking_mode baking_mode] maps a optional value to a [Local] or [Remote] baking mode option. *) diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_commands.ml b/src/proto_022_PsRiotum/lib_delegate/baking_commands.ml index 7e3312c9c41f..71a57d89e335 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_commands.ml +++ b/src/proto_022_PsRiotum/lib_delegate/baking_commands.ml @@ -682,6 +682,12 @@ let remote_calls_timeout_arg = try return (Q.of_string s) with _ -> failwith "remote-calls-timeout expected int or float.")) +let with_accuser_arg = + Tezos_clic.switch + ~long:"with-accuser" + ~doc:"If this flag is set, the accuser runs together with the baker." + () + let lookup_default_vote_file_path (cctxt : Protocol_client_context.full) = let open Lwt_syntax in let default_filename = Per_block_vote_file.default_vote_json_filename in @@ -727,7 +733,7 @@ let check_dal_node without_dal dal_node_rpc_ctxt = type baking_mode = Local of {local_data_dir_path : string} | Remote let baker_args = - Tezos_clic.args17 + Tezos_clic.args19 pidfile_arg node_version_check_bypass_arg node_version_allowed_arg @@ -745,6 +751,34 @@ let baker_args = state_recorder_switch_arg pre_emptive_forge_time_arg remote_calls_timeout_arg + with_accuser_arg + preserved_levels_arg + +let start_async_accuser cctxt ~preserved_levels ~keep_alive = + let open Lwt_syntax in + let accuser = + let* r = + Client_daemon.Accuser.run + cctxt + ~chain:cctxt#chain + ~preserved_levels + ~keep_alive + in + match r with + | Ok () -> + let* () = Events.(emit accuser_finished) () in + Lwt.return_unit + | Error errs -> + let* () = + Events.( + emit + accuser_error + (Format.asprintf "%a@." Error_monad.pp_print_trace errs)) + in + Lwt.return_unit + in + Lwt.async (fun () -> accuser) ; + return_unit let run_baker ?(recommend_agnostic_baker = true) ( pidfile, @@ -763,7 +797,9 @@ let run_baker ?(recommend_agnostic_baker = true) without_dal, state_recorder, pre_emptive_forge_time, - remote_calls_timeout ) baking_mode sources cctxt = + remote_calls_timeout, + with_accuser, + preserved_levels ) baking_mode sources cctxt = let open Lwt_result_syntax in may_lock_pidfile pidfile @@ fun () -> let*! () = @@ -799,6 +835,10 @@ let run_baker ?(recommend_agnostic_baker = true) | Local {local_data_dir_path} -> Some local_data_dir_path | Remote -> None in + let*! () = + if with_accuser then start_async_accuser cctxt ~preserved_levels ~keep_alive + else Lwt.return_unit + in Client_daemon.Baker.run cctxt ?dal_node_rpc_ctxt diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_commands.mli b/src/proto_022_PsRiotum/lib_delegate/baking_commands.mli index a733adf942a3..f667e3634d9f 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_commands.mli +++ b/src/proto_022_PsRiotum/lib_delegate/baking_commands.mli @@ -43,7 +43,9 @@ val run_baker : * bool * Baking_configuration.state_recorder_config * Q.t option - * Q.t option -> + * Q.t option + * bool + * int -> baking_mode -> Environment.Signature.public_key_hash list -> Protocol_client_context.full -> diff --git a/src/proto_022_PsRiotum/lib_delegate/baking_events.ml b/src/proto_022_PsRiotum/lib_delegate/baking_events.ml index ffb9d2bb00b2..3d1dcb687f17 100644 --- a/src/proto_022_PsRiotum/lib_delegate/baking_events.ml +++ b/src/proto_022_PsRiotum/lib_delegate/baking_events.ml @@ -121,6 +121,23 @@ module Commands = struct instead of `octez-baker-`, as it automatically handles \ protocol switches." () + + let accuser_finished = + declare_0 + ~section + ~level:Warning + ~name:"accuser_finished" + ~msg:"Accuser exited cleanly, continuing running the baker." + () + + let accuser_error = + declare_1 + ~section + ~level:Error + ~name:"accuser_error" + ~msg:"Accuser crashed with error {error}. Continuing running the baker." + ~pp1:Format.pp_print_string + ("error", Data_encoding.string) end module State_transitions = struct diff --git a/src/proto_alpha/lib_agnostic_baker/baker_args_parser.ml b/src/proto_alpha/lib_agnostic_baker/baker_args_parser.ml index 3ea1a51283a9..ba823d22f7c8 100644 --- a/src/proto_alpha/lib_agnostic_baker/baker_args_parser.ml +++ b/src/proto_alpha/lib_agnostic_baker/baker_args_parser.ml @@ -55,6 +55,8 @@ let parse_configuration state_recorder; pre_emptive_forge_time; remote_calls_timeout; + with_accuser; + preserved_levels; } = ( pidfile, node_version_check_bypass, @@ -72,7 +74,9 @@ let parse_configuration without_dal, parse_state_recorder state_recorder, pre_emptive_forge_time, - remote_calls_timeout ) + remote_calls_timeout, + with_accuser, + preserved_levels ) let parse_baking_mode baking_mode = match baking_mode with diff --git a/src/proto_alpha/lib_agnostic_baker/baker_args_parser.mli b/src/proto_alpha/lib_agnostic_baker/baker_args_parser.mli index 9e58b64f5ef3..5f318c30bf1a 100644 --- a/src/proto_alpha/lib_agnostic_baker/baker_args_parser.mli +++ b/src/proto_alpha/lib_agnostic_baker/baker_args_parser.mli @@ -34,6 +34,8 @@ val parse_configuration : * Baking_configuration.state_recorder_config * Q.t option * Q.t option + * bool + * int (** [parse_baking_mode baking_mode] maps a optional value to a [Local] or [Remote] baking mode option. *) diff --git a/src/proto_alpha/lib_delegate/baking_commands.ml b/src/proto_alpha/lib_delegate/baking_commands.ml index c48320eeee80..1aecc3329305 100644 --- a/src/proto_alpha/lib_delegate/baking_commands.ml +++ b/src/proto_alpha/lib_delegate/baking_commands.ml @@ -682,6 +682,12 @@ let remote_calls_timeout_arg = try return (Q.of_string s) with _ -> failwith "remote-calls-timeout expected int or float.")) +let with_accuser_arg = + Tezos_clic.switch + ~long:"with-accuser" + ~doc:"If this flag is set, the accuser runs together with the baker." + () + let lookup_default_vote_file_path (cctxt : Protocol_client_context.full) = let open Lwt_syntax in let default_filename = Per_block_vote_file.default_vote_json_filename in @@ -737,7 +743,7 @@ let check_dal_node = type baking_mode = Local of {local_data_dir_path : string} | Remote let baker_args = - Tezos_clic.args17 + Tezos_clic.args19 pidfile_arg node_version_check_bypass_arg node_version_allowed_arg @@ -755,6 +761,34 @@ let baker_args = state_recorder_switch_arg pre_emptive_forge_time_arg remote_calls_timeout_arg + with_accuser_arg + preserved_levels_arg + +let start_async_accuser cctxt ~preserved_levels ~keep_alive = + let open Lwt_syntax in + let accuser = + let* r = + Client_daemon.Accuser.run + cctxt + ~chain:cctxt#chain + ~preserved_levels + ~keep_alive + in + match r with + | Ok () -> + let* () = Events.(emit accuser_finished) () in + Lwt.return_unit + | Error errs -> + let* () = + Events.( + emit + accuser_error + (Format.asprintf "%a@." Error_monad.pp_print_trace errs)) + in + Lwt.return_unit + in + Lwt.async (fun () -> accuser) ; + return_unit let run_baker ?(recommend_agnostic_baker = true) ( pidfile, @@ -773,7 +807,9 @@ let run_baker ?(recommend_agnostic_baker = true) without_dal, state_recorder, pre_emptive_forge_time, - remote_calls_timeout ) baking_mode sources cctxt = + remote_calls_timeout, + with_accuser, + preserved_levels ) baking_mode sources cctxt = let open Lwt_result_syntax in may_lock_pidfile pidfile @@ fun () -> let*! () = @@ -809,6 +845,10 @@ let run_baker ?(recommend_agnostic_baker = true) | Local {local_data_dir_path} -> Some local_data_dir_path | Remote -> None in + let*! () = + if with_accuser then start_async_accuser cctxt ~preserved_levels ~keep_alive + else Lwt.return_unit + in Client_daemon.Baker.run cctxt ?dal_node_rpc_ctxt diff --git a/src/proto_alpha/lib_delegate/baking_commands.mli b/src/proto_alpha/lib_delegate/baking_commands.mli index a733adf942a3..f667e3634d9f 100644 --- a/src/proto_alpha/lib_delegate/baking_commands.mli +++ b/src/proto_alpha/lib_delegate/baking_commands.mli @@ -43,7 +43,9 @@ val run_baker : * bool * Baking_configuration.state_recorder_config * Q.t option - * Q.t option -> + * Q.t option + * bool + * int -> baking_mode -> Environment.Signature.public_key_hash list -> Protocol_client_context.full -> diff --git a/src/proto_alpha/lib_delegate/baking_events.ml b/src/proto_alpha/lib_delegate/baking_events.ml index b2a41166f26c..4ae347b55244 100644 --- a/src/proto_alpha/lib_delegate/baking_events.ml +++ b/src/proto_alpha/lib_delegate/baking_events.ml @@ -128,6 +128,23 @@ module Commands = struct instead of `octez-baker-`, as it automatically handles \ protocol switches." () + + let accuser_finished = + declare_0 + ~section + ~level:Warning + ~name:"accuser_finished" + ~msg:"Accuser exited cleanly, continuing running the baker." + () + + let accuser_error = + declare_1 + ~section + ~level:Error + ~name:"accuser_error" + ~msg:"Accuser crashed with error {error}. Continuing running the baker." + ~pp1:Format.pp_print_string + ("error", Data_encoding.string) end module State_transitions = struct -- GitLab From 64fbea90c6ff3267cb4510f170d41c194b64fe86 Mon Sep 17 00:00:00 2001 From: Gabriel Moise Date: Thu, 1 May 2025 16:58:35 +0100 Subject: [PATCH 2/2] Tezt: Agnostic_baker: Add --with-accuser option --- tezt/lib_tezos/agnostic_baker.ml | 30 +++++++++++++++++++++++++----- tezt/lib_tezos/agnostic_baker.mli | 6 ++++++ tezt/tests/agnostic_baker_test.ml | 8 +++++--- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/tezt/lib_tezos/agnostic_baker.ml b/tezt/lib_tezos/agnostic_baker.ml index fae476c2df55..96a0c68c4b12 100644 --- a/tezt/lib_tezos/agnostic_baker.ml +++ b/tezt/lib_tezos/agnostic_baker.ml @@ -45,6 +45,8 @@ module Parameters = struct node_version_check_bypass : bool; node_version_allowed : string option; keep_alive : bool; + with_accuser : bool; + preserved_levels : int option; } type session_state = {mutable ready : bool} @@ -95,7 +97,8 @@ let create_from_uris ?runner ?(path = Uses.path Constant.octez_agnostic_baker) ?remote_mode ?operations_pool ?dal_node_rpc_endpoint ?dal_node_timeout_percentage ?(state_recorder = false) ?(node_version_check_bypass = false) ?node_version_allowed ~base_dir - ~node_data_dir ~node_rpc_endpoint ?(keep_alive = false) () = + ~node_data_dir ~node_rpc_endpoint ?(keep_alive = false) + ?(with_accuser = false) ?preserved_levels () = let remote_mode = Option.value remote_mode @@ -126,6 +129,8 @@ let create_from_uris ?runner ?(path = Uses.path Constant.octez_agnostic_baker) node_version_check_bypass; node_version_allowed; keep_alive; + with_accuser; + preserved_levels; } in agnostic_baker @@ -137,8 +142,8 @@ let create ?runner ?path ?name ?color ?event_pipe ?(delegates = []) ?votefile ?(liquidity_baking_toggle_vote = Some Pass) ?force_apply_from_round ?remote_mode ?operations_pool ?dal_node_rpc_endpoint ?dal_node_timeout_percentage ?(state_recorder = false) - ?(node_version_check_bypass = false) ?node_version_allowed ?keep_alive node - client = + ?(node_version_check_bypass = false) ?node_version_allowed ?keep_alive + ?with_accuser ?preserved_levels node client = let agnostic_baker = create_from_uris ?runner @@ -161,6 +166,8 @@ let create ?runner ?path ?name ?color ?event_pipe ?(delegates = []) ?votefile ~node_data_dir:(Node.data_dir node) ~node_rpc_endpoint:(Node.as_rpc_endpoint node) ?keep_alive + ?with_accuser + ?preserved_levels () in on_event agnostic_baker (handle_event agnostic_baker) ; @@ -238,6 +245,17 @@ let run_args agnostic_baker = "keep-alive" agnostic_baker.persistent_state.keep_alive in + let with_accuser = + Cli_arg.optional_switch + "with-accuser" + agnostic_baker.persistent_state.with_accuser + in + let preserved_levels = + Cli_arg.optional_arg + "preserved-levels" + string_of_int + agnostic_baker.persistent_state.preserved_levels + in let run_args = if agnostic_baker.persistent_state.remote_mode then ["remotely"] else ["with"; "local"; "node"; node_data_dir] @@ -246,7 +264,7 @@ let run_args agnostic_baker = @ run_args @ delegates @ liquidity_baking_toggle_vote @ votefile @ force_apply_from_round @ operations_pool @ dal_node_endpoint @ without_dal @ dal_node_timeout_percentage @ state_recorder @ node_version_check_bypass - @ node_version_allowed @ keep_alive + @ node_version_allowed @ keep_alive @ with_accuser @ preserved_levels let run ?env ?event_level ?event_sections_levels ?(extra_arguments = []) (agnostic_baker : t) = @@ -303,7 +321,7 @@ let init ?env ?runner ?(path = Uses.path Constant.octez_agnostic_baker) ?name ?votefile ?liquidity_baking_toggle_vote ?force_apply_from_round ?remote_mode ?operations_pool ?dal_node_rpc_endpoint ?dal_node_timeout_percentage ?state_recorder ?node_version_check_bypass ?node_version_allowed ?keep_alive - node client = + ?with_accuser ?preserved_levels node client = let* () = Node.wait_for_ready node in let agnostic_baker = create @@ -324,6 +342,8 @@ let init ?env ?runner ?(path = Uses.path Constant.octez_agnostic_baker) ?name ?node_version_allowed ~delegates ?keep_alive + ?with_accuser + ?preserved_levels node client in diff --git a/tezt/lib_tezos/agnostic_baker.mli b/tezt/lib_tezos/agnostic_baker.mli index 7344da7aeb8b..484d7340200b 100644 --- a/tezt/lib_tezos/agnostic_baker.mli +++ b/tezt/lib_tezos/agnostic_baker.mli @@ -148,6 +148,8 @@ val create : ?node_version_check_bypass:bool -> ?node_version_allowed:string -> ?keep_alive:bool -> + ?with_accuser:bool -> + ?preserved_levels:int -> Node.t -> Client.t -> t @@ -188,6 +190,8 @@ val create_from_uris : node_data_dir:string -> node_rpc_endpoint:Endpoint.t -> ?keep_alive:bool -> + ?with_accuser:bool -> + ?preserved_levels:int -> unit -> t @@ -248,6 +252,8 @@ val init : ?node_version_check_bypass:bool -> ?node_version_allowed:string -> ?keep_alive:bool -> + ?with_accuser:bool -> + ?preserved_levels:int -> Node.t -> Client.t -> t Lwt.t diff --git a/tezt/tests/agnostic_baker_test.ml b/tezt/tests/agnostic_baker_test.ml index 6d85078e84cf..3f55dc1ae23c 100644 --- a/tezt/tests/agnostic_baker_test.ml +++ b/tezt/tests/agnostic_baker_test.ml @@ -171,15 +171,16 @@ let migrate ~migrate_from ~migrate_to ~use_remote_signer = in unit -let test_start_and_stop () = +let test_start_and_stop ?(with_accuser = false) () = + let with_accuser_msg = if with_accuser then " with accuser" else "" in Test.register ~__FILE__ - ~title:"Agnostic baker starts and stops" + ~title:(Format.sprintf "Agnostic baker starts and stops%s" with_accuser_msg) ~tags:[team; "sandbox"; "agnostic"; "baker"; "init"] ~uses:[Constant.octez_agnostic_baker] @@ fun () -> let* node, client = Client.init_with_node `Client () in - let* baker = Agnostic_baker.init node client in + let* baker = Agnostic_baker.init node client ~with_accuser in let* () = Agnostic_baker.wait_for_ready baker in let* () = Agnostic_baker.terminate baker in unit @@ -280,4 +281,5 @@ let register_migration ~migrate_from ~migrate_to = let register_protocol_independent () = test_start_and_stop () ; + test_start_and_stop ~with_accuser:true () ; test_man () -- GitLab