Skip to content

Commit

Permalink
lint: warn on default_trait_access (#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinhani-cw authored Jul 26, 2024
1 parent 753cfd3 commit 61026bd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/eth/consensus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
11 changes: 6 additions & 5 deletions src/eth/executor/evm.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::cmp::min;
use std::collections::HashMap;
use std::sync::Arc;

use anyhow::anyhow;
Expand Down Expand Up @@ -199,17 +200,17 @@ impl RevmSession {
pub fn new(storage: Arc<StratusStorage>) -> 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();
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/eth/primitives/block_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -130,7 +131,7 @@ impl Dummy<Faker> 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),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
}
}
Expand Down
7 changes: 4 additions & 3 deletions src/eth/storage/inmemory/inmemory_permanent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
}
Expand Down Expand Up @@ -158,8 +158,9 @@ impl PermanentStorage for InMemoryPermanentStorage {

fn read_slot(&self, address: &Address, index: &SlotIndex, point_in_time: &StoragePointInTime) -> anyhow::Result<Option<Slot>> {
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) {
Expand Down Expand Up @@ -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(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/eth/storage/inmemory/inmemory_temporary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl InMemoryTemporaryAccount {
fn new(address: Address) -> Self {
Self {
info: Account::new_empty(address),
slots: Default::default(),
slots: HashMap::default(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/eth/storage/rocks/rocks_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 61026bd

Please sign in to comment.