Skip to content

Commit

Permalink
Problem: chainid is used instead of networkid (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-nguy authored Dec 15, 2022
1 parent 9d7001e commit 912c499
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
16 changes: 7 additions & 9 deletions orchestrator/orchestrator/src/ethereum_event_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! or a transaction batch update. It then responds to these events by performing actions on the Cosmos chain if required
use crate::get_with_retry::get_block_number_with_retry;
use crate::get_with_retry::get_chain_id_with_retry;
use crate::get_with_retry::get_network_id_with_retry;
use crate::metrics;
use cosmos_gravity::build;
use cosmos_gravity::crypto::CosmosSigner;
Expand Down Expand Up @@ -274,18 +274,16 @@ pub async fn check_for_events<S: Signer + 'static, CS: CosmosSigner>(
///
///
pub async fn get_block_delay<S: Signer>(eth_client: EthClient<S>) -> Result<U64, GravityError> {
// TODO(bolten): get_net_version() exists on the version of ethers we are currently
// depending on, but it's broken, so we're relying on chain ID
let chain_id_result = get_chain_id_with_retry(eth_client.clone()).await;
let chain_id = downcast_to_u64(chain_id_result);
if chain_id.is_none() {
let network_id_string = get_network_id_with_retry(eth_client.clone()).await;
let network_id = network_id_string.parse::<u64>();
if network_id.is_err() {
return Err(GravityError::EthereumBadDataError(format!(
"Chain ID is larger than u64 max: {}",
chain_id_result
"Chain ID is not valid {}",
network_id.err().unwrap()
)));
}

match chain_id.unwrap() {
match network_id.unwrap() {
// Mainline Ethereum, Ethereum classic, or the Ropsten, Kotti, Mordor testnets
// all Ethereum proof of stake Chains
1 | 3 | 6 | 7 => Ok(96u8.into()),
Expand Down
6 changes: 3 additions & 3 deletions orchestrator/orchestrator/src/get_with_retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ pub async fn get_last_event_nonce_with_retry(
}

/// gets the chain ID, no matter how long it takes
pub async fn get_chain_id_with_retry<S: Signer>(eth_client: EthClient<S>) -> U256 {
let mut res = eth_client.get_chainid().await;
pub async fn get_network_id_with_retry<S: Signer>(eth_client: EthClient<S>) -> String {
let mut res = eth_client.get_net_version().await;
while res.is_err() {
error!("Failed to get chain ID! Is your Eth node working?");
delay_for(RETRY_TIME).await;
res = eth_client.get_chainid().await;
res = eth_client.get_net_version().await;
}
res.unwrap()
}
2 changes: 2 additions & 0 deletions orchestrator/orchestrator/src/main_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ pub async fn eth_oracle_main_loop<S: Signer + 'static, CS: CosmosSigner>(
exit(1);
}
};

info!("Using block delay {:?}", block_delay);
let mut last_checked_block = get_last_checked_block(
grpc_client.clone(),
our_cosmos_address,
Expand Down

0 comments on commit 912c499

Please sign in to comment.