-
Notifications
You must be signed in to change notification settings - Fork 623
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
Conversation
Would like to add a couple of more tests:
Please raise any more in the comments if applicable! |
There was a problem hiding this 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.
Co-authored-by: Carlos Rodriguez <[email protected]>
There was a problem hiding this 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
…ests for discarded state checks
@@ -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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the |
if err := host.ClientIdentifierValidator(req.ClientId); err != nil { | ||
return nil, status.Error(codes.InvalidArgument, err.Error()) | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localhost as well?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created this issue: #5848
There was a problem hiding this comment.
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.
There was a problem hiding this 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
if req.ProofHeight.IsZero() { | ||
return nil, status.Error(codes.InvalidArgument, "proof height must be non-zero") | ||
} | ||
|
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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? :)
if err := host.ClientIdentifierValidator(req.ClientId); err != nil { | ||
return nil, status.Error(codes.InvalidArgument, err.Error()) | ||
} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this 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 👍
if err := host.ClientIdentifierValidator(req.ClientId); err != nil { | ||
return nil, status.Error(codes.InvalidArgument, err.Error()) | ||
} |
There was a problem hiding this comment.
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
if err := host.ClientIdentifierValidator(req.ClientId); err != nil { | ||
return nil, status.Error(codes.InvalidArgument, err.Error()) | ||
} |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
…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 <[email protected]> * 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 <[email protected]> Co-authored-by: Cian Hatton <[email protected]> (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
…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 <[email protected]> * 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 <[email protected]> Co-authored-by: Cian Hatton <[email protected]> (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 <[email protected]>
…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 <[email protected]> * 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 <[email protected]> Co-authored-by: Cian Hatton <[email protected]> (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
…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 <[email protected]> * 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 <[email protected]> Co-authored-by: Cian Hatton <[email protected]> (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 <[email protected]> Co-authored-by: Carlos Rodriguez <[email protected]>
Description
Adds the new
Query
service rpcVerifyMembershipProof
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.
docs/
) or specification (x/<module>/spec/
).godoc
comments.Files changed
in the Github PR explorer.Codecov Report
in the comment section below once CI passes.