From 834f8f8034bbd9a68e3fd6064461a3cff0024508 Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Mon, 22 Sep 2025 16:38:08 +0200 Subject: [PATCH 1/3] Tezt/Baker: reduce log verbosity --- tezt/lib_tezos/agnostic_baker.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tezt/lib_tezos/agnostic_baker.ml b/tezt/lib_tezos/agnostic_baker.ml index f9833b4bd431..42b609c2339b 100644 --- a/tezt/lib_tezos/agnostic_baker.ml +++ b/tezt/lib_tezos/agnostic_baker.ml @@ -132,12 +132,11 @@ let create_from_uris ?runner ?(path = Uses.path Constant.octez_agnostic_baker) agnostic_baker let handle_event node ({name; _} : event) = - Log.debug "Handling event for %s: %s" node.name name ; match name with | "starting_daemon.v0" -> Log.info "Baker %s received starting_daemon event" node.name ; set_ready node - | _ -> Log.debug "Ignoring unhandled event: %s" name + | _ -> () let create ?runner ?path ?name ?color ?event_pipe ?(delegates = []) ?votefile ?(liquidity_baking_toggle_vote = Some Pass) ?force_apply_from_round -- GitLab From be3815989e421fef5d67585f193f67b64557935a Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Mon, 22 Sep 2025 16:38:24 +0200 Subject: [PATCH 2/3] Tezt/Accuser: expose bug with regression test --- tezt/tests/agnostic_baker_test.ml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/tezt/tests/agnostic_baker_test.ml b/tezt/tests/agnostic_baker_test.ml index 6b57df0768a7..f7394e242614 100644 --- a/tezt/tests/agnostic_baker_test.ml +++ b/tezt/tests/agnostic_baker_test.ml @@ -33,10 +33,22 @@ let wait_for_become_old_baker agnostic_baker = Agnostic_baker.wait_for agnostic_baker "become_old_agent.v0" (fun _json -> Some ()) +let wait_for_become_old_accuser accuser = + Lwt.pick + [ + (let* () = Lwt_unix.sleep 60. in + Test.fail + "[wait_for_become_old_baker] has waited for 60 seconds, exiting"); + Accuser.wait_for accuser "become_old_agent.v0" (fun _json -> Some ()); + ] + let wait_for_stopping_baker agnostic_baker = Agnostic_baker.wait_for agnostic_baker "stopping_agent.v0" (fun _json -> Some ()) +let wait_for_stopping_accuser accuser = + Accuser.wait_for accuser "stopping_agent.v0" (fun _json -> Some ()) + let remote_sign client = let* () = Client.forget_all_keys client in let keys = Constant.activator :: (Account.Bootstrap.keys |> Array.to_list) in @@ -66,11 +78,15 @@ let perform_protocol_migration ?node_name ?client_name ?parameter_file let* () = if use_remote_signer then remote_sign client else unit in Log.info "Node %s initialized" (Node.name node) ; let baker = Agnostic_baker.create node client in + let accuser = Accuser.create node in let wait_for_active_protocol_waiting = wait_for_active_protocol_waiting baker in Log.info "Starting agnostic baker" ; let* () = Agnostic_baker.run baker in + Log.info "Starting agnostic accuser" ; + let* () = Accuser.run accuser in + let* () = wait_for_active_protocol_waiting in let* () = Agnostic_baker.wait_for_ready baker in let* () = @@ -84,10 +100,12 @@ let perform_protocol_migration ?node_name ?client_name ?parameter_file Log.info "Baking at least %d blocks to trigger migration" migration_level ; let* _level = Node.wait_for_level node migration_level in let wait_for_become_old_baker = wait_for_become_old_baker baker in + let wait_for_become_old_accuser = wait_for_become_old_accuser accuser in Log.info "Check that the baking process for %s is not killed" (Protocol.tag migrate_from) ; let* () = wait_for_become_old_baker in + let* () = wait_for_become_old_accuser in (* Ensure that the block before migration is consistent *) Log.info "Checking migration block consistency" ; let* () = @@ -114,15 +132,17 @@ let perform_protocol_migration ?node_name ?client_name ?parameter_file (Protocol.tag migrate_from) Agnostic_baker.extra_levels_for_old_baker ; let wait_for_stopping_baker = wait_for_stopping_baker baker in + let wait_for_stopping_accuser = wait_for_stopping_accuser accuser in let* _level = Node.wait_for_level node (migration_level + Agnostic_baker.extra_levels_for_old_baker) in - let* () = wait_for_stopping_baker in + let* () = wait_for_stopping_baker and* () = wait_for_stopping_accuser in (* Test that we can still bake after migration *) let* _level = Node.wait_for_level node baked_blocks_after_migration in - let* () = Agnostic_baker.terminate baker in + let* () = Agnostic_baker.terminate baker + and* () = Accuser.terminate accuser in unit let migrate ~migrate_from ~migrate_to ~use_remote_signer = @@ -150,7 +170,8 @@ let migrate ~migrate_from ~migrate_to ~use_remote_signer = Protocol.tag migrate_from; Protocol.tag migrate_to; ] - ~uses:([Constant.octez_agnostic_baker] @ remote_signer) + ~uses: + ([Constant.octez_agnostic_baker; Constant.octez_accuser] @ remote_signer) @@ fun () -> let blocks_per_cycle = JSON.(get "blocks_per_cycle" parameters |> as_int) in let consensus_rights_delay = -- GitLab From 4bb84a81a2f42451f02d82b7b5e4f2b065166625 Mon Sep 17 00:00:00 2001 From: Valentin Chaboche Date: Sun, 19 Jul 2026 15:09:18 +0200 Subject: [PATCH 3/3] Agnostic/Baker/Accuser: tzboth instead of pick [Lwt.pick] resolves as soon as one of the promise resolves. In theory it's fine, but in our case, the pick has 2 promises: 1. The agent thread 2. The voting monitor thread that may restart (1.) If the agent thread resolves (and not fail), the `Lwt.pick` resolves and the agnostic agent is stopped. Whereas, if the agent resolves around migration time, we need (2.) to start the new thread. --- src/lib_agnostic_baker/daemon.ml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/lib_agnostic_baker/daemon.ml b/src/lib_agnostic_baker/daemon.ml index 665873610373..790699f9dae8 100644 --- a/src/lib_agnostic_baker/daemon.ml +++ b/src/lib_agnostic_baker/daemon.ml @@ -455,19 +455,16 @@ module Make_daemon (Agent : AGENT) : in (* Monitoring voting periods through heads monitoring to avoid missing UAUs. *) - let* () = - Lwt.pick - [ - (* We do not care if --keep-alive is provided, if the baker thread doesn't + let* (), () = + tzboth + (* We do not care if --keep-alive is provided, if the baker thread doesn't have the argument it'll abort the process anyway. *) - retry_on_disconnection - ~emit:(fun _ -> Lwt.return_unit) - node_addr - monitor_voting_periods; - baker_thread ~state; - ] + (retry_on_disconnection + ~emit:(fun _ -> Lwt.return_unit) + node_addr + monitor_voting_periods) + (baker_thread ~state) in - let*! () = Lwt_utils.never_ending () in return_unit end -- GitLab