38 const std::vector<CKey>&
keys,
39 const std::vector<CTxOut>& outputs,
51 {
COutPoint(coinbase_to_spend->GetHash(), 0)},
56 std::vector<CMutableTransaction> txs;
59 for (
int i{0}; i < num_txs; i++) {
60 std::vector<COutPoint> inputs;
61 inputs.reserve(outputs.size());
63 for (
size_t j{0}; j < outputs.size(); j++) {
64 inputs.emplace_back(tx_to_spend->GetHash(), j);
70 tx_to_spend = MakeTransactionRef(tx);
83std::pair<std::vector<CKey>, std::vector<CTxOut>>
CreateKeysAndOutputs(
const CKey& coinbaseKey,
size_t num_schnorr,
size_t num_ecdsa)
85 std::vector<CKey>
keys{coinbaseKey};
86 keys.reserve(num_schnorr + num_ecdsa + 1);
88 std::vector<CTxOut> outputs;
89 outputs.reserve(num_schnorr + num_ecdsa);
91 for (
size_t i{0}; i < num_ecdsa; ++i) {
96 for (
size_t i{0}; i < num_schnorr; ++i) {
101 return {
keys, outputs};
110 auto& chainstate{chainman->ActiveChainstate()};
112 auto* pindex{chainman->m_blockman.AddToBlockIndex(test_block, chainman->m_best_header)};
115 assert(chainstate.ConnectBlock(test_block, test_block_state, pindex, viewNew));
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
constexpr CAmount COIN
The amount of satoshis in one BTC.
int Height() const
Return the maximal height in the chain.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
An encapsulated private key.
CPubKey GetPubKey() const
Compute the public key from a private key.
Serialized script, used inside transaction inputs and outputs.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
XOnlyPubKey()=default
Construct an empty x-only pubkey.
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.
Bench & unit(char const *unit)
Sets the operation unit.
void BenchmarkConnectBlock(benchmark::Bench &bench, std::vector< CKey > &keys, std::vector< CTxOut > &outputs, TestChain100Setup &test_setup)
static void ConnectBlockMixedEcdsaSchnorr(benchmark::Bench &bench)
static void ConnectBlockAllEcdsa(benchmark::Bench &bench)
static void ConnectBlockAllSchnorr(benchmark::Bench &bench)
std::pair< std::vector< CKey >, std::vector< CTxOut > > CreateKeysAndOutputs(const CKey &coinbaseKey, size_t num_schnorr, size_t num_ecdsa)
CBlock CreateTestBlock(TestChain100Setup &test_setup, const std::vector< CKey > &keys, const std::vector< CTxOut > &outputs, int num_txs=1000)
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
CKey GenerateRandomKey(bool compressed) noexcept
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.
Testing fixture that pre-creates a 100-block REGTEST-mode block chain.
std::vector< CTransactionRef > m_coinbase_txns
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.
CBlock CreateAndProcessBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey)
Create a new block with just given transactions, coinbase paying to scriptPubKey, and try to add it t...
CBlock CreateBlock(const std::vector< CMutableTransaction > &txns, const CScript &scriptPubKey)
Create a new block with just given transactions, coinbase paying to scriptPubKey.
std::unique_ptr< ChainstateManager > chainman
std::vector< uint16_t > keys
consteval auto _(util::TranslatedLiteral str)