HomePhabricator

[validation.cpp] update 'cousins' during UpdateFlags

Description

[validation.cpp] update 'cousins' during UpdateFlags

Summary:
In some obscure cases during UpdateFlags, it can happen that we update
an ancestor which itself has children that need updating.

For example, we might call reconsiderblock on a block whose parent is marked
invalid. This would remove the failed flag from said parent block, in which case
all descendants under that one ought to have their FailedParent flag revoked too.

For example consider:

O --- F --- FP* --- FP --- FP
       \
        --- FP --- F --- FP

O = okay,  F = failed, FP = failed parent, * = reconsidered block

Currently, running reconsiderblock on FP* would yield

O --- O --- O* --- O --- O
       \
        --- FP --- F --- FP

This diff would instead do:

O --- O --- O* --- O --- O
       \
        --- O --- F --- O

Note that it's OK if too many blocks get FailedParent removed, like in that
example. This is fine because FindMostWorkChain will notice this and put the
FailedParent flag back in place:

O --- O --- O* --- O --- O
       \
        --- O --- F --- FP

(and it will also find the new correct value for pindexBestInvalid)

Depends on D5041

This patch was written by @markblundeberg

Test Plan: ninja check-all

Reviewers: #bitcoin_abc, jasonbcox, markblundeberg

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D4936

Details

Provenance
deadalnixAuthored on Feb 29 2020, 00:51
deadalnixPushed on Feb 29 2020, 14:30
Reviewer
Restricted Project
Differential Revision
Restricted Differential Revision
Parents
rABCf99b18b3f609: rename: CChainState.chainActive -> m_chain
Branches
Unknown
Tags
Unknown

Event Timeline