From 4362ea4f98531bf4e7ccdd5b9d4b23472e615b84 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sun, 21 Feb 2021 23:47:53 +0000 Subject: [PATCH] Fix false positive "State advance too slow" logs (#2218) ## Issue Addressed - Resolves #2214 ## Proposed Changes Fix the false positive warning log described in #2214. ## Additional Info NA --- beacon_node/beacon_chain/src/state_advance_timer.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/beacon_node/beacon_chain/src/state_advance_timer.rs b/beacon_node/beacon_chain/src/state_advance_timer.rs index 260b9d0bc1..36bd9795cb 100644 --- a/beacon_node/beacon_chain/src/state_advance_timer.rs +++ b/beacon_node/beacon_chain/src/state_advance_timer.rs @@ -286,15 +286,23 @@ fn advance_head( .update_pre_state(head_root, state) .ok_or(Error::HeadMissingFromSnapshotCache(head_root))?; + // If we have moved into the next slot whilst processing the state then this function is going + // to become ineffective and likely become a hindrance as we're stealing the tree hash cache + // from the snapshot cache (which may force the next block to rebuild a new one). + // + // If this warning occurs very frequently on well-resourced machines then we should consider + // starting it earlier in the slot. Otherwise, it's a good indication that the machine is too + // slow/overloaded and will be useful information for the user. + let starting_slot = current_slot; let current_slot = beacon_chain.slot()?; - if final_slot <= current_slot { + if starting_slot < current_slot { warn!( log, "State advance too slow"; "head_root" => %head_root, "advanced_slot" => final_slot, "current_slot" => current_slot, - "initial_slot" => initial_slot, + "starting_slot" => starting_slot, "msg" => "system resources may be overloaded", ); }