Skip to content

Commit

Permalink
feat(deps): upgrade libp2p to 0.53
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuef authored and Benno committed Nov 6, 2023
1 parent e33f47a commit 4798b50
Show file tree
Hide file tree
Showing 15 changed files with 320 additions and 304 deletions.
Binary file added .DS_Store
Binary file not shown.
556 changes: 289 additions & 267 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ name="metrics"
clap = { version = "4.2.1", features = ["cargo", "string"]}
color-eyre = "~0.6.2"
dirs-next = "~2.0.0"
regex = "~1.9.6"
regex = "1.10"
serde = { version = "1.0.133", features = [ "derive"]}
serde_yaml = "0.9.25"
url = "2.4.1"
Expand Down
2 changes: 1 addition & 1 deletion sn_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ color-eyre = "~0.6"
dirs-next = "~2.0.0"
hex = "~0.4.3"
indicatif = { version = "0.17.5", features = ["tokio"] }
libp2p = { version="0.52", features = ["identify", "kad"] }
libp2p = { version="0.53", features = ["identify", "kad"] }
rayon = "1.8.0"
reqwest = { version="0.11.18", default-features=false, features = ["rustls"] }
sn_build_info = { path="../sn_build_info", version = "0.1.2" }
Expand Down
4 changes: 2 additions & 2 deletions sn_client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ futures = "~0.3.13"
hex = "~0.4.3"
indicatif = { version = "0.17.5", features = ["tokio"] }
itertools = "~0.11.0"
libp2p = { version="0.52", features = ["identify"] }
prometheus-client = { version = "0.21.2", optional = true }
libp2p = { version="0.53" , features = ["identify"] }
prometheus-client = { version = "0.22", optional = true }
rand = { version = "~0.8.5", features = ["small_rng"] }
rayon = "1.8.0"
self_encryption = "~0.28.5"
Expand Down
10 changes: 4 additions & 6 deletions sn_networking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ version = "0.9.21"
[features]
default=[]
local-discovery=["libp2p/mdns"]
quic=["libp2p-quic"]
open-metrics=["libp2p-metrics", "prometheus-client", "hyper", "sysinfo"]
quic=["libp2p/quic"]
open-metrics=["libp2p/metrics", "prometheus-client", "hyper", "sysinfo"]

