Skip to content

Rewind the download window with the position on regression. - #10

Open
echennells wants to merge 2 commits into
masterfrom
reorg-window-rewind
Open

echennells wants to merge 2 commits into
masterfrom
reorg-window-rewind

Conversation

@echennells

@echennells echennells commented Sep 14, 2026

Copy link
Copy Markdown
Owner

chaser_check::do_regressed rewinds the position and purges outstanding work but leaves requested_ and advanced_ at their pre-regression heights, and ignores a regression above the position even when it is inside the requested window. Either way set_unassociated then defers all new work (position() < requested_) until the gap is filled, and the gap is the replaced block at the regression height, which only the deferred request can fill. Block download stops while headers continue; a restart clears it because start() re-seeds the window from the position.

The guard now considers the window as well as the position, and both are rewound before the purge, as at start.

The validator has the same gap (second commit): after a regression it advances only on a checked event for the block above the branch point, which never arrives when that block is already associated, as when a reorg returns to a branch already downloaded. Validation stops, so the download window never advances either. It now resumes from the branch point as start does.

Reproduced on regtest against bitcoind: sync to N, invalidate N and mine two on a competing branch; master stays at N while patched follows. Issuing the same reorg while blocks below N are still downloading stalls at N-1 unless the guard is on the window. For the validator: mine A, invalidate it and mine B,C, then reconsider A and mine on it; the first commit alone stalls at C, both follow. The validator case was first observed as a 21 hour stall on a testnet3 block storm.

🤖 Generated with Claude Code

@echennells
echennells force-pushed the reorg-window-rewind branch 4 times, most recently from 34f1f35 to 9b25e7b Compare September 15, 2026 22:01
echennells and others added 2 commits September 18, 2026 15:47
A regression below the position rewound the position but not the
window (requested_/advanced_), and a regression above the position but
within the window was ignored. Either way set_unassociated() then
deferred new work until the gap at the replaced height was filled,
which only a request can do, so a tip reorg stopped block download
until restart while headers continued. Guard on the window and rewind
both with the position.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant