0xMiden / 0xMiden/protocol

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

Aberta
#3,112 0 comentários 0 reações 0 responsáveis Ver no GitHub
rust
Linguagem predominante
Rust
Estrelas
132
Forks
167
Merge médio
1d 23h
PRs com merge (30d)
110

Descrição

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/

Guia de contribuição

Abrir o guia de contribuição

Avaliação

Esta issue ainda não foi avaliada.

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.