chore: refactor tx kernel from ASSET to ASSET_KEY and ASSET_VALUE#2396
Open
PhilippGackstatter wants to merge 48 commits intonextfrom
Open
chore: refactor tx kernel from ASSET to ASSET_KEY and ASSET_VALUE#2396PhilippGackstatter wants to merge 48 commits intonextfrom
ASSET to ASSET_KEY and ASSET_VALUE#2396PhilippGackstatter wants to merge 48 commits intonextfrom
Conversation
mmagician
reviewed
Feb 12, 2026
crates/miden-protocol/asm/kernels/transaction/lib/epilogue.masm
Outdated
Show resolved
Hide resolved
mmagician
approved these changes
Feb 12, 2026
crates/miden-protocol/asm/kernels/transaction/lib/prologue.masm
Outdated
Show resolved
Hide resolved
Collaborator
|
@copilot work on the nits from @mmagician 's PR review |
12 tasks
Contributor
|
@mmagician I've opened a new pull request, #2438, to work on those changes. Once the pull request is ready, I'll request review from you. |
…it ASSET_PTR constants, rename variables, add test Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
…logue Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
Co-authored-by: mmagician <8402446+mmagician@users.noreply.github.com>
refactor: address review nits for asset key/value refactoring
bobbinth
approved these changes
Feb 25, 2026
Contributor
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! I left some comments inline, but pretty much everything could be addressed in follow-up PRs.
huitseeker
reviewed
Feb 26, 2026
| # check if the asset is fungible | ||
| exec.is_fungible_asset | ||
| # => [is_fungible_asset, ASSET] | ||
| # => [is_fungible_asset, ASSET_KEY, ASSET_VALUE] |
Contributor
There was a problem hiding this comment.
This validates key and value separately, but doesn’t check they match. If a caller can pass mismatched key/value, origin checks will use the key and ignore the faucet ID in the value.
Should we assert build_asset_vault_key(ASSET_VALUE) == ASSET_KEY here (or in validate_*) and/or add a test?
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 refactors the tx kernel internals from the previous
ASSETtoASSET_KEYandASSET_VALUE. I.e. assets are now represented by two instead of one word.To keep this change managable:
api.masm). In one of the next PRs, this will go away and the kernel procedures will instead take the key in addition to the value.get_assetskernel procedure.Notable changes
miden::core.NoteAssetsby implementingSequentialCommit.output_note::add_assetwas refactored heavily. It now uses a single procedure for both fungible and non-fungible assets which should prepare nicely for the unified assets in the short-term future.add_asset_rawlogic can later be generalized to: if asset is found and can be merged (mergeprocedure is notEMPTY_WORD) it will call it, otherwise it will abort.asset_vault::remove_assettakes the ASSET_KEY and ASSET_VALUE to remove from the vault. The reason the value is required is so an asset can be partially removed from the vault, e.g. "remove 30 tokens from the total of 80 tokens in the vault". This can work similarly in the future with assets that are splittable (e.g. fungible assets).faucet::burncurrently returns the same ASSET_VALUE that it takes as input. It should either be removed (in line withadd_asset_to_noteprocedure results overhead when calling from Rust #1717) , or return the previous value of the vault. I think the latter makes the most sense as it makes the API strictly more useful. For that reason, I kept the return value so we can more easily change this in the future. The same applies tonative_account::remove_asset.mint_fungible_asset. It previously suggested it returned the same asset it took, but it actually returns the merged asset.Review
The most heavily refactored modules are asset, asset_vault, output_note.
Note that
asset.masmwill change again when changing layouts of asset keys and values, so a very deep review may not be necessary at this point.I tried to keep the commits organized by the module that was refactored (and what conceptually was updated as a consequence), so reviewing by commit should be mostly fine.
Migration
Calls to
{input_note, active_note, output_note}::get_assetsmust be updated since the returned memory layout has changed from previous[ASSET]to[ASSET_KEY, ASSET_VALUE].Potential Follow-Ups
NoteAssets::add_assetrecomputes the commitment every time. Tracked in Consider removingNoteAssets::add_asset#2525.see Avoid returning outputs identical to inputs in kernel procedures #2523faucet::burnshould return previous value. E.g. if we have a total of 80 tokens in the vault and 30 are burnt, then 50 should be returned. This may be useful, for example, to easily check what the remaining balance is after burning. For instance,faucets::burncould set token_supply to that returned value after the burning. The same applies tonative_account::remove_asset.part of #2328