Skip to content

Fix/eth estimated gas returns 6x inflated gas#3358

Open
radhika-kapoor wants to merge 6 commits intotempoxyz:mainfrom
radhika-kapoor:fix/eth-estimatedGas-returns-6x-inflatedGas
Open

Fix/eth estimated gas returns 6x inflated gas#3358
radhika-kapoor wants to merge 6 commits intotempoxyz:mainfrom
radhika-kapoor:fix/eth-estimatedGas-returns-6x-inflatedGas

Conversation

@radhika-kapoor
Copy link
Copy Markdown

Summary

Closes #3178

eth_estimateGas was returning ~6x inflated gas (~293k instead of ~43k)
for TIP-20 transfers submitted using the calls array format with a
non-zero nonceKey.

Root cause

In crates/revm/src/handler.rs, the condition that charges the
new_account_cost (250,000 gas) for contract creation used
tx.kind().is_create() to detect a CREATE operation.

For AA transactions using the calls format, inner.to is None
(the destination lives inside the calls array), which caused
tx.kind() to return TxKind::Create even for plain transfers —
incorrectly triggering the 250k charge.

Fix

Replace tx.kind().is_create() with an inspection of the first entry
in aa_calls, which is the correct source of truth for AA transactions:

Non-AA transactions fall back to the original tx.kind().is_create() path,
so existing behaviour is unchanged.

TestCase Added
test_aa_tx_transfer_calls_format_no_extra_250k

Test plan

  • cargo test -p tempo-revm -p tempo-evm -> 114 passed, 0 failed
  • Regression test: test_aa_tx_transfer_calls_format_no_extra_250k passes
  • Manually verified via eth_estimateGas curl: calls format now returns 0xa9d4 (~43k) instead of 0x47b04 (~293k)
    ~43k Gas Breakdown
    • Base tx cost : 21,000 Gas
    • 2D nonce key init : ~5,000 Gas
    • Cold account access : 2600 Gas
    • Signature/calldata overhead : ~476 Gas
    • Intrinsic AA gas :14,400 -> AA transaction base overhead, not a named constant
    • Total : ~43,476

@klkvr klkvr force-pushed the fix/eth-estimatedGas-returns-6x-inflatedGas branch from fcf8426 to 5764df2 Compare March 31, 2026 17:06
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.

fix(rpc): eth_estimateGas returns ~6x inflated gas for calls array format

3 participants