1.57.0 lints (#2850)

## Issue Addressed

New rust lints

## Proposed Changes

- Boxing some enum variants
- removing some unused fields (is the validator lockfile unused? seemed so to me)

## Additional Info

- some error fields were marked as dead code but are logged out in areas
- left some dead fields in our ef test code because I assume they are useful for debugging?

Co-authored-by: realbigsean <seananderson33@gmail.com>
This commit is contained in:
realbigsean
2021-12-03 04:44:30 +00:00
parent f3c237cfa0
commit a80ccc3a33
22 changed files with 64 additions and 56 deletions
+4 -2
View File
@@ -1602,7 +1602,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// This method is called for API and gossip attestations, so this covers all unaggregated attestation events
if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_attestation_subscribers() {
event_handler.register(EventKind::Attestation(v.attestation().clone()));
event_handler
.register(EventKind::Attestation(Box::new(v.attestation().clone())));
}
}
metrics::inc_counter(&metrics::UNAGGREGATED_ATTESTATION_PROCESSING_SUCCESSES);
@@ -1638,7 +1639,8 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
// This method is called for API and gossip attestations, so this covers all aggregated attestation events
if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_attestation_subscribers() {
event_handler.register(EventKind::Attestation(v.attestation().clone()));
event_handler
.register(EventKind::Attestation(Box::new(v.attestation().clone())));
}
}
metrics::inc_counter(&metrics::AGGREGATED_ATTESTATION_PROCESSING_SUCCESSES);
@@ -41,9 +41,17 @@ const MAX_ADVANCE_DISTANCE: u64 = 4;
enum Error {
BeaconChain(BeaconChainError),
HeadMissingFromSnapshotCache(Hash256),
MaxDistanceExceeded { current_slot: Slot, head_slot: Slot },
StateAlreadyAdvanced { block_root: Hash256 },
BadStateSlot { state_slot: Slot, block_slot: Slot },
MaxDistanceExceeded {
current_slot: Slot,
head_slot: Slot,
},
StateAlreadyAdvanced {
block_root: Hash256,
},
BadStateSlot {
_state_slot: Slot,
_block_slot: Slot,
},
}
impl From<BeaconChainError> for Error {
@@ -224,8 +232,8 @@ fn advance_head<T: BeaconChainTypes>(
// Advancing more than one slot without storing the intermediate state would corrupt the
// database. Future works might store temporary, intermediate states inside this function.
return Err(Error::BadStateSlot {
block_slot: head_slot,
state_slot: state.slot(),
_block_slot: head_slot,
_state_slot: state.slot(),
});
};
@@ -243,8 +243,8 @@ enum Error {
/// The file read from disk does not have a contiguous list of validator public keys. The file
/// has become corrupted.
InconsistentIndex {
expected: Option<usize>,
found: usize,
_expected: Option<usize>,
_found: usize,
},
}
@@ -296,8 +296,8 @@ impl ValidatorPubkeyCacheFile {
indices.insert(pubkey, index);
} else {
return Err(Error::InconsistentIndex {
expected,
found: index,
_expected: expected,
_found: index,
});
}
}
+1 -1
View File
@@ -2310,7 +2310,7 @@ impl ApiTester {
self.attestations
.clone()
.into_iter()
.map(|attestation| EventKind::Attestation(attestation))
.map(|attestation| EventKind::Attestation(Box::new(attestation)))
.collect::<Vec<_>>()
.as_slice()
);
@@ -63,7 +63,7 @@ use types::{
SyncCommitteeMessage, SyncSubnetId,
};
use work_reprocessing_queue::{
spawn_reprocess_scheduler, QueuedAggregate, QueuedBlock, QueuedUnaggregate, ReadyWork,
spawn_reprocess_scheduler, QueuedAggregate, QueuedUnaggregate, ReadyWork,
};
use worker::{Toolbox, Worker};
@@ -72,6 +72,7 @@ mod tests;
mod work_reprocessing_queue;
mod worker;
use crate::beacon_processor::work_reprocessing_queue::QueuedBlock;
pub use worker::{GossipAggregatePackage, GossipAttestationPackage, ProcessId};
/// The maximum size of the channel for work events to the `BeaconProcessor`.
@@ -574,7 +575,7 @@ impl<T: BeaconChainTypes> std::convert::From<ReadyWork<T>> for WorkEvent<T> {
drop_during_sync: false,
work: Work::DelayedImportBlock {
peer_id,
block: Box::new(block),
block,
seen_timestamp,
},
},
@@ -91,7 +91,7 @@ pub struct QueuedAggregate<T: EthSpec> {
/// A block that arrived early and has been queued for later import.
pub struct QueuedBlock<T: BeaconChainTypes> {
pub peer_id: PeerId,
pub block: GossipVerifiedBlock<T>,
pub block: Box<GossipVerifiedBlock<T>>,
pub seen_timestamp: Duration,
}
@@ -121,7 +121,6 @@ pub struct GossipAttestationPackage<E: EthSpec> {
peer_id: PeerId,
attestation: Box<Attestation<E>>,
subnet_id: SubnetId,
beacon_block_root: Hash256,
should_import: bool,
seen_timestamp: Duration,
}
@@ -138,7 +137,6 @@ impl<E: EthSpec> GossipAttestationPackage<E> {
Self {
message_id,
peer_id,
beacon_block_root: attestation.data.beacon_block_root,
attestation,
subnet_id,
should_import,
@@ -830,7 +828,7 @@ impl<T: BeaconChainTypes> Worker<T> {
if reprocess_tx
.try_send(ReprocessQueueMessage::EarlyBlock(QueuedBlock {
peer_id,
block: verified_block,
block: Box::new(verified_block),
seen_timestamp: seen_duration,
}))
.is_err()
+2 -2
View File
@@ -226,7 +226,7 @@ pub fn get_config<E: EthSpec>(
client_config.sync_eth1_chain = true;
client_config.eth1.endpoints = endpoints
.split(',')
.map(|s| SensitiveUrl::parse(s))
.map(SensitiveUrl::parse)
.collect::<Result<_, _>>()
.map_err(|e| format!("eth1-endpoints contains an invalid URL {:?}", e))?;
}
@@ -245,7 +245,7 @@ pub fn get_config<E: EthSpec>(
client_config.sync_eth1_chain = true;
client_config.execution_endpoints = endpoints
.split(',')
.map(|s| SensitiveUrl::parse(s))
.map(SensitiveUrl::parse)
.collect::<Result<_, _>>()
.map(Some)
.map_err(|e| format!("execution-endpoints contains an invalid URL {:?}", e))?;