1- use alloy_rpc_types_engine:: JwtSecret ;
21use clap:: Parser ;
3- use eyre:: bail;
42use jsonrpsee:: { RpcModule , server:: Server } ;
5- use parking_lot:: Mutex ;
6- use std:: {
7- net:: { IpAddr , SocketAddr } ,
8- path:: PathBuf ,
9- str:: FromStr ,
10- sync:: Arc ,
11- } ;
3+ use std:: { net:: SocketAddr , path:: PathBuf } ;
124use tokio:: signal:: unix:: { SignalKind , signal as unix_signal} ;
135use tracing:: { Level , info} ;
146
157use crate :: {
16- BlockSelectionPolicy , Flashblocks , FlashblocksArgs , ProxyLayer , RollupBoostServer , RpcClient ,
8+ BlockSelectionPolicy , ClientArgs , DebugServer , FlashblocksArgs , PayloadSource , ProxyLayer ,
9+ RollupBoostServer ,
1710 client:: rpc:: { BuilderArgs , L2ClientArgs } ,
1811 debug_api:: ExecutionMode ,
1912 get_version, init_metrics,
20- payload:: PayloadSource ,
2113 probe:: ProbeLayer ,
2214} ;
15+ use crate :: { FlashblocksService , RpcClient } ;
2316
2417#[ derive( Clone , Parser , Debug ) ]
2518#[ clap( author, version = get_version( ) , about) ]
@@ -112,90 +105,34 @@ impl RollupBoostArgs {
112105 init_metrics ( & self ) ?;
113106
114107 let debug_addr = format ! ( "{}:{}" , self . debug_host, self . debug_server_port) ;
115- let l2_client_args = self . l2_client ;
116-
117- let l2_auth_jwt = if let Some ( secret) = l2_client_args. l2_jwt_token {
118- secret
119- } else if let Some ( path) = l2_client_args. l2_jwt_path . as_ref ( ) {
120- JwtSecret :: from_file ( path) ?
121- } else {
122- bail ! ( "Missing L2 Client JWT secret" ) ;
123- } ;
108+ let l2_client_args: ClientArgs = self . l2_client . clone ( ) . into ( ) ;
109+ let l2_http_client = l2_client_args. new_http_client ( PayloadSource :: L2 ) ?;
124110
125- let l2_client = RpcClient :: new (
126- l2_client_args. l2_url . clone ( ) ,
127- l2_auth_jwt,
128- l2_client_args. l2_timeout ,
129- PayloadSource :: L2 ,
130- ) ?;
131-
132- let builder_args = self . builder ;
133- let builder_auth_jwt = if let Some ( secret) = builder_args. builder_jwt_token {
134- secret
135- } else if let Some ( path) = builder_args. builder_jwt_path . as_ref ( ) {
136- JwtSecret :: from_file ( path) ?
137- } else {
138- bail ! ( "Missing Builder JWT secret" ) ;
139- } ;
140-
141- let builder_client = RpcClient :: new (
142- builder_args. builder_url . clone ( ) ,
143- builder_auth_jwt,
144- builder_args. builder_timeout ,
145- PayloadSource :: Builder ,
146- ) ?;
111+ let builder_client_args: ClientArgs = self . builder . clone ( ) . into ( ) ;
112+ let builder_http_client = builder_client_args. new_http_client ( PayloadSource :: Builder ) ?;
147113
148114 let ( probe_layer, probes) = ProbeLayer :: new ( ) ;
149- let execution_mode = Arc :: new ( Mutex :: new ( self . execution_mode ) ) ;
150-
151- let ( rpc_module, health_handle) : ( RpcModule < ( ) > , _ ) = if self . flashblocks . flashblocks {
152- let flashblocks_args = self . flashblocks ;
153- let inbound_url = flashblocks_args. flashblocks_builder_url ;
154- let outbound_addr = SocketAddr :: new (
155- IpAddr :: from_str ( & flashblocks_args. flashblocks_host ) ?,
156- flashblocks_args. flashblocks_port ,
157- ) ;
158-
159- let builder_client = Arc :: new ( Flashblocks :: run (
160- builder_client. clone ( ) ,
161- inbound_url,
162- outbound_addr,
163- flashblocks_args. flashblock_builder_ws_reconnect_ms ,
164- ) ?) ;
165-
166- let rollup_boost = RollupBoostServer :: new (
167- l2_client,
168- builder_client,
169- execution_mode. clone ( ) ,
170- self . block_selection_policy ,
171- probes. clone ( ) ,
172- self . external_state_root ,
173- self . ignore_unhealthy_builders ,
174- ) ;
175115
116+ let ( health_handle, rpc_module) = if self . flashblocks . flashblocks {
117+ let rollup_boost = RollupBoostServer :: < FlashblocksService > :: new_from_args (
118+ self . clone ( ) ,
119+ probes. clone ( ) ,
120+ ) ?;
176121 let health_handle = rollup_boost
177122 . spawn_health_check ( self . health_check_interval , self . max_unsafe_interval ) ;
178-
179- // Spawn the debug server
180- rollup_boost. start_debug_server ( debug_addr . as_str ( ) ) . await ?;
181- ( rollup_boost . try_into ( ) ? , health_handle )
123+ let debug_server = DebugServer :: new ( rollup_boost . execution_mode . clone ( ) ) ;
124+ debug_server . run ( & debug_addr ) . await ? ;
125+ let rpc_module : RpcModule < ( ) > = rollup_boost. try_into ( ) ?;
126+ ( health_handle , rpc_module )
182127 } else {
183- let rollup_boost = RollupBoostServer :: new (
184- l2_client,
185- Arc :: new ( builder_client) ,
186- execution_mode. clone ( ) ,
187- self . block_selection_policy ,
188- probes. clone ( ) ,
189- self . external_state_root ,
190- self . ignore_unhealthy_builders ,
191- ) ;
192-
128+ let rollup_boost =
129+ RollupBoostServer :: < RpcClient > :: new_from_args ( self . clone ( ) , probes. clone ( ) ) ?;
193130 let health_handle = rollup_boost
194131 . spawn_health_check ( self . health_check_interval , self . max_unsafe_interval ) ;
195-
196- // Spawn the debug server
197- rollup_boost. start_debug_server ( debug_addr . as_str ( ) ) . await ?;
198- ( rollup_boost . try_into ( ) ? , health_handle )
132+ let debug_server = DebugServer :: new ( rollup_boost . execution_mode . clone ( ) ) ;
133+ debug_server . run ( & debug_addr ) . await ? ;
134+ let rpc_module : RpcModule < ( ) > = rollup_boost. try_into ( ) ?;
135+ ( health_handle , rpc_module )
199136 } ;
200137
201138 // Build and start the server
@@ -205,12 +142,8 @@ impl RollupBoostArgs {
205142 tower:: ServiceBuilder :: new ( )
206143 . layer ( probe_layer)
207144 . layer ( ProxyLayer :: new (
208- l2_client_args. l2_url ,
209- l2_auth_jwt,
210- l2_client_args. l2_timeout ,
211- builder_args. builder_url ,
212- builder_auth_jwt,
213- builder_args. builder_timeout ,
145+ l2_http_client. clone ( ) ,
146+ builder_http_client. clone ( ) ,
214147 ) ) ;
215148
216149 let server = Server :: builder ( )
@@ -247,6 +180,12 @@ impl RollupBoostArgs {
247180 }
248181}
249182
183+ impl Default for RollupBoostArgs {
184+ fn default ( ) -> Self {
185+ Self :: parse_from :: < _ , & str > ( std:: iter:: empty ( ) )
186+ }
187+ }
188+
250189#[ derive( Clone , Debug ) ]
251190pub enum LogFormat {
252191 Json ,
0 commit comments