#34360 bench: add WalletBalanceManySpent for high-history wallet scenario

ReviewabilityReviewsAgreementSize
#34360 w0xlt bench: add WalletBalanceManySpent for high-history wallet scenarioWaiting on author0 (+1)Blocked0 + 249 tests
  • Measure wallet balance calculation performance on wallets with large histories of mostly spent outputs
  • Helps developers evaluate optimizations for high-activity workloads like Lightning nodes and exchanges
  • Ready to review
  • Unaddressed objection: remove dead forward-compatibility assertion code, no author reply (l0rinc)
  • Reversed earlier approval to request simplification of output-state assertions (l0rinc)
  • 0 lines added or modified outside tests
  • 249 lines added or modified in tests
  • 60 lines removed in total
  • 3 files, 2 commits
Test infrastructure#29 of 54
P3 · test coverage
  • P3 because it adds benchmark coverage for spent-heavy wallet histories to evaluate balance optimizations
  • Helps developers profile high-turnover wallet workloads like payment processors and Lightning nodes
  • Ranking pass: Moved down into the benchmark cluster; it serves one optimization PR (#27865) rather than general test signal.
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 the `WalletBalanceManySpent` benchmark to measure `GetBalance()` runtime on wallets with large histories consisting mostly of spent outputs (50,000 created outputs, 49,950 spent, 50 unspent). Also extracts fake block generation helpers from `wallet_create_tx.cpp` into a reusable header `bench/wallet_bench_util.h` for synthetic wallet block generation without full validation.

Problem: Wallet benchmarks lacked coverage for high-activity wallet usage patterns where the vast majority of historical transaction outputs have already been spent, such as in Lightning nodes, payment processors, or exchange hot wallets. Developers had no benchmark to profile or measure the performance of balance calculations under this workload or evaluate optimizations that track spent outputs separately.

Evidence of importance:

  • The PR description states it was created to test #27865 ('Track no-longer-spendable TXOs separately') and that 'this pattern mirrors real-world usage in high-activity wallets such as Lightning nodes, exchanges, hot wallets, and payment processors.'

Scope: Mechanically extracts and parameterizes `generateFakeBlock` from `src/bench/wallet_create_tx.cpp` into a new inline header `src/bench/wallet_bench_util.h`.

Risk of a mistake: low (tests). Touches only benchmark code and benchmark helper utilities with no effect on production code.

Changed since the previous assessment: The pull request is no longer draft, and the diff implementation is now available; the functional scope and approach are unchanged.

Reviewability

Paused · Waiting on author

Open objection from l0rinc with no author reply for 25 days; review would repeat what has been asked.

Waiting on (from the thread read):

  • author: address l0rinc's change request to simplify output-state assertions 2026-10-07
  • author: remove forward-compatibility branch and simplify assertions per l0rinc's change request 2026-10-07

Agreement

Blocked

objection that needs a change, nobody has replied (l0rinc)

Thread notes: l0rinc changed their stance to CHANGES_REQUESTED, asking to remove forward-compatibility dead code in the output-state assertions. / Added l0rinc's objection in rc:4206263403 requesting removal of the dead-code branch, which updated l0rinc's stance to objection and set waiting_on to author.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
l0rinc (member)objection, maintenancesimplify the output-state assertions to current base and remove dead forward-compatibility assertion codeopenchangedno2026-10-07: 'could we rather simplify this to the assertions needed on the current base?'

Support:

  • l0rinc (member) (ACK, 2026-05-22) [read: src/bench/wallet_balance.cpp]: thanked author for taking suggestions and accepted forward-compatibility code [not substantive]

Participants:

  • fanquake (member, neutral, 1 statements 2026-03-03 to 2026-03-03): notified achow101 of relevance to #27865
  • sedited (member, neutral, 2 statements 2026-05-14 to 2026-08-10): requested branch rebases
  • l0rinc (member, objection, 24 statements 2026-05-15 to 2026-10-07): requested changes to remove dead forward-compatibility assertion code
  • maflcko (member, neutral, 2 statements 2026-10-07 to 2026-10-07): discussed DrahtBot summary updating behavior

Dependencies

Enables:

Files

309 lines under test/bench/ci.

  • src/bench/wallet_balance.cpp +138/-1
  • src/bench/wallet_bench_util.h +102/-0
  • src/bench/wallet_create_tx.cpp +9/-59

Card

The short text the ranking pass compares across PRs.

Adds the WalletBalanceManySpent benchmark to measure GetBalance execution time on wallets holding tens of thousands of spent outputs and few unspent coins, simulating exchange hot wallets and Lightning nodes. It also extracts fake block generation helpers into a shared benchmark utility header. The benchmark was created to profile and evaluate optimizations in PR 27865 that separate spent transaction outputs from spendable ones.

Data

dossier JSON · extract JSON · model ledger, generated 2026-10-08T01:21, confidence high, input hash c422b013ed6385e9
thread read through 2026-10-07 (51 statements), head bc9a71bfc7
labels: Tests

Categories

Test infrastructure

P3 · test coverage (ranking pass: Moved down into the benchmark cluster; it serves one optimization PR (#27865) rather than general test signal.)

Adds benchmark coverage for wallets with large histories of spent outputs to profile balance calculations and evaluate optimizations such as #27865. It also refactors synthetic block generation into a reusable helper header 'src/bench/wallet_bench_util.h'.

Membership: Labeled 'Tests', modifies benchmark files in 'src/bench/', and extracts shared benchmark utility helpers into 'bench/wallet_bench_util.h'.

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