Skip to content

fix: eth_estimateGas failing with not enough funds for L1 fee#3169

Open
exeokan wants to merge 8 commits intonightlyfrom
ege/estimate-gas-l1-fee
Open

fix: eth_estimateGas failing with not enough funds for L1 fee#3169
exeokan wants to merge 8 commits intonightlyfrom
ege/estimate-gas-l1-fee

Conversation

@exeokan
Copy link
Contributor

@exeokan exeokan commented Feb 27, 2026

Description

When the "from" address has a low balance, eth_estimateGas was failing because we were inspecting the transaction with non zero L1 fee rate.
This PR fixes the issue by executing with a zero L1 fee rate, and then computing the l1 fee in the handler using the l1 diff from execution.

Testing

Added test_estimate_gas_no_balance.

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 50.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.6%. Comparing base (61b10a9) to head (8467585).

Files with missing lines Patch % Lines
crates/evm/src/query.rs 50.0% 8 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
...overeign-sdk/full-node/db/sov-schema-db/src/lib.rs 78.0% <ø> (ø)
crates/evm/src/query.rs 90.7% <50.0%> (+0.5%) ⬆️

... and 7 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@exeokan exeokan changed the title fix: eth_call failing with not enough L1 fee fix: eth_estimateGas failing with not enough L1 fee Mar 2, 2026
@exeokan exeokan marked this pull request as ready for review March 2, 2026 10:08
@exeokan exeokan requested a review from a team as a code owner March 2, 2026 10:08
Copilot AI review requested due to automatic review settings March 2, 2026 10:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes eth_estimateGas failing for low-/zero-balance from addresses by preventing L1 fee charging during the EVM simulation, while still returning an l1_fee estimate computed from the execution’s recorded L1 diff size.

Changes:

  • Run eth_estimateGas simulations with l1_fee_rate = 0 to avoid "Not enough funds for L1 fee" failures during inspection.
  • Recompute l1_fee in the RPC handler using tx_info.l1_diff_size * real_l1_fee_rate (instead of relying on tx_info.l1_fee produced by a zero-fee simulation).
  • Add test_estimate_gas_no_balance to cover estimateGas behavior when from has zero balance.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
crates/evm/src/query.rs Adjusts estimate gas execution to simulate with zero L1 fee rate and recompute L1 fee from l1_diff_size.
crates/evm/src/tests/queries/estimate_gas_tests.rs Adds a regression test ensuring eth_estimateGas succeeds for zero-balance from (except value transfers).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jfldde
jfldde previously approved these changes Mar 2, 2026
@exeokan exeokan changed the title fix: eth_estimateGas failing with not enough L1 fee fix: eth_estimateGas failing with not enough funds for L1 fee Mar 2, 2026
@exeokan exeokan added this to the v2.3.0 milestone Mar 2, 2026
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 this pull request may close these issues.

4 participants