Merge bitcoin/bitcoin#32216: bench: Match ConnectBlock tx output counts

924f25f6fc bench: Match ConnectBlock tx output counts (monlovesmango)

Pull request description:

  There turned out to be a mismatch in the tx output counts which caused 'ConnectBlockMixedEcdsaSchnorr' benchmark to run slower than 'ConnectBlockAllEcdsa' and 'ConnectBlockAllSchnorr'. This commit makes the tx output counts uniform across all benchmarks.

  This commit also renames the 'taproot_tx' variable to 'tx' to reflect that this variable represents a general tx and not just a taproot tx.

ACKs for top commit:
  davidgumberg:
    Tested ACK 924f25f6fc
  Prabhat1308:
    reACK [`924f25f`](924f25f6fc)
  janb84:
    re ACK [924f25f](924f25f6fc)
  josibake:
    ACK 924f25f6fc

Tree-SHA512: bbf33e0c31b0c46571fd5d6ecd32426e7e823f9e156fd3d39a975bd5f0c1b6cd3dda55fa869cb0954c68dcf28cf4d0a0af40a72e440c1c78380b5b98e1eb6615
This commit is contained in:
Ryan Ofsky 2025-04-08 17:07:32 -04:00
commit 021b4f72db
No known key found for this signature in database
GPG key ID: 46800E30FC748A66

View file

@ -52,10 +52,10 @@ CBlock CreateTestBlock(
inputs.emplace_back(tx_to_spend->GetHash(), j); inputs.emplace_back(tx_to_spend->GetHash(), j);
} }
const auto [taproot_tx, _]{test_setup.CreateValidTransaction( const auto [tx, _]{test_setup.CreateValidTransaction(
{tx_to_spend}, inputs, chainstate.m_chain.Height() + 1, keys, outputs, {}, {})}; {tx_to_spend}, inputs, chainstate.m_chain.Height() + 1, keys, outputs, {}, {})};
txs.emplace_back(taproot_tx); txs.emplace_back(tx);
tx_to_spend = MakeTransactionRef(taproot_tx); tx_to_spend = MakeTransactionRef(tx);
} }
// Coinbase output can use any output type as it is not spent and will not change the benchmark // Coinbase output can use any output type as it is not spent and will not change the benchmark
@ -107,16 +107,10 @@ void BenchmarkConnectBlock(benchmark::Bench& bench, std::vector<CKey>& keys, std
static void ConnectBlockAllSchnorr(benchmark::Bench& bench) static void ConnectBlockAllSchnorr(benchmark::Bench& bench)
{ {
const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()}; const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()};
auto [keys, outputs]{CreateKeysAndOutputs(test_setup->coinbaseKey, /*num_schnorr=*/4, /*num_ecdsa=*/0)}; auto [keys, outputs]{CreateKeysAndOutputs(test_setup->coinbaseKey, /*num_schnorr=*/5, /*num_ecdsa=*/0)};
BenchmarkConnectBlock(bench, keys, outputs, *test_setup); BenchmarkConnectBlock(bench, keys, outputs, *test_setup);
} }
/**
* This benchmark is expected to be slower than the AllSchnorr or Ecdsa benchmark
* because it uses transactions with both Schnorr and Ecdsa signatures
* which requires the transaction to be hashed multiple times for
* the different signature algorithms
*/
static void ConnectBlockMixedEcdsaSchnorr(benchmark::Bench& bench) static void ConnectBlockMixedEcdsaSchnorr(benchmark::Bench& bench)
{ {
const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()}; const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()};
@ -128,7 +122,7 @@ static void ConnectBlockMixedEcdsaSchnorr(benchmark::Bench& bench)
static void ConnectBlockAllEcdsa(benchmark::Bench& bench) static void ConnectBlockAllEcdsa(benchmark::Bench& bench)
{ {
const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()}; const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()};
auto [keys, outputs]{CreateKeysAndOutputs(test_setup->coinbaseKey, /*num_schnorr=*/0, /*num_ecdsa=*/4)}; auto [keys, outputs]{CreateKeysAndOutputs(test_setup->coinbaseKey, /*num_schnorr=*/0, /*num_ecdsa=*/5)};
BenchmarkConnectBlock(bench, keys, outputs, *test_setup); BenchmarkConnectBlock(bench, keys, outputs, *test_setup);
} }