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 misbehaviour checking #1715

Conversation

damiannolan
Copy link
Member

@damiannolan damiannolan commented Jul 15, 2022

Description

  • Updates SignatureAndData type temporarily to SignatureAndDataV2
  • Refactors misbehaviour checking code

NOTE: branch 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 #1715 (ec8e4c4) into damian/solomachine-generic-verify (8bfb01d) will decrease coverage by 0.20%.
The diff coverage is 96.00%.

Impacted file tree graph

@@                          Coverage Diff                          @@
##           damian/solomachine-generic-verify    #1715      +/-   ##
=====================================================================
- Coverage                              80.06%   79.85%   -0.21%     
=====================================================================
  Files                                    166      166              
  Lines                                  11808    11821      +13     
=====================================================================
- Hits                                    9454     9440      -14     
- Misses                                  1905     1931      +26     
- Partials                                 449      450       +1     
Impacted Files Coverage Δ
...ight-clients/06-solomachine/misbehaviour_handle.go 79.31% <90.90%> (-10.69%) ⬇️
...dules/light-clients/06-solomachine/misbehaviour.go 66.66% <100.00%> (-23.34%) ⬇️
modules/light-clients/06-solomachine/proof.go 75.55% <0.00%> (-3.71%) ⬇️

@@ -71,6 +71,24 @@ func (sd SignatureAndData) ValidateBasic() error {
return nil
}

// ValidateBasic ensures that the signature and data fields are non-empty.
func (sd SignatureAndDataV2) ValidateBasic() error {
if len(sd.Signature) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nit, but maybe UX could be slightly improved if we group errors, in case more than one thing is empty. For example, if both signature and data are empty, then you can return one error saying that signature and data cannot be empty.

Copy link
Contributor

@charleenfei charleenfei Jul 18, 2022

Choose a reason for hiding this comment

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

i kind of like having the separate errors as they come rather than arbitrarily grouping errors (sometimes two? sometimes 3? what if all four error out?), this way we can keep it consistent across the codebase...

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 this point has come up a few times before. I tend to agree with the general behaviour of the sdk of "fail fast" where the error is returned immediately rather than grouping. I think it makes for more idiomatic go code. I do see the reasoning for validating the entire message and returning a group of error responses... it is in line with more traditional rest api design in a way. But all things considered I'd prefer to keep the code consistent and stay aligned with the sdk pattern.

If we were to change the behaviour here it should be changed across our entire codebase. And still, it would differ from standard sdk modules then like x/auth,x/bank, x/gov ..etc

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.

Thank you! 🙌 Changes look great! Very clean and easy to review :)

@damiannolan damiannolan merged commit 4d33a46 into damian/solomachine-generic-verify Jul 19, 2022
@damiannolan damiannolan deleted the damian/solomachine-misbehaviour-refactor branch July 19, 2022 12:50
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