Complete merging of network addition branch

This commit is contained in:
Age Manning 2019-06-23 12:34:00 +10:00
parent c7e17c8641
commit 6ee2b4df34
No known key found for this signature in database
GPG Key ID: 05EED64B79E06A93
11 changed files with 12 additions and 22 deletions

View File

@ -22,5 +22,4 @@ tokio-timer = "0.2.10"
futures = "0.1.25" futures = "0.1.25"
exit-future = "0.1.3" exit-future = "0.1.3"
state_processing = { path = "../eth2/state_processing" } state_processing = { path = "../eth2/state_processing" }
slog = "^2.2.3"
env_logger = "0.6.1" env_logger = "0.6.1"

View File

@ -3,7 +3,6 @@ use eth2_libp2p::multiaddr::Protocol;
use eth2_libp2p::Multiaddr; use eth2_libp2p::Multiaddr;
use fork_choice::ForkChoiceAlgorithm; use fork_choice::ForkChoiceAlgorithm;
use http_server::HttpServerConfig; use http_server::HttpServerConfig;
use network::NetworkConfig;
use network::{ChainType, NetworkConfig}; use network::{ChainType, NetworkConfig};
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use slog::{error, o, Drain, Level}; use slog::{error, o, Drain, Level};
@ -29,7 +28,7 @@ impl Default for ClientConfig {
db_name: "chain_db".to_string(), db_name: "chain_db".to_string(),
// Note: there are no default bootnodes specified. // Note: there are no default bootnodes specified.
// Once bootnodes are established, add them here. // Once bootnodes are established, add them here.
network: NetworkConfig::new(vec![]), network: NetworkConfig::new(),
rpc: rpc::RPCConfig::default(), rpc: rpc::RPCConfig::default(),
http: HttpServerConfig::default(), http: HttpServerConfig::default(),
} }

View File

@ -8,7 +8,7 @@ edition = "2018"
beacon_chain = { path = "../beacon_chain" } beacon_chain = { path = "../beacon_chain" }
clap = "2.32.0" clap = "2.32.0"
# SigP repository # SigP repository
libp2p = { git = "https://github.com/SigP/rust-libp2p", rev = "8d5e5bbbe32d07ad271d6a2e15fde0347894061a" } libp2p = { git = "https://github.com/SigP/rust-libp2p", rev = "71744d4090ebd93a993d1b390787919add4098fd" }
types = { path = "../../eth2/types" } types = { path = "../../eth2/types" }
serde = "1.0" serde = "1.0"
serde_derive = "1.0" serde_derive = "1.0"

View File

@ -111,14 +111,16 @@ impl<TSubstream: AsyncRead + AsyncWrite> NetworkBehaviourEventProcess<IdentifyEv
); );
info.listen_addrs.truncate(20); info.listen_addrs.truncate(20);
} }
self.events
.push(BehaviourEvent::Identified(peer_id, Box::new(info)));
trace!(self.log, "Found addresses"; "Peer Id" => format!("{:?}", peer_id), "Addresses" => format!("{:?}", info.listen_addrs)); trace!(self.log, "Found addresses"; "Peer Id" => format!("{:?}", peer_id), "Addresses" => format!("{:?}", info.listen_addrs));
// inject the found addresses into our discovery behaviour // inject the found addresses into our discovery behaviour
for address in &info.listen_addrs { for address in &info.listen_addrs {
self.discovery self.discovery
.add_connected_address(&peer_id, address.clone()); .add_connected_address(&peer_id, address.clone());
} }
self.events
.push(BehaviourEvent::Identified(peer_id, Box::new(info)));
} }
IdentifyEvent::Error { .. } => {} IdentifyEvent::Error { .. } => {}
IdentifyEvent::SendBack { .. } => {} IdentifyEvent::SendBack { .. } => {}

View File

@ -1,8 +1,8 @@
use clap::ArgMatches; use clap::ArgMatches;
use libp2p::gossipsub::{GossipsubConfig, GossipsubConfigBuilder}; use libp2p::gossipsub::{GossipsubConfig, GossipsubConfigBuilder};
use libp2p::multiaddr::{Error as MultiaddrError, Multiaddr};
use serde_derive::{Deserialize, Serialize}; use serde_derive::{Deserialize, Serialize};
use std::time::Duration; use std::time::Duration;
use types::multiaddr::{Error as MultiaddrError, Multiaddr};
/// The beacon node topic string to subscribe to. /// The beacon node topic string to subscribe to.
pub const BEACON_PUBSUB_TOPIC: &str = "beacon_node"; pub const BEACON_PUBSUB_TOPIC: &str = "beacon_node";

