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

feat: add provider info query #1164

Merged
merged 21 commits into from
Aug 9, 2023
Merged

feat: add provider info query #1164

merged 21 commits into from
Aug 9, 2023

Conversation

yaruwangway
Copy link
Contributor

@yaruwangway yaruwangway commented Jul 21, 2023

Description

Closes: #1110

a manual query in docker:

interchain-security-cd q ccvconsumer provider-info
consumer:
  ChainID: consu
  ChannelID: channel-0
  ClientID: 07-tendermint-0
  ConnectionID: connection-0
provider:
  ChainID: provi
  ChannelID: channel-0
  ClientID: 07-tendermint-0
  ConnectionID: connection-0

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • Included the correct type prefix in the PR title
  • Added ! to the type prefix if state-machine breaking change (i.e., requires coordinated upgrade)
  • Confirmed this PR does not introduce changes requiring state migrations, OR migration code has been added to consumer and/or provider modules
  • Targeted the correct branch (see PR Targeting)
  • Provided a link to the relevant issue or specification
  • Followed the guidelines for building SDK modules
  • Included the necessary unit and integration tests
  • Added a changelog entry to CHANGELOG.md
  • Included comments for documenting Go code
  • Updated the relevant documentation or specification
  • Reviewed "Files changed" and left comments if necessary
  • Confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed this PR does not introduce changes requiring state migrations, OR confirmed migration code has been added to consumer and/or provider modules
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage

@yaruwangway
Copy link
Contributor Author

yaruwangway commented Jul 21, 2023

According to issue #1110, I only returned providerChainID when query QueryProviderChainInfo in consumer. Or shall i return the whole ClientState info ?
Here is the ClientSteate info:

type ClientState struct {
    ChainId                      string           `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
    TrustLevel                   Fraction         `protobuf:"bytes,2,opt,name=trust_level,json=trustLevel,proto3" json:"trust_level" yaml:"trust_level"`
    TrustingPeriod               time.Duration    `protobuf:"bytes,3,opt,name=trusting_period,json=trustingPeriod,proto3,stdduration" json:"trusting_period" yaml:"trusting_period"`
    UnbondingPeriod              time.Duration    `protobuf:"bytes,4,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period" yaml:"unbonding_period"`
    MaxClockDrift                time.Duration    `protobuf:"bytes,5,opt,name=max_clock_drift,json=maxClockDrift,proto3,stdduration" json:"max_clock_drift" yaml:"max_clock_drift"`
    FrozenHeight                 types.Height     `protobuf:"bytes,6,opt,name=frozen_height,json=frozenHeight,proto3" json:"frozen_height" yaml:"frozen_height"`
    LatestHeight                 types.Height     `protobuf:"bytes,7,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height" yaml:"latest_height"`
    ProofSpecs                   []*ics23.ProofSpec `protobuf:"bytes,8,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty" yaml:"proof_specs"`
    UpgradePath                  []string         `protobuf:"bytes,9,rep,name=upgrade_path,json=upgradePath,proto3" json:"upgrade_path,omitempty" yaml:"upgrade_path"`
    AllowUpdateAfterExpiry       bool             `protobuf:"varint,10,opt,name=allow_update_after_expiry,json=allowUpdateAfterExpiry,proto3" json:"allow_update_after_expiry,omitempty" yaml:"allow_update_after_expiry"`
    AllowUpdateAfterMisbehaviour bool             `protobuf:"varint,11,opt,name=allow_update_after_misbehaviour,json=allowUpdateAfterMisbehaviour,proto3" json:"allow_update_after_misbehaviour,omitempty" yaml:"allow_update_after_misbehaviour"`
}

@MSalopek
Copy link
Contributor

MSalopek commented Jul 22, 2023

According to issue #1110, I only returned providerChainID when query QueryProviderChainInfo in consumer. Or shall i return the whole ClientState info ? Here is the ClientSteate info:

type ClientState struct {
    ChainId                      string           `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"`
    TrustLevel                   Fraction         `protobuf:"bytes,2,opt,name=trust_level,json=trustLevel,proto3" json:"trust_level" yaml:"trust_level"`
    TrustingPeriod               time.Duration    `protobuf:"bytes,3,opt,name=trusting_period,json=trustingPeriod,proto3,stdduration" json:"trusting_period" yaml:"trusting_period"`
    UnbondingPeriod              time.Duration    `protobuf:"bytes,4,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period" yaml:"unbonding_period"`
    MaxClockDrift                time.Duration    `protobuf:"bytes,5,opt,name=max_clock_drift,json=maxClockDrift,proto3,stdduration" json:"max_clock_drift" yaml:"max_clock_drift"`
    FrozenHeight                 types.Height     `protobuf:"bytes,6,opt,name=frozen_height,json=frozenHeight,proto3" json:"frozen_height" yaml:"frozen_height"`
    LatestHeight                 types.Height     `protobuf:"bytes,7,opt,name=latest_height,json=latestHeight,proto3" json:"latest_height" yaml:"latest_height"`
    ProofSpecs                   []*ics23.ProofSpec `protobuf:"bytes,8,rep,name=proof_specs,json=proofSpecs,proto3" json:"proof_specs,omitempty" yaml:"proof_specs"`
    UpgradePath                  []string         `protobuf:"bytes,9,rep,name=upgrade_path,json=upgradePath,proto3" json:"upgrade_path,omitempty" yaml:"upgrade_path"`
    AllowUpdateAfterExpiry       bool             `protobuf:"varint,10,opt,name=allow_update_after_expiry,json=allowUpdateAfterExpiry,proto3" json:"allow_update_after_expiry,omitempty" yaml:"allow_update_after_expiry"`
    AllowUpdateAfterMisbehaviour bool             `protobuf:"varint,11,opt,name=allow_update_after_misbehaviour,json=allowUpdateAfterMisbehaviour,proto3" json:"allow_update_after_misbehaviour,omitempty" yaml:"allow_update_after_misbehaviour"`
}

