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

pull l0rinc wants to merge 1 commits into bitcoin:master from l0rinc:l0rinc/bench-block-generator changing 4 files +272 −13
  1. l0rinc commented at 9:39 pm on May 18, 2025: contributor

    This is an alternative to #32457 which replaces the current benchmark block 413567 from 2016 with block 784588 from 2023.

    Added bench/block_generator.{h,cpp} that builds a fully valid block at runtime and exposes a serialized and an in-memory block, so benchmarks can fetch whichever form they need: - GetBlock() - in-memory CBlock; - GetBlockData() - serialized DataStream.

    • Generation is steered by ScriptRecipe:
      • per-type probabilities for legacy, P2SH, v0/v1 witness, anchor, multisig, OP_RETURN, non-standard, …
      • a geometric base that controls input/output counts, witness-stack depth, amounts, versions, lock-times, sequences, … Presets kLegacy (pre-SegWit) and kWitness (Taproot-era) are included, callers can supply custom mixes.
    • Deterministic FastRandomContext yields identical output on every run while avoiding repetition and predictability bias.
    • Blocks are mined against the easiest allowed target, then run through CheckBlock() to ensure full validity.

    This delivers diverse, up-to-date test data without adding another megabyte-scale binary to the repository and lets us retune workloads as network patterns evolve.

  2. bench: replace embedded raw block with deterministic generator
    * Add `bench/block_generator.{h,cpp}` that builds a fully valid block at runtime and exposes:
        - `GetBlock()` - in-memory `CBlock`;
        - `GetBlockData()` - serialized `DataStream`;
      so benchmarks can fetch whichever form they need.
    * Generation is steered by `ScriptRecipe`:
      - per-type probabilities for legacy, P2SH, v0/v1 witness, anchor, multisig, OP_RETURN, non-standard, …
      - a geometric base that controls input/output counts, witness-stack depth, amounts, versions, lock-times, sequences, …
      Presets `kLegacy` (pre-SegWit) and `kWitness` (Taproot-era) are included, callers can supply custom mixes.
    * Deterministic `FastRandomContext` yields identical output on every run while avoiding repetition and predictability bias.
    * Blocks are mined against the easiest allowed target, then run through `CheckBlock()` to ensure full validity.
    
    This delivers diverse, up-to-date test data without adding another megabyte-scale binary to the repository and lets us retune workloads as network patterns evolve.
    a1f706bfb2
  3. DrahtBot commented at 9:39 pm on May 18, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32554.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK laanwj

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #32532 (refactor: extract DecodePushData from GetScriptOp and GetLegacySigOpCount by l0rinc)
    • #31682 ([IBD] specialize CheckBlock’s input & coinbase checks by l0rinc)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. laanwj commented at 9:18 am on May 19, 2025: member
    Concept ACK
  5. l0rinc marked this as ready for review on May 21, 2025
  6. l0rinc renamed this:
    RFC: bench: replace embedded raw block with configurable block generator
    bench: replace embedded raw block with configurable block generator
    on May 21, 2025
  7. DrahtBot added the label Tests on May 21, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-05-25 18:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me