Merge PR #2799: Account numbers and sequences to uint64

This commit is contained in:
Sunny Aggarwal 2018-11-26 06:29:21 -05:00 committed by Christopher Goes
parent 2d071763d1
commit b7da2eaa33
32 changed files with 175 additions and 174 deletions

View File

@ -16,6 +16,7 @@ BREAKING CHANGES
* SDK
* [\#2752](https://github.com/cosmos/cosmos-sdk/pull/2752) Don't hardcode bondable denom.
* [\#2701](https://github.com/cosmos/cosmos-sdk/issues/2701) Account numbers and sequence numbers in `auth` are now `uint64` instead of `int64`
* [\#2019](https://github.com/cosmos/cosmos-sdk/issues/2019) Cap total number of signatures. Current per-transaction limit is 7, and if that is exceeded transaction is rejected.
* [\#2801](https://github.com/cosmos/cosmos-sdk/pull/2801) Remove AppInit structure.
* [\#2798](https://github.com/cosmos/cosmos-sdk/issues/2798) Governance API has miss-spelled English word in JSON response ('depositer' -> 'depositor')

View File

@ -92,7 +92,7 @@ func (ctx CLIContext) GetFromName() (string, error) {
// GetAccountNumber returns the next account number for the given account
// address.
func (ctx CLIContext) GetAccountNumber(address []byte) (int64, error) {
func (ctx CLIContext) GetAccountNumber(address []byte) (uint64, error) {
account, err := ctx.GetAccount(address)
if err != nil {
return 0, err
@ -103,7 +103,7 @@ func (ctx CLIContext) GetAccountNumber(address []byte) (int64, error) {
// GetAccountSequence returns the sequence number for the given account
// address.
func (ctx CLIContext) GetAccountSequence(address []byte) (int64, error) {
func (ctx CLIContext) GetAccountSequence(address []byte) (uint64, error) {
account, err := ctx.GetAccount(address)
if err != nil {
return 0, err

View File

@ -74,8 +74,8 @@ func PostCommands(cmds ...*cobra.Command) []*cobra.Command {
for _, c := range cmds {
c.Flags().Bool(FlagIndentResponse, false, "Add indent to JSON response")
c.Flags().String(FlagFrom, "", "Name or address of private key with which to sign")
c.Flags().Int64(FlagAccountNumber, 0, "AccountNumber number to sign the tx")
c.Flags().Int64(FlagSequence, 0, "Sequence number to sign the tx")
c.Flags().Uint64(FlagAccountNumber, 0, "AccountNumber number to sign the tx")
c.Flags().Uint64(FlagSequence, 0, "Sequence number to sign the tx")
c.Flags().String(FlagMemo, "", "Memo to send along with transaction")
c.Flags().String(FlagFee, "", "Fee to pay along with transaction")
c.Flags().String(FlagChainID, "", "Chain ID of tendermint node")

View File

@ -124,8 +124,8 @@ type BaseReq struct {
Name string `json:"name"`
Password string `json:"password"`
ChainID string `json:"chain_id"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
Gas string `json:"gas"`
GasAdjustment string `json:"gas_adjustment"`
}

View File

@ -61,8 +61,8 @@ func NewGenesisState(accounts []GenesisAccount, authData auth.GenesisState,
type GenesisAccount struct {
Address sdk.AccAddress `json:"address"`
Coins sdk.Coins `json:"coins"`
Sequence int64 `json:"sequence_number"`
AccountNumber int64 `json:"account_number"`
Sequence uint64 `json:"sequence_number"`
AccountNumber uint64 `json:"account_number"`
}
func NewGenesisAccount(acc *auth.BaseAccount) GenesisAccount {

View File

@ -52,11 +52,11 @@ type Account interface {
GetPubKey() crypto.PubKey // can return nil.
SetPubKey(crypto.PubKey) error
GetAccountNumber() int64
SetAccountNumber(int64) error
GetAccountNumber() uint64
SetAccountNumber(uint64) error
GetSequence() int64
SetSequence(int64) error
GetSequence() uint64
SetSequence(uint64) error
GetCoins() sdk.Coins
SetCoins(sdk.Coins) error
@ -79,8 +79,8 @@ type BaseAccount struct {
Address sdk.AccAddress `json:"address"`
Coins sdk.Coins `json:"coins"`
PubKey crypto.PubKey `json:"public_key"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
}
```
@ -161,8 +161,8 @@ The standard form for signatures is `StdSignature`:
type StdSignature struct {
crypto.PubKey `json:"pub_key"` // optional
[]byte `json:"signature"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
}
```

View File

@ -88,17 +88,17 @@ func TestMsgQuiz(t *testing.T) {
require.Equal(t, acc1, res1)
// Set the trend, submit a really cool quiz and check for reward
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{setTrendMsg1}, []int64{0}, []int64{0}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg1}, []int64{0}, []int64{1}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{setTrendMsg1}, []uint64{0}, []uint64{0}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg1}, []uint64{0}, []uint64{1}, true, true, priv1)
mock.CheckBalance(t, mapp, addr1, sdk.Coins{sdk.NewCoin("icecold", sdk.NewInt(69))})
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg2}, []int64{0}, []int64{2}, false, false, priv1) // result without reward
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg2}, []uint64{0}, []uint64{2}, false, false, priv1) // result without reward
mock.CheckBalance(t, mapp, addr1, sdk.Coins{sdk.NewCoin("icecold", sdk.NewInt(69))})
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg1}, []int64{0}, []int64{3}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg1}, []uint64{0}, []uint64{3}, true, true, priv1)
mock.CheckBalance(t, mapp, addr1, sdk.Coins{sdk.NewCoin("icecold", sdk.NewInt(138))})
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{setTrendMsg2}, []int64{0}, []int64{4}, true, true, priv1) // reset the trend
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg1}, []int64{0}, []int64{5}, false, false, priv1) // the same answer will nolonger do!
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{setTrendMsg2}, []uint64{0}, []uint64{4}, true, true, priv1) // reset the trend
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg1}, []uint64{0}, []uint64{5}, false, false, priv1) // the same answer will nolonger do!
mock.CheckBalance(t, mapp, addr1, sdk.Coins{sdk.NewCoin("icecold", sdk.NewInt(138))})
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg2}, []int64{0}, []int64{6}, true, true, priv1) // earlier answer now relevant again
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{quizMsg2}, []uint64{0}, []uint64{6}, true, true, priv1) // earlier answer now relevant again
mock.CheckBalance(t, mapp, addr1, sdk.Coins{sdk.NewCoin("badvibesonly", sdk.NewInt(69)), sdk.NewCoin("icecold", sdk.NewInt(138))})
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{setTrendMsg3}, []int64{0}, []int64{7}, false, false, priv1) // expect to fail to set the trend to something which is not cool
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{setTrendMsg3}, []uint64{0}, []uint64{7}, false, false, priv1) // expect to fail to set the trend to something which is not cool
}

View File

@ -74,13 +74,13 @@ func TestMsgMine(t *testing.T) {
// Mine and check for reward
mineMsg1 := GenerateMsgMine(addr1, 1, 2)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{mineMsg1}, []int64{0}, []int64{0}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{mineMsg1}, []uint64{0}, []uint64{0}, true, true, priv1)
mock.CheckBalance(t, mapp, addr1, sdk.Coins{sdk.NewCoin("pow", sdk.NewInt(1))})
// Mine again and check for reward
mineMsg2 := GenerateMsgMine(addr1, 2, 3)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{mineMsg2}, []int64{0}, []int64{1}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{mineMsg2}, []uint64{0}, []uint64{1}, true, true, priv1)
mock.CheckBalance(t, mapp, addr1, sdk.Coins{sdk.NewCoin("pow", sdk.NewInt(2))})
// Mine again - should be invalid
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{mineMsg2}, []int64{0}, []int64{1}, false, false, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{mineMsg2}, []uint64{0}, []uint64{1}, false, false, priv1)
mock.CheckBalance(t, mapp, addr1, sdk.Coins{sdk.NewCoin("pow", sdk.NewInt(2))})
}

View File

@ -21,11 +21,11 @@ type Account interface {
GetPubKey() crypto.PubKey // can return nil.
SetPubKey(crypto.PubKey) error
GetAccountNumber() int64
SetAccountNumber(int64) error
GetAccountNumber() uint64
SetAccountNumber(uint64) error
GetSequence() int64
SetSequence(int64) error
GetSequence() uint64
SetSequence(uint64) error
GetCoins() sdk.Coins
SetCoins(sdk.Coins) error
@ -48,8 +48,8 @@ type BaseAccount struct {
Address sdk.AccAddress `json:"address"`
Coins sdk.Coins `json:"coins"`
PubKey crypto.PubKey `json:"public_key"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
}
// Prototype function for BaseAccount
@ -100,23 +100,23 @@ func (acc *BaseAccount) SetCoins(coins sdk.Coins) error {
}
// Implements Account
func (acc *BaseAccount) GetAccountNumber() int64 {
func (acc *BaseAccount) GetAccountNumber() uint64 {
return acc.AccountNumber
}
// Implements Account
func (acc *BaseAccount) SetAccountNumber(accNumber int64) error {
func (acc *BaseAccount) SetAccountNumber(accNumber uint64) error {
acc.AccountNumber = accNumber
return nil
}
// Implements sdk.Account.
func (acc *BaseAccount) GetSequence() int64 {
func (acc *BaseAccount) GetSequence() uint64 {
return acc.Sequence
}
// Implements sdk.Account.
func (acc *BaseAccount) SetSequence(seq int64) error {
func (acc *BaseAccount) SetSequence(seq uint64) error {
acc.Sequence = seq
return nil
}

View File

@ -67,7 +67,7 @@ func TestBaseAccountSequence(t *testing.T) {
_, _, addr := keyPubAddr()
acc := NewBaseAccountWithAddress(addr)
seq := int64(7)
seq := uint64(7)
err := acc.SetSequence(seq)
require.Nil(t, err)
@ -79,7 +79,7 @@ func TestBaseAccountMarshal(t *testing.T) {
acc := NewBaseAccountWithAddress(addr)
someCoins := sdk.Coins{sdk.NewInt64Coin("atom", 123), sdk.NewInt64Coin("eth", 246)}
seq := int64(7)
seq := uint64(7)
// set everything on the account
err := acc.SetPubKey(pub)

View File

@ -66,7 +66,7 @@ func checkInvalidTx(t *testing.T, anteHandler sdk.AnteHandler, ctx sdk.Context,
}
}
func newTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []int64, seqs []int64, fee StdFee) sdk.Tx {
func newTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee) sdk.Tx {
sigs := make([]StdSignature, len(privs))
for i, priv := range privs {
signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, "")
@ -80,7 +80,7 @@ func newTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums
return tx
}
func newTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []int64, seqs []int64, fee StdFee, memo string) sdk.Tx {
func newTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee, memo string) sdk.Tx {
sigs := make([]StdSignature, len(privs))
for i, priv := range privs {
signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], fee, msgs, memo)
@ -95,7 +95,7 @@ func newTestTxWithMemo(ctx sdk.Context, msgs []sdk.Msg, privs []crypto.PrivKey,
}
// All signers sign over the same StdSignDoc. Should always create invalid signatures
func newTestTxWithSignBytes(msgs []sdk.Msg, privs []crypto.PrivKey, accNums []int64, seqs []int64, fee StdFee, signBytes []byte, memo string) sdk.Tx {
func newTestTxWithSignBytes(msgs []sdk.Msg, privs []crypto.PrivKey, accNums []uint64, seqs []uint64, fee StdFee, signBytes []byte, memo string) sdk.Tx {
sigs := make([]StdSignature, len(privs))
for i, priv := range privs {
sig, err := priv.Sign(signBytes)
@ -133,7 +133,7 @@ func TestAnteHandlerSigErrors(t *testing.T) {
msgs := []sdk.Msg{msg1, msg2}
// test no signatures
privs, accNums, seqs := []crypto.PrivKey{}, []int64{}, []int64{}
privs, accNums, seqs := []crypto.PrivKey{}, []uint64{}, []uint64{}
tx = newTestTx(ctx, msgs, privs, accNums, seqs, fee)
// tx.GetSigners returns addresses in correct order: addr1, addr2, addr3
@ -145,12 +145,12 @@ func TestAnteHandlerSigErrors(t *testing.T) {
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized)
// test num sigs dont match GetSigners
privs, accNums, seqs = []crypto.PrivKey{priv1}, []int64{0}, []int64{0}
privs, accNums, seqs = []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
tx = newTestTx(ctx, msgs, privs, accNums, seqs, fee)
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized)
// test an unrecognized account
privs, accNums, seqs = []crypto.PrivKey{priv1, priv2, priv3}, []int64{0, 1, 2}, []int64{0, 0, 0}
privs, accNums, seqs = []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0}
tx = newTestTx(ctx, msgs, privs, accNums, seqs, fee)
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnknownAddress)
@ -193,30 +193,30 @@ func TestAnteHandlerAccountNumbers(t *testing.T) {
msgs := []sdk.Msg{msg}
// test good tx from one signer
privs, accnums, seqs := []crypto.PrivKey{priv1}, []int64{0}, []int64{0}
privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
// new tx from wrong account number
seqs = []int64{1}
tx = newTestTx(ctx, msgs, privs, []int64{1}, seqs, fee)
seqs = []uint64{1}
tx = newTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee)
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidSequence)
// from correct account number
seqs = []int64{1}
tx = newTestTx(ctx, msgs, privs, []int64{0}, seqs, fee)
seqs = []uint64{1}
tx = newTestTx(ctx, msgs, privs, []uint64{0}, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
// new tx with another signer and incorrect account numbers
msg1 := newTestMsg(addr1, addr2)
msg2 := newTestMsg(addr2, addr1)
msgs = []sdk.Msg{msg1, msg2}
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []int64{1, 0}, []int64{2, 0}
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)
// correct account numbers
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []int64{0, 1}, []int64{2, 0}
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{2, 0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
}
@ -253,30 +253,30 @@ func TestAnteHandlerAccountNumbersAtBlockHeightZero(t *testing.T) {
msgs := []sdk.Msg{msg}
// test good tx from one signer
privs, accnums, seqs := []crypto.PrivKey{priv1}, []int64{0}, []int64{0}
privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
// new tx from wrong account number
seqs = []int64{1}
tx = newTestTx(ctx, msgs, privs, []int64{1}, seqs, fee)
seqs = []uint64{1}
tx = newTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee)
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidSequence)
// from correct account number
seqs = []int64{1}
tx = newTestTx(ctx, msgs, privs, []int64{0}, seqs, fee)
seqs = []uint64{1}
tx = newTestTx(ctx, msgs, privs, []uint64{0}, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
// new tx with another signer and incorrect account numbers
msg1 := newTestMsg(addr1, addr2)
msg2 := newTestMsg(addr2, addr1)
msgs = []sdk.Msg{msg1, msg2}
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []int64{1, 0}, []int64{2, 0}
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)
// correct account numbers
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []int64{0, 0}, []int64{2, 0}
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 0}, []uint64{2, 0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
}
@ -317,7 +317,7 @@ func TestAnteHandlerSequences(t *testing.T) {
msgs := []sdk.Msg{msg}
// test good tx from one signer
privs, accnums, seqs := []crypto.PrivKey{priv1}, []int64{0}, []int64{0}
privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
@ -325,7 +325,7 @@ func TestAnteHandlerSequences(t *testing.T) {
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidSequence)
// fix sequence, should pass
seqs = []int64{1}
seqs = []uint64{1}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
@ -334,7 +334,7 @@ func TestAnteHandlerSequences(t *testing.T) {
msg2 := newTestMsg(addr3, addr1)
msgs = []sdk.Msg{msg1, msg2}
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2, priv3}, []int64{0, 1, 2}, []int64{2, 0, 0}
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{2, 0, 0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
@ -344,18 +344,18 @@ func TestAnteHandlerSequences(t *testing.T) {
// tx from just second signer with incorrect sequence fails
msg = newTestMsg(addr2)
msgs = []sdk.Msg{msg}
privs, accnums, seqs = []crypto.PrivKey{priv2}, []int64{1}, []int64{0}
privs, accnums, seqs = []crypto.PrivKey{priv2}, []uint64{1}, []uint64{0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidSequence)
// fix the sequence and it passes
tx = newTestTx(ctx, msgs, []crypto.PrivKey{priv2}, []int64{1}, []int64{1}, fee)
tx = newTestTx(ctx, msgs, []crypto.PrivKey{priv2}, []uint64{1}, []uint64{1}, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
// another tx from both of them that passes
msg = newTestMsg(addr1, addr2)
msgs = []sdk.Msg{msg}
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []int64{0, 1}, []int64{3, 2}
privs, accnums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{3, 2}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
}
@ -381,7 +381,7 @@ func TestAnteHandlerFees(t *testing.T) {
// msg and signatures
var tx sdk.Tx
msg := newTestMsg(addr1)
privs, accnums, seqs := []crypto.PrivKey{priv1}, []int64{0}, []int64{0}
privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
fee := newStdFee()
msgs := []sdk.Msg{msg}
@ -424,7 +424,7 @@ func TestAnteHandlerMemoGas(t *testing.T) {
// msg and signatures
var tx sdk.Tx
msg := newTestMsg(addr1)
privs, accnums, seqs := []crypto.PrivKey{priv1}, []int64{0}, []int64{0}
privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
fee := NewStdFee(0, sdk.NewInt64Coin("atom", 0))
// tx does not have enough gas
@ -483,19 +483,19 @@ func TestAnteHandlerMultiSigner(t *testing.T) {
fee := newStdFee()
// signers in order
privs, accnums, seqs := []crypto.PrivKey{priv1, priv2, priv3}, []int64{0, 1, 2}, []int64{0, 0, 0}
privs, accnums, seqs := []crypto.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0}
tx = newTestTxWithMemo(ctx, msgs, privs, accnums, seqs, fee, "Check signers are in expected order and different account numbers works")
checkValidTx(t, anteHandler, ctx, tx, false)
// change sequence numbers
tx = newTestTx(ctx, []sdk.Msg{msg1}, []crypto.PrivKey{priv1, priv2}, []int64{0, 1}, []int64{1, 1}, fee)
tx = newTestTx(ctx, []sdk.Msg{msg1}, []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{1, 1}, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
tx = newTestTx(ctx, []sdk.Msg{msg2}, []crypto.PrivKey{priv3, priv1}, []int64{2, 0}, []int64{1, 2}, fee)
tx = newTestTx(ctx, []sdk.Msg{msg2}, []crypto.PrivKey{priv3, priv1}, []uint64{2, 0}, []uint64{1, 2}, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
// expected seqs = [3, 2, 2]
tx = newTestTxWithMemo(ctx, msgs, privs, accnums, []int64{3, 2, 2}, fee, "Check signers are in expected order and different account numbers and sequence numbers works")
tx = newTestTxWithMemo(ctx, msgs, privs, accnums, []uint64{3, 2, 2}, fee, "Check signers are in expected order and different account numbers and sequence numbers works")
checkValidTx(t, anteHandler, ctx, tx, false)
}
@ -532,7 +532,7 @@ func TestAnteHandlerBadSignBytes(t *testing.T) {
fee3.Amount[0].Amount = fee3.Amount[0].Amount.AddRaw(100)
// test good tx and signBytes
privs, accnums, seqs := []crypto.PrivKey{priv1}, []int64{0}, []int64{0}
privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
@ -542,8 +542,8 @@ func TestAnteHandlerBadSignBytes(t *testing.T) {
cases := []struct {
chainID string
accnum int64
seq int64
accnum uint64
seq uint64
fee StdFee
msgs []sdk.Msg
code sdk.CodeType
@ -556,7 +556,7 @@ func TestAnteHandlerBadSignBytes(t *testing.T) {
{chainID, 0, 1, fee3, msgs, codeUnauth}, // test wrong fee
}
privs, seqs = []crypto.PrivKey{priv1}, []int64{1}
privs, seqs = []crypto.PrivKey{priv1}, []uint64{1}
for _, cs := range cases {
tx := newTestTxWithSignBytes(
@ -568,14 +568,14 @@ func TestAnteHandlerBadSignBytes(t *testing.T) {
}
// test wrong signer if public key exist
privs, accnums, seqs = []crypto.PrivKey{priv2}, []int64{0}, []int64{1}
privs, accnums, seqs = []crypto.PrivKey{priv2}, []uint64{0}, []uint64{1}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeUnauthorized)
// test wrong signer if public doesn't exist
msg = newTestMsg(addr2)
msgs = []sdk.Msg{msg}
privs, accnums, seqs = []crypto.PrivKey{priv1}, []int64{1}, []int64{0}
privs, accnums, seqs = []crypto.PrivKey{priv1}, []uint64{1}, []uint64{0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidPubKey)
@ -609,7 +609,7 @@ func TestAnteHandlerSetPubKey(t *testing.T) {
// test good tx and set public key
msg := newTestMsg(addr1)
msgs := []sdk.Msg{msg}
privs, accnums, seqs := []crypto.PrivKey{priv1}, []int64{0}, []int64{0}
privs, accnums, seqs := []crypto.PrivKey{priv1}, []uint64{0}, []uint64{0}
fee := newStdFee()
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkValidTx(t, anteHandler, ctx, tx, false)
@ -620,7 +620,7 @@ func TestAnteHandlerSetPubKey(t *testing.T) {
// test public key not found
msg = newTestMsg(addr2)
msgs = []sdk.Msg{msg}
tx = newTestTx(ctx, msgs, privs, []int64{1}, seqs, fee)
tx = newTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee)
sigs := tx.(StdTx).GetSignatures()
sigs[0].PubKey = nil
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidPubKey)
@ -629,7 +629,7 @@ func TestAnteHandlerSetPubKey(t *testing.T) {
require.Nil(t, acc2.GetPubKey())
// test invalid signature and public key
tx = newTestTx(ctx, msgs, privs, []int64{1}, seqs, fee)
tx = newTestTx(ctx, msgs, privs, []uint64{1}, seqs, fee)
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeInvalidPubKey)
acc2 = mapper.GetAccount(ctx, addr2)
@ -785,7 +785,7 @@ func TestAnteHandlerSigLimitExceeded(t *testing.T) {
// test rejection logic
privs, accnums, seqs := []crypto.PrivKey{priv1, priv2, priv3, priv4, priv5, priv6, priv7, priv8},
[]int64{0, 0, 0, 0, 0, 0, 0, 0}, []int64{0, 0, 0, 0, 0, 0, 0, 0}
[]uint64{0, 0, 0, 0, 0, 0, 0, 0}, []uint64{0, 0, 0, 0, 0, 0, 0, 0}
tx = newTestTx(ctx, msgs, privs, accnums, seqs, fee)
checkInvalidTx(t, anteHandler, ctx, tx, false, sdk.CodeTooManySignatures)
}

View File

@ -18,8 +18,8 @@ type SignBody struct {
LocalAccountName string `json:"name"`
Password string `json:"password"`
ChainID string `json:"chain_id"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
AppendSig bool `json:"append_sig"`
}

View File

@ -10,8 +10,8 @@ import (
// it is signed. For use in the CLI.
type StdSignMsg struct {
ChainID string `json:"chain_id"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
Fee auth.StdFee `json:"fee"`
Msgs []sdk.Msg `json:"msgs"`
Memo string `json:"memo"`

View File

@ -14,8 +14,8 @@ import (
// TxBuilder implements a transaction context created in SDK modules.
type TxBuilder struct {
Codec *codec.Codec
AccountNumber int64
Sequence int64
AccountNumber uint64
Sequence uint64
Gas uint64
GasAdjustment float64
SimulateGas bool
@ -38,10 +38,10 @@ func NewTxBuilderFromCLI() TxBuilder {
return TxBuilder{
ChainID: chainID,
AccountNumber: viper.GetInt64(client.FlagAccountNumber),
AccountNumber: uint64(viper.GetInt64(client.FlagAccountNumber)),
Gas: client.GasFlagVar.Gas,
GasAdjustment: viper.GetFloat64(client.FlagGasAdjustment),
Sequence: viper.GetInt64(client.FlagSequence),
Sequence: uint64(viper.GetInt64(client.FlagSequence)),
SimulateGas: client.GasFlagVar.Simulate,
Fee: viper.GetString(client.FlagFee),
Memo: viper.GetString(client.FlagMemo),
@ -73,7 +73,7 @@ func (bldr TxBuilder) WithFee(fee string) TxBuilder {
}
// WithSequence returns a copy of the context with an updated sequence number.
func (bldr TxBuilder) WithSequence(sequence int64) TxBuilder {
func (bldr TxBuilder) WithSequence(sequence uint64) TxBuilder {
bldr.Sequence = sequence
return bldr
}
@ -85,7 +85,7 @@ func (bldr TxBuilder) WithMemo(memo string) TxBuilder {
}
// WithAccountNumber returns a copy of the context with an account number.
func (bldr TxBuilder) WithAccountNumber(accnum int64) TxBuilder {
func (bldr TxBuilder) WithAccountNumber(accnum uint64) TxBuilder {
bldr.AccountNumber = accnum
return bldr
}

View File

@ -21,8 +21,8 @@ var (
func TestTxBuilderBuild(t *testing.T) {
type fields struct {
Codec *codec.Codec
AccountNumber int64
Sequence int64
AccountNumber uint64
Sequence uint64
Gas uint64
GasAdjustment float64
SimulateGas bool

View File

@ -118,7 +118,7 @@ func (am AccountKeeper) GetPubKey(ctx sdk.Context, addr sdk.AccAddress) (crypto.
}
// Returns the Sequence of the account at address
func (am AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (int64, sdk.Error) {
func (am AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint64, sdk.Error) {
acc := am.GetAccount(ctx, addr)
if acc == nil {
return 0, sdk.ErrUnknownAddress(addr.String())
@ -126,7 +126,7 @@ func (am AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (int64
return acc.GetSequence(), nil
}
func (am AccountKeeper) setSequence(ctx sdk.Context, addr sdk.AccAddress, newSequence int64) sdk.Error {
func (am AccountKeeper) setSequence(ctx sdk.Context, addr sdk.AccAddress, newSequence uint64) sdk.Error {
acc := am.GetAccount(ctx, addr)
if acc == nil {
return sdk.ErrUnknownAddress(addr.String())
@ -141,8 +141,8 @@ func (am AccountKeeper) setSequence(ctx sdk.Context, addr sdk.AccAddress, newSeq
}
// Returns and increments the global account number counter
func (am AccountKeeper) GetNextAccountNumber(ctx sdk.Context) int64 {
var accNumber int64
func (am AccountKeeper) GetNextAccountNumber(ctx sdk.Context) uint64 {
var accNumber uint64
store := ctx.KVStore(am.key)
bz := store.Get(globalAccountNumberKey)
if bz == nil {

View File

@ -49,7 +49,7 @@ func TestAccountMapperGetSet(t *testing.T) {
require.Nil(t, mapper.GetAccount(ctx, addr))
// set some values on the account and save it
newSequence := int64(20)
newSequence := uint64(20)
acc.SetSequence(newSequence)
mapper.SetAccount(ctx, acc)
@ -75,8 +75,8 @@ func TestAccountMapperRemoveAccount(t *testing.T) {
acc1 := mapper.NewAccountWithAddress(ctx, addr1)
acc2 := mapper.NewAccountWithAddress(ctx, addr2)
accSeq1 := int64(20)
accSeq2 := int64(40)
accSeq1 := uint64(20)
accSeq2 := uint64(40)
acc1.SetSequence(accSeq1)
acc2.SetSequence(accSeq2)

View File

@ -156,16 +156,16 @@ func (fee StdFee) Bytes() []byte {
// and the Sequence numbers for each signature (prevent
// inchain replay and enforce tx ordering per account).
type StdSignDoc struct {
AccountNumber int64 `json:"account_number"`
AccountNumber uint64 `json:"account_number"`
ChainID string `json:"chain_id"`
Fee json.RawMessage `json:"fee"`
Memo string `json:"memo"`
Msgs []json.RawMessage `json:"msgs"`
Sequence int64 `json:"sequence"`
Sequence uint64 `json:"sequence"`
}
// StdSignBytes returns the bytes to sign for a transaction.
func StdSignBytes(chainID string, accnum int64, sequence int64, fee StdFee, msgs []sdk.Msg, memo string) []byte {
func StdSignBytes(chainID string, accnum uint64, sequence uint64, fee StdFee, msgs []sdk.Msg, memo string) []byte {
var msgsBytes []json.RawMessage
for _, msg := range msgs {
msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes()))
@ -188,8 +188,8 @@ func StdSignBytes(chainID string, accnum int64, sequence int64, fee StdFee, msgs
type StdSignature struct {
crypto.PubKey `json:"pub_key"` // optional
Signature []byte `json:"signature"`
AccountNumber int64 `json:"account_number"`
Sequence int64 `json:"sequence"`
AccountNumber uint64 `json:"account_number"`
Sequence uint64 `json:"sequence"`
}
// logic for standard transaction decoding

View File

@ -34,8 +34,8 @@ func TestStdTx(t *testing.T) {
func TestStdSignBytes(t *testing.T) {
type args struct {
chainID string
accnum int64
sequence int64
accnum uint64
sequence uint64
fee StdFee
msgs []sdk.Msg
memo string
@ -85,7 +85,7 @@ func TestTxValidateBasic(t *testing.T) {
require.Equal(t, sdk.CodeInsufficientFee, err.Result().Code)
// require to fail validation when no signatures exist
privs, accNums, seqs := []crypto.PrivKey{}, []int64{}, []int64{}
privs, accNums, seqs := []crypto.PrivKey{}, []uint64{}, []uint64{}
tx = newTestTx(ctx, msgs, privs, accNums, seqs, fee)
err = tx.ValidateBasic()
@ -93,7 +93,7 @@ func TestTxValidateBasic(t *testing.T) {
require.Equal(t, sdk.CodeUnauthorized, err.Result().Code)
// require to fail validation when signatures do not match expected signers
privs, accNums, seqs = []crypto.PrivKey{priv1}, []int64{0, 1}, []int64{0, 0}
privs, accNums, seqs = []crypto.PrivKey{priv1}, []uint64{0, 1}, []uint64{0, 0}
tx = newTestTx(ctx, msgs, privs, accNums, seqs, fee)
err = tx.ValidateBasic()
@ -102,7 +102,7 @@ func TestTxValidateBasic(t *testing.T) {
// require to fail validation when memo is too large
badMemo := strings.Repeat("bad memo", 50)
privs, accNums, seqs = []crypto.PrivKey{priv1, priv2}, []int64{0, 1}, []int64{0, 0}
privs, accNums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0}
tx = newTestTxWithMemo(ctx, msgs, privs, accNums, seqs, fee, badMemo)
err = tx.ValidateBasic()
@ -111,7 +111,7 @@ func TestTxValidateBasic(t *testing.T) {
// require to fail validation when there are too many signatures
privs = []crypto.PrivKey{priv1, priv2, priv3, priv4, priv5, priv6, priv7, priv8}
accNums, seqs = []int64{0, 0, 0, 0, 0, 0, 0, 0}, []int64{0, 0, 0, 0, 0, 0, 0, 0}
accNums, seqs = []uint64{0, 0, 0, 0, 0, 0, 0, 0}, []uint64{0, 0, 0, 0, 0, 0, 0, 0}
badMsg := newTestMsg(addr1, addr2, addr3, addr4, addr5, addr6, addr7, addr8)
badMsgs := []sdk.Msg{badMsg}
tx = newTestTx(ctx, badMsgs, privs, accNums, seqs, fee)
@ -121,7 +121,7 @@ func TestTxValidateBasic(t *testing.T) {
require.Equal(t, sdk.CodeTooManySignatures, err.Result().Code)
// require to pass when above criteria are matched
privs, accNums, seqs = []crypto.PrivKey{priv1, priv2}, []int64{0, 1}, []int64{0, 0}
privs, accNums, seqs = []crypto.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0}
tx = newTestTx(ctx, msgs, privs, accNums, seqs, fee)
err = tx.ValidateBasic()

View File

@ -24,8 +24,8 @@ type (
expSimPass bool
expPass bool
msgs []sdk.Msg
accNums []int64
accSeqs []int64
accNums []uint64
accSeqs []uint64
privKeys []crypto.PrivKey
expectedBalances []expectedBalance
}
@ -109,8 +109,8 @@ func TestMsgSendWithAccounts(t *testing.T) {
testCases := []appTestCase{
{
msgs: []sdk.Msg{sendMsg1},
accNums: []int64{0},
accSeqs: []int64{0},
accNums: []uint64{0},
accSeqs: []uint64{0},
expSimPass: true,
expPass: true,
privKeys: []crypto.PrivKey{priv1},
@ -121,8 +121,8 @@ func TestMsgSendWithAccounts(t *testing.T) {
},
{
msgs: []sdk.Msg{sendMsg1, sendMsg2},
accNums: []int64{0},
accSeqs: []int64{0},
accNums: []uint64{0},
accSeqs: []uint64{0},
expSimPass: false,
expPass: false,
privKeys: []crypto.PrivKey{priv1},
@ -140,7 +140,7 @@ func TestMsgSendWithAccounts(t *testing.T) {
// bumping the tx nonce number without resigning should be an auth error
mapp.BeginBlock(abci.RequestBeginBlock{})
tx := mock.GenTx([]sdk.Msg{sendMsg1}, []int64{0}, []int64{0}, priv1)
tx := mock.GenTx([]sdk.Msg{sendMsg1}, []uint64{0}, []uint64{0}, priv1)
tx.Signatures[0].Sequence = 1
res := mapp.Deliver(tx)
@ -148,7 +148,7 @@ func TestMsgSendWithAccounts(t *testing.T) {
require.EqualValues(t, sdk.CodespaceRoot, res.Codespace)
// resigning the tx with the bumped sequence should work
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{sendMsg1, sendMsg2}, []int64{0}, []int64{1}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{sendMsg1, sendMsg2}, []uint64{0}, []uint64{1}, true, true, priv1)
}
func TestMsgSendMultipleOut(t *testing.T) {
@ -168,8 +168,8 @@ func TestMsgSendMultipleOut(t *testing.T) {
testCases := []appTestCase{
{
msgs: []sdk.Msg{sendMsg2},
accNums: []int64{0},
accSeqs: []int64{0},
accNums: []uint64{0},
accSeqs: []uint64{0},
expSimPass: true,
expPass: true,
privKeys: []crypto.PrivKey{priv1},
@ -211,8 +211,8 @@ func TestSengMsgMultipleInOut(t *testing.T) {
testCases := []appTestCase{
{
msgs: []sdk.Msg{sendMsg3},
accNums: []int64{0, 0},
accSeqs: []int64{0, 0},
accNums: []uint64{0, 0},
accSeqs: []uint64{0, 0},
expSimPass: true,
expPass: true,
privKeys: []crypto.PrivKey{priv1, priv4},
@ -247,8 +247,8 @@ func TestMsgSendDependent(t *testing.T) {
testCases := []appTestCase{
{
msgs: []sdk.Msg{sendMsg1},
accNums: []int64{0},
accSeqs: []int64{0},
accNums: []uint64{0},
accSeqs: []uint64{0},
expSimPass: true,
expPass: true,
privKeys: []crypto.PrivKey{priv1},
@ -259,8 +259,8 @@ func TestMsgSendDependent(t *testing.T) {
},
{
msgs: []sdk.Msg{sendMsg4},
accNums: []int64{0},
accSeqs: []int64{0},
accNums: []uint64{0},
accSeqs: []uint64{0},
expSimPass: true,
expPass: true,
privKeys: []crypto.PrivKey{priv2},

View File

@ -37,7 +37,7 @@ func BenchmarkOneBankSendTxPerBlock(b *testing.B) {
// Construct genesis state
mock.SetGenesis(benchmarkApp, accs)
// Precompute all txs
txs := mock.GenSequenceOfTxs([]sdk.Msg{sendMsg1}, []int64{0}, []int64{int64(0)}, b.N, priv1)
txs := mock.GenSequenceOfTxs([]sdk.Msg{sendMsg1}, []uint64{0}, []uint64{uint64(0)}, b.N, priv1)
b.ResetTimer()
// Run this with a profiler, so its easy to distinguish what time comes from
// Committing, and what time comes from Check/Deliver Tx.

View File

@ -95,8 +95,8 @@ func createSingleInputSendMsg(r *rand.Rand, ctx sdk.Context, accs []simulation.A
func sendAndVerifyMsgSend(app *baseapp.BaseApp, mapper auth.AccountKeeper, msg bank.MsgSend, ctx sdk.Context, privkeys []crypto.PrivKey, handler sdk.Handler) error {
initialInputAddrCoins := make([]sdk.Coins, len(msg.Inputs))
initialOutputAddrCoins := make([]sdk.Coins, len(msg.Outputs))
AccountNumbers := make([]int64, len(msg.Inputs))
SequenceNumbers := make([]int64, len(msg.Inputs))
AccountNumbers := make([]uint64, len(msg.Inputs))
SequenceNumbers := make([]uint64, len(msg.Inputs))
for i := 0; i < len(msg.Inputs); i++ {
acc := mapper.GetAccount(ctx, msg.Inputs[i].Address)

View File

@ -70,10 +70,10 @@ func TestIBCMsgs(t *testing.T) {
Sequence: 0,
}
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{transferMsg}, []int64{0}, []int64{0}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{transferMsg}, []uint64{0}, []uint64{0}, true, true, priv1)
mock.CheckBalance(t, mapp, addr1, emptyCoins)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{transferMsg}, []int64{0}, []int64{1}, false, false, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{receiveMsg}, []int64{0}, []int64{2}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{transferMsg}, []uint64{0}, []uint64{1}, false, false, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{receiveMsg}, []uint64{0}, []uint64{2}, true, true, priv1)
mock.CheckBalance(t, mapp, addr1, coins)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{receiveMsg}, []int64{0}, []int64{2}, false, false, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{receiveMsg}, []uint64{0}, []uint64{2}, false, false, priv1)
}

View File

@ -113,7 +113,7 @@ OUTER:
panic(err)
}
var processed int64
var processed uint64
if processedbz == nil {
processed = 0
} else if err = c.cdc.UnmarshalBinaryLengthPrefixed(processedbz, &processed); err != nil {
@ -127,7 +127,7 @@ OUTER:
continue OUTER //TODO replace with continue (I think it should just to the correct place where OUTER is now)
}
var egressLength int64
var egressLength uint64
if egressLengthbz == nil {
egressLength = 0
} else if err = c.cdc.UnmarshalBinaryLengthPrefixed(egressLengthbz, &egressLength); err != nil {
@ -166,12 +166,12 @@ func query(node string, key []byte, storeName string) (res []byte, err error) {
}
// nolint: unparam
func (c relayCommander) broadcastTx(seq int64, node string, tx []byte) error {
func (c relayCommander) broadcastTx(seq uint64, node string, tx []byte) error {
_, err := context.NewCLIContext().WithNodeURI(node).BroadcastTx(tx)
return err
}
func (c relayCommander) getSequence(node string) int64 {
func (c relayCommander) getSequence(node string) uint64 {
res, err := query(node, c.address, c.accStore)
if err != nil {
panic(err)
@ -189,7 +189,7 @@ func (c relayCommander) getSequence(node string) int64 {
return 0
}
func (c relayCommander) refine(bz []byte, sequence int64, passphrase string) []byte {
func (c relayCommander) refine(bz []byte, sequence uint64, passphrase string) []byte {
var packet ibc.IBCPacket
if err := c.cdc.UnmarshalBinaryLengthPrefixed(bz, &packet); err != nil {
panic(err)

View File

@ -90,11 +90,11 @@ func TestIBC(t *testing.T) {
var msg sdk.Msg
var res sdk.Result
var egl int64
var igs int64
var egl uint64
var igs uint64
egl = ibcm.getEgressLength(store, chainid)
require.Equal(t, egl, int64(0))
require.Equal(t, egl, uint64(0))
msg = IBCTransferMsg{
IBCPacket: packet,
@ -107,10 +107,10 @@ func TestIBC(t *testing.T) {
require.Equal(t, zero, coins)
egl = ibcm.getEgressLength(store, chainid)
require.Equal(t, egl, int64(1))
require.Equal(t, egl, uint64(1))
igs = ibcm.GetIngressSequence(ctx, chainid)
require.Equal(t, igs, int64(0))
require.Equal(t, igs, uint64(0))
msg = IBCReceiveMsg{
IBCPacket: packet,
@ -125,11 +125,11 @@ func TestIBC(t *testing.T) {
require.Equal(t, mycoins, coins)
igs = ibcm.GetIngressSequence(ctx, chainid)
require.Equal(t, igs, int64(1))
require.Equal(t, igs, uint64(1))
res = h(ctx, msg)
require.False(t, res.IsOK())
igs = ibcm.GetIngressSequence(ctx, chainid)
require.Equal(t, igs, int64(1))
require.Equal(t, igs, uint64(1))
}

View File

@ -76,7 +76,7 @@ func unmarshalBinaryPanic(cdc *codec.Codec, bz []byte, ptr interface{}) {
}
// TODO add description
func (ibcm Mapper) GetIngressSequence(ctx sdk.Context, srcChain string) int64 {
func (ibcm Mapper) GetIngressSequence(ctx sdk.Context, srcChain string) uint64 {
store := ctx.KVStore(ibcm.key)
key := IngressSequenceKey(srcChain)
@ -87,13 +87,13 @@ func (ibcm Mapper) GetIngressSequence(ctx sdk.Context, srcChain string) int64 {
return 0
}
var res int64
var res uint64
unmarshalBinaryPanic(ibcm.cdc, bz, &res)
return res
}
// TODO add description
func (ibcm Mapper) SetIngressSequence(ctx sdk.Context, srcChain string, sequence int64) {
func (ibcm Mapper) SetIngressSequence(ctx sdk.Context, srcChain string, sequence uint64) {
store := ctx.KVStore(ibcm.key)
key := IngressSequenceKey(srcChain)
@ -102,20 +102,20 @@ func (ibcm Mapper) SetIngressSequence(ctx sdk.Context, srcChain string, sequence
}
// Retrieves the index of the currently stored outgoing IBC packets.
func (ibcm Mapper) getEgressLength(store sdk.KVStore, destChain string) int64 {
func (ibcm Mapper) getEgressLength(store sdk.KVStore, destChain string) uint64 {
bz := store.Get(EgressLengthKey(destChain))
if bz == nil {
zero := marshalBinaryPanic(ibcm.cdc, int64(0))
store.Set(EgressLengthKey(destChain), zero)
return 0
}
var res int64
var res uint64
unmarshalBinaryPanic(ibcm.cdc, bz, &res)
return res
}
// Stores an outgoing IBC packet under "egress/chain_id/index".
func EgressKey(destChain string, index int64) []byte {
func EgressKey(destChain string, index uint64) []byte {
return []byte(fmt.Sprintf("egress/%s/%d", destChain, index))
}

View File

@ -96,7 +96,7 @@ func (msg IBCTransferMsg) ValidateBasic() sdk.Error {
type IBCReceiveMsg struct {
IBCPacket
Relayer sdk.AccAddress
Sequence int64
Sequence uint64
}
// nolint
@ -112,7 +112,7 @@ func (msg IBCReceiveMsg) GetSignBytes() []byte {
b, err := msgCdc.MarshalJSON(struct {
IBCPacket json.RawMessage
Relayer sdk.AccAddress
Sequence int64
Sequence uint64
}{
IBCPacket: json.RawMessage(msg.IBCPacket.GetSignBytes()),
Relayer: msg.Relayer,

View File

@ -185,7 +185,7 @@ func SetGenesis(app *App, accs []auth.Account) {
}
// GenTx generates a signed mock transaction.
func GenTx(msgs []sdk.Msg, accnums []int64, seq []int64, priv ...crypto.PrivKey) auth.StdTx {
func GenTx(msgs []sdk.Msg, accnums []uint64, seq []uint64, priv ...crypto.PrivKey) auth.StdTx {
// Make the transaction free
fee := auth.StdFee{
Amount: sdk.Coins{sdk.NewInt64Coin("foocoin", 0)},
@ -304,7 +304,7 @@ func GetAllAccounts(mapper auth.AccountKeeper, ctx sdk.Context) []auth.Account {
// GenSequenceOfTxs generates a set of signed transactions of messages, such
// that they differ only by having the sequence numbers incremented between
// every transaction.
func GenSequenceOfTxs(msgs []sdk.Msg, accnums []int64, initSeqNums []int64, numToGenerate int, priv ...crypto.PrivKey) []auth.StdTx {
func GenSequenceOfTxs(msgs []sdk.Msg, accnums []uint64, initSeqNums []uint64, numToGenerate int, priv ...crypto.PrivKey) []auth.StdTx {
txs := make([]auth.StdTx, numToGenerate, numToGenerate)
for i := 0; i < numToGenerate; i++ {
txs[i] = GenTx(msgs, accnums, initSeqNums, priv...)
@ -314,7 +314,7 @@ func GenSequenceOfTxs(msgs []sdk.Msg, accnums []int64, initSeqNums []int64, numT
return txs
}
func incrementAllSequenceNumbers(initSeqNums []int64) {
func incrementAllSequenceNumbers(initSeqNums []uint64) {
for i := 0; i < len(initSeqNums); i++ {
initSeqNums[i]++
}

View File

@ -61,14 +61,14 @@ func TestCheckAndDeliverGenTx(t *testing.T) {
SignCheckDeliver(
t, mApp.BaseApp, []sdk.Msg{msg},
[]int64{accs[0].GetAccountNumber()}, []int64{accs[0].GetSequence()},
[]uint64{accs[0].GetAccountNumber()}, []uint64{accs[0].GetSequence()},
true, true, privKeys[0],
)
// Signing a tx with the wrong privKey should result in an auth error
res := SignCheckDeliver(
t, mApp.BaseApp, []sdk.Msg{msg},
[]int64{accs[1].GetAccountNumber()}, []int64{accs[1].GetSequence() + 1},
[]uint64{accs[1].GetAccountNumber()}, []uint64{accs[1].GetSequence() + 1},
true, false, privKeys[1],
)
@ -78,7 +78,7 @@ func TestCheckAndDeliverGenTx(t *testing.T) {
// Resigning the tx with the correct privKey should result in an OK result
SignCheckDeliver(
t, mApp.BaseApp, []sdk.Msg{msg},
[]int64{accs[0].GetAccountNumber()}, []int64{accs[0].GetSequence() + 1},
[]uint64{accs[0].GetAccountNumber()}, []uint64{accs[0].GetSequence() + 1},
true, true, privKeys[0],
)
}
@ -92,14 +92,14 @@ func TestCheckGenTx(t *testing.T) {
msg1 := testMsg{signers: []sdk.AccAddress{addrs[0]}, positiveNum: 1}
CheckGenTx(
t, mApp.BaseApp, []sdk.Msg{msg1},
[]int64{accs[0].GetAccountNumber()}, []int64{accs[0].GetSequence()},
[]uint64{accs[0].GetAccountNumber()}, []uint64{accs[0].GetSequence()},
true, privKeys[0],
)
msg2 := testMsg{signers: []sdk.AccAddress{addrs[0]}, positiveNum: -1}
CheckGenTx(
t, mApp.BaseApp, []sdk.Msg{msg2},
[]int64{accs[0].GetAccountNumber()}, []int64{accs[0].GetSequence()},
[]uint64{accs[0].GetAccountNumber()}, []uint64{accs[0].GetSequence()},
false, privKeys[0],
)
}

View File

@ -50,8 +50,8 @@ func CheckBalance(t *testing.T, app *App, addr sdk.AccAddress, exp sdk.Coins) {
// compared against the parameter 'expPass'. A test assertion is made using the
// parameter 'expPass' against the result. A corresponding result is returned.
func CheckGenTx(
t *testing.T, app *baseapp.BaseApp, msgs []sdk.Msg, accNums []int64,
seq []int64, expPass bool, priv ...crypto.PrivKey,
t *testing.T, app *baseapp.BaseApp, msgs []sdk.Msg, accNums []uint64,
seq []uint64, expPass bool, priv ...crypto.PrivKey,
) sdk.Result {
tx := GenTx(msgs, accNums, seq, priv...)
res := app.Check(tx)
@ -70,8 +70,8 @@ func CheckGenTx(
// the parameter 'expPass' against the result. A corresponding result is
// returned.
func SignCheckDeliver(
t *testing.T, app *baseapp.BaseApp, msgs []sdk.Msg, accNums []int64,
seq []int64, expSimPass, expPass bool, priv ...crypto.PrivKey,
t *testing.T, app *baseapp.BaseApp, msgs []sdk.Msg, accNums []uint64,
seq []uint64, expSimPass, expPass bool, priv ...crypto.PrivKey,
) sdk.Result {
tx := GenTx(msgs, accNums, seq, priv...)
// Must simulate now as CheckTx doesn't run Msgs anymore

View File

@ -111,7 +111,7 @@ func TestSlashingMsgs(t *testing.T) {
createValidatorMsg := stake.NewMsgCreateValidator(
sdk.ValAddress(addr1), priv1.PubKey(), bondCoin, description, commission,
)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{createValidatorMsg}, []int64{0}, []int64{0}, true, true, priv1)
mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{createValidatorMsg}, []uint64{0}, []uint64{0}, true, true, priv1)
mock.CheckBalance(t, mapp, addr1, sdk.Coins{genCoin.Minus(bondCoin)})
mapp.BeginBlock(abci.RequestBeginBlock{})
@ -125,7 +125,7 @@ func TestSlashingMsgs(t *testing.T) {
checkValidatorSigningInfo(t, mapp, keeper, sdk.ConsAddress(addr1), false)
// unjail should fail with unknown validator
res := mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{unjailMsg}, []int64{0}, []int64{1}, false, false, priv1)
res := mock.SignCheckDeliver(t, mapp.BaseApp, []sdk.Msg{unjailMsg}, []uint64{0}, []uint64{1}, false, false, priv1)
require.EqualValues(t, CodeValidatorNotJailed, res.Code)
require.EqualValues(t, DefaultCodespace, res.Codespace)
}

View File

@ -125,7 +125,7 @@ func TestStakeMsgs(t *testing.T) {
sdk.ValAddress(addr1), priv1.PubKey(), bondCoin, description, commissionMsg,
)
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{createValidatorMsg}, []int64{0}, []int64{0}, true, true, priv1)
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{createValidatorMsg}, []uint64{0}, []uint64{0}, true, true, priv1)
mock.CheckBalance(t, mApp, addr1, sdk.Coins{genCoin.Minus(bondCoin)})
mApp.BeginBlock(abci.RequestBeginBlock{})
@ -139,7 +139,7 @@ func TestStakeMsgs(t *testing.T) {
addr1, sdk.ValAddress(addr2), priv2.PubKey(), bondCoin, description, commissionMsg,
)
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{createValidatorMsgOnBehalfOf}, []int64{0, 0}, []int64{1, 0}, true, true, priv1, priv2)
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{createValidatorMsgOnBehalfOf}, []uint64{0, 0}, []uint64{1, 0}, true, true, priv1, priv2)
mock.CheckBalance(t, mApp, addr1, sdk.Coins{genCoin.Minus(bondCoin).Minus(bondCoin)})
mApp.BeginBlock(abci.RequestBeginBlock{})
@ -155,7 +155,7 @@ func TestStakeMsgs(t *testing.T) {
description = NewDescription("bar_moniker", "", "", "")
editValidatorMsg := NewMsgEditValidator(sdk.ValAddress(addr1), description, nil)
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{editValidatorMsg}, []int64{0}, []int64{2}, true, true, priv1)
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{editValidatorMsg}, []uint64{0}, []uint64{2}, true, true, priv1)
validator = checkValidator(t, mApp, keeper, sdk.ValAddress(addr1), true)
require.Equal(t, description, validator.Description)
@ -163,13 +163,13 @@ func TestStakeMsgs(t *testing.T) {
mock.CheckBalance(t, mApp, addr2, sdk.Coins{genCoin})
delegateMsg := NewMsgDelegate(addr2, sdk.ValAddress(addr1), bondCoin)
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{delegateMsg}, []int64{0}, []int64{1}, true, true, priv2)
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{delegateMsg}, []uint64{0}, []uint64{1}, true, true, priv2)
mock.CheckBalance(t, mApp, addr2, sdk.Coins{genCoin.Minus(bondCoin)})
checkDelegation(t, mApp, keeper, addr2, sdk.ValAddress(addr1), true, sdk.NewDec(10))
// begin unbonding
beginUnbondingMsg := NewMsgBeginUnbonding(addr2, sdk.ValAddress(addr1), sdk.NewDec(10))
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{beginUnbondingMsg}, []int64{0}, []int64{2}, true, true, priv2)
mock.SignCheckDeliver(t, mApp.BaseApp, []sdk.Msg{beginUnbondingMsg}, []uint64{0}, []uint64{2}, true, true, priv2)
// delegation should exist anymore
checkDelegation(t, mApp, keeper, addr2, sdk.ValAddress(addr1), false, sdk.Dec{})