Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Apply breaking changes of new libp2p versions #3877

Merged
merged 9 commits into from
Nov 6, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
482 changes: 174 additions & 308 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ client = { package = "substrate-client", path = "../../core/client" }
codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" }
derive_more = "0.15.0"
futures-preview = "0.3.0-alpha.19"
libp2p = { version = "0.12.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
libp2p = { version = "0.13.0", default-features = false, features = ["secp256k1", "libp2p-websocket"] }
log = "0.4.8"
network = { package = "substrate-network", path = "../../core/network" }
primitives = { package = "substrate-primitives", path = "../primitives" }
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2018"

[dependencies]
derive_more = "0.15.0"
libp2p = { version = "0.12.0", default-features = false }
libp2p = { version = "0.13.0", default-features = false }
log = "0.4.8"
primitives = { package = "substrate-primitives", path= "../../primitives" }
inherents = { package = "substrate-inherents", path = "../../inherents" }
Expand Down
2 changes: 1 addition & 1 deletion core/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ linked_hash_set = "0.1.3"
lru-cache = "0.1.2"
rustc-hex = "2.0.1"
rand = "0.7.2"
libp2p = { version = "0.12.0", default-features = false, features = ["libp2p-websocket"] }
libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] }
fork-tree = { path = "../../core/utils/fork-tree" }
consensus = { package = "substrate-consensus-common", path = "../../core/consensus/common" }
client = { package = "substrate-client", path = "../../core/client" }
Expand Down
11 changes: 5 additions & 6 deletions core/network/src/debug_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use libp2p::Multiaddr;
use libp2p::core::{ConnectedPoint, either::EitherOutput, PeerId, PublicKey};
use libp2p::swarm::{IntoProtocolsHandler, IntoProtocolsHandlerSelect, ProtocolsHandler};
use libp2p::swarm::{NetworkBehaviour, NetworkBehaviourAction, PollParameters};
use libp2p::identify::{Identify, IdentifyEvent, protocol::IdentifyInfo};
use libp2p::identify::{Identify, IdentifyEvent, IdentifyInfo};
use libp2p::ping::{Ping, PingConfig, PingEvent, PingSuccess};
use log::{debug, trace, error};
use std::collections::hash_map::Entry;
Expand Down Expand Up @@ -287,16 +287,15 @@ where TSubstream: AsyncRead + AsyncWrite {
Async::NotReady => break,
Async::Ready(NetworkBehaviourAction::GenerateEvent(event)) => {
match event {
IdentifyEvent::Identified { peer_id, info, .. } => {
IdentifyEvent::Received { peer_id, info, .. } => {
self.handle_identify_report(&peer_id, &info);
let event = DebugInfoEvent::Identified { peer_id, info };
return Async::Ready(NetworkBehaviourAction::GenerateEvent(event));
}
IdentifyEvent::Error { .. } => {}
IdentifyEvent::SendBack { result: Err(ref err), ref peer_id } =>
IdentifyEvent::Error { peer_id, error } =>
debug!(target: "sub-libp2p", "Error when sending back identify info \
tomaka marked this conversation as resolved.
Show resolved Hide resolved
to {:?} => {}", peer_id, err),
IdentifyEvent::SendBack { .. } => {}
to {:?} => {}", peer_id, error),
IdentifyEvent::Sent { .. } => {}
}
},
Async::Ready(NetworkBehaviourAction::DialAddress { address }) =>
Expand Down
10 changes: 5 additions & 5 deletions core/network/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn build_transport(
#[cfg(not(target_os = "unknown"))]
let transport = transport.and_then(move |stream, endpoint| {
let upgrade = core::upgrade::SelectUpgrade::new(noise_config, secio_config);
core::upgrade::apply(stream, upgrade, endpoint)
core::upgrade::apply(stream, upgrade, endpoint, upgrade::Version::V1)
.and_then(|out| match out {
// We negotiated noise
EitherOutput::First((remote_id, out)) => {
Expand All @@ -101,8 +101,8 @@ pub fn build_transport(
Ok((EitherOutput::First(out), remote_key.into_peer_id()))
}
// We negotiated secio
EitherOutput::Second(out) =>
Ok((EitherOutput::Second(out.stream), out.remote_key.into_peer_id()))
EitherOutput::Second((remote_id, out)) =>
Ok((EitherOutput::Second(out), remote_id))
})
});

Expand All @@ -120,11 +120,11 @@ pub fn build_transport(
.map_inbound(move |muxer| (peer_id, muxer))
.map_outbound(move |muxer| (peer_id2, muxer));

core::upgrade::apply(stream, upgrade, endpoint)
core::upgrade::apply(stream, upgrade, endpoint, upgrade::Version::V1)
.map(|(id, muxer)| (id, core::muxing::StreamMuxerBox::new(muxer)))
})

.with_timeout(Duration::from_secs(20))
.timeout(Duration::from_secs(20))
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))
.boxed();

Expand Down
2 changes: 1 addition & 1 deletion core/peerset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"

[dependencies]
futures-preview = "0.3.0-alpha.19"
libp2p = { version = "0.12.0", default-features = false }
libp2p = { version = "0.13.0", default-features = false }
linked-hash-map = "0.5.2"
log = "0.4.8"
lru-cache = "0.1.2"
Expand Down
2 changes: 1 addition & 1 deletion core/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parking_lot = "0.9.0"
futures01 = { package = "futures", version = "0.1" }
futures-preview = { version = "0.3.0-alpha.19", features = ["compat"] }
futures-timer = "0.4.0"
libp2p = { version = "0.12.0", default-features = false, features = ["libp2p-websocket"] }
libp2p = { version = "0.13.0", default-features = false, features = ["libp2p-websocket"] }
log = "0.4.8"
rand = "0.7.2"
serde = { version = "1.0.101", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion core/telemetry/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl TelemetryWorker {

let transport = transport
.map((|inner, _| Compat01As03Sink::new(inner)) as fn(_, _) -> _)
.with_timeout(CONNECT_TIMEOUT);
.timeout(CONNECT_TIMEOUT);

TelemetryWorker {
nodes: endpoints.into_iter().map(|(addr, verbosity)| {
Expand Down
2 changes: 1 addition & 1 deletion node/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ transaction-factory = { path = "../../test-utils/transaction-factory", optional
ctrlc = { version = "3.1.3", features = ["termination"], optional = true }

# WASM-specific dependencies
libp2p = { version = "0.12.0", default-features = false, optional = true }
libp2p = { version = "0.13.0", default-features = false, optional = true }
clear_on_drop = { version = "0.2.3", features = ["no_cc"], optional = true } # Imported just for the `no_cc` feature
console_error_panic_hook = { version = "0.1.1", optional = true }
console_log = { version = "0.1.2", optional = true }
Expand Down