Skip to content

Commit

Permalink
Clarify comment and remove anchor_slot garbage
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul committed Sep 16, 2024
1 parent 5d3a83d commit 3d90ac6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 6 additions & 2 deletions beacon_node/store/src/hdiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,12 @@ impl HierarchyModuli {

/// Return `true` if the database ops for this slot should be committed immediately.
///
/// This is the case for all diffs in the 2nd lowest layer and above, which are required by diffs
/// in the 1st layer.
/// This is the case for all diffs aside from the ones in the leaf layer. To store a diff
/// might require loading the state at the previous layer, in which case the diff for that
/// layer must already have been stored.
///
/// In future we may be able to handle this differently (with proper transaction semantics
/// rather than LevelDB's "write batches").
pub fn should_commit_immediately(&self, slot: Slot) -> Result<bool, Error> {
// If there's only 1 layer of snapshots, then commit only when writing a snapshot.
self.moduli.get(1).map_or_else(
Expand Down
6 changes: 1 addition & 5 deletions beacon_node/store/src/hot_cold_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2914,7 +2914,6 @@ pub fn migrate_database<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>(
// boundary (in order for the hot state summary scheme to work).
let current_split_slot = store.split.read_recursive().slot;
let anchor_info = store.anchor_info.read_recursive().clone();
let anchor_slot = anchor_info.as_ref().map(|a| a.anchor_slot);

if finalized_state.slot() < current_split_slot {
return Err(HotColdDBError::FreezeSlotError {
Expand All @@ -2938,10 +2937,7 @@ pub fn migrate_database<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>(
// Iterate in descending order until the current split slot
let state_roots = RootsIterator::new(&store, finalized_state)
.take_while(|result| match result {
Ok((_, _, slot)) => {
slot >= &current_split_slot
&& anchor_slot.map_or(true, |anchor_slot| slot >= &anchor_slot)
}
Ok((_, _, slot)) => *slot >= current_split_slot,
Err(_) => true,
})
.collect::<Result<Vec<_>, _>>()?;
Expand Down

0 comments on commit 3d90ac6

Please sign in to comment.