Remove dependency on the parity repo (#734)

This commit is contained in:
Arkadiy Paronyan
2018-09-13 14:25:38 +02:00
committed by Gav Wood
parent 88ef57e4bd
commit 0ed48c89ab
12 changed files with 119 additions and 263 deletions
+1
View File
@@ -27,6 +27,7 @@ substrate-client = { path = "../../core/client" }
substrate-network = { path = "../../core/network" }
substrate-network-libp2p = { path = "../../core/network-libp2p" }
sr-primitives = { path = "../../core/sr-primitives" }
substrate-primitives = { path = "../../core/primitives" }
substrate-service = { path = "../../core/service" }
substrate-telemetry = { path = "../../core/telemetry" }
names = "0.11.0"
+5 -2
View File
@@ -39,6 +39,7 @@ extern crate substrate_network as network;
extern crate substrate_network_libp2p as network_libp2p;
extern crate sr_primitives as runtime_primitives;
extern crate substrate_service as service;
extern crate substrate_primitives as primitives;
#[macro_use]
extern crate slog; // needed until we can reexport `slog_info` from `substrate_telemetry`
#[macro_use]
@@ -64,6 +65,7 @@ use service::{
FactoryGenesis, PruningMode, ChainSpec,
};
use network::NonReservedPeerMode;
use primitives::H256;
use std::io::{Write, Read, stdin, stdout};
use std::iter;
@@ -71,6 +73,7 @@ use std::fs;
use std::fs::File;
use std::net::{Ipv4Addr, SocketAddr};
use std::path::{Path, PathBuf};
use std::str::FromStr;
use names::{Generator, Name};
use regex::Regex;
@@ -311,8 +314,8 @@ where
config.network.public_addresses = Vec::new();
config.network.client_version = config.client_id();
config.network.use_secret = match matches.value_of("node-key").map(|s| s.parse()) {
Some(Ok(secret)) => Some(secret),
config.network.use_secret = match matches.value_of("node-key").map(H256::from_str) {
Some(Ok(secret)) => Some(secret.into()),
Some(Err(err)) => return Err(format!("Error parsing node key: {}", err).into()),
None => None,
};
+1 -5
View File
@@ -11,9 +11,7 @@ bytes = "0.4"
error-chain = { version = "0.12", default-features = false }
fnv = "1.0"
futures = "0.1"
libp2p = { git = "https://github.com/libp2p/rust-libp2p", rev = "304e9c72c88bc97824f2734dc19d1b5f4556d346", default-features = false, features = ["libp2p-secio", "libp2p-secio-secp256k1"] }
ethcore-io = { git = "https://github.com/paritytech/parity.git" }
ethkey = { git = "https://github.com/paritytech/parity.git" }
libp2p = { git = "https://github.com/libp2p/rust-libp2p", rev = "5980a4538ef6fc8af450893acb01290eaed136de", default-features = false, features = ["libp2p-secio", "libp2p-secio-secp256k1"] }
ethereum-types = "0.3"
parking_lot = "0.5"
libc = "0.2"
@@ -30,5 +28,3 @@ unsigned-varint = { version = "0.2.1", features = ["codec"] }
[dev-dependencies]
assert_matches = "1.2"
parity-bytes = "0.1"
ethcore-io = { git = "https://github.com/paritytech/parity.git" }
ethcore-logger = { git = "https://github.com/paritytech/parity.git" }
@@ -16,8 +16,6 @@
use std::{io, net, fmt};
use libc::{ENFILE, EMFILE};
use io::IoError;
use ethkey;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum DisconnectReason
@@ -82,10 +80,6 @@ impl fmt::Display for DisconnectReason {
}
error_chain! {
foreign_links {
SocketIo(IoError) #[doc = "Socket IO error."];
}
errors {
#[doc = "Error concerning the network address parsing subsystem."]
AddressParse {
@@ -171,17 +165,6 @@ impl From<io::Error> for Error {
}
}
impl From<ethkey::Error> for Error {
fn from(_err: ethkey::Error) -> Self {
ErrorKind::Auth.into()
}
}
impl From<ethkey::crypto::Error> for Error {
fn from(_err: ethkey::crypto::Error) -> Self {
ErrorKind::Auth.into()
}
}
impl From<net::AddrParseError> for Error {
fn from(_err: net::AddrParseError) -> Self { ErrorKind::AddressParse.into() }
+2 -3
View File
@@ -27,7 +27,6 @@ extern crate futures;
extern crate tokio;
extern crate tokio_io;
extern crate tokio_timer;
extern crate ethkey;
extern crate libc;
extern crate libp2p;
extern crate rand;
@@ -38,7 +37,6 @@ extern crate serde_json;
extern crate bytes;
extern crate unsigned_varint;
extern crate ethcore_io as io;
extern crate ethereum_types;
#[macro_use]
@@ -49,11 +47,12 @@ extern crate log;
extern crate assert_matches;
pub use connection_filter::{ConnectionFilter, ConnectionDirection};
pub use io::TimerToken;
pub use error::{Error, ErrorKind, DisconnectReason};
pub use libp2p::{Multiaddr, multiaddr::AddrComponent};
pub use traits::*;
pub type TimerToken = usize;
mod connection_filter;
mod custom_proto;
mod error;
+4 -2
View File
@@ -20,10 +20,9 @@ use std::iter;
use std::net::Ipv4Addr;
use std::str;
use std::time::Duration;
use io::TimerToken;
use TimerToken;
use libp2p::{multiaddr::AddrComponent, Multiaddr};
use error::Error;
use ethkey::Secret;
use ethereum_types::H512;
/// Protocol handler level packet id
@@ -37,6 +36,9 @@ pub type NodeId = H512;
/// Local (temporary) peer session ID.
pub type NodeIndex = usize;
/// secio secret key;
pub type Secret = [u8; 32];
/// Shared session information
#[derive(Debug, Clone)]
pub struct SessionInfo {
@@ -30,9 +30,7 @@ pub fn build_transport(
mplex_config.max_buffer_len(usize::MAX);
let base = libp2p::CommonTransport::new()
.with_upgrade(secio::SecioConfig {
key: local_private_key,
})
.with_upgrade(secio::SecioConfig::new(local_private_key))
.and_then(move |out, endpoint, client_addr| {
let upgrade = upgrade::or(
upgrade::map(mplex_config, either::EitherOutput::First),
+1 -7
View File
@@ -16,10 +16,7 @@
extern crate parking_lot;
extern crate parity_bytes;
extern crate ethcore_io as io;
extern crate ethcore_logger;
extern crate substrate_network_libp2p;
extern crate ethkey;
use std::sync::atomic::{AtomicBool, Ordering as AtomicOrdering};
use std::sync::Arc;
@@ -28,8 +25,7 @@ use std::time::*;
use parking_lot::Mutex;
use parity_bytes::Bytes;
use substrate_network_libp2p::*;
use ethkey::{Random, Generator};
use io::TimerToken;
use TimerToken;
pub struct TestProtocol {
drop_session: bool,
@@ -102,9 +98,7 @@ fn net_service() {
#[test]
#[ignore] // TODO: how is this test even supposed to work?
fn net_disconnect() {
let key1 = Random.generate().unwrap();
let mut config1 = NetworkConfiguration::new_local();
config1.use_secret = Some(key1.secret().clone());
config1.boot_nodes = vec![ ];
let handler1 = Arc::new(TestProtocol::new(false));
let service1 = NetworkService::new(config1, vec![(handler1.clone(), *b"tst", &[(42u8, 1), (43u8, 1)])]).unwrap();
-1
View File
@@ -15,7 +15,6 @@ bitflags = "1.0"
futures = "0.1.17"
linked-hash-map = "0.5"
rustc-hex = "1.0"
ethcore-io = { git = "https://github.com/paritytech/parity.git" }
substrate-primitives = { path = "../../core/primitives" }
substrate-client = { path = "../../core/client" }
sr-primitives = { path = "../../core/sr-primitives" }
-1
View File
@@ -22,7 +22,6 @@
//! Allows attachment of an optional subprotocol for chain-specific requests.
// end::description[]
extern crate ethcore_io as core_io;
extern crate linked_hash_map;
extern crate parking_lot;
extern crate substrate_primitives as primitives;
+2 -1
View File
@@ -22,7 +22,6 @@ use futures::sync::{oneshot, mpsc};
use network_libp2p::{NetworkProtocolHandler, NetworkContext, NodeIndex, ProtocolId,
NetworkConfiguration , NonReservedPeerMode, ErrorKind};
use network_libp2p::{NetworkService};
use core_io::{TimerToken};
use io::NetSyncIo;
use protocol::{Protocol, ProtocolContext, Context, ProtocolStatus, PeerInfo as ProtocolPeerInfo};
use config::{ProtocolConfig};
@@ -39,6 +38,8 @@ pub type FetchFuture = oneshot::Receiver<Vec<u8>>;
/// Type that represents bft messages stream.
pub type BftMessageStream<B> = mpsc::UnboundedReceiver<LocalizedBftMessage<B>>;
type TimerToken = usize;
const TICK_TOKEN: TimerToken = 0;
const TICK_TIMEOUT: Duration = Duration::from_millis(1000);