Skip to content

Fix simulator using raw gas estimator without tip adjustments#4298

Merged
squadgazzz merged 2 commits intomainfrom
fix-simulator-gas-estimator
Mar 27, 2026
Merged

Fix simulator using raw gas estimator without tip adjustments#4298
squadgazzz merged 2 commits intomainfrom
fix-simulator-gas-estimator

Conversation

@squadgazzz
Copy link
Copy Markdown
Contributor

@squadgazzz squadgazzz commented Mar 27, 2026

Summary

Fixes a regression introduced in #4265 (Simulator crate) that caused frequent "max fee per gas less than block base fee" errors during settlement encoding, particularly on Arbitrum.

Root cause

Ethereum::gas_estimator() returns self.inner.gas.gas — the raw dyn GasPriceEstimating without tip adjustments. Before #4265, Ethereum::simulation_gas_price() called GasPriceEstimator::estimate() which adds a configurable tip buffer (default 3 Gwei or 5%) on top of the raw estimate. After #4265, the simulator receives the raw estimator, so simulation gas prices land right at the base fee with no buffer.

On Arbitrum (~250ms blocks), the base fee changes constantly. The tiny gap between estimation and eth_call execution is enough for the base fee to tick up past the estimated price.

Fix

Implement GasPriceEstimating for GasPriceEstimator and return the wrapped estimator from gas_estimator(), so the simulator gets the same tip-adjusted estimates the driver used before #4265.

Test plan

  • cargo check -p driver passes
  • Deploy to staging and verify "max fee per gas less than block base fee" errors stop on Arbitrum

PR #4265 (Simulator crate) introduced a regression where the simulator
receives the raw gas price estimator (without additional tip/min priority
fee adjustments) instead of the wrapped one that the driver previously used.

Before #4265, `Ethereum::simulation_gas_price()` called
`GasPriceEstimator::estimate()` which adds a configurable tip buffer
(default 3 Gwei or 5%) on top of the raw network estimate. After #4265,
the simulator receives `eth.gas_estimator()` which returns `self.inner.gas.gas`
— the raw inner estimator, bypassing the tip logic entirely.

On fast-block chains like Arbitrum (~250ms blocks), the base fee changes
frequently. Without the tip buffer, the simulation gas price lands right at
the current base fee and often falls below it by the time the eth_call
executes, causing "max fee per gas less than block base fee" errors.

Fix: implement `GasPriceEstimating` for `GasPriceEstimator` and return the
wrapped estimator from `gas_estimator()` so the simulator gets the same
tip-adjusted estimates as before.
@squadgazzz squadgazzz marked this pull request as ready for review March 27, 2026 13:44
@squadgazzz squadgazzz requested a review from a team as a code owner March 27, 2026 13:44
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the as_estimating method to the GasPriceEstimator and implements the GasPriceEstimating trait for it, allowing for more accurate gas price estimation in components like the simulator. I have no feedback to provide as the identified medium-severity issue regarding error wrapping does not meet the repository's threshold for critical findings.

@AryanGodara AryanGodara self-requested a review March 27, 2026 13:50
@squadgazzz squadgazzz added the hotfix Labels PRs that should be applied into production right away label Mar 27, 2026
@squadgazzz squadgazzz enabled auto-merge March 27, 2026 13:53
@squadgazzz squadgazzz added this pull request to the merge queue Mar 27, 2026
Merged via the queue into main with commit 0a42e7c Mar 27, 2026
19 checks passed
@squadgazzz squadgazzz deleted the fix-simulator-gas-estimator branch March 27, 2026 14:14
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

hotfix Labels PRs that should be applied into production right away

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants