feat(gas_oracle): implement median-based priority fee suggestion for Optimism#16794
Merged
mattsse merged 3 commits intoparadigmxyz:mainfrom Jun 14, 2025
Merged
Conversation
A median-based priority fee suggestion function for Optimism
mattsse
requested changes
Jun 13, 2025
| .await? | ||
| .ok_or(EthApiError::ReceiptsNotFound(BlockId::latest()))? | ||
| .iter() | ||
| .map(|r| r.cumulative_gas_used()) |
Collaborator
There was a problem hiding this comment.
don't think this is quite right because this is cumulative so this will always be the last receipt in the list
Contributor
Author
There was a problem hiding this comment.
Oh yes that's true.
There is missing trait bound on Provider to get gas_used(), I'll try to fix that.
Contributor
Author
There was a problem hiding this comment.
I haven't found gas_used() method applicable a Receipt. So I made a workaround based on cumulative_gas_used value of each receipt. It's not perfectly clean/readable, but I think it does the job like in op-geth.
- remove comment about unused `default`field - remove sanity check for `max_gas_used` - improve doc
mattsse
approved these changes
Jun 14, 2025
Collaborator
mattsse
left a comment
There was a problem hiding this comment.
great, the windows approach works well here
Comment on lines
+314
to
+316
| let prev = window[0].cumulative_gas_used(); | ||
| let curr = window[1].cumulative_gas_used(); | ||
| curr - prev |
theochap
pushed a commit
to ethereum-optimism/optimism
that referenced
this pull request
Jan 22, 2026
theochap
pushed a commit
to ethereum-optimism/optimism
that referenced
this pull request
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolve #16669 by implementing the op-geth's fee suggestion logic.
I created a separate
op_suggest_tip_cap. But the overall architecture ofgas-pricemodule may be refactored.Here are some remarks:
suggest_tip_capfunction, and the specific OP logic is triggered by checking the chain type. For Reth the current trait bounds forGasPriceOracle<Provider>do not includeEthChainSpecto implement the exactly the same logic (I tried to add it but it breaks at other levels, eg. EthApiBuilder)GasPriceOraclelogic may be moved to optimism crate, with something likeOpGasPriceOraclePlease, let me know what do you think about it...