From 55654264c6b5a0599f767cf4a82d26288faf8466 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 29 Nov 2018 11:33:01 -0500 Subject: [PATCH 1/9] Add and use CodeInvalidAccountNumber in ante handler --- types/errors.go | 38 ++++++++++++++++++++++---------------- x/auth/ante.go | 2 +- x/auth/ante_test.go | 4 ++-- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/types/errors.go b/types/errors.go index 46436531ef54..d3f54940117b 100644 --- a/types/errors.go +++ b/types/errors.go @@ -27,22 +27,23 @@ func (code CodeType) IsOK() bool { // SDK error codes const ( // Base error codes - CodeOK CodeType = 0 - CodeInternal CodeType = 1 - CodeTxDecode CodeType = 2 - CodeInvalidSequence CodeType = 3 - CodeUnauthorized CodeType = 4 - CodeInsufficientFunds CodeType = 5 - CodeUnknownRequest CodeType = 6 - CodeInvalidAddress CodeType = 7 - CodeInvalidPubKey CodeType = 8 - CodeUnknownAddress CodeType = 9 - CodeInsufficientCoins CodeType = 10 - CodeInvalidCoins CodeType = 11 - CodeOutOfGas CodeType = 12 - CodeMemoTooLarge CodeType = 13 - CodeInsufficientFee CodeType = 14 - CodeTooManySignatures CodeType = 15 + CodeOK CodeType = 0 + CodeInternal CodeType = 1 + CodeTxDecode CodeType = 2 + CodeInvalidSequence CodeType = 3 + CodeUnauthorized CodeType = 4 + CodeInsufficientFunds CodeType = 5 + CodeUnknownRequest CodeType = 6 + CodeInvalidAddress CodeType = 7 + CodeInvalidPubKey CodeType = 8 + CodeUnknownAddress CodeType = 9 + CodeInsufficientCoins CodeType = 10 + CodeInvalidCoins CodeType = 11 + CodeOutOfGas CodeType = 12 + CodeMemoTooLarge CodeType = 13 + CodeInsufficientFee CodeType = 14 + CodeTooManySignatures CodeType = 15 + CodeInvalidAccountNumber CodeType = 16 // CodespaceRoot is a codespace for error codes in this file only. // Notice that 0 is an "unset" codespace, which can be overridden with @@ -88,6 +89,8 @@ func CodeToDefaultMsg(code CodeType) string { return "insufficient fee" case CodeTooManySignatures: return "maximum numer of signatures exceeded" + case CodeInvalidAccountNumber: + return "invalid account number" default: return unknownCodeMsg(code) } @@ -107,6 +110,9 @@ func ErrTxDecode(msg string) Error { func ErrInvalidSequence(msg string) Error { return newErrorWithRootCodespace(CodeInvalidSequence, msg) } +func ErrInvalidAccountNumber(msg string) Error { + return newErrorWithRootCodespace(CodeInvalidAccountNumber, msg) +} func ErrUnauthorized(msg string) Error { return newErrorWithRootCodespace(CodeUnauthorized, msg) } diff --git a/x/auth/ante.go b/x/auth/ante.go index 685d60949f23..14eddfea6ef8 100644 --- a/x/auth/ante.go +++ b/x/auth/ante.go @@ -133,7 +133,7 @@ func validateAccNumAndSequence(ctx sdk.Context, accs []Account, sigs []StdSignat for i := 0; i < len(accs); i++ { // On InitChain, make sure account number == 0 if ctx.BlockHeight() == 0 && sigs[i].AccountNumber != 0 { - return sdk.ErrInvalidSequence( + return sdk.ErrInvalidAccountNumber( fmt.Sprintf("Invalid account number for BlockHeight == 0. Got %d, expected 0", sigs[i].AccountNumber)).Result() } diff --git a/x/auth/ante_test.go b/x/auth/ante_test.go index 8d7118e74652..fb82a515fa47 100644 --- a/x/auth/ante_test.go +++ b/x/auth/ante_test.go @@ -260,7 +260,7 @@ func TestAnteHandlerAccountNumbersAtBlockHeightZero(t *testing.T) { // new tx from wrong account number seqs = []uint64{1} tx = newTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) - checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidSequence) + checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidAccountNumber) // from correct account number seqs = []uint64{1} @@ -273,7 +273,7 @@ func TestAnteHandlerAccountNumbersAtBlockHeightZero(t *testing.T) { msgs = []sdk.Msg{msg1, msg2} privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{1, 0}, []uint64{2, 0} tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee) - checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidSequence) + checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidAccountNumber) // correct account numbers privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 0}, []uint64{2, 0} From 6f78416bb500c8f6521d23134b1240e8a4bcf6a7 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 29 Nov 2018 11:58:48 -0500 Subject: [PATCH 2/9] Minor cleanup of ante handler --- x/auth/ante.go | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/x/auth/ante.go b/x/auth/ante.go index 14eddfea6ef8..721a60f46e96 100644 --- a/x/auth/ante.go +++ b/x/auth/ante.go @@ -16,28 +16,31 @@ const ( ed25519VerifyCost = 59 secp256k1VerifyCost = 100 maxMemoCharacters = 100 + // how much gas = 1 atom gasPerUnitCost = 1000 + // max total number of sigs per tx txSigLimit = 7 ) -// NewAnteHandler returns an AnteHandler that checks -// and increments sequence numbers, checks signatures & account numbers, -// and deducts fees from the first signer. +// NewAnteHandler returns an AnteHandler that checks and increments sequence +// numbers, checks signatures & account numbers, and deducts fees from the first +// signer. func NewAnteHandler(am AccountKeeper, fck FeeCollectionKeeper) sdk.AnteHandler { return func( ctx sdk.Context, tx sdk.Tx, simulate bool, ) (newCtx sdk.Context, res sdk.Result, abort bool) { - // This AnteHandler requires Txs to be StdTxs + // all transactions must be of type auth.StdTx stdTx, ok := tx.(StdTx) if !ok { return ctx, sdk.ErrInternal("tx must be StdTx").Result(), true } - // Ensure that the provided fees meet a minimum threshold for the validator, if this is a CheckTx. - // This is only for local mempool purposes, and thus is only ran on check tx. + // Ensure that the provided fees meet a minimum threshold for the validator, + // if this is a CheckTx. This is only for local mempool purposes, and thus + // is only ran on check tx. if ctx.IsCheckTx() && !simulate { res := ensureSufficientMempoolFees(ctx, stdTx) if !res.IsOK() { @@ -47,10 +50,10 @@ func NewAnteHandler(am AccountKeeper, fck FeeCollectionKeeper) sdk.AnteHandler { newCtx = setGasMeter(simulate, ctx, stdTx) - // AnteHandlers must have their own defer/recover in order - // for the BaseApp to know how much gas was used! - // This is because the GasMeter is created in the AnteHandler, - // but if it panics the context won't be set properly in runTx's recover ... + // AnteHandlers must have their own defer/recover in order for the BaseApp + // to know how much gas was used! This is because the GasMeter is created in + // the AnteHandler, but if it panics the context won't be set properly in + // runTx's recover call. defer func() { if r := recover(); r != nil { switch rType := r.(type) { @@ -70,7 +73,6 @@ func NewAnteHandler(am AccountKeeper, fck FeeCollectionKeeper) sdk.AnteHandler { return newCtx, err.Result(), true } - // charge gas for the memo newCtx.GasMeter().ConsumeGas(memoCostPerByte*sdk.Gas(len(stdTx.GetMemo())), "memo") // stdSigs contains the sequence number, account number, and signatures. @@ -84,6 +86,7 @@ func NewAnteHandler(am AccountKeeper, fck FeeCollectionKeeper) sdk.AnteHandler { if !res.IsOK() { return newCtx, res, true } + res = validateAccNumAndSequence(ctx, signerAccs, stdSigs) if !res.IsOK() { return newCtx, res, true @@ -96,6 +99,7 @@ func NewAnteHandler(am AccountKeeper, fck FeeCollectionKeeper) sdk.AnteHandler { if !res.IsOK() { return newCtx, res, true } + fck.AddCollectedFees(newCtx, stdTx.Fee.Amount) } @@ -106,7 +110,6 @@ func NewAnteHandler(am AccountKeeper, fck FeeCollectionKeeper) sdk.AnteHandler { return newCtx, res, true } - // Save the account. am.SetAccount(newCtx, signerAccs[i]) } @@ -126,36 +129,36 @@ func getSignerAccs(ctx sdk.Context, am AccountKeeper, addrs []sdk.AccAddress) (a return nil, sdk.ErrUnknownAddress(addrs[i].String()).Result() } } + return } func validateAccNumAndSequence(ctx sdk.Context, accs []Account, sigs []StdSignature) sdk.Result { for i := 0; i < len(accs); i++ { - // On InitChain, make sure account number == 0 + // on InitChain make sure account number == 0 if ctx.BlockHeight() == 0 && sigs[i].AccountNumber != 0 { return sdk.ErrInvalidAccountNumber( fmt.Sprintf("Invalid account number for BlockHeight == 0. Got %d, expected 0", sigs[i].AccountNumber)).Result() } - // Check account number. accnum := accs[i].GetAccountNumber() if ctx.BlockHeight() != 0 && accnum != sigs[i].AccountNumber { return sdk.ErrInvalidSequence( fmt.Sprintf("Invalid account number. Got %d, expected %d", sigs[i].AccountNumber, accnum)).Result() } - // Check sequence number. seq := accs[i].GetSequence() if seq != sigs[i].Sequence { return sdk.ErrInvalidSequence( fmt.Sprintf("Invalid sequence. Got %d, expected %d", sigs[i].Sequence, seq)).Result() } } + return sdk.Result{} } -// verify the signature and increment the sequence. -// if the account doesn't have a pubkey, set it. +// verify the signature and increment the sequence. If the account doesn't have +// a pubkey, set it. func processSig(ctx sdk.Context, acc Account, sig StdSignature, signBytes []byte, simulate bool) (updatedAcc Account, res sdk.Result) { pubKey, res := processPubKey(acc, sig, simulate) @@ -172,7 +175,6 @@ func processSig(ctx sdk.Context, return nil, sdk.ErrUnauthorized("signature verification failed").Result() } - // increment the sequence number err = acc.SetSequence(acc.GetSequence() + 1) if err != nil { // Handle w/ #870 @@ -190,8 +192,7 @@ func init() { } func processPubKey(acc Account, sig StdSignature, simulate bool) (crypto.PubKey, sdk.Result) { - // If pubkey is not known for account, - // set it from the StdSignature. + // If pubkey is not known for account, set it from the StdSignature. pubKey := acc.GetPubKey() if simulate { // In simulate mode the transaction comes with no signatures, thus @@ -201,18 +202,22 @@ func processPubKey(acc Account, sig StdSignature, simulate bool) (crypto.PubKey, if pubKey == nil { return dummySecp256k1Pubkey, sdk.Result{} } + return pubKey, sdk.Result{} } + if pubKey == nil { pubKey = sig.PubKey if pubKey == nil { return nil, sdk.ErrInvalidPubKey("PubKey not found").Result() } + if !bytes.Equal(pubKey.Address(), acc.GetAddress()) { return nil, sdk.ErrInvalidPubKey( fmt.Sprintf("PubKey does not match Signer address %v", acc.GetAddress())).Result() } } + return pubKey, sdk.Result{} } From 4661658d589d30184cea685e1cc076dab93f21e3 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 29 Nov 2018 11:59:35 -0500 Subject: [PATCH 3/9] Add pending log entry --- PENDING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/PENDING.md b/PENDING.md index b9b7e28c7499..d224382f79cc 100644 --- a/PENDING.md +++ b/PENDING.md @@ -85,6 +85,8 @@ IMPROVEMENTS handler. - #2825 More staking and distribution invariants - #2912 Print commit ID in hex when commit is synced. + * Use `CodeInvalidAccountNumber` instead of `CodeInvalidSequence` in the ante + handler when an invalid account number is given. * Tendermint - #2796 Update to go-amino 0.14.1 From 728e9c44b1efcd1c294340c87d6f89b36389d1ac Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 29 Nov 2018 14:44:47 -0500 Subject: [PATCH 4/9] Spell check and more minor comment restructuring --- x/auth/ante.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/x/auth/ante.go b/x/auth/ante.go index 721a60f46e96..7274401ac98b 100644 --- a/x/auth/ante.go +++ b/x/auth/ante.go @@ -195,10 +195,10 @@ func processPubKey(acc Account, sig StdSignature, simulate bool) (crypto.PubKey, // If pubkey is not known for account, set it from the StdSignature. pubKey := acc.GetPubKey() if simulate { - // In simulate mode the transaction comes with no signatures, thus - // if the account's pubkey is nil, both signature verification - // and gasKVStore.Set() shall consume the largest amount, i.e. - // it takes more gas to verifiy secp256k1 keys than ed25519 ones. + // In simulate mode the transaction comes with no signatures, thus if the + // account's pubkey is nil, both signature verification and gasKVStore.Set() + // shall consume the largest amount, i.e. it takes more gas to verify + // secp256k1 keys than ed25519 ones. if pubKey == nil { return dummySecp256k1Pubkey, sdk.Result{} } @@ -272,8 +272,9 @@ func deductFees(acc Account, fee StdFee) (Account, sdk.Result) { } func ensureSufficientMempoolFees(ctx sdk.Context, stdTx StdTx) sdk.Result { - // currently we use a very primitive gas pricing model with a constant gasPrice. - // adjustFeesByGas handles calculating the amount of fees required based on the provided gas. + // Currently we use a very primitive gas pricing model with a constant + // gasPrice where adjustFeesByGas handles calculating the amount of fees + // required based on the provided gas. // // TODO: // - Make the gasPrice not a constant, and account for tx size. @@ -286,9 +287,12 @@ func ensureSufficientMempoolFees(ctx sdk.Context, stdTx StdTx) sdk.Result { // NOTE: !A.IsAllGTE(B) is not the same as A.IsAllLT(B). if !ctx.MinimumFees().IsZero() && !stdTx.Fee.Amount.IsAllGTE(requiredFees) { // validators reject any tx from the mempool with less than the minimum fee per gas * gas factor - return sdk.ErrInsufficientFee(fmt.Sprintf( - "insufficient fee, got: %q required: %q", stdTx.Fee.Amount, requiredFees)).Result() + return sdk.ErrInsufficientFee( + fmt.Sprintf( + "insufficient fee, got: %q required: %q", stdTx.Fee.Amount, requiredFees), + ).Result() } + return sdk.Result{} } From 24b068ba45e78e3252e149b479048e9f9de68da1 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 29 Nov 2018 15:36:17 -0500 Subject: [PATCH 5/9] Add additional CodeInvalidAccountNumber --- x/auth/ante.go | 2 +- x/auth/ante_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x/auth/ante.go b/x/auth/ante.go index 7274401ac98b..3c2219ff4726 100644 --- a/x/auth/ante.go +++ b/x/auth/ante.go @@ -143,7 +143,7 @@ func validateAccNumAndSequence(ctx sdk.Context, accs []Account, sigs []StdSignat accnum := accs[i].GetAccountNumber() if ctx.BlockHeight() != 0 && accnum != sigs[i].AccountNumber { - return sdk.ErrInvalidSequence( + return sdk.ErrInvalidAccountNumber( fmt.Sprintf("Invalid account number. Got %d, expected %d", sigs[i].AccountNumber, accnum)).Result() } diff --git a/x/auth/ante_test.go b/x/auth/ante_test.go index fb82a515fa47..71d79680524c 100644 --- a/x/auth/ante_test.go +++ b/x/auth/ante_test.go @@ -200,7 +200,7 @@ func TestAnteHandlerAccountNumbers(t *testing.T) { // new tx from wrong account number seqs = []uint64{1} tx = newTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) - checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidSequence) + checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidAccountNumber) // from correct account number seqs = []uint64{1} @@ -213,7 +213,7 @@ func TestAnteHandlerAccountNumbers(t *testing.T) { msgs = []sdk.Msg{msg1, msg2} privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{1, 0}, []uint64{2, 0} tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee) - checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidSequence) + checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidAccountNumber) // correct account numbers privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{2, 0} From 557d82424b0b0b568d043aa1ad1c61e1aa173251 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Thu, 29 Nov 2018 15:39:37 -0500 Subject: [PATCH 6/9] Update validateAccNumAndSequence --- x/auth/ante.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/x/auth/ante.go b/x/auth/ante.go index 3c2219ff4726..5676af974149 100644 --- a/x/auth/ante.go +++ b/x/auth/ante.go @@ -134,17 +134,21 @@ func getSignerAccs(ctx sdk.Context, am AccountKeeper, addrs []sdk.AccAddress) (a } func validateAccNumAndSequence(ctx sdk.Context, accs []Account, sigs []StdSignature) sdk.Result { - for i := 0; i < len(accs); i++ { - // on InitChain make sure account number == 0 - if ctx.BlockHeight() == 0 && sigs[i].AccountNumber != 0 { - return sdk.ErrInvalidAccountNumber( - fmt.Sprintf("Invalid account number for BlockHeight == 0. Got %d, expected 0", sigs[i].AccountNumber)).Result() - } + isGenesis := ctx.BlockHeight() == 0 - accnum := accs[i].GetAccountNumber() - if ctx.BlockHeight() != 0 && accnum != sigs[i].AccountNumber { - return sdk.ErrInvalidAccountNumber( - fmt.Sprintf("Invalid account number. Got %d, expected %d", sigs[i].AccountNumber, accnum)).Result() + for i := 0; i < len(accs); i++ { + if isGenesis { + // on InitChain make sure account number == 0 + if sigs[i].AccountNumber != 0 { + return sdk.ErrInvalidAccountNumber( + fmt.Sprintf("Invalid account number for BlockHeight == 0. Got %d, expected 0", sigs[i].AccountNumber)).Result() + } + } else { + accnum := accs[i].GetAccountNumber() + if accnum != sigs[i].AccountNumber { + return sdk.ErrInvalidAccountNumber( + fmt.Sprintf("Invalid account number. Got %d, expected %d", sigs[i].AccountNumber, accnum)).Result() + } } seq := accs[i].GetSequence() From 803d8d7ad1ddb43b0edc281c8ba6a6d5202108fb Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 30 Nov 2018 10:37:22 -0500 Subject: [PATCH 7/9] Revert account number error in favor of CodeInternal --- types/errors.go | 38 ++++++++++++++++---------------------- x/auth/ante.go | 16 ++++++++++++---- x/auth/ante_test.go | 8 ++++---- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/types/errors.go b/types/errors.go index d3f54940117b..46436531ef54 100644 --- a/types/errors.go +++ b/types/errors.go @@ -27,23 +27,22 @@ func (code CodeType) IsOK() bool { // SDK error codes const ( // Base error codes - CodeOK CodeType = 0 - CodeInternal CodeType = 1 - CodeTxDecode CodeType = 2 - CodeInvalidSequence CodeType = 3 - CodeUnauthorized CodeType = 4 - CodeInsufficientFunds CodeType = 5 - CodeUnknownRequest CodeType = 6 - CodeInvalidAddress CodeType = 7 - CodeInvalidPubKey CodeType = 8 - CodeUnknownAddress CodeType = 9 - CodeInsufficientCoins CodeType = 10 - CodeInvalidCoins CodeType = 11 - CodeOutOfGas CodeType = 12 - CodeMemoTooLarge CodeType = 13 - CodeInsufficientFee CodeType = 14 - CodeTooManySignatures CodeType = 15 - CodeInvalidAccountNumber CodeType = 16 + CodeOK CodeType = 0 + CodeInternal CodeType = 1 + CodeTxDecode CodeType = 2 + CodeInvalidSequence CodeType = 3 + CodeUnauthorized CodeType = 4 + CodeInsufficientFunds CodeType = 5 + CodeUnknownRequest CodeType = 6 + CodeInvalidAddress CodeType = 7 + CodeInvalidPubKey CodeType = 8 + CodeUnknownAddress CodeType = 9 + CodeInsufficientCoins CodeType = 10 + CodeInvalidCoins CodeType = 11 + CodeOutOfGas CodeType = 12 + CodeMemoTooLarge CodeType = 13 + CodeInsufficientFee CodeType = 14 + CodeTooManySignatures CodeType = 15 // CodespaceRoot is a codespace for error codes in this file only. // Notice that 0 is an "unset" codespace, which can be overridden with @@ -89,8 +88,6 @@ func CodeToDefaultMsg(code CodeType) string { return "insufficient fee" case CodeTooManySignatures: return "maximum numer of signatures exceeded" - case CodeInvalidAccountNumber: - return "invalid account number" default: return unknownCodeMsg(code) } @@ -110,9 +107,6 @@ func ErrTxDecode(msg string) Error { func ErrInvalidSequence(msg string) Error { return newErrorWithRootCodespace(CodeInvalidSequence, msg) } -func ErrInvalidAccountNumber(msg string) Error { - return newErrorWithRootCodespace(CodeInvalidAccountNumber, msg) -} func ErrUnauthorized(msg string) Error { return newErrorWithRootCodespace(CodeUnauthorized, msg) } diff --git a/x/auth/ante.go b/x/auth/ante.go index 5676af974149..c30aadbc1d0e 100644 --- a/x/auth/ante.go +++ b/x/auth/ante.go @@ -137,17 +137,25 @@ func validateAccNumAndSequence(ctx sdk.Context, accs []Account, sigs []StdSignat isGenesis := ctx.BlockHeight() == 0 for i := 0; i < len(accs); i++ { + // TODO: The logic below will be removed per #2952 if isGenesis { // on InitChain make sure account number == 0 if sigs[i].AccountNumber != 0 { - return sdk.ErrInvalidAccountNumber( - fmt.Sprintf("Invalid account number for BlockHeight == 0. Got %d, expected 0", sigs[i].AccountNumber)).Result() + return sdk.ErrInternal( + fmt.Sprintf( + "invalid account number for block height zero; got %d, expected 0", + sigs[i].AccountNumber, + ), + ).Result() } } else { accnum := accs[i].GetAccountNumber() if accnum != sigs[i].AccountNumber { - return sdk.ErrInvalidAccountNumber( - fmt.Sprintf("Invalid account number. Got %d, expected %d", sigs[i].AccountNumber, accnum)).Result() + return sdk.ErrInternal( + fmt.Sprintf( + "invalid account number; got %d, expected %d", sigs[i].AccountNumber, accnum, + ), + ).Result() } } diff --git a/x/auth/ante_test.go b/x/auth/ante_test.go index 71d79680524c..c38cf9825a3a 100644 --- a/x/auth/ante_test.go +++ b/x/auth/ante_test.go @@ -200,7 +200,7 @@ func TestAnteHandlerAccountNumbers(t *testing.T) { // new tx from wrong account number seqs = []uint64{1} tx = newTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) - checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidAccountNumber) + checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInternal) // from correct account number seqs = []uint64{1} @@ -213,7 +213,7 @@ func TestAnteHandlerAccountNumbers(t *testing.T) { msgs = []sdk.Msg{msg1, msg2} privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{1, 0}, []uint64{2, 0} tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee) - checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidAccountNumber) + checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInternal) // correct account numbers privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{2, 0} @@ -260,7 +260,7 @@ func TestAnteHandlerAccountNumbersAtBlockHeightZero(t *testing.T) { // new tx from wrong account number seqs = []uint64{1} tx = newTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee) - checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidAccountNumber) + checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInternal) // from correct account number seqs = []uint64{1} @@ -273,7 +273,7 @@ func TestAnteHandlerAccountNumbersAtBlockHeightZero(t *testing.T) { msgs = []sdk.Msg{msg1, msg2} privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{1, 0}, []uint64{2, 0} tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee) - checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidAccountNumber) + checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInternal) // correct account numbers privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 0}, []uint64{2, 0} From 27788b69e7b73d37a460c51921f0cb1f92f84b2a Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 30 Nov 2018 10:37:54 -0500 Subject: [PATCH 8/9] Update pending log --- PENDING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PENDING.md b/PENDING.md index ae4a7a3fc52f..369ed1836bab 100644 --- a/PENDING.md +++ b/PENDING.md @@ -87,8 +87,8 @@ IMPROVEMENTS handler. - #2825 More staking and distribution invariants - #2912 Print commit ID in hex when commit is synced. - * Use `CodeInvalidAccountNumber` instead of `CodeInvalidSequence` in the ante - handler when an invalid account number is given. + * Use `CodeInternal` instead of `CodeInvalidSequence` in the ante handler when + an invalid account number is given. * Tendermint - #2796 Update to go-amino 0.14.1 From f67dda0d915c67434f875a3872e1e9bba3275b9d Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Fri, 30 Nov 2018 10:40:02 -0500 Subject: [PATCH 9/9] Fix pending log --- PENDING.md | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/PENDING.md b/PENDING.md index 300f3eb5bd40..7e43640fe096 100644 --- a/PENDING.md +++ b/PENDING.md @@ -36,21 +36,10 @@ IMPROVEMENTS * Gaia * SDK - - [x/mock/simulation] \#2832, \#2885, \#2873, \#2902 Simulation cleanup - - [x/mock/simulation] [\#2720] major cleanup, introduction of helper objects, reorganization - - \#2821 Codespaces are now strings - - [types] #2776 Improve safety of `Coin` and `Coins` types. Various functions - and methods will panic when a negative amount is discovered. - - #2815 Gas unit fields changed from `int64` to `uint64`. - - #2821 Codespaces are now strings - - #2779 Introduce `ValidateBasic` to the `Tx` interface and call it in the ante - handler. - - #2825 More staking and distribution invariants - - #2912 Print commit ID in hex when commit is synced. - * Use `CodeInternal` instead of `CodeInvalidSequence` in the ante handler when + * Use `CodeInternal` instead of `CodeInvalidSequence` in the ante handler when an invalid account number is given. - - \#1277 Complete bank module specification - + * #1277 Complete bank module specification + * Tendermint