From 11bc8cb2c0af39ec1bfc5845a376e17c5fe66c74 Mon Sep 17 00:00:00 2001 From: Eugen Zalinescu Date: Wed, 19 Feb 2025 09:28:23 +0100 Subject: [PATCH 1/2] DAL/Node: rename function for clarity --- src/bin_dal_node/daemon.ml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index 974828fba201..a12864b44190 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -444,7 +444,8 @@ module Handler = struct cells_of_level (* This functions counts, for each slot, the number of shards attested by the bakers. *) - let get_attestable_slots attestations committee ~number_of_slots is_attested = + let attested_shards_per_slot attestations committee ~number_of_slots + is_attested = let count_per_slot = Array.make number_of_slots 0 in List.iter (fun (_tb_slot, delegate_opt, _attestation_op, dal_attestation_opt) -> @@ -479,8 +480,8 @@ module Handler = struct Node_context.fetch_committee node_ctxt ~level:attestation_level in let attestations = get_attestations () in - let attestable_slots = - get_attestable_slots + let attested_shards_per_slot = + attested_shards_per_slot attestations committee ~number_of_slots:parameters.Types.number_of_slots @@ -491,7 +492,7 @@ module Handler = struct / parameters.cryptobox_parameters.redundancy_factor in let should_be_attested index = - let num_attested_shards = attestable_slots.(index) in + let num_attested_shards = attested_shards_per_slot.(index) in num_attested_shards >= threshold in let*! () = -- GitLab From 20baa0937f8727d626b3e57d1cca777fd0a5b944 Mon Sep 17 00:00:00 2001 From: Eugen Zalinescu Date: Wed, 19 Feb 2025 09:29:51 +0100 Subject: [PATCH 2/2] DAL/Node: replicate 'slot not attested' event for the traps case --- src/bin_dal_node/daemon.ml | 29 +++++++++++++++++++++++++---- src/bin_dal_node/event.ml | 23 +++++++++++++++++++++-- 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/bin_dal_node/daemon.ml b/src/bin_dal_node/daemon.ml index a12864b44190..5b4fef7778cc 100644 --- a/src/bin_dal_node/daemon.ml +++ b/src/bin_dal_node/daemon.ml @@ -495,6 +495,20 @@ module Handler = struct let num_attested_shards = attested_shards_per_slot.(index) in num_attested_shards >= threshold in + let contains_traps = + let store = Node_context.get_store node_ctxt in + let traps_store = Store.traps store in + let published_level = + Int32.(sub block_level (of_int parameters.attestation_lag)) + in + fun pkh index -> + if published_level <= 1l then false + else + Store.Traps.find traps_store ~level:published_level + |> List.exists (fun Store.Traps.{delegate; slot_index; _} -> + index = slot_index + && Signature.Public_key_hash.equal delegate pkh) + in let*! () = List.iter_s (fun (_, delegate_opt, _attestation_op, dal_attestation_opt) -> @@ -523,10 +537,17 @@ module Handler = struct should_be_attested index && not (is_attested bitset index) then - Event.emit_warn_attester_did_not_attest_slot - ~attester:delegate - ~slot_index:index - ~attested_level:block_level + if not (contains_traps delegate index) then + Event.emit_warn_attester_did_not_attest_slot + ~attester:delegate + ~slot_index:index + ~attested_level:block_level + else + Event + .emit_attester_did_not_attest_slot_because_of_traps + ~attester:delegate + ~slot_index:index + ~attested_level:block_level else Lwt.return_unit) (0 -- (parameters.number_of_slots - 1))) | None | Some _ -> diff --git a/src/bin_dal_node/event.ml b/src/bin_dal_node/event.ml index 86f7721ca01f..2955718e7d4a 100644 --- a/src/bin_dal_node/event.ml +++ b/src/bin_dal_node/event.ml @@ -757,14 +757,27 @@ open struct ~section ~name:"attester_did_not_attest_slot" ~msg: - "At level {attested_level}, slot index {slot_index} was attested but \ - shards from {attester} are missing" + "At level {attested_level}, slot index {slot_index} was sufficiently \ + attested, but shards from {attester} are missing" ~level:Warning ("attester", Signature.Public_key_hash.encoding) ("slot_index", Data_encoding.int31) ("attested_level", Data_encoding.int32) ~pp1:Signature.Public_key_hash.pp_short + let attester_did_not_attest_slot_because_of_traps = + declare_3 + ~section + ~name:"attester_did_not_attest_slot_with_traps" + ~msg: + "At level {attested_level}, slot index {slot_index} was sufficiently \ + attested, but {attester} did not attest because of traps" + ~level:Notice + ("attester", Signature.Public_key_hash.encoding) + ("slot_index", Data_encoding.int31) + ("attested_level", Data_encoding.int32) + ~pp1:Signature.Public_key_hash.pp_short + let trap_injection = declare_5 ~section @@ -1079,6 +1092,12 @@ let emit_warn_attester_did_not_attest_slot ~attester ~slot_index ~attested_level = emit warn_attester_did_not_attest_slot (attester, slot_index, attested_level) +let emit_attester_did_not_attest_slot_because_of_traps ~attester ~slot_index + ~attested_level = + emit + attester_did_not_attest_slot_because_of_traps + (attester, slot_index, attested_level) + let emit_trap_injection ~delegate ~published_level ~attested_level ~slot_index ~shard_index = emit -- GitLab