12 #include <validation.h> 26 const std::vector<CKey>& keys,
27 const std::vector<CTxOut>& outputs,
39 {
COutPoint(coinbase_to_spend->GetHash(), 0)},
40 chainstate.m_chain.Height() + 1, keys, outputs, {}, {})};
44 std::vector<CMutableTransaction> txs;
47 for (
int i{0}; i < num_txs; i++) {
48 std::vector<COutPoint> inputs;
49 inputs.reserve(outputs.size());
51 for (
size_t j{0}; j < outputs.size(); j++) {
52 inputs.emplace_back(tx_to_spend->GetHash(), j);
56 {tx_to_spend}, inputs, chainstate.m_chain.Height() + 1, keys, outputs, {}, {})};
62 return test_setup.
CreateBlock(txs, coinbase_spk, chainstate);
71 std::pair<std::vector<CKey>, std::vector<CTxOut>>
CreateKeysAndOutputs(
const CKey& coinbaseKey,
size_t num_schnorr,
size_t num_ecdsa)
73 std::vector<CKey> keys{coinbaseKey};
74 keys.reserve(num_schnorr + num_ecdsa + 1);
76 std::vector<CTxOut> outputs;
77 outputs.reserve(num_schnorr + num_ecdsa);
79 for (
size_t i{0}; i < num_ecdsa; ++i) {
84 for (
size_t i{0}; i < num_schnorr; ++i) {
89 return {keys, outputs};
98 auto& chainstate{chainman->ActiveChainstate()};
100 auto* pindex{chainman->m_blockman.AddToBlockIndex(test_block, chainman->m_best_header)};
103 assert(chainstate.ConnectBlock(test_block, test_block_state, pindex, viewNew));
109 const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()};
116 const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()};
124 const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()};
std::shared_ptr< const CTransaction > CTransactionRef
static void ConnectBlockAllEcdsa(benchmark::Bench &bench)
CPubKey GetPubKey() const
Compute the public key from a private key.
std::vector< CTransactionRef > m_coinbase_txns
static void ConnectBlockAllSchnorr(benchmark::Bench &bench)
consteval auto _(util::TranslatedLiteral str)
CKey GenerateRandomKey(bool compressed) noexcept
CBlock CreateAndProcessBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, Chainstate *chainstate=nullptr)
Create a new block with just given transactions, coinbase paying to scriptPubKey, and try to add it t...
Bench & run(char const *benchmarkName, Op &&op)
Repeatedly calls op() based on the configuration, and performs measurements.
Chainstate stores and provides an API to update our local knowledge of the current best chain...
CBlock CreateTestBlock(TestChain100Setup &test_setup, const std::vector< CKey > &keys, const std::vector< CTxOut > &outputs, int num_txs=1000)
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
std::pair< std::vector< CKey >, std::vector< CTxOut > > CreateKeysAndOutputs(const CKey &coinbaseKey, size_t num_schnorr, size_t num_ecdsa)
An outpoint - a combination of a transaction hash and an index n into its vout.
BENCHMARK(ConnectBlockAllSchnorr)
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
Bench & unit(char const *unit)
Sets the operation unit.
static void ConnectBlockMixedEcdsaSchnorr(benchmark::Bench &bench)
std::pair< CMutableTransaction, CAmount > CreateValidTransaction(const std::vector< CTransactionRef > &input_transactions, const std::vector< COutPoint > &inputs, int input_height, const std::vector< CKey > &input_signing_keys, const std::vector< CTxOut > &outputs, const std::optional< CFeeRate > &feerate, const std::optional< uint32_t > &fee_output)
Create a transaction, optionally setting the fee based on the feerate.
Serialized script, used inside transaction inputs and outputs.
CBlock CreateBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey, Chainstate &chainstate)
Create a new block with just given transactions, coinbase paying to scriptPubKey. ...
Main entry point to nanobench's benchmarking facility.
void BenchmarkConnectBlock(benchmark::Bench &bench, std::vector< CKey > &keys, std::vector< CTxOut > &outputs, TestChain100Setup &test_setup)
An encapsulated private key.
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...
std::unique_ptr< ChainstateManager > chainman
static constexpr CAmount COIN
The amount of satoshis in one BTC.