forked from sigp/lighthouse
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic shard node running via clap tools
- Loading branch information
1 parent
b89d650
commit d4292b8
Showing
5 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "shard_node" | ||
version = "0.1.0" | ||
authors = ["Will Villanueva"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
shard_chain = { path = "./shard_chain" } | ||
types = { path = "../eth2/types" } | ||
toml = "^0.5" | ||
store = { path = "../beacon_node/store" } | ||
shard_store = { path = "./shard_store" } | ||
clap = "2.32.0" | ||
serde = "1.0" | ||
shard_operation_pool = { path = "../eth2/shard_operation_pool" } | ||
slog = { version = "^2.2.3" , features = ["max_level_trace"] } | ||
slog-term = "^2.4.0" | ||
slog-async = "^2.3.0" | ||
slot_clock = { path = "../eth2/utils/slot_clock" } | ||
ctrlc = { version = "3.1.1", features = ["termination"] } | ||
tokio = "0.1.15" | ||
tokio-timer = "0.2.10" | ||
futures = "0.1.25" | ||
exit-future = "0.1.3" | ||
shard_state_processing = { path = "../eth2/shard_state_processing" } | ||
env_logger = "0.6.1" | ||
dirs = "2.0.1" | ||
shard_lmd_ghost = { path = "../eth2/shard_lmd_ghost" } | ||
lmd_ghost = { path = "../eth2/lmd_ghost" } | ||
rand = "0.5.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
mod run; | ||
|
||
extern crate clap; | ||
use shard_chain::ShardChainHarness; | ||
use clap::{Arg, App, SubCommand}; | ||
|
||
fn main() { | ||
let matches = App::new("My Super Program") | ||
.version("0.1.0") | ||
.author("Will Villanueva") | ||
.about("Simulates Shard Chains") | ||
.arg(Arg::with_name("shards") | ||
.short("s") | ||
.long("shards") | ||
.value_name("FILE") | ||
.help("Sets a custom config file") | ||
.takes_value(true)) | ||
.get_matches(); | ||
|
||
// Matches number of shards to run | ||
let shards = matches.value_of("shards").unwrap_or("1"); | ||
run::run_harness(); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use shard_chain::ShardChainHarness; | ||
use lmd_ghost::ThreadSafeReducedTree; | ||
use rand::Rng; | ||
use shard_lmd_ghost::ThreadSafeReducedTree as ShardThreadSafeReducedTree; | ||
use shard_store::{MemoryStore as ShardMemoryStore, Store as ShardStore}; | ||
use store::{MemoryStore, Store}; | ||
use types::test_utils::{SeedableRng, TestRandom, XorShiftRng}; | ||
use types::{EthSpec, MinimalEthSpec, MinimalShardSpec, Slot}; | ||
|
||
pub const VALIDATOR_COUNT: usize = 24; | ||
|
||
pub type TestBeaconForkChoice = ThreadSafeReducedTree<MemoryStore, MinimalEthSpec>; | ||
pub type TestShardForkChoice = ShardThreadSafeReducedTree<ShardMemoryStore, MinimalShardSpec>; | ||
|
||
fn get_harness( | ||
validator_count: usize, | ||
) -> ShardChainHarness<TestBeaconForkChoice, MinimalEthSpec, TestShardForkChoice, MinimalShardSpec> | ||
{ | ||
let harness = ShardChainHarness::new(validator_count); | ||
|
||
// Move past the zero slot | ||
harness.advance_beacon_slot(); | ||
harness.advance_shard_slot(); | ||
|
||
harness | ||
} | ||
|
||
pub fn run_harness() -> () { | ||
let harness = get_harness(VALIDATOR_COUNT); | ||
let num_blocks_produced = | ||
MinimalEthSpec::slots_per_epoch() * harness.beacon_spec.phase_1_fork_epoch; | ||
|
||
harness.extend_beacon_chain((num_blocks_produced + 1) as usize); | ||
harness.extend_shard_chain(1, vec![]); | ||
println!("{:?}", harness.shard_chain.current_state().clone()); | ||
} |