ibd: stop header prefix retries when first header fails - #798
Merged
reardencode merged 2 commits intoSep 28, 2026
Merged
Conversation
Owner
|
we may have an alternative fix for this coming up, but I'll have grok pause and look at yours before continuing. Thank you!!! |
4 tasks
A headers batch that cannot connect used to search longer prefixes after the full batch failed. The release note records that the search now stops when the first header is rejected. Co-authored-by: Cursor <cursoragent@cursor.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.
Problem
On mainnet IBD at ~458k, 2,000-header peer events with no accepted prefix blocked the IBD loop for ~12–13 seconds apiece. Instrumentation measured
accepted_headersas the cost, withaccepted=0,stored_prefix=0, one failed full-batch attempt and 10 failed prefix probes. The same window processed block-body events in milliseconds. See #790.Change
After a failed full batch, validate the first header alone before searching for a longer accepted prefix. If that first header fails, no prefix is acceptable; return without the 10 longer probes. If it succeeds, retain its FK and binary-search the remaining prefix exactly as before. No header validation or store format changes.
Reproduction and validation
/ssd/rbitcoindatadir with--milestone=840000: failed 2,000-header batch fell from ~12–13 s / 11 attempts to ~2.3–2.5 s / 2 attempts. Progress checks moved from ~25 s to ~9–12 s during the brief trial; throughput was variable and is not claimed as a sustained A/B improvement. The node has been restored to the original committed INFO binary.cargo fmt --all -- --check;cargo clippy --workspace --all-targets -- -D warnings;cargo test -p rbitcoin-net --lib(646 passed);cargo test --workspace --no-fail-fast --quiet(passed before a final test-only assertion was added); musl Nix build of the live-tested candidate.Follow-up: the first full-batch attempt still costs ~1.1–1.3 s in the live sample; this PR addresses only redundant retries when the first header cannot be accepted.