Skip to content

Commit 5a3bcd2

Browse files
Validator monitor support for sync committees (#2476)
## Issue Addressed N/A ## Proposed Changes Add functionality in the validator monitor to provide sync committee related metrics for monitored validators. Co-authored-by: Michael Sproul <[email protected]>
1 parent 44fa540 commit 5a3bcd2

File tree

14 files changed

+564
-71
lines changed

14 files changed

+564
-71
lines changed

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,6 +2389,25 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
23892389
}
23902390
}
23912391

2392+
// Register sync aggregate with validator monitor
2393+
if let Some(sync_aggregate) = block.body().sync_aggregate() {
2394+
// `SyncCommittee` for the sync_aggregate should correspond to the duty slot
2395+
let duty_epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
2396+
let sync_committee = self.sync_committee_at_epoch(duty_epoch)?;
2397+
let participant_pubkeys = sync_committee
2398+
.pubkeys
2399+
.iter()
2400+
.zip(sync_aggregate.sync_committee_bits.iter())
2401+
.filter_map(|(pubkey, bit)| bit.then(|| pubkey))
2402+
.collect::<Vec<_>>();
2403+
2404+
validator_monitor.register_sync_aggregate_in_block(
2405+
block.slot(),
2406+
block.parent_root(),
2407+
participant_pubkeys,
2408+
);
2409+
}
2410+
23922411
for exit in block.body().voluntary_exits() {
23932412
validator_monitor.register_block_voluntary_exit(&exit.message)
23942413
}

beacon_node/beacon_chain/src/metrics.rs

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,48 @@ lazy_static! {
553553
"The number of attester slashings seen in the previous epoch.",
554554
&["validator"]
555555
);
556+
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_COMMITTEE_MESSAGES_TOTAL: Result<IntGaugeVec> =
557+
try_create_int_gauge_vec(
558+
"validator_monitor_prev_epoch_sync_committee_messages_total",
559+
"The number of sync committee messages seen in the previous epoch.",
560+
&["validator"]
561+
);
562+
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_COMMITTEE_MESSAGES_MIN_DELAY_SECONDS: Result<HistogramVec> =
563+
try_create_histogram_vec(
564+
"validator_monitor_prev_epoch_sync_committee_messages_min_delay_seconds",
565+
"The min delay between when the validator should send the sync committee message and when it was received.",
566+
&["validator"]
567+
);
568+
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_CONTRIBUTION_INCLUSIONS: Result<IntGaugeVec> =
569+
try_create_int_gauge_vec(
570+
"validator_monitor_prev_epoch_sync_contribution_inclusions",
571+
"The count of times a sync signature was seen inside a sync contribution.",
572+
&["validator"]
573+
);
574+
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_SIGNATURE_BLOCK_INCLUSIONS: Result<IntGaugeVec> =
575+
try_create_int_gauge_vec(
576+
"validator_monitor_prev_epoch_sync_signature_block_inclusions",
577+
"The count of times a sync signature was seen inside a block.",
578+
&["validator"]
579+
);
580+
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_CONTRIBUTIONS_TOTAL: Result<IntGaugeVec> =
581+
try_create_int_gauge_vec(
582+
"validator_monitor_prev_epoch_sync_contributions_total",
583+
"The number of sync contributions seen in the previous epoch.",
584+
&["validator"]
585+
);
586+
pub static ref VALIDATOR_MONITOR_PREV_EPOCH_SYNC_CONTRIBUTION_MIN_DELAY_SECONDS: Result<HistogramVec> =
587+
try_create_histogram_vec(
588+
"validator_monitor_prev_epoch_sync_contribution_min_delay_seconds",
589+
"The min delay between when the validator should send the sync contribution and when it was received.",
590+
&["validator"]
591+
);
592+
pub static ref VALIDATOR_MONITOR_VALIDATOR_IN_CURRENT_SYNC_COMMITTEE: Result<IntGaugeVec> =
593+
try_create_int_gauge_vec(
594+
"validator_monitor_validator_in_current_sync_committee",
595+
"Is the validator in the current sync committee (1 for true and 0 for false)",
596+
&["validator"]
597+
);
556598

