Bitcoin Core  22.99.0
P2P Digital Currency
validation_chainstatemanager_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2019-2021 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 //
5 #include <chainparams.h>
6 #include <consensus/validation.h>
7 #include <node/utxo_snapshot.h>
8 #include <random.h>
9 #include <rpc/blockchain.h>
10 #include <sync.h>
11 #include <test/util/chainstate.h>
12 #include <test/util/setup_common.h>
13 #include <uint256.h>
14 #include <validation.h>
15 #include <validationinterface.h>
16 
17 #include <tinyformat.h>
18 
19 #include <vector>
20 
21 #include <boost/test/unit_test.hpp>
22 
24 
25 BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, ChainTestingSetup)
26 
27 BOOST_AUTO_TEST_CASE(chainstatemanager)
31 {
32  ChainstateManager& manager = *m_node.chainman;
33  CTxMemPool& mempool = *m_node.mempool;
34 
35  std::vector<CChainState*> chainstates;
36 
37  BOOST_CHECK(!manager.SnapshotBlockhash().has_value());
38 
39  // Create a legacy (IBD) chainstate.
40  //
41  CChainState& c1 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(&mempool));
42  chainstates.push_back(&c1);
43  c1.InitCoinsDB(
44  /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
45  WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));
46 
47  BOOST_CHECK(!manager.IsSnapshotActive());
48  BOOST_CHECK(!manager.IsSnapshotValidated());
49  auto all = manager.GetAll();
50  BOOST_CHECK_EQUAL_COLLECTIONS(all.begin(), all.end(), chainstates.begin(), chainstates.end());
51 
52  auto& active_chain = manager.ActiveChain();
53  BOOST_CHECK_EQUAL(&active_chain, &c1.m_chain);
54 
55  BOOST_CHECK_EQUAL(manager.ActiveHeight(), -1);
56 
57  auto active_tip = manager.ActiveTip();
58  auto exp_tip = c1.m_chain.Tip();
59  BOOST_CHECK_EQUAL(active_tip, exp_tip);
60 
61  BOOST_CHECK(!manager.SnapshotBlockhash().has_value());
62 
63  // Create a snapshot-based chainstate.
64  //
65  const uint256 snapshot_blockhash = GetRandHash();
66  CChainState& c2 = WITH_LOCK(::cs_main, return manager.InitializeChainstate(
67  &mempool, snapshot_blockhash));
68  chainstates.push_back(&c2);
69 
70  BOOST_CHECK_EQUAL(manager.SnapshotBlockhash().value(), snapshot_blockhash);
71 
72  c2.InitCoinsDB(
73  /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
74  WITH_LOCK(::cs_main, c2.InitCoinsCache(1 << 23));
75  // Unlike c1, which doesn't have any blocks. Gets us different tip, height.
76  c2.LoadGenesisBlock();
78  BOOST_CHECK(c2.ActivateBestChain(_, nullptr));
79 
80  BOOST_CHECK(manager.IsSnapshotActive());
81  BOOST_CHECK(!manager.IsSnapshotValidated());
82  BOOST_CHECK_EQUAL(&c2, &manager.ActiveChainstate());
83  BOOST_CHECK(&c1 != &manager.ActiveChainstate());
84  auto all2 = manager.GetAll();
85  BOOST_CHECK_EQUAL_COLLECTIONS(all2.begin(), all2.end(), chainstates.begin(), chainstates.end());
86 
87  auto& active_chain2 = manager.ActiveChain();
88  BOOST_CHECK_EQUAL(&active_chain2, &c2.m_chain);
89 
90  BOOST_CHECK_EQUAL(manager.ActiveHeight(), 0);
91 
92  auto active_tip2 = manager.ActiveTip();
93  auto exp_tip2 = c2.m_chain.Tip();
94  BOOST_CHECK_EQUAL(active_tip2, exp_tip2);
95 
96  // Ensure that these pointers actually correspond to different
97  // CCoinsViewCache instances.
98  BOOST_CHECK(exp_tip != exp_tip2);
99 
100  // Let scheduler events finish running to avoid accessing memory that is going to be unloaded
102 
103  WITH_LOCK(::cs_main, manager.Unload());
104 }
105 
107 BOOST_AUTO_TEST_CASE(chainstatemanager_rebalance_caches)
108 {
109  ChainstateManager& manager = *m_node.chainman;
110  CTxMemPool& mempool = *m_node.mempool;
111 
112  size_t max_cache = 10000;
113  manager.m_total_coinsdb_cache = max_cache;
114  manager.m_total_coinstip_cache = max_cache;
115 
116  std::vector<CChainState*> chainstates;
117 
118  // Create a legacy (IBD) chainstate.
119  //
120  CChainState& c1 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool));
121  chainstates.push_back(&c1);
122  c1.InitCoinsDB(
123  /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
124 
125  {
126  LOCK(::cs_main);
127  c1.InitCoinsCache(1 << 23);
128  BOOST_REQUIRE(c1.LoadGenesisBlock());
130  manager.MaybeRebalanceCaches();
131  }
132 
135 
136  // Create a snapshot-based chainstate.
137  //
138  CChainState& c2 = WITH_LOCK(cs_main, return manager.InitializeChainstate(&mempool, GetRandHash()));
139  chainstates.push_back(&c2);
140  c2.InitCoinsDB(
141  /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
142 
143  {
144  LOCK(::cs_main);
145  c2.InitCoinsCache(1 << 23);
146  BOOST_REQUIRE(c2.LoadGenesisBlock());
148  manager.MaybeRebalanceCaches();
149  }
150 
151  // Since both chainstates are considered to be in initial block download,
152  // the snapshot chainstate should take priority.
153  BOOST_CHECK_CLOSE(c1.m_coinstip_cache_size_bytes, max_cache * 0.05, 1);
154  BOOST_CHECK_CLOSE(c1.m_coinsdb_cache_size_bytes, max_cache * 0.05, 1);
155  BOOST_CHECK_CLOSE(c2.m_coinstip_cache_size_bytes, max_cache * 0.95, 1);
156  BOOST_CHECK_CLOSE(c2.m_coinsdb_cache_size_bytes, max_cache * 0.95, 1);
157 }
158 
160 BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
161 {
162  ChainstateManager& chainman = *Assert(m_node.chainman);
163 
164  size_t initial_size;
165  size_t initial_total_coins{100};
166 
167  // Make some initial assertions about the contents of the chainstate.
168  {
169  LOCK(::cs_main);
170  CCoinsViewCache& ibd_coinscache = chainman.ActiveChainstate().CoinsTip();
171  initial_size = ibd_coinscache.GetCacheSize();
172  size_t total_coins{0};
173 
174  for (CTransactionRef& txn : m_coinbase_txns) {
175  COutPoint op{txn->GetHash(), 0};
176  BOOST_CHECK(ibd_coinscache.HaveCoin(op));
177  total_coins++;
178  }
179 
180  BOOST_CHECK_EQUAL(total_coins, initial_total_coins);
181  BOOST_CHECK_EQUAL(initial_size, initial_total_coins);
182  }
183 
184  // Snapshot should refuse to load at this height.
185  BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(m_node, m_path_root));
187  BOOST_CHECK(!chainman.SnapshotBlockhash());
188 
189  // Mine 10 more blocks, putting at us height 110 where a valid assumeutxo value can
190  // be found.
191  constexpr int snapshot_height = 110;
192  mineBlocks(10);
193  initial_size += 10;
194  initial_total_coins += 10;
195 
196  // Should not load malleated snapshots
197  BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
198  m_node, m_path_root, [](CAutoFile& auto_infile, SnapshotMetadata& metadata) {
199  // A UTXO is missing but count is correct
200  metadata.m_coins_count -= 1;
201 
202  COutPoint outpoint;
203  Coin coin;
204 
205  auto_infile >> outpoint;
206  auto_infile >> coin;
207  }));
208  BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
209  m_node, m_path_root, [](CAutoFile& auto_infile, SnapshotMetadata& metadata) {
210  // Coins count is larger than coins in file
211  metadata.m_coins_count += 1;
212  }));
213  BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
214  m_node, m_path_root, [](CAutoFile& auto_infile, SnapshotMetadata& metadata) {
215  // Coins count is smaller than coins in file
216  metadata.m_coins_count -= 1;
217  }));
218  BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
219  m_node, m_path_root, [](CAutoFile& auto_infile, SnapshotMetadata& metadata) {
220  // Wrong hash
221  metadata.m_base_blockhash = uint256::ZERO;
222  }));
223  BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
224  m_node, m_path_root, [](CAutoFile& auto_infile, SnapshotMetadata& metadata) {
225  // Wrong hash
226  metadata.m_base_blockhash = uint256::ONE;
227  }));
228 
229  BOOST_REQUIRE(CreateAndActivateUTXOSnapshot(m_node, m_path_root));
230 
231  // Ensure our active chain is the snapshot chainstate.
235  *chainman.SnapshotBlockhash());
236 
237  // Ensure that the genesis block was not marked assumed-valid.
238  BOOST_CHECK(!chainman.ActiveChain().Genesis()->IsAssumedValid());
239 
240  const AssumeutxoData& au_data = *ExpectedAssumeutxo(snapshot_height, ::Params());
241  const CBlockIndex* tip = chainman.ActiveTip();
242 
243  BOOST_CHECK_EQUAL(tip->nChainTx, au_data.nChainTx);
244 
245  // To be checked against later when we try loading a subsequent snapshot.
246  uint256 loaded_snapshot_blockhash{*chainman.SnapshotBlockhash()};
247 
248  // Make some assertions about the both chainstates. These checks ensure the
249  // legacy chainstate hasn't changed and that the newly created chainstate
250  // reflects the expected content.
251  {
252  LOCK(::cs_main);
253  int chains_tested{0};
254 
255  for (CChainState* chainstate : chainman.GetAll()) {
256  BOOST_TEST_MESSAGE("Checking coins in " << chainstate->ToString());
257  CCoinsViewCache& coinscache = chainstate->CoinsTip();
258 
259  // Both caches will be empty initially.
260  BOOST_CHECK_EQUAL((unsigned int)0, coinscache.GetCacheSize());
261 
262  size_t total_coins{0};
263 
264  for (CTransactionRef& txn : m_coinbase_txns) {
265  COutPoint op{txn->GetHash(), 0};
266  BOOST_CHECK(coinscache.HaveCoin(op));
267  total_coins++;
268  }
269 
270  BOOST_CHECK_EQUAL(initial_size , coinscache.GetCacheSize());
271  BOOST_CHECK_EQUAL(total_coins, initial_total_coins);
272  chains_tested++;
273  }
274 
275  BOOST_CHECK_EQUAL(chains_tested, 2);
276  }
277 
278  // Mine some new blocks on top of the activated snapshot chainstate.
279  constexpr size_t new_coins{100};
280  mineBlocks(new_coins); // Defined in TestChain100Setup.
281 
282  {
283  LOCK(::cs_main);
284  size_t coins_in_active{0};
285  size_t coins_in_background{0};
286  size_t coins_missing_from_background{0};
287 
288  for (CChainState* chainstate : chainman.GetAll()) {
289  BOOST_TEST_MESSAGE("Checking coins in " << chainstate->ToString());
290  CCoinsViewCache& coinscache = chainstate->CoinsTip();
291  bool is_background = chainstate != &chainman.ActiveChainstate();
292 
293  for (CTransactionRef& txn : m_coinbase_txns) {
294  COutPoint op{txn->GetHash(), 0};
295  if (coinscache.HaveCoin(op)) {
296  (is_background ? coins_in_background : coins_in_active)++;
297  } else if (is_background) {
298  coins_missing_from_background++;
299  }
300  }
301  }
302 
303  BOOST_CHECK_EQUAL(coins_in_active, initial_total_coins + new_coins);
304  BOOST_CHECK_EQUAL(coins_in_background, initial_total_coins);
305  BOOST_CHECK_EQUAL(coins_missing_from_background, new_coins);
306  }
307 
308  // Snapshot should refuse to load after one has already loaded.
309  BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(m_node, m_path_root));
310 
311  // Snapshot blockhash should be unchanged.
314  loaded_snapshot_blockhash);
315 }
316 
327 BOOST_FIXTURE_TEST_CASE(chainstatemanager_loadblockindex, TestChain100Setup)
328 {
329  ChainstateManager& chainman = *Assert(m_node.chainman);
330  CTxMemPool& mempool = *m_node.mempool;
331  CChainState& cs1 = chainman.ActiveChainstate();
332 
333  int num_indexes{0};
334  int num_assumed_valid{0};
335  const int expected_assumed_valid{20};
336  const int last_assumed_valid_idx{40};
337  const int assumed_valid_start_idx = last_assumed_valid_idx - expected_assumed_valid;
338 
339  CBlockIndex* validated_tip{nullptr};
340  CBlockIndex* assumed_tip{chainman.ActiveChain().Tip()};
341 
342  auto reload_all_block_indexes = [&]() {
343  for (CChainState* cs : chainman.GetAll()) {
344  LOCK(::cs_main);
345  cs->UnloadBlockIndex();
346  BOOST_CHECK(cs->setBlockIndexCandidates.empty());
347  }
348 
349  WITH_LOCK(::cs_main, chainman.LoadBlockIndex());
350  };
351 
352  // Ensure that without any assumed-valid BlockIndex entries, all entries are considered
353  // tip candidates.
354  reload_all_block_indexes();
356 
357  // Mark some region of the chain assumed-valid.
358  for (int i = 0; i <= cs1.m_chain.Height(); ++i) {
359  auto index = cs1.m_chain[i];
360 
361  if (i < last_assumed_valid_idx && i >= assumed_valid_start_idx) {
363  }
364 
365  ++num_indexes;
366  if (index->IsAssumedValid()) ++num_assumed_valid;
367 
368  // Note the last fully-validated block as the expected validated tip.
369  if (i == (assumed_valid_start_idx - 1)) {
370  validated_tip = index;
371  BOOST_CHECK(!index->IsAssumedValid());
372  }
373  }
374 
375  BOOST_CHECK_EQUAL(expected_assumed_valid, num_assumed_valid);
376 
377  CChainState& cs2 = WITH_LOCK(::cs_main,
378  return chainman.InitializeChainstate(&mempool, GetRandHash()));
379 
380  reload_all_block_indexes();
381 
382  // The fully validated chain only has candidates up to the start of the assumed-valid
383  // blocks.
384  BOOST_CHECK_EQUAL(cs1.setBlockIndexCandidates.count(validated_tip), 1);
385  BOOST_CHECK_EQUAL(cs1.setBlockIndexCandidates.count(assumed_tip), 0);
386  BOOST_CHECK_EQUAL(cs1.setBlockIndexCandidates.size(), assumed_valid_start_idx);
387 
388  // The assumed-valid tolerant chain has all blocks as candidates.
389  BOOST_CHECK_EQUAL(cs2.setBlockIndexCandidates.count(validated_tip), 1);
390  BOOST_CHECK_EQUAL(cs2.setBlockIndexCandidates.count(assumed_tip), 1);
391  BOOST_CHECK_EQUAL(cs2.setBlockIndexCandidates.size(), num_indexes);
392 }
393 
_
bilingual_str _(const char *psz)
Translation function.
Definition: translation.h:63
CCoinsViewCache::GetCacheSize
unsigned int GetCacheSize() const
Calculate the size of the cache (in number of transaction outputs)
Definition: coins.cpp:257
ChainstateManager::m_total_coinstip_cache
int64_t m_total_coinstip_cache
The total number of bytes available for us to use across all in-memory coins caches.
Definition: validation.h:872
node::SnapshotMetadata
Metadata describing a serialized version of a UTXO set from which an assumeutxo CChainState can be co...
Definition: utxo_snapshot.h:15
BlockValidationState
Definition: validation.h:141
setup_common.h
BLOCK_VALID_TREE
@ BLOCK_VALID_TREE
All parent headers found, difficulty matches, timestamp >= median previous, checkpoint.
Definition: chain.h:104
CCoinsViewCache::HaveCoin
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: coins.cpp:159
AssumeutxoData
Holds configuration for use during UTXO snapshot load and validation.
Definition: chainparams.h:40
node::SnapshotMetadata::m_coins_count
uint64_t m_coins_count
The number of coins in the UTXO set contained in this snapshot.
Definition: utxo_snapshot.h:24
sync.h
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:429
uint256.h
InsecureRand256
static uint256 InsecureRand256()
Definition: setup_common.h:73
m_node
node::NodeContext m_node
Definition: bitcoin-gui.cpp:36
validationinterface.h
validation.h
CBlockIndex::IsAssumedValid
bool IsAssumedValid() const
Definition: chain.h:318
WITH_LOCK
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition: sync.h:270
CBlockIndex::nChainTx
unsigned int nChainTx
(memory only) Number of transactions in the chain up to and including this block.
Definition: chain.h:190
node::SnapshotMetadata::m_base_blockhash
uint256 m_base_blockhash
The hash of the block that reflects the tip of the chain for the UTXO set contained in this snapshot.
Definition: utxo_snapshot.h:20
chainparams.h
CChainState::setBlockIndexCandidates
std::set< CBlockIndex *, node::CBlockIndexWorkComparator > setBlockIndexCandidates
The set of all CBlockIndex entries with either BLOCK_VALID_TRANSACTIONS (for itself and all ancestors...
Definition: validation.h:556
ChainstateManager::ActiveChainstate
CChainState & ActiveChainstate() const
The most-work chain.
Definition: validation.cpp:4981
CTransactionRef
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:386
CChainState::ActivateBestChain
bool ActivateBestChain(BlockValidationState &state, std::shared_ptr< const CBlock > pblock=nullptr) LOCKS_EXCLUDED(cs_main)
Find the best known block, and make it the tip of the block chain.
Definition: validation.cpp:2848
BOOST_FIXTURE_TEST_SUITE
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
CChain::Tip
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
Definition: chain.h:434
node::NodeContext::mempool
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:45
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
Assert
#define Assert(val)
Identity function.
Definition: check.h:57
BOOST_FIXTURE_TEST_CASE
BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
Test basic snapshot activation.
Definition: validation_chainstatemanager_tests.cpp:160
cs
static void pool cs
Definition: mempool_eviction.cpp:12
tinyformat.h
ChainstateManager::ActiveChain
CChain & ActiveChain() const
Definition: validation.h:911
CAutoFile
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:544
SyncWithValidationInterfaceQueue
void SyncWithValidationInterfaceQueue()
This is a synonym for the following, which asserts certain locks are not held: std::promise<void> pro...
Definition: validationinterface.cpp:160
ChainstateManager::IsSnapshotActive
bool IsSnapshotActive() const
Definition: validation.cpp:4988
random.h
ChainstateManager::ActiveTip
CBlockIndex * ActiveTip() const
Definition: validation.h:913
Coin
A UTXO entry.
Definition: coins.h:30
ChainstateManager::SnapshotBlockhash
std::optional< uint256 > SnapshotBlockhash() const
Definition: validation.cpp:4630
ChainstateManager::ActiveHeight
int ActiveHeight() const
Definition: validation.h:912
ChainstateManager::IsSnapshotValidated
bool IsSnapshotValidated() const
Is there a snapshot in use and has it been fully validated?
Definition: validation.h:927
GetRandHash
uint256 GetRandHash() noexcept
Definition: random.cpp:602
CChainState::m_from_snapshot_blockhash
const std::optional< uint256 > m_from_snapshot_blockhash
The blockhash which is the base of the snapshot this chainstate was created from.
Definition: validation.h:544
BLOCK_ASSUMED_VALID
@ BLOCK_ASSUMED_VALID
If set, this indicates that the block index entry is assumed-valid.
Definition: chain.h:140
TestChain100Setup
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
Definition: setup_common.h:124
uint256::ZERO
static const uint256 ZERO
Definition: uint256.h:129
utxo_snapshot.h
uint256
256-bit opaque blob.
Definition: uint256.h:124
ChainstateManager::GetAll
CChainState &InitializeChainstate(CTxMemPool *mempool, const std::optional< uint256 > &snapshot_blockhash=std::nullopt) LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(std::vector< CChainState * GetAll)()
Instantiate a new chainstate and assign it based upon whether it is from a snapshot.
Definition: validation.h:891
CChainState
CChainState stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:459
ExpectedAssumeutxo
const AssumeutxoData * ExpectedAssumeutxo(const int height, const CChainParams &chainparams)
Return the expected assumeutxo value for a given height, if one exists.
Definition: validation.cpp:4679
CChainState::m_coinsdb_cache_size_bytes
size_t m_coinsdb_cache_size_bytes
The cache size of the on-disk coins view.
Definition: validation.h:588
CChain::Height
int Height() const
Return the maximal height in the chain.
Definition: chain.h:463
ChainstateManager
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:777
cs_main
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: validation.cpp:138
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:213
CCoinsViewCache::SetBestBlock
void SetBestBlock(const uint256 &hashBlock)
Definition: coins.cpp:175
chainstate.h
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(chainstatemanager)
Basic tests for ChainstateManager.
Definition: validation_chainstatemanager_tests.cpp:30
LOCK
#define LOCK(cs)
Definition: sync.h:226
CreateAndActivateUTXOSnapshot
static bool CreateAndActivateUTXOSnapshot(node::NodeContext &node, const fs::path root, F malleation=NoMalleation)
Create and activate a UTXO snapshot, optionally providing a function to malleate the snapshot.
Definition: chainstate.h:27
ChainstateManager::LoadBlockIndex
bool LoadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Load the block tree and coins database from disk, initializing state if we're running with -reindex.
Definition: validation.cpp:4037
Params
const CChainParams & Params()
Return the currently selected parameters.
Definition: chainparams.cpp:561
node::NodeContext::chainman
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:48
CChainState::InitCoinsDB
void InitCoinsDB(size_t cache_size_bytes, bool in_memory, bool should_wipe, std::string leveldb_name="chainstate")
Initialize the CoinsViews UTXO set database management data structures.
Definition: validation.cpp:1438
AssumeutxoData::nChainTx
const unsigned int nChainTx
Used to populate the nChainTx value, which is used during BlockManager::LoadBlockIndex().
Definition: chainparams.h:48
ChainstateManager::m_total_coinsdb_cache
int64_t m_total_coinsdb_cache
The total number of bytes available for us to use across all leveldb coins databases.
Definition: validation.h:876
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
blockchain.h
CBlockIndex
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:148
CChainState::m_coinstip_cache_size_bytes
size_t m_coinstip_cache_size_bytes
The cache size of the in-memory coins view.
Definition: validation.h:591
CChainState::LoadGenesisBlock
bool LoadGenesisBlock()
Ensures we have a genesis block in the block tree, possibly writing one to disk.
Definition: validation.cpp:4060
CChainState::CoinsTip
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Definition: validation.h:559
CChain::Genesis
CBlockIndex * Genesis() const
Returns the index entry for the genesis block of this chain, or nullptr if none.
Definition: chain.h:428
BOOST_CHECK
#define BOOST_CHECK(expr)
Definition: object.cpp:17
BOOST_CHECK_EQUAL
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18
CChainState::m_chain
CChain m_chain
The current chain of blockheaders we consult and build on.
Definition: validation.h:537
ChainTestingSetup
Testing setup that performs all steps up until right before ChainstateManager gets initialized.
Definition: setup_common.h:98
uint256::ONE
static const uint256 ONE
Definition: uint256.h:130