mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:47:36 +00:00
validation: don't treat snapshot block as linked on startup #36702
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36702
Loading…
Reference in a new issue
No description provided.
Delete branch "fix-snapshot-block-unlinked-on-startup"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background sync requests blocks up to and including the snapshot block from several peers at once, so the snapshot block can be stored before one of its ancestors.
ReceivedBlockTransactions()then keeps it inm_blocks_unlinked, but that isn't persisted. On restartLoadBlockIndex()gives it the hardcodedm_chain_tx_count,PopulateBlockIndexCandidates()makes it a background candidate, andFindMostWorkChain()walks back to its parent, which has no chain tx count:It needs a restart in that window, so it should be rare, but after that the node aborts on every start. The only ways out I found are
-reindex-chainstateor-reindex, and both delete the snapshot chainstate.Fix this by adding the snapshot block to
m_blocks_unlinkedon startup if an ancestor is missing, and not making it a background candidate until then. Both are needed, without the first one background validation stalls. A node that is already stuck starts with the fix and finishes background validation without a reindex.The new step in
feature_assumeutxo.pyrestarts the node after the snapshot block is submitted out of order, and fails on master. I also reproduced it over p2p with a test peer that withholds the snapshot block's parent.These are the two changes from #35307 (closed, the motivation there was
submitblockbeforeloadtxoutset) without its blockfile and VerifyDB changes. cyb3ralbert hit the same assertion while testing #36452 (https://github.com/bitcoin/bitcoin/pull/36452#issuecomment-6464524112), which is still needed when the snapshot tip is at the snapshot block. #36149 drops theBLOCK_HAVE_DATAcheck in the branch right below, so whichever is merged second should match it.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
No verified findings are available from this review.
Review coverage was incomplete.
Reviewed:
aad458e78534· Review report · Previous reportspermalink
Tested
feature_assumeutxo.pyat80f6dddon Windows x64: passes with the fix. Reverting only the two C++ changes while keeping the new test reproduces the startup assertion inFindMostWorkChain().Can target_block->pprev be null under mock parameters in unit tests? pindex->pprev is dereferenced directly without a null guard before checking HaveNumChainTxs(), whereas the loop below explicitly guards against null parents.
Reverting the two C++ hunks against
80f6ddd6creproduces the SIGABRT at validation.cpp:3217 in FindMostWorkChain. With the patch, feature_assumeutxo.py and validation unit tests pass locally.PR #36149 drops BLOCK_HAVE_DATA in LoadBlockIndex so pruned blocks without data stay in m_blocks_unlinked while waiting for parents. Whichever lands second will need to align that branch.
The target block is only set on the historical chainstate to the snapshot base block (in
AddChainstate), which has to match an assumeutxo entry from chainparams and is never genesis. The unit tests create snapshot chainstates on non-genesis blocks as well (or clear the target immediately). Thepprev == nullptrguard further down in the loop is for genesis when iterating all block indices.Could you add
wait_for_full_init=Falseto the restart for current master?The test waits for index sync before establishing the peer connection needed to complete it. With this change,
feature_assumeutxo.pypasses.Rebased and done.
Concept NACK, instead of hacking it further I think we should just remove background sync (with AssumeUTXO) completely, see #36598