@@ -16,7 +16,7 @@ use zkstack_cli_common::{
1616 logger,
1717} ;
1818use zkstack_cli_config:: { ZkStackConfig , ZkStackConfigTrait } ;
19- use zksync_basic_types:: { Address , H256 , U256 , U64 } ;
19+ use zksync_basic_types:: { network :: Network , Address , H256 , U256 , U64 } ;
2020use zksync_system_constants:: L2_BRIDGEHUB_ADDRESS ;
2121use zksync_types:: {
2222 server_notification:: { GatewayMigrationNotification , GatewayMigrationState } ,
@@ -32,7 +32,7 @@ use super::{
3232use crate :: {
3333 abi:: { BridgehubAbi , ChainTypeManagerAbi , IChainAssetHandlerAbi , ZkChainAbi } ,
3434 commands:: chain:: { admin_call_builder:: AdminCallBuilder , utils:: send_tx} ,
35- consts:: DEFAULT_EVENTS_BLOCK_RANGE ,
35+ consts:: { DEFAULT_EVENTS_BLOCK_RANGE , LOCALHOST_L1_EVENTS_BLOCK_RANGE } ,
3636} ;
3737
3838#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
@@ -122,9 +122,16 @@ pub(crate) async fn get_migration_transaction(
122122 let chain_asset_handler =
123123 IChainAssetHandlerAbi :: new ( chain_asset_handler_addr, provider. clone ( ) ) ;
124124
125+ // On local L1 (chain_id 9), large block range queries (0..Latest) can lead to flakiness.
126+ // We reduce the chunk size to ensure reliability.
127+ let block_range = if sl_chain_id. as_u64 ( ) == Network :: Localhost . chain_id ( ) . 0 {
128+ LOCALHOST_L1_EVENTS_BLOCK_RANGE
129+ } else {
130+ DEFAULT_EVENTS_BLOCK_RANGE
131+ } ;
125132 let max_interval_to_search = Utc :: now ( ) - MAX_SEARCHING_MIGRATION_TXS_INTERVAL ;
126133 let latest_tx_hash: Option < H256 > = loop {
127- let lower_bound = search_upper_bound. saturating_sub ( DEFAULT_EVENTS_BLOCK_RANGE ) ;
134+ let lower_bound = search_upper_bound. saturating_sub ( block_range ) ;
128135
129136 logger:: info ( format ! (
130137 "Checking block range: {}..={}" ,
0 commit comments