diff --git a/crates/chain-state/src/cached_provider.rs b/crates/chain-state/src/cached_provider.rs index 379098372..31b7e4afa 100644 --- a/crates/chain-state/src/cached_provider.rs +++ b/crates/chain-state/src/cached_provider.rs @@ -51,7 +51,7 @@ pub struct CachedStateProvider { } impl CachedStateProvider { - /// Create a new CachedStateProvider + /// Create a new `CachedStateProvider` pub fn new( underlying: Box, state_cache: &'static dyn StateCache< diff --git a/crates/engine/tree/src/cache/mod.rs b/crates/engine/tree/src/cache/mod.rs index 0536189dd..1bd4045e9 100644 --- a/crates/engine/tree/src/cache/mod.rs +++ b/crates/engine/tree/src/cache/mod.rs @@ -1,3 +1,4 @@ +#[allow(clippy::type_complexity)] mod plain_state; pub use plain_state::CACHED_PLAIN_STATES; diff --git a/crates/engine/tree/src/cache/plain_state.rs b/crates/engine/tree/src/cache/plain_state.rs index b16502217..0a1ef1577 100644 --- a/crates/engine/tree/src/cache/plain_state.rs +++ b/crates/engine/tree/src/cache/plain_state.rs @@ -16,17 +16,17 @@ type AddressStorageKey = (Address, StorageKey); lazy_static! { /// Account cache - static ref ACCOUNT_CACHE: Cache = Cache::new(ACCOUNT_CACHE_SIZE); + static ref PLAIN_ACCOUNTS: Cache = Cache::new(ACCOUNT_CACHE_SIZE); /// Storage cache - static ref STORAGE_CACHE: Cache = Cache::new(STORAGE_CACHE_SIZE); + static ref PLAIN_STORAGES: Cache = Cache::new(STORAGE_CACHE_SIZE); /// Contract cache /// The size of contract is large and the hot contracts should be limited. - static ref CONTRACT_CACHE: Cache = Cache::new(CONTRACT_CACHE_SIZE); + static ref PLAIN_CONTRACTS: Cache = Cache::new(CONTRACT_CACHE_SIZE); /// Cached plain states - pub static ref CACHED_PLAIN_STATES: (&'static Cache, &'static Cache, &'static Cache) = (&ACCOUNT_CACHE, &STORAGE_CACHE, &CONTRACT_CACHE); + pub static ref CACHED_PLAIN_STATES: (&'static Cache, &'static Cache, &'static Cache) = (&PLAIN_ACCOUNTS, &PLAIN_STORAGES, &PLAIN_CONTRACTS); } // Implementing StateCache trait for CACHED_PLAIN_STATES @@ -94,10 +94,10 @@ pub(crate) fn write_plain_state(bundle: BundleState) { for (address, account_info) in &change_set.accounts { match account_info { None => { - ACCOUNT_CACHE.remove(address); + PLAIN_ACCOUNTS.remove(address); } Some(acc) => { - ACCOUNT_CACHE.insert( + PLAIN_ACCOUNTS.insert( *address, Account { nonce: acc.nonce, @@ -115,14 +115,13 @@ pub(crate) fn write_plain_state(bundle: BundleState) { if storage.wipe_storage { to_wipe = true; break; - } else { - for (k, v) in storage.storage.clone() { - STORAGE_CACHE.insert((storage.address, StorageKey::from(k)), v); - } + } + for (k, v) in storage.storage.clone() { + PLAIN_STORAGES.insert((storage.address, StorageKey::from(k)), v); } } if to_wipe { - STORAGE_CACHE.clear(); + PLAIN_STORAGES.clear(); } } diff --git a/crates/engine/tree/src/tree/metrics.rs b/crates/engine/tree/src/tree/metrics.rs index c5d699438..566e50d7e 100644 --- a/crates/engine/tree/src/tree/metrics.rs +++ b/crates/engine/tree/src/tree/metrics.rs @@ -1,8 +1,8 @@ +pub(crate) use metrics::histogram; use reth_metrics::{ metrics::{Counter, Gauge, Histogram}, Metrics, }; -pub(crate) use metrics::histogram as histogram; /// Metrics for the `EngineApi`. #[derive(Metrics)] diff --git a/crates/engine/tree/src/tree/mod.rs b/crates/engine/tree/src/tree/mod.rs index 24fa233c8..65c249ec1 100644 --- a/crates/engine/tree/src/tree/mod.rs +++ b/crates/engine/tree/src/tree/mod.rs @@ -1785,7 +1785,7 @@ where let elapsed = exec_time.elapsed(); debug!(target: "engine", elapsed=?elapsed, ?block_number, "Executed block"); metrics::histogram!("execution.total").record(elapsed.as_nanos() as f64); - + self.consensus.validate_block_post_execution( &block, PostExecutionInput::new(&output.receipts, &output.requests), @@ -1802,7 +1802,7 @@ where ) .into()) } - let elapsed=root_time.elapsed(); + let elapsed = root_time.elapsed(); debug!(target: "engine", elapsed=?elapsed, ?block_number, "Calculated state root"); metrics::histogram!("state-root.total").record(elapsed.as_nanos() as f64); diff --git a/crates/storage/provider/src/test_utils/mock.rs b/crates/storage/provider/src/test_utils/mock.rs index be328b1dd..6ea3a649a 100644 --- a/crates/storage/provider/src/test_utils/mock.rs +++ b/crates/storage/provider/src/test_utils/mock.rs @@ -603,11 +603,11 @@ impl StateRootProvider for MockEthProvider { fn state_root_from_nodes_caches_with_updates( &self, - nodes: TrieUpdates, - hashed_state: HashedPostState, - prefix_sets: TriePrefixSetsMut, - hashed_cache: &'static dyn TrieCache, - trie_cache: &'static dyn TrieCache< + _nodes: TrieUpdates, + _hashed_state: HashedPostState, + _prefix_sets: TriePrefixSetsMut, + _hashed_cache: &'static dyn TrieCache, + _trie_cache: &'static dyn TrieCache< Nibbles, BranchNodeCompact, (B256, Nibbles), diff --git a/crates/storage/provider/src/test_utils/noop.rs b/crates/storage/provider/src/test_utils/noop.rs index bdc765255..811ff08a1 100644 --- a/crates/storage/provider/src/test_utils/noop.rs +++ b/crates/storage/provider/src/test_utils/noop.rs @@ -354,11 +354,11 @@ impl StateRootProvider for NoopProvider { fn state_root_from_nodes_caches_with_updates( &self, - nodes: TrieUpdates, - hashed_state: HashedPostState, - prefix_sets: TriePrefixSetsMut, - hashed_cache: &'static dyn TrieCache, - trie_cache: &'static dyn TrieCache< + _nodes: TrieUpdates, + _hashed_state: HashedPostState, + _prefix_sets: TriePrefixSetsMut, + _hashed_cache: &'static dyn TrieCache, + _trie_cache: &'static dyn TrieCache< Nibbles, BranchNodeCompact, (B256, Nibbles), diff --git a/crates/trie/db/src/cached_trie_cursor.rs b/crates/trie/db/src/cached_trie_cursor.rs index 3f78907de..2972201f1 100644 --- a/crates/trie/db/src/cached_trie_cursor.rs +++ b/crates/trie/db/src/cached_trie_cursor.rs @@ -121,14 +121,14 @@ where return Ok(Some((key, result))) }; - return match self.cursor.seek(StoredNibbles(key))? { + match self.cursor.seek(StoredNibbles(key))? { Some(value) => { self.trie_cache.insert_account(value.0 .0.clone(), value.1.clone()); Ok(Some((value.0 .0, value.1))) } None => Ok(None), - }; + } } /// Move the cursor to the next entry in the account trie. @@ -136,7 +136,7 @@ where &mut self, last: Nibbles, ) -> Result, DatabaseError> { - let _ = self.cursor.seek(StoredNibbles(last.clone()))?; + let _ = self.cursor.seek(StoredNibbles(last))?; match self.cursor.next()? { Some(value) => { self.trie_cache.insert_account(value.0 .0.clone(), value.1.clone()); @@ -236,7 +236,7 @@ where return Ok(Some((key, result))) }; - return match self + match self .cursor .seek_by_key_subkey(self.hashed_address, StoredNibblesSubKey(key.clone()))? { @@ -251,7 +251,7 @@ where } } None => Ok(None), - }; + } } /// Seek a key in the storage trie that matches or is greater than the provided key. @@ -264,10 +264,7 @@ where return Ok(Some((key, result))) }; - return match self - .cursor - .seek_by_key_subkey(self.hashed_address, StoredNibblesSubKey(key))? - { + match self.cursor.seek_by_key_subkey(self.hashed_address, StoredNibblesSubKey(key))? { Some(value) => { let key = (self.hashed_address, value.nibbles.0.clone()); self.trie_cache.insert_storage(key, value.node.clone()); @@ -275,7 +272,7 @@ where Ok(Some((value.nibbles.0, value.node))) } None => Ok(None), - }; + } } /// Move the cursor to the next entry in the storage trie.