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

feat: implement eth_feeHistory endpoint #502

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ptrus
Copy link
Member

@ptrus ptrus commented Jan 5, 2024

Fixes #501

Implements eth_feeHistory endpoint. The query supports returning the history for the maximum last 20 blocks (this arbitrarily set limit is allowed as per spec: Requested range of blocks. Clients will return less than the requested range if not all blocks are available.)

To avoid fetching multiple blocks, transactions, and receipts from DB on every fee_history query (which can be expensive) the fee_history for last 20 blocks is continuously pre-computed in the gas oracle (only the percentiles are computed on the fly).

TODO:

  • test

@ptrus ptrus force-pushed the ptrus/feature/fee-history branch 4 times, most recently from 09f6075 to bbe0ba6 Compare January 5, 2024 16:16
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 44 lines in your changes are missing coverage. Please review.

Project coverage is 62.45%. Comparing base (1c3f6a2) to head (bbe0ba6).
Report is 70 commits behind head on main.

❗ Current head bbe0ba6 differs from pull request most recent head 7c10b2e. Consider uploading reports for the commit 7c10b2e to get more accurate results

Files Patch % Lines
gas/backend.go 68.80% 28 Missing and 6 partials ⚠️
rpc/eth/api.go 41.17% 7 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #502      +/-   ##
==========================================
+ Coverage   62.31%   62.45%   +0.13%     
==========================================
  Files          38       37       -1     
  Lines        3962     4051      +89     
==========================================
+ Hits         2469     2530      +61     
- Misses       1285     1307      +22     
- Partials      208      214       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@CedarMist
Copy link
Member

CedarMist commented Feb 4, 2024

Metamask uses eth_feeHistory to calculate the different transaction priorities for gas price.

See metamask source:

This doesn't include the current txpool as BTC fee estimation does.

Recently we had a situation where many transactions were queued up, and we were not sure if the fee estimation was returning accurate data, or if the 'Speed Up' button in MetaMask would work correctly.

If eth_feeHistory isn't supported it will fallbcak to eth_gasPrice, in an ideal situation would be to return the average of the minimum and median for having the transaction included within the next block.

@ptrus ptrus force-pushed the ptrus/feature/fee-history branch 3 times, most recently from 0533998 to 7c10b2e Compare May 6, 2024 10:40
@ptrus ptrus force-pushed the ptrus/feature/fee-history branch 11 times, most recently from 606a775 to c3fd2da Compare October 29, 2024 09:28
@ptrus ptrus marked this pull request as ready for review October 29, 2024 09:34
@ptrus ptrus requested a review from kostko as a code owner October 29, 2024 09:34
@ptrus ptrus requested review from matevz and CedarMist and removed request for kostko October 29, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

eth_feeHistory not supported
2 participants