diff --git a/account_manager/src/validator/exit.rs b/account_manager/src/validator/exit.rs index ca8cab5bd..9e5b57a29 100644 --- a/account_manager/src/validator/exit.rs +++ b/account_manager/src/validator/exit.rs @@ -349,7 +349,7 @@ fn load_voting_keypair( password_file_path: Option<&PathBuf>, stdin_inputs: bool, ) -> Result { - let keystore = Keystore::from_json_file(&voting_keystore_path).map_err(|e| { + let keystore = Keystore::from_json_file(voting_keystore_path).map_err(|e| { format!( "Unable to read keystore JSON {:?}: {:?}", voting_keystore_path, e diff --git a/account_manager/src/validator/import.rs b/account_manager/src/validator/import.rs index c581866a2..8dc50a9df 100644 --- a/account_manager/src/validator/import.rs +++ b/account_manager/src/validator/import.rs @@ -176,7 +176,7 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin let password = match keystore_password_path.as_ref() { Some(path) => { - let password_from_file: ZeroizeString = fs::read_to_string(&path) + let password_from_file: ZeroizeString = fs::read_to_string(path) .map_err(|e| format!("Unable to read {:?}: {:?}", path, e))? .into(); password_from_file.without_newlines() @@ -256,7 +256,7 @@ pub fn cli_run(matches: &ArgMatches, validator_dir: PathBuf) -> Result<(), Strin .ok_or_else(|| format!("Badly formatted file name: {:?}", src_keystore))?; // Copy the keystore to the new location. - fs::copy(&src_keystore, &dest_keystore) + fs::copy(src_keystore, &dest_keystore) .map_err(|e| format!("Unable to copy keystore: {:?}", e))?; // Register with slashing protection. diff --git a/account_manager/src/wallet/create.rs b/account_manager/src/wallet/create.rs index 9ebaeae5f..accee11b5 100644 --- a/account_manager/src/wallet/create.rs +++ b/account_manager/src/wallet/create.rs @@ -159,7 +159,7 @@ pub fn create_wallet_from_mnemonic( unknown => return Err(format!("--{} {} is not supported", TYPE_FLAG, unknown)), }; - let mgr = WalletManager::open(&wallet_base_dir) + let mgr = WalletManager::open(wallet_base_dir) .map_err(|e| format!("Unable to open --{}: {:?}", WALLETS_DIR_FLAG, e))?; let wallet_password: PlainText = match wallet_password_path { diff --git a/beacon_node/beacon_chain/src/head_tracker.rs b/beacon_node/beacon_chain/src/head_tracker.rs index 84c800f3b..3fa577ff9 100644 --- a/beacon_node/beacon_chain/src/head_tracker.rs +++ b/beacon_node/beacon_chain/src/head_tracker.rs @@ -45,7 +45,7 @@ impl HeadTracker { /// Returns a `SszHeadTracker`, which contains all necessary information to restore the state /// of `Self` at some later point. pub fn to_ssz_container(&self) -> SszHeadTracker { - SszHeadTracker::from_map(&*self.0.read()) + SszHeadTracker::from_map(&self.0.read()) } /// Creates a new `Self` from the given `SszHeadTracker`, restoring `Self` to the same state of diff --git a/beacon_node/beacon_chain/src/migrate.rs b/beacon_node/beacon_chain/src/migrate.rs index 1c0d9c4ed..66f082742 100644 --- a/beacon_node/beacon_chain/src/migrate.rs +++ b/beacon_node/beacon_chain/src/migrate.rs @@ -588,7 +588,7 @@ impl, Cold: ItemStore> BackgroundMigrator( db: Arc>, deposit_contract_deploy_block: u64, - datadir: &Path, from: SchemaVersion, to: SchemaVersion, log: Logger, @@ -42,21 +40,12 @@ pub fn migrate_schema( migrate_schema::( db.clone(), deposit_contract_deploy_block, - datadir, from, next, log.clone(), spec, )?; - migrate_schema::( - db, - deposit_contract_deploy_block, - datadir, - next, - to, - log, - spec, - ) + migrate_schema::(db, deposit_contract_deploy_block, next, to, log, spec) } // Downgrade across multiple versions by recursively migrating one step at a time. (_, _) if to.as_u64() + 1 < from.as_u64() => { @@ -64,21 +53,12 @@ pub fn migrate_schema( migrate_schema::( db.clone(), deposit_contract_deploy_block, - datadir, from, next, log.clone(), spec, )?; - migrate_schema::( - db, - deposit_contract_deploy_block, - datadir, - next, - to, - log, - spec, - ) + migrate_schema::(db, deposit_contract_deploy_block, next, to, log, spec) } // diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index 3b4a62f5a..a1c7acf17 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -356,7 +356,7 @@ where let urls: Vec = urls .iter() - .map(|s| SensitiveUrl::parse(*s)) + .map(|s| SensitiveUrl::parse(s)) .collect::>() .unwrap(); diff --git a/beacon_node/beacon_chain/src/validator_monitor.rs b/beacon_node/beacon_chain/src/validator_monitor.rs index 06734d3e6..95f4aadce 100644 --- a/beacon_node/beacon_chain/src/validator_monitor.rs +++ b/beacon_node/beacon_chain/src/validator_monitor.rs @@ -332,34 +332,22 @@ impl ValidatorMonitor { metrics::set_int_gauge( &metrics::VALIDATOR_MONITOR_SLASHED, &[id], - if validator.slashed { 1 } else { 0 }, + i64::from(validator.slashed), ); metrics::set_int_gauge( &metrics::VALIDATOR_MONITOR_ACTIVE, &[id], - if validator.is_active_at(current_epoch) { - 1 - } else { - 0 - }, + i64::from(validator.is_active_at(current_epoch)), ); metrics::set_int_gauge( &metrics::VALIDATOR_MONITOR_EXITED, &[id], - if validator.is_exited_at(current_epoch) { - 1 - } else { - 0 - }, + i64::from(validator.is_exited_at(current_epoch)), ); metrics::set_int_gauge( &metrics::VALIDATOR_MONITOR_WITHDRAWABLE, &[id], - if validator.is_withdrawable_at(current_epoch) { - 1 - } else { - 0 - }, + i64::from(validator.is_withdrawable_at(current_epoch)), ); metrics::set_int_gauge( &metrics::VALIDATOR_ACTIVATION_ELIGIBILITY_EPOCH, diff --git a/beacon_node/client/src/builder.rs b/beacon_node/client/src/builder.rs index c89980e6e..36d6491a5 100644 --- a/beacon_node/client/src/builder.rs +++ b/beacon_node/client/src/builder.rs @@ -858,7 +858,6 @@ where /// Specifies that the `Client` should use a `HotColdDB` database. pub fn disk_store( mut self, - datadir: &Path, hot_path: &Path, cold_path: &Path, config: StoreConfig, @@ -888,7 +887,6 @@ where migrate_schema::>( db, deposit_contract_deploy_block, - datadir, from, to, log, diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index c25013fdd..a747430ee 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -1,3 +1,4 @@ +#![recursion_limit = "256"] //! This crate contains a HTTP server which serves the endpoints listed here: //! //! https://github.com/ethereum/beacon-APIs diff --git a/beacon_node/lighthouse_network/src/service/utils.rs b/beacon_node/lighthouse_network/src/service/utils.rs index 2aaa46fe8..8073ae776 100644 --- a/beacon_node/lighthouse_network/src/service/utils.rs +++ b/beacon_node/lighthouse_network/src/service/utils.rs @@ -269,7 +269,7 @@ pub(crate) fn save_metadata_to_disk( metadata: MetaData, log: &slog::Logger, ) { - let _ = std::fs::create_dir_all(&dir); + let _ = std::fs::create_dir_all(dir); match File::create(dir.join(METADATA_FILENAME)) .and_then(|mut f| f.write_all(&metadata.as_ssz_bytes())) { diff --git a/beacon_node/operation_pool/src/lib.rs b/beacon_node/operation_pool/src/lib.rs index 8c335189c..4fe5a7254 100644 --- a/beacon_node/operation_pool/src/lib.rs +++ b/beacon_node/operation_pool/src/lib.rs @@ -267,7 +267,7 @@ impl OperationPool { &prev_epoch_key, &*all_attestations, state, - &*reward_cache, + &reward_cache, total_active_balance, prev_epoch_validity_filter, spec, @@ -278,7 +278,7 @@ impl OperationPool { &curr_epoch_key, &*all_attestations, state, - &*reward_cache, + &reward_cache, total_active_balance, curr_epoch_validity_filter, spec, diff --git a/beacon_node/src/lib.rs b/beacon_node/src/lib.rs index 9fd688220..650763dca 100644 --- a/beacon_node/src/lib.rs +++ b/beacon_node/src/lib.rs @@ -61,7 +61,7 @@ impl ProductionBeaconNode { let client_genesis = client_config.genesis.clone(); let store_config = client_config.store.clone(); let log = context.log().clone(); - let datadir = client_config.create_data_dir()?; + let _datadir = client_config.create_data_dir()?; let db_path = client_config.create_db_path()?; let freezer_db_path = client_config.create_freezer_db_path()?; let executor = context.executor.clone(); @@ -84,13 +84,7 @@ impl ProductionBeaconNode { .runtime_context(context) .chain_spec(spec) .http_api_config(client_config.http_api.clone()) - .disk_store( - &datadir, - &db_path, - &freezer_db_path, - store_config, - log.clone(), - )?; + .disk_store(&db_path, &freezer_db_path, store_config, log.clone())?; let builder = if let Some(slasher_config) = client_config.slasher.clone() { let slasher = Arc::new( diff --git a/common/filesystem/src/lib.rs b/common/filesystem/src/lib.rs index 6305671c5..d73b7a355 100644 --- a/common/filesystem/src/lib.rs +++ b/common/filesystem/src/lib.rs @@ -55,7 +55,7 @@ pub enum Error { /// Creates a file with `600 (-rw-------)` permissions and writes the specified bytes to file. pub fn create_with_600_perms>(path: P, bytes: &[u8]) -> Result<(), Error> { let path = path.as_ref(); - let mut file = File::create(&path).map_err(Error::UnableToCreateFile)?; + let mut file = File::create(path).map_err(Error::UnableToCreateFile)?; #[cfg(unix)] { diff --git a/consensus/serde_utils/src/hex_vec.rs b/consensus/serde_utils/src/hex_vec.rs index 60d649443..f7f483362 100644 --- a/consensus/serde_utils/src/hex_vec.rs +++ b/consensus/serde_utils/src/hex_vec.rs @@ -10,7 +10,7 @@ where S: Serializer, { let mut hex_string: String = "0x".to_string(); - hex_string.push_str(&hex::encode(&bytes)); + hex_string.push_str(&hex::encode(bytes)); serializer.serialize_str(&hex_string) } diff --git a/consensus/serde_utils/src/u64_hex_be.rs b/consensus/serde_utils/src/u64_hex_be.rs index dc6af0fa4..6af8a7589 100644 --- a/consensus/serde_utils/src/u64_hex_be.rs +++ b/consensus/serde_utils/src/u64_hex_be.rs @@ -39,7 +39,7 @@ impl<'de> Visitor<'de> for QuantityVisitor { hex::decode(&format!("0{}", stripped)) .map_err(|e| de::Error::custom(format!("invalid hex ({:?})", e))) } else { - hex::decode(&stripped).map_err(|e| de::Error::custom(format!("invalid hex ({:?})", e))) + hex::decode(stripped).map_err(|e| de::Error::custom(format!("invalid hex ({:?})", e))) } } } diff --git a/consensus/tree_hash/src/merkle_hasher.rs b/consensus/tree_hash/src/merkle_hasher.rs index 1753eade1..2acaf1c3b 100644 --- a/consensus/tree_hash/src/merkle_hasher.rs +++ b/consensus/tree_hash/src/merkle_hasher.rs @@ -368,7 +368,7 @@ mod test { fn context_size() { assert_eq!( mem::size_of::(), - 232, + 224, "Halfnode size should be as expected" ); } diff --git a/consensus/types/src/config_and_preset.rs b/consensus/types/src/config_and_preset.rs index 74b07717a..f72b1710d 100644 --- a/consensus/types/src/config_and_preset.rs +++ b/consensus/types/src/config_and_preset.rs @@ -40,7 +40,7 @@ impl ConfigAndPreset { let extra_fields = get_extra_fields(spec); if spec.bellatrix_fork_epoch.is_some() - || fork_name == None + || fork_name.is_none() || fork_name == Some(ForkName::Merge) { let bellatrix_preset = BellatrixPreset::from_chain_spec::(spec); @@ -65,7 +65,7 @@ impl ConfigAndPreset { /// Get a hashmap of constants to add to the `PresetAndConfig` pub fn get_extra_fields(spec: &ChainSpec) -> HashMap { - let hex_string = |value: &[u8]| format!("0x{}", hex::encode(&value)).into(); + let hex_string = |value: &[u8]| format!("0x{}", hex::encode(value)).into(); let u32_hex = |v: u32| hex_string(&v.to_le_bytes()); let u8_hex = |v: u8| hex_string(&v.to_le_bytes()); hashmap! { diff --git a/consensus/types/src/graffiti.rs b/consensus/types/src/graffiti.rs index 73beb8264..2b0a645cd 100644 --- a/consensus/types/src/graffiti.rs +++ b/consensus/types/src/graffiti.rs @@ -27,7 +27,7 @@ impl Graffiti { impl fmt::Display for Graffiti { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", eth2_serde_utils::hex::encode(&self.0)) + write!(f, "{}", eth2_serde_utils::hex::encode(self.0)) } } diff --git a/database_manager/src/lib.rs b/database_manager/src/lib.rs index cb50a4ee8..c0023f350 100644 --- a/database_manager/src/lib.rs +++ b/database_manager/src/lib.rs @@ -257,7 +257,6 @@ pub fn migrate_db( migrate_schema::, _, _, _>>( db, client_config.eth1.deposit_contract_deploy_block, - &client_config.get_data_dir(), from, to, log, diff --git a/slasher/src/array.rs b/slasher/src/array.rs index d9cb8a4ec..4deb38912 100644 --- a/slasher/src/array.rs +++ b/slasher/src/array.rs @@ -188,7 +188,7 @@ pub trait TargetArrayChunk: Sized + serde::Serialize + serde::de::DeserializeOwn txn.put( Self::select_db(db), - &disk_key.to_be_bytes(), + disk_key.to_be_bytes(), &compressed_value, )?; Ok(()) diff --git a/slasher/src/database.rs b/slasher/src/database.rs index c8046c80d..49d2b00a4 100644 --- a/slasher/src/database.rs +++ b/slasher/src/database.rs @@ -301,7 +301,7 @@ impl SlasherDB { pub fn store_schema_version(&self, txn: &mut RwTransaction<'_>) -> Result<(), Error> { txn.put( &self.databases.metadata_db, - &METADATA_VERSION_KEY, + METADATA_VERSION_KEY, &bincode::serialize(&CURRENT_SCHEMA_VERSION)?, )?; Ok(()) @@ -323,7 +323,7 @@ impl SlasherDB { pub fn store_config(&self, config: &Config, txn: &mut RwTransaction<'_>) -> Result<(), Error> { txn.put( &self.databases.metadata_db, - &METADATA_CONFIG_KEY, + METADATA_CONFIG_KEY, &bincode::serialize(config)?, )?; Ok(()) @@ -367,7 +367,7 @@ impl SlasherDB { txn.put( &self.databases.attesters_db, &AttesterKey::new(validator_index, target_epoch, &self.config), - &CompactAttesterRecord::null().as_bytes(), + CompactAttesterRecord::null().as_bytes(), )?; } } @@ -423,7 +423,7 @@ impl SlasherDB { key: &IndexedAttestationIdKey, value: IndexedAttestationId, ) -> Result<(), Error> { - txn.put(&self.databases.indexed_attestation_id_db, key, &value)?; + txn.put(&self.databases.indexed_attestation_id_db, key, value)?; Ok(()) } @@ -579,7 +579,7 @@ impl SlasherDB { txn.put( &self.databases.attesters_db, &AttesterKey::new(validator_index, target_epoch, &self.config), - &indexed_attestation_id, + indexed_attestation_id, )?; Ok(AttesterSlashingStatus::NotSlashable) diff --git a/testing/execution_engine_integration/src/geth.rs b/testing/execution_engine_integration/src/geth.rs index 467fd8b43..1b96fa9f3 100644 --- a/testing/execution_engine_integration/src/geth.rs +++ b/testing/execution_engine_integration/src/geth.rs @@ -13,7 +13,7 @@ const GETH_REPO_URL: &str = "https://github.com/ethereum/go-ethereum"; pub fn build_result(repo_dir: &Path) -> Output { Command::new("make") .arg("geth") - .current_dir(&repo_dir) + .current_dir(repo_dir) .output() .expect("failed to make geth") } diff --git a/testing/execution_engine_integration/src/test_rig.rs b/testing/execution_engine_integration/src/test_rig.rs index bd179be53..b3464ec98 100644 --- a/testing/execution_engine_integration/src/test_rig.rs +++ b/testing/execution_engine_integration/src/test_rig.rs @@ -203,8 +203,8 @@ impl TestRig { .await; // We hardcode the accounts here since some EEs start with a default unlocked account - let account1 = ethers_core::types::Address::from_slice(&hex::decode(&ACCOUNT1).unwrap()); - let account2 = ethers_core::types::Address::from_slice(&hex::decode(&ACCOUNT2).unwrap()); + let account1 = ethers_core::types::Address::from_slice(&hex::decode(ACCOUNT1).unwrap()); + let account2 = ethers_core::types::Address::from_slice(&hex::decode(ACCOUNT2).unwrap()); /* * Check the transition config endpoint. diff --git a/testing/execution_engine_integration/src/transactions.rs b/testing/execution_engine_integration/src/transactions.rs index a8c0ab3c1..62b77d502 100644 --- a/testing/execution_engine_integration/src/transactions.rs +++ b/testing/execution_engine_integration/src/transactions.rs @@ -30,7 +30,7 @@ pub fn transactions(account1: Address, account2: Address) -> Vec(), diff --git a/validator_client/src/http_api/api_secret.rs b/validator_client/src/http_api/api_secret.rs index 484ac50bd..b42cd11ed 100644 --- a/validator_client/src/http_api/api_secret.rs +++ b/validator_client/src/http_api/api_secret.rs @@ -60,7 +60,7 @@ impl ApiSecret { // Create and write the secret key to file with appropriate permissions create_with_600_perms( &sk_path, - eth2_serde_utils::hex::encode(&sk.serialize()).as_bytes(), + eth2_serde_utils::hex::encode(sk.serialize()).as_bytes(), ) .map_err(|e| { format!(