feat: add version to AssetId - #3670
Open
PhilippGackstatter wants to merge 4 commits into
Open
Conversation
PhilippGackstatter
force-pushed
the
pgackst-asset-version
branch
from
August 21, 2026 11:47
85199d0 to
2c7f128
Compare
PhilippGackstatter
marked this pull request as ready for review
August 21, 2026 11:50
zeapoz
approved these changes
Aug 21, 2026
Comment on lines
+268
to
+270
| let composition = AssetComposition::try_from( | ||
| (metadata_byte & Self::COMPOSITION_MASK) >> Self::COMPOSITION_SHIFT, | ||
| )?; |
Collaborator
There was a problem hiding this comment.
nit: we asserted the reserved section to be zero just above, so there's no need to mask off the bytes beforehand
| - `faucet_id_suffix` and `faucet_id_prefix` is the ID of the faucet which issues the asset. The transaction kernel ensures that a given account can only issue assets when the faucet ID matches its own ID. | ||
| - `asset_class_suffix` and `asset_class_prefix` is a class that determines if two assets issued by the same faucet are considered to be the same asset. It is set by the asset creator arbitrarily - see [identity](#identity) for more. | ||
| - `composition` describes how assets compose. Read on for more details. | ||
| - `version` determines how the remainder of the asset is decoded. It is located at a static offset so a parser can read it first and then decode the rest of the asset accordingly. The only valid version is currently `1`. Version `0` is unassigned and invalid, which means an empty word is guaranteed to _not_ be a valid asset ID. |
Collaborator
There was a problem hiding this comment.
Suggested change
| - `version` determines how the remainder of the asset is decoded. It is located at a static offset so a parser can read it first and then decode the rest of the asset accordingly. The only valid version is currently `1`. Version `0` is unassigned and invalid, which means an empty word is guaranteed to _not_ be a valid asset ID. | |
| - `version` determines how the remainder of the asset is decoded. The only valid version is currently `1`. Version `0` is unassigned and invalid, which means an empty word is guaranteed to _not_ be a valid asset ID. |
nit: I think this is a little bit wordy for what it's trying to say
bobbinth
approved these changes
Aug 21, 2026
bobbinth
left a comment
Contributor
There was a problem hiding this comment.
Looks good! Thank you! I left a couple of small comments inline.
Comment on lines
+72
to
+74
| /// If we make this public, we may want to instead consider introducing an `AssetIdVersion` | ||
| /// struct, similar to [`AccountIdVersion`](crate::account::AccountIdVersion). | ||
| pub(in crate::asset) const VERSION_1: u8 = 1; |
Contributor
There was a problem hiding this comment.
I'd probably remove this comment. If/when we move to a multi-versioned assets, the AssetId may become an enum.
Comment on lines
42
to
51
| pub struct AssetId { | ||
| /// The asset class of the asset ID. | ||
| asset_class: AssetClass, | ||
|
|
||
| /// The ID of the faucet that issued the asset. | ||
| faucet_id: AccountId, | ||
|
|
||
| /// The composition of the asset. | ||
| composition: AssetComposition, | ||
| } |
Contributor
There was a problem hiding this comment.
Similar comment as in the account version PR - maybe we should add the version field here explicitly? Though, maybe it is fine as is for now too.
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.
miden::protocol::account::validatewhich should not be called by user code.validate_structurestays and should be used instead. See first commit for these changes in isolation.part of #1155