Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(net): Reduce maximum number of connections per IP to 1 #6993

Merged
merged 2 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zebra-network/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub const OUTBOUND_PEER_LIMIT_MULTIPLIER: usize = 3;

/// The maximum number of peer connections Zebra will keep for a given IP address
/// before it drops any additional peer connections with that IP.
pub const MAX_CONNS_PER_IP: usize = 3;
pub const MAX_CONNS_PER_IP: usize = 1;

/// The buffer size for the peer set.
///
Expand Down
7 changes: 6 additions & 1 deletion zebra-network/src/peer_set/set/tests/vectors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Fixed test vectors for the peer set.

use std::{iter, time::Duration};
use std::{cmp::max, iter, time::Duration};

use tokio::time::timeout;
use tower::{Service, ServiceExt};
Expand All @@ -12,6 +12,7 @@ use zebra_chain::{

use super::{PeerSetBuilder, PeerVersions};
use crate::{
constants::MAX_CONNS_PER_IP,
peer::{ClientRequest, MinimumPeerVersion},
peer_set::inventory_registry::InventoryStatus,
protocol::external::{types::Version, InventoryHash},
Expand Down Expand Up @@ -144,6 +145,7 @@ fn peer_set_ready_multiple_connections() {
let (mut peer_set, _peer_set_guard) = PeerSetBuilder::new()
.with_discover(discovered_peers)
.with_minimum_peer_version(minimum_peer_version.clone())
.max_conns_per_ip(max(3, MAX_CONNS_PER_IP))
.build();

// Get peerset ready
Expand Down Expand Up @@ -257,6 +259,7 @@ fn peer_set_route_inv_empty_registry() {
let (mut peer_set, _peer_set_guard) = PeerSetBuilder::new()
.with_discover(discovered_peers)
.with_minimum_peer_version(minimum_peer_version.clone())
.max_conns_per_ip(max(2, MAX_CONNS_PER_IP))
.build();

// Get peerset ready
Expand Down Expand Up @@ -339,6 +342,7 @@ fn peer_set_route_inv_advertised_registry_order(advertised_first: bool) {
let (mut peer_set, mut peer_set_guard) = PeerSetBuilder::new()
.with_discover(discovered_peers)
.with_minimum_peer_version(minimum_peer_version.clone())
.max_conns_per_ip(max(2, MAX_CONNS_PER_IP))
.build();

// Advertise some inventory
Expand Down Expand Up @@ -446,6 +450,7 @@ fn peer_set_route_inv_missing_registry_order(missing_first: bool) {
let (mut peer_set, mut peer_set_guard) = PeerSetBuilder::new()
.with_discover(discovered_peers)
.with_minimum_peer_version(minimum_peer_version.clone())
.max_conns_per_ip(max(2, MAX_CONNS_PER_IP))
.build();

// Mark some inventory as missing
Expand Down