diff --git a/CHANGELOG.md b/CHANGELOG.md index e136c50bb1..0788ab1519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,23 @@ * (build) [\#195](https://github.com/line/lfb-sdk/pull/195) Build properly when using libsecp256k1 * (perf) [\#198](https://github.com/line/lfb-sdk/pull/198) Caching paramset * (global) [\#200](https://github.com/line/lfb-sdk/pull/200) Add a env prefix -* (store) [\#202](https://github.com/line/lfb-sdk/pull/202) param store doesn't use gas kv +* (store) [\#202](https://github.com/line/lfb-sdk/pull/202) Param store doesn't use gas kv +* (store) [\#203](https://github.com/line/lfb-sdk/pull/203) Remove transient store that is not used now +* (perf) [\#204](https://github.com/line/lfb-sdk/pull/204) Apply rw mutex to cachekv +* (perf) [\#208](https://github.com/line/lfb-sdk/pull/208) Use easyjson instead of amino when marshal abci logs +* (perf) [\#209](https://github.com/line/lfb-sdk/pull/209) Apply async reactor ostracon +* (proto) [\#212](https://github.com/line/lfb-sdk/pull/212) Reformat proto files and restore proto docs +* (perf) [\#216](https://github.com/line/lfb-sdk/pull/216) Memoize bech32 encoding and decoding +* (perf) [\#218](https://github.com/line/lfb-sdk/pull/218) Rootmulti store parallel commit +* (perf) [\#219](https://github.com/line/lfb-sdk/pull/219) Fix bech32 cache to get bech32 from proper cache +* (bump-up) [\#221](https://github.com/line/lfb-sdk/pull/221) Bump up iavl for parallel processing of batches +* (perf) [\#224](https://github.com/line/lfb-sdk/pull/224) Updated log time to have milliseconds +* (bump-up) [\#228](https://github.com/line/lfb-sdk/pull/228) Bump up ostracon to optimize checking the txs size +* (global) [\#230](https://github.com/line/lfb-sdk/pull/230) Modify module name to lfb-sdk +* (bump-up) [\#246](https://github.com/line/lfb-sdk/pull/246) Bump up ostracon to not flush wal when receive consensus msgs +* (wasm) [\#250](https://github.com/line/lfb-sdk/pull/250) Migrate linkwasmd to the latest commit +* (wasm) [\#254](https://github.com/line/lfb-sdk/pull/254) Specify wasm event types +* (x) [\#255](https://github.com/line/lfb-sdk/pull/255) Remove legacy from modules ### Bug Fixes * (test) [\#92](https://github.com/line/lfb-sdk/pull/92) Fix SendToModuleAccountTest @@ -40,12 +56,27 @@ * (config) [\#138](https://github.com/line/lfb-sdk/pull/138) Fix getting coin type at running cmd * (race) [\#159](https://github.com/line/lfb-sdk/pull/159) Fix test-race failure * (test) [\#193](https://github.com/line/lfb-sdk/pull/193) Allow to add new validator in test network - + ### Breaking Changes * (global) [\#90](https://github.com/line/lfb-sdk/pull/90) Revise module path to `github.com/line/lfb-sdk` * (rpc) [\#97](https://github.com/line/lfb-sdk/pull/97) Send response with 404 status when quering non-exist account * (proto) [\#106](https://github.com/line/lfb-sdk/pull/106) Rename package of proto files * (api) [\#130](https://github.com/line/lfb-sdk/pull/130) Rename rest apis +* (auth) [\#265](https://github.com/line/lfb-sdk/pull/265) Introduce sig block height for the new replay protection + +### Build, CI +* (ci) [\#234](https://github.com/line/lfb-sdk/pull/234) Fix branch name in ci script +* (docker) [\#264](https://github.com/line/lfb-sdk/pull/264) Remove docker publish + +### Document Updates +* (docs) [\#205](https://github.com/line/lfb-sdk/pull/205) Renewal docs for open source +* (docs) [\#207](https://github.com/line/lfb-sdk/pull/207) Fix license +* (docs) [\#211](https://github.com/line/lfb-sdk/pull/211) Remove codeowners +* (docs) [\#248](https://github.com/line/lfb-sdk/pull/248) Add PR procedure, apply main branch +* (docs) [\#256](https://github.com/line/lfb-sdk/pull/256) Modify copyright and contributing +* (docs) [\#259](https://github.com/line/lfb-sdk/pull/259) Modify copyright, verified from legal team +* (docs) [\#260](https://github.com/line/lfb-sdk/pull/260) Remove gov, ibc and readme of wasm module +* (docs) [\#262](https://github.com/line/lfb-sdk/pull/262) Fix link urls, remove invalid reference ## [cosmos-sdk v0.42.1] - 2021-03-15 Initial lfb-sdk is based on the cosmos-sdk v0.42.1 diff --git a/baseapp/accountwgs_test.go b/baseapp/accountwgs_test.go index 4c2e07db4b..859dc06c4f 100644 --- a/baseapp/accountwgs_test.go +++ b/baseapp/accountwgs_test.go @@ -77,6 +77,10 @@ func (tx AccountLockTestTx) ValidateBasic() error { return nil } +func (tx AccountLockTestTx) GetSigBlockHeight() uint64 { + return 0 +} + func newTestPrivKeys(num int) []*secp256k1.PrivKey { privs := make([]*secp256k1.PrivKey, 0, num) for i := 0; i < num; i++ { diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 1125bdec70..b1e02b7061 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -696,8 +696,9 @@ func (tx *txTest) setFailOnHandler(fail bool) { } // Implements Tx -func (tx txTest) GetMsgs() []sdk.Msg { return tx.Msgs } -func (tx txTest) ValidateBasic() error { return nil } +func (tx txTest) GetMsgs() []sdk.Msg { return tx.Msgs } +func (tx txTest) ValidateBasic() error { return nil } +func (tx txTest) GetSigBlockHeight() uint64 { return 0 } const ( routeMsgCounter = "msgCounter" diff --git a/baseapp/msg_service_router_test.go b/baseapp/msg_service_router_test.go index 6e3a278f60..0b889f688a 100644 --- a/baseapp/msg_service_router_test.go +++ b/baseapp/msg_service_router_test.go @@ -104,7 +104,6 @@ func TestMsgService(t *testing.T) { // Second round: all signer infos are set, so each signer can sign. signerData := authsigning.SignerData{ ChainID: "test", - AccountNumber: 0, Sequence: 0, } sigV2, err = tx.SignWithPrivKey( diff --git a/client/account_retriever.go b/client/account_retriever.go index 9f300256e3..75c9378ffa 100644 --- a/client/account_retriever.go +++ b/client/account_retriever.go @@ -9,7 +9,6 @@ import ( type Account interface { GetAddress() sdk.AccAddress GetPubKey() cryptotypes.PubKey // can return nil. - GetAccountNumber() uint64 GetSequence() uint64 } @@ -18,7 +17,8 @@ type Account interface { // for signing. type AccountRetriever interface { GetAccount(clientCtx Context, addr sdk.AccAddress) (Account, error) + GetLatestHeight(clientCtx Context) (uint64, error) GetAccountWithHeight(clientCtx Context, addr sdk.AccAddress) (Account, int64, error) EnsureExists(clientCtx Context, addr sdk.AccAddress) error - GetAccountNumberSequence(clientCtx Context, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error) + GetAccountSequence(clientCtx Context, addr sdk.AccAddress) (accSeq uint64, err error) } diff --git a/client/flags/flags.go b/client/flags/flags.go index 117313bc59..b5bf78d8bf 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -48,7 +48,7 @@ const ( FlagGasAdjustment = "gas-adjustment" FlagFrom = "from" FlagName = "name" - FlagAccountNumber = "account-number" + FlagSigBlockHeight = "sig-block-height" FlagSequence = "sequence" FlagMemo = "memo" FlagFees = "fees" @@ -96,7 +96,7 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) { func AddTxFlagsToCmd(cmd *cobra.Command) { cmd.Flags().String(FlagKeyringDir, "", "The client Keyring directory; if omitted, the default 'home' directory will be used") cmd.Flags().String(FlagFrom, "", "Name or address of private key with which to sign") - cmd.Flags().Uint64P(FlagAccountNumber, "a", 0, "The account number of the signing account (offline mode only)") + cmd.Flags().Uint64P(FlagSigBlockHeight, "n", 0, "The block height to be included in the tx body to protect from replaying") cmd.Flags().Uint64P(FlagSequence, "s", 0, "The sequence number of the signing account (offline mode only)") cmd.Flags().String(FlagMemo, "", "Memo to send along with transaction") cmd.Flags().String(FlagFees, "", "Fees to pay along with transaction; eg: 10uatom") diff --git a/client/test_helpers.go b/client/test_helpers.go index 361a3e8a39..73d003515e 100644 --- a/client/test_helpers.go +++ b/client/test_helpers.go @@ -15,7 +15,6 @@ var ( // TestAccount represents a client Account that can be used in unit tests type TestAccount struct { Address sdk.AccAddress - Num uint64 Seq uint64 } @@ -29,11 +28,6 @@ func (t TestAccount) GetPubKey() cryptotypes.PubKey { return nil } -// GetAccountNumber implements client Account.GetAccountNumber -func (t TestAccount) GetAccountNumber() uint64 { - return t.Num -} - // GetSequence implements client Account.GetSequence func (t TestAccount) GetSequence() uint64 { return t.Seq @@ -54,6 +48,10 @@ func (t TestAccountRetriever) GetAccount(_ Context, addr sdk.AccAddress) (Accoun return acc, nil } +func (t TestAccountRetriever) GetLatestHeight(_ Context) (uint64, error) { + return 0, nil +} + // GetAccountWithHeight implements AccountRetriever.GetAccountWithHeight func (t TestAccountRetriever) GetAccountWithHeight(clientCtx Context, addr sdk.AccAddress) (Account, int64, error) { acc, err := t.GetAccount(clientCtx, addr) @@ -73,11 +71,11 @@ func (t TestAccountRetriever) EnsureExists(_ Context, addr sdk.AccAddress) error return nil } -// GetAccountNumberSequence implements AccountRetriever.GetAccountNumberSequence -func (t TestAccountRetriever) GetAccountNumberSequence(_ Context, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error) { +// GetAccountSequence implements AccountRetriever.GetAccountSequence +func (t TestAccountRetriever) GetAccountSequence(_ Context, addr sdk.AccAddress) (accSeq uint64, err error) { acc, ok := t.Accounts[addr.String()] if !ok { - return 0, 0, fmt.Errorf("account %s not found", addr) + return 0, fmt.Errorf("account %s not found", addr) } - return acc.Num, acc.Seq, nil + return acc.Seq, nil } diff --git a/client/tx/factory.go b/client/tx/factory.go index 64441721a9..b25ab4dd7e 100644 --- a/client/tx/factory.go +++ b/client/tx/factory.go @@ -16,7 +16,7 @@ type Factory struct { keybase keyring.Keyring txConfig client.TxConfig accountRetriever client.AccountRetriever - accountNumber uint64 + sigBlockHeight uint64 sequence uint64 gas uint64 timeoutHeight uint64 @@ -41,7 +41,7 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory { signMode = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON } - accNum, _ := flagSet.GetUint64(flags.FlagAccountNumber) + sigBlockHeight, _ := flagSet.GetUint64(flags.FlagSigBlockHeight) accSeq, _ := flagSet.GetUint64(flags.FlagSequence) gasAdj, _ := flagSet.GetFloat64(flags.FlagGasAdjustment) memo, _ := flagSet.GetString(flags.FlagMemo) @@ -57,7 +57,7 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory { chainID: clientCtx.ChainID, gas: gasSetting.Gas, simulateAndExecute: gasSetting.Simulate, - accountNumber: accNum, + sigBlockHeight: sigBlockHeight, sequence: accSeq, timeoutHeight: timeoutHeight, gasAdjustment: gasAdj, @@ -74,7 +74,7 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory { return f } -func (f Factory) AccountNumber() uint64 { return f.accountNumber } +func (f Factory) SigBlockHeight() uint64 { return f.sigBlockHeight } func (f Factory) Sequence() uint64 { return f.sequence } func (f Factory) Gas() uint64 { return f.gas } func (f Factory) GasAdjustment() float64 { return f.gasAdjustment } @@ -154,9 +154,9 @@ func (f Factory) WithMemo(memo string) Factory { return f } -// WithAccountNumber returns a copy of the Factory with an updated account number. -func (f Factory) WithAccountNumber(accnum uint64) Factory { - f.accountNumber = accnum +// WithSigBlockHeight returns a copy of the Factory with an updated sig block height. +func (f Factory) WithSigBlockHeight(sigBlockHeight uint64) Factory { + f.sigBlockHeight = sigBlockHeight return f } diff --git a/client/tx/legacy.go b/client/tx/legacy.go index 5bcbc6b097..1593407729 100644 --- a/client/tx/legacy.go +++ b/client/tx/legacy.go @@ -61,6 +61,7 @@ func CopyTx(tx signing.Tx, builder client.TxBuilder, ignoreSignatureError bool) builder.SetMemo(tx.GetMemo()) builder.SetFeeAmount(tx.GetFee()) builder.SetGasLimit(tx.GetGas()) + builder.SetSigBlockHeight(tx.GetSigBlockHeight()) builder.SetTimeoutHeight(tx.GetTimeoutHeight()) return nil diff --git a/client/tx/legacy_test.go b/client/tx/legacy_test.go index e5e958df38..d743455b71 100644 --- a/client/tx/legacy_test.go +++ b/client/tx/legacy_test.go @@ -23,6 +23,7 @@ import ( const ( memo = "waboom" gas = uint64(10000) + sbh = 1 timeoutHeight = 5 ) @@ -44,6 +45,7 @@ func buildTestTx(t *testing.T, builder client.TxBuilder) { builder.SetMemo(memo) builder.SetGasLimit(gas) builder.SetFeeAmount(fee) + builder.SetSigBlockHeight(sbh) err := builder.SetMsgs(msg) require.NoError(t, err) err = builder.SetSignatures(sig) diff --git a/client/tx/tx.go b/client/tx/tx.go index 726c643f68..4abf1032de 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -155,7 +155,7 @@ func WriteGeneratedTxResponse( } txf := Factory{fees: br.Fees, gasPrices: br.GasPrices}. - WithAccountNumber(br.AccountNumber). + WithSigBlockHeight(br.SigBlockHeight). WithSequence(br.Sequence). WithGas(gasSetting.Gas). WithGasAdjustment(gasAdj). @@ -240,6 +240,7 @@ func BuildUnsignedTx(txf Factory, msgs ...sdk.Msg) (client.TxBuilder, error) { tx.SetMemo(txf.memo) tx.SetFeeAmount(fees) tx.SetGasLimit(txf.gas) + tx.SetSigBlockHeight(txf.sigBlockHeight) tx.SetTimeoutHeight(txf.TimeoutHeight()) return tx, nil @@ -302,26 +303,32 @@ func CalculateGas( return simRes, uint64(txf.GasAdjustment() * float64(simRes.GasInfo.GasUsed)), nil } -// PrepareFactory ensures the account defined by ctx.GetFromAddress() exists and -// if the account number and/or the account sequence number are zero (not set), -// they will be queried for and set on the provided Factory. A new Factory with -// the updated fields will be returned. +// PrepareFactory set sig block height and account sequence to the tx factory. +// It doesn't require that the account should exist. +// If the account does not exist, then it use the zero sequence number. func PrepareFactory(clientCtx client.Context, txf Factory) (Factory, error) { from := clientCtx.GetFromAddress() - - if err := txf.accountRetriever.EnsureExists(clientCtx, from); err != nil { - return txf, err + sigBlockHeight := txf.sigBlockHeight + + if !clientCtx.Offline { + if sigBlockHeight == 0 { + height, err := txf.accountRetriever.GetLatestHeight(clientCtx) + if err != nil { + return txf, err + } + sigBlockHeight = height + } } - initNum, initSeq := txf.accountNumber, txf.sequence - if initNum == 0 || initSeq == 0 { - num, seq, err := txf.accountRetriever.GetAccountNumberSequence(clientCtx, from) - if err != nil { - return txf, err - } + txf = txf.WithSigBlockHeight(sigBlockHeight) - if initNum == 0 { - txf = txf.WithAccountNumber(num) + initSeq := txf.sequence + if initSeq == 0 && !clientCtx.Offline { + seq, err := txf.accountRetriever.GetAccountSequence(clientCtx, from) + if err != nil { + if sdkError, _ := err.(*sdkerrors.Error); sdkError != sdkerrors.ErrKeyNotFound { + return txf, err + } } if initSeq == 0 { @@ -402,9 +409,8 @@ func Sign(txf Factory, name string, txBuilder client.TxBuilder, overwriteSig boo } pubKey := key.GetPubKey() signerData := authsigning.SignerData{ - ChainID: txf.chainID, - AccountNumber: txf.accountNumber, - Sequence: txf.sequence, + ChainID: txf.chainID, + Sequence: txf.sequence, } // For SIGN_MODE_DIRECT, calling SetSignatures calls setSignerInfos on diff --git a/client/tx/tx_test.go b/client/tx/tx_test.go index 6c56cecda4..5a7a548981 100644 --- a/client/tx/tx_test.go +++ b/client/tx/tx_test.go @@ -90,7 +90,7 @@ func TestBuildSimTx(t *testing.T) { txf := tx.Factory{}. WithTxConfig(txCfg). - WithAccountNumber(50). + WithSigBlockHeight(1). WithSequence(23). WithFees("50stake"). WithMemo("memo"). @@ -106,7 +106,7 @@ func TestBuildSimTx(t *testing.T) { func TestBuildUnsignedTx(t *testing.T) { txf := tx.Factory{}. WithTxConfig(NewTestTxConfig()). - WithAccountNumber(50). + WithSigBlockHeight(1). WithSequence(23). WithFees("50stake"). WithMemo("memo"). @@ -148,7 +148,7 @@ func TestSign(t *testing.T) { txfNoKeybase := tx.Factory{}. WithTxConfig(NewTestTxConfig()). - WithAccountNumber(50). + WithSigBlockHeight(1). WithSequence(23). WithFees("50stake"). WithMemo("memo"). diff --git a/client/tx_config.go b/client/tx_config.go index fcf04b81f2..ef1c2279ee 100644 --- a/client/tx_config.go +++ b/client/tx_config.go @@ -39,6 +39,7 @@ type ( SetMsgs(msgs ...sdk.Msg) error SetSignatures(signatures ...signingtypes.SignatureV2) error SetMemo(memo string) + SetSigBlockHeight(sbh uint64) SetFeeAmount(amount sdk.Coins) SetGasLimit(limit uint64) SetTimeoutHeight(height uint64) diff --git a/codec/amino_codec_test.go b/codec/amino_codec_test.go index 7c9614821f..f5f8960f38 100644 --- a/codec/amino_codec_test.go +++ b/codec/amino_codec_test.go @@ -120,7 +120,7 @@ func TestAminoCodecUnpackAnyFails(t *testing.T) { func TestAminoCodecFullDecodeAndEncode(t *testing.T) { // This tx comes from https://github.com/cosmos/cosmos-sdk/issues/8117. - txSigned := `{"type":"lfb-sdk/StdTx","value":{"msg":[{"type":"lfb-sdk/MsgCreateValidator","value":{"description":{"moniker":"fulltest","identity":"satoshi","website":"example.com","details":"example inc"},"commission":{"rate":"0.500000000000000000","max_rate":"1.000000000000000000","max_change_rate":"0.200000000000000000"},"min_self_delegation":"1000000","delegator_address":"link120yvjfy7m2gnu9mvusrs40cxxhpt8nr3qhn8re","validator_address":"linkvaloper120yvjfy7m2gnu9mvusrs40cxxhpt8nr3jr36d2","pubkey":{"type":"ostracon/PubKeyEd25519","value":"CYrOiM3HtS7uv1B1OAkknZnFYSRpQYSYII8AtMMtev0="},"value":{"denom":"umuon","amount":"700000000"}}}],"fee":{"amount":[{"denom":"umuon","amount":"6000"}],"gas":"160000"},"signatures":[{"pub_key":{"type":"ostracon/PubKeySecp256k1","value":"AwAOXeWgNf1FjMaayrSnrOOKz+Fivr6DiI/i0x0sZCHw"},"signature":"RcnfS/u2yl7uIShTrSUlDWvsXo2p2dYu6WJC8VDVHMBLEQZWc8bsINSCjOnlsIVkUNNe1q/WCA9n3Gy1+0zhYA=="}],"memo":"","timeout_height":"0"}}` + txSigned := `{"type":"lfb-sdk/StdTx","value":{"msg":[{"type":"lfb-sdk/MsgCreateValidator","value":{"description":{"moniker":"fulltest","identity":"satoshi","website":"example.com","details":"example inc"},"commission":{"rate":"0.500000000000000000","max_rate":"1.000000000000000000","max_change_rate":"0.200000000000000000"},"min_self_delegation":"1000000","delegator_address":"link120yvjfy7m2gnu9mvusrs40cxxhpt8nr3qhn8re","validator_address":"linkvaloper120yvjfy7m2gnu9mvusrs40cxxhpt8nr3jr36d2","pubkey":{"type":"ostracon/PubKeyEd25519","value":"CYrOiM3HtS7uv1B1OAkknZnFYSRpQYSYII8AtMMtev0="},"value":{"denom":"umuon","amount":"700000000"}}}],"fee":{"amount":[{"denom":"umuon","amount":"6000"}],"gas":"160000"},"signatures":[{"pub_key":{"type":"ostracon/PubKeySecp256k1","value":"AwAOXeWgNf1FjMaayrSnrOOKz+Fivr6DiI/i0x0sZCHw"},"signature":"RcnfS/u2yl7uIShTrSUlDWvsXo2p2dYu6WJC8VDVHMBLEQZWc8bsINSCjOnlsIVkUNNe1q/WCA9n3Gy1+0zhYA=="}],"sig_block_height":"0","memo":"","timeout_height":"0"}}` _, legacyCdc := simapp.MakeCodecs() var tx legacytx.StdTx diff --git a/crypto/ledger/ledger_test.go b/crypto/ledger/ledger_test.go index f4e3f9c7fa..adb7896426 100644 --- a/crypto/ledger/ledger_test.go +++ b/crypto/ledger/ledger_test.go @@ -196,17 +196,16 @@ func TestPublicKeyHDPath(t *testing.T) { } } -func getFakeTx(accountNumber uint32) []byte { +func getFakeTx() []byte { tmp := fmt.Sprintf( - `{"account_number":"%d","chain_id":"1234","fee":{"amount":[{"amount":"150","denom":"atom"}],"gas":"5000"},"memo":"memo","msgs":[[""]],"sequence":"6"}`, - accountNumber) + `{"chain_id":"1234","fee":{"amount":[{"amount":"150","denom":"atom"}],"gas":"5000"},"memo":"memo","msgs":[[""]],"sequence":"6"}`) return []byte(tmp) } func TestSignaturesHD(t *testing.T) { for account := uint32(0); account < 100; account += 30 { - msg := getFakeTx(account) + msg := getFakeTx() path := *hd.NewFundraiserParams(account, sdk.CoinType, account/5) t.Logf("Checking signature at %v --- PLEASE REVIEW AND ACCEPT IN THE DEVICE\n", path) @@ -224,7 +223,7 @@ func TestSignaturesHD(t *testing.T) { } func TestRealDeviceSecp256k1(t *testing.T) { - msg := getFakeTx(50) + msg := getFakeTx() path := *hd.NewFundraiserParams(0, sdk.CoinType, 0) priv, err := NewPrivKeySecp256k1Unsafe(path) require.NoError(t, err) diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 00fed73cb1..e24b9f7d78 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -3857,7 +3857,6 @@ type for additional functionality (e.g. vesting). | ----- | ---- | ----- | ----------- | | `address` | [string](#string) | | | | `pub_key` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `account_number` | [uint64](#uint64) | | | | `sequence` | [uint64](#uint64) | | | @@ -3895,6 +3894,7 @@ Params defines the parameters for the auth module. | `tx_size_cost_per_byte` | [uint64](#uint64) | | | | `sig_verify_cost_ed25519` | [uint64](#uint64) | | | | `sig_verify_cost_secp256k1` | [uint64](#uint64) | | | +| `valid_sig_block_period` | [uint64](#uint64) | | | @@ -9405,7 +9405,6 @@ SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. | `body_bytes` | [bytes](#bytes) | | body_bytes is protobuf serialization of a TxBody that matches the representation in TxRaw. | | `auth_info_bytes` | [bytes](#bytes) | | auth_info_bytes is a protobuf serialization of an AuthInfo that matches the representation in TxRaw. | | `chain_id` | [string](#string) | | chain_id is the unique identifier of the chain this transaction targets. It prevents signed transactions from being used on another chain by an attacker | -| `account_number` | [uint64](#uint64) | | account_number is the account number of the account in state | @@ -9456,6 +9455,7 @@ TxBody is the body of a transaction that all signers sign over. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `messages` | [google.protobuf.Any](#google.protobuf.Any) | repeated | messages is a list of messages to be executed. The required signers of those messages define the number and order of elements in AuthInfo's signer_infos and Tx's signatures. Each required signer address is added to the list only the first time it occurs. By convention, the first required signer (usually from the first message) is referred to as the primary signer and pays the fee for the whole transaction. | +| `sig_block_height` | [uint64](#uint64) | | sig block height is available between current block height and current block height - `VALID_SIG_BLOCK_DURATION` this is used for distinguish signatures instead of account number. this is mandatory. | | `memo` | [string](#string) | | memo is any arbitrary memo to be added to the transaction | | `timeout_height` | [uint64](#uint64) | | timeout is the block height after which this transaction will not be processed by the chain | | `extension_options` | [google.protobuf.Any](#google.protobuf.Any) | repeated | extension_options are arbitrary options that can be added by chains when the default options are not sufficient. If any of these are present and can't be handled, the transaction will be rejected | diff --git a/proto/lfb/auth/v1beta1/auth.proto b/proto/lfb/auth/v1beta1/auth.proto index 2e9cd9c895..aa81353cbc 100644 --- a/proto/lfb/auth/v1beta1/auth.proto +++ b/proto/lfb/auth/v1beta1/auth.proto @@ -20,8 +20,7 @@ message BaseAccount { string address = 1; google.protobuf.Any pub_key = 2 [(gogoproto.jsontag) = "public_key,omitempty", (gogoproto.moretags) = "yaml:\"public_key\""]; - uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""]; - uint64 sequence = 4; + uint64 sequence = 3; } // ModuleAccount defines an account for modules that holds coins on a pool. @@ -47,4 +46,5 @@ message Params { [(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""]; uint64 sig_verify_cost_secp256k1 = 5 [(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""]; + uint64 valid_sig_block_period = 6 [(gogoproto.moretags) = "yaml:\"valid_sig_block_period\""]; } diff --git a/proto/lfb/tx/v1beta1/tx.proto b/proto/lfb/tx/v1beta1/tx.proto index 61d0b2a39d..91ac04c04c 100644 --- a/proto/lfb/tx/v1beta1/tx.proto +++ b/proto/lfb/tx/v1beta1/tx.proto @@ -58,9 +58,6 @@ message SignDoc { // It prevents signed transactions from being used on another chain by an // attacker string chain_id = 3; - - // account_number is the account number of the account in state - uint64 account_number = 4; } // TxBody is the body of a transaction that all signers sign over. @@ -74,12 +71,16 @@ message TxBody { // transaction. repeated google.protobuf.Any messages = 1; + // sig block height is available between current block height and current block height - `VALID_SIG_BLOCK_PERIOD` + // this is used for distinguish signatures instead of account number. this is mandatory. + uint64 sig_block_height = 2; + // memo is any arbitrary memo to be added to the transaction - string memo = 2; + string memo = 3; // timeout is the block height after which this transaction will not // be processed by the chain - uint64 timeout_height = 3; + uint64 timeout_height = 4; // extension_options are arbitrary options that can be added by chains // when the default options are not sufficient. If any of these are present diff --git a/server/grpc/server_test.go b/server/grpc/server_test.go index 59dc3ac1b9..bdaae99628 100644 --- a/server/grpc/server_test.go +++ b/server/grpc/server_test.go @@ -172,8 +172,8 @@ func (s *IntegrationTestSuite) TestGRPCServer_BroadcastTx() { } // Test and enforce that we upfront reject any connections to baseapp containing -// invalid initial x-cosmos-block-height that aren't positive and in the range [0, max(int64)] -// See issue https://github.com/line/lfb-sdk/issues/7662. +// invalid initial x-lfb-block-height that aren't positive and in the range [0, max(int64)] +// See issue https://github.com/cosmos/cosmos-sdk/issues/7662. func (s *IntegrationTestSuite) TestGRPCServerInvalidHeaderHeights() { t := s.T() val0 := s.network.Validators[0] @@ -183,9 +183,9 @@ func (s *IntegrationTestSuite) TestGRPCServerInvalidHeaderHeights() { value string wantErr string }{ - {"-1", "\"x-cosmos-block-height\" must be >= 0"}, + {"-1", "\"x-lfb-block-height\" must be >= 0"}, {"9223372036854775808", "value out of range"}, // > max(int64) by 1 - {"-10", "\"x-cosmos-block-height\" must be >= 0"}, + {"-10", "\"x-lfb-block-height\" must be >= 0"}, {"18446744073709551615", "value out of range"}, // max uint64, which is > max(int64) {"-9223372036854775809", "value out of range"}, // Out of the range of for negative int64 } diff --git a/server/mock/tx.go b/server/mock/tx.go index 6f556e4102..84f59c6fc8 100644 --- a/server/mock/tx.go +++ b/server/mock/tx.go @@ -53,6 +53,10 @@ func (tx kvstoreTx) GetSignBytes() []byte { return tx.bytes } +func (tx kvstoreTx) GetSigBlockHeight() uint64 { + return 0 +} + // Should the app be calling this? Or only handlers? func (tx kvstoreTx) ValidateBasic() error { return nil diff --git a/simapp/genesis_account_test.go b/simapp/genesis_account_test.go index be5ad80ce4..94a419eece 100644 --- a/simapp/genesis_account_test.go +++ b/simapp/genesis_account_test.go @@ -20,7 +20,7 @@ func TestSimGenesisAccountValidate(t *testing.T) { vestingStart := time.Now().UTC() coins := sdk.NewCoins(sdk.NewInt64Coin("test", 1000)) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0, 0) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0) testCases := []struct { name string @@ -37,14 +37,14 @@ func TestSimGenesisAccountValidate(t *testing.T) { { "invalid basic account with mismatching address/pubkey", simapp.SimGenesisAccount{ - BaseAccount: authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), + BaseAccount: authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0), }, true, }, { "valid basic account with module name", simapp.SimGenesisAccount{ - BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(crypto.AddressHash([]byte("testmod"))), nil, 0, 0), + BaseAccount: authtypes.NewBaseAccount(sdk.AccAddress(crypto.AddressHash([]byte("testmod"))), nil, 0), ModuleName: "testmod", }, false, diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index ac00ed6066..f982754bb7 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -19,7 +19,7 @@ const ( ) // GenTx generates a signed mock transaction. -func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { +func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, sbh, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { sigs := make([]signing.SignatureV2, len(priv)) // create a random length memo @@ -57,10 +57,10 @@ func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, ch // 2nd round: once all signer infos are set, every signer can sign. for i, p := range priv { signerData := authsign.SignerData{ - ChainID: chainID, - AccountNumber: accNums[i], - Sequence: accSeqs[i], + ChainID: chainID, + Sequence: accSeqs[i], } + tx.SetSigBlockHeight(sbh[i]) signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx()) if err != nil { panic(err) diff --git a/simapp/simd/cmd/genaccounts.go b/simapp/simd/cmd/genaccounts.go index 96cbd86c9a..d4edc5b3f4 100644 --- a/simapp/simd/cmd/genaccounts.go +++ b/simapp/simd/cmd/genaccounts.go @@ -85,7 +85,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa var genAccount authtypes.GenesisAccount balances := banktypes.Balance{Address: addr.String(), Coins: coins.Sort()} - baseAccount := authtypes.NewBaseAccount(addr, nil, 0, 0) + baseAccount := authtypes.NewBaseAccount(addr, nil, 0) if !vestingAmt.IsZero() { baseVestingAccount := authvesting.NewBaseVestingAccount(baseAccount, vestingAmt.Sort(), vestingEnd) diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index ea82cf7996..2b54bf4d4f 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -204,7 +204,7 @@ func InitTestnet( } genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()}) - genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) + genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0)) valTokens := sdk.TokensFromConsensusPower(100) createValMsg, err := stakingtypes.NewMsgCreateValidator( diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index fdf1a596ab..ea1534a433 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -326,7 +326,7 @@ func CheckBalance(t *testing.T, app *SimApp, addr sdk.AccAddress, balances sdk.C // returned. func SignCheckDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header ostproto.Header, msgs []sdk.Msg, - chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, + chainID string, sbh, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { tx, err := helpers.GenTx( @@ -335,7 +335,7 @@ func SignCheckDeliver( sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, helpers.DefaultGenTxGas, chainID, - accNums, + sbh, accSeqs, priv..., ) diff --git a/simapp/utils_test.go b/simapp/utils_test.go index b10295df1f..f8a0ab1973 100644 --- a/simapp/utils_test.go +++ b/simapp/utils_test.go @@ -41,8 +41,6 @@ func TestSetup(t *testing.T) { } func TestGetSimulationLog(t *testing.T) { - cdc := makeCodec(ModuleBasics) - decoders := make(sdk.StoreDecoderRegistry) decoders[authtypes.StoreKey] = func(kvAs, kvBs kv.Pair) string { return "10" } @@ -56,11 +54,6 @@ func TestGetSimulationLog(t *testing.T) { []kv.Pair{{}}, "", }, - { - authtypes.StoreKey, - []kv.Pair{{Key: authtypes.GlobalAccountNumberKey, Value: cdc.MustMarshalBinaryBare(uint64(10))}}, - "10", - }, { "OtherStore", []kv.Pair{{Key: []byte("key"), Value: []byte("value")}}, diff --git a/tests/mocks/account_retriever.go b/tests/mocks/account_retriever.go index 398bde25d7..63136d390b 100644 --- a/tests/mocks/account_retriever.go +++ b/tests/mocks/account_retriever.go @@ -63,20 +63,6 @@ func (mr *MockAccountMockRecorder) GetPubKey() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetPubKey", reflect.TypeOf((*MockAccount)(nil).GetPubKey)) } -// GetAccountNumber mocks base method -func (m *MockAccount) GetAccountNumber() uint64 { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAccountNumber") - ret0, _ := ret[0].(uint64) - return ret0 -} - -// GetAccountNumber indicates an expected call of GetAccountNumber -func (mr *MockAccountMockRecorder) GetAccountNumber() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountNumber", reflect.TypeOf((*MockAccount)(nil).GetAccountNumber)) -} - // GetSequence mocks base method func (m *MockAccount) GetSequence() uint64 { m.ctrl.T.Helper() @@ -159,18 +145,18 @@ func (mr *MockAccountRetrieverMockRecorder) EnsureExists(clientCtx, addr interfa return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsureExists", reflect.TypeOf((*MockAccountRetriever)(nil).EnsureExists), clientCtx, addr) } -// GetAccountNumberSequence mocks base method -func (m *MockAccountRetriever) GetAccountNumberSequence(clientCtx client.Context, addr types0.AccAddress) (uint64, uint64, error) { +// GetAccountSequence mocks base method +func (m *MockAccountRetriever) GetAccountSequence(clientCtx client.Context, addr types0.AccAddress) (uint64, uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAccountNumberSequence", clientCtx, addr) + ret := m.ctrl.Call(m, "GetAccountSequence", clientCtx, addr) ret0, _ := ret[0].(uint64) ret1, _ := ret[1].(uint64) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } -// GetAccountNumberSequence indicates an expected call of GetAccountNumberSequence -func (mr *MockAccountRetrieverMockRecorder) GetAccountNumberSequence(clientCtx, addr interface{}) *gomock.Call { +// GetAccountSequence indicates an expected call of GetAccountSequence +func (mr *MockAccountRetrieverMockRecorder) GetAccountSequence(clientCtx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountNumberSequence", reflect.TypeOf((*MockAccountRetriever)(nil).GetAccountNumberSequence), clientCtx, addr) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountSequence", reflect.TypeOf((*MockAccountRetriever)(nil).GetAccountSequence), clientCtx, addr) } diff --git a/testutil/network/network.go b/testutil/network/network.go index 9f8325fa80..bffdfb84f9 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -291,7 +291,7 @@ func New(t *testing.T, cfg Config) *Network { genFiles = append(genFiles, tmCfg.GenesisFile()) genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: balances.Sort()}) - genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) + genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0)) commission, err := sdk.NewDecFromStr("0.5") require.NoError(t, err) diff --git a/testutil/testdata/unknonwnproto.pb.go b/testutil/testdata/unknonwnproto.pb.go index 302c4acab1..24edbb02aa 100644 --- a/testutil/testdata/unknonwnproto.pb.go +++ b/testutil/testdata/unknonwnproto.pb.go @@ -2567,9 +2567,10 @@ func (m *TestUpdatedTxRaw) GetNewField_1024() []byte { type TestUpdatedTxBody struct { Messages []*types.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` - Memo string `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"` - TimeoutHeight int64 `protobuf:"varint,3,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty"` - SomeNewField uint64 `protobuf:"varint,4,opt,name=some_new_field,json=someNewField,proto3" json:"some_new_field,omitempty"` + SigBlockHeight uint64 `protobuf:"varint,2,opt,name=sig_block_height,json=sigBlockHeight,proto3" json:"sig_block_height,omitempty"` + Memo string `protobuf:"bytes,3,opt,name=memo,proto3" json:"memo,omitempty"` + TimeoutHeight int64 `protobuf:"varint,4,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty"` + SomeNewField uint64 `protobuf:"varint,5,opt,name=some_new_field,json=someNewField,proto3" json:"some_new_field,omitempty"` SomeNewFieldNonCriticalField string `protobuf:"bytes,1050,opt,name=some_new_field_non_critical_field,json=someNewFieldNonCriticalField,proto3" json:"some_new_field_non_critical_field,omitempty"` ExtensionOptions []*types.Any `protobuf:"bytes,1023,rep,name=extension_options,json=extensionOptions,proto3" json:"extension_options,omitempty"` NonCriticalExtensionOptions []*types.Any `protobuf:"bytes,2047,rep,name=non_critical_extension_options,json=nonCriticalExtensionOptions,proto3" json:"non_critical_extension_options,omitempty"` @@ -2615,6 +2616,13 @@ func (m *TestUpdatedTxBody) GetMessages() []*types.Any { return nil } +func (m *TestUpdatedTxBody) GetSigBlockHeight() uint64 { + if m != nil { + return m.SigBlockHeight + } + return 0 +} + func (m *TestUpdatedTxBody) GetMemo() string { if m != nil { return m.Memo @@ -2809,110 +2817,112 @@ func init() { func init() { proto.RegisterFile("unknonwnproto.proto", fileDescriptor_448ea787339d1228) } var fileDescriptor_448ea787339d1228 = []byte{ - // 1646 bytes of a gzipped FileDescriptorProto - 0x1f, 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, 0xcf, 0xe3, 0x5c, 0x75, 0xce, 0xe9, 0x29, 0x82, 0x66, 0x0d, - 0x69, 0x58, 0xd8, 0x72, 0x79, 0x51, 0x4d, 0x1b, 0x76, 0x9c, 0xbc, 0x6b, 0x6a, 0x90, 0xe9, 0xec, - 0x2d, 0x4f, 0x67, 0x87, 0xa4, 0x7a, 0x2d, 0x83, 0xc5, 0x5c, 0x5e, 0x68, 0x45, 0xf6, 0xb6, 0xb4, - 0x82, 0x88, 0x5c, 0xae, 0xc0, 0x64, 0x27, 0x62, 0x40, 0xf6, 0xa4, 0xcb, 0x7d, 0x41, 0x55, 0x4f, - 0xe6, 0x48, 0xb0, 0x31, 0x7e, 0x1e, 0xf3, 0xdb, 0xb9, 0x06, 0xbf, 0x73, 0xed, 0x21, 0x03, 0x5a, - 0xcc, 0x80, 0xf1, 0xab, 0xc4, 0x44, 0x69, 0xae, 0x54, 0x17, 0x05, 0x48, 0x79, 0x83, 0x70, 0x74, - 0xa5, 0xbc, 0x01, 0x7e, 0x17, 0x72, 0x9e, 0xef, 0xf6, 0x47, 0x96, 0x3b, 0xa4, 0xe1, 0x24, 0x99, - 0x0b, 0x70, 0x05, 0x36, 0x6d, 0xea, 0x09, 0x87, 0x59, 0x72, 0xba, 0xe9, 0x19, 0xa5, 0x28, 0x29, - 0xc2, 0xf7, 0xa0, 0xd0, 0x77, 0xa9, 0xed, 0x88, 0x6e, 0xdf, 0x72, 0xed, 0x2e, 0xe3, 0xc1, 0xd0, - 0xdb, 0x5f, 0x23, 0xf9, 0x40, 0xbe, 0x6b, 0xb9, 0xf6, 0x11, 0xc7, 0x77, 0x21, 0xd7, 0x1f, 0xd1, - 0x5f, 0xf8, 0x54, 0x42, 0xb2, 0x21, 0x24, 0x1b, 0x88, 0x8e, 0x38, 0xae, 0x43, 0x96, 0xbb, 0xce, - 0xd0, 0x61, 0xd6, 0x58, 0xcf, 0x29, 0x22, 0x6e, 0x9f, 0x9f, 0x4e, 0x0d, 0x12, 0x83, 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 0xbb, 0xd8, 0x18, 0x00, 0x00, + // 1671 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0x4f, 0x6f, 0x1b, 0xc7, + 0x15, 0xd7, 0x70, 0x49, 0x89, 0x7c, 0xa2, 0x69, 0x66, 0x6c, 0x34, 0x1b, 0x39, 0x66, 0x98, 0x85, + 0xe3, 0x30, 0x41, 0x43, 0x9a, 0x4b, 0x06, 0x28, 0x02, 0x14, 0x08, 0xa9, 0x58, 0xb5, 0x01, 0x57, + 0x2e, 0xa6, 0x4e, 0x5a, 0xf8, 0x42, 0x2c, 0xb9, 0xc3, 0xe5, 0x42, 0xe4, 0x8c, 0xba, 0x33, 0x6b, + 0x91, 0xb7, 0xa2, 0x3d, 0xf4, 0xda, 0x4b, 0x51, 0xa0, 0xdf, 0xa0, 0xa7, 0x22, 0xd7, 0x9e, 0x8a, + 0x9e, 0x72, 0x29, 0xe0, 0x4b, 0x81, 0x02, 0x05, 0x82, 0xc2, 0xbe, 0xf6, 0x1b, 0x14, 0x45, 0x8a, + 0x99, 0xfd, 0xc3, 0xa5, 0x24, 0x3a, 0xb4, 0xd2, 0xc6, 0x10, 0xd0, 0x0b, 0x39, 0xf3, 0xf6, 0x37, + 0xef, 0xcf, 0xef, 0xcd, 0x7b, 0xbb, 0x33, 0x70, 0x2d, 0x64, 0x47, 0x8c, 0xb3, 0x13, 0x76, 0x1c, + 0x70, 0xc9, 0x9b, 0xfa, 0x17, 0x17, 0x25, 0x15, 0xd2, 0x75, 0xa4, 0xb3, 0x77, 0xdd, 0xe3, 0x1e, + 0xd7, 0xc2, 0x96, 0x1a, 0x45, 0xcf, 0xf7, 0xde, 0xf0, 0x38, 0xf7, 0xa6, 0xb4, 0xa5, 0x67, 0xc3, + 0x70, 0xdc, 0x72, 0xd8, 0x22, 0x7e, 0xf4, 0xfa, 0x74, 0x3c, 0x6c, 0xc9, 0x79, 0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 0x72, 0x77, 0x31, 0x18, 0x2e, 0x24, 0x15, 0xda, 0x46, 0x99, 0x94, 0x94, 0xa4, 0xaf, 0x04, 0xf8, + 0x36, 0x5c, 0x75, 0x42, 0x39, 0x19, 0xf8, 0x6c, 0xcc, 0x63, 0x4c, 0x4e, 0x63, 0xae, 0x28, 0xf1, + 0x7d, 0x36, 0xe6, 0x11, 0xae, 0x06, 0x20, 0x7c, 0x8f, 0x39, 0x32, 0x0c, 0xa8, 0x30, 0x8d, 0xba, + 0xd1, 0x28, 0x93, 0x8c, 0x04, 0xd7, 0x60, 0x37, 0x3d, 0xbb, 0x0c, 0x3e, 0xd4, 0x37, 0x06, 0x65, + 0x52, 0x4a, 0x4e, 0x2f, 0x1f, 0xe2, 0x77, 0xa0, 0xb2, 0x7c, 0xde, 0xbe, 0x63, 0x77, 0xcd, 0x9f, + 0x17, 0x35, 0xa6, 0x9c, 0x60, 0x94, 0xd0, 0xfa, 0xa3, 0x01, 0xaf, 0xad, 0x84, 0xd0, 0xe7, 0xee, + 0x02, 0xdf, 0x81, 0xe2, 0x8c, 0x0a, 0xe1, 0x78, 0x3a, 0x02, 0x63, 0xed, 0x26, 0x4b, 0x51, 0xb8, + 0x01, 0x55, 0xe1, 0x7b, 0x83, 0xe1, 0x94, 0x8f, 0x8e, 0x06, 0x13, 0xea, 0x7b, 0x13, 0xa9, 0xe3, + 0xca, 0x93, 0x8a, 0xf0, 0xbd, 0xbe, 0x12, 0xdf, 0xd3, 0x52, 0xd5, 0x07, 0x66, 0x74, 0xc6, 0x93, + 0xcb, 0x24, 0x35, 0x56, 0xce, 0x4a, 0x7f, 0x46, 0x79, 0x28, 0x93, 0xb5, 0x11, 0xc7, 0x57, 0x62, + 0x69, 0xbc, 0xf4, 0x16, 0x54, 0x04, 0x9f, 0xd1, 0xc1, 0xf2, 0xd0, 0x56, 0xd0, 0x26, 0xca, 0x4a, + 0x7a, 0x18, 0x87, 0x85, 0xef, 0xc1, 0xdb, 0xab, 0xa8, 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, 0x1c, 0xf1, 0x59, + 0x6b, 0xea, 0x33, 0xda, 0x9a, 0x8e, 0x87, 0x1f, 0x08, 0xf7, 0xa8, 0xa5, 0xda, 0x42, 0x28, 0xfd, + 0x69, 0x2b, 0xe9, 0x0f, 0xc3, 0x6d, 0xcd, 0x6e, 0xe7, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x88, + 0x10, 0xe5, 0x2d, 0x02, 0x19, 0x00, 0x00, } func (m *Customer1) Marshal() (dAtA []byte, err error) { @@ -5252,19 +5262,24 @@ func (m *TestUpdatedTxBody) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.SomeNewField != 0 { i = encodeVarintUnknonwnproto(dAtA, i, uint64(m.SomeNewField)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } if m.TimeoutHeight != 0 { i = encodeVarintUnknonwnproto(dAtA, i, uint64(m.TimeoutHeight)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.Memo) > 0 { i -= len(m.Memo) copy(dAtA[i:], m.Memo) i = encodeVarintUnknonwnproto(dAtA, i, uint64(len(m.Memo))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + if m.SigBlockHeight != 0 { + i = encodeVarintUnknonwnproto(dAtA, i, uint64(m.SigBlockHeight)) + i-- + dAtA[i] = 0x10 } if len(m.Messages) > 0 { for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- { @@ -6416,6 +6431,9 @@ func (m *TestUpdatedTxBody) Size() (n int) { n += 1 + l + sovUnknonwnproto(uint64(l)) } } + if m.SigBlockHeight != 0 { + n += 1 + sovUnknonwnproto(uint64(m.SigBlockHeight)) + } l = len(m.Memo) if l > 0 { n += 1 + l + sovUnknonwnproto(uint64(l)) @@ -12543,6 +12561,25 @@ func (m *TestUpdatedTxBody) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SigBlockHeight", wireType) + } + m.SigBlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowUnknonwnproto + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SigBlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Memo", wireType) } @@ -12574,7 +12611,7 @@ func (m *TestUpdatedTxBody) Unmarshal(dAtA []byte) error { } m.Memo = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TimeoutHeight", wireType) } @@ -12593,7 +12630,7 @@ func (m *TestUpdatedTxBody) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field SomeNewField", wireType) } diff --git a/testutil/testdata/unknonwnproto.proto b/testutil/testdata/unknonwnproto.proto index 1a9139ce20..2893e577fb 100644 --- a/testutil/testdata/unknonwnproto.proto +++ b/testutil/testdata/unknonwnproto.proto @@ -288,9 +288,10 @@ message TestUpdatedTxRaw { message TestUpdatedTxBody { repeated google.protobuf.Any messages = 1; - string memo = 2; - int64 timeout_height = 3; - uint64 some_new_field = 4; + uint64 sig_block_height = 2; + string memo = 3; + int64 timeout_height = 4; + uint64 some_new_field = 5; string some_new_field_non_critical_field = 1050; repeated google.protobuf.Any extension_options = 1023; repeated google.protobuf.Any non_critical_extension_options = 2047; diff --git a/types/errors/errors.go b/types/errors/errors.go index 1aa68816cc..fd2b30907d 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -135,6 +135,10 @@ var ( // supported. ErrNotSupported = Register(RootCodespace, 37, "feature not supported") + // ErrInvalidSigBlockHeight is returned when SigBlockHeight of tx is either greater than current block height or + // less than (current block height - ValidSigBlockPeriod) + ErrInvalidSigBlockHeight = Register(RootCodespace, 38, "invalid sig block height") + // ErrPanic is only set when we recover from a panic, so we know to // redact potentially sensitive system info ErrPanic = Register(UndefinedCodespace, 111222, "panic") diff --git a/types/grpc/headers.go b/types/grpc/headers.go index 0915307958..c3dc08deaf 100644 --- a/types/grpc/headers.go +++ b/types/grpc/headers.go @@ -2,5 +2,5 @@ package grpc const ( // GRPCBlockHeightHeader is the gRPC header for block height. - GRPCBlockHeightHeader = "x-cosmos-block-height" + GRPCBlockHeightHeader = "x-lfb-block-height" ) diff --git a/types/rest/rest.go b/types/rest/rest.go index 04470917f3..d87d6f79e5 100644 --- a/types/rest/rest.go +++ b/types/rest/rest.go @@ -62,35 +62,35 @@ type GasEstimateResponse struct { // BaseReq defines a structure that can be embedded in other request structures // that all share common "base" fields. type BaseReq struct { - From string `json:"from"` - Memo string `json:"memo"` - ChainID string `json:"chain_id"` - AccountNumber uint64 `json:"account_number"` - Sequence uint64 `json:"sequence"` - TimeoutHeight uint64 `json:"timeout_height"` - Fees sdk.Coins `json:"fees"` - GasPrices sdk.DecCoins `json:"gas_prices"` - Gas string `json:"gas"` - GasAdjustment string `json:"gas_adjustment"` - Simulate bool `json:"simulate"` + From string `json:"from"` + Memo string `json:"memo"` + ChainID string `json:"chain_id"` + SigBlockHeight uint64 `json:"sig_block_height"` + Sequence uint64 `json:"sequence"` + TimeoutHeight uint64 `json:"timeout_height"` + Fees sdk.Coins `json:"fees"` + GasPrices sdk.DecCoins `json:"gas_prices"` + Gas string `json:"gas"` + GasAdjustment string `json:"gas_adjustment"` + Simulate bool `json:"simulate"` } // NewBaseReq creates a new basic request instance and sanitizes its values func NewBaseReq( - from, memo, chainID string, gas, gasAdjustment string, accNumber, seq uint64, + from, memo, chainID string, gas, gasAdjustment string, signBlockHeight, seq uint64, fees sdk.Coins, gasPrices sdk.DecCoins, simulate bool, ) BaseReq { return BaseReq{ - From: strings.TrimSpace(from), - Memo: strings.TrimSpace(memo), - ChainID: strings.TrimSpace(chainID), - Fees: fees, - GasPrices: gasPrices, - Gas: strings.TrimSpace(gas), - GasAdjustment: strings.TrimSpace(gasAdjustment), - AccountNumber: accNumber, - Sequence: seq, - Simulate: simulate, + From: strings.TrimSpace(from), + Memo: strings.TrimSpace(memo), + ChainID: strings.TrimSpace(chainID), + Fees: fees, + GasPrices: gasPrices, + Gas: strings.TrimSpace(gas), + GasAdjustment: strings.TrimSpace(gasAdjustment), + SigBlockHeight: signBlockHeight, + Sequence: seq, + Simulate: simulate, } } @@ -98,7 +98,7 @@ func NewBaseReq( func (br BaseReq) Sanitize() BaseReq { return NewBaseReq( br.From, br.Memo, br.ChainID, br.Gas, br.GasAdjustment, - br.AccountNumber, br.Sequence, br.Fees, br.GasPrices, br.Simulate, + br.SigBlockHeight, br.Sequence, br.Fees, br.GasPrices, br.Simulate, ) } diff --git a/types/rest/rest_test.go b/types/rest/rest_test.go index b103506e6f..a0bda34bf2 100644 --- a/types/rest/rest_test.go +++ b/types/rest/rest_test.go @@ -183,7 +183,6 @@ func TestProcessPostResponse(t *testing.T) { Address types.AccAddress `json:"address"` Coins types.Coins `json:"coins"` PubKey cryptotypes.PubKey `json:"public_key"` - AccountNumber uint64 `json:"account_number"` Sequence uint64 `json:"sequence"` } @@ -196,10 +195,9 @@ func TestProcessPostResponse(t *testing.T) { pubKey := privKey.PubKey() addr := types.AccAddress(pubKey.Address()) coins := types.NewCoins(types.NewCoin("atom", types.NewInt(100)), types.NewCoin("tree", types.NewInt(125))) - accNumber := uint64(104) sequence := uint64(32) - acc := mockAccount{addr, coins, pubKey, accNumber, sequence} + acc := mockAccount{addr, coins, pubKey, sequence} cdc := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(cdc) cdc.RegisterConcrete(&mockAccount{}, "lfb-sdk/mockAccount", nil) diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index c49ec414a5..95298d2b2a 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -179,8 +179,6 @@ type SignDoc struct { // It prevents signed transactions from being used on another chain by an // attacker ChainId string `protobuf:"bytes,3,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - // account_number is the account number of the account in state - AccountNumber uint64 `protobuf:"varint,4,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"` } func (m *SignDoc) Reset() { *m = SignDoc{} } @@ -237,13 +235,6 @@ func (m *SignDoc) GetChainId() string { return "" } -func (m *SignDoc) GetAccountNumber() uint64 { - if m != nil { - return m.AccountNumber - } - return 0 -} - // TxBody is the body of a transaction that all signers sign over. type TxBody struct { // messages is a list of messages to be executed. The required signers of @@ -254,11 +245,14 @@ type TxBody struct { // is referred to as the primary signer and pays the fee for the whole // transaction. Messages []*types.Any `protobuf:"bytes,1,rep,name=messages,proto3" json:"messages,omitempty"` + // sig block height is available between current block height and current block height - `VALID_SIG_BLOCK_DURATION` + // this is used for distinguish signatures instead of account number. this is mandatory. + SigBlockHeight uint64 `protobuf:"varint,2,opt,name=sig_block_height,json=sigBlockHeight,proto3" json:"sig_block_height,omitempty"` // memo is any arbitrary memo to be added to the transaction - Memo string `protobuf:"bytes,2,opt,name=memo,proto3" json:"memo,omitempty"` + Memo string `protobuf:"bytes,3,opt,name=memo,proto3" json:"memo,omitempty"` // timeout is the block height after which this transaction will not // be processed by the chain - TimeoutHeight uint64 `protobuf:"varint,3,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty"` + TimeoutHeight uint64 `protobuf:"varint,4,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty"` // extension_options are arbitrary options that can be added by chains // when the default options are not sufficient. If any of these are present // and can't be handled, the transaction will be rejected @@ -309,6 +303,13 @@ func (m *TxBody) GetMessages() []*types.Any { return nil } +func (m *TxBody) GetSigBlockHeight() uint64 { + if m != nil { + return m.SigBlockHeight + } + return 0 +} + func (m *TxBody) GetMemo() string { if m != nil { return m.Memo @@ -758,60 +759,60 @@ func init() { func init() { proto.RegisterFile("lfb/tx/v1beta1/tx.proto", fileDescriptor_3374cf1b0c1528d1) } var fileDescriptor_3374cf1b0c1528d1 = []byte{ - // 844 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x8e, 0xdc, 0x44, - 0x10, 0x1e, 0xcf, 0xdf, 0xce, 0xd4, 0xfe, 0x04, 0x9a, 0x15, 0x4c, 0x66, 0x85, 0x77, 0x34, 0x10, - 0x34, 0x0a, 0x60, 0x93, 0x0d, 0x3f, 0x02, 0x09, 0xa4, 0x9d, 0x40, 0xb4, 0x11, 0x04, 0xa4, 0xde, - 0x3d, 0x85, 0x83, 0xd5, 0xf6, 0xf4, 0x78, 0x5a, 0xb1, 0xbb, 0x07, 0x77, 0x1b, 0xec, 0x27, 0x40, - 0xe2, 0x84, 0x10, 0xbc, 0x04, 0x17, 0x5e, 0x23, 0xc7, 0x70, 0xe3, 0x04, 0x68, 0xf7, 0x41, 0x40, - 0xdd, 0x6e, 0x3b, 0xcb, 0x2a, 0x19, 0x2e, 0xb9, 0x75, 0x55, 0x7d, 0xf5, 0x55, 0x75, 0xfd, 0xc1, - 0x2b, 0xc9, 0x32, 0xf4, 0x55, 0xe1, 0x7f, 0x7b, 0x2b, 0xa4, 0x8a, 0xdc, 0xf2, 0x55, 0xe1, 0xad, - 0x33, 0xa1, 0x04, 0xda, 0x4b, 0x96, 0xa1, 0xa7, 0x0a, 0xcf, 0x1a, 0xc6, 0xfb, 0xb1, 0x88, 0x85, - 0x31, 0xf9, 0xfa, 0x55, 0xa1, 0xc6, 0x37, 0xb5, 0x7b, 0x94, 0x95, 0x6b, 0x25, 0xfc, 0x34, 0x4f, - 0x14, 0x93, 0x2c, 0x6e, 0xb8, 0x6a, 0x85, 0xc5, 0x1e, 0x68, 0x6c, 0x48, 0x24, 0x6d, 0x00, 0x91, - 0x60, 0xdc, 0x1a, 0x5f, 0xb7, 0x79, 0x48, 0x16, 0x73, 0xc6, 0x9f, 0x70, 0x58, 0xd9, 0xa2, 0xae, - 0xc7, 0x42, 0xc4, 0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xfd, 0xeb, 0xf0, 0xb5, 0x98, 0xa9, 0x55, 0x1e, 0x7a, 0x91, 0x48, 0xfd, - 0x84, 0x71, 0xea, 0x27, 0xcb, 0xf0, 0x6d, 0xb9, 0x78, 0xe8, 0xab, 0x72, 0x4d, 0xa5, 0xc1, 0x4a, - 0x6c, 0x29, 0xd1, 0x01, 0x0c, 0x63, 0x22, 0x83, 0x84, 0xa5, 0x4c, 0x99, 0xa2, 0x77, 0xf1, 0x20, - 0x26, 0xf2, 0x0b, 0x2d, 0xa3, 0x7d, 0xe8, 0xad, 0x49, 0x49, 0x33, 0x7b, 0x35, 0x2a, 0x01, 0x8d, - 0x60, 0x2b, 0xce, 0x08, 0x57, 0xf6, 0x58, 0x0c, 0x71, 0x2d, 0xce, 0x3f, 0x7a, 0x74, 0xee, 0x3a, - 0x8f, 0xcf, 0x5d, 0xe7, 0xef, 0x73, 0xd7, 0xf9, 0xf1, 0xc2, 0x6d, 0x3d, 0xbe, 0x70, 0x5b, 0x7f, - 0x5c, 0xb8, 0xad, 0x07, 0x93, 0x8d, 0x39, 0xf9, 0xaa, 0x08, 0xfb, 0x66, 0x5a, 0x6f, 0xff, 0x1b, - 0x00, 0x00, 0xff, 0xff, 0x2f, 0x66, 0x99, 0x92, 0xc3, 0x06, 0x00, 0x00, + // 843 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0xfa, 0x5f, 0xec, 0x97, 0x34, 0x2d, 0x43, 0x04, 0xae, 0x23, 0x36, 0x96, 0xa1, 0xc8, + 0x2a, 0xb0, 0x4b, 0x53, 0xfe, 0x08, 0x24, 0x90, 0xe2, 0x42, 0x95, 0x0a, 0x2a, 0xa4, 0x49, 0x4e, + 0xe5, 0xb0, 0x9a, 0x5d, 0x8f, 0xc7, 0xa3, 0xec, 0xce, 0x98, 0x9d, 0x59,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0xb7, 0x43, 0xdb, 0xc7, 0x95, 0x39, 0xfd, 0xf8, 0xe9, 0xb9, 0xef, 0x3d, 0x3b, + 0xf7, 0xbd, 0xbf, 0xce, 0x7d, 0xef, 0xc7, 0x0b, 0xbf, 0xf1, 0xec, 0xc2, 0x6f, 0xfc, 0x7e, 0xe1, + 0x37, 0x9e, 0x8c, 0x36, 0xe6, 0x14, 0xea, 0x55, 0xdc, 0xb5, 0xdd, 0x7a, 0xff, 0x9f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0xda, 0x07, 0x57, 0x86, 0xc5, 0x06, 0x00, 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -936,11 +937,6 @@ func (m *SignDoc) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.AccountNumber != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.AccountNumber)) - i-- - dAtA[i] = 0x20 - } if len(m.ChainId) > 0 { i -= len(m.ChainId) copy(dAtA[i:], m.ChainId) @@ -1020,14 +1016,19 @@ func (m *TxBody) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.TimeoutHeight != 0 { i = encodeVarintTx(dAtA, i, uint64(m.TimeoutHeight)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.Memo) > 0 { i -= len(m.Memo) copy(dAtA[i:], m.Memo) i = encodeVarintTx(dAtA, i, uint64(len(m.Memo))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + if m.SigBlockHeight != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.SigBlockHeight)) + i-- + dAtA[i] = 0x10 } if len(m.Messages) > 0 { for iNdEx := len(m.Messages) - 1; iNdEx >= 0; iNdEx-- { @@ -1429,9 +1430,6 @@ func (m *SignDoc) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if m.AccountNumber != 0 { - n += 1 + sovTx(uint64(m.AccountNumber)) - } return n } @@ -1447,6 +1445,9 @@ func (m *TxBody) Size() (n int) { n += 1 + l + sovTx(uint64(l)) } } + if m.SigBlockHeight != 0 { + n += 1 + sovTx(uint64(m.SigBlockHeight)) + } l = len(m.Memo) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -2040,25 +2041,6 @@ func (m *SignDoc) Unmarshal(dAtA []byte) error { } m.ChainId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType) - } - m.AccountNumber = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AccountNumber |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) @@ -2144,6 +2126,25 @@ func (m *TxBody) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SigBlockHeight", wireType) + } + m.SigBlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.SigBlockHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Memo", wireType) } @@ -2175,7 +2176,7 @@ func (m *TxBody) Unmarshal(dAtA []byte) error { } m.Memo = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field TimeoutHeight", wireType) } diff --git a/types/tx/types.go b/types/tx/types.go index 4d6d718ae2..c6631c5e0f 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -147,6 +147,10 @@ func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return nil } +func (t *Tx) GetSigBlockHeight() uint64 { + return t.Body.SigBlockHeight +} + // UnpackInterfaces implements the UnpackInterfaceMessages.UnpackInterfaces method func (m *TxBody) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { for _, any := range m.Messages { diff --git a/types/tx_msg.go b/types/tx_msg.go index 646d17e5a8..def852d8ce 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -54,6 +54,9 @@ type ( // ValidateBasic does a simple and lightweight validation check that doesn't // require access to any other information. ValidateBasic() error + + // Gets the sig block height + GetSigBlockHeight() uint64 } // FeeTx defines the interface to be implemented by Tx to use the FeeDecorators diff --git a/x/auth/ante/ante.go b/x/auth/ante/ante.go index 4be8678cc1..98cc086e87 100644 --- a/x/auth/ante/ante.go +++ b/x/auth/ante/ante.go @@ -7,7 +7,7 @@ import ( ) // NewAnteHandler returns an AnteHandler that checks and increments sequence -// numbers, checks signatures & account numbers, and deducts fees from the first +// numbers, checks signatures & sig block height, and deducts fees from the first // signer. func NewAnteHandler( ak AccountKeeper, bankKeeper types.BankKeeper, @@ -19,11 +19,14 @@ func NewAnteHandler( NewRejectExtensionOptionsDecorator(), NewMempoolFeeDecorator(), NewValidateBasicDecorator(), + NewTxSigBlockHeightDecorator(ak), TxTimeoutHeightDecorator{}, NewValidateMemoDecorator(ak), NewConsumeGasForTxSizeDecorator(ak), NewRejectFeeGranterDecorator(), + // The above handlers should not call `GetAccount` or `GetSignerAcc` for signer NewSetPubKeyDecorator(ak), // SetPubKeyDecorator must be called before all signature verification decorators + // The handlers below may call `GetAccount` or `GetSignerAcc` for signer NewValidateSigCountDecorator(ak), NewDeductFeeDecorator(ak, bankKeeper), NewSigGasConsumeDecorator(ak, sigGasConsumer), diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index d0d30d4478..411c6727a8 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -36,7 +36,7 @@ func (suite *AnteTestSuite) TestSimulateGasCost() { gasLimit := testdata.NewTestGasLimit() accSeqs := []uint64{0, 0, 0} privs := []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv} - accNums := []uint64{0, 1, 2} + sbh := []uint64{0, 1, 1} testCases := []TestCase{ { @@ -69,7 +69,7 @@ func (suite *AnteTestSuite) TestSimulateGasCost() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, sbh, accSeqs, suite.ctx.ChainID(), tc) }) } } @@ -92,7 +92,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { // Variable data per test case var ( privs []cryptotypes.PrivKey - accNums []uint64 + sbh []uint64 accSeqs []uint64 ) @@ -100,11 +100,11 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { { "check no signatures fails", func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{}, []uint64{}, []uint64{} + privs, sbh, accSeqs = []cryptotypes.PrivKey{}, []uint64{}, []uint64{} // Create tx manually to test the tx's signers suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) - tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + tx, err := suite.CreateTestTx(privs, sbh, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) // tx.GetSigners returns addresses in correct order: addr1, addr2, addr3 expectedSigners := []sdk.AccAddress{addr0, addr1, addr2} @@ -117,7 +117,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { { "num sigs dont match GetSigners", func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} + privs, sbh, accSeqs = []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} }, false, false, @@ -126,11 +126,11 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { { "unrecognized account", func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{priv0, priv1, priv2}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + privs, sbh, accSeqs = []cryptotypes.PrivKey{priv0, priv1, priv2}, []uint64{0, 0, 0}, []uint64{0, 0, 0} }, false, false, - sdkerrors.ErrUnknownAddress, + sdkerrors.ErrInsufficientFunds, // unknown account may send tx, but he doesn't have enough balance to pay fee }, { "save the first account, but second is still unrecognized", @@ -141,8 +141,8 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { suite.Require().NoError(err) }, false, - false, - sdkerrors.ErrUnknownAddress, + true, + nil, // unknown account may send tx; now they have enough money to pay fee }, } @@ -151,14 +151,15 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, sbh, accSeqs, suite.ctx.ChainID(), tc) }) } } -// Test logic around account number checking with one signer and many signers. -func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { +// Test logic around sig block height checking with one signer and many signers. +func (suite *AnteTestSuite) TestAnteHandlerSigBlockHeight() { suite.SetupTest(false) // reset + suite.ctx = suite.ctx.WithBlockHeight(200) // init block height is 200 // Same data for every test cases accounts := suite.CreateTestAccounts(2) @@ -167,7 +168,7 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { // Variable data per test case var ( - accNums []uint64 + sbh []uint64 msgs []sdk.Msg privs []cryptotypes.PrivKey accSeqs []uint64 @@ -180,46 +181,46 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{100}, []uint64{0} }, false, true, nil, }, { - "new tx from wrong account number", + "new tx from wrong sig block height", func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} + privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} }, false, false, - sdkerrors.ErrUnauthorized, + sdkerrors.ErrInvalidSigBlockHeight, }, { - "new tx from correct account number", + "new tx from correct sig block height", func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} + privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{100}, []uint64{1} }, false, true, nil, }, { - "new tx with another signer and incorrect account numbers", + "new tx with another signer and incorrect sig block height", func() { msg1 := testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()) msg2 := testdata.NewTestMsg(accounts[1].acc.GetAddress(), accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg1, msg2} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 0}, []uint64{2, 0} + privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 0}, []uint64{2, 0} }, false, false, - sdkerrors.ErrUnauthorized, + sdkerrors.ErrInvalidSigBlockHeight, }, { - "new tx with correct account numbers", + "new tx with correct sig block height", func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{2, 0} + privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{100, 101}, []uint64{2, 0} }, false, true, @@ -232,13 +233,13 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, sbh, accSeqs, suite.ctx.ChainID(), tc) }) } } -// Test logic around account number checking with many signers when BlockHeight is 0. -func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { +// Test logic around sig block height checking with many signers when BlockHeight is 0. +func (suite *AnteTestSuite) TestAnteHandlerSigBlockHeightAtBlockHeightZero() { suite.SetupTest(false) // setup suite.ctx = suite.ctx.WithBlockHeight(0) @@ -269,16 +270,16 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { nil, }, { - "new tx from wrong account number", + "new tx from wrong sig block height", func() { privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} }, false, false, - sdkerrors.ErrUnauthorized, + sdkerrors.ErrInvalidSigBlockHeight, }, { - "new tx from correct account number", + "new tx from correct sig block height", func() { privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} }, @@ -287,20 +288,20 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { nil, }, { - "new tx with another signer and incorrect account numbers", + "new tx with another signer and incorrect sig block height", func() { msg1 := testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()) msg2 := testdata.NewTestMsg(accounts[1].acc.GetAddress(), accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg1, msg2} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 0}, []uint64{2, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 1}, []uint64{2, 0} }, false, false, - sdkerrors.ErrUnauthorized, + sdkerrors.ErrInvalidSigBlockHeight, }, { - "new tx with another signer and correct account numbers", + "new tx with another signer and correct sig block height", func() { // Note that accNums is [0,0] at block 0. privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 0}, []uint64{2, 0} @@ -376,7 +377,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { msg2 := testdata.NewTestMsg(accounts[2].acc.GetAddress(), accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg1, msg2} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{2, 0, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 0, 0}, []uint64{2, 0, 0} }, false, true, @@ -394,7 +395,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { func() { msg := testdata.NewTestMsg(accounts[1].acc.GetAddress()) msgs = []sdk.Msg{msg} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{0}, []uint64{0} }, false, false, @@ -415,7 +416,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { msg := testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()) msgs = []sdk.Msg{msg} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{3, 2} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 0}, []uint64{3, 2} }, false, true, @@ -600,13 +601,14 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { accSeqs []uint64 ) + // This test case is no longer meaningful because there is no account number any more. testCases := []TestCase{ { "signers in order", func() { msgs = []sdk.Msg{msg1, msg2, msg3} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} - suite.txBuilder.SetMemo("Check signers are in expected order and different account numbers works") + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{1, 1, 1}, []uint64{0, 0, 0} + suite.txBuilder.SetMemo("Check signers are in expected order works") }, false, true, @@ -616,7 +618,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { "change sequence numbers (only accounts 0 and 1 sign)", func() { msgs = []sdk.Msg{msg1} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{1, 1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 1}, []uint64{1, 1} }, false, true, @@ -626,7 +628,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { "change sequence numbers (only accounts 1 and 2 sign)", func() { msgs = []sdk.Msg{msg2} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[2].priv, accounts[0].priv}, []uint64{2, 0}, []uint64{1, 2} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[2].priv, accounts[0].priv}, []uint64{1, 1}, []uint64{1, 2} }, false, true, @@ -636,7 +638,7 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { "everyone signs again", func() { msgs = []sdk.Msg{msg1, msg2, msg3} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{3, 2, 2} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{1, 1, 1}, []uint64{3, 2, 2} }, false, true, @@ -663,7 +665,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { // Variable data per test case var ( - accNums []uint64 + sbh []uint64 chainID string feeAmount sdk.Coins gasLimit uint64 @@ -680,7 +682,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { feeAmount = testdata.NewTestFeeAmount() gasLimit = testdata.NewTestGasLimit() msgs = []sdk.Msg{msg0} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, true, @@ -707,18 +709,19 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { sdkerrors.ErrWrongSequence, }, { - "test wrong accNums", + "test wrong sig block height", func() { accSeqs = []uint64{1} // Back to correct accSeqs - accNums = []uint64{1} + sbh = []uint64{2} }, false, false, - sdkerrors.ErrUnauthorized, + sdkerrors.ErrInvalidSigBlockHeight, }, { "test wrong msg", func() { + sbh = []uint64{0} // Back to correct sig block height msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} }, false, @@ -726,6 +729,8 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { sdkerrors.ErrInvalidPubKey, }, { + // This test case succeed and this is normal. Different gasLimit does not matter to sign. + // The failure of the past was due to invalid account number "test wrong fee gas", func() { msgs = []sdk.Msg{msg0} // Back to correct msgs @@ -733,26 +738,30 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { gasLimit = testdata.NewTestGasLimit() + 100 }, false, - false, - sdkerrors.ErrUnauthorized, + true, + nil, }, { + // This test case succeed and this is normal. Different feeAmount does not matter to sign. + // The failure of the past was due to invalid account number "test wrong fee amount", func() { + accSeqs = []uint64{2} feeAmount = testdata.NewTestFeeAmount() feeAmount[0].Amount = feeAmount[0].Amount.AddRaw(100) gasLimit = testdata.NewTestGasLimit() }, false, - false, - sdkerrors.ErrUnauthorized, + true, + nil, }, { "test wrong signer if public key exist", func() { + accSeqs = []uint64{3} feeAmount = testdata.NewTestFeeAmount() gasLimit = testdata.NewTestGasLimit() - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{0}, []uint64{1} + privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{0}, []uint64{1} }, false, false, @@ -762,7 +771,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { "test wrong signer if public doesn't exist", func() { msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{0} + privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, false, @@ -775,7 +784,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, chainID, tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, sbh, accSeqs, chainID, tc) }) } } @@ -971,7 +980,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigLimitExceeded() { privs = append(privs, accounts[i].priv) } msgs := []sdk.Msg{testdata.NewTestMsg(addrs...)} - accNums, accSeqs := []uint64{0, 1, 2, 3, 4, 5, 6, 7}, []uint64{0, 0, 0, 0, 0, 0, 0, 0} + accNums, accSeqs := []uint64{0, 0, 0, 0, 0, 0, 0, 0}, []uint64{0, 0, 0, 0, 0, 0, 0, 0} feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() @@ -1091,9 +1100,9 @@ func (suite *AnteTestSuite) TestAnteHandlerReCheck() { name string params types.Params }{ - {"memo size check", types.NewParams(1, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1)}, - {"txsize check", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, 10000000, types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1)}, - {"sig verify cost check", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, types.DefaultSigVerifyCostED25519, 100000000)}, + {"memo size check", types.NewParams(1, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1, types.DefaultValidSigBlockPeriod)}, + {"txsize check", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, 10000000, types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1, types.DefaultValidSigBlockPeriod)}, + {"sig verify cost check", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, types.DefaultSigVerifyCostED25519, 100000000, types.DefaultValidSigBlockPeriod)}, } for _, tc := range testCases { // set testcase parameters diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go index 05df8c9141..7a58299013 100644 --- a/x/auth/ante/basic.go +++ b/x/auth/ante/basic.go @@ -200,3 +200,32 @@ func (txh TxTimeoutHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simul return next(ctx, tx, simulate) } + +type TxSigBlockHeightDecorator struct { + ak AccountKeeper +} + +func NewTxSigBlockHeightDecorator(ak AccountKeeper) TxSigBlockHeightDecorator { + return TxSigBlockHeightDecorator{ + ak: ak, + } +} + +func (txs TxSigBlockHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + if !simulate { + params := txs.ak.GetParams(ctx) + sbh := tx.GetSigBlockHeight() + current := uint64(ctx.BlockHeight()) + validMin := uint64(0) + if current > params.ValidSigBlockPeriod { + validMin = current - params.ValidSigBlockPeriod + } + if sbh > uint64(ctx.BlockHeight()) || sbh < validMin { + return ctx, sdkerrors.Wrapf( + sdkerrors.ErrInvalidSigBlockHeight, "sig block height: %d, current: %d, valid sig block period: %d", + sbh, ctx.BlockHeight(), params.ValidSigBlockPeriod, + ) + } + } + return next(ctx, tx, simulate) +} diff --git a/x/auth/ante/expected_keepers.go b/x/auth/ante/expected_keepers.go index 0efa3da280..5aac54de13 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -8,6 +8,7 @@ import ( // AccountKeeper defines the contract needed for AccountKeeper related APIs. // Interface provides support to use non-sdk AccountKeeper for AnteHandler's decorators. type AccountKeeper interface { + NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountI GetParams(ctx sdk.Context) (params types.Params) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI SetAccount(ctx sdk.Context, acc types.AccountI) diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index c5e9089169..0ce927ac4d 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -81,11 +81,7 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } feePayer := feeTx.FeePayer() - feePayerAcc := dfd.ak.GetAccount(ctx, feePayer) - - if feePayerAcc == nil { - return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", feePayer) - } + feePayerAcc := dfd.ak.NewAccountWithAddress(ctx, feePayer) // deduct the fees if !feeTx.GetFee().IsZero() { diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 6316d9c7fe..bb7e0fe827 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -79,8 +79,11 @@ func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b acc, err := GetSignerAcc(ctx, spkd.ak, signers[i]) if err != nil { - return ctx, err + // At this point, the signer may not be in account keeper. + // So we make an account with address. + acc = spkd.ak.NewAccountWithAddress(ctx, signers[i]) } + // account already has pubkey set,no need to reset if acc.GetPubKey() != nil { continue @@ -89,7 +92,7 @@ func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b if err != nil { return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) } - spkd.ak.SetAccount(ctx, acc) + spkd.ak.SetAccount(ctx, acc) // After here, we can call `GetAccount` or `GetSignerAcc` from other ante handlers } return next(ctx, tx, simulate) @@ -123,7 +126,7 @@ func (sgcd SigGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, err } - // stdSigs contains the sequence number, account number, and signatures. + // stdSigs contains the sequence number, signatures. // When simulating, this would just be a 0-length slice. signerAddrs := sigTx.GetSigners() @@ -210,7 +213,7 @@ func (svd *SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") } - // stdSigs contains the sequence number, account number, and signatures. + // stdSigs contains the sequence number, signatures. // When simulating, this would just be a 0-length slice. sigs, err := sigTx.GetSignaturesV2() if err != nil { @@ -226,7 +229,7 @@ func (svd *SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu newSigKeys := make([]string, 0, len(sigs)) defer func() { - // remove txHashCash if got an error + // remove txHashCache if got an error if err != nil { for _, sigKey := range newSigKeys { svd.txHashCache.Delete(sigKey) @@ -269,18 +272,14 @@ func (svd *SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu // retrieve signer data genesis := ctx.BlockHeight() == 0 chainID := ctx.ChainID() - var accNum uint64 - if !genesis { - accNum = acc.GetAccountNumber() - } signerData := authsigning.SignerData{ - ChainID: chainID, - AccountNumber: accNum, - Sequence: acc.GetSequence(), + ChainID: chainID, + Sequence: acc.GetSequence(), } if !genesis { - sigKey := fmt.Sprintf("%d:%d", signerData.AccountNumber, signerData.Sequence) + sigKey := fmt.Sprintf("%s:%d:%d", acc.GetAddress().String(), + tx.GetSigBlockHeight(), signerData.Sequence) // TODO could we use `tx.(*wrapper).getBodyBytes()` instead of `ctx.TxBytes()`? txHash := sha256.Sum256(ctx.TxBytes()) stored := false @@ -299,9 +298,9 @@ func (svd *SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu if onlyAminoSigners { // 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) + errMsg = fmt.Sprintf("signature verification failed; please verify sequence (%d) and chain-id (%s)", acc.GetSequence(), chainID) } else { - errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d) and chain-id (%s)", accNum, chainID) + errMsg = fmt.Sprintf("signature verification failed; please verify chain-id (%s)", chainID) } return ctx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, errMsg) } diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index 31ccb4fae3..bfa02f2273 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -35,7 +35,6 @@ func (suite *AnteTestSuite) TestSetPubKey() { // set accounts and create msg for each address for i, addr := range addrs { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) - suite.Require().NoError(acc.SetAccountNumber(uint64(i))) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) } @@ -119,7 +118,7 @@ func (suite *AnteTestSuite) TestSigVerification() { suite.SetupTest(true) // setup suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - // make block height non-zero to ensure account numbers part of signBytes + // make block height non-zero to ensure sig block height part suite.ctx = suite.ctx.WithBlockHeight(1) // keys and addresses @@ -133,7 +132,6 @@ func (suite *AnteTestSuite) TestSigVerification() { // set accounts and create msg for each address for i, addr := range addrs { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) - suite.Require().NoError(acc.SetAccountNumber(uint64(i))) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) } @@ -143,12 +141,13 @@ func (suite *AnteTestSuite) TestSigVerification() { spkd := ante.NewSetPubKeyDecorator(suite.app.AccountKeeper) svd := ante.NewSigVerificationDecorator(suite.app.AccountKeeper, suite.clientCtx.TxConfig.SignModeHandler()) - antehandler := sdk.ChainAnteDecorators(spkd, svd) + sbhv := ante.NewTxSigBlockHeightDecorator(suite.app.AccountKeeper) + antehandler := sdk.ChainAnteDecorators(spkd, svd, sbhv) type testCase struct { name string privs []cryptotypes.PrivKey - accNums []uint64 + sbh []uint64 accSeqs []uint64 recheck bool shouldErr bool @@ -156,10 +155,10 @@ func (suite *AnteTestSuite) TestSigVerification() { testCases := []testCase{ {"no signers", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, false, true}, {"not enough signers", []cryptotypes.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0}, false, true}, - {"wrong order signers", []cryptotypes.PrivKey{priv3, priv2, priv1}, []uint64{2, 1, 0}, []uint64{0, 0, 0}, false, true}, - {"wrong accnums", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{7, 8, 9}, []uint64{0, 0, 0}, false, true}, - {"wrong sequences", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{3, 4, 5}, false, true}, - {"valid tx", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0}, false, false}, + {"wrong order signers", []cryptotypes.PrivKey{priv3, priv2, priv1}, []uint64{1, 1, 1}, []uint64{0, 0, 0}, false, true}, + {"wrong sig block height", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{2, 2, 2}, []uint64{0, 0, 0}, false, true}, + {"wrong sequences", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 1}, []uint64{3, 4, 5}, false, true}, + {"valid tx", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{1, 1, 1}, []uint64{0, 0, 0}, false, false}, {"no err on recheck", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, true, false}, } for i, tc := range testCases { @@ -170,7 +169,7 @@ func (suite *AnteTestSuite) TestSigVerification() { suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - tx, err := suite.CreateTestTx(tc.privs, tc.accNums, tc.accSeqs, suite.ctx.ChainID()) + tx, err := suite.CreateTestTx(tc.privs, tc.sbh, tc.accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) _, err = antehandler(suite.ctx, tx, false) @@ -204,7 +203,7 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - // make block height non-zero to ensure account numbers part of signBytes + // make block height non-zero to ensure sig block height suite.ctx = suite.ctx.WithBlockHeight(1) // keys and addresses @@ -218,7 +217,6 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { // set accounts and create msg for each address for i, addr := range addrs { acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) - suite.Require().NoError(acc.SetAccountNumber(uint64(i))) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) } @@ -228,7 +226,8 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { spkd := ante.NewSetPubKeyDecorator(suite.app.AccountKeeper) svd := ante.NewSigVerificationDecorator(suite.app.AccountKeeper, suite.clientCtx.TxConfig.SignModeHandler()) - antehandler := sdk.ChainAnteDecorators(spkd, svd) + sbhv := ante.NewTxSigBlockHeightDecorator(suite.app.AccountKeeper) + antehandler := sdk.ChainAnteDecorators(spkd, svd, sbhv) type testCase struct { name string @@ -241,10 +240,10 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { testCases := []testCase{ {"no signers", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, false, true}, {"not enough signers", []cryptotypes.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0}, false, true}, - {"wrong order signers", []cryptotypes.PrivKey{priv3, priv2, priv1}, []uint64{2, 1, 0}, []uint64{0, 0, 0}, false, true}, - {"wrong accnums", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{7, 8, 9}, []uint64{0, 0, 0}, false, true}, - {"wrong sequences", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{3, 4, 5}, false, true}, - {"valid tx", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0}, false, false}, + {"wrong order signers", []cryptotypes.PrivKey{priv3, priv2, priv1}, []uint64{1, 1, 1}, []uint64{0, 0, 0}, false, true}, + {"wrong sig block height", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{7, 8, 9}, []uint64{0, 0, 0}, false, true}, + {"wrong sequences", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 1}, []uint64{3, 4, 5}, false, true}, + {"valid tx", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 1}, []uint64{0, 0, 0}, false, false}, {"no err on recheck", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, true, false}, } for i, tc := range testCases { @@ -302,7 +301,6 @@ func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs for i, priv := range privs { addr := sdk.AccAddress(priv.PubKey().Address()) acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) - suite.Require().NoError(acc.SetAccountNumber(uint64(i))) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) accNums[i] = uint64(i) @@ -337,20 +335,19 @@ func (suite *AnteTestSuite) TestIncrementSequenceDecorator() { priv, _, addr := testdata.KeyTestPubAddr() acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) - suite.Require().NoError(acc.SetAccountNumber(uint64(50))) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs := []sdk.Msg{testdata.NewTestMsg(addr)} suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) privs := []cryptotypes.PrivKey{priv} - accNums := []uint64{suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetAccountNumber()} + sbh := []uint64{ 1 } accSeqs := []uint64{suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetSequence()} feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + tx, err := suite.CreateTestTx(privs, sbh, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) isd := ante.NewIncrementSequenceDecorator(suite.app.AccountKeeper) diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index 86cd68d8cf..6c59ce36e5 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -72,8 +72,6 @@ func (suite *AnteTestSuite) CreateTestAccounts(numAccs int) []TestAccount { for i := 0; i < numAccs; i++ { priv, _, addr := testdata.KeyTestPubAddr() acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) - err := acc.SetAccountNumber(uint64(i)) - suite.Require().NoError(err) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) suite.app.BankKeeper.SetBalances(suite.ctx, addr, sdk.Coins{ sdk.NewInt64Coin("atom", 10000000), @@ -86,11 +84,12 @@ func (suite *AnteTestSuite) CreateTestAccounts(numAccs int) []TestAccount { } // CreateTestTx is a helper function to create a tx given multiple inputs. -func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { +func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, sbh []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { // First round: we gather all the signer infos. We use the "set empty // signature" hack to do that. var sigsV2 []signing.SignatureV2 for i, priv := range privs { + suite.txBuilder.SetSigBlockHeight(sbh[i]) sigV2 := signing.SignatureV2{ PubKey: priv.PubKey(), Data: &signing.SingleSignatureData{ @@ -111,9 +110,8 @@ func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums [] sigsV2 = []signing.SignatureV2{} for i, priv := range privs { signerData := xauthsigning.SignerData{ - ChainID: chainID, - AccountNumber: accNums[i], - Sequence: accSeqs[i], + ChainID: chainID, + Sequence: accSeqs[i], } sigV2, err := tx.SignWithPrivKey( suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, @@ -142,7 +140,7 @@ type TestCase struct { } // CreateTestTx is a helper function to create a tx given multiple inputs. -func (suite *AnteTestSuite) RunTestCase(privs []cryptotypes.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, accNums, accSeqs []uint64, chainID string, tc TestCase) { +func (suite *AnteTestSuite) RunTestCase(privs []cryptotypes.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, sbh, accSeqs []uint64, chainID string, tc TestCase) { suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) suite.txBuilder.SetFeeAmount(feeAmount) @@ -151,7 +149,7 @@ func (suite *AnteTestSuite) RunTestCase(privs []cryptotypes.PrivKey, msgs []sdk. // Theoretically speaking, ante handler unit tests should only test // ante handlers, but here we sometimes also test the tx creation // process. - tx, txErr := suite.CreateTestTx(privs, accNums, accSeqs, chainID) + tx, txErr := suite.CreateTestTx(privs, sbh, accSeqs, chainID) newCtx, anteErr := suite.anteHandler(suite.ctx, tx, tc.simulate) if tc.expPass { diff --git a/x/auth/client/cli/cli_test.go b/x/auth/client/cli/cli_test.go index fd7ec43f19..3f4bb17faa 100644 --- a/x/auth/client/cli/cli_test.go +++ b/x/auth/client/cli/cli_test.go @@ -110,7 +110,7 @@ func (s *IntegrationTestSuite) TestCLISignBatch() { // sign-batch file - offline is set but account-number and sequence are not res, err := authtest.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--offline") - s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set") + s.Require().EqualError(err, "required flag(s) \"sequence\" not set") // sign-batch file res, err = authtest.TxSignBatchExec(val.ClientCtx, val.Address, outputFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID)) @@ -414,11 +414,11 @@ func (s *IntegrationTestSuite) TestCLISendGenerateSignAndBroadcast() { // Does not work in offline mode res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline") - s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set") + s.Require().EqualError(err, "required flag(s) \"sequence\" not set") - // But works offline if we set account number and sequence + // But works offline if we set sequence val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1) - res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline", "--account-number", "1", "--sequence", "1") + res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline", "--sequence", "1", "--sig-block-height", "1") s.Require().NoError(err) // Sign transaction @@ -737,9 +737,9 @@ func (s *IntegrationTestSuite) TestCLIMultisign() { sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String()) - // Does not work in offline mode. + // Offline mode requires --sequence flag _, err = authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), "--offline", sign1File.Name(), sign2File.Name()) - s.Require().EqualError(err, "couldn't verify signature: unable to verify single signer signature") + s.Require().EqualError(err, "required flag(s) \"sequence\" not set") val1.ClientCtx.Offline = false multiSigWith2Signatures, err := authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name()) @@ -868,14 +868,14 @@ func (s *IntegrationTestSuite) TestMultisignBatch() { s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalInterfaceJSON(queryResJSON.Bytes(), &account)) // sign-batch file - res, err := authtest.TxSignBatchExec(val.ClientCtx, account1.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence()))) + res, err := authtest.TxSignBatchExec(val.ClientCtx, account1.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence()))) s.Require().NoError(err) s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n"))) // write sigs to file file1 := testutil.WriteToNewTempFile(s.T(), res.String()) // sign-batch file with account2 - res, err = authtest.TxSignBatchExec(val.ClientCtx, account2.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence()))) + res, err = authtest.TxSignBatchExec(val.ClientCtx, account2.GetAddress(), filename.Name(), fmt.Sprintf("--%s=%s", flags.FlagChainID, val.ClientCtx.ChainID), "--multisig", multisigInfo.GetAddress().String(), fmt.Sprintf("--%s", flags.FlagOffline), fmt.Sprintf("--%s=%s", flags.FlagSequence, fmt.Sprint(account.GetSequence()))) s.Require().NoError(err) s.Require().Equal(3, len(strings.Split(strings.Trim(res.String(), "\n"), "\n"))) @@ -1109,11 +1109,11 @@ func (s *IntegrationTestSuite) TestSignWithMultiSigners_AminoJSON() { signedByVal0File := testutil.WriteToNewTempFile(s.T(), signedByVal0.String()) // Then let val1 sign the file with signedByVal0. - val1AccNum, val1Seq, err := val0.ClientCtx.AccountRetriever.GetAccountNumberSequence(val0.ClientCtx, val1.Address) + val1Seq, err := val0.ClientCtx.AccountRetriever.GetAccountSequence(val0.ClientCtx, val1.Address) require.NoError(err) signedTx, err := authtest.TxSignExec( val1.ClientCtx, val1.Address, signedByVal0File.Name(), - "--offline", fmt.Sprintf("--account-number=%d", val1AccNum), fmt.Sprintf("--sequence=%d", val1Seq), + "--offline", fmt.Sprintf("--sequence=%d", val1Seq), ) require.NoError(err) signedTxFile := testutil.WriteToNewTempFile(s.T(), signedTx.String()) diff --git a/x/auth/client/cli/tx_multisign.go b/x/auth/client/cli/tx_multisign.go index 6078d50b85..fd4252b504 100644 --- a/x/auth/client/cli/tx_multisign.go +++ b/x/auth/client/cli/tx_multisign.go @@ -50,8 +50,9 @@ The SIGN_MODE_DIRECT sign mode is not supported.' version.AppName, ), ), - RunE: makeMultiSignCmd(), - Args: cobra.MinimumNArgs(3), + PreRun: preMultisignCmd, + RunE: makeMultiSignCmd(), + Args: cobra.MinimumNArgs(3), } cmd.Flags().Bool(flagSigOnly, false, "Print only the generated signature, then exit") @@ -63,6 +64,13 @@ The SIGN_MODE_DIRECT sign mode is not supported.' return cmd } +func preMultisignCmd(cmd *cobra.Command, _ []string) { + // Conditionally mark the account sequence required as no RPC query will be done. + if offline, _ := cmd.Flags().GetBool(flags.FlagOffline); offline { + cmd.MarkFlagRequired(flags.FlagSequence) + } +} + func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) { return func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) @@ -93,12 +101,12 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) { multisigPub := multisigInfo.GetPubKey().(*kmultisig.LegacyAminoPubKey) multisigSig := multisig.NewMultisig(len(multisigPub.PubKeys)) if !clientCtx.Offline { - accnum, seq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, multisigInfo.GetAddress()) + seq, err := clientCtx.AccountRetriever.GetAccountSequence(clientCtx, multisigInfo.GetAddress()) if err != nil { return err } - txFactory = txFactory.WithAccountNumber(accnum).WithSequence(seq) + txFactory = txFactory.WithSigBlockHeight(uint64(clientCtx.Height)).WithSequence(seq) } // read each signature and add it to the multisig if valid @@ -109,9 +117,8 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) { } signingData := signing.SignerData{ - ChainID: txFactory.ChainID(), - AccountNumber: txFactory.AccountNumber(), - Sequence: txFactory.Sequence(), + ChainID: txFactory.ChainID(), + Sequence: txFactory.Sequence(), } for _, sig := range sigs { @@ -267,12 +274,12 @@ func makeBatchMultisignCmd() func(cmd *cobra.Command, args []string) error { } if !clientCtx.Offline { - accnum, seq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, multisigInfo.GetAddress()) + seq, err := clientCtx.AccountRetriever.GetAccountSequence(clientCtx, multisigInfo.GetAddress()) if err != nil { return err } - txFactory = txFactory.WithAccountNumber(accnum).WithSequence(seq) + txFactory = txFactory.WithSequence(seq) } for i := 0; scanner.Scan(); i++ { @@ -284,9 +291,8 @@ func makeBatchMultisignCmd() func(cmd *cobra.Command, args []string) error { multisigPub := multisigInfo.GetPubKey().(*kmultisig.LegacyAminoPubKey) multisigSig := multisig.NewMultisig(len(multisigPub.PubKeys)) signingData := signing.SignerData{ - ChainID: txFactory.ChainID(), - AccountNumber: txFactory.AccountNumber(), - Sequence: txFactory.Sequence(), + ChainID: txFactory.ChainID(), + Sequence: txFactory.Sequence(), } for _, sig := range signatureBatch { diff --git a/x/auth/client/cli/tx_sign.go b/x/auth/client/cli/tx_sign.go index 77425aaaba..66029022a7 100644 --- a/x/auth/client/cli/tx_sign.go +++ b/x/auth/client/cli/tx_sign.go @@ -195,10 +195,8 @@ be generated via the 'multisign' command. } func preSignCmd(cmd *cobra.Command, _ []string) { - // Conditionally mark the account and sequence numbers required as no RPC - // query will be done. + // Conditionally mark the account sequence required as no RPC query will be done. if offline, _ := cmd.Flags().GetBool(flags.FlagOffline); offline { - cmd.MarkFlagRequired(flags.FlagAccountNumber) cmd.MarkFlagRequired(flags.FlagSequence) } } diff --git a/x/auth/client/cli/validate_sigs.go b/x/auth/client/cli/validate_sigs.go index bc935e8bae..e1156c2cfe 100644 --- a/x/auth/client/cli/validate_sigs.go +++ b/x/auth/client/cli/validate_sigs.go @@ -99,16 +99,15 @@ func printAndValidateSigs( // Validate the actual signature over the transaction bytes since we can // reach out to a full node to query accounts. if !offline && success { - accNum, accSeq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, sigAddr) + accSeq, err := clientCtx.AccountRetriever.GetAccountSequence(clientCtx, sigAddr) if err != nil { cmd.Printf("failed to get account: %s\n", sigAddr) return false } signingData := authsigning.SignerData{ - ChainID: chainID, - AccountNumber: accNum, - Sequence: accSeq, + ChainID: chainID, + Sequence: accSeq, } err = authsigning.VerifySignature(pubKey, signingData, sig.Data, signModeHandler, sigTx) if err != nil { diff --git a/x/auth/client/rest/rest_test.go b/x/auth/client/rest/rest_test.go index ad1f742d44..9b39aa2cb0 100644 --- a/x/auth/client/rest/rest_test.go +++ b/x/auth/client/rest/rest_test.go @@ -364,7 +364,7 @@ func (s *IntegrationTestSuite) TestMultipleSyncBroadcastTxRequests() { } } -func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, accNum, sequence uint64) legacytx.StdTx { +func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, sbh, sequence uint64) legacytx.StdTx { txConfig := legacytx.StdTxConfig{Cdc: s.cfg.LegacyAmino} msg := &types.MsgSend{ @@ -388,7 +388,7 @@ func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, accNum, s WithKeybase(val.ClientCtx.Keyring). WithTxConfig(txConfig). WithSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON). - WithAccountNumber(accNum). + WithSigBlockHeight(sbh). WithSequence(sequence) // sign Tx (offline mode so we can manually set sequence number) @@ -615,9 +615,9 @@ func (s *IntegrationTestSuite) TestLegacyMultisig() { sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String()) - // Does not work in offline mode. + // Offline mode requires --sequence flag. _, err = authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), "--offline", sign1File.Name(), sign2File.Name()) - s.Require().EqualError(err, fmt.Sprintf("couldn't verify signature: unable to verify single signer signature")) + s.Require().EqualError(err, fmt.Sprintf("required flag(s) \"sequence\" not set")) val1.ClientCtx.Offline = false multiSigWith2Signatures, err := authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name()) diff --git a/x/auth/client/tx.go b/x/auth/client/tx.go index a334b61b06..37cb889901 100644 --- a/x/auth/client/tx.go +++ b/x/auth/client/tx.go @@ -143,12 +143,12 @@ func populateAccountFromState( txBldr tx.Factory, clientCtx client.Context, addr sdk.AccAddress, ) (tx.Factory, error) { - num, seq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, addr) + seq, err := clientCtx.AccountRetriever.GetAccountSequence(clientCtx, addr) if err != nil { return txBldr, err } - return txBldr.WithAccountNumber(num).WithSequence(seq), nil + return txBldr.WithSequence(seq), nil } // GetTxEncoder return tx encoder from global sdk configuration if ones is defined. diff --git a/x/auth/client/tx_test.go b/x/auth/client/tx_test.go index 17f657e8d6..afb3ffd88b 100644 --- a/x/auth/client/tx_test.go +++ b/x/auth/client/tx_test.go @@ -139,7 +139,7 @@ func TestBatchScanner_Scan(t *testing.T) { func compareEncoders(t *testing.T, expected sdk.TxEncoder, actual sdk.TxEncoder) { msgs := []sdk.Msg{testdata.NewTestMsg(addr)} - tx := legacytx.NewStdTx(msgs, legacytx.StdFee{}, []legacytx.StdSignature{}, "") + tx := legacytx.NewStdTx(msgs, legacytx.StdFee{}, []legacytx.StdSignature{}, 0, "") defaultEncoderBytes, err := expected(tx) require.NoError(t, err) diff --git a/x/auth/genesis.go b/x/auth/genesis.go index 7281ffd4b9..084ec5ae2f 100644 --- a/x/auth/genesis.go +++ b/x/auth/genesis.go @@ -20,8 +20,7 @@ func InitGenesis(ctx sdk.Context, ak keeper.AccountKeeper, data types.GenesisSta accounts = types.SanitizeGenesisAccounts(accounts) for _, a := range accounts { - acc := ak.NewAccount(ctx, a) - ak.SetAccount(ctx, acc) + ak.SetAccount(ctx, a) } ak.GetModuleAccount(ctx, types.FeeCollectorName) diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index c933a62144..98fa4ebb29 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -13,15 +13,6 @@ func (ak AccountKeeper) NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddre panic(err) } - return ak.NewAccount(ctx, acc) -} - -// NewAccount sets the next account number to a given account interface -func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc types.AccountI) types.AccountI { - if err := acc.SetAccountNumber(ak.GetNextAccountNumber(ctx)); err != nil { - panic(err) - } - return acc } diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 96a7544661..d0c7f2aa5b 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -3,7 +3,6 @@ package keeper import ( "fmt" - gogotypes "github.com/gogo/protobuf/types" "github.com/line/ostracon/libs/log" "github.com/line/lfb-sdk/codec" @@ -16,12 +15,9 @@ import ( // AccountKeeperI is the interface contract that x/auth's keeper implements. type AccountKeeperI interface { - // Return a new account with the next account number and the specified address. Does not save the new account to the store. + // Return a new account with the specified address. Does not save the new account to the store. NewAccountWithAddress(sdk.Context, sdk.AccAddress) types.AccountI - // Return a new account with the next account number. Does not save the new account to the store. - NewAccount(sdk.Context, types.AccountI) types.AccountI - // Retrieve an account from the store. GetAccount(sdk.Context, sdk.AccAddress) types.AccountI @@ -39,9 +35,6 @@ type AccountKeeperI interface { // Fetch the sequence of an account at a specified address. GetSequence(sdk.Context, sdk.AccAddress) (uint64, error) - - // Fetch the next account number, and increment the internal counter. - GetNextAccountNumber(sdk.Context) uint64 } // AccountKeeper encodes/decodes accounts using the go-amino (binary) @@ -109,33 +102,6 @@ func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint6 return acc.GetSequence(), nil } -// GetNextAccountNumber returns and increments the global account number counter. -// If the global account number is not set, it initializes it with value 0. -func (ak AccountKeeper) GetNextAccountNumber(ctx sdk.Context) uint64 { - var accNumber uint64 - store := ctx.KVStore(ak.key) - - bz := store.Get(types.GlobalAccountNumberKey) - if bz == nil { - // initialize the account numbers - accNumber = 0 - } else { - val := gogotypes.UInt64Value{} - - err := ak.cdc.UnmarshalBinaryBare(bz, &val) - if err != nil { - panic(err) - } - - accNumber = val.GetValue() - } - - bz = ak.cdc.MustMarshalBinaryBare(&gogotypes.UInt64Value{Value: accNumber + 1}) - store.Set(types.GlobalAccountNumberKey, bz) - - return accNumber -} - // ValidatePermissions validates that the module account has been granted // permissions within its set of allowed permissions. func (ak AccountKeeper) ValidatePermissions(macc types.ModuleAccountI) error { @@ -188,10 +154,9 @@ func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleNa // create a new module account macc := types.NewEmptyModuleAccount(moduleName, perms...) - maccI := (ak.NewAccount(ctx, macc)).(types.ModuleAccountI) // set the account number - ak.SetModuleAccount(ctx, maccI) + ak.SetModuleAccount(ctx, macc) - return maccI, perms + return macc, perms } // GetModuleAccount gets the module account from the auth account store, if the account does not diff --git a/x/auth/legacy/legacytx/amino_signing.go b/x/auth/legacy/legacytx/amino_signing.go index 5fa13e2ec6..ac9be37c3d 100644 --- a/x/auth/legacy/legacytx/amino_signing.go +++ b/x/auth/legacy/legacytx/amino_signing.go @@ -43,7 +43,7 @@ func (stdTxSignModeHandler) GetSignBytes(mode signingtypes.SignMode, data signin } return StdSignBytes( - data.ChainID, data.AccountNumber, data.Sequence, stdTx.GetTimeoutHeight(), StdFee{Amount: stdTx.GetFee(), Gas: stdTx.GetGas()}, tx.GetMsgs(), stdTx.GetMemo(), + data.ChainID, stdTx.GetSigBlockHeight(), data.Sequence, stdTx.GetTimeoutHeight(), StdFee{Amount: stdTx.GetFee(), Gas: stdTx.GetGas()}, tx.GetMsgs(), stdTx.GetMemo(), ), nil } diff --git a/x/auth/legacy/legacytx/amino_signing_test.go b/x/auth/legacy/legacytx/amino_signing_test.go index fa2c6e63ba..5ab4543f2a 100644 --- a/x/auth/legacy/legacytx/amino_signing_test.go +++ b/x/auth/legacy/legacytx/amino_signing_test.go @@ -31,29 +31,29 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { var ( chainId = "test-chain" - accNum uint64 = 7 + sbh uint64 = 7 seqNum uint64 = 7 timeoutHeight uint64 = 10 ) tx := StdTx{ - Msgs: msgs, - Fee: fee, - Signatures: nil, - Memo: memo, - TimeoutHeight: timeoutHeight, + Msgs: msgs, + Fee: fee, + Signatures: nil, + Memo: memo, + SigBlockHeight: sbh, + TimeoutHeight: timeoutHeight, } handler := stdTxSignModeHandler{} signingData := signing.SignerData{ - ChainID: chainId, - AccountNumber: accNum, - Sequence: seqNum, + ChainID: chainId, + Sequence: seqNum, } signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) require.NoError(t, err) - expectedSignBz := StdSignBytes(chainId, accNum, seqNum, timeoutHeight, fee, msgs, memo) + expectedSignBz := StdSignBytes(chainId, sbh, seqNum, timeoutHeight, fee, msgs, memo) require.Equal(t, expectedSignBz, signBz) diff --git a/x/auth/legacy/legacytx/stdsign.go b/x/auth/legacy/legacytx/stdsign.go index 35c3c09d30..f3281ed069 100644 --- a/x/auth/legacy/legacytx/stdsign.go +++ b/x/auth/legacy/legacytx/stdsign.go @@ -18,30 +18,30 @@ import ( // and the Sequence numbers for each signature (prevent // inchain replay and enforce tx ordering per account). type StdSignDoc struct { - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - TimeoutHeight uint64 `json:"timeout_height,omitempty" yaml:"timeout_height"` - ChainID string `json:"chain_id" yaml:"chain_id"` - Memo string `json:"memo" yaml:"memo"` - Fee json.RawMessage `json:"fee" yaml:"fee"` - Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` + SigBlockHeight uint64 `json:"sig_block_height" yaml:"sig_block_height"` + Sequence uint64 `json:"sequence" yaml:"sequence"` + TimeoutHeight uint64 `json:"timeout_height,omitempty" yaml:"timeout_height"` + ChainID string `json:"chain_id" yaml:"chain_id"` + Memo string `json:"memo" yaml:"memo"` + Fee json.RawMessage `json:"fee" yaml:"fee"` + Msgs []json.RawMessage `json:"msgs" yaml:"msgs"` } // StdSignBytes returns the bytes to sign for a transaction. -func StdSignBytes(chainID string, accnum, sequence, timeout uint64, fee StdFee, msgs []sdk.Msg, memo string) []byte { +func StdSignBytes(chainID string, sbh, sequence, timeout uint64, fee StdFee, msgs []sdk.Msg, memo string) []byte { msgsBytes := make([]json.RawMessage, 0, len(msgs)) for _, msg := range msgs { msgsBytes = append(msgsBytes, json.RawMessage(msg.GetSignBytes())) } bz, err := legacy.Cdc.MarshalJSON(StdSignDoc{ - AccountNumber: accnum, - ChainID: chainID, - Fee: json.RawMessage(fee.Bytes()), - Memo: memo, - Msgs: msgsBytes, - Sequence: sequence, - TimeoutHeight: timeout, + SigBlockHeight: sbh, + ChainID: chainID, + Fee: json.RawMessage(fee.Bytes()), + Memo: memo, + Msgs: msgsBytes, + Sequence: sequence, + TimeoutHeight: timeout, }) if err != nil { panic(err) diff --git a/x/auth/legacy/legacytx/stdsignmsg.go b/x/auth/legacy/legacytx/stdsignmsg.go index 2cd8bceaf7..43a7dcbf41 100644 --- a/x/auth/legacy/legacytx/stdsignmsg.go +++ b/x/auth/legacy/legacytx/stdsignmsg.go @@ -10,18 +10,18 @@ var _ types.UnpackInterfacesMessage = StdSignMsg{} // StdSignMsg is a convenience structure for passing along a Msg with the other // requirements for a StdSignDoc before it is signed. For use in the CLI. type StdSignMsg struct { - ChainID string `json:"chain_id" yaml:"chain_id"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - TimeoutHeight uint64 `json:"timeout_height" yaml:"timeout_height"` - Fee StdFee `json:"fee" yaml:"fee"` - Msgs []sdk.Msg `json:"msgs" yaml:"msgs"` - Memo string `json:"memo" yaml:"memo"` + ChainID string `json:"chain_id" yaml:"chain_id"` + SigBlockHeight uint64 `json:"sign_block_height" yaml:"sign_block_height"` + Sequence uint64 `json:"sequence" yaml:"sequence"` + TimeoutHeight uint64 `json:"timeout_height" yaml:"timeout_height"` + Fee StdFee `json:"fee" yaml:"fee"` + Msgs []sdk.Msg `json:"msgs" yaml:"msgs"` + Memo string `json:"memo" yaml:"memo"` } // get message bytes func (msg StdSignMsg) Bytes() []byte { - return StdSignBytes(msg.ChainID, msg.AccountNumber, msg.Sequence, msg.TimeoutHeight, msg.Fee, msg.Msgs, msg.Memo) + return StdSignBytes(msg.ChainID, msg.SigBlockHeight, msg.Sequence, msg.TimeoutHeight, msg.Fee, msg.Msgs, msg.Memo) } func (msg StdSignMsg) UnpackInterfaces(unpacker types.AnyUnpacker) error { diff --git a/x/auth/legacy/legacytx/stdtx.go b/x/auth/legacy/legacytx/stdtx.go index a7916b1bc3..f8b959cb05 100644 --- a/x/auth/legacy/legacytx/stdtx.go +++ b/x/auth/legacy/legacytx/stdtx.go @@ -128,20 +128,22 @@ func (ss StdSignature) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { // NOTE: the first signature is the fee payer (Signatures must not be nil). // Deprecated type StdTx struct { - Msgs []sdk.Msg `json:"msg" yaml:"msg"` - Fee StdFee `json:"fee" yaml:"fee"` - Signatures []StdSignature `json:"signatures" yaml:"signatures"` - Memo string `json:"memo" yaml:"memo"` - TimeoutHeight uint64 `json:"timeout_height" yaml:"timeout_height"` + Msgs []sdk.Msg `json:"msg" yaml:"msg"` + Fee StdFee `json:"fee" yaml:"fee"` + Signatures []StdSignature `json:"signatures" yaml:"signatures"` + SigBlockHeight uint64 `json:"sig_block_height"` + Memo string `json:"memo" yaml:"memo"` + TimeoutHeight uint64 `json:"timeout_height" yaml:"timeout_height"` } // Deprecated -func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string) StdTx { +func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, sbh uint64, memo string) StdTx { return StdTx{ - Msgs: msgs, - Fee: fee, - Signatures: sigs, - Memo: memo, + Msgs: msgs, + Fee: fee, + Signatures: sigs, + SigBlockHeight: sbh, + Memo: memo, } } @@ -256,6 +258,8 @@ func (tx StdTx) GetPubKeys() []cryptotypes.PubKey { return pks } +func (tx StdTx) GetSigBlockHeight() uint64 { return tx.SigBlockHeight } + // GetGas returns the Gas in StdFee func (tx StdTx) GetGas() uint64 { return tx.Fee.Gas } diff --git a/x/auth/legacy/legacytx/stdtx_builder.go b/x/auth/legacy/legacytx/stdtx_builder.go index 647dd66aad..57358d073e 100644 --- a/x/auth/legacy/legacytx/stdtx_builder.go +++ b/x/auth/legacy/legacytx/stdtx_builder.go @@ -79,6 +79,10 @@ func (s *StdTxBuilder) SetMemo(memo string) { s.Memo = memo } +func (s *StdTxBuilder) SetSigBlockHeight(sbh uint64) { + s.SigBlockHeight = sbh +} + // SetTimeoutHeight sets the transaction's height timeout. func (s *StdTxBuilder) SetTimeoutHeight(height uint64) { s.TimeoutHeight = height diff --git a/x/auth/legacy/legacytx/stdtx_test.go b/x/auth/legacy/legacytx/stdtx_test.go index 455ccb3297..f0dabb4c79 100644 --- a/x/auth/legacy/legacytx/stdtx_test.go +++ b/x/auth/legacy/legacytx/stdtx_test.go @@ -39,10 +39,10 @@ func NewTestStdFee() StdFee { } // Deprecated, use TxBuilder. -func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, accNums []uint64, seqs []uint64, timeout uint64, fee StdFee) sdk.Tx { +func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, sbh []uint64, seqs []uint64, timeout uint64, fee StdFee) sdk.Tx { sigs := make([]StdSignature, len(privs)) for i, priv := range privs { - signBytes := StdSignBytes(ctx.ChainID(), accNums[i], seqs[i], timeout, fee, msgs, "") + signBytes := StdSignBytes(ctx.ChainID(), sbh[i], seqs[i], timeout, fee, msgs, "") sig, err := priv.Sign(signBytes) if err != nil { @@ -52,7 +52,7 @@ func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, acc sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } - tx := NewStdTx(msgs, fee, sigs, "") + tx := NewStdTx(msgs, fee, sigs, 0, "") return tx } @@ -61,7 +61,7 @@ func TestStdTx(t *testing.T) { fee := NewTestStdFee() sigs := []StdSignature{} - tx := NewStdTx(msgs, fee, sigs, "") + tx := NewStdTx(msgs, fee, sigs, 0, "") require.Equal(t, msgs, tx.GetMsgs()) require.Equal(t, sigs, tx.Signatures) @@ -89,11 +89,11 @@ func TestStdSignBytes(t *testing.T) { }{ { args{"1234", 3, 6, 10, defaultFee, []sdk.Msg{testdata.NewTestMsg(addr)}, "memo"}, - fmt.Sprintf("{\"account_number\":\"3\",\"chain_id\":\"1234\",\"fee\":{\"amount\":[{\"amount\":\"150\",\"denom\":\"atom\"}],\"gas\":\"100000\"},\"memo\":\"memo\",\"msgs\":[[\"%s\"]],\"sequence\":\"6\",\"timeout_height\":\"10\"}", addr), + fmt.Sprintf("{\"chain_id\":\"1234\",\"fee\":{\"amount\":[{\"amount\":\"150\",\"denom\":\"atom\"}],\"gas\":\"100000\"},\"memo\":\"memo\",\"msgs\":[[\"%s\"]],\"sequence\":\"6\",\"sig_block_height\":\"3\",\"timeout_height\":\"10\"}", addr), }, { args{"1234", 3, 6, 0, defaultFee, []sdk.Msg{testdata.NewTestMsg(addr)}, "memo"}, - fmt.Sprintf("{\"account_number\":\"3\",\"chain_id\":\"1234\",\"fee\":{\"amount\":[{\"amount\":\"150\",\"denom\":\"atom\"}],\"gas\":\"100000\"},\"memo\":\"memo\",\"msgs\":[[\"%s\"]],\"sequence\":\"6\"}", addr), + fmt.Sprintf("{\"chain_id\":\"1234\",\"fee\":{\"amount\":[{\"amount\":\"150\",\"denom\":\"atom\"}],\"gas\":\"100000\"},\"memo\":\"memo\",\"msgs\":[[\"%s\"]],\"sequence\":\"6\",\"sig_block_height\":\"3\"}", addr), }, } for i, tc := range tests { @@ -171,7 +171,7 @@ func TestDefaultTxEncoder(t *testing.T) { fee := NewTestStdFee() sigs := []StdSignature{} - tx := NewStdTx(msgs, fee, sigs, "") + tx := NewStdTx(msgs, fee, sigs, 0, "") cdcBytes, err := cdc.MarshalBinaryBare(tx) @@ -274,7 +274,7 @@ func TestGetSignaturesV2(t *testing.T) { fee := NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) sig := StdSignature{PubKey: pubKey, Signature: dummy} - stdTx := NewStdTx([]sdk.Msg{testdata.NewTestMsg()}, fee, []StdSignature{sig}, "testsigs") + stdTx := NewStdTx([]sdk.Msg{testdata.NewTestMsg()}, fee, []StdSignature{sig}, 0, "testsigs") sigs, err := stdTx.GetSignaturesV2() require.Nil(t, err) diff --git a/x/auth/module.go b/x/auth/module.go index 9768ea9fee..78e6a64c05 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -72,7 +72,7 @@ func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *r // GetTxCmd returns the root tx command for the auth module. func (AppModuleBasic) GetTxCmd() *cobra.Command { - return nil + return cli.NewTxCmd() } // GetQueryCmd returns the root query command for the auth module. diff --git a/x/auth/signing/handler_map_test.go b/x/auth/signing/handler_map_test.go index 56cc2a67ae..1577c33312 100644 --- a/x/auth/signing/handler_map_test.go +++ b/x/auth/signing/handler_map_test.go @@ -43,26 +43,26 @@ func TestHandlerMap_GetSignBytes(t *testing.T) { }, } - tx := legacytx.StdTx{ - Msgs: msgs, - Fee: fee, - Signatures: nil, - Memo: memo, - } - var ( chainId = "test-chain" - accNum uint64 = 7 + sbh uint64 = 7 seqNum uint64 = 7 ) + tx := legacytx.StdTx{ + Msgs: msgs, + Fee: fee, + Signatures: nil, + SigBlockHeight: sbh, + Memo: memo, + } + handler := MakeTestHandlerMap() aminoJSONHandler := legacytx.NewStdTxSignModeHandler() signingData := signing.SignerData{ - ChainID: chainId, - AccountNumber: accNum, - Sequence: seqNum, + ChainID: chainId, + Sequence: seqNum, } signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) require.NoError(t, err) diff --git a/x/auth/signing/sign_mode_handler.go b/x/auth/signing/sign_mode_handler.go index 0894791871..c0f6fba4f8 100644 --- a/x/auth/signing/sign_mode_handler.go +++ b/x/auth/signing/sign_mode_handler.go @@ -26,9 +26,6 @@ type SignerData struct { // ChainID is the chain that this transaction is targeted ChainID string - // AccountNumber is the account number of the signer - AccountNumber uint64 - // Sequence is the account sequence number of the signer that is used // for replay protection. This field is only useful for Legacy Amino signing, // since in SIGN_MODE_DIRECT the account sequence is already in the signer diff --git a/x/auth/signing/verify_test.go b/x/auth/signing/verify_test.go index 9cfca37415..8165f2536e 100644 --- a/x/auth/signing/verify_test.go +++ b/x/auth/signing/verify_test.go @@ -45,13 +45,13 @@ func TestVerifySignature(t *testing.T) { require.NoError(t, app.BankKeeper.SetBalances(ctx, addr, balances)) msgs := []sdk.Msg{testdata.NewTestMsg(addr)} + sbh := uint64(1) fee := legacytx.NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) signerData := signing.SignerData{ - ChainID: chainId, - AccountNumber: acc.GetAccountNumber(), - Sequence: acc.GetSequence(), + ChainID: chainId, + Sequence: acc.GetSequence(), } - signBytes := legacytx.StdSignBytes(signerData.ChainID, signerData.AccountNumber, signerData.Sequence, 10, fee, msgs, memo) + signBytes := legacytx.StdSignBytes(signerData.ChainID, sbh, signerData.Sequence, 10, fee, msgs, memo) signature, err := priv.Sign(signBytes) require.NoError(t, err) @@ -60,7 +60,7 @@ func TestVerifySignature(t *testing.T) { require.NoError(t, err) handler := MakeTestHandlerMap() - stdTx := legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig}, memo) + stdTx := legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig}, sbh, memo) stdTx.TimeoutHeight = 10 err = signing.VerifySignature(pubKey, signerData, sigV2.Data, handler, stdTx) require.NoError(t, err) @@ -69,7 +69,7 @@ func TestVerifySignature(t *testing.T) { multisigKey := kmultisig.NewLegacyAminoPubKey(2, pkSet) multisignature := multisig.NewMultisig(2) msgs = []sdk.Msg{testdata.NewTestMsg(addr, addr1)} - multiSignBytes := legacytx.StdSignBytes(signerData.ChainID, signerData.AccountNumber, signerData.Sequence, 10, fee, msgs, memo) + multiSignBytes := legacytx.StdSignBytes(signerData.ChainID, sbh, signerData.Sequence, 10, fee, msgs, memo) sig1, err := priv.Sign(multiSignBytes) require.NoError(t, err) @@ -88,7 +88,7 @@ func TestVerifySignature(t *testing.T) { err = multisig.AddSignatureFromPubKey(multisignature, sig2V2.Data, pkSet[1], pkSet) require.NoError(t, err) - stdTx = legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig1, stdSig2}, memo) + stdTx = legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig1, stdSig2}, sbh, memo) stdTx.TimeoutHeight = 10 err = signing.VerifySignature(multisigKey, signerData, multisignature, handler, stdTx) diff --git a/x/auth/simulation/decoder.go b/x/auth/simulation/decoder.go index 52e1cc3acd..768faffc0e 100644 --- a/x/auth/simulation/decoder.go +++ b/x/auth/simulation/decoder.go @@ -4,8 +4,6 @@ import ( "bytes" "fmt" - gogotypes "github.com/gogo/protobuf/types" - "github.com/line/lfb-sdk/codec" "github.com/line/lfb-sdk/types/kv" "github.com/line/lfb-sdk/x/auth/types" @@ -34,13 +32,6 @@ func NewDecodeStore(ak AuthUnmarshaler) func(kvA, kvB kv.Pair) string { return fmt.Sprintf("%v\n%v", accA, accB) - case bytes.Equal(kvA.Key, types.GlobalAccountNumberKey): - var globalAccNumberA, globalAccNumberB gogotypes.UInt64Value - ak.GetCodec().MustUnmarshalBinaryBare(kvA.Value, &globalAccNumberA) - ak.GetCodec().MustUnmarshalBinaryBare(kvB.Value, &globalAccNumberB) - - return fmt.Sprintf("GlobalAccNumberA: %d\nGlobalAccNumberB: %d", globalAccNumberA, globalAccNumberB) - default: panic(fmt.Sprintf("unexpected %s key %X (%s)", types.ModuleName, kvA.Key, kvA.Key)) } diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index d98eccde3b..7da1274869 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -4,7 +4,6 @@ import ( "fmt" "testing" - gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" "github.com/line/lfb-sdk/crypto/keys/ed25519" @@ -22,25 +21,18 @@ var ( func TestDecodeStore(t *testing.T) { app := simapp.Setup(false) - cdc, _ := simapp.MakeCodecs() acc := types.NewBaseAccountWithAddress(delAddr1) dec := simulation.NewDecodeStore(app.AccountKeeper) accBz, err := app.AccountKeeper.MarshalAccount(acc) require.NoError(t, err) - globalAccNumber := gogotypes.UInt64Value{Value: 10} - kvPairs := kv.Pairs{ Pairs: []kv.Pair{ { Key: types.AddressStoreKey(delAddr1), Value: accBz, }, - { - Key: types.GlobalAccountNumberKey, - Value: cdc.MustMarshalBinaryBare(&globalAccNumber), - }, { Key: []byte{0x99}, Value: []byte{0x99}, @@ -52,7 +44,6 @@ func TestDecodeStore(t *testing.T) { expectedLog string }{ {"Account", fmt.Sprintf("%v\n%v", acc, acc)}, - {"GlobalAccNumber", fmt.Sprintf("GlobalAccNumberA: %d\nGlobalAccNumberB: %d", globalAccNumber, globalAccNumber)}, {"other", ""}, } diff --git a/x/auth/simulation/genesis.go b/x/auth/simulation/genesis.go index e865815e4e..bd74fdcba0 100644 --- a/x/auth/simulation/genesis.go +++ b/x/auth/simulation/genesis.go @@ -19,6 +19,7 @@ const ( TxSizeCostPerByte = "tx_size_cost_per_byte" SigVerifyCostED25519 = "sig_verify_cost_ed25519" SigVerifyCostSECP256K1 = "sig_verify_cost_secp256k1" + ValidSigBlockPeriod = "valid_sig_block_period" ) // RandomGenesisAccounts defines the default RandomGenesisAccountsFn used on the SDK. @@ -87,6 +88,10 @@ func GenSigVerifyCostSECP256K1(r *rand.Rand) uint64 { return uint64(simulation.RandIntBetween(r, 500, 1000)) } +func GenValidSigBlockPeriod(r *rand.Rand) uint64 { + return uint64(simulation.RandIntBetween(r, 1, 1000)) +} + // RandomizedGenState generates a random GenesisState for auth func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn types.RandomGenesisAccountsFn) { var maxMemoChars uint64 @@ -119,8 +124,14 @@ func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn type func(r *rand.Rand) { sigVerifyCostSECP256K1 = GenSigVerifyCostSECP256K1(r) }, ) + var validSigBlockPeriod uint64 + simState.AppParams.GetOrGenerate( + simState.Cdc, ValidSigBlockPeriod, &validSigBlockPeriod, simState.Rand, + func(r *rand.Rand) { validSigBlockPeriod = GenValidSigBlockPeriod(r) }, + ) + params := types.NewParams(maxMemoChars, txSigLimit, txSizeCostPerByte, - sigVerifyCostED25519, sigVerifyCostSECP256K1) + sigVerifyCostED25519, sigVerifyCostSECP256K1, validSigBlockPeriod) genesisAccs := randGenAccountsFn(simState) authGenesis := types.NewGenesisState(params, genesisAccs) diff --git a/x/auth/simulation/genesis_test.go b/x/auth/simulation/genesis_test.go index 2140e1de33..218bd5206d 100644 --- a/x/auth/simulation/genesis_test.go +++ b/x/auth/simulation/genesis_test.go @@ -50,6 +50,5 @@ func TestRandomizedGenState(t *testing.T) { require.NoError(t, err) require.Len(t, genAccounts, 3) require.Equal(t, "link1ghekyjucln7y67ntx7cf27m9dpuxxemnqk82wt", genAccounts[2].GetAddress().String()) - require.Equal(t, uint64(0), genAccounts[2].GetAccountNumber()) require.Equal(t, uint64(0), genAccounts[2].GetSequence()) } diff --git a/x/auth/testutil/suite.go b/x/auth/testutil/suite.go index cbe7f9bd49..297286ed32 100644 --- a/x/auth/testutil/suite.go +++ b/x/auth/testutil/suite.go @@ -128,9 +128,8 @@ func (s *TxConfigTestSuite) TestTxBuilderSetSignatures() { // sign transaction signerData := signing.SignerData{ - ChainID: "test", - AccountNumber: 1, - Sequence: seq1, + ChainID: "test", + Sequence: seq1, } signBytes, err := signModeHandler.GetSignBytes(signModeHandler.DefaultMode(), signerData, sigTx) s.Require().NoError(err) @@ -138,9 +137,8 @@ func (s *TxConfigTestSuite) TestTxBuilderSetSignatures() { s.Require().NoError(err) signerData = signing.SignerData{ - ChainID: "test", - AccountNumber: 3, - Sequence: mseq, + ChainID: "test", + Sequence: mseq, } mSignBytes, err := signModeHandler.GetSignBytes(signModeHandler.DefaultMode(), signerData, sigTx) s.Require().NoError(err) diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index c7eb8b02dc..a4d2f0046b 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -153,6 +153,10 @@ func (w *wrapper) FeeGranter() sdk.AccAddress { return nil } +func (w *wrapper) GetSigBlockHeight() uint64 { + return w.tx.Body.SigBlockHeight +} + func (w *wrapper) GetMemo() string { return w.tx.Body.Memo } @@ -232,6 +236,10 @@ func (w *wrapper) SetMemo(memo string) { w.bodyBz = nil } +func (w *wrapper) SetSigBlockHeight(sbh uint64) { + w.tx.Body.SigBlockHeight = sbh +} + func (w *wrapper) SetGasLimit(limit uint64) { if w.tx.AuthInfo.Fee == nil { w.tx.AuthInfo.Fee = &tx.Fee{} diff --git a/x/auth/tx/direct.go b/x/auth/tx/direct.go index f201688f8f..8d10fd8911 100644 --- a/x/auth/tx/direct.go +++ b/x/auth/tx/direct.go @@ -39,17 +39,16 @@ func (signModeDirectHandler) GetSignBytes(mode signingtypes.SignMode, data signi bodyBz := protoTx.getBodyBytes() authInfoBz := protoTx.getAuthInfoBytes() - return DirectSignBytes(bodyBz, authInfoBz, data.ChainID, data.AccountNumber) + return DirectSignBytes(bodyBz, authInfoBz, data.ChainID) } // DirectSignBytes returns the SIGN_MODE_DIRECT sign bytes for the provided TxBody bytes, AuthInfo bytes, chain ID, -// account number and sequence. -func DirectSignBytes(bodyBytes, authInfoBytes []byte, chainID string, accnum uint64) ([]byte, error) { +// and sequence. +func DirectSignBytes(bodyBytes, authInfoBytes []byte, chainID string) ([]byte, error) { signDoc := types.SignDoc{ BodyBytes: bodyBytes, AuthInfoBytes: authInfoBytes, ChainId: chainID, - AccountNumber: accnum, } return signDoc.Marshal() } diff --git a/x/auth/tx/direct_test.go b/x/auth/tx/direct_test.go index 1548061bfd..ed951f9837 100644 --- a/x/auth/tx/direct_test.go +++ b/x/auth/tx/direct_test.go @@ -69,8 +69,7 @@ func TestDirectModeHandler(t *testing.T) { require.Len(t, modeHandler.Modes(), 1) signingData := signing.SignerData{ - ChainID: "test-chain", - AccountNumber: 1, + ChainID: "test-chain", } signBytes, err := modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, txBuilder.GetTx()) @@ -103,7 +102,6 @@ func TestDirectModeHandler(t *testing.T) { t.Log("verify GetSignBytes with generating sign bytes by marshaling SignDoc") signDoc := txtypes.SignDoc{ - AccountNumber: 1, AuthInfoBytes: authInfoBytes, BodyBytes: bodyBytes, ChainId: "test-chain", @@ -149,8 +147,9 @@ func TestDirectModeHandler_nonDIRECT_MODE(t *testing.T) { type nonProtoTx int -func (npt *nonProtoTx) GetMsgs() []sdk.Msg { return nil } -func (npt *nonProtoTx) ValidateBasic() error { return nil } +func (npt *nonProtoTx) GetMsgs() []sdk.Msg { return nil } +func (npt *nonProtoTx) ValidateBasic() error { return nil } +func (npt *nonProtoTx) GetSigBlockHeight() uint64 { return 0 } var _ sdk.Tx = (*nonProtoTx)(nil) diff --git a/x/auth/tx/legacy_amino_json.go b/x/auth/tx/legacy_amino_json.go index 2c44541dc8..68abda7601 100644 --- a/x/auth/tx/legacy_amino_json.go +++ b/x/auth/tx/legacy_amino_json.go @@ -47,7 +47,7 @@ func (s signModeLegacyAminoJSONHandler) GetSignBytes(mode signingtypes.SignMode, } return legacytx.StdSignBytes( - data.ChainID, data.AccountNumber, data.Sequence, protoTx.GetTimeoutHeight(), + data.ChainID, tx.GetSigBlockHeight(), data.Sequence, protoTx.GetTimeoutHeight(), legacytx.StdFee{Amount: protoTx.GetFee(), Gas: protoTx.GetGas()}, tx.GetMsgs(), protoTx.GetMemo(), ), nil diff --git a/x/auth/tx/legacy_amino_json_test.go b/x/auth/tx/legacy_amino_json_test.go index 6f924cffcd..158ded4599 100644 --- a/x/auth/tx/legacy_amino_json_test.go +++ b/x/auth/tx/legacy_amino_json_test.go @@ -21,6 +21,7 @@ var ( gas = uint64(10000) msg = testdata.NewTestMsg(addr1, addr2) memo = "foo" + sbh = uint64(1) timeout = uint64(10) ) @@ -28,6 +29,7 @@ func buildTx(t *testing.T, bldr *wrapper) { bldr.SetFeeAmount(coins) bldr.SetGasLimit(gas) bldr.SetMemo(memo) + bldr.SetSigBlockHeight(sbh) bldr.SetTimeoutHeight(timeout) require.NoError(t, bldr.SetMsgs(msg)) } @@ -39,20 +41,18 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { var ( chainId = "test-chain" - accNum uint64 = 7 seqNum uint64 = 7 ) handler := signModeLegacyAminoJSONHandler{} signingData := signing.SignerData{ ChainID: chainId, - AccountNumber: accNum, Sequence: seqNum, } signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) require.NoError(t, err) - expectedSignBz := legacytx.StdSignBytes(chainId, accNum, seqNum, timeout, legacytx.StdFee{ + expectedSignBz := legacytx.StdSignBytes(chainId, sbh, seqNum, timeout, legacytx.StdFee{ Amount: coins, Gas: gas, }, []sdk.Msg{msg}, memo) diff --git a/x/auth/types/account.go b/x/auth/types/account.go index acf6e3075d..72f0c2285b 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -27,11 +27,10 @@ var ( // NewBaseAccount creates a new BaseAccount object //nolint:interfacer -func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNumber, sequence uint64) *BaseAccount { +func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, sequence uint64) *BaseAccount { acc := &BaseAccount{ - Address: address.String(), - AccountNumber: accountNumber, - Sequence: sequence, + Address: address.String(), + Sequence: sequence, } err := acc.SetPubKey(pubKey) @@ -95,17 +94,6 @@ func (acc *BaseAccount) SetPubKey(pubKey cryptotypes.PubKey) error { return err } -// GetAccountNumber - Implements AccountI -func (acc BaseAccount) GetAccountNumber() uint64 { - return acc.AccountNumber -} - -// SetAccountNumber - Implements AccountI -func (acc *BaseAccount) SetAccountNumber(accNumber uint64) error { - acc.AccountNumber = accNumber - return nil -} - // GetSequence - Implements sdk.AccountI. func (acc BaseAccount) GetSequence() uint64 { return acc.Sequence @@ -236,12 +224,11 @@ func (ma ModuleAccount) Validate() error { } type moduleAccountPretty struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - PubKey string `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - Name string `json:"name" yaml:"name"` - Permissions []string `json:"permissions" yaml:"permissions"` + Address sdk.AccAddress `json:"address" yaml:"address"` + PubKey string `json:"public_key" yaml:"public_key"` + Sequence uint64 `json:"sequence" yaml:"sequence"` + Name string `json:"name" yaml:"name"` + Permissions []string `json:"permissions" yaml:"permissions"` } func (ma ModuleAccount) String() string { @@ -257,12 +244,11 @@ func (ma ModuleAccount) MarshalYAML() (interface{}, error) { } bs, err := yaml.Marshal(moduleAccountPretty{ - Address: accAddr, - PubKey: "", - AccountNumber: ma.AccountNumber, - Sequence: ma.Sequence, - Name: ma.Name, - Permissions: ma.Permissions, + Address: accAddr, + PubKey: "", + Sequence: ma.Sequence, + Name: ma.Name, + Permissions: ma.Permissions, }) if err != nil { @@ -280,12 +266,11 @@ func (ma ModuleAccount) MarshalJSON() ([]byte, error) { } return json.Marshal(moduleAccountPretty{ - Address: accAddr, - PubKey: "", - AccountNumber: ma.AccountNumber, - Sequence: ma.Sequence, - Name: ma.Name, - Permissions: ma.Permissions, + Address: accAddr, + PubKey: "", + Sequence: ma.Sequence, + Name: ma.Name, + Permissions: ma.Permissions, }) } @@ -296,7 +281,7 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { return err } - ma.BaseAccount = NewBaseAccount(alias.Address, nil, alias.AccountNumber, alias.Sequence) + ma.BaseAccount = NewBaseAccount(alias.Address, nil, alias.Sequence) ma.Name = alias.Name ma.Permissions = alias.Permissions @@ -305,7 +290,7 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { // AccountI is an interface used to store coins at a given address within state. // It presumes a notion of sequence numbers for replay protection, -// a notion of account numbers for replay protection for previously pruned accounts, +// a notion of sig block height for replay protection for previously pruned accounts, // and a pubkey for authentication purposes. // // Many complex conditions can be used in the concrete struct which implements AccountI. @@ -318,9 +303,6 @@ type AccountI interface { GetPubKey() cryptotypes.PubKey // can return nil. SetPubKey(cryptotypes.PubKey) error - GetAccountNumber() uint64 - SetAccountNumber(uint64) error - GetSequence() uint64 SetSequence(uint64) error diff --git a/x/auth/types/account_retriever.go b/x/auth/types/account_retriever.go index de64c380e4..afe9b84c73 100644 --- a/x/auth/types/account_retriever.go +++ b/x/auth/types/account_retriever.go @@ -5,6 +5,7 @@ import ( "fmt" "strconv" + "github.com/line/lfb-sdk/client/grpc/tmservice" grpc "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -29,6 +30,15 @@ func (ar AccountRetriever) GetAccount(clientCtx client.Context, addr sdk.AccAddr return account, err } +func (ar AccountRetriever) GetLatestHeight(clientCtx client.Context) (uint64, error) { + queryClient := tmservice.NewServiceClient(clientCtx) + res, err := queryClient.GetLatestBlock(context.Background(), &tmservice.GetLatestBlockRequest{}) + if err != nil { + return 0, err + } + return uint64(res.Block.Header.Height), nil +} + // GetAccountWithHeight queries for an account given an address. Returns the // height of the query with the account. An error is returned if the query // or decoding fails. @@ -69,13 +79,13 @@ func (ar AccountRetriever) EnsureExists(clientCtx client.Context, addr sdk.AccAd return nil } -// GetAccountNumberSequence returns sequence and account number for the given address. +// GetAccountSequence returns sequence for the given address. // It returns an error if the account couldn't be retrieved from the state. -func (ar AccountRetriever) GetAccountNumberSequence(clientCtx client.Context, addr sdk.AccAddress) (uint64, uint64, error) { +func (ar AccountRetriever) GetAccountSequence(clientCtx client.Context, addr sdk.AccAddress) (uint64, error) { acc, err := ar.GetAccount(clientCtx, addr) if err != nil { - return 0, 0, err + return 0, err } - return acc.GetAccountNumber(), acc.GetSequence(), nil + return acc.GetSequence(), nil } diff --git a/x/auth/types/account_retriever_test.go b/x/auth/types/account_retriever_test.go index 12aefb8564..b874e1848e 100644 --- a/x/auth/types/account_retriever_test.go +++ b/x/auth/types/account_retriever_test.go @@ -36,8 +36,7 @@ func TestAccountRetriever(t *testing.T) { require.NoError(t, ar.EnsureExists(clientCtx, val.Address)) - accNum, accSeq, err := ar.GetAccountNumberSequence(clientCtx, val.Address) + accSeq, err := ar.GetAccountSequence(clientCtx, val.Address) require.NoError(t, err) - require.Equal(t, accNum, uint64(0)) require.Equal(t, accSeq, uint64(1)) } diff --git a/x/auth/types/account_test.go b/x/auth/types/account_test.go index 47e26bdd07..9829e88f87 100644 --- a/x/auth/types/account_test.go +++ b/x/auth/types/account_test.go @@ -84,7 +84,7 @@ func TestBaseAccountMarshal(t *testing.T) { func TestGenesisAccountValidate(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) - baseAcc := types.NewBaseAccount(addr, pubkey, 0, 0) + baseAcc := types.NewBaseAccount(addr, pubkey, 0) tests := []struct { name string @@ -98,7 +98,7 @@ func TestGenesisAccountValidate(t *testing.T) { }, { "invalid base valid account", - types.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), + types.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0), true, }, } @@ -118,7 +118,7 @@ func TestModuleAccountMarshalYAML(t *testing.T) { bs, err := yaml.Marshal(moduleAcc) require.NoError(t, err) - want := "|\n address: link1n7rdpqvgf37ktx30a2sv2kkszk3m7ncma6dpv3\n public_key: \"\"\n account_number: 0\n sequence: 0\n name: test\n permissions:\n - minter\n - burner\n - staking\n" + want := "|\n address: link1n7rdpqvgf37ktx30a2sv2kkszk3m7ncma6dpv3\n public_key: \"\"\n sequence: 0\n name: test\n permissions:\n - minter\n - burner\n - staking\n" require.Equal(t, want, string(bs)) } @@ -147,7 +147,7 @@ func TestHasPermissions(t *testing.T) { func TestValidate(t *testing.T) { addr := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address()) - baseAcc := types.NewBaseAccount(addr, nil, 0, 0) + baseAcc := types.NewBaseAccount(addr, nil, 0) tests := []struct { name string acc types.GenesisAccount @@ -181,7 +181,7 @@ func TestValidate(t *testing.T) { func TestModuleAccountJSON(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) - baseAcc := types.NewBaseAccount(addr, nil, 10, 50) + baseAcc := types.NewBaseAccount(addr, nil, 50) acc := types.NewModuleAccount(baseAcc, "test", "burner") bz, err := json.Marshal(acc) @@ -199,7 +199,7 @@ func TestModuleAccountJSON(t *testing.T) { func TestGenesisAccountsContains(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) - acc := types.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0) + acc := types.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0) genAccounts := types.GenesisAccounts{} require.False(t, genAccounts.Contains(acc.GetAddress())) diff --git a/x/auth/types/auth.pb.go b/x/auth/types/auth.pb.go index 6bbf8ac0dd..1d5f565bf3 100644 --- a/x/auth/types/auth.pb.go +++ b/x/auth/types/auth.pb.go @@ -29,10 +29,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // for basic account functionality. Any custom account type should extend this // type for additional functionality (e.g. vesting). type BaseAccount struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - PubKey *types.Any `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"public_key,omitempty" yaml:"public_key"` - AccountNumber uint64 `protobuf:"varint,3,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty" yaml:"account_number"` - Sequence uint64 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + PubKey *types.Any `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"public_key,omitempty" yaml:"public_key"` + Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` } func (m *BaseAccount) Reset() { *m = BaseAccount{} } @@ -113,6 +112,7 @@ type Params struct { TxSizeCostPerByte uint64 `protobuf:"varint,3,opt,name=tx_size_cost_per_byte,json=txSizeCostPerByte,proto3" json:"tx_size_cost_per_byte,omitempty" yaml:"tx_size_cost_per_byte"` SigVerifyCostED25519 uint64 `protobuf:"varint,4,opt,name=sig_verify_cost_ed25519,json=sigVerifyCostEd25519,proto3" json:"sig_verify_cost_ed25519,omitempty" yaml:"sig_verify_cost_ed25519"` SigVerifyCostSecp256k1 uint64 `protobuf:"varint,5,opt,name=sig_verify_cost_secp256k1,json=sigVerifyCostSecp256k1,proto3" json:"sig_verify_cost_secp256k1,omitempty" yaml:"sig_verify_cost_secp256k1"` + ValidSigBlockPeriod uint64 `protobuf:"varint,6,opt,name=valid_sig_block_period,json=validSigBlockPeriod,proto3" json:"valid_sig_block_period,omitempty" yaml:"valid_sig_block_period"` } func (m *Params) Reset() { *m = Params{} } @@ -182,6 +182,13 @@ func (m *Params) GetSigVerifyCostSecp256k1() uint64 { return 0 } +func (m *Params) GetValidSigBlockPeriod() uint64 { + if m != nil { + return m.ValidSigBlockPeriod + } + return 0 +} + func init() { proto.RegisterType((*BaseAccount)(nil), "lfb.auth.v1beta1.BaseAccount") proto.RegisterType((*ModuleAccount)(nil), "lfb.auth.v1beta1.ModuleAccount") @@ -191,50 +198,51 @@ func init() { func init() { proto.RegisterFile("lfb/auth/v1beta1/auth.proto", fileDescriptor_f89657c3058cd869) } var fileDescriptor_f89657c3058cd869 = []byte{ - // 678 bytes of a gzipped FileDescriptorProto + // 689 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x3d, 0x4f, 0xdb, 0x5a, - 0x18, 0x8e, 0x6f, 0x72, 0xf9, 0x38, 0x01, 0x74, 0x31, 0x01, 0x9c, 0x70, 0xaf, 0x1d, 0x59, 0x77, - 0xc8, 0xd0, 0xd8, 0x4a, 0x2a, 0x2a, 0x91, 0x01, 0x15, 0xd3, 0x0e, 0xa8, 0x05, 0x21, 0x23, 0x75, - 0xa8, 0x5a, 0x59, 0xc7, 0xce, 0x89, 0xb1, 0xf0, 0xf1, 0x31, 0x3e, 0xc7, 0x28, 0xe6, 0x17, 0x74, - 0xec, 0xd8, 0x91, 0x1f, 0xc1, 0x0f, 0xe8, 0xd8, 0x11, 0x31, 0x75, 0x72, 0xab, 0xb0, 0x54, 0x1d, - 0xb3, 0x57, 0xaa, 0xe2, 0xe3, 0x84, 0x04, 0xd1, 0xed, 0x3c, 0xef, 0xf3, 0xbc, 0xcf, 0xfb, 0x95, - 0x18, 0x6c, 0xf9, 0x3d, 0x5b, 0x87, 0x31, 0x3b, 0xd5, 0x2f, 0x5a, 0x36, 0x62, 0xb0, 0x95, 0x01, - 0x2d, 0x8c, 0x08, 0x23, 0xe2, 0x3f, 0x7e, 0xcf, 0xd6, 0x32, 0x9c, 0x93, 0xb5, 0xaa, 0x43, 0x28, - 0x26, 0xd4, 0xca, 0x78, 0x9d, 0x03, 0x2e, 0xae, 0x55, 0x5c, 0xe2, 0x12, 0x1e, 0x1f, 0xbd, 0xf2, - 0x68, 0xd5, 0x25, 0xc4, 0xf5, 0x91, 0x9e, 0x21, 0x3b, 0xee, 0xe9, 0x30, 0x48, 0x38, 0xa5, 0xfe, - 0x12, 0x40, 0xd9, 0x80, 0x14, 0xed, 0x39, 0x0e, 0x89, 0x03, 0x26, 0x4a, 0x60, 0x1e, 0x76, 0xbb, - 0x11, 0xa2, 0x54, 0x12, 0xea, 0x42, 0x63, 0xd1, 0x1c, 0x43, 0xf1, 0x1d, 0x98, 0x0f, 0x63, 0xdb, - 0x3a, 0x43, 0x89, 0xf4, 0x57, 0x5d, 0x68, 0x94, 0xdb, 0x15, 0x8d, 0xdb, 0x6a, 0x63, 0x5b, 0x6d, - 0x2f, 0x48, 0x8c, 0xe6, 0xcf, 0x54, 0xa9, 0x84, 0xb1, 0xed, 0x7b, 0xce, 0x48, 0xfb, 0x84, 0x60, - 0x8f, 0x21, 0x1c, 0xb2, 0x64, 0x98, 0x2a, 0xab, 0x09, 0xc4, 0x7e, 0x47, 0xbd, 0x67, 0x55, 0x73, - 0x2e, 0x8c, 0xed, 0x57, 0x28, 0x11, 0x9f, 0x83, 0x15, 0xc8, 0x5b, 0xb0, 0x82, 0x18, 0xdb, 0x28, - 0x92, 0x8a, 0x75, 0xa1, 0x51, 0x32, 0xaa, 0xc3, 0x54, 0x59, 0xe7, 0x69, 0xb3, 0xbc, 0x6a, 0x2e, - 0xe7, 0x81, 0xa3, 0x0c, 0x8b, 0x35, 0xb0, 0x40, 0xd1, 0x79, 0x8c, 0x02, 0x07, 0x49, 0xa5, 0x51, - 0xae, 0x39, 0xc1, 0x1d, 0xe9, 0xc3, 0x95, 0x52, 0xf8, 0x74, 0xa5, 0x14, 0x7e, 0x5c, 0x29, 0x85, - 0xdb, 0xeb, 0xe6, 0x42, 0x3e, 0xee, 0x81, 0xfa, 0x59, 0x00, 0xcb, 0x87, 0xa4, 0x1b, 0xfb, 0x93, - 0x0d, 0xbc, 0x07, 0x4b, 0x36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b, 0x9e, + 0x80, 0xf5, 0x73, 0xe8, 0xe1, 0x2e, 0xbf, 0xb0, 0xed, 0x11, 0xa7, 0x9f, 0x5d, 0x07, 0x93, 0xae, + 0x54, 0xe2, 0x7d, 0x1f, 0xa7, 0x89, 0xb2, 0x9d, 0xa7, 0xcf, 0xf7, 0xa9, 0xe6, 0x1a, 0x17, 0x3a, + 0xd8, 0x35, 0x32, 0xfa, 0x98, 0xb3, 0xed, 0xa5, 0xf1, 0x87, 0x20, 0x18, 0x7b, 0xdf, 0x46, 0xb2, + 0x70, 0x3d, 0x92, 0x85, 0x1f, 0x23, 0x59, 0xf8, 0x78, 0x2b, 0x17, 0xae, 0x6f, 0xe5, 0xc2, 0xf7, + 0x5b, 0xb9, 0xf0, 0xf6, 0x89, 0x8b, 0xd9, 0x69, 0x64, 0x6b, 0x0e, 0xf1, 0x75, 0x0f, 0x0f, 0x90, + 0xee, 0xf5, 0xec, 0x06, 0xed, 0xf6, 0xf5, 0x61, 0xfe, 0x97, 0x61, 0x71, 0x80, 0xa8, 0x5d, 0xe2, + 0xdf, 0xed, 0xb3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x78, 0x3d, 0x9d, 0xdb, 0x7e, 0x04, 0x00, + 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -271,6 +279,9 @@ func (this *Params) Equal(that interface{}) bool { if this.SigVerifyCostSecp256k1 != that1.SigVerifyCostSecp256k1 { return false } + if this.ValidSigBlockPeriod != that1.ValidSigBlockPeriod { + return false + } return true } func (m *BaseAccount) Marshal() (dAtA []byte, err error) { @@ -296,11 +307,6 @@ func (m *BaseAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.Sequence != 0 { i = encodeVarintAuth(dAtA, i, uint64(m.Sequence)) i-- - dAtA[i] = 0x20 - } - if m.AccountNumber != 0 { - i = encodeVarintAuth(dAtA, i, uint64(m.AccountNumber)) - i-- dAtA[i] = 0x18 } if m.PubKey != nil { @@ -396,6 +402,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ValidSigBlockPeriod != 0 { + i = encodeVarintAuth(dAtA, i, uint64(m.ValidSigBlockPeriod)) + i-- + dAtA[i] = 0x30 + } if m.SigVerifyCostSecp256k1 != 0 { i = encodeVarintAuth(dAtA, i, uint64(m.SigVerifyCostSecp256k1)) i-- @@ -449,9 +460,6 @@ func (m *BaseAccount) Size() (n int) { l = m.PubKey.Size() n += 1 + l + sovAuth(uint64(l)) } - if m.AccountNumber != 0 { - n += 1 + sovAuth(uint64(m.AccountNumber)) - } if m.Sequence != 0 { n += 1 + sovAuth(uint64(m.Sequence)) } @@ -502,6 +510,9 @@ func (m *Params) Size() (n int) { if m.SigVerifyCostSecp256k1 != 0 { n += 1 + sovAuth(uint64(m.SigVerifyCostSecp256k1)) } + if m.ValidSigBlockPeriod != 0 { + n += 1 + sovAuth(uint64(m.ValidSigBlockPeriod)) + } return n } @@ -609,25 +620,6 @@ func (m *BaseAccount) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType) - } - m.AccountNumber = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAuth - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.AccountNumber |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } @@ -941,6 +933,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidSigBlockPeriod", wireType) + } + m.ValidSigBlockPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuth + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidSigBlockPeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipAuth(dAtA[iNdEx:]) diff --git a/x/auth/types/genesis.go b/x/auth/types/genesis.go index 52c704d847..e174fc357d 100644 --- a/x/auth/types/genesis.go +++ b/x/auth/types/genesis.go @@ -76,7 +76,7 @@ func ValidateGenesis(data GenesisState) error { // SanitizeGenesisAccounts sorts accounts and coin sets. func SanitizeGenesisAccounts(genAccs GenesisAccounts) GenesisAccounts { sort.Slice(genAccs, func(i, j int) bool { - return genAccs[i].GetAccountNumber() < genAccs[j].GetAccountNumber() + return genAccs[i].GetAddress().String() < genAccs[j].GetAddress().String() }) return genAccs diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index da7c8672e8..233334c20a 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -16,20 +16,15 @@ import ( func TestSanitize(t *testing.T) { addr1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) authAcc1 := types.NewBaseAccountWithAddress(addr1) - err := authAcc1.SetAccountNumber(1) - require.NoError(t, err) addr2 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) authAcc2 := types.NewBaseAccountWithAddress(addr2) genAccs := types.GenesisAccounts{authAcc1, authAcc2} - require.True(t, genAccs[0].GetAccountNumber() > genAccs[1].GetAccountNumber()) - require.Equal(t, genAccs[1].GetAddress(), addr2) genAccs = types.SanitizeGenesisAccounts(genAccs) - require.False(t, genAccs[0].GetAccountNumber() > genAccs[1].GetAccountNumber()) - require.Equal(t, genAccs[1].GetAddress(), addr1) + require.False(t, genAccs[0].GetAddress().String() > genAccs[1].GetAddress().String()) } var ( diff --git a/x/auth/types/keys.go b/x/auth/types/keys.go index e0af40cb6d..70bd8542ca 100644 --- a/x/auth/types/keys.go +++ b/x/auth/types/keys.go @@ -24,9 +24,6 @@ const ( var ( // AddressStoreKeyPrefix prefix for account-by-address store AddressStoreKeyPrefix = []byte{0x01} - - // param key for global account number - GlobalAccountNumberKey = []byte("globalAccountNumber") ) // AddressStoreKey turn an address to key used to get it from the account store diff --git a/x/auth/types/params.go b/x/auth/types/params.go index bd1c4fa3ba..15bd4a44b1 100644 --- a/x/auth/types/params.go +++ b/x/auth/types/params.go @@ -15,6 +15,7 @@ const ( DefaultTxSizeCostPerByte uint64 = 10 DefaultSigVerifyCostED25519 uint64 = 590 DefaultSigVerifyCostSecp256k1 uint64 = 1000 + DefaultValidSigBlockPeriod uint64 = 100 ) // Parameter keys @@ -24,13 +25,15 @@ var ( KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte") KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519") KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1") + KeyValidSigBlockPeriod = []byte("ValidSigBlockPeriod") ) var _ paramtypes.ParamSet = &Params{} // NewParams creates a new Params object func NewParams( - maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64, + maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1, + validSigBlockPeriod uint64, ) Params { return Params{ MaxMemoCharacters: maxMemoCharacters, @@ -38,6 +41,7 @@ func NewParams( TxSizeCostPerByte: txSizeCostPerByte, SigVerifyCostED25519: sigVerifyCostED25519, SigVerifyCostSecp256k1: sigVerifyCostSecp256k1, + ValidSigBlockPeriod: validSigBlockPeriod, } } @@ -56,6 +60,7 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyTxSizeCostPerByte, &p.TxSizeCostPerByte, validateTxSizeCostPerByte), paramtypes.NewParamSetPair(KeySigVerifyCostED25519, &p.SigVerifyCostED25519, validateSigVerifyCostED25519), paramtypes.NewParamSetPair(KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1, validateSigVerifyCostSecp256k1), + paramtypes.NewParamSetPair(KeyValidSigBlockPeriod, &p.ValidSigBlockPeriod, validateValidSigBlockPeriod), } } @@ -67,6 +72,7 @@ func DefaultParams() Params { TxSizeCostPerByte: DefaultTxSizeCostPerByte, SigVerifyCostED25519: DefaultSigVerifyCostED25519, SigVerifyCostSecp256k1: DefaultSigVerifyCostSecp256k1, + ValidSigBlockPeriod: DefaultValidSigBlockPeriod, } } @@ -115,6 +121,19 @@ func validateSigVerifyCostSecp256k1(i interface{}) error { return nil } +func validateValidSigBlockPeriod(i interface{}) error { + v, ok := i.(uint64) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if v == 0 { + return fmt.Errorf("invalid validSigBlockPeriod: %d", v) + } + + return nil +} + func validateMaxMemoCharacters(i interface{}) error { v, ok := i.(uint64) if !ok { @@ -158,6 +177,8 @@ func (p Params) Validate() error { if err := validateTxSizeCostPerByte(p.TxSizeCostPerByte); err != nil { return err } - + if err := validateValidSigBlockPeriod(p.ValidSigBlockPeriod); err != nil { + return err + } return nil } diff --git a/x/auth/types/params_test.go b/x/auth/types/params_test.go index c878edbc06..7750509374 100644 --- a/x/auth/types/params_test.go +++ b/x/auth/types/params_test.go @@ -26,15 +26,17 @@ func TestParams_Validate(t *testing.T) { }{ {"default params", types.DefaultParams(), nil}, {"invalid tx signature limit", types.NewParams(types.DefaultMaxMemoCharacters, 0, types.DefaultTxSizeCostPerByte, - types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid tx signature limit: 0")}, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1, types.DefaultValidSigBlockPeriod), fmt.Errorf("invalid tx signature limit: 0")}, {"invalid ED25519 signature verification cost", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, - 0, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid ED25519 signature verification cost: 0")}, + 0, types.DefaultSigVerifyCostSecp256k1, types.DefaultValidSigBlockPeriod), fmt.Errorf("invalid ED25519 signature verification cost: 0")}, {"invalid SECK256k1 signature verification cost", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, - types.DefaultSigVerifyCostED25519, 0), fmt.Errorf("invalid SECK256k1 signature verification cost: 0")}, + types.DefaultSigVerifyCostED25519, 0, types.DefaultValidSigBlockPeriod), fmt.Errorf("invalid SECK256k1 signature verification cost: 0")}, {"invalid max memo characters", types.NewParams(0, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, - types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid max memo characters: 0")}, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1, types.DefaultValidSigBlockPeriod), fmt.Errorf("invalid max memo characters: 0")}, {"invalid tx size cost per byte", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, 0, - types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid tx size cost per byte: 0")}, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1, types.DefaultValidSigBlockPeriod), fmt.Errorf("invalid tx size cost per byte: 0")}, + {"invalid valid sig block period", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1, 0), fmt.Errorf("invalid validSigBlockPeriod: 0")}, } for _, tt := range tests { tt := tt diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index daf3fe3440..55f40c3b96 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -164,7 +164,6 @@ func (bva BaseVestingAccount) Validate() error { type vestingAccountYAML struct { Address sdk.AccAddress `json:"address" yaml:"address"` PubKey string `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` Sequence uint64 `json:"sequence" yaml:"sequence"` OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` @@ -190,7 +189,6 @@ func (bva BaseVestingAccount) MarshalYAML() (interface{}, error) { alias := vestingAccountYAML{ Address: accAddr, - AccountNumber: bva.AccountNumber, Sequence: bva.Sequence, OriginalVesting: bva.OriginalVesting, DelegatedFree: bva.DelegatedFree, @@ -318,7 +316,6 @@ func (cva ContinuousVestingAccount) MarshalYAML() (interface{}, error) { alias := vestingAccountYAML{ Address: accAddr, - AccountNumber: cva.AccountNumber, Sequence: cva.Sequence, OriginalVesting: cva.OriginalVesting, DelegatedFree: cva.DelegatedFree, @@ -476,7 +473,6 @@ func (pva PeriodicVestingAccount) MarshalYAML() (interface{}, error) { alias := vestingAccountYAML{ Address: accAddr, - AccountNumber: pva.AccountNumber, Sequence: pva.Sequence, OriginalVesting: pva.OriginalVesting, DelegatedFree: pva.DelegatedFree, diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index 58e68db763..f7da227131 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -581,7 +581,7 @@ func TestTrackUndelegationPeriodicVestingAcc(t *testing.T) { func TestGenesisAccountValidate(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0, 0) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0) initialVesting := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 50)) baseVestingWithCoins := types.NewBaseVestingAccount(baseAcc, initialVesting, 100) tests := []struct { @@ -596,7 +596,7 @@ func TestGenesisAccountValidate(t *testing.T) { }, { "invalid base valid account", - authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), + authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0), true, }, { @@ -648,7 +648,7 @@ func TestContinuousVestingAccountMarshal(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) coins := sdk.NewCoins(sdk.NewInt64Coin("test", 5)) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 10, 50) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 50) baseVesting := types.NewBaseVestingAccount(baseAcc, coins, time.Now().Unix()) acc := types.NewContinuousVestingAccountRaw(baseVesting, baseVesting.EndTime) @@ -670,7 +670,7 @@ func TestPeriodicVestingAccountMarshal(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) coins := sdk.NewCoins(sdk.NewInt64Coin("test", 5)) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 10, 50) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 50) acc := types.NewPeriodicVestingAccount(baseAcc, coins, time.Now().Unix(), types.Periods{types.Period{3600, coins}}) @@ -691,7 +691,7 @@ func TestDelayedVestingAccountMarshal(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.AccAddress(pubkey.Address()) coins := sdk.NewCoins(sdk.NewInt64Coin("test", 5)) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 10, 50) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 50) acc := types.NewDelayedVestingAccount(baseAcc, coins, time.Now().Unix()) diff --git a/x/bank/app_test.go b/x/bank/app_test.go index d9ea6e1f77..f0568e7fc9 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -25,7 +25,7 @@ type ( expSimPass bool expPass bool msgs []sdk.Msg - accNums []uint64 + sbh []uint64 accSeqs []uint64 privKeys []cryptotypes.PrivKey expectedBalances []expectedBalance @@ -103,13 +103,12 @@ func TestSendNotEnoughBalance(t *testing.T) { require.NotNil(t, res1) require.Equal(t, acc, res1.(*authtypes.BaseAccount)) - origAccNum := res1.GetAccountNumber() origSeq := res1.GetSequence() sendMsg := types.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)}) header := ostproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1) + _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{sendMsg}, "", []uint64{0}, []uint64{origSeq}, false, false, priv1) require.Error(t, err) simapp.CheckBalance(t, app, addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 67)}) @@ -117,7 +116,6 @@ func TestSendNotEnoughBalance(t *testing.T) { res2 := app.AccountKeeper.GetAccount(app.NewContext(true, ostproto.Header{}), addr1) require.NotNil(t, res2) - require.Equal(t, res2.GetAccountNumber(), origAccNum) require.Equal(t, res2.GetSequence(), origSeq+1) } @@ -143,7 +141,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { { desc: "make a valid tx", msgs: []sdk.Msg{multiSendMsg1}, - accNums: []uint64{0}, + sbh: []uint64{0}, accSeqs: []uint64{0}, expSimPass: true, expPass: true, @@ -154,9 +152,9 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { }, }, { - desc: "wrong accNum should pass Simulate, but not Deliver", + desc: "wrong sig block height should pass Simulate, but not Deliver", msgs: []sdk.Msg{multiSendMsg1, multiSendMsg2}, - accNums: []uint64{1}, // wrong account number + sbh: []uint64{5}, // wrong sig block height accSeqs: []uint64{1}, expSimPass: true, // doesn't check signature expPass: false, @@ -165,7 +163,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { { desc: "wrong accSeq should not pass Simulate", msgs: []sdk.Msg{multiSendMsg5}, - accNums: []uint64{0}, + sbh: []uint64{0}, accSeqs: []uint64{0}, // wrong account sequence expSimPass: false, expPass: false, @@ -176,7 +174,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { for _, tc := range testCases { header := ostproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.sbh, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) if tc.expPass { require.NoError(t, err) } else { @@ -212,7 +210,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { testCases := []appTestCase{ { msgs: []sdk.Msg{multiSendMsg2}, - accNums: []uint64{0}, + sbh: []uint64{0}, accSeqs: []uint64{0}, expSimPass: true, expPass: true, @@ -228,7 +226,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { for _, tc := range testCases { header := ostproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.sbh, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) for _, eb := range tc.expectedBalances { @@ -266,7 +264,7 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { testCases := []appTestCase{ { msgs: []sdk.Msg{multiSendMsg3}, - accNums: []uint64{0, 2}, + sbh: []uint64{0, 0}, accSeqs: []uint64{0, 0}, expSimPass: true, expPass: true, @@ -283,7 +281,7 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { for _, tc := range testCases { header := ostproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.sbh, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) for _, eb := range tc.expectedBalances { @@ -295,14 +293,12 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { func TestMsgMultiSendDependent(t *testing.T) { acc1 := authtypes.NewBaseAccountWithAddress(addr1) acc2 := authtypes.NewBaseAccountWithAddress(addr2) - err := acc2.SetAccountNumber(1) - require.NoError(t, err) genAccs := []authtypes.GenesisAccount{acc1, acc2} app := simapp.SetupWithGenesisAccounts(genAccs) ctx := app.BaseApp.NewContext(false, ostproto.Header{}) - err = app.BankKeeper.SetBalances(ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))) + err := app.BankKeeper.SetBalances(ctx, addr1, sdk.NewCoins(sdk.NewInt64Coin("foocoin", 42))) require.NoError(t, err) app.Commit() @@ -310,7 +306,7 @@ func TestMsgMultiSendDependent(t *testing.T) { testCases := []appTestCase{ { msgs: []sdk.Msg{multiSendMsg1}, - accNums: []uint64{0}, + sbh: []uint64{0}, accSeqs: []uint64{0}, expSimPass: true, expPass: true, @@ -322,7 +318,7 @@ func TestMsgMultiSendDependent(t *testing.T) { }, { msgs: []sdk.Msg{multiSendMsg4}, - accNums: []uint64{1}, + sbh: []uint64{0}, accSeqs: []uint64{0}, expSimPass: true, expPass: true, @@ -336,7 +332,7 @@ func TestMsgMultiSendDependent(t *testing.T) { for _, tc := range testCases { header := ostproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.sbh, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) for _, eb := range tc.expectedBalances { diff --git a/x/bank/client/cli/tx.go b/x/bank/client/cli/tx.go index cf2f5d2a69..7f8db26a5e 100644 --- a/x/bank/client/cli/tx.go +++ b/x/bank/client/cli/tx.go @@ -31,7 +31,8 @@ func NewSendTxCmd() *cobra.Command { Use: "send [from_key_or_address] [to_address] [amount]", Short: `Send funds from one account to another. Note, the'--from' flag is ignored as it is implied from [from_key_or_address].`, - Args: cobra.ExactArgs(3), + Args: cobra.ExactArgs(3), + PreRun: preSendCmd, RunE: func(cmd *cobra.Command, args []string) error { cmd.Flags().Set(flags.FlagFrom, args[0]) clientCtx, err := client.GetClientTxContext(cmd) @@ -61,3 +62,9 @@ ignored as it is implied from [from_key_or_address].`, return cmd } + +func preSendCmd(cmd *cobra.Command, _ []string) { + if offline, _ := cmd.Flags().GetBool(flags.FlagOffline); offline { + cmd.MarkFlagRequired(flags.FlagSequence) + } +} diff --git a/x/bank/client/rest/tx_test.go b/x/bank/client/rest/tx_test.go index 7ebdbf304e..6ea5c683ff 100644 --- a/x/bank/client/rest/tx_test.go +++ b/x/bank/client/rest/tx_test.go @@ -75,7 +75,7 @@ func generateSendReq(from authtypes.AccountI, amount types.Coins) bankrest.SendR "some-id", "10000", fmt.Sprintf("%f", 1.0), - from.GetAccountNumber(), + 0, from.GetSequence(), types.NewCoins(), nil, diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index e15d1e67d2..3732f3fac3 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -114,7 +114,7 @@ func sendMsgSend( fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, privkeys..., ) @@ -229,7 +229,7 @@ func sendMsgMultiSend( msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, ) error { - accountNumbers := make([]uint64, len(msg.Inputs)) + sbh := make([]uint64, len(msg.Inputs)) sequenceNumbers := make([]uint64, len(msg.Inputs)) for i := 0; i < len(msg.Inputs); i++ { @@ -238,7 +238,7 @@ func sendMsgMultiSend( panic(err) } acc := ak.GetAccount(ctx, addr) - accountNumbers[i] = acc.GetAccountNumber() + sbh[i] = 0 sequenceNumbers[i] = acc.GetSequence() } @@ -271,7 +271,7 @@ func sendMsgMultiSend( fees, helpers.DefaultGenTxGas, chainID, - accountNumbers, + sbh, sequenceNumbers, privkeys..., ) diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index 9053677d4f..7ecfa1ddff 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -8,7 +8,6 @@ import ( // AccountKeeper defines the account contract that must be fulfilled when // creating a x/bank keeper. type AccountKeeper interface { - NewAccount(sdk.Context, types.AccountI) types.AccountI NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) types.AccountI GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index d96336f14a..a1a6f6329f 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -107,7 +107,7 @@ func SimulateMsgSetWithdrawAddress(ak types.AccountKeeper, bk types.BankKeeper, fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -159,7 +159,7 @@ func SimulateMsgWithdrawDelegatorReward(ak types.AccountKeeper, bk types.BankKee fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -214,7 +214,7 @@ func SimulateMsgWithdrawValidatorCommission(ak types.AccountKeeper, bk types.Ban fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -269,7 +269,7 @@ func SimulateMsgFundCommunityPool(ak types.AccountKeeper, bk types.BankKeeper, k fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, funder.PrivKey, ) diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 56a11047da..aed555b3ed 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -98,7 +98,7 @@ func (suite *KeeperTestSuite) SetupTest() { for i, addr := range valAddresses { addr := sdk.AccAddress(addr) - app.AccountKeeper.SetAccount(suite.ctx, authtypes.NewBaseAccount(addr, pubkeys[i], uint64(i), 0)) + app.AccountKeeper.SetAccount(suite.ctx, authtypes.NewBaseAccount(addr, pubkeys[i], 0)) } queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, app.InterfaceRegistry()) diff --git a/x/genutil/types/expected_keepers.go b/x/genutil/types/expected_keepers.go index 0e35e24f62..7375eb0bf9 100644 --- a/x/genutil/types/expected_keepers.go +++ b/x/genutil/types/expected_keepers.go @@ -18,7 +18,6 @@ type StakingKeeper interface { // AccountKeeper defines the expected account keeper (noalias) type AccountKeeper interface { - NewAccount(sdk.Context, auth.AccountI) auth.AccountI SetAccount(sdk.Context, auth.AccountI) IterateAccounts(ctx sdk.Context, process func(auth.AccountI) (stop bool)) } diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index f1745dce3a..5fd847e331 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -149,7 +149,7 @@ func SimulateMsgSubmitProposal( fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -236,7 +236,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Ke fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -298,7 +298,7 @@ func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k kee fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 497db90b3f..0c8bad3886 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -124,7 +124,7 @@ func NewTestChain(t *testing.T, chainID string) *TestChain { // generate genesis account senderPrivKey := secp256k1.GenPrivKey() - acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) + acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), @@ -294,7 +294,7 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { chain.GetContext().BlockHeader(), msgs, chain.ChainID, - []uint64{chain.SenderAccount.GetAccountNumber()}, + []uint64{0}, []uint64{chain.SenderAccount.GetSequence()}, true, true, chain.senderPrivKey, ) diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index 6cf3207072..53608f35c8 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -96,7 +96,7 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index e09e7828f6..5ef103e4a7 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -160,7 +160,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k k fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -231,7 +231,7 @@ func SimulateMsgEditValidator(ak types.AccountKeeper, bk types.BankKeeper, k kee fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -304,7 +304,7 @@ func SimulateMsgDelegate(ak types.AccountKeeper, bk types.BankKeeper, k keeper.K fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -394,7 +394,7 @@ func SimulateMsgUndelegate(ak types.AccountKeeper, bk types.BankKeeper, k keeper fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -507,7 +507,7 @@ func SimulateMsgBeginRedelegate(ak types.AccountKeeper, bk types.BankKeeper, k k fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, + []uint64{0}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) diff --git a/x/wasm/internal/keeper/keeper_test.go b/x/wasm/internal/keeper/keeper_test.go index 8d4103b9e6..886da5075a 100644 --- a/x/wasm/internal/keeper/keeper_test.go +++ b/x/wasm/internal/keeper/keeper_test.go @@ -287,7 +287,7 @@ func TestInstantiate(t *testing.T) { gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x11bba), gasAfter-gasBefore) + require.Equal(t, uint64(0x10f84), gasAfter-gasBefore) } // ensure it is stored properly @@ -521,7 +521,7 @@ func TestExecute(t *testing.T) { // make sure gas is properly deducted from ctx gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x1180c), gasAfter-gasBefore) + require.Equal(t, uint64(0x10bc4), gasAfter-gasBefore) } // ensure bob now exists and got both payments released bobAcct = accKeeper.GetAccount(ctx, bob) diff --git a/x/wasm/internal/keeper/submsg_test.go b/x/wasm/internal/keeper/submsg_test.go index 919ce1ce7c..f5233613e4 100644 --- a/x/wasm/internal/keeper/submsg_test.go +++ b/x/wasm/internal/keeper/submsg_test.go @@ -262,7 +262,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { submsgID: 5, msg: validBankSend, // note we charge another 40k for the reply call - resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(121000, 134000)}, + resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(118000, 130000)}, }, "not enough tokens": { submsgID: 6, @@ -282,7 +282,7 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) { msg: validBankSend, gasLimit: &subGasLimit, // uses same gas as call without limit - resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(121000, 134000)}, + resultAssertions: []assertion{assertReturnedEvents(3), assertGasUsed(118000, 130000)}, }, "not enough tokens with limit": { submsgID: 16, diff --git a/x/wasm/internal/types/expected_keepers.go b/x/wasm/internal/types/expected_keepers.go index b66a041080..648905d3a7 100644 --- a/x/wasm/internal/types/expected_keepers.go +++ b/x/wasm/internal/types/expected_keepers.go @@ -28,7 +28,7 @@ type BankKeeper interface { // AccountKeeper defines a subset of methods implemented by the cosmos-sdk account keeper type AccountKeeper interface { - // Return a new account with the next account number and the specified address. Does not save the new account to the store. + // Return a new account with the specified address. Does not save the new account to the store. NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI // Retrieve an account from the store. GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI