Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Problem: eip-1559 tx fee deduction is problematic #814

Closed
yihuang opened this issue Dec 8, 2021 · 1 comment · Fixed by #817
Closed

Problem: eip-1559 tx fee deduction is problematic #814

yihuang opened this issue Dec 8, 2021 · 1 comment · Fixed by #817

Comments

@yihuang
Copy link
Contributor

yihuang commented Dec 8, 2021

System info: ethermint main

Steps to reproduce:

  1. start devnet
  2. do an dynamic fee tx
$ seth send 0x104a920D7D1039bb249F9FBB17aAc0eB0869D86D --value 10000 --gas 200000 --gas-price 5000000000001 --prio-fee 1
seth-send: 0xfd1b5006c3ccc018fd23050fd4cc713a8b61c4ed66db21dd5bab9867a3717418
seth-send: Waiting for transaction receipt..........
  1. It don't return, because tx execution failed, we can find the failure reason in /block_results:
failed to execute message; message index: 0: failed to apply transaction: failed to refund gas leftover gas to sender 0x378c50D9264C63F3F92B806d4ee56E9D86FfB3Ec: failed to refund 179000 leftover gas (1432000basetcro): fee collector account failed to refund fees: 200000basetcro is smaller than 1432000basetcro: insufficient funds: insufficient funds

The root cause is in ante handler, it deduct fee using tip gas price, while when refund gas, it use the full gas-price.

Expected behavior: eip-1559 tx should work.

Actual behavior: refund gas error

Additional info:

Deduct fee in ante handler using the GasFeeCap should solve this error, need to further check if it's complaint to go-ethereum behavior.

@yihuang yihuang changed the title Problem: base fee is not deducted in ante handler Problem: eip-1559 tx fee deduction is problematic Dec 8, 2021
@yihuang
Copy link
Contributor Author

yihuang commented Dec 9, 2021

Solution:

  1. We should use effectiveGasPrice rather than GasFeeCap as the tx gas price when checking minimal-gas-price or deduct the fee in ante handler.
  2. baseFee is burned in ethereum, I think it doesn't make much sense in our case, so we collect it together with tip fee in the normal way. we can change it later if we want to burn it.
  3. Also compute gas refund amount using effectGasPrice, it's already the case.
  4. Since we need to load baseFee to calculate the effectGasPrice, we can't reuse the FeeTx interface and need a customized MempoolFeeDecorator in ante handler.

Extra issue: we should return effectiveGasPrice in tx receipt, same as go-ethereum.

yihuang added a commit to yihuang/ethermint that referenced this issue Dec 9, 2021
Closes: evmos#814

Solution:
- use effectiveGasPrice when check minimal-gas-prices, and deduct fee in ante handler
- implement an EthMempoolFeeDecorator
fedekunze added a commit that referenced this issue Dec 15, 2021
* Use effectiveGasPrice in ante handler for dynamic fee tx

Closes: #814

Solution:
- use effectiveGasPrice when check minimal-gas-prices, and deduct fee in ante handler
- implement an EthMempoolFeeDecorator

* add effectiveGasPrice to tx receipt

* changelog

* fix unit test

* fix comments

* add comments

* Apply suggestions from code review

Co-authored-by: Thomas Nguy <81727899+thomas-nguy@users.noreply.github.com>

* review suggestions

Co-authored-by: Thomas Nguy <81727899+thomas-nguy@users.noreply.github.com>
Co-authored-by: Federico Kunze Küllmer <31522760+fedekunze@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant