Update beacon_node bin to spec v0.2.0
This commit is contained in:
parent
12076bce76
commit
9b14742e36
@ -8,6 +8,7 @@ use std::path::PathBuf;
|
|||||||
use crate::config::LighthouseConfig;
|
use crate::config::LighthouseConfig;
|
||||||
use crate::rpc::start_server;
|
use crate::rpc::start_server;
|
||||||
use beacon_chain::BeaconChain;
|
use beacon_chain::BeaconChain;
|
||||||
|
use bls::create_proof_of_possession;
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use db::{
|
use db::{
|
||||||
stores::{BeaconBlockStore, BeaconStateStore},
|
stores::{BeaconBlockStore, BeaconStateStore},
|
||||||
@ -16,7 +17,7 @@ use db::{
|
|||||||
use slog::{error, info, o, Drain};
|
use slog::{error, info, o, Drain};
|
||||||
use slot_clock::SystemTimeSlotClock;
|
use slot_clock::SystemTimeSlotClock;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use types::ChainSpec;
|
use types::{ChainSpec, Deposit, DepositData, DepositInput, Eth1Data, Hash256, Keypair};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let decorator = slog_term::TermDecorator::new().build();
|
let decorator = slog_term::TermDecorator::new().build();
|
||||||
@ -75,13 +76,51 @@ fn main() {
|
|||||||
let state_store = Arc::new(BeaconStateStore::new(db.clone()));
|
let state_store = Arc::new(BeaconStateStore::new(db.clone()));
|
||||||
|
|
||||||
// Slot clock
|
// Slot clock
|
||||||
let slot_clock = SystemTimeSlotClock::new(spec.genesis_time, spec.slot_duration)
|
let genesis_time = 1_549_935_547; // 12th Feb 2018 (arbitrary value in the past).
|
||||||
|
let slot_clock = SystemTimeSlotClock::new(genesis_time, spec.slot_duration)
|
||||||
.expect("Unable to load SystemTimeSlotClock");
|
.expect("Unable to load SystemTimeSlotClock");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generate some random data to start a chain with.
|
||||||
|
*
|
||||||
|
* This is will need to be replace for production usage.
|
||||||
|
*/
|
||||||
|
let latest_eth1_data = Eth1Data {
|
||||||
|
deposit_root: Hash256::zero(),
|
||||||
|
block_hash: Hash256::zero(),
|
||||||
|
};
|
||||||
|
let keypairs: Vec<Keypair> = (0..10)
|
||||||
|
.collect::<Vec<usize>>()
|
||||||
|
.iter()
|
||||||
|
.map(|_| Keypair::random())
|
||||||
|
.collect();
|
||||||
|
let initial_validator_deposits = keypairs
|
||||||
|
.iter()
|
||||||
|
.map(|keypair| Deposit {
|
||||||
|
branch: vec![], // branch verification is not specified.
|
||||||
|
index: 0, // index verification is not specified.
|
||||||
|
deposit_data: DepositData {
|
||||||
|
amount: 32_000_000_000, // 32 ETH (in Gwei)
|
||||||
|
timestamp: genesis_time - 1,
|
||||||
|
deposit_input: DepositInput {
|
||||||
|
pubkey: keypair.pk.clone(),
|
||||||
|
withdrawal_credentials: Hash256::zero(), // Withdrawal not possible.
|
||||||
|
proof_of_possession: create_proof_of_possession(&keypair),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
// Genesis chain
|
// Genesis chain
|
||||||
// TODO: persist chain to storage.
|
let _chain_result = BeaconChain::genesis(
|
||||||
let _chain_result =
|
state_store.clone(),
|
||||||
BeaconChain::genesis(state_store.clone(), block_store.clone(), slot_clock, spec);
|
block_store.clone(),
|
||||||
|
slot_clock,
|
||||||
|
genesis_time,
|
||||||
|
latest_eth1_data,
|
||||||
|
initial_validator_deposits,
|
||||||
|
spec,
|
||||||
|
);
|
||||||
|
|
||||||
let _server = start_server(log.clone());
|
let _server = start_server(log.clone());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user