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

Commit

Permalink
Upgrade libp2p to 0.46.1 (paritytech#11787)
Browse files Browse the repository at this point in the history
* Update libp2p to 0.46.0

* Update libp2p to 0.46.1

* Fix telemetry initialization

* Fix tests
  • Loading branch information
kpp authored and DaviRain-Su committed Aug 23, 2022
1 parent d0de3d1 commit 87da8b9
Show file tree
Hide file tree
Showing 19 changed files with 151 additions and 274 deletions.
362 changes: 122 additions & 240 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
futures = "0.3.21"
futures-timer = "3.0.1"
ip_network = "0.4.1"
libp2p = { version = "0.45.1", default-features = false, features = ["kad"] }
libp2p = { version = "0.46.1", default-features = false, features = ["kad"] }
log = "0.4.17"
prost = "0.10"
rand = "0.7.2"
Expand Down
2 changes: 1 addition & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ clap = { version = "3.1.18", features = ["derive"] }
fdlimit = "0.2.1"
futures = "0.3.21"
hex = "0.4.2"
libp2p = "0.45.1"
libp2p = "0.46.1"
log = "0.4.17"
names = { version = "0.13.0", default-features = false }
parity-scale-codec = "3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion client/consensus/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
async-trait = "0.1.42"
futures = { version = "0.3.21", features = ["thread-pool"] }
futures-timer = "3.0.1"
libp2p = { version = "0.45.1", default-features = false }
libp2p = { version = "0.46.1", default-features = false }
log = "0.4.17"
parking_lot = "0.12.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion client/network-gossip/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
ahash = "0.7.6"
futures = "0.3.21"
futures-timer = "3.0.1"
libp2p = { version = "0.45.1", default-features = false }
libp2p = { version = "0.46.1", default-features = false }
log = "0.4.17"
lru = "0.7.5"
tracing = "0.1.29"
Expand Down
2 changes: 1 addition & 1 deletion client/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ futures = "0.3.21"
futures-timer = "3.0.2"
hex = "0.4.0"
ip_network = "0.4.1"
libp2p = "0.45.1"
libp2p = "0.46.1"
linked_hash_set = "0.1.3"
linked-hash-map = "0.5.4"
log = "0.4.17"
Expand Down
2 changes: 1 addition & 1 deletion client/network/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
] }
futures = "0.3.21"
libp2p = "0.45.1"
libp2p = "0.46.1"
smallvec = "1.8.0"
sc-peerset = { version = "4.0.0-dev", path = "../../peerset" }
2 changes: 1 addition & 1 deletion client/network/light/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
"derive",
] }
futures = "0.3.21"
libp2p = "0.45.1"
libp2p = "0.46.1"
log = "0.4.16"
prost = "0.10"
sp-blockchain = { version = "4.0.0-dev", path = "../../../primitives/blockchain" }
Expand Down
6 changes: 3 additions & 3 deletions client/network/src/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ use futures_timer::Delay;
use ip_network::IpNetwork;
use libp2p::{
core::{
connection::{ConnectionId, ListenerId},
ConnectedPoint, Multiaddr, PeerId, PublicKey,
connection::ConnectionId, transport::ListenerId, ConnectedPoint, Multiaddr, PeerId,
PublicKey,
},
kad::{
handler::KademliaHandlerProto,
Expand Down Expand Up @@ -1030,7 +1030,7 @@ mod tests {
let noise_keys =
noise::Keypair::<noise::X25519Spec>::new().into_authentic(&keypair).unwrap();

let transport = MemoryTransport
let transport = MemoryTransport::new()
.upgrade(upgrade::Version::V1)
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
.multiplex(yamux::YamuxConfig::default())
Expand Down
5 changes: 2 additions & 3 deletions client/network/src/peer_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ use fnv::FnvHashMap;
use futures::prelude::*;
use libp2p::{
core::{
connection::{ConnectionId, ListenerId},
either::EitherOutput,
ConnectedPoint, PeerId, PublicKey,
connection::ConnectionId, either::EitherOutput, transport::ListenerId, ConnectedPoint,
PeerId, PublicKey,
},
identify::{Identify, IdentifyConfig, IdentifyEvent, IdentifyInfo},
ping::{Ping, PingConfig, PingEvent, PingSuccess},
Expand Down
5 changes: 1 addition & 4 deletions client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ use bytes::Bytes;
use codec::{Decode, DecodeAll, Encode};
use futures::{channel::oneshot, prelude::*};
use libp2p::{
core::{
connection::{ConnectionId, ListenerId},
ConnectedPoint,
},
core::{connection::ConnectionId, transport::ListenerId, ConnectedPoint},
request_response::OutboundFailure,
swarm::{
ConnectionHandler, IntoConnectionHandler, NetworkBehaviour, NetworkBehaviourAction,
Expand Down
6 changes: 3 additions & 3 deletions client/network/src/protocol/notifications/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use crate::protocol::notifications::{Notifications, NotificationsOut, ProtocolCo
use futures::prelude::*;
use libp2p::{
core::{
connection::{ConnectionId, ListenerId},
transport::MemoryTransport,
connection::ConnectionId,
transport::{ListenerId, MemoryTransport},
upgrade, ConnectedPoint,
},
identity, noise,
Expand Down Expand Up @@ -56,7 +56,7 @@ fn build_nodes() -> (Swarm<CustomProtoWithAddr>, Swarm<CustomProtoWithAddr>) {
let noise_keys =
noise::Keypair::<noise::X25519Spec>::new().into_authentic(&keypair).unwrap();

let transport = MemoryTransport
let transport = MemoryTransport::new()
.upgrade(upgrade::Version::V1)
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
.multiplex(yamux::YamuxConfig::default())
Expand Down
7 changes: 2 additions & 5 deletions client/network/src/request_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ use futures::{
prelude::*,
};
use libp2p::{
core::{
connection::{ConnectionId, ListenerId},
ConnectedPoint, Multiaddr, PeerId,
},
core::{connection::ConnectionId, transport::ListenerId, ConnectedPoint, Multiaddr, PeerId},
request_response::{
handler::RequestResponseHandler, ProtocolSupport, RequestResponse, RequestResponseCodec,
RequestResponseConfig, RequestResponseEvent, RequestResponseMessage, ResponseChannel,
Expand Down Expand Up @@ -968,7 +965,7 @@ mod tests {
let noise_keys =
noise::Keypair::<noise::X25519Spec>::new().into_authentic(&keypair).unwrap();

let transport = MemoryTransport
let transport = MemoryTransport::new()
.upgrade(upgrade::Version::V1)
.authenticate(noise::NoiseConfig::xx(noise_keys).into_authenticated())
.multiplex(libp2p::yamux::YamuxConfig::default())
Expand Down
9 changes: 5 additions & 4 deletions client/network/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ pub fn build_transport(
) -> (Boxed<(PeerId, StreamMuxerBox)>, Arc<BandwidthSinks>) {
// Build the base layer of the transport.
let transport = if !memory_only {
let desktop_trans = tcp::TcpConfig::new().nodelay(true);
let tcp_config = tcp::GenTcpConfig::new().nodelay(true);
let desktop_trans = tcp::TcpTransport::new(tcp_config.clone());
let desktop_trans = websocket::WsConfig::new(desktop_trans)
.or_transport(tcp::TcpConfig::new().nodelay(true));
.or_transport(tcp::TcpTransport::new(tcp_config.clone()));
let dns_init = futures::executor::block_on(dns::DnsConfig::system(desktop_trans));
EitherTransport::Left(if let Ok(dns) = dns_init {
EitherTransport::Left(dns)
} else {
let desktop_trans = tcp::TcpConfig::new().nodelay(true);
let desktop_trans = tcp::TcpTransport::new(tcp_config.clone());
let desktop_trans = websocket::WsConfig::new(desktop_trans)
.or_transport(tcp::TcpConfig::new().nodelay(true));
.or_transport(tcp::TcpTransport::new(tcp_config));
EitherTransport::Right(desktop_trans.map_err(dns::DnsErr::Transport))
})
} else {
Expand Down
2 changes: 1 addition & 1 deletion client/network/sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ codec = { package = "parity-scale-codec", version = "3.0.0", features = [
] }
either = "1.5.3"
futures = "0.3.21"
libp2p = "0.45.1"
libp2p = "0.46.1"
log = "0.4.17"
lru = "0.7.5"
prost = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion client/network/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async-std = "1.11.0"
async-trait = "0.1.50"
futures = "0.3.21"
futures-timer = "3.0.1"
libp2p = { version = "0.45.1", default-features = false }
libp2p = { version = "0.46.1", default-features = false }
log = "0.4.17"
parking_lot = "0.12.0"
rand = "0.7.2"
Expand Down
2 changes: 1 addition & 1 deletion client/peerset/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
futures = "0.3.21"
libp2p = { version = "0.45.1", default-features = false }
libp2p = { version = "0.46.1", default-features = false }
log = "0.4.17"
serde_json = "1.0.79"
wasm-timer = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion client/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
chrono = "0.4.19"
futures = "0.3.21"
libp2p = { version = "0.45.1", default-features = false, features = ["dns-async-std", "tcp-async-io", "wasm-ext", "websocket"] }
libp2p = { version = "0.46.1", default-features = false, features = ["dns-async-std", "tcp-async-io", "wasm-ext", "websocket"] }
log = "0.4.17"
parking_lot = "0.12.0"
pin-project = "1.0.10"
Expand Down
3 changes: 2 additions & 1 deletion client/telemetry/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const CONNECT_TIMEOUT: Duration = Duration::from_secs(20);

pub(crate) fn initialize_transport() -> Result<WsTrans, io::Error> {
let transport = {
let inner = block_on(libp2p::dns::DnsConfig::system(libp2p::tcp::TcpConfig::new()))?;
let tcp_transport = libp2p::tcp::TcpTransport::new(libp2p::tcp::GenTcpConfig::new());
let inner = block_on(libp2p::dns::DnsConfig::system(tcp_transport))?;
libp2p::websocket::framed::WsConfig::new(inner).and_then(|connec, _| {
let connec = connec
.with(|item| {
Expand Down

0 comments on commit 87da8b9

Please sign in to comment.