Skip to content

Fee mechanism #973

@PhilippGackstatter

Description

@PhilippGackstatter

We need a fee mechanism in Miden and this issue is the start of a description of it.

As mentioned here (#525 (comment)), the mechanism is intended to be multi-dimensional and depend on a number of parameters:

  • Number of cycles it takes to execute the transaction.
  • Number of notes consumed by the transaction.
  • Number of notes produced by the transaction.
  • Total size of produces on-chain notes.
  • For on-chain accounts: size of state delta resulting from the transaction.

On the implementation side a transaction must be able to specify how it wants to pay its fees. One idea from @bobbinth was to have a procedure in the transaction kernel which users can call, likely from the transaction script, and pass a fungible asset. The fees will be payed with this fungible asset. The asset must be produced as a public output of the transaction kernel next to the current outputs [OUTPUT_NOTES_COMMITMENT, FINAL_ACCOUNT_HASH]. Presumably, this asset would be continue to be processed by the operator in the block kernel an, for example, moved to their account's asset vault.

The epilogue invariant that checks that no net asset creation or destruction happened must take this into account.

Open Questions

  • How are fees set? If I understood correctly, we want to take EIP-1559 as inspiration and have a base fee and set it based on the activity on the network in the previous block(s). We may or may not want a priority mechanism as well.
    • Is it important that this base fee does not change too frequently so clients/wallets can assume a fixed value for at least some window of time such that, for example, their transactions do not become invalid too quickly in case the base fee increases? It's also a concern if transaction proving takes some non-trivial amount of time - if the base fee were to change too frequently it would invalidate those slow transactions as well. This is depends on whether we want users to be able to pay exactly the base fee and nothing more or if users are pretty much always expected to pay at least the base fee and a little on top.
  • What happes to fees: Are they burned or are they given to the operator? This depends on how we want to incentivize operators, but perhaps while we have a single operator we may not need to think too much about this mechanism and have a temporary one in place like just giving the fees to the operator as a reward.
  • Is "Number of cycles it takes to execute the transaction" relevant for local transactions because the proof size is dependent on the number of cycles (even though not linearly)?
  • What would the kernel validate about the asset, if anything? I don't recall where I read it but I think the idea was that whatever asset the (or a) Miden operator accepts could be used to pay fees. In that case I assume the kernel could not validate much about the user-provided asset since how the base fee converts to different assets would not be known to the TX kernel.
  • For network transactions how is an operator protected from DOS attacks of transactions that produce an invalid asset to pay fees from (e.g. no or too little fees, incorrect asset type, ...). A related question is how do the operator or user estimate how much fees to attach to or require from a transaction so that it passes the minimum threshold? A user could dry-run a transaction locally to estimate it. But an operator might not be able to without it becoming a DOS attack vector.
  • I have yet to read through Gas fee model miden-vm#248 fully but it seems relevant at least so I just wanted to add it as context to this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions