diff --git a/crates/rpc/rpc/src/eth/revm_utils.rs b/crates/rpc/rpc/src/eth/revm_utils.rs index 2313e19fd6..b0a66e6619 100644 --- a/crates/rpc/rpc/src/eth/revm_utils.rs +++ b/crates/rpc/rpc/src/eth/revm_utils.rs @@ -2,7 +2,8 @@ use crate::eth::error::{EthApiError, EthResult, RpcInvalidTransactionError}; use reth_primitives::{ - AccessList, Address, TransactionSigned, TransactionSignedEcRecovered, TxHash, H256, U256, + constants::ETHEREUM_BLOCK_GAS_LIMIT, AccessList, Address, TransactionSigned, + TransactionSignedEcRecovered, TxHash, H256, U256, }; use reth_revm::env::{fill_tx_env, fill_tx_env_with_recovered}; use reth_rpc_types::{ @@ -236,10 +237,21 @@ where apply_block_overrides(*block_overrides, &mut env.block); } - if request_gas.is_none() && env.tx.gas_price > U256::ZERO { - trace!(target: "rpc::eth::call", ?env, "Applying gas limit cap"); - // no gas limit was provided in the request, so we need to cap the request's gas limit - cap_tx_gas_limit_with_caller_allowance(db, &mut env.tx)?; + if request_gas.is_none() { + // No gas limit was provided in the request, so we need to cap the transaction gas limit + if env.tx.gas_price > U256::ZERO { + // If gas price is specified, cap transaction gas limit with caller allowance + trace!(target: "rpc::eth::call", ?env, "Applying gas limit cap with caller allowance"); + cap_tx_gas_limit_with_caller_allowance(db, &mut env.tx)?; + } else { + // If no gas price is specified, use maximum allowed gas limit. The reason for this is + // that both Erigon and Geth use pre-configured gas cap even if it's possible + // to derive the gas limit from the block: + // https://github.com/ledgerwatch/erigon/blob/eae2d9a79cb70dbe30b3a6b79c436872e4605458/cmd/rpcdaemon/commands/trace_adhoc.go#L956 + // https://github.com/ledgerwatch/erigon/blob/eae2d9a79cb70dbe30b3a6b79c436872e4605458/eth/ethconfig/config.go#L94 + trace!(target: "rpc::eth::call", ?env, "Applying gas limit cap as the maximum gas limit"); + env.tx.gas_limit = ETHEREUM_BLOCK_GAS_LIMIT; + } } Ok(env)