Ensure AncestorHashesSerice selects an open port (#21919)
This commit is contained in:
@ -94,7 +94,7 @@ use {
|
||||
};
|
||||
|
||||
pub const VALIDATOR_PORT_RANGE: PortRange = (8000, 10_000);
|
||||
pub const MINIMUM_VALIDATOR_PORT_RANGE_WIDTH: u16 = 10; // VALIDATOR_PORT_RANGE must be at least this wide
|
||||
pub const MINIMUM_VALIDATOR_PORT_RANGE_WIDTH: u16 = 11; // VALIDATOR_PORT_RANGE must be at least this wide
|
||||
|
||||
/// The Data plane fanout size, also used as the neighborhood size
|
||||
pub const DATA_PLANE_FANOUT: usize = 200;
|
||||
@ -2742,6 +2742,7 @@ pub struct Sockets {
|
||||
pub repair: UdpSocket,
|
||||
pub retransmit_sockets: Vec<UdpSocket>,
|
||||
pub serve_repair: UdpSocket,
|
||||
pub ancestor_hashes_requests: UdpSocket,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -2775,6 +2776,8 @@ impl Node {
|
||||
let broadcast = vec![UdpSocket::bind("0.0.0.0:0").unwrap()];
|
||||
let retransmit_socket = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
let serve_repair = UdpSocket::bind("127.0.0.1:0").unwrap();
|
||||
let ancestor_hashes_requests = UdpSocket::bind("0.0.0.0:0").unwrap();
|
||||
|
||||
let info = ContactInfo {
|
||||
id: *pubkey,
|
||||
gossip: gossip_addr,
|
||||
@ -2804,6 +2807,7 @@ impl Node {
|
||||
repair,
|
||||
retransmit_sockets: vec![retransmit_socket],
|
||||
serve_repair,
|
||||
ancestor_hashes_requests,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -2845,6 +2849,7 @@ impl Node {
|
||||
let (repair_port, repair) = Self::bind(bind_ip_addr, port_range);
|
||||
let (serve_repair_port, serve_repair) = Self::bind(bind_ip_addr, port_range);
|
||||
let (_, broadcast) = Self::bind(bind_ip_addr, port_range);
|
||||
let (_, ancestor_hashes_requests) = Self::bind(bind_ip_addr, port_range);
|
||||
|
||||
let rpc_port = find_available_port_in_range(bind_ip_addr, port_range).unwrap();
|
||||
let rpc_pubsub_port = find_available_port_in_range(bind_ip_addr, port_range).unwrap();
|
||||
@ -2880,6 +2885,7 @@ impl Node {
|
||||
repair,
|
||||
retransmit_sockets: vec![retransmit_socket],
|
||||
serve_repair,
|
||||
ancestor_hashes_requests,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -2917,6 +2923,8 @@ impl Node {
|
||||
let (_, broadcast) =
|
||||
multi_bind_in_range(bind_ip_addr, port_range, 4).expect("broadcast multi_bind");
|
||||
|
||||
let (_, ancestor_hashes_requests) = Self::bind(bind_ip_addr, port_range);
|
||||
|
||||
let info = ContactInfo {
|
||||
id: *pubkey,
|
||||
gossip: SocketAddr::new(gossip_addr.ip(), gossip_port),
|
||||
@ -2948,6 +2956,7 @@ impl Node {
|
||||
retransmit_sockets,
|
||||
serve_repair,
|
||||
ip_echo: Some(ip_echo),
|
||||
ancestor_hashes_requests,
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -3490,7 +3499,10 @@ mod tests {
|
||||
fn new_with_external_ip_test_gossip() {
|
||||
// Can't use VALIDATOR_PORT_RANGE because if this test runs in parallel with others, the
|
||||
// port returned by `bind_in_range()` might be snatched up before `Node::new_with_external_ip()` runs
|
||||
let port_range = (VALIDATOR_PORT_RANGE.1 + 10, VALIDATOR_PORT_RANGE.1 + 20);
|
||||
let port_range = (
|
||||
VALIDATOR_PORT_RANGE.1 + MINIMUM_VALIDATOR_PORT_RANGE_WIDTH,
|
||||
VALIDATOR_PORT_RANGE.1 + (2 * MINIMUM_VALIDATOR_PORT_RANGE_WIDTH),
|
||||
);
|
||||
|
||||
let ip = IpAddr::V4(Ipv4Addr::from(0));
|
||||
let port = bind_in_range(ip, port_range).expect("Failed to bind").0;
|
||||
|
Reference in New Issue
Block a user