Skip to content

Commit

Permalink
Fix timeouts in orchestrators
Browse files Browse the repository at this point in the history
  • Loading branch information
danil-lashin committed Dec 2, 2021
1 parent 645f8c1 commit 9a74f3b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion orchestrator/mhub2_utils/src/types/valsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::{
/// The total power in the Gravity bridge is normalized to u32 max every
/// time a validator set is created. This value of up to u32 max is then
/// stored in a u64 to prevent overflow during computation.
pub const TOTAL_GRAVITY_POWER: u64 = u16::MAX as u64;
pub const TOTAL_GRAVITY_POWER: u64 = u32::MAX as u64;

/// takes in an amount of power in the gravity bridge, returns a percentage of total
fn gravity_power_to_percent(input: u64) -> f32 {
Expand Down
6 changes: 5 additions & 1 deletion orchestrator/orchestrator/src/ethereum_event_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use mhub2_utils::{
ValsetUpdatedEvent,
},
};
use std::ops::{Add, Sub};
use std::time;
use tonic::transport::Channel;
use web30::client::Web3;
Expand All @@ -35,7 +36,10 @@ pub async fn check_for_events(
let prefix = contact.get_prefix();
let our_cosmos_address = cosmos_key.to_address(&prefix).unwrap();
let latest_block = get_block_number_with_retry(web3).await;
let latest_block = latest_block - get_block_delay(web3).await;
let mut latest_block = latest_block - get_block_delay(web3).await;
if latest_block.clone().sub(starting_block.clone()) > 1_000u64.into() {
latest_block = starting_block.clone().add(1_000u64.into())
}

metrics::set_ethereum_check_for_events_starting_block(starting_block.clone());
metrics::set_ethereum_check_for_events_end_block(latest_block.clone());
Expand Down
3 changes: 1 addition & 2 deletions orchestrator/web30/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ use crate::jsonrpc::error::Web3Error;
use crate::types::{
Block, Log, NewFilter, TransactionReceipt, TransactionRequest, TransactionResponse,
};
use crate::types::{ConciseBlock, ConciseXdaiBlock, Data, SendTxOption, UnpaddedHex, XdaiBlock};
use crate::types::{ConciseBlock, ConciseXdaiBlock, Data, SendTxOption, XdaiBlock};
use clarity::abi::{encode_call, Token};
use clarity::utils::bytes_to_hex_str;
use clarity::{Address, PrivateKey, Transaction};
use num::ToPrimitive;
use num256::Uint256;
use std::io::Empty;
use std::{cmp::min, time::Duration};
use std::{sync::Arc, time::Instant};
use tokio::time::sleep as delay_for;
Expand Down

0 comments on commit 9a74f3b

Please sign in to comment.