Skip to content

Commit

Permalink
fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
divagant-martian committed Sep 22, 2022
1 parent 92dc747 commit 76c7257
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 24 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ lint:
-A clippy::derive_partial_eq_without_eq \
-A clippy::from-over-into \
-A clippy::upper-case-acronyms \
-A clippy::vec-init-then-push
-A clippy::vec-init-then-push \
-A clippy::question-mark

nightly-lint:
cp .github/custom/clippy.toml .
Expand Down
6 changes: 3 additions & 3 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {

if let Some(request_root) = request_root_opt {
if let Ok(prev_root) = state.get_block_root(prev_slot) {
return Ok(Some((*prev_root != request_root).then(|| request_root)));
return Ok(Some((*prev_root != request_root).then_some(request_root)));
}
}

Expand All @@ -831,7 +831,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
slot: curr_slot,
});
}
Ok((curr_root != prev_root).then(|| curr_root))
Ok((curr_root != prev_root).then_some(curr_root))
} else {
Ok(None)
}
Expand Down Expand Up @@ -2865,7 +2865,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
.pubkeys
.iter()
.zip(sync_aggregate.sync_committee_bits.iter())
.filter_map(|(pubkey, bit)| bit.then(|| pubkey))
.filter_map(|(pubkey, bit)| bit.then_some(pubkey))
.collect::<Vec<_>>();

validator_monitor.register_sync_aggregate_in_block(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn map_relevant_epochs_to_roots<T: BeaconChainTypes>(

let root = iter
.find_map(|next| match next {
Ok((root, slot)) => (slot == start_slot).then(|| Ok(root)),
Ok((root, slot)) => (slot == start_slot).then_some(Ok(root)),
Err(e) => Some(Err(format!("{:?}", e))),
})
.transpose()?
Expand Down Expand Up @@ -286,7 +286,7 @@ fn find_finalized_descendant_heads(
.filter_map(|(index, node)| {
(!nodes_referenced_as_parents.contains(&index)
&& fork_choice.is_descendant(finalized_root, node.root))
.then(|| HeadInfo {
.then_some(HeadInfo {
index,
root: node.root,
slot: node.slot,
Expand All @@ -306,7 +306,7 @@ fn update_store_justified_checkpoint(
.filter_map(|node| {
(node.finalized_checkpoint
== Some(persisted_fork_choice.fork_choice_store.finalized_checkpoint))
.then(|| node.justified_checkpoint)
.then_some(node.justified_checkpoint)
.flatten()
})
.max_by_key(|justified_checkpoint| justified_checkpoint.epoch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl<T: BeaconChainTypes> VerifiedSyncContribution<T> {
let participant_pubkeys = sync_subcommittee_pubkeys
.into_iter()
.zip(contribution.aggregation_bits.iter())
.filter_map(|(pubkey, bit)| bit.then(|| pubkey))
.filter_map(|(pubkey, bit)| bit.then_some(pubkey))
.collect::<Vec<_>>();

// Ensure that all signatures are valid.
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/beacon_chain/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ where
selection_proof
.is_aggregator::<E>()
.expect("should determine aggregator")
.then(|| validator_index)
.then_some(validator_index)
})?;

let default = SyncCommitteeContribution::from_message(
Expand Down
2 changes: 1 addition & 1 deletion beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2531,7 +2531,7 @@ pub fn serve<T: BeaconChainTypes>(
|| matches!(validator_status, ValidatorStatus::Active);

// Filter out validators who are not 'active' or 'pending'.
is_active_or_pending.then(|| {
is_active_or_pending.then_some({
(
ProposerPreparationData {
validator_index: validator_index as u64,
Expand Down
4 changes: 1 addition & 3 deletions consensus/merkle_proof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ impl MerkleTree {
(Leaf(_), Leaf(_)) => return Err(MerkleTreeError::MerkleTreeFull),
// There is a right node so insert in right node
(Node(_, _, _), Node(_, _, _)) => {
if let Err(e) = right.push_leaf(elem, depth - 1) {
return Err(e);
}
right.push_leaf(elem, depth - 1)?;
}
// Both branches are zero, insert in left one
(Zero(_), Zero(_)) => {
Expand Down
2 changes: 1 addition & 1 deletion consensus/ssz_types/src/fixed_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ mod test {

assert_eq!(fixed[0], 1);
assert_eq!(&fixed[0..1], &vec[0..1]);
assert_eq!((&fixed[..]).len(), 8192);
assert_eq!((fixed[..]).len(), 8192);

fixed[1] = 3;
assert_eq!(fixed[1], 3);
Expand Down
2 changes: 1 addition & 1 deletion consensus/ssz_types/src/variable_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ mod test {

assert_eq!(fixed[0], 1);
assert_eq!(&fixed[0..1], &vec[0..1]);
assert_eq!((&fixed[..]).len(), 2);
assert_eq!((fixed[..]).len(), 2);

fixed[1] = 3;
assert_eq!(fixed[1], 3);
Expand Down
12 changes: 4 additions & 8 deletions validator_client/src/beacon_node_fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,12 @@ impl<E: EthSpec> CandidateBeaconNode<E> {
spec: &ChainSpec,
log: &Logger,
) -> Result<(), CandidateError> {
let new_status = if let Err(e) = self.is_online(log).await {
Err(e)
} else if let Err(e) = self.is_compatible(spec, log).await {
Err(e)
} else if let Err(e) = self.is_synced(slot_clock, log).await {
Err(e)
} else {
let new_status: Result<(), CandidateError> = {
self.is_online(log).await?;
self.is_compatible(spec, log).await?;
self.is_synced(slot_clock, log).await?;
Ok(())
};

// In case of concurrent use, the latest value will always be used. It's possible that a
// long time out might over-ride a recent successful response, leading to a falsely-offline
// status. I deem this edge-case acceptable in return for the concurrency benefits of not
Expand Down
2 changes: 1 addition & 1 deletion validator_client/src/preparation_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl<T: SlotClock + 'static, E: EthSpec> PreparationService<T, E> {
proposal_data.fee_recipient.and_then(|fee_recipient| {
proposal_data
.builder_proposals
.then(|| ValidatorRegistrationKey {
.then_some(ValidatorRegistrationKey {
fee_recipient,
gas_limit: proposal_data.gas_limit,
pubkey,
Expand Down

0 comments on commit 76c7257

Please sign in to comment.