-
Notifications
You must be signed in to change notification settings - Fork 38.1k
p2p: Allow block downloads from peers without snapshot block after assumeutxo validation #33604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
p2p: Allow block downloads from peers without snapshot block after assumeutxo validation #33604
Conversation
…sumeutxo validation After assumeutxo background validation completes, allow block downloads from peers that don't have the snapshot block in their best chain. Previously, these peers were skipped until restart because `GetSnapshotBaseBlock()` continued returning non-null even after validation finished. Add `!IsSnapshotValidated()` check to only apply the restriction while background validation is ongoing.
Add test coverage to ensure peers without the snapshot block in their chain can be used for block downloads after background validation completes. The test fails without the fix in the previous commit.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33604. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
|
Nice, Concept ACK. |
|
cc @mzumsande |
|
This change allows the snapshot chainstate to reorg to chains that don't include the snapshot block after validation completes (not sure yet if this is the only mechanism that would allow such reorgs), so we must not assume anywhere in the codebase that |
|
Concept ACK approach seems fine |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 9f946a7.
nice! I think this aligns with the original intention to restrict the peer only when background sync isn't over in #29519 (comment) where this code was introduced.
looks like we might incorrectly set pindexLastCommonBlock in L1401 to the previous best known block tip again in this scenario. but it's not a problem since we immediately reset it back to the correct value + comments suggest it's ok to set it incorrectly and that's way better than introducing more conditions.
also slightly related: #30288
|
Thanks for the links @stratospher! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Currently, after assumeutxo background validation finishes, the node continues to skip peers that don't have the snapshot block in their best chain until restart. This unnecessarily excludes peers from block downloads even though the background sync has completed and undo data is available.
The restriction persists because
GetSnapshotBaseBlock()continues to return the snapshot base block even after validation completes. Whilem_ibd_chainstate->m_disabledis set to true when validation finishes, the active chainstate remains the snapshot chainstate until the next restart, whenLoadChainstate()tears down both chainstates and reinitializes a single normal (non-snapshot) chainstate.Added
!m_chainman.IsSnapshotValidated()check to only apply the peer restriction while background validation is ongoing. Also added test coverage infeature_assumeutxo.pythat verifies peers without the snapshot block can be used for block downloads after background validation completes. The test fails without this fix.