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 rpc VerifyMembershipProof - querier approach for conditional clients #5821

Merged
merged 22 commits into from
Feb 15, 2024

Conversation

damiannolan
Copy link
Member

Description

Adds the new Query service rpc VerifyMembershipProof outlined in #5310. Big thanks to @srdtrk for the initial deep dive on this issue.

closes: #5310


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/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

@damiannolan
Copy link
Member Author

damiannolan commented Feb 7, 2024

Would like to add a couple of more tests:

  • 08-wasm stargate querier
  • Gas is correctly consumed from context

Please raise any more in the comments if applicable!

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Nice and clean. Thank you for the PR, @damiannolan; and thank you @srdtrk for the ground work.

proto/ibc/core/client/v1/query.proto Outdated Show resolved Hide resolved
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

lgtm, left one minor nit for your viewing pleasure

modules/light-clients/08-wasm/types/querier.go Outdated Show resolved Hide resolved
@@ -328,3 +328,55 @@ func (k Keeper) UpgradedConsensusState(c context.Context, req *types.QueryUpgrad
UpgradedConsensusState: protoAny,
}, nil
}

// VerifyMembership implements the Query/VerifyMembership gRPC method
func (k Keeper) VerifyMembership(c context.Context, req *types.QueryVerifyMembershipRequest) (*types.QueryVerifyMembershipResponse, error) {
Copy link
Contributor

@crodriguezvega crodriguezvega Feb 13, 2024

Choose a reason for hiding this comment

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

Should we document this addition and the fact that there is going to be a set of default allowed queries made available to the querier? Maybe in the 08-wasm docs?

Copy link
Member Author

Choose a reason for hiding this comment

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

@crodriguezvega
Copy link
Contributor

I added the backport-to-v8.2.x label to the PR, but I guess we also need to create a new release branch for 08-wasm that will depend on ibc-go v8.2 and backport to that branch the 08-wasm changes of the PR? Like release/v0.2.x+ibc-go-v8.2.x-wasmvm-v2.0.x (and then we can also upgrade to the latest wasmvm version)?

Comment on lines +338 to +340
if err := host.ClientIdentifierValidator(req.ClientId); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should error if the client type is solo machine?

Copy link
Contributor

Choose a reason for hiding this comment

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

localhost as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

do we also want to error if the client is not active, i.e.

k.GetClientStatus(cachedCtx, clientState, req.ClientId) != exported.Active

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should error if the client type is solo machine?

This would involve adding solomachine types as a concrete dependency in 02-client which I think is currently not the case, (it is already with localhost though).

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should error if the client type is solo machine?

Why would we error if it is solomachine client type? State changes are discarded so no sequence incrementing will happen. Shouldn't it be fine to let it go through, just sig verify on whatever bytes? Is it that solomachine is only signing one particular set of bytes for a one sequence? i.e. you will be able to verify for example, a channel end signed at sequence x? so in theory the VerifyMembership query is only available for proof one value at a particular point in time. Does that make sense?

localhost as well?

Yeah, if you query a chain for a proof and have access to an rpc for a header to get the app hash then you should be able to verify off chain and it would be spammy(?) I guess to allow a query to go through like that. Fee like there's no reason to allow it.

This would involve adding solomachine types as a concrete dependency in 02-client which I think is currently not the case, (it is already with localhost though)

Solomachine client type is in exported afaik.

Copy link
Member Author

Choose a reason for hiding this comment

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

Created this issue: #5848

Copy link
Contributor

Choose a reason for hiding this comment

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

solomachine client type is a string, it can be duplicated

Is it that solomachine is only signing one particular set of bytes for a one sequence?

yes it is.

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Excellent work!!! Thanks for all the followup changes. My only requested addition is to disable light clients on the verify membership query which we don't want to support initially to limit any potential side effects we aren't trying to account for. I'm okay doing this in a followup though since the diffs should be quite minimal and mainly an addition

modules/core/02-client/keeper/grpc_query.go Show resolved Hide resolved
Comment on lines +346 to +349
if req.ProofHeight.IsZero() {
return nil, status.Error(codes.InvalidArgument, "proof height must be non-zero")
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think proof height is allowed to be empty? (for localhost?)

Copy link
Member Author

Choose a reason for hiding this comment

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

if we disable localhost then we should be sweet? :)

Comment on lines +338 to +340
if err := host.ClientIdentifierValidator(req.ClientId); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

localhost as well?

return nil, status.Error(codes.NotFound, errorsmod.Wrap(types.ErrClientNotFound, req.ClientId).Error())
}

