@@ -134,6 +134,141 @@ pub fn execute(
134134 solana_metrics:: set_panic_hook ( "validator" , Some ( String :: from ( solana_version) ) ) ;
135135 solana_entry:: entry:: init_poh ( ) ;
136136
137+ let bind_addresses = {
138+ let parsed = matches
139+ . values_of ( "bind_address" )
140+ . expect ( "bind_address should always be present due to default" )
141+ . map ( solana_net_utils:: parse_host)
142+ . collect :: < Result < Vec < _ > , _ > > ( ) ?;
143+ BindIpAddrs :: new ( parsed) . map_err ( |err| format ! ( "invalid bind_addresses: {err}" ) ) ?
144+ } ;
145+
146+ let entrypoint_addrs = run_args. entrypoints ;
147+ for addr in & entrypoint_addrs {
148+ if !run_args. socket_addr_space . check ( addr) {
149+ Err ( format ! ( "invalid entrypoint address: {addr}" ) ) ?;
150+ }
151+ }
152+
153+ let xdp_interface = matches. value_of ( "retransmit_xdp_interface" ) ;
154+ let xdp_zero_copy = matches. is_present ( "retransmit_xdp_zero_copy" ) ;
155+ let retransmit_xdp = matches. value_of ( "retransmit_xdp_cpu_cores" ) . map ( |cpus| {
156+ XdpConfig :: new (
157+ xdp_interface,
158+ parse_cpu_ranges ( cpus) . unwrap ( ) ,
159+ xdp_zero_copy,
160+ )
161+ } ) ;
162+
163+ let dynamic_port_range =
164+ solana_net_utils:: parse_port_range ( matches. value_of ( "dynamic_port_range" ) . unwrap ( ) )
165+ . expect ( "invalid dynamic_port_range" ) ;
166+
167+ let advertised_ip = matches
168+ . value_of ( "advertised_ip" )
169+ . map ( |advertised_ip| {
170+ solana_net_utils:: parse_host ( advertised_ip)
171+ . map_err ( |err| format ! ( "failed to parse --advertised-ip: {err}" ) )
172+ } )
173+ . transpose ( ) ?;
174+
175+ let advertised_ip = if let Some ( cli_ip) = advertised_ip {
176+ cli_ip
177+ } else if !bind_addresses. active ( ) . is_unspecified ( ) && !bind_addresses. active ( ) . is_loopback ( ) {
178+ bind_addresses. active ( )
179+ } else if !entrypoint_addrs. is_empty ( ) {
180+ let mut order: Vec < _ > = ( 0 ..entrypoint_addrs. len ( ) ) . collect ( ) ;
181+ order. shuffle ( & mut rng ( ) ) ;
182+
183+ order
184+ . into_iter ( )
185+ . find_map ( |i| {
186+ let entrypoint_addr = & entrypoint_addrs[ i] ;
187+ info ! (
188+ "Contacting {entrypoint_addr} to determine the validator's public IP address"
189+ ) ;
190+ solana_net_utils:: get_public_ip_addr_with_binding (
191+ entrypoint_addr,
192+ bind_addresses. active ( ) ,
193+ )
194+ . map_or_else (
195+ |err| {
196+ warn ! ( "Failed to contact cluster entrypoint {entrypoint_addr}: {err}" ) ;
197+ None
198+ } ,
199+ Some ,
200+ )
201+ } )
202+ . ok_or_else ( || "unable to determine the validator's public IP address" . to_string ( ) ) ?
203+ } else {
204+ IpAddr :: V4 ( Ipv4Addr :: LOCALHOST )
205+ } ;
206+ let gossip_port = value_t ! ( matches, "gossip_port" , u16 ) . or_else ( |_| {
207+ solana_net_utils:: find_available_port_in_range ( bind_addresses. active ( ) , ( 0 , 1 ) )
208+ . map_err ( |err| format ! ( "unable to find an available gossip port: {err}" ) )
209+ } ) ?;
210+
211+ let public_tpu_addr = matches
212+ . value_of ( "public_tpu_addr" )
213+ . map ( |public_tpu_addr| {
214+ solana_net_utils:: parse_host_port ( public_tpu_addr)
215+ . map_err ( |err| format ! ( "failed to parse --public-tpu-address: {err}" ) )
216+ } )
217+ . transpose ( ) ?;
218+
219+ let public_tpu_forwards_addr = matches
220+ . value_of ( "public_tpu_forwards_addr" )
221+ . map ( |public_tpu_forwards_addr| {
222+ solana_net_utils:: parse_host_port ( public_tpu_forwards_addr)
223+ . map_err ( |err| format ! ( "failed to parse --public-tpu-forwards-address: {err}" ) )
224+ } )
225+ . transpose ( ) ?;
226+
227+ let public_tvu_addr = matches
228+ . value_of ( "public_tvu_addr" )
229+ . map ( |public_tvu_addr| {
230+ solana_net_utils:: parse_host_port ( public_tvu_addr)
231+ . map_err ( |err| format ! ( "failed to parse --public-tvu-address: {err}" ) )
232+ } )
233+ . transpose ( ) ?;
234+
235+ if bind_addresses. len ( ) > 1 && public_tvu_addr. is_some ( ) {
236+ Err ( String :: from (
237+ "--public-tvu-address can not be used in a multihoming context" ,
238+ ) ) ?;
239+ }
240+
241+ let tpu_vortexor_receiver_address =
242+ matches
243+ . value_of ( "tpu_vortexor_receiver_address" )
244+ . map ( |tpu_vortexor_receiver_address| {
245+ solana_net_utils:: parse_host_port ( tpu_vortexor_receiver_address) . unwrap_or_else (
246+ |err| {
247+ eprintln ! ( "Failed to parse --tpu-vortexor-receiver-address: {err}" ) ;
248+ exit ( 1 ) ;
249+ } ,
250+ )
251+ } ) ;
252+
253+ info ! ( "tpu_vortexor_receiver_address is {tpu_vortexor_receiver_address:?}" ) ;
254+ let num_quic_endpoints = value_t_or_exit ! ( matches, "num_quic_endpoints" , NonZeroUsize ) ;
255+
256+ let node_config = NodeConfig {
257+ advertised_ip,
258+ gossip_port,
259+ port_range : dynamic_port_range,
260+ bind_ip_addrs : bind_addresses. clone ( ) ,
261+ public_tpu_addr,
262+ public_tpu_forwards_addr,
263+ public_tvu_addr,
264+ num_tvu_receive_sockets : tvu_receive_threads,
265+ num_tvu_retransmit_sockets : tvu_retransmit_threads,
266+ num_quic_endpoints,
267+ vortexor_receiver_addr : tpu_vortexor_receiver_address,
268+ } ;
269+
270+ let mut node = Node :: new_with_external_ip ( & identity_keypair. pubkey ( ) , node_config) ;
271+
137272 solana_core:: validator:: report_target_features ( ) ;
138273
139274 let authorized_voter_keypairs = keypairs_of ( matches, "authorized_voter_keypairs" )
@@ -212,15 +347,6 @@ pub fn execute(
212347 "--gossip-validator" ,
213348 ) ?;
214349
215- let bind_addresses = {
216- let parsed = matches
217- . values_of ( "bind_address" )
218- . expect ( "bind_address should always be present due to default" )
219- . map ( solana_net_utils:: parse_host)
220- . collect :: < Result < Vec < _ > , _ > > ( ) ?;
221- BindIpAddrs :: new ( parsed) . map_err ( |err| format ! ( "invalid bind_addresses: {err}" ) ) ?
222- } ;
223-
224350 if bind_addresses. len ( ) > 1 {
225351 for ( flag, msg) in [
226352 (
@@ -277,12 +403,6 @@ pub fn execute(
277403 } else {
278404 AccountShrinkThreshold :: IndividualStore { shrink_ratio }
279405 } ;
280- let entrypoint_addrs = run_args. entrypoints ;
281- for addr in & entrypoint_addrs {
282- if !run_args. socket_addr_space . check ( addr) {
283- Err ( format ! ( "invalid entrypoint address: {addr}" ) ) ?;
284- }
285- }
286406 // TODO: Once entrypoints are updated to return shred-version, this should
287407 // abort if it fails to obtain a shred-version, so that nodes always join
288408 // gossip with a valid shred-version. The code to adopt entrypoint shred
@@ -472,16 +592,6 @@ pub fn execute(
472592 let starting_with_geyser_plugins: bool = on_start_geyser_plugin_config_files. is_some ( )
473593 || matches. is_present ( "geyser_plugin_always_enabled" ) ;
474594
475- let xdp_interface = matches. value_of ( "retransmit_xdp_interface" ) ;
476- let xdp_zero_copy = matches. is_present ( "retransmit_xdp_zero_copy" ) ;
477- let retransmit_xdp = matches. value_of ( "retransmit_xdp_cpu_cores" ) . map ( |cpus| {
478- XdpConfig :: new (
479- xdp_interface,
480- parse_cpu_ranges ( cpus) . unwrap ( ) ,
481- xdp_zero_copy,
482- )
483- } ) ;
484-
485595 let account_paths: Vec < PathBuf > =
486596 if let Ok ( account_paths) = values_t ! ( matches, "account_paths" , String ) {
487597 account_paths
@@ -667,10 +777,6 @@ pub fn execute(
667777 Keypair :: new ( ) . pubkey ( )
668778 } ) ;
669779
670- let dynamic_port_range =
671- solana_net_utils:: parse_port_range ( matches. value_of ( "dynamic_port_range" ) . unwrap ( ) )
672- . expect ( "invalid dynamic_port_range" ) ;
673-
674780 let maximum_local_snapshot_age = value_t_or_exit ! ( matches, "maximum_local_snapshot_age" , u64 ) ;
675781 let minimal_snapshot_download_speed =
676782 value_t_or_exit ! ( matches, "minimal_snapshot_download_speed" , f32 ) ;
@@ -745,95 +851,6 @@ pub fn execute(
745851 } ,
746852 ) ;
747853
748- let advertised_ip = matches
749- . value_of ( "advertised_ip" )
750- . map ( |advertised_ip| {
751- solana_net_utils:: parse_host ( advertised_ip)
752- . map_err ( |err| format ! ( "failed to parse --advertised-ip: {err}" ) )
753- } )
754- . transpose ( ) ?;
755-
756- let advertised_ip = if let Some ( cli_ip) = advertised_ip {
757- cli_ip
758- } else if !bind_addresses. active ( ) . is_unspecified ( ) && !bind_addresses. active ( ) . is_loopback ( ) {
759- bind_addresses. active ( )
760- } else if !entrypoint_addrs. is_empty ( ) {
761- let mut order: Vec < _ > = ( 0 ..entrypoint_addrs. len ( ) ) . collect ( ) ;
762- order. shuffle ( & mut rng ( ) ) ;
763-
764- order
765- . into_iter ( )
766- . find_map ( |i| {
767- let entrypoint_addr = & entrypoint_addrs[ i] ;
768- info ! (
769- "Contacting {entrypoint_addr} to determine the validator's public IP address"
770- ) ;
771- solana_net_utils:: get_public_ip_addr_with_binding (
772- entrypoint_addr,
773- bind_addresses. active ( ) ,
774- )
775- . map_or_else (
776- |err| {
777- warn ! ( "Failed to contact cluster entrypoint {entrypoint_addr}: {err}" ) ;
778- None
779- } ,
780- Some ,
781- )
782- } )
783- . ok_or_else ( || "unable to determine the validator's public IP address" . to_string ( ) ) ?
784- } else {
785- IpAddr :: V4 ( Ipv4Addr :: LOCALHOST )
786- } ;
787- let gossip_port = value_t ! ( matches, "gossip_port" , u16 ) . or_else ( |_| {
788- solana_net_utils:: find_available_port_in_range ( bind_addresses. active ( ) , ( 0 , 1 ) )
789- . map_err ( |err| format ! ( "unable to find an available gossip port: {err}" ) )
790- } ) ?;
791-
792- let public_tpu_addr = matches
793- . value_of ( "public_tpu_addr" )
794- . map ( |public_tpu_addr| {
795- solana_net_utils:: parse_host_port ( public_tpu_addr)
796- . map_err ( |err| format ! ( "failed to parse --public-tpu-address: {err}" ) )
797- } )
798- . transpose ( ) ?;
799-
800- let public_tpu_forwards_addr = matches
801- . value_of ( "public_tpu_forwards_addr" )
802- . map ( |public_tpu_forwards_addr| {
803- solana_net_utils:: parse_host_port ( public_tpu_forwards_addr)
804- . map_err ( |err| format ! ( "failed to parse --public-tpu-forwards-address: {err}" ) )
805- } )
806- . transpose ( ) ?;
807-
808- let public_tvu_addr = matches
809- . value_of ( "public_tvu_addr" )
810- . map ( |public_tvu_addr| {
811- solana_net_utils:: parse_host_port ( public_tvu_addr)
812- . map_err ( |err| format ! ( "failed to parse --public-tvu-address: {err}" ) )
813- } )
814- . transpose ( ) ?;
815-
816- if bind_addresses. len ( ) > 1 && public_tvu_addr. is_some ( ) {
817- Err ( String :: from (
818- "--public-tvu-address can not be used in a multihoming context" ,
819- ) ) ?;
820- }
821-
822- let tpu_vortexor_receiver_address =
823- matches
824- . value_of ( "tpu_vortexor_receiver_address" )
825- . map ( |tpu_vortexor_receiver_address| {
826- solana_net_utils:: parse_host_port ( tpu_vortexor_receiver_address) . unwrap_or_else (
827- |err| {
828- eprintln ! ( "Failed to parse --tpu-vortexor-receiver-address: {err}" ) ;
829- exit ( 1 ) ;
830- } ,
831- )
832- } ) ;
833-
834- info ! ( "tpu_vortexor_receiver_address is {tpu_vortexor_receiver_address:?}" ) ;
835- let num_quic_endpoints = value_t_or_exit ! ( matches, "num_quic_endpoints" , NonZeroUsize ) ;
836-
837854 let tpu_max_connections_per_peer: Option < u64 > = matches
838855 . value_of ( "tpu_max_connections_per_peer" )
839856 . and_then ( |v| v. parse ( ) . ok ( ) ) ;
@@ -854,27 +871,11 @@ pub fn execute(
854871 value_t_or_exit ! ( matches, "tpu_max_connections_per_ipaddr_per_minute" , u64 ) ;
855872 let max_streams_per_ms = value_t_or_exit ! ( matches, "tpu_max_streams_per_ms" , u64 ) ;
856873
857- let node_config = NodeConfig {
858- advertised_ip,
859- gossip_port,
860- port_range : dynamic_port_range,
861- bind_ip_addrs : bind_addresses,
862- public_tpu_addr,
863- public_tpu_forwards_addr,
864- public_tvu_addr,
865- num_tvu_receive_sockets : tvu_receive_threads,
866- num_tvu_retransmit_sockets : tvu_retransmit_threads,
867- num_quic_endpoints,
868- vortexor_receiver_addr : tpu_vortexor_receiver_address,
869- } ;
870-
871874 let cluster_entrypoints = entrypoint_addrs
872875 . iter ( )
873876 . map ( ContactInfo :: new_gossip_entry_point)
874877 . collect :: < Vec < _ > > ( ) ;
875878
876- let mut node = Node :: new_with_external_ip ( & identity_keypair. pubkey ( ) , node_config) ;
877-
878879 if restricted_repair_only_mode {
879880 if validator_config. wen_restart_proto_path . is_some ( ) {
880881 Err ( "--restricted-repair-only-mode is not compatible with --wen_restart" . to_string ( ) ) ?;
0 commit comments