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

Implement fee oracle for EIP-1559 to estimate priority fees #20469

Closed
onyb opened this issue Jan 12, 2022 · 1 comment · Fixed by brave/brave-core#12054
Closed

Implement fee oracle for EIP-1559 to estimate priority fees #20469

onyb opened this issue Jan 12, 2022 · 1 comment · Fixed by brave/brave-core#12054
Assignees
Labels
bug feature/web3/wallet Integrating Ethereum+ wallet support OS/Android Fixes related to Android browser functionality OS/Desktop OS/iOS Fixes related to iOS browser functionality priority/P2 A bad problem. We might uplift this to the next planned release. QA Pass - Android ARM QA Pass - Android Tab QA Pass-macOS QA/Test-All-Device-Types QA/Test-Plan-Specified QA/Yes release-notes/include

Comments

@onyb
Copy link
Member

onyb commented Jan 12, 2022

Avalanche has migrated to EIP-1559, and now supports Type-2 transactions. Polygon has also made the switch on their Mumbai testnet, so it's expected to go live on mainnet very soon.

This poses a problem for us, since we rely on Etherscan API for priority fee estimates (slow/average/fast) and keep track of the BASEFEE. This API supports Ethereum only at the moment, which means on other EVM networks users are over paying fees by a lot. Here's a user complaining about it: https://community.brave.com/t/adjust-fee-mechanism-calculation/320507.

$ curl -s https://mainnet.infura.io/v3/<infura project ID> -X POST -H "Content-Type: application/json" -d '{"id":1,"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false]}' | jq '.result.baseFeePerGas'
"0x239edbf0f5"

$ curl -s https://api.avax-test.network/ext/bc/C/rpc -X POST -H "Content-Type: application/json" -d '{"id":1,"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false]}' | jq '.result.baseFeePerGas'
"0x5d21dba00"

$ curl -s https://polygon-rpc.com -X POST -H "Content-Type: application/json" -d '{"id":1,"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["latest", false]}' | jq '.result.baseFeePerGas'
null  // coming soon

This issue proposes to implement a fee oracle independent of Etherscan API, using the eth_feeHistory RPC. Here's the reference implementation in ethereum-remote-client: https://github.com/brave/ethereum-remote-client/blob/master/app/scripts/controllers/network/eip1559FeeOracle.js. I have not researched the latest and greatest fee oracle out there, but this one used to work quite reliably.

@onyb onyb added bug feature/web3/wallet Integrating Ethereum+ wallet support OS/Desktop labels Jan 12, 2022
@bbondy bbondy added the priority/P2 A bad problem. We might uplift this to the next planned release. label Jan 12, 2022
@bbondy bbondy self-assigned this Jan 18, 2022
onyb added a commit to brave/brave-core that referenced this issue Jan 24, 2022
Our current EIP-1559 gas oracle queries the Etherscan API, which only
supports Ethereum mainnet. As a result, priority fee estimations on
custom networks use results for Ethereum mainnet, which can either
result in transactions being stuck in the mempool forever, or in
over-payment of gas fees.

This commit will be reverted in brave/brave-browser#20469.
onyb added a commit to brave/brave-core that referenced this issue Jan 25, 2022
Our current EIP-1559 gas oracle queries the Etherscan API, which only
supports Ethereum mainnet. As a result, priority fee estimations on
custom networks use results for Ethereum mainnet, which can either
result in transactions being stuck in the mempool forever, or in
over-payment of gas fees.

This commit will be reverted in brave/brave-browser#20469.
onyb added a commit to brave/brave-core that referenced this issue Jan 25, 2022
Our current EIP-1559 gas oracle queries the Etherscan API, which only
supports Ethereum mainnet. As a result, priority fee estimations on
custom networks use results for Ethereum mainnet, which can either
result in transactions being stuck in the mempool forever, or in
over-payment of gas fees.

This commit will be reverted in brave/brave-browser#20469.
onyb added a commit to brave/brave-core that referenced this issue Jan 25, 2022
Our current EIP-1559 gas oracle queries the Etherscan API, which only
supports Ethereum mainnet. As a result, priority fee estimations on
custom networks use results for Ethereum mainnet, which can either
result in transactions being stuck in the mempool forever, or in
over-payment of gas fees.

This commit will be reverted in brave/brave-browser#20469.
onyb added a commit to brave/brave-core that referenced this issue Jan 25, 2022
Our current EIP-1559 gas oracle queries the Etherscan API, which only
supports Ethereum mainnet. As a result, priority fee estimations on
custom networks use results for Ethereum mainnet, which can either
result in transactions being stuck in the mempool forever, or in
over-payment of gas fees.

