Skip to content

Commit c996675

Browse files
committed
validation: fix traversal condition to mark BLOCK_FAILED_CHILD
this block of code is not reached on master since other than initialisation, all other iterations have invalid_walk_tip and to_mark_failed pointers in some form of this layout where 1, 2, 3 and 4 are block heights. invalid_walk_tip ↓ 1 <- 2 <- 3 <- 4 ↑ to_mark_failed fix it so that blocks are correctly marked as BLOCK_FAILED_CHILD if it's a descendant of BLOCK_FAILED_VALID block.
1 parent f93d6cb commit c996675

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,7 @@ bool Chainstate::InvalidateBlock(BlockValidationState& state, CBlockIndex* pinde
37473747
m_blockman.m_dirty_blockindex.insert(invalid_walk_tip);
37483748
setBlockIndexCandidates.erase(invalid_walk_tip);
37493749
setBlockIndexCandidates.insert(invalid_walk_tip->pprev);
3750-
if (invalid_walk_tip->pprev == to_mark_failed && (to_mark_failed->nStatus & BLOCK_FAILED_VALID)) {
3750+
if (invalid_walk_tip == to_mark_failed->pprev && (to_mark_failed->nStatus & BLOCK_FAILED_VALID)) {
37513751
// We only want to mark the last disconnected block as BLOCK_FAILED_VALID; its children
37523752
// need to be BLOCK_FAILED_CHILD instead.
37533753
to_mark_failed->nStatus = (to_mark_failed->nStatus ^ BLOCK_FAILED_VALID) | BLOCK_FAILED_CHILD;

0 commit comments

Comments
 (0)