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
This commit is contained in:
Paul Hauner 2021-02-21 23:47:53 +00:00
parent 8949ae7c4e
commit 4362ea4f98

View File

@ -286,15 +286,23 @@ fn advance_head<T: BeaconChainTypes>(
.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",
);
}