Skip to content

Commit 18efa2c

Browse files
AgeManningjxs
authored andcommitted
fix(gossisub): prevent mesh exceeding mesh_n_high when handling GRAFTs
1 parent a753ab0 commit 18efa2c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

protocols/gossipsub/CHANGELOG.md

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

protocols/gossipsub/src/behaviour.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
@@ -1455,10 +1453,9 @@ where
14551453
}
14561454

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

1461-
if peers.len() >= mesh_n_high && !is_outbound {
1458+
if peers.len() >= mesh_n_high {
14621459
to_prune_topics.insert(topic_hash.clone());
14631460
continue;
14641461
}

0 commit comments

Comments
 (0)