This commit will be reverted in brave/brave-browser#20469.
onyb added a commit to brave/brave-core that referenced this issue Jan 27, 2022
Our current EIP-1559 gas oracle queries the Etherscan API, which only
supports Ethereum mainnet. As a result, priority fee estimations on
custom networks use results for Ethereum mainnet, which can either
result in transactions being stuck in the mempool forever, or in
over-payment of gas fees.

This commit will be reverted in brave/brave-browser#20469.
onyb added a commit to brave/brave-core that referenced this issue Jan 27, 2022
Our current EIP-1559 gas oracle queries the Etherscan API, which only
supports Ethereum mainnet. As a result, priority fee estimations on
custom networks use results for Ethereum mainnet, which can either
result in transactions being stuck in the mempool forever, or in
over-payment of gas fees.

This commit will be reverted in brave/brave-browser#20469.
@bbondy bbondy added OS/Android Fixes related to Android browser functionality OS/iOS Fixes related to iOS browser functionality labels Feb 3, 2022
@bbondy bbondy added this to the 1.37.x - Nightly milestone Feb 7, 2022
@bbondy bbondy added this to Web3 Mar 18, 2022
@bbondy bbondy moved this to Done in Web3 Mar 18, 2022
@Uni-verse
Copy link
Contributor

Uni-verse commented Mar 25, 2022

Verification in Progress using 1.37.105 Chromium: 100.0.4896.46

Test Plan: - brave/brave-core#12054 (comment)

PASS - Ethereum mainnet
PASS - Polygon Mainnet
PASS - Avalanche Fuji Testnet
PASS - Ropsten

Note: Was not tested on Avalanche C-Chain mainnet

Desktop:
https://etherscan.io/tx/0xc4330770638bfd98ce88273683fed413cc5724d10b1d150285236641f2d6f8e9

https://polygonscan.com/tx/0x0132e4ac58a42777b7277e8946a8481e32008796f867fe9929b81a009101e691

https://ropsten.etherscan.io/tx/0x2348d43c3c52b3988907194441d099a4ed80ac9f6240754fd78ea7aebadb3e60

https://testnet.snowtrace.io/tx/0x1b970936e031e4cb12863e000bea330297ea637d21825747c6882a3a85fe20ed

1 2
Screen Shot 2022-03-25 at 12 05 51 PM Screen Shot 2022-03-25 at 12 05 59 PM

Android:
https://polygonscan.com/tx/0xda716528ad5af75aaa39faa01ceb2128b037011e46f9ece802338b74c7370d87

https://ropsten.etherscan.io/tx/0x18791761184f941b148c3156cca947db09b88a9e25d8f3b56bf586b4635c3359

https://etherscan.io/tx/0x55b16ecfb6d7588eb8d66bd5ef179e700a8d350c9af1bf8dfc48e3a800a68f58
https://testnet.snowtrace.io/tx/0x083626488c02871f9da0b990947206e8d5b1657509e47bf9cadb7288a8d34016

Android Tablet:

https://ropsten.etherscan.io/tx/0x920675bec70e951f51b1424713279af9569ea780f0f35a09c8ebd0cb80d48626

https://polygonscan.com/tx/0x3aab3999a2dfe7baa8449243f55f89c7ff108de8ba71e2f991692571b379fdff

https://etherscan.io/tx/0x4be2b5c9c6b138b39cac3c4573cb5a690745eade102e25d9e2ddc6dfe36e12d4

https://testnet.snowtrace.io/tx/0x6de13f9e1c1404f5e93ccb7da856ef8b816f7ee534d606f34d137767cfbdeaa3

1 2
Screen Shot 2022-03-25 at 11 40 03 AM Screen Shot 2022-03-25 at 11 52 50 AM

iOS

https://testnet.snowtrace.io/tx/0x30e16a094fa216cf57a1747896bc3dd2347acf2f3c2e60e6bf00fc368b4c0ca4
https://ropsten.etherscan.io/tx/0xf9701fada5098f8ca28880c4322d816f603740489dfa59309a82fba0d276db9f
https://etherscan.io/tx/0x72d36560305f03cd33c95936fb593d42d27db3e84e789abe49b6526e0a9ffd8d
https://polygonscan.com/tx/0x056c1caf74cdfb442e4b1da616fd09b942e40e84d356b930c1d55d25cf232788

1 2
IMG_2550 IMG_2551

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug feature/web3/wallet Integrating Ethereum+ wallet support OS/Android Fixes related to Android browser functionality OS/Desktop OS/iOS Fixes related to iOS browser functionality priority/P2 A bad problem. We might uplift this to the next planned release. QA Pass - Android ARM QA Pass - Android Tab QA Pass-macOS QA/Test-All-Device-Types QA/Test-Plan-Specified QA/Yes release-notes/include
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants