@@ -29,8 +29,6 @@ use std::{
2929} ;
3030use tokio:: sync:: mpsc;
3131
32- /// The block range used to fetch L1 logs.
33- pub const LOGS_QUERY_BLOCK_RANGE : u64 = 500 ;
3432/// The maximum count of unfinalized blocks we can have in Ethereum.
3533pub const MAX_UNFINALIZED_BLOCK_COUNT : usize = 96 ;
3634
@@ -84,6 +82,8 @@ pub struct L1Watcher<EP> {
8482 metrics : WatcherMetrics ,
8583 /// Whether the watcher is synced to the L1 head.
8684 is_synced : bool ,
85+ /// The log query block range.
86+ log_query_block_range : u64 ,
8787}
8888
8989/// The L1 notification type yielded by the [`L1Watcher`].
@@ -158,10 +158,11 @@ where
158158 execution_provider : EP ,
159159 start_block : Option < u64 > ,
160160 config : Arc < NodeConfig > ,
161+ log_query_block_range : u64 ,
161162 ) -> mpsc:: Receiver < Arc < L1Notification > > {
162163 tracing:: trace!( target: "scroll::watcher" , ?start_block, ?config, "spawning L1 watcher" ) ;
163164
164- let ( tx, rx) = mpsc:: channel ( LOGS_QUERY_BLOCK_RANGE as usize ) ;
165+ let ( tx, rx) = mpsc:: channel ( log_query_block_range as usize ) ;
165166
166167 let fetch_block_number = async |tag : BlockNumberOrTag | {
167168 let block = loop {
@@ -192,6 +193,7 @@ where
192193 config,
193194 metrics : WatcherMetrics :: default ( ) ,
194195 is_synced : false ,
196+ log_query_block_range,
195197 } ;
196198
197199 // notify at spawn.
@@ -612,7 +614,7 @@ where
612614 async fn update_current_block ( & mut self , latest : & Block ) -> L1WatcherResult < ( ) > {
613615 self . current_block_number = self
614616 . current_block_number
615- . saturating_add ( LOGS_QUERY_BLOCK_RANGE )
617+ . saturating_add ( self . log_query_block_range )
616618 . min ( latest. header . number ) ;
617619 self . notify ( L1Notification :: Processed ( self . current_block_number ) ) . await
618620 }
@@ -637,7 +639,8 @@ where
637639
638640 /// Returns the next range of logs, for the block range in
639641 /// \[[`current_block`](field@L1Watcher::current_block_number);
640- /// [`current_block`](field@L1Watcher::current_block_number) + [`LOGS_QUERY_BLOCK_RANGE`]\].
642+ /// [`current_block`](field@L1Watcher::current_block_number) +
643+ /// [`field@L1Watcher::log_query_block_range`]\].
641644 async fn next_filtered_logs ( & self , latest_block_number : u64 ) -> L1WatcherResult < Vec < Log > > {
642645 // set the block range for the query
643646 let address_book = & self . config . address_book ;
@@ -654,7 +657,7 @@ where
654657 ] ) ;
655658 let to_block = self
656659 . current_block_number
657- . saturating_add ( LOGS_QUERY_BLOCK_RANGE )
660+ . saturating_add ( self . log_query_block_range )
658661 . min ( latest_block_number) ;
659662
660663 // skip a block for `from_block` since `self.current_block_number` is the last indexed
@@ -679,6 +682,8 @@ mod tests {
679682 use arbitrary:: Arbitrary ;
680683 use scroll_l1:: abi:: calls:: commitBatchCall;
681684
685+ const LOG_QUERY_BLOCK_RANGE : u64 = 500 ;
686+
682687 // Returns a L1Watcher along with the receiver end of the L1Notifications.
683688 fn l1_watcher (
684689 unfinalized_blocks : Vec < Header > ,
@@ -699,7 +704,7 @@ mod tests {
699704 vec ! [ latest] ,
700705 ) ;
701706
702- let ( tx, rx) = mpsc:: channel ( LOGS_QUERY_BLOCK_RANGE as usize ) ;
707+ let ( tx, rx) = mpsc:: channel ( LOG_QUERY_BLOCK_RANGE as usize ) ;
703708 (
704709 L1Watcher {
705710 execution_provider : provider,
@@ -710,6 +715,7 @@ mod tests {
710715 config : Arc :: new ( NodeConfig :: mainnet ( ) ) ,
711716 metrics : WatcherMetrics :: default ( ) ,
712717 is_synced : false ,
718+ log_query_block_range : LOG_QUERY_BLOCK_RANGE ,
713719 } ,
714720 rx,
715721 )
0 commit comments