From 01ec42e75a8b7a6eb9a84c456552d695acb10f6c Mon Sep 17 00:00:00 2001 From: Eitan Seri-Levi Date: Wed, 20 Mar 2024 07:17:02 +0200 Subject: [PATCH] Fix Rust beta compiler errors 1.78.0-beta.1 (#5439) * remove redundant imports * fix test * contains key * fmt * Merge branch 'unstable' into fix-beta-compiler --- beacon_node/beacon_chain/src/beacon_chain.rs | 5 +-- .../overflow_lru_cache.rs | 2 +- .../beacon_chain/src/early_attester_cache.rs | 1 - beacon_node/beacon_chain/src/eth1_chain.rs | 3 +- .../src/observed_blob_sidecars.rs | 2 +- .../beacon_chain/src/snapshot_cache.rs | 5 +-- beacon_node/beacon_chain/src/test_utils.rs | 1 - .../beacon_chain/src/validator_monitor.rs | 1 - .../src/validator_pubkey_cache.rs | 3 +- .../src/work_reprocessing_queue.rs | 1 - beacon_node/client/src/config.rs | 2 +- beacon_node/eth1/src/block_cache.rs | 1 - beacon_node/eth1/tests/test.rs | 1 - beacon_node/execution_layer/src/engine_api.rs | 1 - .../execution_layer/src/engine_api/http.rs | 3 +- .../src/engine_api/json_structures.rs | 5 +-- .../src/test_utils/handle_rpc.rs | 1 - .../src/test_utils/mock_builder.rs | 9 ----- .../src/test_utils/mock_execution_layer.rs | 6 +-- beacon_node/genesis/src/interop.rs | 2 +- .../http_api/src/block_packing_efficiency.rs | 7 ++-- .../src/gossipsub/behaviour.rs | 4 +- .../src/gossipsub/behaviour/tests.rs | 27 ++++++-------- .../src/gossipsub/config.rs | 2 - .../src/gossipsub/mcache.rs | 4 +- .../src/gossipsub/peer_score.rs | 6 +-- .../src/gossipsub/protocol.rs | 5 +-- .../src/gossipsub/subscription_filter.rs | 1 - .../src/peer_manager/peerdb.rs | 1 - .../src/rpc/codec/ssz_snappy.rs | 17 ++------- .../lighthouse_network/src/rpc/handler.rs | 2 +- .../lighthouse_network/src/rpc/methods.rs | 11 ++++-- .../lighthouse_network/src/rpc/outbound.rs | 7 ++-- .../lighthouse_network/src/rpc/protocol.rs | 5 +-- .../src/rpc/rate_limiter.rs | 1 - .../src/service/gossip_cache.rs | 2 - .../lighthouse_network/src/types/pubsub.rs | 1 - .../network_beacon_processor/rpc_methods.rs | 1 - beacon_node/network/src/persisted_dht.rs | 3 +- .../sync/block_lookups/single_block_lookup.rs | 3 +- .../network/src/sync/block_lookups/tests.rs | 2 - beacon_node/network/src/sync/manager.rs | 1 - .../network/src/sync/range_sync/range.rs | 3 +- beacon_node/operation_pool/src/max_cover.rs | 1 - beacon_node/src/config.rs | 4 +- beacon_node/store/src/chunked_vector.rs | 1 - beacon_node/store/src/hot_cold_store.rs | 2 - beacon_node/store/src/impls/beacon_state.rs | 2 - beacon_node/store/src/iter.rs | 1 - beacon_node/store/src/leveldb_store.rs | 3 +- beacon_node/store/src/partial_beacon_state.rs | 1 - common/deposit_contract/src/lib.rs | 4 +- common/eth2/src/lib.rs | 2 - common/eth2/src/types.rs | 1 - common/eth2_interop_keypairs/src/lib.rs | 1 - common/eth2_network_config/src/lib.rs | 2 +- common/slot_clock/src/manual_slot_clock.rs | 1 - consensus/cached_tree_hash/src/cache.rs | 4 +- consensus/fork_choice/src/fork_choice.rs | 2 +- consensus/proto_array/src/ssz_container.rs | 1 - consensus/state_processing/src/genesis.rs | 1 - .../process_operations.rs | 1 - .../altair/inactivity_updates.rs | 2 - .../altair/participation_flag_updates.rs | 2 - .../historical_roots_update.rs | 2 - .../src/per_epoch_processing/resets.rs | 2 - consensus/types/src/beacon_block.rs | 8 +--- consensus/types/src/beacon_block_body.rs | 1 - consensus/types/src/beacon_state.rs | 5 +-- .../types/src/beacon_state/committee_cache.rs | 1 - consensus/types/src/beacon_state/tests.rs | 1 - .../types/src/beacon_state/tree_hash_cache.rs | 1 - .../types/src/bls_to_execution_change.rs | 1 - consensus/types/src/deposit_data.rs | 1 - consensus/types/src/deposit_message.rs | 1 - consensus/types/src/deposit_tree_snapshot.rs | 1 - consensus/types/src/eth_spec.rs | 4 +- .../types/src/execution_payload_header.rs | 1 - consensus/types/src/fork_name.rs | 1 - consensus/types/src/historical_batch.rs | 1 - consensus/types/src/indexed_attestation.rs | 2 +- consensus/types/src/payload.rs | 1 - consensus/types/src/selection_proof.rs | 1 - consensus/types/src/signed_beacon_block.rs | 1 - .../src/signed_bls_to_execution_change.rs | 1 - consensus/types/src/slot_epoch.rs | 1 - consensus/types/src/sqlite.rs | 1 - consensus/types/src/sync_selection_proof.rs | 1 - consensus/types/src/test_utils/test_random.rs | 1 - .../src/test_utils/test_random/address.rs | 1 - .../test_random/aggregate_signature.rs | 1 - .../src/test_utils/test_random/bitfield.rs | 1 - .../src/test_utils/test_random/hash256.rs | 1 - .../src/test_utils/test_random/kzg_proof.rs | 2 +- .../src/test_utils/test_random/public_key.rs | 1 - .../test_random/public_key_bytes.rs | 4 +- .../src/test_utils/test_random/secret_key.rs | 1 - .../src/test_utils/test_random/signature.rs | 1 - .../test_utils/test_random/signature_bytes.rs | 3 +- .../src/test_utils/test_random/uint256.rs | 1 - consensus/types/src/tree_hash_impls.rs | 1 - crypto/bls/src/generic_public_key_bytes.rs | 1 - crypto/bls/src/generic_signature_bytes.rs | 1 - crypto/bls/src/impls/blst.rs | 1 - crypto/eth2_key_derivation/src/derived_key.rs | 1 - .../src/lamport_secret_key.rs | 1 - .../src/json_keystore/checksum_module.rs | 1 - .../src/json_keystore/cipher_module.rs | 1 - .../src/json_keystore/hex_bytes.rs | 1 - .../src/json_keystore/kdf_module.rs | 1 - crypto/eth2_keystore/src/keystore.rs | 1 - crypto/eth2_wallet/src/json_wallet/mod.rs | 1 - crypto/eth2_wallet/src/validator_path.rs | 1 - slasher/src/array.rs | 2 - slasher/src/database/lmdb_impl.rs | 5 +-- slasher/tests/random.rs | 1 - .../cases/bls_eth_fast_aggregate_verify.rs | 1 - .../src/cases/bls_fast_aggregate_verify.rs | 1 - testing/ef_tests/src/cases/bls_verify_msg.rs | 1 - testing/ef_tests/src/cases/common.rs | 1 - .../ef_tests/src/cases/epoch_processing.rs | 4 +- testing/ef_tests/src/cases/fork.rs | 2 +- testing/ef_tests/src/cases/fork_choice.rs | 4 +- .../src/cases/genesis_initialization.rs | 3 +- .../ef_tests/src/cases/genesis_validity.rs | 3 +- .../src/cases/kzg_verify_blob_kzg_proof.rs | 1 - .../src/cases/merkle_proof_validity.rs | 3 +- testing/ef_tests/src/cases/operations.rs | 6 +-- testing/ef_tests/src/cases/rewards.rs | 3 +- testing/ef_tests/src/cases/sanity_blocks.rs | 2 +- testing/ef_tests/src/cases/sanity_slots.rs | 2 +- testing/ef_tests/src/cases/shuffling.rs | 1 - testing/ef_tests/src/cases/ssz_generic.rs | 6 +-- testing/ef_tests/src/cases/ssz_static.rs | 3 +- testing/ef_tests/src/cases/transition.rs | 2 +- testing/ef_tests/src/decode.rs | 2 +- testing/eth1_test_rig/src/anvil.rs | 1 - testing/state_transition_vectors/src/exit.rs | 3 +- .../src/attestation_tests.rs | 2 +- .../slashing_protection/src/block_tests.rs | 2 +- .../slashing_protection/src/lib.rs | 8 ++-- .../slashing_protection/src/test_utils.rs | 5 +-- validator_client/src/doppelganger_service.rs | 1 - validator_client/src/validator_store.rs | 37 +++---------------- watch/src/database/compat.rs | 2 - watch/src/database/mod.rs | 1 - watch/src/database/utils.rs | 1 - watch/src/updater/handler.rs | 1 - 148 files changed, 104 insertions(+), 301 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index ea1c5089a..e2fe80a49 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 80cbc6c89..b0afcc5e6 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 da3c2c8a1..79d732f51 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 563c29659..74e12ec95 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 148d85bef..00a278961 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 765ed0cb2..0dcbab945 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 6b85c8e49..5370294d8 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 49a555816..5dfda3361 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 00140dd6e..2cf0c3261 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 20f3e21d0..4d9cf68e9 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 197f21c64..48ad77abc 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 e676d17ab..399634a9f 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 505e4a479..0479ea7c5 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 e20009e28..511b38892 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 df0f79c61..7fafeadb8 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 e8641be79..feb6c9974 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 9dff1ac00..623c1c954 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 2c5bde55e..759348bb4 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 77c2410ab..3dd494043 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 d01298343..ced88ee12 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 c73dcb7e0..bae964615 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 10025626d..7b788c34b 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 f191d38f5..4d85ecb57 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 f7f967bfb..227a24a05 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 31931d756..eced0456d 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 d84b2416c..4d609434f 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 fe6c8f787..7a59547e7 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 aa0ec7d3e..12a65a82c 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 ebb355fef..47b36e036 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 7a7f2969f..58a9d137a 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 f4971c18d..44be3ca1a 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 cd3579ad6..1a9a3ea93 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 713e9e0ec..d3da2e563 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 9c174b8e4..44a32eff2 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 0b57374e8..2baa256b6 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 5dc0d29ff..225b4ef8d 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 9bbc7b265..6582e56f1 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 66c98ff3b..c63afcdb2 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 e69230c50..289bf1433 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 8c60621f1..c4d912993 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 d327c5c90..d638ae8a8 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 acb735ea4..0e965457e 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 e42fd936e..6ce277e5d 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 2e629f786..b4a95b1de 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 ba8430ace..8f369818c 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 537614f28..173b06049 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 4bdb0deca..70e02164e 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 88d1d2d7a..324d731a8 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 07c99e5a4..6c2dc6c65 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 d799bdedd..ffd55c16a 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 1fb5751a0..62686bec6 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 2a9f985d5..785b95221 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 3c22c822b..d6d87e27f 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 8a1cf2ff3..4dee868e1 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 3d4ff02c3..3031e1c4d 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 a76a8320a..1ead9a6bd 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 61299f74a..7b42fa906 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 3b4878503..450128f15 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 865a5affb..625dc245f 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 de7fa70d6..3208584dc 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 284a7019f..5f71e3337 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 cb24a7ba7..cab3c93cb 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 a895567d1..c3eb9aa4b 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 7162fa7f4..a5b438e72 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 8466104aa..baba4aa46 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 dc3c9f07c..87be1209c 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 90dff84b3..5853f4d08 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 b0a942d74..38155a4a6 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 4c0ee1bfa..698c3a657 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 8d29bc221..692b3f847 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 6cd9c1dbf..fcc171795 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 69cd6fbb8..95155b063 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 baa65f517..e6426e125 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 e074ffdfa..f62829e79 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 e5c666df8..6184d0aeb 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 d4dcdb2ed..1793be1c7 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 17baad9c4..446267fac 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 e0859c0a1..9a2be345a 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 6523b2a67..7a3b026d3 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 e3e037fd6..dffbf392f 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 c2d48d724..6eccab429 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 2f7975161..4e83e3abf 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 2a404b3b9..14fdf5be9 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 37304de1f..4914c1d29 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 2a4ecdf43..a7bfd7c27 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 ec659d1db..79d006491 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 194d14b23..aa20666ae 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 7cae3946c..b410df83d 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 f31df2ce1..0adaf81bd 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 3aaad307e..421801ce5 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 5d3c916b9..772f28443 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 3992421e3..f73f7c18c 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 8733f7de2..21d443c0e 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 d6d8ed2d0..7e771ca56 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 12821ee62..d33e9ac70 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 f04bfc3bc..6e5cafc4f 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 33fbcec56..3f3f6ed51 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 119c81bab..5b952296b 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 a4ae772d8..2117a4823 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 a74cc6b3d..5eccc0a9f 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 34043c0e8..eb3660d46 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 240568b4f..985bff745 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 8f9f2a4d8..b291adb73 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 e831a175c..0049d79cc 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 b3373782a..21f98796d 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 aa6dbb393..c0c6eca4f 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 bbcc41818..dbb21e4de 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 5300b2f8b..03a9d305a 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 67e156ff4..cc61f13d9 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 94aeab068..a29b895c9 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 2049518cd..304ea3ecd 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 834716fba..d2092508a 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 3b4f7738d..db175aa5d 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 91c8f373f..b733b07c6 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 98839fcc4..78deaf176 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 968a4dbb6..ce0e42df1 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 0fb3a026c..88a161e97 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 dcdc1bd19..cec2edcfa 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 24b62c5fa..42ee459a6 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 2a7c99875..d75880b29 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 cf182af2b..c3b03ae1f 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 bc340fa1c..58498ca62 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 9884a709e..6b8148d30 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 14fe7ef95..11402c75e 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 ec89e0f64..e977fa3d6 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 04d1b8d5d..f68f0fd7e 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 d9deda812..5553df588 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 4c02126d4..40cacb173 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 bb41f6fe1..9d1c020fd 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 cf8e6b5b2..b0902cb5b 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 0da179d53..71c782c78 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 e05763c2d..3d238b529 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 d6c764f52..bb2465aae 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 423dc3152..e41c90c6e 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 c94ce3a23..58e1226b7 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 e95bddffa..51ab682f3 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 1b86711c2..c6c37ae4a 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 50b98d306..e3cd346da 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 c66a67b70..a162c4e15 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 a1f634ef0..abd452a0b 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 1610b5237..c4fa32b61 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 3df892ecd..efdeb9bc6 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 86584d794..442a950dd 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 b8c11a79b..62805710e 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 b8cda0b21..e3e9e0df6 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 841ebe5ee..485684024 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 7e450f0ce..9134c3698 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 1e1662bf7..382908eba 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};