Skip to content

policy: allow exact annex padding for simplicity spends #1539

Open
delta1 wants to merge 2 commits intoElementsProject:masterfrom
delta1:2026-02-annex-policy
Open

policy: allow exact annex padding for simplicity spends #1539
delta1 wants to merge 2 commits intoElementsProject:masterfrom
delta1:2026-02-annex-policy

Conversation

@delta1
Copy link
Copy Markdown
Member

@delta1 delta1 commented Mar 13, 2026

Implements BlockstreamResearch/simplicity#290 for Elements standardness policy.

Something concerning to be investigated is that Cost::get_padding in rust-simplicity is returning a padding 3 bytes bigger than this calculation.. presumably an error in that method?

@roconnor-blockstream
Copy link
Copy Markdown
Contributor

roconnor-blockstream commented Mar 16, 2026

I'll have some more comment later but first and foremost there is no need to amend the Simplicity C code.

Instead there is a minCost parameter that can needs to be passed up through CheckSimplicity. See https://github.com/roconnor-blockstream/bitcoin/pull/1/changes#diff-a0337ffd7259e8c7c9a7786d6dbd420c80abfa1afdb34ebae3261109d9ae3c19R1876-R1886 for an example of this. You will need to pass a minCost of 0 when in consensus mode rather than policy mode.

Have a careful read of the documentation for minCost in execSimplicity.

@delta1 delta1 force-pushed the 2026-02-annex-policy branch from 4a9b55e to 4cdb88c Compare March 25, 2026 13:11
@delta1 delta1 force-pushed the 2026-02-annex-policy branch from 4cdb88c to 1918260 Compare March 25, 2026 13:26
@delta1 delta1 marked this pull request as ready for review March 25, 2026 13:26
@delta1
Copy link
Copy Markdown
Member Author

delta1 commented Mar 25, 2026

Thanks @roconnor-blockstream updated

delta1 added a commit to delta1/rust-simplicity that referenced this pull request Mar 26, 2026
Cost::get_padding previously always assumed only 1 byte for compactsize
encoding when calculating required padding size.

For larger differences in cost/budget, this incorrectly resulted in an
additional 1 or 2 bytes of padding depending on the difference.

I found this when calculating padding for the SimplicityHL hash loop
example, where rust-simplicity was calculating a 7426 byte annex padding
while libsimplicity required a 7424 byte padding, since the compactsize
encoding requires an additional 2 bytes.

See ElementsProject/elements#1539
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.

2 participants