From 59c6329ffa5f04bd70e1674c626a2dac569c1962 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 3 Oct 2024 16:57:03 +0200 Subject: [PATCH] fix: ensure the request's gas limit does not exceed the target gas limit (#11462) --- crates/rpc/rpc-eth-api/src/helpers/call.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/rpc/rpc-eth-api/src/helpers/call.rs b/crates/rpc/rpc-eth-api/src/helpers/call.rs index 8d34020d67..6189b69492 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/call.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/call.rs @@ -1107,6 +1107,14 @@ pub trait Call: LoadState + SpawnBlocking { DB: DatabaseRef, EthApiError: From<::Error>, { + // TODO(mattsse): cleanup, by not disabling gaslimit and instead use self.call_gas_limit + if request.gas > Some(gas_limit) { + // configured gas exceeds limit + return Err( + EthApiError::InvalidTransaction(RpcInvalidTransactionError::GasTooHigh).into() + ) + } + // we want to disable this in eth_call, since this is common practice used by other node // impls and providers cfg.disable_block_gas_limit = true;