Skip to content

Commit 527eeda

Browse files
Merge branch 'master' into 2824-remove-into-connection-handler
2 parents 9c55601 + 5b4eab7 commit 527eeda

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+987
-478
lines changed

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,20 @@
4545

4646
# `libp2p` facade crate
4747

48-
# 0.50.0 - [unreleased]
48+
# 0.50.0
49+
50+
This is a large release. After > 4 years, rust-libp2p ships with an [(alpha) QUIC
51+
implementation](transports/quic/CHANGELOG.md#070-alpha). The [necessary TLS logic is extracted into
52+
its own crate](transports/tls/CHANGELOG.md#010-alpha), and can thus be used detached from QUIC, e.g.
53+
on top of TCP as an alternative to Noise. In addition to these two transports, this release adds
54+
a third, namely [WebRTC (browser-to-server)](transports/webrtc/CHANGELOG.md#040-alpha). But that is
55+
definitely not it. See below for the many other changes packed into this release.
4956

5057
- Introduce [`libp2p-tls` `v0.1.0-alpha`](transports/tls/CHANGELOG.md#010-alpha). See [PR 2945].
5158
- Introduce [`libp2p-quic` `v0.7.0-alpha`](transports/quic/CHANGELOG.md#070-alpha). See [PR 2289].
59+
- Introduce [`libp2p-webrtc` `v0.4.0-alpha`](transports/webrtc/CHANGELOG.md#040-alpha). See [PR 2289].
5260
- Remove deprecated features: `tcp-tokio`, `mdns-tokio`, `dns-tokio`, `tcp-async-io`, `mdns-async-io`, `dns-async-std`.
5361
See [PR 3001].
54-
- Introduce [`libp2p-tls` `v0.1.0`](transports/tls/CHANGELOG.md#010). See [PR 2945].
5562
- Remove `NetworkBehaviour` macro export from root crate in favor of re-exported macro from `libp2p::swarm`.
5663
Change your import from `libp2p::NetworkBehaviour` to `libp2p::swarm::NetworkBehaviour`. See [PR 3055].
5764
- Feature-gate `NetworkBehaviour` macro behind `macros` feature flag. See [PR 3055].
@@ -100,7 +107,7 @@
100107
- `tcp-async-io` in favor of `tcp` + `async-std`
101108
- `mdns-async-io` in favor of `mdns` + `async-std`
102109
- `dns-async-std` in favor of `dns` + `async-std`
103-
110+
104111
See [PR 2962].
105112

106113
- Update individual crates.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ serde = ["libp2p-core/serde", "libp2p-kad?/serde", "libp2p-gossipsub?/serde"]
7878
tcp = ["dep:libp2p-tcp"]
7979
tokio = ["libp2p-swarm/tokio", "libp2p-mdns?/tokio", "libp2p-tcp?/tokio", "libp2p-dns?/tokio", "libp2p-quic?/tokio", "libp2p-webrtc?/tokio"]
8080
uds = ["dep:libp2p-uds"]
81-
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js"]
81+
wasm-bindgen = ["futures-timer/wasm-bindgen", "instant/wasm-bindgen", "getrandom/js", "libp2p-swarm/wasm-bindgen"]
8282
wasm-ext = ["dep:libp2p-wasm-ext"]
8383
wasm-ext-websocket = ["wasm-ext", "libp2p-wasm-ext?/websocket"]
8484
webrtc = ["dep:libp2p-webrtc", "libp2p-webrtc?/pem"]
@@ -123,7 +123,7 @@ libp2p-mdns = { version = "0.42.0", path = "protocols/mdns", optional = true }
123123
libp2p-quic = { version = "0.7.0-alpha", path = "transports/quic", optional = true }
124124
libp2p-tcp = { version = "0.38.0", path = "transports/tcp", optional = true }
125125
libp2p-tls = { version = "0.1.0-alpha", path = "transports/tls", optional = true }
126-
libp2p-webrtc = { version = "0.1.0-alpha", path = "transports/webrtc", optional = true }
126+
libp2p-webrtc = { version = "0.4.0-alpha", path = "transports/webrtc", optional = true }
127127
libp2p-websocket = { version = "0.40.0", path = "transports/websocket", optional = true }
128128

129129
[target.'cfg(not(target_os = "unknown"))'.dependencies]

core/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 0.38.0 [unreleased]
1+
# 0.38.0
22

33
- Remove deprecated functions `StreamMuxerExt::next_{inbound,outbound}`. See [PR 3031].
44

examples/distributed-key-value-store.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ use libp2p::{
5252
swarm::{NetworkBehaviour, SwarmEvent},
5353
PeerId, Swarm,
5454
};
55+
use libp2p_kad::{GetProvidersOk, GetRecordOk};
5556
use std::error::Error;
5657

5758
#[async_std::main]
@@ -120,33 +121,32 @@ async fn main() -> Result<(), Box<dyn Error>> {
120121
swarm.behaviour_mut().kademlia.add_address(&peer_id, multiaddr);
121122
}
122123
}
123-
SwarmEvent::Behaviour(MyBehaviourEvent::Kademlia(KademliaEvent::OutboundQueryCompleted { result, ..})) => {
124+
SwarmEvent::Behaviour(MyBehaviourEvent::Kademlia(KademliaEvent::OutboundQueryProgressed { result, ..})) => {
124125
match result {
125-
QueryResult::GetProviders(Ok(ok)) => {
126-
for peer in ok.providers {
126+
QueryResult::GetProviders(Ok(GetProvidersOk::FoundProviders { key, providers, .. })) => {
127+
for peer in providers {
127128
println!(
128-
"Peer {:?} provides key {:?}",
129-
peer,
130-
std::str::from_utf8(ok.key.as_ref()).unwrap()
129+
"Peer {peer:?} provides key {:?}",
130+
std::str::from_utf8(key.as_ref()).unwrap()
131131
);
132132
}
133133
}
134134
QueryResult::GetProviders(Err(err)) => {
135135
eprintln!("Failed to get providers: {err:?}");
136136
}
137-
QueryResult::GetRecord(Ok(ok)) => {
138-
for PeerRecord {
137+
QueryResult::GetRecord(Ok(
138+
GetRecordOk::FoundRecord(PeerRecord {
139139
record: Record { key, value, .. },
140140
..
141-
} in ok.records
142-
{
143-
println!(
144-
"Got record {:?} {:?}",
145-
std::str::from_utf8(key.as_ref()).unwrap(),
146-
std::str::from_utf8(&value).unwrap(),
147-
);
148-
}
141+
})
142+
)) => {
143+
println!(
144+
"Got record {:?} {:?}",
145+
std::str::from_utf8(key.as_ref()).unwrap(),
146+
std::str::from_utf8(&value).unwrap(),
147+
);
149148
}
149+
QueryResult::GetRecord(Ok(_)) => {}
150150
QueryResult::GetRecord(Err(err)) => {
151151
eprintln!("Failed to get record: {err:?}");
152152
}
@@ -191,7 +191,7 @@ fn handle_input_line(kademlia: &mut Kademlia<MemoryStore>, line: String) {
191191
}
192192
}
193193
};
194-
kademlia.get_record(key, Quorum::One);
194+
kademlia.get_record(key);
195195
}
196196
Some("GET_PROVIDERS") => {
197197
let key = {

examples/file-sharing.rs

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ mod network {
414414
) {
415415
match event {
416416
SwarmEvent::Behaviour(ComposedEvent::Kademlia(
417-
KademliaEvent::OutboundQueryCompleted {
417+
KademliaEvent::OutboundQueryProgressed {
418418
id,
419419
result: QueryResult::StartProviding(_),
420420
..
@@ -427,18 +427,37 @@ mod network {
427427
let _ = sender.send(());
428428
}
429429
SwarmEvent::Behaviour(ComposedEvent::Kademlia(
430-
KademliaEvent::OutboundQueryCompleted {
430+
KademliaEvent::OutboundQueryProgressed {
431431
id,
432-
result: QueryResult::GetProviders(Ok(GetProvidersOk { providers, .. })),
432+
result:
433+
QueryResult::GetProviders(Ok(GetProvidersOk::FoundProviders {
434+
providers,
435+
..
436+
})),
433437
..
434438
},
435439
)) => {
436-
let _ = self
437-
.pending_get_providers
438-
.remove(&id)
439-
.expect("Completed query to be previously pending.")
440-
.send(providers);
440+
if let Some(sender) = self.pending_get_providers.remove(&id) {
441+
sender.send(providers).expect("Receiver not to be dropped");
442+
443+
// Finish the query. We are only interested in the first result.
444+
self.swarm
445+
.behaviour_mut()
446+
.kademlia
447+
.query_mut(&id)
448+
.unwrap()
449+
.finish();
450+
}
441451
}
452+
SwarmEvent::Behaviour(ComposedEvent::Kademlia(
453+
KademliaEvent::OutboundQueryProgressed {
454+
result:
455+
QueryResult::GetProviders(Ok(
456+
GetProvidersOk::FinishedWithNoAdditionalRecord { .. },
457+
)),
458+
..
459+
},
460+
)) => {}
442461
SwarmEvent::Behaviour(ComposedEvent::Kademlia(_)) => {}
443462
SwarmEvent::Behaviour(ComposedEvent::RequestResponse(
444463
RequestResponseEvent::Message { message, .. },

examples/ipfs-kad.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
8181

8282
loop {
8383
let event = swarm.select_next_some().await;
84-
if let SwarmEvent::Behaviour(KademliaEvent::OutboundQueryCompleted {
84+
if let SwarmEvent::Behaviour(KademliaEvent::OutboundQueryProgressed {
8585
result: QueryResult::GetClosestPeers(result),
8686
..
8787
}) = event

misc/metrics/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 0.11.0 [unreleased]
1+
# 0.11.0
22

33
- Update to `libp2p-dcutr` `v0.8.0`.
44

@@ -20,8 +20,12 @@
2020

2121
- Update `rust-version` to reflect the actual MSRV: 1.62.0. See [PR 3090].
2222

23+
- Changed `Metrics::query_result_get_record_ok` from `Histogram` to a `Counter`.
24+
See [PR 2712].
25+
2326
[PR 2982]: https://github.com/libp2p/rust-libp2p/pull/2982/
2427
[PR 3090]: https://github.com/libp2p/rust-libp2p/pull/3090
28+
[PR 2712]: https://github.com/libp2p/rust-libp2p/pull/2712
2529

2630
# 0.10.0
2731

misc/metrics/src/kad.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use prometheus_client::metrics::histogram::{exponential_buckets, Histogram};
2525
use prometheus_client::registry::{Registry, Unit};
2626

2727
pub struct Metrics {
28-
query_result_get_record_ok: Histogram,
28+
query_result_get_record_ok: Counter,
2929
query_result_get_record_error: Family<GetRecordResult, Counter>,
3030

3131
query_result_get_closest_peers_ok: Histogram,
@@ -48,7 +48,7 @@ impl Metrics {
4848
pub fn new(registry: &mut Registry) -> Self {
4949
let sub_registry = registry.sub_registry_with_prefix("kad");
5050

51-
let query_result_get_record_ok = Histogram::new(exponential_buckets(1.0, 2.0, 10));
51+
let query_result_get_record_ok = Counter::default();
5252
sub_registry.register(
5353
"query_result_get_record_ok",
5454
"Number of records returned by a successful Kademlia get record query.",
@@ -162,7 +162,7 @@ impl Metrics {
162162
impl super::Recorder<libp2p_kad::KademliaEvent> for Metrics {
163163
fn record(&self, event: &libp2p_kad::KademliaEvent) {
164164
match event {
165-
libp2p_kad::KademliaEvent::OutboundQueryCompleted { result, stats, .. } => {
165+
libp2p_kad::KademliaEvent::OutboundQueryProgressed { result, stats, .. } => {
166166
self.query_result_num_requests
167167
.get_or_create(&result.into())
168168
.observe(stats.num_requests().into());
@@ -180,9 +180,10 @@ impl super::Recorder<libp2p_kad::KademliaEvent> for Metrics {
180180

181181
match result {
182182
libp2p_kad::QueryResult::GetRecord(result) => match result {
183-
Ok(ok) => self
184-
.query_result_get_record_ok
185-
.observe(ok.records.len() as f64),
183+
Ok(libp2p_kad::GetRecordOk::FoundRecord(_)) => {
184+
self.query_result_get_record_ok.inc();
185+
}
186+
Ok(libp2p_kad::GetRecordOk::FinishedWithNoAdditionalRecord { .. }) => {}
186187
Err(error) => {
187188
self.query_result_get_record_error
188189
.get_or_create(&error.into())
@@ -200,9 +201,13 @@ impl super::Recorder<libp2p_kad::KademliaEvent> for Metrics {
200201
}
201202
},
202203
libp2p_kad::QueryResult::GetProviders(result) => match result {
203-
Ok(ok) => self
204-
.query_result_get_providers_ok
205-
.observe(ok.providers.len() as f64),
204+
Ok(libp2p_kad::GetProvidersOk::FoundProviders { providers, .. }) => {
205+
self.query_result_get_providers_ok
206+
.observe(providers.len() as f64);
207+
}
208+
Ok(libp2p_kad::GetProvidersOk::FinishedWithNoAdditionalRecord {
209+
..
210+
}) => {}
206211
Err(error) => {
207212
self.query_result_get_providers_error
208213
.get_or_create(&error.into())

misc/prost-codec/CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
# 0.3.0 [unreleased]
1+
# 0.3.0
32

43
- Implement `From` trait for `std::io::Error`. See [PR 2622].
54
- Don't leak `prost` dependency in `Error` type. See [PR 3058].

muxers/mplex/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 0.38.0 [unreleased]
1+
# 0.38.0
22

33
- Update to `libp2p-core` `v0.38.0`.
44

0 commit comments

Comments
 (0)