Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process. ConflictsNo conflicts as of last run. |
|
IIUC this bug can't realistically be triggered with default |
86904e6 to
1639200
Compare
|
@andrewtoth, that’s right for ordinary pruning, but this can also happen with default checks under AssumeUTXO before background validation reaches the requested block, so I’ve added a small test for that and expanded the This change is also a prerequisite for the |
1639200 to
e262a1f
Compare
|
Question first: when the snapshot base block's body is present but has no undo data (the state the new The abort is not introduced here: the merge-base with Related: #35307 adds Tested on Linux aarch64 (Debian 13), GCC 14.2.0, Release, e262a1f (merges cleanly with master de96f3a). Reading the code: the new check sits after the level 0-2 reads; it tests the |
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. The other known bug classes of the plan are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
The block index was already driven by a small set of functions that write nStatus and the derived sets (AddToBlockIndex, ReceivedBlockTransactions, InvalidBlockFound, InvalidateBlock, SetBlockFailureFlags, ResetBlockFailureFlags, PruneOneBlockFile, TryAddBlockIndexCandidate, PruneBlockIndexCandidates, OnUndoWritten), with CheckBlockIndex as the invariant checker and the block_index_tree fuzz target driving event sequences against it. Two writers were still inline and move into named transitions: - the validity raise after a block is connected becomes ChainstateManager::MarkBlockScriptsValid; - the removal of an unusable candidate chain inside FindMostWorkChain becomes Chainstate::DropUnusableCandidateChain. CBlockIndex gains a typed state, BlockIndexState, derived from nStatus (which stays the stored representation, so nothing on disk changes), and HaveUndo() for the orthogonal undo bit. CheckBlockIndex checks that the typed state agrees with the flags, that HaveUndo implies a valid undo position and a connected block, in addition to its existing invariants. Unit tests cover the state mapping and the sequence behind bitcoin#36149 (a block in m_blocks_unlinked whose file is pruned must leave the set), which the checker's "no data implies not unlinked" invariant also guards. Other known bug classes are covered by invariants the checker already has: bitcoin#36702 by the snapshot-base m_chain_tx_count checks, bitcoin#36452 by CheckBlockDataAvailability and the HAVE_DATA/nTx relations, bitcoin#34254 by the failed-flag propagation checks.
Restore the highest pruned block so verification reaches its missing undo before an older missing block body. Record the corruption error from deep verifychain checks and confirm that level 2 can still verify the available bodies. Record the failed deep startup check and confirm that restarting with shallow checks preserves the chain tip and restored block. Record the same corruption error from default `verifychain` checks on an AssumeUTXO snapshot tip before background validation reaches it.
Name the existing pruning-or-snapshot allowance so the following undo-data check can reuse it. Rename the skipped-data flag to cover unavailable undo as well as block bodies.
Refetching a pruned block with `getblockfrompeer` restores its body but not its undo record. Stop startup verification and `verifychain` when their disconnect checks need missing pruned undo, rather than reporting database corruption. The existing allowance for unavailable snapshot history also covers missing undo on AssumeUTXO snapshot chainstates. Check available block bodies before stopping for missing undo, preserving the checks at lower verification levels.
This result covers unavailable block bodies and undo records.
e262a1f to
f685225
Compare
|
Rebased, renamed |

Problem:
getblockfrompeerrestores a pruned block's body without recreating its undo record. If startup verification reaches that block at level >2, it attempts to disconnect it and reports database corruption, preventing the node from restarting.With ordinary pruning, reaching the restored block requires a deeper check than the default six blocks. The AssumeUTXO case can occur with the default checks.
Fix: Stop deep verification when a pruned node reaches missing undo data, using the existing result for unavailable history. The same allowance covers missing undo on AssumeUTXO snapshot chainstates, matching the existing treatment of unavailable snapshot history. Level 4 still reconnects the newer blocks that were disconnected.
verifychainreturnsfalseto indicate incomplete verification, including when undo is missing at the snapshot base. Lower verification levels and corruption checks for undo records marked as present retain their existing behavior.An AssumeUTXO restart can still hit a separate block-index candidate assertion after verification.
This came up during pruned
txindexreview. The pendingpruneassumevalidchange also needs verification to handle missing undo correctly, so this fix is being split out to land first.