Skip to content

Commit 924f25f

Browse files
committed
bench: Match ConnectBlock tx output counts
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.
1 parent c66f7da commit 924f25f

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

src/bench/connectblock.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ CBlock CreateTestBlock(
5252
inputs.emplace_back(tx_to_spend->GetHash(), j);
5353
}
5454

55-
const auto [taproot_tx, _]{test_setup.CreateValidTransaction(
55+
const auto [tx, _]{test_setup.CreateValidTransaction(
5656
{tx_to_spend}, inputs, chainstate.m_chain.Height() + 1, keys, outputs, {}, {})};
57-
txs.emplace_back(taproot_tx);
58-
tx_to_spend = MakeTransactionRef(taproot_tx);
57+
txs.emplace_back(tx);
58+
tx_to_spend = MakeTransactionRef(tx);
5959
}
6060

6161
// 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
107107
static void ConnectBlockAllSchnorr(benchmark::Bench& bench)
108108
{
109109
const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()};
110-
auto [keys, outputs]{CreateKeysAndOutputs(test_setup->coinbaseKey, /*num_schnorr=*/4, /*num_ecdsa=*/0)};
110+
auto [keys, outputs]{CreateKeysAndOutputs(test_setup->coinbaseKey, /*num_schnorr=*/5, /*num_ecdsa=*/0)};
111111
BenchmarkConnectBlock(bench, keys, outputs, *test_setup);
112112
}
113113

114-
/**
115-
* This benchmark is expected to be slower than the AllSchnorr or Ecdsa benchmark
116-
* because it uses transactions with both Schnorr and Ecdsa signatures
117-
* which requires the transaction to be hashed multiple times for
118-
* the different signature algorithms
119-
*/
120114
static void ConnectBlockMixedEcdsaSchnorr(benchmark::Bench& bench)
121115
{
122116
const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()};
@@ -128,7 +122,7 @@ static void ConnectBlockMixedEcdsaSchnorr(benchmark::Bench& bench)
128122
static void ConnectBlockAllEcdsa(benchmark::Bench& bench)
129123
{
130124
const auto test_setup{MakeNoLogFileContext<TestChain100Setup>()};
131-
auto [keys, outputs]{CreateKeysAndOutputs(test_setup->coinbaseKey, /*num_schnorr=*/0, /*num_ecdsa=*/4)};
125+
auto [keys, outputs]{CreateKeysAndOutputs(test_setup->coinbaseKey, /*num_schnorr=*/0, /*num_ecdsa=*/5)};
132126
BenchmarkConnectBlock(bench, keys, outputs, *test_setup);
133127
}
134128

0 commit comments

Comments
 (0)