Skip to content

Commit 303deb9

Browse files
committed
Rust 1.54.0 lints (#2483)
## Issue Addressed N/A ## Proposed Changes - Removing a bunch of unnecessary references - Updated `Error::VariantError` to `Error::Variant` - There were additional enum variant lints that I ignored, because I thought our variant names were fine - removed `MonitoredValidator`'s `pubkey` field, because I couldn't find it used anywhere. It looks like we just use the string version of the pubkey (the `id` field) if there is no index ## Additional Info Co-authored-by: realbigsean <[email protected]>
1 parent 8efd9fc commit 303deb9

File tree

104 files changed

+302
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+302
-308
lines changed

account_manager/src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn read_mnemonic_from_cli(
1919
.map_err(|e| format!("Unable to read {:?}: {:?}", path, e))
2020
.and_then(|bytes| {
2121
let bytes_no_newlines: PlainText = strip_off_newlines(bytes).into();
22-
let phrase = from_utf8(&bytes_no_newlines.as_ref())
22+
let phrase = from_utf8(bytes_no_newlines.as_ref())
2323
.map_err(|e| format!("Unable to derive mnemonic: {:?}", e))?;
2424
Mnemonic::from_phrase(phrase, Language::English).map_err(|e| {
2525
format!(

account_manager/src/validator/exit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn cli_app<'a, 'b>() -> App<'a, 'b> {
5151
.long(BEACON_SERVER_FLAG)
5252
.value_name("NETWORK_ADDRESS")
5353
.help("Address to a beacon node HTTP API")
54-
.default_value(&DEFAULT_BEACON_NODE)
54+
.default_value(DEFAULT_BEACON_NODE)
5555
.takes_value(true),
5656
)
5757
.arg(

account_manager/src/validator/slashing_protection.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ pub fn cli_run<T: EthSpec>(
8787

8888
match matches.subcommand() {
8989
(IMPORT_CMD, Some(matches)) => {
90-
let import_filename: PathBuf = clap_utils::parse_required(&matches, IMPORT_FILE_ARG)?;
91-
let minify: bool = clap_utils::parse_required(&matches, MINIFY_FLAG)?;
90+
let import_filename: PathBuf = clap_utils::parse_required(matches, IMPORT_FILE_ARG)?;
91+
let minify: bool = clap_utils::parse_required(matches, MINIFY_FLAG)?;
9292
let import_file = File::open(&import_filename).map_err(|e| {
9393
format!(
9494
"Unable to open import file at {}: {:?}",
@@ -199,8 +199,8 @@ pub fn cli_run<T: EthSpec>(
199199
Ok(())
200200
}
201201
(EXPORT_CMD, Some(matches)) => {
202-
let export_filename: PathBuf = clap_utils::parse_required(&matches, EXPORT_FILE_ARG)?;
203-
let minify: bool = clap_utils::parse_required(&matches, MINIFY_FLAG)?;
202+
let export_filename: PathBuf = clap_utils::parse_required(matches, EXPORT_FILE_ARG)?;
203+
let minify: bool = clap_utils::parse_required(matches, MINIFY_FLAG)?;
204204

205205
if !slashing_protection_db_path.exists() {
206206
return Err(format!(

account_manager/src/wallet/create.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub fn cli_run(matches: &ArgMatches, wallet_base_dir: PathBuf) -> Result<(), Str
114114
Language::English,
115115
);
116116

117-
let wallet = create_wallet_from_mnemonic(matches, &wallet_base_dir.as_path(), &mnemonic)?;
117+
let wallet = create_wallet_from_mnemonic(matches, wallet_base_dir.as_path(), &mnemonic)?;
118118

119119
if let Some(path) = mnemonic_output_path {
120120
create_with_600_perms(&path, mnemonic.phrase().as_bytes())
@@ -168,7 +168,7 @@ pub fn create_wallet_from_mnemonic(
168168
if !path.exists() {
169169
// To prevent users from accidentally supplying their password to the PASSWORD_FLAG and
170170
// create a file with that name, we require that the password has a .pass suffix.
171-
if path.extension() != Some(&OsStr::new("pass")) {
171+
if path.extension() != Some(OsStr::new("pass")) {
172172
return Err(format!(
173173
"Only creates a password file if that file ends in .pass: {:?}",
174174
path
@@ -189,7 +189,7 @@ pub fn create_wallet_from_mnemonic(
189189
.create_wallet(
190190
wallet_name,
191191
wallet_type,
192-
&mnemonic,
192+
mnemonic,
193193
wallet_password.as_bytes(),
194194
)
195195
.map_err(|e| format!("Unable to create wallet: {:?}", e))?;

account_manager/src/wallet/recover.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ pub fn cli_run(matches: &ArgMatches, wallet_base_dir: PathBuf) -> Result<(), Str
7171

7272
let mnemonic = read_mnemonic_from_cli(mnemonic_path, stdin_inputs)?;
7373

74-
let wallet = create_wallet_from_mnemonic(matches, &wallet_base_dir.as_path(), &mnemonic)
74+
let wallet = create_wallet_from_mnemonic(matches, wallet_base_dir.as_path(), &mnemonic)
7575
.map_err(|e| format!("Unable to create wallet: {:?}", e))?;
7676

7777
println!("Your wallet has been successfully recovered.");

beacon_node/beacon_chain/src/attestation_verification.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ impl<T: BeaconChainTypes> VerifiedAggregatedAttestation<T> {
448448
//
449449
// Attestations must be for a known block. If the block is unknown, we simply drop the
450450
// attestation and do not delay consideration for later.
451-
let head_block = verify_head_block_is_known(chain, &attestation, None)?;
451+
let head_block = verify_head_block_is_known(chain, attestation, None)?;
452452

453453
// Check the attestation target root is consistent with the head root.
454454
//
@@ -457,7 +457,7 @@ impl<T: BeaconChainTypes> VerifiedAggregatedAttestation<T> {
457457
//
458458
// Whilst this attestation *technically* could be used to add value to a block, it is
459459
// invalid in the spirit of the protocol. Here we choose safety over profit.
460-
verify_attestation_target_root::<T::EthSpec>(&head_block, &attestation)?;
460+
verify_attestation_target_root::<T::EthSpec>(&head_block, attestation)?;
461461

462462
// Ensure that the attestation has participants.
463463
if attestation.aggregation_bits.is_zero() {
@@ -628,7 +628,7 @@ impl<T: BeaconChainTypes> VerifiedUnaggregatedAttestation<T> {
628628
// MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance).
629629
//
630630
// We do not queue future attestations for later processing.
631-
verify_propagation_slot_range(chain, &attestation)?;
631+
verify_propagation_slot_range(chain, attestation)?;
632632

633633
// Check to ensure that the attestation is "unaggregated". I.e., it has exactly one
634634
// aggregation bit set.
@@ -642,10 +642,10 @@ impl<T: BeaconChainTypes> VerifiedUnaggregatedAttestation<T> {
642642
//
643643
// Enforce a maximum skip distance for unaggregated attestations.
644644
let head_block =
645-
verify_head_block_is_known(chain, &attestation, chain.config.import_max_skip_slots)?;
645+
verify_head_block_is_known(chain, attestation, chain.config.import_max_skip_slots)?;
646646

647647
// Check the attestation target root is consistent with the head root.
648-
verify_attestation_target_root::<T::EthSpec>(&head_block, &attestation)?;
648+
verify_attestation_target_root::<T::EthSpec>(&head_block, attestation)?;
649649

650650
Ok(())
651651
}
@@ -927,7 +927,7 @@ pub fn verify_attestation_signature<T: BeaconChainTypes>(
927927
let signature_set = indexed_attestation_signature_set_from_pubkeys(
928928
|validator_index| pubkey_cache.get(validator_index).map(Cow::Borrowed),
929929
&indexed_attestation.signature,
930-
&indexed_attestation,
930+
indexed_attestation,
931931
&fork,
932932
chain.genesis_validators_root,
933933
&chain.spec,
@@ -1031,15 +1031,15 @@ pub fn verify_signed_aggregate_signatures<T: BeaconChainTypes>(
10311031
let signature_sets = vec![
10321032
signed_aggregate_selection_proof_signature_set(
10331033
|validator_index| pubkey_cache.get(validator_index).map(Cow::Borrowed),
1034-
&signed_aggregate,
1034+
signed_aggregate,
10351035
&fork,
10361036
chain.genesis_validators_root,
10371037
&chain.spec,
10381038
)
10391039
.map_err(BeaconChainError::SignatureSetError)?,
10401040
signed_aggregate_signature_set(
10411041
|validator_index| pubkey_cache.get(validator_index).map(Cow::Borrowed),
1042-
&signed_aggregate,
1042+
signed_aggregate,
10431043
&fork,
10441044
chain.genesis_validators_root,
10451045
&chain.spec,
@@ -1048,7 +1048,7 @@ pub fn verify_signed_aggregate_signatures<T: BeaconChainTypes>(
10481048
indexed_attestation_signature_set_from_pubkeys(
10491049
|validator_index| pubkey_cache.get(validator_index).map(Cow::Borrowed),
10501050
&indexed_attestation.signature,
1051-
&indexed_attestation,
1051+
indexed_attestation,
10521052
&fork,
10531053
chain.genesis_validators_root,
10541054
&chain.spec,
@@ -1069,7 +1069,7 @@ fn obtain_indexed_attestation_and_committees_per_slot<T: BeaconChainTypes>(
10691069
attestation: &Attestation<T::EthSpec>,
10701070
) -> Result<(IndexedAttestation<T::EthSpec>, CommitteesPerSlot), Error> {
10711071
map_attestation_committee(chain, attestation, |(committee, committees_per_slot)| {
1072-
get_indexed_attestation(committee.committee, &attestation)
1072+
get_indexed_attestation(committee.committee, attestation)
10731073
.map(|attestation| (attestation, committees_per_slot))
10741074
.map_err(Error::Invalid)
10751075
})

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,7 +1372,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
13721372
attester_cache_key,
13731373
request_slot,
13741374
request_index,
1375-
&self,
1375+
self,
13761376
)?
13771377
};
13781378
drop(cache_timer);
@@ -1729,7 +1729,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
17291729
self.shuffling_is_compatible(
17301730
&att.data.beacon_block_root,
17311731
att.data.target.epoch,
1732-
&state,
1732+
state,
17331733
)
17341734
})
17351735
}
@@ -2182,9 +2182,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
21822182
for attestation in signed_block.message().body().attestations() {
21832183
let committee =
21842184
state.get_beacon_committee(attestation.data.slot, attestation.data.index)?;
2185-
let indexed_attestation =
2186-
get_indexed_attestation(&committee.committee, attestation)
2187-
.map_err(|e| BlockError::BeaconChainError(e.into()))?;
2185+
let indexed_attestation = get_indexed_attestation(committee.committee, attestation)
2186+
.map_err(|e| BlockError::BeaconChainError(e.into()))?;
21882187
slasher.accept_attestation(indexed_attestation);
21892188
}
21902189
}
@@ -3267,7 +3266,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
32673266

32683267
metrics::stop_timer(committee_building_timer);
32693268

3270-
map_fn(&committee_cache, shuffling_decision_block)
3269+
map_fn(committee_cache, shuffling_decision_block)
32713270
}
32723271
}
32733272

beacon_node/beacon_chain/src/block_verification.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ impl<T: EthSpec> From<DBError> for BlockError<T> {
278278
}
279279

280280
/// Information about invalid blocks which might still be slashable despite being invalid.
281+
#[allow(clippy::enum_variant_names)]
281282
pub enum BlockSlashInfo<TErr> {
282283
/// The block is invalid, but its proposer signature wasn't checked.
283284
SignatureNotChecked(SignedBeaconBlockHeader, TErr),
@@ -837,7 +838,7 @@ impl<T: BeaconChainTypes> IntoFullyVerifiedBlock<T> for SignedBeaconBlock<T::Eth
837838
}
838839

839840
fn block(&self) -> &SignedBeaconBlock<T::EthSpec> {
840-
&self
841+
self
841842
}
842843
}
843844

@@ -996,7 +997,7 @@ impl<'a, T: BeaconChainTypes> FullyVerifiedBlock<'a, T> {
996997
for (i, summary) in summaries.iter().enumerate() {
997998
let epoch = state.current_epoch() - Epoch::from(summaries.len() - i);
998999
if let Err(e) =
999-
validator_monitor.process_validator_statuses(epoch, &summary, &chain.spec)
1000+
validator_monitor.process_validator_statuses(epoch, summary, &chain.spec)
10001001
{
10011002
error!(
10021003
chain.log,
@@ -1204,7 +1205,7 @@ pub fn check_block_relevancy<T: BeaconChainTypes>(
12041205
// Do not process a block from a finalized slot.
12051206
check_block_against_finalized_slot(block, chain)?;
12061207

1207-
let block_root = block_root.unwrap_or_else(|| get_block_root(&signed_block));
1208+
let block_root = block_root.unwrap_or_else(|| get_block_root(signed_block));
12081209

12091210
// Check if the block is already known. We know it is post-finalization, so it is
12101211
// sufficient to check the fork choice.

beacon_node/beacon_chain/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ fn genesis_block<T: EthSpec>(
666666
genesis_state: &mut BeaconState<T>,
667667
spec: &ChainSpec,
668668
) -> Result<SignedBeaconBlock<T>, String> {
669-
let mut genesis_block = BeaconBlock::empty(&spec);
669+
let mut genesis_block = BeaconBlock::empty(spec);
670670
*genesis_block.state_root_mut() = genesis_state
671671
.update_tree_hash_cache()
672672
.map_err(|e| format!("Error hashing genesis state: {:?}", e))?;

beacon_node/beacon_chain/src/eth1_chain.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ mod test {
762762
"test should not use dummy backend"
763763
);
764764

765-
let mut state: BeaconState<E> = BeaconState::new(0, get_eth1_data(0), &spec);
765+
let mut state: BeaconState<E> = BeaconState::new(0, get_eth1_data(0), spec);
766766
*state.eth1_deposit_index_mut() = 0;
767767
state.eth1_data_mut().deposit_count = 0;
768768

@@ -815,7 +815,7 @@ mod test {
815815
"cache should store all logs"
816816
);
817817

818-
let mut state: BeaconState<E> = BeaconState::new(0, get_eth1_data(0), &spec);
818+
let mut state: BeaconState<E> = BeaconState::new(0, get_eth1_data(0), spec);
819819
*state.eth1_deposit_index_mut() = 0;
820820
state.eth1_data_mut().deposit_count = 0;
821821

@@ -877,10 +877,10 @@ mod test {
877877
"test should not use dummy backend"
878878
);
879879

880-
let state: BeaconState<E> = BeaconState::new(0, get_eth1_data(0), &spec);
880+
let state: BeaconState<E> = BeaconState::new(0, get_eth1_data(0), spec);
881881

882882
let a = eth1_chain
883-
.eth1_data_for_block_production(&state, &spec)
883+
.eth1_data_for_block_production(&state, spec)
884884
.expect("should produce default eth1 data vote");
885885
assert_eq!(
886886
a,
@@ -902,11 +902,11 @@ mod test {
902902
"test should not use dummy backend"
903903
);
904904

905-
let mut state: BeaconState<E> = BeaconState::new(0, get_eth1_data(0), &spec);
905+
let mut state: BeaconState<E> = BeaconState::new(0, get_eth1_data(0), spec);
906906

907907
*state.slot_mut() = Slot::from(slots_per_eth1_voting_period * 10);
908908
let follow_distance_seconds = eth1_follow_distance * spec.seconds_per_eth1_block;
909-
let voting_period_start = get_voting_period_start_seconds(&state, &spec);
909+
let voting_period_start = get_voting_period_start_seconds(&state, spec);
910910
let start_eth1_block = voting_period_start - follow_distance_seconds * 2;
911911
let end_eth1_block = voting_period_start - follow_distance_seconds;
912912

@@ -926,7 +926,7 @@ mod test {
926926
});
927927

928928
let vote = eth1_chain
929-
.eth1_data_for_block_production(&state, &spec)
929+
.eth1_data_for_block_production(&state, spec)
930930
.expect("should produce default eth1 data vote");
931931

932932
assert_eq!(
@@ -956,7 +956,7 @@ mod test {
956956
get_votes_to_consider(
957957
blocks.iter(),
958958
get_voting_period_start_seconds(&state, spec),
959-
&spec,
959+
spec,
960960
),
961961
HashMap::new()
962962
);

0 commit comments

Comments
 (0)