From 84a9dbf8e44bd9825eaa4cc6cac18e6e40f8e8f7 Mon Sep 17 00:00:00 2001 From: Feng94 <8751189+Feng94@users.noreply.github.com> Date: Thu, 24 Jan 2019 23:48:52 +1100 Subject: [PATCH 1/6] Fix hardcoded string to use system constant for directory separator --- protos/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protos/build.rs b/protos/build.rs index d8becfa519..d83cb34963 100644 --- a/protos/build.rs +++ b/protos/build.rs @@ -1,7 +1,7 @@ extern crate protoc_grpcio; fn main() { - let proto_root = "src/"; + let proto_root = &format!("{}{}", "src", std::path::MAIN_SEPARATOR); println!("cargo:rerun-if-changed={}", proto_root); protoc_grpcio::compile_grpc_protos(&["services.proto"], &[proto_root], &proto_root) .expect("Failed to compile gRPC definitions!"); From 4a9faa3168064000d489ab115e8b921e98fe202e Mon Sep 17 00:00:00 2001 From: Feng94 <8751189+Feng94@users.noreply.github.com> Date: Sun, 27 Jan 2019 14:57:48 +1100 Subject: [PATCH 2/6] Add windows notes to readme and fix some grammar errors --- README.md | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9ed5acecc5..0d8a32040e 100644 --- a/README.md +++ b/README.md @@ -103,28 +103,41 @@ A few basic steps are needed to get set up: 1. Install [rustup](https://rustup.rs/). It's a toolchain manager for Rust (Linux | macos | Windows). For installation run the below command in your terminal ``` $ curl https://sh.rustup.rs -sSf | sh -``` - 2. To configure your current shell run: + ``` + 2. (Linux & MacOS) To configure your current shell run: ``` $ source $HOME/.cargo/env -``` - - 3. Use the command `rustup show` to get information about the Rust installation. You should see that the active toolchain is the stable version. - 4. Run `rustc --version` to check the installation and version of rust. + ``` + 3. Use the command `rustup show` to get information about the Rust installation. You should see that the + active toolchain is the stable version. + 4. Run `rustc --version` to check the installation and version of rust. - Updates can be performed using` rustup update` . - 5. Install build dependancies (Arch packages are listed here, your distribution will - likely be similar): + 5. Install build dependencies (Arch packages are listed here, your distribution will likely be similar): - `clang`: required by RocksDB. - `protobuf`: required for protobuf serialization (gRPC). - 5. Navigate to the working directory. - 6. Run the test by using command `cargo test --all` . By running, it will pass all the required test cases. If you are doing it for the first time, then you can grab a coffee meantime. Usually, it takes time to build, compile and pass all test cases. If there is no error then, it means everything is working properly and it's time to get hand's dirty. In case, if there is an error, then please raise the [issue](https://github.com/sigp/lighthouse/issues). We will help you. - 7. As an alternative to, or instead of the above step, you may also run benchmarks by using the command `cargo bench --all` + 6. Navigate to the working directory. + 7. Run the test by using command `cargo test --all`. By running, it will pass all the required test cases. + If you are doing it for the first time, then you can grab a coffee in the meantime. Usually, it takes time + to build, compile and pass all test cases. If there is no error then it means everything is working properly + and it's time to get your hands dirty. + In case, if there is an error, then please raise the [issue](https://github.com/sigp/lighthouse/issues). + We will help you. + 8. As an alternative to, or instead of the above step, you may also run benchmarks by using + the command `cargo bench --all` ##### Note: Lighthouse presently runs on Rust `stable`, however, benchmarks currently require the `nightly` version. +##### Note for Windows users: +Perl may also be required to build lighthouse. You can install [Strawberry Perl](http://strawberryperl.com/), +or alternatively use a choco install command `choco install strawberryperl`. + +Additionally, the dependency `protoc-grpcio v0.3.1` is reported to have issues compiling in Windows. You can specify +a known working version by editing version in protos/Cargo.toml's "build-dependencies" section to +`protoc-grpcio = "<=0.3.0"`. + ### Contributing **Lighthouse welcomes contributors with open-arms.** From f218ab8a2383ff5e536ff70e5ebb8137098a8810 Mon Sep 17 00:00:00 2001 From: Feng94 <8751189+Feng94@users.noreply.github.com> Date: Mon, 28 Jan 2019 02:19:53 +1100 Subject: [PATCH 3/6] Change build root folder String to a Path --- protos/build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/protos/build.rs b/protos/build.rs index d83cb34963..108d9e2ddb 100644 --- a/protos/build.rs +++ b/protos/build.rs @@ -1,8 +1,10 @@ extern crate protoc_grpcio; +use std::path::Path; + fn main() { - let proto_root = &format!("{}{}", "src", std::path::MAIN_SEPARATOR); - println!("cargo:rerun-if-changed={}", proto_root); + let proto_root = Path::new("src"); + println!("cargo:rerun-if-changed={}", proto_root.display()); protoc_grpcio::compile_grpc_protos(&["services.proto"], &[proto_root], &proto_root) .expect("Failed to compile gRPC definitions!"); } From 0cbc2936ea1ca555eb5ece64bf687ed2a672d8e3 Mon Sep 17 00:00:00 2001 From: Grant Wuerker Date: Sat, 26 Jan 2019 20:43:49 -0600 Subject: [PATCH 4/6] added version to signature-schemes dependency using tag instead of branch changed signature-schemes tag to 0.3.0 --- eth2/utils/bls/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth2/utils/bls/Cargo.toml b/eth2/utils/bls/Cargo.toml index 0dc64e483d..5148cb7f2f 100644 --- a/eth2/utils/bls/Cargo.toml +++ b/eth2/utils/bls/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Paul Hauner "] edition = "2018" [dependencies] -bls-aggregates = { git = "https://github.com/sigp/signature-schemes" } +bls-aggregates = { git = "https://github.com/sigp/signature-schemes", tag = "v0.3.0" } hashing = { path = "../hashing" } hex = "0.3" ssz = { path = "../ssz" } From 73ba4d3cfc9a921a921bdc6b45ce49ff57d84298 Mon Sep 17 00:00:00 2001 From: Kirk Baird Date: Tue, 29 Jan 2019 09:27:40 +1100 Subject: [PATCH 5/6] Minor modification to merkle hashing --- eth2/utils/ssz/src/tree_hash.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eth2/utils/ssz/src/tree_hash.rs b/eth2/utils/ssz/src/tree_hash.rs index 497d626291..0ec280a6fe 100644 --- a/eth2/utils/ssz/src/tree_hash.rs +++ b/eth2/utils/ssz/src/tree_hash.rs @@ -30,8 +30,9 @@ pub fn merkle_hash(list: &mut Vec>) -> Vec { // Hash two chuncks together new_chunkz.append(&mut hash(two_chunks)); } - chunk_size = HASHSIZE; } + + chunk_size = HASHSIZE; chunkz = new_chunkz; } From aad3b3dc7ab3c184fe4d49a84c78618a0c5a4fb8 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Fri, 1 Feb 2019 19:05:39 +1100 Subject: [PATCH 6/6] Merge `spec` into `types` crate. Also remove some pre-2018 `extern crate` calls. --- Cargo.toml | 1 - beacon_node/src/beacon_chain/mod.rs | 3 +-- beacon_node/src/beacon_chain/tests/chain_test.rs | 2 +- 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/lib.rs | 2 ++ eth2/{spec/src => types/src/spec}/foundation.rs | 2 +- eth2/{spec/src/lib.rs => types/src/spec/mod.rs} | 5 +---- 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/block_producer/mod.rs | 3 +-- validator_client/src/duties/mod.rs | 2 +- validator_client/src/main.rs | 2 +- 21 files changed, 13 insertions(+), 49 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 c73e9f22d6..a473e03915 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ members = [ "eth2/attestation_validation", "eth2/genesis", "eth2/naive_fork_choice", - "eth2/spec", "eth2/types", "eth2/utils/bls", "eth2/utils/boolean-bitfield", diff --git a/beacon_node/src/beacon_chain/mod.rs b/beacon_node/src/beacon_chain/mod.rs index 2a3d415386..09dec741c8 100644 --- a/beacon_node/src/beacon_chain/mod.rs +++ b/beacon_node/src/beacon_chain/mod.rs @@ -7,11 +7,10 @@ use db::{ }; use genesis::{genesis_beacon_block, genesis_beacon_state, GenesisError}; use slot_clock::SlotClock; -use spec::ChainSpec; use ssz::ssz_encode; use std::collections::HashSet; use std::sync::Arc; -use types::Hash256; +use types::{ChainSpec, Hash256}; pub use crate::block_processing::Outcome as BlockProcessingOutcome; diff --git a/beacon_node/src/beacon_chain/tests/chain_test.rs b/beacon_node/src/beacon_chain/tests/chain_test.rs index 8d2cfa501a..fe7dfcf6c0 100644 --- a/beacon_node/src/beacon_chain/tests/chain_test.rs +++ b/beacon_node/src/beacon_chain/tests/chain_test.rs @@ -4,8 +4,8 @@ use db::{ MemoryDB, }; use slot_clock::TestingSlotClock; -use spec::ChainSpec; use std::sync::Arc; +use types::ChainSpec; fn in_memory_test_stores() -> ( Arc, diff --git a/eth2/genesis/Cargo.toml b/eth2/genesis/Cargo.toml index 4993339797..d56b3f929a 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 e79e3d2f46..debc2bd2b5 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 7644e782b3..788af7c824 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 6f45863aa4..003e669593 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 5c535ab414..0000000000 --- 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/lib.rs b/eth2/types/src/lib.rs index 6c4a1b977f..1018e38afa 100644 --- a/eth2/types/src/lib.rs +++ b/eth2/types/src/lib.rs @@ -25,6 +25,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; @@ -54,6 +55,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/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 8508a74e1a..f24a55b2ab 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 3e7d5dd2b6..1bf5b3d504 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)] pub struct ChainSpec { diff --git a/eth2/validator_induction/Cargo.toml b/eth2/validator_induction/Cargo.toml index 3530bbbf1c..5907014df7 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 6efc9af2e6..6b3cfdf16e 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 7119d6c2eb..3a4fa9a14a 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 99a97c5ec0..ae2babf1a4 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 ee59ffeccc..2307dd3011 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 734f5995c8..ea2cba7f44 100644 --- a/eth2/validator_shuffling/src/shuffle.rs +++ b/eth2/validator_shuffling/src/shuffle.rs @@ -1,8 +1,7 @@ use std::cmp::min; use honey_badger_split::SplitExt; -use spec::ChainSpec; -use types::validator_registry::get_active_validator_indices; +use types::{validator_registry::get_active_validator_indices, ChainSpec}; use types::{ShardCommittee, Validator}; use vec_shuffle::{shuffle, ShuffleErr}; diff --git a/validator_client/Cargo.toml b/validator_client/Cargo.toml index c23e6607af..dfec240c41 100644 --- a/validator_client/Cargo.toml +++ b/validator_client/Cargo.toml @@ -12,7 +12,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/block_producer/mod.rs b/validator_client/src/block_producer/mod.rs index f3cd0199bb..e36d4ed80e 100644 --- a/validator_client/src/block_producer/mod.rs +++ b/validator_client/src/block_producer/mod.rs @@ -7,9 +7,8 @@ mod traits; use self::traits::{BeaconNode, BeaconNodeError}; use super::EpochDutiesMap; use slot_clock::SlotClock; -use spec::ChainSpec; use std::sync::{Arc, RwLock}; -use types::BeaconBlock; +use types::{BeaconBlock, ChainSpec}; pub use self::service::BlockProducerService; diff --git a/validator_client/src/duties/mod.rs b/validator_client/src/duties/mod.rs index 4656715bae..851c2a033e 100644 --- a/validator_client/src/duties/mod.rs +++ b/validator_client/src/duties/mod.rs @@ -7,9 +7,9 @@ mod traits; use self::traits::{BeaconNode, BeaconNodeError}; use bls::PublicKey; use slot_clock::SlotClock; -use spec::ChainSpec; use std::collections::HashMap; use std::sync::{Arc, RwLock}; +use types::ChainSpec; pub use self::service::DutiesManagerService; diff --git a/validator_client/src/main.rs b/validator_client/src/main.rs index bbbc0b4c35..56c7054947 100644 --- a/validator_client/src/main.rs +++ b/validator_client/src/main.rs @@ -7,10 +7,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, RwLock}; use std::thread; +use types::ChainSpec; mod block_producer; mod config;