Skip to content

feat(standards): P2ID/P2IDE notes must carry at least one asset#2986

Open
VAIBHAVJINDAL3012 wants to merge 1 commit into
0xMiden:nextfrom
inicio-labs:at-least-one-asset
Open

feat(standards): P2ID/P2IDE notes must carry at least one asset#2986
VAIBHAVJINDAL3012 wants to merge 1 commit into
0xMiden:nextfrom
inicio-labs:at-least-one-asset

Conversation

@VAIBHAVJINDAL3012
Copy link
Copy Markdown
Contributor

This PR add the assertion check for the case that there should be atleast one asset in the note when add_assets_to_account function is called.

[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).

closes #2978

[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).
@bobbinth
Copy link
Copy Markdown
Contributor

Question (without having looked at the code): do we want to do anything about a fungible asset with 0 amount? Technically, it is an asset, but conceptually, it is the same as no assets.

@VAIBHAVJINDAL3012
Copy link
Copy Markdown
Contributor Author

VAIBHAVJINDAL3012 commented May 26, 2026

Question (without having looked at the code): do we want to do anything about a fungible asset with 0 amount? Technically, it is an asset, but conceptually, it is the same as no assets.

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.

@bobbinth
Copy link
Copy Markdown
Contributor

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.

@VAIBHAVJINDAL3012
Copy link
Copy Markdown
Contributor Author

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?

@bobbinth
Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add asset assertions for P2ID and P2IDE notes

2 participants