diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index ea1c5089a36..e2fe80a49f1 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -72,7 +72,7 @@ use crate::{ kzg_utils, metrics, AvailabilityPendingExecutedBlock, BeaconChainError, BeaconForkChoiceStore, BeaconSnapshot, CachedHead, }; -use eth2::types::{EventKind, SseBlobSidecar, SseBlock, SseExtendedPayloadAttributes, SyncDuty}; +use eth2::types::{EventKind, SseBlobSidecar, SseBlock, SseExtendedPayloadAttributes}; use execution_layer::{ BlockProposalContents, BlockProposalContentsType, BuilderParams, ChainHealth, ExecutionLayer, FailedCondition, PayloadAttributes, PayloadStatus, @@ -120,8 +120,7 @@ use store::{ use task_executor::{ShutdownReason, TaskExecutor}; use tokio_stream::Stream; use tree_hash::TreeHash; -use types::beacon_state::CloneConfig; -use types::blob_sidecar::{BlobSidecarList, FixedBlobSidecarList}; +use types::blob_sidecar::FixedBlobSidecarList; use types::payload::BlockProductionVersion; use types::*; diff --git a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs index 80cbc6c8990..b0afcc5e676 100644 --- a/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs +++ b/beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs @@ -780,7 +780,7 @@ mod test { use store::{HotColdDB, ItemStore, LevelDB, StoreConfig}; use tempfile::{tempdir, TempDir}; use types::non_zero_usize::new_non_zero_usize; - use types::{ChainSpec, ExecPayload, MinimalEthSpec}; + use types::{ExecPayload, MinimalEthSpec}; const LOW_VALIDATOR_COUNT: usize = 32; diff --git a/beacon_node/beacon_chain/src/early_attester_cache.rs b/beacon_node/beacon_chain/src/early_attester_cache.rs index da3c2c8a1e9..79d732f51b1 100644 --- a/beacon_node/beacon_chain/src/early_attester_cache.rs +++ b/beacon_node/beacon_chain/src/early_attester_cache.rs @@ -6,7 +6,6 @@ use crate::{ use parking_lot::RwLock; use proto_array::Block as ProtoBlock; use std::sync::Arc; -use types::blob_sidecar::BlobSidecarList; use types::*; pub struct CacheItem { diff --git a/beacon_node/beacon_chain/src/eth1_chain.rs b/beacon_node/beacon_chain/src/eth1_chain.rs index 563c2965981..74e12ec951c 100644 --- a/beacon_node/beacon_chain/src/eth1_chain.rs +++ b/beacon_node/beacon_chain/src/eth1_chain.rs @@ -9,7 +9,6 @@ use ssz_derive::{Decode, Encode}; use state_processing::per_block_processing::get_new_eth1_data; use std::cmp::Ordering; use std::collections::HashMap; -use std::iter::DoubleEndedIterator; use std::marker::PhantomData; use std::time::{SystemTime, UNIX_EPOCH}; use store::{DBColumn, Error as StoreError, StoreItem}; @@ -736,7 +735,7 @@ mod test { mod eth1_chain_json_backend { use super::*; use eth1::DepositLog; - use types::{test_utils::generate_deterministic_keypair, EthSpec, MainnetEthSpec}; + use types::{test_utils::generate_deterministic_keypair, MainnetEthSpec}; fn get_eth1_chain() -> Eth1Chain, E> { let eth1_config = Eth1Config { diff --git a/beacon_node/beacon_chain/src/observed_blob_sidecars.rs b/beacon_node/beacon_chain/src/observed_blob_sidecars.rs index 148d85befb8..00a27896188 100644 --- a/beacon_node/beacon_chain/src/observed_blob_sidecars.rs +++ b/beacon_node/beacon_chain/src/observed_blob_sidecars.rs @@ -111,7 +111,7 @@ mod tests { use super::*; use bls::Hash256; use std::sync::Arc; - use types::{BlobSidecar, MainnetEthSpec}; + use types::MainnetEthSpec; type E = MainnetEthSpec; diff --git a/beacon_node/beacon_chain/src/snapshot_cache.rs b/beacon_node/beacon_chain/src/snapshot_cache.rs index 765ed0cb2aa..0dcbab94587 100644 --- a/beacon_node/beacon_chain/src/snapshot_cache.rs +++ b/beacon_node/beacon_chain/src/snapshot_cache.rs @@ -367,10 +367,7 @@ impl SnapshotCache { mod test { use super::*; use crate::test_utils::{BeaconChainHarness, EphemeralHarnessType}; - use types::{ - test_utils::generate_deterministic_keypair, BeaconBlock, Epoch, MainnetEthSpec, - SignedBeaconBlock, Slot, - }; + use types::{test_utils::generate_deterministic_keypair, BeaconBlock, MainnetEthSpec}; fn get_harness() -> BeaconChainHarness> { let harness = BeaconChainHarness::builder(MainnetEthSpec) diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index 6b85c8e4931..5370294d8a7 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -61,7 +61,6 @@ use task_executor::TaskExecutor; use task_executor::{test_utils::TestRuntime, ShutdownReason}; use tree_hash::TreeHash; use types::payload::BlockProductionVersion; -use types::sync_selection_proof::SyncSelectionProof; pub use types::test_utils::generate_deterministic_keypairs; use types::test_utils::TestRandom; use types::{typenum::U4294967296, *}; diff --git a/beacon_node/beacon_chain/src/validator_monitor.rs b/beacon_node/beacon_chain/src/validator_monitor.rs index 49a555816b8..5dfda3361dc 100644 --- a/beacon_node/beacon_chain/src/validator_monitor.rs +++ b/beacon_node/beacon_chain/src/validator_monitor.rs @@ -15,7 +15,6 @@ use state_processing::per_epoch_processing::{ errors::EpochProcessingError, EpochProcessingSummary, }; use std::collections::{HashMap, HashSet}; -use std::convert::TryFrom; use std::io; use std::marker::PhantomData; use std::str::Utf8Error; diff --git a/beacon_node/beacon_chain/src/validator_pubkey_cache.rs b/beacon_node/beacon_chain/src/validator_pubkey_cache.rs index 00140dd6ec0..2cf0c326158 100644 --- a/beacon_node/beacon_chain/src/validator_pubkey_cache.rs +++ b/beacon_node/beacon_chain/src/validator_pubkey_cache.rs @@ -2,7 +2,6 @@ use crate::errors::BeaconChainError; use crate::{BeaconChainTypes, BeaconStore}; use ssz::{Decode, Encode}; use std::collections::HashMap; -use std::convert::TryInto; use std::marker::PhantomData; use store::{DBColumn, Error as StoreError, StoreItem, StoreOp}; use types::{BeaconState, Hash256, PublicKey, PublicKeyBytes}; @@ -195,7 +194,7 @@ mod test { use logging::test_logger; use std::sync::Arc; use store::HotColdDB; - use types::{BeaconState, EthSpec, Keypair, MainnetEthSpec}; + use types::{EthSpec, Keypair, MainnetEthSpec}; type E = MainnetEthSpec; type T = EphemeralHarnessType; diff --git a/beacon_node/beacon_processor/src/work_reprocessing_queue.rs b/beacon_node/beacon_processor/src/work_reprocessing_queue.rs index 20f3e21d084..4d9cf68e9ef 100644 --- a/beacon_node/beacon_processor/src/work_reprocessing_queue.rs +++ b/beacon_node/beacon_processor/src/work_reprocessing_queue.rs @@ -964,7 +964,6 @@ impl ReprocessQueue { mod tests { use super::*; use slot_clock::TestingSlotClock; - use types::Slot; #[test] fn backfill_processing_schedule_calculation() { diff --git a/beacon_node/client/src/config.rs b/beacon_node/client/src/config.rs index 197f21c64ed..48ad77abc58 100644 --- a/beacon_node/client/src/config.rs +++ b/beacon_node/client/src/config.rs @@ -118,7 +118,7 @@ impl Default for Config { impl Config { /// Updates the data directory for the Client. pub fn set_data_dir(&mut self, data_dir: PathBuf) { - self.data_dir = data_dir.clone(); + self.data_dir.clone_from(&data_dir); self.http_api.data_dir = data_dir; } diff --git a/beacon_node/eth1/src/block_cache.rs b/beacon_node/eth1/src/block_cache.rs index e676d17ab91..399634a9fab 100644 --- a/beacon_node/eth1/src/block_cache.rs +++ b/beacon_node/eth1/src/block_cache.rs @@ -196,7 +196,6 @@ impl BlockCache { #[cfg(test)] mod tests { use super::*; - use types::Hash256; fn get_block(i: u64, interval_secs: u64) -> Eth1Block { Eth1Block { diff --git a/beacon_node/eth1/tests/test.rs b/beacon_node/eth1/tests/test.rs index 505e4a47968..0479ea7c585 100644 --- a/beacon_node/eth1/tests/test.rs +++ b/beacon_node/eth1/tests/test.rs @@ -99,7 +99,6 @@ async fn new_anvil_instance() -> Result { mod eth1_cache { use super::*; - use types::{EthSpec, MainnetEthSpec}; #[tokio::test] async fn simple_scenario() { diff --git a/beacon_node/execution_layer/src/engine_api.rs b/beacon_node/execution_layer/src/engine_api.rs index e20009e2858..511b38892c6 100644 --- a/beacon_node/execution_layer/src/engine_api.rs +++ b/beacon_node/execution_layer/src/engine_api.rs @@ -17,7 +17,6 @@ pub use json_structures::{JsonWithdrawal, TransitionConfigurationV1}; use pretty_reqwest_error::PrettyReqwestError; use reqwest::StatusCode; use serde::{Deserialize, Serialize}; -use std::convert::TryFrom; use strum::IntoStaticStr; use superstruct::superstruct; pub use types::{ diff --git a/beacon_node/execution_layer/src/engine_api/http.rs b/beacon_node/execution_layer/src/engine_api/http.rs index df0f79c61e2..7fafeadb8ac 100644 --- a/beacon_node/execution_layer/src/engine_api/http.rs +++ b/beacon_node/execution_layer/src/engine_api/http.rs @@ -11,7 +11,6 @@ use std::collections::HashSet; use tokio::sync::Mutex; use std::time::{Duration, Instant}; -use types::EthSpec; pub use deposit_log::{DepositLog, Log}; pub use reqwest::Client; @@ -1191,7 +1190,7 @@ mod test { use std::future::Future; use std::str::FromStr; use std::sync::Arc; - use types::{ExecutionPayloadMerge, MainnetEthSpec, Transactions, Unsigned, VariableList}; + use types::{MainnetEthSpec, Unsigned}; struct Tester { server: MockServer, diff --git a/beacon_node/execution_layer/src/engine_api/json_structures.rs b/beacon_node/execution_layer/src/engine_api/json_structures.rs index e8641be7953..feb6c99748c 100644 --- a/beacon_node/execution_layer/src/engine_api/json_structures.rs +++ b/beacon_node/execution_layer/src/engine_api/json_structures.rs @@ -4,10 +4,7 @@ use strum::EnumString; use superstruct::superstruct; use types::beacon_block_body::KzgCommitments; use types::blob_sidecar::BlobsList; -use types::{ - EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadCapella, ExecutionPayloadDeneb, - ExecutionPayloadMerge, FixedVector, Transactions, Unsigned, VariableList, Withdrawal, -}; +use types::{FixedVector, Unsigned}; #[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/beacon_node/execution_layer/src/test_utils/handle_rpc.rs b/beacon_node/execution_layer/src/test_utils/handle_rpc.rs index 9dff1ac0089..623c1c9548a 100644 --- a/beacon_node/execution_layer/src/test_utils/handle_rpc.rs +++ b/beacon_node/execution_layer/src/test_utils/handle_rpc.rs @@ -5,7 +5,6 @@ use crate::test_utils::DEFAULT_MOCK_EL_PAYLOAD_VALUE_WEI; use serde::{de::DeserializeOwned, Deserialize}; use serde_json::Value as JsonValue; use std::sync::Arc; -use types::{EthSpec, ForkName}; pub const GENERIC_ERROR_CODE: i64 = -1234; pub const BAD_PARAMS_ERROR_CODE: i64 = -32602; diff --git a/beacon_node/execution_layer/src/test_utils/mock_builder.rs b/beacon_node/execution_layer/src/test_utils/mock_builder.rs index 2c5bde55ea3..759348bb41c 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_builder.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_builder.rs @@ -71,8 +71,6 @@ pub trait BidStuff { fn set_withdrawals_root(&mut self, withdrawals_root: Hash256); fn sign_builder_message(&mut self, sk: &SecretKey, spec: &ChainSpec) -> Signature; - - fn to_signed_bid(self, signature: Signature) -> SignedBuilderBid; } impl BidStuff for BuilderBid { @@ -183,13 +181,6 @@ impl BidStuff for BuilderBid { let message = self.signing_root(domain); sk.sign(message) } - - fn to_signed_bid(self, signature: Signature) -> SignedBuilderBid { - SignedBuilderBid { - message: self, - signature, - } - } } #[derive(Clone)] diff --git a/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs b/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs index 77c2410ab1d..3dd49404393 100644 --- a/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs +++ b/beacon_node/execution_layer/src/test_utils/mock_execution_layer.rs @@ -2,14 +2,12 @@ use crate::{ test_utils::{ MockServer, DEFAULT_JWT_SECRET, DEFAULT_TERMINAL_BLOCK, DEFAULT_TERMINAL_DIFFICULTY, }, - Config, *, + *, }; use keccak_hash::H256; use kzg::Kzg; -use sensitive_url::SensitiveUrl; -use task_executor::TaskExecutor; use tempfile::NamedTempFile; -use types::{Address, ChainSpec, Epoch, EthSpec, Hash256, MainnetEthSpec}; +use types::MainnetEthSpec; pub struct MockExecutionLayer { pub server: MockServer, diff --git a/beacon_node/genesis/src/interop.rs b/beacon_node/genesis/src/interop.rs index d0129834300..ced88ee1232 100644 --- a/beacon_node/genesis/src/interop.rs +++ b/beacon_node/genesis/src/interop.rs @@ -137,7 +137,7 @@ pub fn interop_genesis_state_with_withdrawal_credentials( #[cfg(test)] mod test { use super::*; - use types::{test_utils::generate_deterministic_keypairs, EthSpec, MinimalEthSpec}; + use types::{test_utils::generate_deterministic_keypairs, MinimalEthSpec}; type TestEthSpec = MinimalEthSpec; diff --git a/beacon_node/http_api/src/block_packing_efficiency.rs b/beacon_node/http_api/src/block_packing_efficiency.rs index c73dcb7e02a..bae964615e9 100644 --- a/beacon_node/http_api/src/block_packing_efficiency.rs +++ b/beacon_node/http_api/src/block_packing_efficiency.rs @@ -132,7 +132,7 @@ impl PackingEfficiencyHandler { } // Remove duplicate attestations as these yield no reward. - attestations_in_block.retain(|x, _| self.included_attestations.get(x).is_none()); + attestations_in_block.retain(|x, _| !self.included_attestations.contains_key(x)); self.included_attestations .extend(attestations_in_block.clone()); @@ -179,8 +179,9 @@ impl PackingEfficiencyHandler { .collect::>() }; - self.committee_store.previous_epoch_committees = - self.committee_store.current_epoch_committees.clone(); + self.committee_store + .previous_epoch_committees + .clone_from(&self.committee_store.current_epoch_committees); self.committee_store.current_epoch_committees = new_committees; diff --git a/beacon_node/lighthouse_network/src/gossipsub/behaviour.rs b/beacon_node/lighthouse_network/src/gossipsub/behaviour.rs index 10025626d31..7b788c34b27 100644 --- a/beacon_node/lighthouse_network/src/gossipsub/behaviour.rs +++ b/beacon_node/lighthouse_network/src/gossipsub/behaviour.rs @@ -525,7 +525,7 @@ where return Err(SubscriptionError::NotAllowed); } - if self.mesh.get(&topic_hash).is_some() { + if self.mesh.contains_key(&topic_hash) { tracing::debug!(%topic, "Topic is already in the mesh"); return Ok(false); } @@ -551,7 +551,7 @@ where tracing::debug!(%topic, "Unsubscribing from topic"); let topic_hash = topic.hash(); - if self.mesh.get(&topic_hash).is_none() { + if !self.mesh.contains_key(&topic_hash) { tracing::debug!(topic=%topic_hash, "Already unsubscribed from topic"); // we are not subscribed return Ok(false); diff --git a/beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs b/beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs index f191d38f515..4d85ecb5742 100644 --- a/beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs +++ b/beacon_node/lighthouse_network/src/gossipsub/behaviour/tests.rs @@ -22,18 +22,13 @@ use super::*; use crate::gossipsub::subscription_filter::WhitelistSubscriptionFilter; -use crate::gossipsub::transform::{DataTransform, IdentityTransform}; -use crate::gossipsub::types::{RpcOut, RpcReceiver}; -use crate::gossipsub::ValidationError; -use crate::gossipsub::{ - config::Config, config::ConfigBuilder, types::Rpc, IdentTopic as Topic, TopicScoreParams, -}; +use crate::gossipsub::types::RpcReceiver; +use crate::gossipsub::{config::ConfigBuilder, types::Rpc, IdentTopic as Topic}; use async_std::net::Ipv4Addr; use byteorder::{BigEndian, ByteOrder}; -use libp2p::core::{ConnectedPoint, Endpoint}; +use libp2p::core::ConnectedPoint; use rand::Rng; use std::thread::sleep; -use std::time::Duration; #[derive(Default, Debug)] struct InjectNodes @@ -427,7 +422,7 @@ fn test_subscribe() { .create_network(); assert!( - gs.mesh.get(&topic_hashes[0]).is_some(), + gs.mesh.contains_key(&topic_hashes[0]), "Subscribe should add a new entry to the mesh[topic] hashmap" ); @@ -477,7 +472,7 @@ fn test_unsubscribe() { "Topic_peers contain a topic entry" ); assert!( - gs.mesh.get(topic_hash).is_some(), + gs.mesh.contains_key(topic_hash), "mesh should contain a topic entry" ); } @@ -511,7 +506,7 @@ fn test_unsubscribe() { // check we clean up internal structures for topic_hash in &topic_hashes { assert!( - gs.mesh.get(topic_hash).is_none(), + !gs.mesh.contains_key(topic_hash), "All topics should have been removed from the mesh" ); } @@ -694,7 +689,7 @@ fn test_publish_without_flood_publishing() { .create_network(); assert!( - gs.mesh.get(&topic_hashes[0]).is_some(), + gs.mesh.contains_key(&topic_hashes[0]), "Subscribe should add a new entry to the mesh[topic] hashmap" ); @@ -774,7 +769,7 @@ fn test_fanout() { .create_network(); assert!( - gs.mesh.get(&topic_hashes[0]).is_some(), + gs.mesh.contains_key(&topic_hashes[0]), "Subscribe should add a new entry to the mesh[topic] hashmap" ); // Unsubscribe from topic @@ -946,7 +941,7 @@ fn test_handle_received_subscriptions() { ); assert!( - gs.connected_peers.get(&unknown_peer).is_none(), + !gs.connected_peers.contains_key(&unknown_peer), "Unknown peer should not have been added" ); @@ -1347,7 +1342,7 @@ fn test_handle_graft_multiple_topics() { } assert!( - gs.mesh.get(&topic_hashes[2]).is_none(), + !gs.mesh.contains_key(&topic_hashes[2]), "Expected the second topic to not be in the mesh" ); } @@ -5228,7 +5223,7 @@ fn test_graft_without_subscribe() { .create_network(); assert!( - gs.mesh.get(&topic_hashes[0]).is_some(), + gs.mesh.contains_key(&topic_hashes[0]), "Subscribe should add a new entry to the mesh[topic] hashmap" ); diff --git a/beacon_node/lighthouse_network/src/gossipsub/config.rs b/beacon_node/lighthouse_network/src/gossipsub/config.rs index f7f967bfbf9..227a24a0532 100644 --- a/beacon_node/lighthouse_network/src/gossipsub/config.rs +++ b/beacon_node/lighthouse_network/src/gossipsub/config.rs @@ -903,10 +903,8 @@ impl std::fmt::Debug for Config { mod test { use super::*; use crate::gossipsub::topic::IdentityHash; - use crate::gossipsub::types::PeerKind; use crate::gossipsub::Topic; use libp2p::core::UpgradeInfo; - use libp2p::swarm::StreamProtocol; use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; diff --git a/beacon_node/lighthouse_network/src/gossipsub/mcache.rs b/beacon_node/lighthouse_network/src/gossipsub/mcache.rs index 31931d756f6..eced0456d68 100644 --- a/beacon_node/lighthouse_network/src/gossipsub/mcache.rs +++ b/beacon_node/lighthouse_network/src/gossipsub/mcache.rs @@ -221,9 +221,7 @@ impl MessageCache { #[cfg(test)] mod tests { use super::*; - use crate::gossipsub::types::RawMessage; - use crate::{IdentTopic as Topic, TopicHash}; - use libp2p::identity::PeerId; + use crate::IdentTopic as Topic; fn gen_testm(x: u64, topic: TopicHash) -> (MessageId, RawMessage) { let default_id = |message: &RawMessage| { diff --git a/beacon_node/lighthouse_network/src/gossipsub/peer_score.rs b/beacon_node/lighthouse_network/src/gossipsub/peer_score.rs index d84b2416c63..4d609434f13 100644 --- a/beacon_node/lighthouse_network/src/gossipsub/peer_score.rs +++ b/beacon_node/lighthouse_network/src/gossipsub/peer_score.rs @@ -102,7 +102,7 @@ impl PeerStats { topic_hash: TopicHash, params: &PeerScoreParams, ) -> Option<&mut TopicStats> { - if params.topics.get(&topic_hash).is_some() { + if params.topics.contains_key(&topic_hash) { Some(self.topics.entry(topic_hash).or_default()) } else { self.topics.get_mut(&topic_hash) @@ -310,7 +310,7 @@ impl PeerScore { // P6: IP collocation factor for ip in peer_stats.known_ips.iter() { - if self.params.ip_colocation_factor_whitelist.get(ip).is_some() { + if self.params.ip_colocation_factor_whitelist.contains(ip) { continue; } @@ -705,7 +705,7 @@ impl PeerScore { ) { let record = self.deliveries.entry(msg_id.clone()).or_default(); - if record.peers.get(from).is_some() { + if record.peers.contains(from) { // we have already seen this duplicate! return; } diff --git a/beacon_node/lighthouse_network/src/gossipsub/protocol.rs b/beacon_node/lighthouse_network/src/gossipsub/protocol.rs index fe6c8f787ba..7a59547e79d 100644 --- a/beacon_node/lighthouse_network/src/gossipsub/protocol.rs +++ b/beacon_node/lighthouse_network/src/gossipsub/protocol.rs @@ -30,7 +30,6 @@ use super::ValidationError; use asynchronous_codec::{Decoder, Encoder, Framed}; use byteorder::{BigEndian, ByteOrder}; use bytes::BytesMut; -use futures::future; use futures::prelude::*; use libp2p::core::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use libp2p::identity::{PeerId, PublicKey}; @@ -508,10 +507,8 @@ impl Decoder for GossipsubCodec { #[cfg(test)] mod tests { use super::*; - use crate::gossipsub::config::Config; - use crate::gossipsub::protocol::{BytesMut, GossipsubCodec, HandlerEvent}; + use crate::gossipsub::IdentTopic as Topic; use crate::gossipsub::*; - use crate::gossipsub::{IdentTopic as Topic, Version}; use libp2p::identity::Keypair; use quickcheck::*; diff --git a/beacon_node/lighthouse_network/src/gossipsub/subscription_filter.rs b/beacon_node/lighthouse_network/src/gossipsub/subscription_filter.rs index aa0ec7d3e96..12a65a82cec 100644 --- a/beacon_node/lighthouse_network/src/gossipsub/subscription_filter.rs +++ b/beacon_node/lighthouse_network/src/gossipsub/subscription_filter.rs @@ -212,7 +212,6 @@ impl TopicSubscriptionFilter for RegexSubscriptionFilter { mod test { use super::*; use crate::gossipsub::types::SubscriptionAction::*; - use std::iter::FromIterator; #[test] fn test_filter_incoming_allow_all_with_duplicates() { diff --git a/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs b/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs index ebb355fefcf..47b36e0362d 100644 --- a/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs +++ b/beacon_node/lighthouse_network/src/peer_manager/peerdb.rs @@ -1251,7 +1251,6 @@ impl BannedPeersCount { mod tests { use super::*; use libp2p::core::multiaddr::Protocol; - use libp2p::core::Multiaddr; use slog::{o, Drain}; use std::net::{Ipv4Addr, Ipv6Addr}; use types::MinimalEthSpec; diff --git a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs index 7a7f2969f16..58a9d137a96 100644 --- a/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs +++ b/beacon_node/lighthouse_network/src/rpc/codec/ssz_snappy.rs @@ -3,7 +3,7 @@ use crate::rpc::{ codec::base::OutboundCodec, protocol::{Encoding, ProtocolId, RPCError, SupportedProtocol, ERROR_TYPE_MAX, ERROR_TYPE_MIN}, }; -use crate::rpc::{InboundRequest, OutboundRequest, RPCCodedResponse, RPCResponse}; +use crate::rpc::{InboundRequest, OutboundRequest}; use libp2p::bytes::BytesMut; use snap::read::FrameDecoder; use snap::write::FrameEncoder; @@ -676,22 +676,13 @@ fn context_bytes_to_fork_name( mod tests { use super::*; - use crate::rpc::{protocol::*, MetaData}; - use crate::{ - rpc::{methods::StatusMessage, Ping, RPCResponseErrorCode}, - types::{EnrAttestationBitfield, EnrSyncCommitteeBitfield}, - }; - use std::sync::Arc; + use crate::rpc::protocol::*; + use crate::types::{EnrAttestationBitfield, EnrSyncCommitteeBitfield}; use types::{ blob_sidecar::BlobIdentifier, BeaconBlock, BeaconBlockAltair, BeaconBlockBase, - BeaconBlockMerge, ChainSpec, EmptyBlock, Epoch, ForkContext, FullPayload, Hash256, - Signature, SignedBeaconBlock, Slot, + BeaconBlockMerge, EmptyBlock, Epoch, FullPayload, Signature, Slot, }; - use snap::write::FrameEncoder; - use ssz::Encode; - use std::io::Write; - type Spec = types::MainnetEthSpec; fn fork_context(fork_name: ForkName) -> ForkContext { diff --git a/beacon_node/lighthouse_network/src/rpc/handler.rs b/beacon_node/lighthouse_network/src/rpc/handler.rs index f4971c18d31..44be3ca1af0 100644 --- a/beacon_node/lighthouse_network/src/rpc/handler.rs +++ b/beacon_node/lighthouse_network/src/rpc/handler.rs @@ -9,7 +9,7 @@ use crate::rpc::outbound::{OutboundFramed, OutboundRequest}; use crate::rpc::protocol::InboundFramed; use fnv::FnvHashMap; use futures::prelude::*; -use futures::{Sink, SinkExt}; +use futures::SinkExt; use libp2p::swarm::handler::{ ConnectionEvent, ConnectionHandler, ConnectionHandlerEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound, StreamUpgradeError, SubstreamProtocol, diff --git a/beacon_node/lighthouse_network/src/rpc/methods.rs b/beacon_node/lighthouse_network/src/rpc/methods.rs index cd3579ad6e3..1a9a3ea93f2 100644 --- a/beacon_node/lighthouse_network/src/rpc/methods.rs +++ b/beacon_node/lighthouse_network/src/rpc/methods.rs @@ -6,6 +6,7 @@ use serde::Serialize; use ssz::Encode; use ssz_derive::{Decode, Encode}; use ssz_types::{typenum::U256, VariableList}; +use std::fmt::Display; use std::marker::PhantomData; use std::ops::Deref; use std::sync::Arc; @@ -44,11 +45,13 @@ impl Deref for ErrorType { } } -impl ToString for ErrorType { - fn to_string(&self) -> String { +impl Display for ErrorType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { #[allow(clippy::invalid_regex)] let re = Regex::new("\\p{C}").expect("Regex is valid"); - String::from_utf8_lossy(&re.replace_all(self.0.deref(), &b""[..])).to_string() + let error_type_str = + String::from_utf8_lossy(&re.replace_all(self.0.deref(), &b""[..])).to_string(); + write!(f, "{}", error_type_str) } } @@ -580,7 +583,7 @@ impl std::fmt::Display for RPCCodedResponse { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { RPCCodedResponse::Success(res) => write!(f, "{}", res), - RPCCodedResponse::Error(code, err) => write!(f, "{}: {}", code, err.to_string()), + RPCCodedResponse::Error(code, err) => write!(f, "{}: {}", code, err), RPCCodedResponse::StreamTermination(_) => write!(f, "Stream Termination"), } } diff --git a/beacon_node/lighthouse_network/src/rpc/outbound.rs b/beacon_node/lighthouse_network/src/rpc/outbound.rs index 713e9e0ec9d..d3da2e56339 100644 --- a/beacon_node/lighthouse_network/src/rpc/outbound.rs +++ b/beacon_node/lighthouse_network/src/rpc/outbound.rs @@ -2,11 +2,10 @@ use super::methods::*; use super::protocol::ProtocolId; use super::protocol::SupportedProtocol; use super::RPCError; -use crate::rpc::protocol::Encoding; -use crate::rpc::{ - codec::{base::BaseOutboundCodec, ssz_snappy::SSZSnappyOutboundCodec, OutboundCodec}, - methods::ResponseTermination, +use crate::rpc::codec::{ + base::BaseOutboundCodec, ssz_snappy::SSZSnappyOutboundCodec, OutboundCodec, }; +use crate::rpc::protocol::Encoding; use futures::future::BoxFuture; use futures::prelude::{AsyncRead, AsyncWrite}; use futures::{FutureExt, SinkExt}; diff --git a/beacon_node/lighthouse_network/src/rpc/protocol.rs b/beacon_node/lighthouse_network/src/rpc/protocol.rs index 9c174b8e425..44a32eff2de 100644 --- a/beacon_node/lighthouse_network/src/rpc/protocol.rs +++ b/beacon_node/lighthouse_network/src/rpc/protocol.rs @@ -1,8 +1,5 @@ use super::methods::*; -use crate::rpc::{ - codec::{base::BaseInboundCodec, ssz_snappy::SSZSnappyInboundCodec, InboundCodec}, - methods::{MaxErrorLen, ResponseTermination, MAX_ERROR_LEN}, -}; +use crate::rpc::codec::{base::BaseInboundCodec, ssz_snappy::SSZSnappyInboundCodec, InboundCodec}; use futures::future::BoxFuture; use futures::prelude::{AsyncRead, AsyncWrite}; use futures::{FutureExt, StreamExt}; diff --git a/beacon_node/lighthouse_network/src/rpc/rate_limiter.rs b/beacon_node/lighthouse_network/src/rpc/rate_limiter.rs index 0b57374e8b6..2baa256b67d 100644 --- a/beacon_node/lighthouse_network/src/rpc/rate_limiter.rs +++ b/beacon_node/lighthouse_network/src/rpc/rate_limiter.rs @@ -3,7 +3,6 @@ use crate::rpc::Protocol; use fnv::FnvHashMap; use libp2p::PeerId; use serde::{Deserialize, Serialize}; -use std::convert::TryInto; use std::future::Future; use std::hash::Hash; use std::pin::Pin; diff --git a/beacon_node/lighthouse_network/src/service/gossip_cache.rs b/beacon_node/lighthouse_network/src/service/gossip_cache.rs index 5dc0d29ff5b..225b4ef8dde 100644 --- a/beacon_node/lighthouse_network/src/service/gossip_cache.rs +++ b/beacon_node/lighthouse_network/src/service/gossip_cache.rs @@ -268,8 +268,6 @@ impl futures::stream::Stream for GossipCache { #[cfg(test)] mod tests { - use crate::types::GossipKind; - use super::*; use futures::stream::StreamExt; diff --git a/beacon_node/lighthouse_network/src/types/pubsub.rs b/beacon_node/lighthouse_network/src/types/pubsub.rs index 9bbc7b2650a..6582e56f18d 100644 --- a/beacon_node/lighthouse_network/src/types/pubsub.rs +++ b/beacon_node/lighthouse_network/src/types/pubsub.rs @@ -5,7 +5,6 @@ use crate::types::{GossipEncoding, GossipKind, GossipTopic}; use crate::TopicHash; use snap::raw::{decompress_len, Decoder, Encoder}; use ssz::{Decode, Encode}; -use std::boxed::Box; use std::io::{Error, ErrorKind}; use std::sync::Arc; use types::{ diff --git a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs index 66c98ff3b84..c63afcdb2fe 100644 --- a/beacon_node/network/src/network_beacon_processor/rpc_methods.rs +++ b/beacon_node/network/src/network_beacon_processor/rpc_methods.rs @@ -6,7 +6,6 @@ use beacon_chain::{BeaconChainError, BeaconChainTypes, HistoricalBlockError, Whe use beacon_processor::SendOnDrop; use itertools::process_results; use lighthouse_network::rpc::methods::{BlobsByRangeRequest, BlobsByRootRequest}; -use lighthouse_network::rpc::StatusMessage; use lighthouse_network::rpc::*; use lighthouse_network::{PeerId, PeerRequestId, ReportSource, Response, SyncInfo}; use slog::{debug, error, warn}; diff --git a/beacon_node/network/src/persisted_dht.rs b/beacon_node/network/src/persisted_dht.rs index e69230c50c0..289bf14335e 100644 --- a/beacon_node/network/src/persisted_dht.rs +++ b/beacon_node/network/src/persisted_dht.rs @@ -60,11 +60,10 @@ impl StoreItem for PersistedDht { #[cfg(test)] mod tests { use super::*; - use lighthouse_network::Enr; use sloggers::{null::NullLoggerBuilder, Build}; use std::str::FromStr; use store::config::StoreConfig; - use store::{HotColdDB, MemoryStore}; + use store::MemoryStore; use types::{ChainSpec, MinimalEthSpec}; #[test] fn test_persisted_dht() { diff --git a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs index 8c60621f1c7..c4d91299345 100644 --- a/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs +++ b/beacon_node/network/src/sync/block_lookups/single_block_lookup.rs @@ -519,7 +519,6 @@ impl slog::Value for SingleLookupRequestState { mod tests { use super::*; use crate::sync::block_lookups::common::LookupType; - use crate::sync::block_lookups::common::{Lookup, RequestState}; use beacon_chain::builder::Witness; use beacon_chain::eth1_chain::CachingEth1Backend; use sloggers::null::NullLoggerBuilder; @@ -529,7 +528,7 @@ mod tests { use store::{HotColdDB, MemoryStore, StoreConfig}; use types::{ test_utils::{SeedableRng, TestRandom, XorShiftRng}, - ChainSpec, EthSpec, MinimalEthSpec as E, SignedBeaconBlock, Slot, + ChainSpec, MinimalEthSpec as E, SignedBeaconBlock, Slot, }; fn rand_block() -> SignedBeaconBlock { diff --git a/beacon_node/network/src/sync/block_lookups/tests.rs b/beacon_node/network/src/sync/block_lookups/tests.rs index d327c5c905a..d638ae8a85a 100644 --- a/beacon_node/network/src/sync/block_lookups/tests.rs +++ b/beacon_node/network/src/sync/block_lookups/tests.rs @@ -1154,9 +1154,7 @@ fn test_same_chain_race_condition() { mod deneb_only { use super::*; - use crate::sync::block_lookups::common::ResponseType; use beacon_chain::data_availability_checker::AvailabilityCheckError; - use beacon_chain::test_utils::NumBlobs; use ssz_types::VariableList; use std::ops::IndexMut; use std::str::FromStr; diff --git a/beacon_node/network/src/sync/manager.rs b/beacon_node/network/src/sync/manager.rs index acb735ea442..0e965457ea1 100644 --- a/beacon_node/network/src/sync/manager.rs +++ b/beacon_node/network/src/sync/manager.rs @@ -57,7 +57,6 @@ use lighthouse_network::types::{NetworkGlobals, SyncState}; use lighthouse_network::SyncInfo; use lighthouse_network::{PeerAction, PeerId}; use slog::{crit, debug, error, info, trace, warn, Logger}; -use std::boxed::Box; use std::ops::IndexMut; use std::ops::Sub; use std::sync::Arc; diff --git a/beacon_node/network/src/sync/range_sync/range.rs b/beacon_node/network/src/sync/range_sync/range.rs index e42fd936e61..6ce277e5d25 100644 --- a/beacon_node/network/src/sync/range_sync/range.rs +++ b/beacon_node/network/src/sync/range_sync/range.rs @@ -395,10 +395,9 @@ mod tests { use slog::{o, Drain}; use slot_clock::TestingSlotClock; use std::collections::HashSet; - use std::sync::Arc; use store::MemoryStore; use tokio::sync::mpsc; - use types::{ForkName, Hash256, MinimalEthSpec as E}; + use types::{ForkName, MinimalEthSpec as E}; #[derive(Debug)] struct FakeStorage { diff --git a/beacon_node/operation_pool/src/max_cover.rs b/beacon_node/operation_pool/src/max_cover.rs index 2e629f786b3..b4a95b1de0b 100644 --- a/beacon_node/operation_pool/src/max_cover.rs +++ b/beacon_node/operation_pool/src/max_cover.rs @@ -118,7 +118,6 @@ where #[cfg(test)] mod test { use super::*; - use std::iter::FromIterator; use std::{collections::HashSet, hash::Hash}; impl MaxCover for HashSet diff --git a/beacon_node/src/config.rs b/beacon_node/src/config.rs index ba8430aceae..8f369818c09 100644 --- a/beacon_node/src/config.rs +++ b/beacon_node/src/config.rs @@ -345,7 +345,9 @@ pub fn get_config( clap_utils::parse_optional(cli_args, "suggested-fee-recipient")?; el_config.jwt_id = clap_utils::parse_optional(cli_args, "execution-jwt-id")?; el_config.jwt_version = clap_utils::parse_optional(cli_args, "execution-jwt-version")?; - el_config.default_datadir = client_config.data_dir().clone(); + el_config + .default_datadir + .clone_from(client_config.data_dir()); let execution_timeout_multiplier = clap_utils::parse_required(cli_args, "execution-timeout-multiplier")?; el_config.execution_timeout_multiplier = Some(execution_timeout_multiplier); diff --git a/beacon_node/store/src/chunked_vector.rs b/beacon_node/store/src/chunked_vector.rs index 537614f2817..173b06049ea 100644 --- a/beacon_node/store/src/chunked_vector.rs +++ b/beacon_node/store/src/chunked_vector.rs @@ -17,7 +17,6 @@ use self::UpdatePattern::*; use crate::*; use ssz::{Decode, Encode}; -use typenum::Unsigned; use types::historical_summary::HistoricalSummary; /// Description of how a `BeaconState` field is updated during state processing. diff --git a/beacon_node/store/src/hot_cold_store.rs b/beacon_node/store/src/hot_cold_store.rs index 4bdb0deca33..70e02164e08 100644 --- a/beacon_node/store/src/hot_cold_store.rs +++ b/beacon_node/store/src/hot_cold_store.rs @@ -33,13 +33,11 @@ use state_processing::{ BlockProcessingError, BlockReplayer, SlotProcessingError, StateProcessingStrategy, }; use std::cmp::min; -use std::convert::TryInto; use std::marker::PhantomData; use std::num::NonZeroUsize; use std::path::Path; use std::sync::Arc; use std::time::Duration; -use types::blob_sidecar::BlobSidecarList; use types::*; /// On-disk database that stores finalized states efficiently. diff --git a/beacon_node/store/src/impls/beacon_state.rs b/beacon_node/store/src/impls/beacon_state.rs index 88d1d2d7a16..324d731a81f 100644 --- a/beacon_node/store/src/impls/beacon_state.rs +++ b/beacon_node/store/src/impls/beacon_state.rs @@ -1,8 +1,6 @@ use crate::*; use ssz::{DecodeError, Encode}; use ssz_derive::Encode; -use std::convert::TryInto; -use types::beacon_state::{CloneConfig, CommitteeCache, CACHED_EPOCHS}; pub fn store_full_state( state_root: &Hash256, diff --git a/beacon_node/store/src/iter.rs b/beacon_node/store/src/iter.rs index 07c99e5a4ef..6c2dc6c658a 100644 --- a/beacon_node/store/src/iter.rs +++ b/beacon_node/store/src/iter.rs @@ -381,7 +381,6 @@ fn slot_of_prev_restore_point(current_slot: Slot) -> Slot { #[cfg(test)] mod test { use super::*; - use crate::HotColdDB; use crate::StoreConfig as Config; use beacon_chain::test_utils::BeaconChainHarness; use beacon_chain::types::{ChainSpec, MainnetEthSpec}; diff --git a/beacon_node/store/src/leveldb_store.rs b/beacon_node/store/src/leveldb_store.rs index d799bdedd3b..ffd55c16a04 100644 --- a/beacon_node/store/src/leveldb_store.rs +++ b/beacon_node/store/src/leveldb_store.rs @@ -1,6 +1,5 @@ use super::*; use crate::hot_cold_store::HotColdDBError; -use crate::metrics; use leveldb::compaction::Compaction; use leveldb::database::batch::{Batch, Writebatch}; use leveldb::database::kv::KV; @@ -8,7 +7,7 @@ use leveldb::database::Database; use leveldb::error::Error as LevelDBError; use leveldb::iterator::{Iterable, KeyIterator, LevelDBIterator}; use leveldb::options::{Options, ReadOptions, WriteOptions}; -use parking_lot::{Mutex, MutexGuard}; +use parking_lot::Mutex; use std::marker::PhantomData; use std::path::Path; diff --git a/beacon_node/store/src/partial_beacon_state.rs b/beacon_node/store/src/partial_beacon_state.rs index 1fb5751a0a9..62686bec6e5 100644 --- a/beacon_node/store/src/partial_beacon_state.rs +++ b/beacon_node/store/src/partial_beacon_state.rs @@ -5,7 +5,6 @@ use crate::chunked_vector::{ use crate::{get_key_for_col, DBColumn, Error, KeyValueStore, KeyValueStoreOp}; use ssz::{Decode, DecodeError, Encode}; use ssz_derive::{Decode, Encode}; -use std::convert::TryInto; use std::sync::Arc; use types::historical_summary::HistoricalSummary; use types::superstruct; diff --git a/common/deposit_contract/src/lib.rs b/common/deposit_contract/src/lib.rs index 2a9f985d5f0..785b9522135 100644 --- a/common/deposit_contract/src/lib.rs +++ b/common/deposit_contract/src/lib.rs @@ -86,8 +86,8 @@ pub fn decode_eth1_tx_data( mod tests { use super::*; use types::{ - test_utils::generate_deterministic_keypair, ChainSpec, EthSpec, Hash256, Keypair, - MinimalEthSpec, Signature, + test_utils::generate_deterministic_keypair, ChainSpec, EthSpec, Keypair, MinimalEthSpec, + Signature, }; type E = MinimalEthSpec; diff --git a/common/eth2/src/lib.rs b/common/eth2/src/lib.rs index 3c22c822b8a..d6d87e27f04 100644 --- a/common/eth2/src/lib.rs +++ b/common/eth2/src/lib.rs @@ -29,10 +29,8 @@ pub use reqwest::{StatusCode, Url}; pub use sensitive_url::{SensitiveError, SensitiveUrl}; use serde::{de::DeserializeOwned, Serialize}; use ssz::Encode; -use std::convert::TryFrom; use std::fmt; use std::future::Future; -use std::iter::Iterator; use std::path::PathBuf; use std::time::Duration; use store::fork_versioned_response::ExecutionOptimisticFinalizedForkVersionedResponse; diff --git a/common/eth2/src/types.rs b/common/eth2/src/types.rs index 8a1cf2ff37e..4dee868e1d9 100644 --- a/common/eth2/src/types.rs +++ b/common/eth2/src/types.rs @@ -12,7 +12,6 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_json::Value; use ssz::{Decode, DecodeError}; use ssz_derive::{Decode, Encode}; -use std::convert::TryFrom; use std::fmt::{self, Display}; use std::str::{from_utf8, FromStr}; use std::sync::Arc; diff --git a/common/eth2_interop_keypairs/src/lib.rs b/common/eth2_interop_keypairs/src/lib.rs index 3d4ff02c383..3031e1c4dc1 100644 --- a/common/eth2_interop_keypairs/src/lib.rs +++ b/common/eth2_interop_keypairs/src/lib.rs @@ -23,7 +23,6 @@ use bls::{Keypair, PublicKey, SecretKey}; use ethereum_hashing::hash; use num_bigint::BigUint; use serde::{Deserialize, Serialize}; -use std::convert::TryInto; use std::fs::File; use std::path::PathBuf; diff --git a/common/eth2_network_config/src/lib.rs b/common/eth2_network_config/src/lib.rs index a76a8320aa8..1ead9a6bde8 100644 --- a/common/eth2_network_config/src/lib.rs +++ b/common/eth2_network_config/src/lib.rs @@ -462,7 +462,7 @@ mod tests { use super::*; use ssz::Encode; use tempfile::Builder as TempBuilder; - use types::{Config, Eth1Data, GnosisEthSpec, Hash256, MainnetEthSpec}; + use types::{Eth1Data, GnosisEthSpec, MainnetEthSpec}; type E = MainnetEthSpec; diff --git a/common/slot_clock/src/manual_slot_clock.rs b/common/slot_clock/src/manual_slot_clock.rs index 61299f74ac4..7b42fa9062d 100644 --- a/common/slot_clock/src/manual_slot_clock.rs +++ b/common/slot_clock/src/manual_slot_clock.rs @@ -1,6 +1,5 @@ use super::SlotClock; use parking_lot::RwLock; -use std::convert::TryInto; use std::sync::Arc; use std::time::Duration; use types::Slot; diff --git a/consensus/cached_tree_hash/src/cache.rs b/consensus/cached_tree_hash/src/cache.rs index 3b4878503ea..450128f15ed 100644 --- a/consensus/cached_tree_hash/src/cache.rs +++ b/consensus/cached_tree_hash/src/cache.rs @@ -50,7 +50,7 @@ impl TreeHashCache { pub fn recalculate_merkle_root( &mut self, arena: &mut CacheArena, - leaves: impl Iterator + ExactSizeIterator, + leaves: impl ExactSizeIterator, ) -> Result { let dirty_indices = self.update_leaves(arena, leaves)?; self.update_merkle_root(arena, dirty_indices) @@ -60,7 +60,7 @@ impl TreeHashCache { pub fn update_leaves( &mut self, arena: &mut CacheArena, - mut leaves: impl Iterator + ExactSizeIterator, + mut leaves: impl ExactSizeIterator, ) -> Result, Error> { let new_leaf_count = leaves.len(); diff --git a/consensus/fork_choice/src/fork_choice.rs b/consensus/fork_choice/src/fork_choice.rs index 865a5affbb9..625dc245f49 100644 --- a/consensus/fork_choice/src/fork_choice.rs +++ b/consensus/fork_choice/src/fork_choice.rs @@ -1655,7 +1655,7 @@ pub struct PersistedForkChoice { #[cfg(test)] mod tests { - use types::{EthSpec, MainnetEthSpec}; + use types::MainnetEthSpec; use super::*; diff --git a/consensus/proto_array/src/ssz_container.rs b/consensus/proto_array/src/ssz_container.rs index de7fa70d6a1..3208584dc45 100644 --- a/consensus/proto_array/src/ssz_container.rs +++ b/consensus/proto_array/src/ssz_container.rs @@ -7,7 +7,6 @@ use crate::{ use ssz::{four_byte_option_impl, Encode}; use ssz_derive::{Decode, Encode}; use std::collections::HashMap; -use std::convert::TryFrom; use superstruct::superstruct; use types::{Checkpoint, Hash256}; diff --git a/consensus/state_processing/src/genesis.rs b/consensus/state_processing/src/genesis.rs index 284a7019f34..5f71e33371b 100644 --- a/consensus/state_processing/src/genesis.rs +++ b/consensus/state_processing/src/genesis.rs @@ -7,7 +7,6 @@ use crate::upgrade::{ }; use safe_arith::{ArithError, SafeArith}; use tree_hash::TreeHash; -use types::DEPOSIT_TREE_DEPTH; use types::*; /// Initialize a `BeaconState` from genesis data. diff --git a/consensus/state_processing/src/per_block_processing/process_operations.rs b/consensus/state_processing/src/per_block_processing/process_operations.rs index cb24a7ba7ec..cab3c93cbf4 100644 --- a/consensus/state_processing/src/per_block_processing/process_operations.rs +++ b/consensus/state_processing/src/per_block_processing/process_operations.rs @@ -6,7 +6,6 @@ use crate::common::{ }; use crate::per_block_processing::errors::{BlockProcessingError, IntoWithIndex}; use crate::VerifySignatures; -use safe_arith::SafeArith; use types::consts::altair::{PARTICIPATION_FLAG_WEIGHTS, PROPOSER_WEIGHT, WEIGHT_DENOMINATOR}; pub fn process_operations>( diff --git a/consensus/state_processing/src/per_epoch_processing/altair/inactivity_updates.rs b/consensus/state_processing/src/per_epoch_processing/altair/inactivity_updates.rs index a895567d12c..c3eb9aa4b66 100644 --- a/consensus/state_processing/src/per_epoch_processing/altair/inactivity_updates.rs +++ b/consensus/state_processing/src/per_epoch_processing/altair/inactivity_updates.rs @@ -1,7 +1,5 @@ use super::ParticipationCache; use crate::EpochProcessingError; -use core::result::Result; -use core::result::Result::Ok; use safe_arith::SafeArith; use std::cmp::min; use types::beacon_state::BeaconState; diff --git a/consensus/state_processing/src/per_epoch_processing/altair/participation_flag_updates.rs b/consensus/state_processing/src/per_epoch_processing/altair/participation_flag_updates.rs index 7162fa7f4af..a5b438e72ab 100644 --- a/consensus/state_processing/src/per_epoch_processing/altair/participation_flag_updates.rs +++ b/consensus/state_processing/src/per_epoch_processing/altair/participation_flag_updates.rs @@ -1,6 +1,4 @@ use crate::EpochProcessingError; -use core::result::Result; -use core::result::Result::Ok; use types::beacon_state::BeaconState; use types::eth_spec::EthSpec; use types::participation_flags::ParticipationFlags; diff --git a/consensus/state_processing/src/per_epoch_processing/historical_roots_update.rs b/consensus/state_processing/src/per_epoch_processing/historical_roots_update.rs index 8466104aa53..baba4aa46b3 100644 --- a/consensus/state_processing/src/per_epoch_processing/historical_roots_update.rs +++ b/consensus/state_processing/src/per_epoch_processing/historical_roots_update.rs @@ -1,6 +1,4 @@ use super::errors::EpochProcessingError; -use core::result::Result; -use core::result::Result::Ok; use safe_arith::SafeArith; use tree_hash::TreeHash; use types::beacon_state::BeaconState; diff --git a/consensus/state_processing/src/per_epoch_processing/resets.rs b/consensus/state_processing/src/per_epoch_processing/resets.rs index dc3c9f07c06..87be1209ce9 100644 --- a/consensus/state_processing/src/per_epoch_processing/resets.rs +++ b/consensus/state_processing/src/per_epoch_processing/resets.rs @@ -1,6 +1,4 @@ use super::errors::EpochProcessingError; -use core::result::Result; -use core::result::Result::Ok; use safe_arith::SafeArith; use types::beacon_state::BeaconState; use types::eth_spec::EthSpec; diff --git a/consensus/types/src/beacon_block.rs b/consensus/types/src/beacon_block.rs index 90dff84b39a..5853f4d0829 100644 --- a/consensus/types/src/beacon_block.rs +++ b/consensus/types/src/beacon_block.rs @@ -1,10 +1,5 @@ -use crate::beacon_block_body::{ - BeaconBlockBodyAltair, BeaconBlockBodyBase, BeaconBlockBodyDeneb, BeaconBlockBodyMerge, - BeaconBlockBodyRef, BeaconBlockBodyRefMut, -}; use crate::test_utils::TestRandom; use crate::*; -use bls::Signature; use derivative::Derivative; use serde::{Deserialize, Serialize}; use ssz::{Decode, DecodeError}; @@ -762,8 +757,7 @@ impl> ForkVersionDeserialize #[cfg(test)] mod tests { use super::*; - use crate::test_utils::{test_ssz_tree_hash_pair_with, SeedableRng, TestRandom, XorShiftRng}; - use crate::{ForkName, MainnetEthSpec}; + use crate::test_utils::{test_ssz_tree_hash_pair_with, SeedableRng, XorShiftRng}; use ssz::Encode; type BeaconBlock = super::BeaconBlock; diff --git a/consensus/types/src/beacon_block_body.rs b/consensus/types/src/beacon_block_body.rs index b0a942d74a4..38155a4a6a5 100644 --- a/consensus/types/src/beacon_block_body.rs +++ b/consensus/types/src/beacon_block_body.rs @@ -4,7 +4,6 @@ use derivative::Derivative; use merkle_proof::{MerkleTree, MerkleTreeError}; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; -use ssz_types::VariableList; use std::marker::PhantomData; use superstruct::superstruct; use test_random_derive::TestRandom; diff --git a/consensus/types/src/beacon_state.rs b/consensus/types/src/beacon_state.rs index 4c0ee1bfa20..698c3a65732 100644 --- a/consensus/types/src/beacon_state.rs +++ b/consensus/types/src/beacon_state.rs @@ -12,8 +12,6 @@ use safe_arith::{ArithError, SafeArith}; use serde::{Deserialize, Serialize}; use ssz::{ssz_encode, Decode, DecodeError, Encode}; use ssz_derive::{Decode, Encode}; -use ssz_types::{typenum::Unsigned, BitVector, FixedVector}; -use std::convert::TryInto; use std::hash::Hash; use std::{fmt, mem, sync::Arc}; use superstruct::superstruct; @@ -1767,7 +1765,8 @@ impl BeaconState { BeaconState::Deneb(inner) => BeaconState::Deneb(inner.clone()), }; if config.committee_caches { - *res.committee_caches_mut() = self.committee_caches().clone(); + res.committee_caches_mut() + .clone_from(self.committee_caches()); *res.total_active_balance_mut() = *self.total_active_balance(); } if config.pubkey_cache { diff --git a/consensus/types/src/beacon_state/committee_cache.rs b/consensus/types/src/beacon_state/committee_cache.rs index 8d29bc22171..692b3f84708 100644 --- a/consensus/types/src/beacon_state/committee_cache.rs +++ b/consensus/types/src/beacon_state/committee_cache.rs @@ -1,6 +1,5 @@ #![allow(clippy::arithmetic_side_effects)] -use super::BeaconState; use crate::*; use core::num::NonZeroUsize; use safe_arith::SafeArith; diff --git a/consensus/types/src/beacon_state/tests.rs b/consensus/types/src/beacon_state/tests.rs index 6cd9c1dbf88..fcc17179593 100644 --- a/consensus/types/src/beacon_state/tests.rs +++ b/consensus/types/src/beacon_state/tests.rs @@ -1,6 +1,5 @@ #![cfg(test)] use crate::test_utils::*; -use crate::test_utils::{SeedableRng, XorShiftRng}; use beacon_chain::test_utils::{ interop_genesis_state_with_eth1, test_spec, BeaconChainHarness, EphemeralHarnessType, DEFAULT_ETH1_BLOCK_HASH, diff --git a/consensus/types/src/beacon_state/tree_hash_cache.rs b/consensus/types/src/beacon_state/tree_hash_cache.rs index 69cd6fbb87b..95155b06375 100644 --- a/consensus/types/src/beacon_state/tree_hash_cache.rs +++ b/consensus/types/src/beacon_state/tree_hash_cache.rs @@ -10,7 +10,6 @@ use rayon::prelude::*; use ssz_derive::{Decode, Encode}; use ssz_types::VariableList; use std::cmp::Ordering; -use std::iter::ExactSizeIterator; use tree_hash::{mix_in_length, MerkleHasher, TreeHash}; /// The number of leaves (including padding) on the `BeaconState` Merkle tree. diff --git a/consensus/types/src/bls_to_execution_change.rs b/consensus/types/src/bls_to_execution_change.rs index baa65f5172d..e6426e125ff 100644 --- a/consensus/types/src/bls_to_execution_change.rs +++ b/consensus/types/src/bls_to_execution_change.rs @@ -1,6 +1,5 @@ use crate::test_utils::TestRandom; use crate::*; -use bls::PublicKeyBytes; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; diff --git a/consensus/types/src/deposit_data.rs b/consensus/types/src/deposit_data.rs index e074ffdfaa1..f62829e7953 100644 --- a/consensus/types/src/deposit_data.rs +++ b/consensus/types/src/deposit_data.rs @@ -1,7 +1,6 @@ use crate::test_utils::TestRandom; use crate::*; -use bls::{PublicKeyBytes, SignatureBytes}; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; diff --git a/consensus/types/src/deposit_message.rs b/consensus/types/src/deposit_message.rs index e5c666df822..6184d0aeb32 100644 --- a/consensus/types/src/deposit_message.rs +++ b/consensus/types/src/deposit_message.rs @@ -1,7 +1,6 @@ use crate::test_utils::TestRandom; use crate::*; -use bls::PublicKeyBytes; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; diff --git a/consensus/types/src/deposit_tree_snapshot.rs b/consensus/types/src/deposit_tree_snapshot.rs index d4dcdb2edaa..1793be1c7c8 100644 --- a/consensus/types/src/deposit_tree_snapshot.rs +++ b/consensus/types/src/deposit_tree_snapshot.rs @@ -5,7 +5,6 @@ use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use test_utils::TestRandom; -use DEPOSIT_TREE_DEPTH; #[derive(Encode, Decode, Deserialize, Serialize, Clone, Debug, PartialEq, TestRandom)] pub struct FinalizedExecutionBlock { diff --git a/consensus/types/src/eth_spec.rs b/consensus/types/src/eth_spec.rs index 17baad9c4c7..446267facc1 100644 --- a/consensus/types/src/eth_spec.rs +++ b/consensus/types/src/eth_spec.rs @@ -3,8 +3,8 @@ use crate::*; use safe_arith::SafeArith; use serde::{Deserialize, Serialize}; use ssz_types::typenum::{ - bit::B0, UInt, Unsigned, U0, U1024, U1048576, U1073741824, U1099511627776, U128, U131072, U16, - U16777216, U2, U2048, U256, U32, U4, U4096, U512, U6, U625, U64, U65536, U8, U8192, + bit::B0, UInt, U0, U1024, U1048576, U1073741824, U1099511627776, U128, U131072, U16, U16777216, + U2, U2048, U256, U32, U4, U4096, U512, U6, U625, U64, U65536, U8, U8192, }; use ssz_types::typenum::{U17, U9}; use std::fmt::{self, Debug}; diff --git a/consensus/types/src/execution_payload_header.rs b/consensus/types/src/execution_payload_header.rs index e0859c0a1e9..9a2be345a8a 100644 --- a/consensus/types/src/execution_payload_header.rs +++ b/consensus/types/src/execution_payload_header.rs @@ -6,7 +6,6 @@ use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; use tree_hash::TreeHash; use tree_hash_derive::TreeHash; -use BeaconStateError; #[superstruct( variants(Merge, Capella, Deneb), diff --git a/consensus/types/src/fork_name.rs b/consensus/types/src/fork_name.rs index 6523b2a678c..7a3b026d300 100644 --- a/consensus/types/src/fork_name.rs +++ b/consensus/types/src/fork_name.rs @@ -1,7 +1,6 @@ use crate::{ChainSpec, Epoch}; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; -use std::convert::TryFrom; use std::fmt::{self, Display, Formatter}; use std::str::FromStr; diff --git a/consensus/types/src/historical_batch.rs b/consensus/types/src/historical_batch.rs index e3e037fd630..dffbf392f6b 100644 --- a/consensus/types/src/historical_batch.rs +++ b/consensus/types/src/historical_batch.rs @@ -3,7 +3,6 @@ use crate::*; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; -use ssz_types::FixedVector; use test_random_derive::TestRandom; use tree_hash_derive::TreeHash; diff --git a/consensus/types/src/indexed_attestation.rs b/consensus/types/src/indexed_attestation.rs index c2d48d72428..6eccab429d9 100644 --- a/consensus/types/src/indexed_attestation.rs +++ b/consensus/types/src/indexed_attestation.rs @@ -106,7 +106,7 @@ mod quoted_variable_list_u64 { mod tests { use super::*; use crate::slot_epoch::Epoch; - use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; + use crate::test_utils::{SeedableRng, XorShiftRng}; use crate::MainnetEthSpec; #[test] diff --git a/consensus/types/src/payload.rs b/consensus/types/src/payload.rs index 2f7975161c5..4e83e3abf60 100644 --- a/consensus/types/src/payload.rs +++ b/consensus/types/src/payload.rs @@ -5,7 +5,6 @@ use serde::{Deserialize, Serialize}; use ssz::{Decode, Encode}; use ssz_derive::{Decode, Encode}; use std::borrow::Cow; -use std::convert::TryFrom; use std::fmt::Debug; use std::hash::Hash; use test_random_derive::TestRandom; diff --git a/consensus/types/src/selection_proof.rs b/consensus/types/src/selection_proof.rs index 2a404b3b963..14fdf5be95a 100644 --- a/consensus/types/src/selection_proof.rs +++ b/consensus/types/src/selection_proof.rs @@ -5,7 +5,6 @@ use ethereum_hashing::hash; use safe_arith::{ArithError, SafeArith}; use ssz::Encode; use std::cmp; -use std::convert::TryInto; #[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone)] pub struct SelectionProof(Signature); diff --git a/consensus/types/src/signed_beacon_block.rs b/consensus/types/src/signed_beacon_block.rs index 37304de1f1b..4914c1d29aa 100644 --- a/consensus/types/src/signed_beacon_block.rs +++ b/consensus/types/src/signed_beacon_block.rs @@ -1,6 +1,5 @@ use crate::beacon_block_body::format_kzg_commitments; use crate::*; -use bls::Signature; use derivative::Derivative; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; diff --git a/consensus/types/src/signed_bls_to_execution_change.rs b/consensus/types/src/signed_bls_to_execution_change.rs index 2a4ecdf4387..a7bfd7c2710 100644 --- a/consensus/types/src/signed_bls_to_execution_change.rs +++ b/consensus/types/src/signed_bls_to_execution_change.rs @@ -1,6 +1,5 @@ use crate::test_utils::TestRandom; use crate::*; -use bls::Signature; use serde::{Deserialize, Serialize}; use ssz_derive::{Decode, Encode}; use test_random_derive::TestRandom; diff --git a/consensus/types/src/slot_epoch.rs b/consensus/types/src/slot_epoch.rs index ec659d1dbbf..79d00649111 100644 --- a/consensus/types/src/slot_epoch.rs +++ b/consensus/types/src/slot_epoch.rs @@ -19,7 +19,6 @@ use serde::{Deserialize, Serialize}; use ssz::{Decode, DecodeError, Encode}; use std::fmt; use std::hash::Hash; -use std::iter::Iterator; #[cfg(feature = "legacy-arith")] use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Rem, Sub, SubAssign}; diff --git a/consensus/types/src/sqlite.rs b/consensus/types/src/sqlite.rs index 194d14b23ea..aa20666ae1c 100644 --- a/consensus/types/src/sqlite.rs +++ b/consensus/types/src/sqlite.rs @@ -4,7 +4,6 @@ use rusqlite::{ types::{FromSql, FromSqlError, ToSql, ToSqlOutput, ValueRef}, Error, }; -use std::convert::TryFrom; macro_rules! impl_to_from_sql { ($type:ty) => { diff --git a/consensus/types/src/sync_selection_proof.rs b/consensus/types/src/sync_selection_proof.rs index 7cae3946c6b..b410df83de1 100644 --- a/consensus/types/src/sync_selection_proof.rs +++ b/consensus/types/src/sync_selection_proof.rs @@ -10,7 +10,6 @@ use safe_arith::{ArithError, SafeArith}; use ssz::Encode; use ssz_types::typenum::Unsigned; use std::cmp; -use std::convert::TryInto; #[derive(arbitrary::Arbitrary, PartialEq, Debug, Clone)] pub struct SyncSelectionProof(Signature); diff --git a/consensus/types/src/test_utils/test_random.rs b/consensus/types/src/test_utils/test_random.rs index f31df2ce1b6..0adaf81bd7d 100644 --- a/consensus/types/src/test_utils/test_random.rs +++ b/consensus/types/src/test_utils/test_random.rs @@ -2,7 +2,6 @@ use crate::*; use rand::RngCore; use rand::SeedableRng; use rand_xorshift::XorShiftRng; -use ssz_types::typenum::Unsigned; use std::marker::PhantomData; use std::sync::Arc; diff --git a/consensus/types/src/test_utils/test_random/address.rs b/consensus/types/src/test_utils/test_random/address.rs index 3aaad307e8a..421801ce53c 100644 --- a/consensus/types/src/test_utils/test_random/address.rs +++ b/consensus/types/src/test_utils/test_random/address.rs @@ -1,5 +1,4 @@ use super::*; -use crate::Address; impl TestRandom for Address { fn random_for_test(rng: &mut impl RngCore) -> Self { diff --git a/consensus/types/src/test_utils/test_random/aggregate_signature.rs b/consensus/types/src/test_utils/test_random/aggregate_signature.rs index 5d3c916b9ab..772f2844313 100644 --- a/consensus/types/src/test_utils/test_random/aggregate_signature.rs +++ b/consensus/types/src/test_utils/test_random/aggregate_signature.rs @@ -1,5 +1,4 @@ use super::*; -use bls::{AggregateSignature, Signature}; impl TestRandom for AggregateSignature { fn random_for_test(rng: &mut impl RngCore) -> Self { diff --git a/consensus/types/src/test_utils/test_random/bitfield.rs b/consensus/types/src/test_utils/test_random/bitfield.rs index 3992421e375..f73f7c18c5a 100644 --- a/consensus/types/src/test_utils/test_random/bitfield.rs +++ b/consensus/types/src/test_utils/test_random/bitfield.rs @@ -1,5 +1,4 @@ use super::*; -use crate::{BitList, BitVector, Unsigned}; use smallvec::smallvec; impl TestRandom for BitList { diff --git a/consensus/types/src/test_utils/test_random/hash256.rs b/consensus/types/src/test_utils/test_random/hash256.rs index 8733f7de244..21d443c0e2a 100644 --- a/consensus/types/src/test_utils/test_random/hash256.rs +++ b/consensus/types/src/test_utils/test_random/hash256.rs @@ -1,5 +1,4 @@ use super::*; -use crate::Hash256; impl TestRandom for Hash256 { fn random_for_test(rng: &mut impl RngCore) -> Self { diff --git a/consensus/types/src/test_utils/test_random/kzg_proof.rs b/consensus/types/src/test_utils/test_random/kzg_proof.rs index d6d8ed2d084..7e771ca5660 100644 --- a/consensus/types/src/test_utils/test_random/kzg_proof.rs +++ b/consensus/types/src/test_utils/test_random/kzg_proof.rs @@ -1,5 +1,5 @@ use super::*; -use kzg::{KzgProof, BYTES_PER_COMMITMENT}; +use kzg::BYTES_PER_COMMITMENT; impl TestRandom for KzgProof { fn random_for_test(rng: &mut impl RngCore) -> Self { diff --git a/consensus/types/src/test_utils/test_random/public_key.rs b/consensus/types/src/test_utils/test_random/public_key.rs index 12821ee6238..d33e9ac7043 100644 --- a/consensus/types/src/test_utils/test_random/public_key.rs +++ b/consensus/types/src/test_utils/test_random/public_key.rs @@ -1,5 +1,4 @@ use super::*; -use bls::{PublicKey, SecretKey}; impl TestRandom for PublicKey { fn random_for_test(rng: &mut impl RngCore) -> Self { diff --git a/consensus/types/src/test_utils/test_random/public_key_bytes.rs b/consensus/types/src/test_utils/test_random/public_key_bytes.rs index f04bfc3bc85..6e5cafc4f03 100644 --- a/consensus/types/src/test_utils/test_random/public_key_bytes.rs +++ b/consensus/types/src/test_utils/test_random/public_key_bytes.rs @@ -1,6 +1,4 @@ -use std::convert::From; - -use bls::{PublicKeyBytes, PUBLIC_KEY_BYTES_LEN}; +use bls::PUBLIC_KEY_BYTES_LEN; use super::*; diff --git a/consensus/types/src/test_utils/test_random/secret_key.rs b/consensus/types/src/test_utils/test_random/secret_key.rs index 33fbcec5609..3f3f6ed5184 100644 --- a/consensus/types/src/test_utils/test_random/secret_key.rs +++ b/consensus/types/src/test_utils/test_random/secret_key.rs @@ -1,5 +1,4 @@ use super::*; -use bls::SecretKey; impl TestRandom for SecretKey { fn random_for_test(_rng: &mut impl RngCore) -> Self { diff --git a/consensus/types/src/test_utils/test_random/signature.rs b/consensus/types/src/test_utils/test_random/signature.rs index 119c81babb9..5b952296b61 100644 --- a/consensus/types/src/test_utils/test_random/signature.rs +++ b/consensus/types/src/test_utils/test_random/signature.rs @@ -1,5 +1,4 @@ use super::*; -use bls::{SecretKey, Signature}; impl TestRandom for Signature { fn random_for_test(rng: &mut impl RngCore) -> Self { diff --git a/consensus/types/src/test_utils/test_random/signature_bytes.rs b/consensus/types/src/test_utils/test_random/signature_bytes.rs index a4ae772d896..2117a482321 100644 --- a/consensus/types/src/test_utils/test_random/signature_bytes.rs +++ b/consensus/types/src/test_utils/test_random/signature_bytes.rs @@ -1,7 +1,6 @@ -use bls::{SignatureBytes, SIGNATURE_BYTES_LEN}; +use bls::SIGNATURE_BYTES_LEN; use super::*; -use std::convert::From; impl TestRandom for SignatureBytes { fn random_for_test(rng: &mut impl RngCore) -> Self { diff --git a/consensus/types/src/test_utils/test_random/uint256.rs b/consensus/types/src/test_utils/test_random/uint256.rs index a74cc6b3d86..5eccc0a9fa5 100644 --- a/consensus/types/src/test_utils/test_random/uint256.rs +++ b/consensus/types/src/test_utils/test_random/uint256.rs @@ -1,5 +1,4 @@ use super::*; -use crate::Uint256; impl TestRandom for Uint256 { fn random_for_test(rng: &mut impl RngCore) -> Self { diff --git a/consensus/types/src/tree_hash_impls.rs b/consensus/types/src/tree_hash_impls.rs index 34043c0e83f..eb3660d4666 100644 --- a/consensus/types/src/tree_hash_impls.rs +++ b/consensus/types/src/tree_hash_impls.rs @@ -101,7 +101,6 @@ fn process_bool_field(val: bool, leaf: &mut Hash256, force_update: bool) -> bool mod test { use super::*; use crate::test_utils::TestRandom; - use crate::Epoch; use rand::SeedableRng; use rand_xorshift::XorShiftRng; use tree_hash::TreeHash; diff --git a/crypto/bls/src/generic_public_key_bytes.rs b/crypto/bls/src/generic_public_key_bytes.rs index 240568b4f67..985bff745c6 100644 --- a/crypto/bls/src/generic_public_key_bytes.rs +++ b/crypto/bls/src/generic_public_key_bytes.rs @@ -6,7 +6,6 @@ use serde::de::{Deserialize, Deserializer}; use serde::ser::{Serialize, Serializer}; use serde_utils::hex::encode as hex_encode; use ssz::{Decode, Encode}; -use std::convert::TryInto; use std::fmt; use std::hash::{Hash, Hasher}; use std::marker::PhantomData; diff --git a/crypto/bls/src/generic_signature_bytes.rs b/crypto/bls/src/generic_signature_bytes.rs index 8f9f2a4d88e..b291adb7357 100644 --- a/crypto/bls/src/generic_signature_bytes.rs +++ b/crypto/bls/src/generic_signature_bytes.rs @@ -7,7 +7,6 @@ use serde::de::{Deserialize, Deserializer}; use serde::ser::{Serialize, Serializer}; use serde_utils::hex::encode as hex_encode; use ssz::{Decode, Encode}; -use std::convert::TryInto; use std::fmt; use std::hash::{Hash, Hasher}; use std::marker::PhantomData; diff --git a/crypto/bls/src/impls/blst.rs b/crypto/bls/src/impls/blst.rs index e831a175c7a..0049d79cc55 100644 --- a/crypto/bls/src/impls/blst.rs +++ b/crypto/bls/src/impls/blst.rs @@ -9,7 +9,6 @@ use crate::{ pub use blst::min_pk as blst_core; use blst::{blst_scalar, BLST_ERROR}; use rand::Rng; -use std::iter::ExactSizeIterator; pub const DST: &[u8] = b"BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_POP_"; pub const RAND_BITS: usize = 64; diff --git a/crypto/eth2_key_derivation/src/derived_key.rs b/crypto/eth2_key_derivation/src/derived_key.rs index b3373782aca..21f98796d43 100644 --- a/crypto/eth2_key_derivation/src/derived_key.rs +++ b/crypto/eth2_key_derivation/src/derived_key.rs @@ -2,7 +2,6 @@ use crate::{lamport_secret_key::LamportSecretKey, secret_bytes::SecretBytes, Zer use num_bigint_dig::BigUint; use ring::hkdf::{KeyType, Prk, Salt, HKDF_SHA256}; use sha2::{Digest, Sha256}; -use std::convert::TryFrom; use zeroize::Zeroize; /// The byte size of a SHA256 hash. diff --git a/crypto/eth2_key_derivation/src/lamport_secret_key.rs b/crypto/eth2_key_derivation/src/lamport_secret_key.rs index aa6dbb39323..c0c6eca4f14 100644 --- a/crypto/eth2_key_derivation/src/lamport_secret_key.rs +++ b/crypto/eth2_key_derivation/src/lamport_secret_key.rs @@ -1,5 +1,4 @@ use crate::derived_key::{HASH_SIZE, LAMPORT_ARRAY_SIZE}; -use std::iter::Iterator; use zeroize::Zeroize; /// A Lamport secret key as specified in [EIP-2333](https://eips.ethereum.org/EIPS/eip-2333). diff --git a/crypto/eth2_keystore/src/json_keystore/checksum_module.rs b/crypto/eth2_keystore/src/json_keystore/checksum_module.rs index bbcc418185d..dbb21e4de19 100644 --- a/crypto/eth2_keystore/src/json_keystore/checksum_module.rs +++ b/crypto/eth2_keystore/src/json_keystore/checksum_module.rs @@ -6,7 +6,6 @@ use super::hex_bytes::HexBytes; use serde::{Deserialize, Serialize}; use serde_json::{Map, Value}; -use std::convert::TryFrom; /// Used for ensuring that serde only decodes valid checksum functions. #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] diff --git a/crypto/eth2_keystore/src/json_keystore/cipher_module.rs b/crypto/eth2_keystore/src/json_keystore/cipher_module.rs index 5300b2f8b28..03a9d305a27 100644 --- a/crypto/eth2_keystore/src/json_keystore/cipher_module.rs +++ b/crypto/eth2_keystore/src/json_keystore/cipher_module.rs @@ -5,7 +5,6 @@ use super::hex_bytes::HexBytes; use serde::{Deserialize, Serialize}; -use std::convert::TryFrom; /// Used for ensuring that serde only decodes valid cipher functions. #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] diff --git a/crypto/eth2_keystore/src/json_keystore/hex_bytes.rs b/crypto/eth2_keystore/src/json_keystore/hex_bytes.rs index 67e156ff43c..cc61f13d979 100644 --- a/crypto/eth2_keystore/src/json_keystore/hex_bytes.rs +++ b/crypto/eth2_keystore/src/json_keystore/hex_bytes.rs @@ -1,5 +1,4 @@ use serde::{Deserialize, Serialize}; -use std::convert::TryFrom; /// To allow serde to encode/decode byte arrays from HEX ASCII strings. #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] diff --git a/crypto/eth2_keystore/src/json_keystore/kdf_module.rs b/crypto/eth2_keystore/src/json_keystore/kdf_module.rs index 94aeab0682a..a29b895c953 100644 --- a/crypto/eth2_keystore/src/json_keystore/kdf_module.rs +++ b/crypto/eth2_keystore/src/json_keystore/kdf_module.rs @@ -8,7 +8,6 @@ use crate::DKLEN; use hmac::{Hmac, Mac, NewMac}; use serde::{Deserialize, Serialize}; use sha2::Sha256; -use std::convert::TryFrom; /// KDF module representation. #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] diff --git a/crypto/eth2_keystore/src/keystore.rs b/crypto/eth2_keystore/src/keystore.rs index 2049518cd4c..304ea3ecd6f 100644 --- a/crypto/eth2_keystore/src/keystore.rs +++ b/crypto/eth2_keystore/src/keystore.rs @@ -23,7 +23,6 @@ use serde::{Deserialize, Serialize}; use sha2::{Digest, Sha256}; use std::fs::File; use std::io::{Read, Write}; -use std::iter::FromIterator; use std::path::Path; use std::str; use unicode_normalization::UnicodeNormalization; diff --git a/crypto/eth2_wallet/src/json_wallet/mod.rs b/crypto/eth2_wallet/src/json_wallet/mod.rs index 834716fba2d..d2092508a23 100644 --- a/crypto/eth2_wallet/src/json_wallet/mod.rs +++ b/crypto/eth2_wallet/src/json_wallet/mod.rs @@ -1,6 +1,5 @@ use serde::{Deserialize, Serialize}; use serde_repr::*; -use std::convert::TryFrom; pub use eth2_keystore::json_keystore::{ Aes128Ctr, ChecksumModule, Cipher, CipherModule, Crypto, EmptyMap, EmptyString, Kdf, KdfModule, diff --git a/crypto/eth2_wallet/src/validator_path.rs b/crypto/eth2_wallet/src/validator_path.rs index 3b4f7738dac..db175aa5d29 100644 --- a/crypto/eth2_wallet/src/validator_path.rs +++ b/crypto/eth2_wallet/src/validator_path.rs @@ -1,5 +1,4 @@ use std::fmt; -use std::iter::Iterator; pub const PURPOSE: u32 = 12381; pub const COIN_TYPE: u32 = 3600; diff --git a/slasher/src/array.rs b/slasher/src/array.rs index 91c8f373f45..b733b07c63f 100644 --- a/slasher/src/array.rs +++ b/slasher/src/array.rs @@ -7,9 +7,7 @@ use flate2::bufread::{ZlibDecoder, ZlibEncoder}; use serde::{Deserialize, Serialize}; use std::borrow::Borrow; use std::collections::{btree_map::Entry, BTreeMap, HashSet}; -use std::convert::TryFrom; use std::io::Read; -use std::iter::Extend; use std::sync::Arc; use types::{AttesterSlashing, Epoch, EthSpec, IndexedAttestation}; diff --git a/slasher/src/database/lmdb_impl.rs b/slasher/src/database/lmdb_impl.rs index 98839fcc46c..78deaf17676 100644 --- a/slasher/src/database/lmdb_impl.rs +++ b/slasher/src/database/lmdb_impl.rs @@ -3,15 +3,12 @@ use crate::{ config::MEGABYTE, database::{ - interface::{Key, OpenDatabases, Value}, + interface::{Key, Value}, *, }, - Config, Error, }; use lmdb::{Cursor as _, DatabaseFlags, Transaction, WriteFlags}; use lmdb_sys::{MDB_FIRST, MDB_GET_CURRENT, MDB_LAST, MDB_NEXT}; -use std::borrow::Cow; -use std::marker::PhantomData; use std::path::PathBuf; #[derive(Debug)] diff --git a/slasher/tests/random.rs b/slasher/tests/random.rs index 968a4dbb688..ce0e42df1d3 100644 --- a/slasher/tests/random.rs +++ b/slasher/tests/random.rs @@ -2,7 +2,6 @@ use logging::test_logger; use rand::prelude::*; -use rand::{rngs::StdRng, thread_rng, Rng, SeedableRng}; use slasher::{ test_utils::{ block, indexed_att, slashed_validators_from_attestations, diff --git a/testing/ef_tests/src/cases/bls_eth_fast_aggregate_verify.rs b/testing/ef_tests/src/cases/bls_eth_fast_aggregate_verify.rs index 0fb3a026cfb..88a161e974b 100644 --- a/testing/ef_tests/src/cases/bls_eth_fast_aggregate_verify.rs +++ b/testing/ef_tests/src/cases/bls_eth_fast_aggregate_verify.rs @@ -3,7 +3,6 @@ use crate::case_result::compare_result; use crate::impl_bls_load_case; use bls::{AggregateSignature, PublicKeyBytes}; use serde::Deserialize; -use std::convert::TryInto; use types::Hash256; #[derive(Debug, Clone, Deserialize)] diff --git a/testing/ef_tests/src/cases/bls_fast_aggregate_verify.rs b/testing/ef_tests/src/cases/bls_fast_aggregate_verify.rs index dcdc1bd1979..cec2edcfad4 100644 --- a/testing/ef_tests/src/cases/bls_fast_aggregate_verify.rs +++ b/testing/ef_tests/src/cases/bls_fast_aggregate_verify.rs @@ -3,7 +3,6 @@ use crate::case_result::compare_result; use crate::impl_bls_load_case; use bls::{AggregateSignature, PublicKeyBytes}; use serde::Deserialize; -use std::convert::TryInto; use types::Hash256; #[derive(Debug, Clone, Deserialize)] diff --git a/testing/ef_tests/src/cases/bls_verify_msg.rs b/testing/ef_tests/src/cases/bls_verify_msg.rs index 24b62c5fa1d..42ee459a607 100644 --- a/testing/ef_tests/src/cases/bls_verify_msg.rs +++ b/testing/ef_tests/src/cases/bls_verify_msg.rs @@ -3,7 +3,6 @@ use crate::case_result::compare_result; use crate::impl_bls_load_case; use bls::{PublicKeyBytes, Signature, SignatureBytes}; use serde::Deserialize; -use std::convert::TryInto; use types::Hash256; #[derive(Debug, Clone, Deserialize)] diff --git a/testing/ef_tests/src/cases/common.rs b/testing/ef_tests/src/cases/common.rs index 2a7c9987583..d75880b2969 100644 --- a/testing/ef_tests/src/cases/common.rs +++ b/testing/ef_tests/src/cases/common.rs @@ -1,7 +1,6 @@ use serde::Deserialize; use ssz::Encode; use ssz_derive::{Decode, Encode}; -use std::convert::TryFrom; use std::fmt::Debug; use tree_hash::TreeHash; use types::ForkName; diff --git a/testing/ef_tests/src/cases/epoch_processing.rs b/testing/ef_tests/src/cases/epoch_processing.rs index cf182af2b21..c3b03ae1fee 100644 --- a/testing/ef_tests/src/cases/epoch_processing.rs +++ b/testing/ef_tests/src/cases/epoch_processing.rs @@ -3,7 +3,6 @@ use crate::bls_setting::BlsSetting; use crate::case_result::compare_beacon_state_results_without_caches; use crate::decode::{ssz_decode_state, yaml_decode_file}; use crate::type_name; -use crate::type_name::TypeName; use serde::Deserialize; use state_processing::per_epoch_processing::capella::process_historical_summaries_update; use state_processing::per_epoch_processing::effective_balance_updates::process_effective_balance_updates; @@ -15,8 +14,7 @@ use state_processing::per_epoch_processing::{ }; use state_processing::EpochProcessingError; use std::marker::PhantomData; -use std::path::{Path, PathBuf}; -use types::{BeaconState, ChainSpec, EthSpec, ForkName}; +use types::BeaconState; #[derive(Debug, Clone, Default, Deserialize)] pub struct Metadata { diff --git a/testing/ef_tests/src/cases/fork.rs b/testing/ef_tests/src/cases/fork.rs index bc340fa1cbb..58498ca62bf 100644 --- a/testing/ef_tests/src/cases/fork.rs +++ b/testing/ef_tests/src/cases/fork.rs @@ -6,7 +6,7 @@ use serde::Deserialize; use state_processing::upgrade::{ upgrade_to_altair, upgrade_to_bellatrix, upgrade_to_capella, upgrade_to_deneb, }; -use types::{BeaconState, ForkName}; +use types::BeaconState; #[derive(Debug, Clone, Default, Deserialize)] pub struct Metadata { diff --git a/testing/ef_tests/src/cases/fork_choice.rs b/testing/ef_tests/src/cases/fork_choice.rs index 9884a709eb9..6b8148d305d 100644 --- a/testing/ef_tests/src/cases/fork_choice.rs +++ b/testing/ef_tests/src/cases/fork_choice.rs @@ -24,8 +24,8 @@ use std::sync::Arc; use std::time::Duration; use types::{ Attestation, AttesterSlashing, BeaconBlock, BeaconState, BlobSidecar, BlobsList, Checkpoint, - EthSpec, ExecutionBlockHash, ForkName, Hash256, IndexedAttestation, KzgProof, - ProgressiveBalancesMode, ProposerPreparationData, SignedBeaconBlock, Slot, Uint256, + ExecutionBlockHash, Hash256, IndexedAttestation, KzgProof, ProgressiveBalancesMode, + ProposerPreparationData, SignedBeaconBlock, Slot, Uint256, }; #[derive(Default, Debug, PartialEq, Clone, Deserialize, Decode)] diff --git a/testing/ef_tests/src/cases/genesis_initialization.rs b/testing/ef_tests/src/cases/genesis_initialization.rs index 14fe7ef9590..11402c75e62 100644 --- a/testing/ef_tests/src/cases/genesis_initialization.rs +++ b/testing/ef_tests/src/cases/genesis_initialization.rs @@ -3,8 +3,7 @@ use crate::case_result::compare_beacon_state_results_without_caches; use crate::decode::{ssz_decode_file, ssz_decode_file_with, ssz_decode_state, yaml_decode_file}; use serde::Deserialize; use state_processing::initialize_beacon_state_from_eth1; -use std::path::PathBuf; -use types::{BeaconState, Deposit, EthSpec, ExecutionPayloadHeader, ForkName, Hash256}; +use types::{BeaconState, Deposit, ExecutionPayloadHeader, Hash256}; #[derive(Debug, Clone, Deserialize)] struct Metadata { diff --git a/testing/ef_tests/src/cases/genesis_validity.rs b/testing/ef_tests/src/cases/genesis_validity.rs index ec89e0f64b8..e977fa3d637 100644 --- a/testing/ef_tests/src/cases/genesis_validity.rs +++ b/testing/ef_tests/src/cases/genesis_validity.rs @@ -2,8 +2,7 @@ use super::*; use crate::decode::{ssz_decode_state, yaml_decode_file}; use serde::Deserialize; use state_processing::is_valid_genesis_state; -use std::path::Path; -use types::{BeaconState, EthSpec, ForkName}; +use types::BeaconState; #[derive(Debug, Clone, Deserialize)] pub struct Metadata { diff --git a/testing/ef_tests/src/cases/kzg_verify_blob_kzg_proof.rs b/testing/ef_tests/src/cases/kzg_verify_blob_kzg_proof.rs index 04d1b8d5dc6..f68f0fd7ed0 100644 --- a/testing/ef_tests/src/cases/kzg_verify_blob_kzg_proof.rs +++ b/testing/ef_tests/src/cases/kzg_verify_blob_kzg_proof.rs @@ -4,7 +4,6 @@ use beacon_chain::kzg_utils::validate_blob; use eth2_network_config::TRUSTED_SETUP_BYTES; use kzg::{Error as KzgError, Kzg, KzgCommitment, KzgProof, TrustedSetup}; use serde::Deserialize; -use std::convert::TryInto; use std::marker::PhantomData; use types::Blob; diff --git a/testing/ef_tests/src/cases/merkle_proof_validity.rs b/testing/ef_tests/src/cases/merkle_proof_validity.rs index d9deda81232..5553df588b6 100644 --- a/testing/ef_tests/src/cases/merkle_proof_validity.rs +++ b/testing/ef_tests/src/cases/merkle_proof_validity.rs @@ -1,9 +1,8 @@ use super::*; use crate::decode::{ssz_decode_file, ssz_decode_state, yaml_decode_file}; use serde::Deserialize; -use std::path::Path; use tree_hash::Hash256; -use types::{BeaconBlockBody, BeaconBlockBodyDeneb, BeaconState, EthSpec, ForkName}; +use types::{BeaconBlockBody, BeaconBlockBodyDeneb, BeaconState}; #[derive(Debug, Clone, Deserialize)] pub struct Metadata { diff --git a/testing/ef_tests/src/cases/operations.rs b/testing/ef_tests/src/cases/operations.rs index 4c02126d41a..40cacb173fb 100644 --- a/testing/ef_tests/src/cases/operations.rs +++ b/testing/ef_tests/src/cases/operations.rs @@ -2,7 +2,6 @@ use super::*; use crate::bls_setting::BlsSetting; use crate::case_result::compare_beacon_state_results_without_caches; use crate::decode::{ssz_decode_file, ssz_decode_file_with, ssz_decode_state, yaml_decode_file}; -use crate::testing_spec; use serde::Deserialize; use ssz::Decode; use state_processing::common::update_progressive_balances_cache::initialize_progressive_balances_cache; @@ -19,11 +18,10 @@ use state_processing::{ ConsensusContext, }; use std::fmt::Debug; -use std::path::Path; use types::{ Attestation, AttesterSlashing, BeaconBlock, BeaconBlockBody, BeaconBlockBodyCapella, - BeaconBlockBodyDeneb, BeaconBlockBodyMerge, BeaconState, BlindedPayload, ChainSpec, Deposit, - EthSpec, ExecutionPayload, ForkName, FullPayload, ProposerSlashing, SignedBlsToExecutionChange, + BeaconBlockBodyDeneb, BeaconBlockBodyMerge, BeaconState, BlindedPayload, Deposit, + ExecutionPayload, FullPayload, ProposerSlashing, SignedBlsToExecutionChange, SignedVoluntaryExit, SyncAggregate, }; diff --git a/testing/ef_tests/src/cases/rewards.rs b/testing/ef_tests/src/cases/rewards.rs index bb41f6fe12f..9d1c020fd67 100644 --- a/testing/ef_tests/src/cases/rewards.rs +++ b/testing/ef_tests/src/cases/rewards.rs @@ -13,10 +13,9 @@ use state_processing::{ }, EpochProcessingError, }; -use std::path::{Path, PathBuf}; use types::{ consts::altair::{TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX, TIMELY_TARGET_FLAG_INDEX}, - BeaconState, EthSpec, ForkName, + BeaconState, }; #[derive(Debug, Clone, PartialEq, Decode, Encode, CompareFields)] diff --git a/testing/ef_tests/src/cases/sanity_blocks.rs b/testing/ef_tests/src/cases/sanity_blocks.rs index cf8e6b5b2ff..b0902cb5b74 100644 --- a/testing/ef_tests/src/cases/sanity_blocks.rs +++ b/testing/ef_tests/src/cases/sanity_blocks.rs @@ -7,7 +7,7 @@ use state_processing::{ per_block_processing, per_slot_processing, BlockProcessingError, BlockSignatureStrategy, ConsensusContext, StateProcessingStrategy, VerifyBlockRoot, }; -use types::{BeaconState, EthSpec, ForkName, RelativeEpoch, SignedBeaconBlock}; +use types::{BeaconState, RelativeEpoch, SignedBeaconBlock}; #[derive(Debug, Clone, Deserialize)] pub struct Metadata { diff --git a/testing/ef_tests/src/cases/sanity_slots.rs b/testing/ef_tests/src/cases/sanity_slots.rs index 0da179d536e..71c782c78f4 100644 --- a/testing/ef_tests/src/cases/sanity_slots.rs +++ b/testing/ef_tests/src/cases/sanity_slots.rs @@ -4,7 +4,7 @@ use crate::case_result::compare_beacon_state_results_without_caches; use crate::decode::{ssz_decode_state, yaml_decode_file}; use serde::Deserialize; use state_processing::per_slot_processing; -use types::{BeaconState, EthSpec, ForkName}; +use types::BeaconState; #[derive(Debug, Clone, Default, Deserialize)] pub struct Metadata { diff --git a/testing/ef_tests/src/cases/shuffling.rs b/testing/ef_tests/src/cases/shuffling.rs index e05763c2d86..3d238b52963 100644 --- a/testing/ef_tests/src/cases/shuffling.rs +++ b/testing/ef_tests/src/cases/shuffling.rs @@ -4,7 +4,6 @@ use crate::decode::yaml_decode_file; use serde::Deserialize; use std::marker::PhantomData; use swap_or_not_shuffle::{compute_shuffled_index, shuffle_list}; -use types::ForkName; #[derive(Debug, Clone, Deserialize)] pub struct Shuffling { diff --git a/testing/ef_tests/src/cases/ssz_generic.rs b/testing/ef_tests/src/cases/ssz_generic.rs index d6c764f52b6..bb2465aae10 100644 --- a/testing/ef_tests/src/cases/ssz_generic.rs +++ b/testing/ef_tests/src/cases/ssz_generic.rs @@ -1,16 +1,14 @@ #![allow(non_snake_case)] use super::*; -use crate::cases::common::{SszStaticType, TestU128, TestU256}; -use crate::cases::ssz_static::{check_serialization, check_tree_hash}; +use crate::cases::common::{TestU128, TestU256}; use crate::decode::{snappy_decode_file, yaml_decode_file}; use serde::Deserialize; use serde::{de::Error as SerdeError, Deserializer}; use ssz_derive::{Decode, Encode}; -use std::path::{Path, PathBuf}; use tree_hash_derive::TreeHash; use types::typenum::*; -use types::{BitList, BitVector, FixedVector, ForkName, VariableList}; +use types::{BitList, BitVector, FixedVector, VariableList}; #[derive(Debug, Clone, Deserialize)] struct Metadata { diff --git a/testing/ef_tests/src/cases/ssz_static.rs b/testing/ef_tests/src/cases/ssz_static.rs index 423dc31528f..e41c90c6e03 100644 --- a/testing/ef_tests/src/cases/ssz_static.rs +++ b/testing/ef_tests/src/cases/ssz_static.rs @@ -1,11 +1,10 @@ use super::*; use crate::case_result::compare_result; -use crate::cases::common::SszStaticType; use crate::decode::{snappy_decode_file, yaml_decode_file}; use serde::Deserialize; use ssz::Decode; use tree_hash::TreeHash; -use types::{BeaconBlock, BeaconState, ForkName, Hash256, SignedBeaconBlock}; +use types::{BeaconBlock, BeaconState, Hash256, SignedBeaconBlock}; #[derive(Debug, Clone, Deserialize)] struct SszStaticRoots { diff --git a/testing/ef_tests/src/cases/transition.rs b/testing/ef_tests/src/cases/transition.rs index c94ce3a23a0..58e1226b7e6 100644 --- a/testing/ef_tests/src/cases/transition.rs +++ b/testing/ef_tests/src/cases/transition.rs @@ -7,7 +7,7 @@ use state_processing::{ ConsensusContext, StateProcessingStrategy, VerifyBlockRoot, }; use std::str::FromStr; -use types::{BeaconState, Epoch, ForkName, SignedBeaconBlock}; +use types::{BeaconState, Epoch, SignedBeaconBlock}; #[derive(Debug, Clone, Deserialize)] pub struct Metadata { diff --git a/testing/ef_tests/src/decode.rs b/testing/ef_tests/src/decode.rs index e95bddffac3..51ab682f3dc 100644 --- a/testing/ef_tests/src/decode.rs +++ b/testing/ef_tests/src/decode.rs @@ -5,7 +5,7 @@ use std::fs::{self}; use std::io::Write; use std::path::Path; use std::path::PathBuf; -use types::{BeaconState, EthSpec}; +use types::BeaconState; /// See `log_file_access` for details. const ACCESSED_FILE_LOG_FILENAME: &str = ".accessed_file_log.txt"; diff --git a/testing/eth1_test_rig/src/anvil.rs b/testing/eth1_test_rig/src/anvil.rs index 1b86711c2fc..c6c37ae4a7f 100644 --- a/testing/eth1_test_rig/src/anvil.rs +++ b/testing/eth1_test_rig/src/anvil.rs @@ -1,7 +1,6 @@ use ethers_core::utils::{Anvil, AnvilInstance}; use ethers_providers::{Http, Middleware, Provider}; use serde_json::json; -use std::convert::TryFrom; use unused_port::unused_tcp4_port; /// Provides a dedicated `anvil` instance. diff --git a/testing/state_transition_vectors/src/exit.rs b/testing/state_transition_vectors/src/exit.rs index 50b98d3066d..e3cd346da13 100644 --- a/testing/state_transition_vectors/src/exit.rs +++ b/testing/state_transition_vectors/src/exit.rs @@ -1,10 +1,9 @@ use super::*; -use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType}; use state_processing::{ per_block_processing, per_block_processing::errors::ExitInvalid, BlockProcessingError, BlockSignatureStrategy, ConsensusContext, StateProcessingStrategy, VerifyBlockRoot, }; -use types::{BeaconBlock, BeaconState, Epoch, EthSpec, SignedBeaconBlock}; +use types::{BeaconBlock, Epoch}; // Default validator index to exit. pub const VALIDATOR_INDEX: u64 = 0; diff --git a/validator_client/slashing_protection/src/attestation_tests.rs b/validator_client/slashing_protection/src/attestation_tests.rs index c66a67b70a6..a162c4e150e 100644 --- a/validator_client/slashing_protection/src/attestation_tests.rs +++ b/validator_client/slashing_protection/src/attestation_tests.rs @@ -2,7 +2,7 @@ use crate::test_utils::*; use crate::*; -use types::{AttestationData, Checkpoint, Epoch, Hash256, Slot}; +use types::{AttestationData, Checkpoint, Epoch, Slot}; pub fn build_checkpoint(epoch_num: u64) -> Checkpoint { Checkpoint { diff --git a/validator_client/slashing_protection/src/block_tests.rs b/validator_client/slashing_protection/src/block_tests.rs index a1f634ef07c..abd452a0b67 100644 --- a/validator_client/slashing_protection/src/block_tests.rs +++ b/validator_client/slashing_protection/src/block_tests.rs @@ -2,7 +2,7 @@ use super::*; use crate::test_utils::*; -use types::{BeaconBlockHeader, Hash256, Slot}; +use types::{BeaconBlockHeader, Slot}; pub fn block(slot: u64) -> BeaconBlockHeader { BeaconBlockHeader { diff --git a/validator_client/slashing_protection/src/lib.rs b/validator_client/slashing_protection/src/lib.rs index 1610b523720..c4fa32b611c 100644 --- a/validator_client/slashing_protection/src/lib.rs +++ b/validator_client/slashing_protection/src/lib.rs @@ -17,8 +17,8 @@ pub use crate::slashing_database::{ SUPPORTED_INTERCHANGE_FORMAT_VERSION, }; use rusqlite::Error as SQLError; +use std::fmt::Display; use std::io::{Error as IOError, ErrorKind}; -use std::string::ToString; use types::{Hash256, PublicKeyBytes}; /// The filename within the `validators` directory that contains the slashing protection DB. @@ -122,9 +122,9 @@ impl From for NotSafe { } } -impl ToString for NotSafe { - fn to_string(&self) -> String { - format!("{:?}", self) +impl Display for NotSafe { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self) } } diff --git a/validator_client/slashing_protection/src/test_utils.rs b/validator_client/slashing_protection/src/test_utils.rs index 3df892ecd97..efdeb9bc6ba 100644 --- a/validator_client/slashing_protection/src/test_utils.rs +++ b/validator_client/slashing_protection/src/test_utils.rs @@ -1,9 +1,6 @@ use crate::*; use tempfile::{tempdir, TempDir}; -use types::{ - test_utils::generate_deterministic_keypair, AttestationData, BeaconBlockHeader, Hash256, - PublicKeyBytes, -}; +use types::{test_utils::generate_deterministic_keypair, AttestationData, BeaconBlockHeader}; pub const DEFAULT_VALIDATOR_INDEX: usize = 0; pub const DEFAULT_DOMAIN: Hash256 = Hash256::zero(); diff --git a/validator_client/src/doppelganger_service.rs b/validator_client/src/doppelganger_service.rs index 86584d794c3..442a950ddcd 100644 --- a/validator_client/src/doppelganger_service.rs +++ b/validator_client/src/doppelganger_service.rs @@ -690,7 +690,6 @@ mod test { use environment::null_logger; use futures::executor::block_on; use slot_clock::TestingSlotClock; - use std::collections::HashSet; use std::future; use std::time::Duration; use types::{ diff --git a/validator_client/src/validator_store.rs b/validator_client/src/validator_store.rs index b8c11a79bc0..62805710e49 100644 --- a/validator_client/src/validator_store.rs +++ b/validator_client/src/validator_store.rs @@ -12,7 +12,6 @@ use slashing_protection::{ }; use slog::{crit, error, info, warn, Logger}; use slot_clock::SlotClock; -use std::iter::FromIterator; use std::marker::PhantomData; use std::path::Path; use std::sync::Arc; @@ -20,13 +19,12 @@ use task_executor::TaskExecutor; use types::{ attestation::Error as AttestationError, graffiti::GraffitiString, AbstractExecPayload, Address, AggregateAndProof, Attestation, BeaconBlock, BlindedPayload, ChainSpec, ContributionAndProof, - Domain, Epoch, EthSpec, Fork, ForkName, Graffiti, Hash256, Keypair, PublicKeyBytes, - SelectionProof, Signature, SignedAggregateAndProof, SignedBeaconBlock, - SignedContributionAndProof, SignedRoot, SignedValidatorRegistrationData, SignedVoluntaryExit, - Slot, SyncAggregatorSelectionData, SyncCommitteeContribution, SyncCommitteeMessage, - SyncSelectionProof, SyncSubnetId, ValidatorRegistrationData, VoluntaryExit, + Domain, Epoch, EthSpec, Fork, ForkName, Graffiti, Hash256, PublicKeyBytes, SelectionProof, + Signature, SignedAggregateAndProof, SignedBeaconBlock, SignedContributionAndProof, SignedRoot, + SignedValidatorRegistrationData, SignedVoluntaryExit, Slot, SyncAggregatorSelectionData, + SyncCommitteeContribution, SyncCommitteeMessage, SyncSelectionProof, SyncSubnetId, + ValidatorRegistrationData, VoluntaryExit, }; -use validator_dir::ValidatorDir; pub use crate::doppelganger_service::DoppelgangerStatus; use crate::preparation_service::ProposalData; @@ -60,31 +58,6 @@ const SLASHING_PROTECTION_HISTORY_EPOCHS: u64 = 512; /// https://github.com/ethereum/builder-specs/issues/17 pub const DEFAULT_GAS_LIMIT: u64 = 30_000_000; -struct LocalValidator { - validator_dir: ValidatorDir, - voting_keypair: Keypair, -} - -/// We derive our own `PartialEq` to avoid doing equality checks between secret keys. -/// -/// It's nice to avoid secret key comparisons from a security perspective, but it's also a little -/// risky when it comes to `HashMap` integrity (that's why we need `PartialEq`). -/// -/// Currently, we obtain keypairs from keystores where we derive the `PublicKey` from a `SecretKey` -/// via a hash function. In order to have two equal `PublicKey` with different `SecretKey` we would -/// need to have either: -/// -/// - A serious upstream integrity error. -/// - A hash collision. -/// -/// It seems reasonable to make these two assumptions in order to avoid the equality checks. -impl PartialEq for LocalValidator { - fn eq(&self, other: &Self) -> bool { - self.validator_dir == other.validator_dir - && self.voting_keypair.pk == other.voting_keypair.pk - } -} - pub struct ValidatorStore { validators: Arc>, slashing_protection: SlashingDatabase, diff --git a/watch/src/database/compat.rs b/watch/src/database/compat.rs index b8cda0b2168..e3e9e0df6fe 100644 --- a/watch/src/database/compat.rs +++ b/watch/src/database/compat.rs @@ -5,8 +5,6 @@ use diesel::pg::{Pg, PgValue}; use diesel::serialize::{self, Output, ToSql}; use diesel::sql_types::{Binary, Integer}; -use std::convert::TryFrom; - macro_rules! impl_to_from_sql_int { ($type:ty) => { impl ToSql for $type diff --git a/watch/src/database/mod.rs b/watch/src/database/mod.rs index 841ebe5ee7b..4856840243d 100644 --- a/watch/src/database/mod.rs +++ b/watch/src/database/mod.rs @@ -13,7 +13,6 @@ use self::schema::{ }; use diesel::dsl::max; -use diesel::pg::PgConnection; use diesel::prelude::*; use diesel::r2d2::{Builder, ConnectionManager, Pool, PooledConnection}; use diesel::upsert::excluded; diff --git a/watch/src/database/utils.rs b/watch/src/database/utils.rs index 7e450f0cee7..9134c3698f6 100644 --- a/watch/src/database/utils.rs +++ b/watch/src/database/utils.rs @@ -1,6 +1,5 @@ #![allow(dead_code)] use crate::database::config::Config; -use diesel::pg::PgConnection; use diesel::prelude::*; use diesel_migrations::{FileBasedMigrations, MigrationHarness}; diff --git a/watch/src/updater/handler.rs b/watch/src/updater/handler.rs index 1e1662bf749..382908eba52 100644 --- a/watch/src/updater/handler.rs +++ b/watch/src/updater/handler.rs @@ -9,7 +9,6 @@ use eth2::{ }; use log::{debug, error, info, warn}; use std::collections::HashSet; -use std::iter::FromIterator; use types::{BeaconBlockHeader, EthSpec, Hash256, SignedBeaconBlock, Slot}; use crate::updater::{get_beacon_block, get_header, get_validators};