@@ -6,7 +6,6 @@ use crate::{
66use scroll_migration:: MigratorTrait ;
77use std:: { fs, path:: PathBuf , sync:: Arc } ;
88
9- use super :: test_utils:: l1_helpers:: L1WatcherMock ;
109use alloy_chains:: NamedChain ;
1110use alloy_primitives:: { hex, Address , U128 } ;
1211use alloy_provider:: { layers:: CacheLayer , Provider , ProviderBuilder } ;
@@ -167,7 +166,6 @@ impl ScrollRollupNodeConfig {
167166 impl ScrollEngineApi ,
168167 > ,
169168 ChainOrchestratorHandle < N > ,
170- Option < L1WatcherMock > ,
171169 ) >
172170 where
173171 N : FullNetwork < Primitives = ScrollNetworkPrimitives > + NetworkProtocols ,
@@ -351,42 +349,49 @@ impl ScrollRollupNodeConfig {
351349 } ;
352350 let consensus = self . consensus_args . consensus ( authorized_signer) ?;
353351
354- let ( l1_watcher_mock, l1_watcher_handle) = if let Some ( provider) =
355- l1_provider. filter ( |_| !self . test )
356- {
357- tracing:: info!( target: "scroll::node::args" , ?l1_block_startup_info, "Starting L1 watcher" ) ;
358- (
359- None ,
360- Some (
361- L1Watcher :: spawn (
362- provider,
363- l1_block_startup_info,
364- node_config,
365- self . l1_provider_args . logs_query_block_range ,
366- )
367- . await ,
368- ) ,
369- )
370- } else {
371- // Create a channel for L1 notifications that we can use to inject L1 messages for
372- // testing
373- #[ cfg( feature = "test-utils" ) ]
374- {
375- let ( notification_tx, notification_rx) = tokio:: sync:: mpsc:: channel ( 1000 ) ;
376- let ( command_tx, command_rx) = tokio:: sync:: mpsc:: unbounded_channel ( ) ;
377- let handle = L1WatcherHandle :: new ( command_tx, notification_rx) ;
378- let watcher_mock = L1WatcherMock {
379- command_rx : Arc :: new ( tokio:: sync:: Mutex :: new ( command_rx) ) ,
380- notification_tx,
381- } ;
382- ( Some ( watcher_mock) , Some ( handle) )
383- }
384-
385- #[ cfg( not( feature = "test-utils" ) ) ]
386- {
387- ( None , None )
388- }
389- } ;
352+ // Define some types to support definitions of return type of following function in no_std.
353+ #[ cfg( feature = "test-utils" ) ]
354+ type L1WatcherMockOpt = Option < rollup_node_watcher:: test_utils:: L1WatcherMock > ;
355+
356+ #[ cfg( not( feature = "test-utils" ) ) ]
357+ type L1WatcherMockOpt = Option < std:: convert:: Infallible > ;
358+
359+ let ( _l1_watcher_mock, l1_watcher_handle) : ( L1WatcherMockOpt , Option < L1WatcherHandle > ) =
360+ if let Some ( provider) = l1_provider. filter ( |_| !self . test ) {
361+ tracing:: info!( target: "scroll::node::args" , ?l1_block_startup_info, "Starting L1 watcher" ) ;
362+ (
363+ None ,
364+ Some (
365+ L1Watcher :: spawn (
366+ provider,
367+ l1_block_startup_info,
368+ node_config,
369+ self . l1_provider_args . logs_query_block_range ,
370+ )
371+ . await ,
372+ ) ,
373+ )
374+ } else {
375+ // Create a channel for L1 notifications that we can use to inject L1 messages for
376+ // testing
377+ #[ cfg( feature = "test-utils" ) ]
378+ {
379+ let ( notification_tx, notification_rx) = tokio:: sync:: mpsc:: channel ( 1000 ) ;
380+ let ( command_tx, command_rx) = tokio:: sync:: mpsc:: unbounded_channel ( ) ;
381+ let handle =
382+ rollup_node_watcher:: L1WatcherHandle :: new ( command_tx, notification_rx) ;
383+ let watcher_mock = rollup_node_watcher:: test_utils:: L1WatcherMock {
384+ command_rx : Arc :: new ( tokio:: sync:: Mutex :: new ( command_rx) ) ,
385+ notification_tx,
386+ } ;
387+ ( Some ( watcher_mock) , Some ( handle) )
388+ }
389+
390+ #[ cfg( not( feature = "test-utils" ) ) ]
391+ {
392+ ( None , None )
393+ }
394+ } ;
390395
391396 // Construct the l1 provider.
392397 let l1_messages_provider = db. clone ( ) ;
@@ -475,7 +480,10 @@ impl ScrollRollupNodeConfig {
475480 )
476481 . await ?;
477482
478- Ok ( ( chain_orchestrator, handle, l1_watcher_mock) )
483+ #[ cfg( feature = "test-utils" ) ]
484+ let handle = handle. with_l1_watcher_mock ( _l1_watcher_mock) ;
485+
486+ Ok ( ( chain_orchestrator, handle) )
479487 }
480488}
481489
0 commit comments