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

Put AccountSequence in SignerInfo #6997

Merged
merged 51 commits into from
Aug 21, 2020
Merged

Put AccountSequence in SignerInfo #6997

merged 51 commits into from
Aug 21, 2020

Conversation

amaury1093
Copy link
Contributor

@amaury1093 amaury1093 commented Aug 10, 2020

Description

fixes #6966

cc @ethanfrey


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

@@ -28,7 +28,7 @@ querying. However, this ADR solely focuses on transactions. Querying should be
addressed in a future ADR, but it should build off of these proposals.

Based on detailed discussions ([\#6030](https://github.com/cosmos/cosmos-sdk/issues/6030)
and [\#6078](https://github.com/cosmos/cosmos-sdk/issues/6078)), the original
and [\#6078](https://github.com/cosmos/cosmos-sdk/issues/6078)), the original
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, spacing changes are made by my editor... but i think they make sense.

Copy link
Member

Choose a reason for hiding this comment

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

Thank you editor. By the way, have you considered adding an .editorconfig to this repo? I made very good experience with it and use it in all projects: https://editorconfig.org/

@codecov
Copy link

codecov bot commented Aug 10, 2020

Codecov Report

Merging #6997 into master will increase coverage by 0.05%.
The diff coverage is 87.27%.

@@            Coverage Diff             @@
##           master    #6997      +/-   ##
==========================================
+ Coverage   54.49%   54.54%   +0.05%     
==========================================
  Files         550      550              
  Lines       37706    37684      -22     
==========================================
+ Hits        20546    20554       +8     
+ Misses      15472    15441      -31     
- Partials     1688     1689       +1     

@amaury1093 amaury1093 added T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). T: Proto Breaking Protobuf breaking changes: never don't do this! and removed T: API Breaking Breaking changes that impact APIs and the SDK only (not state machine). labels Aug 11, 2020
Comment on lines 33 to 36
// for replay protection. This field is only useful for Legacy Amino signing,
// since in SIGN_MODE_DIRECT the account sequence is already in the signer
// info.
AccountSequence uint64
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would have loved to remove AccountSequence from SignerData, but afaiu it is still used for SIGN_MODE_LEGACY. So keeping it here.

Comment on lines 211 to 217
// Check account sequence number.
if sig.AccountSequence != acc.GetSequence() {
return ctx, sdkerrors.Wrapf(
sdkerrors.ErrWrongAccountSequence,
"account sequence mismatch, expected %d, got %d", acc.GetSequence(), sig.AccountSequence,
)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

A separate ante handler would also have made sense, but since it's just 7 lines, I thought just to leave it here.

Copy link
Member

Choose a reason for hiding this comment

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

Amazing to pull out this error case. Much appreciated

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is the a huge benefit for clients.

@amaury1093
Copy link
Contributor Author

A concern I have is how to handle StdTx. Basically, StdTx needs to hold the account sequences of signers, or else functions like StdSignatureToSignatureV2 result in a loss of information.

@amaury1093 amaury1093 marked this pull request as ready for review August 12, 2020 16:42
amaury1093 and others added 5 commits August 14, 2020 14:00
Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>
Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>
Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>
Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

In general, it looks good and I am very happy for this better error message on incorrect sequence numbers (the most common case of a theoretically valid tx failing... when they end up out of order).

I think there is some simplification that can be made and the test constants cleaned up a bit. Also the AccountSequence vs Sequence issue... but I think you inherited the naming mis-match

client/testutil/suite.go Show resolved Hide resolved
client/tx/tx.go Show resolved Hide resolved
client/tx/tx.go Outdated Show resolved Hide resolved
client/tx/tx.go Outdated Show resolved Hide resolved
client/tx/tx.go Outdated Show resolved Hide resolved
x/auth/ante/ante_test.go Outdated Show resolved Hide resolved
Comment on lines 211 to 217
// Check account sequence number.
if sig.AccountSequence != acc.GetSequence() {
return ctx, sdkerrors.Wrapf(
sdkerrors.ErrWrongAccountSequence,
"account sequence mismatch, expected %d, got %d", acc.GetSequence(), sig.AccountSequence,
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is the a huge benefit for clients.

x/auth/ante/sigverify_test.go Outdated Show resolved Hide resolved
x/auth/ante/testutil_test.go Show resolved Hide resolved
x/bank/app_test.go Outdated Show resolved Hide resolved
x/bank/app_test.go Outdated Show resolved Hide resolved
amaury1093 and others added 5 commits August 20, 2020 18:26
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Aug 21, 2020
@mergify mergify bot merged commit 50bab8f into master Aug 21, 2020
@mergify mergify bot deleted the am-6966-seq-in-signerinfo branch August 21, 2020 14:20
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 2023
* WIP test the grounds

* Update ADR020

* Fix compile errors

* Fix ADR

* Make ante tests pass

* Fix remaining ante handler tests

* Simplify code

* Fix x/bank app_test

* Fix tests

* Remove useless accSeq from signerdata

* Fix test

* Update simapp/helpers/test_helpers.go

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>

* Update simapp/helpers/test_helpers.go

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>

* Update x/auth/client/cli/tx_multisign.go

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>

* Address rewview

* Update x/auth/ante/sigverify.go

Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>

* Update x/auth/ante/sigverify_test.go

Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>

* Update x/auth/tx/builder_test.go

Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>

* Update x/auth/tx/builder_test.go

Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>

* Update x/auth/tx/direct_test.go

Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>

* Update x/auth/tx/builder_test.go

Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>

* AccSeq -> Seq

* Address reviews

* Better variable naming

* Fix variable assign

* Remove old SetSignerInfo

* Fix test

* proto-gen

* Make proto-gen

* Reput gw comment

* Add Changelog

* Update x/bank/app_test.go

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>

* Update x/bank/app_test.go

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>

Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: SaReN <sahithnarahari@gmail.com>
Co-authored-by: Simon Warta <2603011+webmaster128@users.noreply.github.com>
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. T: Proto Breaking Protobuf breaking changes: never don't do this!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serialize sequence number with transaction signature
8 participants