mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
Clean up temporary state flags while running (#6422)
* Clean up temporary state flags while running * Add regression test * Simplify
This commit is contained in:
@@ -21,7 +21,6 @@ where
|
||||
.try_fold(vec![], |mut ops, state_root| {
|
||||
let state_root = state_root?;
|
||||
ops.push(StoreOp::DeleteState(state_root, None));
|
||||
ops.push(StoreOp::DeleteStateTemporaryFlag(state_root));
|
||||
Result::<_, Error>::Ok(ops)
|
||||
})?;
|
||||
|
||||
@@ -29,7 +28,7 @@ where
|
||||
debug!(
|
||||
self.log,
|
||||
"Garbage collecting {} temporary states",
|
||||
delete_ops.len() / 2
|
||||
delete_ops.len()
|
||||
);
|
||||
self.do_atomically_with_block_and_blobs_cache(delete_ops)?;
|
||||
}
|
||||
|
||||
@@ -1160,10 +1160,19 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
|
||||
}
|
||||
|
||||
StoreOp::DeleteState(state_root, slot) => {
|
||||
// Delete the hot state summary.
|
||||
let state_summary_key =
|
||||
get_key_for_col(DBColumn::BeaconStateSummary.into(), state_root.as_slice());
|
||||
key_value_batch.push(KeyValueStoreOp::DeleteKey(state_summary_key));
|
||||
|
||||
// Delete the state temporary flag (if any). Temporary flags are commonly
|
||||
// created by the state advance routine.
|
||||
let state_temp_key = get_key_for_col(
|
||||
DBColumn::BeaconStateTemporary.into(),
|
||||
state_root.as_slice(),
|
||||
);
|
||||
key_value_batch.push(KeyValueStoreOp::DeleteKey(state_temp_key));
|
||||
|
||||
if slot.map_or(true, |slot| slot % E::slots_per_epoch() == 0) {
|
||||
let state_key =
|
||||
get_key_for_col(DBColumn::BeaconState.into(), state_root.as_slice());
|
||||
|
||||
Reference in New Issue
Block a user