refactor: remove redundant outputs from kernel procedures#2733
Conversation
Remove outputs identical to inputs from kernel procedures: - note::write_assets_to_memory: output [] instead of [num_assets, dest_ptr] - active_note::get_assets: output [num_assets] instead of [num_assets, dest_ptr] - input_note::get_assets: output [num_assets] instead of [num_assets, dest_ptr, note_index] - output_note::get_assets: output [num_assets] instead of [num_assets, dest_ptr, note_index] - active_note::get_storage: output [num_storage_items] instead of [num_storage_items, dest_ptr] - faucet::mint: output [] instead of [NEW_ASSET_VALUE] Update all callers in miden-standards to reconstruct dropped values where needed. Closes 0xMiden#2523
Update agglayer note scripts (B2AGG, CLAIM, CONFIG_AGG_BRIDGE, UPDATE_GER) to account for removed dest_ptr from get_storage and get_assets outputs. Update kernel tests to not assert removed return values: - test_active_note: remove dest_ptr assertions for get_assets/get_storage - test_faucet: remove minted asset value assertions for mint - test_input_note/test_output_note: remove dest_ptr and note_index from expected get_assets outputs Update faucet_mint_asset API doc and mock faucet comments.
The call frame returns 16 elements. Previously the assert_eqw on the minted asset value consumed a net 4 elements. With that assertion removed, add dropw to keep the stack at 16 elements.
There was a problem hiding this comment.
Pull request overview
This PR implements the #2523 refactor across the Miden protocol/standards stack by removing kernel procedure return values that were redundant with their inputs, and updates downstream MASM callers and kernel tests to align with the new stack effects.
Changes:
- Updated protocol-level MASM procedures to no longer return
dest_ptr/note_indexechoes (and removed theNEW_ASSET_VALUEreturn fromfaucet::mint). - Updated standards and agglayer note scripts to explicitly re-push/reconstruct pointers when needed (and removed now-unnecessary
drop/dropwcleanup). - Updated kernel transaction tests and mock faucet wrappers/documentation to match the new stack outputs.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/miden-testing/src/kernel_tests/tx/test_output_note.rs | Updates asset-reading assertions to re-push dest_ptr since output_note::get_assets no longer returns it. |
| crates/miden-testing/src/kernel_tests/tx/test_input_note.rs | Same as above for input_note::get_assets; adjusts final stack cleanup. |
| crates/miden-testing/src/kernel_tests/tx/test_faucet.rs | Removes assertions on faucet::mint return value and adjusts stack handling after mint. |
| crates/miden-testing/src/kernel_tests/tx/test_active_note.rs | Updates tests to re-push pointers for asset/storage assertions after reduced outputs. |
| crates/miden-standards/src/testing/mock_account_code.rs | Updates mock faucet interface docs to reflect mint no longer returning NEW_ASSET_VALUE. |
| crates/miden-standards/asm/standards/wallets/basic.masm | Reconstructs asset pointer using locaddr.0 after active_note::get_assets output change. |
| crates/miden-standards/asm/standards/notes/swap.masm | Removes reliance on returned pointers for get_storage/get_assets; pushes constants explicitly for loads. |
| crates/miden-standards/asm/standards/notes/p2id.masm | Removes now-unnecessary drop after get_storage. |
| crates/miden-standards/asm/standards/notes/p2ide.masm | Pushes explicit storage pointer before mem_loadw_le after get_storage change. |
| crates/miden-standards/asm/standards/notes/mint.masm | Adjusts stack motion/drop logic in both public/private branches after get_storage output change. |
| crates/miden-standards/asm/standards/faucets/mod.masm | Removes dropw after faucet::mint and updates asset loading to push ASSET_PTR. |
| crates/miden-protocol/asm/protocol/output_note.masm | Changes get_assets to return only num_assets and reshuffles stack accordingly. |
| crates/miden-protocol/asm/protocol/input_note.masm | Same as above for input notes. |
| crates/miden-protocol/asm/protocol/active_note.masm | Changes get_assets/get_storage to drop returned pointers and only return counts. |
| crates/miden-protocol/asm/protocol/note.masm | Makes note::write_assets_to_memory return nothing by dropping echoed inputs. |
| crates/miden-protocol/asm/protocol/faucet.masm | Makes faucet::mint return nothing and updates stack cleanup accordingly. |
| crates/miden-protocol/asm/kernels/transaction/api.masm | Updates kernel API docs to reflect faucet_mint_asset no longer yields a minted value. |
| crates/miden-agglayer/asm/note_scripts/UPDATE_GER.masm | Removes post-assert drop that previously removed returned dest_ptr. |
| crates/miden-agglayer/asm/note_scripts/CONFIG_AGG_BRIDGE.masm | Same as above; keeps stack consistent with new get_storage output. |
| crates/miden-agglayer/asm/note_scripts/CLAIM.masm | Adjusts drop count after get_storage since only one value is returned. |
| crates/miden-agglayer/asm/note_scripts/B2AGG.masm | Pushes explicit pointers before storage/asset loads following output reductions. |
| CHANGELOG.md | Adds a breaking-change entry documenting the procedure signature/output changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PhilippGackstatter
left a comment
There was a problem hiding this comment.
Thank you! I left a few small comments. Could you also merge latest next into this branch and resolve conflicts?
| # write the inputs to the memory using the provided destination pointer | ||
| exec.write_storage_to_memory | ||
| # => [num_storage_items, dest_ptr] | ||
|
|
||
| # drop dest_ptr as it is identical to the input | ||
| swap drop | ||
| # => [num_storage_items] |
There was a problem hiding this comment.
We can remove num_storage_items return value from write_storage_to_memory, then remove the swap drop here.
| movup.6 drop | ||
| # => [ASSETS_COMMITMENT, num_assets, dest_ptr, num_assets] |
There was a problem hiding this comment.
We can consume the note_index in the call to get_assets_info, so we can change the dup.1 to a swap and then we don't need to drop it here.
|
|
||
| # drop num_assets and dest_ptr as these are identical to the inputs | ||
| drop drop | ||
| # OS => [] |
There was a problem hiding this comment.
Instead of dropping them here, we should consume them further above. I think the dup.5 dup.5 can be replaced with movup.x's.
| # save num_assets for the return value and drop note_index | ||
| dup.4 movdn.7 | ||
| # => [ASSETS_COMMITMENT, num_assets, dest_ptr, note_index, num_assets] | ||
|
|
||
| movup.6 drop | ||
| # => [ASSETS_COMMITMENT, num_assets, dest_ptr, num_assets] |
There was a problem hiding this comment.
Same here re consuming rather than dropping.
# Conflicts: # CHANGELOG.md # Cargo.lock # Cargo.toml # crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm # crates/miden-protocol/asm/protocol/note.masm # crates/miden-standards/asm/standards/notes/mint.masm
|
Thanks for the review! I addressed the comments and merged the latest �next� into the branch. |
PhilippGackstatter
left a comment
There was a problem hiding this comment.
I pushed a small doc fix, otherwise looks good to me! Thanks!
This PR addresses #2523 by removing outputs identical to inputs from several kernel procedures.
Changes
Protocol-level procedures (miden-protocol)
Standards-level callers (miden-standards)
Updated all callers to account for removed return values:
Closes #2523