Skip to content

policy: count bare data envelopes (OP_2DROP/pushnum runs) as datacarrier#319

Open
kwsantiago wants to merge 2 commits into
bitcoinknots:29.x-knotsfrom
privkeyio:fix-bip110-envelope-datacarrier
Open

policy: count bare data envelopes (OP_2DROP/pushnum runs) as datacarrier#319
kwsantiago wants to merge 2 commits into
bitcoinknots:29.x-knotsfrom
privkeyio:fix-bip110-envelope-datacarrier

Conversation

@kwsantiago

@kwsantiago kwsantiago commented Jul 3, 2026

Copy link
Copy Markdown

DatacarrierBytes recognizes inscription data in two forms: OP_FALSE OP_IF ... OP_ENDIF envelopes and <data> OP_DROP. It does not match OP_2DROP, so a bare envelope of the form push <marker> <data>... OP_2DROP...OP_DROP counts as zero datacarrier bytes and evades the size limit.

This is the envelope shape ordinals/ord#4545 adopts to remain valid under BIP-110, which disables OP_IF/OP_NOTIF in tapscript.

Changes:

  • Count a contiguous run of pushes/pushnums that is balanced by OP_DROP/OP_2DROP, anchoring data_began at the start of the run so the whole run is counted on the first drop rather than just the last push.
  • Treat pushnums (OP_1NEGATE, OP_1..OP_16) as run members. ord's parser accepts pushnums as payload, so a pushnum interleaved between data pushes must not strand the earlier push from the count. This matches the counting to exactly the grammar ord's envelope parser accepts (pushes, pushnums, OP_DROP, OP_2DROP).

This makes counting slightly stricter for any push-run ending in a drop, not only the new envelope. Standard scripts that use OP_DROP drop a stack item preceded by a non-push opcode (e.g. <locktime> OP_CHECKLOCKTIMEVERIFY OP_DROP), which breaks the run and is not counted.

Testing:

  • Unit (script_DataCarrierBytes): a <data> <data> OP_2DROP run, and a pushnum-interleaved <data> OP_7 <data> OP_2DROP run.
  • Functional (mempool_datacarrier.py): builds P2TR script-path spends with bare envelope tapscripts and asserts txn-datacarrier-exceeded under default policy, including a pushnum-interleaved envelope, mirroring the existing OPNet case. Reverting the counting change alone makes the tests fail (the tx is accepted).

@kwsantiago
kwsantiago force-pushed the fix-bip110-envelope-datacarrier branch from a169975 to 04e6d16 Compare July 3, 2026 02:39
@kwsantiago
kwsantiago force-pushed the fix-bip110-envelope-datacarrier branch from 04e6d16 to 3b776a4 Compare July 3, 2026 02:45
@kwsantiago kwsantiago changed the title policy: count bare OP_2DROP data envelopes as datacarrier policy: count bare data envelopes (OP_2DROP/pushnum runs) as datacarrier Jul 3, 2026
@Retropex

Retropex commented Jul 3, 2026

Copy link
Copy Markdown

tACK 3b776a4

Tested with this transaction (has been mined afterward to be able to share it publicly) on my own signet.

@pdath

pdath commented Jul 5, 2026

Copy link
Copy Markdown

I ran the code changes through a CodeRabbit review, and no issues came up.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants