Skip to content

Commit d56cec8

Browse files
authored
Address clippy lints in tree-states (#4414)
* Address some clippy lints * Box errors to fix error size lint * Add Default impl for Validator * Address more clippy lints * Re-implement `check_state_diff` * Fix misc test compile errors
1 parent 23db089 commit d56cec8

File tree

26 files changed

+94
-73
lines changed

26 files changed

+94
-73
lines changed

beacon_node/beacon_chain/src/migrate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
400400
.max_by_key(|f| f.finalized_checkpoint.epoch);
401401

402402
// Do a bit of state reconstruction first if required.
403-
if let Some(_) = reconstruction_notif {
403+
if reconstruction_notif.is_some() {
404404
let timer = std::time::Instant::now();
405405

406406
match db.reconstruct_historic_states(Some(BLOCKS_PER_RECONSTRUCTION)) {

beacon_node/beacon_chain/src/sync_committee_rewards.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
6565
.zip(sync_aggregate.sync_committee_bits.iter())
6666
{
6767
let participant_balance = balances
68-
.get_mut(&validator_index)
68+
.get_mut(validator_index)
6969
.ok_or(BeaconChainError::SyncCommitteeRewardsSyncError)?;
7070

7171
if participant_bit {

beacon_node/beacon_chain/tests/store_tests.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ use store::{
2828
HotColdDB, LevelDB, StoreConfig,
2929
};
3030
use tempfile::{tempdir, TempDir};
31-
use tokio::time::sleep;
32-
use tree_hash::TreeHash;
3331
use types::test_utils::{SeedableRng, XorShiftRng};
3432
use types::*;
3533

beacon_node/execution_layer/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ use tokio::{
3838
};
3939
use tokio_stream::wrappers::WatchStream;
4040
use tree_hash::TreeHash;
41-
use types::{AbstractExecPayload, BeaconStateError, ExecPayload, Withdrawals};
41+
use types::{AbstractExecPayload, BeaconStateError, ExecPayload};
4242
use types::{
43-
BlindedPayload, BlockType, ChainSpec, Epoch, ExecutionBlockHash, ExecutionPayload,
44-
ExecutionPayloadCapella, ExecutionPayloadMerge, ForkName, ForkVersionedResponse,
45-
ProposerPreparationData, PublicKeyBytes, Signature, SignedBeaconBlock, Slot, Uint256,
43+
BlindedPayload, BlockType, ChainSpec, Epoch, ExecutionPayloadCapella, ExecutionPayloadMerge,
44+
ForkVersionedResponse, ProposerPreparationData, PublicKeyBytes, Signature, SignedBeaconBlock,
45+
Slot,
4646
};
4747

4848
mod block_hash;

beacon_node/genesis/src/interop.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ mod test {
241241
}
242242

243243
for (index, v) in state.validators().iter().enumerate() {
244-
let creds = v.withdrawal_credentials.as_bytes();
244+
let withdrawal_credientials = v.withdrawal_credentials();
245+
let creds = withdrawal_credientials.as_bytes();
245246
if index % 2 == 0 {
246247
assert_eq!(
247248
creds[0], spec.bls_withdrawal_prefix_byte,

beacon_node/operation_pool/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ mod release_tests {
12491249
// Each validator will have a multiple of 1_000_000_000 wei.
12501250
// Safe from overflow unless there are about 18B validators (2^64 / 1_000_000_000).
12511251
for i in 0..state.validators().len() {
1252-
state.validators_mut()[i].effective_balance = 1_000_000_000 * i as u64;
1252+
state.validators_mut().get_mut(i).unwrap().effective_balance = 1_000_000_000 * i as u64;
12531253
}
12541254

12551255
let num_validators = num_committees

beacon_node/store/src/forwards_iter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl<'a, E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>>
234234
// of the pre iterator.
235235
None => {
236236
let continuation_data = continuation_data.take();
237-
let start_slot = Slot::from(iter.limit);
237+
let start_slot = iter.limit;
238238

239239
*self = PostFinalizationLazy {
240240
continuation_data,

beacon_node/store/src/hdiff.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ mod tests {
331331

332332
let xor_diff = XorDiff::compute(&x_values, &y_values).unwrap();
333333

334-
let mut y_from_xor = x_values.clone();
334+
let mut y_from_xor = x_values;
335335
xor_diff.apply(&mut y_from_xor).unwrap();
336336

337337
assert_eq!(y_values, y_from_xor);

beacon_node/store/src/hot_cold_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> HotColdDB<E, Hot, Cold>
15731573
(start_slot.as_u64()..=end_slot.as_u64())
15741574
.map(Slot::new)
15751575
.map(|slot| self.get_cold_blinded_block_by_slot(slot)),
1576-
|iter| iter.filter_map(|x| x).collect(),
1576+
|iter| iter.flatten().collect(),
15771577
)
15781578
}
15791579

beacon_node/store/src/leveldb_store.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ impl<E: EthSpec> KeyValueStore<E> for LevelDB<E> {
183183
}
184184

185185
fn iter_column_from<K: Key>(&self, column: DBColumn, from: &[u8]) -> ColumnIter<K> {
186-
let start_key = BytesKey::from_vec(get_key_for_col(column.into(), &from));
186+
let start_key = BytesKey::from_vec(get_key_for_col(column.into(), from));
187187

188188
let iter = self.db.iter(self.read_options());
189189
iter.seek(&start_key);

0 commit comments

Comments
 (0)