1 minor finding · 3 suggestions
Findings
[minor] · Weight-only trimming leaves sigop-heavy benchmark recipes aborting
A multisig-heavy benchmark recipe can pass weight trimming but still abort in Assert(CheckBlock(...)); no checked-in caller supplying a triggering recipe was found.
Location: src/bench/block_generator.cpp:228 (head).
Details and suggested fix
With multisig_prob = 1.0, each output costs 20 legacy sigops even when it contains fewer than 20 keys. More than 1,000 surviving outputs therefore exceed CheckBlock's 20,000-sigop limit without necessarily exceeding the weight limit. The loop removes transactions only for weight, so that case reaches bad-blk-sigops and the fatal assertion. Trim until both limits are met, then rebuild the witness commitment and merkle root as already done, and add a multisig-heavy recipe test.
Optional improvements
[suggestion] · Custom script probabilities have no test oracle
The new suite would not detect replacing the caller's output-script distribution with WITNESS_RECIPE, leaving the benchmark generator's central configuration behaviour untested.
Location: src/test/bench_block_generator_tests.cpp:25 (head).
Details and suggested fix
The pinned hash uses the default recipe. The legacy assertions check only witness stacks and the commitment, both controlled separately by rec.include_witness; the remaining checks do not assert output types. A factory-only change to CreateScriptFactory(rng, WITNESS_RECIPE) would therefore escape these assertions. Add one-hot P2PKH and P2TR cases with tx_count = 1 and geometric_base_prob = 0, then check the non-coinbase output type using Solver.
[suggestion] · Shared generator compiles twice and is filtered out of lcov
When both binaries are built, the generator compiles twice; its src/bench path also excludes it from the project's lcov reports despite the new unit tests.
Location: src/test/CMakeLists.txt:146 (head).
Details and suggested fix
Move block_generator.{h,cpp} into src/test/util and compile the implementation as part of test_util, which both binaries already link. The generator already depends on <test/util/script.h>. Provide test_util with the secp256k1 header usage requirements when moving it. This preserves benchmark and test behaviour while sharing the compiled implementation and retaining its coverage in the lcov report.
[suggestion] · Benchmark generator declarations omit enforced input constraints
The generator API does not document that non-regtest parameters abort or that its synthetic inputs make the returned blocks unsuitable for chain connection.
Location: src/bench/block_generator.h:84 (head).
Details and suggested fix
Both entry points accept CChainParams, but GenerateBlock immediately asserts REGTEST and GenerateBlockData calls it. Every non-coinbase input receives a random outpoint; the contextual AcceptBlock test does not check whether those coins exist. Document the regtest-only requirement and the synthetic, non-connectable inputs on GenerateBlock, and reference that contract from GenerateBlockData, rather than leaving the synthetic-input caveat only on GenerateBlockUndo.