@@ -58,6 +58,9 @@ pub trait DatabaseWriteOperations {
5858 /// Insert an [`L1MessageEnvelope`] into the database.
5959 async fn insert_l1_message ( & self , l1_message : L1MessageEnvelope ) -> Result < ( ) , DatabaseError > ;
6060
61+ /// Sets the `skipped` column to true for the provided list of L1 messages queue indexes.
62+ async fn update_skipped_l1_messages ( & self , indexes : Vec < u64 > ) -> Result < ( ) , DatabaseError > ;
63+
6164 /// Delete all [`L1MessageEnvelope`]s with a block number greater than the provided block
6265 /// number and return them.
6366 async fn delete_l1_messages_gt (
@@ -329,6 +332,15 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
329332 }
330333 }
331334
335+ async fn update_skipped_l1_messages ( & self , indexes : Vec < u64 > ) -> Result < ( ) , DatabaseError > {
336+ Ok ( models:: l1_message:: Entity :: update_many ( )
337+ . col_expr ( models:: l1_message:: Column :: Skipped , Expr :: value ( true ) )
338+ . filter ( models:: l1_message:: Column :: QueueIndex . is_in ( indexes. iter ( ) . map ( |& x| x as i64 ) ) )
339+ . exec ( self . get_connection ( ) )
340+ . await
341+ . map ( |_| ( ) ) ?)
342+ }
343+
332344 async fn delete_l1_messages_gt (
333345 & self ,
334346 l1_block_number : u64 ,
@@ -531,6 +543,7 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
531543 self . insert_block ( block. block_info , outcome. batch_info ) . await ?;
532544 self . update_l1_messages_with_l2_block ( block) . await ?;
533545 }
546+ self . update_skipped_l1_messages ( outcome. skipped_l1_messages ) . await ?;
534547 Ok ( ( ) )
535548 }
536549
@@ -867,9 +880,10 @@ impl<T: ReadConnectionProvider + Sync + ?Sized> DatabaseReadOperations for T {
867880
868881 // Create a filter condition for messages that have an L1 block number less than or
869882 // equal to the finalized block number and have not been included in an L2 block
870- // (i.e. L2BlockNumber is null).
883+ // (i.e. L2BlockNumber is null) nor skipped .
871884 let condition = Condition :: all ( )
872885 . add ( models:: l1_message:: Column :: L1BlockNumber . lte ( target_block_number as i64 ) )
886+ . add ( models:: l1_message:: Column :: Skipped . eq ( false ) )
873887 . add ( models:: l1_message:: Column :: L2BlockNumber . is_null ( ) ) ;
874888 // Yield n messages matching the condition ordered by increasing queue index.
875889 Ok ( models:: l1_message:: Entity :: find ( )
@@ -899,9 +913,10 @@ impl<T: ReadConnectionProvider + Sync + ?Sized> DatabaseReadOperations for T {
899913 } ;
900914 // Create a filter condition for messages that have an L1 block number less than
901915 // or equal to the target block number and have not been included in an L2 block
902- // (i.e. L2BlockNumber is null).
916+ // (i.e. L2BlockNumber is null) nor skipped .
903917 let condition = Condition :: all ( )
904918 . add ( models:: l1_message:: Column :: L1BlockNumber . lte ( target_block_number as i64 ) )
919+ . add ( models:: l1_message:: Column :: Skipped . eq ( false ) )
905920 . add ( models:: l1_message:: Column :: L2BlockNumber . is_null ( ) ) ;
906921 // Yield n messages matching the condition ordered by increasing queue index.
907922 Ok ( models:: l1_message:: Entity :: find ( )
0 commit comments