Gas fee model #248
Replies: 2 comments 5 replies
-
Thank you for starting this! A few thoughts from my end:
I'm hoping that we can. It would be really nice if the fee was driven by as few factors as possible, and taking the overall length of the execution trace as one of these factors would be a pretty clean way to do it. My initial thinking is that the difference between different co-processor rows is fairly small as compared to the overall proof generation process. So, maybe this difference won't play any meaningful role (i.e., if the difference between a more accurate and a less accurate methodology is 5% - 10%, I think we can safely go with the less accurate one). But more thinking is needed on this. Another component in this is that we'd actually have two different parts which could affect fees:
I think considerations for handling these would be quite different. Conceptually, aggregation fees are relatively simple. A few thoughts on these:
Handling transaction execution fees is probably a bit more complex. A few thoughts on these:
I'd like to support this. Basically, ideally, the fee would be just one of the outputs of a transaction, and then it would be up to a specific note/account logic to figure out how to make sure that the fee is attractive for the block producer to execute and aggregate this transaction into a block. I think the challenge here would be to provide enough machinery to make fee estimation as simple as possible. Maybe we should start with simple transaction types (transfers between two accounts) and see how it could work, and then expand to more complicated scenarios. Another consideration: I think there are benefits to having the general fee structure be similar to how it now works in Ethereum where we have a base fee, which gets burned, and then a tip which is paid to the block producer. But I haven't thought too much about how it could work in our context (this might be especially difficult if we support fees payable in any asset). |
Beta Was this translation helpful? Give feedback.
-
Another thing to note is that the above actually implies that we need two different kernels:
|
Beta Was this translation helpful? Give feedback.
-
This note discusses at a high level how gas fees could work in Polygon Miden, and assumes familiarity with the discussions/issues here: #192 #222 #231
Gas metering could be done directly within the VM by counting the number of rows used in the main trace and for each of the coprocessors. Because coprocessor traces share rows with the main processors, we primarily need to be concerned with overall trace length. However, as each coprocessor may carry an additional computational overhead, we may need to weight each row type according to its computational cost.
To determine the row count of the main processors, one could add a column to the main trace that is incremented by$1$ at each step and is enforced by a continuity constraint. The final value could be read out through an assertion or permutation product column. There may be a more efficient approach.
To track coprocessor usage, there are at least two solutions:
To pay the gas fee to the sequencer, a kernel call
pay_gas_fee
could be made in the epilogue of the transaction. For example, this call could use the counts available in the Gas Meter coprocessor described above to compute the fee, and decrease (increase) the asset balance in the vault of the account (sequencer) by this amount directly. Alternatively, a note could be produced by the account with the fee amount containing a script root that restricts consumption to the sequencer. In this case, the sequencer will need to be able to efficiently aggregate these for consumption if they each contain only a very small amount of fees.Open questions:
fee_per_row
) which may need to be updated as hardware matures and costs decrease. One possibility is to keep these values in storage variables of the sequencer's account, and expose them through getter functions in the kernel.max_fee
field to the transaction to place a cap on the gas fee paid.gasleft
kernel operation.Beta Was this translation helpful? Give feedback.
All reactions