28 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
29 g_setup = testing_setup.get();
36 return state.Invalid(*result);
47 auto block{ConsumeDeserializable<CBlock>(fuzzed_data_provider)};
48 if (!block || block->vtx.size() == 0 ||
49 block->vtx.size() >= std::numeric_limits<uint16_t>::max()) {
59 std::set<uint16_t> available;
63 std::vector<std::pair<uint256, CTransactionRef>>
extra_txn;
64 for (
size_t i = 1; i < block->vtx.size(); ++i) {
65 auto tx{block->vtx[i]};
67 bool add_to_extra_txn{fuzzed_data_provider.ConsumeBool()};
68 bool add_to_mempool{fuzzed_data_provider.ConsumeBool()};
70 if (add_to_extra_txn) {
71 extra_txn.emplace_back(tx->GetWitnessHash(), tx);
82 auto init_status{pdb.InitData(cmpctblock,
extra_txn)};
84 std::vector<CTransactionRef> missing;
87 bool skipped_missing{
false};
88 for (
size_t i = 0; i < cmpctblock.BlockTxCount(); i++) {
96 assert(!pdb.IsTxAvailable(i) || available.count(i) > 0);
99 bool skip{fuzzed_data_provider.ConsumeBool()};
100 if (!pdb.IsTxAvailable(i) && !skip) {
101 missing.push_back(block->vtx[i]);
104 skipped_missing |= (!pdb.IsTxAvailable(i) && skip);
108 bool fail_check_block{fuzzed_data_provider.ConsumeBool()};
109 auto validation_result =
110 fuzzed_data_provider.PickValueInArray(
124 std::optional<BlockValidationResult>{validation_result} :
127 CBlock reconstructed_block;
128 auto fill_status{pdb.FillBlock(reconstructed_block, missing)};
129 switch (fill_status) {
132 assert(!fail_check_block);
133 assert(block->GetHash() == reconstructed_block.GetHash());
We don't have the previous block the checked one is built on.
invalid proof of work or time too old
the block header may be on a too-little-work chain
PartiallyDownloadedBlock::CheckBlockFn FuzzedCheckBlock(std::optional< BlockValidationResult > result)
initial value. Block has not yet been rejected
std::function< bool(const CBlock &, BlockValidationState &, const Consensus::Params &, bool, bool)> CheckBlockFn
CTxMemPoolEntry ConsumeTxMemPoolEntry(FuzzedDataProvider &fuzzed_data_provider, const CTransaction &tx) noexcept
this block was cached as being invalid and we didn't store the reason why
the block failed to meet one of our checkpoints
Parameters that influence chain consensus.
invalid by consensus rules (excluding any below reasons)
FUZZ_TARGET(partially_downloaded_block,.init=initialize_pdb)
the block's data didn't match the data committed to by the PoW
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
A block this one builds on is invalid.
Invalid by a change to consensus rules more recent than SegWit.
block timestamp was > 2 hours in the future (or our clock is bad)
std::vector< std::pair< uint256, CTransactionRef > > extra_txn
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
Testing setup that configures a complete environment.
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)