@@ -325,16 +325,28 @@ where
325325 if latest. header . number != self . current_block_number {
326326 // index the next range of blocks.
327327 let logs = self . next_filtered_logs ( latest. header . number ) . await ?;
328+ let num_logs = logs. len ( ) ;
328329
329330 // prepare notifications.
330331 let mut notifications = Vec :: with_capacity ( logs. len ( ) ) ;
331332
332- // handle all events.
333- notifications. extend ( self . handle_l1_messages ( & logs) . await ?) ;
334- notifications. extend ( self . handle_batch_reverts ( & logs) . await ?) ;
335- notifications. extend ( self . handle_batch_revert_ranges ( & logs) . await ?) ;
336- notifications. extend ( self . handle_batch_commits ( & logs) . await ?) ;
337- notifications. extend ( self . handle_batch_finalization ( & logs) . await ?) ;
333+ for log in logs {
334+ let sig = log. topics ( ) [ 0 ] ;
335+
336+ let notification = match sig {
337+ QueueTransaction :: SIGNATURE_HASH => self . handle_l1_messages ( & [ log] ) . await ?,
338+ CommitBatch :: SIGNATURE_HASH => self . handle_batch_commits ( & [ log] ) . await ?,
339+ FinalizeBatch :: SIGNATURE_HASH => self . handle_batch_finalization ( & [ log] ) . await ?,
340+ RevertBatch_0 :: SIGNATURE_HASH => self . handle_batch_reverts ( & [ log] ) . await ?,
341+ RevertBatch_1 :: SIGNATURE_HASH => {
342+ self . handle_batch_revert_ranges ( & [ log] ) . await ?
343+ }
344+ _ => unreachable ! ( "log signature already filtered" ) ,
345+ } ;
346+
347+ notifications. extend ( notification) ;
348+ }
349+
338350 if let Some ( system_contract_update) =
339351 self . handle_system_contract_update ( & latest) . await ?
340352 {
@@ -344,9 +356,9 @@ where
344356 // Check that we haven't generated more notifications than logs
345357 // Note: notifications.len() may be less than logs.len() because genesis batch
346358 // (batch_index=0) is intentionally skipped
347- if notifications. len ( ) > logs . len ( ) {
359+ if notifications. len ( ) > num_logs {
348360 return Err ( L1WatcherError :: Logs ( FilterLogError :: InvalidNotificationCount (
349- logs . len ( ) ,
361+ num_logs ,
350362 notifications. len ( ) ,
351363 ) ) )
352364 }
0 commit comments