From b9898063bb86a9fb8f9e14b3fc486ba28fbae0b2 Mon Sep 17 00:00:00 2001 From: dgsbl Date: Tue, 2 Nov 2021 21:24:35 +0800 Subject: [PATCH] fix a bug --- go.mod | 1 - x/auth/ante/sigverify.go | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 01bd5092d4ab..f58a9418b7e9 100644 --- a/go.mod +++ b/go.mod @@ -56,7 +56,6 @@ require ( google.golang.org/protobuf v1.27.1 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/yaml.v2 v2.4.0 - nhooyr.io/websocket v1.8.6 // indirect ) replace ( diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 8722cc26b320..23598a27f748 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -264,11 +264,18 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul } // Check account sequence number. - if sig.Sequence != acc.GetSequence() { - return ctx, sdkerrors.Wrapf( - sdkerrors.ErrWrongSequence, - "account sequence mismatch, expected %d, got %d", acc.GetSequence(), sig.Sequence, - ) + // When using Amino StdSignatures, we actually don't have the Sequence in + // the SignatureV2 struct (it's only in the SignDoc). In this case, we + // cannot check sequence directly, and must do it via signature + // verification (in the VerifySignature call below). + onlyAminoSigners := OnlyLegacyAminoSigners(sig.Data) + if !onlyAminoSigners { + if sig.Sequence != acc.GetSequence() { + return ctx, sdkerrors.Wrapf( + sdkerrors.ErrWrongSequence, + "account sequence mismatch, expected %d, got %d", acc.GetSequence(), sig.Sequence, + ) + } } // retrieve signer data