Skip to content

policy: make unstructured Taproot annexes standard - #36466

Open
RobinLinus wants to merge 4 commits into
bitcoin:masterfrom
RobinLinus:policy-unstructured-annex
Open

RobinLinus wants to merge 4 commits into
bitcoin:masterfrom
RobinLinus:policy-unstructured-annex

Conversation

@RobinLinus

@RobinLinus RobinLinus commented Oct 8, 2026 •

Copy link
Copy Markdown

Make Taproot annexes standard for key and script paths:

  • 0x50: marker-only opt-in.
  • 0x50 0x00 <data>: arbitrary data; other prefixes remain nonstandard.
  • All non-P2A inputs must carry an annex, or none may. P2A witnesses must be empty.

No annex-specific size limit; the existing 400,000 WU standard transaction limit applies.

This opt-in rule protects transactions that do not opt in. It does not prevent annex inflation by opted-in participants. Consensus and witness replacement are unchanged.

Builds on #27926 and Libre Relay.

Validation: full build, 17 transaction unit tests, full feature_taproot.py, and git diff --check passed.

AI-assisted implementation and tests.

Permit marker-only annexes and annexes whose first byte after the
0x50 marker is 0x00, reserving other prefixes for future semantics.
Annex weight remains subject to MAX_STANDARD_TX_WEIGHT without an
additional per-input limit.

Require all transaction inputs to carry an annex if any does. This
prevents unilateral introduction of an annex into transactions with
participants who did not opt in; it does not prevent witness inflation
among participants who opted in.

Cover key and script paths, mixed input types, reserved prefixes,
script stack limits, and the transaction weight boundary. Update the
Taproot functional tests to exercise standard unstructured annexes.

Builds on the all-input opt-in approach in bitcoin#27926 and
the Libre Relay implementation.
@DrahtBot

DrahtBot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

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

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
ACK petertodd
Concept ACK Rob1Ham

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:

  • #36918 (Witness stacks in serialized form (optimization follow-ups) by sipa)
  • #36909 (kernel: add btck_witness_stack_get_items by pzafonte)
  • #36895 (Keep witness stacks in serialized form in CScriptWitness by sipa)
  • #36794 (test: make script_combineSigs and spends_witness_prog cases independent by alexanderwiederin)
  • #36455 (Test: Add legacy script edge case spender test by benthecarman)
  • #36122 (BIP460: CISA for Taproot key path spends by fjahr)
  • #29491 ([EXPERIMENTAL] Schnorr batch verification for blocks by fjahr)

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.

@petertodd

Copy link
Copy Markdown
Contributor

All inputs must carry an annex, or none may.

We should exclude spends of P2A outputs here, as they can't contain an annex.

Exclude native P2A inputs from the all-input annex requirement while retaining their empty-witness policy. Other inputs must still opt in together.

Cover mixed spends, input ordering, multiple anchors, wrapped and unknown witness programs, and witness stuffing in unit and functional tests.
@RobinLinus

Copy link
Copy Markdown
Author

@petertodd Thanks, fixed in bb6ccd0. Native P2A inputs are exempt; their witnesses must remain empty.

Comment thread src/policy/policy.cpp Resolved
Comment thread src/policy/policy.cpp Resolved
Comment thread src/policy/policy.cpp Resolved
Comment thread src/policy/policy.cpp Resolved
Comment thread src/policy/policy.cpp Resolved
Comment thread src/policy/policy.cpp Resolved
@RobinLinus

Copy link
Copy Markdown
Author

@petertodd Thanks, addressed in b4179ad. The empty-witness check moved below P2A handling so anchors are counted before the early continue.

@petertodd

Copy link
Copy Markdown
Contributor

utACK b4179ad

@sipa

sipa commented Oct 20, 2026

Copy link
Copy Markdown
Member

What is the purpose of this? I was imagining that annex standardness would be added at the same time consensus-relevant meaning would be given to annexes.

Of course, if there were active use of annexes on the network it would be useful to accommodate relay, but as of now I don't see the point.

@RobinLinus

RobinLinus commented Oct 22, 2026 •

Copy link
Copy Markdown
Author

@sipa The motivation is data availability for metaprotocols, including a range of shielded protocols such as Shielded CSV.

Annexes would let these protocols publish data directly in a Taproot key-path spend, avoiding the script-path commitment and reveal required by inscription-style encoding.

The motivation for enabling relay now is to support these applications. They need data availability independently of future consensus semantics for the annex; the proposed 0x00 prefix distinguishes this unstructured use from future extensions.

Standard relay would also let these applications reach miners through the public P2P network, reducing the incentive to build private mempools or depend on arrangements with individual mining pools.

@Rob1Ham

Rob1Ham commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

ACK

@AndreaDiazCorreia AndreaDiazCorreia left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on b4179ad, the unit and functional tests pass, and they fail with master's policy.cpp. I also changed the policy code in 7 ways (no P2A exemption, no opt-in rule, no prefix check, empty-witness skip before the P2A check, etc.) and annex_standardness catches all of them.

A tx with one 399,580-byte annex (exactly 400,000 WU) is accepted, also by a node with -datacarrier=0. #27926 had a 256-byte limit. Why remove it? Should node operators have an option to turn off annex relay?

@DrahtBot

Copy link
Copy Markdown
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants