Skip to content

Commit 1904fe4

Browse files
authored
Merge branch 'master' into identity-k256
2 parents 890b151 + 37aa175 commit 1904fe4

24 files changed

+149
-156
lines changed

Cargo.lock

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,20 +86,20 @@ libp2p-identity = { version = "0.2.10" }
8686
libp2p-kad = { version = "0.47.0", path = "protocols/kad" }
8787
libp2p-mdns = { version = "0.47.0", path = "protocols/mdns" }
8888
libp2p-memory-connection-limits = { version = "0.4.0", path = "misc/memory-connection-limits" }
89-
libp2p-metrics = { version = "0.16.0", path = "misc/metrics" }
89+
libp2p-metrics = { version = "0.16.1", path = "misc/metrics" }
9090
libp2p-mplex = { version = "0.43.1", path = "muxers/mplex" }
9191
libp2p-noise = { version = "0.46.0", path = "transports/noise" }
9292
libp2p-perf = { version = "0.4.0", path = "protocols/perf" }
9393
libp2p-ping = { version = "0.46.0", path = "protocols/ping" }
9494
libp2p-plaintext = { version = "0.43.0", path = "transports/plaintext" }
9595
libp2p-pnet = { version = "0.26.0", path = "transports/pnet" }
9696
libp2p-quic = { version = "0.12.0", path = "transports/quic" }
97-
libp2p-relay = { version = "0.19.1", path = "protocols/relay" }
97+
libp2p-relay = { version = "0.20.0", path = "protocols/relay" }
9898
libp2p-rendezvous = { version = "0.16.0", path = "protocols/rendezvous" }
9999
libp2p-request-response = { version = "0.28.1", path = "protocols/request-response" }
100100
libp2p-server = { version = "0.12.6", path = "misc/server" }
101101
libp2p-stream = { version = "0.3.0-alpha", path = "protocols/stream" }
102-
libp2p-swarm = { version = "0.46.1", path = "swarm" }
102+
libp2p-swarm = { version = "0.47.0", path = "swarm" }
103103
libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-swarm-derive` may not be compatible with different `libp2p-swarm` non-breaking releases. E.g. `libp2p-swarm` might introduce a new enum variant `FromSwarm` (which is `#[non-exhaustive]`) in a non-breaking release. Older versions of `libp2p-swarm-derive` would not forward this enum variant within the `NetworkBehaviour` hierarchy. Thus the version pinning is required.
104104
libp2p-swarm-test = { version = "0.5.0", path = "swarm-test" }
105105
libp2p-tcp = { version = "0.43.0", path = "transports/tcp" }

ROADMAP.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Below is a high level roadmap for the rust-libp2p project.
44
Items are ordered by priority (high to low).
55

6-
This is a living document.
6+
This is a living document. We believe the roadmap should be shaped by the needs of our user community. Many of the items below are contributions made by downstream users.
77
Input is always welcome e.g. via GitHub issues or pull requests.
88

99
This is the roadmap of the Rust implementation of libp2p.

