Skip to content

Commit 32e9877

Browse files
committed
Merge branch 'master' of https://github.com/libp2p/rust-libp2p into feat/mdns/only-send-if-addresses
2 parents aa8d379 + b0edc68 commit 32e9877

File tree

24 files changed

+191
-187
lines changed

24 files changed

+191
-187
lines changed

.github/workflows/cache-factory.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222

2323
- uses: dtolnay/rust-toolchain@stable
2424

25-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
25+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
2626
with:
2727
shared-key: stable-cache
2828

.github/workflows/ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
- uses: dtolnay/rust-toolchain@stable
3838

39-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
39+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
4040
with:
4141
shared-key: stable-cache
4242
save-if: false
@@ -145,7 +145,7 @@ jobs:
145145

146146
- uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0
147147

148-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
148+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
149149
with:
150150
key: ${{ matrix.target }}
151151
save-if: ${{ github.ref == 'refs/heads/master' }}
@@ -170,7 +170,7 @@ jobs:
170170

171171
- uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0
172172

173-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
173+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
174174
with:
175175
save-if: ${{ github.ref == 'refs/heads/master' }}
176176

@@ -190,7 +190,7 @@ jobs:
190190

191191
- uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0
192192

193-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
193+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
194194
with:
195195
key: ${{ matrix.features }}
196196
save-if: ${{ github.ref == 'refs/heads/master' }}
@@ -207,7 +207,7 @@ jobs:
207207

208208
- uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0
209209

210-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
210+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
211211
with:
212212
save-if: ${{ github.ref == 'refs/heads/master' }}
213213

@@ -233,7 +233,7 @@ jobs:
233233

234234
- uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0
235235

236-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
236+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
237237
with:
238238
save-if: ${{ github.ref == 'refs/heads/master' }}
239239

@@ -249,7 +249,7 @@ jobs:
249249

250250
- uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0
251251

252-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
252+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
253253
with:
254254
save-if: ${{ github.ref == 'refs/heads/master' }}
255255

@@ -268,7 +268,7 @@ jobs:
268268

269269
- uses: r7kamura/rust-problem-matchers@9fe7ca9f6550e5d6358e179d451cc25ea6b54f98 #v1.5.0
270270

271-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
271+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
272272
with:
273273
shared-key: stable-cache
274274
save-if: false
@@ -359,7 +359,7 @@ jobs:
359359
steps:
360360
- uses: actions/checkout@v5
361361

362-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
362+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
363363

364364
- run: cargo install --version 0.10.0 pb-rs --locked
365365

@@ -385,7 +385,7 @@ jobs:
385385
runs-on: ubuntu-latest
386386
steps:
387387
- uses: actions/checkout@v5
388-
- uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # v2.8.1
388+
- uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
389389
- run: cargo metadata --locked --format-version=1 > /dev/null
390390

391391
cargo-deny:

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ libp2p-swarm-derive = { version = "=0.35.1", path = "swarm-derive" } # `libp2p-s
107107
libp2p-swarm-test = { version = "0.6.0", path = "swarm-test" }
108108
libp2p-tcp = { version = "0.44.0", path = "transports/tcp" }
109109
libp2p-tls = { version = "0.6.2", path = "transports/tls" }
110-
libp2p-uds = { version = "0.43.0", path = "transports/uds" }
110+
libp2p-uds = { version = "0.43.1", path = "transports/uds" }
111111
libp2p-upnp = { version = "0.6.0", path = "protocols/upnp" }
112112
libp2p-webrtc = { version = "0.9.0-alpha.2", path = "transports/webrtc" }
113113
libp2p-webrtc-utils = { version = "0.4.0", path = "misc/webrtc-utils" }
114114
libp2p-webrtc-websys = { version = "0.4.0", path = "transports/webrtc-websys" }
115115
libp2p-websocket = { version = "0.45.2", path = "transports/websocket" }
116116
libp2p-websocket-websys = { version = "0.5.0", path = "transports/websocket-websys" }
117-
libp2p-webtransport-websys = { version = "0.5.1", path = "transports/webtransport-websys" }
117+
libp2p-webtransport-websys = { version = "0.5.2", path = "transports/webtransport-websys" }
118118
libp2p-yamux = { version = "0.47.0", path = "muxers/yamux" }
119119

120120
# External dependencies

