mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 05:18:30 +00:00
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 <seananderson33@gmail.com>
This commit is contained in:
@@ -489,7 +489,7 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
) -> Result<&[usize], Error> {
|
||||
let cache = self.committee_cache(relative_epoch)?;
|
||||
|
||||
Ok(&cache.active_validator_indices())
|
||||
Ok(cache.active_validator_indices())
|
||||
}
|
||||
|
||||
/// Returns the active validator indices for the given epoch.
|
||||
@@ -770,7 +770,7 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
.pubkeys
|
||||
.iter()
|
||||
.map(|pubkey| {
|
||||
self.get_validator_index(&pubkey)?
|
||||
self.get_validator_index(pubkey)?
|
||||
.ok_or(Error::PubkeyCacheInconsistent)
|
||||
})
|
||||
.collect()
|
||||
@@ -1326,7 +1326,7 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
epoch: Epoch,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<CommitteeCache, Error> {
|
||||
CommitteeCache::initialized(&self, epoch, spec)
|
||||
CommitteeCache::initialized(self, epoch, spec)
|
||||
}
|
||||
|
||||
/// Advances the cache for this state into the next epoch.
|
||||
@@ -1438,7 +1438,7 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
if let Some(mut cache) = cache {
|
||||
// Note: we return early if the tree hash fails, leaving `self.tree_hash_cache` as
|
||||
// None. There's no need to keep a cache that fails.
|
||||
let root = cache.recalculate_tree_hash_root(&self)?;
|
||||
let root = cache.recalculate_tree_hash_root(self)?;
|
||||
self.tree_hash_cache_mut().restore(cache);
|
||||
Ok(root)
|
||||
} else {
|
||||
|
||||
@@ -67,13 +67,13 @@ fn initializes_with_the_right_epoch() {
|
||||
let cache = CommitteeCache::default();
|
||||
assert!(!cache.is_initialized_at(state.current_epoch()));
|
||||
|
||||
let cache = CommitteeCache::initialized(&state, state.current_epoch(), &spec).unwrap();
|
||||
let cache = CommitteeCache::initialized(&state, state.current_epoch(), spec).unwrap();
|
||||
assert!(cache.is_initialized_at(state.current_epoch()));
|
||||
|
||||
let cache = CommitteeCache::initialized(&state, state.previous_epoch(), &spec).unwrap();
|
||||
let cache = CommitteeCache::initialized(&state, state.previous_epoch(), spec).unwrap();
|
||||
assert!(cache.is_initialized_at(state.previous_epoch()));
|
||||
|
||||
let cache = CommitteeCache::initialized(&state, state.next_epoch().unwrap(), &spec).unwrap();
|
||||
let cache = CommitteeCache::initialized(&state, state.next_epoch().unwrap(), spec).unwrap();
|
||||
assert!(cache.is_initialized_at(state.next_epoch().unwrap()));
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ fn test_beacon_proposer_index<T: EthSpec>() {
|
||||
// Get the i'th candidate proposer for the given state and slot
|
||||
let ith_candidate = |state: &BeaconState<T>, slot: Slot, i: usize, spec: &ChainSpec| {
|
||||
let epoch = slot.epoch(T::slots_per_epoch());
|
||||
let seed = state.get_beacon_proposer_seed(slot, &spec).unwrap();
|
||||
let seed = state.get_beacon_proposer_seed(slot, spec).unwrap();
|
||||
let active_validators = state.get_active_validator_indices(epoch, spec).unwrap();
|
||||
active_validators[compute_shuffled_index(
|
||||
i,
|
||||
@@ -338,7 +338,7 @@ mod committees {
|
||||
new_head_state,
|
||||
cache_epoch,
|
||||
validator_count as usize,
|
||||
&spec,
|
||||
spec,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -247,7 +247,7 @@ impl<T: EthSpec> BeaconTreeHashCacheInner<T> {
|
||||
hasher.write(state.eth1_data().tree_hash_root().as_bytes())?;
|
||||
hasher.write(
|
||||
self.eth1_data_votes
|
||||
.recalculate_tree_hash_root(&state)?
|
||||
.recalculate_tree_hash_root(state)?
|
||||
.as_bytes(),
|
||||
)?;
|
||||
hasher.write(state.eth1_deposit_index().tree_hash_root().as_bytes())?;
|
||||
|
||||
@@ -84,7 +84,7 @@ impl Into<Graffiti> for GraffitiString {
|
||||
graffiti
|
||||
.get_mut(..graffiti_len)
|
||||
.expect("graffiti_len <= GRAFFITI_BYTES_LEN")
|
||||
.copy_from_slice(&graffiti_bytes);
|
||||
.copy_from_slice(graffiti_bytes);
|
||||
graffiti.into()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ impl<'a, N: Unsigned> CachedTreeHash<TreeHashCache> for ParticipationList<'a, N>
|
||||
cache: &mut TreeHashCache,
|
||||
) -> Result<Hash256, Error> {
|
||||
Ok(mix_in_length(
|
||||
&cache.recalculate_merkle_root(arena, leaf_iter(&self.inner))?,
|
||||
&cache.recalculate_merkle_root(arena, leaf_iter(self.inner))?,
|
||||
self.inner.len(),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ pub struct SubnetId(#[serde(with = "serde_utils::quoted_u64")] u64);
|
||||
|
||||
pub fn subnet_id_to_string(i: u64) -> &'static str {
|
||||
if i < MAX_SUBNET_ID as u64 {
|
||||
&SUBNET_ID_TO_STRING
|
||||
SUBNET_ID_TO_STRING
|
||||
.get(i as usize)
|
||||
.expect("index below MAX_SUBNET_ID")
|
||||
} else {
|
||||
|
||||
@@ -21,7 +21,7 @@ pub struct SyncSubnetId(#[serde(with = "serde_utils::quoted_u64")] u64);
|
||||
|
||||
pub fn sync_subnet_id_to_string(i: u64) -> &'static str {
|
||||
if i < SYNC_COMMITTEE_SUBNET_COUNT {
|
||||
&SYNC_SUBNET_ID_TO_STRING
|
||||
SYNC_SUBNET_ID_TO_STRING
|
||||
.get(i as usize)
|
||||
.expect("index below SYNC_COMMITTEE_SUBNET_COUNT")
|
||||
} else {
|
||||
|
||||
@@ -77,7 +77,7 @@ fn process_pubkey_bytes_field(
|
||||
|
||||
fn process_slice_field(new_tree_hash: &[u8], leaf: &mut Hash256, force_update: bool) -> bool {
|
||||
if force_update || leaf.as_bytes() != new_tree_hash {
|
||||
leaf.assign_from_slice(&new_tree_hash);
|
||||
leaf.assign_from_slice(new_tree_hash);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
||||
Reference in New Issue
Block a user