policy: Improve Taproot control block size precheck #34142

pull billymcbip wants to merge 2 commits into bitcoin:master from billymcbip:control-2 changing 4 files +12 −8
  1. billymcbip commented at 12:43 pm on December 23, 2025: contributor

    I’d like to improve the Taproot control size check in IsWitnessStandard. Rather than just checking emptiness, we should perform all three checks implemented in VerifyTaprootControlBlockSize (see below). This way we can invalidate the transaction earlier when it’s clear that the control size is incompatible with consensus rules (saving compute).

    Old checks:

    • control.size() > 0

    New checks:

    • control.size() >= TAPROOT_CONTROL_BASE_SIZE
    • control.size() <= TAPROOT_CONTROL_MAX_SIZE
    • (control.size() - TAPROOT_CONTROL_BASE_SIZE) % TAPROOT_CONTROL_NODE_SIZE == 0

    For example, a single byte control block wouldn’t be empty, but it would be invalid because it’s shorter than TAPROOT_CONTROL_BASE_SIZE (33).

    429aed9 is the behavioral change (just one LOC). d7bbd8d adds the VerifyTaprootControlBlockSize helper function without changing behavior. I have a separate PR out with only that change: #34139.

    I ran: cmake -B build -DENABLE_WALLET=OFF && cmake --build build -j 8 && ctest --test-dir build -j 8

    Looking forward to your feedback.

  2. refactor: Add helper for Taproot control block size check d7bbd8de23
  3. policy: Improve Taproot control block size precheck 429aed9816
  4. DrahtBot added the label TX fees and policy on Dec 23, 2025
  5. DrahtBot commented at 12:43 pm on December 23, 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/34142.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  6. sedited commented at 1:21 pm on December 23, 2025: contributor
    Can you expand in the desccription what this actually improves and why this change should be done?
  7. billymcbip commented at 1:59 pm on December 23, 2025: contributor
    @sedited done (the new checks are those in VerifyTaprootControlBlockSize).
  8. billymcbip commented at 2:05 pm on December 23, 2025: contributor
    To be clear, this does not change which transactions are policy-valid. It just adds the control size check to IsWitnessStandard because it’s a light-weight check we can run with the context available at that point.

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-12-26 09:12 UTC

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