From ea523c86585ba85111322959f9f9a99ae1f94e8a Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Fri, 25 Jan 2019 13:52:21 +1100 Subject: [PATCH] Merge `spec` crate into `types` --- Cargo.toml | 1 - beacon_node/Cargo.toml | 1 - beacon_node/beacon_chain/Cargo.toml | 1 - beacon_node/beacon_chain/src/lib.rs | 3 +-- beacon_node/beacon_chain/src/state_transition.rs | 16 ++++++++-------- beacon_node/beacon_chain/tests/chain.rs | 3 +-- beacon_node/beacon_chain/tests/utils/test_rig.rs | 8 +++----- .../beacon_chain/tests/utils/validator.rs | 5 ++--- beacon_node/db/src/stores/mod.rs | 2 -- beacon_node/db/src/stores/validator_store.rs | 4 ++-- beacon_node/src/main.rs | 2 +- eth2/block_producer/Cargo.toml | 1 - eth2/block_producer/src/lib.rs | 3 +-- eth2/genesis/Cargo.toml | 1 - eth2/genesis/src/beacon_block.rs | 3 +-- eth2/genesis/src/beacon_state.rs | 3 +-- eth2/genesis/src/lib.rs | 5 ----- eth2/spec/Cargo.toml | 9 --------- eth2/types/src/attestation.rs | 6 +++--- eth2/types/src/attestation_data.rs | 4 ++-- .../src/attestation_data_and_custody_bit.rs | 4 ++-- eth2/types/src/beacon_block.rs | 4 ++-- eth2/types/src/beacon_block_body.rs | 4 ++-- eth2/types/src/beacon_state.rs | 2 +- eth2/types/src/casper_slashing.rs | 4 ++-- eth2/types/src/crosslink.rs | 4 ++-- eth2/types/src/deposit.rs | 4 ++-- eth2/types/src/deposit_data.rs | 4 ++-- eth2/types/src/deposit_input.rs | 4 ++-- eth2/types/src/eth1_data.rs | 4 ++-- eth2/types/src/eth1_data_vote.rs | 4 ++-- eth2/types/src/exit.rs | 4 ++-- eth2/types/src/fork.rs | 4 ++-- eth2/types/src/lib.rs | 9 +++------ eth2/types/src/pending_attestation.rs | 4 ++-- eth2/types/src/proposal_signed_data.rs | 4 ++-- eth2/types/src/proposer_slashing.rs | 4 ++-- eth2/types/src/shard_committee.rs | 4 ++-- eth2/types/src/shard_reassignment_record.rs | 4 ++-- eth2/types/src/slashable_vote_data.rs | 4 ++-- eth2/{spec/src => types/src/spec}/foundation.rs | 2 +- eth2/{spec/src/lib.rs => types/src/spec/mod.rs} | 5 +---- eth2/types/src/special_record.rs | 2 +- eth2/types/src/validator.rs | 4 ++-- eth2/types/src/validator_registry_delta_block.rs | 2 +- eth2/utils/bls/src/aggregate_signature.rs | 4 ++-- eth2/utils/bls/src/public_key.rs | 2 +- eth2/utils/bls/src/signature.rs | 4 ++-- eth2/validator_induction/Cargo.toml | 1 - eth2/validator_induction/src/inductor.rs | 3 +-- eth2/validator_induction/src/lib.rs | 5 ----- eth2/validator_shuffling/Cargo.toml | 1 - eth2/validator_shuffling/src/lib.rs | 5 ----- eth2/validator_shuffling/src/shuffle.rs | 3 +-- validator_client/Cargo.toml | 1 - validator_client/src/duties/mod.rs | 2 +- validator_client/src/main.rs | 2 +- 57 files changed, 81 insertions(+), 131 deletions(-) delete mode 100644 eth2/spec/Cargo.toml rename eth2/{spec/src => types/src/spec}/foundation.rs (98%) rename eth2/{spec/src/lib.rs => types/src/spec/mod.rs} (95%) diff --git a/Cargo.toml b/Cargo.toml index 5a25e3484..e22d78d3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ members = [ "eth2/block_producer", "eth2/genesis", "eth2/naive_fork_choice", - "eth2/spec", "eth2/types", "eth2/utils/bls", "eth2/utils/boolean-bitfield", diff --git a/beacon_node/Cargo.toml b/beacon_node/Cargo.toml index 7b44bb0f9..e5893195e 100644 --- a/beacon_node/Cargo.toml +++ b/beacon_node/Cargo.toml @@ -19,7 +19,6 @@ slog = "^2.2.3" slot_clock = { path = "../eth2/utils/slot_clock" } slog-term = "^2.4.0" slog-async = "^2.3.0" -spec = { path = "../eth2/spec" } types = { path = "../eth2/types" } ssz = { path = "../eth2/utils/ssz" } tokio = "0.1" diff --git a/beacon_node/beacon_chain/Cargo.toml b/beacon_node/beacon_chain/Cargo.toml index 7e157dffb..4fba69546 100644 --- a/beacon_node/beacon_chain/Cargo.toml +++ b/beacon_node/beacon_chain/Cargo.toml @@ -14,6 +14,5 @@ failure_derive = "0.1" genesis = { path = "../../eth2/genesis" } serde_derive = "1.0" slot_clock = { path = "../../eth2/utils/slot_clock" } -spec = { path = "../../eth2/spec" } ssz = { path = "../../eth2/utils/ssz" } types = { path = "../../eth2/types" } diff --git a/beacon_node/beacon_chain/src/lib.rs b/beacon_node/beacon_chain/src/lib.rs index 8ae6d0f90..e820c4b20 100644 --- a/beacon_node/beacon_chain/src/lib.rs +++ b/beacon_node/beacon_chain/src/lib.rs @@ -16,10 +16,9 @@ use db::{ }; use genesis::{genesis_beacon_block, genesis_beacon_state, GenesisError}; use slot_clock::SlotClock; -use spec::ChainSpec; use ssz::ssz_encode; use std::sync::{Arc, RwLock}; -use types::{BeaconBlock, BeaconState, Hash256}; +use types::{BeaconBlock, BeaconState, ChainSpec, Hash256}; pub use self::block_processing::Outcome as BlockProcessingOutcome; diff --git a/beacon_node/beacon_chain/src/state_transition.rs b/beacon_node/beacon_chain/src/state_transition.rs index 4a41d6f2c..95fd9a7ad 100644 --- a/beacon_node/beacon_chain/src/state_transition.rs +++ b/beacon_node/beacon_chain/src/state_transition.rs @@ -430,19 +430,19 @@ fn get_domain(_fork: &Fork, _slot: u64, _domain_type: u64) -> u64 { 0 } -fn bls_verify(_pubkey: &PublicKey, _message: &[u8], _signature: &Signature, _domain: u64) -> bool { - // TODO: stubbed out. - true +fn bls_verify(pubkey: &PublicKey, message: &[u8], signature: &Signature, _domain: u64) -> bool { + // TODO: add domain + signature.verify(message, pubkey) } fn bls_verify_aggregate( - _pubkey: &AggregatePublicKey, - _message: &[u8], - _signature: &AggregateSignature, + pubkey: &AggregatePublicKey, + message: &[u8], + signature: &AggregateSignature, _domain: u64, ) -> bool { - // TODO: stubbed out. - true + // TODO: add domain + signature.verify(message, pubkey) } fn hash_tree_root(_input: &T) -> Hash256 { diff --git a/beacon_node/beacon_chain/tests/chain.rs b/beacon_node/beacon_chain/tests/chain.rs index 52d001eed..9bf8959c5 100644 --- a/beacon_node/beacon_chain/tests/chain.rs +++ b/beacon_node/beacon_chain/tests/chain.rs @@ -7,9 +7,8 @@ use db::{ MemoryDB, }; use slot_clock::TestingSlotClock; -use spec::ChainSpec; use std::sync::{Arc, RwLock}; -use types::{Keypair, Validator}; +use types::{ChainSpec, Keypair, Validator}; mod utils; diff --git a/beacon_node/beacon_chain/tests/utils/test_rig.rs b/beacon_node/beacon_chain/tests/utils/test_rig.rs index 7bd494b23..b6aef3290 100644 --- a/beacon_node/beacon_chain/tests/utils/test_rig.rs +++ b/beacon_node/beacon_chain/tests/utils/test_rig.rs @@ -1,15 +1,13 @@ -use super::{DirectBeaconNode, DirectDuties, TestValidator}; +use super::TestValidator; use beacon_chain::BeaconChain; #[cfg(test)] -use block_producer::{test_utils::TestSigner, BlockProducer}; use db::{ stores::{BeaconBlockStore, BeaconStateStore}, MemoryDB, }; use slot_clock::TestingSlotClock; -use spec::ChainSpec; -use std::sync::{Arc, RwLock}; -use types::{Keypair, Validator}; +use std::sync::Arc; +use types::{ChainSpec, Keypair, Validator}; pub struct TestRig { db: Arc, diff --git a/beacon_node/beacon_chain/tests/utils/validator.rs b/beacon_node/beacon_chain/tests/utils/validator.rs index 755ea51d1..7a3b3404d 100644 --- a/beacon_node/beacon_chain/tests/utils/validator.rs +++ b/beacon_node/beacon_chain/tests/utils/validator.rs @@ -4,9 +4,8 @@ use beacon_chain::BeaconChain; use block_producer::{test_utils::TestSigner, BlockProducer, Error as PollError}; use db::MemoryDB; use slot_clock::TestingSlotClock; -use spec::ChainSpec; -use std::sync::{Arc, RwLock}; -use types::{Keypair, Validator}; +use std::sync::Arc; +use types::{ChainSpec, Keypair}; pub use block_producer::PollOutcome; diff --git a/beacon_node/db/src/stores/mod.rs b/beacon_node/db/src/stores/mod.rs index c78d10dbf..44de7eed1 100644 --- a/beacon_node/db/src/stores/mod.rs +++ b/beacon_node/db/src/stores/mod.rs @@ -12,8 +12,6 @@ pub use self::beacon_state_store::BeaconStateStore; pub use self::pow_chain_store::PoWChainStore; pub use self::validator_store::{ValidatorStore, ValidatorStoreError}; -use super::bls; - pub const BLOCKS_DB_COLUMN: &str = "blocks"; pub const STATES_DB_COLUMN: &str = "states"; pub const POW_CHAIN_DB_COLUMN: &str = "powchain"; diff --git a/beacon_node/db/src/stores/validator_store.rs b/beacon_node/db/src/stores/validator_store.rs index 500bb50af..02e90dc5c 100644 --- a/beacon_node/db/src/stores/validator_store.rs +++ b/beacon_node/db/src/stores/validator_store.rs @@ -1,9 +1,9 @@ extern crate bytes; use self::bytes::{BufMut, BytesMut}; -use super::bls::PublicKey; use super::VALIDATOR_DB_COLUMN as DB_COLUMN; use super::{ClientDB, DBError}; +use bls::PublicKey; use ssz::{ssz_encode, Decodable}; use std::sync::Arc; @@ -80,8 +80,8 @@ impl ValidatorStore { #[cfg(test)] mod tests { use super::super::super::MemoryDB; - use super::super::bls::Keypair; use super::*; + use bls::Keypair; #[test] fn test_prefix_bytes() { diff --git a/beacon_node/src/main.rs b/beacon_node/src/main.rs index f9e77723a..25239a9f6 100644 --- a/beacon_node/src/main.rs +++ b/beacon_node/src/main.rs @@ -15,8 +15,8 @@ use db::{ }; use slog::{error, info, o, Drain}; use slot_clock::SystemTimeSlotClock; -use spec::ChainSpec; use std::sync::Arc; +use types::ChainSpec; fn main() { let decorator = slog_term::TermDecorator::new().build(); diff --git a/eth2/block_producer/Cargo.toml b/eth2/block_producer/Cargo.toml index 7203dbe31..86dde92f7 100644 --- a/eth2/block_producer/Cargo.toml +++ b/eth2/block_producer/Cargo.toml @@ -6,6 +6,5 @@ edition = "2018" [dependencies] slot_clock = { path = "../../eth2/utils/slot_clock" } -spec = { path = "../../eth2/spec" } ssz = { path = "../../eth2/utils/ssz" } types = { path = "../../eth2/types" } diff --git a/eth2/block_producer/src/lib.rs b/eth2/block_producer/src/lib.rs index 74788eb60..8ce6da859 100644 --- a/eth2/block_producer/src/lib.rs +++ b/eth2/block_producer/src/lib.rs @@ -2,10 +2,9 @@ pub mod test_utils; mod traits; use slot_clock::SlotClock; -use spec::ChainSpec; use ssz::ssz_encode; use std::sync::Arc; -use types::{BeaconBlock, Hash256, ProposalSignedData, PublicKey}; +use types::{BeaconBlock, ChainSpec, Hash256, ProposalSignedData, PublicKey}; pub use self::traits::{ BeaconNode, BeaconNodeError, DutiesReader, DutiesReaderError, PublishOutcome, Signer, diff --git a/eth2/genesis/Cargo.toml b/eth2/genesis/Cargo.toml index 499333979..d56b3f929 100644 --- a/eth2/genesis/Cargo.toml +++ b/eth2/genesis/Cargo.toml @@ -6,7 +6,6 @@ edition = "2018" [dependencies] bls = { path = "../utils/bls" } -spec = { path = "../spec" } ssz = { path = "../utils/ssz" } types = { path = "../types" } validator_induction = { path = "../validator_induction" } diff --git a/eth2/genesis/src/beacon_block.rs b/eth2/genesis/src/beacon_block.rs index 478d76ded..8b78f9e2d 100644 --- a/eth2/genesis/src/beacon_block.rs +++ b/eth2/genesis/src/beacon_block.rs @@ -1,5 +1,4 @@ -use spec::ChainSpec; -use types::{BeaconBlock, BeaconBlockBody, Eth1Data, Hash256}; +use types::{BeaconBlock, BeaconBlockBody, ChainSpec, Eth1Data, Hash256}; /// Generate a genesis BeaconBlock. pub fn genesis_beacon_block(state_root: Hash256, spec: &ChainSpec) -> BeaconBlock { diff --git a/eth2/genesis/src/beacon_state.rs b/eth2/genesis/src/beacon_state.rs index 7644e782b..788af7c82 100644 --- a/eth2/genesis/src/beacon_state.rs +++ b/eth2/genesis/src/beacon_state.rs @@ -1,5 +1,4 @@ -use spec::ChainSpec; -use types::{BeaconState, Crosslink, Fork}; +use types::{BeaconState, ChainSpec, Crosslink, Fork}; use validator_shuffling::{shard_and_committees_for_cycle, ValidatorAssignmentError}; #[derive(Debug, PartialEq)] diff --git a/eth2/genesis/src/lib.rs b/eth2/genesis/src/lib.rs index 6f45863aa..003e66959 100644 --- a/eth2/genesis/src/lib.rs +++ b/eth2/genesis/src/lib.rs @@ -1,8 +1,3 @@ -extern crate spec; -extern crate types; -extern crate validator_induction; -extern crate validator_shuffling; - mod beacon_block; mod beacon_state; diff --git a/eth2/spec/Cargo.toml b/eth2/spec/Cargo.toml deleted file mode 100644 index 5c535ab41..000000000 --- a/eth2/spec/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "spec" -version = "0.1.0" -authors = ["Paul Hauner "] -edition = "2018" - -[dependencies] -bls = { path = "../utils/bls" } -types = { path = "../types" } diff --git a/eth2/types/src/attestation.rs b/eth2/types/src/attestation.rs index bef35bc78..911464ba0 100644 --- a/eth2/types/src/attestation.rs +++ b/eth2/types/src/attestation.rs @@ -1,8 +1,8 @@ -use super::bls::AggregateSignature; -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::{AttestationData, Bitfield}; use crate::test_utils::TestRandom; +use bls::AggregateSignature; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, Clone, PartialEq)] pub struct Attestation { @@ -62,7 +62,7 @@ impl TestRandom for Attestation { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/attestation_data.rs b/eth2/types/src/attestation_data.rs index c1e895d6c..682838075 100644 --- a/eth2/types/src/attestation_data.rs +++ b/eth2/types/src/attestation_data.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::Hash256; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; pub const SSZ_ATTESTION_DATA_LENGTH: usize = { 8 + // slot @@ -102,7 +102,7 @@ impl TestRandom for AttestationData { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/attestation_data_and_custody_bit.rs b/eth2/types/src/attestation_data_and_custody_bit.rs index f53614d6b..5d5747f94 100644 --- a/eth2/types/src/attestation_data_and_custody_bit.rs +++ b/eth2/types/src/attestation_data_and_custody_bit.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::AttestationData; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, Clone, PartialEq, Default)] pub struct AttestationDataAndCustodyBit { @@ -39,7 +39,7 @@ impl TestRandom for AttestationDataAndCustodyBit { #[cfg(test)] mod test { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/beacon_block.rs b/eth2/types/src/beacon_block.rs index 4dff199f3..7d80cd398 100644 --- a/eth2/types/src/beacon_block.rs +++ b/eth2/types/src/beacon_block.rs @@ -1,9 +1,9 @@ -use super::ssz::{ssz_encode, Decodable, DecodeError, Encodable, SszStream}; use super::{BeaconBlockBody, Eth1Data, Hash256}; use crate::test_utils::TestRandom; use bls::Signature; use hashing::canonical_hash; use rand::RngCore; +use ssz::{ssz_encode, Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone)] pub struct BeaconBlock { @@ -77,7 +77,7 @@ impl TestRandom for BeaconBlock { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/beacon_block_body.rs b/eth2/types/src/beacon_block_body.rs index 67fa34d91..94a7cf0d7 100644 --- a/eth2/types/src/beacon_block_body.rs +++ b/eth2/types/src/beacon_block_body.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::{Attestation, CasperSlashing, Deposit, Exit, ProposerSlashing}; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; // The following types are just dummy classes as they will not be defined until // Phase 1 (Sharding phase) @@ -78,7 +78,7 @@ impl TestRandom for BeaconBlockBody { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/beacon_state.rs b/eth2/types/src/beacon_state.rs index 34afeaa83..921d49360 100644 --- a/eth2/types/src/beacon_state.rs +++ b/eth2/types/src/beacon_state.rs @@ -203,7 +203,7 @@ impl TestRandom for BeaconState { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/casper_slashing.rs b/eth2/types/src/casper_slashing.rs index 08dbd9ff3..0bdfab511 100644 --- a/eth2/types/src/casper_slashing.rs +++ b/eth2/types/src/casper_slashing.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::SlashableVoteData; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone)] pub struct CasperSlashing { @@ -42,7 +42,7 @@ impl TestRandom for CasperSlashing { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/crosslink.rs b/eth2/types/src/crosslink.rs index 69f94662a..50cc50305 100644 --- a/eth2/types/src/crosslink.rs +++ b/eth2/types/src/crosslink.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::Hash256; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Clone, Debug, PartialEq)] pub struct Crosslink { @@ -52,7 +52,7 @@ impl TestRandom for Crosslink { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/deposit.rs b/eth2/types/src/deposit.rs index 9d84bc278..f5e716f9e 100644 --- a/eth2/types/src/deposit.rs +++ b/eth2/types/src/deposit.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::{DepositData, Hash256}; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone)] pub struct Deposit { @@ -47,7 +47,7 @@ impl TestRandom for Deposit { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/deposit_data.rs b/eth2/types/src/deposit_data.rs index b85a95708..984a3f0f0 100644 --- a/eth2/types/src/deposit_data.rs +++ b/eth2/types/src/deposit_data.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::DepositInput; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone)] pub struct DepositData { @@ -47,7 +47,7 @@ impl TestRandom for DepositData { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/deposit_input.rs b/eth2/types/src/deposit_input.rs index 4f2d71096..f02db2640 100644 --- a/eth2/types/src/deposit_input.rs +++ b/eth2/types/src/deposit_input.rs @@ -1,8 +1,8 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::Hash256; use crate::test_utils::TestRandom; use bls::{PublicKey, Signature}; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone)] pub struct DepositInput { @@ -48,7 +48,7 @@ impl TestRandom for DepositInput { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/eth1_data.rs b/eth2/types/src/eth1_data.rs index a20559e18..0f1645242 100644 --- a/eth2/types/src/eth1_data.rs +++ b/eth2/types/src/eth1_data.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::Hash256; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; // Note: this is refer to as DepositRootVote in specs #[derive(Debug, PartialEq, Clone, Default)] @@ -43,7 +43,7 @@ impl TestRandom for Eth1Data { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/eth1_data_vote.rs b/eth2/types/src/eth1_data_vote.rs index c4d9d01af..3353e4068 100644 --- a/eth2/types/src/eth1_data_vote.rs +++ b/eth2/types/src/eth1_data_vote.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::Eth1Data; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; // Note: this is refer to as DepositRootVote in specs #[derive(Debug, PartialEq, Clone, Default)] @@ -43,7 +43,7 @@ impl TestRandom for Eth1DataVote { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/exit.rs b/eth2/types/src/exit.rs index eeac11ce7..a780e1966 100644 --- a/eth2/types/src/exit.rs +++ b/eth2/types/src/exit.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use crate::test_utils::TestRandom; use bls::Signature; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone)] pub struct Exit { @@ -47,7 +47,7 @@ impl TestRandom for Exit { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/fork.rs b/eth2/types/src/fork.rs index b70dafccc..f7e3135d6 100644 --- a/eth2/types/src/fork.rs +++ b/eth2/types/src/fork.rs @@ -1,6 +1,6 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, Clone, PartialEq, Default)] pub struct Fork { @@ -46,7 +46,7 @@ impl TestRandom for Fork { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/lib.rs b/eth2/types/src/lib.rs index b4b43695d..3bf13e2d4 100644 --- a/eth2/types/src/lib.rs +++ b/eth2/types/src/lib.rs @@ -1,8 +1,3 @@ -extern crate bls; -extern crate boolean_bitfield; -extern crate ethereum_types; -extern crate ssz; - pub mod test_utils; pub mod attestation; @@ -26,6 +21,7 @@ pub mod proposer_slashing; pub mod shard_committee; pub mod shard_reassignment_record; pub mod slashable_vote_data; +pub mod spec; pub mod special_record; pub mod validator; pub mod validator_registry; @@ -33,7 +29,7 @@ pub mod validator_registry_delta_block; pub mod readers; -use self::ethereum_types::{H160, H256, U256}; +use ethereum_types::{H160, H256, U256}; use std::collections::HashMap; pub use crate::attestation::Attestation; @@ -56,6 +52,7 @@ pub use crate::proposal_signed_data::ProposalSignedData; pub use crate::proposer_slashing::ProposerSlashing; pub use crate::shard_committee::ShardCommittee; pub use crate::slashable_vote_data::SlashableVoteData; +pub use crate::spec::ChainSpec; pub use crate::special_record::{SpecialRecord, SpecialRecordKind}; pub use crate::validator::{StatusFlags as ValidatorStatusFlags, Validator}; pub use crate::validator_registry_delta_block::ValidatorRegistryDeltaBlock; diff --git a/eth2/types/src/pending_attestation.rs b/eth2/types/src/pending_attestation.rs index ad3dbb782..0453b11ed 100644 --- a/eth2/types/src/pending_attestation.rs +++ b/eth2/types/src/pending_attestation.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::{AttestationData, Bitfield}; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, Clone, PartialEq)] pub struct PendingAttestation { @@ -52,7 +52,7 @@ impl TestRandom for PendingAttestation { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/proposal_signed_data.rs b/eth2/types/src/proposal_signed_data.rs index e38a9cadb..9a1f2f0b2 100644 --- a/eth2/types/src/proposal_signed_data.rs +++ b/eth2/types/src/proposal_signed_data.rs @@ -1,7 +1,7 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::Hash256; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone, Default)] pub struct ProposalSignedData { @@ -47,7 +47,7 @@ impl TestRandom for ProposalSignedData { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/proposer_slashing.rs b/eth2/types/src/proposer_slashing.rs index 3754c3b32..c02dc8c8e 100644 --- a/eth2/types/src/proposer_slashing.rs +++ b/eth2/types/src/proposer_slashing.rs @@ -1,8 +1,8 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::ProposalSignedData; use crate::test_utils::TestRandom; use bls::Signature; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone)] pub struct ProposerSlashing { @@ -58,7 +58,7 @@ impl TestRandom for ProposerSlashing { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/shard_committee.rs b/eth2/types/src/shard_committee.rs index d920f7db3..961140fbd 100644 --- a/eth2/types/src/shard_committee.rs +++ b/eth2/types/src/shard_committee.rs @@ -1,6 +1,6 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Clone, Debug, PartialEq)] pub struct ShardCommittee { @@ -35,7 +35,7 @@ impl TestRandom for ShardCommittee { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/shard_reassignment_record.rs b/eth2/types/src/shard_reassignment_record.rs index 9bc014689..f4c976bda 100644 --- a/eth2/types/src/shard_reassignment_record.rs +++ b/eth2/types/src/shard_reassignment_record.rs @@ -1,6 +1,6 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use crate::test_utils::TestRandom; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone)] pub struct ShardReassignmentRecord { @@ -46,9 +46,9 @@ impl TestRandom for ShardReassignmentRecord { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; + use ssz::ssz_encode; #[test] pub fn test_ssz_round_trip() { diff --git a/eth2/types/src/slashable_vote_data.rs b/eth2/types/src/slashable_vote_data.rs index e6fa36bc1..2984c9298 100644 --- a/eth2/types/src/slashable_vote_data.rs +++ b/eth2/types/src/slashable_vote_data.rs @@ -1,8 +1,8 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; use super::AttestationData; use crate::test_utils::TestRandom; use bls::AggregateSignature; use rand::RngCore; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; #[derive(Debug, PartialEq, Clone)] pub struct SlashableVoteData { @@ -53,7 +53,7 @@ impl TestRandom for SlashableVoteData { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/spec/src/foundation.rs b/eth2/types/src/spec/foundation.rs similarity index 98% rename from eth2/spec/src/foundation.rs rename to eth2/types/src/spec/foundation.rs index 8508a74e1..f24a55b2a 100644 --- a/eth2/spec/src/foundation.rs +++ b/eth2/types/src/spec/foundation.rs @@ -1,7 +1,7 @@ use super::ChainSpec; use bls::{Keypair, PublicKey, SecretKey, Signature}; -use types::{Address, Eth1Data, Hash256, Validator}; +use crate::{Address, Eth1Data, Hash256, Validator}; /// The size of a validators deposit in GWei. pub const DEPOSIT_GWEI: u64 = 32_000_000_000; diff --git a/eth2/spec/src/lib.rs b/eth2/types/src/spec/mod.rs similarity index 95% rename from eth2/spec/src/lib.rs rename to eth2/types/src/spec/mod.rs index aa3906076..077b6bef5 100644 --- a/eth2/spec/src/lib.rs +++ b/eth2/types/src/spec/mod.rs @@ -1,10 +1,7 @@ -extern crate bls; -extern crate types; - mod foundation; +use crate::{Address, Eth1Data, Hash256, Validator}; use bls::Signature; -use types::{Address, Eth1Data, Hash256, Validator}; #[derive(PartialEq, Debug, Clone)] pub struct ChainSpec { diff --git a/eth2/types/src/special_record.rs b/eth2/types/src/special_record.rs index 0a0a6978a..47ee3de36 100644 --- a/eth2/types/src/special_record.rs +++ b/eth2/types/src/special_record.rs @@ -1,4 +1,4 @@ -use super::ssz::{Decodable, DecodeError, Encodable, SszStream}; +use ssz::{Decodable, DecodeError, Encodable, SszStream}; /// The value of the "type" field of SpecialRecord. /// diff --git a/eth2/types/src/validator.rs b/eth2/types/src/validator.rs index 8408e7423..1015f70b2 100644 --- a/eth2/types/src/validator.rs +++ b/eth2/types/src/validator.rs @@ -1,6 +1,6 @@ -use super::bls::PublicKey; use super::Hash256; use crate::test_utils::TestRandom; +use bls::PublicKey; use rand::RngCore; use ssz::{Decodable, DecodeError, Encodable, SszStream}; @@ -162,7 +162,7 @@ impl TestRandom for Validator { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/types/src/validator_registry_delta_block.rs b/eth2/types/src/validator_registry_delta_block.rs index 57aa469df..253671cda 100644 --- a/eth2/types/src/validator_registry_delta_block.rs +++ b/eth2/types/src/validator_registry_delta_block.rs @@ -72,7 +72,7 @@ impl TestRandom for ValidatorRegistryDeltaBlock { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; use crate::test_utils::{SeedableRng, TestRandom, XorShiftRng}; diff --git a/eth2/utils/bls/src/aggregate_signature.rs b/eth2/utils/bls/src/aggregate_signature.rs index 6012f78c1..5f02d93f8 100644 --- a/eth2/utils/bls/src/aggregate_signature.rs +++ b/eth2/utils/bls/src/aggregate_signature.rs @@ -1,6 +1,6 @@ -use super::ssz::{decode_ssz_list, Decodable, DecodeError, Encodable, SszStream}; use super::{AggregatePublicKey, Signature}; use bls_aggregates::AggregateSignature as RawAggregateSignature; +use ssz::{decode_ssz_list, Decodable, DecodeError, Encodable, SszStream}; /// A BLS aggregate signature. /// @@ -46,8 +46,8 @@ impl Decodable for AggregateSignature { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; use super::super::{Keypair, Signature}; + use super::ssz::ssz_encode; use super::*; #[test] diff --git a/eth2/utils/bls/src/public_key.rs b/eth2/utils/bls/src/public_key.rs index 4a53893f0..981f25a75 100644 --- a/eth2/utils/bls/src/public_key.rs +++ b/eth2/utils/bls/src/public_key.rs @@ -67,7 +67,7 @@ impl Hash for PublicKey { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; + use super::ssz::ssz_encode; use super::*; #[test] diff --git a/eth2/utils/bls/src/signature.rs b/eth2/utils/bls/src/signature.rs index 7f9e61718..59fcda725 100644 --- a/eth2/utils/bls/src/signature.rs +++ b/eth2/utils/bls/src/signature.rs @@ -1,6 +1,6 @@ -use super::ssz::{decode_ssz_list, Decodable, DecodeError, Encodable, SszStream}; use super::{PublicKey, SecretKey}; use bls_aggregates::Signature as RawSignature; +use ssz::{decode_ssz_list, Decodable, DecodeError, Encodable, SszStream}; /// A single BLS signature. /// @@ -59,8 +59,8 @@ impl Decodable for Signature { #[cfg(test)] mod tests { - use super::super::ssz::ssz_encode; use super::super::Keypair; + use super::ssz::ssz_encode; use super::*; #[test] diff --git a/eth2/validator_induction/Cargo.toml b/eth2/validator_induction/Cargo.toml index 3530bbbf1..5907014df 100644 --- a/eth2/validator_induction/Cargo.toml +++ b/eth2/validator_induction/Cargo.toml @@ -8,4 +8,3 @@ edition = "2018" bls = { path = "../utils/bls" } hashing = { path = "../utils/hashing" } types = { path = "../types" } -spec = { path = "../spec" } diff --git a/eth2/validator_induction/src/inductor.rs b/eth2/validator_induction/src/inductor.rs index 6efc9af2e..6b3cfdf16 100644 --- a/eth2/validator_induction/src/inductor.rs +++ b/eth2/validator_induction/src/inductor.rs @@ -1,6 +1,5 @@ use bls::verify_proof_of_possession; -use spec::ChainSpec; -use types::{BeaconState, Deposit, Validator}; +use types::{BeaconState, ChainSpec, Deposit, Validator}; #[derive(Debug, PartialEq, Clone)] pub enum ValidatorInductionError { diff --git a/eth2/validator_induction/src/lib.rs b/eth2/validator_induction/src/lib.rs index 7119d6c2e..3a4fa9a14 100644 --- a/eth2/validator_induction/src/lib.rs +++ b/eth2/validator_induction/src/lib.rs @@ -1,8 +1,3 @@ -extern crate bls; -extern crate hashing; -extern crate spec; -extern crate types; - mod inductor; pub use crate::inductor::{process_deposit, ValidatorInductionError}; diff --git a/eth2/validator_shuffling/Cargo.toml b/eth2/validator_shuffling/Cargo.toml index 99a97c5ec..ae2babf1a 100644 --- a/eth2/validator_shuffling/Cargo.toml +++ b/eth2/validator_shuffling/Cargo.toml @@ -6,6 +6,5 @@ edition = "2018" [dependencies] honey-badger-split = { path = "../utils/honey-badger-split" } -spec = { path = "../spec" } types = { path = "../types" } vec_shuffle = { path = "../utils/vec_shuffle" } diff --git a/eth2/validator_shuffling/src/lib.rs b/eth2/validator_shuffling/src/lib.rs index ee59ffecc..2307dd301 100644 --- a/eth2/validator_shuffling/src/lib.rs +++ b/eth2/validator_shuffling/src/lib.rs @@ -1,8 +1,3 @@ -extern crate honey_badger_split; -extern crate spec; -extern crate types; -extern crate vec_shuffle; - mod shuffle; pub use crate::shuffle::{shard_and_committees_for_cycle, ValidatorAssignmentError}; diff --git a/eth2/validator_shuffling/src/shuffle.rs b/eth2/validator_shuffling/src/shuffle.rs index 734f5995c..48d16fddc 100644 --- a/eth2/validator_shuffling/src/shuffle.rs +++ b/eth2/validator_shuffling/src/shuffle.rs @@ -1,9 +1,8 @@ use std::cmp::min; use honey_badger_split::SplitExt; -use spec::ChainSpec; use types::validator_registry::get_active_validator_indices; -use types::{ShardCommittee, Validator}; +use types::{ChainSpec, ShardCommittee, Validator}; use vec_shuffle::{shuffle, ShuffleErr}; type DelegatedCycle = Vec>; diff --git a/validator_client/Cargo.toml b/validator_client/Cargo.toml index c4f8b8f4a..8ab515e15 100644 --- a/validator_client/Cargo.toml +++ b/validator_client/Cargo.toml @@ -13,7 +13,6 @@ grpcio = { version = "0.4", default-features = false, features = ["protobuf-code protobuf = "2.0.2" protos = { path = "../protos" } slot_clock = { path = "../eth2/utils/slot_clock" } -spec = { path = "../eth2/spec" } types = { path = "../eth2/types" } slog = "^2.2.3" slog-term = "^2.4.0" diff --git a/validator_client/src/duties/mod.rs b/validator_client/src/duties/mod.rs index f368d6dca..c9ebda249 100644 --- a/validator_client/src/duties/mod.rs +++ b/validator_client/src/duties/mod.rs @@ -11,8 +11,8 @@ pub use self::service::DutiesManagerService; use self::traits::{BeaconNode, BeaconNodeError}; use bls::PublicKey; use slot_clock::SlotClock; -use spec::ChainSpec; use std::sync::Arc; +use types::ChainSpec; #[derive(Debug, PartialEq, Clone, Copy)] pub enum PollOutcome { diff --git a/validator_client/src/main.rs b/validator_client/src/main.rs index 49927b8c9..3b516870a 100644 --- a/validator_client/src/main.rs +++ b/validator_client/src/main.rs @@ -8,10 +8,10 @@ use grpcio::{ChannelBuilder, EnvBuilder}; use protos::services_grpc::{BeaconBlockServiceClient, ValidatorServiceClient}; use slog::{error, info, o, Drain}; use slot_clock::SystemTimeSlotClock; -use spec::ChainSpec; use std::path::PathBuf; use std::sync::Arc; use std::thread; +use types::ChainSpec; mod block_producer_service; mod config;