From 6d4aab6d17389118c8e8e5cf4b4ef0f57bebc039 Mon Sep 17 00:00:00 2001 From: varun-doshi Date: Fri, 4 Oct 2024 00:37:36 +0530 Subject: [PATCH 1/4] cleaned up prepare_call_env() --- crates/rpc/rpc-eth-api/src/helpers/call.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/crates/rpc/rpc-eth-api/src/helpers/call.rs b/crates/rpc/rpc-eth-api/src/helpers/call.rs index 6189b69492a2..e16f1ccacdbc 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/call.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/call.rs @@ -256,7 +256,6 @@ pub trait EthCall: Call + LoadPendingBlock { )?; let block = block.ok_or(EthApiError::HeaderNotFound(target_block))?; - let gas_limit = self.call_gas_limit(); // we're essentially replaying the transactions in the block here, hence we need the // state that points to the beginning of the block, which is the state at @@ -306,7 +305,6 @@ pub trait EthCall: Call + LoadPendingBlock { cfg.clone(), block_env.clone(), tx, - gas_limit, &mut db, overrides, ) @@ -563,7 +561,6 @@ pub trait Call: LoadState + SpawnBlocking { cfg, block_env, request, - this.call_gas_limit(), &mut db, overrides, )?; @@ -1099,7 +1096,6 @@ pub trait Call: LoadState + SpawnBlocking { mut cfg: CfgEnvWithHandlerCfg, mut block: BlockEnv, mut request: TransactionRequest, - gas_limit: u64, db: &mut CacheDB, overrides: EvmOverrides, ) -> Result @@ -1108,7 +1104,7 @@ pub trait Call: LoadState + SpawnBlocking { EthApiError: From<::Error>, { // TODO(mattsse): cleanup, by not disabling gaslimit and instead use self.call_gas_limit - if request.gas > Some(gas_limit) { + if request.gas > Some(self.call_gas_limit()) { // configured gas exceeds limit return Err( EthApiError::InvalidTransaction(RpcInvalidTransactionError::GasTooHigh).into() @@ -1117,7 +1113,7 @@ pub trait Call: LoadState + SpawnBlocking { // 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; + // cfg.disable_block_gas_limit = true; // Disabled because eth_call is sometimes used with eoa senders // See @@ -1154,7 +1150,7 @@ pub trait Call: LoadState + SpawnBlocking { // trace!(target: "rpc::eth::call", ?env, "Applying gas limit cap as the maximum gas limit"); - env.tx.gas_limit = gas_limit; + env.tx.gas_limit = self.call_gas_limit(); } } From e85eb1e25d8ed0cd3e638e7cb4bb6faaf8078b82 Mon Sep 17 00:00:00 2001 From: varun-doshi Date: Fri, 4 Oct 2024 00:44:21 +0530 Subject: [PATCH 2/4] removed gas_limit params in other files --- crates/rpc/rpc/src/debug.rs | 1 - crates/rpc/rpc/src/trace.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index b47473c34270..6d6402dbefb5 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -570,7 +570,6 @@ where cfg.clone(), block_env.clone(), tx, - gas_limit, &mut db, overrides, )?; diff --git a/crates/rpc/rpc/src/trace.rs b/crates/rpc/rpc/src/trace.rs index 185383d811b7..54bc179814b1 100644 --- a/crates/rpc/rpc/src/trace.rs +++ b/crates/rpc/rpc/src/trace.rs @@ -168,7 +168,6 @@ where cfg.clone(), block_env.clone(), call, - gas_limit, &mut db, Default::default(), )?; From a622ebd00b9c8b806ca9280158a4938a1749cd6c Mon Sep 17 00:00:00 2001 From: varun-doshi Date: Fri, 4 Oct 2024 00:46:59 +0530 Subject: [PATCH 3/4] removed unused gas_limit --- crates/rpc/rpc/src/debug.rs | 1 - crates/rpc/rpc/src/trace.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/crates/rpc/rpc/src/debug.rs b/crates/rpc/rpc/src/debug.rs index 6d6402dbefb5..f4aba778f572 100644 --- a/crates/rpc/rpc/src/debug.rs +++ b/crates/rpc/rpc/src/debug.rs @@ -506,7 +506,6 @@ where let opts = opts.unwrap_or_default(); let block = block.ok_or(EthApiError::HeaderNotFound(target_block))?; let GethDebugTracingCallOptions { tracing_options, mut state_overrides, .. } = opts; - let gas_limit = self.inner.eth_api.call_gas_limit(); // we're essentially replaying the transactions in the block here, hence we need the state // that points to the beginning of the block, which is the state at the parent block diff --git a/crates/rpc/rpc/src/trace.rs b/crates/rpc/rpc/src/trace.rs index 54bc179814b1..e905ff685c86 100644 --- a/crates/rpc/rpc/src/trace.rs +++ b/crates/rpc/rpc/src/trace.rs @@ -153,7 +153,6 @@ where let at = block_id.unwrap_or(BlockId::pending()); let (cfg, block_env, at) = self.inner.eth_api.evm_env_at(at).await?; - let gas_limit = self.inner.eth_api.call_gas_limit(); let this = self.clone(); // execute all transactions on top of each other and record the traces self.eth_api() From 08cf6685f427731dc50cbb99678eea34195f4c4e Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Fri, 4 Oct 2024 10:02:15 +0200 Subject: [PATCH 4/4] chore: touchups --- crates/rpc/rpc-eth-api/src/helpers/call.rs | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/crates/rpc/rpc-eth-api/src/helpers/call.rs b/crates/rpc/rpc-eth-api/src/helpers/call.rs index e16f1ccacdbc..4d12450a1c7f 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/call.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/call.rs @@ -301,13 +301,7 @@ pub trait EthCall: Call + LoadPendingBlock { let overrides = EvmOverrides::new(state_overrides, block_overrides.clone()); let env = this - .prepare_call_env( - cfg.clone(), - block_env.clone(), - tx, - &mut db, - overrides, - ) + .prepare_call_env(cfg.clone(), block_env.clone(), tx, &mut db, overrides) .map(Into::into)?; let (res, _) = this.transact(&mut db, env)?; @@ -557,13 +551,7 @@ pub trait Call: LoadState + SpawnBlocking { let mut db = CacheDB::new(StateProviderDatabase::new(StateProviderTraitObjWrapper(&state))); - let env = this.prepare_call_env( - cfg, - block_env, - request, - &mut db, - overrides, - )?; + let env = this.prepare_call_env(cfg, block_env, request, &mut db, overrides)?; f(StateCacheDbRefMutWrapper(&mut db), env) }) @@ -1103,7 +1091,6 @@ 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(self.call_gas_limit()) { // configured gas exceeds limit return Err( @@ -1111,10 +1098,6 @@ pub trait Call: LoadState + SpawnBlocking { ) } - // 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; - // Disabled because eth_call is sometimes used with eoa senders // See cfg.disable_eip3607 = true;