diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 2bbb6901c..2b2d5f015 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -191,7 +191,6 @@ where count: usize, skip: usize, ) -> Result, Error> { - let spec = &self.spec; let step_by = Slot::from(skip + 1); let mut roots: Vec = vec![]; diff --git a/beacon_node/client/src/client_types.rs b/beacon_node/client/src/client_types.rs index b934b508e..ba8fc47de 100644 --- a/beacon_node/client/src/client_types.rs +++ b/beacon_node/client/src/client_types.rs @@ -1,16 +1,13 @@ -use crate::ClientConfig; +use crate::{ArcBeaconChain, ClientConfig}; use beacon_chain::{ db::{ClientDB, DiskDB, MemoryDB}, fork_choice::BitwiseLMDGhost, initialise, slot_clock::{SlotClock, SystemTimeSlotClock}, - BeaconChain, }; use fork_choice::ForkChoice; use types::{BeaconStateTypes, FewValidatorsStateTypes, FoundationStateTypes}; -use std::sync::Arc; - pub trait ClientTypes { type DB: ClientDB + 'static; type SlotClock: SlotClock + 'static; @@ -19,7 +16,7 @@ pub trait ClientTypes { fn initialise_beacon_chain( config: &ClientConfig, - ) -> Arc>; + ) -> ArcBeaconChain; } pub struct StandardClientType; @@ -32,7 +29,7 @@ impl ClientTypes for StandardClientType { fn initialise_beacon_chain( config: &ClientConfig, - ) -> Arc> { + ) -> ArcBeaconChain { initialise::initialise_beacon_chain(&config.spec, Some(&config.db_name)) } } @@ -47,7 +44,7 @@ impl ClientTypes for TestingClientType { fn initialise_beacon_chain( config: &ClientConfig, - ) -> Arc> { + ) -> ArcBeaconChain { initialise::initialise_test_beacon_chain(&config.spec, None) } } diff --git a/beacon_node/client/src/lib.rs b/beacon_node/client/src/lib.rs index 466256735..c3dd5cbd8 100644 --- a/beacon_node/client/src/lib.rs +++ b/beacon_node/client/src/lib.rs @@ -22,13 +22,15 @@ use tokio::runtime::TaskExecutor; use tokio::timer::Interval; use types::BeaconStateTypes; +type ArcBeaconChain = Arc>; + /// Main beacon node client service. This provides the connection and initialisation of the clients /// sub-services in multiple threads. pub struct Client { /// Configuration for the lighthouse client. _config: ClientConfig, /// The beacon chain for the running client. - _beacon_chain: Arc>, + _beacon_chain: ArcBeaconChain, /// Reference to the network service. pub network: Arc>, /// Signal to terminate the RPC server. diff --git a/beacon_node/db/src/disk_db.rs b/beacon_node/db/src/disk_db.rs index 9d8a71bc4..2d26315da 100644 --- a/beacon_node/db/src/disk_db.rs +++ b/beacon_node/db/src/disk_db.rs @@ -97,7 +97,7 @@ impl ClientDB for DiskDB { None => Err(DBError { message: "Unknown column".to_string(), }), - Some(handle) => self.db.put_cf(handle, key, val).map_err(|e| e.into()), + Some(handle) => self.db.put_cf(handle, key, val).map_err(Into::into), } } diff --git a/beacon_node/db/src/stores/beacon_state_store.rs b/beacon_node/db/src/stores/beacon_state_store.rs index 5a5af33d3..4c40d2287 100644 --- a/beacon_node/db/src/stores/beacon_state_store.rs +++ b/beacon_node/db/src/stores/beacon_state_store.rs @@ -2,7 +2,7 @@ use super::STATES_DB_COLUMN as DB_COLUMN; use super::{ClientDB, DBError}; use ssz::decode; use std::sync::Arc; -use types::{BeaconState, BeaconStateTypes, FoundationBeaconState, Hash256}; +use types::{BeaconState, BeaconStateTypes, Hash256}; pub struct BeaconStateStore where @@ -43,7 +43,7 @@ mod tests { use ssz::ssz_encode; use std::sync::Arc; use types::test_utils::{SeedableRng, TestRandom, XorShiftRng}; - use types::Hash256; + use types::{FoundationBeaconState, Hash256}; test_crud_for_store!(BeaconStateStore, DB_COLUMN); diff --git a/beacon_node/network/src/message_handler.rs b/beacon_node/network/src/message_handler.rs index 90aff0041..6d3348910 100644 --- a/beacon_node/network/src/message_handler.rs +++ b/beacon_node/network/src/message_handler.rs @@ -300,7 +300,7 @@ impl NetworkContext { let next_id = self .outgoing_request_ids .entry(peer_id.clone()) - .and_modify(|id| id.increment()) + .and_modify(RequestId::increment) .or_insert_with(|| RequestId::from(1)); next_id.previous() diff --git a/eth2/operation_pool/src/lib.rs b/eth2/operation_pool/src/lib.rs index eed46196a..66f0f0df8 100644 --- a/eth2/operation_pool/src/lib.rs +++ b/eth2/operation_pool/src/lib.rs @@ -175,11 +175,7 @@ impl OperationPool { /// Total number of attestations in the pool, including attestations for the same data. pub fn num_attestations(&self) -> usize { - self.attestations - .read() - .values() - .map(|atts| atts.len()) - .sum() + self.attestations.read().values().map(Vec::len).sum() } /// Get a list of attestations for inclusion in a block. diff --git a/eth2/types/src/beacon_state.rs b/eth2/types/src/beacon_state.rs index 3dc5358c8..03c39db61 100644 --- a/eth2/types/src/beacon_state.rs +++ b/eth2/types/src/beacon_state.rs @@ -817,7 +817,7 @@ impl BeaconState { self.tree_hash_cache .tree_hash_root() .and_then(|b| Ok(Hash256::from_slice(b))) - .map_err(|e| e.into()) + .map_err(Into::into) } } diff --git a/eth2/utils/boolean-bitfield/src/lib.rs b/eth2/utils/boolean-bitfield/src/lib.rs index d49da0d10..875da855c 100644 --- a/eth2/utils/boolean-bitfield/src/lib.rs +++ b/eth2/utils/boolean-bitfield/src/lib.rs @@ -226,7 +226,7 @@ impl Decodable for BooleanBitfield { // as the BitVec library and the hex-parser use opposing bit orders. fn reverse_bit_order(mut bytes: Vec) -> Vec { bytes.reverse(); - bytes.into_iter().map(|b| b.swap_bits()).collect() + bytes.into_iter().map(LookupReverse::swap_bits).collect() } impl Serialize for BooleanBitfield { diff --git a/eth2/utils/fixed_len_vec/src/lib.rs b/eth2/utils/fixed_len_vec/src/lib.rs index 0d811566b..085b1835b 100644 --- a/eth2/utils/fixed_len_vec/src/lib.rs +++ b/eth2/utils/fixed_len_vec/src/lib.rs @@ -22,6 +22,10 @@ impl FixedLenVec { self.vec.len() } + pub fn is_empty(&self) -> bool { + self.len() == 0 + } + pub fn capacity() -> usize { N::to_usize() } diff --git a/eth2/utils/hashing/src/lib.rs b/eth2/utils/hashing/src/lib.rs index 68e29fc9b..d1d2c28d9 100644 --- a/eth2/utils/hashing/src/lib.rs +++ b/eth2/utils/hashing/src/lib.rs @@ -35,7 +35,7 @@ pub fn merkle_root(values: &[Vec]) -> Option> { } // the root hash will be at index 1 - return Some(o[1].clone()); + Some(o[1].clone()) } #[cfg(test)] diff --git a/validator_client/src/duties/mod.rs b/validator_client/src/duties/mod.rs index 7db4672e3..b2ddfd0b0 100644 --- a/validator_client/src/duties/mod.rs +++ b/validator_client/src/duties/mod.rs @@ -51,7 +51,7 @@ impl DutiesManager { /// /// be a wall-clock (e.g., system time, remote server time, etc.). fn update(&self, epoch: Epoch) -> Result { - let public_keys: Vec = self.signers.iter().map(|s| s.to_public()).collect(); + let public_keys: Vec = self.signers.iter().map(Signer::to_public).collect(); let duties = self.beacon_node.request_duties(epoch, &public_keys)?; { // If these duties were known, check to see if they're updates or identical. diff --git a/validator_client/src/service.rs b/validator_client/src/service.rs index fb5f32778..a340f99fc 100644 --- a/validator_client/src/service.rs +++ b/validator_client/src/service.rs @@ -31,7 +31,6 @@ use tokio::prelude::*; use tokio::runtime::Builder; use tokio::timer::Interval; use tokio_timer::clock::Clock; -use types::test_utils::generate_deterministic_keypairs; use types::{ChainSpec, Epoch, Fork, Slot}; /// A fixed amount of time after a slot to perform operations. This gives the node time to complete