Clippy 1.49.0 updates and dht persistence test fix (#2156)

## Issue Addressed

`test_dht_persistence` failing

## Proposed Changes

Bind `NetworkService::start` to an underscore prefixed variable rather than `_`.  `_` was causing it to be dropped immediately

This was failing 5/100 times before this update, but I haven't been able to get it to fail after updating it

Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
realbigsean
2021-01-19 00:34:28 +00:00
parent e5b1a37110
commit 7a71977987
29 changed files with 134 additions and 115 deletions

View File

@@ -24,15 +24,15 @@ pub fn u64_leaf_count(len: usize) -> usize {
(len + vals_per_chunk - 1) / vals_per_chunk
}
pub fn hash256_iter<'a>(
values: &'a [Hash256],
) -> impl Iterator<Item = [u8; BYTES_PER_CHUNK]> + ExactSizeIterator + 'a {
pub fn hash256_iter(
values: &[Hash256],
) -> impl Iterator<Item = [u8; BYTES_PER_CHUNK]> + ExactSizeIterator + '_ {
values.iter().copied().map(Hash256::to_fixed_bytes)
}
pub fn u64_iter<'a>(
values: &'a [u64],
) -> impl Iterator<Item = [u8; BYTES_PER_CHUNK]> + ExactSizeIterator + 'a {
pub fn u64_iter(
values: &[u64],
) -> impl Iterator<Item = [u8; BYTES_PER_CHUNK]> + ExactSizeIterator + '_ {
let type_size = size_of::<u64>();
let vals_per_chunk = BYTES_PER_CHUNK / type_size;
values.chunks(vals_per_chunk).map(move |xs| {

View File

@@ -4,7 +4,6 @@ use crate::{
};
use ssz_derive::{Decode, Encode};
use std::collections::HashMap;
use std::iter::FromIterator;
use types::{Epoch, Hash256};
#[derive(Encode, Decode)]
@@ -41,7 +40,7 @@ impl From<SszContainer> for ProtoArrayForkChoice {
justified_epoch: from.justified_epoch,
finalized_epoch: from.finalized_epoch,
nodes: from.nodes,
indices: HashMap::from_iter(from.indices.into_iter()),
indices: from.indices.into_iter().collect::<HashMap<_, _>>(),
};
Self {

View File

@@ -14,9 +14,7 @@ use syn::{parse_macro_input, DeriveInput};
///
/// # Panics
/// Any unnamed struct field (like in a tuple struct) will raise a panic at compile time.
fn get_serializable_named_field_idents<'a>(
struct_data: &'a syn::DataStruct,
) -> Vec<&'a syn::Ident> {
fn get_serializable_named_field_idents(struct_data: &syn::DataStruct) -> Vec<&syn::Ident> {
struct_data
.fields
.iter()
@@ -35,7 +33,7 @@ fn get_serializable_named_field_idents<'a>(
/// Returns a Vec of `syn::Type` for each named field in the struct, whilst filtering out fields
/// that should not be serialized.
fn get_serializable_field_types<'a>(struct_data: &'a syn::DataStruct) -> Vec<&'a syn::Type> {
fn get_serializable_field_types(struct_data: &syn::DataStruct) -> Vec<&syn::Type> {
struct_data
.fields
.iter()

View File

@@ -44,10 +44,10 @@ impl From<BeaconStateError> for Error {
}
/// Helper function to get a public key from a `state`.
pub fn get_pubkey_from_state<'a, T>(
state: &'a BeaconState<T>,
pub fn get_pubkey_from_state<T>(
state: &BeaconState<T>,
validator_index: usize,
) -> Option<Cow<'a, PublicKey>>
) -> Option<Cow<PublicKey>>
where
T: EthSpec,
{

View File

@@ -391,7 +391,7 @@ fn invalid_attestation_wrong_justified_checkpoint() {
root: Hash256::zero(),
},
attestation: Checkpoint {
epoch: Epoch::from(0 as u64),
epoch: Epoch::from(0_u64),
root: Hash256::zero(),
},
is_current: true,
@@ -877,7 +877,7 @@ fn invalid_proposer_slashing_proposal_epoch_mismatch() {
Err(BlockProcessingError::ProposerSlashingInvalid {
index: 0,
reason: ProposerSlashingInvalid::ProposalSlotMismatch(
Slot::from(0 as u64),
Slot::from(0_u64),
Slot::from(128 as u64)
)
})

View File

@@ -10,7 +10,7 @@ use syn::{parse_macro_input, Attribute, DeriveInput, Meta};
///
/// # Panics
/// Any unnamed struct field (like in a tuple struct) will raise a panic at compile time.
fn get_hashable_fields<'a>(struct_data: &'a syn::DataStruct) -> Vec<&'a syn::Ident> {
fn get_hashable_fields(struct_data: &syn::DataStruct) -> Vec<&syn::Ident> {
get_hashable_fields_and_their_caches(struct_data)
.into_iter()
.map(|(ident, _, _)| ident)
@@ -18,9 +18,9 @@ fn get_hashable_fields<'a>(struct_data: &'a syn::DataStruct) -> Vec<&'a syn::Ide
}
/// Return a Vec of the hashable fields of a struct, and each field's type and optional cache field.
fn get_hashable_fields_and_their_caches<'a>(
struct_data: &'a syn::DataStruct,
) -> Vec<(&'a syn::Ident, syn::Type, Option<syn::Ident>)> {
fn get_hashable_fields_and_their_caches(
struct_data: &syn::DataStruct,
) -> Vec<(&syn::Ident, syn::Type, Option<syn::Ident>)> {
struct_data
.fields
.iter()

View File

@@ -68,7 +68,7 @@ impl<T: EthSpec> BeaconBlock<T> {
};
let indexed_attestation: IndexedAttestation<T> = IndexedAttestation {
attesting_indices: VariableList::new(vec![
0 as u64;
0_u64;
T::MaxValidatorsPerCommittee::to_usize()
])
.unwrap(),

View File

@@ -69,7 +69,7 @@ impl TestingAttestationDataBuilder {
}
AttestationTestTask::WrongJustifiedCheckpoint => {
source = Checkpoint {
epoch: Epoch::from(0 as u64),
epoch: Epoch::from(0_u64),
root: Hash256::zero(),
}
}