feat(standards): P2ID/P2IDE notes must carry at least one asset#2986
feat(standards): P2ID/P2IDE notes must carry at least one asset#2986VAIBHAVJINDAL3012 wants to merge 1 commit into
Conversation
c94a5cc to
af33c26
Compare
[BREAKING] Enforced at both layers: - Rust: P2idNote::create / P2ideNote::create return the new NoteError::MissingAsset on empty assets. - MASM: basic_wallet::add_assets_to_account asserts num_assets > 0 (new ERR_BASIC_WALLET_EMPTY_NOTE_ASSETS). Adds unit tests for both rejection paths. Kernel-test fixtures that constructed 0-asset P2ID notes are updated: incidental sites pass a dummy FungibleAsset; the dedicated p2id_note_0_assets scenario in TestSetup is dropped (1- and 2-asset coverage remains).
af33c26 to
35a4f39
Compare
|
Question (without having looked at the code): do we want to do anything about a fungible asset with |
Technically we shouldn't allow it but it still doesn't have any attack vector. We can also put checks while transferring asset to account that asset value shouldn't be 0. |
This may be tricky as we can't check this for all assets in general (especially, at the protocol level) - e.g., "custom" assets would be excluded. |
Which assets have value 0? |
Fungible assets currently. In the future, we'll have "custom" asset with asset-specific structure - so, inferring whether an asset is a "zero" asset by looking at the asset itself, may not be possible in generality. But we may be able to do the check in a different way: if the root of the asset vault didn't change after the asset was added, we know that adding an asset didn't have an effect. I haven't looked into the code to know how easy/viable it is to perform this check - but it may be not too bad. |
This PR add the assertion check for the case that there should be atleast one asset in the note when
add_assets_to_accountfunction is called.[BREAKING] Enforced at both layers:
closes #2978