fix(prune): add minimum 64 block retention for receipts and bodies#21520
Merged
fix(prune): add minimum 64 block retention for receipts and bodies#21520
Conversation
When PruneMode::Full is used for receipts, the pruner would prune all receipts up to the tip block immediately after persistence. This causes a race condition during chain reorganizations: 1. Block A at height N is persisted to disk 2. Pruner runs and prunes A's receipts 3. Block B at height N arrives (reorg) 4. FCU tries to make B canonical 5. on_new_head calls canonical_block_by_hash(A) to walk back old chain 6. canonical_block_by_hash tries to reconstruct ExecutedBlock from disk 7. get_state() fails with 'no receipt found' because receipts were pruned This fix adds MINIMUM_RECEIPTS_DISTANCE (64 blocks) to ensure receipts and bodies are retained long enough to handle any potential reorgs. Fixes a regression introduced by PR #17938 which added canonical_block_by_hash that assumes ExecutedBlock can always be reconstructed from disk.
1f2648c to
73bff9e
Compare
…STANCE - MINIMUM_STATE_HISTORY_DISTANCE (10064): used for AccountHistory, StorageHistory, ContractLogs - MINIMUM_PRUNING_DISTANCE (64): used for Receipts, Bodies to ensure reorg safety
73bff9e to
f938e79
Compare
mattsse
approved these changes
Jan 28, 2026
mediocregopher
approved these changes
Jan 28, 2026
shekhirin
reviewed
Jan 28, 2026
| @@ -80,9 +82,9 @@ impl Default for DefaultPruningValues { | |||
| sender_recovery: Some(PruneMode::Full), | |||
| transaction_lookup: Some(PruneMode::Full), | |||
| receipts: Some(PruneMode::Full), | |||
mattsse
pushed a commit
that referenced
this pull request
Jan 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
PruneMode::Fullfor receipts (min_blocks() == 0), receipts are pruned immediately after persistence. During a same-height reorg,canonical_block_by_hashfails withno receipt foundbecause receipts were already pruned.Fix
MINIMUM_DISTANCE = 64forReceiptsandBodiessegmentsMINIMUM_PRUNING_DISTANCE→MINIMUM_UNWIND_SAFE_DISTANCE