Bitcoin Core 31.99.0
P2P Digital Currency
cmpctblock.cpp
Go to the documentation of this file.
1// Copyright (c) 2026 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 <addrman.h>
6#include <blockencodings.h>
7#include <chain.h>
8#include <chainparams.h>
9#include <coins.h>
10#include <consensus/amount.h>
11#include <consensus/consensus.h>
12#include <consensus/merkle.h>
13#include <net.h>
14#include <net_processing.h>
15#include <netmessagemaker.h>
16#include <node/blockstorage.h>
17#include <node/miner.h>
18#include <policy/truc_policy.h>
19#include <primitives/block.h>
21#include <protocol.h>
22#include <script/script.h>
23#include <sync.h>
25#include <test/fuzz/fuzz.h>
26#include <test/fuzz/util.h>
27#include <test/fuzz/util/net.h>
28#include <test/util/mining.h>
29#include <test/util/net.h>
30#include <test/util/random.h>
31#include <test/util/script.h>
33#include <test/util/time.h>
34#include <test/util/txmempool.h>
36#include <txmempool.h>
37#include <uint256.h>
38#include <util/check.h>
39#include <util/time.h>
40#include <util/translation.h>
41#include <validation.h>
42#include <validationinterface.h>
43
44#include <boost/multi_index/detail/hash_index_iterator.hpp>
45#include <boost/operators.hpp>
46
47#include <cstddef>
48#include <cstdint>
49#include <functional>
50#include <iterator>
51#include <memory>
52#include <optional>
53#include <string>
54#include <string_view>
55#include <utility>
56#include <vector>
57
58namespace {
59
61
63const CAmount AMOUNT_FEE{1000};
65std::vector<std::pair<COutPoint, CAmount>> g_mature_coinbase;
67uint32_t g_nBits;
69struct BlockInfo {
70 std::shared_ptr<CBlock> block;
71 uint256 hash;
72 uint32_t height;
73};
75class FuzzedCBlockHeaderAndShortTxIDs : public CBlockHeaderAndShortTxIDs
76{
78
79public:
80 void AddPrefilledTx(PrefilledTransaction&& prefilledtx)
81 {
82 prefilledtxn.push_back(std::move(prefilledtx));
83 }
84
85 void RemoveCoinbasePrefill()
86 {
87 prefilledtxn.erase(prefilledtxn.begin());
88 }
89
90 void InsertCoinbaseShortTxID(uint64_t shorttxid)
91 {
92 shorttxids.insert(shorttxids.begin(), shorttxid);
93 }
94
95 void EraseShortTxIDs(size_t index)
96 {
97 shorttxids.erase(shorttxids.begin() + index);
98 }
99
100 size_t PrefilledTxCount() {
101 return prefilledtxn.size();
102 }
103
104 size_t ShortTxIDCount() {
105 return shorttxids.size();
106 }
107};
108
109void ResetChainmanAndMempool(TestingSetup& setup)
110{
111 SetMockTime(Params().GenesisBlock().Time());
112
113 bilingual_str error{};
114 setup.m_node.mempool.reset();
115 setup.m_node.mempool = std::make_unique<CTxMemPool>(MemPoolOptionsForTest(setup.m_node), error);
116 Assert(error.empty());
117
118 setup.m_node.chainman.reset();
119 setup.m_make_chainman();
120 setup.LoadVerifyActivateChainstate();
121
124 options.include_dummy_extranonce = true;
125
126 g_mature_coinbase.clear();
127
128 for (int i = 0; i < 2 * COINBASE_MATURITY; ++i) {
129 COutPoint prevout{MineBlock(setup.m_node, options)};
130 if (i < COINBASE_MATURITY) {
131 LOCK(cs_main);
132 CAmount subsidy{setup.m_node.chainman->ActiveChainstate().CoinsTip().GetCoin(prevout)->out.nValue};
133 g_mature_coinbase.emplace_back(prevout, subsidy);
134 }
135 }
136}
137
138} // namespace
139
140extern void MakeRandDeterministicDANGEROUS(const uint256& seed) noexcept;
141
143{
144 static const auto testing_setup = MakeNoLogFileContext<TestingSetup>();
145 g_setup = testing_setup.get();
146 g_nBits = Params().GenesisBlock().nBits;
147 ResetChainmanAndMempool(*g_setup);
148}
149
151{
153 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
154
155 NodeClockContext clock_ctx{1610000000s};
156
157 auto setup = g_setup;
158 auto& mempool = *setup->m_node.mempool;
159 auto& chainman = static_cast<TestChainstateManager&>(*setup->m_node.chainman);
160 chainman.ResetIbd();
161 chainman.DisableNextWrite();
162 const size_t initial_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())};
163
164 AddrMan addrman{*setup->m_node.netgroupman, /*deterministic=*/true, /*consistency_check_ratio=*/0};
165 auto& connman = *static_cast<ConnmanTestMsg*>(setup->m_node.connman.get());
166 auto peerman = PeerManager::make(connman, addrman,
167 /*banman=*/nullptr, chainman,
168 mempool, *setup->m_node.warnings,
170 .deterministic_rng = true,
171 });
172 connman.SetMsgProc(peerman.get());
173
174 setup->m_node.validation_signals->RegisterValidationInterface(peerman.get());
175 setup->m_node.validation_signals->SyncWithValidationInterfaceQueue();
176
178
179 std::vector<CNode*> peers;
180 for (int i = 0; i < 4; ++i) {
181 peers.push_back(ConsumeNodeAsUniquePtr(fuzzed_data_provider, i).release());
182 CNode& p2p_node = *peers.back();
183 FillNode(fuzzed_data_provider, connman, p2p_node);
184 connman.AddTestNode(p2p_node);
185 }
186
187 // Stores blocks generated this iteration.
188 std::vector<BlockInfo> info;
189
190 // Coinbase UTXOs for this iteration.
191 std::vector<std::pair<COutPoint, CAmount>> mature_coinbase = g_mature_coinbase;
192
193 const uint64_t initial_sequence{WITH_LOCK(mempool.cs, return mempool.GetSequence())};
194
195 auto create_tx = [&]() -> CTransactionRef {
196 CMutableTransaction tx_mut;
199
200 // Choose an outpoint from the mempool, created blocks, or coinbases.
201 CAmount amount_in;
202 COutPoint outpoint;
203 unsigned long mempool_size = mempool.size();
204 if (mempool_size != 0 && fuzzed_data_provider.ConsumeBool()) {
205 size_t random_idx = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, mempool_size - 1);
206 CTransactionRef tx = WITH_LOCK(mempool.cs, return mempool.txns_randomized[random_idx].second->GetSharedTx(););
207 outpoint = COutPoint(tx->GetHash(), 0);
208 amount_in = tx->vout[0].nValue;
209 } else if (info.size() != 0 && fuzzed_data_provider.ConsumeBool()) {
210 // These blocks (and txs) may be invalid, use a spent output, or not be in the main chain.
211 auto info_it = info.begin();
212 std::advance(info_it, fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, info.size() - 1));
213 auto tx_it = info_it->block->vtx.begin();
214 std::advance(tx_it, fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, info_it->block->vtx.size() - 1));
215 outpoint = COutPoint(tx_it->get()->GetHash(), 0);
216 amount_in = tx_it->get()->vout[0].nValue;
217 } else {
218 auto coinbase_it = mature_coinbase.begin();
219 std::advance(coinbase_it, fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, mature_coinbase.size() - 1));
220 outpoint = coinbase_it->first;
221 amount_in = coinbase_it->second;
222 }
223
225 const auto script_sig = CScript{};
226 const auto script_wit_stack = std::vector<std::vector<uint8_t>>{WITNESS_STACK_ELEM_OP_TRUE};
227
228 CTxIn in;
229 in.prevout = outpoint;
230 in.nSequence = sequence;
231 in.scriptSig = script_sig;
232 in.scriptWitness.stack = script_wit_stack;
233 tx_mut.vin.push_back(in);
234
235 const CAmount amount_out = amount_in - AMOUNT_FEE;
236 tx_mut.vout.emplace_back(amount_out, P2WSH_OP_TRUE);
237
238 auto tx = MakeTransactionRef(tx_mut);
239 return tx;
240 };
241
242 auto create_block = [&]() {
243 uint256 prev;
244 uint32_t height;
245
246 if (info.size() == 0 || fuzzed_data_provider.ConsumeBool()) {
247 LOCK(cs_main);
248 prev = chainman.ActiveChain().Tip()->GetBlockHash();
249 height = chainman.ActiveChain().Height() + 1;
250 } else {
251 size_t index = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, info.size() - 1);
252 prev = info[index].hash;
253 height = info[index].height + 1;
254 }
255
256 const auto new_time = WITH_LOCK(::cs_main, return chainman.ActiveChain().Tip()->GetMedianTimePast() + 1);
257
258 CBlockHeader header;
259 header.nNonce = 0;
260 header.hashPrevBlock = prev;
261 header.nBits = g_nBits;
262 header.nTime = new_time;
264
265 std::shared_ptr<CBlock> block = std::make_shared<CBlock>();
266 *block = header;
267
268 CMutableTransaction coinbase_tx;
269 coinbase_tx.vin.resize(1);
270 coinbase_tx.vin[0].prevout.SetNull();
271 coinbase_tx.vin[0].scriptSig = CScript() << height << OP_0;
272 coinbase_tx.vout.resize(1);
273 coinbase_tx.vout[0].scriptPubKey = CScript() << OP_TRUE;
274 coinbase_tx.vout[0].nValue = COIN;
275 block->vtx.push_back(MakeTransactionRef(coinbase_tx));
276
277 const auto mempool_size = mempool.size();
278 if (fuzzed_data_provider.ConsumeBool() && mempool_size != 0) {
279 // Add txns from the mempool. Since we do not include parents, it may be an invalid block.
280 size_t num_txns = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, mempool_size);
281 size_t random_idx = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, mempool_size - 1);
282
283 LOCK(mempool.cs);
284 for (size_t i = random_idx; i < random_idx + num_txns; ++i) {
285 CTransactionRef mempool_tx = mempool.txns_randomized[i % mempool_size].second->GetSharedTx();
286 block->vtx.push_back(mempool_tx);
287 }
288 }
289
290 // Create and add (possibly invalid) txns that are not in the mempool.
292 size_t new_txns = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(1, 10);
293 for (size_t i = 0; i < new_txns; ++i) {
294 CTransactionRef non_mempool_tx = create_tx();
295 block->vtx.push_back(non_mempool_tx);
296 }
297 }
298
299 CBlockIndex* pindexPrev{WITH_LOCK(::cs_main, return chainman.m_blockman.LookupBlockIndex(prev))};
300 chainman.GenerateCoinbaseCommitment(*block, pindexPrev);
301
302 bool mutated;
303 block->hashMerkleRoot = BlockMerkleRoot(*block, &mutated);
304 FinalizeHeader(*block, chainman);
305
306 BlockInfo block_info;
307 block_info.block = block;
308 block_info.hash = block->GetHash();
309 block_info.height = height;
310
311 return block_info;
312 };
313
315 {
316 CSerializedNetMsg net_msg;
317 bool sent_net_msg = true;
318 bool requested_hb = false;
319 bool sent_sendcmpct = false;
320 bool valid_sendcmpct = false;
321
322 CallOneOf(
324 [&]() {
325 // Send a compact block.
326 std::shared_ptr<CBlock> cblock;
327
328 // Pick an existing block or create a new block.
329 if (fuzzed_data_provider.ConsumeBool() && info.size() != 0) {
330 size_t index = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, info.size() - 1);
331 cblock = info[index].block;
332 } else {
333 BlockInfo block_info = create_block();
334 cblock = block_info.block;
335 info.push_back(block_info);
336 }
337
338 uint64_t nonce = fuzzed_data_provider.ConsumeIntegral<uint64_t>();
339 FuzzedCBlockHeaderAndShortTxIDs cmpctblock(*cblock, nonce);
340
342 CBlockHeaderAndShortTxIDs base_cmpctblock = cmpctblock;
343 net_msg = NetMsg::Make(NetMsgType::CMPCTBLOCK, base_cmpctblock);
344 return;
345 }
346
347 int prev_idx = 0;
348 size_t num_erased = 1;
349 size_t num_txs = cblock->vtx.size();
350
351 for (size_t i = 0; i < num_txs; ++i) {
352 if (i == 0) {
353 // Handle the coinbase specially. We either keep it prefilled or remove it.
354 if (fuzzed_data_provider.ConsumeBool()) continue;
355
356 // Remove the prefilled coinbase.
357 num_erased = 0;
358 uint64_t coinbase_shortid = cmpctblock.GetShortID(cblock->vtx[0]->GetWitnessHash());
359 cmpctblock.RemoveCoinbasePrefill();
360 cmpctblock.InsertCoinbaseShortTxID(coinbase_shortid);
361 continue;
362 }
363
364 if (fuzzed_data_provider.ConsumeBool()) continue;
365
366 uint16_t prefill_idx = num_erased == 0 ? i : i - prev_idx - 1;
367 prev_idx = i;
368 CTransactionRef txref = cblock->vtx[i];
369 PrefilledTransaction prefilledtx = {/*index=*/prefill_idx, txref};
370 cmpctblock.AddPrefilledTx(std::move(prefilledtx));
371
372 // Remove from shorttxids since we've prefilled. Subtract however many txs have been prefilled.
373 cmpctblock.EraseShortTxIDs(i - num_erased);
374 ++num_erased;
375 }
376
377 assert(cmpctblock.PrefilledTxCount() + cmpctblock.ShortTxIDCount() == num_txs);
378
379 CBlockHeaderAndShortTxIDs base_cmpctblock = cmpctblock;
380 net_msg = NetMsg::Make(NetMsgType::CMPCTBLOCK, base_cmpctblock);
381 },
382 [&]() {
383 // Send a blocktxn message for an existing block (if one exists).
384 size_t num_blocks = info.size();
385 if (num_blocks == 0) {
386 sent_net_msg = false;
387 return;
388 }
389
390 // Fetch an existing block and randomly choose transactions to send over.
391 size_t index = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, num_blocks - 1);
392 const BlockInfo& block_info = info[index];
393 BlockTransactions block_txn;
394 block_txn.blockhash = block_info.hash;
395 std::shared_ptr<CBlock> cblock = block_info.block;
396
397 for (size_t i = 0; i < cblock->vtx.size(); i++) {
398 if (fuzzed_data_provider.ConsumeBool()) continue;
399
400 block_txn.txn.push_back(cblock->vtx[i]);
401 }
402
403 net_msg = NetMsg::Make(NetMsgType::BLOCKTXN, block_txn);
404 },
405 [&]() {
406 // Send a headers message for an existing block (if one exists).
407 size_t num_blocks = info.size();
408 if (num_blocks == 0) {
409 sent_net_msg = false;
410 return;
411 }
412
413 // Choose an existing block and send a HEADERS message for it.
414 size_t index = fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, num_blocks - 1);
415 CBlock block = *info[index].block;
416 block.vtx.clear(); // No tx in HEADERS.
417 std::vector<CBlock> headers;
418 headers.emplace_back(block);
419
421 },
422 [&]() {
423 // Send a sendcmpct message, optionally setting hb mode.
426 net_msg = NetMsg::Make(NetMsgType::SENDCMPCT, /*high_bandwidth=*/hb, /*version=*/version);
427 requested_hb = hb;
428 sent_sendcmpct = true;
429 valid_sendcmpct = version == CMPCTBLOCKS_VERSION;
430 },
431 [&]() {
432 // Mine a block, but don't send it.
433 BlockInfo block_info = create_block();
434 info.push_back(block_info);
435 sent_net_msg = false;
436 },
437 [&]() {
438 // Send a transaction.
439 CTransactionRef tx = create_tx();
441 },
442 [&]() {
443 // Set mock time randomly or to tip's time.
445 clock_ctx.set(ConsumeTime(fuzzed_data_provider));
446 } else {
447 const NodeSeconds tip_time = WITH_LOCK(::cs_main, return chainman.ActiveChain().Tip()->Time());
448 clock_ctx.set(tip_time);
449 }
450
451 sent_net_msg = false;
452 });
453
454 if (!sent_net_msg) {
455 continue;
456 }
457
458 CNode& random_node = *PickValue(fuzzed_data_provider, peers);
459 connman.FlushSendBuffer(random_node);
460 (void)connman.ReceiveMsgFrom(random_node, std::move(net_msg));
461
462 bool more_work{true};
463 while (more_work) {
464 random_node.fPauseSend = false;
465
466 more_work = connman.ProcessMessagesOnce(random_node);
467 peerman->SendMessages(random_node);
468 }
469
470 std::vector<CNodeStats> stats;
471 connman.GetNodeStats(stats);
472
473 // We should have at maximum 3 HB peers.
474 int num_hb = 0;
475 for (const CNodeStats& stat : stats) {
476 if (stat.m_bip152_highbandwidth_to) {
477 // HB peers cannot be feelers or other "special" connections (besides addr-fetch).
478 CNode* hb_peer = peers[stat.nodeid];
479 if (!hb_peer->fDisconnect) num_hb += 1;
480 assert(hb_peer->IsInboundConn() || hb_peer->IsOutboundOrBlockRelayConn() || hb_peer->IsManualConn() || hb_peer->IsAddrFetchConn());
481 }
482 }
483 assert(num_hb <= 3);
484
485 if (sent_sendcmpct && !random_node.fDisconnect) {
486 // If the fuzzer sent SENDCMPCT with proper version, check the node's state matches what it sent.
487 const CNodeStats& random_node_stats = stats[random_node.GetId()];
488 if (valid_sendcmpct) assert(random_node_stats.m_bip152_highbandwidth_from == requested_hb);
489 }
490 }
491
492 setup->m_node.validation_signals->SyncWithValidationInterfaceQueue();
493 setup->m_node.validation_signals->UnregisterAllValidationInterfaces();
494 connman.StopNodes();
495
496 const size_t end_index_size{WITH_LOCK(chainman.GetMutex(), return chainman.BlockIndex().size())};
497 const uint64_t end_sequence{WITH_LOCK(mempool.cs, return mempool.GetSequence())};
498
499 if (initial_index_size != end_index_size || initial_sequence != end_sequence) {
501 ResetChainmanAndMempool(*g_setup);
502 }
503}
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
static constexpr CAmount COIN
The amount of satoshis in one BTC.
Definition: amount.h:15
const TestingSetup * g_setup
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Definition: check.h:116
Stochastic address manager.
Definition: addrman.h:110
std::vector< CTransactionRef > txn
CBlockHeaderAndShortTxIDs()=default
Dummy for deserialization.
Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce value...
Definition: block.h:27
uint32_t nNonce
Definition: block.h:35
uint32_t nBits
Definition: block.h:34
uint32_t nTime
Definition: block.h:33
int32_t nVersion
Definition: block.h:30
uint256 hashPrevBlock
Definition: block.h:31
Definition: block.h:74
std::vector< CTransactionRef > vtx
Definition: block.h:77
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:94
const CBlock & GenesisBlock() const
Definition: chainparams.h:94
Information about a peer.
Definition: net.h:680
bool IsInboundConn() const
Definition: net.h:829
bool IsOutboundOrBlockRelayConn() const
Definition: net.h:771
NodeId GetId() const
Definition: net.h:914
bool IsManualConn() const
Definition: net.h:791
bool IsAddrFetchConn() const
Definition: net.h:820
std::atomic_bool fPauseSend
Definition: net.h:744
std::atomic_bool fDisconnect
Definition: net.h:738
bool m_bip152_highbandwidth_from
Definition: net.h:207
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:29
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
static const uint32_t CURRENT_VERSION
Definition: transaction.h:284
An input of a transaction.
Definition: transaction.h:62
uint32_t nSequence
Definition: transaction.h:66
CScript scriptSig
Definition: transaction.h:65
CScriptWitness scriptWitness
Only serialized through CTransaction.
Definition: transaction.h:67
COutPoint prevout
Definition: transaction.h:64
T ConsumeIntegralInRange(T min, T max)
static Mutex g_msgproc_mutex
Mutex for anything that is only accessed via the msg processing thread.
Definition: net.h:1030
Helper to initialize the global NodeClock, let a duration elapse, and reset it after use in a test.
Definition: time.h:40
static std::unique_ptr< PeerManager > make(CConnman &connman, AddrMan &addrman, BanMan *banman, ChainstateManager &chainman, CTxMemPool &pool, node::Warnings &warnings, Options opts)
256-bit opaque blob.
Definition: uint256.h:196
static const uint256 ZERO
Definition: uint256.h:204
void MakeRandDeterministicDANGEROUS(const uint256 &seed) noexcept
Internal function to set g_determinstic_rng.
Definition: random.cpp:595
FUZZ_TARGET(cmpctblock,.init=initialize_cmpctblock)
Definition: cmpctblock.cpp:150
void initialize_cmpctblock()
Definition: cmpctblock.cpp:142
uint256 BlockMerkleRoot(const CBlock &block, bool *mutated)
Definition: merkle.cpp:66
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
Definition: consensus.h:19
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition: cs_main.cpp:8
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Definition: fuzz.h:22
uint64_t sequence
unsigned int nonce
Definition: miner_tests.cpp:82
CSerializedNetMsg Make(std::string msg_type, Args &&... args)
constexpr const char * HEADERS
The headers message sends one or more block headers to a node which previously requested certain head...
Definition: protocol.h:123
constexpr const char * CMPCTBLOCK
Contains a CBlockHeaderAndShortTxIDs object - providing a header and list of "short txids".
Definition: protocol.h:206
constexpr const char * BLOCKTXN
Contains a BlockTransactions.
Definition: protocol.h:218
constexpr const char * SENDCMPCT
Contains a 1-byte bool and 8-byte LE version number.
Definition: protocol.h:200
constexpr const char * TX
The tx message transmits a single transaction.
Definition: protocol.h:117
Definition: basic.cpp:8
static constexpr uint64_t CMPCTBLOCKS_VERSION
The compactblocks version we support.
static constexpr TransactionSerParams TX_WITH_WITNESS
Definition: transaction.h:180
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Definition: transaction.h:404
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:403
@ OP_TRUE
Definition: script.h:84
@ OP_0
Definition: script.h:76
A mutable version of CTransaction.
Definition: transaction.h:358
std::vector< CTxOut > vout
Definition: transaction.h:360
std::vector< CTxIn > vin
Definition: transaction.h:359
std::vector< std::vector< unsigned char > > stack
Definition: script.h:580
void ResetIbd()
Reset the ibd cache to its initial state.
Definition: validation.cpp:33
Testing setup that configures a complete environment.
Definition: setup_common.h:118
Bilingual messages:
Definition: translation.h:24
bool include_dummy_extranonce
Whether to include an OP_0 as a dummy extraNonce in the template's coinbase.
Definition: types.h:78
CScript coinbase_output_script
Script to put in the coinbase transaction.
Definition: types.h:74
#define LOCK(cs)
Definition: sync.h:268
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition: sync.h:299
void FillNode(FuzzedDataProvider &fuzzed_data_provider, ConnmanTestMsg &connman, CNode &node) noexcept
Definition: net.cpp:457
std::unique_ptr< CNode > ConsumeNodeAsUniquePtr(FuzzedDataProvider &fdp, const std::optional< NodeId > &node_id_in=std::nullopt)
Definition: net.h:310
NodeSeconds ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
Definition: util.cpp:34
uint32_t ConsumeSequence(FuzzedDataProvider &fuzzed_data_provider) noexcept
Definition: util.cpp:155
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
Definition: util.h:49
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
Definition: util.h:37
void FinalizeHeader(CBlockHeader &header, const ChainstateManager &chainman)
Definition: util.h:363
COutPoint MineBlock(const NodeContext &node, const node::BlockAssembler::Options &assembler_options)
Returns the generated coin.
Definition: mining.cpp:72
void SeedRandomStateForTest(SeedRand seedtype)
Seed the global RNG state for testing and log the seed value.
Definition: random.cpp:19
@ ZEROS
Seed with a compile time constant of zeros.
static const std::vector< uint8_t > WITNESS_STACK_ELEM_OP_TRUE
Definition: script.h:12
static const CScript P2WSH_OP_TRUE
Definition: script.h:13
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
Definition: txmempool.cpp:21
static int setup(void)
Definition: tests.c:8040
static constexpr decltype(CTransaction::version) TRUC_VERSION
Definition: truc_policy.h:20
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
Definition: time.cpp:52
std::chrono::time_point< NodeClock, std::chrono::seconds > NodeSeconds
Definition: time.h:35
for(const CTxIn &txin :tx.vin)
Definition: validation.cpp:406
assert(!tx.IsCoinBase())
FuzzedDataProvider & fuzzed_data_provider
Definition: fees.cpp:39