From 091ac07af9ddd1e98b1717c6e084ad454bc6d4f9 Mon Sep 17 00:00:00 2001 From: pscott <30843220+pscott@users.noreply.github.com> Date: Wed, 30 Oct 2019 09:20:40 +0100 Subject: [PATCH] Warn during long beacon state skips (#566) * Add warn whenever trying to skip more than 3 blocks * Define block skipping threshold warning as const * Fix cargo fmt --- beacon_node/beacon_chain/src/beacon_chain.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index df0a3f80d..7385edb00 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -44,6 +44,8 @@ pub const GRAFFITI: &str = "sigp/lighthouse-0.0.0-prerelease"; /// Only useful for testing. const WRITE_BLOCK_PROCESSING_SSZ: bool = cfg!(feature = "write_ssz_files"); +const BLOCK_SKIPPING_LOGGING_THRESHOLD: u64 = 3; + #[derive(Debug, PartialEq)] pub enum BlockProcessingOutcome { /// Block was valid and imported into the block graph. @@ -374,6 +376,14 @@ impl BeaconChain { if slot == head_state.slot { Ok(head_state) } else if slot > head_state.slot { + if slot > head_state.slot + BLOCK_SKIPPING_LOGGING_THRESHOLD { + warn!( + self.log, + "Skipping more than {} blocks", BLOCK_SKIPPING_LOGGING_THRESHOLD; + "head_slot" => head_state.slot, + "request_slot" => slot + ) + } let head_state_slot = head_state.slot; let mut state = head_state; while state.slot < slot {