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

Fetch gas price natively #305

Closed
Siegrift opened this issue May 13, 2024 · 4 comments · Fixed by #321
Closed

Fetch gas price natively #305

Siegrift opened this issue May 13, 2024 · 4 comments · Fixed by #321
Assignees

Comments

@Siegrift
Copy link
Collaborator

See: https://api3workspace.slack.com/archives/C06R2JCFSS1/p1715585624116669?thread_ts=1715333508.842309&cid=C06R2JCFSS1

@Siegrift
Copy link
Collaborator Author

We discussed on the call to implement this now, but there was an idea to make sure sanitized gas price is higher than the base fee. Tracked in #306

@Siegrift Siegrift self-assigned this May 17, 2024
@Siegrift
Copy link
Collaborator Author

We discussed on call to only implement #306

@bdrhn9
Copy link
Contributor

bdrhn9 commented May 27, 2024

Although the issue #306 requires obtaining the base fee for blocks, my investigation of the underlying getFeeData function in ethers.js revealed that it does not directly return the block's base fee. Instead, it performs heuristic calculations using both the base fee and the maximum priority fee (eth_maxPriorityFeePerGas). Specifically, it returns a value computed as 2 * base fee + max priority fee. You can see the implementation here: ethers.js source code.

While it is theoretically possible to reverse this calculation to derive the base fee, it introduces several potential issues, such as handling cases where the maximum priority fee is null, and increases the risk of errors during the reverse calculation. Addition to that, we will still end up with making 3 calls (eth_gasPrice, eth_getBlockByNumber, eth_maxPriorityFeePerGas).

Therefore, it would be more efficient to fetch gas price using low-level RPC call.

@Siegrift
Copy link
Collaborator Author

Thanks for that. I agree.

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 a pull request may close this issue.

2 participants