From 997095fc434cc447400c22e4791bee85e66fd28c Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 1 Jun 2019 15:29:13 +1000 Subject: [PATCH] Add attestations per block metric --- beacon_node/beacon_chain/src/beacon_chain.rs | 32 +------------------- beacon_node/beacon_chain/src/metrics.rs | 9 ++++++ 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 64cd8ddfc..63a00747e 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -345,37 +345,6 @@ impl BeaconChain { 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) -> 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 /// updated to match the current slot clock. pub fn current_state(&self) -> RwLockReadGuard> { @@ -732,6 +701,7 @@ impl BeaconChain { self.fork_choice()?; self.metrics.block_processing_successes.inc(); + self.metrics.operations_per_block_attestation.observe(block.body.attestations.len() as f64); timer.observe_duration(); Ok(BlockProcessingOutcome::ValidBlock(ValidBlock::Processed)) diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index a3c8553a1..fa1718ebf 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -18,6 +18,7 @@ pub struct Metrics { pub fork_choice_changed_head: IntCounter, pub fork_choice_reorg_count: IntCounter, pub fork_choice_times: Histogram, + pub operations_per_block_attestation: Histogram, } impl Metrics { @@ -108,6 +109,13 @@ impl Metrics { let opts = HistogramOpts::new("fork_choice_time", "total_time_to_run_fork_choice"); 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_reorg_count.clone()))?; registry.register(Box::new(self.fork_choice_times.clone()))?; + registry.register(Box::new(self.operations_per_block_attestation.clone()))?; Ok(()) }