From 74541dac8bc18ec73d9a93abcb81f218c2ab8c72 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Wed, 28 Apr 2021 12:12:09 +0200 Subject: [PATCH 1/8] Return PortId information in query_channels --- relayer/src/chain.rs | 5 ++++- relayer/src/chain/cosmos.rs | 11 +++++++++-- relayer/src/chain/mock.rs | 5 ++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/relayer/src/chain.rs b/relayer/src/chain.rs index 4dab38938d..e906b15626 100644 --- a/relayer/src/chain.rs +++ b/relayer/src/chain.rs @@ -172,7 +172,10 @@ pub trait Chain: Sized { ) -> Result, Error>; /// Performs a query to retrieve the identifiers of all channels. - fn query_channels(&self, request: QueryChannelsRequest) -> Result, Error>; + fn query_channels( + &self, + request: QueryChannelsRequest, + ) -> Result, Error>; fn query_channel( &self, diff --git a/relayer/src/chain/cosmos.rs b/relayer/src/chain/cosmos.rs index 4ed288942f..54f8821597 100644 --- a/relayer/src/chain/cosmos.rs +++ b/relayer/src/chain/cosmos.rs @@ -768,7 +768,10 @@ impl Chain for CosmosSdkChain { Ok(vec_ids) } - fn query_channels(&self, request: QueryChannelsRequest) -> Result, Error> { + fn query_channels( + &self, + request: QueryChannelsRequest, + ) -> Result, Error> { crate::time!("query_connections"); let mut client = self @@ -792,7 +795,11 @@ impl Chain for CosmosSdkChain { let ids = response .channels .iter() - .filter_map(|ch| ChannelId::from_str(ch.channel_id.as_str()).ok()) + .filter_map(|ch| { + let channel_id = ChannelId::from_str(ch.channel_id.as_str()).ok()?; + let port_id = PortId::from_str(ch.port_id.as_str()).ok()?; + Some((channel_id, port_id)) + }) .collect(); Ok(ids) diff --git a/relayer/src/chain/mock.rs b/relayer/src/chain/mock.rs index 9b9a1286b6..619031c73c 100644 --- a/relayer/src/chain/mock.rs +++ b/relayer/src/chain/mock.rs @@ -184,7 +184,10 @@ impl Chain for MockChain { unimplemented!() } - fn query_channels(&self, _request: QueryChannelsRequest) -> Result, Error> { + fn query_channels( + &self, + _request: QueryChannelsRequest, + ) -> Result, Error> { unimplemented!() } From 1eba6d822822b91640551f498acc7dafa77066c5 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Wed, 28 Apr 2021 13:50:26 +0200 Subject: [PATCH 2/8] Update guide documentation --- guide/src/commands/queries/channel.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/guide/src/commands/queries/channel.md b/guide/src/commands/queries/channel.md index f9777ee67e..e14342b0bd 100644 --- a/guide/src/commands/queries/channel.md +++ b/guide/src/commands/queries/channel.md @@ -27,11 +27,21 @@ hermes query channels ibc-1 ```rust Success: [ - ChannelId( - "channel-0", + ( + ChannelId( + "channel-0", + ), + PortId( + "transfer", + ), ), - ChannelId( - "channel-1", + ( + ChannelId( + "channel-2", + ), + PortId( + "transfer", + ), ), ] ``` @@ -76,7 +86,7 @@ __Example__ Query the channel end of channel `channel-1` on port `transfer` on `ibc-1`: ```shell -hermes query channel end ibc-1 channel-1 +hermes query channel end ibc-1 transfer channel-1 ``` ```rust @@ -101,4 +111,3 @@ Success: ChannelEnd { version: "ics20-1", } ``` - From f9d4879238b63de5fe4a89f8638d0117c9759a63 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Wed, 28 Apr 2021 14:03:00 +0200 Subject: [PATCH 3/8] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33d9e6e5a4..430eac01b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - [ibc-relayer] - Fix pagination in gRPC query for clients ([#811]) - Fix relayer crash when hermes starts in the same time as packets are being sent ([#851]) + - Fix missing port information in `hermes query channels` ([#840]) - [ibc-relayer-cli] - Fix for `ft-transfer` mismatching arguments ([#869]) From 37f0517399eaee67e4d9f465a924ea8117da1e09 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Wed, 28 Apr 2021 21:42:08 +0200 Subject: [PATCH 4/8] Add PortChannelId type to bundle PortId and ChannelId together --- modules/src/ics24_host/identifier.rs | 7 +++++++ relayer/src/chain.rs | 9 ++++----- relayer/src/chain/cosmos.rs | 16 +++++++++------- relayer/src/chain/mock.rs | 9 ++++----- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/modules/src/ics24_host/identifier.rs b/modules/src/ics24_host/identifier.rs index e2ef78e2cd..9d178d7fd2 100644 --- a/modules/src/ics24_host/identifier.rs +++ b/modules/src/ics24_host/identifier.rs @@ -372,3 +372,10 @@ impl PartialEq for ChannelId { self.as_str().eq(other) } } + +/// A pair of [`PortId`] and [`ChannelId`] are used together for sending IBC packets. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] +pub struct PortChannelId { + pub channel_id: ChannelId, + pub port_id: PortId, +} diff --git a/relayer/src/chain.rs b/relayer/src/chain.rs index e906b15626..a121ef421f 100644 --- a/relayer/src/chain.rs +++ b/relayer/src/chain.rs @@ -15,7 +15,9 @@ use ibc::ics03_connection::version::{get_compatible_versions, Version}; use ibc::ics04_channel::channel::ChannelEnd; use ibc::ics04_channel::packet::{PacketMsgType, Sequence}; use ibc::ics23_commitment::commitment::{CommitmentPrefix, CommitmentProofBytes}; -use ibc::ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}; +use ibc::ics24_host::identifier::{ + ChainId, ChannelId, ClientId, ConnectionId, PortChannelId, PortId, +}; use ibc::proofs::{ConsensusProof, Proofs}; use ibc::query::QueryTxRequest; use ibc::signer::Signer; @@ -172,10 +174,7 @@ pub trait Chain: Sized { ) -> Result, Error>; /// Performs a query to retrieve the identifiers of all channels. - fn query_channels( - &self, - request: QueryChannelsRequest, - ) -> Result, Error>; + fn query_channels(&self, request: QueryChannelsRequest) -> Result, Error>; fn query_channel( &self, diff --git a/relayer/src/chain/cosmos.rs b/relayer/src/chain/cosmos.rs index 54f8821597..5634a4d893 100644 --- a/relayer/src/chain/cosmos.rs +++ b/relayer/src/chain/cosmos.rs @@ -36,7 +36,9 @@ use ibc::ics07_tendermint::consensus_state::ConsensusState as TMConsensusState; use ibc::ics07_tendermint::header::Header as TmHeader; use ibc::ics23_commitment::commitment::CommitmentPrefix; use ibc::ics23_commitment::merkle::convert_tm_to_ics_merkle_proof; -use ibc::ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}; +use ibc::ics24_host::identifier::{ + ChainId, ChannelId, ClientId, ConnectionId, PortChannelId, PortId, +}; use ibc::ics24_host::Path::ClientConsensusState as ClientConsensusPath; use ibc::ics24_host::Path::ClientState as ClientStatePath; use ibc::ics24_host::{ClientUpgradePath, Path, IBC_QUERY_PATH, SDK_UPGRADE_QUERY_PATH}; @@ -768,10 +770,7 @@ impl Chain for CosmosSdkChain { Ok(vec_ids) } - fn query_channels( - &self, - request: QueryChannelsRequest, - ) -> Result, Error> { + fn query_channels(&self, request: QueryChannelsRequest) -> Result, Error> { crate::time!("query_connections"); let mut client = self @@ -796,9 +795,12 @@ impl Chain for CosmosSdkChain { .channels .iter() .filter_map(|ch| { - let channel_id = ChannelId::from_str(ch.channel_id.as_str()).ok()?; let port_id = PortId::from_str(ch.port_id.as_str()).ok()?; - Some((channel_id, port_id)) + let channel_id = ChannelId::from_str(ch.channel_id.as_str()).ok()?; + Some(PortChannelId { + port_id, + channel_id, + }) }) .collect(); diff --git a/relayer/src/chain/mock.rs b/relayer/src/chain/mock.rs index 619031c73c..3c4e67410b 100644 --- a/relayer/src/chain/mock.rs +++ b/relayer/src/chain/mock.rs @@ -20,7 +20,9 @@ use ibc::ics07_tendermint::consensus_state::ConsensusState as TendermintConsensu use ibc::ics07_tendermint::header::Header as TendermintHeader; use ibc::ics18_relayer::context::Ics18Context; use ibc::ics23_commitment::commitment::CommitmentPrefix; -use ibc::ics24_host::identifier::{ChainId, ChannelId, ClientId, ConnectionId, PortId}; +use ibc::ics24_host::identifier::{ + ChainId, ChannelId, ClientId, ConnectionId, PortChannelId, PortId, +}; use ibc::mock::context::MockContext; use ibc::mock::host::HostType; use ibc::query::QueryTxRequest; @@ -184,10 +186,7 @@ impl Chain for MockChain { unimplemented!() } - fn query_channels( - &self, - _request: QueryChannelsRequest, - ) -> Result, Error> { + fn query_channels(&self, _request: QueryChannelsRequest) -> Result, Error> { unimplemented!() } From e0163aaa7d7265bd3ebb86b3f99d4468e44932ae Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Wed, 28 Apr 2021 21:45:51 +0200 Subject: [PATCH 5/8] Add PR link in changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 430eac01b4..eaafda23fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ [#851]: https://github.com/informalsystems/ibc-rs/issues/851 [#869]: https://github.com/informalsystems/ibc-rs/issues/869 [#855]: https://github.com/informalsystems/ibc-rs/issues/855 +[#861]: https://github.com/informalsystems/ibc-rs/issues/861 ## v0.2.0 From 6c6558fb65f427253008babf69d50849c89f3b47 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 29 Apr 2021 09:38:08 +0200 Subject: [PATCH 6/8] Add this PR as breaking change in changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eaafda23fa..47e323b539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,8 @@ ### BREAKING CHANGES -> Nothing yet. +- [ibc-relayer] + - `hermes -j query channels` command now returns `result` array with the format `[{"channel_id":"channel-0","port_id":"transfer"}, ...]` instead of `["channel-0", ...]`. [#785]: https://github.com/informalsystems/ibc-rs/issues/785 @@ -33,6 +34,7 @@ [#869]: https://github.com/informalsystems/ibc-rs/issues/869 [#855]: https://github.com/informalsystems/ibc-rs/issues/855 [#861]: https://github.com/informalsystems/ibc-rs/issues/861 +[#840]: https://github.com/informalsystems/ibc-rs/issues/840 ## v0.2.0 From ba92ebdf0dffa1e3398d5226c027f317bb013c11 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 29 Apr 2021 20:36:47 +0200 Subject: [PATCH 7/8] Fix ordering in changelog and link to issue intead of PR --- CHANGELOG.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47e323b539..036dceee46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - [ibc] - Reinstated `ics23` dependency ([#854]) - - Use proper Timestamp type to track time ([#855]) + - Use proper Timestamp type to track time ([#758]) - [ibc-relayer] - Change the default for client creation to allow governance recovery in case of expiration or misbehaviour ([#785]) @@ -27,14 +27,14 @@ - `hermes -j query channels` command now returns `result` array with the format `[{"channel_id":"channel-0","port_id":"transfer"}, ...]` instead of `["channel-0", ...]`. +[#758]: https://github.com/informalsystems/ibc-rs/issues/758 [#785]: https://github.com/informalsystems/ibc-rs/issues/785 [#811]: https://github.com/informalsystems/ibc-rs/issues/811 -[#854]: https://github.com/informalsystems/ibc-rs/issues/854 +[#840]: https://github.com/informalsystems/ibc-rs/issues/840 [#851]: https://github.com/informalsystems/ibc-rs/issues/851 -[#869]: https://github.com/informalsystems/ibc-rs/issues/869 -[#855]: https://github.com/informalsystems/ibc-rs/issues/855 +[#854]: https://github.com/informalsystems/ibc-rs/issues/854 [#861]: https://github.com/informalsystems/ibc-rs/issues/861 -[#840]: https://github.com/informalsystems/ibc-rs/issues/840 +[#869]: https://github.com/informalsystems/ibc-rs/issues/869 ## v0.2.0 From bbc769effa2ad8033e842916f039553afdfbe119 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Thu, 29 Apr 2021 21:05:22 +0200 Subject: [PATCH 8/8] Update example command output in guide --- guide/src/commands/queries/channel.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/guide/src/commands/queries/channel.md b/guide/src/commands/queries/channel.md index e14342b0bd..eda61b66b0 100644 --- a/guide/src/commands/queries/channel.md +++ b/guide/src/commands/queries/channel.md @@ -27,22 +27,22 @@ hermes query channels ibc-1 ```rust Success: [ - ( - ChannelId( + PortChannelId { + channel_id: ChannelId( "channel-0", ), - PortId( + port_id: PortId( "transfer", ), - ), - ( - ChannelId( - "channel-2", + }, + PortChannelId { + channel_id: ChannelId( + "channel-1", ), - PortId( + port_id: PortId( "transfer", ), - ), + }, ] ```