Skip to content

Conversation

@l0rinc
Copy link
Contributor

@l0rinc l0rinc commented May 18, 2025

Problem

The hardcoded benchmark block 413567 has several issues:

  • embeds 1.1MB of binary data in the repository
  • mined in 2016, predates SegWit v0, Taproot, and modern script types
  • benchmarks cannot test different transaction patterns or script mixes
  • updating to a newer block (e.g., #32457) would still add binary bloat and would remain inflexible

Fix

Added configurable bench/block_generator.{h,cpp} that builds fully valid blocks at runtime providing blocks or raw serialized stream.

Note that HexStrBench was simplified to work with random data - it doesn't need to be block-related.


This supersedes #32457 by eliminating the need for any hardcoded block data while enabling flexible benchmark scenarios.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 18, 2025

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, yuvicc, Raimo33

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34208 (bench: add fluent API for untimed setup steps in nanobench by l0rinc)
  • #32729 (test,refactor: extract script template helpers & widen sigop count coverage 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.

@laanwj
Copy link
Member

laanwj commented May 19, 2025

Concept ACK

@l0rinc l0rinc marked this pull request as ready for review May 21, 2025 13:44
@l0rinc l0rinc changed the title RFC: bench: replace embedded raw block with configurable block generator bench: replace embedded raw block with configurable block generator May 21, 2025
@DrahtBot DrahtBot added the Tests label May 21, 2025
@yuvicc
Copy link
Contributor

yuvicc commented Jun 29, 2025

Concept ACK

This one is pretty useful as I can test with up-to date test_data.

@Raimo33
Copy link
Contributor

Raimo33 commented Oct 19, 2025

Concept ACK for more realistic benchmarks

Remove the bundled `block413567.raw` fixture and replace with runtime block generation via `bench/block_generator.{h,cpp}`.

Expose `GetBlock()`/`GetBlockData()` with `ScriptRecipe` presets (`kLegacy`, `kWitness`) and deterministic seeding for reproducible benchmarks.
@l0rinc l0rinc force-pushed the l0rinc/bench-block-generator branch from a1f706b to 0fbbefd Compare December 20, 2025 23:18
@l0rinc
Copy link
Contributor Author

l0rinc commented Dec 20, 2025

Rebased and applied the new block everywhere, removing the binary of block 413567 embedded in the benchmarks.
Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants