-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Refund Unused Fee #9569
Comments
We implemented this on Ethermint https://github.com/tharsis/ethermint/blob/main/x/evm/keeper/state_transition.go#L274 |
can we close this in favor of #2150 |
I think ante decorators should wrap all of |
I'm in favor of the approach if the Regen team approves as well. I know I along with the initial SDK team decided to go with a less powerful approach, but as SDK has evolved I think it makes sense to enable this feature and potentially others. |
One issue to note that the SDK team initially considered when making our decision was how CheckTx should change in light of this. Originally the antehandler was purely doing pre-processing of a transaction, and made basic tx-level checks on validity before handlers did message-specific checks and state updates. So CheckTx naturally just ran the antehandler and skipped message execution which happened after the antehandler was done executing. In the case where antedecorators wrap the entire message processing, it becomes less clear what to do for CheckTx. Should CheckTx run the entire transaction along with message processing? We could make the last "antedecorator" implement the msg routing currently in |
Closing in favor of #2150 |
I think this makes sense. One thought I had was to have separate |
Summary
Currently, the SDK tx only allows a user to specify the maximum gas for a tx and the fee they're willing to pay. This creates an implied
gasPrice
. However, the fee gets deducted in its totality regardless of what the eventual gas ends up being. It would be ideal if the remainder of the fee gets refunded in cases where the consumed gas is less than the specified limit.Problem Definition
Proposal
Solving this would require some form of post-processing of the transaction. We could still deduct the entire fee in the antehandler (in order to ensure beforehand that the user has enough fees to pay for their gas limit), however after the tx is complete, we should refund the fee like so:
distributionPool.Send(tx.feePayer, tx.Fee * (1 - ctx.GasConsumed()/tx.gasLimit))
The post processing can be done either as a decorator that wraps the entire msg processing, or as a separate post-processing function.
For Admin Use
The text was updated successfully, but these errors were encountered: