Skip to content

feat: clientv2 module#7936

Merged
AdityaSripal merged 18 commits intomainfrom
feat/client-v2-module
Feb 11, 2025
Merged

feat: clientv2 module#7936
AdityaSripal merged 18 commits intomainfrom
feat/client-v2-module

Conversation

@aljo242
Copy link
Copy Markdown
Contributor

@aljo242 aljo242 commented Feb 7, 2025

Description

closes: #7875
closes: #7923

  • move all Counterparty keeper and type logic to a v2 package
  • create query implementation
  • create and wire genesis into core module

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Copy link
Copy Markdown
Contributor

@gjermundgaraba gjermundgaraba left a comment

Choose a reason for hiding this comment

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

Similar to the comment in channel-v2. Genesis (including tests) and most of the wiring happens in the core module for v1. v2 should do the same.

Copy link
Copy Markdown
Contributor

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

I think I would prefer the channelV2Keeper still only taking a single clientV2Keeper since the fact that they are different is an implementation detail that only exists because ibc-go is implementing both IBC Classic and IBC Eureka

But open to pushback from the other engineers

// CounterpartyInfo gets the CounterpartyInfo from the store corresponding to the request client ID.
func (q queryServer) CounterpartyInfo(ctx context.Context, request *types.QueryCounterpartyInfoRequest) (*types.QueryCounterpartyInfoResponse, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We generally do a bit more validation before the grpc directly gets from store. Would be good to follow the same.

See the v1 chanKeeper grpc implementation

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should have a test file for this as well.

Comment on lines +41 to +52
cdc codec.Codec
ctx sdk.Context
keeper *keeper.Keeper
consensusState *ibctm.ConsensusState
valSet *cmttypes.ValidatorSet
valSetHash cmtbytes.HexBytes
privVal cmttypes.PrivValidator
now time.Time
past time.Time
solomachine *ibctesting.Solomachine

signers map[string]cmttypes.PrivValidator
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Lot of unnecessary fields here

Comment on lines 23 to -27
GetClientState(ctx context.Context, clientID string) (exported.ClientState, bool)
// GetClientConsensusState gets the stored consensus state from a client at a given height.
GetClientConsensusState(ctx context.Context, clientID string, height exported.Height) (exported.ConsensusState, bool)
// GetClientCounterparty returns the counterpartyInfo given a clientID
GetClientCounterparty(ctx context.Context, clientID string) (clienttypes.CounterpartyInfo, bool)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I kind of think this should remain but have clientV2Keeper implement this interface and only have channelKeeper take in a ClientV2Keeper.

What do you think @gjermundgaraba

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To me it seems a bit strange to have it on v1, since it is not used there. The only reason to keep it on v1 would be to avoid having to deal with v2. I feel like it would be less indirection and clearer code if we use the v2 keeper directly when needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@AdityaSripal do you mean to have the ClientV2Keeper basically wrap the client V1 Keeper and extend it with this extra CounterParty functionality?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but i will do this in a separate PR probably after the audit

@@ -37,13 +41,15 @@ func NewKeeper(
cdc codec.BinaryCodec,
env appmodule.Environment,
clientKeeper types.ClientKeeper,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Think we should still just have this interface and have clientV2Keeper implement it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you mean have the clientV2Keeper implement the full ClientKeeper interface?

@sonarqubecloud
Copy link
Copy Markdown

path1.SetupClients()
// counter party not set up

expInfo = types.NewCounterpartyInfo(path1.EndpointA.Counterparty.MerklePathPrefix.KeyPath, path1.EndpointA.ClientID)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this doesn't need to exist right since we have non-nil err


// Validate checks the CounterpartyInfos added to the genesis for validity.
func (gs GenesisState) Validate() error {
seenIDs := make(map[string]struct{})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why do you do this instead of a bool?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a good check but don't think we do this elsewhere

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You think better to remove? The empty struct pattern is a bit of a go idiom for doing inclusion checks like this. Its technically more space / cache efficient because to the compiler it does not take up space whereas a bool does.

In this case it is such a minor use case that it wont have any impact.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ahh i see. no its fine keep it as-is

Comment on lines 23 to -27
GetClientState(ctx context.Context, clientID string) (exported.ClientState, bool)
// GetClientConsensusState gets the stored consensus state from a client at a given height.
GetClientConsensusState(ctx context.Context, clientID string, height exported.Height) (exported.ConsensusState, bool)
// GetClientCounterparty returns the counterpartyInfo given a clientID
GetClientCounterparty(ctx context.Context, clientID string) (clienttypes.CounterpartyInfo, bool)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, but i will do this in a separate PR probably after the audit

@AdityaSripal AdityaSripal added this pull request to the merge queue Feb 11, 2025
Merged via the queue into main with commit 5296070 Feb 11, 2025
58 of 64 checks passed
@AdityaSripal AdityaSripal deleted the feat/client-v2-module branch February 11, 2025 18:39
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.

Refactor 02-client v2 with a standardized msg server and genesis Add a query for CounterpartyInfo

3 participants