MinaFoundation / ecosystem-ideas

Get inspired to build on MinaProtocol.
MIT License
0 stars 0 forks source link

Mina GasStation #7

Open hgedia opened 1 month ago

hgedia commented 1 month ago

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:

Proposal Overview

The solution proposed allows and intends to:

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:

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.