Merge bitcoin/bitcoin#36966: bench: fix `InputType` ODR violation
What changed, and why it matters
This change fixes a C++ programming rule violation where two unrelated pieces of benchmark code happened to use the same name, 'InputType', for slightly different lists of Bitcoin address types. With whole-program optimization enabled, this could cause build warnings or incorrect linking, but it only affects internal benchmark tools—not the live Bitcoin network code, wallet handling, or consensus logic. There is no security vulnerability in the running software.
No security action required. Treat as a normal code-quality/build-hygiene fix. If backporting, include only for build cleanliness; it is not a vulnerability patch.
Security signals we found
ODR violation in benchmark-only code
No runtime security boundary crossed
No input parsing, network, wallet, or consensus code modified
Evidence from the diff
The commit resolves an ODR (One Definition Rule) violation: two translation units in the bench/ directory (bip352.cpp and sign_transaction.cpp) each defined an enum class named InputType with different enumerators. Under link-time optimization (LTO), identical type names with different definitions violate the C++ ODR and can produce -Wodr warnings or undefined behavior at link time. The fix wraps each enum in an anonymous namespace, giving them internal linkage and distinct identities. A CI job is also updated to enable CMAKE_INTERPROCEDURAL_OPTIMIZATION and treat linker warnings as errors, which would catch such issues in future builds.
Changed components
src/bench/bip352.cppsrc/bench/sign_transaction.cppci/test/00_setup_env_native_alpine_musl.shInspect captured patch +7 / −1
### ci/test/00_setup_env_native_alpine_musl.sh
@@ -13,7 +13,9 @@ export DEP_OPTS="DEBUG=1"
printf -v BITCOIN_CONFIG "%q " \
--preset=dev-mode \
-DREDUCE_EXPORTS=ON \
- -DCMAKE_BUILD_TYPE=Debug
+ -DCMAKE_BUILD_TYPE=Debug \
+ -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON \
+ -DCMAKE_LINK_WARNING_AS_ERROR=ON
export BITCOIN_CONFIG
export TEST_RUNNER_EXTRA="--v2transport --usecli --extended --exclude feature_dbcrash" # Run extended tests under --usecli and --v2transport, but exclude the very slow dbcrash
export BITCOIN_CMD="bitcoin -m" # Used in functional tests
### src/bench/bip352.cpp
@@ -19,13 +19,15 @@
#include <variant>
#include <vector>
+namespace {
enum class InputType {
P2PKH, // legacy pubkey-hash
P2SH_P2WPKH, // nested segwitv0 witness-pubkey-hash
P2WPKH, // segwitv0 witness-pubkey-hash
P2TR, // segwitv1, taproot script-path spend (covers more extraction logic than key-path)
P2PKH_WorstCase, // legacy pubkey-hash, with scriptSig malleated for worst-case performance (see below)
};
+} // namespace
// The extraction doesn't verify signatures, so dummy ones with realistic sizes suffice.
static const std::vector<unsigned char> DUMMY_ECDSA_SIG(71, 0x01); // low-R/low-S DER signature (following BIP-461) + sighash byte
### src/bench/sign_transaction.cpp
@@ -21,10 +21,12 @@
#include <span>
#include <vector>
+namespace {
enum class InputType {
P2WPKH, // segwitv0, witness-pubkey-hash (ECDSA signature)
P2TR, // segwitv1, taproot key-path spend (Schnorr signature)
};
+} // namespace
static void SignTransactionSingleInput(benchmark::Bench& bench, InputType input_type)
{Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.