examples/browser-webrtc/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Rust-libp2p Browser-Server WebRTC Example
22

33
This example demonstrates how to use the `libp2p-webrtc-websys` transport library in a browser to ping the WebRTC Server.
4-
It uses [wasm-pack](https://rustwasm.github.io/docs/wasm-pack/) to build the project for use in the browser.
4+
It uses [wasm-pack](https://drager.github.io/wasm-pack/) to build the project for use in the browser.
55

66
## Running the example
77

8-
Ensure you have `wasm-pack` [installed](https://rustwasm.github.io/wasm-pack/).
8+
Ensure you have `wasm-pack` [installed](https://drager.github.io/wasm-pack/).
99

1010
1. Build the client library:
1111
```shell

interop-tests/Dockerfile.chromium

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# syntax=docker/dockerfile:1.5-labs
22
FROM rust:1.83 as chef
33
RUN rustup target add wasm32-unknown-unknown
4-
RUN wget -q -O- https://github.com/rustwasm/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz | tar -zx -C /usr/local/bin --strip-components 1 --wildcards "wasm-pack-*/wasm-pack"
4+
RUN wget -q -O- https://github.com/drager/wasm-pack/releases/download/v0.12.1/wasm-pack-v0.12.1-x86_64-unknown-linux-musl.tar.gz | tar -zx -C /usr/local/bin --strip-components 1 --wildcards "wasm-pack-*/wasm-pack"
55
RUN wget -q -O- https://github.com/WebAssembly/binaryen/releases/download/version_115/binaryen-version_115-x86_64-linux.tar.gz | tar -zx -C /usr/local/bin --strip-components 2 --wildcards "binaryen-version_*/bin/wasm-opt"
66
RUN wget -q -O- https://github.com/LukeMathWalker/cargo-chef/releases/download/v0.1.62/cargo-chef-x86_64-unknown-linux-gnu.tar.gz | tar -zx -C /usr/local/bin
77
WORKDIR /app

protocols/dcutr/src/handler/relayed.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,8 @@ impl Handler {
148148

149149
fn on_listen_upgrade_error(
150150
&mut self,
151-
ListenUpgradeError { error, .. }: ListenUpgradeError<
152-
(),
153-
<Self as ConnectionHandler>::InboundProtocol,
154-
>,
151+
_: ListenUpgradeError<(), <Self as ConnectionHandler>::InboundProtocol>,
155152
) {
156-
libp2p_core::util::unreachable(error.into_inner());
157153
}
158154

159155
fn on_dial_upgrade_error(

protocols/gossipsub/CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
## 0.50.0
2+
- Prevent mesh exceeding mesh_n_high.
3+
See [PR 6184](https://github.com/libp2p/rust-libp2p/pull/6184)
4+
25
- Fix underflow when shuffling peers after prunning.
36
See [PR 6183](https://github.com/libp2p/rust-libp2p/pull/6183)
47

@@ -16,13 +19,19 @@
1619

1720
- Fix incorrect default values in ConfigBuilder
1821
See [PR 6113](https://github.com/libp2p/rust-libp2p/pull/6113)
19-
22+
2023
- Remove duplicated config `set_topic_max_transmit_size` method, prefer `max_transmit_size_for_topic`.
2124
See [PR 6173](https://github.com/libp2p/rust-libp2p/pull/6173).
2225

2326
- Switch the internal `async-channel` used to dispatch messages from `NetworkBehaviour` to the `ConnectionHandler`
2427
with an internal priority queue. See [PR 6175](https://github.com/libp2p/rust-libp2p/pull/6175)
2528

29+
- gossipsub: do early return in for an empty input
30+
See [PR 6208](https://github.com/libp2p/rust-libp2p/pull/6208).
31+
32+
- Refactor gossipsub with in-place negative-score peer removal.
33+
See [PR 6209](https://github.com/libp2p/rust-libp2p/pull/6209).
34+
2635
## 0.49.2
2736

2837
- Relax `Behaviour::with_metrics` requirements, do not require DataTransform and TopicSubscriptionFilter to also impl Default

protocols/gossipsub/src/behaviour.rs

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ where
511511

512512
/// Subscribe to a topic.
513513
///
514-
/// Returns [`Ok(true)`] if the subscription worked. Returns [`Ok(false)`] if we were already
515-
/// subscribed.
514+
/// Returns [`Ok(true)`](Ok) if the subscription worked. Returns [`Ok(false)`](Ok) if we were
515+
/// already subscribed.
516516
pub fn subscribe<H: Hasher>(&mut self, topic: &Topic<H>) -> Result<bool, SubscriptionError> {
517517
let topic_hash = topic.hash();
518518
if !self.subscription_filter.can_subscribe(&topic_hash) {
@@ -1366,8 +1366,6 @@ where
13661366
tracing::error!(peer_id = %peer_id, "Peer non-existent when handling graft");
13671367
return;
13681368
};
1369-
// Needs to be here to comply with the borrow checker.
1370-
let is_outbound = connected_peer.outbound;
13711369

13721370
// For each topic, if a peer has grafted us, then we necessarily must be in their mesh
13731371
// and they must be subscribed to the topic. Ensure we have recorded the mapping.
@@ -1419,8 +1417,6 @@ where
14191417
peer_score.add_penalty(peer_id, 1);
14201418

14211419
// check the flood cutoff
1422-
// See: https://github.com/rust-lang/rust-clippy/issues/10061
1423-
#[allow(unknown_lints, clippy::unchecked_duration_subtraction)]
14241420
let flood_cutoff = (backoff_time
14251421
+ self.config.graft_flood_threshold())
14261422
- self.config.prune_backoff();
@@ -1455,10 +1451,9 @@ where
14551451
}
14561452

14571453
// check mesh upper bound and only allow graft if the upper bound is not reached
1458-
// or if it is an outbound peer
14591454
let mesh_n_high = self.config.mesh_n_high_for_topic(&topic_hash);
14601455

1461-
if peers.len() >= mesh_n_high && !is_outbound {
1456+
if peers.len() >= mesh_n_high {
14621457
to_prune_topics.insert(topic_hash.clone());
14631458
continue;
14641459
}
@@ -2140,11 +2135,14 @@ where
21402135
let mesh_n_high = self.config.mesh_n_high_for_topic(topic_hash);
21412136
let mesh_outbound_min = self.config.mesh_outbound_min_for_topic(topic_hash);
21422137

2143-
// drop all peers with negative score, without PX
2144-
// if there is at some point a stable retain method for BTreeSet the following can be
2145-
// written more efficiently with retain.
2146-
let mut to_remove_peers = Vec::new();
2147-
for peer_id in peers.iter() {
2138+
#[cfg(feature = "metrics")]
2139+
let mut removed_peers_count = 0;
2140+
2141+
// Drop all peers with negative score, without PX
2142+
//
2143+
// TODO: Use `extract_if` once MSRV is raised to a version that includes its
2144+
// stabilization.
2145+
peers.retain(|peer_id| {
21482146
let peer_score = scores.get(peer_id).map(|r| r.score).unwrap_or_default();
21492147

21502148
// Record the score per mesh
@@ -2164,17 +2162,20 @@ where
21642162
let current_topic = to_prune.entry(*peer_id).or_insert_with(Vec::new);
21652163
current_topic.push(topic_hash.clone());
21662164
no_px.insert(*peer_id);
2167-
to_remove_peers.push(*peer_id);
2165+
2166+
#[cfg(feature = "metrics")]
2167+
{
2168+
removed_peers_count += 1;
2169+
}
2170+
2171+
return false;
21682172
}
2169-
}
2173+
true
2174+
});
21702175

21712176
#[cfg(feature = "metrics")]
21722177
if let Some(m) = self.metrics.as_mut() {
2173-
m.peers_removed(topic_hash, Churn::BadScore, to_remove_peers.len())
2174-
}
2175-
2176-
for peer_id in to_remove_peers {
2177-
peers.remove(&peer_id);
2178+
m.peers_removed(topic_hash, Churn::BadScore, removed_peers_count)
21782179
}
21792180

21802181
// too little peers - add some
@@ -2208,7 +2209,7 @@ where
22082209
}
22092210

22102211
// too many peers - remove some
2211-
if peers.len() > mesh_n_high {
2212+
if peers.len() >= mesh_n_high {
22122213
tracing::debug!(
22132214
topic=%topic_hash,
22142215
"HEARTBEAT: Mesh high. Topic contains: {} will reduce to: {}",

0 commit comments

Comments
 (0)