libp2p/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
- Introduce `libp2p-webrtc-websys` behind `webrtc-websys` feature flag.
33
See [PR 5819](https://github.com/libp2p/rust-libp2p/pull/5819).
44

5+
- Make the `*-websys` variants (`libp2p-webrtc-websys`, `libp2p-websocket-websys`, `libp2p-webtransport-websys`) only available on wasm32 target architecture.
6+
See [PR 5891](https://github.com/libp2p/rust-libp2p/pull/5891).
7+
58
## 0.55.0
69

710
- Raise MSRV to 1.83.0.

libp2p/Cargo.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ futures-timer = "3.0.2" # Explicit dependency to be used in `wasm-bindgen` featu
9999
getrandom = { workspace = true } # Explicit dependency to be used in `wasm-bindgen` feature
100100
# TODO feature flag?
101101
rw-stream-sink = { workspace = true }
102-
103102
libp2p-allow-block-list = { workspace = true }
104103
libp2p-autonat = { workspace = true, optional = true }
105104
libp2p-connection-limits = { workspace = true }
@@ -119,14 +118,16 @@ libp2p-relay = { workspace = true, optional = true }
119118
libp2p-rendezvous = { workspace = true, optional = true }
120119
libp2p-request-response = { workspace = true, optional = true }
121120
libp2p-swarm = { workspace = true }
122-
libp2p-webrtc-websys = { workspace = true, optional = true }
123-
libp2p-websocket-websys = { workspace = true, optional = true }
124-
libp2p-webtransport-websys = { workspace = true, optional = true }
125121
libp2p-yamux = { workspace = true, optional = true }
126122
multiaddr = { workspace = true }
127123
pin-project = "1.0.0"
128124
thiserror = { workspace = true }
129125

126+
[target.'cfg(target_arch = "wasm32")'.dependencies]
127+
libp2p-webrtc-websys = { workspace = true, optional = true }
128+
libp2p-websocket-websys = { workspace = true, optional = true }
129+
libp2p-webtransport-websys = { workspace = true, optional = true }
130+
130131
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
131132
libp2p-dns = { workspace = true, optional = true }
132133
libp2p-mdns = { workspace = true, optional = true }

libp2p/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,17 @@ pub use libp2p_uds as uds;
123123
#[cfg(not(target_arch = "wasm32"))]
124124
#[doc(inline)]
125125
pub use libp2p_upnp as upnp;
126-
#[cfg(feature = "webrtc-websys")]
126+
#[cfg(all(feature = "webrtc-websys", target_arch = "wasm32"))]
127127
#[doc(inline)]
128128
pub use libp2p_webrtc_websys as webrtc_websys;
129129
#[cfg(feature = "websocket")]
130130
#[cfg(not(target_arch = "wasm32"))]
131131
#[doc(inline)]
132132
pub use libp2p_websocket as websocket;
133-
#[cfg(feature = "websocket-websys")]
133+
#[cfg(all(feature = "websocket-websys", target_arch = "wasm32"))]
134134
#[doc(inline)]
135135
pub use libp2p_websocket_websys as websocket_websys;
136-
#[cfg(feature = "webtransport-websys")]
136+
#[cfg(all(feature = "webtransport-websys", target_arch = "wasm32"))]
137137
#[cfg_attr(docsrs, doc(cfg(feature = "webtransport-websys")))]
138138
#[doc(inline)]
139139
pub use libp2p_webtransport_websys as webtransport_websys;

libp2p/src/tutorials/ping.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@
205205
//! ## Idle connection timeout
206206
//!
207207
//! Now, for this example in particular, we need set the idle connection timeout.
208-
//! Otherwise, the connection will be closed immediately.
208+
//! The default connection timeout is 10 seconds.
209209
//!
210210
//! Whether you need to set this in your application too depends on your usecase.
211211
//! Typically, connections are kept alive if they are "in use" by a certain protocol.
212212
//! The ping protocol however is only an "auxiliary" kind of protocol.
213-
//! Thus, without any other behaviour in place, we would not be able to observe the pings.
213+
//! Thus, without any other behaviour in place, we would not be able to observe any pings after 10s.
214214
//!
215215
//! ```rust
216216
//! use std::{error::Error, time::Duration};
@@ -232,6 +232,9 @@
232232
//! yamux::Config::default,
233233
//! )?
234234
//! .with_behaviour(|_| ping::Behaviour::default())?
235+
//! .with_swarm_config(|cfg| {
236+
//! cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))
237+
//! }) // Allows us to observe pings indefinitely.
235238
//! .build();
236239
//!
237240
//! Ok(())
@@ -284,6 +287,9 @@
284287
//! yamux::Config::default,
285288
//! )?
286289
//! .with_behaviour(|_| ping::Behaviour::default())?
290+
//! .with_swarm_config(|cfg| {
291+
//! cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))
292+
//! }) // Allows us to observe pings indefinitely.
287293
//! .build();
288294
//!
289295
//! // Tell the swarm to listen on all interfaces and a random, OS-assigned
@@ -329,6 +335,9 @@
329335
//! yamux::Config::default,
330336
//! )?
331337
//! .with_behaviour(|_| ping::Behaviour::default())?
338+
//! .with_swarm_config(|cfg| {
339+
//! cfg.with_idle_connection_timeout(Duration::from_secs(u64::MAX))
340+
//! }) // Allows us to observe pings indefinitely.
332341
//! .build();
333342
//!
334343
//! // Tell the swarm to listen on all interfaces and a random, OS-assigned

misc/metrics/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.16.1
2+
- Add `ReservationClosed` as a relay metric.
3+
See [PR 5869](https://github.com/libp2p/rust-libp2p/pull/5869).
4+
15
## 0.16.0
26

37
<!-- Update to libp2p-core v0.43.0 -->

misc/metrics/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-metrics"
33
edition = "2021"
44
rust-version = { workspace = true }
55
description = "Metrics for libp2p"
6-
version = "0.16.0"
6+
version = "0.16.1"
77
authors = ["Max Inden <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

misc/metrics/src/relay.rs

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ enum EventType {
5454
ReservationReqAcceptFailed,
5555
ReservationReqDenied,
5656
ReservationReqDenyFailed,
57+
ReservationClosed,
5758
ReservationTimedOut,
5859
CircuitReqDenied,
5960
CircuitReqDenyFailed,
@@ -76,6 +77,7 @@ impl From<&libp2p_relay::Event> for EventType {
7677
libp2p_relay::Event::ReservationReqDenyFailed { .. } => {
7778
EventType::ReservationReqDenyFailed
7879
}
80+
libp2p_relay::Event::ReservationClosed { .. } => EventType::ReservationClosed,
7981
libp2p_relay::Event::ReservationTimedOut { .. } => EventType::ReservationTimedOut,
8082
libp2p_relay::Event::CircuitReqDenied { .. } => EventType::CircuitReqDenied,
8183
#[allow(deprecated)]

protocols/gossipsub/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## 0.48.1
2+
- Allow whitelisting topics for metrics to ensure metrics are recorded correctly for these topics.
3+
See [PR 5895](https://github.com/libp2p/rust-libp2p/pull/5895)
4+
25
- Improve `max_messages_per_rpc` consistency by ensuring RPC control messages also adhere to the existing limits.
36
See [PR 5826](https://github.com/libp2p/rust-libp2p/pull/5826)
47

protocols/gossipsub/src/behaviour.rs

+7
Original file line numberDiff line numberDiff line change
@@ -3053,6 +3053,13 @@ where
30533053
}
30543054
}
30553055
}
3056+
3057+
/// Register topics to ensure metrics are recorded correctly for these topics.
3058+
pub fn register_topics_for_metrics(&mut self, topics: Vec<TopicHash>) {
3059+
if let Some(metrics) = &mut self.metrics {
3060+
metrics.register_allowed_topics(topics);
3061+
}
3062+
}
30563063
}
30573064

30583065
fn get_ip_addr(addr: &Multiaddr) -> Option<IpAddr> {

protocols/gossipsub/src/metrics.rs

+7
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,13 @@ impl Metrics {
648648
metric.set(metric.get() - 1);
649649
}
650650
}
651+
652+
/// Registers a set of topics that we want to store calculate metrics for.
653+
pub(crate) fn register_allowed_topics(&mut self, topics: Vec<TopicHash>) {
654+
for topic_hash in topics {
655+
self.topic_info.insert(topic_hash, true);
656+
}
657+
}
651658
}
652659

653660
/// Reasons why a peer was included in the mesh.

protocols/relay/CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
## 0.19.1
1+
## 0.20.0
22

33
- Remove duplicated forwarding of pending events to connection handler.
4+
- Emit `relay::Event::ReservationClosed` when an active reservation is dropped due to the connection closing.
5+
See [PR 5869](https://github.com/libp2p/rust-libp2p/pull/5869).
46

57
## 0.19.0
68

protocols/relay/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-relay"
33
edition = "2021"
44
rust-version = { workspace = true }
55
description = "Communications relaying for libp2p"
6-
version = "0.19.1"
6+
version = "0.20.0"
77
authors = ["Parity Technologies <[email protected]>", "Max Inden <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

protocols/relay/src/behaviour.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ pub enum Event {
193193
src_peer_id: PeerId,
194194
error: inbound_hop::Error,
195195
},
196+
/// A reservation has been closed.
197+
ReservationClosed { src_peer_id: PeerId },
196198
/// An inbound reservation has timed out.
197199
ReservationTimedOut { src_peer_id: PeerId },
198200
/// An inbound circuit request has been denied.
@@ -277,7 +279,12 @@ impl Behaviour {
277279
}: ConnectionClosed,
278280
) {
279281
if let hash_map::Entry::Occupied(mut peer) = self.reservations.entry(peer_id) {
280-
peer.get_mut().remove(&connection_id);
282+
if peer.get_mut().remove(&connection_id) {
283+
self.queued_actions
284+
.push_back(ToSwarm::GenerateEvent(Event::ReservationClosed {
285+
src_peer_id: peer_id,
286+
}));
287+
}
281288
if peer.get().is_empty() {
282289
peer.remove();
283290
}

protocols/upnp/src/behaviour.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,10 @@ impl NetworkBehaviour for Behaviour {
264264
listener_id,
265265
addr: multiaddr,
266266
}) => {
267-
let (addr, protocol) = match multiaddr_to_socketaddr_protocol(multiaddr.clone()) {
268-
Ok(addr_port) => addr_port,
269-
Err(()) => {
270-
tracing::debug!("multiaddress not supported for UPnP {multiaddr}");
271-
return;
272-
}
267+
let Ok((addr, protocol)) = multiaddr_to_socketaddr_protocol(multiaddr.clone())
268+
else {
269+
tracing::debug!("multiaddress not supported for UPnP {multiaddr}");
270+
return;
273271
};
274272

275273
if let Some((mapping, _state)) = self

scripts/ensure-version-bump-and-changelog.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ MERGE_BASE=$(git merge-base "$HEAD_SHA" "$PR_BASE") # Find the merge base. This
1010
SRC_DIFF_TO_BASE=$(git diff "$HEAD_SHA".."$MERGE_BASE" --name-status -- "$DIR_TO_CRATE/src" "$DIR_TO_CRATE/Cargo.toml")
1111
CHANGELOG_DIFF=$(git diff "$HEAD_SHA".."$MERGE_BASE" --name-only -- "$DIR_TO_CRATE/CHANGELOG.md")
1212

13-
RELEASED_VERSION=$(git tag --sort=version:refname | grep "^$CRATE-v" | tail -n1 | grep -Po "\d+\.\d+\.\d+")
13+
RELEASED_VERSION=$(git tag --sort=version:refname | grep "^$CRATE-v" | tail -n1 | grep -Po "\d+\.\d+\.\d+(-.+)?")
1414

1515

1616
# If the source files of this crate weren't touched in this PR, exit early.

swarm/CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
## 0.46.1
1+
## 0.47.0
2+
- Separate the `PendingConnectionError` into two parts `PendingOutboundConnectionError` and `PendingInboundConnectionError` to have better control over error handling. See [PR](https://github.com/libp2p/rust-libp2p/pull/5861)
3+
24
- Undo `ConnectionHandler::{InboundOpenInfo, OutboundOpenInfo}` deprecation.
35
Substreams are not completely interchangeable and a certain Substream may be associated with a
46
certain upgrade.

swarm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "libp2p-swarm"
33
edition = "2021"
44
rust-version = { workspace = true }
55
description = "The libp2p swarm"
6-
version = "0.46.1"
6+
version = "0.47.0"
77
authors = ["Parity Technologies <[email protected]>"]
88
license = "MIT"
99
repository = "https://github.com/libp2p/rust-libp2p"

swarm/src/connection.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ use std::{
3636
};
3737

3838
pub use error::ConnectionError;
39-
pub(crate) use error::{
40-
PendingConnectionError, PendingInboundConnectionError, PendingOutboundConnectionError,
41-
};
39+
pub(crate) use error::{PendingInboundConnectionError, PendingOutboundConnectionError};
4240
use futures::{future::BoxFuture, stream, stream::FuturesUnordered, FutureExt, StreamExt};
4341
use futures_timer::Delay;
4442
use libp2p_core::{

0 commit comments

Comments
 (0)