Add attestations per block metric
This commit is contained in:
parent
244ffbc604
commit
997095fc43
@ -345,37 +345,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
/// Updates the canonical `BeaconState` with the supplied state.
|
|
||||||
///
|
|
||||||
/// Advances the chain forward to the present slot. This method is better than just setting
|
|
||||||
/// state and calling `catchup_state` as it will not result in an old state being installed and
|
|
||||||
/// then having it iteratively updated -- in such a case it's possible for another thread to
|
|
||||||
/// find the state at an old slot.
|
|
||||||
///
|
|
||||||
/// Also persists the `BeaconChain` to the store, in the case the client does not exit
|
|
||||||
/// gracefully.
|
|
||||||
fn update_state(&self, mut state: BeaconState<T::EthSpec>) -> Result<(), Error> {
|
|
||||||
let present_slot = match self.slot_clock.present_slot() {
|
|
||||||
Ok(Some(slot)) => slot,
|
|
||||||
_ => return Err(Error::UnableToReadSlot),
|
|
||||||
};
|
|
||||||
|
|
||||||
// If required, transition the new state to the present slot.
|
|
||||||
for _ in state.slot.as_u64()..present_slot.as_u64() {
|
|
||||||
per_slot_processing(&mut state, &T::EthSpec::spec())?;
|
|
||||||
}
|
|
||||||
|
|
||||||
state.build_all_caches(&T::EthSpec::spec())?;
|
|
||||||
|
|
||||||
*self.state.write() = state;
|
|
||||||
|
|
||||||
self.persist()?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// Returns a read-lock guarded `BeaconState` which is the `canonical_head` that has been
|
/// Returns a read-lock guarded `BeaconState` which is the `canonical_head` that has been
|
||||||
/// updated to match the current slot clock.
|
/// updated to match the current slot clock.
|
||||||
pub fn current_state(&self) -> RwLockReadGuard<BeaconState<T::EthSpec>> {
|
pub fn current_state(&self) -> RwLockReadGuard<BeaconState<T::EthSpec>> {
|
||||||
@ -732,6 +701,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
self.fork_choice()?;
|
self.fork_choice()?;
|
||||||
|
|
||||||
self.metrics.block_processing_successes.inc();
|
self.metrics.block_processing_successes.inc();
|
||||||
|
self.metrics.operations_per_block_attestation.observe(block.body.attestations.len() as f64);
|
||||||
timer.observe_duration();
|
timer.observe_duration();
|
||||||
|
|
||||||
Ok(BlockProcessingOutcome::ValidBlock(ValidBlock::Processed))
|
Ok(BlockProcessingOutcome::ValidBlock(ValidBlock::Processed))
|
||||||
|
@ -18,6 +18,7 @@ pub struct Metrics {
|
|||||||
pub fork_choice_changed_head: IntCounter,
|
pub fork_choice_changed_head: IntCounter,
|
||||||
pub fork_choice_reorg_count: IntCounter,
|
pub fork_choice_reorg_count: IntCounter,
|
||||||
pub fork_choice_times: Histogram,
|
pub fork_choice_times: Histogram,
|
||||||
|
pub operations_per_block_attestation: Histogram,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Metrics {
|
impl Metrics {
|
||||||
@ -108,6 +109,13 @@ impl Metrics {
|
|||||||
let opts = HistogramOpts::new("fork_choice_time", "total_time_to_run_fork_choice");
|
let opts = HistogramOpts::new("fork_choice_time", "total_time_to_run_fork_choice");
|
||||||
Histogram::with_opts(opts)?
|
Histogram::with_opts(opts)?
|
||||||
},
|
},
|
||||||
|
operations_per_block_attestation: {
|
||||||
|
let opts = HistogramOpts::new(
|
||||||
|
"operations_per_block_attestation",
|
||||||
|
"count_of_attestations_per_block",
|
||||||
|
);
|
||||||
|
Histogram::with_opts(opts)?
|
||||||
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,6 +136,7 @@ impl Metrics {
|
|||||||
registry.register(Box::new(self.fork_choice_changed_head.clone()))?;
|
registry.register(Box::new(self.fork_choice_changed_head.clone()))?;
|
||||||
registry.register(Box::new(self.fork_choice_reorg_count.clone()))?;
|
registry.register(Box::new(self.fork_choice_reorg_count.clone()))?;
|
||||||
registry.register(Box::new(self.fork_choice_times.clone()))?;
|
registry.register(Box::new(self.fork_choice_times.clone()))?;
|
||||||
|
registry.register(Box::new(self.operations_per_block_attestation.clone()))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user