Skip to content

Commit

Permalink
Possible fix for #734
Browse files Browse the repository at this point in the history
  • Loading branch information
adizere committed Mar 11, 2021
1 parent c59224f commit 466f281
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
18 changes: 17 additions & 1 deletion relayer/src/foreign_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{thread, time::Duration};

use prost_types::Any;
use thiserror::Error;
use tracing::{debug, error, info};
use tracing::{debug, error, info, warn};

use ibc::events::IbcEvent;
use ibc::ics02_client::header::Header;
Expand Down Expand Up @@ -324,6 +324,14 @@ impl ForeignClient {
})?
.latest_height();

if trusted_height >= target_height {
warn!(
"Client height ({}) >= chain target height ({}). Cannot build update message.",
trusted_height, target_height
);
return Ok(vec![]);
}

let header = self
.src_chain()
.build_header(trusted_height, target_height)
Expand Down Expand Up @@ -360,6 +368,14 @@ impl ForeignClient {
))
})?;
let new_msgs = self.build_update_client(h)?;
if new_msgs.is_empty() {
return Err(ForeignClientError::ClientUpdate(format!(
"Client {} is already up-to-date with chain {}@{}",
self.id,
self.src_chain.id(),
h
)));
}

let mut events = self.dst_chain().send_msgs(new_msgs).map_err(|e| {
ForeignClientError::ClientUpdate(format!(
Expand Down
4 changes: 2 additions & 2 deletions scripts/init-clients
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ cargo run --bin hermes -- -c "$CONFIG_FILE" light rm -c "$CHAIN_1_ID" --all -y &

# set the primary peers for clients on each chain
echo "Adding primary peers to light client configuration..."
cargo run --bin hermes -- -c "$CONFIG_FILE" light add $CHAIN_0_RPC_ADDR -c "$CHAIN_0_ID" -f -p -s "$GAIA_DATA/$CHAIN_0_ID/data" -y &>/dev/null
cargo run --bin hermes -- -c "$CONFIG_FILE" light add $CHAIN_1_RPC_ADDR -c "$CHAIN_1_ID" -f -p -s "$GAIA_DATA/$CHAIN_1_ID/data" -y &>/dev/null
cargo run --bin hermes -- -c "$CONFIG_FILE" light add $CHAIN_0_RPC_ADDR -c "$CHAIN_0_ID" -f -p -s "$GAIA_DATA/$CHAIN_0_ID/data" -y &>/dev/null || printf "\tError adding primary peer to %s\n" "$CHAIN_0_RPC_ADDR"
cargo run --bin hermes -- -c "$CONFIG_FILE" light add $CHAIN_1_RPC_ADDR -c "$CHAIN_1_ID" -f -p -s "$GAIA_DATA/$CHAIN_1_ID/data" -y &>/dev/null || printf "\tError adding primary peer to %s\n" "$CHAIN_1_RPC_ADDR"

# set the secondary peers for clients on each chain
echo "Adding secondary peers to light client configuration..."
Expand Down

0 comments on commit 466f281

Please sign in to comment.