Skip to content

Commit 0e4b0ba

Browse files
committed
validation: Don't add pruned blocks to m_blocks_unlinked on startup
LoadBlockIndex() adds to m_blocks_unlinked based only on nTx > 0, without checking BLOCK_HAVE_DATA. Pruning preserves nTx but clears BLOCK_HAVE_DATA, so a pruned block whose parent was header-only gets re-added on every restart, causing the CheckBlockIndex() assertion that entries must have data on disk to fail. Check that BLOCK_HAVE_DATA is set before inserting into m_blocks_unlinked. Fixes #35050.
1 parent ad3f738 commit 0e4b0ba

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎src/node/blockstorage.cpp‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,9 @@ bool BlockManager::LoadBlockIndex(const std::optional<uint256>& snapshot_blockha
487487
pindex->m_chain_tx_count = pindex->pprev->m_chain_tx_count + pindex->nTx;
488488
} else {
489489
pindex->m_chain_tx_count = 0;
490-
m_blocks_unlinked.insert(std::make_pair(pindex->pprev, pindex));
490+
if (pindex->nStatus & BLOCK_HAVE_DATA) {
491+
m_blocks_unlinked.insert(std::make_pair(pindex->pprev, pindex));
492+
}
491493
}
492494
} else {
493495
pindex->m_chain_tx_count = pindex->nTx;

0 commit comments

Comments
 (0)