Bitcoin Core 32.99.0
P2P Digital Currency
Loading...
Searching...
No Matches
tx_pool.cpp
Go to the documentation of this file.
1// Copyright (c) 2021-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 <chain.h>
6#include <coins.h>
7#include <consensus/amount.h>
10#include <node/miner.h>
11#include <node/mining_types.h>
12#include <policy/feerate.h>
13#include <policy/packages.h>
14#include <policy/policy.h>
15#include <policy/truc_policy.h>
16#include <primitives/block.h>
18#include <script/script.h>
19#include <sync.h>
21#include <test/fuzz/fuzz.h>
22#include <test/fuzz/util.h>
25#include <test/util/mining.h>
26#include <test/util/random.h>
27#include <test/util/script.h>
29#include <test/util/txmempool.h>
30#include <txmempool.h>
31#include <util/check.h>
32#include <util/string.h>
33#include <util/time.h>
34#include <util/translation.h>
35#include <validation.h>
36#include <validationinterface.h>
37
38#include <cstddef>
39#include <cstdint>
40#include <functional>
41#include <iterator>
42#include <limits>
43#include <map>
44#include <memory>
45#include <optional>
46#include <set>
47#include <span>
48#include <string>
49#include <utility>
50#include <vector>
54using util::ToString;
55
56namespace {
57
59std::vector<COutPoint> g_outpoints_coinbase_init_mature;
60std::vector<COutPoint> g_outpoints_coinbase_init_immature;
61constexpr ReachabilityGoal TX_POOL_STANDARD_ACCEPTS_TRANSACTION{"tx_pool_standard accepts a transaction"};
62constexpr ReachabilityGoal TX_POOL_ACCEPTS_TRANSACTION{"tx_pool accepts a transaction"};
63
64struct MockedTxPool : public CTxMemPool {
66 {
67 LOCK(cs);
70 }
71};
72
74{
75 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
76 g_setup = testing_setup.get();
77 SetMockTime(WITH_LOCK(g_setup->m_node.chainman->GetMutex(), return g_setup->m_node.chainman->ActiveTip()->Time()));
78
79 for (int i = 0; i < 2 * COINBASE_MATURITY; ++i) {
81 .coinbase_output_script = P2WSH_OP_TRUE,
82 })};
83 // Remember the txids to avoid expensive disk access later on
84 auto& outpoints = i < COINBASE_MATURITY ?
87 outpoints.push_back(prevout);
88 }
89 g_setup->m_node.validation_signals->SyncWithValidationInterfaceQueue();
90}
91
93{
96}
97
99{
102}
103
104struct TransactionsDelta final : public CValidationInterface {
105 std::set<CTransactionRef>& m_removed;
106 std::set<CTransactionRef>& m_added;
107
108 explicit TransactionsDelta(std::set<CTransactionRef>& r, std::set<CTransactionRef>& a)
109 : m_removed{r}, m_added{a} {}
110
111 void TransactionAddedToMempool(const NewMempoolTransactionInfo& tx, uint64_t /* mempool_sequence */) override
112 {
113 Assert(m_added.insert(tx.info.m_tx).second);
114 }
115
116 void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t /* mempool_sequence */) override
117 {
118 Assert(m_removed.insert(tx).second);
119 }
120};
121
123{
124 args.ForceSetArg("-limitclustercount",
126 args.ForceSetArg("-limitclustersize",
128 args.ForceSetArg("-maxmempool",
130 args.ForceSetArg("-mempoolexpiry",
132}
133
136std::vector<Wtxid> WtxidsToRelay(FuzzedDataProvider& fuzzed_data_provider, const MockedTxPool& tx_pool)
137{
138 LOCK(tx_pool.cs);
139 std::vector<Wtxid> res;
140
141 uint8_t dummy{0};
142 const auto mempool_entries{tx_pool.entryAll()};
145 // Wtxid of an in-mempool transaction
147 res.push_back(entry_ref.GetTx().GetWitnessHash());
148 // Don't remove it from the mempool, so the next pick is possibly a duplicate
149 } else {
150 // Wtxid of a not-in-mempool transaction
151 res.push_back(Wtxid::FromUint256(uint256{dummy}));
152 // Possibly make the next wtxid of a not-in-mempool transaction, a duplicate
153 if (fuzzed_data_provider.ConsumeBool()) dummy++;
154 }
155 }
156
157 return res;
158}
159
161{
162 WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
163 {
164 BlockCreateOptions options{
167 };
168 auto assembler = BlockAssembler{chainstate, &tx_pool, options};
170 Assert(block_template->block.vtx.size() >= 1);
171
172 // Try updating the mempool for this block, as though it were mined.
174 tx_pool.removeForBlock(block_template->block.vtx);
175
176 // Now try to add those transactions back, as though a reorg happened.
177 std::vector<Txid> hashes_to_update;
178 for (const auto& tx : block_template->block.vtx) {
179 const auto res = AcceptToMemoryPool(chainstate, tx, GetTime(), true, /*test_accept=*/false);
180 if (res.m_result_type == MempoolAcceptResult::ResultType::VALID) {
181 hashes_to_update.push_back(tx->GetHash());
182 } else {
183 tx_pool.removeRecursive(*tx, MemPoolRemovalReason::REORG);
184 }
185 }
186 tx_pool.UpdateTransactionsFromBlock(hashes_to_update);
187 }
188 const auto info_all = tx_pool.infoAll();
189 if (!info_all.empty()) {
191 WITH_LOCK(tx_pool.cs, tx_pool.removeRecursive(tx_to_remove, MemPoolRemovalReason::BLOCK /* dummy */));
192 assert(tx_pool.size() < info_all.size());
193 }
194
195 // Query a number of mempool entries as if to relay them, and assert some invariants on the result.
197 const auto wtxids_count_before{wtxids_to_relay.size()};
198 const auto n_to_sort{fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 100)};
199 const auto sorted_iter{WITH_LOCK(tx_pool.cs, return tx_pool.ExtractBestByMiningScoreWithTopology(wtxids_to_relay, n_to_sort))};
200 const auto expected_count{std::min(n_to_sort, wtxids_count_before)};
201 // We removed at least as many transactions from the list as we expected sorted entries.
203 // When there is enough non-duplicate in-mempool transactions (list of remaining wtxids is
204 // non-empty), we must have received the expected number of entries.
205 Assert(sorted_iter.size() == expected_count || wtxids_to_relay.empty());
206 if (n_to_sort > 0) {
207 // If we asked for a positive number of entries, we must have removed all wtxids that do
208 // not correspond to a mempool entry..
209 const auto is_in_mempool = [&](const auto& wtxid) EXCLUSIVE_LOCKS_REQUIRED(tx_pool.cs) { return tx_pool.GetIter(wtxid).has_value(); };
210 Assert(WITH_LOCK(tx_pool.cs, return std::ranges::all_of(wtxids_to_relay, is_in_mempool)));
211 // ..As well as all duplicates.
212 const auto wtxids_count{wtxids_to_relay.size()};
213 const std::set<Wtxid> unique_wtxids{std::make_move_iterator(wtxids_to_relay.begin()), std::make_move_iterator(wtxids_to_relay.end())};
215 }
216
218 // Try eviction
220 tx_pool.TrimToSize(fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0U, tx_pool.DynamicMemoryUsage() * 2));
221 }
223 // Try expiry
225 tx_pool.Expire(GetMockTime() - std::chrono::seconds(fuzzed_data_provider.ConsumeIntegral<uint32_t>()));
226 }
227 WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
228 g_setup->m_node.validation_signals->SyncWithValidationInterfaceQueue();
229}
230
232{
233 const auto time = ConsumeTime(fuzzed_data_provider,
234 chainstate.m_chain.Tip()->GetMedianTimePast() + 1,
235 std::numeric_limits<decltype(chainstate.m_chain.Tip()->nTime)>::max());
236 SetMockTime(time);
237}
238
239std::unique_ptr<CTxMemPool> MakeMempool(FuzzedDataProvider& fuzzed_data_provider, const NodeContext& node)
240{
241 // Take the default options for tests...
243
244 // ...override specific options for this specific fuzz suite
246 mempool_opts.require_standard = fuzzed_data_provider.ConsumeBool();
247
248 // ...and construct a CTxMemPool from it
249 bilingual_str error;
250 auto mempool{std::make_unique<CTxMemPool>(std::move(mempool_opts), error)};
251 // ... ignore the error since it might be beneficial to fuzz even when the
252 // mempool size is unreasonably small
253 Assert(error.empty() || error.original.starts_with("-maxmempool must be at least "));
254 return mempool;
255}
256
258{
259
260 switch (res.m_result_type) {
262 {
265 Assert(res.m_state.IsValid());
266 Assert(!res.m_state.IsInvalid());
267 Assert(res.m_vsize);
268 Assert(res.m_base_fees);
269 Assert(res.m_effective_feerate);
270 Assert(res.m_wtxids_fee_calculations);
271 Assert(!res.m_other_wtxid);
272 break;
273 }
275 {
276 // It may be already in the mempool since in ATMP cases we don't set MEMPOOL_ENTRY or DIFFERENT_WITNESS
277 Assert(!res.m_state.IsValid());
278 Assert(res.m_state.IsInvalid());
279
280 const bool is_reconsiderable{res.m_state.GetResult() == TxValidationResult::TX_RECONSIDERABLE};
281 Assert(!res.m_vsize);
282 Assert(!res.m_base_fees);
283 // Fee information is provided if the failure is TX_RECONSIDERABLE.
284 // In other cases, validation may be unable or unwilling to calculate the fees.
285 Assert(res.m_effective_feerate.has_value() == is_reconsiderable);
286 Assert(res.m_wtxids_fee_calculations.has_value() == is_reconsiderable);
287 Assert(!res.m_other_wtxid);
288 break;
289 }
291 {
292 // ATMP never sets this; only set in package settings
293 Assert(false);
294 break;
295 }
297 {
298 // ATMP never sets this; only set in package settings
299 Assert(false);
300 break;
301 }
302 }
303}
304
306{
308 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
309 const auto& node = g_setup->m_node;
310 auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
311
313
314 // All RBF-spendable outpoints
315 std::set<COutPoint> outpoints_rbf;
316 // All outpoints counting toward the total supply (subset of outpoints_rbf)
317 std::set<COutPoint> outpoints_supply;
318 for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
319 Assert(outpoints_supply.insert(outpoint).second);
320 }
322
323 // The sum of the values of all spendable outpoints
324 constexpr CAmount SUPPLY_TOTAL{COINBASE_MATURITY * 50 * COIN};
325
327 auto tx_pool_{MakeMempool(fuzzed_data_provider, node)};
328 MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(tx_pool_.get());
329
330 chainstate.SetMempool(&tx_pool);
331
332 bool accepted_transaction{false};
333
334 // Helper to query an amount
336 const auto GetAmount = [&](const COutPoint& outpoint) {
337 auto coin{amount_view.GetCoin(outpoint).value()};
338 return coin.out.nValue;
339 };
340
342 {
343 // Total supply is the mempool fee + all outpoints
344 CAmount supply_now{WITH_LOCK(tx_pool.cs, return tx_pool.GetTotalFee())};
345 for (const auto& op : outpoints_supply) {
346 supply_now += GetAmount(op);
347 }
349 }
350 Assert(!outpoints_supply.empty());
351
352 // Create transaction to add to the mempool
353 const CTransactionRef tx = [&] {
358 const auto num_out = fuzzed_data_provider.ConsumeIntegralInRange<int>(1, outpoints_rbf.size() * 2);
359
361 for (int i = 0; i < num_in; ++i) {
362 // Pop random outpoint
363 auto pop = outpoints_rbf.begin();
364 std::advance(pop, fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, outpoints_rbf.size() - 1));
365 const auto outpoint = *pop;
366 outpoints_rbf.erase(pop);
367 amount_in += GetAmount(outpoint);
368
369 // Create input
371 const auto script_sig = CScript{};
372 const auto script_wit_stack = std::vector<std::vector<uint8_t>>{WITNESS_STACK_ELEM_OP_TRUE};
373 CTxIn in;
374 in.prevout = outpoint;
375 in.nSequence = sequence;
378
379 tx_mut.vin.push_back(in);
380 }
381
382 // Check sigops in mempool + block template creation
384
386 const auto amount_out = (amount_in - amount_fee) / num_out;
387 for (int i = 0; i < num_out; ++i) {
388 if (i == 0 && add_sigops) {
389 tx_mut.vout.emplace_back(amount_out, CScript() << std::vector<unsigned char>(33, 0x02) << OP_CHECKSIG);
390 } else {
391 tx_mut.vout.emplace_back(amount_out, P2WSH_OP_TRUE);
392 }
393 }
394
395 auto tx = MakeTransactionRef(tx_mut);
396 // Restore previously removed outpoints
397 for (const auto& in : tx->vin) {
398 Assert(outpoints_rbf.insert(in.prevout).second);
399 }
400 return tx;
401 }();
402
405 }
407 tx_pool.RollingFeeUpdate();
408 }
410 const auto& txid = fuzzed_data_provider.ConsumeBool() ?
411 tx->GetHash() :
413 const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
414 tx_pool.PrioritiseTransaction(txid, delta);
415 }
416
417 // Remember all removed and added transactions
418 std::set<CTransactionRef> removed;
419 std::set<CTransactionRef> added;
420 auto txr = std::make_shared<TransactionsDelta>(removed, added);
421 node.validation_signals->RegisterSharedValidationInterface(txr);
422
423 // Make sure ProcessNewPackage on one transaction works.
424 // The result is not guaranteed to be the same as what is returned by ATMP.
426 return ProcessNewPackage(chainstate, tx_pool, {tx}, true, /*client_maxfeerate=*/{}));
427 // If something went wrong due to a package-specific policy, it might not return a
428 // validation result for the transaction.
429 if (result_package.m_state.GetResult() != PackageValidationResult::PCKG_POLICY) {
430 auto it = result_package.m_tx_results.find(tx->GetWitnessHash());
431 Assert(it != result_package.m_tx_results.end());
432 Assert(it->second.m_result_type == MempoolAcceptResult::ResultType::VALID ||
433 it->second.m_result_type == MempoolAcceptResult::ResultType::INVALID);
434 }
435
436 const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), /*bypass_limits=*/false, /*test_accept=*/false));
437 const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
439 node.validation_signals->SyncWithValidationInterfaceQueue();
440 node.validation_signals->UnregisterSharedValidationInterface(txr);
441
442 bool txid_in_mempool = tx_pool.exists(tx->GetHash());
443 bool wtxid_in_mempool = tx_pool.exists(tx->GetWitnessHash());
445
446 Assert(accepted != added.empty());
447 if (accepted) {
448 Assert(added.size() == 1); // For now, no package acceptance
449 Assert(tx == *added.begin());
451 } else {
452 // Do not consider rejected transaction removed
453 removed.erase(tx);
454 }
455
456 // Helper to insert spent and created outpoints of a tx into collections
457 using Sets = std::vector<std::reference_wrapper<std::set<COutPoint>>>;
458 const auto insert_tx = [](Sets created_by_tx, Sets consumed_by_tx, const auto& tx) {
459 for (size_t i{0}; i < tx.vout.size(); ++i) {
460 for (auto& set : created_by_tx) {
461 Assert(set.get().emplace(tx.GetHash(), i).second);
462 }
463 }
464 for (const auto& in : tx.vin) {
465 for (auto& set : consumed_by_tx) {
466 Assert(set.get().insert(in.prevout).second);
467 }
468 }
469 };
470 // Add created outpoints, remove spent outpoints
471 {
472 // Outpoints that no longer exist at all
473 std::set<COutPoint> consumed_erased;
474 // Outpoints that no longer count toward the total supply
475 std::set<COutPoint> consumed_supply;
476 for (const auto& removed_tx : removed) {
477 insert_tx(/*created_by_tx=*/{consumed_erased}, /*consumed_by_tx=*/{outpoints_supply}, /*tx=*/*removed_tx);
478 }
479 for (const auto& added_tx : added) {
480 insert_tx(/*created_by_tx=*/{outpoints_supply, outpoints_rbf}, /*consumed_by_tx=*/{consumed_supply}, /*tx=*/*added_tx);
481 }
482 for (const auto& p : consumed_erased) {
483 Assert(outpoints_supply.erase(p) == 1);
484 Assert(outpoints_rbf.erase(p) == 1);
485 }
486 for (const auto& p : consumed_supply) {
487 Assert(outpoints_supply.erase(p) == 1);
488 }
489 }
490 }
493}
494
496{
498 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
499 const auto& node = g_setup->m_node;
500 auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
501
503
504 std::vector<Txid> txids;
505 txids.reserve(g_outpoints_coinbase_init_mature.size());
506 for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
507 txids.push_back(outpoint.hash);
508 }
509 for (int i{0}; i <= 3; ++i) {
510 // Add some immature and non-existent outpoints
511 txids.push_back(g_outpoints_coinbase_init_immature.at(i).hash);
513 }
514
516 auto tx_pool_{MakeMempool(fuzzed_data_provider, node)};
517 MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(tx_pool_.get());
518
519 chainstate.SetMempool(&tx_pool);
520
521 bool accepted_transaction{false};
522
523 // If we ever bypass limits, do not do TRUC invariants checks
524 bool ever_bypassed_limits{false};
525
528
531 }
533 tx_pool.RollingFeeUpdate();
534 }
536 const auto txid = fuzzed_data_provider.ConsumeBool() ?
537 mut_tx.GetHash() :
539 const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
540 tx_pool.PrioritiseTransaction(txid, delta);
541 }
542
545
546 const auto tx = MakeTransactionRef(mut_tx);
547 const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), bypass_limits, /*test_accept=*/false));
548 const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
550 if (accepted) {
551 txids.push_back(tx->GetHash());
554 }
555 }
556 }
559}
560} // namespace
int64_t CAmount
Amount in satoshis (Can be negative)
Definition amount.h:12
constexpr CAmount COIN
The amount of satoshis in one BTC.
Definition amount.h:15
static void pool cs
ArgsManager & args
Definition bitcoind.cpp:280
const TestingSetup * g_setup
#define Assert(val)
Identity function.
Definition check.h:119
void ForceSetArg(const std::string &strArg, const std::string &strValue) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Definition args.cpp:611
CCoinsView that brings transactions from a mempool into view.
Definition txmempool.h:785
std::optional< Coin > GetCoin(const COutPoint &outpoint) const override
GetCoin, returning whether it exists and is not spent.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
Definition feerate.h:32
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition transaction.h:30
Serialized script, used inside transaction inputs and outputs.
Definition script.h:406
static constexpr uint32_t CURRENT_VERSION
An input of a transaction.
Definition transaction.h:63
uint32_t nSequence
Definition transaction.h:67
CScript scriptSig
Definition transaction.h:66
CScriptWitness scriptWitness
Only serialized through CTransaction.
Definition transaction.h:68
COutPoint prevout
Definition transaction.h:65
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition txmempool.h:188
Implement this to subscribe to events generated in validation and mempool.
virtual void TransactionRemovedFromMempool(const CTransactionRef &tx, MemPoolRemovalReason reason, uint64_t mempool_sequence)
Notifies listeners of a transaction leaving mempool.
virtual void TransactionAddedToMempool(const NewMempoolTransactionInfo &tx, uint64_t mempool_sequence)
Notifies listeners of a transaction having been added to mempool.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
Definition validation.h:550
T ConsumeIntegralInRange(T min, T max)
Generate a new block, without valid proof-of-work.
Definition miner.h:51
std::unique_ptr< CBlockTemplate > CreateNewBlock()
Construct a new block template.
Definition miner.cpp:126
static transaction_identifier FromUint256(const uint256 &id)
256-bit opaque blob.
Definition uint256.h:196
@ TX_RECONSIDERABLE
fails some policy, but might be acceptable if submitted in a (different) package
constexpr int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
Definition consensus.h:19
constexpr unsigned int MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule)
Definition consensus.h:15
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
Definition cs_main.cpp:8
#define FUZZ_TARGET(...)
Definition fuzz.h:35
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
Definition fuzz.h:22
uint64_t sequence
MemPoolRemovalReason
Reason why a transaction was removed from the mempool, this is passed to the notification signal.
@ BLOCK
Removed for block.
@ REORG
Removed for reorganization.
is used externally by mining IPC clients, so it should only declare simple data definitions.
Definition basic.cpp:11
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition string.h:250
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT
Default for -blockreservedweight.
Definition policy.h:27
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
void ObserveReachabilityGoal(bool reached, const ReachabilityGoal &goal)
Record whether a registered goal is satisfied by at least one fuzz input.
void RegisterReachabilityGoal(const ReachabilityGoal &goal)
Register a goal before executing any fuzz inputs.
@ OP_CHECKSIG
Definition script.h:191
node::NodeContext m_node
A mutable version of CTransaction.
std::vector< std::vector< unsigned char > > stack
Definition script.h:581
Validation result for a transaction evaluated by MemPoolAccept (single or package).
Definition validation.h:134
@ DIFFERENT_WITNESS
‍Valid, transaction was already in the mempool.
@ INVALID
‍Fully validated, valid.
A reachability condition explicitly registered by a fuzz target.
Testing setup that configures a complete environment.
const CTransactionRef m_tx
Bilingual messages:
Definition translation.h:24
bool empty() const
Definition translation.h:35
std::string original
Definition translation.h:25
Options struct containing options for constructing a CTxMemPool.
Block template creation options.
std::optional< CFeeRate > block_min_fee_rate
Minimum fee rate for transactions to be included.
NodeContext struct containing references to chain state and connection state.
Definition context.h:57
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
Definition context.h:89
std::unique_ptr< ChainstateManager > chainman
Definition context.h:74
#define LOCK2(cs1, cs2)
Definition sync.h:269
#define LOCK(cs)
Definition sync.h:268
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Definition sync.h:299
SeedRandomStateForTest(SeedRand::ZEROS)
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
CMutableTransaction ConsumeTransaction(FuzzedDataProvider &fuzzed_data_provider, const std::optional< std::vector< Txid > > &prevout_txids, const int max_num_in, const int max_num_out) noexcept
Definition util.cpp:42
CAmount ConsumeMoney(FuzzedDataProvider &fuzzed_data_provider, const std::optional< CAmount > &max) noexcept
Definition util.cpp:29
auto & PickValue(FuzzedDataProvider &fuzzed_data_provider, Collection &col)
Definition util.h:57
uint256 ConsumeUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
Definition util.h:195
COutPoint MineBlock(const NodeContext &node, const node::BlockCreateOptions &assembler_options)
Returns the generated coin.
Definition mining.cpp:123
@ 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
void CheckMempoolTRUCInvariants(const CTxMemPool &tx_pool)
For every transaction in tx_pool, check TRUC invariants:
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
Definition txmempool.cpp:21
#define EXCLUSIVE_LOCKS_REQUIRED(...)
constexpr decltype(CTransaction::version) TRUC_VERSION
Definition truc_policy.h:20
void SetMockTime(std::chrono::time_point< NodeClock, std::chrono::seconds > mock)
Definition time.cpp:52
std::chrono::seconds GetMockTime()
For testing.
Definition time.cpp:59
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
Definition time.cpp:88
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
Definition time.h:82
PackageMempoolAcceptResult ProcessNewPackage(Chainstate &active_chainstate, CTxMemPool &pool, const Package &package, bool test_accept, const std::optional< CFeeRate > &client_maxfeerate)
Validate (and maybe submit) a package to the mempool.
MempoolAcceptResult AcceptToMemoryPool(Chainstate &active_chainstate, const CTransactionRef &tx, int64_t accept_time, bool bypass_limits, bool test_accept)
Try to add a transaction to the mempool.
assert(!tx.IsCoinBase())
FuzzedDataProvider & fuzzed_data_provider
Definition fees.cpp:46