From 2934414740e197f3d3ca4dfa66d85a78d9849093 Mon Sep 17 00:00:00 2001 From: Alexandru Vasile <60601340+lexnv@users.noreply.github.com> Date: Thu, 28 Nov 2024 11:16:06 +0200 Subject: [PATCH] BACKPORT-CONFLICT --- Cargo.lock | 6 ++++ Cargo.toml | 5 +++ prdoc/pr_6677.prdoc | 11 ++++++ substrate/client/network/src/litep2p/mod.rs | 40 ++++++++++++++++++++- 4 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 prdoc/pr_6677.prdoc diff --git a/Cargo.lock b/Cargo.lock index 7968ba6bff24..99f04626cfb7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8156,9 +8156,15 @@ dependencies = [ [[package]] name = "litep2p" +<<<<<<< HEAD version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f46c51c205264b834ceed95c8b195026e700494bc3991aaba3b4ea9e20626d9" +======= +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "569e7dbec8a0d4b08d30f4942cd579cfe8db5d3f83f8604abe61697c38d17e73" +>>>>>>> 51c3e95 (chore: Update litep2p to v0.8.2 (#6677)) dependencies = [ "async-trait", "bs58 0.4.0", diff --git a/Cargo.toml b/Cargo.toml index e5547b8a3e94..d8d6b9096e03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -815,8 +815,13 @@ linked-hash-map = { version = "0.5.4" } linked_hash_set = { version = "0.1.4" } linregress = { version = "0.5.1" } lite-json = { version = "0.2.0", default-features = false } +<<<<<<< HEAD litep2p = { version = "0.6.2" } log = { version = "0.4.21", default-features = false } +======= +litep2p = { version = "0.8.2", features = ["websocket"] } +log = { version = "0.4.22", default-features = false } +>>>>>>> 51c3e95 (chore: Update litep2p to v0.8.2 (#6677)) macro_magic = { version = "0.5.1" } maplit = { version = "1.0.2" } memmap2 = { version = "0.9.3" } diff --git a/prdoc/pr_6677.prdoc b/prdoc/pr_6677.prdoc new file mode 100644 index 000000000000..c6766889e68d --- /dev/null +++ b/prdoc/pr_6677.prdoc @@ -0,0 +1,11 @@ +title: 'chore: Update litep2p to v0.8.2' +doc: +- audience: Node Dev + description: |- + This includes a critical fix for debug release versions of litep2p (which are running in Kusama as validators). + + While at it, have stopped the oncall pain of alerts around `incoming_connections_total`. We can rethink the metric expose of litep2p in Q1. + +crates: +- name: sc-network + bump: minor diff --git a/substrate/client/network/src/litep2p/mod.rs b/substrate/client/network/src/litep2p/mod.rs index 34ca5b716101..7dcbc6c0dceb 100644 --- a/substrate/client/network/src/litep2p/mod.rs +++ b/substrate/client/network/src/litep2p/mod.rs @@ -949,7 +949,15 @@ impl NetworkBackend for Litep2pNetworkBac let direction = match endpoint { Endpoint::Dialer { .. } => "out", - Endpoint::Listener { .. } => "in", + Endpoint::Listener { .. } => { + // Increment incoming connections counter. + // + // Note: For litep2p these are represented by established negotiated connections, + // while for libp2p (legacy) these represent not-yet-negotiated connections. + metrics.incoming_connections_total.inc(); + + "in" + }, }; metrics.connections_opened_total.with_label_values(&[direction]).inc(); @@ -1006,12 +1014,42 @@ impl NetworkBackend for Litep2pNetworkBac "failed to dial peer at {address:?}: {error:?}", ); +<<<<<<< HEAD let reason = match error { Litep2pError::PeerIdMismatch(_, _) => "invalid-peer-id", Litep2pError::Timeout | Litep2pError::TransportError(_) | Litep2pError::IoError(_) | Litep2pError::WebSocket(_) => "transport-error", _ => "other", }; +======= + if let Some(metrics) = &self.metrics { + let reason = match error { + DialError::Timeout => "timeout", + DialError::AddressError(_) => "invalid-address", + DialError::DnsError(_) => "cannot-resolve-dns", + DialError::NegotiationError(error) => match error { + NegotiationError::Timeout => "timeout", + NegotiationError::PeerIdMissing => "missing-peer-id", + NegotiationError::StateMismatch => "state-mismatch", + NegotiationError::PeerIdMismatch(_,_) => "peer-id-missmatch", + NegotiationError::MultistreamSelectError(_) => "multistream-select-error", + NegotiationError::SnowError(_) => "noise-error", + NegotiationError::ParseError(_) => "parse-error", + NegotiationError::IoError(_) => "io-error", + NegotiationError::WebSocket(_) => "webscoket-error", + NegotiationError::BadSignature => "bad-signature", + } + }; + + metrics.pending_connections_errors_total.with_label_values(&[&reason]).inc(); + } + } + Some(Litep2pEvent::ListDialFailures { errors }) => { + log::debug!( + target: LOG_TARGET, + "failed to dial peer on multiple addresses {errors:?}", + ); +>>>>>>> 51c3e95 (chore: Update litep2p to v0.8.2 (#6677)) if let Some(metrics) = &self.metrics { metrics.pending_connections_errors_total.with_label_values(&[reason]).inc();