#32554 bench: replace embedded raw block with configurable block generator

full analysis

https://github.com/bitcoin/bitcoin/pull/32554 · l0rinc · +460/-45 in 10 files, 3 commits · labels: Tests, Needs rebase

Goal

  • Make block benchmarks representative of modern traffic using configurable runtime block generation
  • Avoids repository bloat from committing large raw block fixtures into the source tree

Replaces the hardcoded ~1MB raw block 413567 binary fixture with a deterministic runtime block generator (`bench/block_generator.{h,cpp}`). The generator builds valid regtest blocks matching configurable script recipes (legacy, witness/taproot mixes) and seedable randomness. Benchmark call sites for block deserialization, checkblock, and block storage I/O are updated to use the generated blocks.

Problem: Bitcoin Core's block benchmarks relied on a single 2016 block (413567) embedded directly in the repository. It predated SegWit v0 and Taproot, preventing benchmarks from reflecting modern transaction patterns, while updating by embedding newer blocks would add repo bloat without configurability.

Category: Test infrastructure (#3 of 45)

P3 · test coverage

  • P2 because benchmarks test 2016 data and fail to capture modern SegWit and Taproot execution costs
  • Provides an extensible framework for modern benchmarks without checking in large raw block fixtures

Improves benchmark realism and coverage across block deserialization and checkblock tests by replacing an obsolete 2016 pre-SegWit block with modern SegWit and Taproot output mixes. While not fixing a user-facing defect or consensus bug, it solves a recognized gap in the benchmarking infrastructure.

Membership: Modifies test and benchmark infrastructure files under src/bench/ and src/test/.

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

Reviewability: Stale: Needs rebase

  • Needs rebase due to merge conflicts with master

The PR has merge conflicts with the current base branch and requires a rebase.

Author status: active, frequently rebasing and iterating based on reviewer feedback

Resolved concerns:

  • Ensuring block difficulty allows fast nonce discovery during benchmark setup, addressed by switching chain params to regtest.
  • Ensuring realistic script sigs, pubkeys, and witness commitments, iteratively refined with review suggestions from hodlinator.
  • CI failure due to a floating-point probability assertion in `CreateScriptFactory`, promptly resolved by the author.

Agreement: Strong

  • Broad support for replacing outdated pre-SegWit test fixtures and avoiding repo bloat
  • Strong support because modern workloads are needed and generator avoids repo bloat (hodlinator, 0xB10C)
  • Concept approval without stated reasons (laanwj, yuvicc, Raimo33)
  • Suggested also generating block undo data for future undo benchmarks (0xB10C)

Broad support for replacing the obsolete pre-SegWit fixture with a dynamic generator; no open objections.

Multiple maintainers and contributors agree on the necessity of moving away from the pre-SegWit block fixture. Technical feedback from hodlinator on realism and generation details has been incorporated.

  • hodlinator (2026-02-11): 'Strong problem ACK - It's quite bad that we are only benchmarking against a pre-segwit block.'
  • 0xB10C (2026-09-16): 'Concept ACK ... something like this is the right move as a) it takes up far less repo space, and b) is extensible'

Objections:

ReviewerKindHarmStatusBlockingAuthor repliedQuote
hodlinatorcorrectnessthe generator can produce blocks that exceed block size limits when transaction count or script sizes are largeresolvednoyes2025-12-23: "When experimenting with changing the scripts I hit block size limits with just 2000 transactions due to large scripts. It seems more precise to have rec.tx_occupancy_limit between 0.0-1.0 and just fill up the block with transactions until the serialized size exceeds that fraction of the maximum size."
Settled: 2026-02-16: "The occupancy limit would be a cool solution to make sure this always generates a valid block, but it's not a real property of the blocks... I have added a block_generator_multiple_seed_sanity to help us discover these invalid setups anyway."

Support:

  • hodlinator: Stated 'Strong problem ACK - It's quite bad that we are only benchmarking against a pre-segwit block'
  • 0xB10C: Noted runtime generation takes far less repo space and avoids having to add new static blocks periodically
  • yuvicc: Helpful to run benchmarks against up-to-date transaction data
  • laanwj: Concept ACK [not substantive]
  • Raimo33: allows more realistic benchmarks

Participants: laanwj (support), yuvicc (support), Raimo33 (support), hodlinator (objection), maflcko (question), 0xB10C (support)

State derived from the lists: substantive support, no open objection (hodlinator, 0xB10C, yuvicc, Raimo33)

Review verdicts (DrahtBot): 0

Dependencies

Enables:

  • Configurable script-mix benchmarks and future block/undo I/O benchmarks (#36254)

Files

505 lines under test/bench/ci.

  • src/bench/block_generator.cpp +278/-0
  • src/bench/block_generator.h +86/-0
  • src/test/bench_block_generator_tests.cpp +62/-0
  • src/bench/readwriteblock.cpp +13/-20
  • src/bench/rpc_blockchain.cpp +5/-9
  • src/bench/checkblock.cpp +6/-6
  • src/bench/load_external.cpp +6/-5
  • src/bench/CMakeLists.txt +2/-5
  • src/test/CMakeLists.txt +2/-0
  • src/bench/data/block413567.raw +None/-None

Card

This PR replaces the hardcoded ~1MB raw block fixture from 2016 used across block benchmarks with a configurable, deterministic runtime block generator. It enables benchmarks such as DeserializeBlockTest and CheckBlockTest to cover modern SegWit and Taproot scripts without inflating git history with new raw block files. There is strong project agreement on solving this problem, with Concept ACKs from multiple contributors and maintainers. The PR is currently marked needs rebase due to merge conflicts.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T21:23, confidence high, input hash 7b017e600457945e