7#include <chainparams.h>
21#include <unordered_map>
50 CBlockIndex* genesis = chainman.ActiveChainstate().m_chain[0];
52 std::vector<CBlockIndex*>
blocks;
83 chainman.InvalidBlockFound(index, state);
87 block.
vtx = std::vector<CTransactionRef>(nTx);
89 chainman.ReceivedBlockTransactions(block, index, pos);
98 auto& chain = chainman.ActiveChain();
118 chain.SetTip(*chain[
fork->nHeight]);
135 chainman.InvalidBlockFound(block, state);
137 chainman.InvalidChainFound(
to_connect.front());
144 chain.SetTip(*block);
145 chainman.ActiveChainstate().PruneBlockIndexCandidates();
160 auto& chain = chainman.ActiveChain();
171 while (range.first != range.second) {
172 std::multimap<CBlockIndex*, CBlockIndex*>::iterator
_it = range.first;
190 block.
vtx = std::vector<CTransactionRef>(index->nTx);
192 chainman.ReceivedBlockTransactions(block, index, pos);
199 chainman.CheckBlockIndex();
207 chainman.m_best_header = genesis;
208 chainman.ResetBestInvalid();
209 chainman.nBlockSequenceId = 2;
210 chainman.ActiveChain().SetTip(*genesis);
211 chainman.ActiveChainstate().setBlockIndexCandidates.clear();
212 chainman.m_cached_is_ibd =
true;
218 std::erase_if(
blockman.m_block_index, [&](
const auto& entry) { return entry.first != genesis_hash; });
219 chainman.ActiveChainstate().TryAddBlockIndexCandidate(genesis);
221 assert(chainman.ActiveChainstate().setBlockIndexCandidates.size() == 1);
222 assert(chainman.ActiveChain().Height() == 0);
CBlockHeader ConsumeBlockHeader(FuzzedDataProvider &provider, uint256 prev_hash, int &nonce_counter)
void initialize_block_index_tree()
const TestingSetup * g_setup
@ BLOCK_VALID_TRANSACTIONS
Only first tx is coinbase, 2 <= coinbase input script length <= 100, transactions valid,...
@ BLOCK_VALID_SCRIPTS
Scripts & signatures ok.
@ BLOCK_VALID_TREE
All parent headers found, difficulty matches, timestamp >= median previous.
@ BLOCK_HAVE_UNDO
undo data available in rev*.dat
@ BLOCK_HAVE_DATA
full block available in blk*.dat
@ BLOCK_FAILED_VALID
stage after last reached validness failed
const CChainParams & Params()
Return the currently selected parameters.
std::vector< CTransactionRef > vtx
The block chain is a tree shaped structure starting with the genesis block at the root,...
CBlockIndex * pprev
pointer to the index of the predecessor of this block
uint256 GetBlockHash() const
unsigned int nTx
Number of transactions in this block.
int nHeight
height of the entry in the chain. The genesis block has height 0
const CBlock & GenesisBlock() const
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
T ConsumeIntegralInRange(T min, T max)
bool Invalid(Result result, const std::string &reject_reason="", const std::string &debug_message="")
@ BLOCK_CONSENSUS
invalid by consensus rules (excluding any below reasons)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Testing setup that configures a complete environment.
std::unique_ptr< ChainstateManager > chainman
FuzzedDataProvider provider
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
FuzzedDataProvider & fuzzed_data_provider