Skip to content

Commit

Permalink
Register blocks in validator monitor (#3635)
Browse files Browse the repository at this point in the history
## Issue Addressed

Closes #3460

## Proposed Changes

`blocks` and `block_min_delay` are never updated in the epoch summary



Co-authored-by: Michael Sproul <micsproul@gmail.com>
  • Loading branch information
tthebst and michaelsproul committed Nov 9, 2022
1 parent 9d62097 commit 266d765
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions beacon_node/beacon_chain/src/validator_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ impl EpochSummary {
}
}

pub fn register_block(&mut self, delay: Duration) {
self.blocks += 1;
Self::update_if_lt(&mut self.block_min_delay, delay);
}

pub fn register_unaggregated_attestation(&mut self, delay: Duration) {
self.attestations += 1;
Self::update_if_lt(&mut self.attestation_min_delay, delay);
Expand Down Expand Up @@ -613,13 +618,6 @@ impl<T: EthSpec> ValidatorMonitor<T> {
Ok(())
}

fn get_validator_id(&self, validator_index: u64) -> Option<&str> {
self.indices
.get(&validator_index)
.and_then(|pubkey| self.validators.get(pubkey))
.map(|validator| validator.id.as_str())
}

fn get_validator(&self, validator_index: u64) -> Option<&MonitoredValidator> {
self.indices
.get(&validator_index)
Expand Down Expand Up @@ -685,7 +683,9 @@ impl<T: EthSpec> ValidatorMonitor<T> {
block_root: Hash256,
slot_clock: &S,
) {
if let Some(id) = self.get_validator_id(block.proposer_index()) {
let epoch = block.slot().epoch(T::slots_per_epoch());
if let Some(validator) = self.get_validator(block.proposer_index()) {
let id = &validator.id;
let delay = get_block_delay_ms(seen_timestamp, block, slot_clock);

metrics::inc_counter_vec(&metrics::VALIDATOR_MONITOR_BEACON_BLOCK_TOTAL, &[src, id]);
Expand All @@ -704,6 +704,8 @@ impl<T: EthSpec> ValidatorMonitor<T> {
"src" => src,
"validator" => %id,
);

validator.with_epoch_summary(epoch, |summary| summary.register_block(delay));
}
}

Expand Down

0 comments on commit 266d765

Please sign in to comment.