0xMiden / 0xMiden/protocol

Improve sponsorship note creation in `AuthNetworkAccount`

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

Descrição

Follow-ups coming out of https://github.com/0xMiden/protocol/pull/3321 and fee discussions.

**Make note creation configurable in `create_network_note_sponsorships`**
- Change the `create_network_note_sponsorships` procedure to be a thin wrapper over an internal helper procedure that looks something like:

```
proc process_sponsorship_notes(create_notes: bool) -> Asset
```

The idea of this internal procedure is:
- It keeps track of total fee amount for the created sponsorship notes.
- If `create_notes == false`, it doesn't actually create the nodes (just computes the total fee).

This procedure would be used as follows:

- Called from `create_sponsorship_notes` as `process_sponsorship_notes(true)`.
- Called from `compute_sponsorship_fees` as `process_sponsorship_notes(false)`.

The latter procedure would be useful for multisig authentication.

**Have `create_network_note_sponsorships` take `AssetId`** ✔️ (done)

Have `create_network_note_sponsorships` take `AssetId` as a parameter. This asset ID would define the asset to deposit into the sponsorship notes. For now, assert asset ID returned by `estimate_note_fee` is the same as the fee asset ID of the current fee manager. In the future, we'd try to perform a conversions.

**Add extra parameters into serial number derivation of the sponsorship note**

Add extra parameters into the serial number derivation of the sponsorship note to prevent potential collisions in the future. I think doing something like: `merge(FEATURE_NOTE_ID, [account_id_suffix, account_id_prefix, nonce, 0])` should probably work fine (`AccountId` here is the ID of the native account).

**Provide nicer error on insufficient fee**

If the vault doesn't have the required fee asset, would be really nice to error out with a message that says something like "insufficient fee".

Here we could consider adding a custom event.

**Estimate note fee needs to handle calling itself**

If account X runs `create_network_note_sponsorships`, the procedure doesn't currently handle the case where the target of a network note is X itself. We need a small branch to handle calling the account's own fee manager and not do an FPI call.

**Add check/unchecked sponsored fee conservation check** ✔️ (done)

We should add a flag somewhere to network accounts auth component to allow specifying whether the collected amount of fees needs to be greater or equal to the created amount of fees or not. Basically, this allows an account to configure whether it wants to pay for fees of outgoing notes (that aren't covered by the collected amount) by itself or if collected fees need to fully pay for them.

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.