Adds bootnodes to chainspec. Handles type correctly
This commit is contained in:
parent
c5a7c62d5d
commit
21032334ac
@ -7,13 +7,11 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
beacon_chain = { path = "../beacon_chain" }
|
beacon_chain = { path = "../beacon_chain" }
|
||||||
network = { path = "../network" }
|
network = { path = "../network" }
|
||||||
libp2p = { path = "../libp2p" }
|
|
||||||
sync = { path = "../sync" }
|
sync = { path = "../sync" }
|
||||||
db = { path = "../db" }
|
db = { path = "../db" }
|
||||||
fork_choice = { path = "../../eth2/fork_choice" }
|
fork_choice = { path = "../../eth2/fork_choice" }
|
||||||
types = { path = "../../eth2/types" }
|
types = { path = "../../eth2/types" }
|
||||||
slot_clock = { path = "../../eth2/utils/slot_clock" }
|
slot_clock = { path = "../../eth2/utils/slot_clock" }
|
||||||
|
|
||||||
error-chain = "0.12.0"
|
error-chain = "0.12.0"
|
||||||
slog = "^2.2.3"
|
slog = "^2.2.3"
|
||||||
tokio = "0.1.15"
|
tokio = "0.1.15"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
use clap::ArgMatches;
|
use clap::ArgMatches;
|
||||||
use db::DBType;
|
use db::DBType;
|
||||||
use fork_choice::ForkChoiceAlgorithm;
|
use fork_choice::ForkChoiceAlgorithm;
|
||||||
use libp2p::multiaddr::ToMultiaddr;
|
|
||||||
use network::NetworkConfig;
|
use network::NetworkConfig;
|
||||||
use slog::error;
|
use slog::error;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use types::multiaddr::ToMultiaddr;
|
||||||
use types::ChainSpec;
|
use types::ChainSpec;
|
||||||
|
|
||||||
/// Stores the client configuration for this Lighthouse instance.
|
/// Stores the client configuration for this Lighthouse instance.
|
||||||
@ -32,11 +32,15 @@ impl Default for ClientConfig {
|
|||||||
};
|
};
|
||||||
fs::create_dir_all(&data_dir)
|
fs::create_dir_all(&data_dir)
|
||||||
.unwrap_or_else(|_| panic!("Unable to create {:?}", &data_dir));
|
.unwrap_or_else(|_| panic!("Unable to create {:?}", &data_dir));
|
||||||
|
|
||||||
|
let default_spec = ChainSpec::lighthouse_testnet();
|
||||||
|
let default_net_conf = NetworkConfig::new(default_spec.boot_nodes.clone());
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
data_dir: data_dir.clone(),
|
data_dir: data_dir.clone(),
|
||||||
// default to foundation for chain specs
|
// default to foundation for chain specs
|
||||||
spec: ChainSpec::foundation(),
|
spec: default_spec,
|
||||||
net_conf: NetworkConfig::default(),
|
net_conf: default_net_conf,
|
||||||
// default to bitwise LMD Ghost
|
// default to bitwise LMD Ghost
|
||||||
fork_choice: ForkChoiceAlgorithm::BitwiseLMDGhost,
|
fork_choice: ForkChoiceAlgorithm::BitwiseLMDGhost,
|
||||||
// default to memory db for now
|
// default to memory db for now
|
||||||
|
@ -7,8 +7,8 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
# SigP repository until PR is merged
|
# SigP repository until PR is merged
|
||||||
libp2p = { git = "https://github.com/SigP/rust-libp2p", branch = "gossipsub" }
|
libp2p = { git = "https://github.com/SigP/rust-libp2p", branch = "gossipsub" }
|
||||||
|
types = { path = "../../eth2/types" }
|
||||||
slog = "2.4.1"
|
slog = "2.4.1"
|
||||||
version = { path = "../version" }
|
version = { path = "../version" }
|
||||||
tokio = "0.1.16"
|
tokio = "0.1.16"
|
||||||
futures = "0.1.25"
|
futures = "0.1.25"
|
||||||
parity-multiaddr = "0.2.0"
|
|
||||||
|
@ -6,11 +6,11 @@ mod behaviour;
|
|||||||
mod network_config;
|
mod network_config;
|
||||||
mod service;
|
mod service;
|
||||||
|
|
||||||
pub use libp2p::multiaddr;
|
|
||||||
pub use libp2p::Multiaddr;
|
|
||||||
pub use libp2p::{
|
pub use libp2p::{
|
||||||
gossipsub::{GossipsubConfig, GossipsubConfigBuilder},
|
gossipsub::{GossipsubConfig, GossipsubConfigBuilder},
|
||||||
PeerId,
|
PeerId,
|
||||||
};
|
};
|
||||||
pub use network_config::NetworkConfig;
|
pub use network_config::NetworkConfig;
|
||||||
pub use service::Service;
|
pub use service::Service;
|
||||||
|
pub use types::multiaddr;
|
||||||
|
pub use types::Multiaddr;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
use crate::Multiaddr;
|
||||||
use libp2p::gossipsub::{GossipsubConfig, GossipsubConfigBuilder};
|
use libp2p::gossipsub::{GossipsubConfig, GossipsubConfigBuilder};
|
||||||
use libp2p::secio;
|
use libp2p::secio;
|
||||||
use libp2p::Multiaddr;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@ -40,8 +40,11 @@ impl Default for NetworkConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl NetworkConfig {
|
impl NetworkConfig {
|
||||||
pub fn new() -> Self {
|
pub fn new(boot_nodes: Vec<Multiaddr>) -> Self {
|
||||||
NetworkConfig::default()
|
let mut conf = NetworkConfig::default();
|
||||||
|
conf.boot_nodes = boot_nodes;
|
||||||
|
|
||||||
|
conf
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::behaviour::Behaviour;
|
use crate::behaviour::Behaviour;
|
||||||
|
use crate::multiaddr::Protocol;
|
||||||
use crate::NetworkConfig;
|
use crate::NetworkConfig;
|
||||||
use futures::prelude::*;
|
use futures::prelude::*;
|
||||||
use libp2p::core::{
|
use libp2p::core::{
|
||||||
@ -7,7 +8,6 @@ use libp2p::core::{
|
|||||||
transport::boxed::Boxed,
|
transport::boxed::Boxed,
|
||||||
upgrade::{InboundUpgradeExt, OutboundUpgradeExt},
|
upgrade::{InboundUpgradeExt, OutboundUpgradeExt},
|
||||||
};
|
};
|
||||||
use libp2p::multiaddr::Protocol;
|
|
||||||
use libp2p::{core, secio, Transport};
|
use libp2p::{core, secio, Transport};
|
||||||
use libp2p::{PeerId, Swarm};
|
use libp2p::{PeerId, Swarm};
|
||||||
use slog::{debug, info, warn};
|
use slog::{debug, info, warn};
|
||||||
|
@ -22,6 +22,7 @@ ssz = { path = "../utils/ssz" }
|
|||||||
ssz_derive = { path = "../utils/ssz_derive" }
|
ssz_derive = { path = "../utils/ssz_derive" }
|
||||||
swap_or_not_shuffle = { path = "../utils/swap_or_not_shuffle" }
|
swap_or_not_shuffle = { path = "../utils/swap_or_not_shuffle" }
|
||||||
test_random_derive = { path = "../utils/test_random_derive" }
|
test_random_derive = { path = "../utils/test_random_derive" }
|
||||||
|
libp2p = { git = "https://github.com/SigP/rust-libp2p", branch = "gossipsub" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.6.0"
|
env_logger = "0.6.0"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{Address, Epoch, Fork, Hash256, Slot};
|
use crate::{Address, Epoch, Fork, Hash256, Multiaddr, Slot};
|
||||||
use bls::Signature;
|
use bls::Signature;
|
||||||
|
|
||||||
const GWEI: u64 = 1_000_000_000;
|
const GWEI: u64 = 1_000_000_000;
|
||||||
@ -106,6 +106,12 @@ pub struct ChainSpec {
|
|||||||
domain_exit: u64,
|
domain_exit: u64,
|
||||||
domain_randao: u64,
|
domain_randao: u64,
|
||||||
domain_transfer: u64,
|
domain_transfer: u64,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Network specific parameters
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
pub boot_nodes: Vec<Multiaddr>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChainSpec {
|
impl ChainSpec {
|
||||||
@ -232,9 +238,31 @@ impl ChainSpec {
|
|||||||
domain_exit: 3,
|
domain_exit: 3,
|
||||||
domain_randao: 4,
|
domain_randao: 4,
|
||||||
domain_transfer: 5,
|
domain_transfer: 5,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Boot nodes
|
||||||
|
*/
|
||||||
|
boot_nodes: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a `ChainSpec` compatible with the Lighthouse testnet specification.
|
||||||
|
///
|
||||||
|
/// Spec v0.4.0
|
||||||
|
pub fn lighthouse_testnet() -> Self {
|
||||||
|
/*
|
||||||
|
* Lighthouse testnet bootnodes
|
||||||
|
*/
|
||||||
|
let boot_nodes = vec!["/ip4/127.0.0.1/tcp/9000"
|
||||||
|
.parse()
|
||||||
|
.expect("correct multiaddr")];
|
||||||
|
|
||||||
|
let mut standard_spec = ChainSpec::foundation();
|
||||||
|
standard_spec.boot_nodes = boot_nodes;
|
||||||
|
|
||||||
|
standard_spec
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a `ChainSpec` compatible with the specification suitable for 8 validators.
|
/// Returns a `ChainSpec` compatible with the specification suitable for 8 validators.
|
||||||
///
|
///
|
||||||
/// Spec v0.4.0
|
/// Spec v0.4.0
|
||||||
|
@ -73,3 +73,5 @@ pub type AttesterMap = HashMap<(u64, u64), Vec<usize>>;
|
|||||||
pub type ProposerMap = HashMap<u64, usize>;
|
pub type ProposerMap = HashMap<u64, usize>;
|
||||||
|
|
||||||
pub use bls::{AggregatePublicKey, AggregateSignature, Keypair, PublicKey, Signature};
|
pub use bls::{AggregatePublicKey, AggregateSignature, Keypair, PublicKey, Signature};
|
||||||
|
pub use libp2p::multiaddr;
|
||||||
|
pub use libp2p::Multiaddr;
|
||||||
|
Loading…
Reference in New Issue
Block a user