diff --git a/Cargo.toml b/Cargo.toml index 325fb6655..38bd71e55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -188,6 +188,7 @@ raft = [] [lints.clippy] clone_on_ref_ptr = "warn" cloned_instead_of_copied = "warn" +default_trait_access = "warn" disallowed_names = "warn" manual_let_else = "warn" semicolon_if_nothing_returned = "warn" diff --git a/src/eth/consensus/mod.rs b/src/eth/consensus/mod.rs index 7096fe18c..d9dcee3cc 100644 --- a/src/eth/consensus/mod.rs +++ b/src/eth/consensus/mod.rs @@ -36,7 +36,7 @@ use crate::infra::BlockchainClient; use crate::GlobalState; pub mod append_entry { - #![allow(clippy::wildcard_imports)] + #![allow(clippy::default_trait_access, clippy::wildcard_imports)] tonic::include_proto!("append_entry"); } #[allow(unused_imports)] diff --git a/src/eth/executor/evm.rs b/src/eth/executor/evm.rs index a5f062fc3..3a0a765ff 100644 --- a/src/eth/executor/evm.rs +++ b/src/eth/executor/evm.rs @@ -1,4 +1,5 @@ use std::cmp::min; +use std::collections::HashMap; use std::sync::Arc; use anyhow::anyhow; @@ -199,17 +200,17 @@ impl RevmSession { pub fn new(storage: Arc) -> Self { Self { storage, - input: Default::default(), - storage_changes: Default::default(), - metrics: Default::default(), + input: EvmInput::default(), + storage_changes: HashMap::default(), + metrics: EvmExecutionMetrics::default(), } } /// Resets the session to be used with a new transaction. pub fn reset(&mut self, input: EvmInput) { self.input = input; - self.storage_changes = Default::default(); - self.metrics = Default::default(); + self.storage_changes = HashMap::default(); + self.metrics = EvmExecutionMetrics::default(); } } diff --git a/src/eth/primitives/block_header.rs b/src/eth/primitives/block_header.rs index 033360afb..1ceea9573 100644 --- a/src/eth/primitives/block_header.rs +++ b/src/eth/primitives/block_header.rs @@ -11,6 +11,7 @@ use hex_literal::hex; use jsonrpsee::SubscriptionMessage; use crate::alias::EthersBlockVoid; +use crate::alias::EthersBytes; use crate::eth::consensus::append_entry; use crate::eth::primitives::logs_bloom::LogsBloom; use crate::eth::primitives::Address; @@ -130,7 +131,7 @@ impl Dummy for BlockHeader { hash: faker.fake_with_rng(rng), transactions_root: faker.fake_with_rng(rng), gas_used: faker.fake_with_rng(rng), - bloom: Default::default(), + bloom: LogsBloom::default(), timestamp: faker.fake_with_rng(rng), parent_hash: faker.fake_with_rng(rng), gas_limit: faker.fake_with_rng(rng), @@ -160,7 +161,7 @@ where // block: identifiers hash: Some(header.hash.into()), number: Some(header.number.into()), - mix_hash: Some(Default::default()), + mix_hash: Some(H256::default()), // block: relation with other blocks uncles_hash: HASH_EMPTY_UNCLES.into(), @@ -194,9 +195,9 @@ where // data size: Some(u64::from(header.size).into()), logs_bloom: Some(*header.bloom), - extra_data: Default::default(), + extra_data: EthersBytes::default(), state_root: header.state_root.into(), - seal_fields: Default::default(), + seal_fields: Vec::default(), other: OtherFields::default(), } } diff --git a/src/eth/storage/inmemory/inmemory_permanent.rs b/src/eth/storage/inmemory/inmemory_permanent.rs index 9dacc303b..e78d80314 100644 --- a/src/eth/storage/inmemory/inmemory_permanent.rs +++ b/src/eth/storage/inmemory/inmemory_permanent.rs @@ -121,7 +121,7 @@ impl Default for InMemoryPermanentStorage { tracing::info!("creating inmemory permanent storage"); Self { state: RwLock::new(InMemoryPermanentStorageState::default()), - block_number: Default::default(), + block_number: AtomicU64::default(), } } } @@ -158,8 +158,9 @@ impl PermanentStorage for InMemoryPermanentStorage { fn read_slot(&self, address: &Address, index: &SlotIndex, point_in_time: &StoragePointInTime) -> anyhow::Result> { let state = self.lock_read(); + let Some(account) = state.accounts.get(address) else { - return Ok(Default::default()); + return Ok(None); }; match account.slots.get(index) { @@ -333,7 +334,7 @@ impl InMemoryPermanentAccount { nonce: InMemoryHistory::new_at_zero(Nonce::ZERO), bytecode: InMemoryHistory::new_at_zero(None), code_hash: InMemoryHistory::new_at_zero(CodeHash::default()), - slots: Default::default(), + slots: HashMap::default(), } } diff --git a/src/eth/storage/inmemory/inmemory_temporary.rs b/src/eth/storage/inmemory/inmemory_temporary.rs index 0f20b8f6d..d7b3a5d6b 100644 --- a/src/eth/storage/inmemory/inmemory_temporary.rs +++ b/src/eth/storage/inmemory/inmemory_temporary.rs @@ -106,7 +106,7 @@ impl InMemoryTemporaryAccount { fn new(address: Address) -> Self { Self { info: Account::new_empty(address), - slots: Default::default(), + slots: HashMap::default(), } } } diff --git a/src/eth/storage/rocks/rocks_state.rs b/src/eth/storage/rocks/rocks_state.rs index 330ad06a6..ffd619990 100644 --- a/src/eth/storage/rocks/rocks_state.rs +++ b/src/eth/storage/rocks/rocks_state.rs @@ -138,7 +138,7 @@ impl RocksStorageState { blocks_by_hash: new_cf_ref(&db, "blocks_by_hash")?, logs: new_cf_ref(&db, "logs")?, #[cfg(feature = "metrics")] - prev_stats: Default::default(), + prev_stats: Mutex::default(), #[cfg(feature = "metrics")] db_options, db,