File tree Expand file tree Collapse file tree 5 files changed +34
-3
lines changed
Expand file tree Collapse file tree 5 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -415,6 +415,10 @@ impl<
415415 self . engine . update_fcs ( None , Some ( block_info) , None ) . await ?;
416416 }
417417 }
418+
419+ // Revert the L1 watcher to the specified block.
420+ self . l1_watcher . revert_to_l1_block ( block_number) ;
421+
418422 self . notify ( ChainOrchestratorEvent :: UnwoundToL1Block ( block_number) ) ;
419423 let _ = tx. send ( true ) ;
420424 }
Original file line number Diff line number Diff line change @@ -1025,6 +1025,16 @@ async fn can_revert_to_l1_block() -> eyre::Result<()> {
10251025 // Wait for the chain to be unwound
10261026 fixture. expect_event ( ) . revert_to_l1_block ( ) . await ?;
10271027
1028+ // Now have the L1 watcher mock handle the command to rewind the L1 head.
1029+ fixture
1030+ . follower ( 0 )
1031+ . rollup_manager_handle
1032+ . l1_watcher_mock
1033+ . as_mut ( )
1034+ . unwrap ( )
1035+ . handle_command ( )
1036+ . await ;
1037+
10281038 // Get the node status
10291039 let status = fixture. get_status ( 0 ) . await ?;
10301040
Original file line number Diff line number Diff line change @@ -34,13 +34,15 @@ impl L1WatcherHandle {
3434 }
3535
3636 /// Reset the L1 Watcher to a specific block number with a fresh notification channel.
37- pub fn revert_to_l1_block ( & self , block : u64 ) -> mpsc :: Receiver < Arc < L1Notification > > {
37+ pub fn revert_to_l1_block ( & mut self , block : u64 ) {
3838 // Create a fresh notification channel with the same capacity as the original channel
3939 let capacity = self . l1_notification_rx . max_capacity ( ) ;
4040 let ( tx, rx) = mpsc:: channel ( capacity) ;
4141
42+ // Send the reset command to the watcher
4243 self . send_command ( L1WatcherCommand :: ResetToBlock { block, tx } ) ;
4344
44- rx
45+ // Replace the old receiver with the new one
46+ self . l1_notification_rx = rx;
4547 }
4648}
Original file line number Diff line number Diff line change @@ -338,7 +338,6 @@ where
338338
339339 // reset the state.
340340 self . current_block_number = block;
341- self . unfinalized_blocks . clear ( ) ;
342341 self . is_synced = false ;
343342
344343 // replace the notification sender.
Original file line number Diff line number Diff line change @@ -21,6 +21,22 @@ pub struct L1WatcherMock {
2121 pub notification_tx : mpsc:: Sender < Arc < L1Notification > > ,
2222}
2323
24+ impl L1WatcherMock {
25+ /// Handle commands sent to the L1 watcher mock.
26+ pub async fn handle_command ( & mut self ) {
27+ let mut commands = self . command_rx . lock ( ) . await ;
28+ if let Some ( command) = commands. recv ( ) . await {
29+ match command {
30+ L1WatcherCommand :: ResetToBlock { block, tx } => {
31+ // For testing purposes, we can just log the reset action.
32+ tracing:: info!( target: "scroll::watcher::test_utils" , "L1 Watcher Mock resetting to block {}" , block) ;
33+ self . notification_tx = tx;
34+ }
35+ }
36+ }
37+ }
38+ }
39+
2440/// Returns a chain of random headers of size `len`.
2541pub fn chain ( len : usize ) -> ( Header , Header , Vec < Header > ) {
2642 assert ! ( len >= 2 , "chain should have a minimal length of two" ) ;
You can’t perform that action at this time.
0 commit comments