-
Notifications
You must be signed in to change notification settings - Fork 277
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(api): change gas_price to use pending block #1082
Conversation
WalkthroughThe changes in this pull request primarily focus on the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
internal/ethapi/backend.go (1)
66-66
: Add documentation for the new method.
The method signature looks good and aligns well with the interface's design. However, please add documentation to clarify:
- The purpose of this method
- Whether the returned block/receipts can be nil
- Any thread safety guarantees
Consider this documentation:
+// PendingBlockAndReceipts returns the currently pending block and associated receipts.
+// Both return values may be nil if no block is pending.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- internal/ethapi/api.go (1 hunks)
- internal/ethapi/backend.go (1 hunks)
🔇 Additional comments (1)
internal/ethapi/api.go (1)
71-73
: LGTM! The changes improve gas price estimation accuracy.
The modification to use pending block's base fee instead of latest block's base fee is a good improvement that will help prevent transaction failures during L1 gas price spikes. The implementation is robust with proper nil checks for both pending block and base fee.
* fix(api): change gas_price to use pending block
* fix(api): change gas_price to use pending block (#1082) * fix(api): change gas_price to use pending block * fix --------- Co-authored-by: Morty <[email protected]>
1. Purpose or design rationale of this PR
The eth_gasPrice API returns gas price based on latest block, but eth_estimateGas use gas price based on pending block. So if we use the eth_gasPrice API gas price to do an eth_estimateGas API call, there is a possibility it will fail and return
max fee per gas less than block base fee
. that's because if L1 gas spike and gas-oracle updates the l1BaseFee, the pending block baseFee will be higher than the one based on latest block.So I think we could change eth_gasPrice API to return gas price based on pending block, that will prevent this issue, and provides a more accurate suggest gas price.
See more details here: https://www.notion.so/scrollzkp/l2geth-returns-wrong-gas-price-issue-1297792d22af8045bbb1e57ff974e6c7
2. PR title
Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:
3. Deployment tag versioning
Has the version in
params/version.go
been updated?4. Breaking change label
Does this PR have the
breaking-change
label?Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Chores