diff --git a/orchestrator/gravity_utils/src/lib.rs b/orchestrator/gravity_utils/src/lib.rs index 0a7ad8774..20d21bf5b 100644 --- a/orchestrator/gravity_utils/src/lib.rs +++ b/orchestrator/gravity_utils/src/lib.rs @@ -21,15 +21,15 @@ use web30::client::Web3; // constants commonly modified across chains are here // if the net version is this, the test values will be used -pub const TEST_ETH_CHAIN_ID: u64 = 15; +pub const TEST_ETH_CHAIN_ID: u64 = 1337; // see `orchestrator/src/ethereum_event_watcher.rs` -pub const BLOCK_DELAY: Uint256 = u256!(35); +pub const BLOCK_DELAY: Uint256 = u256!(96); pub const TEST_BLOCK_DELAY: Uint256 = u256!(0); -pub const USE_FINALIZATION: bool = false; -pub const EXPECTED_MIN_BLOCK_DELAY: Uint256 = u256!(0); +pub const USE_FINALIZATION: bool = true; +pub const EXPECTED_MIN_BLOCK_DELAY: Uint256 = u256!(32); pub const TEST_EXPECTED_MIN_BLOCK_DELAY: Uint256 = u256!(0); /// Only for tests, some chains are quiescent and need dummy transactions to keep block diff --git a/orchestrator/orchestrator/src/ethereum_event_watcher.rs b/orchestrator/orchestrator/src/ethereum_event_watcher.rs index dd91a8b12..ef7aa5b2a 100644 --- a/orchestrator/orchestrator/src/ethereum_event_watcher.rs +++ b/orchestrator/orchestrator/src/ethereum_event_watcher.rs @@ -38,13 +38,15 @@ pub async fn check_for_events( let our_cosmos_address = our_private_key.to_address(&contact.get_prefix()).unwrap(); let ending_block = if USE_FINALIZATION { + // get this first in case inbetween the calls is a block boundary + // don't accidentally use this variable elswhere + let unsafe_latest_block = get_latest_block_number_with_retry(web3).await; + // NOTE: the delay can only be omitted if we are using the `finalized` version on a PoS network let finalized_block = get_finalized_block_number_with_retry(web3).await; let expected_delay = get_expected_block_delay(web3).await; - // don't accidentally use this variable elswhere - let unsafe_latest_block = get_latest_block_number_with_retry(web3).await; // do this even if `expected_delay` is zero, be extra paranoid if finalized_block.checked_add(expected_delay).unwrap() > unsafe_latest_block { return Err(GravityError::UnrecoverableError(format!(