HomePhabricator

Tighten requirements for adding elements to setBlockIndexCandidates

Description

Tighten requirements for adding elements to setBlockIndexCandidates

Summary:
When using assumeutxo, we only need the background chainstate to consider
blocks that are on the chain leading to the snapshotted block.

Note that this introduces the new invariant that we can only have an assumeutxo
snapshot where the snapshotted blockhash is in our block index. Unknown block
hashes that are somehow passed in will cause assertion failures when processing
new blocks.

Includes test fixes and improvements by Andrew Chow and Fabian Jahr.

This is a partial backport of core#27746
https://github.com/bitcoin/bitcoin/pull/27746/commits/d43a1f1a2fa35d377c7a9ad7ab92d1ae325bde3d

We also need a change from https://github.com/bitcoin/bitcoin/pull/27596/commits/49ef778158c43859946a592e11ec34fe1b93a5b6 in validation_chainstatemanager_tests to make the c2.ActivateBestChain call succesfully pass the CheckBlockIndex tests (which are more aggressive in our codebase as of D4717). Specifically, we need to have the chain tip be in c2.setBlockIndexCandidates, or else we will trigger an assertion in validation.cpp:6049 ( setBlockIndexCandidates.count(pindex) !=0)

Depends on D17533

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
Suhas Daftuar <sdaftuar@chaincode.com>Authored on May 24 2023, 17:38
PiRKCommitted on Fri, Jan 17, 08:07
PiRKPushed on Fri, Jan 17, 08:07
Reviewer
Restricted Project
Differential Revision
D17534: Tighten requirements for adding elements to setBlockIndexCandidates
Parents
rABC2edc904cea06: Move block-storage-related logic to ChainstateManager
Branches
Unknown
Tags
Unknown