From a78285db5e09c097791ebfc4f67c60b7eb8e5a11 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Fri, 21 Apr 2023 18:29:28 +0000 Subject: [PATCH] Fix Rust 1.69 lints (#4222) ## Issue Addressed N/A ## Proposed Changes Fixes lints mostly `extra-unused-type-parameters` https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_type_paramete --- beacon_node/beacon_chain/src/beacon_chain.rs | 4 +-- beacon_node/beacon_chain/src/eth1_chain.rs | 34 ++++++++----------- .../execution_layer/src/engine_api/http.rs | 2 +- .../types/src/beacon_state/tree_hash_cache.rs | 4 +-- lcli/src/check_deposit_data.rs | 3 +- lcli/src/main.rs | 2 +- 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 0165c54dc..ca0c5ce15 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -3619,7 +3619,7 @@ impl BeaconChain { let (state, state_root_opt) = self .task_executor .spawn_blocking_handle( - move || chain.load_state_for_block_production::(slot), + move || chain.load_state_for_block_production(slot), "produce_partial_beacon_block", ) .ok_or(BlockProductionError::ShuttingDown)? @@ -3642,7 +3642,7 @@ impl BeaconChain { /// Load a beacon state from the database for block production. This is a long-running process /// that should not be performed in an `async` context. - fn load_state_for_block_production>( + fn load_state_for_block_production( self: &Arc, slot: Slot, ) -> Result<(BeaconState, Option), BlockProductionError> { diff --git a/beacon_node/beacon_chain/src/eth1_chain.rs b/beacon_node/beacon_chain/src/eth1_chain.rs index 25971bf85..f820622e5 100644 --- a/beacon_node/beacon_chain/src/eth1_chain.rs +++ b/beacon_node/beacon_chain/src/eth1_chain.rs @@ -88,7 +88,7 @@ fn get_sync_status( let period = T::SlotsPerEth1VotingPeriod::to_u64(); let voting_period_start_slot = (current_slot / period) * period; - let period_start = slot_start_seconds::( + let period_start = slot_start_seconds( genesis_time, spec.seconds_per_slot, voting_period_start_slot, @@ -470,7 +470,7 @@ impl Eth1ChainBackend for CachingEth1Backend { fn eth1_data(&self, state: &BeaconState, spec: &ChainSpec) -> Result { let period = T::SlotsPerEth1VotingPeriod::to_u64(); let voting_period_start_slot = (state.slot() / period) * period; - let voting_period_start_seconds = slot_start_seconds::( + let voting_period_start_seconds = slot_start_seconds( state.genesis_time(), spec.seconds_per_slot, voting_period_start_slot, @@ -658,11 +658,7 @@ fn find_winning_vote(valid_votes: Eth1DataVoteCount) -> Option { } /// Returns the unix-epoch seconds at the start of the given `slot`. -fn slot_start_seconds( - genesis_unix_seconds: u64, - seconds_per_slot: u64, - slot: Slot, -) -> u64 { +fn slot_start_seconds(genesis_unix_seconds: u64, seconds_per_slot: u64, slot: Slot) -> u64 { genesis_unix_seconds + slot.as_u64() * seconds_per_slot } @@ -698,7 +694,7 @@ mod test { fn get_voting_period_start_seconds(state: &BeaconState, spec: &ChainSpec) -> u64 { let period = ::SlotsPerEth1VotingPeriod::to_u64(); let voting_period_start_slot = (state.slot() / period) * period; - slot_start_seconds::( + slot_start_seconds( state.genesis_time(), spec.seconds_per_slot, voting_period_start_slot, @@ -708,23 +704,23 @@ mod test { #[test] fn slot_start_time() { let zero_sec = 0; - assert_eq!(slot_start_seconds::(100, zero_sec, Slot::new(2)), 100); + assert_eq!(slot_start_seconds(100, zero_sec, Slot::new(2)), 100); let one_sec = 1; - assert_eq!(slot_start_seconds::(100, one_sec, Slot::new(0)), 100); - assert_eq!(slot_start_seconds::(100, one_sec, Slot::new(1)), 101); - assert_eq!(slot_start_seconds::(100, one_sec, Slot::new(2)), 102); + assert_eq!(slot_start_seconds(100, one_sec, Slot::new(0)), 100); + assert_eq!(slot_start_seconds(100, one_sec, Slot::new(1)), 101); + assert_eq!(slot_start_seconds(100, one_sec, Slot::new(2)), 102); let three_sec = 3; - assert_eq!(slot_start_seconds::(100, three_sec, Slot::new(0)), 100); - assert_eq!(slot_start_seconds::(100, three_sec, Slot::new(1)), 103); - assert_eq!(slot_start_seconds::(100, three_sec, Slot::new(2)), 106); + assert_eq!(slot_start_seconds(100, three_sec, Slot::new(0)), 100); + assert_eq!(slot_start_seconds(100, three_sec, Slot::new(1)), 103); + assert_eq!(slot_start_seconds(100, three_sec, Slot::new(2)), 106); let five_sec = 5; - assert_eq!(slot_start_seconds::(100, five_sec, Slot::new(0)), 100); - assert_eq!(slot_start_seconds::(100, five_sec, Slot::new(1)), 105); - assert_eq!(slot_start_seconds::(100, five_sec, Slot::new(2)), 110); - assert_eq!(slot_start_seconds::(100, five_sec, Slot::new(3)), 115); + assert_eq!(slot_start_seconds(100, five_sec, Slot::new(0)), 100); + assert_eq!(slot_start_seconds(100, five_sec, Slot::new(1)), 105); + assert_eq!(slot_start_seconds(100, five_sec, Slot::new(2)), 110); + assert_eq!(slot_start_seconds(100, five_sec, Slot::new(3)), 115); } fn get_eth1_block(timestamp: u64, number: u64) -> Eth1Block { diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index 993957450..f542bf5b4 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -1187,7 +1187,7 @@ mod test { transactions, ..<_>::default() }); - let json = serde_json::to_value(&ep)?; + let json = serde_json::to_value(ep)?; Ok(json.get("transactions").unwrap().clone()) } diff --git a/consensus/types/src/beacon_state/tree_hash_cache.rs b/consensus/types/src/beacon_state/tree_hash_cache.rs index efc6573d2..d1d63e3c8 100644 --- a/consensus/types/src/beacon_state/tree_hash_cache.rs +++ b/consensus/types/src/beacon_state/tree_hash_cache.rs @@ -403,7 +403,7 @@ impl ValidatorsListTreeHashCache { validators.len(), ), list_arena, - values: ParallelValidatorTreeHash::new::(validators), + values: ParallelValidatorTreeHash::new(validators), } } @@ -468,7 +468,7 @@ impl ParallelValidatorTreeHash { /// /// Allocates the necessary memory to store all of the cached Merkle trees but does perform any /// hashing. - fn new(validators: &[Validator]) -> Self { + fn new(validators: &[Validator]) -> Self { let num_arenas = std::cmp::max( 1, (validators.len() + VALIDATORS_PER_ARENA - 1) / VALIDATORS_PER_ARENA, diff --git a/lcli/src/check_deposit_data.rs b/lcli/src/check_deposit_data.rs index 56f18f998..47c2c7add 100644 --- a/lcli/src/check_deposit_data.rs +++ b/lcli/src/check_deposit_data.rs @@ -2,9 +2,8 @@ use clap::ArgMatches; use clap_utils::{parse_required, parse_ssz_required}; use deposit_contract::{decode_eth1_tx_data, DEPOSIT_DATA_LEN}; use tree_hash::TreeHash; -use types::EthSpec; -pub fn run(matches: &ArgMatches) -> Result<(), String> { +pub fn run(matches: &ArgMatches) -> Result<(), String> { let rlp_bytes = parse_ssz_required::>(matches, "deposit-data")?; let amount = parse_required(matches, "deposit-amount")?; diff --git a/lcli/src/main.rs b/lcli/src/main.rs index cdf9cfa67..eeb098f04 100644 --- a/lcli/src/main.rs +++ b/lcli/src/main.rs @@ -847,7 +847,7 @@ fn run( } ("new-testnet", Some(matches)) => new_testnet::run::(testnet_dir, matches) .map_err(|e| format!("Failed to run new_testnet command: {}", e)), - ("check-deposit-data", Some(matches)) => check_deposit_data::run::(matches) + ("check-deposit-data", Some(matches)) => check_deposit_data::run(matches) .map_err(|e| format!("Failed to run check-deposit-data command: {}", e)), ("generate-bootnode-enr", Some(matches)) => generate_bootnode_enr::run::(matches) .map_err(|e| format!("Failed to run generate-bootnode-enr command: {}", e)),