Skip to content

feat: change native_account::remove_asset to return the remaining asset#2626

Open
PhilippGackstatter wants to merge 6 commits intonextfrom
pgackst-remove-asset-remaining-asset
Open

feat: change native_account::remove_asset to return the remaining asset#2626
PhilippGackstatter wants to merge 6 commits intonextfrom
pgackst-remove-asset-remaining-asset

Conversation

@PhilippGackstatter
Copy link
Contributor

@PhilippGackstatter PhilippGackstatter commented Mar 18, 2026

Changes

Refactors native_account::remove_asset to return the asset value remaining in the vault after the operation in order to make the return value more useful.

  • For that, the asset_vault::remove_asset API was changed to return the remaining value.
  • Since faucet::burn also made use of that API, it had to be updated as well. The strategy there is to remove the return value since it is not meaningful (described in Avoid returning outputs identical to inputs in kernel procedures #2523).
  • To keep the API logic in MASM and Rust the same, AssetVault::remove_asset was changed to return not the removed asset but the remaining asset, represented as Option<Asset>, where:
    • None is returned for non-fungible assets since nothing remains in the vault
    • and the remaining asset for fungible assets.
      • We could technically return FungibleAsset at this point in time, but this will likely become Asset in the future anyway.
  • When adding or removing fungible assets from the vault, there was a previously useful optimization to check if the remaining fungible asset representation's was [amount = 0, 0, faucet_id_suffix, faucet_id_prefix] and if so, insert an empty word to avoid storing zero amounts to keep the merkle tree sparse. Since the asset refactor, this is no longer necessary and so this optimization was removed.

Migration

  • miden::protocol::native_account::remove_asset returns the asset value remaining in the vault instead of the removed value
  • AssetVault::remove_asset returns the asset value remaining in the vault Option<Asset> rather than the removed value Asset.
  • miden::protocol::faucet::burn no longer returns the burnt asset value.

closes #2524

@PhilippGackstatter PhilippGackstatter added kernels Related to transaction, batch, or block kernels rust Issues that affect or pull requests that update Rust code pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority labels Mar 18, 2026
@PhilippGackstatter PhilippGackstatter force-pushed the pgackst-remove-asset-remaining-asset branch from 002ee72 to 589b1aa Compare March 18, 2026 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernels Related to transaction, batch, or block kernels pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority rust Issues that affect or pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor native_account::remove_asset to return the remaining balance

1 participant