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

refactor: solomachine generic VerifyNonMembership #1720

Conversation

damiannolan
Copy link
Member

Description

  • Adding solomachine generic VerifyNonMembership implementation
  • Adding tests
  • Refactoring common code to produceVerificationArgs helper func

NOTE: this PR is targeted for #1687

closes: #XXXX


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 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.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@codecov-commenter
Copy link

Codecov Report

Merging #1720 (a438052) into damian/solomachine-generic-verify (8bfb01d) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@                          Coverage Diff                          @@
##           damian/solomachine-generic-verify    #1720      +/-   ##
=====================================================================
+ Coverage                              80.06%   80.11%   +0.05%     
=====================================================================
  Files                                    166      166              
  Lines                                  11808    11841      +33     
=====================================================================
+ Hits                                    9454     9487      +33     
+ Misses                                  1905     1904       -1     
- Partials                                 449      450       +1     
Impacted Files Coverage Δ
...dules/light-clients/06-solomachine/client_state.go 71.54% <100.00%> (+2.85%) ⬆️

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.

Appreciate the great test coverage ❤️

sdkerrors.ErrInvalidHeight,
"client state sequence != proof sequence (%d != %d)", latestSequence, sequence,
)
publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, proof)
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] I know produceVerificationArgs wasn't changed in this PR, so feel free to dis-regard, but I think 5 values is a bit too many to return. What do you think about wrapping the first 4 values in a struct and having the the method signature return the struct and an error? (unless we can't change the method signature for some reason)

verificationArgs, err := produceVerificationArgs(cdc, cs, height, proof)

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like a great suggestion to me

I guess my only concern would be constructing a type verificationArgs which are dependent on arguments that needed to be checked rather than the totality of arguments required for verification. The path/diversifier/data being the others. We could also take away some of the return arguments (public key, sequence) can be derived from the client state. Originally this function was made to reduce redundancy of calls by 6-7 functions, now only 2 functions rely on it so redundancy isn't as much of a concern. Thoughts?

Copy link
Member Author

Choose a reason for hiding this comment

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

In general I agree, and normally lean against having such a large number of return args. I'd be happy to continue the discussion or explore options for improving the function sig and its usage, maybe we could potentially open an issue for this? At least this an unexported function so whatever we decide should not have any implications on consumers.
I'm going to go ahead and merge this to the [WIP] branch and get it R4R with renaming types to remove the V2 suffixes.

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! :)

sdkerrors.ErrInvalidHeight,
"client state sequence != proof sequence (%d != %d)", latestSequence, sequence,
)
publicKey, sigData, timestamp, sequence, err := produceVerificationArgs(cdc, cs, height, proof)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds like a great suggestion to me

I guess my only concern would be constructing a type verificationArgs which are dependent on arguments that needed to be checked rather than the totality of arguments required for verification. The path/diversifier/data being the others. We could also take away some of the return arguments (public key, sequence) can be derived from the client state. Originally this function was made to reduce redundancy of calls by 6-7 functions, now only 2 functions rely on it so redundancy isn't as much of a concern. Thoughts?

modules/light-clients/06-solomachine/client_state_test.go Outdated Show resolved Hide resolved
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
@damiannolan damiannolan merged commit e9b5801 into damian/solomachine-generic-verify Jul 27, 2022
@damiannolan damiannolan deleted the damian/solomachine-verify-non-membership branch July 27, 2022 20:35
colin-axner added a commit that referenced this pull request Aug 2, 2022
…lification (#1687)

* adding new SignBytes type, generic membership verification implementation and tests

* adding protodocs

* updating comment

* refactor: solomachine misbehaviour checking (#1715)

* adding SignatureAndDataV2 proto message type

* updating misbehaviour checking

* removing dead solomachine code (#1716)

* updating tests with concrete ibc core types

* refactor: solomachine generic VerifyNonMembership (#1720)

* adding verification of non-membership with tests

* refactor common code to produceVerificationArgs

* removing unused produce args func

* Update modules/light-clients/06-solomachine/client_state_test.go

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

* removing V2 suffix from SignBytes and SignatureAndData types

* use current diversifier when verifying header details

* Add test for new diversifier for solomachine (#1860)

* add test for successful new diversifier

* add changelog entry

* fix tests

* restoring solomachine/v2 protos, updadting v2 codegen path and adding solomachine/v3 protobuf defs

* adding changelog entries

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
oshorefueled pushed a commit to ComposableFi/ibc-go that referenced this pull request Aug 9, 2022
…lification (cosmos#1687)

* adding new SignBytes type, generic membership verification implementation and tests

* adding protodocs

* updating comment

* refactor: solomachine misbehaviour checking (cosmos#1715)

* adding SignatureAndDataV2 proto message type

* updating misbehaviour checking

* removing dead solomachine code (cosmos#1716)

* updating tests with concrete ibc core types

* refactor: solomachine generic VerifyNonMembership (cosmos#1720)

* adding verification of non-membership with tests

* refactor common code to produceVerificationArgs

* removing unused produce args func

* Update modules/light-clients/06-solomachine/client_state_test.go

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>

* removing V2 suffix from SignBytes and SignatureAndData types

* use current diversifier when verifying header details

* Add test for new diversifier for solomachine (cosmos#1860)

* add test for successful new diversifier

* add changelog entry

* fix tests

* restoring solomachine/v2 protos, updadting v2 codegen path and adding solomachine/v3 protobuf defs

* adding changelog entries

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
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.

5 participants