@@ -32,7 +32,6 @@ const SQL_SELECT_SAFE_BLOCK: &str =
3232 "SELECT block_number FROM l1_safe_head WHERE singleton_id = 0 LIMIT 1" ;
3333const SQL_INSERT_SAFE_INPUT : & str = "INSERT INTO safe_inputs (safe_input_index, sender, payload, block_number) VALUES (?1, ?2, ?3, ?4)" ;
3434const SQL_INSERT_USER_OP : & str = include_str ! ( "queries/insert_user_op.sql" ) ;
35- const SQL_INSERT_SEQUENCED_USER_OP : & str = include_str ! ( "queries/insert_sequenced_user_op.sql" ) ;
3635const SQL_INSERT_SEQUENCED_DIRECT_INPUT : & str =
3736 include_str ! ( "queries/insert_sequenced_direct_input.sql" ) ;
3837const SQL_UPDATE_BATCH_POLICY_GAS_PRICE : & str =
@@ -190,7 +189,10 @@ pub(super) fn sql_insert_safe_inputs_batch(
190189 Ok ( ( ) )
191190}
192191
193- pub ( super ) fn sql_insert_user_ops_and_sequenced_batch (
192+ /// Insert user-ops into the `user_ops` table.
193+ /// The `trg_sequence_user_op` trigger automatically appends a corresponding row
194+ /// to `sequenced_l2_txs` for each inserted user-op.
195+ pub ( super ) fn sql_insert_user_ops_batch (
194196 tx : & Transaction < ' _ > ,
195197 batch_index : i64 ,
196198 frame_in_batch : i64 ,
@@ -201,12 +203,11 @@ pub(super) fn sql_insert_user_ops_and_sequenced_batch(
201203 return Ok ( ( ) ) ;
202204 }
203205
204- let mut user_ops_stmt = tx. prepare_cached ( SQL_INSERT_USER_OP ) ?;
205- let mut sequenced_stmt = tx. prepare_cached ( SQL_INSERT_SEQUENCED_USER_OP ) ?;
206+ let mut stmt = tx. prepare_cached ( SQL_INSERT_USER_OP ) ?;
206207 for ( offset, item) in user_ops. iter ( ) . enumerate ( ) {
207208 let pos_in_frame = frame_pos_start. saturating_add ( offset as u32 ) ;
208209 let sig = item. signed . signature . as_bytes ( ) ;
209- user_ops_stmt . execute ( params ! [
210+ stmt . execute ( params ! [
210211 batch_index,
211212 frame_in_batch,
212213 i64 :: from( pos_in_frame) ,
@@ -217,11 +218,6 @@ pub(super) fn sql_insert_user_ops_and_sequenced_batch(
217218 & sig[ ..] ,
218219 to_unix_ms( item. received_at) ,
219220 ] ) ?;
220- sequenced_stmt. execute ( params ! [
221- batch_index,
222- frame_in_batch,
223- i64 :: from( pos_in_frame) ,
224- ] ) ?;
225221 }
226222 Ok ( ( ) )
227223}
@@ -411,9 +407,9 @@ fn u64_to_i64(value: u64) -> i64 {
411407mod tests {
412408 use super :: {
413409 FrameHeaderRow , SQL_INSERT_SAFE_INPUT , SQL_INSERT_SEQUENCED_DIRECT_INPUT ,
414- SQL_INSERT_SEQUENCED_USER_OP , SQL_INSERT_USER_OP , sql_insert_open_batch,
410+ SQL_INSERT_USER_OP , sql_insert_open_batch,
415411 sql_insert_open_batch_with_index, sql_insert_open_frame, sql_insert_safe_inputs_batch,
416- sql_insert_sequenced_direct_inputs_for_frame, sql_insert_user_ops_and_sequenced_batch ,
412+ sql_insert_sequenced_direct_inputs_for_frame, sql_insert_user_ops_batch ,
417413 sql_select_batch_policy, sql_select_frames_for_batch, sql_select_latest_batch_index,
418414 sql_select_latest_batch_with_user_op_count, sql_select_max_safe_input_index,
419415 sql_select_ordered_l2_tx_count, sql_select_ordered_l2_txs_from_offset,
@@ -561,13 +557,12 @@ mod tests {
561557 ] ,
562558 )
563559 . expect ( "insert user op" ) ;
560+ // The trg_sequence_user_op trigger automatically inserts the sequenced row.
564561 conn. execute (
565562 SQL_INSERT_SAFE_INPUT ,
566563 params ! [ 0_i64 , vec![ 0x11_u8 ; 20 ] , vec![ 0xaa_u8 ] , 10_i64 ] ,
567564 )
568565 . expect ( "insert direct input" ) ;
569- conn. execute ( SQL_INSERT_SEQUENCED_USER_OP , params ! [ 0_i64 , 0_i64 , 0_i64 ] )
570- . expect ( "insert sequenced user op" ) ;
571566 conn. execute (
572567 SQL_INSERT_SEQUENCED_DIRECT_INPUT ,
573568 params ! [ 0_i64 , 0_i64 , 0_i64 ] ,
@@ -758,7 +753,7 @@ mod tests {
758753 sample_pending_user_op( 0x20 , 0 , 1 ) ,
759754 sample_pending_user_op( 0x21 , 1 , 1 ) ,
760755 ] ;
761- sql_insert_user_ops_and_sequenced_batch ( & tx, 0 , 0 , 0 , user_ops. as_slice ( ) )
756+ sql_insert_user_ops_batch ( & tx, 0 , 0 , 0 , user_ops. as_slice ( ) )
762757 . expect ( "insert user ops + sequenced batch" ) ;
763758
764759 sql_insert_sequenced_direct_inputs_for_frame (
0 commit comments