diff --git a/orchestrator/Cargo.lock b/orchestrator/Cargo.lock index ed1e88732..f6c291325 100644 --- a/orchestrator/Cargo.lock +++ b/orchestrator/Cargo.lock @@ -2227,7 +2227,7 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "gorc" -version = "2.0.0" +version = "2.0.1" dependencies = [ "abscissa_core", "abscissa_tokio", @@ -3252,7 +3252,7 @@ dependencies = [ [[package]] name = "orchestrator" -version = "2.0.0" +version = "2.0.1" dependencies = [ "actix-rt 2.5.0", "axum", diff --git a/orchestrator/gorc/Cargo.toml b/orchestrator/gorc/Cargo.toml index 91ffff6f0..03420f1d2 100644 --- a/orchestrator/gorc/Cargo.toml +++ b/orchestrator/gorc/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "gorc" authors = [] -version = "2.0.0" +version = "2.0.1" edition = "2021" rust-version = "1.58" diff --git a/orchestrator/orchestrator/Cargo.toml b/orchestrator/orchestrator/Cargo.toml index 535af573c..13eb25298 100644 --- a/orchestrator/orchestrator/Cargo.toml +++ b/orchestrator/orchestrator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "orchestrator" -version = "2.0.0" +version = "2.0.1" authors = ["Justin Kilpatrick "] edition = "2018" diff --git a/orchestrator/orchestrator/src/ethereum_event_watcher.rs b/orchestrator/orchestrator/src/ethereum_event_watcher.rs index 8c189fcae..430aa50db 100644 --- a/orchestrator/orchestrator/src/ethereum_event_watcher.rs +++ b/orchestrator/orchestrator/src/ethereum_event_watcher.rs @@ -35,6 +35,7 @@ pub async fn check_for_events( gravity_contract_address: EthAddress, cosmos_key: CosmosPrivateKey, starting_block: U64, + blocks_to_search: U64, block_delay: U64, msg_sender: tokio::sync::mpsc::Sender>, ) -> Result { @@ -43,6 +44,11 @@ pub async fn check_for_events( let latest_block = get_block_number_with_retry(eth_client.clone()).await; let latest_block = latest_block - block_delay; + let mut ending_block = starting_block + blocks_to_search; + if ending_block > latest_block { + ending_block = latest_block; + } + metrics::set_ethereum_check_for_events_starting_block(starting_block.as_u64()); metrics::set_ethereum_check_for_events_end_block(latest_block.as_u64()); @@ -64,7 +70,7 @@ pub async fn check_for_events( .address(filter_gravity_contract_address.clone()) .event(&ValsetUpdatedEventFilter::abi_signature()); - let search_range = starting_block..latest_block; + let search_range = starting_block..ending_block; // select uses an inclusive version of the range erc20_deployed_filter = erc20_deployed_filter.select(search_range.clone()); @@ -233,9 +239,10 @@ pub async fn check_for_events( } } - Ok(latest_block) + Ok(ending_block) } + /// The number of blocks behind the 'latest block' on Ethereum our event checking should be. /// Ethereum does not have finality and as such is subject to chain reorgs and temporary forks /// if we check for events up to the very latest block we may process an event which did not diff --git a/orchestrator/orchestrator/src/main_loop.rs b/orchestrator/orchestrator/src/main_loop.rs index f61c7e398..a3fae0dbb 100644 --- a/orchestrator/orchestrator/src/main_loop.rs +++ b/orchestrator/orchestrator/src/main_loop.rs @@ -211,6 +211,7 @@ pub async fn eth_oracle_main_loop( gravity_contract_address, cosmos_key, last_checked_block, + blocks_to_search.into(), block_delay, msg_sender.clone(), )