Register blocks in validator monitor
## Issue Addressed
Closes
## Proposed Changes
`blocks` and `block_min_delay` are never updated in the epoch summary
@@ -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);
@@ -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)
@@ -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]);
@@ -704,6 +704,8 @@ impl<T: EthSpec> ValidatorMonitor<T> {
"src" => src,
"validator" => %id,
);
+
+ validator.with_epoch_summary(epoch, |summary| summary.register_block(delay));
}
}
