15 #include <validation.h> 44 std::vector<Available> available_coins;
45 std::vector<CTransactionRef> ordered_coins;
47 size_t tx_counter = 1;
48 for (
auto x = 0; x < 100; ++x) {
52 tx.
vin[0].scriptWitness.stack.push_back(
CScriptNum(x).getvch());
59 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
61 for (
auto x = 0; x < childTxs && !available_coins.empty(); ++x) {
63 size_t n_ancestors = det_rand.
randrange(10)+1;
64 for (
size_t ancestor = 0; ancestor < n_ancestors && !available_coins.empty(); ++ancestor){
65 size_t idx = det_rand.
randrange(available_coins.size());
67 Txid hash = coin.
ref->GetHash();
69 size_t n_to_take = det_rand.
randrange(2) == 0 ?
72 for (
size_t i = 0; i < n_to_take; ++i) {
73 tx.
vin.emplace_back();
79 coin = available_coins.back();
80 available_coins.pop_back();
89 available_coins.emplace_back(ordered_coins.back(), tx_counter++);
101 std::vector<CTransactionRef> ordered_coins =
CreateOrderedCoins(det_rand, childTxs, 1);
102 const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(
ChainType::MAIN);
106 for (
auto& tx : ordered_coins) {
109 pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4);
117 auto testing_setup = MakeNoLogFileContext<TestChain100Setup>(
ChainType::REGTEST, {.extra_args = {
"-checkmempool=1"}});
120 testing_setup->PopulateMempool(det_rand, 400,
true);
121 const CCoinsViewCache& coins_tip = testing_setup.get()->m_node.chainman->ActiveChainstate().CoinsTip();
125 pool.check(coins_tip, 300);
std::shared_ptr< const CTransaction > CTransactionRef
#define NO_THREAD_SAFETY_ANALYSIS
AddToMempool(pool, CTxMemPoolEntry(tx, 1000, nTime, nHeight, sequence, spendsCoinbase, sigOpCost, lp))
Bench & complexityN(T n) noexcept
BENCHMARK(ComplexMemPool, benchmark::PriorityLevel::HIGH)
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
Available(CTransactionRef &ref, size_t tx_count)
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
static std::vector< CTransactionRef > CreateOrderedCoins(FastRandomContext &det_rand, int childTxs, int min_ancestors)
std::vector< unsigned char > getvch() const
static void MempoolCheck(benchmark::Bench &bench)
An outpoint - a combination of a transaction hash and an index n into its vout.
std::vector< CTxOut > vout
static CTransactionRef MakeTransactionRef(Tx &&txIn)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Serialized script, used inside transaction inputs and outputs.
static void ComplexMemPool(benchmark::Bench &bench)
I randrange(I range) noexcept
Generate a random integer in the range [0..range), with range > 0.
A mutable version of CTransaction.
CTransactionRef get(const uint256 &hash) const
Main entry point to nanobench's benchmarking facility.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
static constexpr CAmount COIN
The amount of satoshis in one BTC.
static void AddTx(const CTransactionRef &tx, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main