Skip to content

A stalled ChainLock reorg can still advance the conflicting branch #8250

Backlog

Description

@thepastaclaw

PastaClaw flagged this while reviewing #8235, where it was deferred to a follow-up instead of being fixed in that pull request. This issue tracks the follow-up.

A stalled ChainLock reorg can still advance the conflicting branch (suggestion)

Impact: A snapshot chainstate that stalls while disconnecting a conflicting tip can still activate and announce a new block on that branch above the locked height.

Where: src/validation.cpp:4518-4530 at 686a97a1fc92:

dash/src/validation.cpp

Lines 4518 to 4530 in 686a97a

// Now mark the blocks we just disconnected as descendants conflicting
// (note this may not be all descendants).
while (pindex_was_in_chain && conflicting_walk_tip != pindex && conflicting_walk_tip != m_chain.Tip()) {
conflicting_walk_tip->nStatus |= BLOCK_CONFLICT_CHAINLOCK;
setBlockIndexCandidates.erase(conflicting_walk_tip);
conflicting_walk_tip = conflicting_walk_tip->pprev;
}
if (!stalled) {
// Mark the block itself as conflicting.
pindex->nStatus |= BLOCK_CONFLICT_CHAINLOCK;
setBlockIndexCandidates.erase(pindex);
}

Keeping the current tip as a fallback is necessary when it cannot be disconnected, but it should not remain extendable. On a partial stall, MarkConflictingBlock() marks only the blocks it disconnected; on a first-disconnect stall, it marks none. If the retained tip is at or above the locked height, a child passes the direct-parent flag check, and HasConflictingChainLock() returns false for the child because its height is above the lock. The remembered disconnect stall also permits the child because its chain contains the retained tip. Check the locked ancestor before activating an extension, and extend the snapshot stall test to cover a child above the locked height rather than only a sibling at that height.

Origin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions