feat: Describe encoding and composition of assets in docs#2956
Conversation
| ```text | ||
| [ | ||
| asset_id_suffix (64 bits), | ||
| asset_id_prefix (64 bits), | ||
| [faucet_id_suffix (56 bits) | reserved (5 bits) | callback_flag (1 bit) | composition (2 bits)], | ||
| faucet_id_prefix (64 bits) | ||
| ] | ||
| ``` |
There was a problem hiding this comment.
If two assets have the same asset ID and faucet ID but perhaps different callback flags or composition bits, they are just treated as fully different assets, right? Or is there any problem when dealing with them in the same context?
There was a problem hiding this comment.
If two assets have the same asset ID and faucet ID but perhaps different callback flags or composition bits, they are just treated as fully different assets, right?
Yes, fully different. So the rule
Two assets are of the same type whenever their vault keys match.
fully applies, including the composition and callback flag.
It wouldn't be clear how to merge/split an asset whose key matches except for the composition bit. Similarly, it wouldn't be clear how to merge callback-enabled and callback-disabled asset - what would be the flag for the merged asset?
| - `asset_id_suffix` and `asset_id_prefix` is and ID 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. | ||
| - `callback_flag` is the flag that determines whether callbacks are enabled (see also [callbacks](#callbacks)). | ||
| - `composition` describes how assets compose. Read on for more details. | ||
| - `reserved` bits are reserved for future use and should be assumed to be undefined and therefore not relied upon. |
There was a problem hiding this comment.
Do we not enforce these to be zeros?
There was a problem hiding this comment.
We do, but this is about warning users not to rely on these being zero. If someone writes code to deal with assets and assumes these are zero, and we start using these bits in the future, that code might break.
That's why I added the "should not be relied upon" sentence here.
Follows up on #2942 (comment) to describe asset composition in more detail. As a byproduct, it was useful to describe the encoding of assets, which may supersede #2867, cc @BrianSeong99.