aboutsummaryrefslogtreecommitdiff
path: root/test/functional/feature_assumeutxo.py
diff options
context:
space:
mode:
authorRyan Ofsky <ryan@ofsky.org>2024-02-02 10:59:24 -0500
committerRyan Ofsky <ryan@ofsky.org>2024-03-18 11:28:40 -0500
commitef29c8b662309a438121a83f27fd7bdd1779700c (patch)
treef01d0382e05f2cf1b5fa1b4310932c0ae9a40dd8 /test/functional/feature_assumeutxo.py
parent9b97d5bbf980d657a277c85d113c2ae3e870e0ec (diff)
downloadbitcoin-ef29c8b662309a438121a83f27fd7bdd1779700c.tar.xz
assumeutxo: Get rid of faked nTx and nChainTx values
The `PopulateAndValidateSnapshot` function introduced in f6e2da5fb7c6406c37612c838c998078ea8d2252 from #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 next two commits. Compatibility note: This change could result in -checkblockindex failures if a snapshot was loaded by a previous version of Bitcoin Core and not fully validated, because fake nTx values will have been saved to the block index. It would be pretty easy to avoid these failures by adding some compatibility code to `LoadBlockIndex` and changing `nTx` values from 1 to 0 when they are fake (when `(pindex->nStatus & BLOCK_VALID_MASK) < BLOCK_VALID_TRANSACTIONS`), but a little simpler not to worry about being compatible in this case.
Diffstat (limited to 'test/functional/feature_assumeutxo.py')
-rwxr-xr-xtest/functional/feature_assumeutxo.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index a29ee8be8b..27910c3909 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -244,20 +244,19 @@ class AssumeutxoTest(BitcoinTestFramework):
tx = n1.getblockheader(block.hash)["nTx"]
chain_tx = n1.getchaintxstats(nblocks=1, blockhash=block.hash)["txcount"]
- # Intermediate nTx of the starting block should be real, but nTx of
- # later blocks should be fake 1 values set by snapshot loading code.
+ # Intermediate nTx of the starting block should be set, but nTx of
+ # later blocks should be 0 before they are downloaded.
if final or height == START_HEIGHT:
assert_equal(tx, block.tx)
else:
- assert_equal(tx, 1)
+ assert_equal(tx, 0)
# Intermediate nChainTx of the starting block and snapshot block
- # should be real, but others will be fake values set by snapshot
- # loading code.
+ # should be set, but others should be 0 until they are downloaded.
if final or height in (START_HEIGHT, SNAPSHOT_BASE_HEIGHT):
assert_equal(chain_tx, block.chain_tx)
else:
- assert_equal(chain_tx, height + 1)
+ assert_equal(chain_tx, 0)
check_tx_counts(final=False)