9#include <test/util/setup_common.h>
11#include <validation.h>
33static std::vector<CTransactionRef>
36 std::vector<Available> available_coins;
37 std::vector<CTransactionRef> ordered_coins;
39 size_t tx_counter = 1;
40 for (
auto x = 0; x < 100; ++x) {
45 for (
auto &out : tx.
vout) {
47 out.nValue = 10 *
COIN;
50 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
52 for (
auto x = 0; x < childTxs && !available_coins.empty(); ++x) {
54 size_t n_ancestors = det_rand.
randrange(10) + 1;
55 for (
size_t ancestor = 0;
56 ancestor < n_ancestors && !available_coins.empty(); ++ancestor) {
57 size_t idx = det_rand.
randrange(available_coins.size());
64 : min_ancestors + det_rand.
randrange(coin.
ref->vout.size() -
66 for (
size_t i = 0; i < n_to_take; ++i) {
67 tx.
vin.emplace_back();
68 tx.
vin.back().prevout = COutPoint(txid, coin.
vin_left++);
69 tx.
vin.back().scriptSig = CScript() << coin.
tx_count;
72 coin = available_coins.back();
73 available_coins.pop_back();
76 for (
auto &out : tx.
vout) {
77 out.scriptPubKey = CScript()
79 out.nValue = 10 *
COIN;
83 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
94 std::vector<CTransactionRef> ordered_coins =
96 const auto testing_setup =
101 for (
auto &tx : ordered_coins) {
111 auto testing_setup = MakeNoLogFileContext<TestChain100Setup>(
115 testing_setup->PopulateMempool(det_rand, 400,
true);
117 testing_setup.get()->m_node.chainman->ActiveChainstate().CoinsTip();
122 pool.check(coins_tip, 300);
static constexpr Amount SATOSHI
static constexpr Amount COIN
static const std::string REGTEST
static const std::string MAIN
BIP70 chain name strings (main, test or regtest)
CCoinsView that adds a memory cache for transactions to another CCoinsView.
A mutable version of CTransaction.
std::vector< CTxOut > vout
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
void TrimToSize(size_t sizelimit, std::vector< COutPoint > *pvNoSpendsRemaining=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove transactions from the mempool until its dynamic size is <= sizelimit.
size_t DynamicMemoryUsage() const
CTransactionRef get(const TxId &txid) const
void check(const CCoinsViewCache &active_coins_tip, int64_t spendheight) const EXCLUSIVE_LOCKS_REQUIRED(void addUnchecked(CTxMemPoolEntryRef entry) EXCLUSIVE_LOCKS_REQUIRED(cs
If sanity-checking is turned on, check makes sure the pool is consistent (does not contain two transa...
uint64_t randrange(uint64_t range) noexcept
Generate a random integer in the range [0..range).
static RCUPtr make(Args &&...args)
Construct a new object that is owned by the pointer.
Main entry point to nanobench's benchmarking facility.
Bench & complexityN(T b) noexcept
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
static void AddTx(const CTransactionRef &tx, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
static void MempoolCheck(benchmark::Bench &bench)
static std::vector< CTransactionRef > CreateOrderedCoins(FastRandomContext &det_rand, int childTxs, int min_ancestors)
BENCHMARK(ComplexMemPool)
static void ComplexMemPool(benchmark::Bench &bench)
int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigChecks, unsigned int bytes_per_sigCheck)
Compute the virtual transaction size (size, or more if sigChecks are too dense).
static CTransactionRef MakeTransactionRef()
std::shared_ptr< const CTransaction > CTransactionRef
Available(CTransactionRef &_ref, size_t _tx_count)
A TxId is the identifier of a transaction.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
#define NO_THREAD_SAFETY_ANALYSIS