diff --git a/CHANGELOG.md b/CHANGELOG.md index da7e76c7dd..f69e7e8a07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,1074 +1,189 @@ -# Changelog - -## Unreleased - -### Bug Fixes -* [x/wasm](https://github.com/line/lbm-sdk/pull/434) remove `x/wasm/linkwasmd` - - -## [v0.42.9](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.9) - 2021-08-04 - -### Bug Fixes - -* [\#9835](https://github.com/cosmos/cosmos-sdk/pull/9835) Moved capability initialization logic to BeginBlocker to fix nondeterminsim issue mentioned in [\#9800](https://github.com/cosmos/cosmos-sdk/issues/9800). Applications must now include the capability module in their BeginBlocker order before any module that uses capabilities gets run. -* [\#9201](https://github.com/cosmos/cosmos-sdk/pull/9201) Fixed ` init --recover` flag. - - -### API Breaking Changes - -* [\#9835](https://github.com/cosmos/cosmos-sdk/pull/9835) The `InitializeAndSeal` API has not changed, however it no longer initializes the in-memory state. `InitMemStore` has been introduced to serve this function, which will be called either in `InitChain` or `BeginBlock` (whichever is first after app start). Nodes may run this version on a network running 0.42.x, however, they must update their app.go files to include the capability module in their begin blockers. - -### Client Breaking Changes - -* [\#9781](https://github.com/cosmos/cosmos-sdk/pull/9781) Improve`withdraw-all-rewards` UX when broadcast mode `async` or `async` is used. - -## [v0.42.8](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.8) - 2021-07-30 - -### Features - -* [\#9750](https://github.com/cosmos/cosmos-sdk/pull/9750) Emit events for tx signature and sequence, so clients can now query txs by signature (`tx.signature=''`) or by address and sequence combo (`tx.acc_seq='/'`). - -### Improvements - -* (cli) [\#9717](https://github.com/cosmos/cosmos-sdk/pull/9717) Added CLI flag `--output json/text` to `tx` cli commands. - -### Bug Fixes - -* [\#9766](https://github.com/cosmos/cosmos-sdk/pull/9766) Fix hardcoded ledger signing algorithm on `keys add` command. - -## [v0.42.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.7) - 2021-07-09 - -### Improvements - -* (baseapp) [\#9578](https://github.com/cosmos/cosmos-sdk/pull/9578) Return `Baseapp`'s `trace` value for logging error stack traces. -* (cli) [\#9593](https://github.com/cosmos/cosmos-sdk/pull/9593) Check if chain-id is blank before verifying signatures in multisign and error. - -### Bug Fixes - -* (x/ibc) [\#9640](https://github.com/cosmos/cosmos-sdk/pull/9640) Fix IBC Transfer Ack Success event as it was initially emitting opposite value. -* [\#9645](https://github.com/cosmos/cosmos-sdk/pull/9645) Use correct Prometheus format for metric labels. -* [\#9299](https://github.com/cosmos/cosmos-sdk/pull/9299) Fix `[appd] keys parse cosmos1...` freezing. -* (keyring) [\#9563](https://github.com/cosmos/cosmos-sdk/pull/9563) fix keyring kwallet backend when using with empty wallet. -* (x/capability) [\#9392](https://github.com/cosmos/cosmos-sdk/pull/9392) initialization fix, which fixes the consensus error when using statesync. - - -## [v0.42.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.6) - 2021-06-18 - -### Improvements - -* [\#9428](https://github.com/cosmos/cosmos-sdk/pull/9428) Optimize bank InitGenesis. Added `k.initBalances`. -* [\#9429](https://github.com/cosmos/cosmos-sdk/pull/9429) Add `cosmos_sdk_version` to node_info -* [\#9541](https://github.com/cosmos/cosmos-sdk/pull/9541) Bump tendermint dependency to v0.34.11. - -### Bug Fixes - -* [\#9385](https://github.com/cosmos/cosmos-sdk/pull/9385) Fix IBC `query ibc client header` cli command. Support historical queries for query header/node-state commands. -* [\#9401](https://github.com/cosmos/cosmos-sdk/pull/9401) Fixes incorrect export of IBC identifier sequences. Previously, the next identifier sequence for clients/connections/channels was not set during genesis export. This resulted in the next identifiers being generated on the new chain to reuse old identifiers (the sequences began again from 0). -* [\#9408](https://github.com/cosmos/cosmos-sdk/pull/9408) Update simapp to use correct default broadcast mode. -* [\#9513](https://github.com/cosmos/cosmos-sdk/pull/9513) Fixes testnet CLI command. Testnet now updates the supply in genesis. Previously, when using add-genesis-account and testnet together, inconsistent genesis files would be produced, as only add-genesis-account was updating the supply. -* (x/gov) [\#8813](https://github.com/cosmos/cosmos-sdk/pull/8813) fix `GET /cosmos/gov/v1beta1/proposals/{proposal_id}/deposits` to include initial deposit - -### Features - -* [\#9383](https://github.com/cosmos/cosmos-sdk/pull/9383) New CLI command `query ibc-transfer escrow-address ` to get the escrow address for a channel; can be used to then query balance of escrowed tokens -* (baseapp, types) [#\9390](https://github.com/cosmos/cosmos-sdk/pull/9390) Add current block header hash to `Context` -* (store) [\#9403](https://github.com/cosmos/cosmos-sdk/pull/9403) Add `RefundGas` function to `GasMeter` interface - -## [v0.42.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.5) - 2021-05-18 - -### Bug Fixes - -* [\#9514](https://github.com/cosmos/cosmos-sdk/issues/9514) Fix panic when retrieving the `BlockGasMeter` on `(Re)CheckTx` mode. -* [\#9235](https://github.com/cosmos/cosmos-sdk/pull/9235) CreateMembershipProof/CreateNonMembershipProof now returns an error -if input key is empty, or input data contains empty key. -* [\#9108](https://github.com/cosmos/cosmos-sdk/pull/9108) Fixed the bug with querying multisig account, which is not showing threshold and public_keys. -* [\#9345](https://github.com/cosmos/cosmos-sdk/pull/9345) Fix ARM support. -* [\#9040](https://github.com/cosmos/cosmos-sdk/pull/9040) Fix ENV variables binding to CLI flags for client config. - -### Features - -* [\#8953](https://github.com/cosmos/cosmos-sdk/pull/8953) Add the `config` CLI subcommand back to the SDK, which saves client-side configuration in a `client.toml` file. - - -## [v0.42.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.4) - 2021-04-08 - -### Client Breaking Changes - -* [\#9026](https://github.com/cosmos/cosmos-sdk/pull/9026) By default, the `tx sign` and `tx sign-batch` CLI commands use SIGN_MODE_DIRECT to sign transactions for local pubkeys. For multisigs and ledger keys, the default LEGACY_AMINO_JSON is used. - -### Bug Fixes - -* (gRPC) [\#9015](https://github.com/cosmos/cosmos-sdk/pull/9015) Fix invalid status code when accessing gRPC endpoints. -* [\#9026](https://github.com/cosmos/cosmos-sdk/pull/9026) Fixed the bug that caused the `gentx` command to fail for Ledger keys. - -### Improvements - -* [\#9081](https://github.com/cosmos/cosmos-sdk/pull/9081) Upgrade Tendermint to v0.34.9 that includes a security issue fix for Tendermint light clients. - -## [v0.42.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.3) - 2021-03-24 - -This release fixes a security vulnerability identified in x/bank. - -## [v0.42.2](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.2) - 2021-03-19 - -### Improvements - -* (grpc) [\#8815](https://github.com/cosmos/cosmos-sdk/pull/8815) Add orderBy parameter to `TxsByEvents` endpoint. -* (cli) [\#8826](https://github.com/cosmos/cosmos-sdk/pull/8826) Add trust to macOS Keychain for caller app by default. -* (store) [\#8811](https://github.com/cosmos/cosmos-sdk/pull/8811) store/cachekv: use typed types/kv.List instead of container/list.List - -### Bug Fixes - -* (crypto) [\#8841](https://github.com/cosmos/cosmos-sdk/pull/8841) Fix legacy multisig amino marshaling, allowing migrations to work between v0.39 and v0.40+. -* (cli) [\#8873](https://github.com/cosmos/cosmos-sdk/pull/8873) add --output-document to multisign-batch. - -## [v0.42.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.1) - 2021-03-10 - -This release fixes security vulnerability identified in the simapp. - - -## [v0.42.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.0) - 2021-03-08 - -**IMPORTANT**: This release contains an important security fix for all non Cosmos Hub chains running Stargate version of the Cosmos SDK (>0.40). Non-hub chains should not be using any version of the SDK in the v0.40.x or v0.41.x release series. See [#8461](https://github.com/cosmos/cosmos-sdk/pull/8461) for more details. - -### Improvements - -* (x/ibc) [\#8624](https://github.com/cosmos/cosmos-sdk/pull/8624) Emit full header in IBC UpdateClient message. -* (x/crisis) [\#8621](https://github.com/cosmos/cosmos-sdk/issues/8621) crisis invariants names now print to loggers. - -### Bug fixes - -* (x/evidence) [\#8461](https://github.com/cosmos/cosmos-sdk/pull/8461) Fix bech32 prefix in evidence validator address conversion -* (x/gov) [\#8806](https://github.com/cosmos/cosmos-sdk/issues/8806) Fix q gov proposals command's mishandling of the --status parameter's values. - -## [v0.41.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.41.3) - 2021-03-02 - -### Features - -* [\#7787](https://github.com/cosmos/cosmos-sdk/pull/7787) Add multisign-batch command. - -### Bug fixes - -* [\#8730](https://github.com/cosmos/cosmos-sdk/pull/8730) Allow REST endpoint to query txs with multisig addresses. -* [\#8680](https://github.com/cosmos/cosmos-sdk/issues/8680) Fix missing timestamp in GetTxsEvent response [\#8732](https://github.com/cosmos/cosmos-sdk/pull/8732). -* [\#8681](https://github.com/cosmos/cosmos-sdk/issues/8681) Fix missing error message when calling GetTxsEvent [\#8732](https://github.com/cosmos/cosmos-sdk/pull/8732) -* (server) [\#8641](https://github.com/cosmos/cosmos-sdk/pull/8641) Fix Tendermint and application configuration reading from file -* (client/keys) [\#8639] (https://github.com/cosmos/cosmos-sdk/pull/8639) Fix keys migrate for mulitisig, offline, and ledger keys. The migrate command now takes a positional old_home_dir argument. - -### Improvements - -* (store/cachekv), (x/bank/types) [\#8719](https://github.com/cosmos/cosmos-sdk/pull/8719) algorithmically fix pathologically slow code -* [\#8701](https://github.com/cosmos/cosmos-sdk/pull/8701) Upgrade tendermint v0.34.8. -* [\#8714](https://github.com/cosmos/cosmos-sdk/pull/8714) Allow accounts to have a balance of 0 at genesis. - -## [v0.41.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.41.3) - 2021-02-18 - -### Bug Fixes - -* [\#8617](https://github.com/cosmos/cosmos-sdk/pull/8617) Fix build failures caused by a small API breakage introduced in tendermint v0.34.7. - -## [v0.41.2](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.41.2) - 2021-02-18 - -### Improvements - -* Bump tendermint dependency to v0.34.7. - -## [v0.41.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.41.1) - 2021-02-17 - -### Bug Fixes - -* (grpc) [\#8549](https://github.com/cosmos/cosmos-sdk/pull/8549) Make gRPC requests go through ABCI and disallow concurrency. -* (x/staking) [\#8546](https://github.com/cosmos/cosmos-sdk/pull/8546) Fix caching bug where concurrent calls to GetValidator could cause a node to crash -* (server) [\#8481](https://github.com/cosmos/cosmos-sdk/pull/8481) Don't create files when running `{appd} tendermint show-*` subcommands. -* (client/keys) [\#8436](https://github.com/cosmos/cosmos-sdk/pull/8436) Fix keybase->keyring keys migration. -* (crypto/hd) [\#8607](https://github.com/cosmos/cosmos-sdk/pull/8607) Make DerivePrivateKeyForPath error and not panic on trailing slashes. - -### Improvements - -* (x/ibc) [\#8458](https://github.com/cosmos/cosmos-sdk/pull/8458) Add `packet_connection` attribute to ibc events to enable relayer filtering -* [\#8396](https://github.com/cosmos/cosmos-sdk/pull/8396) Add support for ARM platform -* (x/bank) [\#8479](https://github.com/cosmos/cosmos-sdk/pull/8479) Aditional client denom metadata validation for `base` and `display` denoms. -* (codec/types) [\#8605](https://github.com/cosmos/cosmos-sdk/pull/8605) Avoid unnecessary allocations for NewAnyWithCustomTypeURL on error. - -## [v0.41.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.41.0) - 2021-01-26 - -### State Machine Breaking - -* (x/ibc) [\#8266](https://github.com/cosmos/cosmos-sdk/issues/8266) Add amino JSON for IBC messages in order to support Ledger text signing. -* (x/ibc) [\#8404](https://github.com/cosmos/cosmos-sdk/pull/8404) Reorder IBC `ChanOpenAck` and `ChanOpenConfirm` handler execution to perform core handler first, followed by application callbacks. - -### Bug Fixes - -* (simapp) [\#8418](https://github.com/cosmos/cosmos-sdk/pull/8418) Add balance coin to supply when adding a new genesis account -* (x/bank) [\#8417](https://github.com/cosmos/cosmos-sdk/pull/8417) Validate balances and coin denom metadata on genesis -* (x/staking) [\#8546](https://github.com/cosmos/cosmos-sdk/pull/8546) Fix caching bug where concurrent calls to GetValidator could cause a node to crash - -## [v0.40.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.40.1) - 2021-01-19 - -### Improvements - -* (x/bank) [\#8302](https://github.com/cosmos/cosmos-sdk/issues/8302) Add gRPC and CLI queries for client denomination metadata. -* (tendermint) Bump Tendermint version to [v0.34.3](https://github.com/tendermint/tendermint/releases/tag/v0.34.3). - -### Bug Fixes - -* [\#8085](https://github.com/cosmos/cosmos-sdk/pull/8058) fix zero time checks -* [\#8280](https://github.com/cosmos/cosmos-sdk/pull/8280) fix GET /upgrade/current query -* (x/auth) [\#8287](https://github.com/cosmos/cosmos-sdk/pull/8287) Fix `tx sign --signature-only` to return correct sequence value in signature. -* (build) [\8300](https://github.com/cosmos/cosmos-sdk/pull/8300), [\8301](https://github.com/cosmos/cosmos-sdk/pull/8301) Fix reproducible builds -* (types/errors) [\#8355][https://github.com/cosmos/cosmos-sdk/pull/8355] Fix errorWrap `Is` method. -* (x/ibc) [\#8341](https://github.com/cosmos/cosmos-sdk/pull/8341) Fix query latest consensus state. -* (proto) [\#8350][https://github.com/cosmos/cosmos-sdk/pull/8350], [\#8361](https://github.com/cosmos/cosmos-sdk/pull/8361) Update gogo proto deps with v1.3.2 security fixes -* (x/ibc) [\#8359](https://github.com/cosmos/cosmos-sdk/pull/8359) Add missing UnpackInterfaces functions to IBC Query Responses. Fixes 'cannot unpack Any' error for IBC types. -* (x/bank) [\#8317](https://github.com/cosmos/cosmos-sdk/pull/8317) Fix panic when querying for a not found client denomination metadata. - - -## [v0.40.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.40.0) - 2021-01-08 - -v0.40.0, known as the Stargate release of the Cosmos SDK, is one of the largest releases -of the Cosmos SDK since launch. Please read through this changelog and [release notes](./RELEASE_NOTES.md) to make -sure you are aware of any relevant breaking changes. - -### Client Breaking Changes - -* __Modules__ - -* __CLI__ - * (client/keys) [\#5889](https://github.com/cosmos/cosmos-sdk/pull/5889) remove `keys update` command. - * (x/auth) [\#5844](https://github.com/cosmos/cosmos-sdk/pull/5844) `tx sign` command now returns an error when signing is attempted with offline/multisig keys. - * (x/auth) [\#6108](https://github.com/cosmos/cosmos-sdk/pull/6108) `tx sign` command's `--validate-signatures` flag is migrated into a `tx validate-signatures` standalone command. - * (x/auth) [#7788](https://github.com/cosmos/cosmos-sdk/pull/7788) Remove `tx auth` subcommands, all auth subcommands exist as `tx ` - * (x/genutil) [\#6651](https://github.com/cosmos/cosmos-sdk/pull/6651) The `gentx` command has been improved. No longer are `--from` and `--name` flags required. Instead, a single argument, `name`, is required which refers to the key pair in the Keyring. In addition, an optional - `--moniker` flag can be provided to override the moniker found in `config.toml`. - * (x/upgrade) [#7697](https://github.com/cosmos/cosmos-sdk/pull/7697) Rename flag name "--time" to "--upgrade-time", "--info" to "--upgrade-info", to keep it consistent with help message. -* __REST / Queriers__ - * (api) [\#6426](https://github.com/cosmos/cosmos-sdk/pull/6426) The ability to start an out-of-process API REST server has now been removed. Instead, the API server is now started in-process along with the application and Tendermint. Configuration options have been added to `app.toml` to enable/disable the API server along with additional HTTP server options. - * (client) [\#7246](https://github.com/cosmos/cosmos-sdk/pull/7246) The rest server endpoint `/swagger-ui/` is replaced by `/swagger/`, and contains swagger documentation for gRPC Gateway routes in addition to legacy REST routes. Swagger API is exposed only if set in `app.toml`. - * (x/auth) [\#5702](https://github.com/cosmos/cosmos-sdk/pull/5702) The `x/auth` querier route has changed from `"acc"` to `"auth"`. - * (x/bank) [\#5572](https://github.com/cosmos/cosmos-sdk/pull/5572) The `/bank/balances/{address}` endpoint now returns all account balances or a single balance by denom when the `denom` query parameter is present. - * (x/evidence) [\#5952](https://github.com/cosmos/cosmos-sdk/pull/5952) Remove CLI and REST handlers for querying `x/evidence` parameters. - * (x/gov) [#6295](https://github.com/cosmos/cosmos-sdk/pull/6295) Fix typo in querying governance params. -* __General__ - * (baseapp) [\#6384](https://github.com/cosmos/cosmos-sdk/pull/6384) The `Result.Data` is now a Protocol Buffer encoded binary blob of type `TxData`. The `TxData` contains `Data` which contains a list of Protocol Buffer encoded message data and the corresponding message type. - * (client) [\#5783](https://github.com/cosmos/cosmos-sdk/issues/5783) Unify all coins representations on JSON client requests for governance proposals. - * (crypto) [\#7419](https://github.com/cosmos/cosmos-sdk/pull/7419) The SDK doesn't use Tendermint's `crypto.PubKey` - interface anymore, and uses instead it's own `PubKey` interface, defined in `crypto/types`. Replace all instances of - `crypto.PubKey` by `cryptotypes.Pubkey`. - * (store/rootmulti) [\#6390](https://github.com/cosmos/cosmos-sdk/pull/6390) Proofs of empty stores are no longer supported. - * (store/types) [\#5730](https://github.com/cosmos/cosmos-sdk/pull/5730) store.types.Cp() is removed in favour of types.CopyBytes(). - * (x/auth) [\#6054](https://github.com/cosmos/cosmos-sdk/pull/6054) Remove custom JSON marshaling for base accounts as multsigs cannot be bech32 decoded. - * (x/auth/vesting) [\#6859](https://github.com/cosmos/cosmos-sdk/pull/6859) Custom JSON marshaling of vesting accounts was removed. Vesting accounts are now marshaled using their default proto or amino JSON representation. - * (x/bank) [\#5785](https://github.com/cosmos/cosmos-sdk/issues/5785) In x/bank errors, JSON strings coerced to valid UTF-8 bytes at JSON marshalling time - are now replaced by human-readable expressions. This change can potentially break compatibility with all those client side tools - that parse log messages. - * (x/evidence) [\#7538](https://github.com/cosmos/cosmos-sdk/pull/7538) The ABCI's `Result.Data` field for - `MsgSubmitEvidence` responses does not contain the raw evidence's hash, but the protobuf encoded - `MsgSubmitEvidenceResponse` struct. - * (x/gov) [\#7533](https://github.com/cosmos/cosmos-sdk/pull/7533) The ABCI's `Result.Data` field for - `MsgSubmitProposal` responses does not contain a raw binary encoding of the `proposalID`, but the protobuf encoded - `MsgSubmitSubmitProposalResponse` struct. - * (x/gov) [\#6859](https://github.com/cosmos/cosmos-sdk/pull/6859) `ProposalStatus` and `VoteOption` are now JSON serialized using its protobuf name, so expect names like `PROPOSAL_STATUS_DEPOSIT_PERIOD` as opposed to `DepositPeriod`. - * (x/staking) [\#7499](https://github.com/cosmos/cosmos-sdk/pull/7499) `BondStatus` is now a protobuf `enum` instead - of an `int32`, and JSON serialized using its protobuf name, so expect names like `BOND_STATUS_UNBONDING` as opposed - to `Unbonding`. - * (x/staking) [\#7556](https://github.com/cosmos/cosmos-sdk/pull/7556) The ABCI's `Result.Data` field for - `MsgBeginRedelegate` and `MsgUndelegate` responses does not contain custom binary marshaled `completionTime`, but the - protobuf encoded `MsgBeginRedelegateResponse` and `MsgUndelegateResponse` structs respectively - -### API Breaking Changes + -* (x/auth) [\#5950](https://github.com/cosmos/cosmos-sdk/pull/5950) Fix `IncrementSequenceDecorator` to use is `IsReCheckTx` instead of `IsCheckTx` to allow account sequence incrementing. - -## [v0.38.3] - 2020-04-09 - -### Improvements - -* (tendermint) Bump Tendermint version to [v0.33.3](https://github.com/tendermint/tendermint/releases/tag/v0.33.3). - -## [v0.38.2] - 2020-03-25 - -### Bug Fixes - -* (baseapp) [\#5718](https://github.com/cosmos/cosmos-sdk/pull/5718) Remove call to `ctx.BlockGasMeter` during failed message validation which resulted in a panic when the tx execution mode was `CheckTx`. -* (x/genutil) [\#5775](https://github.com/cosmos/cosmos-sdk/pull/5775) Fix `ExportGenesis` in `x/genutil` to export default genesis state (`[]`) instead of `null`. -* (client) [\#5618](https://github.com/cosmos/cosmos-sdk/pull/5618) Fix crash on the client when the verifier is not set. -* (crypto/keys/mintkey) [\#5823](https://github.com/cosmos/cosmos-sdk/pull/5823) fix errors handling in `UnarmorPubKeyBytes` (underlying armoring function's return error was not being checked). -* (x/distribution) [\#5620](https://github.com/cosmos/cosmos-sdk/pull/5620) Fix nil pointer deref in distribution tax/reward validation helpers. - -### Improvements - -* (rest) [\#5648](https://github.com/cosmos/cosmos-sdk/pull/5648) Enhance /txs usability: - * Add `tx.minheight` key to filter transaction with an inclusive minimum block height - * Add `tx.maxheight` key to filter transaction with an inclusive maximum block height -* (crypto/keys) [\#5739](https://github.com/cosmos/cosmos-sdk/pull/5739) Print an error message if the password input failed. - -## [v0.38.1] - 2020-02-11 - -### Improvements - -* (modules) [\#5597](https://github.com/cosmos/cosmos-sdk/pull/5597) Add `amount` event attribute to the `complete_unbonding` -and `complete_redelegation` events that reflect the total balances of the completed unbondings and redelegations -respectively. - -### Bug Fixes - -* (types) [\#5579](https://github.com/cosmos/cosmos-sdk/pull/5579) The IAVL `Store#Commit` method has been refactored to -delete a flushed version if it is not a snapshot version. The root multi-store now keeps track of `commitInfo` instead -of `types.CommitID`. During `Commit` of the root multi-store, `lastCommitInfo` is updated from the saved state -and is only flushed to disk if it is a snapshot version. During `Query` of the root multi-store, if the request height -is the latest height, we'll use the store's `lastCommitInfo`. Otherwise, we fetch `commitInfo` from disk. -* (x/bank) [\#5531](https://github.com/cosmos/cosmos-sdk/issues/5531) Added missing amount event to MsgMultiSend, emitted for each output. -* (x/gov) [\#5622](https://github.com/cosmos/cosmos-sdk/pull/5622) Track any events emitted from a proposal's handler upon successful execution. - -## [v0.38.0] - 2020-01-23 - -### State Machine Breaking - -* (genesis) [\#5506](https://github.com/cosmos/cosmos-sdk/pull/5506) The `x/distribution` genesis state - now includes `params` instead of individual parameters. -* (genesis) [\#5017](https://github.com/cosmos/cosmos-sdk/pull/5017) The `x/genaccounts` module has been -deprecated and all components removed except the `legacy/` package. This requires changes to the -genesis state. Namely, `accounts` now exist under `app_state.auth.accounts`. The corresponding migration -logic has been implemented for v0.38 target version. Applications can migrate via: -`$ {appd} migrate v0.38 genesis.json`. -* (modules) [\#5299](https://github.com/cosmos/cosmos-sdk/pull/5299) Handling of `ABCIEvidenceTypeDuplicateVote` - during `BeginBlock` along with the corresponding parameters (`MaxEvidenceAge`) have moved from the - `x/slashing` module to the `x/evidence` module. - -### API Breaking Changes - -* (modules) [\#5506](https://github.com/cosmos/cosmos-sdk/pull/5506) Remove individual setters of `x/distribution` parameters. Instead, follow the module spec in getting parameters, setting new value(s) and finally calling `SetParams`. -* (types) [\#5495](https://github.com/cosmos/cosmos-sdk/pull/5495) Remove redundant `(Must)Bech32ify*` and `(Must)Get*KeyBech32` functions in favor of `(Must)Bech32ifyPubKey` and `(Must)GetPubKeyFromBech32` respectively, both of which take a `Bech32PubKeyType` (string). -* (types) [\#5430](https://github.com/cosmos/cosmos-sdk/pull/5430) `DecCoins#Add` parameter changed from `DecCoins` -to `...DecCoin`, `Coins#Add` parameter changed from `Coins` to `...Coin`. -* (baseapp/types) [\#5421](https://github.com/cosmos/cosmos-sdk/pull/5421) The `Error` interface (`types/errors.go`) -has been removed in favor of the concrete type defined in `types/errors/` which implements the standard `error` interface. - * As a result, the `Handler` and `Querier` implementations now return a standard `error`. - Within `BaseApp`, `runTx` now returns a `(GasInfo, *Result, error)` tuple and `runMsgs` returns a - `(*Result, error)` tuple. A reference to a `Result` is now used to indicate success whereas an error - signals an invalid message or failed message execution. As a result, the fields `Code`, `Codespace`, - `GasWanted`, and `GasUsed` have been removed the `Result` type. The latter two fields are now found - in the `GasInfo` type which is always returned regardless of execution outcome. - * Note to developers: Since all handlers and queriers must now return a standard `error`, the `types/errors/` - package contains all the relevant and pre-registered errors that you typically work with. A typical - error returned will look like `sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "...")`. You can retrieve - relevant ABCI information from the error via `ABCIInfo`. -* (client) [\#5442](https://github.com/cosmos/cosmos-sdk/pull/5442) Remove client/alias.go as it's not necessary and -components can be imported directly from the packages. -* (store) [\#4748](https://github.com/cosmos/cosmos-sdk/pull/4748) The `CommitMultiStore` interface -now requires a `SetInterBlockCache` method. Applications that do not wish to support this can simply -have this method perform a no-op. -* (modules) [\#4665](https://github.com/cosmos/cosmos-sdk/issues/4665) Refactored `x/gov` module structure and dev-UX: - * Prepare for module spec integration - * Update gov keys to use big endian encoding instead of little endian -* (modules) [\#5017](https://github.com/cosmos/cosmos-sdk/pull/5017) The `x/genaccounts` module has been deprecated and all components removed except the `legacy/` package. -* [\#4486](https://github.com/cosmos/cosmos-sdk/issues/4486) Vesting account types decoupled from the `x/auth` module and now live under `x/auth/vesting`. Applications wishing to use vesting account types must be sure to register types via `RegisterCodec` under the new vesting package. -* [\#4486](https://github.com/cosmos/cosmos-sdk/issues/4486) The `NewBaseVestingAccount` constructor returns an error -if the provided arguments are invalid. -* (x/auth) [\#5006](https://github.com/cosmos/cosmos-sdk/pull/5006) Modular `AnteHandler` via composable decorators: - * The `AnteHandler` interface now returns `(newCtx Context, err error)` instead of `(newCtx Context, result sdk.Result, abort bool)` - * The `NewAnteHandler` function returns an `AnteHandler` function that returns the new `AnteHandler` - interface and has been moved into the `auth/ante` directory. - * `ValidateSigCount`, `ValidateMemo`, `ProcessPubKey`, `EnsureSufficientMempoolFee`, and `GetSignBytes` - have all been removed as public functions. - * Invalid Signatures may return `InvalidPubKey` instead of `Unauthorized` error, since the transaction - will first hit `SetPubKeyDecorator` before the `SigVerificationDecorator` runs. - * `StdTx#GetSignatures` will return an array of just signature byte slices `[][]byte` instead of - returning an array of `StdSignature` structs. To replicate the old behavior, use the public field - `StdTx.Signatures` to get back the array of StdSignatures `[]StdSignature`. -* (modules) [\#5299](https://github.com/cosmos/cosmos-sdk/pull/5299) `HandleDoubleSign` along with params `MaxEvidenceAge` and `DoubleSignJailEndTime` have moved from the `x/slashing` module to the `x/evidence` module. -* (keys) [\#4941](https://github.com/cosmos/cosmos-sdk/issues/4941) Keybase concrete types constructors such as `NewKeyBaseFromDir` and `NewInMemory` now accept optional parameters of type `KeybaseOption`. These -optional parameters are also added on the keys sub-commands functions, which are now public, and allows -these options to be set on the commands or ignored to default to previous behavior. -* [\#5547](https://github.com/cosmos/cosmos-sdk/pull/5547) `NewKeyBaseFromHomeFlag` constructor has been removed. -* [\#5439](https://github.com/cosmos/cosmos-sdk/pull/5439) Further modularization was done to the `keybase` -package to make it more suitable for use with different key formats and algorithms: - * The `WithKeygenFunc` function added as a `KeybaseOption` which allows a custom bytes to key - implementation to be defined when keys are created. - * The `WithDeriveFunc` function added as a `KeybaseOption` allows custom logic for deriving a key - from a mnemonic, bip39 password, and HD Path. - * BIP44 is no longer build into `keybase.CreateAccount()`. It is however the default when using - the `client/keys` add command. - * `SupportedAlgos` and `SupportedAlgosLedger` functions return a slice of `SigningAlgo`s that are - supported by the keybase and the ledger integration respectively. -* (simapp) [\#5419](https://github.com/cosmos/cosmos-sdk/pull/5419) The `helpers.GenTx()` now accepts a gas argument. -* (baseapp) [\#5455](https://github.com/cosmos/cosmos-sdk/issues/5455) A `sdk.Context` is now passed into the `router.Route()` function. - -### Client Breaking Changes +# Changelog -* (rest) [\#5270](https://github.com/cosmos/cosmos-sdk/issues/5270) All account types now implement custom JSON serialization. -* (rest) [\#4783](https://github.com/cosmos/cosmos-sdk/issues/4783) The balance field in the DelegationResponse type is now sdk.Coin instead of sdk.Int -* (x/auth) [\#5006](https://github.com/cosmos/cosmos-sdk/pull/5006) The gas required to pass the `AnteHandler` has -increased significantly due to modular `AnteHandler` support. Increase GasLimit accordingly. -* (rest) [\#5336](https://github.com/cosmos/cosmos-sdk/issues/5336) `MsgEditValidator` uses `description` instead of `Description` as a JSON key. -* (keys) [\#5097](https://github.com/cosmos/cosmos-sdk/pull/5097) Due to the keybase -> keyring transition, keys need to be migrated. See `keys migrate` command for more info. -* (x/auth) [\#5424](https://github.com/cosmos/cosmos-sdk/issues/5424) Drop `decode-tx` command from x/auth/client/cli, duplicate of the `decode` command. +## [Unreleased](https://github.com/line/lbm-sdk/compare/v0.44.0-rc...HEAD) ### Features - -* (store) [\#5435](https://github.com/cosmos/cosmos-sdk/pull/5435) New iterator for paginated requests. Iterator limits DB reads to the range of the requested page. -* (x/evidence) [\#5240](https://github.com/cosmos/cosmos-sdk/pull/5240) Initial implementation of the `x/evidence` module. -* (cli) [\#5212](https://github.com/cosmos/cosmos-sdk/issues/5212) The `q gov proposals` command now supports pagination. -* (store) [\#4724](https://github.com/cosmos/cosmos-sdk/issues/4724) Multistore supports substore migrations upon load. New `rootmulti.Store.LoadLatestVersionAndUpgrade` method in -`Baseapp` supports `StoreLoader` to enable various upgrade strategies. It no -longer panics if the store to load contains substores that we didn't explicitly mount. -* [\#4972](https://github.com/cosmos/cosmos-sdk/issues/4972) A `TxResponse` with a corresponding code -and tx hash will be returned for specific Tendermint errors: - * `CodeTxInMempoolCache` - * `CodeMempoolIsFull` - * `CodeTxTooLarge` -* [\#3872](https://github.com/cosmos/cosmos-sdk/issues/3872) Implement a RESTful endpoint and cli command to decode transactions. -* (keys) [\#4754](https://github.com/cosmos/cosmos-sdk/pull/4754) Introduce new Keybase implementation that can -leverage operating systems' built-in functionalities to securely store secrets. MacOS users may encounter -the following [issue](https://github.com/keybase/go-keychain/issues/47) with the `go-keychain` library. If -you encounter this issue, you must upgrade your xcode command line tools to version >= `10.2`. You can -upgrade via: `sudo rm -rf /Library/Developer/CommandLineTools; xcode-select --install`. Verify the -correct version via: `pkgutil --pkg-info=com.apple.pkg.CLTools_Executables`. -* [\#5355](https://github.com/cosmos/cosmos-sdk/pull/5355) Client commands accept a new `--keyring-backend` option through which users can specify which backend should be used -by the new key store: - * `os`: use OS default credentials storage (default). - * `file`: use encrypted file-based store. - * `kwallet`: use [KDE Wallet](https://utils.kde.org/projects/kwalletmanager/) service. - * `pass`: use the [pass](https://www.passwordstore.org/) command line password manager. - * `test`: use password-less key store. *For testing purposes only. Use it at your own risk.* -* (keys) [\#5097](https://github.com/cosmos/cosmos-sdk/pull/5097) New `keys migrate` command to assist users migrate their keys -to the new keyring. -* (keys) [\#5366](https://github.com/cosmos/cosmos-sdk/pull/5366) `keys list` now accepts a `--list-names` option to list key names only, whilst the `keys delete` -command can delete multiple keys by passing their names as arguments. The aforementioned commands can then be piped together, e.g. -`appcli keys list -n | xargs appcli keys delete` -* (modules) [\#4233](https://github.com/cosmos/cosmos-sdk/pull/4233) Add upgrade module that coordinates software upgrades of live chains. -* [\#4486](https://github.com/cosmos/cosmos-sdk/issues/4486) Introduce new `PeriodicVestingAccount` vesting account type -that allows for arbitrary vesting periods. -* (baseapp) [\#5196](https://github.com/cosmos/cosmos-sdk/pull/5196) Baseapp has a new `runTxModeReCheck` to allow applications to skip expensive and unnecessary re-checking of transactions. -* (types) [\#5196](https://github.com/cosmos/cosmos-sdk/pull/5196) Context has new `IsRecheckTx() bool` and `WithIsReCheckTx(bool) Context` methods to to be used in the `AnteHandler`. -* (x/auth/ante) [\#5196](https://github.com/cosmos/cosmos-sdk/pull/5196) AnteDecorators have been updated to avoid unnecessary checks when `ctx.IsReCheckTx() == true` -* (x/auth) [\#5006](https://github.com/cosmos/cosmos-sdk/pull/5006) Modular `AnteHandler` via composable decorators: - * The `AnteDecorator` interface has been introduced to allow users to implement modular `AnteHandler` - functionality that can be composed together to create a single `AnteHandler` rather than implementing - a custom `AnteHandler` completely from scratch, where each `AnteDecorator` allows for custom behavior in - tightly defined and logically isolated manner. These custom `AnteDecorator` can then be chained together - with default `AnteDecorator` or third-party `AnteDecorator` to create a modularized `AnteHandler` - which will run each `AnteDecorator` in the order specified in `ChainAnteDecorators`. For details - on the new architecture, refer to the [ADR](docs/architecture/adr-010-modular-antehandler.md). - * `ChainAnteDecorators` function has been introduced to take in a list of `AnteDecorators` and chain - them in sequence and return a single `AnteHandler`: - * `SetUpContextDecorator`: Sets `GasMeter` in context and creates defer clause to recover from any - `OutOfGas` panics in future AnteDecorators and return `OutOfGas` error to `BaseApp`. It MUST be the - first `AnteDecorator` in the chain for any application that uses gas (or another one that sets the gas meter). - * `ValidateBasicDecorator`: Calls tx.ValidateBasic and returns any non-nil error. - * `ValidateMemoDecorator`: Validates tx memo with application parameters and returns any non-nil error. - * `ConsumeGasTxSizeDecorator`: Consumes gas proportional to the tx size based on application parameters. - * `MempoolFeeDecorator`: Checks if fee is above local mempool `minFee` parameter during `CheckTx`. - * `DeductFeeDecorator`: Deducts the `FeeAmount` from first signer of the transaction. - * `SetPubKeyDecorator`: Sets pubkey of account in any account that does not already have pubkey saved in state machine. - * `SigGasConsumeDecorator`: Consume parameter-defined amount of gas for each signature. - * `SigVerificationDecorator`: Verify each signature is valid, return if there is an error. - * `ValidateSigCountDecorator`: Validate the number of signatures in tx based on app-parameters. - * `IncrementSequenceDecorator`: Increments the account sequence for each signer to prevent replay attacks. -* (cli) [\#5223](https://github.com/cosmos/cosmos-sdk/issues/5223) Cosmos Ledger App v2.0.0 is now supported. The changes are backwards compatible and App v1.5.x is still supported. -* (x/staking) [\#5380](https://github.com/cosmos/cosmos-sdk/pull/5380) Introduced ability to store historical info entries in staking keeper, allows applications to introspect specified number of past headers and validator sets - * Introduces new parameter `HistoricalEntries` which allows applications to determine how many recent historical info entries they want to persist in store. Default value is 0. - * Introduces cli commands and rest routes to query historical information at a given height -* (modules) [\#5249](https://github.com/cosmos/cosmos-sdk/pull/5249) Funds are now allowed to be directly sent to the community pool (via the distribution module account). -* (keys) [\#4941](https://github.com/cosmos/cosmos-sdk/issues/4941) Introduce keybase option to allow overriding the default private key implementation of a key generated through the `keys add` cli command. -* (keys) [\#5439](https://github.com/cosmos/cosmos-sdk/pull/5439) Flags `--algo` and `--hd-path` are added to - `keys add` command in order to make use of keybase modularized. By default, it uses (0, 0) bip44 - HD path and secp256k1 keys, so is non-breaking. -* (types) [\#5447](https://github.com/cosmos/cosmos-sdk/pull/5447) Added `ApproxRoot` function to sdk.Decimal type in order to get the nth root for a decimal number, where n is a positive integer. - * An `ApproxSqrt` function was also added for convenience around the common case of n=2. - -### Improvements - -* (iavl) [\#5538](https://github.com/cosmos/cosmos-sdk/pull/5538) Remove manual IAVL pruning in favor of IAVL's internal pruning strategy. -* (server) [\#4215](https://github.com/cosmos/cosmos-sdk/issues/4215) The `--pruning` flag -has been moved to the configuration file, to allow easier node configuration. -* (cli) [\#5116](https://github.com/cosmos/cosmos-sdk/issues/5116) The `CLIContext` now supports multiple verifiers -when connecting to multiple chains. The connecting chain's `CLIContext` will have to have the correct -chain ID and node URI or client set. To use a `CLIContext` with a verifier for another chain: - ```go - // main or parent chain (chain as if you're running without IBC) - mainCtx := context.NewCLIContext() - - // connecting IBC chain - sideCtx := context.NewCLIContext(). - WithChainID(sideChainID). - WithNodeURI(sideChainNodeURI) // or .WithClient(...) - - sideCtx = sideCtx.WithVerifier( - context.CreateVerifier(sideCtx, context.DefaultVerifierCacheSize), - ) - ``` -* (modules) [\#5017](https://github.com/cosmos/cosmos-sdk/pull/5017) The `x/auth` package now supports -generalized genesis accounts through the `GenesisAccount` interface. -* (modules) [\#4762](https://github.com/cosmos/cosmos-sdk/issues/4762) Deprecate remove and add permissions in ModuleAccount. -* (modules) [\#4760](https://github.com/cosmos/cosmos-sdk/issues/4760) update `x/auth` to match module spec. -* (modules) [\#4814](https://github.com/cosmos/cosmos-sdk/issues/4814) Add security contact to Validator description. -* (modules) [\#4875](https://github.com/cosmos/cosmos-sdk/issues/4875) refactor integration tests to use SimApp and separate test package -* (sdk) [\#4566](https://github.com/cosmos/cosmos-sdk/issues/4566) Export simulation's parameters and app state to JSON in order to reproduce bugs and invariants. -* (sdk) [\#4640](https://github.com/cosmos/cosmos-sdk/issues/4640) improve import/export simulation errors by extending `DiffKVStores` to return an array of `KVPairs` that are then compared to check for inconsistencies. -* (sdk) [\#4717](https://github.com/cosmos/cosmos-sdk/issues/4717) refactor `x/slashing` to match the new module spec -* (sdk) [\#4758](https://github.com/cosmos/cosmos-sdk/issues/4758) update `x/genaccounts` to match module spec -* (simulation) [\#4824](https://github.com/cosmos/cosmos-sdk/issues/4824) `PrintAllInvariants` flag will print all failed invariants -* (simulation) [\#4490](https://github.com/cosmos/cosmos-sdk/issues/4490) add `InitialBlockHeight` flag to resume a simulation from a given block - - * Support exporting the simulation stats to a given JSON file -* (simulation) [\#4847](https://github.com/cosmos/cosmos-sdk/issues/4847), [\#4838](https://github.com/cosmos/cosmos-sdk/pull/4838) and [\#4869](https://github.com/cosmos/cosmos-sdk/pull/4869) `SimApp` and simulation refactors: - * Implement `SimulationManager` for executing modules' simulation functionalities in a modularized way - * Add `RegisterStoreDecoders` to the `SimulationManager` for decoding each module's types - * Add `GenerateGenesisStates` to the `SimulationManager` to generate a randomized `GenState` for each module - * Add `RandomizedParams` to the `SimulationManager` that registers each modules' parameters in order to - simulate `ParamChangeProposal`s' `Content`s - * Add `WeightedOperations` to the `SimulationManager` that define simulation operations (modules' `Msg`s) with their - respective weights (i.e chance of being simulated). - * Add `ProposalContents` to the `SimulationManager` to register each module's governance proposal `Content`s. -* (simulation) [\#4893](https://github.com/cosmos/cosmos-sdk/issues/4893) Change `SimApp` keepers to be public and add getter functions for keys and codec -* (simulation) [\#4906](https://github.com/cosmos/cosmos-sdk/issues/4906) Add simulation `Config` struct that wraps simulation flags -* (simulation) [\#4935](https://github.com/cosmos/cosmos-sdk/issues/4935) Update simulation to reflect a proper `ABCI` application without bypassing `BaseApp` semantics -* (simulation) [\#5378](https://github.com/cosmos/cosmos-sdk/pull/5378) Simulation tests refactor: - * Add `App` interface for general SDK-based app's methods. - * Refactor and cleanup simulation tests into util functions to simplify their implementation for other SDK apps. -* (store) [\#4792](https://github.com/cosmos/cosmos-sdk/issues/4792) panic on non-registered store -* (types) [\#4821](https://github.com/cosmos/cosmos-sdk/issues/4821) types/errors package added with support for stacktraces. It is meant as a more feature-rich replacement for sdk.Errors in the mid-term. -* (store) [\#1947](https://github.com/cosmos/cosmos-sdk/issues/1947) Implement inter-block (persistent) -caching through `CommitKVStoreCacheManager`. Any application wishing to utilize an inter-block cache -must set it in their app via a `BaseApp` option. The `BaseApp` docs have been drastically improved -to detail this new feature and how state transitions occur. -* (docs/spec) All module specs moved into their respective module dir in x/ (i.e. docs/spec/staking -->> x/staking/spec) -* (docs/) [\#5379](https://github.com/cosmos/cosmos-sdk/pull/5379) Major documentation refactor, including: - * (docs/intro/) Add and improve introduction material for newcomers. - * (docs/basics/) Add documentation about basic concepts of the cosmos sdk such as the anatomy of an SDK application, the transaction lifecycle or accounts. - * (docs/core/) Add documentation about core conepts of the cosmos sdk such as `baseapp`, `server`, `store`s, `context` and more. - * (docs/building-modules/) Add reference documentation on concepts relevant for module developers (`keeper`, `handler`, `messages`, `queries`,...). - * (docs/interfaces/) Add documentation on building interfaces for the Cosmos SDK. - * Redesigned user interface that features new dynamically generated sidebar, build-time code embedding from GitHub, new homepage as well as many other improvements. -* (types) [\#5428](https://github.com/cosmos/cosmos-sdk/pull/5428) Add `Mod` (modulo) method and `RelativePow` (exponentation) function for `Uint`. -* (modules) [\#5506](https://github.com/cosmos/cosmos-sdk/pull/5506) Remove redundancy in `x/distribution`s use of parameters. There - now exists a single `Params` type with a getter and setter along with a getter for each individual parameter. - -### Bug Fixes - -* (client) [\#5303](https://github.com/cosmos/cosmos-sdk/issues/5303) Fix ignored error in tx generate only mode. -* (cli) [\#4763](https://github.com/cosmos/cosmos-sdk/issues/4763) Fix flag `--min-self-delegation` for staking `EditValidator` -* (keys) Fix ledger custom coin type support bug. -* (x/gov) [\#5107](https://github.com/cosmos/cosmos-sdk/pull/5107) Sum validator operator's all voting power when tally votes -* (rest) [\#5212](https://github.com/cosmos/cosmos-sdk/issues/5212) Fix pagination in the `/gov/proposals` handler. - -## [v0.37.14] - 2020-08-12 - -### Improvements - -* (tendermint) Bump Tendermint version to [v0.32.13](https://github.com/tendermint/tendermint/releases/tag/v0.32.13). - - -## [v0.37.13] - 2020-06-03 - -### Improvements - -* (tendermint) Bump Tendermint version to [v0.32.12](https://github.com/tendermint/tendermint/releases/tag/v0.32.12). -* (cosmos-ledger-go) Bump Cosmos Ledger Wallet library version to [v0.11.1](https://github.com/cosmos/ledger-cosmos-go/releases/tag/v0.11.1). - -## [v0.37.12] - 2020-05-05 +* (feat) [\#434](https://github.com/line/lbm-sdk/pull/434) Revert signature mechanism using `sig_block_height` ### Improvements -* (tendermint) Bump Tendermint version to [v0.32.11](https://github.com/tendermint/tendermint/releases/tag/v0.32.11). - -## [v0.37.11] - 2020-04-22 - -### Bug Fixes - -* (x/staking) [\#6021](https://github.com/cosmos/cosmos-sdk/pull/6021) --trust-node's false default value prevents creation of the genesis transaction. - -## [v0.37.10] - 2020-04-22 - ### Bug Fixes +* (x/wasm) [\#436](https://github.com/line/lbm-sdk/pull/436) remove `x/wasm/linkwasmd` -* (client/context) [\#5964](https://github.com/cosmos/cosmos-sdk/issues/5964) Fix incorrect instantiation of tmlite verifier when --trust-node is off. - -## [v0.37.9] - 2020-04-09 - -### Improvements - -* (tendermint) Bump Tendermint version to [v0.32.10](https://github.com/tendermint/tendermint/releases/tag/v0.32.10). - -## [v0.37.8] - 2020-03-11 - -### Bug Fixes - -* (rest) [\#5508](https://github.com/cosmos/cosmos-sdk/pull/5508) Fix `x/distribution` endpoints to properly return height in the response. -* (x/genutil) [\#5499](https://github.com/cosmos/cosmos-sdk/pull/) Ensure `DefaultGenesis` returns valid and non-nil default genesis state. -* (x/genutil) [\#5775](https://github.com/cosmos/cosmos-sdk/pull/5775) Fix `ExportGenesis` in `x/genutil` to export default genesis state (`[]`) instead of `null`. -* (genesis) [\#5086](https://github.com/cosmos/cosmos-sdk/issues/5086) Ensure `gentxs` are always an empty array instead of `nil`. - -### Improvements - -* (rest) [\#5648](https://github.com/cosmos/cosmos-sdk/pull/5648) Enhance /txs usability: - * Add `tx.minheight` key to filter transaction with an inclusive minimum block height - * Add `tx.maxheight` key to filter transaction with an inclusive maximum block height - -## [v0.37.7] - 2020-02-10 - -### Improvements - -* (modules) [\#5597](https://github.com/cosmos/cosmos-sdk/pull/5597) Add `amount` event attribute to the `complete_unbonding` -and `complete_redelegation` events that reflect the total balances of the completed unbondings and redelegations -respectively. - -### Bug Fixes - -* (x/gov) [\#5622](https://github.com/cosmos/cosmos-sdk/pull/5622) Track any events emitted from a proposal's handler upon successful execution. -* (x/bank) [\#5531](https://github.com/cosmos/cosmos-sdk/issues/5531) Added missing amount event to MsgMultiSend, emitted for each output. - -## [v0.37.6] - 2020-01-21 +### Breaking Changes -### Improvements +### Build, CI -* (tendermint) Bump Tendermint version to [v0.32.9](https://github.com/tendermint/tendermint/releases/tag/v0.32.9) +### Document Updates -## [v0.37.5] - 2020-01-07 +## [v0.44.0-rc0](https://github.com/line/lbm-sdk/releases/tag/v0.44.0-rc0) - 2022-02-04 ### Features - -* (types) [\#5360](https://github.com/cosmos/cosmos-sdk/pull/5360) Implement `SortableDecBytes` which - allows the `Dec` type be sortable. +* (feat) [\#352](https://github.com/line/lbm-sdk/pull/352) iavl, db & disk stats logging +* (x/gov) [\#368](https://github.com/line/lbm-sdk/pull/368) Governance Split Votes, use `MsgWeightedVote` to send a split vote. Sending a regular `MsgVote` will convert the underlying vote option into a weighted vote with weight 1. +* (x/upgrade) [\#377](https://github.com/line/lbm-sdk/pull/377) To smoothen the update to the latest stable release, the SDK includes vesion map for managing migrations between SDK versions. +* (x/wasm) [\#358](https://github.com/line/lbm-sdk/pull/358) change wasm metrics method to using prometheus directly +* (x/feegrant) [\#380](https://github.com/line/lbm-sdk/pull/380) Feegrant module +* (x/wasm) [\#395](https://github.com/line/lbm-sdk/pull/395) Add the instantiate_permission in the CodeInfoResponse +* (x/consortium) [\#406](https://github.com/line/lbm-sdk/pull/406) Add CreateValidator access control feature +* (x/bank) [\#400](https://github.com/line/lbm-sdk/pull/400) add `bankplus` function to restrict to send coin to inactive smart contract. ### Improvements - -* (tendermint) Bump Tendermint version to [v0.32.8](https://github.com/tendermint/tendermint/releases/tag/v0.32.8) -* (cli) [\#5482](https://github.com/cosmos/cosmos-sdk/pull/5482) Remove old "tags" nomenclature from the `q txs` command in - favor of the new events system. Functionality remains unchanged except that `=` is used instead of `:` to be - consistent with the API's use of event queries. +* (slashing) [\#347](https://github.com/line/lbm-sdk/pull/347) Introduce VoterSetCounter +* (auth) [\#348](https://github.com/line/lbm-sdk/pull/348) Increase default valid_sig_block_period ### Bug Fixes +* (x/feegrant) [\#383](https://github.com/line/lbm-sdk/pull/383) Update allowance inside AllowedMsgAllowance +* (tm-db) [\#388](https://github.com/line/lbm-sdk/pull/388) Bump up tm-db fixing invalid memory reference +* (swagger) [\#391](https://github.com/line/lbm-sdk/pull/391) fix swagger's config path for wasm +* (x/wasm) [\#393](https://github.com/line/lbm-sdk/pull/393) fix bug where `StoreCodeAndInstantiateContract`, `UpdateContractStatus`, `UpdateContractStatusProposal` API does not work +* (x/slashing) [\#407](https://github.com/line/lbm-sdk/pull/407) Fix query signing infos command -* (iavl) [\#5276](https://github.com/cosmos/cosmos-sdk/issues/5276) Fix potential race condition in `iavlIterator#Close`. -* (baseapp) [\#5350](https://github.com/cosmos/cosmos-sdk/issues/5350) Allow a node to restart successfully - after a `halt-height` or `halt-time` has been triggered. -* (types) [\#5395](https://github.com/cosmos/cosmos-sdk/issues/5395) Fix `Uint#LTE`. -* (types) [\#5408](https://github.com/cosmos/cosmos-sdk/issues/5408) `NewDecCoins` constructor now sorts the coins. - -## [v0.37.4] - 2019-11-04 - -### Improvements +### Breaking Changes +* (x/consortium) [\#411](https://github.com/line/lbm-sdk/pull/411) Validate validator addresses in update-validator-auths proposal -* (tendermint) Bump Tendermint version to [v0.32.7](https://github.com/tendermint/tendermint/releases/tag/v0.32.7) -* (ledger) [\#4716](https://github.com/cosmos/cosmos-sdk/pull/4716) Fix ledger custom coin type support bug. +### Build, CI +* (ci) [\#350](https://github.com/line/lbm-sdk/pull/350) Reduce sim test time +* (ci) [\#351](https://github.com/line/lbm-sdk/pull/351) Remove diff condition from sim-normal -### Bug Fixes +### Document Updates +* (docs) [\#361](https://github.com/line/lbm-sdk/pull/361) Add sample command docs +* (docs) [\#392](https://github.com/line/lbm-sdk/pull/392) Modify with latest version of swagger REST interface docs. -* (baseapp) [\#5200](https://github.com/cosmos/cosmos-sdk/issues/5200) Remove duplicate events from previous messages. -## [v0.37.3] - 2019-10-10 +## [v0.43.1](https://github.com/line/lbm-sdk/releases/tag/v0.43.1) ### Bug Fixes +* (distribution) [\#364](https://github.com/line/lbm-sdk/pull/364) Force genOrBroadcastFn even when max-msgs != 0 +* (bank) [\#366](https://github.com/line/lbm-sdk/pull/366) Check bech32 address format in bank query -* (genesis) [\#5095](https://github.com/cosmos/cosmos-sdk/issues/5095) Fix genesis file migration from v0.34 to -v0.36/v0.37 not converting validator consensus pubkey to bech32 format. - -### Improvements - -* (tendermint) Bump Tendermint version to [v0.32.6](https://github.com/tendermint/tendermint/releases/tag/v0.32.6) - -## [v0.37.1] - 2019-09-19 +## [v0.43.0](https://github.com/line/lbm-sdk/releases/tag/v0.43.0) ### Features - -### Improvements - -### Bug Fixes +* (global) [\#97](https://github.com/line/lbm-sdk/pull/97) Add codespace to query error +* (config) [\#114](https://github.com/line/lbm-sdk/pull/114) Add idle-timeout to rest server and rpc server config +* (x/wasm) [\#127](https://github.com/line/lbm-sdk/pull/127) Add wasm with Staragate migration completed. +* (x/wasm) [\#151](https://github.com/line/lbm-sdk/pull/151) Add contract access control. +* (x/wasm) [\#194](https://github.com/line/lbm-sdk/pull/194) Replace importing CosmWasm/wasmvm with line/wasmvm. +* (x/auth) [\#176](https://github.com/line/lbm-sdk/pull/176) Add MsgEmpty to auth module +* (metric) [\#184](https://github.com/line/lbm-sdk/pull/184) Add prometheus metrics for caches reverting telemetry metrics +* (grpc) [\#291](https://github.com/line/lbm-sdk/pull/291) Add GRPC API the BlockByHash and BlockResultsByHeight, add prove parameter to GetTxsEvent + +### Improvements +* (bump-up) [\#93](https://github.com/line/lbm-sdk/pull/93) Adopt ostracon, line/tm-db and line/iavl +* (bump-up) [\#107](https://github.com/line/lbm-sdk/pull/107) Bump up tm-db, iavl and ostracon +* (script) [\#110](https://github.com/line/lbm-sdk/pull/110) Add script initializing simd +* (bump-up) [\#118](https://github.com/line/lbm-sdk/pull/118) Bump up tm-db and remove Domain() call +* (test) [\#128](https://github.com/line/lbm-sdk/pull/128) Allow creating new test network without init +* (db) [\#136](https://github.com/line/lbm-sdk/pull/136) Fix DB_BACKEND configuration +* (global) [\#140](https://github.com/line/lbm-sdk/pull/140) Modify default coin type, default address prefix +* (perf) [\#141](https://github.com/line/lbm-sdk/pull/141) Concurrent `checkTx` +* (perf) [\#142](https://github.com/line/lbm-sdk/pull/142) Implement `validateGasWanted()` +* (perf) [\#143](https://github.com/line/lbm-sdk/pull/143) Signature verification cache +* (global) [\#145](https://github.com/line/lbm-sdk/pull/145) Modify key type name +* (perf) [\#155](https://github.com/line/lbm-sdk/pull/155) Concurrent recheckTx +* (global) [\#158](https://github.com/line/lbm-sdk/pull/158) Remove tm-db dependency +* (x/wasm) [\#162](https://github.com/line/lbm-sdk/pull/162) Add missed UpdateContractStatusProposal types +* (perf) [\#164](https://github.com/line/lbm-sdk/pull/164) Sse fastcache +* (build) [\#181](https://github.com/line/lbm-sdk/pull/181) Raise codecov-action version to 1.5.0 +* (build) [\#195](https://github.com/line/lbm-sdk/pull/195) Build properly when using libsecp256k1 +* (perf) [\#198](https://github.com/line/lbm-sdk/pull/198) Caching paramset +* (global) [\#200](https://github.com/line/lbm-sdk/pull/200) Add a env prefix +* (store) [\#202](https://github.com/line/lbm-sdk/pull/202) Param store doesn't use gas kv +* (store) [\#203](https://github.com/line/lbm-sdk/pull/203) Remove transient store that is not used now +* (perf) [\#204](https://github.com/line/lbm-sdk/pull/204) Apply rw mutex to cachekv +* (perf) [\#208](https://github.com/line/lbm-sdk/pull/208) Use easyjson instead of amino when marshal abci logs +* (perf) [\#209](https://github.com/line/lbm-sdk/pull/209) Apply async reactor ostracon +* (proto) [\#212](https://github.com/line/lbm-sdk/pull/212) Reformat proto files and restore proto docs +* (perf) [\#216](https://github.com/line/lbm-sdk/pull/216) Memoize bech32 encoding and decoding +* (perf) [\#218](https://github.com/line/lbm-sdk/pull/218) Rootmulti store parallel commit +* (perf) [\#219](https://github.com/line/lbm-sdk/pull/219) Fix bech32 cache to get bech32 from proper cache +* (bump-up) [\#221](https://github.com/line/lbm-sdk/pull/221) Bump up iavl for parallel processing of batches +* (perf) [\#224](https://github.com/line/lbm-sdk/pull/224) Updated log time to have milliseconds +* (bump-up) [\#228](https://github.com/line/lbm-sdk/pull/228) Bump up ostracon to optimize checking the txs size +* (global) [\#230](https://github.com/line/lbm-sdk/pull/230) Modify module name to lfb-sdk +* (bump-up) [\#246](https://github.com/line/lbm-sdk/pull/246) Bump up ostracon to not flush wal when receive consensus msgs +* (wasm) [\#250](https://github.com/line/lbm-sdk/pull/250) Migrate linkwasmd to the latest commit +* (wasm) [\#253](https://github.com/line/lbm-sdk/pull/253) remove MaxGas const +* (wasm) [\#254](https://github.com/line/lbm-sdk/pull/254) Specify wasm event types +* (x) [\#255](https://github.com/line/lbm-sdk/pull/255) Remove legacy from modules +* (perf) [\#320](https:/github.com/line/lbm-sdk/pull/320) internal objects optimization (BaseAccount, Balance & Supply) +* (auth) [\#344](https://github.com/line/lbm-sdk/pull/344) move SigBlockHeight from TxBody into AuthInfo + +### Bug Fixes +* (test) [\#92](https://github.com/line/lbm-sdk/pull/92) Fix SendToModuleAccountTest +* (store) [\#105](https://github.com/line/lbm-sdk/pull/105) Check `store == nil` +* (test) [\#133](https://github.com/line/lbm-sdk/pull/133) Fix `Test_runImportCmd()` +* (config) [\#138](https://github.com/line/lbm-sdk/pull/138) Fix getting coin type at running cmd +* (race) [\#159](https://github.com/line/lbm-sdk/pull/159) Fix test-race failure +* (test) [\#193](https://github.com/line/lbm-sdk/pull/193) Allow to add new validator in test network +* (client) [\#286](https://github.com/line/lbm-sdk/pull/286) Fix invalid type casting for error +* (test) [\#326](https://github.com/line/lbm-sdk/pull/326) Enable sim test and fix address related bug ### Breaking Changes +* (global) [\#90](https://github.com/line/lbm-sdk/pull/90) Revise module path to `github.com/line/lfb-sdk` +* (rpc) [\#97](https://github.com/line/lbm-sdk/pull/97) Send response with 404 status when quering non-exist account +* (proto) [\#106](https://github.com/line/lbm-sdk/pull/106) Rename package of proto files +* (api) [\#130](https://github.com/line/lbm-sdk/pull/130) Rename rest apis +* (auth) [\#265](https://github.com/line/lbm-sdk/pull/265) Introduce sig block height for the new replay protection +* (global) [\#298](https://github.com/line/lbm-sdk/pull/298) Treat addresses as strings +* (ostracon) [\#317](https://github.com/line/lbm-sdk/pull/317) Integrate Ostracon including vrf election and voter concept +* (global) [\#323](https://github.com/line/lfb-sdk/pull/323) Re-brand lfb-sdk to lbm-sdk +* (proto) [\#338](https://github.com/line/lbm-sdk/pull/338) Upgrade proto buf from v1beta1 to v1 ### Build, CI +* (ci) [\#234](https://github.com/line/lbm-sdk/pull/234) Fix branch name in ci script +* (docker) [\#264](https://github.com/line/lbm-sdk/pull/264) Remove docker publish ### Document Updates +* (docs) [\#205](https://github.com/line/lbm-sdk/pull/205) Renewal docs for open source +* (docs) [\#207](https://github.com/line/lbm-sdk/pull/207) Fix license +* (docs) [\#211](https://github.com/line/lbm-sdk/pull/211) Remove codeowners +* (docs) [\#248](https://github.com/line/lbm-sdk/pull/248) Add PR procedure, apply main branch +* (docs) [\#256](https://github.com/line/lbm-sdk/pull/256) Modify copyright and contributing +* (docs) [\#259](https://github.com/line/lbm-sdk/pull/259) Modify copyright, verified from legal team +* (docs) [\#260](https://github.com/line/lbm-sdk/pull/260) Remove gov, ibc and readme of wasm module +* (docs) [\#262](https://github.com/line/lbm-sdk/pull/262) Fix link urls, remove invalid reference +* (docs) [\#328](https://github.com/line/lbm-sdk/pull/328) Update quick start guide + +## [cosmos-sdk v0.42.1] - 2021-03-15 +Initial lbm-sdk is based on the cosmos-sdk v0.42.1 + +* (cosmos-sdk) [v0.42.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.42.1). + +Please refer [CHANGELOG_OF_COSMOS_SDK_v0.42.1](https://github.com/cosmos/cosmos-sdk/blob/v0.42.1/CHANGELOG.md) diff --git a/baseapp/accountwgs_test.go b/baseapp/accountwgs_test.go index 334527e4b3..d2e99d24de 100644 --- a/baseapp/accountwgs_test.go +++ b/baseapp/accountwgs_test.go @@ -77,10 +77,6 @@ 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 35c21c6f61..259b991753 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -696,9 +696,8 @@ 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) GetSigBlockHeight() uint64 { return 0 } +func (tx txTest) GetMsgs() []sdk.Msg { return tx.Msgs } +func (tx txTest) ValidateBasic() error { return nil } const ( routeMsgCounter = "msgCounter" diff --git a/baseapp/msg_service_router_test.go b/baseapp/msg_service_router_test.go index 3a144ee395..68709f1b1f 100644 --- a/baseapp/msg_service_router_test.go +++ b/baseapp/msg_service_router_test.go @@ -103,8 +103,9 @@ func TestMsgService(t *testing.T) { // Second round: all signer infos are set, so each signer can sign. signerData := authsigning.SignerData{ - ChainID: "test", - Sequence: 0, + ChainID: "test", + AccountNumber: 0, + Sequence: 0, } sigV2, err = tx.SignWithPrivKey( encCfg.TxConfig.SignModeHandler().DefaultMode(), signerData, diff --git a/client/account_retriever.go b/client/account_retriever.go index dbe0d2f259..27d8e0364b 100644 --- a/client/account_retriever.go +++ b/client/account_retriever.go @@ -9,6 +9,7 @@ import ( type Account interface { GetAddress() sdk.AccAddress GetPubKey() cryptotypes.PubKey // can return nil. + GetAccountNumber() uint64 GetSequence() uint64 } @@ -17,8 +18,7 @@ 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 - GetAccountSequence(clientCtx Context, addr sdk.AccAddress) (accSeq uint64, err error) + GetAccountNumberSequence(clientCtx Context, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error) } diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 22594d81ec..0de11932d2 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -4926,9 +4926,6 @@ paths: sig_verify_cost_secp256k1: type: string format: uint64 - valid_sig_block_period: - type: string - format: uint64 description: >- QueryParamsResponse is the response type for the Query/Params RPC method. @@ -35180,9 +35177,6 @@ definitions: sig_verify_cost_secp256k1: type: string format: uint64 - valid_sig_block_period: - type: string - format: uint64 description: Params defines the parameters for the auth module. lbm.auth.v1.QueryAccountResponse: type: object @@ -35274,9 +35268,6 @@ definitions: sig_verify_cost_secp256k1: type: string format: uint64 - valid_sig_block_period: - type: string - format: uint64 description: QueryParamsResponse is the response type for the Query/Params RPC method. lbm.bank.v1.DenomUnit: type: object @@ -47143,15 +47134,6 @@ definitions: appropriate fee grant does not exist or the chain does not support fee grants, this will fail - sig_block_height: - type: string - format: uint64 - description: >- - 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. description: |- AuthInfo describes the fee and signer modes that are used to sign a transaction. diff --git a/client/flags/flags.go b/client/flags/flags.go index ce492181fb..0c66780b9a 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -49,7 +49,7 @@ const ( FlagGasAdjustment = "gas-adjustment" FlagFrom = "from" FlagName = "name" - FlagSigBlockHeight = "sig-block-height" + FlagAccountNumber = "account-number" FlagSequence = "sequence" FlagMemo = "memo" FlagFees = "fees" @@ -101,7 +101,7 @@ func AddTxFlagsToCmd(cmd *cobra.Command) { cmd.Flags().StringP(ostcli.OutputFlag, "o", "json", "Output format (text|json)") 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(FlagSigBlockHeight, "n", 0, "The block height to be included in the tx body to protect from replaying") + cmd.Flags().Uint64P(FlagAccountNumber, "a", 0, "The account number of the signing account (offline mode only)") 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 3e7b122bb5..f182d89ffc 100644 --- a/client/test_helpers.go +++ b/client/test_helpers.go @@ -15,6 +15,7 @@ var ( // TestAccount represents a client Account that can be used in unit tests type TestAccount struct { Address sdk.AccAddress + Num uint64 Seq uint64 } @@ -28,6 +29,11 @@ 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 @@ -48,10 +54,6 @@ 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) @@ -71,11 +73,11 @@ func (t TestAccountRetriever) EnsureExists(_ Context, addr sdk.AccAddress) error return nil } -// GetAccountSequence implements AccountRetriever.GetAccountSequence -func (t TestAccountRetriever) GetAccountSequence(_ Context, addr sdk.AccAddress) (accSeq uint64, err error) { +// GetAccountNumberSequence implements AccountRetriever.GetAccountNumberSequence +func (t TestAccountRetriever) GetAccountNumberSequence(_ Context, addr sdk.AccAddress) (accNum uint64, accSeq uint64, err error) { acc, ok := t.Accounts[addr.String()] if !ok { - return 0, fmt.Errorf("account %s not found", addr) + return 0, 0, fmt.Errorf("account %s not found", addr) } - return acc.Seq, nil + return acc.Num, acc.Seq, nil } diff --git a/client/tx/factory.go b/client/tx/factory.go index 6c2483b2a9..a35cb50158 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 - sigBlockHeight uint64 + accountNumber 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 } - sigBlockHeight, _ := flagSet.GetUint64(flags.FlagSigBlockHeight) + accNum, _ := flagSet.GetUint64(flags.FlagAccountNumber) 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, - sigBlockHeight: sigBlockHeight, + accountNumber: accNum, sequence: accSeq, timeoutHeight: timeoutHeight, gasAdjustment: gasAdj, @@ -74,7 +74,7 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory { return f } -func (f Factory) SigBlockHeight() uint64 { return f.sigBlockHeight } +func (f Factory) AccountNumber() uint64 { return f.accountNumber } 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 } -// WithSigBlockHeight returns a copy of the Factory with an updated sig block height. -func (f Factory) WithSigBlockHeight(sigBlockHeight uint64) Factory { - f.sigBlockHeight = sigBlockHeight +// WithAccountNumber returns a copy of the Factory with an updated account number. +func (f Factory) WithAccountNumber(accnum uint64) Factory { + f.accountNumber = accnum return f } diff --git a/client/tx/legacy.go b/client/tx/legacy.go index 9ad4e4d426..e37d7a7b36 100644 --- a/client/tx/legacy.go +++ b/client/tx/legacy.go @@ -61,7 +61,6 @@ 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 6a4fdb6d04..6363c68120 100644 --- a/client/tx/legacy_test.go +++ b/client/tx/legacy_test.go @@ -23,7 +23,6 @@ import ( const ( memo = "waboom" gas = uint64(10000) - sbh = 1 timeoutHeight = 5 ) @@ -45,7 +44,6 @@ 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 841fa5ed30..4f4addc8f8 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -156,7 +156,7 @@ func WriteGeneratedTxResponse( } txf := Factory{fees: br.Fees, gasPrices: br.GasPrices}. - WithSigBlockHeight(br.SigBlockHeight). + WithAccountNumber(br.AccountNumber). WithSequence(br.Sequence). WithGas(gasSetting.Gas). WithGasAdjustment(gasAdj). @@ -241,7 +241,6 @@ 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 @@ -304,36 +303,30 @@ func CalculateGas( return simRes, uint64(txf.GasAdjustment() * float64(simRes.GasInfo.GasUsed)), nil } -// 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. +// 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. func PrepareFactory(clientCtx client.Context, txf Factory) (Factory, error) { from := clientCtx.GetFromAddress() - sigBlockHeight := txf.sigBlockHeight - if !clientCtx.Offline { - if sigBlockHeight == 0 { - height, err := txf.accountRetriever.GetLatestHeight(clientCtx) - if err != nil { - return txf, err - } - // `ctx.Height` of checkTx may be later by 1 block than consensus block height. - // Some cli integrated test fails because of this(sigBlockHeight = height). - sigBlockHeight = height - 1 - } + if err := txf.accountRetriever.EnsureExists(clientCtx, from); err != nil { + return txf, err } - txf = txf.WithSigBlockHeight(sigBlockHeight) - - initSeq := txf.sequence - if initSeq == 0 && !clientCtx.Offline { - seq, err := txf.accountRetriever.GetAccountSequence(clientCtx, from) + initNum, initSeq := txf.accountNumber, txf.sequence + if initNum == 0 || initSeq == 0 { + num, seq, err := txf.accountRetriever.GetAccountNumberSequence(clientCtx, from) if err != nil { if cliError, ok := err.(*client.Error); !ok || cliError.Code != sdkerrors.ErrKeyNotFound.ABCICode() { return txf, err } } + if initNum == 0 { + txf = txf.WithAccountNumber(num) + } + if initSeq == 0 { txf = txf.WithSequence(seq) } @@ -412,8 +405,9 @@ func Sign(txf Factory, name string, txBuilder client.TxBuilder, overwriteSig boo } pubKey := key.GetPubKey() signerData := authsigning.SignerData{ - ChainID: txf.chainID, - Sequence: txf.sequence, + ChainID: txf.chainID, + AccountNumber: txf.accountNumber, + 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 89a292a070..68e02ff897 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). - WithSigBlockHeight(1). + WithAccountNumber(50). 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()). - WithSigBlockHeight(1). + WithAccountNumber(50). WithSequence(23). WithFees("50stake"). WithMemo("memo"). @@ -148,7 +148,7 @@ func TestSign(t *testing.T) { txfNoKeybase := tx.Factory{}. WithTxConfig(NewTestTxConfig()). - WithSigBlockHeight(1). + WithAccountNumber(50). WithSequence(23). WithFees("50stake"). WithMemo("memo"). diff --git a/client/tx_config.go b/client/tx_config.go index 68bc73477d..bfa8f8c9ce 100644 --- a/client/tx_config.go +++ b/client/tx_config.go @@ -39,7 +39,6 @@ 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 9c7274dca9..7df62adf59 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":"lbm-sdk/StdTx","value":{"msg":[{"type":"lbm-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"}}` + txSigned := `{"type":"lbm-sdk/StdTx","value":{"msg":[{"type":"lbm-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"}}` _, legacyCdc := simapp.MakeCodecs() var tx legacytx.StdTx diff --git a/crypto/ledger/ledger_test.go b/crypto/ledger/ledger_test.go index d08aefaf3d..6cf51553d3 100644 --- a/crypto/ledger/ledger_test.go +++ b/crypto/ledger/ledger_test.go @@ -196,16 +196,17 @@ func TestPublicKeyHDPath(t *testing.T) { } } -func getFakeTx() []byte { +func getFakeTx(accountNumber uint32) []byte { tmp := fmt.Sprintf( - `{"chain_id":"1234","fee":{"amount":[{"amount":"150","denom":"atom"}],"gas":"5000"},"memo":"memo","msgs":[[""]],"sequence":"6"}`) + `{"account_number":"%d","chain_id":"1234","fee":{"amount":[{"amount":"150","denom":"atom"}],"gas":"5000"},"memo":"memo","msgs":[[""]],"sequence":"6"}`, + accountNumber) return []byte(tmp) } func TestSignaturesHD(t *testing.T) { for account := uint32(0); account < 100; account += 30 { - msg := getFakeTx() + msg := getFakeTx(account) path := *hd.NewFundraiserParams(account, sdk.CoinType, account/5) t.Logf("Checking signature at %v --- PLEASE REVIEW AND ACCEPT IN THE DEVICE\n", path) @@ -223,7 +224,7 @@ func TestSignaturesHD(t *testing.T) { } func TestRealDeviceSecp256k1(t *testing.T) { - msg := getFakeTx() + msg := getFakeTx(50) 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 8fb484b248..713b3c476b 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -4133,6 +4133,7 @@ type for additional functionality (e.g. vesting). | `ed25519_pub_key` | [lbm.crypto.ed25519.PubKey](#lbm.crypto.ed25519.PubKey) | | | | `secp256k1_pub_key` | [lbm.crypto.secp256k1.PubKey](#lbm.crypto.secp256k1.PubKey) | | | | `multisig_pub_key` | [lbm.crypto.multisig.LegacyAminoPubKey](#lbm.crypto.multisig.LegacyAminoPubKey) | | | +| `account_number` | [uint64](#uint64) | | | | `sequence` | [uint64](#uint64) | | | @@ -4170,7 +4171,6 @@ 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) | | | @@ -10168,7 +10168,6 @@ transaction. | ----- | ---- | ----- | ----------- | | `signer_infos` | [SignerInfo](#lbm.tx.v1.SignerInfo) | repeated | signer_infos defines the signing modes for the required signers. The number and order of elements must match the required signers from TxBody's messages. The first element is the primary signer and the one which pays the fee. | | `fee` | [Fee](#lbm.tx.v1.Fee) | | Fee is the fee and gas limit for the transaction. The first signer is the primary signer and the one which pays the fee. The fee can be calculated based on the cost of evaluating the body and doing signature verification of the signers. This can be estimated via simulation. | -| `sig_block_height` | [uint64](#uint64) | | 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. | @@ -10255,6 +10254,7 @@ 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 | diff --git a/proto/lbm/auth/v1/auth.proto b/proto/lbm/auth/v1/auth.proto index 741c532e6d..db693d5e89 100644 --- a/proto/lbm/auth/v1/auth.proto +++ b/proto/lbm/auth/v1/auth.proto @@ -26,7 +26,8 @@ message BaseAccount { [(gogoproto.jsontag) = "secp256k1_public_key,omitempty", (gogoproto.moretags) = "yaml:\"secp256k1_public_key\""]; lbm.crypto.multisig.LegacyAminoPubKey multisig_pub_key = 4 [(gogoproto.jsontag) = "multisig_public_key,omitempty", (gogoproto.moretags) = "yaml:\"multisig_public_key\""]; - uint64 sequence = 5; + uint64 account_number = 5 [(gogoproto.moretags) = "yaml:\"account_number\""]; + uint64 sequence = 6; } // ModuleAccount defines an account for modules that holds coins on a pool. @@ -52,5 +53,4 @@ 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/lbm/tx/v1/tx.proto b/proto/lbm/tx/v1/tx.proto index 265151e4fc..f150aaddf0 100644 --- a/proto/lbm/tx/v1/tx.proto +++ b/proto/lbm/tx/v1/tx.proto @@ -58,6 +58,9 @@ 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. @@ -103,10 +106,6 @@ message AuthInfo { // based on the cost of evaluating the body and doing signature verification // of the signers. This can be estimated via simulation. Fee fee = 2; - - // 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 = 3; } // SignerInfo describes the public key and signing mode of a single top-level diff --git a/server/mock/tx.go b/server/mock/tx.go index 0ef966bccc..4fcd86e44b 100644 --- a/server/mock/tx.go +++ b/server/mock/tx.go @@ -53,10 +53,6 @@ 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 ed9bb5f4be..b521502724 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) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0, 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), + BaseAccount: authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), }, true, }, { "valid basic account with module name", simapp.SimGenesisAccount{ - BaseAccount: authtypes.NewBaseAccount(sdk.BytesToAccAddress(crypto.AddressHash([]byte("testmod"))), nil, 0), + BaseAccount: authtypes.NewBaseAccount(sdk.BytesToAccAddress(crypto.AddressHash([]byte("testmod"))), nil, 0, 0), ModuleName: "testmod", }, false, diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index 22f425f03a..4e6352f85a 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, sbh, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { +func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, 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, - Sequence: accSeqs[i], + ChainID: chainID, + AccountNumber: accNums[i], + 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 9597e3c87e..bd7e1b80fc 100644 --- a/simapp/simd/cmd/genaccounts.go +++ b/simapp/simd/cmd/genaccounts.go @@ -86,7 +86,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) + baseAccount := authtypes.NewBaseAccount(addr, nil, 0, 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 a692b6feb5..7016e54ed8 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)) + genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) valTokens := sdk.TokensFromConsensusPower(100) createValMsg, err := stakingtypes.NewMsgCreateValidator( diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 02e3c2b1ed..39f2d28781 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -374,7 +374,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 ocproto.Header, msgs []sdk.Msg, - chainID string, sbh, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, + chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { tx, err := helpers.GenTx( @@ -383,7 +383,7 @@ func SignCheckDeliver( sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, helpers.DefaultGenTxGas, chainID, - sbh, + accNums, accSeqs, priv..., ) diff --git a/simapp/utils_test.go b/simapp/utils_test.go index b585bfed66..a5f6d446c1 100644 --- a/simapp/utils_test.go +++ b/simapp/utils_test.go @@ -41,6 +41,8 @@ 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" } @@ -54,6 +56,11 @@ 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 9cbf433945..855ea5f930 100644 --- a/tests/mocks/account_retriever.go +++ b/tests/mocks/account_retriever.go @@ -63,6 +63,20 @@ 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() @@ -145,18 +159,18 @@ func (mr *MockAccountRetrieverMockRecorder) EnsureExists(clientCtx, addr interfa return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsureExists", reflect.TypeOf((*MockAccountRetriever)(nil).EnsureExists), clientCtx, addr) } -// GetAccountSequence mocks base method -func (m *MockAccountRetriever) GetAccountSequence(clientCtx client.Context, addr types0.AccAddress) (uint64, uint64, error) { +// GetAccountNumberSequence mocks base method +func (m *MockAccountRetriever) GetAccountNumberSequence(clientCtx client.Context, addr types0.AccAddress) (uint64, uint64, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAccountSequence", clientCtx, addr) + ret := m.ctrl.Call(m, "GetAccountNumberSequence", clientCtx, addr) ret0, _ := ret[0].(uint64) ret1, _ := ret[1].(uint64) ret2, _ := ret[2].(error) return ret0, ret1, ret2 } -// GetAccountSequence indicates an expected call of GetAccountSequence -func (mr *MockAccountRetrieverMockRecorder) GetAccountSequence(clientCtx, addr interface{}) *gomock.Call { +// GetAccountNumberSequence indicates an expected call of GetAccountNumberSequence +func (mr *MockAccountRetrieverMockRecorder) GetAccountNumberSequence(clientCtx, addr interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountSequence", reflect.TypeOf((*MockAccountRetriever)(nil).GetAccountSequence), clientCtx, addr) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountNumberSequence", reflect.TypeOf((*MockAccountRetriever)(nil).GetAccountNumberSequence), clientCtx, addr) } diff --git a/testutil/network/network.go b/testutil/network/network.go index 379127e0f8..978a832237 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)) + genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) commission, err := sdk.NewDecFromStr("0.5") require.NoError(t, err) diff --git a/types/errors/errors.go b/types/errors/errors.go index 9e43917e64..9d880f81a0 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -134,10 +134,6 @@ 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") - // ErrNotFound defines an error when requested entity doesn't exist in the state. ErrNotFound = Register(RootCodespace, 39, "not found") diff --git a/types/rest/rest.go b/types/rest/rest.go index 89b868dccd..636bcfcc93 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"` - 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"` + 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"` } // NewBaseReq creates a new basic request instance and sanitizes its values func NewBaseReq( - from, memo, chainID string, gas, gasAdjustment string, signBlockHeight, seq uint64, + from, memo, chainID string, gas, gasAdjustment string, accNumber, 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), - SigBlockHeight: signBlockHeight, - 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), + AccountNumber: accNumber, + 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.SigBlockHeight, br.Sequence, br.Fees, br.GasPrices, br.Simulate, + br.AccountNumber, br.Sequence, br.Fees, br.GasPrices, br.Simulate, ) } diff --git a/types/rest/rest_test.go b/types/rest/rest_test.go index ef1f379083..3040053f6c 100644 --- a/types/rest/rest_test.go +++ b/types/rest/rest_test.go @@ -180,10 +180,11 @@ func TestProcessPostResponse(t *testing.T) { t.Parallel() type mockAccount struct { - Address types.AccAddress `json:"address"` - Coins types.Coins `json:"coins"` - PubKey cryptotypes.PubKey `json:"public_key"` - Sequence uint64 `json:"sequence"` + 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"` } // setup @@ -195,9 +196,10 @@ 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, sequence} + acc := mockAccount{addr, coins, pubKey, accNumber, sequence} cdc := codec.NewLegacyAmino() cryptocodec.RegisterCrypto(cdc) cdc.RegisterConcrete(&mockAccount{}, "lbm-sdk/mockAccount", nil) diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index 9d4bbfaa8e..54df318d69 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -179,6 +179,8 @@ 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{} } @@ -235,6 +237,13 @@ 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 @@ -341,9 +350,6 @@ type AuthInfo struct { // based on the cost of evaluating the body and doing signature verification // of the signers. This can be estimated via simulation. Fee *Fee `protobuf:"bytes,2,opt,name=fee,proto3" json:"fee,omitempty"` - // 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. - SigBlockHeight uint64 `protobuf:"varint,3,opt,name=sig_block_height,json=sigBlockHeight,proto3" json:"sig_block_height,omitempty"` } func (m *AuthInfo) Reset() { *m = AuthInfo{} } @@ -393,13 +399,6 @@ func (m *AuthInfo) GetFee() *Fee { return nil } -func (m *AuthInfo) GetSigBlockHeight() uint64 { - if m != nil { - return m.SigBlockHeight - } - return 0 -} - // SignerInfo describes the public key and signing mode of a single top-level // signer. type SignerInfo struct { @@ -759,60 +758,60 @@ func init() { func init() { proto.RegisterFile("lbm/tx/v1/tx.proto", fileDescriptor_f80bf4f3a3e5da31) } var fileDescriptor_f80bf4f3a3e5da31 = []byte{ - // 835 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0x1c, 0x45, - 0x10, 0xde, 0xd9, 0x3f, 0xef, 0x96, 0x1d, 0x27, 0x69, 0x0c, 0x5a, 0xaf, 0xc5, 0x7a, 0xb5, 0xc8, - 0xb0, 0x12, 0x62, 0x26, 0x76, 0x38, 0x00, 0x37, 0xaf, 0x21, 0x72, 0x04, 0x11, 0xd2, 0xd8, 0xe2, - 0x90, 0xcb, 0xa8, 0x67, 0xb6, 0xdd, 0xdb, 0xf2, 0x4c, 0xf7, 0x32, 0xdd, 0x63, 0x76, 0x0e, 0x48, - 0xbc, 0x01, 0xb9, 0xf0, 0x12, 0x79, 0x02, 0x1e, 0x21, 0xc7, 0x1c, 0x39, 0x01, 0xb2, 0x1f, 0x04, - 0xd4, 0x3f, 0x33, 0x18, 0x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, 0xf6, 0x14, 0xa8, 0x55, - 0xdc, 0x35, 0xa3, 0xf8, 0xf8, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x34, 0x82, 0xea, 0x2b, 0x75, - 0x06, 0x00, 0x00, + // 833 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0xcd, 0x6e, 0x23, 0x45, + 0x10, 0xf6, 0xf8, 0x2f, 0x9e, 0xca, 0xcf, 0xb2, 0x4d, 0x40, 0x8e, 0x23, 0x1c, 0xcb, 0x28, 0x60, + 0x09, 0x31, 0xb3, 0xc9, 0x72, 0x00, 0x6e, 0x71, 0x60, 0x95, 0x15, 0x2c, 0x48, 0x9d, 0x88, 0xc3, + 0x5e, 0x46, 0x3d, 0xe3, 0xf6, 0xb8, 0xb5, 0xd3, 0xdd, 0x66, 0xba, 0x27, 0xd8, 0x07, 0x24, 0xde, + 0x00, 0x84, 0xc4, 0x4b, 0xec, 0x13, 0xf0, 0x08, 0x7b, 0xdc, 0x23, 0x27, 0x40, 0xc9, 0x83, 0x80, + 0xba, 0xa7, 0x67, 0x88, 0x50, 0x12, 0x2e, 0xdc, 0xea, 0xe7, 0xab, 0xaa, 0x4f, 0xf5, 0x07, 0x28, + 0x8b, 0x79, 0xa8, 0x57, 0xe1, 0xe5, 0x51, 0xa8, 0x57, 0xc1, 0x32, 0x97, 0x5a, 0x22, 0x3f, 0x8b, + 0x79, 0xa0, 0x57, 0xc1, 0xe5, 0xd1, 0x60, 0x37, 0x95, 0xa9, 0xb4, 0xd6, 0xd0, 0x48, 0x25, 0x60, + 0x70, 0x68, 0x82, 0x92, 0x7c, 0xbd, 0xd4, 0x32, 0xe4, 0x45, 0xa6, 0x99, 0x62, 0xa9, 0xc9, 0x50, + 0xc9, 0x0e, 0xf6, 0xb6, 0x81, 0xc5, 0x44, 0x51, 0xe3, 0x4b, 0x24, 0x13, 0xce, 0x7e, 0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f0, 0xea, 0xf7, 0x83, 0xc6, 0xcb, 0x3f, 0x0e, 0xde, 0x4d, 0x99, 0x5e, 0x14, + 0x71, 0x90, 0x48, 0x1e, 0x66, 0x4c, 0xd0, 0x30, 0x8b, 0xf9, 0x87, 0x6a, 0xf6, 0x22, 0xd4, 0xeb, + 0x25, 0x55, 0x16, 0xab, 0xb0, 0xcb, 0x86, 0xf6, 0xc1, 0x4f, 0x89, 0x8a, 0x32, 0xc6, 0x99, 0xb6, + 0xbd, 0x6d, 0xe3, 0x5e, 0x4a, 0xd4, 0x97, 0x46, 0x47, 0xbb, 0xd0, 0x59, 0x92, 0x35, 0xcd, 0xdd, + 0x23, 0x28, 0x15, 0xd4, 0x87, 0x8d, 0x34, 0x27, 0x42, 0xbb, 0xfb, 0xf7, 0x71, 0xa5, 0x4e, 0x3f, + 0x7d, 0x75, 0x35, 0xf4, 0x5e, 0x5f, 0x0d, 0xbd, 0x3f, 0xaf, 0x86, 0xde, 0x4f, 0xd7, 0xc3, 0xc6, + 0xeb, 0xeb, 0x61, 0xe3, 0xb7, 0xeb, 0x61, 0xe3, 0xf9, 0xe8, 0x5e, 0x4e, 0xa1, 0x5e, 0xc5, 0x5d, + 0xbb, 0x8a, 0x8f, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x32, 0xb7, 0x97, 0x08, 0x72, 0x06, 0x00, + 0x00, } func (m *Tx) Marshal() (dAtA []byte, err error) { @@ -937,6 +936,11 @@ 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) @@ -1062,11 +1066,6 @@ func (m *AuthInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.SigBlockHeight != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.SigBlockHeight)) - i-- - dAtA[i] = 0x18 - } if m.Fee != nil { { size, err := m.Fee.MarshalToSizedBuffer(dAtA[:i]) @@ -1430,6 +1429,9 @@ 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 } @@ -1483,9 +1485,6 @@ func (m *AuthInfo) Size() (n int) { l = m.Fee.Size() n += 1 + l + sovTx(uint64(l)) } - if m.SigBlockHeight != 0 { - n += 1 + sovTx(uint64(m.SigBlockHeight)) - } return n } @@ -2041,6 +2040,25 @@ 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:]) @@ -2364,25 +2382,6 @@ func (m *AuthInfo) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: - 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 - } - } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/types/tx/types.go b/types/tx/types.go index 57b70e5545..0b48409b12 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -143,10 +143,6 @@ func (t *Tx) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { return nil } -func (t *Tx) GetSigBlockHeight() uint64 { - return t.AuthInfo.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 ec7af0a725..c52c8d250e 100644 --- a/types/tx_msg.go +++ b/types/tx_msg.go @@ -54,9 +54,6 @@ 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 5b69eee2ef..5e89e8c7e2 100644 --- a/x/auth/ante/ante.go +++ b/x/auth/ante/ante.go @@ -10,7 +10,7 @@ import ( ) // NewAnteHandler returns an AnteHandler that checks and increments sequence -// numbers, checks signatures & sig block height, and deducts fees from the first +// numbers, checks signatures & account numbers, and deducts fees from the first // signer. func NewAnteHandler( ak AccountKeeper, bankKeeper types.BankKeeper, feegrantKeeper keeper.Keeper, @@ -22,11 +22,11 @@ func NewAnteHandler( NewRejectExtensionOptionsDecorator(), NewMempoolFeeDecorator(), NewValidateBasicDecorator(), - NewTxSigBlockHeightDecorator(ak), TxTimeoutHeightDecorator{}, NewValidateMemoDecorator(ak), NewConsumeGasForTxSizeDecorator(ak), NewDeductGrantedFeeDecorator(ak.(keeper2.AccountKeeper), bankKeeper.(types2.BankKeeper), feegrantKeeper), + // NewRejectFeeGranterDecorator(), // todo: Please check it when upgrade `feegrant` // 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 diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 65db7afb65..5e44c34013 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} - sbh := []uint64{0, 1, 1} + accNums := []uint64{0, 1, 2} testCases := []TestCase{ { @@ -69,7 +69,7 @@ func (suite *AnteTestSuite) TestSimulateGasCost() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, sbh, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } @@ -92,7 +92,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { // Variable data per test case var ( privs []cryptotypes.PrivKey - sbh []uint64 + accNums []uint64 accSeqs []uint64 ) @@ -100,11 +100,11 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { { "check no signatures fails", func() { - privs, sbh, accSeqs = []cryptotypes.PrivKey{}, []uint64{}, []uint64{} + privs, accNums, 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, sbh, accSeqs, suite.ctx.ChainID()) + tx, err := suite.CreateTestTx(privs, accNums, 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, sbh, accSeqs = []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} }, false, false, @@ -126,7 +126,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { { "unrecognized account", func() { - privs, sbh, accSeqs = []cryptotypes.PrivKey{priv0, priv1, priv2}, []uint64{0, 0, 0}, []uint64{0, 0, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{priv0, priv1, priv2}, []uint64{0, 1, 2}, []uint64{0, 0, 0} }, false, false, @@ -141,8 +141,8 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { suite.Require().NoError(err) }, false, - true, - nil, // unknown account may send tx; now they have enough money to pay fee + false, + sdkerrors.ErrUnknownAddress, }, } @@ -151,17 +151,15 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, sbh, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } -// Test logic around sig block height checking with one signer and many signers. -func (suite *AnteTestSuite) TestAnteHandlerSigBlockHeight() { +// Test logic around account number checking with one signer and many signers. +func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { suite.SetupTest(false) // reset - suite.ctx = suite.ctx.WithBlockHeight(5000) // init block height is 5000 - // Same data for every test cases accounts := suite.CreateTestAccounts(2) feeAmount := testdata.NewTestFeeAmount() @@ -169,7 +167,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigBlockHeight() { // Variable data per test case var ( - sbh []uint64 + accNums []uint64 msgs []sdk.Msg privs []cryptotypes.PrivKey accSeqs []uint64 @@ -182,46 +180,46 @@ func (suite *AnteTestSuite) TestAnteHandlerSigBlockHeight() { msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) msgs = []sdk.Msg{msg} - privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{3600}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, true, nil, }, { - "new tx from wrong sig block height", + "new tx from wrong account number", func() { - privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} }, false, false, - sdkerrors.ErrInvalidSigBlockHeight, + sdkerrors.ErrUnauthorized, }, { - "new tx from correct sig block height", + "new tx from correct account number", func() { - privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{3600}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} }, false, true, nil, }, { - "new tx with another signer and incorrect sig block height", + "new tx with another signer and incorrect account numbers", 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, sbh, 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, 0}, []uint64{2, 0} }, false, false, - sdkerrors.ErrInvalidSigBlockHeight, + sdkerrors.ErrUnauthorized, }, { - "new tx with correct sig block height", + "new tx with correct account numbers", func() { - privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{3600, 3601}, []uint64{2, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{2, 0} }, false, true, @@ -234,13 +232,13 @@ func (suite *AnteTestSuite) TestAnteHandlerSigBlockHeight() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, sbh, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } -// Test logic around sig block height checking with many signers when BlockHeight is 0. -func (suite *AnteTestSuite) TestAnteHandlerSigBlockHeightAtBlockHeightZero() { +// Test logic around account number checking with many signers when BlockHeight is 0. +func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { suite.SetupTest(false) // setup suite.ctx = suite.ctx.WithBlockHeight(0) @@ -271,16 +269,16 @@ func (suite *AnteTestSuite) TestAnteHandlerSigBlockHeightAtBlockHeightZero() { nil, }, { - "new tx from wrong sig block height", + "new tx from wrong account number", func() { privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} }, false, false, - sdkerrors.ErrInvalidSigBlockHeight, + sdkerrors.ErrUnauthorized, }, { - "new tx from correct sig block height", + "new tx from correct account number", func() { privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} }, @@ -289,20 +287,20 @@ func (suite *AnteTestSuite) TestAnteHandlerSigBlockHeightAtBlockHeightZero() { nil, }, { - "new tx with another signer and incorrect sig block height", + "new tx with another signer and incorrect account numbers", 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, 1}, []uint64{2, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{1, 0}, []uint64{2, 0} }, false, false, - sdkerrors.ErrInvalidSigBlockHeight, + sdkerrors.ErrUnauthorized, }, { - "new tx with another signer and correct sig block height", + "new tx with another signer and correct account numbers", 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} @@ -378,7 +376,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, 0, 0}, []uint64{2, 0, 0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{2, 0, 0} }, false, true, @@ -396,7 +394,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{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0} }, false, false, @@ -417,7 +415,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, 0}, []uint64{3, 2} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{3, 2} }, false, true, @@ -602,14 +600,13 @@ 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{1, 1, 1}, []uint64{0, 0, 0} - suite.txBuilder.SetMemo("Check signers are in expected order works") + 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") }, false, true, @@ -619,7 +616,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{1, 1}, []uint64{1, 1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{1, 1} }, false, true, @@ -629,7 +626,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{1, 1}, []uint64{1, 2} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[2].priv, accounts[0].priv}, []uint64{2, 0}, []uint64{1, 2} }, false, true, @@ -639,7 +636,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{1, 1, 1}, []uint64{3, 2, 2} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{3, 2, 2} }, false, true, @@ -666,7 +663,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { // Variable data per test case var ( - sbh []uint64 + accNums []uint64 chainID string feeAmount sdk.Coins gasLimit uint64 @@ -683,7 +680,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { feeAmount = testdata.NewTestFeeAmount() gasLimit = testdata.NewTestGasLimit() msgs = []sdk.Msg{msg0} - privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, true, @@ -710,19 +707,18 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { sdkerrors.ErrWrongSequence, }, { - "test wrong sig block height", + "test wrong accNums", func() { accSeqs = []uint64{1} // Back to correct accSeqs - sbh = []uint64{2} + accNums = []uint64{1} }, false, false, - sdkerrors.ErrInvalidSigBlockHeight, + sdkerrors.ErrUnauthorized, }, { "test wrong msg", func() { - sbh = []uint64{0} // Back to correct sig block height msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} }, false, @@ -730,8 +726,6 @@ 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 @@ -739,30 +733,26 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { gasLimit = testdata.NewTestGasLimit() + 100 }, false, - true, - nil, + false, + sdkerrors.ErrUnauthorized, }, { - // 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, - true, - nil, + false, + sdkerrors.ErrUnauthorized, }, { "test wrong signer if public key exist", func() { - accSeqs = []uint64{3} feeAmount = testdata.NewTestFeeAmount() gasLimit = testdata.NewTestGasLimit() - privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{0}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{0}, []uint64{1} }, false, false, @@ -772,7 +762,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { "test wrong signer if public doesn't exist", func() { msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} - privs, sbh, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{0} }, false, false, @@ -785,7 +775,7 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, sbh, accSeqs, chainID, tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, chainID, tc) }) } } @@ -981,7 +971,7 @@ func (suite *AnteTestSuite) TestAnteHandlerSigLimitExceeded() { privs = append(privs, accounts[i].priv) } msgs := []sdk.Msg{testdata.NewTestMsg(addrs...)} - accNums, accSeqs := []uint64{0, 0, 0, 0, 0, 0, 0, 0}, []uint64{0, 0, 0, 0, 0, 0, 0, 0} + accNums, accSeqs := []uint64{0, 1, 2, 3, 4, 5, 6, 7}, []uint64{0, 0, 0, 0, 0, 0, 0, 0} feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() @@ -1012,14 +1002,14 @@ func (suite *AnteTestSuite) TestCustomSignatureVerificationGasConsumer() { // setup an ante handler that only accepts PubKeyEd25519 suite.anteHandler = ante.NewAnteHandler(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.FeeGrantKeeper, func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error { - switch pubkey := sig.PubKey.(type) { - case *ed25519.PubKey: - meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519") - return nil - default: - return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey) - } - }, suite.clientCtx.TxConfig.SignModeHandler()) + switch pubkey := sig.PubKey.(type) { + case *ed25519.PubKey: + meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519") + return nil + default: + return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey) + } + }, suite.clientCtx.TxConfig.SignModeHandler()) // Same data for every test cases accounts := suite.CreateTestAccounts(1) @@ -1102,9 +1092,9 @@ func (suite *AnteTestSuite) TestAnteHandlerReCheck() { name string params types.Params }{ - {"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)}, + {"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)}, } for _, tc := range testCases { // set testcase parameters diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go index ed08d32720..a060ed14c3 100644 --- a/x/auth/ante/basic.go +++ b/x/auth/ante/basic.go @@ -200,32 +200,3 @@ 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 08200e18d7..6770b38eb2 100644 --- a/x/auth/ante/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -8,7 +8,6 @@ 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 3ca399f1a0..18ab9b2889 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -82,7 +82,11 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } feePayer := feeTx.FeePayer() - feePayerAcc := dfd.ak.NewAccountWithAddress(ctx, feePayer) + feePayerAcc := dfd.ak.GetAccount(ctx, feePayer) + + if feePayerAcc == nil { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "fee payer address: %s does not exist", feePayer) + } // deduct the fees if !feeTx.GetFee().IsZero() { diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index c4e2ebcdc1..cb3c064eeb 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -80,11 +80,8 @@ func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b acc, err := GetSignerAcc(ctx, spkd.ak, signers[i]) if err != nil { - // 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]) + return ctx, err } - // account already has pubkey set,no need to reset if acc.GetPubKey() != nil { continue @@ -93,7 +90,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) // After here, we can call `GetAccount` or `GetSignerAcc` from other ante handlers + spkd.ak.SetAccount(ctx, acc) } // Also emit the following events, so that txs can be indexed by these @@ -155,7 +152,7 @@ func (sgcd SigGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simula return ctx, err } - // stdSigs contains the sequence number, signatures. + // stdSigs contains the sequence number, account number, and signatures. // When simulating, this would just be a 0-length slice. signerAddrs := sigTx.GetSigners() @@ -242,7 +239,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, signatures. + // stdSigs contains the sequence number, account number, and signatures. // When simulating, this would just be a 0-length slice. sigs, err := sigTx.GetSignaturesV2() if err != nil { @@ -301,14 +298,18 @@ 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, - Sequence: acc.GetSequence(), + ChainID: chainID, + AccountNumber: accNum, + Sequence: acc.GetSequence(), } if !genesis { - sigKey := fmt.Sprintf("%s:%d:%d", acc.GetAddress().String(), - tx.GetSigBlockHeight(), signerData.Sequence) + sigKey := fmt.Sprintf("%d:%d", signerData.AccountNumber, signerData.Sequence) // TODO could we use `tx.(*wrapper).getBodyBytes()` instead of `ctx.TxBytes()`? txHash := sha256.Sum256(ctx.TxBytes()) stored := false @@ -327,9 +328,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 sequence (%d) and chain-id (%s)", acc.GetSequence(), chainID) + errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d), sequence (%d) and chain-id (%s)", accNum, acc.GetSequence(), chainID) } else { - errMsg = fmt.Sprintf("signature verification failed; please verify chain-id (%s)", chainID) + errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d) and chain-id (%s)", accNum, 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 768ea6e68f..36473ebcb5 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -35,6 +35,7 @@ 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) } @@ -118,7 +119,7 @@ func (suite *AnteTestSuite) TestSigVerification() { suite.SetupTest(true) // setup suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - // make block height non-zero to ensure sig block height part + // make block height non-zero to ensure account numbers part of signBytes suite.ctx = suite.ctx.WithBlockHeight(1) // keys and addresses @@ -132,6 +133,7 @@ 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) } @@ -141,13 +143,12 @@ func (suite *AnteTestSuite) TestSigVerification() { spkd := ante.NewSetPubKeyDecorator(suite.app.AccountKeeper) svd := ante.NewSigVerificationDecorator(suite.app.AccountKeeper, suite.clientCtx.TxConfig.SignModeHandler()) - sbhv := ante.NewTxSigBlockHeightDecorator(suite.app.AccountKeeper) - antehandler := sdk.ChainAnteDecorators(spkd, svd, sbhv) + antehandler := sdk.ChainAnteDecorators(spkd, svd) type testCase struct { name string privs []cryptotypes.PrivKey - sbh []uint64 + accNums []uint64 accSeqs []uint64 recheck bool shouldErr bool @@ -155,10 +156,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{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}, + {"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}, {"no err on recheck", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, true, false}, } for i, tc := range testCases { @@ -169,7 +170,7 @@ func (suite *AnteTestSuite) TestSigVerification() { suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - tx, err := suite.CreateTestTx(tc.privs, tc.sbh, tc.accSeqs, suite.ctx.ChainID()) + tx, err := suite.CreateTestTx(tc.privs, tc.accNums, tc.accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) _, err = antehandler(suite.ctx, tx, false) @@ -204,7 +205,7 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - // make block height non-zero to ensure sig block height + // make block height non-zero to ensure account numbers part of signBytes suite.ctx = suite.ctx.WithBlockHeight(1) // keys and addresses @@ -218,6 +219,7 @@ 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) } @@ -227,8 +229,7 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { spkd := ante.NewSetPubKeyDecorator(suite.app.AccountKeeper) svd := ante.NewSigVerificationDecorator(suite.app.AccountKeeper, suite.clientCtx.TxConfig.SignModeHandler()) - sbhv := ante.NewTxSigBlockHeightDecorator(suite.app.AccountKeeper) - antehandler := sdk.ChainAnteDecorators(spkd, svd, sbhv) + antehandler := sdk.ChainAnteDecorators(spkd, svd) type testCase struct { name string @@ -241,10 +242,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{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}, + {"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}, {"no err on recheck", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, true, false}, } for i, tc := range testCases { @@ -302,6 +303,7 @@ func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs for i, priv := range privs { addr := sdk.BytesToAccAddress(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) @@ -336,19 +338,20 @@ 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} - sbh := []uint64{1} + accNums := []uint64{suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetAccountNumber()} 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, sbh, accSeqs, suite.ctx.ChainID()) + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) suite.Require().NoError(err) isd := ante.NewIncrementSequenceDecorator(suite.app.AccountKeeper, suite.app.BankKeeper) diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index 951f881164..99626ccc8f 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -73,6 +73,8 @@ 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), @@ -85,12 +87,11 @@ 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, sbh []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { +func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []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,8 +112,9 @@ func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, sbh []uint sigsV2 = []signing.SignatureV2{} for i, priv := range privs { signerData := xauthsigning.SignerData{ - ChainID: chainID, - Sequence: accSeqs[i], + ChainID: chainID, + AccountNumber: accNums[i], + Sequence: accSeqs[i], } sigV2, err := tx.SignWithPrivKey( suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, @@ -141,7 +143,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, sbh, accSeqs []uint64, chainID string, tc TestCase) { +func (suite *AnteTestSuite) RunTestCase(privs []cryptotypes.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, accNums, 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) @@ -150,7 +152,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, sbh, accSeqs, chainID) + tx, txErr := suite.CreateTestTx(privs, accNums, 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 78f1666291..598a1c100a 100644 --- a/x/auth/client/cli/cli_test.go +++ b/x/auth/client/cli/cli_test.go @@ -127,7 +127,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) \"sequence\" not set") + s.Require().EqualError(err, "required flag(s) \"account-number\", \"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)) @@ -555,11 +555,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) \"sequence\" not set") + s.Require().EqualError(err, "required flag(s) \"account-number\", \"sequence\" not set") - // But works offline if we set sequence + // But works offline if we set account number and sequence val1.ClientCtx.HomeDir = strings.Replace(val1.ClientCtx.HomeDir, "simd", "simcli", 1) - res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline", "--sequence", "1", "--sig-block-height", "1") + res, err = authtest.TxSignExec(val1.ClientCtx, val1.Address, unsignedTxFile.Name(), "--offline", "--account-number", "1", "--sequence", "1") s.Require().NoError(err) // Sign transaction @@ -878,9 +878,9 @@ func (s *IntegrationTestSuite) TestCLIMultisign() { sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String()) - // Offline mode requires --sequence flag + // Does not work in offline mode. _, err = authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), "--offline", sign1File.Name(), sign2File.Name()) - s.Require().EqualError(err, "required flag(s) \"sequence\" not set") + s.Require().EqualError(err, "couldn't verify signature: unable to verify single signer signature") val1.ClientCtx.Offline = false multiSigWith2Signatures, err := authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), sign1File.Name(), sign2File.Name()) @@ -1009,14 +1009,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.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.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), 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.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.FlagAccountNumber, fmt.Sprint(account.GetAccountNumber())), 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"))) @@ -1252,11 +1252,11 @@ func (s *IntegrationTestSuite) TestSignWithMultiSigners_AminoJSON() { signedByVal0File := testutil.WriteToNewTempFile(s.T(), signedByVal0.String()) // Then let val1 sign the file with signedByVal0. - val1Seq, err := val0.ClientCtx.AccountRetriever.GetAccountSequence(val0.ClientCtx, val1.Address) + val1AccNum, val1Seq, err := val0.ClientCtx.AccountRetriever.GetAccountNumberSequence(val0.ClientCtx, val1.Address) require.NoError(err) signedTx, err := authtest.TxSignExec( val1.ClientCtx, val1.Address, signedByVal0File.Name(), - "--offline", fmt.Sprintf("--sequence=%d", val1Seq), "--sign-mode=amino-json", + "--offline", fmt.Sprintf("--account-number=%d", val1AccNum), fmt.Sprintf("--sequence=%d", val1Seq), "--sign-mode=amino-json", ) 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 d8cb504c6d..b9f3263bbf 100644 --- a/x/auth/client/cli/tx_multisign.go +++ b/x/auth/client/cli/tx_multisign.go @@ -50,9 +50,8 @@ The SIGN_MODE_DIRECT sign mode is not supported.' version.AppName, ), ), - PreRun: preMultisignCmd, - RunE: makeMultiSignCmd(), - Args: cobra.MinimumNArgs(3), + RunE: makeMultiSignCmd(), + Args: cobra.MinimumNArgs(3), } cmd.Flags().Bool(flagSigOnly, false, "Print only the generated signature, then exit") @@ -64,13 +63,6 @@ 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) @@ -101,12 +93,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 { - seq, err := clientCtx.AccountRetriever.GetAccountSequence(clientCtx, multisigInfo.GetAddress()) + accnum, seq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, multisigInfo.GetAddress()) if err != nil { return err } - txFactory = txFactory.WithSigBlockHeight(uint64(clientCtx.Height)).WithSequence(seq) + txFactory = txFactory.WithAccountNumber(accnum).WithSequence(seq) } // read each signature and add it to the multisig if valid @@ -121,8 +113,9 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) { } signingData := signing.SignerData{ - ChainID: txFactory.ChainID(), - Sequence: txFactory.Sequence(), + ChainID: txFactory.ChainID(), + AccountNumber: txFactory.AccountNumber(), + Sequence: txFactory.Sequence(), } for _, sig := range sigs { @@ -279,12 +272,12 @@ func makeBatchMultisignCmd() func(cmd *cobra.Command, args []string) error { } if !clientCtx.Offline { - seq, err := clientCtx.AccountRetriever.GetAccountSequence(clientCtx, multisigInfo.GetAddress()) + accnum, seq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, multisigInfo.GetAddress()) if err != nil { return err } - txFactory = txFactory.WithSequence(seq) + txFactory = txFactory.WithAccountNumber(accnum).WithSequence(seq) } // prepare output document @@ -305,8 +298,9 @@ 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(), - Sequence: txFactory.Sequence(), + ChainID: txFactory.ChainID(), + AccountNumber: txFactory.AccountNumber(), + 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 c274fe9619..79fd2bbc4c 100644 --- a/x/auth/client/cli/tx_sign.go +++ b/x/auth/client/cli/tx_sign.go @@ -188,8 +188,10 @@ be generated via the 'multisign' command. } func preSignCmd(cmd *cobra.Command, _ []string) { - // Conditionally mark the account sequence required as no RPC query will be done. + // Conditionally mark the account and sequence numbers 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 6d19057b99..673b60f330 100644 --- a/x/auth/client/cli/validate_sigs.go +++ b/x/auth/client/cli/validate_sigs.go @@ -99,15 +99,16 @@ 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 { - accSeq, err := clientCtx.AccountRetriever.GetAccountSequence(clientCtx, sigAddr) + accNum, accSeq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, sigAddr) if err != nil { cmd.Printf("failed to get account: %s\n", sigAddr) return false } signingData := authsigning.SignerData{ - ChainID: chainID, - Sequence: accSeq, + ChainID: chainID, + AccountNumber: accNum, + 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 34aad519b4..3ce4f8eb07 100644 --- a/x/auth/client/rest/rest_test.go +++ b/x/auth/client/rest/rest_test.go @@ -366,7 +366,7 @@ func (s *IntegrationTestSuite) TestMultipleSyncBroadcastTxRequests() { } } -func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, sbh, sequence uint64) legacytx.StdTx { +func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, accNum, sequence uint64) legacytx.StdTx { txConfig := legacytx.StdTxConfig{Cdc: s.cfg.LegacyAmino} msg := &types.MsgSend{ @@ -390,7 +390,7 @@ func (s *IntegrationTestSuite) createTestStdTx(val *network.Validator, sbh, sequ WithKeybase(val.ClientCtx.Keyring). WithTxConfig(txConfig). WithSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON). - WithSigBlockHeight(sbh). + WithAccountNumber(accNum). WithSequence(sequence) // sign Tx (offline mode so we can manually set sequence number) @@ -617,9 +617,9 @@ func (s *IntegrationTestSuite) TestLegacyMultisig() { sign2File := testutil.WriteToNewTempFile(s.T(), account2Signature.String()) - // Offline mode requires --sequence flag. + // Does not work in offline mode. _, err = authtest.TxMultiSignExec(val1.ClientCtx, multisigInfo.GetName(), multiGeneratedTxFile.Name(), "--offline", sign1File.Name(), sign2File.Name()) - s.Require().EqualError(err, fmt.Sprintf("required flag(s) \"sequence\" not set")) + s.Require().EqualError(err, fmt.Sprintf("couldn't verify signature: unable to verify single signer signature")) 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 20da15a89a..8e218b7f07 100644 --- a/x/auth/client/tx.go +++ b/x/auth/client/tx.go @@ -158,12 +158,12 @@ func populateAccountFromState( txBldr tx.Factory, clientCtx client.Context, addr sdk.AccAddress, ) (tx.Factory, error) { - seq, err := clientCtx.AccountRetriever.GetAccountSequence(clientCtx, addr) + num, seq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, addr) if err != nil { return txBldr, err } - return txBldr.WithSequence(seq), nil + return txBldr.WithAccountNumber(num).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 da5ce849bb..e496c70d41 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{}, 0, "") + tx := legacytx.NewStdTx(msgs, legacytx.StdFee{}, []legacytx.StdSignature{}, "") defaultEncoderBytes, err := expected(tx) require.NoError(t, err) diff --git a/x/auth/genesis.go b/x/auth/genesis.go index aad3b1e22b..a8e2e24845 100644 --- a/x/auth/genesis.go +++ b/x/auth/genesis.go @@ -20,7 +20,8 @@ func InitGenesis(ctx sdk.Context, ak keeper.AccountKeeper, data types.GenesisSta accounts = types.SanitizeGenesisAccounts(accounts) for _, a := range accounts { - ak.SetAccount(ctx, a) + acc := ak.NewAccount(ctx, a) + ak.SetAccount(ctx, acc) } ak.GetModuleAccount(ctx, types.FeeCollectorName) diff --git a/x/auth/keeper/account.go b/x/auth/keeper/account.go index ccbfc31a5b..427112be82 100644 --- a/x/auth/keeper/account.go +++ b/x/auth/keeper/account.go @@ -13,6 +13,15 @@ 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 5f1e26f21b..b6de88e597 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + gogotypes "github.com/gogo/protobuf/types" "github.com/line/ostracon/libs/log" "github.com/line/lbm-sdk/codec" @@ -15,9 +16,12 @@ import ( // AccountKeeperI is the interface contract that x/auth's keeper implements. type AccountKeeperI interface { - // Return a new account with the specified address. Does not save the new account to the store. + // Return a new account with the next account number and 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 @@ -38,6 +42,8 @@ type AccountKeeperI interface { // Prefetch an account, i.e. pre-fetch Prefetch(sdk.Context, sdk.AccAddress, bool) + // Fetch the next account number, and increment the internal counter. + GetNextAccountNumber(sdk.Context) uint64 } // AccountKeeper encodes/decodes accounts using the go-amino (binary) @@ -105,6 +111,33 @@ 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 { @@ -157,9 +190,10 @@ func (ak AccountKeeper) GetModuleAccountAndPermissions(ctx sdk.Context, moduleNa // create a new module account macc := types.NewEmptyModuleAccount(moduleName, perms...) - ak.SetModuleAccount(ctx, macc) + maccI := (ak.NewAccount(ctx, macc)).(types.ModuleAccountI) // set the account number + ak.SetModuleAccount(ctx, maccI) - return macc, perms + return maccI, 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 d9611d5780..2221dba791 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, stdTx.GetSigBlockHeight(), data.Sequence, stdTx.GetTimeoutHeight(), StdFee{Amount: stdTx.GetFee(), Gas: stdTx.GetGas()}, tx.GetMsgs(), stdTx.GetMemo(), + data.ChainID, data.AccountNumber, 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 a2edbdc5ea..d998135f1f 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" - sbh uint64 = 7 + accNum uint64 = 7 seqNum uint64 = 7 timeoutHeight uint64 = 10 ) tx := StdTx{ - Msgs: msgs, - Fee: fee, - Signatures: nil, - Memo: memo, - SigBlockHeight: sbh, - TimeoutHeight: timeoutHeight, + Msgs: msgs, + Fee: fee, + Signatures: nil, + Memo: memo, + TimeoutHeight: timeoutHeight, } handler := stdTxSignModeHandler{} signingData := signing.SignerData{ - ChainID: chainId, - Sequence: seqNum, + ChainID: chainId, + AccountNumber: accNum, + Sequence: seqNum, } signBz, err := handler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON, signingData, tx) require.NoError(t, err) - expectedSignBz := StdSignBytes(chainId, sbh, seqNum, timeoutHeight, fee, msgs, memo) + expectedSignBz := StdSignBytes(chainId, accNum, 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 052e2f6fb3..75ecc34397 100644 --- a/x/auth/legacy/legacytx/stdsign.go +++ b/x/auth/legacy/legacytx/stdsign.go @@ -36,30 +36,30 @@ type LegacyMsg interface { // and the Sequence numbers for each signature (prevent // inchain replay and enforce tx ordering per account). type StdSignDoc struct { - 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"` + 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"` } // StdSignBytes returns the bytes to sign for a transaction. -func StdSignBytes(chainID string, sbh, sequence, timeout uint64, fee StdFee, msgs []sdk.Msg, memo string) []byte { +func StdSignBytes(chainID string, accnum, 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{ - SigBlockHeight: sbh, - ChainID: chainID, - Fee: json.RawMessage(fee.Bytes()), - Memo: memo, - Msgs: msgsBytes, - Sequence: sequence, - TimeoutHeight: timeout, + AccountNumber: accnum, + 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 f496978194..606564b65a 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"` - 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"` + 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"` } // get message bytes func (msg StdSignMsg) Bytes() []byte { - return StdSignBytes(msg.ChainID, msg.SigBlockHeight, msg.Sequence, msg.TimeoutHeight, msg.Fee, msg.Msgs, msg.Memo) + return StdSignBytes(msg.ChainID, msg.AccountNumber, 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 fd706f0c9b..45a88e1b9a 100644 --- a/x/auth/legacy/legacytx/stdtx.go +++ b/x/auth/legacy/legacytx/stdtx.go @@ -128,22 +128,20 @@ 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"` - SigBlockHeight uint64 `json:"sig_block_height"` - 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"` + Memo string `json:"memo" yaml:"memo"` + TimeoutHeight uint64 `json:"timeout_height" yaml:"timeout_height"` } // Deprecated -func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, sbh uint64, memo string) StdTx { +func NewStdTx(msgs []sdk.Msg, fee StdFee, sigs []StdSignature, memo string) StdTx { return StdTx{ - Msgs: msgs, - Fee: fee, - Signatures: sigs, - SigBlockHeight: sbh, - Memo: memo, + Msgs: msgs, + Fee: fee, + Signatures: sigs, + Memo: memo, } } @@ -258,8 +256,6 @@ 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 09f8e73231..78cf30e448 100644 --- a/x/auth/legacy/legacytx/stdtx_builder.go +++ b/x/auth/legacy/legacytx/stdtx_builder.go @@ -79,10 +79,6 @@ 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 195946b2d3..5723269d99 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, sbh []uint64, seqs []uint64, timeout uint64, fee StdFee) sdk.Tx { +func NewTestTx(ctx sdk.Context, msgs []sdk.Msg, privs []cryptotypes.PrivKey, accNums []uint64, seqs []uint64, timeout uint64, fee StdFee) sdk.Tx { sigs := make([]StdSignature, len(privs)) for i, priv := range privs { - signBytes := StdSignBytes(ctx.ChainID(), sbh[i], seqs[i], timeout, fee, msgs, "") + signBytes := StdSignBytes(ctx.ChainID(), accNums[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, sbh sigs[i] = StdSignature{PubKey: priv.PubKey(), Signature: sig} } - tx := NewStdTx(msgs, fee, sigs, 0, "") + tx := NewStdTx(msgs, fee, sigs, "") return tx } @@ -61,7 +61,7 @@ func TestStdTx(t *testing.T) { fee := NewTestStdFee() sigs := []StdSignature{} - tx := NewStdTx(msgs, fee, sigs, 0, "") + tx := NewStdTx(msgs, fee, sigs, "") 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("{\"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), + 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), }, { args{"1234", 3, 6, 0, defaultFee, []sdk.Msg{testdata.NewTestMsg(addr)}, "memo"}, - fmt.Sprintf("{\"chain_id\":\"1234\",\"fee\":{\"amount\":[{\"amount\":\"150\",\"denom\":\"atom\"}],\"gas\":\"100000\"},\"memo\":\"memo\",\"msgs\":[[\"%s\"]],\"sequence\":\"6\",\"sig_block_height\":\"3\"}", addr), + fmt.Sprintf("{\"account_number\":\"3\",\"chain_id\":\"1234\",\"fee\":{\"amount\":[{\"amount\":\"150\",\"denom\":\"atom\"}],\"gas\":\"100000\"},\"memo\":\"memo\",\"msgs\":[[\"%s\"]],\"sequence\":\"6\"}", addr), }, } for i, tc := range tests { @@ -171,7 +171,7 @@ func TestDefaultTxEncoder(t *testing.T) { fee := NewTestStdFee() sigs := []StdSignature{} - tx := NewStdTx(msgs, fee, sigs, 0, "") + tx := NewStdTx(msgs, fee, sigs, "") 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}, 0, "testsigs") + stdTx := NewStdTx([]sdk.Msg{testdata.NewTestMsg()}, fee, []StdSignature{sig}, "testsigs") sigs, err := stdTx.GetSignaturesV2() require.Nil(t, err) diff --git a/x/auth/module.go b/x/auth/module.go index 707c23e8d5..1c12ebae45 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 cli.NewTxCmd() + return nil } // 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 3a5b1ebb8f..307d67187e 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" - sbh uint64 = 7 + accNum 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, - Sequence: seqNum, + ChainID: chainId, + AccountNumber: accNum, + 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 09d3c12ff7..6e70c8c024 100644 --- a/x/auth/signing/sign_mode_handler.go +++ b/x/auth/signing/sign_mode_handler.go @@ -26,6 +26,9 @@ 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 94111b01df..53f4964090 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, - Sequence: acc.GetSequence(), + ChainID: chainId, + AccountNumber: acc.GetAccountNumber(), + Sequence: acc.GetSequence(), } - signBytes := legacytx.StdSignBytes(signerData.ChainID, sbh, signerData.Sequence, 10, fee, msgs, memo) + signBytes := legacytx.StdSignBytes(signerData.ChainID, signerData.AccountNumber, 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}, sbh, memo) + stdTx := legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig}, 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, sbh, signerData.Sequence, 10, fee, msgs, memo) + multiSignBytes := legacytx.StdSignBytes(signerData.ChainID, signerData.AccountNumber, 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}, sbh, memo) + stdTx = legacytx.NewStdTx(msgs, fee, []legacytx.StdSignature{stdSig1, stdSig2}, 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 f12743f385..89c3bc702b 100644 --- a/x/auth/simulation/decoder.go +++ b/x/auth/simulation/decoder.go @@ -4,6 +4,8 @@ import ( "bytes" "fmt" + gogotypes "github.com/gogo/protobuf/types" + "github.com/line/lbm-sdk/codec" "github.com/line/lbm-sdk/types/kv" "github.com/line/lbm-sdk/x/auth/types" @@ -32,6 +34,13 @@ 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 8b9dca4fde..823fc0ffb9 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" "github.com/line/lbm-sdk/crypto/keys/ed25519" @@ -21,18 +22,25 @@ 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}, @@ -44,6 +52,7 @@ 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 18c50c557b..cf30fc9bb8 100644 --- a/x/auth/simulation/genesis.go +++ b/x/auth/simulation/genesis.go @@ -19,7 +19,6 @@ 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. @@ -88,11 +87,6 @@ func GenSigVerifyCostSECP256K1(r *rand.Rand) uint64 { return uint64(simulation.RandIntBetween(r, 500, 1000)) } -func GenValidSigBlockPeriod(r *rand.Rand) uint64 { - // We use valid sig block period greater than 500 for testing (to include test-sim-multi-seed-long 500 blocks) - return uint64(simulation.RandIntBetween(r, 501, 10000)) -} - // RandomizedGenState generates a random GenesisState for auth func RandomizedGenState(simState *module.SimulationState, randGenAccountsFn types.RandomGenesisAccountsFn) { var maxMemoChars uint64 @@ -125,14 +119,8 @@ 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, validSigBlockPeriod) + sigVerifyCostED25519, sigVerifyCostSECP256K1) 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 704021b349..9dca0d2e29 100644 --- a/x/auth/simulation/genesis_test.go +++ b/x/auth/simulation/genesis_test.go @@ -50,5 +50,6 @@ 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 0c46f6156c..03b4ad335a 100644 --- a/x/auth/testutil/suite.go +++ b/x/auth/testutil/suite.go @@ -128,8 +128,9 @@ func (s *TxConfigTestSuite) TestTxBuilderSetSignatures() { // sign transaction signerData := signing.SignerData{ - ChainID: "test", - Sequence: seq1, + ChainID: "test", + AccountNumber: 1, + Sequence: seq1, } signBytes, err := signModeHandler.GetSignBytes(signModeHandler.DefaultMode(), signerData, sigTx) s.Require().NoError(err) @@ -137,8 +138,9 @@ func (s *TxConfigTestSuite) TestTxBuilderSetSignatures() { s.Require().NoError(err) signerData = signing.SignerData{ - ChainID: "test", - Sequence: mseq, + ChainID: "test", + AccountNumber: 3, + 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 315475038d..2efc752e83 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -145,10 +145,6 @@ func (w *wrapper) FeeGranter() sdk.AccAddress { return "" } -func (w *wrapper) GetSigBlockHeight() uint64 { - return w.tx.AuthInfo.SigBlockHeight -} - func (w *wrapper) GetMemo() string { return w.tx.Body.Memo } @@ -228,10 +224,6 @@ func (w *wrapper) SetMemo(memo string) { w.bodyBz = nil } -func (w *wrapper) SetSigBlockHeight(sbh uint64) { - w.tx.AuthInfo.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 51fe31734a..845d603a59 100644 --- a/x/auth/tx/direct.go +++ b/x/auth/tx/direct.go @@ -39,16 +39,17 @@ func (signModeDirectHandler) GetSignBytes(mode signingtypes.SignMode, data signi bodyBz := protoTx.getBodyBytes() authInfoBz := protoTx.getAuthInfoBytes() - return DirectSignBytes(bodyBz, authInfoBz, data.ChainID) + return DirectSignBytes(bodyBz, authInfoBz, data.ChainID, data.AccountNumber) } // DirectSignBytes returns the SIGN_MODE_DIRECT sign bytes for the provided TxBody bytes, AuthInfo bytes, chain ID, -// and sequence. -func DirectSignBytes(bodyBytes, authInfoBytes []byte, chainID string) ([]byte, error) { +// account number. +func DirectSignBytes(bodyBytes, authInfoBytes []byte, chainID string, accnum uint64) ([]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 d50eac7178..af87bec767 100644 --- a/x/auth/tx/direct_test.go +++ b/x/auth/tx/direct_test.go @@ -69,7 +69,8 @@ func TestDirectModeHandler(t *testing.T) { require.Len(t, modeHandler.Modes(), 1) signingData := signing.SignerData{ - ChainID: "test-chain", + ChainID: "test-chain", + AccountNumber: 1, } signBytes, err := modeHandler.GetSignBytes(signingtypes.SignMode_SIGN_MODE_DIRECT, signingData, txBuilder.GetTx()) @@ -102,6 +103,7 @@ 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", @@ -147,9 +149,8 @@ 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) GetSigBlockHeight() uint64 { return 0 } +func (npt *nonProtoTx) GetMsgs() []sdk.Msg { return nil } +func (npt *nonProtoTx) ValidateBasic() error { return nil } var _ sdk.Tx = (*nonProtoTx)(nil) diff --git a/x/auth/tx/legacy_amino_json.go b/x/auth/tx/legacy_amino_json.go index c982dba160..5485504ede 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, tx.GetSigBlockHeight(), data.Sequence, protoTx.GetTimeoutHeight(), + data.ChainID, data.AccountNumber, 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 00482f0a29..9688df85e6 100644 --- a/x/auth/tx/legacy_amino_json_test.go +++ b/x/auth/tx/legacy_amino_json_test.go @@ -21,7 +21,6 @@ var ( gas = uint64(10000) msg = testdata.NewTestMsg(addr1, addr2) memo = "foo" - sbh = uint64(1) timeout = uint64(10) ) @@ -29,7 +28,6 @@ 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)) } @@ -41,18 +39,20 @@ func TestLegacyAminoJSONHandler_GetSignBytes(t *testing.T) { var ( chainId = "test-chain" + accNum uint64 = 7 seqNum uint64 = 7 ) handler := signModeLegacyAminoJSONHandler{} signingData := signing.SignerData{ - ChainID: chainId, - Sequence: seqNum, + 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, sbh, seqNum, timeout, legacytx.StdFee{ + expectedSignBz := legacytx.StdSignBytes(chainId, accNum, 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 bf071aceda..cd8086eb6a 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -39,10 +39,11 @@ var ( // NewBaseAccount creates a new BaseAccount object //nolint:interfacer -func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, sequence uint64) *BaseAccount { +func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNumber, sequence uint64) *BaseAccount { acc := &BaseAccount{ - Address: address.String(), - Sequence: sequence, + Address: address.String(), + AccountNumber: accountNumber, + Sequence: sequence, } err := acc.SetPubKey(pubKey) @@ -108,6 +109,17 @@ func (acc *BaseAccount) SetPubKey(pubKey cryptotypes.PubKey) error { return nil } +// 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 @@ -256,11 +268,12 @@ func (ma *ModuleAccount) MarshalX() ([]byte, error) { } type moduleAccountPretty struct { - 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"` + 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"` } func (ma ModuleAccount) String() string { @@ -276,11 +289,12 @@ func (ma ModuleAccount) MarshalYAML() (interface{}, error) { } bs, err := yaml.Marshal(moduleAccountPretty{ - Address: sdk.AccAddress(ma.Address), - PubKey: "", - Sequence: ma.Sequence, - Name: ma.Name, - Permissions: ma.Permissions, + Address: sdk.AccAddress(ma.Address), + PubKey: "", + AccountNumber: ma.AccountNumber, + Sequence: ma.Sequence, + Name: ma.Name, + Permissions: ma.Permissions, }) if err != nil { @@ -298,11 +312,12 @@ func (ma ModuleAccount) MarshalJSON() ([]byte, error) { } return json.Marshal(moduleAccountPretty{ - Address: sdk.AccAddress(ma.Address), - PubKey: "", - Sequence: ma.Sequence, - Name: ma.Name, - Permissions: ma.Permissions, + Address: sdk.AccAddress(ma.Address), + PubKey: "", + AccountNumber: ma.AccountNumber, + Sequence: ma.Sequence, + Name: ma.Name, + Permissions: ma.Permissions, }) } @@ -313,7 +328,7 @@ func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { return err } - ma.BaseAccount = NewBaseAccount(alias.Address, nil, alias.Sequence) + ma.BaseAccount = NewBaseAccount(alias.Address, nil, alias.AccountNumber, alias.Sequence) ma.Name = alias.Name ma.Permissions = alias.Permissions @@ -322,7 +337,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 sig block height for replay protection for previously pruned accounts, +// a notion of account numbers 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. @@ -335,6 +350,9 @@ type AccountI interface { GetPubKey() cryptotypes.PubKey // can return nil. SetPubKey(cryptotypes.PubKey) error + GetAccountNumber() uint64 + SetAccountNumber(uint64) error + GetSequence() uint64 SetSequence(uint64) error @@ -416,15 +434,17 @@ type PubKeyJSON struct { Key []byte `json:"key"` } type BaseAccountJSON struct { - Address string `json:"address"` - PubKey PubKeyJSON `json:"pub_key"` - Sequence string `json:"sequence"` + Address string `json:"address"` + PubKey PubKeyJSON `json:"pub_key"` + AccountNumber uint64 `json:"account_number"` + Sequence string `json:"sequence"` } func (acc BaseAccount) MarshalJSONPB(m *jsonpb.Marshaler) ([]byte, error) { var bi BaseAccountJSON bi.Address = acc.GetAddress().String() + bi.AccountNumber = acc.GetAccountNumber() bi.Sequence = strconv.FormatUint(acc.Sequence, 10) var bz []byte var err error @@ -456,6 +476,7 @@ func (acc *BaseAccount) UnmarshalJSONPB(m *jsonpb.Unmarshaler, bz []byte) error } acc.Address = bi.Address + acc.AccountNumber = bi.AccountNumber acc.Sequence, err = strconv.ParseUint(bi.Sequence, 10, 64) if err != nil { return err diff --git a/x/auth/types/account_retriever.go b/x/auth/types/account_retriever.go index cbea4788e3..ab284267bb 100644 --- a/x/auth/types/account_retriever.go +++ b/x/auth/types/account_retriever.go @@ -5,7 +5,6 @@ import ( "fmt" "strconv" - "github.com/line/lbm-sdk/client/grpc/tmservice" grpc "google.golang.org/grpc" "google.golang.org/grpc/metadata" @@ -30,15 +29,6 @@ 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. @@ -78,13 +68,13 @@ func (ar AccountRetriever) EnsureExists(clientCtx client.Context, addr sdk.AccAd return nil } -// GetAccountSequence returns sequence for the given address. +// GetAccountNumberSequence returns sequence and account number for the given address. // It returns an error if the account couldn't be retrieved from the state. -func (ar AccountRetriever) GetAccountSequence(clientCtx client.Context, addr sdk.AccAddress) (uint64, error) { +func (ar AccountRetriever) GetAccountNumberSequence(clientCtx client.Context, addr sdk.AccAddress) (uint64, uint64, error) { acc, err := ar.GetAccount(clientCtx, addr) if err != nil { - return 0, err + return 0, 0, err } - return acc.GetSequence(), nil + return acc.GetAccountNumber(), acc.GetSequence(), nil } diff --git a/x/auth/types/account_retriever_test.go b/x/auth/types/account_retriever_test.go index e013323593..e515d9870e 100644 --- a/x/auth/types/account_retriever_test.go +++ b/x/auth/types/account_retriever_test.go @@ -36,7 +36,8 @@ func TestAccountRetriever(t *testing.T) { require.NoError(t, ar.EnsureExists(clientCtx, val.Address)) - accSeq, err := ar.GetAccountSequence(clientCtx, val.Address) + accNum, accSeq, err := ar.GetAccountNumberSequence(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 0a2ecd76cd..e497cfc197 100644 --- a/x/auth/types/account_test.go +++ b/x/auth/types/account_test.go @@ -101,7 +101,7 @@ func TestBaseAccountMarshal(t *testing.T) { func TestGenesisAccountValidate(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.BytesToAccAddress(pubkey.Address()) - baseAcc := types.NewBaseAccount(addr, pubkey, 0) + baseAcc := types.NewBaseAccount(addr, pubkey, 0, 0) tests := []struct { name string @@ -115,7 +115,7 @@ func TestGenesisAccountValidate(t *testing.T) { }, { "invalid base valid account", - types.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0), + types.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), true, }, } @@ -135,7 +135,7 @@ func TestModuleAccountMarshalYAML(t *testing.T) { bs, err := yaml.Marshal(moduleAcc) require.NoError(t, err) - want := "|\n address: link1n7rdpqvgf37ktx30a2sv2kkszk3m7ncma6dpv3\n public_key: \"\"\n sequence: 0\n name: test\n permissions:\n - minter\n - burner\n - staking\n" + 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" require.Equal(t, want, string(bs)) } @@ -164,7 +164,7 @@ func TestHasPermissions(t *testing.T) { func TestValidate(t *testing.T) { addr := sdk.BytesToAccAddress(secp256k1.GenPrivKey().PubKey().Address()) - baseAcc := types.NewBaseAccount(addr, nil, 0) + baseAcc := types.NewBaseAccount(addr, nil, 0, 0) tests := []struct { name string acc types.GenesisAccount @@ -198,7 +198,7 @@ func TestValidate(t *testing.T) { func TestModuleAccountJSON(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.BytesToAccAddress(pubkey.Address()) - baseAcc := types.NewBaseAccount(addr, nil, 50) + baseAcc := types.NewBaseAccount(addr, nil, 10, 50) acc := types.NewModuleAccount(baseAcc, "test", "burner") bz, err := json.Marshal(acc) @@ -216,7 +216,7 @@ func TestModuleAccountJSON(t *testing.T) { func TestGenesisAccountsContains(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.BytesToAccAddress(pubkey.Address()) - acc := types.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0) + acc := types.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 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 2635234ab6..878153ddc7 100644 --- a/x/auth/types/auth.pb.go +++ b/x/auth/types/auth.pb.go @@ -35,7 +35,8 @@ type BaseAccount struct { Ed25519PubKey *ed25519.PubKey `protobuf:"bytes,2,opt,name=ed25519_pub_key,json=ed25519PubKey,proto3" json:"ed25519_public_key,omitempty" yaml:"ed25519_public_key"` Secp256K1PubKey *secp256k1.PubKey `protobuf:"bytes,3,opt,name=secp256k1_pub_key,json=secp256k1PubKey,proto3" json:"secp256k1_public_key,omitempty" yaml:"secp256k1_public_key"` MultisigPubKey *multisig.LegacyAminoPubKey `protobuf:"bytes,4,opt,name=multisig_pub_key,json=multisigPubKey,proto3" json:"multisig_public_key,omitempty" yaml:"multisig_public_key"` - Sequence uint64 `protobuf:"varint,5,opt,name=sequence,proto3" json:"sequence,omitempty"` + AccountNumber uint64 `protobuf:"varint,5,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty" yaml:"account_number"` + Sequence uint64 `protobuf:"varint,6,opt,name=sequence,proto3" json:"sequence,omitempty"` } func (m *BaseAccount) Reset() { *m = BaseAccount{} } @@ -116,7 +117,6 @@ 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{} } @@ -186,13 +186,6 @@ 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), "lbm.auth.v1.BaseAccount") proto.RegisterType((*ModuleAccount)(nil), "lbm.auth.v1.ModuleAccount") @@ -202,57 +195,57 @@ func init() { func init() { proto.RegisterFile("lbm/auth/v1/auth.proto", fileDescriptor_1d85c5e32d5ed883) } var fileDescriptor_1d85c5e32d5ed883 = []byte{ - // 800 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0xcf, 0x6f, 0xdc, 0x44, - 0x14, 0xc7, 0xd7, 0xc4, 0x84, 0x64, 0xb6, 0x3f, 0x88, 0x13, 0xd2, 0xcd, 0x36, 0xf1, 0x2c, 0x16, - 0x42, 0x39, 0x10, 0x5b, 0x09, 0x0a, 0x52, 0x57, 0xa2, 0x28, 0x2e, 0x1c, 0x2a, 0x5a, 0x14, 0x39, - 0x52, 0x85, 0xb8, 0x58, 0xb6, 0x77, 0x70, 0x46, 0xeb, 0xd9, 0x71, 0x3d, 0xe3, 0x68, 0xdd, 0x1b, - 0xe2, 0x82, 0xc4, 0x05, 0x6e, 0x1c, 0xf3, 0x47, 0x54, 0xe2, 0xc0, 0x3f, 0xc0, 0x31, 0xea, 0x89, - 0x93, 0x85, 0x36, 0x17, 0x94, 0xe3, 0xfe, 0x05, 0xc8, 0x33, 0x5e, 0x77, 0xb6, 0xf1, 0xc9, 0x7e, - 0xef, 0x7d, 0xdf, 0x9b, 0xcf, 0x8c, 0xbf, 0x63, 0xb0, 0x9d, 0x84, 0xc4, 0x09, 0x72, 0x7e, 0xee, - 0x5c, 0x1c, 0x8a, 0xa7, 0x9d, 0x66, 0x94, 0x53, 0xa3, 0x9b, 0x84, 0xc4, 0x16, 0xf1, 0xc5, 0x61, - 0x7f, 0xaf, 0x12, 0x45, 0x59, 0x91, 0x72, 0xea, 0xa0, 0xd1, 0xd1, 0xf1, 0xf1, 0xe1, 0x23, 0x67, - 0x8c, 0x0a, 0x26, 0xb5, 0x7d, 0x53, 0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0x75, 0x3a, 0x98, 0x8e, 0x7a, 0xab, 0x62, - 0xdd, 0x8f, 0xe7, 0x25, 0xdc, 0x93, 0xd3, 0xdb, 0x75, 0x96, 0xb7, 0x29, 0x0a, 0x67, 0x38, 0x76, - 0xab, 0xf4, 0xa9, 0xc8, 0x0e, 0xd7, 0xea, 0x3b, 0xa0, 0xb9, 0x8f, 0xff, 0x9e, 0x99, 0xda, 0xd5, - 0xcc, 0xd4, 0xfe, 0x9d, 0x99, 0xda, 0x6f, 0xd7, 0x66, 0xe7, 0xea, 0xda, 0xec, 0xfc, 0x73, 0x6d, - 0x76, 0x7e, 0xf8, 0x24, 0xc6, 0xfc, 0x3c, 0x0f, 0xed, 0x88, 0x12, 0x27, 0xc1, 0x13, 0xe4, 0x24, - 0x21, 0x39, 0x60, 0xa3, 0xb1, 0x33, 0x95, 0xff, 0x78, 0x5e, 0xa4, 0x88, 0x85, 0xab, 0xe2, 0x27, - 0xfa, 0xf9, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, 0x25, 0xe6, 0xe9, 0x4f, 0xfc, 0x05, 0x00, 0x00, + // 786 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x94, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0xc7, 0x63, 0x62, 0x4a, 0x3b, 0xd9, 0x76, 0xa9, 0xb7, 0xdb, 0x75, 0xb2, 0x5d, 0x4f, 0x64, + 0x21, 0x94, 0x03, 0xb5, 0x95, 0xa0, 0x22, 0x6d, 0x24, 0x16, 0xea, 0xc2, 0xa1, 0xa2, 0xad, 0x2a, + 0x57, 0x42, 0x88, 0x8b, 0x65, 0x3b, 0x43, 0x6a, 0xc5, 0x93, 0x71, 0x3d, 0xe3, 0x2a, 0xee, 0x8d, + 0x1b, 0x12, 0x17, 0xb8, 0x71, 0xec, 0x87, 0xe8, 0x8d, 0x33, 0x12, 0xc7, 0xaa, 0x27,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 0x01, + 0xa1, 0xec, 0x14, 0xc5, 0x56, 0xca, 0x90, 0x72, 0x01, 0x5e, 0xe5, 0xa7, 0x5d, 0xa2, 0x38, 0xf8, + 0x21, 0x2d, 0xf4, 0xe5, 0x8a, 0x71, 0xe7, 0xca, 0x56, 0x7f, 0x9a, 0xc1, 0xad, 0xb3, 0x60, 0xf8, + 0x2d, 0x57, 0xe4, 0xad, 0x5f, 0x7f, 0xc5, 0xeb, 0xb3, 0x0c, 0x6a, 0xe5, 0x7a, 0x2c, 0x1f, 0xa0, + 0xdb, 0x5b, 0x74, 0xa1, 0xaf, 0x48, 0x2b, 0x29, 0x68, 0x3e, 0xee, 0xa8, 0x36, 0xa9, 0x74, 0xe7, + 0xbb, 0x69, 0x06, 0xb7, 0x17, 0x0e, 0x3d, 0x9b, 0x2b, 0x66, 0x19, 0x6c, 0x2f, 0x3f, 0xb6, 0x1a, + 0xa2, 0xdb, 0xdb, 0x74, 0x69, 0x6f, 0x7f, 0xb5, 0xf4, 0xaa, 0x64, 0xbd, 0xfb, 0x73, 0xaa, 0x49, + 0xb7, 0x53, 0x4d, 0xfa, 0x67, 0xaa, 0x49, 0xbf, 0xdc, 0x6b, 0xb5, 0xdb, 0x7b, 0xad, 0xf6, 0xd7, + 0xbd, 0x56, 0xfb, 0xfe, 0xa3, 0x61, 0xc0, 0xce, 0x13, 0xcf, 0xf0, 0x09, 0x36, 0xc3, 0x60, 0x8c, + 0xcc, 0xd0, 0xc3, 0xbb, 0x74, 0x30, 0x32, 0x27, 0xc5, 0xd7, 0x9c, 0xa5, 0x11, 0xa2, 0xde, 0x0a, + 0xff, 0x5c, 0x7e, 0xfa, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x62, 0xc8, 0x44, 0xe6, 0x05, + 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -289,9 +282,6 @@ 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) { @@ -317,6 +307,11 @@ func (m *BaseAccount) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.Sequence != 0 { i = encodeVarintAuth(dAtA, i, uint64(m.Sequence)) i-- + dAtA[i] = 0x30 + } + if m.AccountNumber != 0 { + i = encodeVarintAuth(dAtA, i, uint64(m.AccountNumber)) + i-- dAtA[i] = 0x28 } if m.MultisigPubKey != nil { @@ -436,11 +431,6 @@ 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-- @@ -502,6 +492,9 @@ func (m *BaseAccount) Size() (n int) { l = m.MultisigPubKey.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)) } @@ -552,9 +545,6 @@ 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 } @@ -734,6 +724,25 @@ func (m *BaseAccount) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 5: + 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 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } @@ -1047,25 +1056,6 @@ 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 eeb861d39f..57db523f49 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].GetAddress().String() < genAccs[j].GetAddress().String() + return genAccs[i].GetAccountNumber() < genAccs[j].GetAccountNumber() }) return genAccs diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index 5a1f8c9f66..7ffd034e8f 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -16,15 +16,20 @@ import ( func TestSanitize(t *testing.T) { addr1 := sdk.BytesToAccAddress(ed25519.GenPrivKey().PubKey().Address()) authAcc1 := types.NewBaseAccountWithAddress(addr1) + err := authAcc1.SetAccountNumber(1) + require.NoError(t, err) addr2 := sdk.BytesToAccAddress(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].GetAddress().String() > genAccs[1].GetAddress().String()) + require.False(t, genAccs[0].GetAccountNumber() > genAccs[1].GetAccountNumber()) + require.Equal(t, genAccs[1].GetAddress(), addr1) } var ( diff --git a/x/auth/types/keys.go b/x/auth/types/keys.go index 69325ed285..e76505ae80 100644 --- a/x/auth/types/keys.go +++ b/x/auth/types/keys.go @@ -24,6 +24,9 @@ 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 f02d4181c6..c0403f6f2a 100644 --- a/x/auth/types/params.go +++ b/x/auth/types/params.go @@ -15,7 +15,6 @@ const ( DefaultTxSizeCostPerByte uint64 = 10 DefaultSigVerifyCostED25519 uint64 = 590 DefaultSigVerifyCostSecp256k1 uint64 = 1000 - DefaultValidSigBlockPeriod uint64 = 3600 // 1 hour for 1 second block interval ) // Parameter keys @@ -25,15 +24,13 @@ 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, - validSigBlockPeriod uint64, + maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64, ) Params { return Params{ MaxMemoCharacters: maxMemoCharacters, @@ -41,7 +38,6 @@ func NewParams( TxSizeCostPerByte: txSizeCostPerByte, SigVerifyCostED25519: sigVerifyCostED25519, SigVerifyCostSecp256k1: sigVerifyCostSecp256k1, - ValidSigBlockPeriod: validSigBlockPeriod, } } @@ -59,7 +55,6 @@ 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), } } @@ -71,7 +66,6 @@ func DefaultParams() Params { TxSizeCostPerByte: DefaultTxSizeCostPerByte, SigVerifyCostED25519: DefaultSigVerifyCostED25519, SigVerifyCostSecp256k1: DefaultSigVerifyCostSecp256k1, - ValidSigBlockPeriod: DefaultValidSigBlockPeriod, } } @@ -120,19 +114,6 @@ 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 { @@ -176,8 +157,6 @@ 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 a948bc7c9b..4f2922ecbb 100644 --- a/x/auth/types/params_test.go +++ b/x/auth/types/params_test.go @@ -26,17 +26,15 @@ 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, types.DefaultValidSigBlockPeriod), fmt.Errorf("invalid tx signature limit: 0")}, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid tx signature limit: 0")}, {"invalid ED25519 signature verification cost", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, - 0, types.DefaultSigVerifyCostSecp256k1, types.DefaultValidSigBlockPeriod), fmt.Errorf("invalid ED25519 signature verification cost: 0")}, + 0, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid ED25519 signature verification cost: 0")}, {"invalid SECK256k1 signature verification cost", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, - types.DefaultSigVerifyCostED25519, 0, types.DefaultValidSigBlockPeriod), fmt.Errorf("invalid SECK256k1 signature verification cost: 0")}, + types.DefaultSigVerifyCostED25519, 0), fmt.Errorf("invalid SECK256k1 signature verification cost: 0")}, {"invalid max memo characters", types.NewParams(0, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, - types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1, types.DefaultValidSigBlockPeriod), fmt.Errorf("invalid max memo characters: 0")}, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid max memo characters: 0")}, {"invalid tx size cost per byte", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, 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")}, + types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1), fmt.Errorf("invalid tx size cost per byte: 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 4331c5460b..e58960a1aa 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -166,6 +166,7 @@ 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"` @@ -186,6 +187,7 @@ func (bva BaseVestingAccount) String() string { func (bva BaseVestingAccount) MarshalYAML() (interface{}, error) { alias := vestingAccountYAML{ Address: sdk.AccAddress(bva.Address), + AccountNumber: bva.AccountNumber, Sequence: bva.Sequence, OriginalVesting: bva.OriginalVesting, DelegatedFree: bva.DelegatedFree, @@ -356,6 +358,7 @@ func (cva ContinuousVestingAccount) String() string { func (cva ContinuousVestingAccount) MarshalYAML() (interface{}, error) { alias := vestingAccountYAML{ Address: sdk.AccAddress(cva.Address), + AccountNumber: cva.AccountNumber, Sequence: cva.Sequence, OriginalVesting: cva.OriginalVesting, DelegatedFree: cva.DelegatedFree, @@ -547,6 +550,7 @@ func (pva PeriodicVestingAccount) String() string { func (pva PeriodicVestingAccount) MarshalYAML() (interface{}, error) { alias := vestingAccountYAML{ Address: sdk.AccAddress(pva.Address), + 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 e8b3b52446..6d6af07dde 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.BytesToAccAddress(pubkey.Address()) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 0, 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), + authtypes.NewBaseAccount(addr, secp256k1.GenPrivKey().PubKey(), 0, 0), true, }, { @@ -648,7 +648,7 @@ func TestContinuousVestingAccountMarshal(t *testing.T) { pubkey := secp256k1.GenPrivKey().PubKey() addr := sdk.BytesToAccAddress(pubkey.Address()) coins := sdk.NewCoins(sdk.NewInt64Coin("test", 5)) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 50) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 10, 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.BytesToAccAddress(pubkey.Address()) coins := sdk.NewCoins(sdk.NewInt64Coin("test", 5)) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 50) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 10, 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.BytesToAccAddress(pubkey.Address()) coins := sdk.NewCoins(sdk.NewInt64Coin("test", 5)) - baseAcc := authtypes.NewBaseAccount(addr, pubkey, 50) + baseAcc := authtypes.NewBaseAccount(addr, pubkey, 10, 50) acc := types.NewDelayedVestingAccount(baseAcc, coins, time.Now().Unix()) diff --git a/x/bank/app_test.go b/x/bank/app_test.go index 6cfba62099..b7dab334d0 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 - sbh []uint64 + accNums []uint64 accSeqs []uint64 privKeys []cryptotypes.PrivKey expectedBalances []expectedBalance @@ -103,12 +103,13 @@ 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 := ocproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{sendMsg}, "", []uint64{0}, []uint64{origSeq}, false, false, priv1) + _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1) require.Error(t, err) simapp.CheckBalance(t, app, addr1, sdk.Coins{sdk.NewInt64Coin("foocoin", 67)}) @@ -116,6 +117,7 @@ func TestSendNotEnoughBalance(t *testing.T) { res2 := app.AccountKeeper.GetAccount(app.NewContext(true, ocproto.Header{}), addr1) require.NotNil(t, res2) + require.Equal(t, res2.GetAccountNumber(), origAccNum) require.Equal(t, res2.GetSequence(), origSeq+1) } @@ -141,7 +143,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { { desc: "make a valid tx", msgs: []sdk.Msg{multiSendMsg1}, - sbh: []uint64{0}, + accNums: []uint64{0}, accSeqs: []uint64{0}, expSimPass: true, expPass: true, @@ -152,9 +154,9 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { }, }, { - desc: "wrong sig block height should pass Simulate, but not Deliver", + desc: "wrong accNum should pass Simulate, but not Deliver", msgs: []sdk.Msg{multiSendMsg1, multiSendMsg2}, - sbh: []uint64{5}, // wrong sig block height + accNums: []uint64{1}, // wrong account number accSeqs: []uint64{1}, expSimPass: true, // doesn't check signature expPass: false, @@ -163,7 +165,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { { desc: "wrong accSeq should not pass Simulate", msgs: []sdk.Msg{multiSendMsg5}, - sbh: []uint64{0}, + accNums: []uint64{0}, accSeqs: []uint64{0}, // wrong account sequence expSimPass: false, expPass: false, @@ -174,7 +176,7 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { for _, tc := range testCases { header := ocproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.sbh, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) if tc.expPass { require.NoError(t, err) } else { @@ -210,7 +212,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { testCases := []appTestCase{ { msgs: []sdk.Msg{multiSendMsg2}, - sbh: []uint64{0}, + accNums: []uint64{0}, accSeqs: []uint64{0}, expSimPass: true, expPass: true, @@ -226,7 +228,7 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { for _, tc := range testCases { header := ocproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.sbh, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) for _, eb := range tc.expectedBalances { @@ -264,7 +266,7 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { testCases := []appTestCase{ { msgs: []sdk.Msg{multiSendMsg3}, - sbh: []uint64{0, 0}, + accNums: []uint64{0, 2}, accSeqs: []uint64{0, 0}, expSimPass: true, expPass: true, @@ -281,7 +283,7 @@ func TestMsgMultiSendMultipleInOut(t *testing.T) { for _, tc := range testCases { header := ocproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.sbh, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) for _, eb := range tc.expectedBalances { @@ -293,12 +295,14 @@ 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, ocproto.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() @@ -306,7 +310,7 @@ func TestMsgMultiSendDependent(t *testing.T) { testCases := []appTestCase{ { msgs: []sdk.Msg{multiSendMsg1}, - sbh: []uint64{0}, + accNums: []uint64{0}, accSeqs: []uint64{0}, expSimPass: true, expPass: true, @@ -318,7 +322,7 @@ func TestMsgMultiSendDependent(t *testing.T) { }, { msgs: []sdk.Msg{multiSendMsg4}, - sbh: []uint64{0}, + accNums: []uint64{1}, accSeqs: []uint64{0}, expSimPass: true, expPass: true, @@ -332,7 +336,7 @@ func TestMsgMultiSendDependent(t *testing.T) { for _, tc := range testCases { header := ocproto.Header{Height: app.LastBlockHeight() + 1} txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.sbh, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, 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 2dc3c432cc..f6e5a12280 100644 --- a/x/bank/client/cli/tx.go +++ b/x/bank/client/cli/tx.go @@ -31,8 +31,7 @@ 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), - PreRun: preSendCmd, + Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { cmd.Flags().Set(flags.FlagFrom, args[0]) clientCtx, err := client.GetClientTxContext(cmd) @@ -59,9 +58,3 @@ 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 2c7523cc08..0595d4b0b3 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), - 0, + from.GetAccountNumber(), from.GetSequence(), types.NewCoins(), nil, diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index d95bb46814..46bfe3789a 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -110,7 +110,7 @@ func sendMsgSend( fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, privkeys..., ) @@ -223,13 +223,13 @@ func sendMsgMultiSend( msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, ) error { - sbh := make([]uint64, len(msg.Inputs)) + accountNumbers := make([]uint64, len(msg.Inputs)) sequenceNumbers := make([]uint64, len(msg.Inputs)) for i := 0; i < len(msg.Inputs); i++ { addr := sdk.AccAddress(msg.Inputs[i].Address) acc := ak.GetAccount(ctx, addr) - sbh[i] = 0 + accountNumbers[i] = acc.GetAccountNumber() sequenceNumbers[i] = acc.GetSequence() } @@ -259,7 +259,7 @@ func sendMsgMultiSend( fees, helpers.DefaultGenTxGas, chainID, - sbh, + accountNumbers, sequenceNumbers, privkeys..., ) diff --git a/x/bank/types/expected_keepers.go b/x/bank/types/expected_keepers.go index 8fe5f4a48f..f0ab0f451c 100644 --- a/x/bank/types/expected_keepers.go +++ b/x/bank/types/expected_keepers.go @@ -8,6 +8,7 @@ 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 a6f2ee2ab5..5149ea899d 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{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -159,7 +159,7 @@ func SimulateMsgWithdrawDelegatorReward(ak types.AccountKeeper, bk types.BankKee fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -214,7 +214,7 @@ func SimulateMsgWithdrawValidatorCommission(ak types.AccountKeeper, bk types.Ban fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -269,7 +269,7 @@ func SimulateMsgFundCommunityPool(ak types.AccountKeeper, bk types.BankKeeper, k fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, funder.PrivKey, ) diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 953bc56060..89969b4e07 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 := addr.ToAccAddress() - app.AccountKeeper.SetAccount(suite.ctx, authtypes.NewBaseAccount(addr, pubkeys[i], 0)) + app.AccountKeeper.SetAccount(suite.ctx, authtypes.NewBaseAccount(addr, pubkeys[i], uint64(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 2ac24b2e12..94f1745fb3 100644 --- a/x/genutil/types/expected_keepers.go +++ b/x/genutil/types/expected_keepers.go @@ -18,6 +18,7 @@ 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 933038dc2b..5f73239e91 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -161,7 +161,7 @@ func SimulateMsgSubmitProposal( fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -248,7 +248,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Ke fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -310,7 +310,7 @@ func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k kee fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -373,7 +373,7 @@ func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeepe fees, helpers.DefaultGenTxGas, ctx.ChainID(), - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 485da818a5..7e165a6223 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -133,8 +133,7 @@ func NewTestChain(t *testing.T, chainID string) *TestChain { // generate genesis account senderPrivKey := secp256k1.GenPrivKey() - acc := authtypes.NewBaseAccount(sdk.BytesToAccAddress(senderPrivKey.PubKey().Address()), - senderPrivKey.PubKey(), 0) + acc := authtypes.NewBaseAccount(sdk.BytesToAccAddress(senderPrivKey.PubKey().Address()), senderPrivKey.PubKey(), 0, 0) balance := banktypes.Balance{ Address: acc.GetAddress().String(), Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), @@ -305,7 +304,7 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { chain.GetContext().BlockHeader(), msgs, chain.ChainID, - []uint64{0}, + []uint64{chain.SenderAccount.GetAccountNumber()}, []uint64{chain.SenderAccount.GetSequence()}, true, true, chain.senderPrivKey, ) diff --git a/x/simulation/util.go b/x/simulation/util.go index f58f9ff1aa..d276147ee2 100644 --- a/x/simulation/util.go +++ b/x/simulation/util.go @@ -106,7 +106,7 @@ func GenAndDeliverTx(txCtx OperationInput, fees types.Coins) (simtype.OperationM fees, helpers.DefaultGenTxGas, txCtx.Context.ChainID(), - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, txCtx.SimAccount.PrivKey, ) diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index bda3d2bf8b..eae6add410 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -95,7 +95,7 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 420911530e..90b88c864f 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -159,7 +159,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k k fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -229,7 +229,7 @@ func SimulateMsgEditValidator(ak types.AccountKeeper, bk types.BankKeeper, k kee fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -301,7 +301,7 @@ func SimulateMsgDelegate(ak types.AccountKeeper, bk types.BankKeeper, k keeper.K fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -390,7 +390,7 @@ func SimulateMsgUndelegate(ak types.AccountKeeper, bk types.BankKeeper, k keeper fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) @@ -502,7 +502,7 @@ func SimulateMsgBeginRedelegate(ak types.AccountKeeper, bk types.BankKeeper, k k fees, helpers.DefaultGenTxGas, chainID, - []uint64{0}, + []uint64{account.GetAccountNumber()}, []uint64{account.GetSequence()}, simAccount.PrivKey, ) diff --git a/x/wasm/keeper/keeper_test.go b/x/wasm/keeper/keeper_test.go index 3e19a2250c..1303824707 100644 --- a/x/wasm/keeper/keeper_test.go +++ b/x/wasm/keeper/keeper_test.go @@ -287,7 +287,7 @@ func TestInstantiate(t *testing.T) { gasAfter := ctx.GasMeter().GasConsumed() if types.EnableGasVerification { - require.Equal(t, uint64(0x1115c), gasAfter-gasBefore) + require.Equal(t, uint64(0x11d92), 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(0x107b7), gasAfter-gasBefore) + require.Equal(t, uint64(0x113ff), gasAfter-gasBefore) } // ensure bob now exists and got both payments released bobAcct = accKeeper.GetAccount(ctx, bob) diff --git a/x/wasm/types/expected_keepers.go b/x/wasm/types/expected_keepers.go index af7839cab0..a7bd2b555a 100644 --- a/x/wasm/types/expected_keepers.go +++ b/x/wasm/types/expected_keepers.go @@ -35,7 +35,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 specified address. Does not save the new account to the store. + // Return a new account with the next account number and 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