Skip to content

Commit 8adf82f

Browse files
committed
try smaller block range
1 parent cb93996 commit 8adf82f

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

zkstack_cli/crates/zkstack/src/commands/chain/gateway/gateway_common.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use zkstack_cli_common::{
1616
logger,
1717
};
1818
use 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};
2020
use zksync_system_constants::L2_BRIDGEHUB_ADDRESS;
2121
use zksync_types::{
2222
server_notification::{GatewayMigrationNotification, GatewayMigrationState},
@@ -32,7 +32,7 @@ use super::{
3232
use 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: {}..={}",

zkstack_cli/crates/zkstack/src/consts.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pub const AMOUNT_FOR_DISTRIBUTION_TO_WALLETS: u128 = 2_000u128 * 1_000_000_000_0
33
pub const MINIMUM_BALANCE_FOR_WALLET: u128 = 5u128 * 1_000_000_000_000_000_000u128;
44
/// The default block range within which we search for events within one query.
55
pub const DEFAULT_EVENTS_BLOCK_RANGE: u64 = 50_000;
6+
pub const LOCALHOST_L1_EVENTS_BLOCK_RANGE: u64 = 1_000;
67
pub const SERVER_MIGRATIONS: &str = "core/lib/dal/migrations";
78
pub const PROVER_MIGRATIONS: &str = "prover/crates/lib/prover_dal/migrations";
89
pub const PROVER_STORE_MAX_RETRIES: u16 = 10;

0 commit comments

Comments
 (0)