diff --git a/client/tx/legacy.go b/client/tx/legacy.go index 80626bd896..7a46e194aa 100644 --- a/client/tx/legacy.go +++ b/client/tx/legacy.go @@ -5,7 +5,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/signing" ) @@ -65,24 +64,3 @@ func CopyTx(tx signing.Tx, builder client.TxBuilder, ignoreSignatureError bool) return nil } - -// ConvertAndEncodeStdTx encodes the stdTx as a transaction in the format specified by txConfig -func ConvertAndEncodeStdTx(txConfig client.TxConfig, stdTx legacytx.StdTx) ([]byte, error) { - builder := txConfig.NewTxBuilder() - - var theTx sdk.Tx - - // check if we need a StdTx anyway, in that case don't copy - if _, ok := builder.GetTx().(legacytx.StdTx); ok { - theTx = stdTx - } else { - err := CopyTx(stdTx, builder, false) - if err != nil { - return nil, err - } - - theTx = builder.GetTx() - } - - return txConfig.TxEncoder()(theTx) -} diff --git a/client/tx/legacy_test.go b/client/tx/legacy_test.go index 7172bfe26c..65949a038f 100644 --- a/client/tx/legacy_test.go +++ b/client/tx/legacy_test.go @@ -15,7 +15,6 @@ import ( "github.com/cosmos/cosmos-sdk/types" signing2 "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" - "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/tx" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -149,27 +148,6 @@ func (s *TestSuite) TestConvertTxToStdTx() { s.Require().Equal(stdTx, stdTx2) } -func (s *TestSuite) TestConvertAndEncodeStdTx() { - // convert amino -> proto -> amino - aminoBuilder := s.aminoCfg.NewTxBuilder() - buildTestTx(s.T(), aminoBuilder) - stdTx := aminoBuilder.GetTx().(legacytx.StdTx) - txBz, err := tx2.ConvertAndEncodeStdTx(s.protoCfg, stdTx) - s.Require().NoError(err) - decodedTx, err := s.protoCfg.TxDecoder()(txBz) - s.Require().NoError(err) - aminoBuilder2 := s.aminoCfg.NewTxBuilder() - s.Require().NoError(tx2.CopyTx(decodedTx.(signing.Tx), aminoBuilder2, false)) - s.Require().Equal(stdTx, aminoBuilder2.GetTx()) - - // just use amino everywhere - txBz, err = tx2.ConvertAndEncodeStdTx(s.aminoCfg, stdTx) - s.Require().NoError(err) - decodedTx, err = s.aminoCfg.TxDecoder()(txBz) - s.Require().NoError(err) - s.Require().Equal(stdTx, decodedTx) -} - func TestTestSuite(t *testing.T) { suite.Run(t, new(TestSuite)) } diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 638e837aa3..5097478da2 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -265,18 +265,11 @@ func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul } // Check account sequence number. - // 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, - ) - } + 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 @@ -296,7 +289,7 @@ 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 onlyAminoSigners { + if OnlyLegacyAminoSigners(sig.Data) { // If all signers are using SIGN_MODE_LEGACY_AMINO, we rely on VerifySignature to check account sequence number, // and therefore communicate sequence number as a potential cause of error. errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d), sequence (%d) and chain-id (%s)", accNum, acc.GetSequence(), chainID)