[dependencies]
async-trait = "0.1"
Expand All @@ -23,10 +23,8 @@ futures = "~0.3.13"
hyper = { version = "0.14", features = ["server", "tcp", "http1"], optional = true}
itertools = "~0.11.0"
custom_debug = "~0.5.0"
libp2p = { version="0.52", features = ["tokio", "dns", "kad", "macros", "request-response", "cbor","identify", "autonat", "noise", "tcp", "yamux", "gossipsub"] }
libp2p-metrics = { version = "0.13.1", features = ["identify", "kad", "gossipsub"], optional = true }
libp2p-quic = { version = "0.9.2", features = ["tokio"], optional = true }
prometheus-client = { version = "0.21.2", optional = true }
libp2p = { version="0.53" , features = ["tokio", "dns", "kad", "macros", "request-response", "cbor","identify", "autonat", "noise", "tcp", "yamux", "gossipsub"] }
prometheus-client = { version = "0.22", optional = true }
rand = { version = "~0.8.5", features = ["small_rng"] }
rmp-serde = "1.1.1"
serde = { version = "1.0.133", features = [ "derive", "rc" ]}
Expand Down
16 changes: 8 additions & 8 deletions sn_networking/src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ use futures::StreamExt;
use libp2p::core::muxing::StreamMuxerBox;
#[cfg(feature = "local-discovery")]
use libp2p::mdns;
#[cfg(feature = "quic")]
use libp2p::quic;
use libp2p::{
autonat,
identity::Keypair,
kad::{self, QueryId, Record, K_VALUE},
multiaddr::Protocol,
request_response::{self, Config as RequestResponseConfig, ProtocolSupport, RequestId},
request_response::{self, Config as RequestResponseConfig, OutboundRequestId, ProtocolSupport},
swarm::{
behaviour::toggle::Toggle,
dial_opts::{DialOpts, PeerCondition},
DialError, NetworkBehaviour, StreamProtocol, Swarm,
},
Multiaddr, PeerId, Transport,
};
#[cfg(feature = "quic")]
use libp2p_quic as quic;
#[cfg(feature = "open-metrics")]
use prometheus_client::registry::Registry;
use sn_protocol::{
Expand Down Expand Up @@ -313,9 +313,8 @@ impl NetworkBuilder {

// RequestResponse Behaviour
let request_response = {
let mut cfg = RequestResponseConfig::default();
let _ =
cfg.set_request_timeout(self.request_timeout.unwrap_or(REQUEST_TIMEOUT_DEFAULT_S));
let cfg = RequestResponseConfig::default()
.with_request_timeout(self.request_timeout.unwrap_or(REQUEST_TIMEOUT_DEFAULT_S));

request_response::cbor::Behaviour::new(
[(
Expand Down Expand Up @@ -387,7 +386,7 @@ impl NetworkBuilder {
.boxed();

#[cfg(feature = "quic")]
let mut transport = libp2p_quic::tokio::Transport::new(quic::Config::new(&self.keypair))
let mut transport = libp2p::quic::tokio::Transport::new(quic::Config::new(&self.keypair))
.map(|(peer_id, muxer), _| (peer_id, StreamMuxerBox::new(muxer)))
.boxed();

Expand Down Expand Up @@ -499,7 +498,8 @@ pub struct SwarmDriver {

/// Trackers for underlying behaviour related events
pub(crate) pending_get_closest_peers: PendingGetClosest,
pub(crate) pending_requests: HashMap<RequestId, Option<oneshot::Sender<Result<Response>>>>,
pub(crate) pending_requests:
HashMap<OutboundRequestId, Option<oneshot::Sender<Result<Response>>>>,
pub(crate) pending_get_record: PendingGetRecord,
/// A list of the most recent peers we have dialed ourselves.
pub(crate) dialed_peers: CircularVec<PeerId>,
Expand Down
4 changes: 2 additions & 2 deletions sn_networking/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use libp2p::{
gossipsub::{PublishError, SubscriptionError},
kad::{self, Record},
request_response::{OutboundFailure, RequestId},
request_response::{OutboundFailure, OutboundRequestId},
swarm::DialError,
PeerId, TransportError,
};
Expand Down Expand Up @@ -42,7 +42,7 @@ pub enum Error {
InternalMsgChannelDropped,

#[error("Response received for a request not found in our local tracking map: {0}")]
ReceivedResponseDropped(RequestId),
ReceivedResponseDropped(OutboundRequestId),

#[error("Outgoing response has been dropped due to a conn being closed or timeout: {0}")]
OutgoingResponseDropped(Response),
Expand Down
9 changes: 3 additions & 6 deletions sn_networking/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use custom_debug::Debug as CustomDebug;
use itertools::Itertools;
#[cfg(feature = "local-discovery")]
use libp2p::mdns;
#[cfg(feature = "open-metrics")]
use libp2p::metrics::Recorder;
use libp2p::{
autonat::{self, NatStatus},
kad::{
Expand All @@ -29,8 +31,6 @@ use libp2p::{
swarm::SwarmEvent,
Multiaddr, PeerId,
};
#[cfg(feature = "open-metrics")]
use libp2p_metrics::Recorder;

use sn_protocol::{
messages::{Request, Response},
Expand Down Expand Up @@ -204,10 +204,7 @@ impl Debug for NetworkEvent {

impl SwarmDriver {
/// Handle `SwarmEvents`
pub(super) fn handle_swarm_events<EventError: std::error::Error>(
&mut self,
event: SwarmEvent<NodeEvent, EventError>,
) -> Result<()> {
pub(super) fn handle_swarm_events(&mut self, event: SwarmEvent<NodeEvent>) -> Result<()> {
// This does not record all the events. `SwarmEvent::Behaviour(_)` are skipped. Hence `.record()` has to be
// called individually on each behaviour.
#[cfg(feature = "open-metrics")]
Expand Down
6 changes: 3 additions & 3 deletions sn_networking/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use libp2p_metrics::{Metrics as Libp2pMetrics, Recorder};
use libp2p::metrics::{Metrics as Libp2pMetrics, Recorder};
use prometheus_client::{metrics::gauge::Gauge, registry::Registry};
use std::time::Duration;
use sysinfo::{Pid, PidExt, ProcessExt, ProcessRefreshKind, System, SystemExt};
Expand Down Expand Up @@ -113,8 +113,8 @@ impl Recorder<libp2p::identify::Event> for NetworkMetrics {
}
}

impl<TBvEv, THandleErr> Recorder<libp2p::swarm::SwarmEvent<TBvEv, THandleErr>> for NetworkMetrics {
fn record(&self, event: &libp2p::swarm::SwarmEvent<TBvEv, THandleErr>) {
impl<T> Recorder<libp2p::swarm::SwarmEvent<T>> for NetworkMetrics {
fn record(&self, event: &libp2p::swarm::SwarmEvent<T>) {
self.libp2p_metrics.record(event);
}
}
3 changes: 1 addition & 2 deletions sn_networking/src/record_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ use crate::event::NetworkEvent;
use libp2p::{
identity::PeerId,
kad::{
record::{Key, ProviderRecord, Record},
store::{Error, RecordStore, Result},
KBucketDistance as Distance, KBucketKey,
KBucketDistance as Distance, KBucketKey, ProviderRecord, Record, RecordKey as Key,
},
};
#[cfg(feature = "open-metrics")]
Expand Down
4 changes: 2 additions & 2 deletions sn_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ futures = "~0.3.13"
hex = "~0.4.3"
itertools = "~0.11.0"
lazy_static = "~1.4.0"
libp2p = { version="0.52", features = ["tokio", "dns", "kad", "macros", "autonat"] }
prometheus-client = { version = "0.21.2", optional = true }
libp2p = { version="0.53" , features = ["tokio", "dns", "kad", "macros", "autonat"] }
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
prost = { version = "0.9" }
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 @@ network-contacts = ["reqwest", "tokio", "url"]
[dependencies]
clap = { version = "4.2.1", features = ["derive", "env"] }
color-eyre = "~0.6"
libp2p = { version="0.52", features = [] }
libp2p = { version="0.53" , features = [] }
reqwest = { version="0.11.18", default-features=false, features = ["rustls-tls"], optional = true }
tokio = { version = "1.32.0", optional = true}
tracing = { version = "~0.1.26" }
Expand Down
2 changes: 1 addition & 1 deletion sn_protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ bytes = { version = "1.0.1", features = ["serde"] }
crdts = { version = "7.3", default-features = false, features = ["merkle"] }
custom_debug = "~0.5.0"
hex = "~0.4.3"
libp2p = { version="0.52", features = ["identify", "kad"] }
libp2p = { version="0.53" , features = ["identify", "kad"] }
rmp-serde = "1.1.1"
serde = { version = "1.0.133", features = [ "derive", "rc" ]}
sha2 = "0.10.7"
Expand Down
4 changes: 2 additions & 2 deletions sn_testnet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ color-eyre = "~0.6.0"
eyre = "~0.6.5"
clap = { version = "3.2.0", features = ["derive", "env"]}
dirs-next = "2.0.0"
libp2p = { version="0.52" }
libp2p = "0.53"
# watch out updating this, protoc compiler needs to be installed on all build systems
# arm builds + musl are very problematic
prost = { version = "0.9" }
regex = "~1.9.6"
regex = "1.10"
tonic = { version = "0.6.2" }
tracing = "~0.1.26"
tracing-core = "~0.1.21"
Expand Down

0 comments on commit 4798b50

Please sign in to comment.