40 static CBlock DummyBlock()
46 block.
nTime = 1231006505;
47 block.
nBits = 0x1d00ffff;
50 CMutableTransaction tx;
53 block.
vtx.emplace_back(MakeTransactionRef(tx));
58 BenchCBHAST(InsecureRandomContext&
rng,
int txs) : CBlockHeaderAndShortTxIDs(DummyBlock(),
rng.rand64())
60 shorttxids.reserve(txs);
62 shorttxids.push_back(
rng.
randbits<SHORTTXIDS_LENGTH*8>());
76 std::vector<std::pair<Wtxid, CTransactionRef>> extratxn;
77 extratxn.reserve(n_extra);
80 std::array<std::byte,200> sigspam;
81 sigspam.fill(std::byte(42));
84 std::vector<CTransactionRef> refs;
85 refs.reserve(n_pool + n_extra);
86 for (
size_t i = 0; i < n_pool + n_extra; ++i) {
90 tx.
vin[0].scriptWitness.stack.push_back({1});
92 refs.push_back(MakeTransactionRef(tx));
97 std::shuffle(refs.begin(), refs.end(),
rng);
99 for (
size_t i = 0; i < n_pool; ++i) {
100 AddTx(refs[i], refs[i]->vout[0].nValue, pool);
102 for (
size_t i = n_pool; i < n_pool + n_extra; ++i) {
103 extratxn.emplace_back(refs[i]->GetWitnessHash(), refs[i]);
106 BenchCBHAST cmpctblock{
rng, 3000};
110 auto res = pdb.
InitData(cmpctblock, extratxn);
int64_t CAmount
Amount in satoshis (Can be negative).
static void BlockEncodingNoExtra(benchmark::Bench &bench)
static void BlockEncodingStdExtra(benchmark::Bench &bench)
static void BlockEncodingBench(benchmark::Bench &bench, size_t n_pool, size_t n_extra)
static void AddTx(const CTransactionRef &tx, const CAmount &fee, CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(cs_main
TryAddToMempool(pool, CTxMemPoolEntry(tx, fee, 0, 1, 0, false, 4, lp))
static void BlockEncodingLargeExtra(benchmark::Bench &bench)
#define Assert(val)
Identity function.
std::vector< CTransactionRef > vtx
CTxMemPoolEntry(const CTxMemPoolEntry &)=delete
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
An output of a transaction.
ReadStatus InitData(const CBlockHeaderAndShortTxIDs &cmpctblock, const std::vector< std::pair< Wtxid, CTransactionRef > > &extra_txn)
uint64_t randbits(int bits) noexcept
Generate a random (bits)-bit integer.
Main entry point to nanobench's benchmarking facility.
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.
constexpr uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN
Default number of non-mempool transactions to keep around for block reconstruction.
std::shared_ptr< const CTransaction > CTransactionRef
std::unique_ptr< T > MakeNoLogFileContext(const ChainType chain_type=ChainType::REGTEST, TestOpts opts={})
Make a test setup that has disk access to the debug.log file disabled.
A mutable version of CTransaction.
std::vector< CTxOut > vout
#define EXCLUSIVE_LOCKS_REQUIRED(...)