HomePhabricator

validation: mark blocks building on an invalid block as having failed parents

Description

validation: mark blocks building on an invalid block as having failed parents

Summary:
https://github.com/bitcoin/bitcoin/pull/30666/commits/f5149ddb9b7de3559943d7fda0f440e59413dfb5:

Without doing so, header-only chains building on a chain that
will be marked as invalid would still be eligible for m_best_header.
This improves both getblockchaininfo and getchaintips behavior.

While this adds an iteration over the entire block index, it can only be
triggered by the user (invalidateblock) or by others at a cost (the
header needs to be accepted in the first place, so it needs valid PoW).

Co-authored-by: TheCharlatan <seb.kung@gmail.com>

https://github.com/bitcoin/bitcoin/pull/30666/commits/ccd98ea4c88fc1aa959e41e0686d8dff00a44209
https://github.com/bitcoin/bitcoin/pull/30666/commits/0bd53d913c1c2ffd2d0779f01bc51c81537b6992

test: add test for getchaintips behavior with invalid chains

This test would fail to mark the chain tip as "invalid" instead
of "headers-only" without the previous commit marking the headers
as BLOCK_FAILED_CHILD.

Now the unintuitive behavior revealed and documented in D1987 in abc_feature_parkedchain.py becomes the expected behavior.

This concludes backport of core#30666

Depends on D18042

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
Martin Zumsande <mzumsande@gmail.com>Authored on Apr 23 2024, 21:36
PiRKCommitted on Fri, May 2, 21:49
PiRKPushed on Fri, May 2, 21:49
Reviewer
Restricted Project
Differential Revision
D18002: validation: mark blocks building on an invalid block as having failed parents
Parents
rABC44bc22686223: bugfix: the end of a reorged chain is invalid when connect fails
Branches
Unknown
Tags
Unknown