refactor: remove redundant outputs from kernel procedures#2733
Open
giwaov wants to merge 3 commits into0xMiden:nextfrom
Open
refactor: remove redundant outputs from kernel procedures#2733giwaov wants to merge 3 commits into0xMiden:nextfrom
giwaov wants to merge 3 commits into0xMiden:nextfrom
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.
Contributor
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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