diff --git a/client/tx/legacy.go b/client/tx/legacy.go index b551ecebb81c..a5f292a8eec4 100644 --- a/client/tx/legacy.go +++ b/client/tx/legacy.go @@ -5,8 +5,12 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" +<<<<<<< HEAD sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" +======= + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" +>>>>>>> 78c3c4e92 (fix!: Remove onlyAminoSigners in sequence check (#10029)) "github.com/cosmos/cosmos-sdk/x/auth/signing" ) @@ -65,24 +69,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 9a4993201d89..36533c626bdb 100644 --- a/client/tx/legacy_test.go +++ b/client/tx/legacy_test.go @@ -14,8 +14,12 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" "github.com/cosmos/cosmos-sdk/types" signing2 "github.com/cosmos/cosmos-sdk/types/tx/signing" +<<<<<<< HEAD "github.com/cosmos/cosmos-sdk/x/auth/legacy/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/signing" +======= + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" +>>>>>>> 78c3c4e92 (fix!: Remove onlyAminoSigners in sequence check (#10029)) "github.com/cosmos/cosmos-sdk/x/auth/tx" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -149,27 +153,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 5f777b947db6..8ff8ee8d98d7 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)