diff --git a/crates/rpc/rpc-eth-api/src/helpers/call.rs b/crates/rpc/rpc-eth-api/src/helpers/call.rs index 70c844775a4..19370c62b02 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/call.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/call.rs @@ -757,6 +757,9 @@ pub trait Call: DB: Database + DatabaseCommit + OverrideBlockHashes, EthApiError: From<::Error>, { + // track whether the request has a gas limit set + let request_has_gas_limit = request.as_ref().gas_limit().is_some(); + if let Some(requested_gas) = request.as_ref().gas_limit() { let global_gas_cap = self.call_gas_limit(); if global_gas_cap != 0 && global_gas_cap < requested_gas { @@ -800,7 +803,6 @@ pub trait Call: .map_err(EthApiError::from_state_overrides_err)?; } - let request_gas = request.as_ref().gas_limit(); let mut tx_env = self.create_txn_env(&evm_env, request, &mut *db)?; // lower the basefee to 0 to avoid breaking EVM invariants (basefee < gasprice): @@ -808,7 +810,7 @@ pub trait Call: evm_env.block_env.basefee = 0; } - if request_gas.is_none() { + if !request_has_gas_limit { // No gas limit was provided in the request, so we need to cap the transaction gas limit if tx_env.gas_price() > 0 { // If gas price is specified, cap transaction gas limit with caller allowance