diff --git a/beacon_node/store/src/hdiff.rs b/beacon_node/store/src/hdiff.rs index 4f508a88b78..d1f8fecb3a6 100644 --- a/beacon_node/store/src/hdiff.rs +++ b/beacon_node/store/src/hdiff.rs @@ -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 { // If there's only 1 layer of snapshots, then commit only when writing a snapshot. self.moduli.get(1).map_or_else( diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 4311f234f71..02553b5e76c 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -2914,7 +2914,6 @@ pub fn migrate_database, Cold: ItemStore>( // 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 { @@ -2938,10 +2937,7 @@ pub fn migrate_database, Cold: ItemStore>( // 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 >= ¤t_split_slot - && anchor_slot.map_or(true, |anchor_slot| slot >= &anchor_slot) - } + Ok((_, _, slot)) => *slot >= current_split_slot, Err(_) => true, }) .collect::, _>>()?;