From 0dc383f54ba350e7fb7fac1a1963521e1cb52f29 Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 29 Jun 2023 00:38:49 +0200 Subject: [PATCH 01/10] feat: add `rpc-gas-cap` cli arg --- bin/reth/src/args/rpc_server_args.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/reth/src/args/rpc_server_args.rs b/bin/reth/src/args/rpc_server_args.rs index c08aebe0e54d..d210d4836fa3 100644 --- a/bin/reth/src/args/rpc_server_args.rs +++ b/bin/reth/src/args/rpc_server_args.rs @@ -7,6 +7,7 @@ use clap::{ }; use futures::TryFutureExt; use reth_network_api::{NetworkInfo, Peers}; +use reth_primitives::constants::ETHEREUM_BLOCK_GAS_LIMIT; use reth_provider::{ BlockReaderIdExt, CanonStateSubscriptions, EvmEnvProvider, HeaderProvider, StateProviderFactory, }; @@ -47,6 +48,8 @@ pub(crate) const RPC_DEFAULT_MAX_RESPONSE_SIZE_MB: u32 = 100; pub(crate) const RPC_DEFAULT_MAX_CONNECTIONS: u32 = 100; /// Default number of incoming connections. pub(crate) const RPC_DEFAULT_MAX_TRACING_REQUESTS: u32 = 25; +/// Default max gas limit for `eth_call` and call tracing RPC methods. +pub(crate) const RPC_DEFAULT_GAS_CAP: u64 = ETHEREUM_BLOCK_GAS_LIMIT; /// Parameters for configuring the rpc more granularity via CLI #[derive(Debug, Args, PartialEq, Eq, Default)] @@ -147,6 +150,10 @@ pub struct RpcServerArgs { /// Max size for cached evm env data in megabytes. #[arg(long, default_value_t = DEFAULT_ENV_CACHE_SIZE_BYTES_MB)] pub env_cache_size: usize, + + /// Maximum gas limit for `eth_call` and call tracing RPC methods. + #[arg(long, default_value_t = RPC_DEFAULT_GAS_CAP)] + pub rpc_gas_cap: u64, } impl RpcServerArgs { From 6b8ec53569bb14eff1dc4a040e5373b33073e50a Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 29 Jun 2023 00:57:19 +0200 Subject: [PATCH 02/10] chore: move `rpc-gas-cap` argument in RPC section --- bin/reth/src/args/rpc_server_args.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/reth/src/args/rpc_server_args.rs b/bin/reth/src/args/rpc_server_args.rs index d210d4836fa3..c9bc4a568b85 100644 --- a/bin/reth/src/args/rpc_server_args.rs +++ b/bin/reth/src/args/rpc_server_args.rs @@ -135,6 +135,10 @@ pub struct RpcServerArgs { #[arg(long, value_name = "COUNT", default_value_t = RPC_DEFAULT_MAX_TRACING_REQUESTS)] pub rpc_max_tracing_requests: u32, + /// Maximum gas limit for `eth_call` and call tracing RPC methods. + #[arg(long, default_value_t = RPC_DEFAULT_GAS_CAP)] + pub rpc_gas_cap: u64, + /// Gas price oracle configuration. #[clap(flatten)] pub gas_price_oracle: GasPriceOracleArgs, @@ -150,10 +154,6 @@ pub struct RpcServerArgs { /// Max size for cached evm env data in megabytes. #[arg(long, default_value_t = DEFAULT_ENV_CACHE_SIZE_BYTES_MB)] pub env_cache_size: usize, - - /// Maximum gas limit for `eth_call` and call tracing RPC methods. - #[arg(long, default_value_t = RPC_DEFAULT_GAS_CAP)] - pub rpc_gas_cap: u64, } impl RpcServerArgs { From accf395e70cc845cab353e38c2100494502245ba Mon Sep 17 00:00:00 2001 From: leovct Date: Thu, 29 Jun 2023 00:59:52 +0200 Subject: [PATCH 03/10] doc: add `rpc-gas-cap` arg to `reth node` in book --- book/cli/node.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/book/cli/node.md b/book/cli/node.md index f68b16b5d6c6..234a481e5d74 100644 --- a/book/cli/node.md +++ b/book/cli/node.md @@ -155,6 +155,9 @@ Rpc: --rpc-max-tracing-requests Maximum number of concurrent tracing requests. + + --rpc-gas-cap + Maximum gas limit for `eth_call` and call tracing RPC methods --gas-price-oracle Gas price oracle configuration. From cdfd9f1174e0a9c0645ff469c21cdacaf60270e6 Mon Sep 17 00:00:00 2001 From: leovct Date: Tue, 4 Jul 2023 09:57:39 +0200 Subject: [PATCH 04/10] chore: add "rpc.gascap" alias --- bin/reth/src/args/rpc_server_args.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/reth/src/args/rpc_server_args.rs b/bin/reth/src/args/rpc_server_args.rs index c9bc4a568b85..5803d6ed94b5 100644 --- a/bin/reth/src/args/rpc_server_args.rs +++ b/bin/reth/src/args/rpc_server_args.rs @@ -136,7 +136,7 @@ pub struct RpcServerArgs { pub rpc_max_tracing_requests: u32, /// Maximum gas limit for `eth_call` and call tracing RPC methods. - #[arg(long, default_value_t = RPC_DEFAULT_GAS_CAP)] + #[arg(long = "rpc.gascap", default_value_t = RPC_DEFAULT_GAS_CAP)] pub rpc_gas_cap: u64, /// Gas price oracle configuration. From 86de00ac1afa46bc3304a83eb312d982e2de913c Mon Sep 17 00:00:00 2001 From: leovct Date: Tue, 4 Jul 2023 09:59:50 +0200 Subject: [PATCH 05/10] chore: update arg value name --- bin/reth/src/args/rpc_server_args.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/reth/src/args/rpc_server_args.rs b/bin/reth/src/args/rpc_server_args.rs index 5803d6ed94b5..b2ef161d6662 100644 --- a/bin/reth/src/args/rpc_server_args.rs +++ b/bin/reth/src/args/rpc_server_args.rs @@ -136,7 +136,7 @@ pub struct RpcServerArgs { pub rpc_max_tracing_requests: u32, /// Maximum gas limit for `eth_call` and call tracing RPC methods. - #[arg(long = "rpc.gascap", default_value_t = RPC_DEFAULT_GAS_CAP)] + #[arg(long = "rpc.gascap", value_name = "GAS_CAP", default_value_t = RPC_DEFAULT_GAS_CAP)] pub rpc_gas_cap: u64, /// Gas price oracle configuration. From c8f3e159e4173d92b4169a1967607c6552ec6933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Mon, 10 Jul 2023 12:25:16 +0200 Subject: [PATCH 06/10] add `rpc.gascap` alias Co-authored-by: Alexey Shekhirin --- bin/reth/src/args/rpc_server_args.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/reth/src/args/rpc_server_args.rs b/bin/reth/src/args/rpc_server_args.rs index b2ef161d6662..00e5e04557bf 100644 --- a/bin/reth/src/args/rpc_server_args.rs +++ b/bin/reth/src/args/rpc_server_args.rs @@ -136,7 +136,7 @@ pub struct RpcServerArgs { pub rpc_max_tracing_requests: u32, /// Maximum gas limit for `eth_call` and call tracing RPC methods. - #[arg(long = "rpc.gascap", value_name = "GAS_CAP", default_value_t = RPC_DEFAULT_GAS_CAP)] + #[arg(long, alias = "rpc.gascap", value_name = "GAS_CAP", default_value_t = RPC_DEFAULT_GAS_CAP)] pub rpc_gas_cap: u64, /// Gas price oracle configuration. From e5cec58a4dd32d43eec46f97bce7ac480fd6301e Mon Sep 17 00:00:00 2001 From: leovct Date: Mon, 10 Jul 2023 12:58:31 +0200 Subject: [PATCH 07/10] feat: add `rpc_gas_cap` to `EthConfig` --- crates/rpc/rpc-builder/src/eth.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/rpc/rpc-builder/src/eth.rs b/crates/rpc/rpc-builder/src/eth.rs index 907740b76958..6c8167ac5572 100644 --- a/crates/rpc/rpc-builder/src/eth.rs +++ b/crates/rpc/rpc-builder/src/eth.rs @@ -1,3 +1,4 @@ +use reth_primitives::constants::ETHEREUM_BLOCK_GAS_LIMIT; use reth_rpc::{ eth::{ cache::{EthStateCache, EthStateCacheConfig}, @@ -37,6 +38,8 @@ pub struct EthConfig { pub max_tracing_requests: u32, /// Maximum number of logs that can be returned in a single response in `eth_getLogs` calls. pub max_logs_per_response: usize, + /// Maximum gas limit for `eth_call` and call tracing RPC methods. + pub rpc_gas_cap: u64, } impl Default for EthConfig { @@ -46,6 +49,7 @@ impl Default for EthConfig { gas_oracle: GasPriceOracleConfig::default(), max_tracing_requests: DEFAULT_MAX_TRACING_REQUESTS, max_logs_per_response: DEFAULT_MAX_LOGS_IN_RESPONSE, + rpc_gas_cap: ETHEREUM_BLOCK_GAS_LIMIT, } } } @@ -74,4 +78,10 @@ impl EthConfig { self.max_logs_per_response = max_logs; self } + + /// Configures the maximum gas limit for `eth_call` and call tracing RPC methods + pub fn rpc_gas_cap(mut self, rpc_gas_cap: u64) -> Self { + self.rpc_gas_cap = rpc_gas_cap; + self + } } From 92f2fb5e4e0c612226ffbb1b29aac5c797877eda Mon Sep 17 00:00:00 2001 From: leovct Date: Mon, 10 Jul 2023 13:02:32 +0200 Subject: [PATCH 08/10] feat: add `gas_cap` to `EthApi` --- crates/rpc/rpc/src/eth/api/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/crates/rpc/rpc/src/eth/api/mod.rs b/crates/rpc/rpc/src/eth/api/mod.rs index 227e14cefb6e..7ab8e0def79c 100644 --- a/crates/rpc/rpc/src/eth/api/mod.rs +++ b/crates/rpc/rpc/src/eth/api/mod.rs @@ -78,6 +78,7 @@ where network: Network, eth_cache: EthStateCache, gas_oracle: GasPriceOracle, + gas_cap: u64, ) -> Self { Self::with_spawner( provider, @@ -85,6 +86,7 @@ where network, eth_cache, gas_oracle, + gas_cap, Box::::default(), ) } @@ -96,6 +98,7 @@ where network: Network, eth_cache: EthStateCache, gas_oracle: GasPriceOracle, + gas_cap: u64, task_spawner: Box, ) -> Self { // get the block number of the latest block @@ -113,6 +116,7 @@ where signers: Default::default(), eth_cache, gas_oracle, + gas_cap, starting_block: U256::from(latest_block), task_spawner, }; @@ -149,6 +153,11 @@ where &self.inner.gas_oracle } + // Returns the gas cap + pub(crate) fn rpc_cap(&self) -> &u64 { + &self.inner.gas_cap + } + /// Returns the inner `Provider` pub fn provider(&self) -> &Provider { &self.inner.provider @@ -280,6 +289,8 @@ struct EthApiInner { eth_cache: EthStateCache, /// The async gas oracle frontend for gas price suggestions gas_oracle: GasPriceOracle, + // TODO + gas_cap: u64, /// The block number at which the node started starting_block: U256, /// The type that can spawn tasks which would otherwise block. From 63d64478ec5cc01034ae5cd7d8059a53c5e1f9f2 Mon Sep 17 00:00:00 2001 From: leovct Date: Mon, 10 Jul 2023 13:24:06 +0200 Subject: [PATCH 09/10] fix: test --- crates/rpc/rpc/src/eth/api/state.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/rpc/rpc/src/eth/api/state.rs b/crates/rpc/rpc/src/eth/api/state.rs index 281198be0796..bd958482c48b 100644 --- a/crates/rpc/rpc/src/eth/api/state.rs +++ b/crates/rpc/rpc/src/eth/api/state.rs @@ -164,6 +164,7 @@ mod tests { (), cache.clone(), GasPriceOracle::new(NoopProvider::default(), Default::default(), cache), + ETHEREUM_BLOCK_GAS_LIMIT, ); let address = Address::random(); let storage = eth_api.storage_at(address, U256::ZERO.into(), None).unwrap(); From 469e173d6dcd50c4f7a92af5835d2cc361fb1059 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 17 Jul 2023 11:27:05 +0200 Subject: [PATCH 10/10] feat: rpc gas cap finishing touches --- bin/reth/src/args/rpc_server_args.rs | 27 +++++++++++++++++-- book/cli/node.md | 2 +- crates/blockchain-tree/src/block_indices.rs | 4 +-- crates/blockchain-tree/src/blockchain_tree.rs | 4 ++- crates/net/eth-wire/src/p2pstream.rs | 4 ++- crates/net/nat/src/lib.rs | 6 +++-- crates/net/network/src/eth_requests.rs | 4 ++- crates/net/network/src/peers/manager.rs | 10 ++++--- crates/rpc/rpc-builder/src/auth.rs | 2 ++ crates/rpc/rpc-builder/src/lib.rs | 1 + crates/rpc/rpc/src/eth/api/fees.rs | 3 ++- crates/rpc/rpc/src/eth/api/mod.rs | 9 ++++--- crates/rpc/rpc/src/eth/api/server.rs | 5 ++-- crates/rpc/rpc/src/eth/api/state.rs | 3 ++- crates/rpc/rpc/src/eth/api/transactions.rs | 3 ++- crates/storage/provider/src/chain.rs | 4 ++- crates/trie/src/walker.rs | 6 ++--- 17 files changed, 69 insertions(+), 28 deletions(-) diff --git a/bin/reth/src/args/rpc_server_args.rs b/bin/reth/src/args/rpc_server_args.rs index 00e5e04557bf..5da1094ad401 100644 --- a/bin/reth/src/args/rpc_server_args.rs +++ b/bin/reth/src/args/rpc_server_args.rs @@ -2,7 +2,7 @@ use crate::args::GasPriceOracleArgs; use clap::{ - builder::{PossibleValue, TypedValueParser}, + builder::{PossibleValue, RangedU64ValueParser, TypedValueParser}, Arg, Args, Command, }; use futures::TryFutureExt; @@ -48,6 +48,7 @@ pub(crate) const RPC_DEFAULT_MAX_RESPONSE_SIZE_MB: u32 = 100; pub(crate) const RPC_DEFAULT_MAX_CONNECTIONS: u32 = 100; /// Default number of incoming connections. pub(crate) const RPC_DEFAULT_MAX_TRACING_REQUESTS: u32 = 25; + /// Default max gas limit for `eth_call` and call tracing RPC methods. pub(crate) const RPC_DEFAULT_GAS_CAP: u64 = ETHEREUM_BLOCK_GAS_LIMIT; @@ -136,7 +137,13 @@ pub struct RpcServerArgs { pub rpc_max_tracing_requests: u32, /// Maximum gas limit for `eth_call` and call tracing RPC methods. - #[arg(long, alias = "rpc.gascap", value_name = "GAS_CAP", default_value_t = RPC_DEFAULT_GAS_CAP)] + #[arg( + long, + alias = "rpc.gascap", + value_name = "GAS_CAP", + value_parser = RangedU64ValueParser::::new().range(1..), + default_value_t = RPC_DEFAULT_GAS_CAP + )] pub rpc_gas_cap: u64, /// Gas price oracle configuration. @@ -196,6 +203,7 @@ impl RpcServerArgs { pub fn eth_config(&self) -> EthConfig { EthConfig::default() .max_tracing_requests(self.rpc_max_tracing_requests) + .rpc_gas_cap(self.rpc_gas_cap) .gpo_config(self.gas_price_oracle_config()) } @@ -515,6 +523,21 @@ mod tests { args: T, } + #[test] + fn test_rpc_gas_cap() { + let args = CommandParser::::parse_from(["reth"]).args; + let config = args.eth_config(); + assert_eq!(config.rpc_gas_cap, RPC_DEFAULT_GAS_CAP); + + let args = + CommandParser::::parse_from(["reth", "--rpc.gascap", "1000"]).args; + let config = args.eth_config(); + assert_eq!(config.rpc_gas_cap, 1000); + + let args = CommandParser::::try_parse_from(["reth", "--rpc.gascap", "0"]); + assert!(args.is_err()); + } + #[test] fn test_rpc_server_args_parser() { let args = diff --git a/book/cli/node.md b/book/cli/node.md index 234a481e5d74..8f4411ec7b36 100644 --- a/book/cli/node.md +++ b/book/cli/node.md @@ -156,7 +156,7 @@ Rpc: --rpc-max-tracing-requests Maximum number of concurrent tracing requests. - --rpc-gas-cap + --rpc.gascap Maximum gas limit for `eth_call` and call tracing RPC methods --gas-price-oracle diff --git a/crates/blockchain-tree/src/block_indices.rs b/crates/blockchain-tree/src/block_indices.rs index 54076974a7a6..b4c8e7548c4e 100644 --- a/crates/blockchain-tree/src/block_indices.rs +++ b/crates/blockchain-tree/src/block_indices.rs @@ -177,7 +177,7 @@ impl BlockIndices { } break }; - let Some(new_block_value) = new_hash else { + let Some(new_block_value) = new_hash else { // Old canonical chain had more block than new chain. // remove all present block. // this is mostly not going to happen as reorg should make new chain in Tree. @@ -185,7 +185,7 @@ impl BlockIndices { removed.push(rem); old_hash = old_hashes.next(); } - break; + break }; // compare old and new canonical block number match new_block_value.0.cmp(&old_block_value.0) { diff --git a/crates/blockchain-tree/src/blockchain_tree.rs b/crates/blockchain-tree/src/blockchain_tree.rs index d951939f4986..b7aa4c63d4ff 100644 --- a/crates/blockchain-tree/src/blockchain_tree.rs +++ b/crates/blockchain-tree/src/blockchain_tree.rs @@ -903,7 +903,9 @@ impl BlockchainTree let Some(chain_id) = self.block_indices.get_blocks_chain_id(block_hash) else { warn!(target: "blockchain_tree", ?block_hash, "Block hash not found in block indices"); // TODO: better error - return Err(BlockExecutionError::BlockHashNotFoundInChain { block_hash: *block_hash }.into()) + return Err( + BlockExecutionError::BlockHashNotFoundInChain { block_hash: *block_hash }.into() + ) }; let chain = self.chains.remove(&chain_id).expect("To be present"); diff --git a/crates/net/eth-wire/src/p2pstream.rs b/crates/net/eth-wire/src/p2pstream.rs index 55b70877f51c..bc1e34a48381 100644 --- a/crates/net/eth-wire/src/p2pstream.rs +++ b/crates/net/eth-wire/src/p2pstream.rs @@ -533,7 +533,9 @@ where match ready!(this.inner.as_mut().poll_flush(cx)) { Err(err) => return Poll::Ready(Err(err.into())), Ok(()) => { - let Some(message) = this.outgoing_messages.pop_front() else { return Poll::Ready(Ok(())) }; + let Some(message) = this.outgoing_messages.pop_front() else { + return Poll::Ready(Ok(())) + }; if let Err(err) = this.inner.as_mut().start_send(message) { return Poll::Ready(Err(err.into())) } diff --git a/crates/net/nat/src/lib.rs b/crates/net/nat/src/lib.rs index 1822dc7c7322..06e2d4daa043 100644 --- a/crates/net/nat/src/lib.rs +++ b/crates/net/nat/src/lib.rs @@ -92,9 +92,11 @@ impl FromStr for NatResolver { "none" => NatResolver::None, "publicip" | "public-ip" => NatResolver::PublicIp, s => { - let Some(ip) = s.strip_prefix("extip:") else { return Err(ParseNatResolverError::UnknownVariant(format!( + let Some(ip) = s.strip_prefix("extip:") else { + return Err(ParseNatResolverError::UnknownVariant(format!( "Unknown Nat Resolver: {s}" - ))) }; + ))) + }; NatResolver::ExternalIp(ip.parse::()?) } }; diff --git a/crates/net/network/src/eth_requests.rs b/crates/net/network/src/eth_requests.rs index 09fc31129c31..7cb4db72b37b 100644 --- a/crates/net/network/src/eth_requests.rs +++ b/crates/net/network/src/eth_requests.rs @@ -81,7 +81,9 @@ where let mut block: BlockHashOrNumber = match start_block { BlockHashOrNumber::Hash(start) => start.into(), BlockHashOrNumber::Number(num) => { - let Some(hash) = self.client.block_hash(num).unwrap_or_default() else { return headers }; + let Some(hash) = self.client.block_hash(num).unwrap_or_default() else { + return headers + }; hash.into() } }; diff --git a/crates/net/network/src/peers/manager.rs b/crates/net/network/src/peers/manager.rs index 0b6bb854b819..63a89a24682c 100644 --- a/crates/net/network/src/peers/manager.rs +++ b/crates/net/network/src/peers/manager.rs @@ -1139,9 +1139,7 @@ impl PeersConfig { self, optional_file: Option>, ) -> Result { - let Some(file_path) = optional_file else { - return Ok(self) - }; + let Some(file_path) = optional_file else { return Ok(self) }; let reader = match std::fs::File::open(file_path.as_ref()) { Ok(file) => io::BufReader::new(file), Err(e) if e.kind() == ErrorKind::NotFound => return Ok(self), @@ -1875,7 +1873,11 @@ mod test { let mut peer_manager = PeersManager::new(config); peer_manager.on_incoming_session_established(given_peer_id, socket_addr); - let Some(PeerAction::DisconnectBannedIncoming { peer_id }) = peer_manager.queued_actions.pop_front() else { panic!() }; + let Some(PeerAction::DisconnectBannedIncoming { peer_id }) = + peer_manager.queued_actions.pop_front() + else { + panic!() + }; assert_eq!(peer_id, given_peer_id) } diff --git a/crates/rpc/rpc-builder/src/auth.rs b/crates/rpc/rpc-builder/src/auth.rs index e44911d4bbf2..2e415e0a7695 100644 --- a/crates/rpc/rpc-builder/src/auth.rs +++ b/crates/rpc/rpc-builder/src/auth.rs @@ -2,6 +2,7 @@ use crate::{ constants, error::{RpcError, ServerKind}, eth::DEFAULT_MAX_LOGS_IN_RESPONSE, + EthConfig, }; use hyper::header::AUTHORIZATION; pub use jsonrpsee::server::ServerBuilder; @@ -61,6 +62,7 @@ where network, eth_cache.clone(), gas_oracle, + EthConfig::default().rpc_gas_cap, Box::new(executor.clone()), ); let eth_filter = EthFilter::new( diff --git a/crates/rpc/rpc-builder/src/lib.rs b/crates/rpc/rpc-builder/src/lib.rs index 38fbb76f4f51..c7d31c8a2d04 100644 --- a/crates/rpc/rpc-builder/src/lib.rs +++ b/crates/rpc/rpc-builder/src/lib.rs @@ -899,6 +899,7 @@ where self.network.clone(), cache.clone(), gas_oracle, + self.config.eth.rpc_gas_cap, executor.clone(), ); let filter = EthFilter::new( diff --git a/crates/rpc/rpc/src/eth/api/fees.rs b/crates/rpc/rpc/src/eth/api/fees.rs index 5122fb0627fb..bdd30a0ac3fb 100644 --- a/crates/rpc/rpc/src/eth/api/fees.rs +++ b/crates/rpc/rpc/src/eth/api/fees.rs @@ -64,7 +64,8 @@ where } let Some(end_block) = self.provider().block_number_for_id(newest_block.into())? else { - return Err(EthApiError::UnknownBlockNumber) }; + return Err(EthApiError::UnknownBlockNumber) + }; // Check that we would not be querying outside of genesis if end_block < block_count { diff --git a/crates/rpc/rpc/src/eth/api/mod.rs b/crates/rpc/rpc/src/eth/api/mod.rs index 7ab8e0def79c..f36ddf1b166b 100644 --- a/crates/rpc/rpc/src/eth/api/mod.rs +++ b/crates/rpc/rpc/src/eth/api/mod.rs @@ -153,9 +153,10 @@ where &self.inner.gas_oracle } - // Returns the gas cap - pub(crate) fn rpc_cap(&self) -> &u64 { - &self.inner.gas_cap + /// Returns the configured gas limit cap for `eth_call` and tracing related calls + #[allow(unused)] + pub(crate) fn gas_cap(&self) -> u64 { + self.inner.gas_cap } /// Returns the inner `Provider` @@ -289,7 +290,7 @@ struct EthApiInner { eth_cache: EthStateCache, /// The async gas oracle frontend for gas price suggestions gas_oracle: GasPriceOracle, - // TODO + /// Maximum gas limit for `eth_call` and call tracing RPC methods. gas_cap: u64, /// The block number at which the node started starting_block: U256, diff --git a/crates/rpc/rpc/src/eth/api/server.rs b/crates/rpc/rpc/src/eth/api/server.rs index acca88323cdc..f99f8c15ab7b 100644 --- a/crates/rpc/rpc/src/eth/api/server.rs +++ b/crates/rpc/rpc/src/eth/api/server.rs @@ -398,8 +398,8 @@ mod tests { use reth_interfaces::test_utils::{generators, generators::Rng}; use reth_network_api::test_utils::NoopNetwork; use reth_primitives::{ - basefee::calculate_next_block_base_fee, Block, BlockNumberOrTag, Header, TransactionSigned, - H256, U256, + basefee::calculate_next_block_base_fee, constants::ETHEREUM_BLOCK_GAS_LIMIT, Block, + BlockNumberOrTag, Header, TransactionSigned, H256, U256, }; use reth_provider::{ test_utils::{MockEthProvider, NoopProvider}, @@ -427,6 +427,7 @@ mod tests { NoopNetwork, cache.clone(), GasPriceOracle::new(provider, Default::default(), cache), + ETHEREUM_BLOCK_GAS_LIMIT, ) } diff --git a/crates/rpc/rpc/src/eth/api/state.rs b/crates/rpc/rpc/src/eth/api/state.rs index bd958482c48b..0930bf0b6c50 100644 --- a/crates/rpc/rpc/src/eth/api/state.rs +++ b/crates/rpc/rpc/src/eth/api/state.rs @@ -147,7 +147,7 @@ where mod tests { use super::*; use crate::eth::{cache::EthStateCache, gas_oracle::GasPriceOracle}; - use reth_primitives::{StorageKey, StorageValue}; + use reth_primitives::{constants::ETHEREUM_BLOCK_GAS_LIMIT, StorageKey, StorageValue}; use reth_provider::test_utils::{ExtendedAccount, MockEthProvider, NoopProvider}; use reth_transaction_pool::test_utils::testing_pool; use std::collections::HashMap; @@ -185,6 +185,7 @@ mod tests { (), cache.clone(), GasPriceOracle::new(mock_provider, Default::default(), cache), + ETHEREUM_BLOCK_GAS_LIMIT, ); let storage_key: U256 = storage_key.into(); diff --git a/crates/rpc/rpc/src/eth/api/transactions.rs b/crates/rpc/rpc/src/eth/api/transactions.rs index fe4eca4be8f8..4bf387693404 100644 --- a/crates/rpc/rpc/src/eth/api/transactions.rs +++ b/crates/rpc/rpc/src/eth/api/transactions.rs @@ -893,7 +893,7 @@ mod tests { EthApi, }; use reth_network_api::test_utils::NoopNetwork; - use reth_primitives::{hex_literal::hex, Bytes}; + use reth_primitives::{constants::ETHEREUM_BLOCK_GAS_LIMIT, hex_literal::hex, Bytes}; use reth_provider::test_utils::NoopProvider; use reth_transaction_pool::{test_utils::testing_pool, TransactionPool}; @@ -911,6 +911,7 @@ mod tests { noop_network_provider, cache.clone(), GasPriceOracle::new(noop_provider, Default::default(), cache), + ETHEREUM_BLOCK_GAS_LIMIT, ); // https://etherscan.io/tx/0xa694b71e6c128a2ed8e2e0f6770bddbe52e3bb8f10e8472f9a79ab81497a8b5d diff --git a/crates/storage/provider/src/chain.rs b/crates/storage/provider/src/chain.rs index 605caadedd90..02ca47be6809 100644 --- a/crates/storage/provider/src/chain.rs +++ b/crates/storage/provider/src/chain.rs @@ -192,7 +192,9 @@ impl Chain { let chain_tip = *self.blocks.last_entry().expect("chain is never empty").key(); let block_number = match split_at { SplitAt::Hash(block_hash) => { - let Some(block_number) = self.block_number(block_hash) else { return ChainSplit::NoSplitPending(self)}; + let Some(block_number) = self.block_number(block_hash) else { + return ChainSplit::NoSplitPending(self) + }; // If block number is same as tip whole chain is becoming canonical. if block_number == chain_tip { return ChainSplit::NoSplitCanonical(self) diff --git a/crates/trie/src/walker.rs b/crates/trie/src/walker.rs index f10c1cee2275..3ccab8ba6e51 100644 --- a/crates/trie/src/walker.rs +++ b/crates/trie/src/walker.rs @@ -146,7 +146,7 @@ impl<'a, K: Key + From>, C: TrieCursor> TrieWalker<'a, K, C> { let Some((key, node)) = self.node(false)? else { // If no next node is found, clear the stack. self.stack.clear(); - return Ok(()); + return Ok(()) }; // Overwrite the root node's first nibble @@ -178,9 +178,7 @@ impl<'a, K: Key + From>, C: TrieCursor> TrieWalker<'a, K, C> { &mut self, allow_root_to_child_nibble: bool, ) -> Result<(), DatabaseError> { - let Some(subnode) = self.stack.last_mut() else { - return Ok(()); - }; + let Some(subnode) = self.stack.last_mut() else { return Ok(()) }; // Check if the walker needs to backtrack to the previous level in the trie during its // traversal.