Client state is not needed, only ClientId.

The issue states this as a nice to have:

  • The connection ends between the provider and consumer, containing the client ids on the provider and consumer side

I think you can get all the info needed using functions from ibc.ChannelKeeper:

You may need to add those functions to the expected_keepers.go to make them available in ICS

@yaruwangway
Copy link
Contributor Author

yaruwangway commented Jul 31, 2023

hi @MSalopek , i can get providerClientID, but for the connectionEnd, I need connectionID, how could i know connectionID?

 connectionEnd, found := k.connectionKeeper.GetConnection(ctx, "connectionID")

@MSalopek
Copy link
Contributor

hi @MSalopek , i can get providerClientID, but for the connectionEnd, I need connectionID, how could i know connectionID?

 connectionEnd, found := k.connectionKeeper.GetConnection(ctx, "connectionID")

Answered in a pair programming session.

@yaruwangway yaruwangway marked this pull request as ready for review August 3, 2023 15:44
@yaruwangway yaruwangway requested a review from a team as a code owner August 3, 2023 15:44
Copy link
Contributor

@p-offtermatt p-offtermatt left a comment

Choose a reason for hiding this comment

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

Thanks for the nice work!
Changes look good to me. One suggestion, I think in a few places there should be errors returned instead of nil. If you do really want to return nil there, I think you might want to add a comment explaining why.
Other than that, make sure to run make lint locally, seems the CI linter is complaining

x/ccv/consumer/keeper/provider_info.go Outdated Show resolved Hide resolved
x/ccv/consumer/keeper/provider_info.go Outdated Show resolved Hide resolved
@MSalopek
Copy link
Contributor

MSalopek commented Aug 4, 2023

Pls fix the linter issues

Copy link
Contributor

@MSalopek MSalopek left a comment

Choose a reason for hiding this comment

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

LGTM

Not sure the mock is actually used?

testutil/keeper/mocks.go Show resolved Hide resolved
@yaruwangway yaruwangway merged commit aaa545d into main Aug 9, 2023
@yaruwangway yaruwangway deleted the add-provider-info-query branch August 9, 2023 08:45
@@ -8,6 +8,7 @@ Add an entry to the unreleased section whenever merging a PR to main that is not
* (fix!) revert consumer packet data changes from #1037 [#1150](https://github.com/cosmos/interchain-security/pull/1150)
* (fix!) proper deletion of pending packets [#1146](https://github.com/cosmos/interchain-security/pull/1146)
* (feat!) optimize pending packets storage on consumer, with migration! [#1037](https://github.com/cosmos/interchain-security/pull/1037)
* (feat) introduce the gRPC query `/interchain_security/ccv/consumer/provider-info` and CLI command `interchain-security-cd q ccvconsumer provider-info`to retrieve provider info from the consumer chain.
Copy link
Contributor

Choose a reason for hiding this comment

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

@yaruwangway please include a PR link next time

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.

Add gRPC query to consumer to fetch info about provider
5 participants