Skip to content

refactor(protocol): share MAX_ASSETS_PER_NOTE through protocol_utils - #3821

Open
mmagician wants to merge 5 commits into
nextfrom
mmagician-claude/masm-shared-constants
Open

refactor(protocol): share MAX_ASSETS_PER_NOTE through protocol_utils#3821
mmagician wants to merge 5 commits into
nextfrom
mmagician-claude/masm-shared-constants

Conversation

@mmagician

@mmagician mmagician commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Makes #3713 easier, see the review comment.

The constant lived in the transaction kernel, which is statically linked and so
unreachable from `miden-standards`. A standard script that needs to bound
itself by the note asset limit therefore had to re-derive the value, leaving
two independent literals with nothing tying them together.

Moves it next to `WORD_NUM_ELEMENTS` in `protocol_utils` and re-exports it from
both the kernel and `miden::protocol::constants`, so the kernel's use sites are
unchanged and standard scripts can import it.

Also drops the last local `WORD_NUM_ELEMENTS` copy in `send_notes::common`,
whose comment was waiting on a VM version the workspace has long since passed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpaHTkPD94eEhrv7JTDoej
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpaHTkPD94eEhrv7JTDoej
Also says the kernel still re-exports the constant, so the entry does not read
as a removal from that namespace.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpaHTkPD94eEhrv7JTDoej
Comment thread CHANGELOG.md Outdated
@mmagician mmagician changed the title refactor(protocol): share MAX_ASSETS_PER_NOTE through protocol_utils refactor(protocol): share MAX_ASSETS_PER_NOTE through protocol_utils Sep 7, 2026
@mmagician
mmagician marked this pull request as ready for review September 7, 2026 10:45
mmagician pushed a commit that referenced this pull request Sep 7, 2026
Drops both asserts from the sweep component. `assert_vault_unchanged` is
replaced by the account-commitment check in the auth component (#3733), and the
initial-balance assert belongs there too - the procedure should be agnostic to
what the vault holds. That leaves the component with the one action it is for,
and keeps the stack's diff to what survives once all three PRs merge.

Bounds the payload by importing `MAX_ASSETS_PER_NOTE` (#3821) rather than
re-deriving it from the locals frame, which also removes the local
`WORD_NUM_ELEMENTS` copy and its stale VM-issue comment.

Validates the account interface in `new` the way `SendNotesTransactionScript`
does: an account missing `sweep_asset_to_note`, `create_note` or
`receive_asset` is now rejected at construction rather than deep inside
execution.

Also applies the review's wording throughout: assets are listed by the payload,
not named by it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpaHTkPD94eEhrv7JTDoej

@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!

Comment thread crates/miden-standards/asm/standards/tx_scripts/send_notes/common.masm Outdated
`send_notes::common` is private to `send_notes`, and no consumer imports
`WORD_NUM_ELEMENTS` from it - the three script modules name the constants
they need explicitly. The `pub` was carried over from the `pub const` this
import replaced.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FpaHTkPD94eEhrv7JTDoej

@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!

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.

4 participants