Skip to content

feat(gas_oracle): implement median-based priority fee suggestion for Optimism#16794

Merged
mattsse merged 3 commits intoparadigmxyz:mainfrom
mablr:feature/op-suggest-median-tip
Jun 14, 2025
Merged

feat(gas_oracle): implement median-based priority fee suggestion for Optimism#16794
mattsse merged 3 commits intoparadigmxyz:mainfrom
mablr:feature/op-suggest-median-tip

Conversation

@mablr
Copy link
Contributor

@mablr mablr commented Jun 12, 2025

Resolve #16669 by implementing the op-geth's fee suggestion logic.

I created a separate op_suggest_tip_cap. But the overall architecture of gas-price module may be refactored.

Here are some remarks:

  • In op-geth, there is a unique suggest_tip_cap function, and the specific OP logic is triggered by checking the chain type. For Reth the current trait bounds for GasPriceOracle<Provider> do not include EthChainSpec to implement the exactly the same logic (I tried to add it but it breaks at other levels, eg. EthApiBuilder)
  • On the other hand, this new OP-specific GasPriceOracle logic may be moved to optimism crate, with something like OpGasPriceOracle

Please, let me know what do you think about it...

A median-based priority fee suggestion function for Optimism
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, almost there

.await?
.ok_or(EthApiError::ReceiptsNotFound(BlockId::latest()))?
.iter()
.map(|r| r.cumulative_gas_used())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think this is quite right because this is cumulative so this will always be the last receipt in the list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes that's true.

There is missing trait bound on Provider to get gas_used(), I'll try to fix that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-project-automation github-project-automation bot moved this from Backlog to In Progress in Reth Tracker Jun 13, 2025
@mattsse mattsse marked this pull request as ready for review June 13, 2025 08:24
@mattsse mattsse requested review from Rjected and fgimenez as code owners June 13, 2025 08:24
@mattsse mattsse added the A-op-reth Related to Optimism and op-reth label Jun 13, 2025
mablr added 2 commits June 13, 2025 14:35
- remove comment about unused `default`field
- remove sanity check for `max_gas_used`
- improve doc
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@mattsse mattsse added this pull request to the merge queue Jun 14, 2025
Merged via the queue into paradigmxyz:main with commit bb4bf29 Jun 14, 2025
44 of 45 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Reth Tracker Jun 14, 2025
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-op-reth Related to Optimism and op-reth

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Use median prio for suggested fee for optimism

2 participants