0xMiden / 0xMiden/protocol

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

未关闭
#3,112 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
rust
主要语言
Rust
星标
132
派生
167
平均合并
1 天 23 小时
30 天内合并 PR
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 摘要。