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

Include chain-id in hermes query clients output #995

Merged
merged 13 commits into from
Jun 1, 2021
Merged

Conversation

adizere
Copy link
Member

@adizere adizere commented May 26, 2021

Closes: #992

Description

Three improvements for hermes query clients:

  1. For each client id that is found, the command also outputs the chain identifier.
$ hermes query clients ibc-1
Success: [
    ChainClientTuple {
        client_id: ClientId(
            "07-tendermint-0",
        ),
        target_chain_id: "ibc-0",
    },
    ChainClientTuple {
        client_id: ClientId(
            "07-tendermint-1",
        ),
        target_chain_id: "ibc-0",
    },
]

The option -o, --omit-chain-ids can disable this behavior and print only the client identifiers.

$ hermes query clients ibc-1 -o
Success: [
    ClientId(
        "07-tendermint-0",
    ),
    ClientId(
        "07-tendermint-1",
    ),
]
  1. The output of CLI hermes query clients is now sorted by the suffix of client ids
 $ hermes query clients ibc-0 -o
Success: [
    ClientId(
        "07-tendermint-0",
    ),
    ClientId(
        "07-tendermint-1",
    ),
    ClientId(
        "07-tendermint-2",
    ),
    ClientId(
        "07-tendermint-3",
    ),
    ClientId(
        "07-tendermint-4",
    ),
    ClientId(
        "07-tendermint-5",
    ),
    ClientId(
        "07-tendermint-6",
    ),
    ClientId(
        "07-tendermint-7",
    ),
    ClientId(
        "07-tendermint-8",
    ),
    ClientId(
        "07-tendermint-9",
    ),
    ClientId(
        "07-tendermint-10",
    ),
    ClientId(
        "07-tendermint-11",
    ),
]
  1. The command can filter clients by their source chain id using the option -s, --src-chain-id
hermes query clients ibc-0 -s network5
May 26 17:11:12.313  INFO ibc_relayer_cli::commands::query::clients: printing identifiers of all clients hosted on chain ibc-0 which target chain network5
Success: [
    ClientId(
        "07-tendermint-6",
    ),
]

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.

@adizere adizere requested a review from ebuchman May 26, 2021 09:04
@adizere adizere requested review from ancazamfir and romac as code owners May 26, 2021 09:04
@romac
Copy link
Member

romac commented May 26, 2021

Can we use a struct here instead of a tuple, to give names to the data?

$ hermes query clients network5 -i
 Success: [
    (
        ClientId(
            "07-tendermint-0",
        ),
        "network3",
    ),
]

@ancazamfir
Copy link
Collaborator

ancazamfir commented May 26, 2021

A few comments:

  • output typed ChainId
  • should allow hermes query clients ibc-0 [--src-chain ibc-1] [--include-chain-ids]
  • maybe make the -i default and add -s like in summary or some other better name for IDs only

@adizere
Copy link
Member Author

adizere commented May 26, 2021

@romac @ancazamfir thank you for the review! Most comments should be addressed.

@ancazamfir
Copy link
Collaborator

@romac @ancazamfir thank you for the review! Most comments should be addressed.

thanks, could you please update the description?

@adizere adizere requested a review from ancazamfir May 26, 2021 15:15
@adizere
Copy link
Member Author

adizere commented May 26, 2021

@romac @ancazamfir thank you for the review! Most comments should be addressed.

thanks, could you please update the description?

Done!

@ancazamfir
Copy link
Collaborator

Not sure if we should introduce target_chain_id here, I would keep it chain_id to be consistent with the state query.
So the two commands side-by-side would look like this (also maybe rename ClientChain, also it's not a tuple):

$ hermes query clients ibc-0
Success: [
    ClientChain {
        client_id: ClientId(
            "07-tendermint-0",
        ),
        chain_id: ChainId {
            id: "ibc-1",
            version: 1,
        },
    },
]
$ hermes query client state ibc-0 07-tendermint-0
Success: ClientState {
    chain_id: ChainId {
        id: "ibc-1",
        version: 1,
    },
    trust_level: TrustThresholdFraction {
        numerator: 1,
        denominator: 3,
    },
    trusting_period: 1209600s,
    unbonding_period: 1814400s,
    max_clock_drift: 5s,
    frozen_height: Height {
        revision: 0,
        height: 0,
    },
    latest_height: Height {
        revision: 1,
        height: 468,
    },
    upgrade_path: [
        "upgrade",
        "upgradedIBCState",
    ],
    allow_update: AllowUpdate {
        after_expiry: false,
        after_misbehaviour: false,
    },
}

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! A few comments around help, debugs, etc.

modules/src/ics24_host/identifier.rs Outdated Show resolved Hide resolved
relayer-cli/src/commands/query/clients.rs Outdated Show resolved Hide resolved
relayer-cli/src/commands/query/clients.rs Outdated Show resolved Hide resolved
relayer-cli/src/commands/query/clients.rs Outdated Show resolved Hide resolved
relayer-cli/src/commands/query/clients.rs Outdated Show resolved Hide resolved
@adizere adizere requested a review from ancazamfir May 27, 2021 13:50
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 eea2a60 into master Jun 1, 2021
@adizere adizere deleted the adi/992_clients branch June 1, 2021 08:28
@adizere adizere mentioned this pull request Jun 1, 2021
9 tasks
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Added option to include chain ids. Client ids sorted by counter.

* Changelog

* Address comments

* Removed useless gumdrop derive attributes.

* Better info log message

* Better names for output struct. Using ChainId instead of String.

* Lowered log level to debug

* Succint help messages.

* Moved ClientId::suffix() into cosmos.rs
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.

Include chain-id in hermes query clients output
3 participants