Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eth 2.0 Production #109

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions orchestrator/gravity_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions orchestrator/orchestrator/src/ethereum_event_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this upwards because there could be a spurious race condition where a new block is produced or finalized in the middle, this order won't cause spurious failures I don't think

// 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!(
Expand Down