if err := clientState.VerifyMembership(cachedCtx, k.ClientStore(cachedCtx, req.ClientId), k.cdc, req.ProofHeight, req.TimeDelay, req.BlockDelay, req.Proof, req.MerklePath, req.Value); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

if we ever add a mock client, I think this would be a good test case we could use it on. I think it is nice to be testing the state change in 02-client rather than 08-wasm, but it is fine for now

Copy link
Contributor

@chatton chatton 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! Left some small suggestions but nothing major 👍

Comment on lines +338 to +340
if err := host.ClientIdentifierValidator(req.ClientId); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do we also want to error if the client is not active, i.e.

k.GetClientStatus(cachedCtx, clientState, req.ClientId) != exported.Active

Comment on lines +338 to +340
if err := host.ClientIdentifierValidator(req.ClientId); err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should error if the client type is solo machine?

This would involve adding solomachine types as a concrete dependency in 02-client which I think is currently not the case, (it is already with localhost though).

@@ -130,7 +135,7 @@ func NewDefaultQueryPlugins() *QueryPlugins {
func AcceptListStargateQuerier(acceptedQueries []string) func(sdk.Context, *wasmvmtypes.StargateQuery) ([]byte, error) {
return func(ctx sdk.Context, request *wasmvmtypes.StargateQuery) ([]byte, error) {
// A default list of accepted queries can be added here.
Copy link
Contributor

Choose a reason for hiding this comment

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

think this comment can be adjusted since we are adding this default list now

@damiannolan damiannolan enabled auto-merge (squash) February 15, 2024 12:28
@damiannolan damiannolan merged commit ed9bf74 into main Feb 15, 2024
77 of 79 checks passed
@damiannolan damiannolan deleted the damian/5310-conditional-clients-querier branch February 15, 2024 12:32
mergify bot pushed a commit that referenced this pull request Feb 15, 2024
…nal clients (#5821)

* feat: adding protobuf msgs and rpc for VerifyMembershipProof

* feat: adding VerifyMembershipProof query implementation and wiring

* chore(08-wasm): add VerifyMembershipProof to stargate query acceptlist

* test: adding failure case unit tests for VerifyMembershipProof query

* fix: correct protodoc

* chore: proto-swagger-gen

* chore: protodocs

* test: adding additional test cases

* test: assert gas consumed in tests

* chore: rename rpc to VerifyMembership and update tests

* chore: update service definition URL in 08-wasm stargate accepted queries

* test: adding verify membership test to 08-wasm querier

* Update proto/ibc/core/client/v1/query.proto

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>

* chore: review items - log error at debug, pass cachedCtx and adjust tests for discarded state checks

* chore: add doc comment to querier test, address nit to move defaultAcceptList

* chore: regen protos and swagger doc

* nit: update comment in querier

* imp: add more info to godoc for VerifyMembership rpc

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Cian Hatton <cian@interchain.io>
(cherry picked from commit ed9bf74)

# Conflicts:
#	docs/client/swagger-ui/swagger.yaml
#	modules/light-clients/08-wasm/types/querier.go
#	modules/light-clients/08-wasm/types/querier_test.go
damiannolan added a commit that referenced this pull request Feb 15, 2024
…nal clients (backport #5821) (#5850)

* feat: add rpc `VerifyMembershipProof` - querier approach for conditional clients (#5821)

* feat: adding protobuf msgs and rpc for VerifyMembershipProof

* feat: adding VerifyMembershipProof query implementation and wiring

* chore(08-wasm): add VerifyMembershipProof to stargate query acceptlist

* test: adding failure case unit tests for VerifyMembershipProof query

* fix: correct protodoc

* chore: proto-swagger-gen

* chore: protodocs

* test: adding additional test cases

* test: assert gas consumed in tests

* chore: rename rpc to VerifyMembership and update tests

* chore: update service definition URL in 08-wasm stargate accepted queries

* test: adding verify membership test to 08-wasm querier

* Update proto/ibc/core/client/v1/query.proto

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>

* chore: review items - log error at debug, pass cachedCtx and adjust tests for discarded state checks

* chore: add doc comment to querier test, address nit to move defaultAcceptList

* chore: regen protos and swagger doc

* nit: update comment in querier

* imp: add more info to godoc for VerifyMembership rpc

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Cian Hatton <cian@interchain.io>
(cherry picked from commit ed9bf74)

# Conflicts:
#	docs/client/swagger-ui/swagger.yaml
#	modules/light-clients/08-wasm/types/querier.go
#	modules/light-clients/08-wasm/types/querier_test.go

* chore: rm 08-wasm module files

* fix: setup path using coordinator in tests

---------

Co-authored-by: Damian Nolan <damiannolan@gmail.com>
mergify bot pushed a commit that referenced this pull request Apr 8, 2024
…nal clients (#5821)

* feat: adding protobuf msgs and rpc for VerifyMembershipProof

* feat: adding VerifyMembershipProof query implementation and wiring

* chore(08-wasm): add VerifyMembershipProof to stargate query acceptlist

* test: adding failure case unit tests for VerifyMembershipProof query

* fix: correct protodoc

* chore: proto-swagger-gen

* chore: protodocs

* test: adding additional test cases

* test: assert gas consumed in tests

* chore: rename rpc to VerifyMembership and update tests

* chore: update service definition URL in 08-wasm stargate accepted queries

* test: adding verify membership test to 08-wasm querier

* Update proto/ibc/core/client/v1/query.proto

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>

* chore: review items - log error at debug, pass cachedCtx and adjust tests for discarded state checks

* chore: add doc comment to querier test, address nit to move defaultAcceptList

* chore: regen protos and swagger doc

* nit: update comment in querier

* imp: add more info to godoc for VerifyMembership rpc

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Cian Hatton <cian@interchain.io>
(cherry picked from commit ed9bf74)

# Conflicts:
#	docs/client/swagger-ui/swagger.yaml
#	modules/light-clients/08-wasm/types/querier.go
#	modules/light-clients/08-wasm/types/querier_test.go
damiannolan added a commit that referenced this pull request Apr 8, 2024
…nal clients (backport #5821) (#6105)

* feat: add rpc `VerifyMembershipProof` - querier approach for conditional clients (#5821)

* feat: adding protobuf msgs and rpc for VerifyMembershipProof

* feat: adding VerifyMembershipProof query implementation and wiring

* chore(08-wasm): add VerifyMembershipProof to stargate query acceptlist

* test: adding failure case unit tests for VerifyMembershipProof query

* fix: correct protodoc

* chore: proto-swagger-gen

* chore: protodocs

* test: adding additional test cases

* test: assert gas consumed in tests

* chore: rename rpc to VerifyMembership and update tests

* chore: update service definition URL in 08-wasm stargate accepted queries

* test: adding verify membership test to 08-wasm querier

* Update proto/ibc/core/client/v1/query.proto

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>

* chore: review items - log error at debug, pass cachedCtx and adjust tests for discarded state checks

* chore: add doc comment to querier test, address nit to move defaultAcceptList

* chore: regen protos and swagger doc

* nit: update comment in querier

* imp: add more info to godoc for VerifyMembership rpc

---------

Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Co-authored-by: Cian Hatton <cian@interchain.io>
(cherry picked from commit ed9bf74)

# Conflicts:
#	docs/client/swagger-ui/swagger.yaml
#	modules/light-clients/08-wasm/types/querier.go
#	modules/light-clients/08-wasm/types/querier_test.go

* fix conflicts

---------

Co-authored-by: Damian Nolan <damiannolan@gmail.com>
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-to-v8.3.x priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Querier Approach for Conditional Clients
5 participants