Skip deep-reorg parking during initial block download / reindex#136
Open
VictorLux wants to merge 1 commit into
Open
Skip deep-reorg parking during initial block download / reindex#136VictorLux wants to merge 1 commit into
VictorLux wants to merge 1 commit into
Conversation
… stall) The deep-reorg park in AcceptBlock fired during -reindex because blocks are loaded from blk*.dat out of height order, so 'would cause a deep reorg' (fork depth > 1) triggers spuriously and parks large swaths of the chain — the stall that forces -parkdeepreorg=0 on a from-genesis reindex (observed at ~478543). Gate the park behind !IsInitialBlockDownload(): deep-reorg/51% protection is an at-tip defense; during IBD the node only follows the best chain forward, so there is nothing to protect. Behaviour at tip is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
The deep-reorg park in
AcceptBlockfires spuriously during-reindex, because blocks are loaded fromblk*.datout of height order — so the "would cause a deep reorg" test (fork depth > 1) triggers and parks large swaths of the chain, stalling a from-genesis reindex. Gate the park behind!IsInitialBlockDownload().Safety
At-tip behaviour is unchanged:
IsInitialBlockDownload()latches to false after first catch-up, so once synced the parking is always active again (an attacker cannot disable it by staling the tip). During IBD the node only follows the best-work chain forward; deep-reorg protection is an at-tip defense, and the skip window remains backstopped by depth-N auto-finalization and theMAX_REORG_LENGTHcap.