Minting from the native faucet once fees are on
- Linguagem predominante
- Rust
- Estrelas
- 132
- Forks
- 167
- Merge médio
- 1d 23h
- PRs com merge (30d)
- 110
Descrição
Assumes the native faucet is not a network account and no accounts or assets exist at genesis.
### The problem
Once fees are on, the auth procedure pays the fee out of the account's own vault and panics if there isn't sufficient balance. The mint action itself is fine; it's just that a transaction against the native faucet will error out in the auth procedure with `ERR_VAULT_FUNGIBLE_ASSET_AMOUNT_LESS_THAN_AMOUNT_TO_WITHDRAW`. Any account without the native asset will hit this error.
The native faucet can't be funded first, because it's the only source of the fee asset:
- `mint_and_send` puts the minted asset in the output note. `faucet::mint` credits the input vault, not the account vault, so minting doesn't give the faucet a balance.
- New accounts must start with an empty vault.
None of the current faucet tests set a base fee, so this flow has never been tested.
The solution is that the faucet has to be able to mint to itself.
### Proposed solution
Add a `mint_to_self` procedure that mints the faucet's own asset into its own vault. The owner authorizes it: the account's auth component (e.g. a multisig quorum) signs the transaction, and the active mint policy runs exactly as in `mint_and_send` so it can't be used to bypass policy constraints.
Flow:
1. Owner signs a transaction calling `mint_to_self`. The faucet mints the fee asset into its own vault and pays its own fee from that balance, in the same transaction. Verified in a prototype, including with a 2-of-3 multisig owner.
2. From then on the owner mints for people as today, via `mint_and_send`. The fee for each mint transaction comes out of the faucet's vault balance.
3. Recipients pay their own fees from the asset they received; auth runs after note scripts, so a fresh account can pay for the very transaction in which it consumes its first note.
Prerequisite: `faucet::mint`/`faucet::burn` mutate the input vault via the generic `asset_vault::add_asset`, which emits no witness-request event, so minting fails whenever the vault is non-empty and no input note carries the minted asset. Fix is to emit the existing `ACCOUNT_VAULT_BEFORE_ADD_ASSET_EVENT` before the mutation. This fix should be its own PR.
### Open questions
- Faucet tests should run with a non-zero base fee and a non-empty vault; both gaps hid all of this.
- Confirm we're fine with the native faucet minting to cover its own fees.
Guia de contribuição
Avaliação
Esta issue ainda não foi avaliada.