Skip to content

Commit

Permalink
Merge branch 'Gravity-Bridge:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tubackkhoa authored May 22, 2023
2 parents e09c8e9 + 95449a7 commit 0224f64
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion 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/gbt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gbt"
version = "1.9.2"
version = "1.9.3"
authors = ["Justin Kilpatrick <[email protected]>"]
edition = "2018"
license = "Apache-2.0"
Expand Down
28 changes: 17 additions & 11 deletions orchestrator/gbt/src/client/spot_relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::args::SpotRelayOpts;
use crate::utils::TIMEOUT;
use clarity::Address as EthAddress;
use cosmos_gravity::query::{
get_gravity_params, get_latest_transaction_batches, get_latest_valsets, get_pending_batch_fees,
get_gravity_params, get_latest_transaction_batches, get_pending_batch_fees,
get_transaction_batch_signatures,
};
use cosmos_gravity::send::send_request_batch;
Expand All @@ -12,6 +12,7 @@ use gravity_proto::gravity::query_client::QueryClient;
use gravity_proto::gravity::{QueryDenomToErc20Request, QueryErc20ToDenomRequest};
use gravity_utils::connection_prep::{check_for_eth, create_rpc_connections};
use gravity_utils::types::TransactionBatch;
use relayer::find_latest_valset::find_latest_valset;
use std::process::exit;
use tonic::transport::Channel;

Expand Down Expand Up @@ -96,21 +97,26 @@ pub async fn spot_relay(args: SpotRelayOpts, address_prefix: String) {
return;
}
info!("Found pending batch {} for {}", batch.nonce, args.token);
let sigs =
get_transaction_batch_signatures(&mut grpc, batch.nonce, gravity_contract_address)
.await
.expect("Failed to get sigs for batch!");
let current_valset = get_latest_valsets(&mut grpc)
let sigs = get_transaction_batch_signatures(&mut grpc, batch.nonce, ethereum_erc20)
.await
.expect("Failed to get validator sets")
.into_iter()
.last()
.unwrap();
.expect("Failed to get sigs for batch!");
if sigs.is_empty() {
panic!("Failed to get sigs for batch");
}

let current_valset = find_latest_valset(&mut grpc, gravity_contract_address, &web3).await;
if current_valset.is_err() {
error!("Could not get current valset! {:?}", current_valset);
return;
}
let current_valset = current_valset.unwrap();

// this checks that the signatures for the batch are actually possible to submit to the chain
let hash = encode_tx_batch_confirm_hashed(gravity_id.clone(), batch.clone());

if current_valset.order_sigs(&hash, &sigs).is_err() {
if let Err(e) = current_valset.order_sigs(&hash, &sigs) {
error!("Current validator set is not valid to relay this batch, a validator set update must be submitted!");
error!("{:?}", e);
return;
}

Expand Down

0 comments on commit 0224f64

Please sign in to comment.