557599
/*
558600
* Validator Monitor Metrics (real-time)
@@ -571,6 +613,26 @@ lazy_static! {
571613
"The delay between when the validator should send the attestation and when it was received.",
572614
&["src", "validator"]
573615
);
616+
pub static ref VALIDATOR_MONITOR_SYNC_COMMITTEE_MESSAGES_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
617+
"validator_monitor_sync_committee_messages_total",
618+
"Number of sync committee messages seen",
619+
&["src", "validator"]
620+
);
621+
pub static ref VALIDATOR_MONITOR_SYNC_COMMITTEE_MESSAGES_DELAY_SECONDS: Result<HistogramVec> = try_create_histogram_vec(
622+
"validator_monitor_sync_committee_messages_delay_seconds",
623+
"The delay between when the validator should send the sync committee message and when it was received.",
624+
&["src", "validator"]
625+
);
626+
pub static ref VALIDATOR_MONITOR_SYNC_CONTRIBUTIONS_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
627+
"validator_monitor_sync_contributions_total",
628+
"Number of sync contributions seen",
629+
&["src", "validator"]
630+
);
631+
pub static ref VALIDATOR_MONITOR_SYNC_COONTRIBUTIONS_DELAY_SECONDS: Result<HistogramVec> = try_create_histogram_vec(
632+
"validator_monitor_sync_contribtions_delay_seconds",
633+
"The delay between when the aggregator should send the sync contribution and when it was received.",
634+
&["src", "validator"]
635+
);
574636
pub static ref VALIDATOR_MONITOR_AGGREGATED_ATTESTATION_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
575637
"validator_monitor_aggregated_attestation_total",
576638
"Number of aggregated attestations seen",
@@ -586,6 +648,11 @@ lazy_static! {
586648
"Number of times an attestation has been seen in an aggregate",
587649
&["src", "validator"]
588650
);
651+
pub static ref VALIDATOR_MONITOR_SYNC_COMMITTEE_MESSAGE_IN_CONTRIBUTION_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
652+
"validator_monitor_sync_committee_message_in_contribution_total",
653+
"Number of times a sync committee message has been seen in a sync contribution",
654+
&["src", "validator"]
655+
);
589656
pub static ref VALIDATOR_MONITOR_ATTESTATION_IN_AGGREGATE_DELAY_SECONDS: Result<HistogramVec> = try_create_histogram_vec(
590657
"validator_monitor_attestation_in_aggregate_delay_seconds",
591658
"The delay between when the validator should send the aggregate and when it was received.",
@@ -596,6 +663,11 @@ lazy_static! {
596663
"Number of times an attestation has been seen in a block",
597664
&["src", "validator"]
598665
);
666+
pub static ref VALIDATOR_MONITOR_SYNC_COMMITTEE_MESSAGE_IN_BLOCK_TOTAL: Result<IntCounterVec> = try_create_int_counter_vec(
667+
"validator_monitor_sync_committee_message_in_block_total",
668+
"Number of times a validator's sync committee message has been seen in a sync aggregate",
669+
&["src", "validator"]
670+
);
599671
pub static ref VALIDATOR_MONITOR_ATTESTATION_IN_BLOCK_DELAY_SLOTS: Result<IntGaugeVec> = try_create_int_gauge_vec(
600672
"validator_monitor_attestation_in_block_delay_slots",
601673
"The excess slots (beyond the minimum delay) between the attestation slot and the block slot.",

beacon_node/beacon_chain/src/sync_committee_verification.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ impl From<ContributionError> for Error {
251251
#[derivative(Clone(bound = "T: BeaconChainTypes"))]
252252
pub struct VerifiedSyncContribution<T: BeaconChainTypes> {
253253
signed_aggregate: SignedContributionAndProof<T::EthSpec>,
254+
participant_pubkeys: Vec<PublicKeyBytes>,
254255
}
255256

256257
/// Wraps a `SyncCommitteeMessage` that has been verified for propagation on the gossip network.
@@ -385,7 +386,10 @@ impl<T: BeaconChainTypes> VerifiedSyncContribution<T> {
385386
slot: contribution.slot,
386387
});
387388
}
388-
Ok(VerifiedSyncContribution { signed_aggregate })
389+
Ok(VerifiedSyncContribution {
390+
signed_aggregate,
391+
participant_pubkeys,
392+
})
389393
}
390394

391395
/// A helper function to add this aggregate to `beacon_chain.op_pool`.
@@ -402,6 +406,11 @@ impl<T: BeaconChainTypes> VerifiedSyncContribution<T> {
402406
pub fn aggregate(&self) -> &SignedContributionAndProof<T::EthSpec> {
403407
&self.signed_aggregate
404408
}
409+
410+
/// Returns the pubkeys of all validators that are included in the aggregate.
411+
pub fn participant_pubkeys(&self) -> &[PublicKeyBytes] {
412+
&self.participant_pubkeys
413+
}
405414
}
406415

407416
impl VerifiedSyncCommitteeMessage {

0 commit comments

Comments
 (0)