2727 pubkey:: Pubkey , saturating_add_assign, signature:: Signer , signer:: keypair:: Keypair ,
2828 } ,
2929 std:: {
30+ net:: { IpAddr , Ipv4Addr } ,
3031 str:: FromStr ,
3132 sync:: {
3233 atomic:: { AtomicBool , Ordering } ,
@@ -74,13 +75,27 @@ pub struct BlockBuilderFeeInfo {
7475 pub block_builder_commission : u64 ,
7576}
7677
77- #[ derive( Clone , Debug , Default , PartialEq , Eq ) ]
78+ #[ derive( Clone , Debug , PartialEq , Eq ) ]
7879pub struct BlockEngineConfig {
7980 /// Block Engine URL
8081 pub block_engine_url : String ,
8182
8283 /// If set then it will be assumed the backend verified packets so signature verification will be bypassed in the validator.
8384 pub trust_packets : bool ,
85+
86+ /// Address of local interface to bind socket. Set from cli arg in solana-validator.
87+ /// Needed for e.g. connecting over double zero.
88+ pub bind_address : IpAddr ,
89+ }
90+
91+ impl Default for BlockEngineConfig {
92+ fn default ( ) -> Self {
93+ Self {
94+ block_engine_url : String :: default ( ) ,
95+ trust_packets : bool:: default ( ) ,
96+ bind_address : IpAddr :: from ( Ipv4Addr :: UNSPECIFIED ) ,
97+ }
98+ }
8499}
85100
86101pub struct BlockEngineStage {
@@ -228,14 +243,24 @@ impl BlockEngineStage {
228243 } ) ?;
229244 }
230245
246+ // Create connector for block-engine connection to respect cli bind-addr.
247+ let local_ip: IpAddr = local_block_engine_config. bind_address ;
248+ let mut http = hyper:: client:: connect:: HttpConnector :: new ( ) ;
249+ http. enforce_http ( false ) ;
250+ http. set_local_address ( Some ( local_ip) ) ;
251+
231252 debug ! (
232253 "connecting to auth: {}" ,
233254 local_block_engine_config. block_engine_url
234255 ) ;
235- let auth_channel = timeout ( * connection_timeout, backend_endpoint. connect ( ) )
236- . await
237- . map_err ( |_| ProxyError :: AuthenticationConnectionTimeout ) ?
238- . map_err ( |e| ProxyError :: AuthenticationConnectionError ( e. to_string ( ) ) ) ?;
256+
257+ let auth_channel = timeout (
258+ * connection_timeout,
259+ backend_endpoint. connect_with_connector ( http. clone ( ) ) ,
260+ )
261+ . await
262+ . map_err ( |_| ProxyError :: AuthenticationConnectionTimeout ) ?
263+ . map_err ( |e| ProxyError :: AuthenticationConnectionError ( e. to_string ( ) ) ) ?;
239264
240265 let mut auth_client = AuthServiceClient :: new ( auth_channel) ;
241266
@@ -257,10 +282,14 @@ impl BlockEngineStage {
257282 "connecting to block engine: {}" ,
258283 local_block_engine_config. block_engine_url
259284 ) ;
260- let block_engine_channel = timeout ( * connection_timeout, backend_endpoint. connect ( ) )
261- . await
262- . map_err ( |_| ProxyError :: BlockEngineConnectionTimeout ) ?
263- . map_err ( |e| ProxyError :: BlockEngineConnectionError ( e. to_string ( ) ) ) ?;
285+
286+ let block_engine_channel = timeout (
287+ * connection_timeout,
288+ backend_endpoint. connect_with_connector ( http) ,
289+ )
290+ . await
291+ . map_err ( |_| ProxyError :: BlockEngineConnectionTimeout ) ?
292+ . map_err ( |e| ProxyError :: BlockEngineConnectionError ( e. to_string ( ) ) ) ?;
264293
265294 let access_token = Arc :: new ( Mutex :: new ( access_token) ) ;
266295 let block_engine_client = BlockEngineValidatorClient :: with_interceptor (
0 commit comments