0xMiden / 0xMiden/protocol

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

オープン
#3,112 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
rust
主要言語
Rust
スター
132
フォーク
167
平均マージ
1日 23時間
マージ済み PR(30日)
110

説明

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/

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。