Skip to content

fix: set L1 fee rate to zero in eth_estimateGas if sender has no balance#3169

Merged
eyusufatik merged 16 commits intonightlyfrom
ege/estimate-gas-l1-fee
Mar 16, 2026
Merged

fix: set L1 fee rate to zero in eth_estimateGas if sender has no balance#3169
eyusufatik merged 16 commits intonightlyfrom
ege/estimate-gas-l1-fee

Conversation

@exeokan
Copy link
Contributor

@exeokan exeokan commented Feb 27, 2026

Description

When the from address is not specified or has zero balance (a simulation scenario), eth_estimateGas failed because the transaction was inspected using a non-zero L1 fee rate.
This PR resolves the issue by executing with a zero L1 fee rate in those cases, and computing the L1 fee afterward 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 80.00000% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.5%. Comparing base (7e79a8a) to head (90f9593).
⚠️ Report is 2 commits behind head on nightly.

Files with missing lines Patch % Lines
crates/evm/src/query.rs 80.0% 5 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
crates/evm/src/query.rs 90.1% <80.0%> (+<0.1%) ⬆️

... and 10 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
ercecan
ercecan previously approved these changes Mar 2, 2026
jfldde
jfldde previously approved these changes Mar 11, 2026
@exeokan exeokan dismissed stale reviews from jfldde and ercecan via 607c930 March 12, 2026 12:07
eyusufatik
eyusufatik previously approved these changes Mar 13, 2026
@exeokan exeokan changed the title fix: eth_estimateGas failing with not enough funds for L1 fee fix: set L1 fee rate to zero in eth_estimateGas if sender has no balance Mar 13, 2026
@eyusufatik eyusufatik merged commit c6cd63a into nightly Mar 16, 2026
23 checks passed
@eyusufatik eyusufatik deleted the ege/estimate-gas-l1-fee branch March 16, 2026 11:57
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.

5 participants