Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mina GasStation #7

Open
hgedia opened this issue Sep 2, 2024 · 0 comments
Open

Mina GasStation #7

hgedia opened this issue Sep 2, 2024 · 0 comments

Comments

@hgedia
Copy link
Collaborator

hgedia commented Sep 2, 2024

Summary

The fee that zkApp tx needs to pay does not depend on the amount of computation made off-chain, but it does depend upon the number of AccountUpdates, their weights in the transaction, and the current market fee rate. Most zkApps set a fixed fee (PunkPoll uses 0.01 MINA, and most other projects use the recommended 0.1 MINA fee). When blocks are not full, it works well. As soon as the transaction pool has more than 24 zkApp tx pending, some transactions will not go into the block, and according to the devnet experience, the waiting time can be up to several hours even if the fee for the transaction is the same as higher than the fee for other transactions.

GasStation API has the following uses:

  • Having predictable and manageable time for transaction inclusion. The current limit is 8 tx/min (24 per block).

  • Meta (gasless) transactions are important for user experience. It allows onboarding users and sending zkApp transactions without requiring the user to get MINA first on some exchange.

Proposal Overview

The solution proposed allows and intends to:

  • Get real-time recommended fees to guarantee inclusion of the transaction to the next block (fastest), to one of the next blocks (fast), to have the average inclusion time (standard), and save on fees (low).

  • Change the transaction fee after the proof generation to ensure the market fee rate is used in the transaction just before the signing.

  • Change the transaction fee if the transaction is stuck in the transaction pool.

  • Provide meta (gasless) transactions where the user does not pay for the transaction (similar to the PunkPoll approach). In this case, the developer should prepay the fees to the Gas Station, and the Gas Station will sign, and send transactions.

  • Prepare pull request for o1js to specify the fee in weight units as an option in Mina.transaction to close

API

async getFee(params: {
       chain: 'devnet' | 'mainnet',
       speed?: `fastest` | `fast` | `standard` | `low`,
       numberOfAccountUpdates?: number,
       weightUnits?: number,
       tx?: string // the result of tx.toJSON()
       }) : number
async changeFee(params: {
        chain: 'devnet' | 'mainnet',
        speed?: `fastest` | `fast` | `standard` | `low`,
        tx: string // the result of tx.toJSON()
    }) : string //tx as JSON stringified
async sendMetaTransaction(params: {
        chain: 'devnet' | 'mainnet',
        speed?: `fastest` | `fast` | `standard` | `low`,
        tx: string // the result of tx.toJSON()
    }) : string //tx as JSON stringified

Architecture & Design

To get the market fee, the following sources can be used:

  • Data from the node(s) that is being run by the developer
  • BlockBerry API
  • Statistics on average fee fluctuations during the day, week, month, and year (as soon as these statistics will be available)

The current content of the transaction pool should be analyzed, including the number of the AccountUpdates and weightUnits for each transaction in the transaction pool.

Not all transactions can be used with the gasless feature, for example, the transactions that use this.sender cannot be signed by the private key of the gasless station.

The sendGasless() function will return the internal ID of the Gasless Station that can be used to get the hash of the transaction. This hash can change during volatility times as the Gasless Station can increase the fee and resend the tx with the same nonce, replacing the previous transaction and getting the new transaction hash.

The important part of the Gasless Station is the storage of the hot private keys used to send transactions. The design should preview the secure storage, for example, using AWS KMS in the separate AWS account used only for signing the transactions.

submitted by DFST

Resources

Ready to build?

Please read the docs on how to progress.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant