#36475 bench: add BIP-352 pubkey extraction benchmarks (standard + P2PKH worst-case)

ReviewabilityReviewsAgreementSize
#36475 theStack bench: add BIP-352 pubkey extraction benchmarks (standard + P2PKH worst-case)Waiting on author2Strong0 + 112 tests
  • Benchmark Silent Payments public key extraction to measure performance overhead and catch regressions
  • Helps developers evaluate input parsing performance during ongoing protocol implementation updates
  • Ready for review; standalone benchmark suite touches no production code
  • Strong support for establishing Silent Payments parsing benchmarks
  • Verified benchmarks on Apple M5 and checked test inputs against btclib-wallet (fametrano)
  • Verified benchmark numbers on Windows and endorsed the test scope (Yudis-bit)
  • Suggested hoisting allocations outside loop to avoid repeated reallocations (Yudis-bit)
  • 0 lines added or modified outside tests
  • 112 lines added or modified in tests
  • 0 lines removed in total
  • 2 files, 2 commits
Test infrastructure#30 of 54
P3 · test coverage
  • P3 because it adds performance regression coverage for recently added Silent Payments parsing logic
  • Catches performance issues and reveals worst-case transaction parsing slowdowns during ongoing work
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Adds microbenchmarks for BIP-352 Silent Payments public key extraction (bip352::GetPubKeyFromInput) to bench_bitcoin. The suite tests standard input types—P2PKH, P2SH-P2WPKH, P2WPKH, and P2TR script-path spend—as well as a worst-case malleated P2PKH scriptSig designed to maximize hash iterations under consensus limits.

Problem: Silent Payments input parsing and key extraction logic has seen bug fixes and ongoing adjustments without dedicated benchmarks to evaluate execution overhead or protect against performance regressions.

Evidence of importance:

  • The PR author notes ongoing updates to GetPubKeyFromInput in recently merged #36338 and open #36417.
  • Benchmark figures from the description show that standard input extraction runs in ~2.8 to 3.0 µs, whereas the worst-case malleated P2PKH input takes ~69.9 µs (a ~23x slowdown).

Scope: Adds benchmark code only; introduces no production logic changes.

Risk of a mistake: low (tests). Only introduces standalone microbenchmarks in bench_bitcoin and touches no node or consensus code.

Changed since the previous assessment: Updated the P2TR benchmark input from a key-path spend to a script-path spend to exercise control block checking and NUMS-H internal key comparisons.

Reviewability

Paused · Waiting on author

Open objection from Yudis-bit with no author reply for 11 days; review would repeat what has been asked.

Waiting on (from the thread read):

  • author: response to Yudis-bit's suggestion regarding hoisting pubkey_candidate 2026-10-09

Agreement

Strong

substantive support, no open objection (Yudis-bit, Yudis-bit, fametrano)

Thread notes: Added fametrano's Tested ACK (c:6310687100) with benchmark results on Apple M5 and independent verification using btclib-wallet.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
Yudis-bit (none)suggestion, approachhoist pubkey_candidate outside the while loop in GetPubKeyFromInput to save heap reallocations across dummy pushesopen · no author replyansweredno2026-10-09: 'hoisting `pubkey_candidate` outside the while loop in `GetPubKeyFromInput` would save ~290 heap reallocations across the dummy pushes'
Yudis-bit (none)suggestion, scopeadd P2TR_ScriptPath and P2TR_ScriptPath_NUMS benchmarks for control-block validation and early rejectionaccepted · reviewer accepted author's rationale for sticking to a single representative P2TR benchmarkansweredyes2026-10-09: 'It might also be worth adding `P2TR_ScriptPath` and `P2TR_ScriptPath_NUMS` to benchmark the control-block validation and the early rejection path.'
Status from: 2026-10-17: Yudis-bit: 'Makes sense to stick to one P2TR case.'

Support:

  • w0xlt (contributor) (Concept ACK, 2026-10-08): (no reason given) [not substantive]
  • Yudis-bit (none) (Approach ACK, 2026-10-09) [read]: Numbers make sense given that `IsFullyValid()` point validation dominates the standard paths.
  • Yudis-bit (none) (Tested ACK, 2026-10-17) [tested]: Tested benchmarks on Windows and agreed with sticking to a single P2TR case
  • fametrano (contributor) (Tested ACK, 2026-10-21) [both]: The five benchmarks build and run on Apple M5, and rebuilt input shapes independently verified against btclib-wallet

Participants:

  • w0xlt (contributor, support, 1 statements 2026-10-08 to 2026-10-08): Concept ACK
  • Yudis-bit (none, support, 2 statements 2026-10-09 to 2026-10-17): Approach ACK, then Tested ACK after author answered suggestion on P2TR benchmark scope
  • fametrano (contributor, support, 1 statements 2026-10-21 to 2026-10-21): Tested ACK with benchmark results on Apple M5 and independent verification of input shapes

Files

112 lines under test/bench/ci.

  • src/bench/bip352.cpp +111/-0
  • src/bench/CMakeLists.txt +1/-0

Card

The short text the ranking pass compares across PRs.

Adds microbenchmarks for BIP-352 Silent Payments public key extraction (bip352::GetPubKeyFromInput) to bench_bitcoin. The benchmarks evaluate standard spend types (P2PKH, P2SH-P2WPKH, P2WPKH, P2TR script-path) along with an adversarial worst-case malleated P2PKH scriptSig. Benchmark numbers in the description demonstrate a 23x performance penalty under worst-case inputs, establishing a baseline to track performance across related Silent Payments PRs like #36338 and #36417.

Data

dossier JSON · extract JSON · model ledger, generated 2026-10-22T01:16, confidence high, input hash 714ab4a9d8bd55a2
thread read through 2026-10-21 (5 statements), head 56c0f168d1
labels: Tests

Categories

Test infrastructure

P3 · test coverage

Adds microbenchmarks to track execution overhead and protect against performance regressions in BIP-352 input extraction logic. The benchmarks cover standard input parsing and highlight a worst-case malleated P2PKH path with ~23x slowdown during ongoing logic updates.

Membership: Matches the Tests label and adds benchmark coverage in src/bench/bip352.cpp and src/bench/CMakeLists.txt, which is explicitly covered under test infrastructure.

Factors: security/stability 0, bug 0, performance 1, user value 0, leverage 1