Bitcoin Core 30.99.0
P2P Digital Currency
tx_pool.cpp
Go to the documentation of this file.
1// Copyright (c) 2021-2022 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
6#include <node/context.h>
7#include <node/mempool_args.h>
8#include <node/miner.h>
11#include <test/fuzz/fuzz.h>
12#include <test/fuzz/util.h>
14#include <test/util/mining.h>
15#include <test/util/script.h>
17#include <test/util/txmempool.h>
18#include <util/check.h>
19#include <util/rbf.h>
20#include <util/translation.h>
21#include <validation.h>
22#include <validationinterface.h>
23
26using util::ToString;
27
28namespace {
29
30const TestingSetup* g_setup;
31std::vector<COutPoint> g_outpoints_coinbase_init_mature;
32std::vector<COutPoint> g_outpoints_coinbase_init_immature;
33
34struct MockedTxPool : public CTxMemPool {
35 void RollingFeeUpdate() EXCLUSIVE_LOCKS_REQUIRED(!cs)
36 {
37 LOCK(cs);
38 lastRollingFeeUpdate = GetTime();
39 blockSinceLastRollingFeeBump = true;
40 }
41};
42
43void initialize_tx_pool()
44{
45 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
46 g_setup = testing_setup.get();
47 SetMockTime(WITH_LOCK(g_setup->m_node.chainman->GetMutex(), return g_setup->m_node.chainman->ActiveTip()->Time()));
48
49 BlockAssembler::Options options;
50 options.coinbase_output_script = P2WSH_OP_TRUE;
51
52 for (int i = 0; i < 2 * COINBASE_MATURITY; ++i) {
53 COutPoint prevout{MineBlock(g_setup->m_node, options)};
54 // Remember the txids to avoid expensive disk access later on
55 auto& outpoints = i < COINBASE_MATURITY ?
56 g_outpoints_coinbase_init_mature :
57 g_outpoints_coinbase_init_immature;
58 outpoints.push_back(prevout);
59 }
60 g_setup->m_node.validation_signals->SyncWithValidationInterfaceQueue();
61}
62
63struct TransactionsDelta final : public CValidationInterface {
64 std::set<CTransactionRef>& m_removed;
65 std::set<CTransactionRef>& m_added;
66
67 explicit TransactionsDelta(std::set<CTransactionRef>& r, std::set<CTransactionRef>& a)
68 : m_removed{r}, m_added{a} {}
69
70 void TransactionAddedToMempool(const NewMempoolTransactionInfo& tx, uint64_t /* mempool_sequence */) override
71 {
72 Assert(m_added.insert(tx.info.m_tx).second);
73 }
74
75 void TransactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRemovalReason reason, uint64_t /* mempool_sequence */) override
76 {
77 Assert(m_removed.insert(tx).second);
78 }
79};
80
81void SetMempoolConstraints(ArgsManager& args, FuzzedDataProvider& fuzzed_data_provider)
82{
83 args.ForceSetArg("-limitclustercount",
85 args.ForceSetArg("-limitclustersize",
87 args.ForceSetArg("-maxmempool",
89 args.ForceSetArg("-mempoolexpiry",
91}
92
93void Finish(FuzzedDataProvider& fuzzed_data_provider, MockedTxPool& tx_pool, Chainstate& chainstate)
94{
95 WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
96 {
97 BlockAssembler::Options options;
99 options.blockMinFeeRate = CFeeRate{ConsumeMoney(fuzzed_data_provider, /*max=*/COIN)};
100 auto assembler = BlockAssembler{chainstate, &tx_pool, options};
101 auto block_template = assembler.CreateNewBlock();
102 Assert(block_template->block.vtx.size() >= 1);
103
104 // Try updating the mempool for this block, as though it were mined.
105 LOCK2(::cs_main, tx_pool.cs);
106 tx_pool.removeForBlock(block_template->block.vtx, chainstate.m_chain.Height() + 1);
107
108 // Now try to add those transactions back, as though a reorg happened.
109 std::vector<Txid> hashes_to_update;
110 for (const auto& tx : block_template->block.vtx) {
111 const auto res = AcceptToMemoryPool(chainstate, tx, GetTime(), true, /*test_accept=*/false);
112 if (res.m_result_type == MempoolAcceptResult::ResultType::VALID) {
113 hashes_to_update.push_back(tx->GetHash());
114 } else {
115 tx_pool.removeRecursive(*tx, MemPoolRemovalReason::REORG);
116 }
117 }
118 tx_pool.UpdateTransactionsFromBlock(hashes_to_update);
119 }
120 const auto info_all = tx_pool.infoAll();
121 if (!info_all.empty()) {
122 const auto& tx_to_remove = *PickValue(fuzzed_data_provider, info_all).tx;
123 WITH_LOCK(tx_pool.cs, tx_pool.removeRecursive(tx_to_remove, MemPoolRemovalReason::BLOCK /* dummy */));
124 assert(tx_pool.size() < info_all.size());
125 }
126
128 // Try eviction
129 LOCK2(::cs_main, tx_pool.cs);
130 tx_pool.TrimToSize(fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0U, tx_pool.DynamicMemoryUsage() * 2));
131 }
133 // Try expiry
134 LOCK2(::cs_main, tx_pool.cs);
135 tx_pool.Expire(GetMockTime() - std::chrono::seconds(fuzzed_data_provider.ConsumeIntegral<uint32_t>()));
136 }
137 WITH_LOCK(::cs_main, tx_pool.check(chainstate.CoinsTip(), chainstate.m_chain.Height() + 1));
138 g_setup->m_node.validation_signals->SyncWithValidationInterfaceQueue();
139}
140
141void MockTime(FuzzedDataProvider& fuzzed_data_provider, const Chainstate& chainstate)
142{
143 const auto time = ConsumeTime(fuzzed_data_provider,
144 chainstate.m_chain.Tip()->GetMedianTimePast() + 1,
145 std::numeric_limits<decltype(chainstate.m_chain.Tip()->nTime)>::max());
146 SetMockTime(time);
147}
148
149std::unique_ptr<CTxMemPool> MakeMempool(FuzzedDataProvider& fuzzed_data_provider, const NodeContext& node)
150{
151 // Take the default options for tests...
153
154 // ...override specific options for this specific fuzz suite
155 mempool_opts.check_ratio = 1;
156 mempool_opts.require_standard = fuzzed_data_provider.ConsumeBool();
157
158 // ...and construct a CTxMemPool from it
159 bilingual_str error;
160 auto mempool{std::make_unique<CTxMemPool>(std::move(mempool_opts), error)};
161 // ... ignore the error since it might be beneficial to fuzz even when the
162 // mempool size is unreasonably small
163 Assert(error.empty() || error.original.starts_with("-maxmempool must be at least "));
164 return mempool;
165}
166
167void CheckATMPInvariants(const MempoolAcceptResult& res, bool txid_in_mempool, bool wtxid_in_mempool)
168{
169
170 switch (res.m_result_type) {
172 {
173 Assert(txid_in_mempool);
174 Assert(wtxid_in_mempool);
175 Assert(res.m_state.IsValid());
176 Assert(!res.m_state.IsInvalid());
177 Assert(res.m_vsize);
178 Assert(res.m_base_fees);
181 Assert(!res.m_other_wtxid);
182 break;
183 }
185 {
186 // It may be already in the mempool since in ATMP cases we don't set MEMPOOL_ENTRY or DIFFERENT_WITNESS
187 Assert(!res.m_state.IsValid());
188 Assert(res.m_state.IsInvalid());
189
190 const bool is_reconsiderable{res.m_state.GetResult() == TxValidationResult::TX_RECONSIDERABLE};
191 Assert(!res.m_vsize);
192 Assert(!res.m_base_fees);
193 // Fee information is provided if the failure is TX_RECONSIDERABLE.
194 // In other cases, validation may be unable or unwilling to calculate the fees.
195 Assert(res.m_effective_feerate.has_value() == is_reconsiderable);
196 Assert(res.m_wtxids_fee_calculations.has_value() == is_reconsiderable);
197 Assert(!res.m_other_wtxid);
198 break;
199 }
201 {
202 // ATMP never sets this; only set in package settings
203 Assert(false);
204 break;
205 }
207 {
208 // ATMP never sets this; only set in package settings
209 Assert(false);
210 break;
211 }
212 }
213}
214
215FUZZ_TARGET(tx_pool_standard, .init = initialize_tx_pool)
216{
218 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
219 const auto& node = g_setup->m_node;
220 auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
221
222 MockTime(fuzzed_data_provider, chainstate);
223
224 // All RBF-spendable outpoints
225 std::set<COutPoint> outpoints_rbf;
226 // All outpoints counting toward the total supply (subset of outpoints_rbf)
227 std::set<COutPoint> outpoints_supply;
228 for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
229 Assert(outpoints_supply.insert(outpoint).second);
230 }
231 outpoints_rbf = outpoints_supply;
232
233 // The sum of the values of all spendable outpoints
234 constexpr CAmount SUPPLY_TOTAL{COINBASE_MATURITY * 50 * COIN};
235
236 SetMempoolConstraints(*node.args, fuzzed_data_provider);
237 auto tx_pool_{MakeMempool(fuzzed_data_provider, node)};
238 MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(tx_pool_.get());
239
240 chainstate.SetMempool(&tx_pool);
241
242 // Helper to query an amount
243 const CCoinsViewMemPool amount_view{WITH_LOCK(::cs_main, return &chainstate.CoinsTip()), tx_pool};
244 const auto GetAmount = [&](const COutPoint& outpoint) {
245 auto coin{amount_view.GetCoin(outpoint).value()};
246 return coin.out.nValue;
247 };
248
250 {
251 {
252 // Total supply is the mempool fee + all outpoints
253 CAmount supply_now{WITH_LOCK(tx_pool.cs, return tx_pool.GetTotalFee())};
254 for (const auto& op : outpoints_supply) {
255 supply_now += GetAmount(op);
256 }
257 Assert(supply_now == SUPPLY_TOTAL);
258 }
259 Assert(!outpoints_supply.empty());
260
261 // Create transaction to add to the mempool
262 const CTransactionRef tx = [&] {
263 CMutableTransaction tx_mut;
266 const auto num_in = fuzzed_data_provider.ConsumeIntegralInRange<int>(1, outpoints_rbf.size());
267 const auto num_out = fuzzed_data_provider.ConsumeIntegralInRange<int>(1, outpoints_rbf.size() * 2);
268
269 CAmount amount_in{0};
270 for (int i = 0; i < num_in; ++i) {
271 // Pop random outpoint
272 auto pop = outpoints_rbf.begin();
273 std::advance(pop, fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, outpoints_rbf.size() - 1));
274 const auto outpoint = *pop;
275 outpoints_rbf.erase(pop);
276 amount_in += GetAmount(outpoint);
277
278 // Create input
280 const auto script_sig = CScript{};
281 const auto script_wit_stack = std::vector<std::vector<uint8_t>>{WITNESS_STACK_ELEM_OP_TRUE};
282 CTxIn in;
283 in.prevout = outpoint;
284 in.nSequence = sequence;
285 in.scriptSig = script_sig;
286 in.scriptWitness.stack = script_wit_stack;
287
288 tx_mut.vin.push_back(in);
289 }
290
291 // Check sigops in mempool + block template creation
292 bool add_sigops{fuzzed_data_provider.ConsumeBool()};
293
294 const auto amount_fee = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-1000, amount_in);
295 const auto amount_out = (amount_in - amount_fee) / num_out;
296 for (int i = 0; i < num_out; ++i) {
297 if (i == 0 && add_sigops) {
298 tx_mut.vout.emplace_back(amount_out, CScript() << std::vector<unsigned char>(33, 0x02) << OP_CHECKSIG);
299 } else {
300 tx_mut.vout.emplace_back(amount_out, P2WSH_OP_TRUE);
301 }
302 }
303
304 auto tx = MakeTransactionRef(tx_mut);
305 // Restore previously removed outpoints
306 for (const auto& in : tx->vin) {
307 Assert(outpoints_rbf.insert(in.prevout).second);
308 }
309 return tx;
310 }();
311
313 MockTime(fuzzed_data_provider, chainstate);
314 }
316 tx_pool.RollingFeeUpdate();
317 }
319 const auto& txid = fuzzed_data_provider.ConsumeBool() ?
320 tx->GetHash() :
321 PickValue(fuzzed_data_provider, outpoints_rbf).hash;
322 const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
323 tx_pool.PrioritiseTransaction(txid, delta);
324 }
325
326 // Remember all removed and added transactions
327 std::set<CTransactionRef> removed;
328 std::set<CTransactionRef> added;
329 auto txr = std::make_shared<TransactionsDelta>(removed, added);
330 node.validation_signals->RegisterSharedValidationInterface(txr);
331
332 // Make sure ProcessNewPackage on one transaction works.
333 // The result is not guaranteed to be the same as what is returned by ATMP.
334 const auto result_package = WITH_LOCK(::cs_main,
335 return ProcessNewPackage(chainstate, tx_pool, {tx}, true, /*client_maxfeerate=*/{}));
336 // If something went wrong due to a package-specific policy, it might not return a
337 // validation result for the transaction.
338 if (result_package.m_state.GetResult() != PackageValidationResult::PCKG_POLICY) {
339 auto it = result_package.m_tx_results.find(tx->GetWitnessHash());
340 Assert(it != result_package.m_tx_results.end());
341 Assert(it->second.m_result_type == MempoolAcceptResult::ResultType::VALID ||
342 it->second.m_result_type == MempoolAcceptResult::ResultType::INVALID);
343 }
344
345 const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), /*bypass_limits=*/false, /*test_accept=*/false));
346 const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
347 node.validation_signals->SyncWithValidationInterfaceQueue();
348 node.validation_signals->UnregisterSharedValidationInterface(txr);
349
350 bool txid_in_mempool = tx_pool.exists(tx->GetHash());
351 bool wtxid_in_mempool = tx_pool.exists(tx->GetWitnessHash());
352 CheckATMPInvariants(res, txid_in_mempool, wtxid_in_mempool);
353
354 Assert(accepted != added.empty());
355 if (accepted) {
356 Assert(added.size() == 1); // For now, no package acceptance
357 Assert(tx == *added.begin());
359 } else {
360 // Do not consider rejected transaction removed
361 removed.erase(tx);
362 }
363
364 // Helper to insert spent and created outpoints of a tx into collections
365 using Sets = std::vector<std::reference_wrapper<std::set<COutPoint>>>;
366 const auto insert_tx = [](Sets created_by_tx, Sets consumed_by_tx, const auto& tx) {
367 for (size_t i{0}; i < tx.vout.size(); ++i) {
368 for (auto& set : created_by_tx) {
369 Assert(set.get().emplace(tx.GetHash(), i).second);
370 }
371 }
372 for (const auto& in : tx.vin) {
373 for (auto& set : consumed_by_tx) {
374 Assert(set.get().insert(in.prevout).second);
375 }
376 }
377 };
378 // Add created outpoints, remove spent outpoints
379 {
380 // Outpoints that no longer exist at all
381 std::set<COutPoint> consumed_erased;
382 // Outpoints that no longer count toward the total supply
383 std::set<COutPoint> consumed_supply;
384 for (const auto& removed_tx : removed) {
385 insert_tx(/*created_by_tx=*/{consumed_erased}, /*consumed_by_tx=*/{outpoints_supply}, /*tx=*/*removed_tx);
386 }
387 for (const auto& added_tx : added) {
388 insert_tx(/*created_by_tx=*/{outpoints_supply, outpoints_rbf}, /*consumed_by_tx=*/{consumed_supply}, /*tx=*/*added_tx);
389 }
390 for (const auto& p : consumed_erased) {
391 Assert(outpoints_supply.erase(p) == 1);
392 Assert(outpoints_rbf.erase(p) == 1);
393 }
394 for (const auto& p : consumed_supply) {
395 Assert(outpoints_supply.erase(p) == 1);
396 }
397 }
398 }
399 Finish(fuzzed_data_provider, tx_pool, chainstate);
400}
401
402FUZZ_TARGET(tx_pool, .init = initialize_tx_pool)
403{
405 FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());
406 const auto& node = g_setup->m_node;
407 auto& chainstate{static_cast<DummyChainState&>(node.chainman->ActiveChainstate())};
408
409 MockTime(fuzzed_data_provider, chainstate);
410
411 std::vector<Txid> txids;
412 txids.reserve(g_outpoints_coinbase_init_mature.size());
413 for (const auto& outpoint : g_outpoints_coinbase_init_mature) {
414 txids.push_back(outpoint.hash);
415 }
416 for (int i{0}; i <= 3; ++i) {
417 // Add some immature and non-existent outpoints
418 txids.push_back(g_outpoints_coinbase_init_immature.at(i).hash);
420 }
421
422 SetMempoolConstraints(*node.args, fuzzed_data_provider);
423 auto tx_pool_{MakeMempool(fuzzed_data_provider, node)};
424 MockedTxPool& tx_pool = *static_cast<MockedTxPool*>(tx_pool_.get());
425
426 chainstate.SetMempool(&tx_pool);
427
428 // If we ever bypass limits, do not do TRUC invariants checks
429 bool ever_bypassed_limits{false};
430
432 {
433 const auto mut_tx = ConsumeTransaction(fuzzed_data_provider, txids);
434
436 MockTime(fuzzed_data_provider, chainstate);
437 }
439 tx_pool.RollingFeeUpdate();
440 }
442 const auto txid = fuzzed_data_provider.ConsumeBool() ?
443 mut_tx.GetHash() :
445 const auto delta = fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(-50 * COIN, +50 * COIN);
446 tx_pool.PrioritiseTransaction(txid, delta);
447 }
448
449 const bool bypass_limits{fuzzed_data_provider.ConsumeBool()};
450 ever_bypassed_limits |= bypass_limits;
451
452 const auto tx = MakeTransactionRef(mut_tx);
453 const auto res = WITH_LOCK(::cs_main, return AcceptToMemoryPool(chainstate, tx, GetTime(), bypass_limits, /*test_accept=*/false));
454 const bool accepted = res.m_result_type == MempoolAcceptResult::ResultType::VALID;
455 if (accepted) {
456 txids.push_back(tx->GetHash());
457 if (!ever_bypassed_limits) {
459 }
460 }
461 }
462 Finish(fuzzed_data_provider, tx_pool, chainstate);
463}
464} // namespace
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
static void pool cs
ArgsManager & args
Definition: bitcoind.cpp:277
#define Assert(val)
Identity function.
Definition: check.h:113
void ForceSetArg(const std::string &strArg, const std::string &strValue)
Definition: args.cpp:550
uint32_t nTime
Definition: chain.h:151
int64_t GetMedianTimePast() const
Definition: chain.h:242
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
Definition: chain.h:397
int Height() const
Return the maximal height in the chain.
Definition: chain.h:426
CCoinsView that brings transactions from a mempool into view.
Definition: txmempool.h:779
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
Definition: feerate.h:35
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:413
static const uint32_t CURRENT_VERSION
Definition: transaction.h:299
An input of a transaction.
Definition: transaction.h:67
uint32_t nSequence
Definition: transaction.h:71
CScript scriptSig
Definition: transaction.h:70
CScriptWitness scriptWitness
Only serialized through CTransaction.
Definition: transaction.h:72
COutPoint prevout
Definition: transaction.h:69
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:189
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:532
CChain m_chain
The current chain of blockheaders we consult and build on.
Definition: validation.h:614
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(
Definition: validation.h:640
T ConsumeIntegralInRange(T min, T max)
bool IsValid() const
Definition: validation.h:105
Result GetResult() const
Definition: validation.h:108
bool IsInvalid() const
Definition: validation.h:106
Generate a new block, without valid proof-of-work.
Definition: miner.h:57
static transaction_identifier FromUint256(const uint256 &id)
@ TX_RECONSIDERABLE
fails some policy, but might be acceptable if submitted in a (different) package
static const unsigned int MAX_BLOCK_WEIGHT
The maximum allowed weight for a block, see BIP 141 (network rule)
Definition: consensus.h:15
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 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.
Definition: messages.h:21
std::string ToString(const T &t)
Locale-independent version of std::to_string.
Definition: string.h:245
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Definition: transaction.h:424
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:423
@ OP_CHECKSIG
Definition: script.h:190
node::NodeContext m_node
Definition: setup_common.h:66
A mutable version of CTransaction.
Definition: transaction.h:378
std::vector< CTxOut > vout
Definition: transaction.h:380
std::vector< CTxIn > vin
Definition: transaction.h:379
std::vector< std::vector< unsigned char > > stack
Definition: script.h:588
Validation result for a transaction evaluated by MemPoolAccept (single or package).
Definition: validation.h:127
const std::optional< int64_t > m_vsize
Virtual size as used by the mempool, calculated using serialized size and sigops.
Definition: validation.h:144
const ResultType m_result_type
Result type.
Definition: validation.h:136
const std::optional< CAmount > m_base_fees
Raw base fees in satoshis.
Definition: validation.h:146
const TxValidationState m_state
Contains information about why the transaction failed.
Definition: validation.h:139
@ DIFFERENT_WITNESS
‍Valid, transaction was already in the mempool.
@ INVALID
‍Fully validated, valid.
const std::optional< CFeeRate > m_effective_feerate
The feerate at which this transaction was considered.
Definition: validation.h:152
const std::optional< Wtxid > m_other_wtxid
The wtxid of the transaction in the mempool which has the same txid but different witness.
Definition: validation.h:161
const std::optional< std::vector< Wtxid > > m_wtxids_fee_calculations
Contains the wtxids of the transactions used for fee-related checks.
Definition: validation.h:158
Testing setup that configures a complete environment.
Definition: setup_common.h:121
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.
NodeContext struct containing references to chain state and connection state.
Definition: context.h:56
std::unique_ptr< ValidationSignals > validation_signals
Issues calls about blocks and transactions.
Definition: context.h:88
std::unique_ptr< ChainstateManager > chainman
Definition: context.h:72
#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
uint32_t ConsumeSequence(FuzzedDataProvider &fuzzed_data_provider) noexcept
Definition: util.cpp:155
int64_t ConsumeTime(FuzzedDataProvider &fuzzed_data_provider, const std::optional< int64_t > &min, const std::optional< int64_t > &max) noexcept
Definition: util.cpp:34
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:47
uint256 ConsumeUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
Definition: util.h:171
COutPoint MineBlock(const NodeContext &node, const node::BlockAssembler::Options &assembler_options)
Returns the generated coin.
Definition: mining.cpp:70
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
void CheckMempoolTRUCInvariants(const CTxMemPool &tx_pool)
For every transaction in tx_pool, check TRUC invariants:
Definition: txmempool.cpp:182
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
Definition: txmempool.cpp:21
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
static constexpr decltype(CTransaction::version) TRUC_VERSION
Definition: truc_policy.h:20
std::chrono::seconds GetMockTime()
For testing.
Definition: time.cpp:48
int64_t GetTime()
DEPRECATED Use either ClockType::now() or Now<TimePointType>() if a cast is needed.
Definition: time.cpp:77
void SetMockTime(int64_t nMockTimeIn)
DEPRECATED Use SetMockTime with chrono type.
Definition: time.cpp:40
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:38