Skip to content

Commit

Permalink
Hermes ft-transfer: Verify open channel before sending message (inf…
Browse files Browse the repository at this point in the history
…ormalsystems#961)

* Channel open verification and bail unless Open

* Changelog
  • Loading branch information
adizere authored May 20, 2021
1 parent a0f672f commit 3374a33
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

## Unreleased

### BUG FIXES

- [ibc-relayer-cli]
- Prevent sending `ft-transfer` MsgTransfer on a non-Open channel. ([#960])

### FEATURES

- [release]
- Official hermes image on Docker Hub.
- Official hermes image on Docker Hub. ([#894])


[#960]: https://github.com/informalsystems/ibc-rs/issues/960
[#894]: https://github.com/informalsystems/ibc-rs/pull/894

## v0.3.1
*May 14h, 2021*
Expand Down
8 changes: 4 additions & 4 deletions e2e/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,25 @@ def loop(c: Config):
unreceived = packet.query_unreceived_packets(
c, chain=IBC_1, port=TRANSFER, channel=IBC_1_CHANNEL)

assert (len(unreceived) == 0), (unreceived, "unreceived packet mismatch")
assert (len(unreceived) == 0), (unreceived, "unreceived packets mismatch (expected 0)")

# hermes query packet unreceived-acks ibc-1 transfer channel-1
unreceived = packet.query_unreceived_acks(
c, chain=IBC_1, port=TRANSFER, channel=IBC_1_CHANNEL)

assert (len(unreceived) == 0), (unreceived, "unreceived packet mismatch")
assert (len(unreceived) == 0), (unreceived, "unreceived acks mismatch (expected 0)")

# hermes query packet unreceived-packets ibc-0 transfer channel-0
unreceived = packet.query_unreceived_packets(
c, chain=IBC_0, port=TRANSFER, channel=IBC_0_CHANNEL)

assert (len(unreceived) == 0), (unreceived, "unreceived packet mismatch")
assert (len(unreceived) == 0), (unreceived, "unreceived packets mismatch (expected 0)")

# hermes query packet unreceived-acks ibc-0 transfer channel-0
unreceived = packet.query_unreceived_acks(
c, chain=IBC_0, port=TRANSFER, channel=IBC_0_CHANNEL)

assert (len(unreceived) == 0), (unreceived, "unreceived packet mismatch")
assert (len(unreceived) == 0), (unreceived, "unreceived acks mismatch (expected 0)")

# 6. All good, stop the relayer
proc.kill()
Expand Down
12 changes: 11 additions & 1 deletion relayer-cli/src/commands/tx/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,16 @@ impl Runnable for TxIcs20MsgTransferCmd {
Height::zero(),
)
.unwrap_or_else(exit_with_unrecoverable_error);
if !channel_end.is_open() {
return Output::error(format!(
"the requested port/channel ('{}'/'{}') on chain id '{}' is in state '{}'; expected 'open' state",
opts.packet_src_port_id,
opts.packet_src_channel_id,
self.src_chain_id,
channel_end.state
))
.exit();
}

let conn_id = match channel_end.connection_hops.first() {
None => {
Expand All @@ -166,7 +176,7 @@ impl Runnable for TxIcs20MsgTransferCmd {
);
if src_chain_client_state.chain_id != self.dst_chain_id {
return Output::error(
format!("the requested port/channel ({}/{}) provides a path from chain '{}' to \
format!("the requested port/channel ('{}'/'{}') provides a path from chain '{}' to \
chain '{}' (not to the destination chain '{}'). Bailing due to mismatching arguments.",
opts.packet_src_port_id, opts.packet_src_channel_id,
self.src_chain_id,
Expand Down

0 comments on commit 3374a33

Please sign in to comment.