Skip to content

Fix(evm): emit gas in ETHTransaction.toEstimate() when > 0 only#35

Merged
mrtnetwork merged 2 commits into
mrtnetwork:mainfrom
KabaDH:fix/eth-toestimate-gas-field
Jun 19, 2026
Merged

Fix(evm): emit gas in ETHTransaction.toEstimate() when > 0 only#35
mrtnetwork merged 2 commits into
mrtnetwork:mainfrom
KabaDH:fix/eth-toestimate-gas-field

Conversation

@KabaDH

@KabaDH KabaDH commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What

toEstimate() now adds a gas field to the eth_estimateGas payload when
gasLimit > 0. When gasLimit == 0 (auto-fill) the behavior is unchanged.

if (gasLimit > BigInt.zero) 'gas': '0x${gasLimit.toRadixString(16)}',

Why

Optimism: without gas, the node uses the block gas limit (~40M) as the upper bound.
Strict op-geth nodes run an affordability pre-check on that bound
(40M × gas_price > balance) and reject the request with intrinsic gas too high — breaking gas estimation for token transfers (legacy and EIP-1559). With
gas set, the bound becomes affordable and estimation succeeds.

Verified against live OP Sepolia nodes (identical payload):

Node without gas with gas
sepolia.optimism.io intrinsic gas too high 0xb173
optimism-sepolia-rpc.publicnode.com intrinsic gas too high 0xb173

Important

The error currently shows up on testnet (OP Sepolia): its op-geth already
ships the stricter gas estimator. On mainnet the node still silently caps the
bound, so there is no error yet. Once the network upgrade reaches mainnet, the
same behavior is expected to appear there too — so we land this fix ahead of
time, as insurance.

On every other geth network the change is safe: gas is added only when
gasLimit is explicitly set.

Tests

Tests added in test/etherum/transaction_test.dart.

KabaDH and others added 2 commits June 19, 2026 16:07
Assert toEstimate() emits `gas` when gasLimit > 0 (the field strict op-geth
nodes need to avoid "intrinsic gas too high") and omits it when gasLimit == 0
so the auto-fill payload is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@KabaDH

KabaDH commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi @mrtnetwork!
Could you please take a look at one more pull request when you have a chance? I'd really appreciate it. Thanks in advance!

@mrtnetwork mrtnetwork merged commit 66c306b into mrtnetwork:main Jun 19, 2026
1 check passed
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.

2 participants