Skip to content

Commit abb3c3f

Browse files
committed
Prevent deletion of payloads >= split slot
1 parent 5cc266c commit abb3c3f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

beacon_node/beacon_chain/src/migrate.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
712712

713713
// Prune all payloads of the canonical finalized blocks
714714
if store.get_config().prune_payloads {
715-
Self::prune_finalized_payloads(&newly_finalized_blocks, &mut batch);
715+
Self::prune_finalized_payloads(new_finalized_slot, &newly_finalized_blocks, &mut batch);
716716
}
717717

718718
store.do_atomically_with_block_and_blobs_cache(batch)?;
@@ -728,15 +728,17 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
728728
}
729729

730730
fn prune_finalized_payloads(
731+
new_finalized_slot: Slot,
731732
finalized_blocks: &[(Hash256, Slot)],
732733
hot_db_ops: &mut Vec<StoreOp<E>>,
733734
) {
734-
for (block_root, _) in finalized_blocks {
735+
for (block_root, slot) in finalized_blocks {
735736
// Delete the execution payload if payload pruning is enabled. At a skipped slot we may
736737
// delete the payload for the finalized block itself, but that's OK as we only guarantee
737-
// that payloads are present for slots >= the split slot. The payload fetching code is also
738-
// forgiving of missing payloads.
739-
hot_db_ops.push(StoreOp::DeleteExecutionPayload(*block_root));
738+
// that payloads are present for slots >= the split slot.
739+
if *slot < new_finalized_slot {
740+
hot_db_ops.push(StoreOp::DeleteExecutionPayload(*block_root));
741+
}
740742
}
741743
}
742744

0 commit comments

Comments
 (0)