From 444e6797bfaf28c2df7bc67f78c0e80d2691d6f6 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Thu, 9 Jul 2026 12:36:24 -0700 Subject: [PATCH] Fix lints --- beacon_node/beacon_chain/src/validator_monitor.rs | 2 +- beacon_node/lighthouse_network/src/peer_manager/mod.rs | 2 +- .../lighthouse_network/src/peer_manager/peerdb.rs | 4 ++-- .../lighthouse_network/src/service/gossip_cache.rs | 2 +- beacon_node/operation_pool/src/attestation.rs | 2 +- consensus/proto_array/src/proto_array.rs | 2 +- crypto/eth2_keystore/src/keystore.rs | 2 +- validator_client/lighthouse_validator_store/src/lib.rs | 9 +++------ validator_client/slashing_protection/src/lib.rs | 2 +- validator_manager/src/create_validators.rs | 2 +- 10 files changed, 13 insertions(+), 16 deletions(-) diff --git a/beacon_node/beacon_chain/src/validator_monitor.rs b/beacon_node/beacon_chain/src/validator_monitor.rs index 010b82975d9..294f160b821 100644 --- a/beacon_node/beacon_chain/src/validator_monitor.rs +++ b/beacon_node/beacon_chain/src/validator_monitor.rs @@ -1893,7 +1893,7 @@ impl ValidatorMonitor { epoch - 2 }; - for (_, validator) in self.validators.iter() { + for validator in self.validators.values() { let id = &validator.id; let summaries = validator.summaries.read(); diff --git a/beacon_node/lighthouse_network/src/peer_manager/mod.rs b/beacon_node/lighthouse_network/src/peer_manager/mod.rs index 898b97a85f7..84b14cb3f64 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/mod.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/mod.rs @@ -2236,7 +2236,7 @@ mod tests { // Make sure a peer on the same subnet has been removed println!( "Check against: {}, {}", - alternative_index, &peers[alternative_index] + alternative_index, peers[alternative_index] ); assert!(!connected_peers.contains(&peers[alternative_index])); } diff --git a/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs index 0f75766f1cf..9db1ac15823 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs @@ -1565,7 +1565,7 @@ mod tests { } assert_eq!(pdb.disconnected_peers, 0); - for (_, p) in peer_list.iter() { + for p in peer_list.values() { pdb.inject_disconnect(p); // Allow the timing to update correctly } @@ -1600,7 +1600,7 @@ mod tests { peer_list.insert(id, new_peer); } assert_eq!(pdb.disconnected_peers, pdb.disconnected_peers().count()); - for (_, p) in peer_list.iter() { + for p in peer_list.values() { pdb.inject_disconnect(p); } assert_eq!(pdb.disconnected_peers, pdb.disconnected_peers().count()); diff --git a/beacon_node/lighthouse_network/src/service/gossip_cache.rs b/beacon_node/lighthouse_network/src/service/gossip_cache.rs index 4b96fe884e8..b1e5f2d20d6 100644 --- a/beacon_node/lighthouse_network/src/service/gossip_cache.rs +++ b/beacon_node/lighthouse_network/src/service/gossip_cache.rs @@ -277,7 +277,7 @@ impl GossipCache { // Get the registered messages for this topic. pub fn retrieve(&mut self, topic: &GossipTopic) -> Option> + '_> { if let Some(msgs) = self.topic_msgs.remove(topic) { - for (_, key) in msgs.iter() { + for key in msgs.values() { self.expirations.remove(key); } Some(msgs.into_keys()) diff --git a/beacon_node/operation_pool/src/attestation.rs b/beacon_node/operation_pool/src/attestation.rs index 045adfebe02..c54f45eacb9 100644 --- a/beacon_node/operation_pool/src/attestation.rs +++ b/beacon_node/operation_pool/src/attestation.rs @@ -107,7 +107,7 @@ impl<'a, E: EthSpec> AttMaxCover<'a, E> { } } - Some((index, proposer_reward_numerator)).filter(|_| proposer_reward_numerator != 0) + (proposer_reward_numerator != 0).then_some((index, proposer_reward_numerator)) }) .collect(); diff --git a/consensus/proto_array/src/proto_array.rs b/consensus/proto_array/src/proto_array.rs index 57d3acd55b4..9b89f70bed8 100644 --- a/consensus/proto_array/src/proto_array.rs +++ b/consensus/proto_array/src/proto_array.rs @@ -1722,7 +1722,7 @@ impl ProtoArray { } // Adjust the indices map. - for (_root, index) in self.indices.iter_mut() { + for index in self.indices.values_mut() { *index = index .checked_sub(finalized_index) .ok_or(Error::IndexOverflow("indices"))?; diff --git a/crypto/eth2_keystore/src/keystore.rs b/crypto/eth2_keystore/src/keystore.rs index e6fc59d4624..e255368629f 100644 --- a/crypto/eth2_keystore/src/keystore.rs +++ b/crypto/eth2_keystore/src/keystore.rs @@ -261,7 +261,7 @@ impl Keystore { /// Returns the pubkey for the keystore, parsed as a `PublicKey` if it parses. pub fn public_key(&self) -> Option { - serde_json::from_str(&format!("\"0x{}\"", &self.json.pubkey)).ok() + serde_json::from_str(&format!("\"0x{}\"", self.json.pubkey)).ok() } /// Returns the key derivation function for the keystore. diff --git a/validator_client/lighthouse_validator_store/src/lib.rs b/validator_client/lighthouse_validator_store/src/lib.rs index cc9729b44d9..b69cbd432aa 100644 --- a/validator_client/lighthouse_validator_store/src/lib.rs +++ b/validator_client/lighthouse_validator_store/src/lib.rs @@ -942,12 +942,9 @@ impl ValidatorStore for LighthouseValidatorS } }) }) - .and_then(|factor| { - // If builder boost factor is set to 100 it should be treated - // as None to prevent unnecessary calculations that could - // lead to loss of information. - if factor == 100 { None } else { Some(factor) } - }) + // If builder boost factor is set to 100 it should be treated as None + // to prevent unnecessary calculations that could lead to loss of information. + .filter(|&factor| factor != 100) } async fn randao_reveal( diff --git a/validator_client/slashing_protection/src/lib.rs b/validator_client/slashing_protection/src/lib.rs index d8039acda63..31191eef34d 100644 --- a/validator_client/slashing_protection/src/lib.rs +++ b/validator_client/slashing_protection/src/lib.rs @@ -87,7 +87,7 @@ impl SigningRoot { } fn to_hash256(self) -> Option { - Some(self.0).filter(|_| !self.is_null()) + (!self.is_null()).then_some(self.0) } } diff --git a/validator_manager/src/create_validators.rs b/validator_manager/src/create_validators.rs index 8682705956c..4d1eccad975 100644 --- a/validator_manager/src/create_validators.rs +++ b/validator_manager/src/create_validators.rs @@ -434,7 +434,7 @@ impl ValidatorsAndDeposits { .await { Ok(Some(_)) => { - return Err(format!( + Err(format!( "Validator {:?} at derivation index {} already exists in the beacon chain. \ This indicates a slashing risk, be sure to never run the same validator on two \ different validator clients. If you understand the risks and are certain you \