From 1b0b3e2c2cbb60bb6a4e352c9bad221ec416e340 Mon Sep 17 00:00:00 2001 From: stratospher <44024636+stratospher@users.noreply.github.com> Date: Thu, 19 Mar 2026 22:07:26 +0530 Subject: [PATCH] validation: remove redundant marking in FindMostWorkChain since ed764ea, all descendants in m_block_index are required to be marked BLOCK_FAILED_VALID when an invalid block is encountered, as enforced by a CheckBlockIndex assert. remove the now-redundant marking in FindMostWorkChain's inner loop, so it is only responsible for cleaning up setBlockIndexCandidates, not for modifying block validity state --- src/validation.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 00c1bab501f..e0a8c1b38db 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3142,13 +3142,10 @@ CBlockIndex* Chainstate::FindMostWorkChain() CBlockIndex *pindexFailed = pindexNew; // Remove the entire chain from the set. while (pindexTest != pindexFailed) { - if (fFailedChain) { - pindexFailed->nStatus |= BLOCK_FAILED_VALID; - m_blockman.m_dirty_blockindex.insert(pindexFailed); - } else if (fMissingData) { - // If we're missing data, then add back to m_blocks_unlinked, - // so that if the block arrives in the future we can try adding - // to setBlockIndexCandidates again. + if (fMissingData && !fFailedChain) { + // If we're missing data and not a descendant of an invalid block, + // then add back to m_blocks_unlinked, so that if the block arrives in the future + // we can try adding to setBlockIndexCandidates again. m_blockman.m_blocks_unlinked.insert( std::make_pair(pindexFailed->pprev, pindexFailed)); }