Skip to content

Commit

Permalink
Address Clippy 1.73 lints on Deneb branch (sigp#4810)
Browse files Browse the repository at this point in the history
* Address Clippy 1.73 lints (sigp#4809)

## Proposed Changes

Fix Clippy lints enabled by default in Rust 1.73.0, released today.

* Address Clippy 1.73 lints.

---------

Co-authored-by: Michael Sproul <michael@sigmaprime.io>
  • Loading branch information
jimmygchen and michaelsproul authored Oct 6, 2023
1 parent 203ac65 commit 4ad7e15
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 35 deletions.
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/blob_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ pub struct KzgVerifiedBlob<T: EthSpec> {

impl<T: EthSpec> PartialOrd for KzgVerifiedBlob<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.blob.partial_cmp(&other.blob)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/eth1_finalization_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl CheckpointMap {
pub fn insert(&mut self, checkpoint: Checkpoint, eth1_finalization_data: Eth1FinalizationData) {
self.store
.entry(checkpoint.epoch)
.or_insert_with(Vec::new)
.or_default()
.push((checkpoint.root, eth1_finalization_data));

// faster to reduce size after the fact than do pre-checking to see
Expand Down
25 changes: 11 additions & 14 deletions beacon_node/beacon_chain/src/historical_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,17 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
let signature_set = signed_blocks
.iter()
.zip_eq(block_roots)
.filter_map(|(block, block_root)| {
(block_root != self.genesis_block_root).then(|| {
block_proposal_signature_set_from_parts(
block,
Some(block_root),
block.message().proposer_index(),
&self.spec.fork_at_epoch(block.message().epoch()),
self.genesis_validators_root,
|validator_index| {
pubkey_cache.get(validator_index).cloned().map(Cow::Owned)
},
&self.spec,
)
})
.filter(|&(_block, block_root)| (block_root != self.genesis_block_root))
.map(|(block, block_root)| {
block_proposal_signature_set_from_parts(
block,
Some(block_root),
block.message().proposer_index(),
&self.spec.fork_at_epoch(block.message().epoch()),
self.genesis_validators_root,
|validator_index| pubkey_cache.get(validator_index).cloned().map(Cow::Owned),
&self.spec,
)
})
.collect::<Result<Vec<_>, _>>()
.map_err(HistoricalBlockError::SignatureSet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ impl<T: EthSpec> ExecutionBlockGenerator<T> {
let block_hash = block.block_hash();
self.block_hashes
.entry(block.block_number())
.or_insert_with(Vec::new)
.or_default()
.push(block_hash);
self.blocks.insert(block_hash, block);

Expand Down
4 changes: 2 additions & 2 deletions beacon_node/http_api/src/standard_block_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use beacon_chain::{BeaconChain, BeaconChainTypes};
use eth2::lighthouse::StandardBlockReward;
use std::sync::Arc;
use warp_utils::reject::beacon_chain_error;
//// The difference between block_rewards and beacon_block_rewards is the later returns block
//// reward format that satisfies beacon-api specs
/// The difference between block_rewards and beacon_block_rewards is the later returns block
/// reward format that satisfies beacon-api specs
pub fn compute_beacon_block_rewards<T: BeaconChainTypes>(
chain: Arc<BeaconChain<T>>,
block_id: BlockId,
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/lighthouse_network/src/peer_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,7 +1055,7 @@ impl<TSpec: EthSpec> PeerManager<TSpec> {
Subnet::Attestation(_) => {
subnet_to_peer
.entry(subnet)
.or_insert_with(Vec::new)
.or_default()
.push((*peer_id, info.clone()));
}
Subnet::SyncCommittee(id) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,15 @@ impl Eq for Score {}

impl PartialOrd for Score {
fn partial_cmp(&self, other: &Score) -> Option<std::cmp::Ordering> {
self.score().partial_cmp(&other.score())
Some(self.cmp(other))
}
}

impl Ord for Score {
fn cmp(&self, other: &Score) -> std::cmp::Ordering {
self.partial_cmp(other).unwrap_or(std::cmp::Ordering::Equal)
self.score()
.partial_cmp(&other.score())
.unwrap_or(std::cmp::Ordering::Equal)
}
}

Expand Down
10 changes: 2 additions & 8 deletions beacon_node/operation_pool/src/attestation_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,8 @@ impl<T: EthSpec> AttestationMap<T> {
indexed,
} = SplitAttestation::new(attestation, attesting_indices);

let attestation_map = self
.checkpoint_map
.entry(checkpoint)
.or_insert_with(AttestationDataMap::default);
let attestations = attestation_map
.attestations
.entry(data)
.or_insert_with(Vec::new);
let attestation_map = self.checkpoint_map.entry(checkpoint).or_default();
let attestations = attestation_map.attestations.entry(data).or_default();

// Greedily aggregate the attestation with all existing attestations.
// NOTE: this is sub-optimal and in future we will remove this in favour of max-clique
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/store/src/memory_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<E: EthSpec> KeyValueStore<E> for MemoryStore<E> {
self.col_keys
.write()
.entry(col.as_bytes().to_vec())
.or_insert_with(HashSet::new)
.or_default()
.insert(key.to_vec());
Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions consensus/types/src/blob_sidecar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl BlobIdentifier {

impl PartialOrd for BlobIdentifier {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.index.partial_cmp(&other.index)
Some(self.cmp(other))
}
}

Expand Down Expand Up @@ -109,7 +109,7 @@ impl<E: EthSpec> From<BlobSidecar<E>> for BlindedBlobSidecar {

impl<T: EthSpec> PartialOrd for BlobSidecar<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.index.partial_cmp(&other.index)
Some(self.cmp(other))
}
}

Expand Down
2 changes: 1 addition & 1 deletion validator_client/src/attestation_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl<T: SlotClock + 'static, E: EthSpec> AttestationService<T, E> {
.into_iter()
.fold(HashMap::new(), |mut map, duty_and_proof| {
map.entry(duty_and_proof.duty.committee_index)
.or_insert_with(Vec::new)
.or_default()
.push(duty_and_proof);
map
});
Expand Down
2 changes: 1 addition & 1 deletion validator_client/src/duties_service/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl SyncDutiesMap {

committees_writer
.entry(committee_period)
.or_insert_with(CommitteeDuties::default)
.or_default()
.init(validator_indices);

// Return shared reference
Expand Down

0 comments on commit 4ad7e15

Please sign in to comment.