mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
assumeutxo: Remove BLOCK_ASSUMED_VALID flag
Flag adds complexity and is not currently used for anything.
This commit is contained in:
@@ -276,9 +276,6 @@ struct SnapshotTestSetup : TestChain100Setup {
|
||||
BOOST_CHECK_EQUAL(
|
||||
*node::ReadSnapshotBaseBlockhash(found),
|
||||
*chainman.SnapshotBlockhash());
|
||||
|
||||
// Ensure that the genesis block was not marked assumed-valid.
|
||||
BOOST_CHECK(!chainman.ActiveChain().Genesis()->IsAssumedValid());
|
||||
}
|
||||
|
||||
const auto& au_data = ::Params().AssumeutxoForHeight(snapshot_height);
|
||||
@@ -410,7 +407,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, SnapshotTestSetup)
|
||||
//! - First, verify that setBlockIndexCandidates is as expected when using a single,
|
||||
//! fully-validating chainstate.
|
||||
//!
|
||||
//! - Then mark a region of the chain BLOCK_ASSUMED_VALID and introduce a second chainstate
|
||||
//! - Then mark a region of the chain as missing data and introduce a second chainstate
|
||||
//! that will tolerate assumed-valid blocks. Run LoadBlockIndex() and ensure that the first
|
||||
//! chainstate only contains fully validated blocks and the other chainstate contains all blocks,
|
||||
//! except those marked assume-valid, because those entries don't HAVE_DATA.
|
||||
@@ -421,7 +418,6 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_loadblockindex, TestChain100Setup)
|
||||
Chainstate& cs1 = chainman.ActiveChainstate();
|
||||
|
||||
int num_indexes{0};
|
||||
int num_assumed_valid{0};
|
||||
// Blocks in range [assumed_valid_start_idx, last_assumed_valid_idx) will be
|
||||
// marked as assumed-valid and not having data.
|
||||
const int expected_assumed_valid{20};
|
||||
@@ -456,37 +452,30 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_loadblockindex, TestChain100Setup)
|
||||
reload_all_block_indexes();
|
||||
BOOST_CHECK_EQUAL(cs1.setBlockIndexCandidates.size(), 1);
|
||||
|
||||
// Mark some region of the chain assumed-valid, and remove the HAVE_DATA flag.
|
||||
// Reset some region of the chain's nStatus, removing the HAVE_DATA flag.
|
||||
for (int i = 0; i <= cs1.m_chain.Height(); ++i) {
|
||||
LOCK(::cs_main);
|
||||
auto index = cs1.m_chain[i];
|
||||
|
||||
// Blocks with heights in range [91, 110] are marked ASSUMED_VALID
|
||||
// Blocks with heights in range [91, 110] are marked as missing data.
|
||||
if (i < last_assumed_valid_idx && i >= assumed_valid_start_idx) {
|
||||
index->nStatus = BlockStatus::BLOCK_VALID_TREE | BlockStatus::BLOCK_ASSUMED_VALID;
|
||||
index->nStatus = BlockStatus::BLOCK_VALID_TREE;
|
||||
index->nTx = 0;
|
||||
index->nChainTx = 0;
|
||||
}
|
||||
|
||||
++num_indexes;
|
||||
if (index->IsAssumedValid()) ++num_assumed_valid;
|
||||
|
||||
// Note the last fully-validated block as the expected validated tip.
|
||||
if (i == (assumed_valid_start_idx - 1)) {
|
||||
validated_tip = index;
|
||||
BOOST_CHECK(!index->IsAssumedValid());
|
||||
}
|
||||
// Note the last assumed valid block as the snapshot base
|
||||
if (i == last_assumed_valid_idx - 1) {
|
||||
assumed_base = index;
|
||||
BOOST_CHECK(index->IsAssumedValid());
|
||||
} else if (i == last_assumed_valid_idx) {
|
||||
BOOST_CHECK(!index->IsAssumedValid());
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_CHECK_EQUAL(expected_assumed_valid, num_assumed_valid);
|
||||
|
||||
// Note: cs2's tip is not set when ActivateExistingSnapshot is called.
|
||||
Chainstate& cs2 = WITH_LOCK(::cs_main,
|
||||
return chainman.ActivateExistingSnapshot(*assumed_base->phashBlock));
|
||||
|
||||
Reference in New Issue
Block a user