From 0e4b0bacecf94063342c7f9eb9b03dac8a7a7936 Mon Sep 17 00:00:00 2001 From: marcofleon Date: Mon, 27 Apr 2026 18:16:44 +0100 Subject: [PATCH] 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. --- src/node/blockstorage.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index b0842a00505..411f0ca849b 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -487,7 +487,9 @@ bool BlockManager::LoadBlockIndex(const std::optional& snapshot_blockha pindex->m_chain_tx_count = pindex->pprev->m_chain_tx_count + pindex->nTx; } else { pindex->m_chain_tx_count = 0; - m_blocks_unlinked.insert(std::make_pair(pindex->pprev, pindex)); + if (pindex->nStatus & BLOCK_HAVE_DATA) { + m_blocks_unlinked.insert(std::make_pair(pindex->pprev, pindex)); + } } } else { pindex->m_chain_tx_count = pindex->nTx;