Bitcoin Core 30.99.0
P2P Digital Currency
validation_chainstatemanager_tests.cpp
Go to the documentation of this file.
1// Copyright (c) 2019-present 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>
10#include <node/utxo_snapshot.h>
11#include <random.h>
12#include <rpc/blockchain.h>
13#include <sync.h>
15#include <test/util/logging.h>
16#include <test/util/random.h>
19#include <uint256.h>
20#include <util/result.h>
21#include <util/vector.h>
22#include <validation.h>
23#include <validationinterface.h>
24
25#include <tinyformat.h>
26
27#include <vector>
28
29#include <boost/test/unit_test.hpp>
30
34
35BOOST_FIXTURE_TEST_SUITE(validation_chainstatemanager_tests, TestingSetup)
36
37
41{
43
45
46 // Create a legacy (IBD) chainstate.
47 //
48 Chainstate& c1 = manager.ActiveChainstate();
49
51 {
52 LOCK(manager.GetMutex());
53 BOOST_CHECK_EQUAL(manager.m_chainstates.size(), 1);
54 BOOST_CHECK_EQUAL(manager.m_chainstates[0].get(), &c1);
55 }
56
57 auto& active_chain = WITH_LOCK(manager.GetMutex(), return manager.ActiveChain());
58 BOOST_CHECK_EQUAL(&active_chain, &c1.m_chain);
59
60 // Get to a valid assumeutxo tip (per chainparams);
61 mineBlocks(10);
62 BOOST_CHECK_EQUAL(WITH_LOCK(manager.GetMutex(), return manager.ActiveHeight()), 110);
63 auto active_tip = WITH_LOCK(manager.GetMutex(), return manager.ActiveTip());
64 auto exp_tip = c1.m_chain.Tip();
65 BOOST_CHECK_EQUAL(active_tip, exp_tip);
66
68
69 // Create a snapshot-based chainstate.
70 //
71 const uint256 snapshot_blockhash = active_tip->GetBlockHash();
72 Chainstate& c2{WITH_LOCK(::cs_main, return manager.AddChainstate(std::make_unique<Chainstate>(nullptr, manager.m_blockman, manager, snapshot_blockhash)))};
73 c2.InitCoinsDB(
74 /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
75 {
77 c2.InitCoinsCache(1 << 23);
78 c2.CoinsTip().SetBestBlock(active_tip->GetBlockHash());
79 c2.setBlockIndexCandidates.insert(manager.m_blockman.LookupBlockIndex(active_tip->GetBlockHash()));
80 c2.LoadChainTip();
81 }
83 BOOST_CHECK(c2.ActivateBestChain(_, nullptr));
84
87 BOOST_CHECK_EQUAL(&c2, &manager.ActiveChainstate());
88 BOOST_CHECK(&c1 != &manager.ActiveChainstate());
89 {
90 LOCK(manager.GetMutex());
91 BOOST_CHECK_EQUAL(manager.m_chainstates.size(), 2);
92 BOOST_CHECK_EQUAL(manager.m_chainstates[0].get(), &c1);
93 BOOST_CHECK_EQUAL(manager.m_chainstates[1].get(), &c2);
94 }
95
96 auto& active_chain2 = WITH_LOCK(manager.GetMutex(), return manager.ActiveChain());
97 BOOST_CHECK_EQUAL(&active_chain2, &c2.m_chain);
98
99 BOOST_CHECK_EQUAL(WITH_LOCK(manager.GetMutex(), return manager.ActiveHeight()), 110);
100 mineBlocks(1);
101 BOOST_CHECK_EQUAL(WITH_LOCK(manager.GetMutex(), return manager.ActiveHeight()), 111);
102 BOOST_CHECK_EQUAL(WITH_LOCK(manager.GetMutex(), return c1.m_chain.Height()), 110);
103
104 auto active_tip2 = WITH_LOCK(manager.GetMutex(), return manager.ActiveTip());
105 BOOST_CHECK_EQUAL(active_tip, active_tip2->pprev);
106 BOOST_CHECK_EQUAL(active_tip, c1.m_chain.Tip());
107 BOOST_CHECK_EQUAL(active_tip2, c2.m_chain.Tip());
108
109 // Let scheduler events finish running to avoid accessing memory that is going to be unloaded
110 m_node.validation_signals->SyncWithValidationInterfaceQueue();
111}
112
114BOOST_FIXTURE_TEST_CASE(chainstatemanager_rebalance_caches, TestChain100Setup)
115{
117
118 size_t max_cache = 10000;
119 manager.m_total_coinsdb_cache = max_cache;
120 manager.m_total_coinstip_cache = max_cache;
121
122 std::vector<Chainstate*> chainstates;
123
124 // Create a legacy (IBD) chainstate.
125 //
126 Chainstate& c1 = manager.ActiveChainstate();
127 chainstates.push_back(&c1);
128 {
130 c1.InitCoinsCache(1 << 23);
131 manager.MaybeRebalanceCaches();
132 }
133
136
137 // Create a snapshot-based chainstate.
138 //
139 CBlockIndex* snapshot_base{WITH_LOCK(manager.GetMutex(), return manager.ActiveChain()[manager.ActiveChain().Height() / 2])};
140 Chainstate& c2{WITH_LOCK(::cs_main, return manager.AddChainstate(std::make_unique<Chainstate>(nullptr, manager.m_blockman, manager, *snapshot_base->phashBlock)))};
141 chainstates.push_back(&c2);
142 c2.InitCoinsDB(
143 /*cache_size_bytes=*/1 << 23, /*in_memory=*/true, /*should_wipe=*/false);
144
145 // Reset IBD state so IsInitialBlockDownload() returns true and causes
146 // MaybeRebalanceCaches() to prioritize the snapshot chainstate, giving it
147 // more cache space than the snapshot chainstate. Calling ResetIbd() is
148 // necessary because m_cached_is_ibd is already latched to false before
149 // the test starts due to the test setup. After ResetIbd() is called,
150 // IsInitialBlockDownload() will return true because at this point the active
151 // chainstate has a null chain tip.
152 static_cast<TestChainstateManager&>(manager).ResetIbd();
153
154 {
156 c2.InitCoinsCache(1 << 23);
157 manager.MaybeRebalanceCaches();
158 }
159
160 BOOST_CHECK_CLOSE(double(c1.m_coinstip_cache_size_bytes), max_cache * 0.05, 1);
161 BOOST_CHECK_CLOSE(double(c1.m_coinsdb_cache_size_bytes), max_cache * 0.05, 1);
162 BOOST_CHECK_CLOSE(double(c2.m_coinstip_cache_size_bytes), max_cache * 0.95, 1);
163 BOOST_CHECK_CLOSE(double(c2.m_coinsdb_cache_size_bytes), max_cache * 0.95, 1);
164}
165
166BOOST_FIXTURE_TEST_CASE(chainstatemanager_ibd_exit_after_loading_blocks, ChainTestingSetup)
167{
168 CBlockIndex tip;
170 auto apply{[&](bool cached_is_ibd, bool loading_blocks, bool tip_exists, bool enough_work, bool tip_recent) {
172 chainman.ResetChainstates();
173 chainman.InitializeChainstate(m_node.mempool.get());
174
175 const auto recent_time{Now<NodeSeconds>() - chainman.m_options.max_tip_age};
176
177 chainman.m_cached_is_ibd.store(cached_is_ibd, std::memory_order_relaxed);
178 chainman.m_blockman.m_importing = loading_blocks;
179 if (tip_exists) {
180 tip.nChainWork = chainman.MinimumChainWork() - (enough_work ? 0 : 1);
181 tip.nTime = (recent_time - (tip_recent ? 0h : 100h)).time_since_epoch().count();
182 chainman.ActiveChain().SetTip(tip);
183 } else {
184 assert(!chainman.ActiveChain().Tip());
185 }
186 chainman.UpdateIBDStatus();
187 }};
188
189 for (const bool cached_is_ibd : {false, true}) {
190 for (const bool loading_blocks : {false, true}) {
191 for (const bool tip_exists : {false, true}) {
192 for (const bool enough_work : {false, true}) {
193 for (const bool tip_recent : {false, true}) {
194 apply(cached_is_ibd, loading_blocks, tip_exists, enough_work, tip_recent);
195 const bool expected_ibd = cached_is_ibd && (loading_blocks || !tip_exists || !enough_work || !tip_recent);
196 BOOST_CHECK_EQUAL(chainman.IsInitialBlockDownload(), expected_ibd);
197 }
198 }
199 }
200 }
201 }
202}
203
205 // Run with coinsdb on the filesystem to support, e.g., moving invalidated
206 // chainstate dirs to "*_invalid".
207 //
208 // Note that this means the tests run considerably slower than in-memory DB
209 // tests, but we can't otherwise test this functionality since it relies on
210 // destructive filesystem operations.
212 {},
213 {
214 .coins_db_in_memory = false,
215 .block_tree_db_in_memory = false,
216 },
217 }
218 {
219 }
220
221 std::tuple<Chainstate*, Chainstate*> SetupSnapshot()
222 {
224
225 {
229 }
230
231 size_t initial_size;
232 size_t initial_total_coins{100};
233
234 // Make some initial assertions about the contents of the chainstate.
235 {
237 CCoinsViewCache& ibd_coinscache = chainman.ActiveChainstate().CoinsTip();
238 initial_size = ibd_coinscache.GetCacheSize();
239 size_t total_coins{0};
240
241 for (CTransactionRef& txn : m_coinbase_txns) {
242 COutPoint op{txn->GetHash(), 0};
243 BOOST_CHECK(ibd_coinscache.HaveCoin(op));
244 total_coins++;
245 }
246
247 BOOST_CHECK_EQUAL(total_coins, initial_total_coins);
248 BOOST_CHECK_EQUAL(initial_size, initial_total_coins);
249 }
250
251 Chainstate& validation_chainstate = chainman.ActiveChainstate();
252
253 // Snapshot should refuse to load at this height.
254 BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(this));
256
257 // Mine 10 more blocks, putting at us height 110 where a valid assumeutxo value can
258 // be found.
259 constexpr int snapshot_height = 110;
260 mineBlocks(10);
261 initial_size += 10;
262 initial_total_coins += 10;
263
264 // Should not load malleated snapshots
265 BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
266 this, [](AutoFile& auto_infile, SnapshotMetadata& metadata) {
267 // A UTXO is missing but count is correct
268 metadata.m_coins_count -= 1;
269
270 Txid txid;
271 auto_infile >> txid;
272 // coins size
273 (void)ReadCompactSize(auto_infile);
274 // vout index
275 (void)ReadCompactSize(auto_infile);
276 Coin coin;
277 auto_infile >> coin;
278 }));
279
281
282 BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
283 this, [](AutoFile& auto_infile, SnapshotMetadata& metadata) {
284 // Coins count is larger than coins in file
285 metadata.m_coins_count += 1;
286 }));
287 BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
288 this, [](AutoFile& auto_infile, SnapshotMetadata& metadata) {
289 // Coins count is smaller than coins in file
290 metadata.m_coins_count -= 1;
291 }));
292 BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
293 this, [](AutoFile& auto_infile, SnapshotMetadata& metadata) {
294 // Wrong hash
296 }));
297 BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(
298 this, [](AutoFile& auto_infile, SnapshotMetadata& metadata) {
299 // Wrong hash
301 }));
302
303 BOOST_REQUIRE(CreateAndActivateUTXOSnapshot(this));
305
306 // Ensure our active chain is the snapshot chainstate.
308
309 Chainstate& snapshot_chainstate = chainman.ActiveChainstate();
310
311 {
313
314 fs::path found = *node::FindAssumeutxoChainstateDir(chainman.m_options.datadir);
315
316 // Note: WriteSnapshotBaseBlockhash() is implicitly tested above.
320 }
321
322 const auto& au_data = ::Params().AssumeutxoForHeight(snapshot_height);
323 const CBlockIndex* tip = WITH_LOCK(chainman.GetMutex(), return chainman.ActiveTip());
324
325 BOOST_CHECK_EQUAL(tip->m_chain_tx_count, au_data->m_chain_tx_count);
326
327 // To be checked against later when we try loading a subsequent snapshot.
328 uint256 loaded_snapshot_blockhash{*Assert(WITH_LOCK(chainman.GetMutex(), return chainman.CurrentChainstate().m_from_snapshot_blockhash))};
329
330 // Make some assertions about the both chainstates. These checks ensure the
331 // legacy chainstate hasn't changed and that the newly created chainstate
332 // reflects the expected content.
333 {
335 int chains_tested{0};
336
337 for (const auto& chainstate : chainman.m_chainstates) {
338 BOOST_TEST_MESSAGE("Checking coins in " << chainstate->ToString());
339 CCoinsViewCache& coinscache = chainstate->CoinsTip();
340
341 // Both caches will be empty initially.
342 BOOST_CHECK_EQUAL((unsigned int)0, coinscache.GetCacheSize());
343
344 size_t total_coins{0};
345
346 for (CTransactionRef& txn : m_coinbase_txns) {
347 COutPoint op{txn->GetHash(), 0};
348 BOOST_CHECK(coinscache.HaveCoin(op));
349 total_coins++;
350 }
351
352 BOOST_CHECK_EQUAL(initial_size , coinscache.GetCacheSize());
353 BOOST_CHECK_EQUAL(total_coins, initial_total_coins);
354 chains_tested++;
355 }
356
357 BOOST_CHECK_EQUAL(chains_tested, 2);
358 }
359
360 // Mine some new blocks on top of the activated snapshot chainstate.
361 constexpr size_t new_coins{100};
362 mineBlocks(new_coins); // Defined in TestChain100Setup.
363
364 {
366 size_t coins_in_active{0};
367 size_t coins_in_background{0};
368 size_t coins_missing_from_background{0};
369
370 for (const auto& chainstate : chainman.m_chainstates) {
371 BOOST_TEST_MESSAGE("Checking coins in " << chainstate->ToString());
372 CCoinsViewCache& coinscache = chainstate->CoinsTip();
373 bool is_background = chainstate.get() != &chainman.ActiveChainstate();
374
375 for (CTransactionRef& txn : m_coinbase_txns) {
376 COutPoint op{txn->GetHash(), 0};
377 if (coinscache.HaveCoin(op)) {
378 (is_background ? coins_in_background : coins_in_active)++;
379 } else if (is_background) {
380 coins_missing_from_background++;
381 }
382 }
383 }
384
385 BOOST_CHECK_EQUAL(coins_in_active, initial_total_coins + new_coins);
386 BOOST_CHECK_EQUAL(coins_in_background, initial_total_coins);
387 BOOST_CHECK_EQUAL(coins_missing_from_background, new_coins);
388 }
389
390 // Snapshot should refuse to load after one has already loaded.
391 BOOST_REQUIRE(!CreateAndActivateUTXOSnapshot(this));
392
393 // Snapshot blockhash should be unchanged.
396 loaded_snapshot_blockhash);
397 return std::make_tuple(&validation_chainstate, &snapshot_chainstate);
398 }
399
400 // Simulate a restart of the node by flushing all state to disk, clearing the
401 // existing ChainstateManager, and unloading the block index.
402 //
403 // @returns a reference to the "restarted" ChainstateManager
405 {
407
408 BOOST_TEST_MESSAGE("Simulating node restart");
409 {
410 LOCK(chainman.GetMutex());
411 for (const auto& cs : chainman.m_chainstates) {
412 if (cs->CanFlushToDisk()) cs->ForceFlushStateToDisk();
413 }
414 }
415 {
416 // Process all callbacks referring to the old manager before wiping it.
417 m_node.validation_signals->SyncWithValidationInterfaceQueue();
419 chainman.ResetChainstates();
420 BOOST_CHECK_EQUAL(chainman.m_chainstates.size(), 0);
421 m_node.notifications = std::make_unique<KernelNotifications>(Assert(m_node.shutdown_request), m_node.exit_status, *Assert(m_node.warnings));
422 const ChainstateManager::Options chainman_opts{
424 .datadir = chainman.m_options.datadir,
425 .notifications = *m_node.notifications,
426 .signals = m_node.validation_signals.get(),
427 };
428 const BlockManager::Options blockman_opts{
429 .chainparams = chainman_opts.chainparams,
430 .blocks_dir = m_args.GetBlocksDirPath(),
431 .notifications = chainman_opts.notifications,
432 .block_tree_db_params = DBParams{
433 .path = chainman.m_options.datadir / "blocks" / "index",
434 .cache_bytes = m_kernel_cache_sizes.block_tree_db,
435 .memory_only = m_block_tree_db_in_memory,
436 },
437 };
438 // For robustness, ensure the old manager is destroyed before creating a
439 // new one.
440 m_node.chainman.reset();
441 m_node.chainman = std::make_unique<ChainstateManager>(*Assert(m_node.shutdown_signal), chainman_opts, blockman_opts);
442 }
443 return *Assert(m_node.chainman);
444 }
445};
446
448BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, SnapshotTestSetup)
449{
450 this->SetupSnapshot();
451}
452
463BOOST_FIXTURE_TEST_CASE(chainstatemanager_loadblockindex, TestChain100Setup)
464{
466 Chainstate& cs1 = chainman.ActiveChainstate();
467
468 int num_indexes{0};
469 // Blocks in range [assumed_valid_start_idx, last_assumed_valid_idx) will be
470 // marked as assumed-valid and not having data.
471 const int expected_assumed_valid{20};
472 const int last_assumed_valid_idx{111};
473 const int assumed_valid_start_idx = last_assumed_valid_idx - expected_assumed_valid;
474
475 // Mine to height 120, past the hardcoded regtest assumeutxo snapshot at
476 // height 110
477 mineBlocks(20);
478
479 CBlockIndex* validated_tip{nullptr};
480 CBlockIndex* assumed_base{nullptr};
481 CBlockIndex* assumed_tip{WITH_LOCK(chainman.GetMutex(), return chainman.ActiveChain().Tip())};
482 BOOST_CHECK_EQUAL(assumed_tip->nHeight, 120);
483
484 auto reload_all_block_indexes = [&]() {
485 LOCK(chainman.GetMutex());
486 // For completeness, we also reset the block sequence counters to
487 // ensure that no state which affects the ranking of tip-candidates is
488 // retained (even though this isn't strictly necessary).
490 for (const auto& cs : chainman.m_chainstates) {
491 cs->ClearBlockIndexCandidates();
492 BOOST_CHECK(cs->setBlockIndexCandidates.empty());
493 }
494 chainman.LoadBlockIndex();
495 };
496
497 // Ensure that without any assumed-valid BlockIndex entries, only the current tip is
498 // considered as a candidate.
499 reload_all_block_indexes();
501
502 // Reset some region of the chain's nStatus, removing the HAVE_DATA flag.
503 for (int i = 0; i <= cs1.m_chain.Height(); ++i) {
505 auto index = cs1.m_chain[i];
506
507 // Blocks with heights in range [91, 110] are marked as missing data.
508 if (i < last_assumed_valid_idx && i >= assumed_valid_start_idx) {
509 index->nStatus = BlockStatus::BLOCK_VALID_TREE;
510 index->nTx = 0;
511 index->m_chain_tx_count = 0;
512 }
513
514 ++num_indexes;
515
516 // Note the last fully-validated block as the expected validated tip.
517 if (i == (assumed_valid_start_idx - 1)) {
518 validated_tip = index;
519 }
520 // Note the last assumed valid block as the snapshot base
521 if (i == last_assumed_valid_idx - 1) {
522 assumed_base = index;
523 }
524 }
525
526 // Note: cs2's tip is not set when ActivateExistingSnapshot is called.
527 Chainstate& cs2{WITH_LOCK(::cs_main, return chainman.AddChainstate(std::make_unique<Chainstate>(nullptr, chainman.m_blockman, chainman, *assumed_base->phashBlock)))};
528
529 // Set tip of the fully validated chain to be the validated tip
530 cs1.m_chain.SetTip(*validated_tip);
531
532 // Set tip of the assume-valid-based chain to the assume-valid block
533 cs2.m_chain.SetTip(*assumed_base);
534
535 // Sanity check test variables.
536 BOOST_CHECK_EQUAL(num_indexes, 121); // 121 total blocks, including genesis
537 BOOST_CHECK_EQUAL(assumed_tip->nHeight, 120); // original chain has height 120
538 BOOST_CHECK_EQUAL(validated_tip->nHeight, 90); // current cs1 chain has height 90
539 BOOST_CHECK_EQUAL(assumed_base->nHeight, 110); // current cs2 chain has height 110
540
541 // Regenerate cs1.setBlockIndexCandidates and cs2.setBlockIndexCandidate and
542 // check contents below.
543 reload_all_block_indexes();
544
545 // The fully validated chain should only have the current validated tip and
546 // the assumed valid base as candidates, blocks 90 and 110. Specifically:
547 //
548 // - It does not have blocks 0-89 because they contain less work than the
549 // chain tip.
550 //
551 // - It has block 90 because it has data and equal work to the chain tip,
552 // (since it is the chain tip).
553 //
554 // - It does not have blocks 91-109 because they do not contain data.
555 //
556 // - It has block 110 even though it does not have data, because
557 // LoadBlockIndex has a special case to always add the snapshot block as a
558 // candidate. The special case is only actually intended to apply to the
559 // snapshot chainstate cs2, not the background chainstate cs1, but it is
560 // written broadly and applies to both.
561 //
562 // - It does not have any blocks after height 110 because cs1 is a background
563 // chainstate, and only blocks where are ancestors of the snapshot block
564 // are added as candidates for the background chainstate.
566 BOOST_CHECK_EQUAL(cs1.setBlockIndexCandidates.count(validated_tip), 1);
567 BOOST_CHECK_EQUAL(cs1.setBlockIndexCandidates.count(assumed_base), 1);
568
569 // The assumed-valid tolerant chain has the assumed valid base as a
570 // candidate, but otherwise has none of the assumed-valid (which do not
571 // HAVE_DATA) blocks as candidates.
572 //
573 // Specifically:
574 // - All blocks below height 110 are not candidates, because cs2 chain tip
575 // has height 110 and they have less work than it does.
576 //
577 // - Block 110 is a candidate even though it does not have data, because it
578 // is the snapshot block, which is assumed valid.
579 //
580 // - Blocks 111-120 are added because they have data.
581
582 // Check that block 90 is absent
583 BOOST_CHECK_EQUAL(cs2.setBlockIndexCandidates.count(validated_tip), 0);
584 // Check that block 109 is absent
585 BOOST_CHECK_EQUAL(cs2.setBlockIndexCandidates.count(assumed_base->pprev), 0);
586 // Check that block 110 is present
587 BOOST_CHECK_EQUAL(cs2.setBlockIndexCandidates.count(assumed_base), 1);
588 // Check that block 120 is present
589 BOOST_CHECK_EQUAL(cs2.setBlockIndexCandidates.count(assumed_tip), 1);
590 // Check that 11 blocks total are present.
591 BOOST_CHECK_EQUAL(cs2.setBlockIndexCandidates.size(), num_indexes - last_assumed_valid_idx + 1);
592}
593
596BOOST_FIXTURE_TEST_CASE(chainstatemanager_snapshot_init, SnapshotTestSetup)
597{
599 Chainstate& bg_chainstate = chainman.ActiveChainstate();
600
601 this->SetupSnapshot();
602
603 fs::path snapshot_chainstate_dir = *node::FindAssumeutxoChainstateDir(chainman.m_options.datadir);
604 BOOST_CHECK(fs::exists(snapshot_chainstate_dir));
605 BOOST_CHECK_EQUAL(snapshot_chainstate_dir, gArgs.GetDataDirNet() / "chainstate_snapshot");
606
608 const uint256 snapshot_tip_hash = WITH_LOCK(chainman.GetMutex(),
609 return chainman.ActiveTip()->GetBlockHash());
610
611 BOOST_CHECK_EQUAL(WITH_LOCK(chainman.GetMutex(), return chainman.m_chainstates.size()), 2);
612
613 // "Rewind" the background chainstate so that its tip is not at the
614 // base block of the snapshot - this is so after simulating a node restart,
615 // it will initialize instead of attempting to complete validation.
616 //
617 // Note that this is not a realistic use of DisconnectTip().
619 BlockValidationState unused_state;
620 {
621 LOCK2(::cs_main, bg_chainstate.MempoolMutex());
622 BOOST_CHECK(bg_chainstate.DisconnectTip(unused_state, &unused_pool));
623 unused_pool.clear(); // to avoid queuedTx assertion errors on teardown
624 }
625 BOOST_CHECK_EQUAL(bg_chainstate.m_chain.Height(), 109);
626
627 // Test that simulating a shutdown (resetting ChainstateManager) and then performing
628 // chainstate reinitializing successfully reloads both chainstates.
629 ChainstateManager& chainman_restarted = this->SimulateNodeRestart();
630
631 BOOST_TEST_MESSAGE("Performing Load/Verify/Activate of chainstate");
632
633 // This call reinitializes the chainstates.
634 this->LoadVerifyActivateChainstate();
635
636 {
637 LOCK(chainman_restarted.GetMutex());
638 BOOST_CHECK_EQUAL(chainman_restarted.m_chainstates.size(), 2);
639 // Background chainstate has height of 109 not 110 here due to a quirk
640 // of the LoadVerifyActivate only calling ActivateBestChain on one
641 // chainstate. The height would be 110 after a real restart, but it's
642 // fine for this test which is focused on the snapshot chainstate.
643 BOOST_CHECK_EQUAL(chainman_restarted.m_chainstates[0]->m_chain.Height(), 109);
644 BOOST_CHECK_EQUAL(chainman_restarted.m_chainstates[1]->m_chain.Height(), 210);
645
647 BOOST_CHECK(chainman_restarted.CurrentChainstate().m_assumeutxo == Assumeutxo::UNVALIDATED);
648
649 BOOST_CHECK_EQUAL(chainman_restarted.ActiveTip()->GetBlockHash(), snapshot_tip_hash);
650 BOOST_CHECK_EQUAL(chainman_restarted.ActiveHeight(), 210);
651 BOOST_CHECK_EQUAL(chainman_restarted.HistoricalChainstate()->m_chain.Height(), 109);
652 }
653
654 BOOST_TEST_MESSAGE(
655 "Ensure we can mine blocks on top of the initialized snapshot chainstate");
656 mineBlocks(10);
657 {
658 LOCK(chainman_restarted.GetMutex());
659 BOOST_CHECK_EQUAL(chainman_restarted.ActiveHeight(), 220);
660
661 // Background chainstate should be unaware of new blocks on the snapshot
662 // chainstate, but the block disconnected above is now reattached.
663 BOOST_CHECK_EQUAL(chainman_restarted.m_chainstates.size(), 2);
664 BOOST_CHECK_EQUAL(chainman_restarted.m_chainstates[0]->m_chain.Height(), 110);
665 BOOST_CHECK_EQUAL(chainman_restarted.m_chainstates[1]->m_chain.Height(), 220);
666 BOOST_CHECK_EQUAL(chainman_restarted.HistoricalChainstate(), nullptr);
667 }
668}
669
670BOOST_FIXTURE_TEST_CASE(chainstatemanager_snapshot_completion, SnapshotTestSetup)
671{
672 this->SetupSnapshot();
673
675 Chainstate& active_cs = chainman.ActiveChainstate();
676 Chainstate& validated_cs{*Assert(WITH_LOCK(cs_main, return chainman.HistoricalChainstate()))};
677 auto tip_cache_before_complete = active_cs.m_coinstip_cache_size_bytes;
678 auto db_cache_before_complete = active_cs.m_coinsdb_cache_size_bytes;
679
681 m_node.notifications->m_shutdown_on_fatal_error = false;
682
683 fs::path snapshot_chainstate_dir = *node::FindAssumeutxoChainstateDir(chainman.m_options.datadir);
684 BOOST_CHECK(fs::exists(snapshot_chainstate_dir));
685 BOOST_CHECK_EQUAL(snapshot_chainstate_dir, gArgs.GetDataDirNet() / "chainstate_snapshot");
686
688 const uint256 snapshot_tip_hash = WITH_LOCK(chainman.GetMutex(),
689 return chainman.ActiveTip()->GetBlockHash());
690
691 res = WITH_LOCK(::cs_main, return chainman.MaybeValidateSnapshot(validated_cs, active_cs));
693
694 BOOST_CHECK(WITH_LOCK(::cs_main, return chainman.CurrentChainstate().m_assumeutxo == Assumeutxo::VALIDATED));
696 BOOST_CHECK_EQUAL(WITH_LOCK(chainman.GetMutex(), return chainman.HistoricalChainstate()), nullptr);
697
698 // Cache should have been rebalanced and reallocated to the "only" remaining
699 // chainstate.
700 BOOST_CHECK(active_cs.m_coinstip_cache_size_bytes > tip_cache_before_complete);
701 BOOST_CHECK(active_cs.m_coinsdb_cache_size_bytes > db_cache_before_complete);
702
703 // Trying completion again should return false.
704 res = WITH_LOCK(::cs_main, return chainman.MaybeValidateSnapshot(validated_cs, active_cs));
706
707 // The invalid snapshot path should not have been used.
708 fs::path snapshot_invalid_dir = gArgs.GetDataDirNet() / "chainstate_snapshot_INVALID";
709 BOOST_CHECK(!fs::exists(snapshot_invalid_dir));
710 // chainstate_snapshot should still exist.
711 BOOST_CHECK(fs::exists(snapshot_chainstate_dir));
712
713 // Test that simulating a shutdown (resetting ChainstateManager) and then performing
714 // chainstate reinitializing successfully cleans up the background-validation
715 // chainstate data, and we end up with a single chainstate that is at tip.
716 ChainstateManager& chainman_restarted = this->SimulateNodeRestart();
717
718 BOOST_TEST_MESSAGE("Performing Load/Verify/Activate of chainstate");
719
720 // This call reinitializes the chainstates, and should clean up the now unnecessary
721 // background-validation leveldb contents.
722 this->LoadVerifyActivateChainstate();
723
724 BOOST_CHECK(!fs::exists(snapshot_invalid_dir));
725 // chainstate_snapshot should now *not* exist.
726 BOOST_CHECK(!fs::exists(snapshot_chainstate_dir));
727
728 const Chainstate& active_cs2 = chainman_restarted.ActiveChainstate();
729
730 {
731 LOCK(chainman_restarted.GetMutex());
732 BOOST_CHECK_EQUAL(chainman_restarted.m_chainstates.size(), 1);
734 BOOST_CHECK(active_cs2.m_coinstip_cache_size_bytes > tip_cache_before_complete);
735 BOOST_CHECK(active_cs2.m_coinsdb_cache_size_bytes > db_cache_before_complete);
736
737 BOOST_CHECK_EQUAL(chainman_restarted.ActiveTip()->GetBlockHash(), snapshot_tip_hash);
738 BOOST_CHECK_EQUAL(chainman_restarted.ActiveHeight(), 210);
739 }
740
741 BOOST_TEST_MESSAGE(
742 "Ensure we can mine blocks on top of the \"new\" IBD chainstate");
743 mineBlocks(10);
744 {
745 LOCK(chainman_restarted.GetMutex());
746 BOOST_CHECK_EQUAL(chainman_restarted.ActiveHeight(), 220);
747 }
748}
749
750BOOST_FIXTURE_TEST_CASE(chainstatemanager_snapshot_completion_hash_mismatch, SnapshotTestSetup)
751{
752 auto chainstates = this->SetupSnapshot();
753 Chainstate& validation_chainstate = *std::get<0>(chainstates);
754 Chainstate& unvalidated_cs = *std::get<1>(chainstates);
757 m_node.notifications->m_shutdown_on_fatal_error = false;
758
759 // Test tampering with the IBD UTXO set with an extra coin to ensure it causes
760 // snapshot completion to fail.
762 return validation_chainstate.CoinsTip());
763 Coin badcoin;
764 badcoin.out.nValue = m_rng.rand32();
765 badcoin.nHeight = 1;
766 badcoin.out.scriptPubKey.assign(m_rng.randbits(6), 0);
767 Txid txid = Txid::FromUint256(m_rng.rand256());
768 ibd_coins.AddCoin(COutPoint(txid, 0), std::move(badcoin), false);
769
770 fs::path snapshot_chainstate_dir = gArgs.GetDataDirNet() / "chainstate_snapshot";
771 BOOST_CHECK(fs::exists(snapshot_chainstate_dir));
772
773 {
774 ASSERT_DEBUG_LOG("failed to validate the -assumeutxo snapshot state");
775 res = WITH_LOCK(::cs_main, return chainman.MaybeValidateSnapshot(validation_chainstate, unvalidated_cs));
777 }
778
779 {
780 LOCK(chainman.GetMutex());
781 BOOST_CHECK_EQUAL(chainman.m_chainstates.size(), 2);
782 BOOST_CHECK(chainman.m_chainstates[0]->m_assumeutxo == Assumeutxo::VALIDATED);
783 BOOST_CHECK(!chainman.m_chainstates[0]->SnapshotBase());
784 BOOST_CHECK(chainman.m_chainstates[1]->m_assumeutxo == Assumeutxo::INVALID);
785 BOOST_CHECK(chainman.m_chainstates[1]->SnapshotBase());
786 }
787
788 fs::path snapshot_invalid_dir = gArgs.GetDataDirNet() / "chainstate_snapshot_INVALID";
789 BOOST_CHECK(fs::exists(snapshot_invalid_dir));
790
791 // Test that simulating a shutdown (resetting ChainstateManager) and then performing
792 // chainstate reinitializing successfully loads only the fully-validated
793 // chainstate data, and we end up with a single chainstate that is at tip.
794 ChainstateManager& chainman_restarted = this->SimulateNodeRestart();
795
796 BOOST_TEST_MESSAGE("Performing Load/Verify/Activate of chainstate");
797
798 // This call reinitializes the chainstates, and should clean up the now unnecessary
799 // background-validation leveldb contents.
800 this->LoadVerifyActivateChainstate();
801
802 BOOST_CHECK(fs::exists(snapshot_invalid_dir));
803 BOOST_CHECK(!fs::exists(snapshot_chainstate_dir));
804
805 {
807 BOOST_CHECK_EQUAL(chainman_restarted.m_chainstates.size(), 1);
809 BOOST_CHECK_EQUAL(chainman_restarted.ActiveHeight(), 210);
810 }
811
812 BOOST_TEST_MESSAGE(
813 "Ensure we can mine blocks on top of the \"new\" IBD chainstate");
814 mineBlocks(10);
815 {
817 BOOST_CHECK_EQUAL(chainman_restarted.ActiveHeight(), 220);
818 }
819}
820
822template <typename Options>
824 const std::vector<const char*>& args)
825{
826 const auto argv{Cat({"ignore"}, args)};
827 std::string error{};
828 if (!args_man.ParseParameters(argv.size(), argv.data(), error)) {
829 return util::Error{Untranslated("ParseParameters failed with error: " + error)};
830 }
831 const auto result{node::ApplyArgsManOptions(args_man, opts)};
832 if (!result) return util::Error{util::ErrorString(result)};
833 return opts;
834}
835
837{
839 auto get_opts = [&](const std::vector<const char*>& args) {
840 static kernel::Notifications notifications{};
841 static const ChainstateManager::Options options{
843 .datadir = {},
844 .notifications = notifications};
845 return SetOptsFromArgs(*this->m_node.args, options, args);
846 };
848 auto get_valid_opts = [&](const std::vector<const char*>& args) {
849 const auto result{get_opts(args)};
850 BOOST_REQUIRE_MESSAGE(result, util::ErrorString(result).original);
851 return *result;
852 };
853
854 // test -assumevalid
855 BOOST_CHECK(!get_valid_opts({}).assumed_valid_block);
856 BOOST_CHECK_EQUAL(get_valid_opts({"-assumevalid="}).assumed_valid_block, uint256::ZERO);
857 BOOST_CHECK_EQUAL(get_valid_opts({"-assumevalid=0"}).assumed_valid_block, uint256::ZERO);
858 BOOST_CHECK_EQUAL(get_valid_opts({"-noassumevalid"}).assumed_valid_block, uint256::ZERO);
859 BOOST_CHECK_EQUAL(get_valid_opts({"-assumevalid=0x12"}).assumed_valid_block, uint256{0x12});
860
861 std::string assume_valid{"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"};
862 BOOST_CHECK_EQUAL(get_valid_opts({("-assumevalid=" + assume_valid).c_str()}).assumed_valid_block, uint256::FromHex(assume_valid));
863
864 BOOST_CHECK(!get_opts({"-assumevalid=xyz"})); // invalid hex characters
865 BOOST_CHECK(!get_opts({"-assumevalid=01234567890123456789012345678901234567890123456789012345678901234"})); // > 64 hex chars
866
867 // test -minimumchainwork
868 BOOST_CHECK(!get_valid_opts({}).minimum_chain_work);
869 BOOST_CHECK_EQUAL(get_valid_opts({"-minimumchainwork=0"}).minimum_chain_work, arith_uint256());
870 BOOST_CHECK_EQUAL(get_valid_opts({"-nominimumchainwork"}).minimum_chain_work, arith_uint256());
871 BOOST_CHECK_EQUAL(get_valid_opts({"-minimumchainwork=0x1234"}).minimum_chain_work, arith_uint256{0x1234});
872
873 std::string minimum_chainwork{"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"};
874 BOOST_CHECK_EQUAL(get_valid_opts({("-minimumchainwork=" + minimum_chainwork).c_str()}).minimum_chain_work, UintToArith256(uint256::FromHex(minimum_chainwork).value()));
875
876 BOOST_CHECK(!get_opts({"-minimumchainwork=xyz"})); // invalid hex characters
877 BOOST_CHECK(!get_opts({"-minimumchainwork=01234567890123456789012345678901234567890123456789012345678901234"})); // > 64 hex chars
878}
879
ArgsManager gArgs
Definition: args.cpp:40
arith_uint256 UintToArith256(const uint256 &a)
static void pool cs
node::NodeContext m_node
Definition: bitcoin-gui.cpp:43
ArgsManager & args
Definition: bitcoind.cpp:277
@ BLOCK_VALID_TREE
All parent headers found, difficulty matches, timestamp >= median previous.
Definition: chain.h:51
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Definition: check.h:113
bool ParseParameters(int argc, const char *const argv[], std::string &error)
Definition: args.cpp:177
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
Definition: args.h:235
Non-refcounted RAII wrapper for FILE*.
Definition: streams.h:371
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:95
uint64_t m_chain_tx_count
(memory only) Number of transactions in the chain up to and including this block.
Definition: chain.h:130
arith_uint256 nChainWork
(memory only) Total amount of work (expected number of hashes) in the chain up to and including this ...
Definition: chain.h:119
uint32_t nTime
Definition: chain.h:143
uint256 GetBlockHash() const
Definition: chain.h:199
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
Definition: chain.h:397
void SetTip(CBlockIndex &block)
Set/initialize a chain with a given tip.
Definition: chain.cpp:16
int Height() const
Return the maximal height in the chain.
Definition: chain.h:426
std::optional< AssumeutxoData > AssumeutxoForHeight(int height) const
Definition: chainparams.h:119
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:355
void AddCoin(const COutPoint &outpoint, Coin &&coin, bool possible_overwrite)
Add a coin.
Definition: coins.cpp:74
unsigned int GetCacheSize() const
Calculate the size of the cache (in number of transaction outputs)
Definition: coins.cpp:297
bool HaveCoin(const COutPoint &outpoint) const override
Just check whether a given outpoint is unspent.
Definition: coins.cpp:168
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:29
CScript scriptPubKey
Definition: transaction.h:143
CAmount nValue
Definition: transaction.h:142
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Definition: validation.h:550
CChain m_chain
The current chain of blockheaders we consult and build on.
Definition: validation.h:624
size_t m_coinstip_cache_size_bytes
The cache size of the in-memory coins view.
Definition: validation.h:720
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:685
size_t m_coinsdb_cache_size_bytes
The cache size of the on-disk coins view.
Definition: validation.h:717
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:636
bool DisconnectTip(BlockValidationState &state, DisconnectedBlockTransactions *disconnectpool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
Disconnect m_chain's tip.
std::set< CBlockIndex *, node::CBlockIndexWorkComparator > setBlockIndexCandidates
The set of all CBlockIndex entries that have as much work as our current tip or more,...
Definition: validation.h:682
CoinsCacheSizeState GetCoinsCacheSizeState() EXCLUSIVE_LOCKS_REQUIRED(CoinsCacheSizeState GetCoinsCacheSizeState(size_t max_coins_cache_size_bytes, size_t max_mempool_size_bytes) EXCLUSIVE_LOCKS_REQUIRED(std::string ToString() EXCLUSIVE_LOCKS_REQUIRED(RecursiveMutex * MempoolMutex() const LOCK_RETURNED(m_mempool -> cs)
Dictates whether we need to flush the cache to disk or not.
Definition: validation.h:838
Interface for managing multiple Chainstate objects, where each chainstate is associated with chainsta...
Definition: validation.h:935
Chainstate * HistoricalChainstate() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Return historical chainstate targeting a specific block, if any.
Definition: validation.h:1123
size_t m_total_coinstip_cache
The total number of bytes available for us to use across all in-memory coins caches.
Definition: validation.h:1077
RecursiveMutex & GetMutex() const LOCK_RETURNED(
Alias for cs_main.
Definition: validation.h:1027
CBlockIndex * ActiveTip() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1162
Chainstate & ActiveChainstate() const
Alternatives to CurrentChainstate() used by older code to query latest chainstate information without...
SnapshotCompletionResult MaybeValidateSnapshot(Chainstate &validated_cs, Chainstate &unvalidated_cs) EXCLUSIVE_LOCKS_REQUIRED(Chainstate & CurrentChainstate() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Try to validate an assumeutxo snapshot by using a validated historical chainstate targeted at the sna...
Definition: validation.h:1114
size_t m_total_coinsdb_cache
The total number of bytes available for us to use across all leveldb coins databases.
Definition: validation.h:1081
int ActiveHeight() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1161
const Options m_options
Definition: validation.h:1030
bool LoadBlockIndex() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Load the block tree and coins database from disk, initializing state if we're running with -reindex.
CChain & ActiveChain() const EXCLUSIVE_LOCKS_REQUIRED(GetMutex())
Definition: validation.h:1160
void ResetBlockSequenceCounters() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:1061
node::BlockManager m_blockman
A single BlockManager instance is shared across each constructed chainstate to avoid duplicating bloc...
Definition: validation.h:1033
A UTXO entry.
Definition: coins.h:34
CTxOut out
unspent transaction output
Definition: coins.h:37
uint32_t nHeight
at which height this containing transaction was included in the active block chain
Definition: coins.h:43
DisconnectedBlockTransactions.
256-bit unsigned big integer.
A base class defining functions for notifying about certain kernel events.
Maintains a tree of blocks (stored in m_block_index) which is consulted to determine where the most-w...
Definition: blockstorage.h:191
CBlockIndex * LookupBlockIndex(const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Metadata describing a serialized version of a UTXO set from which an assumeutxo Chainstate can be con...
Definition: utxo_snapshot.h:38
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:45
uint64_t m_coins_count
The number of coins in the UTXO set contained in this snapshot.
Definition: utxo_snapshot.h:50
void assign(size_type n, const T &val)
Definition: prevector.h:176
static transaction_identifier FromUint256(const uint256 &id)
256-bit opaque blob.
Definition: uint256.h:195
static const uint256 ONE
Definition: uint256.h:204
static const uint256 ZERO
Definition: uint256.h:203
static std::optional< uint256 > FromHex(std::string_view str)
Definition: uint256.h:197
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:8
BOOST_FIXTURE_TEST_SUITE(cuckoocache_tests, BasicTestingSetup)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_SUITE_END()
static const unsigned int MAX_DISCONNECTED_TX_POOL_BYTES
Maximum bytes for transactions to store for processing during reorg.
static bool exists(const path &p)
Definition: fs.h:95
util::Result< void > ApplyArgsManOptions(const ArgsManager &args, BlockManager::Options &opts)
std::optional< fs::path > FindAssumeutxoChainstateDir(const fs::path &data_dir)
Return a path to the snapshot-based chainstate dir, if one exists.
std::optional< uint256 > ReadSnapshotBaseBlockhash(fs::path chaindir)
bilingual_str ErrorString(const Result< T > &result)
Definition: result.h:93
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:17
#define BOOST_CHECK(expr)
Definition: object.cpp:16
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:403
uint64_t ReadCompactSize(Stream &is, bool range_check=true)
Decode a CompactSize-encoded variable-length integer.
Definition: serialize.h:330
Basic testing setup.
Definition: setup_common.h:64
Testing setup that performs all steps up until right before ChainstateManager gets initialized.
Definition: setup_common.h:106
Application-specific storage settings.
Definition: dbwrapper.h:33
fs::path path
Location in the filesystem where leveldb data will be stored.
Definition: dbwrapper.h:35
std::tuple< Chainstate *, Chainstate * > SetupSnapshot()
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
Definition: setup_common.h:146
Testing setup that configures a complete environment.
Definition: setup_common.h:121
An options struct for ChainstateManager, more ergonomically referred to as ChainstateManager::Options...
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
Definition: context.h:88
std::unique_ptr< CTxMemPool > mempool
Definition: context.h:68
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:72
std::unique_ptr< node::Warnings > warnings
Manages all the node warnings.
Definition: context.h:91
std::function< bool()> shutdown_request
Function to request a shutdown.
Definition: context.h:63
std::unique_ptr< KernelNotifications > notifications
Issues blocking calls about sync status, errors and warnings.
Definition: context.h:86
util::SignalInterrupt * shutdown_signal
Interrupt object used to track whether node shutdown was requested.
Definition: context.h:65
ArgsManager * args
Definition: context.h:74
std::atomic< int > exit_status
Definition: context.h:89
#define LOCK2(cs1, cs2)
Definition: sync.h:260
#define LOCK(cs)
Definition: sync.h:259
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition: sync.h:290
static bool CreateAndActivateUTXOSnapshot(TestingSetup *fixture, F malleation=NoMalleation, bool reset_chainstate=false, bool in_memory_chainstate=false)
Create and activate a UTXO snapshot, optionally providing a function to malleate the snapshot.
Definition: chainstate.h:33
#define ASSERT_DEBUG_LOG(message)
Definition: logging.h:42
consteval auto _(util::TranslatedLiteral str)
Definition: translation.h:79
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
Definition: translation.h:82
assert(!tx.IsCoinBase())
SnapshotCompletionResult
Definition: validation.h:897
@ VALIDATED
Every block in the chain has been validated.
@ UNVALIDATED
Blocks after an assumeutxo snapshot have been validated but the snapshot itself has not been validate...
@ INVALID
The assumeutxo snapshot failed validation.
BOOST_FIXTURE_TEST_CASE(chainstatemanager, TestChain100Setup)
Basic tests for ChainstateManager.
util::Result< Options > SetOptsFromArgs(ArgsManager &args_man, Options opts, const std::vector< const char * > &args)
Helper function to parse args into args_man and return the result of applying them to opts.
V Cat(V v1, V &&v2)
Concatenate two vectors, moving elements.
Definition: vector.h:34