0xMiden / 0xMiden/protocol

Improve sponsorship note creation in `AuthNetworkAccount`

未關閉
#3,345 2 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視
fees standards
主要語言
Rust
星號
132
分支
167
平均合併
1 天 23 小時
30 天內合併 PR
110

描述

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.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。