This backports a series of commit that improve the handling of CBlockIndex::nChainTx for assumed valid blocks, improve the consistency checks for this and fix the corresponding tests and assumeutxo checkpoint data which were wrong (which would cause test failures with these new consistency checks)
validation: populate nChainTx value for assumedvalid chainstates
Use the expected AssumeutxoData in order to bootstrap nChainTx values
for assumedvalid blockindex entries in the snapshot chainstate. This
is necessary because nChainTx is normally built up from nTx values,
which are populated using blockdata which the snapshot chainstate
does not yet have.
https://github.com/bitcoin/bitcoin/pull/27596/commits/4c3b8ca35c2e4a441264749bb312df2bd054b5b8
refactor: Remove unused nchaintx from SnapshotMetadata constructor
Also, remove wrong nChainTx comment and cast (see D16281)
https://github.com/bitcoin/bitcoin/pull/28639/commits/faa90f6e7b6b8c531e1ae142a5c2f568b48502a9
validation: Check GuessVerificationProgress is not called with disconnected block
Use Assume macro as suggested https://github.com/bitcoin/bitcoin/pull/29370#discussion_r1479427801
https://github.com/bitcoin/bitcoin/pull/29370/commits/0fd915ee6bef63bb360ccc5c039a3c11676c38e3
assumeutxo: Get rid of faked nTx and nChainTx values
The PopulateAndValidateSnapshot function introduced in
core#19806 has been setting fake
nTx and nChainTx values that can show up in RPC results (see #29328) and
make CBlockIndex state hard to reason about, because it is difficult to know
whether the values are real or fake.Revert to previous behavior of setting nTx and nChainTx to 0 when the
values are unknown, instead of faking them.This commit fixes at least two assert failures in the (pindex->nChainTx ==
pindex->nTx + prev_chain_tx) check that would happen previously. Tests for
these failures are added separately in the functional test for assumeutxo.
improve consistency check for nChainTx and fix assume_utxo checkpoint data: https://github.com/bitcoin/bitcoin/pull/28562/commits/73700fb554d6abad705d8f48aed4840fedb36c79
move that consistency check: core#29299
main commit: https://github.com/bitcoin/bitcoin/pull/29370/commits/ef29c8b662309a438121a83f27fd7bdd1779700c
This is a partial backport of core#27596, core#28639, core#29730, core#28562 and core#29299
Depends on D17872