From adbe6d9da0a338b265ed83edd3b6a7f748de9b4d Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 26 Jan 2026 13:39:15 +0100 Subject: [PATCH] fix(rpc): cap simulate_v1 default gas limit to RPC gas cap (#21402) Co-authored-by: Amp --- crates/rpc/rpc-eth-api/src/helpers/call.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/rpc/rpc-eth-api/src/helpers/call.rs b/crates/rpc/rpc-eth-api/src/helpers/call.rs index 359ce9fd0f..6e7bbdd389 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/call.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/call.rs @@ -152,7 +152,17 @@ pub trait EthCall: EstimateCall + Call + LoadPendingBlock + LoadBlock + FullEthA } if txs_without_gas_limit > 0 { - (block_gas_limit - total_specified_gas) / txs_without_gas_limit as u64 + // Per spec: "gasLimit: blockGasLimit - soFarUsedGasInBlock" + // Divide remaining gas equally among transactions without gas + let gas_per_tx = (block_gas_limit - total_specified_gas) / + txs_without_gas_limit as u64; + // Cap to RPC gas limit, matching spec behavior + let call_gas_limit = this.call_gas_limit(); + if call_gas_limit > 0 { + gas_per_tx.min(call_gas_limit) + } else { + gas_per_tx + } } else { 0 }