-
Notifications
You must be signed in to change notification settings - Fork 817
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
Fix volatile eth_gasPrice #2006
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2006 +/- ##
==========================================
- Coverage 61.36% 61.34% -0.02%
==========================================
Files 263 263
Lines 24483 24525 +42
==========================================
+ Hits 15024 15045 +21
- Misses 8341 8358 +17
- Partials 1118 1122 +4
|
continue | ||
} | ||
// okay to get from latest since receipt is immutable | ||
receipt, err := i.keeper.GetReceipt(i.ctxProvider(LatestCtxHeight), ethtx.Hash()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best to check if receipt.BlockHeight
matches height in block
, and ignore if mismatch
Describe your changes and provide context
Our current eth_gasPrice uses the reward of the 50th percentile tx in the latest block as part of the calculation. This works decently well if the previous block is congested. However, if the previous block had only 1 tx where the user dramatically overpriced their tx, it will return a very high reward. This often causes our eth_gasPrice endpoint to jump around erratically.
This change uses the previous block's total gas used to determine if the block is congested. If the previous block is congested, we will use the previous logic of 50% of reward. Otherwise, eth_gasPrice now pulls the latest base fee and increases it by 10% to ensure the user's tx can be included in a timely manner without dramatically overpaying.
This also makes a similar adjustment to
eth_maxPriorityFeePerGas
where if the chain is not congested, a default priority fee of 1gwei is returned to the user.Testing performed to validate your change
existing unit testing + manually patched it onto an RPC node.