Skip to content

Commit

Permalink
Fix cache logic for epoch boundary skips (sigp#4833)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul authored Oct 13, 2023
1 parent b77de69 commit b121e69
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions beacon_node/store/src/state_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,16 @@ impl<E: EthSpec> StateCache<E> {
let could_finalize =
(self.max_epoch - state.current_epoch()) <= EPOCH_FINALIZATION_LIMIT;

if is_advanced {
if is_boundary {
if could_finalize {
good_boundary_state_roots.push(state_root);
} else {
old_boundary_state_roots.push(state_root);
}
} else if is_advanced {
advanced_state_roots.push(state_root);
} else if !is_boundary {
mid_epoch_state_roots.push(state_root);
} else if !could_finalize {
old_boundary_state_roots.push(state_root);
} else {
good_boundary_state_roots.push(state_root);
mid_epoch_state_roots.push(state_root);
}

// Terminate early in the common case where we've already found enough junk to cull.
Expand All @@ -244,10 +246,7 @@ impl<E: EthSpec> StateCache<E> {

impl BlockMap {
fn insert(&mut self, block_root: Hash256, slot: Slot, state_root: Hash256) {
let slot_map = self
.blocks
.entry(block_root)
.or_default();
let slot_map = self.blocks.entry(block_root).or_default();
slot_map.slots.insert(slot, state_root);
}

Expand Down

0 comments on commit b121e69

Please sign in to comment.