0xMiden / 0xMiden/protocol

Remove merge/split logic from `AssetVault::{add_asset, remove_asset}`

Aperta
#3,112 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
rust
Lingua principale
Rust
Stelle
132
Fork
167
Merge medio
1g 23h
PR unite (30g)
110

Descrizione

We have the `AssetVault::{add_asset, remove_asset}` APIs that add and remove assets. These require that the asset vault knows how to `merge` and `split` an asset, in order to be able to merge an incoming `FungibleAsset(10)` with an existing `FungibleAsset(20)`. This works while we effectively only allow `AssetComposition::{None, Fungible}`. Once we start using `AssetComposition::Custom`, this would no longer work, as the asset vault wouldn't know how to compose assets.

The question is whether we should only allow mutation of assets through transactions and make the `AssetVault` Rust type merely an "asset container", but not support merge and split-style mutation, but only upsert-style mutation. The alternative is to track merge/split logic, implemented in MASM with an asset to be able to merge it, but this requires running those procedures in the VM in order to merge/split assets.

I would go with the "only allow asset vault mutation through transactions" approach. The impact of this change would be:
- Remove `add_asset` and use `insert_asset` instead (and possibly rename the latter to the former). The latter was already added in https://github.com/0xMiden/protocol/pull/3110.
- `remove_asset` would only allow full removal of an asset, rather than partial like it does now.

Context: https://github.com/0xMiden/protocol/pull/3110/

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.