Skip to content

Commit 91d93aa

Browse files
committed
validation: remove nchaintx from assumeutxo metadata
This value is no longer used and is instead specified statically in chainparams. This change means that previously generated snapshots will no longer be usable.
1 parent 931684b commit 91d93aa

File tree

3 files changed

+4
-23
lines changed

3 files changed

+4
-23
lines changed

src/node/utxo_snapshot.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,15 @@ class SnapshotMetadata
2222
//! during snapshot load to estimate progress of UTXO set reconstruction.
2323
uint64_t m_coins_count = 0;
2424

25-
//! Necessary to "fake" the base nChainTx so that we can estimate progress during
26-
//! initial block download for the assumeutxo chainstate.
27-
//!
28-
//! TODO: this is unused and should be removed.
29-
unsigned int m_nchaintx = 0;
30-
3125
SnapshotMetadata() { }
3226
SnapshotMetadata(
3327
const uint256& base_blockhash,
3428
uint64_t coins_count,
3529
unsigned int nchaintx) :
3630
m_base_blockhash(base_blockhash),
37-
m_coins_count(coins_count),
38-
m_nchaintx(nchaintx) { }
31+
m_coins_count(coins_count) { }
3932

40-
SERIALIZE_METHODS(SnapshotMetadata, obj) { READWRITE(obj.m_base_blockhash, obj.m_coins_count, obj.m_nchaintx); }
33+
SERIALIZE_METHODS(SnapshotMetadata, obj) { READWRITE(obj.m_base_blockhash, obj.m_coins_count); }
4134
};
4235

4336
#endif // BITCOIN_NODE_UTXO_SNAPSHOT_H

src/test/validation_chainstatemanager_tests.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
266266
metadata.m_base_blockhash = uint256::ONE;
267267
}));
268268

269-
constexpr int bad_nchaintx = 9999;
270-
271-
BOOST_REQUIRE(CreateAndActivateUTXOSnapshot(
272-
m_node, m_path_root, [](CAutoFile& auto_infile, SnapshotMetadata& metadata) {
273-
// Provide an nChainTx that differs from the hardcoded one.
274-
//
275-
// Ultimately this malleation check should be removed when we remove
276-
// the now-unnecessary nChainTx from the user-specified snapshot metadata.
277-
metadata.m_nchaintx = bad_nchaintx;
278-
}));
269+
BOOST_REQUIRE(CreateAndActivateUTXOSnapshot(m_node, m_path_root));
279270

280271
// Ensure our active chain is the snapshot chainstate.
281272
BOOST_CHECK(!chainman.ActiveChainstate().m_from_snapshot_blockhash.IsNull());
@@ -286,10 +277,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
286277
const AssumeutxoData& au_data = *ExpectedAssumeutxo(snapshot_height, ::Params());
287278
const CBlockIndex* tip = chainman.ActiveTip();
288279

289-
// Ensure that, despite a bad nChainTx value being in the snapshot, activation
290-
// uses the hardcoded value from chainparams.
291280
BOOST_CHECK_EQUAL(tip->nChainTx, au_data.nChainTx);
292-
BOOST_CHECK(tip->nChainTx != bad_nchaintx);
293281

294282
// To be checked against later when we try loading a subsequent snapshot.
295283
uint256 loaded_snapshot_blockhash{*chainman.SnapshotBlockhash()};

test/functional/rpc_dumptxoutset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def run_test(self):
4141
digest = hashlib.sha256(f.read()).hexdigest()
4242
# UTXO snapshot hash should be deterministic based on mocked time.
4343
assert_equal(
44-
digest, 'be032e5f248264ba08e11099ac09dbd001f6f87ffc68bf0f87043d8146d50664')
44+
digest, '7ae82c986fa5445678d2a21453bb1c86d39e47af13da137640c2b1cf8093691c')
4545

4646
# Specifying a path to an existing file will fail.
4747
assert_raises_rpc_error(

0 commit comments

Comments
 (0)