diff --git a/gossip/src/cluster_info.rs b/gossip/src/cluster_info.rs index 7f0fcb5208..e9feb8e545 100644 --- a/gossip/src/cluster_info.rs +++ b/gossip/src/cluster_info.rs @@ -2899,6 +2899,7 @@ impl Node { gossip_addr: &SocketAddr, port_range: PortRange, bind_ip_addr: IpAddr, + overwrite_tpu_addr: Option, ) -> Node { let (gossip_port, (gossip, ip_echo)) = Self::get_gossip_port(gossip_addr, port_range, bind_ip_addr); @@ -2940,7 +2941,7 @@ impl Node { tvu: SocketAddr::new(gossip_addr.ip(), tvu_port), tvu_forwards: SocketAddr::new(gossip_addr.ip(), tvu_forwards_port), repair: SocketAddr::new(gossip_addr.ip(), repair_port), - tpu: SocketAddr::new(gossip_addr.ip(), tpu_port), + tpu: overwrite_tpu_addr.unwrap_or_else(|| SocketAddr::new(gossip_addr.ip(), tpu_port)), tpu_forwards: SocketAddr::new(gossip_addr.ip(), tpu_forwards_port), tpu_vote: SocketAddr::new(gossip_addr.ip(), tpu_vote_port), rpc: socketaddr_any!(), @@ -3500,6 +3501,7 @@ mod tests { &socketaddr!(ip, 0), VALIDATOR_PORT_RANGE, IpAddr::V4(ip), + None, ); check_node_sockets(&node, IpAddr::V4(ip), VALIDATOR_PORT_RANGE); @@ -3521,6 +3523,7 @@ mod tests { &socketaddr!(0, port), port_range, ip, + None, ); check_node_sockets(&node, ip, port_range); diff --git a/replica-node/src/main.rs b/replica-node/src/main.rs index a2d84f9dc4..42aa6a60ab 100644 --- a/replica-node/src/main.rs +++ b/replica-node/src/main.rs @@ -291,6 +291,7 @@ pub fn main() { &gossip_addr, dynamic_port_range, bind_address, + None, ); let ledger_path = PathBuf::from(matches.value_of("ledger_path").unwrap()); diff --git a/replica-node/tests/local_replica.rs b/replica-node/tests/local_replica.rs index 173b9360c7..372de06c9d 100644 --- a/replica-node/tests/local_replica.rs +++ b/replica-node/tests/local_replica.rs @@ -252,6 +252,7 @@ fn test_replica_bootstrap() { &gossip_addr, dynamic_port_range, bind_address, + None, ); info!("The peer id: {:?}", &contact_info.id); diff --git a/validator/src/main.rs b/validator/src/main.rs index 90c03172a6..c169b97d9c 100644 --- a/validator/src/main.rs +++ b/validator/src/main.rs @@ -775,6 +775,16 @@ pub fn main() { .help("Gossip DNS name or IP address for the validator to advertise in gossip \ [default: ask --entrypoint, or 127.0.0.1 when --entrypoint is not provided]"), ) + .arg( + Arg::with_name("tpu_host_addr") + .long("tpu-host-addr") + .value_name("HOST:PORT") + .takes_value(true) + .validator(solana_net_utils::is_host_port) + .help("Specify TPU address to advertise in gossip [default: ask --entrypoint or localhost\ + when --entrypoint is not provided]"), + + ) .arg( Arg::with_name("public_rpc_addr") .long("public-rpc-address") @@ -2602,6 +2612,13 @@ pub fn main() { }), ); + let overwrite_tpu_addr = matches.value_of("tpu_host_addr").map(|tpu_addr| { + solana_net_utils::parse_host_port(tpu_addr).unwrap_or_else(|err| { + eprintln!("Failed to parse --overwrite-tpu-addr: {}", err); + exit(1); + }) + }); + let cluster_entrypoints = entrypoint_addrs .iter() .map(ContactInfo::new_gossip_entry_point) @@ -2612,6 +2629,7 @@ pub fn main() { &gossip_addr, dynamic_port_range, bind_address, + overwrite_tpu_addr, ); if restricted_repair_only_mode {