From 8a0d08105bf23c468de368a39000e516d7340746 Mon Sep 17 00:00:00 2001 From: Guillaume Genestier Date: Tue, 10 Dec 2024 12:49:35 +0100 Subject: [PATCH] Baker: Notice when a delegate has no slots at at current level Co-authored-by: Eugen Zalinescu Co-authored-by: Albin Coquereau --- .../lib_delegate/baking_actions.ml | 18 ++++++++++++++++++ .../lib_delegate/baking_events.ml | 13 +++++++++++++ .../lib_delegate/baking_actions.ml | 18 ++++++++++++++++++ .../lib_delegate/baking_events.ml | 13 +++++++++++++ src/proto_alpha/lib_delegate/baking_actions.ml | 18 ++++++++++++++++++ src/proto_alpha/lib_delegate/baking_events.ml | 13 +++++++++++++ 6 files changed, 93 insertions(+) diff --git a/src/proto_020_PsParisC/lib_delegate/baking_actions.ml b/src/proto_020_PsParisC/lib_delegate/baking_actions.ml index 7da52063ad06..88a04f07e34e 100644 --- a/src/proto_020_PsParisC/lib_delegate/baking_actions.ml +++ b/src/proto_020_PsParisC/lib_delegate/baking_actions.ml @@ -918,6 +918,21 @@ let compute_round proposal round_durations = ~predecessor_round:predecessor_block.round ~timestamp +let notice_delegates_without_slots all_delegates delegate_slots level = + let delegates_without_slots = + List.filter + (fun {Baking_state.public_key_hash; _} -> + not + @@ List.exists + (fun {consensus_key_and_delegate = _, pkh_with_rights; _} -> + public_key_hash = pkh_with_rights) + (Baking_state.Delegate_slots.own_delegates delegate_slots)) + all_delegates + in + match delegates_without_slots with + | [] -> Lwt.return_unit + | delegates -> Events.(emit delegates_without_slots (delegates, level)) + let update_to_level state level_update = let open Lwt_result_syntax in let {new_level_proposal; compute_new_state} = level_update in @@ -951,6 +966,9 @@ let update_to_level state level_update = ~chain [@profiler.record_s {verbosity = Debug} "compute current delegate slots"]) in + let*! () = + notice_delegates_without_slots delegates delegate_slots new_level + in let round_durations = state.global_state.round_durations in let*? current_round = (compute_round diff --git a/src/proto_020_PsParisC/lib_delegate/baking_events.ml b/src/proto_020_PsParisC/lib_delegate/baking_events.ml index 54cf06abf989..b8b63d256938 100644 --- a/src/proto_020_PsParisC/lib_delegate/baking_events.ml +++ b/src/proto_020_PsParisC/lib_delegate/baking_events.ml @@ -1068,6 +1068,19 @@ module Actions = struct ~msg:"Signature call failed with {errors}" ~pp1:pp_print_top_error_of_trace ("errors", Error_monad.(TzTrace.encoding error_encoding)) + + let delegates_without_slots = + declare_2 + ~section + ~name:"delegates_without_slots" + ~level:Notice + ~msg: + "The following delegates have no attesting rights at level {level}: \ + {delegates}" + ~pp1:(Format.pp_print_list Baking_state.pp_consensus_key) + ("delegates", Data_encoding.list Baking_state.consensus_key_encoding) + ~pp2:pp_int32 + ("level", Data_encoding.int32) end module VDF = struct diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_actions.ml b/src/proto_021_PsQuebec/lib_delegate/baking_actions.ml index 90cbfa113784..f4274807613f 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_actions.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_actions.ml @@ -920,6 +920,21 @@ let compute_round proposal round_durations = ~predecessor_round:predecessor_block.round ~timestamp +let notice_delegates_without_slots all_delegates delegate_slots level = + let delegates_without_slots = + List.filter + (fun {Baking_state.public_key_hash; _} -> + not + @@ List.exists + (fun {consensus_key_and_delegate = _, pkh_with_rights; _} -> + public_key_hash = pkh_with_rights) + (Baking_state.Delegate_slots.own_delegates delegate_slots)) + all_delegates + in + match delegates_without_slots with + | [] -> Lwt.return_unit + | delegates -> Events.(emit delegates_without_slots (delegates, level)) + let update_to_level state level_update = let open Lwt_result_syntax in let {new_level_proposal; compute_new_state} = level_update in @@ -953,6 +968,9 @@ let update_to_level state level_update = ~chain [@profiler.record_s {verbosity = Debug} "compute current delegate slots"]) in + let*! () = + notice_delegates_without_slots delegates delegate_slots new_level + in let round_durations = state.global_state.round_durations in let*? current_round = (compute_round diff --git a/src/proto_021_PsQuebec/lib_delegate/baking_events.ml b/src/proto_021_PsQuebec/lib_delegate/baking_events.ml index 334fc83fefae..8d418a7522d9 100644 --- a/src/proto_021_PsQuebec/lib_delegate/baking_events.ml +++ b/src/proto_021_PsQuebec/lib_delegate/baking_events.ml @@ -1071,6 +1071,19 @@ module Actions = struct ~msg:"Signature call failed with {errors}" ~pp1:pp_print_top_error_of_trace ("errors", Error_monad.(TzTrace.encoding error_encoding)) + + let delegates_without_slots = + declare_2 + ~section + ~name:"delegates_without_slots" + ~level:Notice + ~msg: + "The following delegates have no attesting rights at level {level}: \ + {delegates}" + ~pp1:(Format.pp_print_list Baking_state.pp_consensus_key) + ("delegates", Data_encoding.list Baking_state.consensus_key_encoding) + ~pp2:pp_int32 + ("level", Data_encoding.int32) end module VDF = struct diff --git a/src/proto_alpha/lib_delegate/baking_actions.ml b/src/proto_alpha/lib_delegate/baking_actions.ml index a141ef812d42..726dc29335ad 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.ml +++ b/src/proto_alpha/lib_delegate/baking_actions.ml @@ -931,6 +931,21 @@ let compute_round (proposal : proposal) round_durations = ~predecessor_round:predecessor_block.round ~timestamp +let notice_delegates_without_slots all_delegates delegate_slots level = + let delegates_without_slots = + List.filter + (fun {Baking_state.public_key_hash; _} -> + not + @@ List.exists + (fun {consensus_key_and_delegate = _, pkh_with_rights; _} -> + public_key_hash = pkh_with_rights) + (Baking_state.Delegate_slots.own_delegates delegate_slots)) + all_delegates + in + match delegates_without_slots with + | [] -> Lwt.return_unit + | delegates -> Events.(emit delegates_without_slots (delegates, level)) + let update_to_level state level_update = let open Lwt_result_syntax in let {new_level_proposal; compute_new_state} = level_update in @@ -964,6 +979,9 @@ let update_to_level state level_update = ~chain [@profiler.record_s {verbosity = Debug} "compute current delegate slots"]) in + let*! () = + notice_delegates_without_slots delegates delegate_slots new_level + in let round_durations = state.global_state.round_durations in let*? current_round = (compute_round diff --git a/src/proto_alpha/lib_delegate/baking_events.ml b/src/proto_alpha/lib_delegate/baking_events.ml index fde49c5171c2..14c756611308 100644 --- a/src/proto_alpha/lib_delegate/baking_events.ml +++ b/src/proto_alpha/lib_delegate/baking_events.ml @@ -1061,6 +1061,19 @@ module Actions = struct ~msg:"Signature call failed with {errors}" ~pp1:pp_print_top_error_of_trace ("errors", Error_monad.(TzTrace.encoding error_encoding)) + + let delegates_without_slots = + declare_2 + ~section + ~name:"delegates_without_slots" + ~level:Notice + ~msg: + "The following delegates have no attesting rights at level {level}: \ + {delegates}" + ~pp1:(Format.pp_print_list Baking_state.pp_consensus_key) + ("delegates", Data_encoding.list Baking_state.consensus_key_encoding) + ~pp2:pp_int32 + ("level", Data_encoding.int32) end module VDF = struct -- GitLab