32 static CBlock DummyBlock()
38 block.
nTime = 1231006505;
39 block.
nBits = 0x1d00ffff;
42 CMutableTransaction tx;
45 block.
vtx.emplace_back(MakeTransactionRef(tx));
50 BenchCBHAST(InsecureRandomContext& rng,
int txs) : CBlockHeaderAndShortTxIDs(DummyBlock(), rng.rand64())
52 shorttxids.reserve(txs);
54 shorttxids.push_back(rng.
randbits<SHORTTXIDS_LENGTH*8>());
68 std::vector<std::pair<Wtxid, CTransactionRef>> extratxn;
69 extratxn.reserve(n_extra);
72 std::array<std::byte,200> sigspam;
73 sigspam.fill(std::byte(42));
76 std::vector<CTransactionRef> refs;
77 refs.reserve(n_pool + n_extra);
78 for (
size_t i = 0; i < n_pool + n_extra; ++i) {
82 tx.
vin[0].scriptWitness.stack.push_back({1});
85 tx.
vout[0].nValue = i;
86 refs.push_back(MakeTransactionRef(tx));
91 std::shuffle(refs.begin(), refs.end(), rng);
93 for (
size_t i = 0; i < n_pool; ++i) {
94 AddTx(refs[i], refs[i]->vout[0].nValue, pool);
96 for (
size_t i = n_pool; i < n_pool + n_extra; ++i) {
97 extratxn.emplace_back(refs[i]->GetWitnessHash(), refs[i]);
100 BenchCBHAST cmpctblock{rng, 3000};
104 auto res = pdb.
InitData(cmpctblock, extratxn);
120 static_assert(DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN == 100);
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 ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
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.
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(...)