View File

@ -55,7 +55,7 @@ impl<TSubstream> Discovery<TSubstream> {
/// We have discovered an address for a peer, add it to known peers. /// We have discovered an address for a peer, add it to known peers.
pub fn add_connected_address(&mut self, peer_id: &PeerId, address: Multiaddr) { pub fn add_connected_address(&mut self, peer_id: &PeerId, address: Multiaddr) {
// pass the address on to kademlia // pass the address on to kademlia
self.discovery.add_connected_address(peer_id, address); self.discovery.add_address(peer_id, address);
} }
} }

View File

@ -5,7 +5,6 @@ use eth2_libp2p::rpc::methods::*;
use eth2_libp2p::rpc::{RPCRequest, RPCResponse, RequestId}; use eth2_libp2p::rpc::{RPCRequest, RPCResponse, RequestId};
use eth2_libp2p::PeerId; use eth2_libp2p::PeerId;
use slog::{debug, error, info, o, trace, warn}; use slog::{debug, error, info, o, trace, warn};
use ssz::TreeHash;
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::Arc; use std::sync::Arc;
use std::time::Duration; use std::time::Duration;

View File

@ -62,7 +62,6 @@ pub fn start_server<T: BeaconChainTypes + Clone + 'static>(
let instance = AttestationServiceInstance { let instance = AttestationServiceInstance {
network_chan, network_chan,
chain: beacon_chain.clone(), chain: beacon_chain.clone(),
network_chan,
log: log.clone(), log: log.clone(),
}; };
create_attestation_service(instance) create_attestation_service(instance)

View File

@ -4,7 +4,7 @@ use clap::{App, Arg};
use client::{ClientConfig, Eth2Config}; use client::{ClientConfig, Eth2Config};
use env_logger::{Builder, Env}; use env_logger::{Builder, Env};
use eth2_config::{get_data_dir, read_from_file, write_to_file}; use eth2_config::{get_data_dir, read_from_file, write_to_file};
use slog::{crit, o, Drain}; use slog::{crit, o, Drain, Level};
use std::path::PathBuf; use std::path::PathBuf;
pub const DEFAULT_DATA_DIR: &str = ".lighthouse"; pub const DEFAULT_DATA_DIR: &str = ".lighthouse";

View File

@ -32,7 +32,6 @@ 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" }
tree_hash = { path = "../utils/tree_hash" } tree_hash = { path = "../utils/tree_hash" }
tree_hash_derive = { path = "../utils/tree_hash_derive" } tree_hash_derive = { path = "../utils/tree_hash_derive" }
libp2p = { git = "https://github.com/SigP/rust-libp2p", rev = "b3c32d9a821ae6cc89079499cc6e8a6bab0bffc3" }
[dev-dependencies] [dev-dependencies]
env_logger = "0.6.0" env_logger = "0.6.0"

View File

@ -104,10 +104,7 @@ pub struct ChainSpec {
domain_voluntary_exit: u32, domain_voluntary_exit: u32,
domain_transfer: u32, domain_transfer: u32,
/* pub boot_nodes: Vec<String>,
* Network specific parameters
*/
pub boot_nodes: Vec<Multiaddr>,
pub chain_id: u8, pub chain_id: u8,
} }
@ -230,12 +227,8 @@ impl ChainSpec {
pub fn minimal() -> Self { pub fn minimal() -> Self {
let genesis_slot = Slot::new(0); let genesis_slot = Slot::new(0);
// Note: these bootnodes are placeholders. // Note: bootnodes to be updated when static nodes exist.
// let boot_nodes = vec![];
// Should be updated once static bootnodes exist.
let boot_nodes = vec!["/ip4/127.0.0.1/tcp/9000"
.parse()
.expect("correct multiaddr")];
Self { Self {
target_committee_size: 4, target_committee_size: 4,