Skip to content

Commit

Permalink
Merge pull request #2101 from b-zee/feat-update-libp2p-0.54.1
Browse files Browse the repository at this point in the history
feat(global): update libp2p to 0.54.1
  • Loading branch information
maqi authored Sep 11, 2024
2 parents d6b55bc + 02ce072 commit 35eb5f6
Show file tree
Hide file tree
Showing 19 changed files with 107 additions and 125 deletions.
172 changes: 72 additions & 100 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion autonomi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ transfers = []
bip39 = "2.0.0"
bls = { package = "blsttc", version = "8.0.1" }
bytes = { version = "1.0.1", features = ["serde"] }
libp2p = "0.53"
libp2p = "0.54.1"
rand = "0.8.5"
rmp-serde = "1.1.1"
self_encryption = "~0.29.0"
Expand Down
2 changes: 1 addition & 1 deletion nat-detection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ clap = { version = "4.5.4", features = ["derive"] }
clap-verbosity-flag = "2.2.0"
color-eyre = { version = "0.6", default-features = false }
futures = "~0.3.13"
libp2p = { version = "0.53", features = [
libp2p = { version = "0.54.1", features = [
"tokio",
"tcp",
"noise",
Expand Down
12 changes: 8 additions & 4 deletions nat-detection/src/behaviour/identify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ use crate::{behaviour::PROTOCOL_VERSION, App};
impl App {
pub(crate) fn on_event_identify(&mut self, event: identify::Event) {
match event {
identify::Event::Received { peer_id, info } => {
identify::Event::Received {
peer_id,
info,
connection_id,
} => {
debug!(
%peer_id,
protocols=?info.protocols,
Expand All @@ -18,7 +22,7 @@ impl App {

// Disconnect if peer has incompatible protocol version.
if info.protocol_version != PROTOCOL_VERSION {
warn!(%peer_id, "Incompatible protocol version. Disconnecting from peer.");
warn!(conn_id=%connection_id, %peer_id, "Incompatible protocol version. Disconnecting from peer.");
let _ = self.swarm.disconnect_peer_id(peer_id);
return;
}
Expand All @@ -29,12 +33,12 @@ impl App {
.iter()
.any(|p| *p == autonat::DEFAULT_PROTOCOL_NAME)
{
warn!(%peer_id, "Peer does not support AutoNAT. Disconnecting from peer.");
warn!(conn_id=%connection_id, %peer_id, "Peer does not support AutoNAT. Disconnecting from peer.");
let _ = self.swarm.disconnect_peer_id(peer_id);
return;
}

info!(%peer_id, "Received peer info: confirmed it supports AutoNAT");
info!(conn_id=%connection_id, %peer_id, "Received peer info: confirmed it supports AutoNAT");

// If we're a client and the peer has (a) global listen address(es),
// add it as an AutoNAT server.
Expand Down
2 changes: 1 addition & 1 deletion sn_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dirs-next = "~2.0.0"
futures = "~0.3.13"
hex = "~0.4.3"
indicatif = { version = "0.17.5", features = ["tokio"] }
libp2p = { version = "0.53", features = ["identify", "kad"] }
libp2p = { version = "0.54.1", features = ["identify", "kad"] }
rand = "0.8.5"
rayon = "1.8.0"
reqwest = { version = "0.12.2", default-features = false, features = [
Expand Down
2 changes: 1 addition & 1 deletion sn_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dashmap = "~6.1.0"
futures = "~0.3.13"
hex = "~0.4.3"
itertools = "~0.12.1"
libp2p = { version = "0.53", features = ["identify"] }
libp2p = { version = "0.54.1", features = ["identify"] }
petgraph = { version = "0.6.4", features = ["serde-1"] }
prometheus-client = { version = "0.22", optional = true }
rand = { version = "~0.8.5", features = ["small_rng"] }
Expand Down
4 changes: 2 additions & 2 deletions sn_networking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ encrypt-records = []

[dependencies]
lazy_static = "~1.4.0"
libp2p = { version = "0.53", features = [
libp2p = { version = "0.54.1", features = [
"tokio",
"dns",
"kad",
Expand Down Expand Up @@ -93,7 +93,7 @@ crate-type = ["cdylib", "rlib"]

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.12", features = ["js"] }
libp2p = { version = "0.53", features = [
libp2p = { version = "0.54.1", features = [
"tokio",
"dns",
"kad",
Expand Down
2 changes: 1 addition & 1 deletion sn_networking/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ impl SwarmDriver {
if let Some(distance) = range.0.ilog2() {
let peers_in_kbucket = kbucket
.iter()
.map(|peer_entry| peer_entry.node.key.clone().into_preimage())
.map(|peer_entry| (*peer_entry.node.key).into_preimage())
.collect::<Vec<PeerId>>();
let _ = ilog2_kbuckets.insert(distance, peers_in_kbucket);
} else {
Expand Down
6 changes: 4 additions & 2 deletions sn_networking/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ pub(crate) const CLOSET_RECORD_CHECK_INTERVAL: Duration = Duration::from_secs(15
/// Interval over which we query relay manager to check if we can make any more reservations.
pub(crate) const RELAY_MANAGER_RESERVATION_INTERVAL: Duration = Duration::from_secs(30);

const KAD_STREAM_PROTOCOL_ID: StreamProtocol = StreamProtocol::new("/autonomi/kad/1.0.0");

/// The ways in which the Get Closest queries are used.
pub(crate) enum PendingGetClosestType {
/// The network discovery method is present at the networking layer
Expand Down Expand Up @@ -314,7 +316,7 @@ impl NetworkBuilder {
///
/// Returns an error if there is a problem initializing the mDNS behaviour.
pub fn build_node(self) -> Result<(Network, mpsc::Receiver<NetworkEvent>, SwarmDriver)> {
let mut kad_cfg = kad::Config::default();
let mut kad_cfg = kad::Config::new(KAD_STREAM_PROTOCOL_ID);
let _ = kad_cfg
.set_kbucket_inserts(libp2p::kad::BucketInserts::Manual)
// how often a node will replicate records that it has stored, aka copying the key-value pair to other nodes
Expand Down Expand Up @@ -399,7 +401,7 @@ impl NetworkBuilder {
pub fn build_client(self) -> Result<(Network, mpsc::Receiver<NetworkEvent>, SwarmDriver)> {
// Create a Kademlia behaviour for client mode, i.e. set req/resp protocol
// to outbound-only mode and don't listen on any address
let mut kad_cfg = kad::Config::default(); // default query timeout is 60 secs
let mut kad_cfg = kad::Config::new(KAD_STREAM_PROTOCOL_ID); // default query timeout is 60 secs

// 1mb packet size
let _ = kad_cfg
Expand Down
4 changes: 2 additions & 2 deletions sn_networking/src/event/kad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ impl SwarmDriver {
// following criteria:
// 1, `stats.num_pending()` is 0
// 2, `stats.duration()` is longer than a defined period
current_closest.extend(closest_peers.peers.clone());
current_closest.extend(closest_peers.peers.iter().map(|i| i.peer_id));
if current_closest.len() >= usize::from(K_VALUE) || step.last {
let (get_closest_type, current_closest) = entry.remove();
match get_closest_type {
Expand Down Expand Up @@ -101,7 +101,7 @@ impl SwarmDriver {
// Trust them and leave for the caller to check whether they are enough.
match err {
GetClosestPeersError::Timeout { ref peers, .. } => {
current_closest.extend(peers);
current_closest.extend(peers.iter().map(|i| i.peer_id));
}
}

Expand Down
8 changes: 6 additions & 2 deletions sn_networking/src/event/swarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ impl SwarmDriver {
event_string = "identify";

match *iden {
libp2p::identify::Event::Received { peer_id, info } => {
debug!(%peer_id, ?info, "identify: received info");
libp2p::identify::Event::Received {
peer_id,
info,
connection_id,
} => {
debug!(conn_id=%connection_id, %peer_id, ?info, "identify: received info");

if info.protocol_version != IDENTIFY_PROTOCOL_STR.to_string() {
warn!(?info.protocol_version, "identify: {peer_id:?} does not have the same protocol. Our IDENTIFY_PROTOCOL_STR: {:?}", IDENTIFY_PROTOCOL_STR.as_str());
Expand Down
2 changes: 1 addition & 1 deletion sn_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ file-rotate = "0.7.3"
futures = "~0.3.13"
hex = "~0.4.3"
itertools = "~0.12.1"
libp2p = { version = "0.53", features = ["tokio", "dns", "kad", "macros"] }
libp2p = { version = "0.54.1", features = ["tokio", "dns", "kad", "macros"] }
prometheus-client = { version = "0.22", optional = true }
# watch out updating this, protoc compiler needs to be installed on all build systems
# arm builds + musl are very problematic
Expand Down
2 changes: 1 addition & 1 deletion sn_node_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ colored = "2.0.4"
color-eyre = "~0.6"
dirs-next = "2.0.0"
indicatif = { version = "0.17.5", features = ["tokio"] }
libp2p = { version = "0.53", features = [] }
libp2p = { version = "0.54.1", features = [] }
libp2p-identity = { version = "0.2.7", features = ["rand"] }
prost = { version = "0.9" }
rand = "0.8.5"
Expand Down
2 changes: 1 addition & 1 deletion sn_node_rpc_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bls = { package = "blsttc", version = "8.0.1" }
clap = { version = "4.2.1", features = ["derive"] }
color-eyre = "0.6.2"
hex = "~0.4.3"
libp2p = { version="0.53", features = ["kad"]}
libp2p = { version = "0.54.1", features = ["kad"]}
libp2p-identity = { version="0.2.7", features = ["rand"] }
sn_client = { path = "../sn_client", version = "0.110.0" }
sn_logging = { path = "../sn_logging", version = "0.2.33" }
Expand Down
2 changes: 1 addition & 1 deletion sn_peers_acquisition/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ websockets = []
[dependencies]
clap = { version = "4.2.1", features = ["derive", "env"] }
lazy_static = "~1.4.0"
libp2p = { version="0.53", features = [] }
libp2p = { version = "0.54.1", features = [] }
rand = "0.8.5"
reqwest = { version="0.12.2", default-features=false, features = ["rustls-tls"] }
sn_protocol = { path = "../sn_protocol", version = "0.17.8", optional = true}
Expand Down
2 changes: 1 addition & 1 deletion sn_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ custom_debug = "~0.6.1"
dirs-next = "~2.0.0"
hex = "~0.4.3"
lazy_static = "1.4.0"
libp2p = { version="0.53", features = ["identify", "kad"] }
libp2p = { version = "0.54.1", features = ["identify", "kad"] }
rmp-serde = "1.1.1"
serde = { version = "1.0.133", features = [ "derive", "rc" ]}
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion sn_service_management/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version = "0.3.11"
[dependencies]
async-trait = "0.1"
dirs-next = "2.0.0"
libp2p = { version = "0.53", features = ["kad"] }
libp2p = { version = "0.54.1", features = ["kad"] }
libp2p-identity = { version = "0.2.7", features = ["rand"] }
prost = { version = "0.9" }
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion sn_transfers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ custom_debug = "~0.6.1"
dirs-next = "~2.0.0"
hex = "~0.4.3"
lazy_static = "~1.4.0"
libp2p = { version = "0.53", features = ["identify", "kad"] }
libp2p = { version = "0.54.1", features = ["identify", "kad"] }
rand = { version = "~0.8.5", features = ["small_rng"] }
rmp-serde = "1.1.1"
secrecy = "0.8.0"
Expand Down
2 changes: 1 addition & 1 deletion test_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ version = "0.4.4"
[dependencies]
color-eyre = "~0.6.2"
dirs-next = "~2.0.0"
libp2p = { version="0.53", features = ["identify", "kad"] }
libp2p = { version = "0.54.1", features = ["identify", "kad"] }
serde = { version = "1.0.133", features = [ "derive"]}
serde_json = "1.0"

0 comments on commit 35eb5f6

Please sign in to comment.