Skip to content

fix(standards): seal PSWAP paybacks and remainders - #3927

Merged
partylikeits1983 merged 11 commits into
ajl-output-note-sealfrom
ajl-pswap-seal-outputs
Sep 25, 2026
Merged

partylikeits1983 merged 11 commits into
ajl-output-note-sealfrom
ajl-pswap-seal-outputs

Conversation

@partylikeits1983

@partylikeits1983 partylikeits1983 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

PSWAP leaves its payback and remainder outputs mutable after filling an order. The filler can append another asset later in the transaction, changing the payback commitment or making the remainder fail its single asset check.

After asset callbacks finish, PSWAP checks that each output has the expected asset, amount, and attachment. It then calls output_note::seal to prevent further changes. Regression tests cover complete fill paybacks, partial fill paybacks, remainders, public/private visibility, additional assets, balance increases, and callback mutations.

Depends on #3923 and is based on ajl-output-note-seal. This changes the PSWAP script root; existing notes retain their original script. Storage and Rust APIs are unchanged.

@partylikeits1983
partylikeits1983 requested review from PhilippGackstatter and zeapoz and removed request for zeapoz September 23, 2026 16:48
@partylikeits1983
partylikeits1983 marked this pull request as ready for review September 23, 2026 16:48
@partylikeits1983 partylikeits1983 self-assigned this Sep 23, 2026
@partylikeits1983 partylikeits1983 added standards Related to standard note scripts or account components pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority labels Sep 23, 2026

@zeapoz zeapoz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good! Left two questions on the test code

Comment thread crates/miden-testing/tests/scripts/pswap.rs Outdated
Comment thread crates/miden-testing/tests/scripts/pswap.rs Outdated
Comment thread crates/miden-standards/asm/standards/notes/pswap.masm
Comment thread crates/miden-standards/asm/standards/notes/pswap.masm Outdated
Comment thread crates/miden-standards/asm/standards/notes/pswap.masm Outdated
Comment thread crates/miden-standards/asm/standards/notes/pswap.masm Outdated
Comment thread crates/miden-testing/tests/scripts/pswap.rs

@PhilippGackstatter PhilippGackstatter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Consider removing the explicit attachment check if you can confirm it's redundant.

Comment thread crates/miden-standards/asm/standards/notes/pswap.masm Outdated
Comment thread crates/miden-standards/src/note/pswap.rs Outdated
Comment thread crates/miden-standards/src/note/pswap.rs

@bobbinth bobbinth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good! Thank you!

@Fumuran Fumuran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, have just two optional nits

dup exec.output_note::get_assets_info
# => [ASSETS_COMMITMENT, num_assets, note_idx, EXPECTED_ASSETS_COMMITMENT]

movup.4 eq.1 assert.err=ERR_PSWAP_OUTPUT_ALTERED

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

optional nit: I would probably create a constant for the expected number of assets and use it here instead of plain 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similarly, there's another plain 1 that could be an associated constant in the Rust TryFrom impl:

if note.assets().num_assets() != 1 {

Comment thread crates/miden-standards/asm/standards/notes/pswap.masm Outdated

@zeapoz zeapoz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me!

dup exec.output_note::get_assets_info
# => [ASSETS_COMMITMENT, num_assets, note_idx, EXPECTED_ASSETS_COMMITMENT]

movup.4 eq.1 assert.err=ERR_PSWAP_OUTPUT_ALTERED

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similarly, there's another plain 1 that could be an associated constant in the Rust TryFrom impl:

if note.assets().num_assets() != 1 {

@partylikeits1983
partylikeits1983 added this pull request to stack #3948 September 25, 2026 10:43
@partylikeits1983
partylikeits1983 added this pull request to the merge queue Sep 25, 2026
Merged via the queue into next with commit c712b5f Sep 25, 2026
20 of 35 checks passed
@partylikeits1983
partylikeits1983 deleted the ajl-pswap-seal-outputs branch September 25, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority standards Related to standard note scripts or account components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants