diff --git a/src/lib_agnostic_baker/configuration.ml b/src/lib_agnostic_baker/configuration.ml index d0a9667f630d921342666718297c77d2a3cb6890..dd1083aa886d8e9ae49e3511760cbf72b1b1767d 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 32e77234a5bd974f93f6c6ac84048b062fd8e8ab..23e215415c130662ab2d489fa45e7b73317a14ef 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 764f7803957a129ff4aa855a8007458ecc8acef8..9ce014e0533bf01bcd00de55f7a876b2cdad0a83 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 cd2af5efebd562170e7f458e26eee4aaf5da8f11..01d062a4ac47b87f4753c29138ad9294ffff89a7 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 da310b94a93f69d1c0553e66cdd491f39d3273f4..3d039ff2feaaa19de42bed4a8e9927f96977a59d 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 a733adf942a3b5d500aca6d5a1155b6c8563715d..f667e3634d9fd75b4522bd59278e5e7c93ffe9c2 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 e8be873ba04eb2b2928c9df87e9ec3c63921cd0d..f5def3d9061ca33b8404bf232c1fb28a46f64c99 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 764f7803957a129ff4aa855a8007458ecc8acef8..9ce014e0533bf01bcd00de55f7a876b2cdad0a83 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 cd2af5efebd562170e7f458e26eee4aaf5da8f11..01d062a4ac47b87f4753c29138ad9294ffff89a7 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 7e3312c9c41fa0ea06f560078d55b73f5eeb1db7..71a57d89e335b04ada6f901b602f6afdfa1b3c10 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 a733adf942a3b5d500aca6d5a1155b6c8563715d..f667e3634d9fd75b4522bd59278e5e7c93ffe9c2 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 ffb9d2bb00b2c080f585cc859d1330f6d5c4a959..3d1dcb687f176c10d1e6ceafd9ddc3794817e45b 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 3ea1a51283a98eae97561e9f6fd54c19bab467ac..ba823d22f7c878878450b82687d54ffcabe23b6f 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 9e58b64f5ef33a08e520bfb036b29cd8a69ce121..5f318c30bf1af9a9a84d66cca7a3b39fdaa6db16 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 c48320eeee806392fd5747402bbe1053f1c7b10b..1aecc33293059ba30f36627697364cb5c5fded8d 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 a733adf942a3b5d500aca6d5a1155b6c8563715d..f667e3634d9fd75b4522bd59278e5e7c93ffe9c2 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 b2a41166f26cfed74b2b347d47920ecedb95e87c..4ae347b55244e5ac6b15aba727f77af1a9b13e1f 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 diff --git a/tezt/lib_tezos/agnostic_baker.ml b/tezt/lib_tezos/agnostic_baker.ml index fae476c2df55091ae7aed3d5e4773589839278a9..96a0c68c4b12dd2e53f6302a1769722a060086be 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 7344da7aeb8b6f0406e15737b8e6af06e544df6b..484d7340200bac0e768929205b907426abc17967 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 6d85078e84cf58c1c0fcdc1cef0ef15460aadf25..3f55dc1ae23cd4004b6cf325e2c799580d2b17ff 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 ()