Skip to content

Commit

Permalink
Merge pull request #406 from PeggyJV/bolten/chunky-oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
zmanian authored May 20, 2022
2 parents ed557f4 + 9774da5 commit 4e1b44e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions orchestrator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion orchestrator/gorc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "gorc"
authors = []
version = "2.0.0"
version = "2.0.1"
edition = "2021"
rust-version = "1.58"

Expand Down
2 changes: 1 addition & 1 deletion orchestrator/orchestrator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "orchestrator"
version = "2.0.0"
version = "2.0.1"
authors = ["Justin Kilpatrick <justin@althea.net>"]
edition = "2018"

Expand Down
11 changes: 9 additions & 2 deletions orchestrator/orchestrator/src/ethereum_event_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Msg>>,
) -> Result<U64, GravityError> {
Expand All @@ -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());

Expand All @@ -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());
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions orchestrator/orchestrator/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)
Expand Down

0 comments on commit 4e1b44e

Please sign in to comment.