chore: refactor miden::protocol from ASSET to ASSET_KEY and ASSET_VALUE#2410
chore: refactor miden::protocol from ASSET to ASSET_KEY and ASSET_VALUE#2410PhilippGackstatter wants to merge 42 commits intopgackst-kernel-asset-key-valuefrom
miden::protocol from ASSET to ASSET_KEY and ASSET_VALUE#2410Conversation
599ba84 to
4143ebe
Compare
4143ebe to
d94dc4e
Compare
d94dc4e to
b1af2ca
Compare
igamigo
left a comment
There was a problem hiding this comment.
Not a full review yet but leaving some comments, overall looks great.
| const CREATE_BURN_NOTE_ASSET_KEY_LOC=0 | ||
| const CREATE_BURN_NOTE_ASSET_VALUE_LOC=4 |
There was a problem hiding this comment.
not for this PR, but I do wonder if there are better ways to name these constants. I ran into the issue of defining memory locals for similar (w.r.t. function) constants in different procedures, only to find that names get unnecessarily long.
There was a problem hiding this comment.
Yep, agreed. My favorite thing would be constants that can be defined in a procedure body to make them scoped and accessible in only that body, e.g.:
@locals(9)
proc create_burn_note
const ASSET_KEY_LOC = 0
const ASSET_VALUE_LOC = ASSET_KEY_LOC + ASSET_VALUE_MEMORY_OFFSET
loc_storew_be.ASSET_KEY_LOC
swapw
# => [ASSET_VALUE, ASSET_KEY]
loc_storew_be.ASSET_VALUE_LOC
dropw dupw
# => [ASSET_KEY, ASSET_KEY]
end
Alternatively, we could define these in the @locals attribute:
@locals(
ASSET_KEY = 0,
ASSET_VALUE = ASSET_KEY + ASSET_VALUE_MEMORY_OFFSET,
)
proc create_burn_note
loc_storew_be.ASSET_KEY
# ...
end
The assembler could translate these into globally defined constants under the hood to not require a new MASM feature, though this may be a bit too much magic for an assembly language.
cc @bitwalker in case you have thoughts for how difficult this would be to add
|
@mmagician I've opened a new pull request, #2498, to work on those changes. Once the pull request is ready, I'll request review from you. |
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! Not a full review yet, but I left a few small comments inline.
Changes
miden::protocolasset APIs to takeASSET_KEYandASSET_VALUEinstead of justASSETto adapt to the kernel changes from #2396.This PR, like #2396, also keeps the key and value layout of assets unchanged and only deals with expanding assets from one to two words for simplicity.
Migration
REQUESTED_ASSET. Now it storesREQUESTED_ASSET_KEYandREQUESTED_ASSET_VALUE.miden::standards::wallets::basic::move_asset_to_noteno longer returns parameters (motivated byadd_asset_to_noteprocedure results overhead when calling from Rust #1717).miden::protocol::asset::build_(non_)fungible_asset->miden::protocol::asset::create_(non_)fungible_asset, for consistency with themiden::protocol::faucetprocedures of the same name.create_andbuild_interchangeably in APIs and it would be nice to be more consistent there.miden::protocol::faucet::create_fungible_assetmiden::protocol::faucet::create_non_fungible_assetmiden::protocol::faucet::mintmiden::protocol::faucet::burnmiden::protocol::asset::create_fungible_assetmiden::protocol::asset::create_non_fungible_assetmiden::protocol::native_account::add_assetmiden::protocol::native_account::remove_assetmiden::protocol::output_note::add_assetmiden::standards::wallets::basic::move_asset_to_noteNotable Changes
bridge_out.masmneeded a bigger update:miden::protocol. This logic will change when the layout changes, but some procedure to create a vault key will probably remain at least until generalized assets and maybe beyond.mock::utillibrary to miden-standards to be able to provideexec-wrappers forbasic::wallet::move_asset_to_note.part of #2328