Skip to content

Commit

Permalink
Return PortId information in query_channels (informalsystems#861)
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen authored Apr 29, 2021
1 parent 13098cc commit 91f79ca
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 19 deletions.
12 changes: 8 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -16,21 +16,25 @@
- [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])

### 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", ...]`.


[#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
[#854]: https://github.com/informalsystems/ibc-rs/issues/854
[#861]: https://github.com/informalsystems/ibc-rs/issues/861
[#869]: https://github.com/informalsystems/ibc-rs/issues/869
[#855]: https://github.com/informalsystems/ibc-rs/issues/855


## v0.2.0
Expand Down
25 changes: 17 additions & 8 deletions guide/src/commands/queries/channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,22 @@ hermes query channels ibc-1

```rust
Success: [
ChannelId(
"channel-0",
),
ChannelId(
"channel-1",
),
PortChannelId {
channel_id: ChannelId(
"channel-0",
),
port_id: PortId(
"transfer",
),
},
PortChannelId {
channel_id: ChannelId(
"channel-1",
),
port_id: PortId(
"transfer",
),
},
]
```

Expand Down Expand Up @@ -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
Expand All @@ -101,4 +111,3 @@ Success: ChannelEnd {
version: "ics20-1",
}
```

6 changes: 4 additions & 2 deletions relayer/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -172,7 +174,7 @@ pub trait Chain: Sized {
) -> Result<Vec<ChannelId>, Error>;

/// Performs a query to retrieve the identifiers of all channels.
fn query_channels(&self, request: QueryChannelsRequest) -> Result<Vec<ChannelId>, Error>;
fn query_channels(&self, request: QueryChannelsRequest) -> Result<Vec<PortChannelId>, Error>;

fn query_channel(
&self,
Expand Down
15 changes: 12 additions & 3 deletions relayer/src/chain/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -768,7 +770,7 @@ impl Chain for CosmosSdkChain {
Ok(vec_ids)
}

fn query_channels(&self, request: QueryChannelsRequest) -> Result<Vec<ChannelId>, Error> {
fn query_channels(&self, request: QueryChannelsRequest) -> Result<Vec<PortChannelId>, Error> {
crate::time!("query_connections");

let mut client = self
Expand All @@ -792,7 +794,14 @@ 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 port_id = PortId::from_str(ch.port_id.as_str()).ok()?;
let channel_id = ChannelId::from_str(ch.channel_id.as_str()).ok()?;
Some(PortChannelId {
port_id,
channel_id,
})
})
.collect();

Ok(ids)
Expand Down
6 changes: 4 additions & 2 deletions relayer/src/chain/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -184,7 +186,7 @@ impl Chain for MockChain {
unimplemented!()
}

fn query_channels(&self, _request: QueryChannelsRequest) -> Result<Vec<ChannelId>, Error> {
fn query_channels(&self, _request: QueryChannelsRequest) -> Result<Vec<PortChannelId>, Error> {
unimplemented!()
}

Expand Down

0 comments on commit 91f79ca

Please sign in to comment.