Skip to content

Conversation

eserilev
Copy link
Member

@eserilev eserilev commented Mar 3, 2025

Added a new flag update_cache to get_state. When set to false, prevent writing fetched state to the cache

@@ -821,7 +821,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.get_blinded_block(&block_root)?
.ok_or(Error::MissingBeaconBlock(block_root))?;
let state = self
.get_state(&block.state_root(), Some(block.slot()))?
.get_state(&block.state_root(), Some(block.slot()), true)?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only used in tests so doesn't matter

.get_state(
&genesis_block.state_root(),
Some(genesis_block.slot()),
true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ok as we almost always have the genesis state in the freezer

- 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
@michaelsproul michaelsproul merged commit defdc59 into sigp:holesky-rescue Mar 4, 2025
12 of 23 checks passed
@michaelsproul michaelsproul added the v7.0.0-beta.2 Second hacky Holesky rescue release label Mar 5, 2025
@michaelsproul michaelsproul mentioned this pull request Mar 5, 2025
14 tasks
@michaelsproul
Copy link
Member

I'll PR this to release-v7.0.0 with a Co-author tag for you @eserilev

michaelsproul added a commit to michaelsproul/lighthouse that referenced this pull request Mar 10, 2025
* add an update_cache flag to get_state to have more granular control over when we write to the cache

* State cache tweaks

- 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

---------

Co-authored-by: Michael Sproul <michael@sigmaprime.io>
mergify bot pushed a commit that referenced this pull request Mar 18, 2025
Backport of:

- #7067

For:

- #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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v7.0.0-beta.2 Second hacky Holesky rescue release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants