mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-03 09:47:38 +00:00
Register blocks in validator monitor (#3635)
## 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>
This commit is contained in:
parent
9d6209725f
commit
266d765285
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user