@@ -36,7 +36,7 @@ use rollup_node_providers::{
3636use rollup_node_sequencer:: {
3737 L1MessageInclusionMode , PayloadBuildingConfig , Sequencer , SequencerConfig ,
3838} ;
39- use rollup_node_watcher:: { L1Watcher , L1WatcherHandle } ;
39+ use rollup_node_watcher:: { L1Watcher , L1WatcherCommand } ;
4040use scroll_alloy_hardforks:: ScrollHardforks ;
4141use scroll_alloy_network:: Scroll ;
4242use scroll_alloy_provider:: { ScrollAuthApiEngineClient , ScrollEngineApi } ;
@@ -52,12 +52,23 @@ use scroll_wire::ScrollWireEvent;
5252use std:: { fs, path:: PathBuf , sync:: Arc } ;
5353use tokio:: sync:: mpsc:: UnboundedReceiver ;
5454
55- /// A struct that represents the arguments for the rollup node .
56- #[ derive( Debug , Clone , clap:: Args ) ]
57- pub struct ScrollRollupNodeConfig {
55+ /// Test-related configuration arguments.
56+ #[ derive( Debug , Clone , Default , clap:: Args ) ]
57+ pub struct TestArgs {
5858 /// Whether the rollup node should be run in test mode.
5959 #[ arg( long) ]
6060 pub test : bool ,
61+ /// Test mode: skip L1 watcher Synced notifications.
62+ #[ arg( long, default_value = "false" ) ]
63+ pub skip_l1_synced : bool ,
64+ }
65+
66+ /// A struct that represents the arguments for the rollup node.
67+ #[ derive( Debug , Clone , clap:: Args ) ]
68+ pub struct ScrollRollupNodeConfig {
69+ /// Test-related arguments
70+ #[ command( flatten) ]
71+ pub test_args : TestArgs ,
6172 /// Consensus args
6273 #[ command( flatten) ]
6374 pub consensus_args : ConsensusArgs ,
@@ -152,6 +163,7 @@ impl ScrollRollupNodeConfig {
152163 ) -> eyre:: Result < ( ) > {
153164 // Instantiate the database
154165 let db_path = node_config. datadir ( ) . db ( ) ;
166+
155167 let database_path = if let Some ( database_path) = & self . database_args . rn_db_path {
156168 database_path. to_string_lossy ( ) . to_string ( )
157169 } else {
@@ -274,7 +286,7 @@ impl ScrollRollupNodeConfig {
274286 // Run the database migrations
275287 if let Some ( named) = chain_spec. chain ( ) . named ( ) {
276288 named
277- . migrate ( db. inner ( ) . get_connection ( ) , self . test )
289+ . migrate ( db. inner ( ) . get_connection ( ) , self . test_args . test )
278290 . await
279291 . expect ( "failed to perform migration" ) ;
280292 } else {
@@ -388,51 +400,44 @@ impl ScrollRollupNodeConfig {
388400 } ;
389401 let consensus = self . consensus_args . consensus ( authorized_signer) ?;
390402
391- // Define some types to support definitions of return type of following function in no_std.
392- #[ cfg( feature = "test-utils" ) ]
393- type L1WatcherMockOpt = Option < rollup_node_watcher:: test_utils:: L1WatcherMock > ;
394-
395- #[ cfg( not( feature = "test-utils" ) ) ]
396- type L1WatcherMockOpt = Option < std:: convert:: Infallible > ;
397-
398- let ( _l1_watcher_mock, l1_watcher_handle) : ( L1WatcherMockOpt , Option < L1WatcherHandle > ) =
399- if let Some ( provider) = l1_provider. filter ( |_| !self . test ) {
400- tracing:: info!( target: "scroll::node::args" , ?l1_block_startup_info, "Starting L1 watcher" ) ;
401- (
402- None ,
403- Some (
404- L1Watcher :: spawn (
405- provider,
406- l1_block_startup_info,
407- node_config,
408- self . l1_provider_args . logs_query_block_range ,
409- self . l1_provider_args . liveness_threshold ,
410- self . l1_provider_args . liveness_check_interval ,
411- )
412- . await ,
413- ) ,
414- )
415- } else {
416- // Create a channel for L1 notifications that we can use to inject L1 messages for
417- // testing
403+ let is_anvil_provider = self . blob_provider_args . anvil_url . is_some ( ) ;
404+
405+ let ( _l1_notification_tx, _l1_command_rx, l1_watcher_handle) : ( _ , _ , _ ) = if let Some (
406+ provider,
407+ ) =
408+ l1_provider. filter ( |_| !self . test_args . test || is_anvil_provider)
409+ {
410+ tracing:: info!( target: "scroll::node::args" , ?l1_block_startup_info, "Starting L1 watcher" ) ;
411+
412+ let ( notification_tx, handle) = L1Watcher :: spawn (
413+ provider,
414+ l1_block_startup_info,
415+ node_config,
416+ self . l1_provider_args . logs_query_block_range ,
417+ self . l1_provider_args . liveness_threshold ,
418+ self . l1_provider_args . liveness_check_interval ,
418419 #[ cfg( feature = "test-utils" ) ]
419- {
420- let ( notification_tx, notification_rx) = tokio:: sync:: mpsc:: channel ( 1000 ) ;
421- let ( command_tx, command_rx) = tokio:: sync:: mpsc:: unbounded_channel ( ) ;
422- let handle =
423- rollup_node_watcher:: L1WatcherHandle :: new ( command_tx, notification_rx) ;
424- let watcher_mock = rollup_node_watcher:: test_utils:: L1WatcherMock {
425- command_rx : Arc :: new ( tokio:: sync:: Mutex :: new ( command_rx) ) ,
426- notification_tx,
427- } ;
428- ( Some ( watcher_mock) , Some ( handle) )
429- }
420+ self . test_args . skip_l1_synced ,
421+ )
422+ . await ;
423+ ( Some ( notification_tx) , None :: < UnboundedReceiver < L1WatcherCommand > > , Some ( handle) )
424+ } else {
425+ // Create a channel for L1 notifications that we can use to inject L1 messages for
426+ // testing
427+ #[ cfg( feature = "test-utils" ) ]
428+ {
429+ let ( notification_tx, notification_rx) = tokio:: sync:: mpsc:: channel ( 1000 ) ;
430+ let ( command_tx, command_rx) = tokio:: sync:: mpsc:: unbounded_channel ( ) ;
431+ let handle = rollup_node_watcher:: L1WatcherHandle :: new ( command_tx, notification_rx) ;
430432
431- #[ cfg( not( feature = "test-utils" ) ) ]
432- {
433- ( None , None )
434- }
435- } ;
433+ ( Some ( notification_tx) , Some ( command_rx) , Some ( handle) )
434+ }
435+
436+ #[ cfg( not( feature = "test-utils" ) ) ]
437+ {
438+ ( None , None , None )
439+ }
440+ } ;
436441
437442 // Construct the l1 provider.
438443 let l1_messages_provider = db. clone ( ) ;
@@ -474,7 +479,7 @@ impl ScrollRollupNodeConfig {
474479 let signer = if let Some ( configured_signer) = self . signer_args . signer ( chain_id) . await ? {
475480 // Use the signer configured by SignerArgs
476481 Some ( rollup_node_signer:: Signer :: spawn ( configured_signer) )
477- } else if self . test {
482+ } else if self . test_args . test {
478483 // Use a random private key signer for testing
479484 Some ( rollup_node_signer:: Signer :: spawn ( PrivateKeySigner :: random ( ) ) )
480485 } else {
@@ -522,7 +527,14 @@ impl ScrollRollupNodeConfig {
522527 . await ?;
523528
524529 #[ cfg( feature = "test-utils" ) ]
525- let handle = handle. with_l1_watcher_mock ( _l1_watcher_mock) ;
530+ let handle = {
531+ let command_rx = _l1_command_rx. map ( |rx| Arc :: new ( tokio:: sync:: Mutex :: new ( rx) ) ) ;
532+ let l1_watcher_mock = rollup_node_watcher:: test_utils:: L1WatcherMock {
533+ command_rx,
534+ notification_tx : _l1_notification_tx. expect ( "L1 notification sender should be set" ) ,
535+ } ;
536+ handle. with_l1_watcher_mock ( Some ( l1_watcher_mock) )
537+ } ;
526538
527539 Ok ( ( chain_orchestrator, handle) )
528540 }
@@ -1036,7 +1048,7 @@ mod tests {
10361048 #[ test]
10371049 fn test_validate_sequencer_enabled_without_any_signer_fails ( ) {
10381050 let config = ScrollRollupNodeConfig {
1039- test : false ,
1051+ test_args : TestArgs :: default ( ) ,
10401052 sequencer_args : SequencerArgs { sequencer_enabled : true , ..Default :: default ( ) } ,
10411053 signer_args : SignerArgs { key_file : None , aws_kms_key_id : None , private_key : None } ,
10421054 database_args : RollupNodeDatabaseArgs :: default ( ) ,
@@ -1067,7 +1079,7 @@ mod tests {
10671079 #[ test]
10681080 fn test_validate_remote_source_enabled_without_url_fails ( ) {
10691081 let config = ScrollRollupNodeConfig {
1070- test : false ,
1082+ test_args : TestArgs :: default ( ) ,
10711083 sequencer_args : SequencerArgs :: default ( ) ,
10721084 signer_args : SignerArgs :: default ( ) ,
10731085 database_args : RollupNodeDatabaseArgs :: default ( ) ,
@@ -1099,7 +1111,7 @@ mod tests {
10991111 #[ test]
11001112 fn test_validate_sequencer_enabled_with_both_signers_fails ( ) {
11011113 let config = ScrollRollupNodeConfig {
1102- test : false ,
1114+ test_args : TestArgs :: default ( ) ,
11031115 sequencer_args : SequencerArgs { sequencer_enabled : true , ..Default :: default ( ) } ,
11041116 signer_args : SignerArgs {
11051117 key_file : Some ( PathBuf :: from ( "/path/to/key" ) ) ,
@@ -1132,7 +1144,7 @@ mod tests {
11321144 #[ test]
11331145 fn test_validate_sequencer_enabled_with_key_file_succeeds ( ) {
11341146 let config = ScrollRollupNodeConfig {
1135- test : false ,
1147+ test_args : TestArgs :: default ( ) ,
11361148 sequencer_args : SequencerArgs { sequencer_enabled : true , ..Default :: default ( ) } ,
11371149 signer_args : SignerArgs {
11381150 key_file : Some ( PathBuf :: from ( "/path/to/key" ) ) ,
@@ -1160,7 +1172,7 @@ mod tests {
11601172 #[ test]
11611173 fn test_validate_sequencer_enabled_with_aws_kms_succeeds ( ) {
11621174 let config = ScrollRollupNodeConfig {
1163- test : false ,
1175+ test_args : TestArgs :: default ( ) ,
11641176 sequencer_args : SequencerArgs { sequencer_enabled : true , ..Default :: default ( ) } ,
11651177 signer_args : SignerArgs {
11661178 key_file : None ,
@@ -1188,7 +1200,7 @@ mod tests {
11881200 #[ test]
11891201 fn test_validate_sequencer_disabled_without_any_signer_succeeds ( ) {
11901202 let config = ScrollRollupNodeConfig {
1191- test : false ,
1203+ test_args : TestArgs :: default ( ) ,
11921204 sequencer_args : SequencerArgs { sequencer_enabled : false , ..Default :: default ( ) } ,
11931205 signer_args : SignerArgs { key_file : None , aws_kms_key_id : None , private_key : None } ,
11941206 database_args : RollupNodeDatabaseArgs :: default ( ) ,
0 commit comments