mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 13:28:33 +00:00
State cache tweaks (#7095)
Backport of: - https://github.com/sigp/lighthouse/pull/7067 For: - https://github.com/sigp/lighthouse/issues/7039 - Prevent writing to state cache when migrating the database - Add `state-cache-headroom` flag to control pruning - Prune old epoch boundary states ahead of mid-epoch states - Never prune head block's state - Avoid caching ancestor states unless they are on an epoch boundary - Log when states enter/exit the cache Co-authored-by: Eitan Seri-Levi <eserilev@ucsc.edu>
This commit is contained in:
@@ -58,8 +58,10 @@ pub fn get_state_before_applying_block<T: BeaconChainTypes>(
|
||||
})
|
||||
.map_err(|e| custom_not_found(format!("Parent block is not available! {:?}", e)))?;
|
||||
|
||||
// We are about to apply a new block to the chain. It's parent state
|
||||
// is a useful/recent state, we elect to cache it.
|
||||
let parent_state = chain
|
||||
.get_state(&parent_block.state_root(), Some(parent_block.slot()))
|
||||
.get_state(&parent_block.state_root(), Some(parent_block.slot()), true)
|
||||
.and_then(|maybe_state| {
|
||||
maybe_state
|
||||
.ok_or_else(|| BeaconChainError::MissingBeaconState(parent_block.state_root()))
|
||||
|
||||
Reference in New Issue
Block a user