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

Fix sequence number handling for LegacyAmino > SignatureV2 #7285

Merged
merged 14 commits into from
Sep 16, 2020

Conversation

clevinson
Copy link
Contributor

@clevinson clevinson commented Sep 11, 2020

Description

I've added a new rest handler test in x/auth/client/rest/rest_test.go with which i've been able to reproduce @zmanian's error.

Additionally, I implemented the basic logic @aaronc described (checking for any SIGN_MODE_DIRECT modes in SignatureData), as an alternative to SkipSequenceCheck flag. This strategy does infact get my tests to pass.

Would be great if @zmanian can have a look.

closes: #7229


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
Copy link

codecov bot commented Sep 11, 2020

Codecov Report

Merging #7285 into master will increase coverage by 0.99%.
The diff coverage is 51.33%.

@@            Coverage Diff             @@
##           master    #7285      +/-   ##
==========================================
+ Coverage   55.60%   56.60%   +0.99%     
==========================================
  Files         457      435      -22     
  Lines       27440    31712    +4272     
==========================================
+ Hits        15257    17949    +2692     
- Misses      11083    12291    +1208     
- Partials     1100     1472     +372     

}
return false
default:
panic("Type Mismatch")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this panic?

Copy link
Contributor Author

@clevinson clevinson Sep 12, 2020

Choose a reason for hiding this comment

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

WIP, sorry, forgot to mark as draft. Would this be better off returning false, or an error?

@alexanderbez alexanderbez marked this pull request as draft September 12, 2020 14:02
@alexanderbez
Copy link
Contributor

alexanderbez commented Sep 12, 2020

Moved this back to draft mode as it seems we still have incomplete work to do. Also, can't we add an integration test for the REST handler? It'd be no different than the CLI integration tests. Then again, this is for the legacy API correct?

@clevinson
Copy link
Contributor Author

Sorry! this was meant to be draft. Thanks for reverting.

Also, can't we add an integration test for the REST handler? It'd be no different than the CLI integration tests. Then again, this is for the legacy API correct?

@alexanderbez Yes this is for the legacy API. I thought this WIP test for broadcasting signed transaction was testing the rest handler (not CLI)... isn't it? I was using some CLI stuff to generate a valid signature & tx to send over REST though...

My thought was to get this test working, and then add a subsequent tx to it to check for non-zero sequences. Should i be looking at something else for rest handler tests?

@zmanian
Copy link
Member

zmanian commented Sep 13, 2020

The test case looks correct to me

@alexanderbez
Copy link
Contributor

You're absolutely correct @clevinson. That strategy looks correct to me :)

@clevinson
Copy link
Contributor Author

clevinson commented Sep 15, 2020

New rest handler test is passing, marking R4R. @zmanian @amaurymartiny @alexanderbez

@clevinson clevinson marked this pull request as ready for review September 15, 2020 00:26
Copy link
Contributor

@amaury1093 amaury1093 left a comment

Choose a reason for hiding this comment

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

Looks very nice, thanks! Just small docs nits.

types/tx/signing/signature.go Show resolved Hide resolved
x/auth/ante/sigverify.go Show resolved Hide resolved
@@ -237,7 +253,9 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul
err := authsigning.VerifySignature(pubKey, signerData, sig.Data, svd.signModeHandler, tx)
if err != nil {
var errMsg string
if sig.SkipSequenceCheck {
if OnlyLegacyAminoSigners(sig.Data) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

in line 230 we already evaluated OnlyLegacyAminoSigners(sig.Data). So let's store the result above and use it in both if statements.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we just fail a transaction that contains mixed Sign modes?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Depending on the users. This would solve my other concern.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mixed sign modes I believe is a valid use case that we need to support (see ADR020, and this issue thread on protobuf tx signing). When dealing with multisig transactions, each signer may be using their own independent sign mode, right?

@zmanian
Copy link
Member

zmanian commented Sep 16, 2020

It looks like some miscellaneous stuff was committed accidentally in /artifacts ?

@alessio
Copy link
Contributor

alessio commented Sep 16, 2020

@zmanian this will prevent it from happening again

@clevinson
Copy link
Contributor Author

Should i rebase & cherry pick the commit with artifact files out ? looks like the folder is 78Mb :/

@zmanian
Copy link
Member

zmanian commented Sep 16, 2020

I think they should be eliminated when squashing the commits?

@amaury1093
Copy link
Contributor

I think they should be eliminated when squashing the commits?

Yeah, I would say so too.

x/auth/ante/sigverify.go Outdated Show resolved Hide resolved
clevinson and others added 2 commits September 16, 2020 12:25
Co-authored-by: Zaki Manian <zaki@manian.org>
@clevinson clevinson added the A:automerge Automatically merge PR once all prerequisites pass. label Sep 16, 2020
@mergify mergify bot merged commit 62b4aa9 into master Sep 16, 2020
@mergify mergify bot deleted the 7229-amino-sequence-bugfix branch September 16, 2020 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Signatures converted from LegacyAmino to SignaturesV2 fail on sequence number other than 0
6 participants