Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI Command to query connection channels #506

Merged
merged 14 commits into from
Jan 13, 2021
Merged

CLI Command to query connection channels #506

merged 14 commits into from
Jan 13, 2021

Conversation

adizere
Copy link
Member

@adizere adizere commented Jan 7, 2021

Closes: #505

Description

Added the following command:

rrly -c loop_config.toml query connection channels [CHAIN-ID] [CONNECTION-ID]

Sample outputs:

$ rrly -c loop_config.toml query connection channels ibc-0 connection-1
connection query result: []

$ rrly -c loop_config.toml query connection channels ibc-0 connection-0
connection query result: [ChannelId("channel-0")]

Error-prone cases:

$ rrly -c loop_config.toml query connection channels ibc-3 connection-0
error: invalid options: missing chain configuration for the given chain id

$ rrly -c loop_config.toml query connection channels ibc-3 connection-0
connection query error query error: GRPC error: transport error: error trying to connect: tcp connect error: Connection refused (os error 61)

Also offers option for json output (initial experience towards #500): (this work will take place in a different PR)


For contributor use:

  • Updated the Unreleased section of CHANGELOG.md with the issue.
  • If applicable: Unit tests written, added test to CI.
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments.
  • Re-reviewed Files changed in the Github PR explorer.

@codecov-io
Copy link

codecov-io commented Jan 7, 2021

Codecov Report

Merging #506 (0076f0c) into master (b1b37f5) will increase coverage by 16.0%.
The diff coverage is 56.4%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #506      +/-   ##
=========================================
+ Coverage    13.6%   29.7%   +16.0%     
=========================================
  Files          69     160      +91     
  Lines        3752   12917    +9165     
  Branches     1374    5092    +3718     
=========================================
+ Hits          513    3845    +3332     
- Misses       2618    8389    +5771     
- Partials      621     683      +62     
Impacted Files Coverage Δ
...application/ics20_fungible_token_transfer/error.rs 0.0% <0.0%> (ø)
...pplication/ics20_fungible_token_transfer/events.rs 0.0% <ø> (ø)
...ion/ics20_fungible_token_transfer/msgs/transfer.rs 0.0% <0.0%> (ø)
modules/src/events.rs 0.0% <0.0%> (ø)
modules/src/ics02_client/events.rs 0.0% <0.0%> (ø)
modules/src/ics02_client/msgs.rs 0.0% <0.0%> (ø)
modules/src/ics02_client/raw.rs 0.0% <0.0%> (ø)
modules/src/ics03_connection/error.rs 13.6% <0.0%> (-19.7%) ⬇️
modules/src/ics03_connection/events.rs 0.0% <0.0%> (ø)
modules/src/ics04_channel/error.rs 75.0% <ø> (+50.0%) ⬆️
... and 283 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b324dc0...c51b814. Read the comment docs.

@adizere adizere requested a review from cezarad January 12, 2021 16:00
@adizere
Copy link
Member Author

adizere commented Jan 12, 2021

This should be ready for review. If you wish, @cezarad and @vitorenesduarte please also have a look over the PR and any thoughts or questions would be welcome!

relayer-cli/src/commands/query/connection.rs Outdated Show resolved Hide resolved
let vec_ids = response
.channels
.iter()
.filter_map(|ic| ChannelId::from_str(ic.channel_id.as_str()).ok())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there are any errors here, they will be silently ignored. Maybe we can instead do something like this: https://doc.rust-lang.org/rust-by-example/error/iter_result.html#fail-the-entire-operation-with-collect

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do this but the question is do we want to fail the entire operation if we cannot extract one ChannelId?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch.

Between the option of failing the operation because an identifier fails to parse, and ignoring the offending identifier(s), I would rather go with the latter.

One middle-road solution is to have warnings in case some identifiers fail to parse. We're not (yet) principled with how we use warnings, if at all, so I'm adding a TODO here to keep an eye out in the future. c51b814

Copy link
Collaborator

@ancazamfir ancazamfir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks Adi!

@adizere adizere merged commit 1e5f2dc into master Jan 13, 2021
@adizere adizere deleted the adi/505_querycc branch January 13, 2021 14:06
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Implemented the 'query connection channels' command

* Avoid calls to unwrap

* Updated the changelog

* Added basic CLI test

* Fix FMT

* Added JSON output option

* Overrriding default tracing cfg [WIP]

* Revert "Overrriding default tracing cfg [WIP]"

This reverts commit fb2e270.

* Simplified output, removed JSON

* Fixed output text

* Using find_chain method

* Added TODO addressing Vitor's comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Query channels per connection
4 participants