diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 000000000000..6598e00166c6 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,51 @@ +name: Tests E2E +# Tests Race workflow runs unit tests with the race detector +# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed +on: + pull_request: + push: + branches: + - main + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - uses: technote-space/get-diff-action@v6.1.0 + id: git_diff + with: + PATTERNS: | + **/**.go + **/go.mod + **/go.sum + key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} + - name: Build + if: env.GIT_DIFF + run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build + + + test-e2e: + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + - uses: technote-space/get-diff-action@v6.1.0 + with: + PATTERNS: | + **/**.go + go.mod + go.sum + - name: e2e tests + if: env.GIT_DIFF + run: | + cd tests/e2e && go test ./... -mod=readonly -timeout 30m -race -tags='e2e' diff --git a/.github/workflows/fork-cherry-pick.yml b/.github/workflows/fork-cherry-pick.yml new file mode 100644 index 000000000000..6b68996ac6ad --- /dev/null +++ b/.github/workflows/fork-cherry-pick.yml @@ -0,0 +1,46 @@ +on: + #Set to trigger on every merge to main, not just a closed PR. + workflow_dispatch: + pull_request_target: + branches: + - main + types: ["closed"] + +jobs: + cherry_pick: + runs-on: ubuntu-latest + name: Cherry pick into main + if: github.event.pull_request.merged == true + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 1 + - name: Create PR Patch Branch + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git config --global user.name "${GITHUB_ACTOR}" #Configs have to be set for pushing the cherry-picked changes onto fork pr-patch branch. + git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git remote add upstream https://github.com/cosmos/cosmos-sdk.git + git fetch --all # Get the latest code + git checkout -b pr-patch upstream/main # Create new branch based on main branch + git cherry-pick ${{github.event.pull_request.head.sha}} # Cherry pick the latest commit of PR + git push -u origin pr-patch # Push your changes to the remote branch + - name: Autocreate PR + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + curl --request POST \ + --url https://api.github.com/repos/cosmos/cosmos-sdk/pulls \ + --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ + --header 'content-type: application/json' \ + --data '{ + "title": "Automated PR for commit: ${{github.event.pull_request.head.sha}}", + "body":"Please merge these awesome changes in!", + "head":"${{github.event.pull_request.user.login}}:pr-patch", + "base":"main" + }' \ + --fail diff --git a/.github/workflows/proto-registry.yml b/.github/workflows/proto-registry.yml index 0b86185e7e6b..7a6945b3f0fe 100644 --- a/.github/workflows/proto-registry.yml +++ b/.github/workflows/proto-registry.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1.6.0 + - uses: bufbuild/buf-setup-action@v1.7.0 - uses: bufbuild/buf-push-action@v1 with: input: "proto" diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 7d73948e4399..20d6d798f161 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -15,7 +15,7 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1.6.0 + - uses: bufbuild/buf-setup-action@v1.7.0 - uses: bufbuild/buf-lint-action@v1 with: input: "proto" @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1.6.0 + - uses: bufbuild/buf-setup-action@v1.7.0 - uses: bufbuild/buf-breaking-action@v1 with: input: "proto" diff --git a/.github/workflows/test-race.yml b/.github/workflows/test-race.yml deleted file mode 100644 index f793539d6ef5..000000000000 --- a/.github/workflows/test-race.yml +++ /dev/null @@ -1,138 +0,0 @@ -name: Tests Race -# Tests Race workflow runs unit tests with the race detector -# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed -on: - pull_request: - push: - branches: - - main - -permissions: - contents: read - -jobs: - cleanup-runs: - runs-on: buildjet-4vcpu-ubuntu-2004 - steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" - - install-tparse: - runs-on: buildjet-4vcpu-ubuntu-2004 - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - name: Display go version - run: go version - - name: install tparse - run: go install github.com/mfridman/tparse@v0.8.3 - - uses: actions/cache@v3 - with: - path: ~/go/bin - key: ${{ runner.os }}-go-tparse-binary - - build: - runs-on: buildjet-4vcpu-ubuntu-2004 - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - uses: technote-space/get-diff-action@v6.1.0 - id: git_diff - with: - PATTERNS: | - **/**.go - **/go.mod - **/go.sum - - name: Get data from Go build cache - uses: actions/cache@v3 - # if: env.GIT_DIFF - if: ${{ false }} - with: - path: | - ~/go/pkg/mod - ~/.cache/golangci-lint - ~/.cache/go-build - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - - name: Build - if: env.GIT_DIFF - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make build - - - name: Build cosmovisor - if: env.GIT_DIFF - run: GOARCH=${{ matrix.go-arch }} LEDGER_ENABLED=false make cosmovisor - - split-test-files: - runs-on: buildjet-4vcpu-ubuntu-2004 - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - name: Create a file with all core Cosmos SDK pkgs - run: go list ./... > pkgs.txt - - name: Split pkgs into 4 files - run: split -d -n l/4 pkgs.txt pkgs.txt.part. - # cache multiple - - uses: actions/upload-artifact@v3 - with: - name: "${{ github.sha }}-00" - path: ./pkgs.txt.part.00 - - uses: actions/upload-artifact@v3 - with: - name: "${{ github.sha }}-01" - path: ./pkgs.txt.part.01 - - uses: actions/upload-artifact@v3 - with: - name: "${{ github.sha }}-02" - path: ./pkgs.txt.part.02 - - uses: actions/upload-artifact@v3 - with: - name: "${{ github.sha }}-03" - path: ./pkgs.txt.part.03 - - test-race: - runs-on: buildjet-4vcpu-ubuntu-2004 - needs: split-test-files - strategy: - fail-fast: false - matrix: - part: ["00", "01", "02", "03"] - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.18 - - uses: technote-space/get-diff-action@v6.1.0 - with: - PATTERNS: | - **/**.go - go.mod - go.sum - - name: Get data from Go build cache - uses: actions/cache@v3 - # if: env.GIT_DIFF - if: ${{ false }} - with: - path: | - ~/go/pkg/mod - ~/.cache/golangci-lint - ~/.cache/go-build - key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} - - uses: actions/download-artifact@v3 - if: env.GIT_DIFF - with: - name: "${{ github.sha }}-${{ matrix.part }}" - - name: test & coverage report creation - if: env.GIT_DIFF - run: | - xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -timeout 30m -race -tags='cgo ledger test_ledger_mock' - - uses: actions/upload-artifact@v3 - if: env.GIT_DIFF - with: - name: "${{ github.sha }}-${{ matrix.part }}-race-output" - path: ./${{ matrix.part }}-race-output.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 357ae8efb995..c1a26183a0c9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -157,7 +157,7 @@ jobs: if: env.GIT_DIFF - name: test & coverage report creation run: | - cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='norace ledger test_ledger_mock' + cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -race -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='ledger test_ledger_mock' if: env.GIT_DIFF - uses: actions/upload-artifact@v3 with: diff --git a/.golangci.yml b/.golangci.yml index b3bb53915185..173d530b9b32 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,7 +6,6 @@ run: linters: disable-all: true enable: - - bodyclose - deadcode - depguard - dogsled @@ -23,11 +22,9 @@ linters: - nakedret - nolintlint - staticcheck - - structcheck - stylecheck - typecheck - unconvert - - unparam - unused issues: diff --git a/CHANGELOG.md b/CHANGELOG.md index 527a7a4ac54d..1f0356a5b70d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,25 +39,18 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (x/authz) [#12648](https://github.com/cosmos/cosmos-sdk/pull/12648) Add an allow list, an optional list of addresses allowed to receive bank assests via authz MsgSend grant. * (cli) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Add the `tendermint key-migrate` to perform Tendermint v0.35 DB key migration. -* (query) [#12253](https://github.com/cosmos/cosmos-sdk/pull/12253) Add `GenericFilteredPaginate` to the `query` package to improve UX. -* (telemetry) [#12405](https://github.com/cosmos/cosmos-sdk/pull/12405) Add _query_ calls metric to telemetry. * (sdk.Coins) [#12627](https://github.com/cosmos/cosmos-sdk/pull/12627) Make a Denoms method on sdk.Coins. -* (upgrade) [#12603](https://github.com/cosmos/cosmos-sdk/pull/12603) feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces ### Improvements -* [#12668](https://github.com/cosmos/cosmos-sdk/pull/12668) Add `authz_msg_index` event attribute to message events emitted when executing via `MsgExec` through `x/authz`. +* [#12717](https://github.com/cosmos/cosmos-sdk/pull/12717) Use injected encoding params in simapp. +* (x/bank) [#12674](https://github.com/cosmos/cosmos-sdk/pull/12674) Add convenience function `CreatePrefixedAccountStoreKey()` to construct key to access account's balance for a given denom. +* [#12702](https://github.com/cosmos/cosmos-sdk/pull/12702) Linting and tidiness, fixed two minor security warnings. * [#12634](https://github.com/cosmos/cosmos-sdk/pull/12634) Move `sdk.Dec` to math package. * [#12596](https://github.com/cosmos/cosmos-sdk/pull/12596) Remove all imports of the non-existent gogo/protobuf v1.3.3 to ease downstream use and go workspaces. -* [#12589](https://github.com/cosmos/cosmos-sdk/pull/12589) Allow zero gas in simulation mode. -* [#12576](https://github.com/cosmos/cosmos-sdk/pull/12576) Remove dependency on cosmos/keyring and upgrade to 99designs/keyring v1.2.1 -* [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Mark the `TipDecorator` as beta, don't include it in simapp by default. -* [#12153](https://github.com/cosmos/cosmos-sdk/pull/12153) Add a new `NewSimulationManagerFromAppModules` constructor, to simplify simulation wiring. * [#12187](https://github.com/cosmos/cosmos-sdk/pull/12187) Add batch operation for x/nft module. -* [#12453](https://github.com/cosmos/cosmos-sdk/pull/12453) Add `NewInMemoryWithKeyring` function which allows the creation of in memory `keystore` instances with a specified set of existing items. -* [#11390](https://github.com/cosmos/cosmos-sdk/pull/11390) `LatestBlockResponse` & `BlockByHeightResponse` types' `Block` filed has been deprecated and they now contains new field `sdk_block` with `proposer_address` as `string` -* [#12626](https://github.com/cosmos/cosmos-sdk/pull/12626) Upgrade IAVL to v0.19.0 with fast index and error propagation. NOTE: first start will take a while to propagate into new model. * [#12693](https://github.com/cosmos/cosmos-sdk/pull/12693) Make sure the order of each node is consistent when emitting proto events. ### State Machine Breaking @@ -70,10 +63,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/distribution) [#12434](https://github.com/cosmos/cosmos-sdk/pull/12434) Migrate `x/distribution` to self-managed parameters and deprecate it's usage of `x/params`. * (x/crisis) [#12445](https://github.com/cosmos/cosmos-sdk/pull/12445) Migrate `x/crisis` to self-managed parameters and deprecate it's usage of `x/params`. * (x/staking) [#12409](https://github.com/cosmos/cosmos-sdk/pull/12409) Migrate `x/staking` to self-managed parameters and deprecate it's usage of `x/params`. - +* (x/bank) [#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) Move the SendEnabled information out of the Params and into the state store directly. ### API Breaking Changes +* (simapp) [#12747](https://github.com/cosmos/cosmos-sdk/pull/12747) Remove `simapp.MakeTestEncodingConfig`. Please use `moduletestutil.MakeTestEncodingConfig` (`types/module/testutil`) in tests instead. +* (x/bank) [#12648](https://github.com/cosmos/cosmos-sdk/pull/12648) `NewSendAuthorization` takes a new argument of an optional list of addresses allowed to receive bank assests via authz MsgSend grant. You can pass `nil` for the same behavior as before, i.e. any recipient is allowed. * (x/bank) [\#12593](https://github.com/cosmos/cosmos-sdk/pull/12593) Add `SpendableCoin` method to `BaseViewKeeper` * (x/slashing) [#12581](https://github.com/cosmos/cosmos-sdk/pull/12581) Remove `x/slashing` legacy querier. * (types) [\#12355](https://github.com/cosmos/cosmos-sdk/pull/12355) Remove the compile-time `types.DBbackend` variable. Removes usage of the same in server/util.go @@ -89,38 +84,36 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/distribution) [#12434](https://github.com/cosmos/cosmos-sdk/pull/12434) `x/distribution` module `SetParams` keeper method definition is now updated to return `error`. * (x/staking) [#12409](https://github.com/cosmos/cosmos-sdk/pull/12409) `x/staking` module `SetParams` keeper method definition is now updated to return `error`. * (x/crisis) [#12445](https://github.com/cosmos/cosmos-sdk/pull/12445) `x/crisis` module `SetConstantFee` keeper method definition is now updated to return `error`. +* (x/bank) [#12630](https://github.com/cosmos/cosmos-sdk/pull/12630) `x/bank` module `SetParams` keeper method definition is now updated to return `error`. +* (x/bank) [\#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) Move the SendEnabled information out of the Params and into the state store directly. + The information can now be accessed using the BankKeeper. + Setting can be done using MsgSetSendEnabled as a governance proposal. + A SendEnabled query has been added to both GRPC and CLI. +* (appModule) Remove `Route`, `QuerierRoute` and `LegacyQuerierHandler` from AppModule Interface. +* (x/modules) Remove all LegacyQueries and related code from modules ### CLI Breaking Changes -* (x/group) [#12551](https://github.com/cosmos/cosmos-sdk/pull/12551) read the decision policy from disk in group CLI commands. +* / ### Bug Fixes * [#12548](https://github.com/cosmos/cosmos-sdk/pull/12548) Prevent signing from wrong key while using multisig. -* [#12416](https://github.com/cosmos/cosmos-sdk/pull/12416) Prevent zero gas transactions in the `DeductFeeDecorator` AnteHandler decorator. -* (x/mint) [#12384](https://github.com/cosmos/cosmos-sdk/pull/12384) Ensure `GoalBonded` must be positive when performing `x/mint` parameter validation. -* (x/auth) [#12261](https://github.com/cosmos/cosmos-sdk/pull/12261) Deprecate pagination in GetTxsEventRequest/Response in favor of page and limit to align with tendermint `SignClient.TxSearch` -* (vesting) [#12190](https://github.com/cosmos/cosmos-sdk/pull/12190) Replace https://github.com/cosmos/cosmos-sdk/pull/12190 to use `NewBaseAccountWithAddress` in all vesting account message handlers. -* (linting) [#12135](https://github.com/cosmos/cosmos-sdk/pull/12135) Fix variable naming issues per enabled linters. Run gofumpt to ensure easy reviews of ongoing linting work. -* (linting) [#12132](https://github.com/cosmos/cosmos-sdk/pull/12132) Change sdk.Int to math.Int, run `gofumpt -w -l .`, and `golangci-lint run ./... --fix` -* (cli) [#12127](https://github.com/cosmos/cosmos-sdk/pull/12127) Fix the CLI not always taking into account `--fee-payer` and `--fee-granter` flags. -* (migrations) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Fix v0.45->v0.46 in-place store migrations. -* (baseapp) [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Include antehandler and runMsgs events in SimulateTx. -* (cli) [#12095](https://github.com/cosmos/cosmos-sdk/pull/12095) Fix running a tx with --dry-run returns an error -* (x/auth) [#12108](https://github.com/cosmos/cosmos-sdk/pull/12108) Fix GetBlockWithTxs error when querying block with 0 tx * (genutil) [#12140](https://github.com/cosmos/cosmos-sdk/pull/12140) Fix staking's genesis JSON migrate in the `simd migrate v0.46` CLI command. * (types) [#12154](https://github.com/cosmos/cosmos-sdk/pull/12154) Add `baseAccountGetter` to avoid invalid account error when create vesting account. * (x/authz) [#12184](https://github.com/cosmos/cosmos-sdk/pull/12184) Fix MsgExec not verifying the validity of nested messages. -* (x/crisis) [#12208](https://github.com/cosmos/cosmos-sdk/pull/12208) Fix progress index of crisis invariant assertion logs. -* (types) [#12229](https://github.com/cosmos/cosmos-sdk/pull/12229) Increase sdk.Dec maxApproxRootIterations to 300 * (x/staking) [#12303](https://github.com/cosmos/cosmos-sdk/pull/12303) Use bytes instead of string comparison in delete validator queue -* (testutil/sims) [#12374](https://github.com/cosmos/cosmos-sdk/pull/12374) fix the non-determinstic behavior in simulations caused by `GenSignedMockTx` and check -empty coins slice before it is used to create `banktype.MsgSend`. * (x/auth/tx) [#12474](https://github.com/cosmos/cosmos-sdk/pull/12474) Remove condition in GetTxsEvent that disallowed multiple equal signs, which would break event queries with base64 strings (i.e. query by signature). -* [#12448](https://github.com/cosmos/cosmos-sdk/pull/12448) Start telemetry independently from the API server. * (store/rootmulti) [#12487](https://github.com/cosmos/cosmos-sdk/pull/12487) Fix non-deterministic map iteration. -## [v0.46.0-rc1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0-rc1) - 2022-05-23 +### Deprecated + +* (x/bank) [#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) The Params.SendEnabled field is deprecated and unusable. + The information can now be accessed using the BankKeeper. + Setting can be done using MsgSetSendEnabled as a governance proposal. + A SendEnabled query has been added to both GRPC and CLI. + +## [v0.46.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0) - 2022-07-26 ### Features @@ -173,6 +166,10 @@ empty coins slice before it is used to create `banktype.MsgSend`. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) Support grant with no expire time. * (rosetta) [\#11590](https://github.com/cosmos/cosmos-sdk/pull/11590) Add fee suggestion for rosetta and enable offline mode. Also force set events about Fees to Success to pass reconciliation test. * (types) [\#11959](https://github.com/cosmos/cosmos-sdk/pull/11959) Added `sdk.Coins.Find` helper method to find a coin by denom. +* (upgrade) [#12603](https://github.com/cosmos/cosmos-sdk/pull/12603) feat: Move AppModule.BeginBlock and AppModule.EndBlock to extension interfaces +* (telemetry) [#12405](https://github.com/cosmos/cosmos-sdk/pull/12405) Add _query_ calls metric to telemetry. +* (cli) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Add the `tendermint key-migrate` to perform Tendermint v0.35 DB key migration. +* (query) [#12253](https://github.com/cosmos/cosmos-sdk/pull/12253) Add `GenericFilteredPaginate` to the `query` package to improve UX. ### API Breaking Changes @@ -249,10 +246,6 @@ empty coins slice before it is used to create `banktype.MsgSend`. * [\#11334](https://github.com/cosmos/cosmos-sdk/pull/11334) Move `x/gov/types/v1beta2` to `x/gov/types/v1`. * (x/auth/middleware) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to be extensible on tx fee logic. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, make the logic extensible using the `TxFeeChecker` option, the current fee logic is preserved by the default `checkTxFeeWithValidatorMinGasPrices` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` which is extensible with the `ExtensionOptionChecker` option. Unpack the tx extension options `Any`s to interface `TxExtensionOptionI`. * (migrations) [#11556](https://github.com/cosmos/cosmos-sdk/pull/11556#issuecomment-1091385011) Remove migration code from 0.42 and below. To use previous migrations, checkout previous versions of the cosmos-sdk. -* (x/bank) [\#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) Move the SendEnabled information out of the Params and into the state store directly. - The information can now be accessed using the BankKeeper. - Setting can be done using MsgSetSendEnabled as a governance proposal. - A SendEnabled query has been added to both GRPC and CLI. ### Client Breaking Changes @@ -309,19 +302,27 @@ empty coins slice before it is used to create `banktype.MsgSend`. * (x/auth) [\#11482](https://github.com/cosmos/cosmos-sdk/pull/11482) Improve panic message when attempting to register a method handler for a message that does not implement sdk.Msg * (x/staking) [\#11596](https://github.com/cosmos/cosmos-sdk/pull/11596) Add (re)delegation getters * (errors) [\#11960](https://github.com/cosmos/cosmos-sdk/pull/11960) Removed 'redacted' error message from defaultErrEncoder -* (ante) [#12013](https://github.com/cosmos/cosmos-sdk/pull/12013) Index ante events for failed tx. +* (ante) [#12013](https://github.com/cosmos/cosmos-sdk/pull/12013) Index ante events for failed tx. +* [#12668](https://github.com/cosmos/cosmos-sdk/pull/12668) Add `authz_msg_index` event attribute to message events emitted when executing via `MsgExec` through `x/authz`. +* [#12626](https://github.com/cosmos/cosmos-sdk/pull/12626) Upgrade IAVL to v0.19.0 with fast index and error propagation. NOTE: first start will take a while to propagate into new model. +* [#12649](https://github.com/cosmos/cosmos-sdk/pull/12649) Bump tendermint to v0.34.20. +* [#12576](https://github.com/cosmos/cosmos-sdk/pull/12576) Remove dependency on cosmos/keyring and upgrade to 99designs/keyring v1.2.1 +* [#12590](https://github.com/cosmos/cosmos-sdk/pull/12590) Allow zero gas in simulation mode. +* [#12453](https://github.com/cosmos/cosmos-sdk/pull/12453) Add `NewInMemoryWithKeyring` function which allows the creation of in memory `keystore` instances with a specified set of existing items. +* [#11390](https://github.com/cosmos/cosmos-sdk/pull/11390) `LatestBlockResponse` & `BlockByHeightResponse` types' `Block` filed has been deprecated and they now contains new field `sdk_block` with `proposer_address` as `string` +* (deps) Downgrade to Tendermint [v0.34.20-rc0](https://github.com/tendermint/tendermint/releases/tag/v0.34.20-rc0). +* [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Mark the `TipDecorator` as beta, don't include it in simapp by default. +* [#12153](https://github.com/cosmos/cosmos-sdk/pull/12153) Add a new `NewSimulationManagerFromAppModules` constructor, to simplify simulation wiring. ### Bug Fixes -* (cli) [#12075](https://github.com/cosmos/cosmos-sdk/pull/12075) Add `p2p-port` to the `gentx` and `create-validator` CLI commands to support custom P2P ports. -* (x/slashing) [\#11973](https://github.com/cosmos/cosmos-sdk/pull/11973) Update StartHeight signing info in AfterValidatorBonded hook when validator re-bonds -* [\#11969](https://github.com/cosmos/cosmos-sdk/pull/11969) Fix the panic error in `x/upgrade` when `AppVersion` is not set. +* [#11969](https://github.com/cosmos/cosmos-sdk/pull/11969) Fix the panic error in `x/upgrade` when `AppVersion` is not set. * (tests) [\#11940](https://github.com/cosmos/cosmos-sdk/pull/11940) Fix some client tests in the `x/gov` module * [\#11772](https://github.com/cosmos/cosmos-sdk/pull/11772) Limit types.Dec length to avoid overflow. * [\#11724](https://github.com/cosmos/cosmos-sdk/pull/11724) Fix data race issues with api.Server * [\#11693](https://github.com/cosmos/cosmos-sdk/pull/11693) Add validation for gentx cmd. -* (cli) [\#11645](https://github.com/cosmos/cosmos-sdk/pull/11645) Fix `--home` flag ignored when running help. -* (cli) [\#11558](https://github.com/cosmos/cosmos-sdk/pull/11558) Fix `--dry-run` not working when using tx command. +* [\#11645](https://github.com/cosmos/cosmos-sdk/pull/11645) Fix `--home` flag ignored when running help. +* [\#11558](https://github.com/cosmos/cosmos-sdk/pull/11558) Fix `--dry-run` not working when using tx command. * [\#11354](https://github.com/cosmos/cosmos-sdk/pull/11355) Added missing pagination flag for `bank q total` query. * [\#11197](https://github.com/cosmos/cosmos-sdk/pull/11197) Signing with multisig now works with multisig address which is not in the keyring. * (makefile) [\#11285](https://github.com/cosmos/cosmos-sdk/pull/11285) Fix lint-fix make target. @@ -370,6 +371,25 @@ empty coins slice before it is used to create `banktype.MsgSend`. * (simapp) [\#11855](https://github.com/cosmos/cosmos-sdk/pull/11855) Use `sdkmath.Int` instead of `int64` for `SimulationState.InitialStake`. * (x/capability) [\#11737](https://github.com/cosmos/cosmos-sdk/pull/11737) Use a fixed length encoding of `Capability` pointer for `FwdCapabilityKey` * [\#11983](https://github.com/cosmos/cosmos-sdk/pull/11983) (x/feegrant, x/authz) rename grants query commands to `grants-by-grantee`, `grants-by-granter` cmds. +* (protos) [#12701](https://github.com/cosmos/cosmos-sdk/pull/12701) Fix tendermint and ics23 versions used in Makefile. Run "make proto-gen". +* (testutil/sims) [#12374](https://github.com/cosmos/cosmos-sdk/pull/12374) fix the non-determinstic behavior in simulations caused by `GenSignedMockTx` and check empty coins slice before it is used to create `banktype.MsgSend`. +* [#12448](https://github.com/cosmos/cosmos-sdk/pull/12448) Start telemetry independently from the API server. +* [#12509](https://github.com/cosmos/cosmos-sdk/pull/12509) Fix `Register{Tx,Tendermint}Service` not being called, resulting in some endpoints like the Simulate endpoint not working. +* [#12416](https://github.com/cosmos/cosmos-sdk/pull/12416) Prevent zero gas transactions in the `DeductFeeDecorator` AnteHandler decorator. +* (x/mint) [#12384](https://github.com/cosmos/cosmos-sdk/pull/12384) Ensure `GoalBonded` must be positive when performing `x/mint` parameter validation. +* (x/auth) [#12261](https://github.com/cosmos/cosmos-sdk/pull/12261) Deprecate pagination in GetTxsEventRequest/Response in favor of page and limit to align with tendermint `SignClient.TxSearch` +* (vesting) [#12190](https://github.com/cosmos/cosmos-sdk/pull/12190) Replace https://github.com/cosmos/cosmos-sdk/pull/12190 to use `NewBaseAccountWithAddress` in all vesting account message handlers. +* (linting) [#12135](https://github.com/cosmos/cosmos-sdk/pull/12135/) Fix variable naming issues per enabled linters. Run gofumpt to ensure easy reviews of ongoing linting work. +* (linting) [#12132](https://github.com/cosmos/cosmos-sdk/pull/12132) Change sdk.Int to math.Int, run `gofumpt -w -l .`, and `golangci-lint run ./... --fix` +* (cli) [#12127](https://github.com/cosmos/cosmos-sdk/pull/12127) Fix the CLI not always taking into account `--fee-payer` and `--fee-granter` flags. +* (migrations) [#12028](https://github.com/cosmos/cosmos-sdk/pull/12028) Fix v0.45->v0.46 in-place store migrations. +* (baseapp) [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Include antehandler and runMsgs events in SimulateTx. +* (cli) [#12095](https://github.com/cosmos/cosmos-sdk/pull/12095) Fix running a tx with --dry-run returns an error +* (x/auth) [#12108](https://github.com/cosmos/cosmos-sdk/pull/12108) Fix GetBlockWithTxs error when querying block with 0 tx +* (genutil) [#12140](https://github.com/cosmos/cosmos-sdk/pull/12140) Fix staking's genesis JSON migrate in the `simd migrate v0.46` CLI command. +* (types) [#12154](https://github.com/cosmos/cosmos-sdk/pull/12154) Add `baseAccountGetter` to avoid invalid account error when create vesting account. +* (x/crisis) [#12208](https://github.com/cosmos/cosmos-sdk/pull/12208) Fix progress index of crisis invariant assertion logs. +* (types) [#12229](https://github.com/cosmos/cosmos-sdk/pull/12229) Increase sdk.Dec maxApproxRootIterations to 300 ### State Machine Breaking @@ -385,7 +405,7 @@ empty coins slice before it is used to create `banktype.MsgSend`. * (x/upgrade) [\#10189](https://github.com/cosmos/cosmos-sdk/issues/10189) Removed potential sources of non-determinism in upgrades * [\#10422](https://github.com/cosmos/cosmos-sdk/pull/10422) and [\#10529](https://github.com/cosmos/cosmos-sdk/pull/10529) Add `MinCommissionRate` param to `x/staking` module. * (x/gov) [#10763](https://github.com/cosmos/cosmos-sdk/pull/10763) modify the fields in `TallyParams` to use `string` instead of `bytes` -* [#10770](https://github.com/cosmos/cosmos-sdk/pull/10770) revert tx when block gas limit exceeded +* [#10770](https://github.com/cosmos/cosmos-sdk/pull/10770) revert tx when block gas limit exceeded * (x/gov) [\#10868](https://github.com/cosmos/cosmos-sdk/pull/10868) Bump gov to v1beta2. Both v1beta1 and v1beta2 queries and Msgs are accepted. * [\#11011](https://github.com/cosmos/cosmos-sdk/pull/11011) Remove burning of deposits when qourum is not reached on a governance proposal and when the deposit is not fully met. * [\#11019](https://github.com/cosmos/cosmos-sdk/pull/11019) Add `MsgCreatePermanentLockedAccount` and CLI method for creating permanent locked account @@ -395,16 +415,11 @@ empty coins slice before it is used to create `banktype.MsgSend`. * (x/authz,x/feegrant) [\#11214](https://github.com/cosmos/cosmos-sdk/pull/11214) Fix Amino JSON encoding of authz and feegrant Msgs to be consistent with other modules. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) Support grant with no expire time. * (x/gov) [\#10868](https://github.com/cosmos/cosmos-sdk/pull/10868) Bump gov to v1. -* (x/bank) [\#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) Move the SendEnabled information out of the Params and into the state store directly. ### Deprecated * (x/upgrade) [\#9906](https://github.com/cosmos/cosmos-sdk/pull/9906) Deprecate `UpgradeConsensusState` gRPC query since this functionality is only used for IBC, which now has its own [IBC replacement](https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54) * (types) [\#10948](https://github.com/cosmos/cosmos-sdk/issues/10948) Deprecate the types.DBBackend variable and types.NewLevelDB function. They are replaced by a new entry in `app.toml`: `app-db-backend` and `tendermint/tm-db`s `NewDB` function. If `app-db-backend` is defined, then it is used. Otherwise, if `types.DBBackend` is defined, it is used (until removed: [\#11241](https://github.com/cosmos/cosmos-sdk/issues/11241)). Otherwise, Tendermint config's `db-backend` is used. -* (x/bank) [\#11859](https://github.com/cosmos/cosmos-sdk/pull/11859) The Params.SendEnabled field is deprecated and unusable. - The information can now be accessed using the BankKeeper. - Setting can be done using MsgSetSendEnabled as a governance proposal. - A SendEnabled query has been added to both GRPC and CLI. ## [v0.45.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.6) - 2022-06-28 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 05f3ff79d0c2..d3acacb03de3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -109,7 +109,7 @@ Then: Draft PRs also helps the core team provide early feedback and ensure the work is in the right direction. 2. When the code is complete, change your PR from `Draft` to `Ready for Review`. 3. Go through the actions for each checkbox present in the PR template description. The PR actions are automatically provided for each new PR. -4. Be sure to include a relevant changelog entry in the `Unreleased` section of `CHANGELOG.md` (see file for log format). +4. Be sure to include a relevant changelog entry in the `Unreleased` section of `CHANGELOG.md` (see file for log format). The entry should be on top of all others changes in the section. PRs must have a category prefix that is based on the type of changes being made (for example, `fix`, `feat`, `refactor`, `docs`, and so on). The *type* must be included in the PR title as a prefix (for example, diff --git a/Makefile b/Makefile index c386f74b96c1..2c57fc741a23 100644 --- a/Makefile +++ b/Makefile @@ -430,10 +430,10 @@ proto-check-breaking: @$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main -TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc6/proto/tendermint +TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.35.9/proto/tendermint GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master -CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.6.3 +CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.7.0 TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto TM_ABCI_TYPES = third_party/proto/tendermint/abci diff --git a/UPGRADING.md b/UPGRADING.md index 453e7b93de8d..2af7041ee495 100644 --- a/UPGRADING.md +++ b/UPGRADING.md @@ -2,7 +2,31 @@ This guide provides instructions for upgrading to specific versions of Cosmos SDK. -## v0.46 +## [Unreleased] + +### AppModule Interface + +Remove `Querier`, `Route` and `LegacyQuerier` from the app module interface. This removes and fully deprecates all legacy queriers. All modules no longer support the REST API previously known as the LCD, and the `sdk.Msg#Route` method won't be used anymore. + + + +### SimApp + +SimApp's `app.go` is using App Wiring, the dependency injection framework of the Cosmos SDK. +This means that modules are injected directly into SimApp thanks to a [configuration file](https://github.com/cosmos/cosmos-sdk/blob/main/simapp/app_config.go). +The old behavior is preserved and still can be used, without the dependency injection framework, as shows [`app_legacy.go`](https://github.com/cosmos/cosmos-sdk/blob/main/simapp/app_legacy.go). + +The constructor, `NewSimApp` has been simplified: + +* `NewSimApp` does not take encoding parameters (`encodingConfig`) as input, instead the encoding parameters are injected (when using app wiring), or directly created in the constructor. Instead, we can instantiate `SimApp` for getting the encoding configuration. +* `NewSimApp` now uses `AppOptions` for getting the home path (`homePath`) and the invariant checks period (`invCheckPeriod`). These were unnecessary given as arguments as they were already present in the `AppOptions`. + +### Encoding + +`simapp.MakeTestEncodingConfig()` was deprecated and has been removed. Instead you can use the `TestEncodingConfig` from the `types/module/testutil` package. +This means you can replace your usage of `simapp.MakeTestEncodingConfig` in tests to `moduletestutil.MakeTestEncodingConfig`, which takes a series of relevant `AppModuleBasic` as input (the module being tested and any potential dependencies). + +## [v0.46.x](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.0) ### Client Changes diff --git a/api/cosmos/bank/v1beta1/authz.pulsar.go b/api/cosmos/bank/v1beta1/authz.pulsar.go index f00963c1459b..144371420335 100644 --- a/api/cosmos/bank/v1beta1/authz.pulsar.go +++ b/api/cosmos/bank/v1beta1/authz.pulsar.go @@ -66,15 +66,63 @@ func (x *_SendAuthorization_1_list) IsValid() bool { return x.list != nil } +var _ protoreflect.List = (*_SendAuthorization_2_list)(nil) + +type _SendAuthorization_2_list struct { + list *[]string +} + +func (x *_SendAuthorization_2_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_SendAuthorization_2_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_SendAuthorization_2_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_SendAuthorization_2_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_SendAuthorization_2_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message SendAuthorization at list field AllowList as it is not of Message kind")) +} + +func (x *_SendAuthorization_2_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_SendAuthorization_2_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_SendAuthorization_2_list) IsValid() bool { + return x.list != nil +} + var ( md_SendAuthorization protoreflect.MessageDescriptor fd_SendAuthorization_spend_limit protoreflect.FieldDescriptor + fd_SendAuthorization_allow_list protoreflect.FieldDescriptor ) func init() { file_cosmos_bank_v1beta1_authz_proto_init() md_SendAuthorization = File_cosmos_bank_v1beta1_authz_proto.Messages().ByName("SendAuthorization") fd_SendAuthorization_spend_limit = md_SendAuthorization.Fields().ByName("spend_limit") + fd_SendAuthorization_allow_list = md_SendAuthorization.Fields().ByName("allow_list") } var _ protoreflect.Message = (*fastReflection_SendAuthorization)(nil) @@ -148,6 +196,12 @@ func (x *fastReflection_SendAuthorization) Range(f func(protoreflect.FieldDescri return } } + if len(x.AllowList) != 0 { + value := protoreflect.ValueOfList(&_SendAuthorization_2_list{list: &x.AllowList}) + if !f(fd_SendAuthorization_allow_list, value) { + return + } + } } // Has reports whether a field is populated. @@ -165,6 +219,8 @@ func (x *fastReflection_SendAuthorization) Has(fd protoreflect.FieldDescriptor) switch fd.FullName() { case "cosmos.bank.v1beta1.SendAuthorization.spend_limit": return len(x.SpendLimit) != 0 + case "cosmos.bank.v1beta1.SendAuthorization.allow_list": + return len(x.AllowList) != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.SendAuthorization")) @@ -183,6 +239,8 @@ func (x *fastReflection_SendAuthorization) Clear(fd protoreflect.FieldDescriptor switch fd.FullName() { case "cosmos.bank.v1beta1.SendAuthorization.spend_limit": x.SpendLimit = nil + case "cosmos.bank.v1beta1.SendAuthorization.allow_list": + x.AllowList = nil default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.SendAuthorization")) @@ -205,6 +263,12 @@ func (x *fastReflection_SendAuthorization) Get(descriptor protoreflect.FieldDesc } listValue := &_SendAuthorization_1_list{list: &x.SpendLimit} return protoreflect.ValueOfList(listValue) + case "cosmos.bank.v1beta1.SendAuthorization.allow_list": + if len(x.AllowList) == 0 { + return protoreflect.ValueOfList(&_SendAuthorization_2_list{}) + } + listValue := &_SendAuthorization_2_list{list: &x.AllowList} + return protoreflect.ValueOfList(listValue) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.SendAuthorization")) @@ -229,6 +293,10 @@ func (x *fastReflection_SendAuthorization) Set(fd protoreflect.FieldDescriptor, lv := value.List() clv := lv.(*_SendAuthorization_1_list) x.SpendLimit = *clv.list + case "cosmos.bank.v1beta1.SendAuthorization.allow_list": + lv := value.List() + clv := lv.(*_SendAuthorization_2_list) + x.AllowList = *clv.list default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.SendAuthorization")) @@ -255,6 +323,12 @@ func (x *fastReflection_SendAuthorization) Mutable(fd protoreflect.FieldDescript } value := &_SendAuthorization_1_list{list: &x.SpendLimit} return protoreflect.ValueOfList(value) + case "cosmos.bank.v1beta1.SendAuthorization.allow_list": + if x.AllowList == nil { + x.AllowList = []string{} + } + value := &_SendAuthorization_2_list{list: &x.AllowList} + return protoreflect.ValueOfList(value) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.SendAuthorization")) @@ -271,6 +345,9 @@ func (x *fastReflection_SendAuthorization) NewField(fd protoreflect.FieldDescrip case "cosmos.bank.v1beta1.SendAuthorization.spend_limit": list := []*v1beta1.Coin{} return protoreflect.ValueOfList(&_SendAuthorization_1_list{list: &list}) + case "cosmos.bank.v1beta1.SendAuthorization.allow_list": + list := []string{} + return protoreflect.ValueOfList(&_SendAuthorization_2_list{list: &list}) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.bank.v1beta1.SendAuthorization")) @@ -346,6 +423,12 @@ func (x *fastReflection_SendAuthorization) ProtoMethods() *protoiface.Methods { n += 1 + l + runtime.Sov(uint64(l)) } } + if len(x.AllowList) > 0 { + for _, s := range x.AllowList { + l = len(s) + n += 1 + l + runtime.Sov(uint64(l)) + } + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -375,6 +458,15 @@ func (x *fastReflection_SendAuthorization) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.AllowList) > 0 { + for iNdEx := len(x.AllowList) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.AllowList[iNdEx]) + copy(dAtA[i:], x.AllowList[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AllowList[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } if len(x.SpendLimit) > 0 { for iNdEx := len(x.SpendLimit) - 1; iNdEx >= 0; iNdEx-- { encoded, err := options.Marshal(x.SpendLimit[iNdEx]) @@ -474,6 +566,38 @@ func (x *fastReflection_SendAuthorization) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AllowList", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.AllowList = append(x.AllowList, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -532,6 +656,11 @@ type SendAuthorization struct { unknownFields protoimpl.UnknownFields SpendLimit []*v1beta1.Coin `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3" json:"spend_limit,omitempty"` + // allow_list specifies an optional list of addresses to whom the grantee can send tokens on behalf of the + // granter. If omitted, any recipient is allowed. + // + // Since: cosmos-sdk 0.47 + AllowList []string `protobuf:"bytes,2,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` } func (x *SendAuthorization) Reset() { @@ -561,6 +690,13 @@ func (x *SendAuthorization) GetSpendLimit() []*v1beta1.Coin { return nil } +func (x *SendAuthorization) GetAllowList() []string { + if x != nil { + return x.AllowList + } + return nil +} + var File_cosmos_bank_v1beta1_authz_proto protoreflect.FileDescriptor var file_cosmos_bank_v1beta1_authz_proto_rawDesc = []byte{ @@ -572,7 +708,7 @@ var file_cosmos_bank_v1beta1_authz_proto_rawDesc = []byte{ 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, - 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x94, 0x01, 0x0a, 0x11, 0x53, 0x65, 0x6e, 0x64, + 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb3, 0x01, 0x0a, 0x11, 0x53, 0x65, 0x6e, 0x64, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x6c, 0x0a, 0x0b, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, @@ -580,21 +716,23 @@ var file_cosmos_bank_v1beta1_authz_proto_rawDesc = []byte{ 0xde, 0x1f, 0x00, 0xaa, 0xdf, 0x1f, 0x28, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, - 0x0a, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x3a, 0x11, 0xca, 0xb4, 0x2d, - 0x0d, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xc5, - 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, - 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x41, 0x75, 0x74, 0x68, - 0x7a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, - 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, - 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x2e, 0x56, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, - 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x6e, 0x6b, 0x3a, 0x3a, 0x56, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x0a, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x61, + 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x09, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x4c, 0x69, 0x73, 0x74, 0x3a, 0x11, 0xca, 0xb4, 0x2d, 0x0d, + 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xc5, 0x01, + 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, + 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x7a, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, + 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, + 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x2e, 0x56, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, + 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x1f, 0x43, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x6e, 0x6b, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x15, + 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x6e, 0x6b, 0x3a, 0x3a, 0x56, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/cosmos/staking/v1beta1/tx_grpc.pb.go b/api/cosmos/staking/v1beta1/tx_grpc.pb.go index ee50ca5ab56b..60a83c19955b 100644 --- a/api/cosmos/staking/v1beta1/tx_grpc.pb.go +++ b/api/cosmos/staking/v1beta1/tx_grpc.pb.go @@ -40,7 +40,7 @@ type MsgClient interface { // // Since: cosmos-sdk 0.46 CancelUnbondingDelegation(ctx context.Context, in *MsgCancelUnbondingDelegation, opts ...grpc.CallOption) (*MsgCancelUnbondingDelegationResponse, error) - // UpdateParams defines a operation for updating the x/staking module + // UpdateParams defines an operation for updating the x/staking module // parameters. // Since: cosmos-sdk 0.47 UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) @@ -139,7 +139,7 @@ type MsgServer interface { // // Since: cosmos-sdk 0.46 CancelUnbondingDelegation(context.Context, *MsgCancelUnbondingDelegation) (*MsgCancelUnbondingDelegationResponse, error) - // UpdateParams defines a operation for updating the x/staking module + // UpdateParams defines an operation for updating the x/staking module // parameters. // Since: cosmos-sdk 0.47 UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) diff --git a/api/go.mod b/api/go.mod index 6d4f2617d6a2..c2cf1a41ae0c 100644 --- a/api/go.mod +++ b/api/go.mod @@ -5,14 +5,15 @@ go 1.18 require ( github.com/cosmos/cosmos-proto v1.0.0-alpha7 github.com/gogo/protobuf v1.3.2 - google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb + google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd google.golang.org/grpc v1.48.0 - google.golang.org/protobuf v1.28.0 + google.golang.org/protobuf v1.28.1 ) require ( github.com/golang/protobuf v1.5.2 // indirect - golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect - golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect - golang.org/x/text v0.3.5 // indirect + github.com/google/go-cmp v0.5.8 // indirect + golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect + golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/text v0.3.7 // indirect ) diff --git a/api/go.sum b/api/go.sum index 8ba0ac9ae851..c4f245da910e 100644 --- a/api/go.sum +++ b/api/go.sum @@ -1,16 +1,13 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= @@ -21,7 +18,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -49,8 +45,9 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= @@ -58,7 +55,6 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -84,8 +80,9 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -102,13 +99,15 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -120,7 +119,6 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -128,15 +126,15 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -151,8 +149,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/client/rpc/rpc_test.go b/client/rpc/rpc_test.go index e1d947977e6d..21dbd2b8cd3a 100644 --- a/client/rpc/rpc_test.go +++ b/client/rpc/rpc_test.go @@ -1,6 +1,3 @@ -//go:build norace -// +build norace - package rpc_test import ( diff --git a/client/v2/go.mod b/client/v2/go.mod index ab9d299b54b0..5f6d7c0686eb 100644 --- a/client/v2/go.mod +++ b/client/v2/go.mod @@ -9,18 +9,17 @@ require ( github.com/spf13/cobra v1.5.0 github.com/spf13/pflag v1.0.5 google.golang.org/grpc v1.48.0 - google.golang.org/protobuf v1.28.0 + google.golang.org/protobuf v1.28.1 gotest.tools/v3 v3.3.0 ) require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.6 // indirect + github.com/google/go-cmp v0.5.8 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect - golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect - golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect - golang.org/x/text v0.3.5 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect + golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect + golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect ) diff --git a/client/v2/go.sum b/client/v2/go.sum index 1f611995b44a..3fbd98dc7289 100644 --- a/client/v2/go.sum +++ b/client/v2/go.sum @@ -1,16 +1,13 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= @@ -24,7 +21,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -52,8 +48,9 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= @@ -66,7 +63,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= @@ -97,8 +93,9 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -115,13 +112,15 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -134,7 +133,6 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -142,15 +140,15 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -165,8 +163,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/core/go.mod b/core/go.mod index b9bc031a5370..93f164d46e6b 100644 --- a/core/go.mod +++ b/core/go.mod @@ -6,23 +6,22 @@ require ( cosmossdk.io/api v0.1.0-alpha8 cosmossdk.io/depinject v1.0.0-alpha.4 github.com/cosmos/cosmos-proto v1.0.0-alpha7 - google.golang.org/protobuf v1.28.0 + google.golang.org/protobuf v1.28.1 gotest.tools/v3 v3.3.0 sigs.k8s.io/yaml v1.3.0 ) require ( github.com/golang/protobuf v1.5.2 // indirect - github.com/google/go-cmp v0.5.6 // indirect - github.com/kr/pretty v0.1.0 // indirect + github.com/google/go-cmp v0.5.8 // indirect + github.com/kr/text v0.2.0 // indirect github.com/pkg/errors v0.9.1 // indirect golang.org/x/exp v0.0.0-20220428152302-39d4317da171 // indirect - golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect - golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect - golang.org/x/text v0.3.5 // indirect - google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect + golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect + golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect google.golang.org/grpc v1.48.0 // indirect - gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/core/go.sum b/core/go.sum index 35a28918998a..d33d65fb9e5a 100644 --- a/core/go.sum +++ b/core/go.sum @@ -1,23 +1,21 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/participle/v2 v2.0.0-alpha7 h1:cK4vjj0VSgb3lN1nuKA5F7dw+1s1pWBe5bx7nNCnN+c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w= github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cucumber/common/gherkin/go/v22 v22.0.0 h1:4K8NqptbvdOrjL9DEea6HFjSpbdT9+Q5kgLpmmsHYl0= github.com/cucumber/common/messages/go/v17 v17.1.1 h1:RNqopvIFyLWnKv0LfATh34SWBhXeoFTJnSrgm9cT/Ts= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -27,7 +25,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -54,15 +51,14 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -70,7 +66,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/regen-network/gocuke v0.6.2 h1:pHviZ0kKAq2U2hN2q3smKNxct6hS0mGByFMHGnWA97M= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -97,8 +93,9 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -115,13 +112,14 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -132,7 +130,6 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -140,15 +137,15 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -163,11 +160,11 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= @@ -178,7 +175,7 @@ gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -pgregory.net/rapid v0.4.7 h1:MTNRktPuv5FNqOO151TM9mDTa+XHcX6ypYeISDVD14g= pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= +pgregory.net/rapid v0.4.8 h1:d+5SGZWUbJPbl3ss6tmPFqnNeQR6VDOFly+eTjwPiEw= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/cosmovisor/CHANGELOG.md b/cosmovisor/CHANGELOG.md index fc38e7634b43..6f71487a42cb 100644 --- a/cosmovisor/CHANGELOG.md +++ b/cosmovisor/CHANGELOG.md @@ -37,6 +37,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## v1.2.0 2022-07-26 + ### Features * [\#12464](https://github.com/cosmos/cosmos-sdk/pull/12464) Create the `cosmovisor init` command. @@ -52,7 +54,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#12188](https://github.com/cosmos/cosmos-sdk/pull/12188) Remove the possibility to set a time with only a number. `DAEMON_POLL_INTERVAL` env variable now only supports a duration (e.g. `100ms`, `30s`, `20m`). -## v1.1.0 2022-10-02 +## v1.1.0 2022-02-10 ### Features diff --git a/cosmovisor/Makefile b/cosmovisor/Makefile index d904c990cc11..2e4ac6f1b47a 100644 --- a/cosmovisor/Makefile +++ b/cosmovisor/Makefile @@ -5,9 +5,9 @@ VERSION := $(shell echo $(shell git describe --always --match "cosmovisor/v*") | all: cosmovisor test cosmovisor: - go build -ldflags="-X 'github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor/cmd.Version=$(VERSION)'" -mod=readonly ./cmd/cosmovisor + GOWORK=off go build -ldflags="-X 'github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor/cmd.Version=$(VERSION)'" -mod=readonly ./cmd/cosmovisor test: - go test -mod=readonly -race ./... + GOWORK=off go test -mod=readonly -race ./... .PHONY: all cosmovisor test diff --git a/cosmovisor/RELEASE_NOTES.md b/cosmovisor/RELEASE_NOTES.md index 443ce73369c5..495a36049811 100644 --- a/cosmovisor/RELEASE_NOTES.md +++ b/cosmovisor/RELEASE_NOTES.md @@ -1,28 +1,15 @@ -# Cosmovisor v1.1.0 Release Notes - -### New execution model - -With this release we are shifting to a new CLI design: - -* in the past, Cosmovisor was designed to act as a wrapper for a Cosmos App. An admin could link it and use it instead of the Cosmos App. When running it will pass all options and configuration parameters to the app. Hence the only way to configure the Cosmovisor was through environment variables. -* now, we are moving to a more traditional model, where Cosmovisor has it's own command set and is a true supervisor. - -New commands have been added: - -* `run` will start the Cosmos App and pass remaining arguments to the app (similar to `npm run`) -* `help` will display Cosmovisor help -* `version` will display both Cosmovisor and the associated app version. - -The existing way of starting an app with Cosmovisor has been deprecated (`cosmovisor [app params]`) and will be removed in the future version. Please use `cosmovisor run [app pararms]` instead. +# Cosmovisor v1.2.0 Release Notes ### New Features -We added a new configuration option: `DAEMON_DATA_BACKUP_DIR` (as env variable). When set, Cosmovisor will create backup the app data backup in that directory (instead of using the app home directory) before running the update. See the [README](https://github.com/cosmos/cosmos-sdk/blob/main/cosmovisor/README.md#command-line-arguments-and-environment-variables) file for more details. +With the `cosmovisor init` command, all the necessary folders for using cosmovisor are automatically created. You do not need to manually symlink the chain binary anymore. -### Bug Fixes +We've added a new configuration option: `DAEMON_RESTART_DELAY` (as env variable). When set, Cosmovisor will wait that delay between the node halt and backup. See the [README](https://github.com/cosmos/cosmos-sdk/blob/main/cosmovisor/README.md#command-line-arguments-and-environment-variables) file for more details. -* Fixed `cosmovisor version` output when installed using 'go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0'. +### Bug Fixes +* Fix Cosmovisor binary usage for pre-upgrade. Cosmovisor was using the wrong binary when running a `pre-upgrade` command. + ### Changelog For more details, please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/cosmovisor/v1.1.0/cosmovisor/CHANGELOG.md). diff --git a/cosmovisor/args.go b/cosmovisor/args.go index af16586c9113..b50120c36d14 100644 --- a/cosmovisor/args.go +++ b/cosmovisor/args.go @@ -271,7 +271,7 @@ func (cfg *Config) validate() []error { } // SetCurrentUpgrade sets the named upgrade to be the current link, returns error if this binary doesn't exist -func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) error { +func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) (rerr error) { // ensure named upgrade exists bin := cfg.UpgradeBin(u.Name) @@ -299,14 +299,19 @@ func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) error { if err != nil { return err } + defer func() { + cerr := f.Close() + if rerr == nil { + rerr = cerr + } + }() + bz, err := json.Marshal(u) if err != nil { return err } - if _, err := f.Write(bz); err != nil { - return err - } - return f.Close() + _, err = f.Write(bz) + return err } func (cfg *Config) UpgradeInfo() (upgradetypes.Plan, error) { diff --git a/cosmovisor/cmd/cosmovisor/version.go b/cosmovisor/cmd/cosmovisor/version.go index 617f6bd88d52..c8e427eb9316 100644 --- a/cosmovisor/cmd/cosmovisor/version.go +++ b/cosmovisor/cmd/cosmovisor/version.go @@ -17,7 +17,7 @@ func init() { var ( // Version represents Cosmovisor version value. Overwritten during build - Version = "1.1.0" + Version = "1.2.0" // OutputFlag defines the output format flag OutputFlag = "output" ) diff --git a/cosmovisor/go.mod b/cosmovisor/go.mod index 38a5446e1b93..d31f08c6ce43 100644 --- a/cosmovisor/go.mod +++ b/cosmovisor/go.mod @@ -3,7 +3,7 @@ module github.com/cosmos/cosmos-sdk/cosmovisor go 1.18 require ( - github.com/cosmos/cosmos-sdk v0.46.0-rc3 + github.com/cosmos/cosmos-sdk v0.46.0 github.com/hashicorp/go-getter v1.6.2 github.com/otiai10/copy v1.7.0 github.com/rs/zerolog v1.27.0 @@ -16,7 +16,6 @@ require ( cloud.google.com/go/compute v1.6.1 // indirect cloud.google.com/go/iam v0.3.0 // indirect cloud.google.com/go/storage v1.14.0 // indirect - cosmossdk.io/api v0.1.1-0.20220719182652-282b3be2dc2b // indirect cosmossdk.io/errors v1.0.0-beta.7 // indirect cosmossdk.io/math v1.0.0-beta.2 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect @@ -37,7 +36,7 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect - github.com/cosmos/iavl v0.17.3 // indirect + github.com/cosmos/iavl v0.19.0 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -87,7 +86,6 @@ require ( github.com/mitchellh/go-testing-interface v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/onsi/gomega v1.19.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.2 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect @@ -109,7 +107,7 @@ require ( github.com/tendermint/btcd v0.1.1 // indirect github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect github.com/tendermint/go-amino v0.16.0 // indirect - github.com/tendermint/tendermint v0.34.20-rc1 // indirect + github.com/tendermint/tendermint v0.34.20 // indirect github.com/tendermint/tm-db v0.6.7 // indirect github.com/ulikunitz/xz v0.5.8 // indirect github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 // indirect diff --git a/cosmovisor/go.sum b/cosmovisor/go.sum index 9b9bb6dd6e94..fe9043477a4a 100644 --- a/cosmovisor/go.sum +++ b/cosmovisor/go.sum @@ -48,7 +48,6 @@ cloud.google.com/go/compute v1.6.1 h1:2sMmt8prCn7DPaG4Pmh0N3Inmc8cT8ae5k1M6VJ9Wq cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= cloud.google.com/go/iam v0.3.0 h1:exkAomrVUuzx9kWFI1wm3KI0uoDeUFPB4kKGzx6x+Gc= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= @@ -66,8 +65,6 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.14.0 h1:6RRlFMv1omScs6iq2hfE3IvgE+l6RfJPampq8UZc5TU= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= -cosmossdk.io/api v0.1.1-0.20220719182652-282b3be2dc2b h1:bGCmeU98XRrMZ9LzVLGN1Ju4tqagvpSS80s1nX/oYNc= -cosmossdk.io/api v0.1.1-0.20220719182652-282b3be2dc2b/go.mod h1:ulo4QN34qBWB2XyPRaWvuh+FH6Iz5lI4d+2WixOZy6Y= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= cosmossdk.io/math v1.0.0-beta.2 h1:17hSVc9ne1c31IaLDfjRojtN+y4Rd2N8H/6Fht2sBzw= @@ -105,8 +102,6 @@ github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF0 github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= @@ -116,10 +111,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= -github.com/adlio/schema v1.1.13/go.mod h1:L5Z7tw+7lRK1Fnpi/LT/ooCP1elkXn0krMWBQHUhEDE= github.com/adlio/schema v1.3.3/go.mod h1:1EsRssiv9/Ce2CMzq5DoL7RiMshhuigQxrR4DMV9fHg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= @@ -135,8 +128,6 @@ github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHG github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ= -github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= @@ -146,18 +137,14 @@ github.com/armon/go-metrics v0.4.0 h1:yCQqn7dwca4ITXb+CbubHmedzaQYHhNhrEXLYUeEe8 github.com/armon/go-metrics v0.4.0/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/ashanbrown/forbidigo v1.3.0/go.mod h1:vVW7PEdqEFqapJe95xHkTfB1+XvZXBFg8t0sG2FIxmI= github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI= -github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.36.30/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.40.45 h1:QN1nsY27ssD/JmW4s83qmSb+uL6DG4GmCDzjmJB4xUI= github.com/aws/aws-sdk-go v1.40.45/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= -github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= @@ -171,8 +158,6 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= github.com/bombsimon/wsl/v3 v3.3.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= @@ -180,7 +165,6 @@ github.com/breml/bidichk v0.2.3/go.mod h1:8u2C6DnAy0g2cEq+k/A2+tr9O1s+vHGxWn0LTc github.com/breml/errchkjson v0.3.0/go.mod h1:9Cogkyv9gcT8HREpzi3TiqBxCqDzo8awa92zSDFcofU= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= @@ -188,7 +172,6 @@ github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtyd github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= @@ -200,7 +183,6 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bufbuild/buf v1.4.0/go.mod h1:mwHG7klTHnX+rM/ym8LXGl7vYpVmnwT96xWoRB4H5QI= github.com/butuzov/ireturn v0.1.1/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc= -github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= @@ -216,18 +198,15 @@ github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cb github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/charithe/durationcheck v0.0.9/go.mod h1:SSbRIBVfMjCi/kEB6K65XEA83D6prSM8ap1UCpNKtgg= github.com/chavacava/garif v0.0.0-20220316182200-5cad0b5181d4/go.mod h1:W8EnPSQ8Nv4fUjc/v1/8tHFqhuOJXnRub0dTfuAQktU= -github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= github.com/cilium/ebpf v0.7.0/go.mod h1:/oI2+1shJiTGAMgl6/RgJr36Eo1jzrRcAWbcXO2usCA= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= -github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -241,24 +220,17 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= github.com/coinbase/rosetta-sdk-go v0.7.10 h1:m5Prrqg9CD1GFZm0tu8z3LEDF/BY5RKUSkODZRpAkEc= github.com/coinbase/rosetta-sdk-go v0.7.10/go.mod h1:/glajndJEMrp+D7cO2PJZWKeclK8mDyzSCokCMc6Ftc= -github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8= github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= -github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U= -github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.3.0/go.mod h1:wJEAIwKOm/pBZuBd0JmeTvnLquTB1Ag8espWhkykbPM= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= @@ -268,15 +240,15 @@ github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= -github.com/cosmos/cosmos-sdk v0.46.0-rc3 h1:BWU0YJ1RXUCYUmKY8k3kH/yEavMF/7y81Sjd+2otZpY= -github.com/cosmos/cosmos-sdk v0.46.0-rc3/go.mod h1:fWrmJ90UcB11LoaaTtF/qsqkA8HusUc8+XARAdnJfmA= +github.com/cosmos/cosmos-sdk v0.46.0 h1:TwifvVmAmqUNB70tN1clrqExryWyBU3RxbI2QZEJUJY= +github.com/cosmos/cosmos-sdk v0.46.0/go.mod h1:u6Ci6+V+srijJhzctEEPYBygUz3O2YXP5ZijPnV6mt0= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= -github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= -github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w= +github.com/cosmos/iavl v0.19.0 h1:sgyrjqOkycXiN7Tuupuo4QAldKFg7Sipyfeg/IL7cps= +github.com/cosmos/iavl v0.19.0/go.mod h1:l5h9pAB3m5fihB3pXVgwYqdY8aBsMagqz7T0MUjxZeA= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -289,7 +261,6 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/daixiang0/gci v0.3.3/go.mod h1:1Xr2bxnQbDxCqqulUOv8qpGqkgRw9RSCGGjEC2LjF8o= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= @@ -313,7 +284,6 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/cli v20.10.14+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/cli v20.10.17+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= @@ -330,7 +300,6 @@ github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5m github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -363,7 +332,6 @@ github.com/firefart/nonamedreturns v1.0.1/go.mod h1:D3dpIBojGGNh5UfElmwPu73SwDCm github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= -github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= @@ -384,7 +352,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2 github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= @@ -422,8 +389,6 @@ github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= -github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= -github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8= @@ -432,7 +397,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -558,12 +522,10 @@ github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b0 github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= @@ -580,14 +542,11 @@ github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Repi5x3CuviD3dgAZaBU= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= @@ -599,13 +558,9 @@ github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -626,7 +581,6 @@ github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHh github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= @@ -636,12 +590,10 @@ github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= @@ -650,13 +602,10 @@ github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:i github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= @@ -666,7 +615,6 @@ github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSo github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= -github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -678,7 +626,6 @@ github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/jdxcode/netrc v0.0.0-20210204082910-926c7f70242a/go.mod h1:Zi/ZFkEqFHTm7qkjyNJjaWH4LQA9LQhGJyF0lTYGpxw= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -709,7 +656,6 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -759,23 +705,17 @@ github.com/leonklingele/grouper v1.1.0/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7s github.com/letsencrypt/pkcs11key/v4 v4.0.0/go.mod h1:EFUvBDay26dErnNb70Nd0/VW3tJiIbETBPTl9ATXQag= github.com/lib/pq v0.0.0-20180327071824-d34b9ff171c2/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= -github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lufeee/execinquery v1.2.1/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= -github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= @@ -820,7 +760,6 @@ github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjK github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -829,8 +768,6 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= @@ -840,7 +777,6 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= github.com/moby/sys/mountinfo v0.5.0/go.mod h1:3bMD3Rg+zkqx8MRYPi7Pyb0Ie97QEBmdxbhnCLlSvSU= github.com/moby/term v0.0.0-20201216013528-df9cb8a40635/go.mod h1:FBS0z0QWA44HXygs7VXDUOGoN/1TV3RuWkLO04am3wc= github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= @@ -862,16 +798,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRW github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= github.com/mwitkow/go-proto-validators v0.2.0/go.mod h1:ZfA1hW+UH/2ZHOWvQ3HnQaU0DtnpXu850MZiy+YUgcc= github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE= -github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= -github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q= github.com/nats-io/jwt/v2 v2.0.3/go.mod h1:VRP+deawSXyhNjXmxPCHskrR6Mq50BqpEI5SEcNiGlY= -github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= github.com/nats-io/nats-server/v2 v2.5.0/go.mod h1:Kj86UtrXAL6LwYRA6H4RqzkHhK0Vcv2ZnKD5WbQ1t3g= -github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= github.com/nats-io/nats.go v1.12.1/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w= -github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s= github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= @@ -883,9 +813,6 @@ github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3L github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/oklog/ulid/v2 v2.0.2/go.mod h1:mtBL0Qe/0HAx6/a4Z30qxVIAL1eQDweXq5lxOEiwQ68= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= @@ -907,30 +834,17 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= -github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= -github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= github.com/opencontainers/runc v1.1.2/go.mod h1:Tj1hFw6eFWp/o33uxGf5yF2BX5yz2Z6iptFpuvbbKqc= github.com/opencontainers/runc v1.1.3/go.mod h1:1J5XiS+vdZ3wCyZybsuxXZWGrgSr8fFJHLXuG2PsnNg= github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= github.com/opencontainers/selinux v1.10.0/go.mod h1:2i0OySw99QjzBBQByd1Gr9gSjvuho1lHsJxIJ3gGbJI= -github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= -github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= -github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= -github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= -github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/ory/dockertest/v3 v3.9.1/go.mod h1:42Ir9hmvaAPm0Mgibk6mBPi7SFvTXxEcnztDYOJ//uM= @@ -943,12 +857,10 @@ github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT9 github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI= github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o= -github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= @@ -958,7 +870,6 @@ github.com/pelletier/go-toml/v2 v2.0.0/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZO github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= -github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= @@ -966,7 +877,6 @@ github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCr github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d/go.mod h1:3OzsM7FXDQlpCiw2j81fOmAwQLnZnLGXVKUzeKQXIAw= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -986,33 +896,22 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= @@ -1020,16 +919,12 @@ github.com/prometheus/common v0.34.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRL github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30= @@ -1073,12 +968,10 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= github.com/sagikazarmark/crypt v0.5.0/go.mod h1:l+nzl7KWh51rpzp2h7t4MZWyiEWdhNpOAnclKvg+mdA= github.com/sagikazarmark/crypt v0.6.0/go.mod h1:U8+INwJo3nBv1m6A/8OBXAq7Jnpspk5AxSgDyEQcea8= -github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sanposhiho/wastedassign/v2 v2.0.6/go.mod h1:KyZ0MWTwxxBmfwn33zh3k1dmsbF2ud9pAAGfoLfjhtI= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/securego/gosec/v2 v2.11.0/go.mod h1:SX8bptShuG8reGC0XS09+a4H2BoWSJi+fscA+Pulbpo= @@ -1089,7 +982,6 @@ github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxr github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= @@ -1117,7 +1009,6 @@ github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= @@ -1130,8 +1021,6 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= github.com/spf13/viper v1.11.0/go.mod h1:djo0X/bA5+tYVoCn+C7cAYJGcVn/qYLFTG8gdUsX7Zk= github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= @@ -1139,9 +1028,7 @@ github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiu github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -1176,10 +1063,8 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0= -github.com/tendermint/tendermint v0.34.20-rc1 h1:5ej9Fk5zlDF6Pa8/FJKp9j3Sto95JdCV+wVJFi94E5k= -github.com/tendermint/tendermint v0.34.20-rc1/go.mod h1:u2xI6q3IeLQQ2NdIpRKLUKBNog0o7EzBpvDCE0/OTmg= -github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw= +github.com/tendermint/tendermint v0.34.20 h1:/pmvJhO3IqOxhbi8iRXudTjA2YKpaMqrLwFNkyxDSzw= +github.com/tendermint/tendermint v0.34.20/go.mod h1:KtOwCLYJcsS1ymtAfnjjAtXfXClbqcqjdqzFt2Em1Ac= github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI= github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8= github.com/tendermint/tm-db v0.6.7/go.mod h1:byQDzFkZV1syXr/ReXS808NxA2xvyuuVgXOJ/088L6I= @@ -1238,13 +1123,10 @@ github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWp github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 h1:O9XLFXGkVswDFmH9LaYpqu+r/AAFWqr0DL6V00KEVFg= github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= gitlab.com/bosi/decorder v0.2.1/go.mod h1:6C/nhLSbF6qZbYD8bRmISBwc6vcWdNsiIBkRvjJFrH0= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= -go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c/go.mod h1:xCI7ZzBfRuGgBXyXO6yfWfDmlWd35khcWpUa4L0xI/k= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= @@ -1261,8 +1143,6 @@ go.etcd.io/etcd/client/v2 v2.305.4/go.mod h1:Ud+VUwIi9/uQHOMA+4ekToJ12lTxlv0zB/+ go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= go.etcd.io/etcd/client/v3 v3.5.4/go.mod h1:ZaRkVgBZC+L+dLCjTcF1hRXpgZXQPOvnA/Ak/gq3kiY= go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o= -go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= -go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -1310,7 +1190,6 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= @@ -1375,10 +1254,8 @@ golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -1427,7 +1304,6 @@ golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -1480,7 +1356,6 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1507,7 +1382,6 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1532,10 +1406,8 @@ golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1553,7 +1425,6 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1567,7 +1438,6 @@ golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210906170528-6f6e22806c34/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1623,7 +1493,6 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1654,7 +1523,6 @@ golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1663,7 +1531,6 @@ golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117220505-0cba7a3a9ee9/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1739,7 +1606,6 @@ gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJ gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= -google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -1783,7 +1649,6 @@ google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6r google.golang.org/api v0.81.0 h1:o8WF5AvfidafWbFjsRyupxyEQJNUWxLZJCK5NXrxZZ8= google.golang.org/api v0.81.0/go.mod h1:FA6Mb/bZxj706H2j+j2d6mHEEaHBmbbWnkfvmorOCko= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= @@ -1800,7 +1665,6 @@ google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= @@ -1833,7 +1697,6 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -1885,14 +1748,9 @@ google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= -google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= @@ -1924,7 +1782,6 @@ google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ5 google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= @@ -1958,7 +1815,6 @@ gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qS gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI= @@ -1986,7 +1842,6 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.2.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -2009,4 +1864,3 @@ sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= -sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/db/go.mod b/db/go.mod index 20027955af99..a4c6cbbf2a54 100644 --- a/db/go.mod +++ b/db/go.mod @@ -16,6 +16,7 @@ require ( github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.0.0 // indirect @@ -23,12 +24,16 @@ require ( github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/flatbuffers v2.0.0+incompatible // indirect - github.com/klauspost/compress v1.13.6 // indirect + github.com/google/go-cmp v0.5.8 // indirect + github.com/klauspost/compress v1.15.1 // indirect + github.com/kr/pretty v0.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.8.1 // indirect go.opencensus.io v0.23.0 // indirect - golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect - golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 // indirect - google.golang.org/protobuf v1.27.1 // indirect + golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect + golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + google.golang.org/protobuf v1.28.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/db/go.sum b/db/go.sum index cbe3c3239424..b92f6d2ce84a 100644 --- a/db/go.sum +++ b/db/go.sum @@ -17,6 +17,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -24,8 +25,9 @@ github.com/dgraph-io/badger/v3 v3.2103.2 h1:dpyM5eCJAtQCBcMCZcT4UBZchuTJgCywerHH github.com/dgraph-io/badger/v3 v3.2103.2/go.mod h1:RHo4/GmYcKKh5Lxu63wLEMHJ70Pac2JqZRYGhlyAo2M= github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= -github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= +github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -74,30 +76,38 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= +github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -142,8 +152,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -158,8 +168,8 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 h1:7NCfEGl0sfUojmX78nK9pBJuUlSZWEJA/TwASvfiPLo= -golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -173,7 +183,6 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -198,11 +207,14 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/depinject/README.md b/depinject/README.md index 3d65fffe81e7..41dd6ceea513 100644 --- a/depinject/README.md +++ b/depinject/README.md @@ -140,7 +140,6 @@ func NewSimApp( db dbm.DB, traceStore io.Writer, loadLatest bool, - encodingConfig simappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { diff --git a/depinject/go.mod b/depinject/go.mod index b5333c5a5c07..04fd00166fd6 100644 --- a/depinject/go.mod +++ b/depinject/go.mod @@ -17,8 +17,12 @@ require ( github.com/cucumber/common/messages/go/v17 v17.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/gofrs/uuid v4.2.0+incompatible // indirect - github.com/google/go-cmp v0.5.5 // indirect + github.com/google/go-cmp v0.5.8 // indirect + github.com/kr/pretty v0.3.0 // indirect + github.com/lib/pq v1.10.6 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.8.1 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - pgregory.net/rapid v0.4.7 // indirect + pgregory.net/rapid v0.4.8 // indirect ) diff --git a/depinject/go.sum b/depinject/go.sum index 12f3a6d451c1..1842acfbf6a2 100644 --- a/depinject/go.sum +++ b/depinject/go.sum @@ -4,6 +4,7 @@ github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1 h1:GDQdwm/gAcJcLAK github.com/alecthomas/repr v0.0.0-20181024024818-d37bc2a10ba1/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ= github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w= github.com/cockroachdb/apd/v3 v3.1.0/go.mod h1:6qgPBMXjATAdD/VefbRP9NoSLKjbB4LCoA7gN4LpHs4= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cucumber/common/gherkin/go/v22 v22.0.0 h1:4K8NqptbvdOrjL9DEea6HFjSpbdT9+Q5kgLpmmsHYl0= github.com/cucumber/common/gherkin/go/v22 v22.0.0/go.mod h1:3mJT10B2GGn3MvVPd3FwR7m2u4tLhSRhWUqJU4KN4Fg= github.com/cucumber/common/messages/go/v17 v17.1.1 h1:RNqopvIFyLWnKv0LfATh34SWBhXeoFTJnSrgm9cT/Ts= @@ -14,9 +15,20 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0= github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= +github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -24,6 +36,9 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/regen-network/gocuke v0.6.2 h1:pHviZ0kKAq2U2hN2q3smKNxct6hS0mGByFMHGnWA97M= github.com/regen-network/gocuke v0.6.2/go.mod h1:zYaqIHZobHyd0xOrHGPQjbhGJsuZ1oElx150u2o1xuk= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= @@ -56,15 +71,17 @@ golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo= gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= -pgregory.net/rapid v0.4.7 h1:MTNRktPuv5FNqOO151TM9mDTa+XHcX6ypYeISDVD14g= -pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= +pgregory.net/rapid v0.4.8 h1:d+5SGZWUbJPbl3ss6tmPFqnNeQR6VDOFly+eTjwPiEw= +pgregory.net/rapid v0.4.8/go.mod h1:Z5PbWqjvWR1I3UGjvboUuan4fe4ZYEYNLNQLExzCoUs= diff --git a/docs/architecture/adr-038-state-listening.md b/docs/architecture/adr-038-state-listening.md index cb824c00d6bf..88fca0315518 100644 --- a/docs/architecture/adr-038-state-listening.md +++ b/docs/architecture/adr-038-state-listening.md @@ -430,7 +430,12 @@ e.g. in `NewSimApp`: ```go func NewSimApp( - logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, encodingConfig simappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + loadLatest bool, + appOpts servertypes.AppOptions, + baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { ... diff --git a/docs/run-node/txs.md b/docs/run-node/txs.md index 9674d32f4eed..59995a267b06 100644 --- a/docs/run-node/txs.md +++ b/docs/run-node/txs.md @@ -121,12 +121,11 @@ import ( ) func sendTx() error { - // Choose your codec: Amino or Protobuf. Here, we use Protobuf, given by the - // following function. - encCfg := simapp.MakeTestEncodingConfig() + // Choose your codec: Amino or Protobuf. Here, we use Protobuf, given by the following function. + app := simapp.NewSimApp(...) // Create a new TxBuilder. - txBuilder := encCfg.TxConfig.NewTxBuilder() + txBuilder := app.TxConfig().NewTxBuilder() // --snip-- } diff --git a/errors/go.mod b/errors/go.mod index 17c27da29364..07f4da52aa3d 100644 --- a/errors/go.mod +++ b/errors/go.mod @@ -11,8 +11,14 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.8 // indirect + github.com/kr/pretty v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect - google.golang.org/protobuf v1.27.1 // indirect + github.com/rogpeppe/go-internal v1.8.1 // indirect + golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect + golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect + google.golang.org/protobuf v1.28.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/errors/go.sum b/errors/go.sum index c21cee931ab8..19bd71f4b916 100644 --- a/errors/go.sum +++ b/errors/go.sum @@ -11,6 +11,7 @@ github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XP github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -43,16 +44,29 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -74,8 +88,10 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -87,32 +103,39 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 h1:myAQVi0cGEoqQVR5POX+8RR2mrocKqNN1hmeMqhX27k= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -126,10 +149,14 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/go.mod b/go.mod index 8757c6847540..2b89342550d9 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,11 @@ go 1.18 module github.com/cosmos/cosmos-sdk require ( - cosmossdk.io/api v0.1.0-alpha8 - cosmossdk.io/core v0.0.0 - cosmossdk.io/depinject v1.0.0-alpha.4 + cosmossdk.io/api v0.1.1-0.20220726092710-f848e4300a8a + cosmossdk.io/core v0.1.0 + cosmossdk.io/depinject v1.0.0-alpha.1.0.20220726092710-f848e4300a8a cosmossdk.io/errors v1.0.0-beta.7 - cosmossdk.io/math v1.0.0-beta.2 + cosmossdk.io/math v1.0.0-beta.3.0.20220726092710-f848e4300a8a github.com/99designs/keyring v1.2.1 github.com/armon/go-metrics v0.4.0 github.com/bgentry/speakeasy v0.1.0 @@ -17,11 +17,11 @@ require ( github.com/confio/ics23/go v0.7.0 github.com/cosmos/btcutil v1.0.4 github.com/cosmos/cosmos-proto v1.0.0-alpha7 - github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 + github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1.0.20220726092710-f848e4300a8a + github.com/cosmos/cosmos-sdk/store/tools/ics23 v0.0.0-20220726092710-f848e4300a8a github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl v0.19.0 github.com/cosmos/ledger-cosmos-go v0.11.1 - github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/gogo/gateway v1.1.0 github.com/gogo/protobuf v1.3.2 github.com/golang/mock v1.6.0 @@ -36,7 +36,7 @@ require ( github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 github.com/improbable-eng/grpc-web v0.15.0 - github.com/jhump/protoreflect v1.12.0 + github.com/jhump/protoreflect v1.12.1-0.20220417024638-438db461d753 github.com/lazyledger/smt v0.2.1-0.20210709230900-03ea40719554 github.com/magiconair/properties v1.8.6 github.com/mattn/go-isatty v0.0.14 @@ -60,13 +60,11 @@ require ( golang.org/x/exp v0.0.0-20220428152302-39d4317da171 google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd google.golang.org/grpc v1.48.0 - google.golang.org/protobuf v1.28.0 + google.golang.org/protobuf v1.28.1 pgregory.net/rapid v0.4.8 sigs.k8s.io/yaml v1.3.0 ) -require github.com/cosmos/cosmos-sdk/store/tools/ics23 v0.0.0-00010101000000-000000000000 - require ( 4d63.com/gochecknoglobals v0.1.0 // indirect cloud.google.com/go v0.100.2 // indirect @@ -100,6 +98,8 @@ require ( github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/charithe/durationcheck v0.0.9 // indirect github.com/chavacava/garif v0.0.0-20220316182200-5cad0b5181d4 // indirect + github.com/cosmos/cosmos-sdk/api v0.1.0 // indirect + github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect @@ -107,6 +107,7 @@ require ( github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/denis-tingaikin/go-header v0.4.3 // indirect + github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect @@ -118,6 +119,7 @@ require ( github.com/fatih/structtag v1.2.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/firefart/nonamedreturns v1.0.4 // indirect + github.com/fogleman/gg v1.3.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/go-critic/go-critic v0.6.3 // indirect @@ -131,8 +133,10 @@ require ( github.com/go-toolsmith/typep v1.0.2 // indirect github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect github.com/gobwas/glob v0.2.3 // indirect + github.com/goccy/go-graphviz v0.0.9 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect + github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/golang/glog v1.0.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.4 // indirect @@ -147,6 +151,7 @@ require ( github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect github.com/google/btree v1.0.1 // indirect github.com/google/go-cmp v0.5.8 // indirect + github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/googleapis/gax-go/v2 v2.4.0 // indirect github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 // indirect @@ -203,6 +208,7 @@ require ( github.com/nishanths/predeclared v0.2.2 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20210609091139-0a56a4bca00b // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/otiai10/copy v1.7.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.2 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect @@ -256,6 +262,7 @@ require ( go.uber.org/multierr v1.8.0 // indirect go.uber.org/zap v1.21.0 // indirect golang.org/x/exp/typeparams v0.0.0-20220613132600-b0d781184e0d // indirect + golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect @@ -267,6 +274,7 @@ require ( golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect google.golang.org/api v0.81.0 // indirect google.golang.org/appengine v1.6.7 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.66.6 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect @@ -279,13 +287,6 @@ require ( ) replace ( - cosmossdk.io/api => ./api - cosmossdk.io/core => ./core - cosmossdk.io/depinject => ./depinject - cosmossdk.io/math => ./math - github.com/cosmos/cosmos-sdk/db => ./db - github.com/cosmos/cosmos-sdk/store/tools/ics23 => ./store/tools/ics23 - // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 diff --git a/go.sum b/go.sum index 41d13e157c13..a5bc99f29fe0 100644 --- a/go.sum +++ b/go.sum @@ -66,8 +66,16 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 cloud.google.com/go/storage v1.14.0 h1:6RRlFMv1omScs6iq2hfE3IvgE+l6RfJPampq8UZc5TU= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= +cosmossdk.io/api v0.1.1-0.20220726092710-f848e4300a8a h1:0jPt136cL+BeghIj+Yp7NGNjCGqz+DUVN44LP8Yvjh0= +cosmossdk.io/api v0.1.1-0.20220726092710-f848e4300a8a/go.mod h1:ulo4QN34qBWB2XyPRaWvuh+FH6Iz5lI4d+2WixOZy6Y= +cosmossdk.io/core v0.1.0 h1:aQ7BMt+74WUHlIBGDHyYDeojU7KoGXRf+iM0aaXMn84= +cosmossdk.io/core v0.1.0/go.mod h1:HbNfxUJxzj1StpRRXj5abDyD8FQnUuXAnIAtbSxjUEg= +cosmossdk.io/depinject v1.0.0-alpha.1.0.20220726092710-f848e4300a8a h1:yXENAEjWJpWUlvxFjNbEFkE+tyHSQKYJrh7nJl3uGZ4= +cosmossdk.io/depinject v1.0.0-alpha.1.0.20220726092710-f848e4300a8a/go.mod h1:zEXZ6zmw52FyN3X/oH9QxBXGbBQjzFDJjWxzkCw7FJo= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= +cosmossdk.io/math v1.0.0-beta.3.0.20220726092710-f848e4300a8a h1:3lmQIAF6ScBJ8kW5ZNejcBUJpwWhE2y57qEUI+OBESU= +cosmossdk.io/math v1.0.0-beta.3.0.20220726092710-f848e4300a8a/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= @@ -270,10 +278,20 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/corona10/goimagehash v1.0.2 h1:pUfB0LnsJASMPGEZLj7tGY251vF+qLGqOgEP4rUs6kA= +github.com/corona10/goimagehash v1.0.2/go.mod h1:/l9umBhvcHQXVtQO1V6Gp1yD20STawkhRnnX0D1bvVI= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= +github.com/cosmos/cosmos-sdk/api v0.1.0 h1:xfSKM0e9p+EJTMQnf5PbWE6VT8ruxTABIJ64Rd064dE= +github.com/cosmos/cosmos-sdk/api v0.1.0/go.mod h1:CupqQBskAOiTXO1XDZ/wrtWzN/wTxUvbQmOqdUhR8wI= +github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3 h1:CC8p43RhsrtZdPOkT/Q5q8QkEGKCq3BbTr/wG/3vJ70= +github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3/go.mod h1:fd4VKEYJiPjjElIRm7xsjUFMh2ljTtooK1H/DJa0uPU= +github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1.0.20220726092710-f848e4300a8a h1:2humuGPw3O5riJVFq/E2FRjF57UrO97W1qJcGVmK+6k= +github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1.0.20220726092710-f848e4300a8a/go.mod h1:c8IO23vgNxueCCJlSI9awQtcxsvc+buzaeThB85qfBU= +github.com/cosmos/cosmos-sdk/store/tools/ics23 v0.0.0-20220726092710-f848e4300a8a h1:wSIzyCwb0yTsh+xrZQVaD6b+lQyqAre3/IAico5OPrg= +github.com/cosmos/cosmos-sdk/store/tools/ics23 v0.0.0-20220726092710-f848e4300a8a/go.mod h1:fzNat9v5zQccOS2MJW+iPlwV2uIYtW3SDh8jP29WFCM= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= @@ -381,6 +399,8 @@ github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSw github.com/firefart/nonamedreturns v1.0.4 h1:abzI1p7mAEPYuR4A+VLKn4eNDOycjYo2phmY9sfv40Y= github.com/firefart/nonamedreturns v1.0.4/go.mod h1:TDhe/tjI1BXo48CmYbUduTV7BdIga8MAO/xbKdcVsGI= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= +github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= @@ -461,6 +481,8 @@ github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= +github.com/goccy/go-graphviz v0.0.9 h1:s/FMMJ1Joj6La3S5ApO3Jk2cwM4LpXECC2muFx3IPQQ= +github.com/goccy/go-graphviz v0.0.9/go.mod h1:wXVsXxmyMQU6TN3zGRttjNn3h+iCAS7xQFC6TlNvLhk= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -475,6 +497,7 @@ github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFG github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= @@ -563,8 +586,9 @@ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8 github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= -github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= +github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -751,8 +775,8 @@ github.com/jhump/protocompile v0.0.0-20220216033700-d705409f108f/go.mod h1:qr2b5 github.com/jhump/protoreflect v1.6.1/go.mod h1:RZQ/lnuN+zqeRVpQigTwO6o0AJUkxbnSnpuG7toUTG4= github.com/jhump/protoreflect v1.11.0/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= github.com/jhump/protoreflect v1.11.1-0.20220213155251-0c2aedc66cf4/go.mod h1:U7aMIjN0NWq9swDP7xDdoMfRHb35uiuTd3Z9nFXJf5E= -github.com/jhump/protoreflect v1.12.0 h1:1NQ4FpWMgn3by/n1X0fbeKEUxP1wBt7+Oitpv01HR10= -github.com/jhump/protoreflect v1.12.0/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= +github.com/jhump/protoreflect v1.12.1-0.20220417024638-438db461d753 h1:uFlcJKZPLQd7rmOY/RrvBuUaYmAFnlFHKLivhO6cOy8= +github.com/jhump/protoreflect v1.12.1-0.20220417024638-438db461d753/go.mod h1:JytZfP5d0r8pVNLZvai7U/MCuTWITgrI4tTg7puQFKI= github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs= github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c= github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af h1:KA9BjwUk7KlCh6S9EAGWBt1oExIUv9WyNCiRz5amv48= @@ -965,7 +989,8 @@ github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6FxaNu/BnU2OAaLF86eTVhP2hjTB6iMvItA= github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 h1:BvoENQQU+fZ9uukda/RzCAL/191HHwJA5b13R6diVlY= +github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nishanths/exhaustive v0.8.1 h1:0QKNascWv9qIHY7zRoZSxeRr6kuk5aAT3YXLTiDmjTo= github.com/nishanths/exhaustive v0.8.1/go.mod h1:qj+zJJUgJ76tR92+25+03oYUhzF4R7/2Wk7fGTfCHmg= @@ -1027,12 +1052,14 @@ github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/ory/dockertest/v3 v3.9.1/go.mod h1:42Ir9hmvaAPm0Mgibk6mBPi7SFvTXxEcnztDYOJ//uM= -github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= +github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= +github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= +github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= @@ -1419,6 +1446,7 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -1458,6 +1486,8 @@ golang.org/x/exp/typeparams v0.0.0-20220613132600-b0d781184e0d/go.mod h1:AbB0pIl golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/image v0.0.0-20200119044424-58c23975cae1 h1:5h3ngYt7+vXCDZCup/HkCQgW5XwmSvR/nA2JmJ0RErg= +golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -2055,15 +2085,17 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= diff --git a/go.work b/go.work new file mode 100644 index 000000000000..9b88cc75ee56 --- /dev/null +++ b/go.work @@ -0,0 +1,15 @@ +go 1.18 + +use ( + . + ./api + ./client/v2 + ./core + ./db + ./depinject + ./errors + ./math + ./orm + ./store/tools/ics23 + ./tx +) diff --git a/go.work.sum b/go.work.sum new file mode 100644 index 000000000000..1808dec105ba --- /dev/null +++ b/go.work.sum @@ -0,0 +1,59 @@ +cosmossdk.io/core v0.1.1-0.20220726092710-f848e4300a8a/go.mod h1:NI7jc1kHeG47qN5RCEHuJQ8hpuy+I5l4iQ595nFCZno= +cosmossdk.io/math v1.0.0-beta.3.0.20220726092710-f848e4300a8a/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= +github.com/Antonboom/errname v0.1.6/go.mod h1:7lz79JAnuoMNDAWE9MeeIr1/c/VpSUWatBv2FH9NYpI= +github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= +github.com/GaijinEntertainment/go-exhaustruct/v2 v2.1.0/go.mod h1:LGOGuvEgCfCQsy3JF2tRmpGDpzA53iZfyGEWSPwQ6/4= +github.com/bufbuild/buf v1.4.0/go.mod h1:mwHG7klTHnX+rM/ym8LXGl7vYpVmnwT96xWoRB4H5QI= +github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3 h1:CC8p43RhsrtZdPOkT/Q5q8QkEGKCq3BbTr/wG/3vJ70= +github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1/go.mod h1:JUMM2MxF9wuwzRWZJjb8BjXsn1BmPmdBd3a75pIct4I= +github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/daixiang0/gci v0.3.3/go.mod h1:1Xr2bxnQbDxCqqulUOv8qpGqkgRw9RSCGGjEC2LjF8o= +github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= +github.com/firefart/nonamedreturns v1.0.1/go.mod h1:D3dpIBojGGNh5UfElmwPu73SwDCm+VKhHYqwlNOk2uQ= +github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= +github.com/fzipp/gocyclo v0.5.1/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/goccy/go-graphviz v0.0.9 h1:s/FMMJ1Joj6La3S5ApO3Jk2cwM4LpXECC2muFx3IPQQ= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= +github.com/golangci/golangci-lint v1.46.2/go.mod h1:3DkdHnxn9eoTTrpT2gB0TEv8KSziuoqe9FitgQLHvAY= +github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= +github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= +github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= +github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= +github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kulti/thelper v0.6.2/go.mod h1:DsqKShOvP40epevkFrvIwkCMNYxMeTNjdWL4dqWHZ6I= +github.com/kunwardeep/paralleltest v1.0.3/go.mod h1:vLydzomDFpk7yu5UX02RmP0H8QfRPOV/oFhWN85Mjb4= +github.com/maratori/testpackage v1.0.1/go.mod h1:ddKdw+XG0Phzhx8BFDTKgpWP4i7MpApTE5fXSKAqwDU= +github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= +github.com/nishanths/exhaustive v0.7.11/go.mod h1:gX+MP7DWMKJmNa1HfMozK+u04hQd3na9i0hyqf3/dOI= +github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= +github.com/pelletier/go-toml/v2 v2.0.0-beta.8/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= +github.com/pelletier/go-toml/v2 v2.0.0/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= +github.com/prometheus/common v0.34.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= +github.com/quasilyte/go-ruleguard/dsl v0.3.19/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/sagikazarmark/crypt v0.5.0/go.mod h1:l+nzl7KWh51rpzp2h7t4MZWyiEWdhNpOAnclKvg+mdA= +github.com/securego/gosec/v2 v2.11.0/go.mod h1:SX8bptShuG8reGC0XS09+a4H2BoWSJi+fscA+Pulbpo= +github.com/shirou/gopsutil/v3 v3.22.4/go.mod h1:D01hZJ4pVHPpCTZ3m3T2+wDF2YAGfd+H4ifUguaQzHM= +github.com/sivchari/tenv v1.5.0/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= +github.com/spf13/viper v1.11.0/go.mod h1:djo0X/bA5+tYVoCn+C7cAYJGcVn/qYLFTG8gdUsX7Zk= +github.com/tendermint/tendermint v0.34.20-rc1/go.mod h1:u2xI6q3IeLQQ2NdIpRKLUKBNog0o7EzBpvDCE0/OTmg= +github.com/tendermint/tendermint v0.34.20/go.mod h1:KtOwCLYJcsS1ymtAfnjjAtXfXClbqcqjdqzFt2Em1Ac= +github.com/tomarrell/wrapcheck/v2 v2.6.1/go.mod h1:Eo+Opt6pyMW1b6cNllOcDSSoHO0aTJ+iF6BfCUbHltA= +github.com/uudashr/gocognit v1.0.5/go.mod h1:wgYz0mitoKOTysqxTDMOUXg+Jb5SvtihkfmugIZYpEA= +gitlab.com/bosi/decorder v0.2.1/go.mod h1:6C/nhLSbF6qZbYD8bRmISBwc6vcWdNsiIBkRvjJFrH0= +go.etcd.io/etcd/api/v3 v3.5.2/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= +go.etcd.io/etcd/client/pkg/v3 v3.5.2/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= +go.etcd.io/etcd/client/v2 v2.305.2/go.mod h1:2D7ZejHVMIfog1221iLSYlQRzrtECw3kz4I4VAQm3qI= +golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20220313003712-b769efc7c000/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/image v0.0.0-20200119044424-58c23975cae1 h1:5h3ngYt7+vXCDZCup/HkCQgW5XwmSvR/nA2JmJ0RErg= +golang.org/x/sys v0.0.0-20220403020550-483a9cbc67c0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20220411215600-e5f449aeb171/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +honnef.co/go/tools v0.3.1/go.mod h1:vlRD9XErLMGT+mDuofSr0mMMquscM/1nQqtRSsh6m70= diff --git a/math/go.mod b/math/go.mod index 8d808843efbc..47389e7c2afe 100644 --- a/math/go.mod +++ b/math/go.mod @@ -9,7 +9,10 @@ require ( require ( github.com/davecgh/go-spew v1.1.1 // indirect + github.com/kr/pretty v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.8.1 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/math/go.sum b/math/go.sum index 341b49b6f410..a9cfda4749e0 100644 --- a/math/go.sum +++ b/math/go.sum @@ -1,15 +1,31 @@ +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/orm/go.mod b/orm/go.mod index 41f54ac2dc5d..e05c41436f35 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -13,38 +13,46 @@ require ( github.com/stretchr/testify v1.8.0 github.com/tendermint/tm-db v0.6.7 google.golang.org/grpc v1.48.0 - google.golang.org/protobuf v1.28.0 + google.golang.org/protobuf v1.28.1 gotest.tools/v3 v3.3.0 pgregory.net/rapid v0.4.8 ) require ( - github.com/DataDog/zstd v1.4.5 // indirect github.com/alecthomas/participle/v2 v2.0.0-alpha7 // indirect github.com/cespare/xxhash v1.1.0 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/cockroachdb/apd/v3 v3.1.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cucumber/common/gherkin/go/v22 v22.0.0 // indirect github.com/cucumber/common/messages/go/v17 v17.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dgraph-io/badger/v2 v2.2007.2 // indirect - github.com/dgraph-io/ristretto v0.0.3 // indirect + github.com/dgraph-io/badger/v2 v2.2007.4 // indirect + github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/gofrs/uuid v4.2.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/glog v1.0.0 // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3 // indirect - github.com/google/btree v1.0.0 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/google/btree v1.0.1 // indirect github.com/jmhodges/levigo v1.0.0 // indirect + github.com/klauspost/compress v1.15.1 // indirect + github.com/kr/pretty v0.3.0 // indirect + github.com/lib/pq v1.10.6 // indirect + github.com/onsi/ginkgo v1.16.4 // indirect + github.com/onsi/gomega v1.19.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect + github.com/rogpeppe/go-internal v1.8.1 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect go.etcd.io/bbolt v1.3.6 // indirect - golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect - golang.org/x/sys v0.0.0-20210903071746-97244b99971b // indirect - golang.org/x/text v0.3.6 // indirect - google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect + golang.org/x/sys v0.0.0-20220702020025-31831981b65f // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/orm/go.sum b/orm/go.sum index 9e6aa097d34a..3afa0c445479 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -3,9 +3,6 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= -github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/alecthomas/participle/v2 v2.0.0-alpha7 h1:cK4vjj0VSgb3lN1nuKA5F7dw+1s1pWBe5bx7nNCnN+c= @@ -18,11 +15,12 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= @@ -38,6 +36,7 @@ github.com/cosmos/cosmos-sdk/api v0.1.0/go.mod h1:CupqQBskAOiTXO1XDZ/wrtWzN/wTxU github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cucumber/common/gherkin/go/v22 v22.0.0 h1:4K8NqptbvdOrjL9DEea6HFjSpbdT9+Q5kgLpmmsHYl0= github.com/cucumber/common/gherkin/go/v22 v22.0.0/go.mod h1:3mJT10B2GGn3MvVPd3FwR7m2u4tLhSRhWUqJU4KN4Fg= github.com/cucumber/common/messages/go/v17 v17.1.1 h1:RNqopvIFyLWnKv0LfATh34SWBhXeoFTJnSrgm9cT/Ts= @@ -45,11 +44,11 @@ github.com/cucumber/common/messages/go/v17 v17.1.1/go.mod h1:bpGxb57tDE385Rb2Eoh github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k= -github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= +github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= +github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgraph-io/ristretto v0.0.3 h1:jh22xisGBjrEVnRZ1DVTpBVQm0Xndu8sMl0CWDzSIBI= -github.com/dgraph-io/ristretto v0.0.3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= +github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= @@ -59,22 +58,25 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0= github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= @@ -93,11 +95,11 @@ github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3 h1:ur2rms48b3Ep1dxh7aUV2FZEQ8jEVO2F6ILKx8ofkAg= -github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -118,25 +120,36 @@ github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.15.1 h1:y9FcTHGyrebwfP0ZZqFiaxTaiDnUrGkJkI+f583BL1A= +github.com/klauspost/compress v1.15.1/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= +github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= -github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= -github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -147,6 +160,9 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/regen-network/gocuke v0.6.2 h1:pHviZ0kKAq2U2hN2q3smKNxct6hS0mGByFMHGnWA97M= github.com/regen-network/gocuke v0.6.2/go.mod h1:zYaqIHZobHyd0xOrHGPQjbhGJsuZ1oElx150u2o1xuk= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= @@ -166,8 +182,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= -github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8= github.com/tendermint/tm-db v0.6.7/go.mod h1:byQDzFkZV1syXr/ReXS808NxA2xvyuuVgXOJ/088L6I= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= @@ -203,8 +219,8 @@ golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f h1:w6wWR0H+nyVpbSAQbzVEIACVyr/h8l/BEkY6Sokc7Eg= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 h1:Yqz/iviulwKwAREEeUd3nbBFn0XuyJqkoft2IlrvOhc= +golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -229,18 +245,20 @@ golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210903071746-97244b99971b h1:3Dq0eVHn0uaQJmPO+/aYPI/fRMqdrVDbu7MQcku54gg= -golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f h1:xdsejrW/0Wf2diT5CPp3XmKUNbr7Xvw8kYilQ+6qjRY= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -248,13 +266,13 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -262,15 +280,15 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf h1:SVYXkUz2yZS9FWb2Gm8ivSlbNQzL2Z/NpPKE3RG2jWk= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -285,11 +303,15 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= @@ -298,7 +320,6 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/orm/model/ormdb/json.go b/orm/model/ormdb/json.go index 3a64ae52fbe6..79a668ccd10d 100644 --- a/orm/model/ormdb/json.go +++ b/orm/model/ormdb/json.go @@ -15,7 +15,17 @@ import ( ) func (m moduleDB) DefaultJSON(target ormjson.WriteTarget) error { - for name, table := range m.tablesByName { + tableNames := make([]protoreflect.FullName, 0, len(m.tablesByName)) + for name := range m.tablesByName { + tableNames = append(tableNames, name) + } + sort.Slice(tableNames, func(i, j int) bool { + ti, tj := tableNames[i], tableNames[j] + return ti.Name() < tj.Name() + }) + + for _, name := range tableNames { + table := m.tablesByName[name] w, err := target.OpenWriter(name) if err != nil { return err diff --git a/proto/cosmos/bank/v1beta1/authz.proto b/proto/cosmos/bank/v1beta1/authz.proto index 4f58b15e4970..36f695f4c937 100644 --- a/proto/cosmos/bank/v1beta1/authz.proto +++ b/proto/cosmos/bank/v1beta1/authz.proto @@ -16,4 +16,10 @@ message SendAuthorization { repeated cosmos.base.v1beta1.Coin spend_limit = 1 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // allow_list specifies an optional list of addresses to whom the grantee can send tokens on behalf of the + // granter. If omitted, any recipient is allowed. + // + // Since: cosmos-sdk 0.47 + repeated string allow_list = 2; } diff --git a/scripts/mockgen.sh b/scripts/mockgen.sh index a8f814464592..f2c03d0f7dc1 100755 --- a/scripts/mockgen.sh +++ b/scripts/mockgen.sh @@ -15,3 +15,6 @@ $mockgen_cmd -source=x/feegrant/expected_keepers.go -package testutil -destinati $mockgen_cmd -source=x/mint/types/expected_keepers.go -package testutil -destination x/mint/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/params/proposal_handler_test.go -package testutil -destination x/params/testutil/staking_keeper_mock.go $mockgen_cmd -source=x/crisis/types/expected_keepers.go -package testutil -destination x/crisis/testutil/expected_keepers_mocks.go +$mockgen_cmd -source=x/auth/types/expected_keepers.go -package testutil -destination x/auth/testutil/expected_keepers_mocks.go +$mockgen_cmd -source=x/auth/ante/expected_keepers.go -package testutil -destination x/auth/ante/testutil/expected_keepers_mocks.go +$mockgen_cmd -source=x/bank/types/expected_keepers.go -package testutil -destination x/bank/testutil/expected_keepers_mocks.go \ No newline at end of file diff --git a/server/grpc/grpc_web.go b/server/grpc/grpc_web.go index e08f007c73f0..b02db57166fb 100644 --- a/server/grpc/grpc_web.go +++ b/server/grpc/grpc_web.go @@ -25,8 +25,9 @@ func StartGRPCWeb(grpcSrv *grpc.Server, config config.Config) (*http.Server, err wrappedServer := grpcweb.WrapServer(grpcSrv, options...) grpcWebSrv := &http.Server{ - Addr: config.GRPCWeb.Address, - Handler: wrappedServer, + Addr: config.GRPCWeb.Address, + Handler: wrappedServer, + ReadHeaderTimeout: 500000000, // added because G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server } errCh := make(chan error) diff --git a/server/grpc/server_test.go b/server/grpc/server_test.go index 26c09102af22..a6fba07b0db5 100644 --- a/server/grpc/server_test.go +++ b/server/grpc/server_test.go @@ -1,6 +1,3 @@ -//go:build norace -// +build norace - package grpc_test import ( diff --git a/server/start.go b/server/start.go index d745ddc44a11..7eedd92e624b 100644 --- a/server/start.go +++ b/server/start.go @@ -27,7 +27,6 @@ import ( "github.com/cosmos/cosmos-sdk/codec" pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/server/api" - "github.com/cosmos/cosmos-sdk/server/config" serverconfig "github.com/cosmos/cosmos-sdk/server/config" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" "github.com/cosmos/cosmos-sdk/server/rosetta" @@ -502,7 +501,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App return WaitForQuitSignals() } -func startTelemetry(cfg config.Config) (*telemetry.Metrics, error) { +func startTelemetry(cfg serverconfig.Config) (*telemetry.Metrics, error) { if !cfg.Telemetry.Enabled { return nil, nil } diff --git a/simapp/app.go b/simapp/app.go index b0689eaf7d1d..3196951407c7 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -25,7 +25,6 @@ import ( "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/store/streaming" storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar" @@ -148,6 +147,7 @@ type SimApp struct { *runtime.App legacyAmino *codec.LegacyAmino appCodec codec.Codec + txConfig client.TxConfig interfaceRegistry codectypes.InterfaceRegistry // keys to access the substores @@ -186,8 +186,12 @@ func init() { // NewSimApp returns a reference to an initialized SimApp. func NewSimApp( - logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, encodingConfig simappparams.EncodingConfig, - appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + loadLatest bool, + appOpts servertypes.AppOptions, + baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { var ( app = &SimApp{} @@ -215,6 +219,7 @@ func NewSimApp( &appBuilder, &app.appCodec, &app.legacyAmino, + &app.txConfig, &app.interfaceRegistry, &app.AccountKeeper, &app.BankKeeper, @@ -269,7 +274,6 @@ func NewSimApp( // app.ModuleManager.SetOrderMigrations(custom order) app.ModuleManager.RegisterInvariants(app.CrisisKeeper) - app.ModuleManager.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) // RegisterUpgradeHandlers is used for registering any on-chain upgrades. // Make sure it's called after `app.ModuleManager` and `app.configurator` are set. @@ -337,6 +341,11 @@ func (app *SimApp) InterfaceRegistry() codectypes.InterfaceRegistry { return app.interfaceRegistry } +// TxConfig returns SimApp's TxConfig +func (app *SimApp) TxConfig() client.TxConfig { + return app.txConfig +} + // GetKey returns the KVStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. diff --git a/simapp/app_config.go b/simapp/app_config.go index ebd4eff04722..7f1484ab5581 100644 --- a/simapp/app_config.go +++ b/simapp/app_config.go @@ -48,6 +48,9 @@ import ( vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" ) +// Alternatively the AppConfig can be defined as a YAML or a JSON file. +// e.g. https://github.com/cosmos/cosmos-sdk/blob/91b1d83f1339e235a1dfa929ecc00084101a19e3/simapp/app.yaml + var AppConfig = appconfig.Compose(&appv1alpha1.Config{ Modules: []*appv1alpha1.ModuleConfig{ { @@ -122,7 +125,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ }, }), }, - { Name: vestingtypes.ModuleName, Config: appconfig.WrapAny(&vestingmodulev1.Module{}), @@ -202,5 +204,3 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ }, }, }) - -// Alternatively this configuration can be set as yaml or json: https://github.com/cosmos/cosmos-sdk/blob/91b1d83f1339e235a1dfa929ecc00084101a19e3/simapp/app.yaml diff --git a/simapp/app_legacy.go b/simapp/app_legacy.go index 248b9a0e1ff5..7a41c6812cf3 100644 --- a/simapp/app_legacy.go +++ b/simapp/app_legacy.go @@ -28,6 +28,7 @@ import ( "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + "github.com/cosmos/cosmos-sdk/std" "github.com/cosmos/cosmos-sdk/store/streaming" storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar" @@ -158,6 +159,7 @@ type SimApp struct { *baseapp.BaseApp legacyAmino *codec.LegacyAmino appCodec codec.Codec + txConfig client.TxConfig interfaceRegistry types.InterfaceRegistry // keys to access the substores @@ -204,14 +206,21 @@ func init() { // NewSimApp returns a reference to an initialized SimApp. func NewSimApp( - logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, encodingConfig simappparams.EncodingConfig, - appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + loadLatest bool, + appOpts servertypes.AppOptions, + baseAppOptions ...func(*baseapp.BaseApp), ) *SimApp { + encodingConfig := makeEncodingConfig() + appCodec := encodingConfig.Codec legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry + txConfig := encodingConfig.TxConfig - bApp := baseapp.NewBaseApp(appName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) + bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) @@ -238,6 +247,7 @@ func NewSimApp( BaseApp: bApp, legacyAmino: legacyAmino, appCodec: appCodec, + txConfig: txConfig, interfaceRegistry: interfaceRegistry, keys: keys, tkeys: tkeys, @@ -409,7 +419,6 @@ func NewSimApp( // app.ModuleManager.SetOrderMigrations(custom order) app.ModuleManager.RegisterInvariants(app.CrisisKeeper) - app.ModuleManager.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) app.ModuleManager.RegisterServices(app.configurator) @@ -569,6 +578,11 @@ func (app *SimApp) InterfaceRegistry() types.InterfaceRegistry { return app.interfaceRegistry } +// TxConfig returns SimApp's TxConfig +func (app *SimApp) TxConfig() client.TxConfig { + return app.txConfig +} + // GetKey returns the KVStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. @@ -671,3 +685,12 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino return paramsKeeper } + +func makeEncodingConfig() simappparams.EncodingConfig { + encodingConfig := simappparams.MakeTestEncodingConfig() + std.RegisterLegacyAminoCodec(encodingConfig.Amino) + std.RegisterInterfaces(encodingConfig.InterfaceRegistry) + ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) + ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) + return encodingConfig +} diff --git a/simapp/app_test.go b/simapp/app_test.go index 49076b2a1bf9..3c6a451216bf 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -37,14 +37,12 @@ import ( ) func TestSimAppExportAndBlockedAddrs(t *testing.T) { - encCfg := MakeTestEncodingConfig() db := dbm.NewMemDB() logger, _ := log.NewDefaultLogger("plain", "info", false) app := NewSimappWithCustomOptions(t, false, SetupOptions{ - Logger: logger, - DB: db, - EncConfig: encCfg, - AppOpts: simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), + Logger: logger, + DB: db, + AppOpts: simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), }) for acc := range maccPerms { @@ -59,7 +57,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { logger2, _ := log.NewDefaultLogger("plain", "info", false) // Making a new app object with the db, so that initchain hasn't been called - app2 := NewSimApp(logger2, db, nil, true, encCfg, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) + app2 := NewSimApp(logger2, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) _, err := app2.ExportAppStateAndValidators(false, []string{}) require.NoError(t, err, "ExportAppStateAndValidators should not have an error") } @@ -71,14 +69,13 @@ func TestGetMaccPerms(t *testing.T) { func TestRunMigrations(t *testing.T) { db := dbm.NewMemDB() - encCfg := MakeTestEncodingConfig() logger, _ := log.NewDefaultLogger("plain", "info", false) - app := NewSimApp(logger, db, nil, true, encCfg, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) + app := NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) // Create a new baseapp and configurator for the purpose of this test. - bApp := baseapp.NewBaseApp(app.Name(), logger, db, encCfg.TxConfig.TxDecoder()) + bApp := baseapp.NewBaseApp(app.Name(), logger, db, app.TxConfig().TxDecoder()) bApp.SetCommitMultiStoreTracer(nil) - bApp.SetInterfaceRegistry(encCfg.InterfaceRegistry) + bApp.SetInterfaceRegistry(app.InterfaceRegistry()) app.BaseApp = bApp configurator := module.NewConfigurator(app.appCodec, bApp.MsgServiceRouter(), app.GRPCQueryRouter()) @@ -204,9 +201,8 @@ func TestRunMigrations(t *testing.T) { func TestInitGenesisOnMigration(t *testing.T) { db := dbm.NewMemDB() - encCfg := MakeTestEncodingConfig() logger, _ := log.NewDefaultLogger("plain", "info", false) - app := NewSimApp(logger, db, nil, true, encCfg, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) + app := NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome)) ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) // Create a mock module. This module will serve as the new module we're @@ -247,14 +243,12 @@ func TestInitGenesisOnMigration(t *testing.T) { } func TestUpgradeStateOnGenesis(t *testing.T) { - encCfg := MakeTestEncodingConfig() db := dbm.NewMemDB() logger, _ := log.NewDefaultLogger("plain", "info", false) app := NewSimappWithCustomOptions(t, false, SetupOptions{ - Logger: logger, - DB: db, - EncConfig: encCfg, - AppOpts: simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), + Logger: logger, + DB: db, + AppOpts: simtestutil.NewAppOptionsWithFlagHome(DefaultNodeHome), }) // make sure the upgrade keeper has version map in state diff --git a/simapp/encoding.go b/simapp/encoding.go deleted file mode 100644 index 8a90ff852478..000000000000 --- a/simapp/encoding.go +++ /dev/null @@ -1,19 +0,0 @@ -package simapp - -import ( - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" - "github.com/cosmos/cosmos-sdk/std" -) - -// MakeTestEncodingConfig creates an EncodingConfig for testing. This function -// should be used only in tests or when creating a new app instance (NewApp*()). -// App user shouldn't create new codecs - use the app.AppCodec instead. -// [DEPRECATED] -func MakeTestEncodingConfig() simappparams.EncodingConfig { - encodingConfig := simappparams.MakeTestEncodingConfig() - std.RegisterLegacyAminoCodec(encodingConfig.Amino) - std.RegisterInterfaces(encodingConfig.InterfaceRegistry) - ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino) - ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry) - return encodingConfig -} diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index 115dd62b6073..36cb9092eb9c 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -37,7 +37,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { appOptions[flags.FlagHome] = DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue - app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, interBlockCacheOpt()) + app := NewSimApp(logger, db, nil, true, appOptions, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( @@ -88,7 +88,7 @@ func BenchmarkInvariants(b *testing.B) { appOptions[flags.FlagHome] = DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue - app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, interBlockCacheOpt()) + app := NewSimApp(logger, db, nil, true, appOptions, interBlockCacheOpt()) // run randomized simulation _, simParams, simErr := simulation.SimulateFromSeed( diff --git a/simapp/sim_test.go b/simapp/sim_test.go index fc7bc7e8c0ba..ed96329cbace 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -77,7 +77,7 @@ func TestFullAppSimulation(t *testing.T) { appOptions[flags.FlagHome] = DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue - app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) + app := NewSimApp(logger, db, nil, true, appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", app.Name()) // run randomized simulation @@ -119,7 +119,7 @@ func TestAppImportExport(t *testing.T) { appOptions[flags.FlagHome] = DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue - app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) + app := NewSimApp(logger, db, nil, true, appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", app.Name()) // Run randomized simulation @@ -159,7 +159,7 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) + newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", newApp.Name()) var genesisState GenesisState @@ -232,7 +232,7 @@ func TestAppSimulationAfterImport(t *testing.T) { appOptions[flags.FlagHome] = DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = FlagPeriodValue - app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) + app := NewSimApp(logger, db, nil, true, appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", app.Name()) // Run randomized simulation @@ -277,7 +277,7 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, os.RemoveAll(newDir)) }() - newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, MakeTestEncodingConfig(), appOptions, fauxMerkleModeOpt) + newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, appOptions, fauxMerkleModeOpt) require.Equal(t, "SimApp", newApp.Name()) newApp.InitChain(abci.RequestInitChain{ @@ -332,7 +332,7 @@ func TestAppStateDeterminism(t *testing.T) { } db := dbm.NewMemDB() - app := NewSimApp(logger, db, nil, true, MakeTestEncodingConfig(), appOptions, interBlockCacheOpt()) + app := NewSimApp(logger, db, nil, true, appOptions, interBlockCacheOpt()) fmt.Printf( "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", diff --git a/simapp/simd/cmd/cmd_test.go b/simapp/simd/cmd/cmd_test.go index ab9d8de71064..f98c2bee6bb3 100644 --- a/simapp/simd/cmd/cmd_test.go +++ b/simapp/simd/cmd/cmd_test.go @@ -14,7 +14,7 @@ import ( ) func TestInitCmd(t *testing.T) { - rootCmd, _ := cmd.NewRootCmd() + rootCmd := cmd.NewRootCmd() rootCmd.SetArgs([]string{ "init", // Test the init cmd "simapp-test", // Moniker @@ -27,8 +27,7 @@ func TestInitCmd(t *testing.T) { func TestHomeFlagRegistration(t *testing.T) { homeDir := "/tmp/foo" - rootCmd, _ := cmd.NewRootCmd() - + rootCmd := cmd.NewRootCmd() rootCmd.SetArgs([]string{ "query", fmt.Sprintf("--%s", flags.FlagHome), diff --git a/simapp/simd/cmd/genaccounts_test.go b/simapp/simd/cmd/genaccounts_test.go index ca751fc34f62..34dc5e3071ff 100644 --- a/simapp/simd/cmd/genaccounts_test.go +++ b/simapp/simd/cmd/genaccounts_test.go @@ -16,10 +16,11 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" - "github.com/cosmos/cosmos-sdk/simapp" simcmd "github.com/cosmos/cosmos-sdk/simapp/simd/cmd" "github.com/cosmos/cosmos-sdk/testutil/testdata" "github.com/cosmos/cosmos-sdk/types/module" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/genutil" genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" ) @@ -73,7 +74,7 @@ func TestAddGenesisAccountCmd(t *testing.T) { cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) - appCodec := simapp.MakeTestEncodingConfig().Codec + appCodec := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}).Codec err = genutiltest.ExecInitCmd(testMbm, home, appCodec) require.NoError(t, err) diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index b1747abdceaa..7eb91d5d1c59 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -29,6 +29,7 @@ import ( "github.com/cosmos/cosmos-sdk/snapshots" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store" + simutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -39,8 +40,16 @@ import ( // NewRootCmd creates a new root command for simd. It is called once in the // main function. -func NewRootCmd() (*cobra.Command, params.EncodingConfig) { - encodingConfig := simapp.MakeTestEncodingConfig() +func NewRootCmd() *cobra.Command { + // we "pre"-instantiate the application for getting the injected/configured encoding configuration + tempApp := simapp.NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simutil.EmptyAppOptions{}) + encodingConfig := params.EncodingConfig{ + InterfaceRegistry: tempApp.InterfaceRegistry(), + Codec: tempApp.AppCodec(), + TxConfig: tempApp.TxConfig(), + Amino: tempApp.LegacyAmino(), + } + initClientCtx := client.Context{}. WithCodec(encodingConfig.Codec). WithInterfaceRegistry(encodingConfig.InterfaceRegistry). @@ -82,7 +91,7 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) { initRootCmd(rootCmd, encodingConfig) - return rootCmd, encodingConfig + return rootCmd } // initTendermintConfig helps to override default Tendermint Config values. @@ -170,8 +179,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { config.Cmd(), ) - a := appCreator{encodingConfig} - server.AddCommands(rootCmd, simapp.DefaultNodeHome, a.newApp, a.appExport, addModuleInitFlags) + server.AddCommands(rootCmd, simapp.DefaultNodeHome, newApp, appExport, addModuleInitFlags) // add keybase, auxiliary RPC, query, and tx child commands rootCmd.AddCommand( @@ -240,12 +248,13 @@ func txCommand() *cobra.Command { return cmd } -type appCreator struct { - encCfg params.EncodingConfig -} - -// newApp is an appCreator -func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts servertypes.AppOptions) servertypes.Application { +// newApp creates the application +func newApp( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + appOpts servertypes.AppOptions, +) servertypes.Application { var cache sdk.MultiStorePersistentCache if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) { @@ -279,7 +288,6 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a return simapp.NewSimApp( logger, db, traceStore, true, - a.encCfg, appOpts, baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), @@ -293,10 +301,15 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a ) } -// appExport creates a new simapp (optionally at a given height) -// and exports state. -func (a appCreator) appExport( - logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts servertypes.AppOptions, +// appExport creates a new simapp (optionally at a given height) and exports state. +func appExport( + logger log.Logger, + db dbm.DB, + traceStore io.Writer, + height int64, + forZeroHeight bool, + jailAllowedAddrs []string, + appOpts servertypes.AppOptions, ) (servertypes.ExportedApp, error) { var simApp *simapp.SimApp @@ -317,13 +330,13 @@ func (a appCreator) appExport( appOpts = viperAppOpts if height != -1 { - simApp = simapp.NewSimApp(logger, db, traceStore, false, a.encCfg, appOpts) + simApp = simapp.NewSimApp(logger, db, traceStore, false, appOpts) if err := simApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - simApp = simapp.NewSimApp(logger, db, traceStore, true, a.encCfg, appOpts) + simApp = simapp.NewSimApp(logger, db, traceStore, true, appOpts) } return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index ace2448a3e63..19d02700b459 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -11,6 +11,7 @@ import ( "os" "path/filepath" + "cosmossdk.io/math" "github.com/spf13/cobra" tmconfig "github.com/tendermint/tendermint/config" tmos "github.com/tendermint/tendermint/libs/os" @@ -297,7 +298,7 @@ func initTestnetFiles( sdk.NewCoin(sdk.DefaultBondDenom, valTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), - sdk.OneInt(), + math.OneInt(), ) if err != nil { return err diff --git a/simapp/simd/cmd/testnet_test.go b/simapp/simd/cmd/testnet_test.go index 09134383a16c..716e9f862b23 100644 --- a/simapp/simd/cmd/testnet_test.go +++ b/simapp/simd/cmd/testnet_test.go @@ -13,14 +13,17 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/simapp" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/auth" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/staking" ) func Test_TestnetCmd(t *testing.T) { home := t.TempDir() - encodingConfig := simapp.MakeTestEncodingConfig() + encodingConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModuleBasic{}, auth.AppModuleBasic{}) logger := log.NewNopLogger() cfg, err := genutiltest.CreateDefaultTendermintConfig(home) require.NoError(t, err) diff --git a/simapp/simd/main.go b/simapp/simd/main.go index 6ac86d18d3f3..bd069e161694 100644 --- a/simapp/simd/main.go +++ b/simapp/simd/main.go @@ -10,8 +10,7 @@ import ( ) func main() { - rootCmd, _ := cmd.NewRootCmd() - + rootCmd := cmd.NewRootCmd() if err := svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome); err != nil { switch e := err.(type) { case server.ErrorCode: diff --git a/simapp/state.go b/simapp/state.go index 135863c5bd7c..14eb5aeedce5 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -11,7 +11,7 @@ import ( tmjson "github.com/tendermint/tendermint/libs/json" tmtypes "github.com/tendermint/tendermint/types" - sdkmath "cosmossdk.io/math" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -88,7 +88,7 @@ func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simty panic(err) } // compute not bonded balance - notBondedTokens := sdk.ZeroInt() + notBondedTokens := math.ZeroInt() for _, val := range stakingState.Validators { if val.Status != stakingtypes.Unbonded { continue @@ -149,11 +149,11 @@ func AppStateRandomizedFn( // number of bonded accounts var ( numInitiallyBonded int64 - initialStake sdkmath.Int + initialStake math.Int ) appParams.GetOrGenerate( cdc, simappparams.StakePerAccount, &initialStake, r, - func(r *rand.Rand) { initialStake = sdkmath.NewInt(r.Int63n(1e12)) }, + func(r *rand.Rand) { initialStake = math.NewInt(r.Int63n(1e12)) }, ) appParams.GetOrGenerate( cdc, simappparams.InitiallyBondedValidators, &numInitiallyBonded, r, diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 5ae000294933..bcf8051752d8 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -26,7 +26,6 @@ import ( "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/testutil/mock" "github.com/cosmos/cosmos-sdk/testutil/network" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" @@ -40,23 +39,21 @@ import ( // SetupOptions defines arguments that are passed into `Simapp` constructor. type SetupOptions struct { - Logger log.Logger - DB *dbm.MemDB - EncConfig simappparams.EncodingConfig - AppOpts types.AppOptions + Logger log.Logger + DB *dbm.MemDB + AppOpts types.AppOptions } func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { db := dbm.NewMemDB() - encCdc := MakeTestEncodingConfig() appOptions := make(simtestutil.AppOptionsMap, 0) appOptions[flags.FlagHome] = DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = invCheckPeriod - app := NewSimApp(log.NewNopLogger(), db, nil, true, encCdc, appOptions) + app := NewSimApp(log.NewNopLogger(), db, nil, true, appOptions) if withGenesis { - return app, NewDefaultGenesisState(encCdc.Codec) + return app, NewDefaultGenesisState(app.AppCodec()) } return app, GenesisState{} } @@ -80,7 +77,7 @@ func NewSimappWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptio Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), } - app := NewSimApp(options.Logger, options.DB, nil, true, options.EncConfig, options.AppOpts) + app := NewSimApp(options.Logger, options.DB, nil, true, options.AppOpts) genesisState := NewDefaultGenesisState(app.appCodec) genesisState, err = simtestutil.GenesisStateWithValSet(app.AppCodec(), genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) require.NoError(t, err) @@ -359,17 +356,11 @@ func ModuleAccountAddrs() map[string]bool { // NewTestNetworkFixture returns a new simapp AppConstructor for network simulation tests func NewTestNetworkFixture() network.TestFixture { - encodingCfg := MakeTestEncodingConfig() - cfg := testutil.TestEncodingConfig{ - TxConfig: encodingCfg.TxConfig, - Codec: encodingCfg.Codec, - Amino: encodingCfg.Amino, - InterfaceRegistry: encodingCfg.InterfaceRegistry, - } + app := NewSimApp(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}) + appCtr := func(val testutil.Validator) servertypes.Application { return NewSimApp( val.GetCtx().Logger, dbm.NewMemDB(), nil, true, - encodingCfg, simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir), bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)), bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices), @@ -378,7 +369,12 @@ func NewTestNetworkFixture() network.TestFixture { return network.TestFixture{ AppConstructor: appCtr, - GenesisState: ModuleBasics.DefaultGenesis(cfg.Codec), - EncodingConfig: cfg, + GenesisState: ModuleBasics.DefaultGenesis(app.AppCodec()), + EncodingConfig: testutil.TestEncodingConfig{ + InterfaceRegistry: app.InterfaceRegistry(), + Codec: app.AppCodec(), + TxConfig: app.TxConfig(), + Amino: app.LegacyAmino(), + }, } } diff --git a/simapp/testutil_network_test.go b/simapp/testutil_network_test.go index ae34608bcd74..520326455e27 100644 --- a/simapp/testutil_network_test.go +++ b/simapp/testutil_network_test.go @@ -1,6 +1,3 @@ -//go:build norace -// +build norace - package simapp_test import ( diff --git a/store/iavl/store.go b/store/iavl/store.go index e8b12c47b40b..1b409101e605 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -417,6 +417,7 @@ var _ types.Iterator = (*iavlIterator)(nil) // newIAVLIterator will create a new iavlIterator. // CONTRACT: Caller must release the iavlIterator, as each one creates a new // goroutine. +//nolint:deadcode,unused func newIAVLIterator(tree *iavl.ImmutableTree, start, end []byte, ascending bool) *iavlIterator { iterator, err := tree.Iterator(start, end, ascending) if err != nil { diff --git a/store/streaming/constructor_test.go b/store/streaming/constructor_test.go index 5edaeccd4eac..a7d6b83489a1 100644 --- a/store/streaming/constructor_test.go +++ b/store/streaming/constructor_test.go @@ -7,12 +7,13 @@ import ( "github.com/cosmos/cosmos-sdk/codec" codecTypes "github.com/cosmos/cosmos-sdk/codec/types" serverTypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store/streaming" "github.com/cosmos/cosmos-sdk/store/streaming/file" "github.com/cosmos/cosmos-sdk/store/types" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" @@ -51,7 +52,7 @@ func TestStreamingServiceConstructor(t *testing.T) { func TestLoadStreamingServices(t *testing.T) { db := dbm.NewMemDB() - encCdc := simapp.MakeTestEncodingConfig() + encCdc := testutil.MakeTestEncodingConfig() keys := sdk.NewKVStoreKeys("mockKey1", "mockKey2") bApp := baseapp.NewBaseApp("appName", log.NewNopLogger(), db, nil) diff --git a/store/tools/ics23/go.mod b/store/tools/ics23/go.mod index 125d012db1a9..703189bc13d8 100644 --- a/store/tools/ics23/go.mod +++ b/store/tools/ics23/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/confio/ics23/go v0.7.0 - github.com/cosmos/cosmos-sdk v0.46.0-rc3 + github.com/cosmos/cosmos-sdk v0.46.0 github.com/cosmos/iavl v0.19.0 github.com/lazyledger/smt v0.2.1-0.20210709230900-03ea40719554 github.com/tendermint/tendermint v0.35.9 diff --git a/store/tools/ics23/go.sum b/store/tools/ics23/go.sum index c62da87f3d1d..b9bd5affa953 100644 --- a/store/tools/ics23/go.sum +++ b/store/tools/ics23/go.sum @@ -199,8 +199,8 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/cosmos/cosmos-sdk v0.46.0-rc3 h1:BWU0YJ1RXUCYUmKY8k3kH/yEavMF/7y81Sjd+2otZpY= -github.com/cosmos/cosmos-sdk v0.46.0-rc3/go.mod h1:fWrmJ90UcB11LoaaTtF/qsqkA8HusUc8+XARAdnJfmA= +github.com/cosmos/cosmos-sdk v0.46.0 h1:TwifvVmAmqUNB70tN1clrqExryWyBU3RxbI2QZEJUJY= +github.com/cosmos/cosmos-sdk v0.46.0/go.mod h1:u6Ci6+V+srijJhzctEEPYBygUz3O2YXP5ZijPnV6mt0= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.0 h1:sgyrjqOkycXiN7Tuupuo4QAldKFg7Sipyfeg/IL7cps= diff --git a/store/v2alpha1/multi/migration.go b/store/v2alpha1/multi/migration.go index caaddbf45283..c1285de5989a 100644 --- a/store/v2alpha1/multi/migration.go +++ b/store/v2alpha1/multi/migration.go @@ -1,6 +1,8 @@ package multi import ( + "sort" + dbm "github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/store/iavl" "github.com/cosmos/cosmos-sdk/store/mem" @@ -16,8 +18,16 @@ func MigrateFromV1(rootMultiStore *v1Store.Store, store2db dbm.Connection, store *iavl.Store name string } + storeKeysByName := rootMultiStore.StoreKeysByName() + keys := make([]string, 0, len(storeKeysByName)) + for key := range storeKeysByName { + keys = append(keys, key) + } + sort.Strings(keys) + var stores []namedStore - for _, storeKey := range rootMultiStore.StoreKeysByName() { + for _, key := range keys { + storeKey := storeKeysByName[key] keyName := storeKey.Name() switch store := rootMultiStore.GetStoreByName(keyName).(type) { case *iavl.Store: diff --git a/store/v2alpha1/multi/store.go b/store/v2alpha1/multi/store.go index c39b8e0e854c..0913979f10f5 100644 --- a/store/v2alpha1/multi/store.go +++ b/store/v2alpha1/multi/store.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "math" + "sort" "strings" "sync" @@ -327,8 +328,14 @@ func NewStore(db dbm.Connection, opts StoreConfig) (ret *Store, err error) { if err != nil { return } + skeys := make([]string, 0, len(reg.StoreSchema)) + for skey := range reg.StoreSchema { + skeys = append(skeys, skey) + } + sort.Strings(skeys) // NB. the migrated contents and schema are not committed until the next store.Commit - for skey, typ := range reg.StoreSchema { + for _, skey := range skeys { + typ := reg.StoreSchema[skey] err = schemaWriter.Set([]byte(skey), []byte{byte(typ)}) if err != nil { return diff --git a/tests/e2e/auth/client/testutil/cli_test.go b/tests/e2e/auth/client/testutil/cli_test.go new file mode 100644 index 000000000000..7b836c7f761b --- /dev/null +++ b/tests/e2e/auth/client/testutil/cli_test.go @@ -0,0 +1,20 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + clientestutil "github.com/cosmos/cosmos-sdk/x/auth/client/testutil" + + "github.com/stretchr/testify/suite" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 2 + suite.Run(t, clientestutil.NewIntegrationTestSuite(cfg)) +} diff --git a/x/crisis/client/testsuite/cli_test.go b/tests/e2e/auth/vesting/client/testutil/cli_test.go similarity index 65% rename from x/crisis/client/testsuite/cli_test.go rename to tests/e2e/auth/vesting/client/testutil/cli_test.go index 4bd59d02e52b..7f3e580db1ec 100644 --- a/x/crisis/client/testsuite/cli_test.go +++ b/tests/e2e/auth/vesting/client/testutil/cli_test.go @@ -1,5 +1,5 @@ -//go:build norace -// +build norace +//go:build e2e +// +build e2e package testutil @@ -10,10 +10,11 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/network" + testutil2 "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/testutil" ) func TestIntegrationTestSuite(t *testing.T) { cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) + suite.Run(t, testutil2.NewIntegrationTestSuite(cfg)) } diff --git a/tests/e2e/authz/client/testutil/cli_test.go b/tests/e2e/authz/client/testutil/cli_test.go new file mode 100644 index 000000000000..38c1933e6018 --- /dev/null +++ b/tests/e2e/authz/client/testutil/cli_test.go @@ -0,0 +1,20 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + clienttestutil "github.com/cosmos/cosmos-sdk/x/authz/client/testutil" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 1 + suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg)) +} diff --git a/x/genutil/client/testutil/cli_test.go b/tests/e2e/bank/client/testutil/cli_test.go similarity index 68% rename from x/genutil/client/testutil/cli_test.go rename to tests/e2e/bank/client/testutil/cli_test.go index 26677c392c24..d121354d38ed 100644 --- a/x/genutil/client/testutil/cli_test.go +++ b/tests/e2e/bank/client/testutil/cli_test.go @@ -1,5 +1,5 @@ -//go:build norace -// +build norace +//go:build e2e +// +build e2e package testutil @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" "github.com/stretchr/testify/suite" ) @@ -15,5 +16,5 @@ import ( func TestIntegrationTestSuite(t *testing.T) { cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) + suite.Run(t, testutil.NewIntegrationTestSuite(cfg)) } diff --git a/simapp/integration/client/grpc/tmservice/service_test.go b/tests/e2e/client/grpc/tmservice/service_test.go similarity index 99% rename from simapp/integration/client/grpc/tmservice/service_test.go rename to tests/e2e/client/grpc/tmservice/service_test.go index 10b2db205922..f75b15347d77 100644 --- a/simapp/integration/client/grpc/tmservice/service_test.go +++ b/tests/e2e/client/grpc/tmservice/service_test.go @@ -1,5 +1,5 @@ -//go:build norace -// +build norace +//go:build e2e +// +build e2e package tmservice_test @@ -31,7 +31,6 @@ type IntegrationTestSuite struct { } func TestIntegrationTestSuite(t *testing.T) { - //t.Skip() // to be re-enabled in https://github.com/cosmos/cosmos-sdk/pull/12482/ suite.Run(t, new(IntegrationTestSuite)) } diff --git a/tests/e2e/crisis/client/testsuite/cli_test.go b/tests/e2e/crisis/client/testsuite/cli_test.go new file mode 100644 index 000000000000..26af9843ef0d --- /dev/null +++ b/tests/e2e/crisis/client/testsuite/cli_test.go @@ -0,0 +1,20 @@ +//go:build e2e +// +build e2e + +package testsuite + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/x/crisis/client/testsuite" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 1 + suite.Run(t, testutil.NewIntegrationTestSuite(cfg)) +} diff --git a/tests/e2e/distribution/client/testutil/cli_test.go b/tests/e2e/distribution/client/testutil/cli_test.go new file mode 100644 index 000000000000..ba7dfb8231db --- /dev/null +++ b/tests/e2e/distribution/client/testutil/cli_test.go @@ -0,0 +1,24 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/x/distribution/client/testutil" +) + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(testutil.IntegrationTestSuite)) +} + +func TestGRPCQueryTestSuite(t *testing.T) { + suite.Run(t, new(testutil.GRPCQueryTestSuite)) +} + +func TestWithdrawAllSuite(t *testing.T) { + suite.Run(t, new(testutil.WithdrawAllTestSuite)) +} diff --git a/tests/e2e/evidence/client/testutil/cli_test.go b/tests/e2e/evidence/client/testutil/cli_test.go new file mode 100644 index 000000000000..d5ea5fa80de6 --- /dev/null +++ b/tests/e2e/evidence/client/testutil/cli_test.go @@ -0,0 +1,20 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + clienttestutil "github.com/cosmos/cosmos-sdk/x/evidence/client/testutil" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 1 + suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg)) +} diff --git a/tests/e2e/feegrant/client/testutil/cli_test.go b/tests/e2e/feegrant/client/testutil/cli_test.go new file mode 100644 index 000000000000..7db09c25e26a --- /dev/null +++ b/tests/e2e/feegrant/client/testutil/cli_test.go @@ -0,0 +1,20 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + clienttestutil "github.com/cosmos/cosmos-sdk/x/feegrant/client/testutil" + + "github.com/stretchr/testify/suite" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 3 + suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg)) +} diff --git a/x/authz/client/testutil/cli_test.go b/tests/e2e/genutil/client/testutil/cli_test.go similarity index 68% rename from x/authz/client/testutil/cli_test.go rename to tests/e2e/genutil/client/testutil/cli_test.go index 4bd59d02e52b..2f228207f2e0 100644 --- a/x/authz/client/testutil/cli_test.go +++ b/tests/e2e/genutil/client/testutil/cli_test.go @@ -1,19 +1,20 @@ -//go:build norace -// +build norace +//go:build e2e +// +build e2e package testutil import ( "testing" - "github.com/stretchr/testify/suite" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" + + "github.com/stretchr/testify/suite" ) func TestIntegrationTestSuite(t *testing.T) { cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) + suite.Run(t, testutil.NewIntegrationTestSuite(cfg)) } diff --git a/x/gov/client/testutil/cli_test.go b/tests/e2e/gov/client/testutil/cli_test.go similarity index 81% rename from x/gov/client/testutil/cli_test.go rename to tests/e2e/gov/client/testutil/cli_test.go index 13d394e30eb5..6941bce38208 100644 --- a/x/gov/client/testutil/cli_test.go +++ b/tests/e2e/gov/client/testutil/cli_test.go @@ -1,3 +1,6 @@ +//go:build e2e +// +build e2e + package testutil import ( @@ -7,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/gov/client/testutil" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/stretchr/testify/require" @@ -16,7 +20,7 @@ import ( func TestIntegrationTestSuite(t *testing.T) { cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) + suite.Run(t, testutil.NewIntegrationTestSuite(cfg)) dp := v1.NewDepositParams(sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, v1.DefaultMinDepositTokens)), time.Duration(15)*time.Second) vp := v1.NewVotingParams(time.Duration(5) * time.Second) @@ -26,5 +30,5 @@ func TestIntegrationTestSuite(t *testing.T) { bz, err := cfg.Codec.MarshalJSON(genesisState) require.NoError(t, err) cfg.GenesisState["gov"] = bz - suite.Run(t, NewDepositTestSuite(cfg)) + suite.Run(t, testutil.NewDepositTestSuite(cfg)) } diff --git a/tests/e2e/group/client/testutil/cli_test.go b/tests/e2e/group/client/testutil/cli_test.go new file mode 100644 index 000000000000..fc26405b7c79 --- /dev/null +++ b/tests/e2e/group/client/testutil/cli_test.go @@ -0,0 +1,20 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + clienttestutil "github.com/cosmos/cosmos-sdk/x/group/client/testutil" + + "github.com/stretchr/testify/suite" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 2 + suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg)) +} diff --git a/tests/e2e/mint/client/testutil/cli_test.go b/tests/e2e/mint/client/testutil/cli_test.go new file mode 100644 index 000000000000..513b8f43ebcd --- /dev/null +++ b/tests/e2e/mint/client/testutil/cli_test.go @@ -0,0 +1,20 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + clienttestutil "github.com/cosmos/cosmos-sdk/x/mint/client/testutil" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 1 + suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg)) +} diff --git a/x/bank/client/testutil/cli_test.go b/tests/e2e/nft/client/testutil/cli_test.go similarity index 65% rename from x/bank/client/testutil/cli_test.go rename to tests/e2e/nft/client/testutil/cli_test.go index 26677c392c24..df9f045baa80 100644 --- a/x/bank/client/testutil/cli_test.go +++ b/tests/e2e/nft/client/testutil/cli_test.go @@ -1,19 +1,20 @@ -//go:build norace -// +build norace +//go:build e2e +// +build e2e package testutil import ( "testing" + "github.com/stretchr/testify/suite" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/network" - - "github.com/stretchr/testify/suite" + clienttestutil "github.com/cosmos/cosmos-sdk/x/nft/client/testutil" ) func TestIntegrationTestSuite(t *testing.T) { cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) + suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg)) } diff --git a/tests/e2e/params/client/testutil/cli_test.go b/tests/e2e/params/client/testutil/cli_test.go new file mode 100644 index 000000000000..2b5170d9537c --- /dev/null +++ b/tests/e2e/params/client/testutil/cli_test.go @@ -0,0 +1,20 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/stretchr/testify/suite" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + clienttestutil "github.com/cosmos/cosmos-sdk/x/params/client/testutil" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 1 + suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg)) +} diff --git a/simapp/integration/server/export_test.go b/tests/e2e/server/export_test.go similarity index 94% rename from simapp/integration/server/export_test.go rename to tests/e2e/server/export_test.go index be92d72d4175..2452bd2836a9 100644 --- a/simapp/integration/server/export_test.go +++ b/tests/e2e/server/export_test.go @@ -1,3 +1,6 @@ +//go:build e2e +// +build e2e + package server_test import ( @@ -128,8 +131,7 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t logger, _ := log.NewDefaultLogger("plain", "info", false) db := dbm.NewMemDB() - encCfg := simapp.MakeTestEncodingConfig() - app := simapp.NewSimApp(logger, db, nil, true, encCfg, simtestutil.NewAppOptionsWithFlagHome(tempDir)) + app := simapp.NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir)) genesisState := simapp.GenesisStateWithSingleValidator(t, app) stateBytes, err := tmjson.MarshalIndent(genesisState, "", " ") @@ -156,17 +158,15 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t cmd := server.ExportCmd( func(_ log.Logger, _ dbm.DB, _ io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOptions types.AppOptions) (types.ExportedApp, error) { - encCfg := simapp.MakeTestEncodingConfig() - var simApp *simapp.SimApp if height != -1 { - simApp = simapp.NewSimApp(logger, db, nil, false, encCfg, appOptions) + simApp = simapp.NewSimApp(logger, db, nil, false, appOptions) if err := simApp.LoadHeight(height); err != nil { return types.ExportedApp{}, err } } else { - simApp = simapp.NewSimApp(logger, db, nil, true, encCfg, appOptions) + simApp = simapp.NewSimApp(logger, db, nil, true, appOptions) } return simApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) diff --git a/tests/e2e/slashing/client/testutil/cli_test.go b/tests/e2e/slashing/client/testutil/cli_test.go new file mode 100644 index 000000000000..3fe7a357e141 --- /dev/null +++ b/tests/e2e/slashing/client/testutil/cli_test.go @@ -0,0 +1,20 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + clienttestutil "github.com/cosmos/cosmos-sdk/x/slashing/client/testutil" + + "github.com/stretchr/testify/suite" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 1 + suite.Run(t, clienttestutil.NewIntegrationTestSuite(cfg)) +} diff --git a/x/staking/client/testutil/cli_test.go b/tests/e2e/staking/client/testutil/cli_test.go similarity index 68% rename from x/staking/client/testutil/cli_test.go rename to tests/e2e/staking/client/testutil/cli_test.go index b944e1f898fe..3bfc2f15edba 100644 --- a/x/staking/client/testutil/cli_test.go +++ b/tests/e2e/staking/client/testutil/cli_test.go @@ -1,5 +1,5 @@ -//go:build norace -// +build norace +//go:build e2e +// +build e2e package testutil @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/x/staking/client/testutil" "github.com/stretchr/testify/suite" ) @@ -15,5 +16,5 @@ import ( func TestIntegrationTestSuite(t *testing.T) { cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) cfg.NumValidators = 2 - suite.Run(t, NewIntegrationTestSuite(cfg)) + suite.Run(t, testutil.NewIntegrationTestSuite(cfg)) } diff --git a/tests/e2e/upgrade/client/testutil/cli_test.go b/tests/e2e/upgrade/client/testutil/cli_test.go new file mode 100644 index 000000000000..6e431b137889 --- /dev/null +++ b/tests/e2e/upgrade/client/testutil/cli_test.go @@ -0,0 +1,28 @@ +//go:build e2e +// +build e2e + +package testutil + +import ( + "testing" + + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/x/upgrade/client/testutil" +) + +func TestIntegrationTestSuite(t *testing.T) { + cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) + cfg.NumValidators = 1 + + app := simapp.Setup(t, false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + app.UpgradeKeeper.SetVersionSetter(app.BaseApp) + app.UpgradeKeeper.SetModuleVersionMap(ctx, app.ModuleManager.GetVersionMap()) + + suite.Run(t, testutil.NewIntegrationTestSuite(cfg, app.UpgradeKeeper, ctx)) +} diff --git a/testutil/network/network.go b/testutil/network/network.go index 0939f83ab057..57648af5d595 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -484,7 +484,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { sdk.NewCoin(cfg.BondDenom, cfg.BondedTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), stakingtypes.NewCommissionRates(commission, sdk.OneDec(), sdk.OneDec()), - sdk.OneInt(), + math.OneInt(), ) if err != nil { return nil, err diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index 4a689324b532..be8133fb0a6d 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -14,6 +14,7 @@ import ( dbm "github.com/tendermint/tm-db" "cosmossdk.io/depinject" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -199,7 +200,7 @@ func GenesisStateWithValSet(codec codec.Codec, genesisState map[string]json.RawM UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), + MinSelfDelegation: math.ZeroInt(), } validators = append(validators, validator) delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) diff --git a/tx/go.mod b/tx/go.mod new file mode 100644 index 000000000000..27403eab1e98 --- /dev/null +++ b/tx/go.mod @@ -0,0 +1,22 @@ +module cosmossdk.io/tx + +go 1.18 + +require ( + cosmossdk.io/api v0.1.0-alpha8 + cosmossdk.io/math v1.0.0-beta.3 + github.com/cosmos/cosmos-proto v1.0.0-alpha7 + github.com/stretchr/testify v1.8.0 + google.golang.org/protobuf v1.28.0 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/google/go-cmp v0.5.8 // indirect + github.com/kr/pretty v0.3.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.8.1 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/tx/go.sum b/tx/go.sum new file mode 100644 index 000000000000..763656e5f36b --- /dev/null +++ b/tx/go.sum @@ -0,0 +1,81 @@ +cosmossdk.io/api v0.1.0-alpha8 h1:Hr+8bLI4UphF+aMiDIVklrdzRm99dFaNq2inBKGDzNU= +cosmossdk.io/api v0.1.0-alpha8/go.mod h1:gIs3NW5OSNK5wKqxF8JHnGTL82QMsXpwGeKmu2i5xFA= +cosmossdk.io/math v1.0.0-beta.3 h1:TbZxSopz2LqjJ7aXYfn7nJSb8vNaBklW6BLpcei1qwM= +cosmossdk.io/math v1.0.0-beta.3/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= +github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= +github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/tx/textual/internal/testdata/README.md b/tx/textual/internal/testdata/README.md new file mode 100644 index 000000000000..b7af90f7783f --- /dev/null +++ b/tx/textual/internal/testdata/README.md @@ -0,0 +1,3 @@ +# Testdata + +This folder contains test vectors shared between [CosmJS](https://github.com/cosmos/cosmjs/pull/1147) and the Cosmos SDK. \ No newline at end of file diff --git a/tx/textual/internal/testdata/bytes.json b/tx/textual/internal/testdata/bytes.json new file mode 100644 index 000000000000..0080bd5a49ff --- /dev/null +++ b/tx/textual/internal/testdata/bytes.json @@ -0,0 +1,10 @@ +[ + ["", ""], + ["00", "AA=="], + ["66", "Zg=="], + ["666F", "Zm8="], + ["666F6F", "Zm9v"], + ["666F6F62", "Zm9vYg=="], + ["666F6F6261", "Zm9vYmE="], + ["666F6F626172", "Zm9vYmFy"] + ] \ No newline at end of file diff --git a/tx/textual/internal/testdata/decimals.json b/tx/textual/internal/testdata/decimals.json new file mode 100644 index 000000000000..8893fef9e24b --- /dev/null +++ b/tx/textual/internal/testdata/decimals.json @@ -0,0 +1,43 @@ +[ + ["0", "0"], + ["1", "1"], + ["12", "12"], + ["123", "123"], + ["1234", "1'234"], + ["0.1", "0.1"], + ["0.01", "0.01"], + ["0.001", "0.001"], + ["0.0001", "0.0001"], + ["0.00001", "0.00001"], + ["0.000001", "0.000001"], + ["0.0000001", "0.0000001"], + ["0.00000001", "0.00000001"], + ["0.000000001", "0.000000001"], + ["0.0000000001", "0.0000000001"], + ["0.00000000001", "0.00000000001"], + ["0.000000000001", "0.000000000001"], + ["0.0000000000001", "0.0000000000001"], + ["0.00000000000001", "0.00000000000001"], + ["0.000000000000001", "0.000000000000001"], + ["0.0000000000000001", "0.0000000000000001"], + ["0.00000000000000001", "0.00000000000000001"], + ["0.000000000000000001", "0.000000000000000001"], + ["0.100000000000000000", "0.1"], + ["0.010000000000000000", "0.01"], + ["0.001000000000000000", "0.001"], + ["0.000100000000000000", "0.0001"], + ["0.000010000000000000", "0.00001"], + ["0.000001000000000000", "0.000001"], + ["0.000000100000000000", "0.0000001"], + ["0.000000010000000000", "0.00000001"], + ["0.000000001000000000", "0.000000001"], + ["0.000000000100000000", "0.0000000001"], + ["0.000000000010000000", "0.00000000001"], + ["0.000000000001000000", "0.000000000001"], + ["0.000000000000100000", "0.0000000000001"], + ["0.000000000000010000", "0.00000000000001"], + ["0.000000000000001000", "0.000000000000001"], + ["0.000000000000000100", "0.0000000000000001"], + ["0.000000000000000010", "0.00000000000000001"], + ["0.000000000000000001", "0.000000000000000001"] +] diff --git a/tx/textual/internal/testdata/integers.json b/tx/textual/internal/testdata/integers.json new file mode 100644 index 000000000000..0faa4f5fea4b --- /dev/null +++ b/tx/textual/internal/testdata/integers.json @@ -0,0 +1,19 @@ +[ + ["0", "0"], + ["1", "1"], + ["12", "12"], + ["123", "123"], + ["1234", "1'234"], + ["12345", "12'345"], + ["123456", "123'456"], + ["1234567", "1'234'567"], + ["9007199254740991", "9'007'199'254'740'991"], + ["9007199254740992", "9'007'199'254'740'992"], + ["18446744073709551615", "18'446'744'073'709'551'615"], + ["18446744073709551616", "18'446'744'073'709'551'616"], + ["340282366920938463463374607431768211455", "340'282'366'920'938'463'463'374'607'431'768'211'455"], + ["01", "1"], + ["001", "1"], + ["0001", "1"], + ["00001", "1"] +] diff --git a/tx/textual/internal/testpb/1.proto b/tx/textual/internal/testpb/1.proto new file mode 100644 index 000000000000..8501cc06c6e7 --- /dev/null +++ b/tx/textual/internal/testpb/1.proto @@ -0,0 +1,41 @@ +syntax = "proto3"; + +option go_package = "cosmossdk.io/tx/textual/internal/testpb"; + +import "google/protobuf/descriptor.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +enum Enumeration { + One = 0; + Two = 1; +} + +// A contains fields that are parseable by SIGN_MODE_TEXTUAL. +message A { + uint32 UINT32 = 1; + uint64 UINT64 = 2; + int32 INT32 = 3; + int64 INT64 = 4; + string SDKINT = 5 [(cosmos_proto.scalar) = "cosmos.Int"]; + string SDKDEC = 6 [(cosmos_proto.scalar) = "cosmos.Dec"]; + cosmos.base.v1beta1.Coin COIN = 7; + repeated cosmos.base.v1beta1.Coin COINS = 8; + bytes BYTES = 9; +} + +// B contains fields that are not parseable by SIGN_MODE_TEXTUAL, some fields +// may be moved to A at some point. +message B { + int32 INT32 = 1; + sint32 SINT32 = 2; + int64 INT64 = 3; + sint64 SING64 = 4; + sfixed32 SFIXED32 = 5; + fixed32 FIXED32 = 6; + float FLOAT = 7; + sfixed64 SFIXED64 = 8; + fixed64 FIXED64 = 9; + double DOUBLE = 10; + map MAP = 11; +} diff --git a/tx/textual/internal/testpb/1.pulsar.go b/tx/textual/internal/testpb/1.pulsar.go new file mode 100644 index 000000000000..50aab3696ff7 --- /dev/null +++ b/tx/textual/internal/testpb/1.pulsar.go @@ -0,0 +1,2517 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package testpb + +import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + binary "encoding/binary" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + runtime "github.com/cosmos/cosmos-proto/runtime" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + _ "google.golang.org/protobuf/types/descriptorpb" + io "io" + math "math" + reflect "reflect" + sort "sort" + sync "sync" +) + +var _ protoreflect.List = (*_A_8_list)(nil) + +type _A_8_list struct { + list *[]*v1beta1.Coin +} + +func (x *_A_8_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_A_8_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_A_8_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + (*x.list)[i] = concreteValue +} + +func (x *_A_8_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + *x.list = append(*x.list, concreteValue) +} + +func (x *_A_8_list) AppendMutable() protoreflect.Value { + v := new(v1beta1.Coin) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_A_8_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_A_8_list) NewElement() protoreflect.Value { + v := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_A_8_list) IsValid() bool { + return x.list != nil +} + +var ( + md_A protoreflect.MessageDescriptor + fd_A_UINT32 protoreflect.FieldDescriptor + fd_A_UINT64 protoreflect.FieldDescriptor + fd_A_INT32 protoreflect.FieldDescriptor + fd_A_INT64 protoreflect.FieldDescriptor + fd_A_SDKINT protoreflect.FieldDescriptor + fd_A_SDKDEC protoreflect.FieldDescriptor + fd_A_COIN protoreflect.FieldDescriptor + fd_A_COINS protoreflect.FieldDescriptor + fd_A_BYTES protoreflect.FieldDescriptor +) + +func init() { + file__1_proto_init() + md_A = File__1_proto.Messages().ByName("A") + fd_A_UINT32 = md_A.Fields().ByName("UINT32") + fd_A_UINT64 = md_A.Fields().ByName("UINT64") + fd_A_INT32 = md_A.Fields().ByName("INT32") + fd_A_INT64 = md_A.Fields().ByName("INT64") + fd_A_SDKINT = md_A.Fields().ByName("SDKINT") + fd_A_SDKDEC = md_A.Fields().ByName("SDKDEC") + fd_A_COIN = md_A.Fields().ByName("COIN") + fd_A_COINS = md_A.Fields().ByName("COINS") + fd_A_BYTES = md_A.Fields().ByName("BYTES") +} + +var _ protoreflect.Message = (*fastReflection_A)(nil) + +type fastReflection_A A + +func (x *A) ProtoReflect() protoreflect.Message { + return (*fastReflection_A)(x) +} + +func (x *A) slowProtoReflect() protoreflect.Message { + mi := &file__1_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_A_messageType fastReflection_A_messageType +var _ protoreflect.MessageType = fastReflection_A_messageType{} + +type fastReflection_A_messageType struct{} + +func (x fastReflection_A_messageType) Zero() protoreflect.Message { + return (*fastReflection_A)(nil) +} +func (x fastReflection_A_messageType) New() protoreflect.Message { + return new(fastReflection_A) +} +func (x fastReflection_A_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_A +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_A) Descriptor() protoreflect.MessageDescriptor { + return md_A +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_A) Type() protoreflect.MessageType { + return _fastReflection_A_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_A) New() protoreflect.Message { + return new(fastReflection_A) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_A) Interface() protoreflect.ProtoMessage { + return (*A)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_A) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.UINT32 != uint32(0) { + value := protoreflect.ValueOfUint32(x.UINT32) + if !f(fd_A_UINT32, value) { + return + } + } + if x.UINT64 != uint64(0) { + value := protoreflect.ValueOfUint64(x.UINT64) + if !f(fd_A_UINT64, value) { + return + } + } + if x.INT32 != int32(0) { + value := protoreflect.ValueOfInt32(x.INT32) + if !f(fd_A_INT32, value) { + return + } + } + if x.INT64 != int64(0) { + value := protoreflect.ValueOfInt64(x.INT64) + if !f(fd_A_INT64, value) { + return + } + } + if x.SDKINT != "" { + value := protoreflect.ValueOfString(x.SDKINT) + if !f(fd_A_SDKINT, value) { + return + } + } + if x.SDKDEC != "" { + value := protoreflect.ValueOfString(x.SDKDEC) + if !f(fd_A_SDKDEC, value) { + return + } + } + if x.COIN != nil { + value := protoreflect.ValueOfMessage(x.COIN.ProtoReflect()) + if !f(fd_A_COIN, value) { + return + } + } + if len(x.COINS) != 0 { + value := protoreflect.ValueOfList(&_A_8_list{list: &x.COINS}) + if !f(fd_A_COINS, value) { + return + } + } + if len(x.BYTES) != 0 { + value := protoreflect.ValueOfBytes(x.BYTES) + if !f(fd_A_BYTES, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_A) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "A.UINT32": + return x.UINT32 != uint32(0) + case "A.UINT64": + return x.UINT64 != uint64(0) + case "A.INT32": + return x.INT32 != int32(0) + case "A.INT64": + return x.INT64 != int64(0) + case "A.SDKINT": + return x.SDKINT != "" + case "A.SDKDEC": + return x.SDKDEC != "" + case "A.COIN": + return x.COIN != nil + case "A.COINS": + return len(x.COINS) != 0 + case "A.BYTES": + return len(x.BYTES) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_A) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "A.UINT32": + x.UINT32 = uint32(0) + case "A.UINT64": + x.UINT64 = uint64(0) + case "A.INT32": + x.INT32 = int32(0) + case "A.INT64": + x.INT64 = int64(0) + case "A.SDKINT": + x.SDKINT = "" + case "A.SDKDEC": + x.SDKDEC = "" + case "A.COIN": + x.COIN = nil + case "A.COINS": + x.COINS = nil + case "A.BYTES": + x.BYTES = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_A) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "A.UINT32": + value := x.UINT32 + return protoreflect.ValueOfUint32(value) + case "A.UINT64": + value := x.UINT64 + return protoreflect.ValueOfUint64(value) + case "A.INT32": + value := x.INT32 + return protoreflect.ValueOfInt32(value) + case "A.INT64": + value := x.INT64 + return protoreflect.ValueOfInt64(value) + case "A.SDKINT": + value := x.SDKINT + return protoreflect.ValueOfString(value) + case "A.SDKDEC": + value := x.SDKDEC + return protoreflect.ValueOfString(value) + case "A.COIN": + value := x.COIN + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "A.COINS": + if len(x.COINS) == 0 { + return protoreflect.ValueOfList(&_A_8_list{}) + } + listValue := &_A_8_list{list: &x.COINS} + return protoreflect.ValueOfList(listValue) + case "A.BYTES": + value := x.BYTES + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_A) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "A.UINT32": + x.UINT32 = uint32(value.Uint()) + case "A.UINT64": + x.UINT64 = value.Uint() + case "A.INT32": + x.INT32 = int32(value.Int()) + case "A.INT64": + x.INT64 = value.Int() + case "A.SDKINT": + x.SDKINT = value.Interface().(string) + case "A.SDKDEC": + x.SDKDEC = value.Interface().(string) + case "A.COIN": + x.COIN = value.Message().Interface().(*v1beta1.Coin) + case "A.COINS": + lv := value.List() + clv := lv.(*_A_8_list) + x.COINS = *clv.list + case "A.BYTES": + x.BYTES = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_A) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "A.COIN": + if x.COIN == nil { + x.COIN = new(v1beta1.Coin) + } + return protoreflect.ValueOfMessage(x.COIN.ProtoReflect()) + case "A.COINS": + if x.COINS == nil { + x.COINS = []*v1beta1.Coin{} + } + value := &_A_8_list{list: &x.COINS} + return protoreflect.ValueOfList(value) + case "A.UINT32": + panic(fmt.Errorf("field UINT32 of message A is not mutable")) + case "A.UINT64": + panic(fmt.Errorf("field UINT64 of message A is not mutable")) + case "A.INT32": + panic(fmt.Errorf("field INT32 of message A is not mutable")) + case "A.INT64": + panic(fmt.Errorf("field INT64 of message A is not mutable")) + case "A.SDKINT": + panic(fmt.Errorf("field SDKINT of message A is not mutable")) + case "A.SDKDEC": + panic(fmt.Errorf("field SDKDEC of message A is not mutable")) + case "A.BYTES": + panic(fmt.Errorf("field BYTES of message A is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_A) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "A.UINT32": + return protoreflect.ValueOfUint32(uint32(0)) + case "A.UINT64": + return protoreflect.ValueOfUint64(uint64(0)) + case "A.INT32": + return protoreflect.ValueOfInt32(int32(0)) + case "A.INT64": + return protoreflect.ValueOfInt64(int64(0)) + case "A.SDKINT": + return protoreflect.ValueOfString("") + case "A.SDKDEC": + return protoreflect.ValueOfString("") + case "A.COIN": + m := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "A.COINS": + list := []*v1beta1.Coin{} + return protoreflect.ValueOfList(&_A_8_list{list: &list}) + case "A.BYTES": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: A")) + } + panic(fmt.Errorf("message A does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_A) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in A", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_A) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_A) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_A) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_A) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*A) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.UINT32 != 0 { + n += 1 + runtime.Sov(uint64(x.UINT32)) + } + if x.UINT64 != 0 { + n += 1 + runtime.Sov(uint64(x.UINT64)) + } + if x.INT32 != 0 { + n += 1 + runtime.Sov(uint64(x.INT32)) + } + if x.INT64 != 0 { + n += 1 + runtime.Sov(uint64(x.INT64)) + } + l = len(x.SDKINT) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.SDKDEC) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.COIN != nil { + l = options.Size(x.COIN) + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.COINS) > 0 { + for _, e := range x.COINS { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + l = len(x.BYTES) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*A) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.BYTES) > 0 { + i -= len(x.BYTES) + copy(dAtA[i:], x.BYTES) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BYTES))) + i-- + dAtA[i] = 0x4a + } + if len(x.COINS) > 0 { + for iNdEx := len(x.COINS) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.COINS[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x42 + } + } + if x.COIN != nil { + encoded, err := options.Marshal(x.COIN) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x3a + } + if len(x.SDKDEC) > 0 { + i -= len(x.SDKDEC) + copy(dAtA[i:], x.SDKDEC) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SDKDEC))) + i-- + dAtA[i] = 0x32 + } + if len(x.SDKINT) > 0 { + i -= len(x.SDKINT) + copy(dAtA[i:], x.SDKINT) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.SDKINT))) + i-- + dAtA[i] = 0x2a + } + if x.INT64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.INT64)) + i-- + dAtA[i] = 0x20 + } + if x.INT32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.INT32)) + i-- + dAtA[i] = 0x18 + } + if x.UINT64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.UINT64)) + i-- + dAtA[i] = 0x10 + } + if x.UINT32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.UINT32)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*A) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: A: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: A: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field UINT32", wireType) + } + x.UINT32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.UINT32 |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field UINT64", wireType) + } + x.UINT64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.UINT64 |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field INT32", wireType) + } + x.INT32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.INT32 |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field INT64", wireType) + } + x.INT64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.INT64 |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SDKINT", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.SDKINT = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SDKDEC", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.SDKDEC = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field COIN", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.COIN == nil { + x.COIN = &v1beta1.Coin{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.COIN); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field COINS", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.COINS = append(x.COINS, &v1beta1.Coin{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.COINS[len(x.COINS)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BYTES", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.BYTES = append(x.BYTES[:0], dAtA[iNdEx:postIndex]...) + if x.BYTES == nil { + x.BYTES = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.Map = (*_B_11_map)(nil) + +type _B_11_map struct { + m *map[string]*B +} + +func (x *_B_11_map) Len() int { + if x.m == nil { + return 0 + } + return len(*x.m) +} + +func (x *_B_11_map) Range(f func(protoreflect.MapKey, protoreflect.Value) bool) { + if x.m == nil { + return + } + for k, v := range *x.m { + mapKey := (protoreflect.MapKey)(protoreflect.ValueOfString(k)) + mapValue := protoreflect.ValueOfMessage(v.ProtoReflect()) + if !f(mapKey, mapValue) { + break + } + } +} + +func (x *_B_11_map) Has(key protoreflect.MapKey) bool { + if x.m == nil { + return false + } + keyUnwrapped := key.String() + concreteValue := keyUnwrapped + _, ok := (*x.m)[concreteValue] + return ok +} + +func (x *_B_11_map) Clear(key protoreflect.MapKey) { + if x.m == nil { + return + } + keyUnwrapped := key.String() + concreteKey := keyUnwrapped + delete(*x.m, concreteKey) +} + +func (x *_B_11_map) Get(key protoreflect.MapKey) protoreflect.Value { + if x.m == nil { + return protoreflect.Value{} + } + keyUnwrapped := key.String() + concreteKey := keyUnwrapped + v, ok := (*x.m)[concreteKey] + if !ok { + return protoreflect.Value{} + } + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_B_11_map) Set(key protoreflect.MapKey, value protoreflect.Value) { + if !key.IsValid() || !value.IsValid() { + panic("invalid key or value provided") + } + keyUnwrapped := key.String() + concreteKey := keyUnwrapped + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*B) + (*x.m)[concreteKey] = concreteValue +} + +func (x *_B_11_map) Mutable(key protoreflect.MapKey) protoreflect.Value { + keyUnwrapped := key.String() + concreteKey := keyUnwrapped + v, ok := (*x.m)[concreteKey] + if ok { + return protoreflect.ValueOfMessage(v.ProtoReflect()) + } + newValue := new(B) + (*x.m)[concreteKey] = newValue + return protoreflect.ValueOfMessage(newValue.ProtoReflect()) +} + +func (x *_B_11_map) NewValue() protoreflect.Value { + v := new(B) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_B_11_map) IsValid() bool { + return x.m != nil +} + +var ( + md_B protoreflect.MessageDescriptor + fd_B_INT32 protoreflect.FieldDescriptor + fd_B_SINT32 protoreflect.FieldDescriptor + fd_B_INT64 protoreflect.FieldDescriptor + fd_B_SING64 protoreflect.FieldDescriptor + fd_B_SFIXED32 protoreflect.FieldDescriptor + fd_B_FIXED32 protoreflect.FieldDescriptor + fd_B_FLOAT protoreflect.FieldDescriptor + fd_B_SFIXED64 protoreflect.FieldDescriptor + fd_B_FIXED64 protoreflect.FieldDescriptor + fd_B_DOUBLE protoreflect.FieldDescriptor + fd_B_MAP protoreflect.FieldDescriptor +) + +func init() { + file__1_proto_init() + md_B = File__1_proto.Messages().ByName("B") + fd_B_INT32 = md_B.Fields().ByName("INT32") + fd_B_SINT32 = md_B.Fields().ByName("SINT32") + fd_B_INT64 = md_B.Fields().ByName("INT64") + fd_B_SING64 = md_B.Fields().ByName("SING64") + fd_B_SFIXED32 = md_B.Fields().ByName("SFIXED32") + fd_B_FIXED32 = md_B.Fields().ByName("FIXED32") + fd_B_FLOAT = md_B.Fields().ByName("FLOAT") + fd_B_SFIXED64 = md_B.Fields().ByName("SFIXED64") + fd_B_FIXED64 = md_B.Fields().ByName("FIXED64") + fd_B_DOUBLE = md_B.Fields().ByName("DOUBLE") + fd_B_MAP = md_B.Fields().ByName("MAP") +} + +var _ protoreflect.Message = (*fastReflection_B)(nil) + +type fastReflection_B B + +func (x *B) ProtoReflect() protoreflect.Message { + return (*fastReflection_B)(x) +} + +func (x *B) slowProtoReflect() protoreflect.Message { + mi := &file__1_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_B_messageType fastReflection_B_messageType +var _ protoreflect.MessageType = fastReflection_B_messageType{} + +type fastReflection_B_messageType struct{} + +func (x fastReflection_B_messageType) Zero() protoreflect.Message { + return (*fastReflection_B)(nil) +} +func (x fastReflection_B_messageType) New() protoreflect.Message { + return new(fastReflection_B) +} +func (x fastReflection_B_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_B +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_B) Descriptor() protoreflect.MessageDescriptor { + return md_B +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_B) Type() protoreflect.MessageType { + return _fastReflection_B_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_B) New() protoreflect.Message { + return new(fastReflection_B) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_B) Interface() protoreflect.ProtoMessage { + return (*B)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_B) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.INT32 != int32(0) { + value := protoreflect.ValueOfInt32(x.INT32) + if !f(fd_B_INT32, value) { + return + } + } + if x.SINT32 != int32(0) { + value := protoreflect.ValueOfInt32(x.SINT32) + if !f(fd_B_SINT32, value) { + return + } + } + if x.INT64 != int64(0) { + value := protoreflect.ValueOfInt64(x.INT64) + if !f(fd_B_INT64, value) { + return + } + } + if x.SING64 != int64(0) { + value := protoreflect.ValueOfInt64(x.SING64) + if !f(fd_B_SING64, value) { + return + } + } + if x.SFIXED32 != int32(0) { + value := protoreflect.ValueOfInt32(x.SFIXED32) + if !f(fd_B_SFIXED32, value) { + return + } + } + if x.FIXED32 != uint32(0) { + value := protoreflect.ValueOfUint32(x.FIXED32) + if !f(fd_B_FIXED32, value) { + return + } + } + if x.FLOAT != float32(0) || math.Signbit(float64(x.FLOAT)) { + value := protoreflect.ValueOfFloat32(x.FLOAT) + if !f(fd_B_FLOAT, value) { + return + } + } + if x.SFIXED64 != int64(0) { + value := protoreflect.ValueOfInt64(x.SFIXED64) + if !f(fd_B_SFIXED64, value) { + return + } + } + if x.FIXED64 != uint64(0) { + value := protoreflect.ValueOfUint64(x.FIXED64) + if !f(fd_B_FIXED64, value) { + return + } + } + if x.DOUBLE != float64(0) || math.Signbit(x.DOUBLE) { + value := protoreflect.ValueOfFloat64(x.DOUBLE) + if !f(fd_B_DOUBLE, value) { + return + } + } + if len(x.MAP) != 0 { + value := protoreflect.ValueOfMap(&_B_11_map{m: &x.MAP}) + if !f(fd_B_MAP, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_B) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "B.INT32": + return x.INT32 != int32(0) + case "B.SINT32": + return x.SINT32 != int32(0) + case "B.INT64": + return x.INT64 != int64(0) + case "B.SING64": + return x.SING64 != int64(0) + case "B.SFIXED32": + return x.SFIXED32 != int32(0) + case "B.FIXED32": + return x.FIXED32 != uint32(0) + case "B.FLOAT": + return x.FLOAT != float32(0) || math.Signbit(float64(x.FLOAT)) + case "B.SFIXED64": + return x.SFIXED64 != int64(0) + case "B.FIXED64": + return x.FIXED64 != uint64(0) + case "B.DOUBLE": + return x.DOUBLE != float64(0) || math.Signbit(x.DOUBLE) + case "B.MAP": + return len(x.MAP) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_B) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "B.INT32": + x.INT32 = int32(0) + case "B.SINT32": + x.SINT32 = int32(0) + case "B.INT64": + x.INT64 = int64(0) + case "B.SING64": + x.SING64 = int64(0) + case "B.SFIXED32": + x.SFIXED32 = int32(0) + case "B.FIXED32": + x.FIXED32 = uint32(0) + case "B.FLOAT": + x.FLOAT = float32(0) + case "B.SFIXED64": + x.SFIXED64 = int64(0) + case "B.FIXED64": + x.FIXED64 = uint64(0) + case "B.DOUBLE": + x.DOUBLE = float64(0) + case "B.MAP": + x.MAP = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_B) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "B.INT32": + value := x.INT32 + return protoreflect.ValueOfInt32(value) + case "B.SINT32": + value := x.SINT32 + return protoreflect.ValueOfInt32(value) + case "B.INT64": + value := x.INT64 + return protoreflect.ValueOfInt64(value) + case "B.SING64": + value := x.SING64 + return protoreflect.ValueOfInt64(value) + case "B.SFIXED32": + value := x.SFIXED32 + return protoreflect.ValueOfInt32(value) + case "B.FIXED32": + value := x.FIXED32 + return protoreflect.ValueOfUint32(value) + case "B.FLOAT": + value := x.FLOAT + return protoreflect.ValueOfFloat32(value) + case "B.SFIXED64": + value := x.SFIXED64 + return protoreflect.ValueOfInt64(value) + case "B.FIXED64": + value := x.FIXED64 + return protoreflect.ValueOfUint64(value) + case "B.DOUBLE": + value := x.DOUBLE + return protoreflect.ValueOfFloat64(value) + case "B.MAP": + if len(x.MAP) == 0 { + return protoreflect.ValueOfMap(&_B_11_map{}) + } + mapValue := &_B_11_map{m: &x.MAP} + return protoreflect.ValueOfMap(mapValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_B) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "B.INT32": + x.INT32 = int32(value.Int()) + case "B.SINT32": + x.SINT32 = int32(value.Int()) + case "B.INT64": + x.INT64 = value.Int() + case "B.SING64": + x.SING64 = value.Int() + case "B.SFIXED32": + x.SFIXED32 = int32(value.Int()) + case "B.FIXED32": + x.FIXED32 = uint32(value.Uint()) + case "B.FLOAT": + x.FLOAT = float32(value.Float()) + case "B.SFIXED64": + x.SFIXED64 = value.Int() + case "B.FIXED64": + x.FIXED64 = value.Uint() + case "B.DOUBLE": + x.DOUBLE = value.Float() + case "B.MAP": + mv := value.Map() + cmv := mv.(*_B_11_map) + x.MAP = *cmv.m + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_B) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "B.MAP": + if x.MAP == nil { + x.MAP = make(map[string]*B) + } + value := &_B_11_map{m: &x.MAP} + return protoreflect.ValueOfMap(value) + case "B.INT32": + panic(fmt.Errorf("field INT32 of message B is not mutable")) + case "B.SINT32": + panic(fmt.Errorf("field SINT32 of message B is not mutable")) + case "B.INT64": + panic(fmt.Errorf("field INT64 of message B is not mutable")) + case "B.SING64": + panic(fmt.Errorf("field SING64 of message B is not mutable")) + case "B.SFIXED32": + panic(fmt.Errorf("field SFIXED32 of message B is not mutable")) + case "B.FIXED32": + panic(fmt.Errorf("field FIXED32 of message B is not mutable")) + case "B.FLOAT": + panic(fmt.Errorf("field FLOAT of message B is not mutable")) + case "B.SFIXED64": + panic(fmt.Errorf("field SFIXED64 of message B is not mutable")) + case "B.FIXED64": + panic(fmt.Errorf("field FIXED64 of message B is not mutable")) + case "B.DOUBLE": + panic(fmt.Errorf("field DOUBLE of message B is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_B) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "B.INT32": + return protoreflect.ValueOfInt32(int32(0)) + case "B.SINT32": + return protoreflect.ValueOfInt32(int32(0)) + case "B.INT64": + return protoreflect.ValueOfInt64(int64(0)) + case "B.SING64": + return protoreflect.ValueOfInt64(int64(0)) + case "B.SFIXED32": + return protoreflect.ValueOfInt32(int32(0)) + case "B.FIXED32": + return protoreflect.ValueOfUint32(uint32(0)) + case "B.FLOAT": + return protoreflect.ValueOfFloat32(float32(0)) + case "B.SFIXED64": + return protoreflect.ValueOfInt64(int64(0)) + case "B.FIXED64": + return protoreflect.ValueOfUint64(uint64(0)) + case "B.DOUBLE": + return protoreflect.ValueOfFloat64(float64(0)) + case "B.MAP": + m := make(map[string]*B) + return protoreflect.ValueOfMap(&_B_11_map{m: &m}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: B")) + } + panic(fmt.Errorf("message B does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_B) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in B", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_B) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_B) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_B) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_B) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*B) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.INT32 != 0 { + n += 1 + runtime.Sov(uint64(x.INT32)) + } + if x.SINT32 != 0 { + n += 1 + runtime.Soz(uint64(x.SINT32)) + } + if x.INT64 != 0 { + n += 1 + runtime.Sov(uint64(x.INT64)) + } + if x.SING64 != 0 { + n += 1 + runtime.Soz(uint64(x.SING64)) + } + if x.SFIXED32 != 0 { + n += 5 + } + if x.FIXED32 != 0 { + n += 5 + } + if x.FLOAT != 0 || math.Signbit(float64(x.FLOAT)) { + n += 5 + } + if x.SFIXED64 != 0 { + n += 9 + } + if x.FIXED64 != 0 { + n += 9 + } + if x.DOUBLE != 0 || math.Signbit(x.DOUBLE) { + n += 9 + } + if len(x.MAP) > 0 { + SiZeMaP := func(k string, v *B) { + l := 0 + if v != nil { + l = options.Size(v) + } + l += 1 + runtime.Sov(uint64(l)) + mapEntrySize := 1 + len(k) + runtime.Sov(uint64(len(k))) + l + n += mapEntrySize + 1 + runtime.Sov(uint64(mapEntrySize)) + } + if options.Deterministic { + sortme := make([]string, 0, len(x.MAP)) + for k := range x.MAP { + sortme = append(sortme, k) + } + sort.Strings(sortme) + for _, k := range sortme { + v := x.MAP[k] + SiZeMaP(k, v) + } + } else { + for k, v := range x.MAP { + SiZeMaP(k, v) + } + } + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*B) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.MAP) > 0 { + MaRsHaLmAp := func(k string, v *B) (protoiface.MarshalOutput, error) { + baseI := i + encoded, err := options.Marshal(v) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = runtime.EncodeVarint(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = runtime.EncodeVarint(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x5a + return protoiface.MarshalOutput{}, nil + } + if options.Deterministic { + keysForMAP := make([]string, 0, len(x.MAP)) + for k := range x.MAP { + keysForMAP = append(keysForMAP, string(k)) + } + sort.Slice(keysForMAP, func(i, j int) bool { + return keysForMAP[i] < keysForMAP[j] + }) + for iNdEx := len(keysForMAP) - 1; iNdEx >= 0; iNdEx-- { + v := x.MAP[string(keysForMAP[iNdEx])] + out, err := MaRsHaLmAp(keysForMAP[iNdEx], v) + if err != nil { + return out, err + } + } + } else { + for k := range x.MAP { + v := x.MAP[k] + out, err := MaRsHaLmAp(k, v) + if err != nil { + return out, err + } + } + } + } + if x.DOUBLE != 0 || math.Signbit(x.DOUBLE) { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(math.Float64bits(float64(x.DOUBLE)))) + i-- + dAtA[i] = 0x51 + } + if x.FIXED64 != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(x.FIXED64)) + i-- + dAtA[i] = 0x49 + } + if x.SFIXED64 != 0 { + i -= 8 + binary.LittleEndian.PutUint64(dAtA[i:], uint64(x.SFIXED64)) + i-- + dAtA[i] = 0x41 + } + if x.FLOAT != 0 || math.Signbit(float64(x.FLOAT)) { + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(math.Float32bits(float32(x.FLOAT)))) + i-- + dAtA[i] = 0x3d + } + if x.FIXED32 != 0 { + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(x.FIXED32)) + i-- + dAtA[i] = 0x35 + } + if x.SFIXED32 != 0 { + i -= 4 + binary.LittleEndian.PutUint32(dAtA[i:], uint32(x.SFIXED32)) + i-- + dAtA[i] = 0x2d + } + if x.SING64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64((uint64(x.SING64)<<1)^uint64((x.SING64>>63)))) + i-- + dAtA[i] = 0x20 + } + if x.INT64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.INT64)) + i-- + dAtA[i] = 0x18 + } + if x.SINT32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64((uint32(x.SINT32)<<1)^uint32((x.SINT32>>31)))) + i-- + dAtA[i] = 0x10 + } + if x.INT32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.INT32)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*B) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: B: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: B: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field INT32", wireType) + } + x.INT32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.INT32 |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SINT32", wireType) + } + var v int32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + v = int32((uint32(v) >> 1) ^ uint32(((v&1)<<31)>>31)) + x.SINT32 = v + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field INT64", wireType) + } + x.INT64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.INT64 |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SING64", wireType) + } + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + v = (v >> 1) ^ uint64((int64(v&1)<<63)>>63) + x.SING64 = int64(v) + case 5: + if wireType != 5 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SFIXED32", wireType) + } + x.SFIXED32 = 0 + if (iNdEx + 4) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.SFIXED32 = int32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + case 6: + if wireType != 5 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FIXED32", wireType) + } + x.FIXED32 = 0 + if (iNdEx + 4) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.FIXED32 = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + case 7: + if wireType != 5 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FLOAT", wireType) + } + var v uint32 + if (iNdEx + 4) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint32(binary.LittleEndian.Uint32(dAtA[iNdEx:])) + iNdEx += 4 + x.FLOAT = float32(math.Float32frombits(v)) + case 8: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SFIXED64", wireType) + } + x.SFIXED64 = 0 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.SFIXED64 = int64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + case 9: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FIXED64", wireType) + } + x.FIXED64 = 0 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.FIXED64 = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + case 10: + if wireType != 1 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field DOUBLE", wireType) + } + var v uint64 + if (iNdEx + 8) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + v = uint64(binary.LittleEndian.Uint64(dAtA[iNdEx:])) + iNdEx += 8 + x.DOUBLE = float64(math.Float64frombits(v)) + case 11: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field MAP", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.MAP == nil { + x.MAP = make(map[string]*B) + } + var mapkey string + var mapvalue *B + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postStringIndexmapkey > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postmsgIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + mapvalue = &B{} + if err := options.Unmarshal(dAtA[iNdEx:postmsgIndex], mapvalue); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > postIndex { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + x.MAP[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: 1.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Enumeration int32 + +const ( + Enumeration_One Enumeration = 0 + Enumeration_Two Enumeration = 1 +) + +// Enum value maps for Enumeration. +var ( + Enumeration_name = map[int32]string{ + 0: "One", + 1: "Two", + } + Enumeration_value = map[string]int32{ + "One": 0, + "Two": 1, + } +) + +func (x Enumeration) Enum() *Enumeration { + p := new(Enumeration) + *p = x + return p +} + +func (x Enumeration) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Enumeration) Descriptor() protoreflect.EnumDescriptor { + return file__1_proto_enumTypes[0].Descriptor() +} + +func (Enumeration) Type() protoreflect.EnumType { + return &file__1_proto_enumTypes[0] +} + +func (x Enumeration) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Enumeration.Descriptor instead. +func (Enumeration) EnumDescriptor() ([]byte, []int) { + return file__1_proto_rawDescGZIP(), []int{0} +} + +// A contains fields that are parseable by SIGN_MODE_TEXTUAL. +type A struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UINT32 uint32 `protobuf:"varint,1,opt,name=UINT32,proto3" json:"UINT32,omitempty"` + UINT64 uint64 `protobuf:"varint,2,opt,name=UINT64,proto3" json:"UINT64,omitempty"` + INT32 int32 `protobuf:"varint,3,opt,name=INT32,proto3" json:"INT32,omitempty"` + INT64 int64 `protobuf:"varint,4,opt,name=INT64,proto3" json:"INT64,omitempty"` + SDKINT string `protobuf:"bytes,5,opt,name=SDKINT,proto3" json:"SDKINT,omitempty"` + SDKDEC string `protobuf:"bytes,6,opt,name=SDKDEC,proto3" json:"SDKDEC,omitempty"` + COIN *v1beta1.Coin `protobuf:"bytes,7,opt,name=COIN,proto3" json:"COIN,omitempty"` + COINS []*v1beta1.Coin `protobuf:"bytes,8,rep,name=COINS,proto3" json:"COINS,omitempty"` + BYTES []byte `protobuf:"bytes,9,opt,name=BYTES,proto3" json:"BYTES,omitempty"` +} + +func (x *A) Reset() { + *x = A{} + if protoimpl.UnsafeEnabled { + mi := &file__1_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *A) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*A) ProtoMessage() {} + +// Deprecated: Use A.ProtoReflect.Descriptor instead. +func (*A) Descriptor() ([]byte, []int) { + return file__1_proto_rawDescGZIP(), []int{0} +} + +func (x *A) GetUINT32() uint32 { + if x != nil { + return x.UINT32 + } + return 0 +} + +func (x *A) GetUINT64() uint64 { + if x != nil { + return x.UINT64 + } + return 0 +} + +func (x *A) GetINT32() int32 { + if x != nil { + return x.INT32 + } + return 0 +} + +func (x *A) GetINT64() int64 { + if x != nil { + return x.INT64 + } + return 0 +} + +func (x *A) GetSDKINT() string { + if x != nil { + return x.SDKINT + } + return "" +} + +func (x *A) GetSDKDEC() string { + if x != nil { + return x.SDKDEC + } + return "" +} + +func (x *A) GetCOIN() *v1beta1.Coin { + if x != nil { + return x.COIN + } + return nil +} + +func (x *A) GetCOINS() []*v1beta1.Coin { + if x != nil { + return x.COINS + } + return nil +} + +func (x *A) GetBYTES() []byte { + if x != nil { + return x.BYTES + } + return nil +} + +// B contains fields that are not parseable by SIGN_MODE_TEXTUAL, some fields +// may be moved to A at some point. +type B struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + INT32 int32 `protobuf:"varint,1,opt,name=INT32,proto3" json:"INT32,omitempty"` + SINT32 int32 `protobuf:"zigzag32,2,opt,name=SINT32,proto3" json:"SINT32,omitempty"` + INT64 int64 `protobuf:"varint,3,opt,name=INT64,proto3" json:"INT64,omitempty"` + SING64 int64 `protobuf:"zigzag64,4,opt,name=SING64,proto3" json:"SING64,omitempty"` + SFIXED32 int32 `protobuf:"fixed32,5,opt,name=SFIXED32,proto3" json:"SFIXED32,omitempty"` + FIXED32 uint32 `protobuf:"fixed32,6,opt,name=FIXED32,proto3" json:"FIXED32,omitempty"` + FLOAT float32 `protobuf:"fixed32,7,opt,name=FLOAT,proto3" json:"FLOAT,omitempty"` + SFIXED64 int64 `protobuf:"fixed64,8,opt,name=SFIXED64,proto3" json:"SFIXED64,omitempty"` + FIXED64 uint64 `protobuf:"fixed64,9,opt,name=FIXED64,proto3" json:"FIXED64,omitempty"` + DOUBLE float64 `protobuf:"fixed64,10,opt,name=DOUBLE,proto3" json:"DOUBLE,omitempty"` + MAP map[string]*B `protobuf:"bytes,11,rep,name=MAP,proto3" json:"MAP,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +func (x *B) Reset() { + *x = B{} + if protoimpl.UnsafeEnabled { + mi := &file__1_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *B) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*B) ProtoMessage() {} + +// Deprecated: Use B.ProtoReflect.Descriptor instead. +func (*B) Descriptor() ([]byte, []int) { + return file__1_proto_rawDescGZIP(), []int{1} +} + +func (x *B) GetINT32() int32 { + if x != nil { + return x.INT32 + } + return 0 +} + +func (x *B) GetSINT32() int32 { + if x != nil { + return x.SINT32 + } + return 0 +} + +func (x *B) GetINT64() int64 { + if x != nil { + return x.INT64 + } + return 0 +} + +func (x *B) GetSING64() int64 { + if x != nil { + return x.SING64 + } + return 0 +} + +func (x *B) GetSFIXED32() int32 { + if x != nil { + return x.SFIXED32 + } + return 0 +} + +func (x *B) GetFIXED32() uint32 { + if x != nil { + return x.FIXED32 + } + return 0 +} + +func (x *B) GetFLOAT() float32 { + if x != nil { + return x.FLOAT + } + return 0 +} + +func (x *B) GetSFIXED64() int64 { + if x != nil { + return x.SFIXED64 + } + return 0 +} + +func (x *B) GetFIXED64() uint64 { + if x != nil { + return x.FIXED64 + } + return 0 +} + +func (x *B) GetDOUBLE() float64 { + if x != nil { + return x.DOUBLE + } + return 0 +} + +func (x *B) GetMAP() map[string]*B { + if x != nil { + return x.MAP + } + return nil +} + +var File__1_proto protoreflect.FileDescriptor + +var file__1_proto_rawDesc = []byte{ + 0x0a, 0x07, 0x31, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, + 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, + 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa5, 0x02, 0x0a, 0x01, 0x41, 0x12, 0x16, 0x0a, 0x06, + 0x55, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x49, + 0x4e, 0x54, 0x33, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x55, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x12, 0x14, 0x0a, 0x05, + 0x49, 0x4e, 0x54, 0x33, 0x32, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x49, 0x4e, 0x54, + 0x33, 0x32, 0x12, 0x14, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x05, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x12, 0x26, 0x0a, 0x06, 0x53, 0x44, 0x4b, 0x49, + 0x4e, 0x54, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0e, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x49, 0x6e, 0x74, 0x52, 0x06, 0x53, 0x44, 0x4b, 0x49, 0x4e, 0x54, + 0x12, 0x26, 0x0a, 0x06, 0x53, 0x44, 0x4b, 0x44, 0x45, 0x43, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x42, 0x0e, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x44, 0x65, 0x63, + 0x52, 0x06, 0x53, 0x44, 0x4b, 0x44, 0x45, 0x43, 0x12, 0x2d, 0x0a, 0x04, 0x43, 0x4f, 0x49, 0x4e, + 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, + 0x6e, 0x52, 0x04, 0x43, 0x4f, 0x49, 0x4e, 0x12, 0x2f, 0x0a, 0x05, 0x43, 0x4f, 0x49, 0x4e, 0x53, + 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, + 0x6e, 0x52, 0x05, 0x43, 0x4f, 0x49, 0x4e, 0x53, 0x12, 0x14, 0x0a, 0x05, 0x42, 0x59, 0x54, 0x45, + 0x53, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x42, 0x59, 0x54, 0x45, 0x53, 0x22, 0xd4, + 0x02, 0x0a, 0x01, 0x42, 0x12, 0x14, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x05, 0x49, 0x4e, 0x54, 0x33, 0x32, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x49, + 0x4e, 0x54, 0x33, 0x32, 0x18, 0x02, 0x20, 0x01, 0x28, 0x11, 0x52, 0x06, 0x53, 0x49, 0x4e, 0x54, + 0x33, 0x32, 0x12, 0x14, 0x0a, 0x05, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x05, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x12, 0x16, 0x0a, 0x06, 0x53, 0x49, 0x4e, 0x47, + 0x36, 0x34, 0x18, 0x04, 0x20, 0x01, 0x28, 0x12, 0x52, 0x06, 0x53, 0x49, 0x4e, 0x47, 0x36, 0x34, + 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x46, 0x49, 0x58, 0x45, 0x44, 0x33, 0x32, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x0f, 0x52, 0x08, 0x53, 0x46, 0x49, 0x58, 0x45, 0x44, 0x33, 0x32, 0x12, 0x18, 0x0a, 0x07, + 0x46, 0x49, 0x58, 0x45, 0x44, 0x33, 0x32, 0x18, 0x06, 0x20, 0x01, 0x28, 0x07, 0x52, 0x07, 0x46, + 0x49, 0x58, 0x45, 0x44, 0x33, 0x32, 0x12, 0x14, 0x0a, 0x05, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x46, 0x4c, 0x4f, 0x41, 0x54, 0x12, 0x1a, 0x0a, 0x08, + 0x53, 0x46, 0x49, 0x58, 0x45, 0x44, 0x36, 0x34, 0x18, 0x08, 0x20, 0x01, 0x28, 0x10, 0x52, 0x08, + 0x53, 0x46, 0x49, 0x58, 0x45, 0x44, 0x36, 0x34, 0x12, 0x18, 0x0a, 0x07, 0x46, 0x49, 0x58, 0x45, + 0x44, 0x36, 0x34, 0x18, 0x09, 0x20, 0x01, 0x28, 0x06, 0x52, 0x07, 0x46, 0x49, 0x58, 0x45, 0x44, + 0x36, 0x34, 0x12, 0x16, 0x0a, 0x06, 0x44, 0x4f, 0x55, 0x42, 0x4c, 0x45, 0x18, 0x0a, 0x20, 0x01, + 0x28, 0x01, 0x52, 0x06, 0x44, 0x4f, 0x55, 0x42, 0x4c, 0x45, 0x12, 0x1d, 0x0a, 0x03, 0x4d, 0x41, + 0x50, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x42, 0x2e, 0x4d, 0x41, 0x50, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x52, 0x03, 0x4d, 0x41, 0x50, 0x1a, 0x3a, 0x0a, 0x08, 0x4d, 0x41, 0x50, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x18, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x02, 0x2e, 0x42, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x3a, 0x02, 0x38, 0x01, 0x2a, 0x1f, 0x0a, 0x0b, 0x45, 0x6e, 0x75, 0x6d, 0x65, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x07, 0x0a, 0x03, 0x4f, 0x6e, 0x65, 0x10, 0x00, 0x12, 0x07, 0x0a, + 0x03, 0x54, 0x77, 0x6f, 0x10, 0x01, 0x42, 0x33, 0x42, 0x06, 0x31, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x27, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x74, 0x78, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, +} + +var ( + file__1_proto_rawDescOnce sync.Once + file__1_proto_rawDescData = file__1_proto_rawDesc +) + +func file__1_proto_rawDescGZIP() []byte { + file__1_proto_rawDescOnce.Do(func() { + file__1_proto_rawDescData = protoimpl.X.CompressGZIP(file__1_proto_rawDescData) + }) + return file__1_proto_rawDescData +} + +var file__1_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file__1_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file__1_proto_goTypes = []interface{}{ + (Enumeration)(0), // 0: Enumeration + (*A)(nil), // 1: A + (*B)(nil), // 2: B + nil, // 3: B.MAPEntry + (*v1beta1.Coin)(nil), // 4: cosmos.base.v1beta1.Coin +} +var file__1_proto_depIdxs = []int32{ + 4, // 0: A.COIN:type_name -> cosmos.base.v1beta1.Coin + 4, // 1: A.COINS:type_name -> cosmos.base.v1beta1.Coin + 3, // 2: B.MAP:type_name -> B.MAPEntry + 2, // 3: B.MAPEntry.value:type_name -> B + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file__1_proto_init() } +func file__1_proto_init() { + if File__1_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file__1_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*A); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file__1_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*B); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file__1_proto_rawDesc, + NumEnums: 1, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file__1_proto_goTypes, + DependencyIndexes: file__1_proto_depIdxs, + EnumInfos: file__1_proto_enumTypes, + MessageInfos: file__1_proto_msgTypes, + }.Build() + File__1_proto = out.File + file__1_proto_rawDesc = nil + file__1_proto_goTypes = nil + file__1_proto_depIdxs = nil +} diff --git a/tx/textual/internal/testpb/Makefile b/tx/textual/internal/testpb/Makefile new file mode 100644 index 000000000000..f102fd503e2a --- /dev/null +++ b/tx/textual/internal/testpb/Makefile @@ -0,0 +1,2 @@ +codegen: + @(buf generate) diff --git a/tx/textual/internal/testpb/buf.gen.yaml b/tx/textual/internal/testpb/buf.gen.yaml new file mode 100644 index 000000000000..137c21bccb00 --- /dev/null +++ b/tx/textual/internal/testpb/buf.gen.yaml @@ -0,0 +1,15 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: cosmossdk.io/tx/textual/internal/testpb + except: + - buf.build/googleapis/googleapis + - buf.build/cosmos/gogo-proto + - buf.build/cosmos/cosmos-proto + override: + buf.build/cosmos/cosmos-sdk: cosmossdk.io/api +plugins: + - name: go-pulsar + out: . + opt: paths=source_relative diff --git a/tx/textual/internal/testpb/buf.lock b/tx/textual/internal/testpb/buf.lock new file mode 100644 index 000000000000..f5ea8b24862b --- /dev/null +++ b/tx/textual/internal/testpb/buf.lock @@ -0,0 +1,11 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: cosmos + repository: cosmos-proto + commit: 1935555c206d4afb9e94615dfd0fad31 + - remote: buf.build + owner: cosmos + repository: gogo-proto + commit: bee5511075b7499da6178d9e4aaa628b diff --git a/tx/textual/internal/testpb/buf.yaml b/tx/textual/internal/testpb/buf.yaml new file mode 100644 index 000000000000..5aee45ac2b4f --- /dev/null +++ b/tx/textual/internal/testpb/buf.yaml @@ -0,0 +1,12 @@ +version: v1 +deps: + - buf.build/cosmos/cosmos-proto + - buf.build/cosmos/gogo-proto +lint: + use: + - DEFAULT + except: + - PACKAGE_VERSION_SUFFIX +breaking: + ignore: + - testpb diff --git a/tx/textual/valuerenderer/bytes.go b/tx/textual/valuerenderer/bytes.go new file mode 100644 index 000000000000..23ece74c94df --- /dev/null +++ b/tx/textual/valuerenderer/bytes.go @@ -0,0 +1,34 @@ +package valuerenderer + +import ( + "context" + "encoding/base64" + "io" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +//bytesValueRenderer implements ValueRenderer for bytes +type bytesValueRenderer struct { +} + +var _ ValueRenderer = bytesValueRenderer{} + +func (vr bytesValueRenderer) Format(ctx context.Context, v protoreflect.Value, w io.Writer) error { + _, err := w.Write([]byte(base64.StdEncoding.EncodeToString(v.Bytes()))) + return err +} + +func (vr bytesValueRenderer) Parse(_ context.Context, r io.Reader) (protoreflect.Value, error) { + formatted, err := io.ReadAll(r) + if err != nil { + return protoreflect.ValueOfBytes([]byte{}), err + } + + data, err := base64.StdEncoding.DecodeString(string(formatted)) + if err != nil { + return protoreflect.ValueOfBytes([]byte{}), err + } + + return protoreflect.ValueOfBytes(data), nil +} diff --git a/tx/textual/valuerenderer/bytes_test.go b/tx/textual/valuerenderer/bytes_test.go new file mode 100644 index 000000000000..63565282743b --- /dev/null +++ b/tx/textual/valuerenderer/bytes_test.go @@ -0,0 +1,45 @@ +package valuerenderer_test + +import ( + "context" + "encoding/hex" + "encoding/json" + "io/ioutil" + "strings" + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/reflect/protoreflect" +) + +func TestFormatBytes(t *testing.T) { + var testcases []bytesTest + raw, err := ioutil.ReadFile("../internal/testdata/bytes.json") + require.NoError(t, err) + + err = json.Unmarshal(raw, &testcases) + require.NoError(t, err) + + for _, tc := range testcases { + data, err := hex.DecodeString(tc.hex) + require.NoError(t, err) + + r, err := valueRendererOf(data) + require.NoError(t, err) + + b := new(strings.Builder) + err = r.Format(context.Background(), protoreflect.ValueOfBytes(data), b) + require.NoError(t, err) + require.Equal(t, tc.expRes, b.String()) + } +} + +type bytesTest struct { + hex string + expRes string +} + +func (t *bytesTest) UnmarshalJSON(b []byte) error { + a := []interface{}{&t.hex, &t.expRes} + return json.Unmarshal(b, &a) +} diff --git a/tx/textual/valuerenderer/dec.go b/tx/textual/valuerenderer/dec.go new file mode 100644 index 000000000000..688ef73c2340 --- /dev/null +++ b/tx/textual/valuerenderer/dec.go @@ -0,0 +1,56 @@ +package valuerenderer + +import ( + "context" + "fmt" + "io" + "strings" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +const thousandSeparator string = "'" + +type decValueRenderer struct{} + +var _ ValueRenderer = decValueRenderer{} + +func (vr decValueRenderer) Format(_ context.Context, v protoreflect.Value, w io.Writer) error { + formatted, err := formatDecimal(v.String()) + if err != nil { + return err + } + + _, err = w.Write([]byte(formatted)) + return err +} + +func (vr decValueRenderer) Parse(_ context.Context, r io.Reader) (protoreflect.Value, error) { + panic("implement me") +} + +// formatDecimal formats a decimal into a value-rendered string. This function +// operates with string manipulation (instead of manipulating the sdk.Dec +// object). +func formatDecimal(v string) (string, error) { + parts := strings.Split(v, ".") + intPart, err := formatInteger(parts[0]) + if err != nil { + return "", err + } + + if len(parts) > 2 { + return "", fmt.Errorf("invalid decimal %s", v) + } + + if len(parts) == 1 { + return intPart, nil + } + + decPart := strings.TrimRight(parts[1], "0") + if len(decPart) == 0 { + return intPart, nil + } + + return intPart + "." + decPart, nil +} diff --git a/tx/textual/valuerenderer/int.go b/tx/textual/valuerenderer/int.go new file mode 100644 index 000000000000..2770cce13fbc --- /dev/null +++ b/tx/textual/valuerenderer/int.go @@ -0,0 +1,48 @@ +package valuerenderer + +import ( + "context" + "io" + "strings" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +type intValueRenderer struct{} + +var _ ValueRenderer = intValueRenderer{} + +func (vr intValueRenderer) Format(_ context.Context, v protoreflect.Value, w io.Writer) error { + formatted, err := formatInteger(v.String()) + if err != nil { + return err + } + + _, err = w.Write([]byte(formatted)) + return err +} + +func (vr intValueRenderer) Parse(_ context.Context, r io.Reader) (protoreflect.Value, error) { + panic("implement me") +} + +// formatInteger formats an integer into a value-rendered string. This function +// operates with string manipulation (instead of manipulating the int or sdk.Int +// object). +func formatInteger(v string) (string, error) { + if v[0] == '-' { + v = v[1:] + } + if len(v) > 1 { + v = strings.TrimLeft(v, "0") + + } + + startOffset := 3 + for outputIndex := len(v); outputIndex > startOffset; { + outputIndex -= 3 + v = v[:outputIndex] + thousandSeparator + v[outputIndex:] + } + + return v, nil +} diff --git a/tx/textual/valuerenderer/types.go b/tx/textual/valuerenderer/types.go new file mode 100644 index 000000000000..21ca059cb234 --- /dev/null +++ b/tx/textual/valuerenderer/types.go @@ -0,0 +1,20 @@ +package valuerenderer + +import ( + "context" + "io" + + "google.golang.org/protobuf/reflect/protoreflect" +) + +// ValueRenderer defines an interface to produce formatted output for all +// protobuf types as well as parse a string into those protobuf types. +// +// The notion of "value renderer" is defined in ADR-050, and that ADR provides +// a default spec for value renderers. However, we define it as an interface +// here, so that optionally more value renderers could be built, for example, a +// separate one for a different language. +type ValueRenderer interface { + Format(context.Context, protoreflect.Value, io.Writer) error + Parse(context.Context, io.Reader) (protoreflect.Value, error) +} diff --git a/tx/textual/valuerenderer/valuerenderer.go b/tx/textual/valuerenderer/valuerenderer.go new file mode 100644 index 000000000000..a22e181f959a --- /dev/null +++ b/tx/textual/valuerenderer/valuerenderer.go @@ -0,0 +1,71 @@ +package valuerenderer + +import ( + "fmt" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + cosmos_proto "github.com/cosmos/cosmos-proto" +) + +type Textual struct { + scalars map[string]ValueRenderer +} + +func NewTextual() Textual { + return Textual{} +} + +// GetValueRenderer returns the value renderer for the given FieldDescriptor. +func (r Textual) GetValueRenderer(fd protoreflect.FieldDescriptor) (ValueRenderer, error) { + switch { + // Scalars, such as sdk.Int and sdk.Dec. + case fd.Kind() == protoreflect.StringKind && proto.GetExtension(fd.Options(), cosmos_proto.E_Scalar) != "": + { + scalar, ok := proto.GetExtension(fd.Options(), cosmos_proto.E_Scalar).(string) + if !ok || scalar == "" { + return nil, fmt.Errorf("got extension option %s of type %T", scalar, scalar) + } + + if r.scalars == nil { + r.init() + } + + vr := r.scalars[scalar] + if vr == nil { + return nil, fmt.Errorf("got empty value renderer for scalar %s", scalar) + } + + return vr, nil + } + case fd.Kind() == protoreflect.BytesKind: + return bytesValueRenderer{}, nil + + // Integers + case fd.Kind() == protoreflect.Uint32Kind || + fd.Kind() == protoreflect.Uint64Kind || + fd.Kind() == protoreflect.Int32Kind || + fd.Kind() == protoreflect.Int64Kind: + { + return intValueRenderer{}, nil + } + + default: + return nil, fmt.Errorf("value renderers cannot format value of type %s", fd.Kind()) + } +} + +func (r *Textual) init() { + if r.scalars == nil { + r.scalars = map[string]ValueRenderer{} + r.scalars["cosmos.Int"] = intValueRenderer{} + r.scalars["cosmos.Dec"] = decValueRenderer{} + } +} + +// DefineScalar adds a value renderer to the given Cosmos scalar. +func (r *Textual) DefineScalar(scalar string, vr ValueRenderer) { + r.init() + r.scalars[scalar] = vr +} diff --git a/tx/textual/valuerenderer/valuerenderer_test.go b/tx/textual/valuerenderer/valuerenderer_test.go new file mode 100644 index 000000000000..36b399f2b026 --- /dev/null +++ b/tx/textual/valuerenderer/valuerenderer_test.go @@ -0,0 +1,148 @@ +package valuerenderer_test + +import ( + "context" + "encoding/json" + "fmt" + "io/ioutil" + "strconv" + "strings" + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/reflect/protoreflect" + + "cosmossdk.io/math" + "cosmossdk.io/tx/textual/internal/testpb" + "cosmossdk.io/tx/textual/valuerenderer" +) + +func TestFormatInteger(t *testing.T) { + type integerTest []string + var testcases []integerTest + raw, err := ioutil.ReadFile("../internal/testdata/integers.json") + require.NoError(t, err) + err = json.Unmarshal(raw, &testcases) + require.NoError(t, err) + + for _, tc := range testcases { + // Parse test case strings as protobuf uint64 + i, err := strconv.ParseUint(tc[0], 10, 64) + if err == nil { + r, err := valueRendererOf(i) + require.NoError(t, err) + b := new(strings.Builder) + err = r.Format(context.Background(), protoreflect.ValueOf(i), b) + require.NoError(t, err) + + require.Equal(t, tc[1], b.String()) + } + + // Parse test case strings as protobuf uint32 + i, err = strconv.ParseUint(tc[0], 10, 32) + if err == nil { + r, err := valueRendererOf(i) + require.NoError(t, err) + b := new(strings.Builder) + err = r.Format(context.Background(), protoreflect.ValueOf(i), b) + require.NoError(t, err) + + require.Equal(t, tc[1], b.String()) + } + + // Parse test case strings as sdk.Ints + sdkInt, ok := math.NewIntFromString(tc[0]) + if ok { + r, err := valueRendererOf(sdkInt) + require.NoError(t, err) + b := new(strings.Builder) + err = r.Format(context.Background(), protoreflect.ValueOf(tc[0]), b) + require.NoError(t, err) + + require.Equal(t, tc[1], b.String()) + } + } +} + +func TestFormatDecimal(t *testing.T) { + type decimalTest []string + var testcases []decimalTest + raw, err := ioutil.ReadFile("../internal/testdata/decimals.json") + require.NoError(t, err) + err = json.Unmarshal(raw, &testcases) + require.NoError(t, err) + + for _, tc := range testcases { + d, err := math.LegacyNewDecFromStr(tc[0]) + require.NoError(t, err) + r, err := valueRendererOf(d) + require.NoError(t, err) + b := new(strings.Builder) + err = r.Format(context.Background(), protoreflect.ValueOf(tc[0]), b) + require.NoError(t, err) + + require.Equal(t, tc[1], b.String()) + } +} + +func TestGetADR050ValueRenderer(t *testing.T) { + testcases := []struct { + name string + v interface{} + expErr bool + }{ + {"uint32", uint32(1), false}, + {"uint64", uint64(1), false}, + {"sdk.Int", math.NewInt(1), false}, + {"sdk.Dec", math.LegacyNewDec(1), false}, + {"[]byte", []byte{1}, false}, + {"float32", float32(1), true}, + {"float64", float64(1), true}, + } + + for _, tc := range testcases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + _, err := valueRendererOf(tc.v) + if tc.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +// valueRendererOf is like GetADR050ValueRenderer, but taking a Go type +// as input instead of a protoreflect.FieldDescriptor. +func valueRendererOf(v interface{}) (valuerenderer.ValueRenderer, error) { + a, b := (&testpb.A{}).ProtoReflect().Descriptor().Fields(), (&testpb.B{}).ProtoReflect().Descriptor().Fields() + + textual := valuerenderer.NewTextual() + switch v := v.(type) { + // Valid types for SIGN_MODE_TEXTUAL + case uint32: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("UINT32"))) + case uint64: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("UINT64"))) + case int32: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("INT32"))) + case int64: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("INT64"))) + case []byte: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("BYTES"))) + case math.Int: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("SDKINT"))) + case math.LegacyDec: + return textual.GetValueRenderer(a.ByName(protoreflect.Name("SDKDEC"))) + + // Invalid types for SIGN_MODE_TEXTUAL + case float32: + return textual.GetValueRenderer(b.ByName(protoreflect.Name("FLOAT"))) + case float64: + return textual.GetValueRenderer(b.ByName(protoreflect.Name("FLOAT"))) + + default: + return nil, fmt.Errorf("value %s of type %T not recognized", v, v) + } +} diff --git a/types/coin_test.go b/types/coin_test.go index 47241af71a55..02b1d8b9f434 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -5,6 +5,7 @@ import ( "strings" "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/codec" @@ -27,7 +28,7 @@ func TestCoinTestSuite(t *testing.T) { func (s *coinTestSuite) SetupSuite() { zero := sdk.NewInt(0) - one := sdk.OneInt() + one := math.OneInt() two := sdk.NewInt(2) four := sdk.NewInt(4) @@ -90,15 +91,15 @@ func (s *coinTestSuite) TestCoinIsValid() { }{ {sdk.Coin{testDenom1, sdk.NewInt(-1)}, false}, {sdk.Coin{testDenom1, sdk.NewInt(0)}, true}, - {sdk.Coin{testDenom1, sdk.OneInt()}, true}, - {sdk.Coin{"Atom", sdk.OneInt()}, true}, - {sdk.Coin{"ATOM", sdk.OneInt()}, true}, - {sdk.Coin{"a", sdk.OneInt()}, false}, - {sdk.Coin{loremIpsum, sdk.OneInt()}, false}, - {sdk.Coin{"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.OneInt()}, true}, - {sdk.Coin{"atOm", sdk.OneInt()}, true}, - {sdk.Coin{"x:y-z.1_2", sdk.OneInt()}, true}, - {sdk.Coin{" ", sdk.OneInt()}, false}, + {sdk.Coin{testDenom1, math.OneInt()}, true}, + {sdk.Coin{"Atom", math.OneInt()}, true}, + {sdk.Coin{"ATOM", math.OneInt()}, true}, + {sdk.Coin{"a", math.OneInt()}, false}, + {sdk.Coin{loremIpsum, math.OneInt()}, false}, + {sdk.Coin{"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", math.OneInt()}, true}, + {sdk.Coin{"atOm", math.OneInt()}, true}, + {sdk.Coin{"x:y-z.1_2", math.OneInt()}, true}, + {sdk.Coin{" ", math.OneInt()}, false}, } for i, tc := range cases { @@ -130,7 +131,6 @@ func (s *coinTestSuite) TestCustomValidation() { } func (s *coinTestSuite) TestCoinsDenoms() { - cases := []struct { coins sdk.Coins testOutput []string @@ -155,7 +155,6 @@ func (s *coinTestSuite) TestCoinsDenoms() { } s.Require().Equal(count == 0, tc.expectPass, "unexpected result for coins.Denoms, tc #%d", i) } - } func (s *coinTestSuite) TestAddCoin() { @@ -184,7 +183,7 @@ func (s *coinTestSuite) TestAddCoin() { func (s *coinTestSuite) TestAddCoinAmount() { cases := []struct { coin sdk.Coin - amount sdk.Int + amount math.Int expected sdk.Coin }{ {sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt(1), sdk.NewInt64Coin(testDenom1, 2)}, @@ -232,7 +231,7 @@ func (s *coinTestSuite) TestSubCoin() { func (s *coinTestSuite) TestSubCoinAmount() { cases := []struct { coin sdk.Coin - amount sdk.Int + amount math.Int expected sdk.Coin shouldPanic bool }{ @@ -256,7 +255,7 @@ func (s *coinTestSuite) TestSubCoinAmount() { func (s *coinTestSuite) TestMulIntCoins() { testCases := []struct { input sdk.Coins - multiplier sdk.Int + multiplier math.Int expected sdk.Coins shouldPanic bool }{ @@ -281,7 +280,7 @@ func (s *coinTestSuite) TestMulIntCoins() { func (s *coinTestSuite) TestQuoIntCoins() { testCases := []struct { input sdk.Coins - divisor sdk.Int + divisor math.Int expected sdk.Coins isValid bool shouldPanic bool @@ -413,7 +412,7 @@ func (s *coinTestSuite) TestFilteredZeroCoins() { { name: "all greater than zero", input: sdk.Coins{ - {"testa", sdk.OneInt()}, + {"testa", math.OneInt()}, {"testb", sdk.NewInt(2)}, {"testc", sdk.NewInt(3)}, {"testd", sdk.NewInt(4)}, @@ -425,7 +424,7 @@ func (s *coinTestSuite) TestFilteredZeroCoins() { { name: "zero coin in middle", input: sdk.Coins{ - {"testa", sdk.OneInt()}, + {"testa", math.OneInt()}, {"testb", sdk.NewInt(2)}, {"testc", sdk.NewInt(0)}, {"testd", sdk.NewInt(4)}, @@ -439,7 +438,7 @@ func (s *coinTestSuite) TestFilteredZeroCoins() { input: sdk.Coins{ {"teste", sdk.NewInt(5)}, {"testc", sdk.NewInt(3)}, - {"testa", sdk.OneInt()}, + {"testa", math.OneInt()}, {"testd", sdk.NewInt(4)}, {"testb", sdk.NewInt(0)}, }, @@ -471,15 +470,15 @@ func (s *coinTestSuite) TestCoins_String() { }, { "single coin", - sdk.Coins{{"tree", sdk.OneInt()}}, + sdk.Coins{{"tree", math.OneInt()}}, "1tree", }, { "multiple coins", sdk.Coins{ - {"tree", sdk.OneInt()}, - {"gas", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"tree", math.OneInt()}, + {"gas", math.OneInt()}, + {"mineral", math.OneInt()}, }, "1tree,1gas,1mineral", }, @@ -619,87 +618,87 @@ func (s *coinTestSuite) TestCoins_Validate() { { "valid lowercase coins", sdk.Coins{ - {"gas", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, - {"tree", sdk.OneInt()}, + {"gas", math.OneInt()}, + {"mineral", math.OneInt()}, + {"tree", math.OneInt()}, }, true, }, { "valid uppercase coins", sdk.Coins{ - {"GAS", sdk.OneInt()}, - {"MINERAL", sdk.OneInt()}, - {"TREE", sdk.OneInt()}, + {"GAS", math.OneInt()}, + {"MINERAL", math.OneInt()}, + {"TREE", math.OneInt()}, }, true, }, { "valid uppercase coin", sdk.Coins{ - {"ATOM", sdk.OneInt()}, + {"ATOM", math.OneInt()}, }, true, }, { "valid lower and uppercase coins (1)", sdk.Coins{ - {"GAS", sdk.OneInt()}, - {"gAs", sdk.OneInt()}, + {"GAS", math.OneInt()}, + {"gAs", math.OneInt()}, }, true, }, { "valid lower and uppercase coins (2)", sdk.Coins{ - {"ATOM", sdk.OneInt()}, - {"Atom", sdk.OneInt()}, - {"atom", sdk.OneInt()}, + {"ATOM", math.OneInt()}, + {"Atom", math.OneInt()}, + {"atom", math.OneInt()}, }, true, }, { "mixed case (1)", sdk.Coins{ - {"MineraL", sdk.OneInt()}, - {"TREE", sdk.OneInt()}, - {"gAs", sdk.OneInt()}, + {"MineraL", math.OneInt()}, + {"TREE", math.OneInt()}, + {"gAs", math.OneInt()}, }, true, }, { "mixed case (2)", sdk.Coins{ - {"gAs", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"gAs", math.OneInt()}, + {"mineral", math.OneInt()}, }, true, }, { "mixed case (3)", sdk.Coins{ - {"gAs", sdk.OneInt()}, + {"gAs", math.OneInt()}, }, true, }, { "unicode letters and numbers", sdk.Coins{ - {"𐀀𐀆𐀉Ⅲ", sdk.OneInt()}, + {"𐀀𐀆𐀉Ⅲ", math.OneInt()}, }, false, }, { "emojis", sdk.Coins{ - {"🤑😋🤔", sdk.OneInt()}, + {"🤑😋🤔", math.OneInt()}, }, false, }, { "IBC denominations (ADR 001)", sdk.Coins{ - {"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.OneInt()}, + {"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", math.OneInt()}, {"ibc/876563AAAACF739EB061C67CDB5EDF2B7C9FD4AA9D876450CC21210807C2820A", sdk.NewInt(2)}, }, true, @@ -717,44 +716,44 @@ func (s *coinTestSuite) TestCoins_Validate() { { "invalid denomination (1)", sdk.Coins{ - {"MineraL", sdk.OneInt()}, - {"0TREE", sdk.OneInt()}, - {"gAs", sdk.OneInt()}, + {"MineraL", math.OneInt()}, + {"0TREE", math.OneInt()}, + {"gAs", math.OneInt()}, }, false, }, { "invalid denomination (2)", sdk.Coins{ - {"-GAS", sdk.OneInt()}, - {"gAs", sdk.OneInt()}, + {"-GAS", math.OneInt()}, + {"gAs", math.OneInt()}, }, false, }, { "bad sort (1)", sdk.Coins{ - {"tree", sdk.OneInt()}, - {"gas", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"tree", math.OneInt()}, + {"gas", math.OneInt()}, + {"mineral", math.OneInt()}, }, false, }, { "bad sort (2)", sdk.Coins{ - {"gas", sdk.OneInt()}, - {"tree", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"gas", math.OneInt()}, + {"tree", math.OneInt()}, + {"mineral", math.OneInt()}, }, false, }, { "non-positive amount (1)", sdk.Coins{ - {"gas", sdk.OneInt()}, + {"gas", math.OneInt()}, {"tree", sdk.NewInt(0)}, - {"mineral", sdk.OneInt()}, + {"mineral", math.OneInt()}, }, false, }, @@ -762,17 +761,17 @@ func (s *coinTestSuite) TestCoins_Validate() { "non-positive amount (2)", sdk.Coins{ {"gas", sdk.NewInt(-1)}, - {"tree", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"tree", math.OneInt()}, + {"mineral", math.OneInt()}, }, false, }, { "duplicate denomination", sdk.Coins{ - {"gas", sdk.OneInt()}, - {"gas", sdk.OneInt()}, - {"mineral", sdk.OneInt()}, + {"gas", math.OneInt()}, + {"gas", math.OneInt()}, + {"mineral", math.OneInt()}, }, false, }, @@ -789,7 +788,7 @@ func (s *coinTestSuite) TestCoins_Validate() { } func (s *coinTestSuite) TestMinMax() { - one := sdk.OneInt() + one := math.OneInt() two := sdk.NewInt(2) cases := []struct { @@ -821,7 +820,7 @@ func (s *coinTestSuite) TestMinMax() { } func (s *coinTestSuite) TestCoinsGT() { - one := sdk.OneInt() + one := math.OneInt() two := sdk.NewInt(2) s.Require().False(sdk.Coins{}.IsAllGT(sdk.Coins{})) @@ -833,7 +832,7 @@ func (s *coinTestSuite) TestCoinsGT() { } func (s *coinTestSuite) TestCoinsLT() { - one := sdk.OneInt() + one := math.OneInt() two := sdk.NewInt(2) s.Require().False(sdk.Coins{}.IsAllLT(sdk.Coins{})) @@ -848,7 +847,7 @@ func (s *coinTestSuite) TestCoinsLT() { } func (s *coinTestSuite) TestCoinsLTE() { - one := sdk.OneInt() + one := math.OneInt() two := sdk.NewInt(2) s.Require().True(sdk.Coins{}.IsAllLTE(sdk.Coins{})) @@ -863,7 +862,7 @@ func (s *coinTestSuite) TestCoinsLTE() { } func (s *coinTestSuite) TestParseCoins() { - one := sdk.OneInt() + one := math.OneInt() cases := []struct { input string @@ -1033,7 +1032,7 @@ func (s *coinTestSuite) TestSearch() { } func (s *coinTestSuite) TestCoinsIsAnyGTE() { - one := sdk.OneInt() + one := math.OneInt() two := sdk.NewInt(2) s.Require().False(sdk.Coins{}.IsAnyGTE(sdk.Coins{})) @@ -1053,7 +1052,7 @@ func (s *coinTestSuite) TestCoinsIsAnyGTE() { } func (s *coinTestSuite) TestCoinsIsAllGT() { - one := sdk.OneInt() + one := math.OneInt() two := sdk.NewInt(2) s.Require().False(sdk.Coins{}.IsAllGT(sdk.Coins{})) @@ -1073,7 +1072,7 @@ func (s *coinTestSuite) TestCoinsIsAllGT() { } func (s *coinTestSuite) TestCoinsIsAllGTE() { - one := sdk.OneInt() + one := math.OneInt() two := sdk.NewInt(2) s.Require().True(sdk.Coins{}.IsAllGTE(sdk.Coins{})) @@ -1098,7 +1097,7 @@ func (s *coinTestSuite) TestNewCoins() { tenatom := sdk.NewInt64Coin("atom", 10) tenbtc := sdk.NewInt64Coin("btc", 10) zeroeth := sdk.NewInt64Coin("eth", 0) - invalidCoin := sdk.Coin{"0ETH", sdk.OneInt()} + invalidCoin := sdk.Coin{"0ETH", math.OneInt()} tests := []struct { name string coins sdk.Coins diff --git a/types/module/module.go b/types/module/module.go index bbf4abcadba7..da4719fb7fad 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -152,15 +152,6 @@ type AppModule interface { // registers RegisterInvariants(sdk.InvariantRegistry) - // Deprecated: use RegisterServices - Route() sdk.Route - - // Deprecated: use RegisterServices - QuerierRoute() string - - // Deprecated: use RegisterServices - LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier - // RegisterServices allows a module to register services RegisterServices(Configurator) @@ -288,18 +279,6 @@ func (m *Manager) RegisterInvariants(ir sdk.InvariantRegistry) { } } -// RegisterRoutes registers all module routes and module querier routes -func (m *Manager) RegisterRoutes(router sdk.Router, queryRouter sdk.QueryRouter, legacyQuerierCdc *codec.LegacyAmino) { - for _, module := range m.Modules { - if r := module.Route(); !r.Empty() { - router.AddRoute(r) - } - if r := module.QuerierRoute(); r != "" { - queryRouter.AddRoute(r, module.LegacyQuerierHandler(legacyQuerierCdc)) - } - } -} - // RegisterServices registers all module services func (m *Manager) RegisterServices(cfg Configurator) { for _, module := range m.Modules { diff --git a/types/module/module_test.go b/types/module/module_test.go index 926a4a4ab3f8..2f52b0dbbc00 100644 --- a/types/module/module_test.go +++ b/types/module/module_test.go @@ -73,10 +73,6 @@ func TestGenesisOnlyAppModule(t *testing.T) { mockInvariantRegistry := mocks.NewMockInvariantRegistry(mockCtrl) goam := module.NewGenesisOnlyAppModule(mockModule) - require.True(t, goam.Route().Empty()) - require.Empty(t, goam.QuerierRoute()) - require.Nil(t, goam.LegacyQuerierHandler(nil)) - // no-op goam.RegisterInvariants(mockInvariantRegistry) } @@ -129,37 +125,6 @@ func TestManager_RegisterInvariants(t *testing.T) { mm.RegisterInvariants(mockInvariantRegistry) } -func TestManager_RegisterRoutes(t *testing.T) { - mockCtrl := gomock.NewController(t) - t.Cleanup(mockCtrl.Finish) - - mockAppModule1 := mocks.NewMockAppModule(mockCtrl) - mockAppModule2 := mocks.NewMockAppModule(mockCtrl) - mockAppModule1.EXPECT().Name().Times(2).Return("module1") - mockAppModule2.EXPECT().Name().Times(2).Return("module2") - mm := module.NewManager(mockAppModule1, mockAppModule2) - require.NotNil(t, mm) - require.Equal(t, 2, len(mm.Modules)) - - router := mocks.NewMockRouter(mockCtrl) - noopHandler := sdk.Handler(func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { return nil, nil }) - route1 := sdk.NewRoute("route1", noopHandler) - route2 := sdk.NewRoute("", noopHandler) - mockAppModule1.EXPECT().Route().Times(1).Return(route1) - mockAppModule2.EXPECT().Route().Times(1).Return(route2) - router.EXPECT().AddRoute(gomock.Any()).Times(1) // Use of Any due to limitations to compare Functions as the sdk.Handler - - queryRouter := mocks.NewMockQueryRouter(mockCtrl) - mockAppModule1.EXPECT().QuerierRoute().Times(1).Return("querierRoute1") - mockAppModule2.EXPECT().QuerierRoute().Times(1).Return("") - handler3 := sdk.Querier(nil) - amino := codec.NewLegacyAmino() - mockAppModule1.EXPECT().LegacyQuerierHandler(amino).Times(1).Return(handler3) - queryRouter.EXPECT().AddRoute(gomock.Eq("querierRoute1"), gomock.Eq(handler3)).Times(1) - - mm.RegisterRoutes(router, queryRouter, amino) -} - func TestManager_RegisterQueryServices(t *testing.T) { mockCtrl := gomock.NewController(t) t.Cleanup(mockCtrl.Finish) diff --git a/types/query/filtered_pagination_test.go b/types/query/filtered_pagination_test.go index ee118f9c7a6d..0fd697def138 100644 --- a/types/query/filtered_pagination_test.go +++ b/types/query/filtered_pagination_test.go @@ -16,7 +16,6 @@ import ( var addr1 = sdk.AccAddress([]byte("addr1")) func (s *paginationTestSuite) TestFilteredPaginations() { - var balances sdk.Coins for i := 0; i < numBalances; i++ { denom := fmt.Sprintf("foo%ddenom", i) @@ -248,7 +247,6 @@ func execFilterPaginate(store sdk.KVStore, pageReq *query.PageRequest, appCodec } func (s *paginationTestSuite) TestFilteredPaginationsNextKey() { - var balances sdk.Coins for i := 1; i <= 10; i++ { diff --git a/types/query/pagination_test.go b/types/query/pagination_test.go index c632492c37e1..512db35a180c 100644 --- a/types/query/pagination_test.go +++ b/types/query/pagination_test.go @@ -5,6 +5,7 @@ import ( "fmt" "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -74,8 +75,7 @@ func (s *paginationTestSuite) SetupTest() { ctx := app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) - s.ctx, s.bankKeeper, s.accountKeeper, s.cdc, s.app, s.interfaceReg = - ctx, bankKeeper, accountKeeper, cdc, app, reg + s.ctx, s.bankKeeper, s.accountKeeper, s.cdc, s.app, s.interfaceReg = ctx, bankKeeper, accountKeeper, cdc, app, reg } func (s *paginationTestSuite) TestParsePagination() { @@ -352,7 +352,7 @@ func (s *paginationTestSuite) TestPaginate() { balancesStore := prefix.NewStore(authStore, types.BalancesPrefix) accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1)) pageRes, err := query.Paginate(accountStore, request.Pagination, func(key []byte, value []byte) error { - var amount sdk.Int + var amount math.Int err := amount.Unmarshal(value) if err != nil { return err diff --git a/types/simulation/rand_util.go b/types/simulation/rand_util.go index cc62fd7e89fd..464b88cc1197 100644 --- a/types/simulation/rand_util.go +++ b/types/simulation/rand_util.go @@ -42,13 +42,13 @@ func RandStringOfLength(r *rand.Rand, n int) string { // RandPositiveInt get a rand positive math.Int func RandPositiveInt(r *rand.Rand, max math.Int) (math.Int, error) { - if !max.GTE(sdk.OneInt()) { + if !max.GTE(math.OneInt()) { return math.Int{}, errors.New("max too small") } - max = max.Sub(sdk.OneInt()) + max = max.Sub(math.OneInt()) - return sdk.NewIntFromBigInt(new(big.Int).Rand(r, max.BigInt())).Add(sdk.OneInt()), nil + return sdk.NewIntFromBigInt(new(big.Int).Rand(r, max.BigInt())).Add(math.OneInt()), nil } // RandomAmount generates a random amount diff --git a/x/README.md b/x/README.md index 9ae681208c59..e4e2cf8d240b 100644 --- a/x/README.md +++ b/x/README.md @@ -21,6 +21,7 @@ Here are some production-grade modules that can be used in Cosmos SDK applicatio * [Slashing](slashing/spec/README.md) - Validator punishment mechanisms. * [Staking](staking/spec/README.md) - Proof-of-Stake layer for public blockchains. * [Upgrade](upgrade/spec/README.md) - Software upgrades handling and coordination. +* [Nft](nft/spec/README.md) - NFT module implemented based on [ADR43](https://docs.cosmos.network/master/architecture/adr-043-nft-module.html). To learn more about the process of building modules, visit the [building modules reference documentation](../docs/building-modules/README.md). @@ -30,4 +31,4 @@ The IBC module for the SDK has moved to its [own repository](https://github.com/ ## CosmWasm -The CosmWasm module enables smart contracts, and has its [own repository](https://github.com/CosmWasm/cosmwasm) and [documentation site](https://docs.cosmwasm.com/docs/1.0). \ No newline at end of file +The CosmWasm module enables smart contracts, and has its [own repository](https://github.com/CosmWasm/cosmwasm) and [documentation site](https://docs.cosmwasm.com/docs/1.0). diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index b1327914dff9..397b1ae4abdb 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -7,9 +7,7 @@ import ( "strings" "testing" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - + "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -21,32 +19,38 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" - "github.com/cosmos/cosmos-sdk/x/auth/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) // Test that simulate transaction accurately estimates gas cost -func (suite *AnteTestSuite) TestSimulateGasCost() { - suite.SetupTest(false) // reset +func TestSimulateGasCost(t *testing.T) { + // This test has a test case that uses another's output. + var simulatedGas uint64 - // Same data for every test cases - accounts := suite.CreateTestAccounts(3) - msgs := []sdk.Msg{ - testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()), - testdata.NewTestMsg(accounts[2].acc.GetAddress(), accounts[0].acc.GetAddress()), - testdata.NewTestMsg(accounts[1].acc.GetAddress(), accounts[2].acc.GetAddress()), - } + // Same data for every test case feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - accSeqs := []uint64{0, 0, 0} - privs := []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv} - accNums := []uint64{0, 1, 2} testCases := []TestCase{ { "tx with 150atom fee", - func() { - suite.txBuilder.SetFeeAmount(feeAmount) - suite.txBuilder.SetGasLimit(gasLimit) + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), authtypes.FeeCollectorName, feeAmount).Return(nil) + + msgs := []sdk.Msg{ + testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()), + testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()), + testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[2].acc.GetAddress()), + } + + return TestCaseArgs{ + accNums: []uint64{0, 1, 2}, + accSeqs: []uint64{0, 0, 0}, + feeAmount: feeAmount, + gasLimit: testdata.NewTestGasLimit(), + msgs: msgs, + privs: []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, + } }, true, true, @@ -54,12 +58,23 @@ func (suite *AnteTestSuite) TestSimulateGasCost() { }, { "with previously estimated gas", - func() { - simulatedGas := suite.ctx.GasMeter().GasConsumed() + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), authtypes.FeeCollectorName, feeAmount).Return(nil) + + msgs := []sdk.Msg{ + testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()), + testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()), + testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[2].acc.GetAddress()), + } - accSeqs = []uint64{1, 1, 1} - suite.txBuilder.SetFeeAmount(feeAmount) - suite.txBuilder.SetGasLimit(simulatedGas) + return TestCaseArgs{accNums: []uint64{0, 1, 2}, + accSeqs: []uint64{0, 0, 0}, + feeAmount: feeAmount, + gasLimit: simulatedGas, + msgs: msgs, + privs: []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, + } }, false, true, @@ -68,20 +83,22 @@ func (suite *AnteTestSuite) TestSimulateGasCost() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) + args.chainID = suite.ctx.ChainID() + suite.RunTestCase(t, tc, args) - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + // Gather info for the next test case + simulatedGas = suite.ctx.GasMeter().GasConsumed() }) } } // Test various error cases in the AnteHandler control flow. -func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { - suite.SetupTest(false) // reset - - // Same data for every test cases +func TestAnteHandlerSigErrors(t *testing.T) { + // This test requires the accounts to not be set, so we create them here priv0, _, addr0 := testdata.KeyTestPubAddr() priv1, _, addr1 := testdata.KeyTestPubAddr() priv2, _, addr2 := testdata.KeyTestPubAddr() @@ -89,29 +106,28 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { testdata.NewTestMsg(addr0, addr1), testdata.NewTestMsg(addr0, addr2), } - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - - // Variable data per test case - var ( - privs []cryptotypes.PrivKey - accNums []uint64 - accSeqs []uint64 - ) testCases := []TestCase{ { "check no signatures fails", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{}, []uint64{}, []uint64{} + func(suite *AnteTestSuite) TestCaseArgs { + privs, accNums, accSeqs := []cryptotypes.PrivKey{}, []uint64{}, []uint64{} // Create tx manually to test the tx's signers - suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + require.NoError(t, suite.txBuilder.SetMsgs(msgs...)) tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) + // tx.GetSigners returns addresses in correct order: addr1, addr2, addr3 expectedSigners := []sdk.AccAddress{addr0, addr1, addr2} - suite.Require().Equal(expectedSigners, tx.GetSigners()) + require.Equal(t, expectedSigners, tx.GetSigners()) + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, false, @@ -119,8 +135,15 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { }, { "num sigs dont match GetSigners", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} + func(suite *AnteTestSuite) TestCaseArgs { + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, false, @@ -128,8 +151,15 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { }, { "unrecognized account", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{priv0, priv1, priv2}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + func(suite *AnteTestSuite) TestCaseArgs { + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0, priv1, priv2}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, false, @@ -137,55 +167,76 @@ func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { }, { "save the first account, but second is still unrecognized", - func() { - acc1 := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr0) - suite.accountKeeper.SetAccount(suite.ctx, acc1) - err := suite.bankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, feeAmount) - suite.Require().NoError(err) - err = suite.bankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr0, feeAmount) - suite.Require().NoError(err) + func(suite *AnteTestSuite) TestCaseArgs { + suite.accountKeeper.SetAccount(suite.ctx, suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr0)) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0, priv1, priv2}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, false, sdkerrors.ErrUnknownAddress, }, + { + "save all the accounts, should pass", + func(suite *AnteTestSuite) TestCaseArgs { + suite.accountKeeper.SetAccount(suite.ctx, suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr0)) + suite.accountKeeper.SetAccount(suite.ctx, suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr1)) + suite.accountKeeper.SetAccount(suite.ctx, suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr2)) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0, priv1, priv2}, []uint64{1, 2, 3}, []uint64{0, 0, 0} + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } + }, + false, + true, + nil, + }, } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) + args.chainID = suite.ctx.ChainID() + args.feeAmount = testdata.NewTestFeeAmount() + args.gasLimit = testdata.NewTestGasLimit() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(t, tc, args) }) } } // Test logic around account number checking with one signer and many signers. -func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { - suite.SetupTest(false) // reset - - // Same data for every test cases - accounts := suite.CreateTestAccounts(2) - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - - // Variable data per test case - var ( - accNums []uint64 - msgs []sdk.Msg - privs []cryptotypes.PrivKey - accSeqs []uint64 - ) - +func TestAnteHandlerAccountNumbers(t *testing.T) { testCases := []TestCase{ { "good tx from one signer", - func() { - msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) - msgs = []sdk.Msg{msg} - - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + msgs: []sdk.Msg{msg}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, true, @@ -193,29 +244,36 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { }, { "new tx from wrong account number", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{1}, + accSeqs: []uint64{0}, + msgs: []sdk.Msg{msg}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, sdkerrors.ErrUnauthorized, }, - { - "new tx from correct account number", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} - }, - false, - true, - nil, - }, { "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, 0}, []uint64{2, 0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{2, 0}, + accSeqs: []uint64{0, 0}, + msgs: []sdk.Msg{msg1, msg2}, + privs: []cryptotypes.PrivKey{accs[0].priv, accs[1].priv}, + } }, false, false, @@ -223,8 +281,18 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { }, { "new tx with correct account numbers", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{2, 0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0, 1}, + accSeqs: []uint64{0, 0}, + msgs: []sdk.Msg{msg1, msg2}, + privs: []cryptotypes.PrivKey{accs[0].priv, accs[1].priv}, + } }, false, true, @@ -233,41 +301,34 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() - - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) + args := tc.malleate(suite) + args.feeAmount = testdata.NewTestFeeAmount() + args.gasLimit = testdata.NewTestGasLimit() + args.chainID = suite.ctx.ChainID() + + suite.RunTestCase(t, tc, args) }) } } // 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) - - // Same data for every test cases - accounts := suite.CreateTestAccounts(2) - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - - // Variable data per test case - var ( - accNums []uint64 - msgs []sdk.Msg - privs []cryptotypes.PrivKey - accSeqs []uint64 - ) - +func TestAnteHandlerAccountNumbersAtBlockHeightZero(t *testing.T) { testCases := []TestCase{ { "good tx from one signer", - func() { - msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) - msgs = []sdk.Msg{msg} - - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + msgs: []sdk.Msg{msg}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, true, @@ -275,30 +336,37 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { }, { "new tx from wrong account number", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{1} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{1}, // wrong account number + accSeqs: []uint64{0}, + msgs: []sdk.Msg{msg}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, sdkerrors.ErrUnauthorized, }, - { - "new tx from correct account number", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} - }, - false, - true, - nil, - }, { "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, 0}, []uint64{2, 0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[0].acc.GetAddress()) + + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{1, 0}, // wrong account numbers + accSeqs: []uint64{0, 0}, + msgs: []sdk.Msg{msg1, msg2}, + privs: []cryptotypes.PrivKey{accs[0].priv, accs[1].priv}, + } }, false, false, @@ -306,9 +374,19 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { }, { "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} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[0].acc.GetAddress()) + + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0, 0}, // correct account numbers + accSeqs: []uint64{0, 0}, + msgs: []sdk.Msg{msg1, msg2}, + privs: []cryptotypes.PrivKey{accs[0].priv, accs[1].priv}, + } }, false, true, @@ -317,40 +395,40 @@ func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) + suite.ctx = suite.ctx.WithBlockHeight(0) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + args := tc.malleate(suite) + args.feeAmount = testdata.NewTestFeeAmount() + args.gasLimit = testdata.NewTestGasLimit() + + suite.RunTestCase(t, tc, args) }) } } // Test logic around sequence checking with one signer and many signers. -func (suite *AnteTestSuite) TestAnteHandlerSequences() { - suite.SetupTest(false) // setup - +func TestAnteHandlerSequences(t *testing.T) { // Same data for every test cases - accounts := suite.CreateTestAccounts(3) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - // Variable data per test case - var ( - accNums []uint64 - msgs []sdk.Msg - privs []cryptotypes.PrivKey - accSeqs []uint64 - ) - testCases := []TestCase{ { "good tx from one signer", - func() { - msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) - msgs = []sdk.Msg{msg} - - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + msgs: []sdk.Msg{msg}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, true, @@ -358,8 +436,26 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { }, { "test sending it again fails (replay protection)", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) + msgs := []sdk.Msg{msg} + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv}, []uint64{0}, []uint64{0} + + // This will be called only once given that the second tx will fail + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + + // Send the same tx before running the test case, to trigger replay protection. + var err error + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.NoError(t, err) + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, false, @@ -367,8 +463,28 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { }, { "fix sequence, should pass", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{1} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) + msgs := []sdk.Msg{msg} + + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv}, []uint64{0}, []uint64{0} + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + + // Send the same tx before running the test case, then change the sequence to a valid one. + var err error + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.NoError(t, err) + + // +1 the account sequence + accSeqs = []uint64{1} + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, true, @@ -376,12 +492,19 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { }, { "new tx with another signer and correct sequences", - func() { - msg1 := testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()) - msg2 := testdata.NewTestMsg(accounts[2].acc.GetAddress(), accounts[0].acc.GetAddress()) - msgs = []sdk.Msg{msg1, msg2} - - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{2, 0, 0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()) + + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0, 1, 2}, + accSeqs: []uint64{0, 0, 0}, + msgs: []sdk.Msg{msg1, msg2}, + privs: []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, + } }, false, true, @@ -389,17 +512,59 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { }, { "replay fails", - func() {}, + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()) + msgs := []sdk.Msg{msg1, msg2} + + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + + // Send the same tx before running the test case, to trigger replay protection. + var err error + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.NoError(t, err) + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: []sdk.Msg{msg1, msg2}, + privs: privs, + } + }, false, false, sdkerrors.ErrWrongSequence, }, { "tx from just second signer with incorrect sequence fails", - func() { - msg := testdata.NewTestMsg(accounts[1].acc.GetAddress()) - msgs = []sdk.Msg{msg} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()) + msgs := []sdk.Msg{msg1, msg2} + + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + + // Send the same tx before running the test case, to trigger replay protection. + var err error + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.NoError(t, err) + + // Send a message using the second signer, this will fail given that the second signer already sent a TX, + // thus the sequence (0) is incorrect. + msg1 = testdata.NewTestMsg(accs[1].acc.GetAddress()) + msgs = []sdk.Msg{msg1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[1].priv}, []uint64{1}, []uint64{0} + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, false, @@ -407,20 +572,32 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { }, { "fix the sequence and it passes", - func() { - accSeqs = []uint64{1} - }, - false, - true, - nil, - }, - { - "fix the sequence and it passes", - func() { - msg := testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()) - msgs = []sdk.Msg{msg} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()) + msgs := []sdk.Msg{msg1, msg2} + + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + + // Send the same tx before running the test case, to trigger replay protection. + var err error + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.NoError(t, err) + + // Send a message using the second signer, this will now pass given that the second signer already sent a TX + // and the sequence was fixed (1). + msg1 = testdata.NewTestMsg(accs[1].acc.GetAddress()) + msgs = []sdk.Msg{msg1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[1].priv}, []uint64{1}, []uint64{1} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{3, 2} + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, true, @@ -429,117 +606,89 @@ func (suite *AnteTestSuite) TestAnteHandlerSequences() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) + args.feeAmount = feeAmount + args.gasLimit = gasLimit - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(t, tc, args) }) } } // Test logic around fee deduction. -func (suite *AnteTestSuite) TestAnteHandlerFees() { - suite.SetupTest(false) // setup - +func TestAnteHandlerFees(t *testing.T) { // Same data for every test cases - priv0, _, addr0 := testdata.KeyTestPubAddr() - - acc1 := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr0) - suite.accountKeeper.SetAccount(suite.ctx, acc1) - msgs := []sdk.Msg{testdata.NewTestMsg(addr0)} feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} - testCases := []struct { - desc string - malleate func() - simulate bool - expPass bool - expErr error - }{ + testCases := []TestCase{ { "signer has no funds", - func() { - accSeqs = []uint64{0} - }, - false, - false, - sdkerrors.ErrInsufficientFunds, - }, - { - "signer does not have enough funds to pay the fee", - func() { - err := testutil.FundAccount(suite.bankKeeper, suite.ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 149))) - suite.Require().NoError(err) + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), gomock.Any(), feeAmount).Return(sdkerrors.ErrInsufficientFunds) + + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, sdkerrors.ErrInsufficientFunds, }, { - "signer as enough funds, should pass", - func() { - accNums = []uint64{acc1.GetAccountNumber()} - - modAcc := suite.accountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName) - - suite.Require().True(suite.bankKeeper.GetAllBalances(suite.ctx, modAcc.GetAddress()).Empty()) - require.True(sdk.IntEq(suite.T(), suite.bankKeeper.GetAllBalances(suite.ctx, addr0).AmountOf("atom"), sdk.NewInt(149))) - - err := testutil.FundAccount(suite.bankKeeper, suite.ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 1))) - suite.Require().NoError(err) + "signer has enough funds, should pass", + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), gomock.Any(), feeAmount).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, true, nil, }, - { - "signer doesn't have any more funds", - func() { - modAcc := suite.accountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName) - - require.True(sdk.IntEq(suite.T(), suite.bankKeeper.GetAllBalances(suite.ctx, modAcc.GetAddress()).AmountOf("atom"), sdk.NewInt(150))) - require.True(sdk.IntEq(suite.T(), suite.bankKeeper.GetAllBalances(suite.ctx, addr0).AmountOf("atom"), sdk.NewInt(0))) - }, - false, - false, - sdkerrors.ErrInsufficientFunds, - }, } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) + args.feeAmount = feeAmount + args.gasLimit = gasLimit - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(t, tc, args) }) } } // Test logic around memo gas consumption. -func (suite *AnteTestSuite) TestAnteHandlerMemoGas() { - suite.SetupTest(false) // setup - - // Same data for every test cases - accounts := suite.CreateTestAccounts(1) - msgs := []sdk.Msg{testdata.NewTestMsg(accounts[0].acc.GetAddress())} - privs, accNums, accSeqs := []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} - - // Variable data per test case - var ( - feeAmount sdk.Coins - gasLimit uint64 - ) - +func TestAnteHandlerMemoGas(t *testing.T) { testCases := []TestCase{ { "tx does not have enough gas", - func() { - feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) - gasLimit = 0 + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + feeAmount: sdk.NewCoins(sdk.NewInt64Coin("atom", 0)), + gasLimit: 0, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, @@ -547,10 +696,18 @@ func (suite *AnteTestSuite) TestAnteHandlerMemoGas() { }, { "tx with memo doesn't have enough gas", - func() { - feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) - gasLimit = 801 + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) suite.txBuilder.SetMemo("abcininasidniandsinasindiansdiansdinaisndiasndiadninsd") + + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + feeAmount: sdk.NewCoins(sdk.NewInt64Coin("atom", 0)), + gasLimit: 801, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, @@ -558,10 +715,18 @@ func (suite *AnteTestSuite) TestAnteHandlerMemoGas() { }, { "memo too large", - func() { - feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) - gasLimit = 50000 + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) suite.txBuilder.SetMemo(strings.Repeat("01234567890", 500)) + + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + feeAmount: sdk.NewCoins(sdk.NewInt64Coin("atom", 0)), + gasLimit: 50000, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, @@ -569,10 +734,17 @@ func (suite *AnteTestSuite) TestAnteHandlerMemoGas() { }, { "tx with memo has enough gas", - func() { - feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) - gasLimit = 60000 + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) suite.txBuilder.SetMemo(strings.Repeat("0123456789", 10)) + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + feeAmount: sdk.NewCoins(sdk.NewInt64Coin("atom", 0)), + gasLimit: 60000, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, true, @@ -581,41 +753,37 @@ func (suite *AnteTestSuite) TestAnteHandlerMemoGas() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(t, tc, args) }) } } -func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { - suite.SetupTest(false) // setup - - // Same data for every test cases - accounts := suite.CreateTestAccounts(3) - msg1 := testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()) - msg2 := testdata.NewTestMsg(accounts[2].acc.GetAddress(), accounts[0].acc.GetAddress()) - msg3 := testdata.NewTestMsg(accounts[1].acc.GetAddress(), accounts[2].acc.GetAddress()) +func TestAnteHandlerMultiSigner(t *testing.T) { feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - // Variable data per test case - var ( - accNums []uint64 - msgs []sdk.Msg - privs []cryptotypes.PrivKey - accSeqs []uint64 - ) - testCases := []TestCase{ { "signers in order", - func() { - msgs = []sdk.Msg{msg1, msg2, msg3} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()) + msg3 := testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[2].acc.GetAddress()) suite.txBuilder.SetMemo("Check signers are in expected order and different account numbers works") + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0, 1, 2}, + accSeqs: []uint64{0, 0, 0}, + msgs: []sdk.Msg{msg1, msg2, msg3}, + privs: []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, + } }, false, true, @@ -623,9 +791,29 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { }, { "change sequence numbers (only accounts 0 and 1 sign)", - func() { + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()) + msg3 := testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[2].acc.GetAddress()) + msgs := []sdk.Msg{msg1, msg2, msg3} + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + + var err error + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.NoError(t, err) + msgs = []sdk.Msg{msg1} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv}, []uint64{0, 1}, []uint64{1, 1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[0].priv, accs[1].priv}, []uint64{0, 1}, []uint64{1, 1} + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, true, @@ -633,9 +821,28 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { }, { "change sequence numbers (only accounts 1 and 2 sign)", - func() { - msgs = []sdk.Msg{msg2} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[2].priv, accounts[0].priv}, []uint64{2, 0}, []uint64{1, 2} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()) + msg3 := testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[2].acc.GetAddress()) + msgs := []sdk.Msg{msg1, msg2, msg3} + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + var err error + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.NoError(t, err) + + msgs = []sdk.Msg{msg3} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[1].priv, accs[2].priv}, []uint64{1, 2}, []uint64{1, 1} + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, true, @@ -643,9 +850,27 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { }, { "everyone signs again", - func() { - msgs = []sdk.Msg{msg1, msg2, msg3} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{3, 2, 2} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(3) + msg1 := testdata.NewTestMsg(accs[0].acc.GetAddress(), accs[1].acc.GetAddress()) + msg2 := testdata.NewTestMsg(accs[2].acc.GetAddress(), accs[0].acc.GetAddress()) + msg3 := testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[2].acc.GetAddress()) + msgs := []sdk.Msg{msg1, msg2, msg3} + + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} + + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + var err error + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.NoError(t, err) + + privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{1, 1, 1} + + return TestCaseArgs{accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, true, @@ -654,42 +879,40 @@ func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) + args.feeAmount = feeAmount + args.gasLimit = gasLimit + args.chainID = suite.ctx.ChainID() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(t, tc, args) }) } } -func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { - suite.SetupTest(false) // setup - - // Same data for every test cases - accounts := suite.CreateTestAccounts(2) - msg0 := testdata.NewTestMsg(accounts[0].acc.GetAddress()) - - // Variable data per test case - var ( - accNums []uint64 - chainID string - feeAmount sdk.Coins - gasLimit uint64 - msgs []sdk.Msg - privs []cryptotypes.PrivKey - accSeqs []uint64 - ) +func TestAnteHandlerBadSignBytes(t *testing.T) { + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() testCases := []TestCase{ { "test good tx and signBytes", - func() { - chainID = suite.ctx.ChainID() - feeAmount = testdata.NewTestFeeAmount() - gasLimit = testdata.NewTestGasLimit() - msgs = []sdk.Msg{msg0} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg0 := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + chainID: suite.ctx.ChainID(), + accNums: []uint64{0}, + accSeqs: []uint64{0}, + feeAmount: feeAmount, + gasLimit: gasLimit, + msgs: []sdk.Msg{msg0}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, true, @@ -697,9 +920,20 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { }, { "test wrong chainID", - func() { - accSeqs = []uint64{1} // Back to correct accSeqs - chainID = "chain-foo" + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg0 := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + chainID: "wrong-chain-id", + accNums: []uint64{0}, + accSeqs: []uint64{0}, + feeAmount: feeAmount, + gasLimit: gasLimit, + msgs: []sdk.Msg{msg0}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, @@ -707,9 +941,20 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { }, { "test wrong accSeqs", - func() { - chainID = suite.ctx.ChainID() // Back to correct chainID - accSeqs = []uint64{2} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg0 := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + chainID: suite.ctx.ChainID(), + accNums: []uint64{0}, + accSeqs: []uint64{2}, //wrong accSeq + feeAmount: feeAmount, + gasLimit: gasLimit, + msgs: []sdk.Msg{msg0}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, @@ -717,9 +962,20 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { }, { "test wrong accNums", - func() { - accSeqs = []uint64{1} // Back to correct accSeqs - accNums = []uint64{1} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + msg0 := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + chainID: suite.ctx.ChainID(), + accNums: []uint64{1}, // wrong accNum + accSeqs: []uint64{0}, + feeAmount: feeAmount, + gasLimit: gasLimit, + msgs: []sdk.Msg{msg0}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, @@ -727,41 +983,41 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { }, { "test wrong msg", - func() { - msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + chainID: suite.ctx.ChainID(), + accNums: []uint64{0}, + accSeqs: []uint64{0}, + feeAmount: feeAmount, + gasLimit: gasLimit, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[1].acc.GetAddress())}, // wrong account in the msg + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, sdkerrors.ErrInvalidPubKey, }, - { - "test wrong fee gas", - func() { - msgs = []sdk.Msg{msg0} // Back to correct msgs - feeAmount = testdata.NewTestFeeAmount() - gasLimit = testdata.NewTestGasLimit() + 100 - }, - false, - false, - sdkerrors.ErrUnauthorized, - }, - { - "test wrong fee amount", - func() { - feeAmount = testdata.NewTestFeeAmount() - feeAmount[0].Amount = feeAmount[0].Amount.AddRaw(100) - gasLimit = testdata.NewTestGasLimit() - }, - false, - false, - sdkerrors.ErrUnauthorized, - }, { "test wrong signer if public key exist", - func() { - feeAmount = testdata.NewTestFeeAmount() - gasLimit = testdata.NewTestGasLimit() - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{0}, []uint64{1} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + msg0 := testdata.NewTestMsg(accs[0].acc.GetAddress()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + chainID: suite.ctx.ChainID(), + accNums: []uint64{0}, + accSeqs: []uint64{0}, + feeAmount: feeAmount, + gasLimit: gasLimit, + msgs: []sdk.Msg{msg0}, + privs: []cryptotypes.PrivKey{accs[1].priv}, + } + }, false, false, @@ -769,9 +1025,19 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { }, { "test wrong signer if public doesn't exist", - func() { - msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{1}, []uint64{0} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + chainID: suite.ctx.ChainID(), + accNums: []uint64{1}, + accSeqs: []uint64{0}, + feeAmount: feeAmount, + gasLimit: gasLimit, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[1].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, @@ -780,37 +1046,33 @@ func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, chainID, tc) + suite.RunTestCase(t, tc, args) }) } } -func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { - suite.SetupTest(false) // setup - - // Same data for every test cases - accounts := suite.CreateTestAccounts(2) +func TestAnteHandlerSetPubKey(t *testing.T) { feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - // Variable data per test case - var ( - accNums []uint64 - msgs []sdk.Msg - privs []cryptotypes.PrivKey - accSeqs []uint64 - ) - testCases := []TestCase{ { "test good tx", - func() { - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} - msgs = []sdk.Msg{testdata.NewTestMsg(accounts[0].acc.GetAddress())} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, true, @@ -818,10 +1080,26 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { }, { "make sure public key has been set (tx itself should fail because of replay protection)", - func() { + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(1) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv}, []uint64{0}, []uint64{0} + msgs := []sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())} + var err error + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.NoError(t, err) + // Make sure public key has been set from previous test. - acc0 := suite.accountKeeper.GetAccount(suite.ctx, accounts[0].acc.GetAddress()) - suite.Require().Equal(acc0.GetPubKey(), accounts[0].priv.PubKey()) + acc0 := suite.accountKeeper.GetAccount(suite.ctx, accs[0].acc.GetAddress()) + require.Equal(t, acc0.GetPubKey(), accs[0].priv.PubKey()) + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, false, @@ -829,9 +1107,15 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { }, { "test public key not found", - func() { - // See above, `privs` still holds the private key of accounts[0]. - msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[1].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, // wrong signer + } }, false, false, @@ -839,35 +1123,45 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { }, { "make sure public key is not set, when tx has no pubkey or signature", - func() { + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + // Make sure public key has not been set from previous test. - acc1 := suite.accountKeeper.GetAccount(suite.ctx, accounts[1].acc.GetAddress()) - suite.Require().Nil(acc1.GetPubKey()) + acc1 := suite.accountKeeper.GetAccount(suite.ctx, accs[1].acc.GetAddress()) + require.Nil(t, acc1.GetPubKey()) - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0} - msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[1].priv}, []uint64{1}, []uint64{0} + msgs := []sdk.Msg{testdata.NewTestMsg(accs[1].acc.GetAddress())} suite.txBuilder.SetMsgs(msgs...) suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) // Manually create tx, and remove signature. tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) txBuilder, err := suite.clientCtx.TxConfig.WrapTxBuilder(tx) - suite.Require().NoError(err) - suite.Require().NoError(txBuilder.SetSignatures()) + require.NoError(t, err) + require.NoError(t, txBuilder.SetSignatures()) // Run anteHandler manually, expect ErrNoSignatures. _, err = suite.anteHandler(suite.ctx, txBuilder.GetTx(), false) - suite.Require().Error(err) - suite.Require().True(errors.Is(err, sdkerrors.ErrNoSignatures)) + require.Error(t, err) + require.True(t, errors.Is(err, sdkerrors.ErrNoSignatures)) // Make sure public key has not been set. - acc1 = suite.accountKeeper.GetAccount(suite.ctx, accounts[1].acc.GetAddress()) - suite.Require().Nil(acc1.GetPubKey()) + acc1 = suite.accountKeeper.GetAccount(suite.ctx, accs[1].acc.GetAddress()) + require.Nil(t, acc1.GetPubKey()) // Set incorrect accSeq, to generate incorrect signature. - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{1} + privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[1].priv}, []uint64{1}, []uint64{1} + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, false, @@ -875,11 +1169,54 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { }, { "make sure previous public key has been set after wrong signature", - func() { + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(2) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + // Make sure public key has not been set from previous test. + acc1 := suite.accountKeeper.GetAccount(suite.ctx, accs[1].acc.GetAddress()) + require.Nil(t, acc1.GetPubKey()) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[1].priv}, []uint64{1}, []uint64{0} + msgs := []sdk.Msg{testdata.NewTestMsg(accs[1].acc.GetAddress())} + suite.txBuilder.SetMsgs(msgs...) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + // Manually create tx, and remove signature. + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + require.NoError(t, err) + txBuilder, err := suite.clientCtx.TxConfig.WrapTxBuilder(tx) + require.NoError(t, err) + require.NoError(t, txBuilder.SetSignatures()) + + // Run anteHandler manually, expect ErrNoSignatures. + _, err = suite.anteHandler(suite.ctx, txBuilder.GetTx(), false) + require.Error(t, err) + require.True(t, errors.Is(err, sdkerrors.ErrNoSignatures)) + + // Make sure public key has not been set. + acc1 = suite.accountKeeper.GetAccount(suite.ctx, accs[1].acc.GetAddress()) + require.Nil(t, acc1.GetPubKey()) + + // Set incorrect accSeq, to generate incorrect signature. + privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[1].priv}, []uint64{1}, []uint64{1} + + suite.ctx, err = suite.DeliverMsgs(t, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), false) + require.Error(t, err) + // Make sure public key has been set, as SetPubKeyDecorator // is called before all signature verification decorators. - acc1 := suite.accountKeeper.GetAccount(suite.ctx, accounts[1].acc.GetAddress()) - suite.Require().Equal(acc1.GetPubKey(), accounts[1].priv.PubKey()) + acc1 = suite.accountKeeper.GetAccount(suite.ctx, accs[1].acc.GetAddress()) + require.Equal(t, acc1.GetPubKey(), accs[1].priv.PubKey()) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: accNums, + accSeqs: accSeqs, + msgs: msgs, + privs: privs, + } }, false, false, @@ -888,11 +1225,15 @@ func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) + args.chainID = suite.ctx.ChainID() + args.feeAmount = feeAmount + args.gasLimit = gasLimit - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(t, tc, args) }) } } @@ -924,9 +1265,9 @@ func expectedGasCostByKeys(pubkeys []cryptotypes.PubKey) uint64 { pubkeyType := strings.ToLower(fmt.Sprintf("%T", pubkey)) switch { case strings.Contains(pubkeyType, "ed25519"): - cost += types.DefaultParams().SigVerifyCostED25519 + cost += authtypes.DefaultParams().SigVerifyCostED25519 case strings.Contains(pubkeyType, "secp256k1"): - cost += types.DefaultParams().SigVerifyCostSecp256k1 + cost += authtypes.DefaultParams().SigVerifyCostSecp256k1 default: panic("unexpected key type") } @@ -968,26 +1309,30 @@ func TestCountSubkeys(t *testing.T) { } } -func (suite *AnteTestSuite) TestAnteHandlerSigLimitExceeded() { - suite.SetupTest(false) // setup - - // Same data for every test cases - accounts := suite.CreateTestAccounts(8) - var addrs []sdk.AccAddress - var privs []cryptotypes.PrivKey - for i := 0; i < 8; i++ { - addrs = append(addrs, accounts[i].acc.GetAddress()) - privs = append(privs, accounts[i].priv) - } - msgs := []sdk.Msg{testdata.NewTestMsg(addrs...)} - accNums, accSeqs := []uint64{0, 1, 2, 3, 4, 5, 6, 7}, []uint64{0, 0, 0, 0, 0, 0, 0, 0} - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - +func TestAnteHandlerSigLimitExceeded(t *testing.T) { testCases := []TestCase{ { "test rejection logic", - func() {}, + func(suite *AnteTestSuite) TestCaseArgs { + accs := suite.CreateTestAccounts(8) + var ( + addrs []sdk.AccAddress + privs []cryptotypes.PrivKey + ) + for i := 0; i < 8; i++ { + addrs = append(addrs, accs[i].acc.GetAddress()) + privs = append(privs, accs[i].priv) + } + + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0, 1, 2, 3, 4, 5, 6, 7}, + accSeqs: []uint64{0, 0, 0, 0, 0, 0, 0, 0}, + msgs: []sdk.Msg{testdata.NewTestMsg(addrs...)}, + privs: privs, + } + }, false, false, sdkerrors.ErrTooManySignatures, @@ -995,60 +1340,55 @@ func (suite *AnteTestSuite) TestAnteHandlerSigLimitExceeded() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) + args.chainID = suite.ctx.ChainID() + args.feeAmount = testdata.NewTestFeeAmount() + args.gasLimit = testdata.NewTestGasLimit() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(t, tc, args) }) } } // Test custom SignatureVerificationGasConsumer -func (suite *AnteTestSuite) TestCustomSignatureVerificationGasConsumer() { - suite.SetupTest(false) // setup - - // setup an ante handler that only accepts PubKeyEd25519 - anteHandler, err := ante.NewAnteHandler( - ante.HandlerOptions{ - AccountKeeper: suite.accountKeeper, - BankKeeper: suite.bankKeeper, - FeegrantKeeper: suite.feeGrantKeeper, - SignModeHandler: suite.clientCtx.TxConfig.SignModeHandler(), - SigGasConsumer: 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.Require().NoError(err) - suite.anteHandler = anteHandler - - // Same data for every test cases - accounts := suite.CreateTestAccounts(1) - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - - // Variable data per test case - var ( - accNums []uint64 - msgs []sdk.Msg - privs []cryptotypes.PrivKey - accSeqs []uint64 - ) - +func TestCustomSignatureVerificationGasConsumer(t *testing.T) { testCases := []TestCase{ { "verify that an secp256k1 account gets rejected", - func() { - msgs = []sdk.Msg{testdata.NewTestMsg(accounts[0].acc.GetAddress())} - privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + func(suite *AnteTestSuite) TestCaseArgs { + // setup an ante handler that only accepts PubKeyEd25519 + anteHandler, err := ante.NewAnteHandler( + ante.HandlerOptions{ + AccountKeeper: suite.accountKeeper, + BankKeeper: suite.bankKeeper, + FeegrantKeeper: suite.feeGrantKeeper, + SignModeHandler: suite.clientCtx.TxConfig.SignModeHandler(), + SigGasConsumer: func(meter sdk.GasMeter, sig signing.SignatureV2, params authtypes.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) + } + }, + }, + ) + require.NoError(t, err) + suite.anteHandler = anteHandler + + accs := suite.CreateTestAccounts(1) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) + + return TestCaseArgs{ + accNums: []uint64{0}, + accSeqs: []uint64{0}, + msgs: []sdk.Msg{testdata.NewTestMsg(accs[0].acc.GetAddress())}, + privs: []cryptotypes.PrivKey{accs[0].priv}, + } }, false, false, @@ -1057,77 +1397,85 @@ func (suite *AnteTestSuite) TestCustomSignatureVerificationGasConsumer() { } for _, tc := range testCases { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + t.Run(fmt.Sprintf("Case %s", tc.desc), func(t *testing.T) { + suite := SetupTestSuite(t, false) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - tc.malleate() + args := tc.malleate(suite) + args.chainID = suite.ctx.ChainID() + args.feeAmount = testdata.NewTestFeeAmount() + args.gasLimit = testdata.NewTestGasLimit() - suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) + suite.RunTestCase(t, tc, args) }) } } -func (suite *AnteTestSuite) TestAnteHandlerReCheck() { - suite.SetupTest(false) // setup +func TestAnteHandlerReCheck(t *testing.T) { + suite := SetupTestSuite(t, false) // Set recheck=true suite.ctx = suite.ctx.WithIsReCheckTx(true) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - // Same data for every test cases - accounts := suite.CreateTestAccounts(1) + // Same data for every test case + accs := suite.CreateTestAccounts(1) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) - msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) msgs := []sdk.Msg{msg} - suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + require.NoError(t, suite.txBuilder.SetMsgs(msgs...)) suite.txBuilder.SetMemo("thisisatestmemo") // test that operations skipped on recheck do not run - privs, accNums, accSeqs := []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) // make signature array empty which would normally cause ValidateBasicDecorator and SigVerificationDecorator fail // since these decorators don't run on recheck, the tx should pass the antehandler txBuilder, err := suite.clientCtx.TxConfig.WrapTxBuilder(tx) - suite.Require().NoError(err) + require.NoError(t, err) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil).Times(2) _, err = suite.anteHandler(suite.ctx, txBuilder.GetTx(), false) - suite.Require().Nil(err, "AnteHandler errored on recheck unexpectedly: %v", err) + require.Nil(t, err, "AnteHandler errored on recheck unexpectedly: %v", err) tx, err = suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) txBytes, err := json.Marshal(tx) - suite.Require().Nil(err, "Error marshalling tx: %v", err) + require.Nil(t, err, "Error marshalling tx: %v", err) suite.ctx = suite.ctx.WithTxBytes(txBytes) // require that state machine param-dependent checking is still run on recheck since parameters can change between check and recheck testCases := []struct { name string - params types.Params + params authtypes.Params }{ - {"memo size check", types.NewParams(1, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1)}, - {"txsize check", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, 10000000, types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1)}, - {"sig verify cost check", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, types.DefaultSigVerifyCostED25519, 100000000)}, + {"memo size check", authtypes.NewParams(1, authtypes.DefaultTxSigLimit, authtypes.DefaultTxSizeCostPerByte, authtypes.DefaultSigVerifyCostED25519, authtypes.DefaultSigVerifyCostSecp256k1)}, + {"txsize check", authtypes.NewParams(authtypes.DefaultMaxMemoCharacters, authtypes.DefaultTxSigLimit, 10000000, authtypes.DefaultSigVerifyCostED25519, authtypes.DefaultSigVerifyCostSecp256k1)}, + {"sig verify cost check", authtypes.NewParams(authtypes.DefaultMaxMemoCharacters, authtypes.DefaultTxSigLimit, authtypes.DefaultTxSizeCostPerByte, authtypes.DefaultSigVerifyCostED25519, 100000000)}, } + for _, tc := range testCases { + // set testcase parameters err := suite.accountKeeper.SetParams(suite.ctx, tc.params) - suite.Require().NoError(err) + require.NoError(t, err) _, err = suite.anteHandler(suite.ctx, tx, false) - suite.Require().NotNil(err, "tx does not fail on recheck with updated params in test case: %s", tc.name) + require.NotNil(t, err, "tx does not fail on recheck with updated params in test case: %s", tc.name) // reset parameters to default values - err = suite.accountKeeper.SetParams(suite.ctx, types.DefaultParams()) - suite.Require().NoError(err) + err = suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams()) + require.NoError(t, err) } + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(sdkerrors.ErrInsufficientFee) // require that local mempool fee check is still run on recheck since validator may change minFee between check and recheck // create new minimum gas price so antehandler fails on recheck suite.ctx = suite.ctx.WithMinGasPrices([]sdk.DecCoin{{ @@ -1135,16 +1483,13 @@ func (suite *AnteTestSuite) TestAnteHandlerReCheck() { Amount: sdk.NewDec(5), }}) _, err = suite.anteHandler(suite.ctx, tx, false) - suite.Require().NotNil(err, "antehandler on recheck did not fail when mingasPrice was changed") + require.NotNil(t, err, "antehandler on recheck did not fail when mingasPrice was changed") // reset min gasprice suite.ctx = suite.ctx.WithMinGasPrices(sdk.DecCoins{}) // remove funds for account so antehandler fails on recheck - suite.accountKeeper.SetAccount(suite.ctx, accounts[0].acc) - balances := suite.bankKeeper.GetAllBalances(suite.ctx, accounts[0].acc.GetAddress()) - err = suite.bankKeeper.SendCoinsFromAccountToModule(suite.ctx, accounts[0].acc.GetAddress(), minttypes.ModuleName, balances) - suite.Require().NoError(err) + suite.accountKeeper.SetAccount(suite.ctx, accs[0].acc) _, err = suite.anteHandler(suite.ctx, tx, false) - suite.Require().NotNil(err, "antehandler on recheck did not fail once feePayer no longer has sufficient funds") + require.NotNil(t, err, "antehandler on recheck did not fail once feePayer no longer has sufficient funds") } diff --git a/x/auth/ante/basic_test.go b/x/auth/ante/basic_test.go index 11e57f1ebdcb..8bf7b7abbb16 100644 --- a/x/auth/ante/basic_test.go +++ b/x/auth/ante/basic_test.go @@ -2,17 +2,20 @@ package ante_test import ( "strings" + "testing" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" + "github.com/stretchr/testify/require" ) -func (suite *AnteTestSuite) TestValidateBasic() { - suite.SetupTest(true) // setup +func TestValidateBasic(t *testing.T) { + suite := SetupTestSuite(t, true) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // keys and addresses @@ -22,26 +25,26 @@ func (suite *AnteTestSuite) TestValidateBasic() { msg := testdata.NewTestMsg(addr1) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + require.NoError(t, suite.txBuilder.SetMsgs(msg)) suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) privs, accNums, accSeqs := []cryptotypes.PrivKey{}, []uint64{}, []uint64{} invalidTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) vbd := ante.NewValidateBasicDecorator() antehandler := sdk.ChainAnteDecorators(vbd) _, err = antehandler(suite.ctx, invalidTx, false) - suite.Require().NotNil(err, "Did not error on invalid tx") + require.ErrorIs(t, err, sdkerrors.ErrNoSignatures, "Did not error on invalid tx") privs, accNums, accSeqs = []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} validTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) _, err = antehandler(suite.ctx, validTx, false) - suite.Require().Nil(err, "ValidateBasicDecorator returned error on valid tx. err: %v", err) + require.Nil(t, err, "ValidateBasicDecorator returned error on valid tx. err: %v", err) // test decorator skips on recheck suite.ctx = suite.ctx.WithIsReCheckTx(true) @@ -49,11 +52,11 @@ func (suite *AnteTestSuite) TestValidateBasic() { // decorator should skip processing invalidTx on recheck and thus return nil-error _, err = antehandler(suite.ctx, invalidTx, false) - suite.Require().Nil(err, "ValidateBasicDecorator ran on ReCheck") + require.Nil(t, err, "ValidateBasicDecorator ran on ReCheck") } -func (suite *AnteTestSuite) TestValidateMemo() { - suite.SetupTest(true) // setup +func TestValidateMemo(t *testing.T) { + suite := SetupTestSuite(t, true) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // keys and addresses @@ -63,33 +66,33 @@ func (suite *AnteTestSuite) TestValidateMemo() { msg := testdata.NewTestMsg(addr1) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + require.NoError(t, suite.txBuilder.SetMsgs(msg)) suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} suite.txBuilder.SetMemo(strings.Repeat("01234567890", 500)) invalidTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) // require that long memos get rejected vmd := ante.NewValidateMemoDecorator(suite.accountKeeper) antehandler := sdk.ChainAnteDecorators(vmd) _, err = antehandler(suite.ctx, invalidTx, false) - suite.Require().NotNil(err, "Did not error on tx with high memo") + require.ErrorIs(t, err, sdkerrors.ErrMemoTooLarge, "Did not error on tx with high memo") suite.txBuilder.SetMemo(strings.Repeat("01234567890", 10)) validTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) // require small memos pass ValidateMemo Decorator _, err = antehandler(suite.ctx, validTx, false) - suite.Require().Nil(err, "ValidateBasicDecorator returned error on valid tx. err: %v", err) + require.Nil(t, err, "ValidateBasicDecorator returned error on valid tx. err: %v", err) } -func (suite *AnteTestSuite) TestConsumeGasForTxSize() { - suite.SetupTest(true) // setup +func TestConsumeGasForTxSize(t *testing.T) { + suite := SetupTestSuite(t, true) // keys and addresses priv1, _, addr1 := testdata.KeyTestPubAddr() @@ -111,19 +114,19 @@ func (suite *AnteTestSuite) TestConsumeGasForTxSize() { } for _, tc := range testCases { - suite.Run(tc.name, func() { + t.Run(tc.name, func(t *testing.T) { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + require.NoError(t, suite.txBuilder.SetMsgs(msg)) suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) suite.txBuilder.SetMemo(strings.Repeat("01234567890", 10)) privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) txBytes, err := suite.clientCtx.TxConfig.TxJSONEncoder()(tx) - suite.Require().Nil(err, "Cannot marshal tx: %v", err) + require.Nil(t, err, "Cannot marshal tx: %v", err) params := suite.accountKeeper.GetParams(suite.ctx) expectedGas := sdk.Gas(len(txBytes)) * params.TxSizeCostPerByte @@ -139,22 +142,22 @@ func (suite *AnteTestSuite) TestConsumeGasForTxSize() { beforeGas = suite.ctx.GasMeter().GasConsumed() suite.ctx, err = antehandler(suite.ctx, tx, false) - suite.Require().Nil(err, "ConsumeTxSizeGasDecorator returned error: %v", err) + require.Nil(t, err, "ConsumeTxSizeGasDecorator returned error: %v", err) // require that decorator consumes expected amount of gas consumedGas := suite.ctx.GasMeter().GasConsumed() - beforeGas - suite.Require().Equal(expectedGas, consumedGas, "Decorator did not consume the correct amount of gas") + require.Equal(t, expectedGas, consumedGas, "Decorator did not consume the correct amount of gas") // simulation must not underestimate gas of this decorator even with nil signatures txBuilder, err := suite.clientCtx.TxConfig.WrapTxBuilder(tx) - suite.Require().NoError(err) - suite.Require().NoError(txBuilder.SetSignatures(tc.sigV2)) + require.NoError(t, err) + require.NoError(t, txBuilder.SetSignatures(tc.sigV2)) tx = txBuilder.GetTx() simTxBytes, err := suite.clientCtx.TxConfig.TxJSONEncoder()(tx) - suite.Require().Nil(err, "Cannot marshal tx: %v", err) + require.Nil(t, err, "Cannot marshal tx: %v", err) // require that simulated tx is smaller than tx with signatures - suite.Require().True(len(simTxBytes) < len(txBytes), "simulated tx still has signatures") + require.True(t, len(simTxBytes) < len(txBytes), "simulated tx still has signatures") // Set suite.ctx with smaller simulated TxBytes manually suite.ctx = suite.ctx.WithTxBytes(simTxBytes) @@ -166,14 +169,14 @@ func (suite *AnteTestSuite) TestConsumeGasForTxSize() { consumedSimGas := suite.ctx.GasMeter().GasConsumed() - beforeSimGas // require that antehandler passes and does not underestimate decorator cost - suite.Require().Nil(err, "ConsumeTxSizeGasDecorator returned error: %v", err) - suite.Require().True(consumedSimGas >= expectedGas, "Simulate mode underestimates gas on AnteDecorator. Simulated cost: %d, expected cost: %d", consumedSimGas, expectedGas) + require.Nil(t, err, "ConsumeTxSizeGasDecorator returned error: %v", err) + require.True(t, consumedSimGas >= expectedGas, "Simulate mode underestimates gas on AnteDecorator. Simulated cost: %d, expected cost: %d", consumedSimGas, expectedGas) }) } } -func (suite *AnteTestSuite) TestTxHeightTimeoutDecorator() { - suite.SetupTest(true) +func TestTxHeightTimeoutDecorator(t *testing.T) { + suite := SetupTestSuite(t, true) antehandler := sdk.ChainAnteDecorators(ante.NewTxTimeoutHeightDecorator()) @@ -186,24 +189,24 @@ func (suite *AnteTestSuite) TestTxHeightTimeoutDecorator() { gasLimit := testdata.NewTestGasLimit() testCases := []struct { - name string - timeout uint64 - height int64 - expectErr bool + name string + timeout uint64 + height int64 + expectedErr error }{ - {"default value", 0, 10, false}, - {"no timeout (greater height)", 15, 10, false}, - {"no timeout (same height)", 10, 10, false}, - {"timeout (smaller height)", 9, 10, true}, + {"default value", 0, 10, nil}, + {"no timeout (greater height)", 15, 10, nil}, + {"no timeout (same height)", 10, 10, nil}, + {"timeout (smaller height)", 9, 10, sdkerrors.ErrTxTimeoutHeight}, } for _, tc := range testCases { tc := tc - suite.Run(tc.name, func() { + t.Run(tc.name, func(t *testing.T) { suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() - suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + require.NoError(t, suite.txBuilder.SetMsgs(msg)) suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) @@ -212,11 +215,11 @@ func (suite *AnteTestSuite) TestTxHeightTimeoutDecorator() { privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) ctx := suite.ctx.WithBlockHeight(tc.height) _, err = antehandler(ctx, tx, true) - suite.Require().Equal(tc.expectErr, err != nil, err) + require.ErrorIs(t, err, tc.expectedErr) }) } } diff --git a/x/auth/ante/ext_test.go b/x/auth/ante/ext_test.go index 3bd0f8f60275..8230b5205e75 100644 --- a/x/auth/ante/ext_test.go +++ b/x/auth/ante/ext_test.go @@ -1,15 +1,18 @@ package ante_test import ( + "testing" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/tx" + "github.com/stretchr/testify/require" ) -func (suite *AnteTestSuite) TestRejectExtensionOptionsDecorator() { - suite.SetupTest(true) // setup +func TestRejectExtensionOptionsDecorator(t *testing.T) { + suite := SetupTestSuite(t, true) testCases := []struct { msg string @@ -19,7 +22,7 @@ func (suite *AnteTestSuite) TestRejectExtensionOptionsDecorator() { {"reject extension", false}, } for _, tc := range testCases { - suite.Run(tc.msg, func() { + t.Run(tc.msg, func(t *testing.T) { txBuilder := suite.clientCtx.TxConfig.NewTxBuilder() reod := ante.NewExtensionOptionsDecorator(func(_ *codectypes.Any) bool { @@ -30,7 +33,7 @@ func (suite *AnteTestSuite) TestRejectExtensionOptionsDecorator() { // no extension options should not trigger an error theTx := txBuilder.GetTx() _, err := antehandler(suite.ctx, theTx, false) - suite.Require().NoError(err) + require.NoError(t, err) extOptsTxBldr, ok := txBuilder.(tx.ExtensionOptionsTxBuilder) if !ok { @@ -40,14 +43,14 @@ func (suite *AnteTestSuite) TestRejectExtensionOptionsDecorator() { // set an extension option and check any, err := codectypes.NewAnyWithValue(testdata.NewTestMsg()) - suite.Require().NoError(err) + require.NoError(t, err) extOptsTxBldr.SetExtensionOptions(any) theTx = txBuilder.GetTx() _, err = antehandler(suite.ctx, theTx, false) if tc.allow { - suite.Require().NoError(err) + require.NoError(t, err) } else { - suite.Require().EqualError(err, "unknown extension options") + require.EqualError(t, err, "unknown extension options") } }) } diff --git a/x/auth/ante/fee.go b/x/auth/ante/fee.go index 0f10041c3733..73792d3e63dd 100644 --- a/x/auth/ante/fee.go +++ b/x/auth/ante/fee.go @@ -47,10 +47,10 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } var ( - priority int64 - err error + priority int64 + err error ) - + fee := feeTx.GetFee() if !simulate { fee, priority, err = dfd.txFeeChecker(ctx, tx) diff --git a/x/auth/ante/fee_test.go b/x/auth/ante/fee_test.go index 4d2fdac56e46..62f93ac0d8fd 100644 --- a/x/auth/ante/fee_test.go +++ b/x/auth/ante/fee_test.go @@ -1,70 +1,73 @@ package ante_test import ( + "testing" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" ) -func (s *AnteTestSuite) TestDeductFeeDecorator_ZeroGas() { - s.SetupTest(true) // setup +func TestDeductFeeDecorator_ZeroGas(t *testing.T) { + s := SetupTestSuite(t, true) s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() mfd := ante.NewDeductFeeDecorator(s.accountKeeper, s.bankKeeper, s.feeGrantKeeper, nil) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - coins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(300))) - testutil.FundAccount(s.bankKeeper, s.ctx, addr1, coins) + accs := s.CreateTestAccounts(1) // msg and signatures - msg := testdata.NewTestMsg(addr1) - s.Require().NoError(s.txBuilder.SetMsgs(msg)) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) + require.NoError(t, s.txBuilder.SetMsgs(msg)) // set zero gas s.txBuilder.SetGasLimit(0) - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv}, []uint64{0}, []uint64{0} tx, err := s.CreateTestTx(privs, accNums, accSeqs, s.ctx.ChainID()) - s.Require().NoError(err) + require.NoError(t, err) // Set IsCheckTx to true s.ctx = s.ctx.WithIsCheckTx(true) _, err = antehandler(s.ctx, tx, false) - s.Require().Error(err) + require.Error(t, err) // zero gas is accepted in simulation mode _, err = antehandler(s.ctx, tx, true) - s.Require().NoError(err) + require.NoError(t, err) } -func (s *AnteTestSuite) TestEnsureMempoolFees() { - s.SetupTest(true) // setup +func TestEnsureMempoolFees(t *testing.T) { + s := SetupTestSuite(t, true) // setup s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() mfd := ante.NewDeductFeeDecorator(s.accountKeeper, s.bankKeeper, s.feeGrantKeeper, nil) antehandler := sdk.ChainAnteDecorators(mfd) // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - coins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(300))) - testutil.FundAccount(s.bankKeeper, s.ctx, addr1, coins) + accs := s.CreateTestAccounts(1) // msg and signatures - msg := testdata.NewTestMsg(addr1) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - s.Require().NoError(s.txBuilder.SetMsgs(msg)) + require.NoError(t, s.txBuilder.SetMsgs(msg)) s.txBuilder.SetFeeAmount(feeAmount) s.txBuilder.SetGasLimit(gasLimit) - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), authtypes.FeeCollectorName, feeAmount).Return(nil).Times(3) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv}, []uint64{0}, []uint64{0} tx, err := s.CreateTestTx(privs, accNums, accSeqs, s.ctx.ChainID()) - s.Require().NoError(err) + require.NoError(t, err) // Set high gas price so standard test fee fails atomPrice := sdk.NewDecCoinFromDec("atom", sdk.NewDec(200).Quo(sdk.NewDec(100000))) @@ -76,19 +79,19 @@ func (s *AnteTestSuite) TestEnsureMempoolFees() { // antehandler errors with insufficient fees _, err = antehandler(s.ctx, tx, false) - s.Require().NotNil(err, "Decorator should have errored on too low fee for local gasPrice") + require.NotNil(t, err, "Decorator should have errored on too low fee for local gasPrice") // antehandler should not error since we do not check minGasPrice in simulation mode cacheCtx, _ := s.ctx.CacheContext() _, err = antehandler(cacheCtx, tx, true) - s.Require().Nil(err, "Decorator should not have errored in simulation mode") + require.Nil(t, err, "Decorator should not have errored in simulation mode") // Set IsCheckTx to false s.ctx = s.ctx.WithIsCheckTx(false) // antehandler should not error since we do not check minGasPrice in DeliverTx _, err = antehandler(s.ctx, tx, false) - s.Require().Nil(err, "MempoolFeeDecorator returned error in DeliverTx") + require.Nil(t, err, "MempoolFeeDecorator returned error in DeliverTx") // Set IsCheckTx back to true for testing sufficient mempool fee s.ctx = s.ctx.WithIsCheckTx(true) @@ -98,51 +101,41 @@ func (s *AnteTestSuite) TestEnsureMempoolFees() { s.ctx = s.ctx.WithMinGasPrices(lowGasPrice) newCtx, err := antehandler(s.ctx, tx, false) - s.Require().Nil(err, "Decorator should not have errored on fee higher than local gasPrice") + require.Nil(t, err, "Decorator should not have errored on fee higher than local gasPrice") // Priority is the smallest amount in any denom. Since we have only 1 fee // of 150atom, the priority here is 150. - s.Require().Equal(feeAmount.AmountOf("atom").Int64(), newCtx.Priority()) + require.Equal(t, feeAmount.AmountOf("atom").Int64(), newCtx.Priority()) } -func (s *AnteTestSuite) TestDeductFees() { - s.SetupTest(false) // setup +func TestDeductFees(t *testing.T) { + s := SetupTestSuite(t, false) s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder() // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() + accs := s.CreateTestAccounts(1) // msg and signatures - msg := testdata.NewTestMsg(addr1) + msg := testdata.NewTestMsg(accs[0].acc.GetAddress()) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - s.Require().NoError(s.txBuilder.SetMsgs(msg)) + require.NoError(t, s.txBuilder.SetMsgs(msg)) s.txBuilder.SetFeeAmount(feeAmount) s.txBuilder.SetGasLimit(gasLimit) - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + privs, accNums, accSeqs := []cryptotypes.PrivKey{accs[0].priv}, []uint64{0}, []uint64{0} tx, err := s.CreateTestTx(privs, accNums, accSeqs, s.ctx.ChainID()) - s.Require().NoError(err) - - // Set account with insufficient funds - acc := s.accountKeeper.NewAccountWithAddress(s.ctx, addr1) - s.accountKeeper.SetAccount(s.ctx, acc) - coins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(10))) - err = testutil.FundAccount(s.bankKeeper, s.ctx, addr1, coins) - s.Require().NoError(err) + require.NoError(t, err) dfd := ante.NewDeductFeeDecorator(s.accountKeeper, s.bankKeeper, nil, nil) antehandler := sdk.ChainAnteDecorators(dfd) + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(sdkerrors.ErrInsufficientFunds) _, err = antehandler(s.ctx, tx, false) - s.Require().NotNil(err, "Tx did not error when fee payer had insufficient funds") - - // Set account with sufficient funds - s.accountKeeper.SetAccount(s.ctx, acc) - err = testutil.FundAccount(s.bankKeeper, s.ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200)))) - s.Require().NoError(err) + require.NotNil(t, err, "Tx did not error when fee payer had insufficient funds") + s.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Return(nil) _, err = antehandler(s.ctx, tx, false) - s.Require().Nil(err, "Tx errored after account has been set with sufficient funds") + require.Nil(t, err, "Tx errored after account has been set with sufficient funds") } diff --git a/x/auth/ante/feegrant_test.go b/x/auth/ante/feegrant_test.go index 1874945d857c..9729b14c6879 100644 --- a/x/auth/ante/feegrant_test.go +++ b/x/auth/ante/feegrant_test.go @@ -5,157 +5,177 @@ import ( "testing" "time" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" authsign "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/feegrant" ) -func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { - suite.SetupTest(false) - - protoTxCfg := tx.NewTxConfig(codec.NewProtoCodec(suite.interfaceRegistry), tx.DefaultSignModes) - - // this just tests our handler - dfd := ante.NewDeductFeeDecorator(suite.accountKeeper, suite.bankKeeper, suite.feeGrantKeeper, nil) - feeAnteHandler := sdk.ChainAnteDecorators(dfd) - - // this tests the whole stack - anteHandlerStack := suite.anteHandler - - // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - priv2, _, addr2 := testdata.KeyTestPubAddr() - priv3, _, addr3 := testdata.KeyTestPubAddr() - priv4, _, addr4 := testdata.KeyTestPubAddr() - priv5, _, addr5 := testdata.KeyTestPubAddr() - - // Set addr1 with insufficient funds - err := testutil.FundAccount(suite.bankKeeper, suite.ctx, addr1, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))}) - suite.Require().NoError(err) - - // Set addr2 with more funds - err = testutil.FundAccount(suite.bankKeeper, suite.ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) - suite.Require().NoError(err) - - // grant fee allowance from `addr2` to `addr3` (plenty to pay) - err = suite.feeGrantKeeper.GrantAllowance(suite.ctx, addr2, addr3, &feegrant.BasicAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), - }) - suite.Require().NoError(err) - - // grant low fee allowance (20atom), to check the tx requesting more than allowed. - err = suite.feeGrantKeeper.GrantAllowance(suite.ctx, addr2, addr4, &feegrant.BasicAllowance{ - SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)), - }) - suite.Require().NoError(err) - +func TestDeductFeesNoDelegation(t *testing.T) { cases := map[string]struct { - signerKey cryptotypes.PrivKey - signer sdk.AccAddress - feeAccount sdk.AccAddress - fee int64 - valid bool - }{ - "paying with low funds": { - signerKey: priv1, - signer: addr1, - fee: 50, - valid: false, + fee int64 + valid bool + err error + malleate func(*AnteTestSuite) (signer TestAccount, feeAcc sdk.AccAddress) + }{"paying with low funds": { + fee: 50, + valid: false, + err: sdkerrors.ErrInsufficientFunds, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + accs := suite.CreateTestAccounts(1) + // 2 calls are needed because we run the ante twice + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), authtypes.FeeCollectorName, gomock.Any()).Return(sdkerrors.ErrInsufficientFunds).Times(2) + return accs[0], nil }, + }, "paying with good funds": { - signerKey: priv2, - signer: addr2, - fee: 50, - valid: true, + fee: 50, + valid: true, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + accs := suite.CreateTestAccounts(1) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[0].acc.GetAddress(), authtypes.FeeCollectorName, gomock.Any()).Return(nil).Times(2) + return accs[0], nil + }, }, "paying with no account": { - signerKey: priv3, - signer: addr3, - fee: 1, - valid: false, + fee: 1, + valid: false, + err: sdkerrors.ErrUnknownAddress, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + // Do not register the account + priv, _, addr := testdata.KeyTestPubAddr() + return TestAccount{ + acc: authtypes.NewBaseAccountWithAddress(addr), + priv: priv, + }, nil + }, }, "no fee with real account": { - signerKey: priv1, - signer: addr1, - fee: 0, - valid: true, + fee: 0, + valid: true, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + accs := suite.CreateTestAccounts(1) + return accs[0], nil + }, }, "no fee with no account": { - signerKey: priv5, - signer: addr5, - fee: 0, - valid: false, + fee: 0, + valid: false, + err: sdkerrors.ErrUnknownAddress, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + // Do not register the account + priv, _, addr := testdata.KeyTestPubAddr() + return TestAccount{ + acc: authtypes.NewBaseAccountWithAddress(addr), + priv: priv, + }, nil + }, }, - "valid fee grant without account": { - signerKey: priv3, - signer: addr3, - feeAccount: addr2, - fee: 50, - valid: true, + "valid fee grant": { + // note: the original test said "valid fee grant with no account". + // this is impossible given that feegrant.GrantAllowance calls + // SetAccount for the grantee. + fee: 50, + valid: true, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + accs := suite.CreateTestAccounts(2) + suite.feeGrantKeeper.EXPECT().UseGrantedFees(gomock.Any(), accs[1].acc.GetAddress(), accs[0].acc.GetAddress(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[1].acc.GetAddress(), authtypes.FeeCollectorName, gomock.Any()).Return(nil).Times(2) + + return accs[0], accs[1].acc.GetAddress() + }, }, "no fee grant": { - signerKey: priv3, - signer: addr3, - feeAccount: addr1, - fee: 2, - valid: false, + fee: 2, + valid: false, + err: sdkerrors.ErrNotFound, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + accs := suite.CreateTestAccounts(2) + suite.feeGrantKeeper.EXPECT(). + UseGrantedFees(gomock.Any(), accs[1].acc.GetAddress(), accs[0].acc.GetAddress(), gomock.Any(), gomock.Any()). + Return(sdkerrors.ErrNotFound.Wrap("fee-grant not found")). + Times(2) + return accs[0], accs[1].acc.GetAddress() + }, }, "allowance smaller than requested fee": { - signerKey: priv4, - signer: addr4, - feeAccount: addr2, - fee: 50, - valid: false, + fee: 50, + valid: false, + err: feegrant.ErrFeeLimitExceeded, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + accs := suite.CreateTestAccounts(2) + suite.feeGrantKeeper.EXPECT(). + UseGrantedFees(gomock.Any(), accs[1].acc.GetAddress(), accs[0].acc.GetAddress(), gomock.Any(), gomock.Any()). + Return(feegrant.ErrFeeLimitExceeded.Wrap("basic allowance")). + Times(2) + return accs[0], accs[1].acc.GetAddress() + }, }, "granter cannot cover allowed fee grant": { - signerKey: priv4, - signer: addr4, - feeAccount: addr1, - fee: 50, - valid: false, + fee: 50, + valid: false, + err: sdkerrors.ErrInsufficientFunds, + malleate: func(suite *AnteTestSuite) (TestAccount, sdk.AccAddress) { + accs := suite.CreateTestAccounts(2) + suite.feeGrantKeeper.EXPECT().UseGrantedFees(gomock.Any(), accs[1].acc.GetAddress(), accs[0].acc.GetAddress(), gomock.Any(), gomock.Any()).Return(nil).Times(2) + suite.bankKeeper.EXPECT().SendCoinsFromAccountToModule(gomock.Any(), accs[1].acc.GetAddress(), authtypes.FeeCollectorName, gomock.Any()).Return(sdkerrors.ErrInsufficientFunds).Times(2) + return accs[0], accs[1].acc.GetAddress() + }, }, } for name, stc := range cases { tc := stc // to make scopelint happy - suite.T().Run(name, func(t *testing.T) { + t.Run(name, func(t *testing.T) { + suite := SetupTestSuite(t, false) + protoTxCfg := tx.NewTxConfig(codec.NewProtoCodec(suite.encCfg.InterfaceRegistry), tx.DefaultSignModes) + // this just tests our handler + dfd := ante.NewDeductFeeDecorator(suite.accountKeeper, suite.bankKeeper, suite.feeGrantKeeper, nil) + feeAnteHandler := sdk.ChainAnteDecorators(dfd) + + // this tests the whole stack + anteHandlerStack := suite.anteHandler + + signer, feeAcc := stc.malleate(suite) + fee := sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)) - msgs := []sdk.Msg{testdata.NewTestMsg(tc.signer)} + msgs := []sdk.Msg{testdata.NewTestMsg(signer.acc.GetAddress())} - acc := suite.accountKeeper.GetAccount(suite.ctx, tc.signer) - privs, accNums, seqs := []cryptotypes.PrivKey{tc.signerKey}, []uint64{0}, []uint64{0} + acc := suite.accountKeeper.GetAccount(suite.ctx, signer.acc.GetAddress()) + privs, accNums, seqs := []cryptotypes.PrivKey{signer.priv}, []uint64{0}, []uint64{0} if acc != nil { accNums, seqs = []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} } - tx, err := genTxWithFeeGranter(protoTxCfg, msgs, fee, simtestutil.DefaultGenTxGas, suite.ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...) - suite.Require().NoError(err) + var defaultGenTxGas uint64 = 10000000 + tx, err := genTxWithFeeGranter(protoTxCfg, msgs, fee, defaultGenTxGas, suite.ctx.ChainID(), accNums, seqs, feeAcc, privs...) + require.NoError(t, err) _, err = feeAnteHandler(suite.ctx, tx, false) // tests only feegrant ante if tc.valid { - suite.Require().NoError(err) + require.NoError(t, err) } else { - suite.Require().Error(err) + require.ErrorIs(t, err, tc.err) } _, err = anteHandlerStack(suite.ctx, tx, false) // tests while stack if tc.valid { - suite.Require().NoError(err) + require.NoError(t, err) } else { - suite.Require().Error(err) + require.ErrorIs(t, err, tc.err) } }) } diff --git a/x/auth/ante/setup_test.go b/x/auth/ante/setup_test.go index ed4e543b56a4..e7138af70e19 100644 --- a/x/auth/ante/setup_test.go +++ b/x/auth/ante/setup_test.go @@ -1,15 +1,18 @@ package ante_test import ( + "testing" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/ante" + "github.com/stretchr/testify/require" ) -func (suite *AnteTestSuite) TestSetup() { - suite.SetupTest(true) // setup +func TestSetup(t *testing.T) { + suite := SetupTestSuite(t, true) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // keys and addresses @@ -19,13 +22,13 @@ func (suite *AnteTestSuite) TestSetup() { msg := testdata.NewTestMsg(addr1) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + require.NoError(t, suite.txBuilder.SetMsgs(msg)) suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) sud := ante.NewSetUpContextDecorator() antehandler := sdk.ChainAnteDecorators(sud) @@ -34,17 +37,17 @@ func (suite *AnteTestSuite) TestSetup() { suite.ctx = suite.ctx.WithBlockHeight(1).WithGasMeter(sdk.NewGasMeter(0)) // Context GasMeter Limit not set - suite.Require().Equal(uint64(0), suite.ctx.GasMeter().Limit(), "GasMeter set with limit before setup") + require.Equal(t, uint64(0), suite.ctx.GasMeter().Limit(), "GasMeter set with limit before setup") newCtx, err := antehandler(suite.ctx, tx, false) - suite.Require().Nil(err, "SetUpContextDecorator returned error") + require.Nil(t, err, "SetUpContextDecorator returned error") // Context GasMeter Limit should be set after SetUpContextDecorator runs - suite.Require().Equal(gasLimit, newCtx.GasMeter().Limit(), "GasMeter not set correctly") + require.Equal(t, gasLimit, newCtx.GasMeter().Limit(), "GasMeter not set correctly") } -func (suite *AnteTestSuite) TestRecoverPanic() { - suite.SetupTest(true) // setup +func TestRecoverPanic(t *testing.T) { + suite := SetupTestSuite(t, true) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // keys and addresses @@ -54,13 +57,13 @@ func (suite *AnteTestSuite) TestRecoverPanic() { msg := testdata.NewTestMsg(addr1) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + require.NoError(t, suite.txBuilder.SetMsgs(msg)) suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) sud := ante.NewSetUpContextDecorator() antehandler := sdk.ChainAnteDecorators(sud, OutOfGasDecorator{}) @@ -70,13 +73,13 @@ func (suite *AnteTestSuite) TestRecoverPanic() { newCtx, err := antehandler(suite.ctx, tx, false) - suite.Require().NotNil(err, "Did not return error on OutOfGas panic") + require.NotNil(t, err, "Did not return error on OutOfGas panic") - suite.Require().True(sdkerrors.ErrOutOfGas.Is(err), "Returned error is not an out of gas error") - suite.Require().Equal(gasLimit, newCtx.GasMeter().Limit()) + require.True(t, sdkerrors.ErrOutOfGas.Is(err), "Returned error is not an out of gas error") + require.Equal(t, gasLimit, newCtx.GasMeter().Limit()) antehandler = sdk.ChainAnteDecorators(sud, PanicDecorator{}) - suite.Require().Panics(func() { antehandler(suite.ctx, tx, false) }, "Recovered from non-Out-of-Gas panic") // nolint:errcheck + require.Panics(t, func() { antehandler(suite.ctx, tx, false) }, "Recovered from non-Out-of-Gas panic") // nolint:errcheck } type OutOfGasDecorator struct{} diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index d398357eb987..9f7a14f5e95f 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -2,6 +2,7 @@ package ante_test import ( "fmt" + "testing" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -17,17 +18,17 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/stretchr/testify/require" ) -func (suite *AnteTestSuite) TestSetPubKey() { - suite.SetupTest(true) // setup - require := suite.Require() +func TestSetPubKey(t *testing.T) { + suite := SetupTestSuite(t, true) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // keys and addresses priv1, pub1, addr1 := testdata.KeyTestPubAddr() priv2, pub2, addr2 := testdata.KeyTestPubAddr() - priv3, pub3, addr3 := testdata.KeyTestPubAddrSecp256R1(require) + priv3, pub3, addr3 := testdata.KeyTestPubAddrSecp256R1(require.New(t)) addrs := []sdk.AccAddress{addr1, addr2, addr3} pubs := []cryptotypes.PubKey{pub1, pub2, pub3} @@ -36,34 +37,35 @@ func (suite *AnteTestSuite) TestSetPubKey() { // set accounts and create msg for each address for i, addr := range addrs { acc := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr) - require.NoError(acc.SetAccountNumber(uint64(i))) + require.NoError(t, acc.SetAccountNumber(uint64(i))) suite.accountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) } - require.NoError(suite.txBuilder.SetMsgs(msgs...)) + require.NoError(t, suite.txBuilder.SetMsgs(msgs...)) suite.txBuilder.SetFeeAmount(testdata.NewTestFeeAmount()) suite.txBuilder.SetGasLimit(testdata.NewTestGasLimit()) privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0} tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - require.NoError(err) + require.NoError(t, err) spkd := ante.NewSetPubKeyDecorator(suite.accountKeeper) antehandler := sdk.ChainAnteDecorators(spkd) ctx, err := antehandler(suite.ctx, tx, false) - require.NoError(err) + require.NoError(t, err) // Require that all accounts have pubkey set after Decorator runs for i, addr := range addrs { pk, err := suite.accountKeeper.GetPubKey(ctx, addr) - require.NoError(err, "Error on retrieving pubkey from account") - require.True(pubs[i].Equals(pk), + require.NoError(t, err, "Error on retrieving pubkey from account") + require.True(t, pubs[i].Equals(pk), "Wrong Pubkey retrieved from AccountKeeper, idx=%d\nexpected=%s\n got=%s", i, pubs[i], pk) } } -func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() { +func TestConsumeSignatureVerificationGas(t *testing.T) { + suite := SetupTestSuite(t, true) params := types.DefaultParams() msg := []byte{1, 2, 3, 4} @@ -76,9 +78,9 @@ func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() { for i := 0; i < len(pkSet1); i++ { stdSig := legacytx.StdSignature{PubKey: pkSet1[i], Signature: sigSet1[i]} sigV2, err := legacytx.StdSignatureToSignatureV2(suite.clientCtx.LegacyAmino, stdSig) - suite.Require().NoError(err) + require.NoError(t, err) err = multisig.AddSignatureV2(multisignature1, sigV2, pkSet1) - suite.Require().NoError(err) + require.NoError(t, err) } type args struct { @@ -108,16 +110,16 @@ func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() { err := ante.DefaultSigVerificationGasConsumer(tt.args.meter, sigV2, tt.args.params) if tt.shouldErr { - suite.Require().NotNil(err) + require.NotNil(t, err) } else { - suite.Require().Nil(err) - suite.Require().Equal(tt.gasConsumed, tt.args.meter.GasConsumed(), fmt.Sprintf("%d != %d", tt.gasConsumed, tt.args.meter.GasConsumed())) + require.Nil(t, err) + require.Equal(t, tt.gasConsumed, tt.args.meter.GasConsumed(), fmt.Sprintf("%d != %d", tt.gasConsumed, tt.args.meter.GasConsumed())) } } } -func (suite *AnteTestSuite) TestSigVerification() { - suite.SetupTest(true) // setup +func TestSigVerification(t *testing.T) { + suite := SetupTestSuite(t, true) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // make block height non-zero to ensure account numbers part of signBytes @@ -134,7 +136,7 @@ func (suite *AnteTestSuite) TestSigVerification() { // set accounts and create msg for each address for i, addr := range addrs { acc := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr) - suite.Require().NoError(acc.SetAccountNumber(uint64(i))) + require.NoError(t, acc.SetAccountNumber(uint64(i))) suite.accountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) } @@ -169,12 +171,12 @@ func (suite *AnteTestSuite) TestSigVerification() { suite.ctx = suite.ctx.WithIsReCheckTx(tc.recheck) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test - suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + require.NoError(t, suite.txBuilder.SetMsgs(msgs...)) suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) tx, err := suite.CreateTestTx(tc.privs, tc.accNums, tc.accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) if tc.invalidSigs { txSigs, _ := tx.GetSignaturesV2() badSig, _ := tc.privs[0].Sign([]byte("unrelated message")) @@ -192,9 +194,9 @@ func (suite *AnteTestSuite) TestSigVerification() { _, err = antehandler(suite.ctx, tx, false) if tc.shouldErr { - suite.Require().NotNil(err, "TestCase %d: %s did not error as expected", i, tc.name) + require.NotNil(t, err, "TestCase %d: %s did not error as expected", i, tc.name) } else { - suite.Require().Nil(err, "TestCase %d: %s errored unexpectedly. Err: %v", i, tc.name, err) + require.Nil(t, err, "TestCase %d: %s errored unexpectedly. Err: %v", i, tc.name, err) } } } @@ -205,7 +207,8 @@ func (suite *AnteTestSuite) TestSigVerification() { // this, since it'll be handled by the test matrix. // In the meantime, we want to make double-sure amino compatibility works. // ref: https://github.com/cosmos/cosmos-sdk/issues/7229 -func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { +func TestSigVerification_ExplicitAmino(t *testing.T) { + suite := SetupTestSuite(t, true) // Set up TxConfig. aminoCdc := codec.NewLegacyAmino() // We're using TestMsg amino encoding in some tests, so register it here. @@ -224,7 +227,7 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { }, ) - suite.Require().NoError(err) + require.NoError(t, err) suite.anteHandler = anteHandler suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() @@ -243,7 +246,7 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { // set accounts and create msg for each address for i, addr := range addrs { acc := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr) - suite.Require().NoError(acc.SetAccountNumber(uint64(i))) + require.NoError(t, acc.SetAccountNumber(uint64(i))) suite.accountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) } @@ -276,23 +279,23 @@ func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { suite.ctx = suite.ctx.WithIsReCheckTx(tc.recheck) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test - suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + require.NoError(t, suite.txBuilder.SetMsgs(msgs...)) suite.txBuilder.SetFeeAmount(feeAmount) suite.txBuilder.SetGasLimit(gasLimit) tx, err := suite.CreateTestTx(tc.privs, tc.accNums, tc.accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) _, err = antehandler(suite.ctx, tx, false) if tc.shouldErr { - suite.Require().NotNil(err, "TestCase %d: %s did not error as expected", i, tc.name) + require.NotNil(t, err, "TestCase %d: %s did not error as expected", i, tc.name) } else { - suite.Require().Nil(err, "TestCase %d: %s errored unexpectedly. Err: %v", i, tc.name, err) + require.Nil(t, err, "TestCase %d: %s errored unexpectedly. Err: %v", i, tc.name, err) } } } -func (suite *AnteTestSuite) TestSigIntegration() { +func TestSigIntegration(t *testing.T) { // generate private keys privs := []cryptotypes.PrivKey{ secp256k1.GenPrivKey(), @@ -302,24 +305,24 @@ func (suite *AnteTestSuite) TestSigIntegration() { params := types.DefaultParams() initialSigCost := params.SigVerifyCostSecp256k1 - initialCost, err := suite.runSigDecorators(params, false, privs...) - suite.Require().Nil(err) + initialCost, err := runSigDecorators(t, params, false, privs...) + require.Nil(t, err) params.SigVerifyCostSecp256k1 *= 2 - doubleCost, err := suite.runSigDecorators(params, false, privs...) - suite.Require().Nil(err) + doubleCost, err := runSigDecorators(t, params, false, privs...) + require.Nil(t, err) - suite.Require().Equal(initialSigCost*uint64(len(privs)), doubleCost-initialCost) + require.Equal(t, initialSigCost*uint64(len(privs)), doubleCost-initialCost) } -func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs ...cryptotypes.PrivKey) (sdk.Gas, error) { - suite.SetupTest(true) // setup +func runSigDecorators(t *testing.T, params types.Params, _ bool, privs ...cryptotypes.PrivKey) (sdk.Gas, error) { + suite := SetupTestSuite(t, true) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Make block-height non-zero to include accNum in SignBytes suite.ctx = suite.ctx.WithBlockHeight(1) err := suite.accountKeeper.SetParams(suite.ctx, params) - suite.Require().NoError(err) + require.NoError(t, err) msgs := make([]sdk.Msg, len(privs)) accNums := make([]uint64, len(privs)) @@ -328,13 +331,13 @@ func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs for i, priv := range privs { addr := sdk.AccAddress(priv.PubKey().Address()) acc := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr) - suite.Require().NoError(acc.SetAccountNumber(uint64(i))) + require.NoError(t, acc.SetAccountNumber(uint64(i))) suite.accountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) accNums[i] = uint64(i) accSeqs[i] = uint64(0) } - suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + require.NoError(t, suite.txBuilder.SetMsgs(msgs...)) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() @@ -342,7 +345,7 @@ func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs suite.txBuilder.SetGasLimit(gasLimit) tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) spkd := ante.NewSetPubKeyDecorator(suite.accountKeeper) svgc := ante.NewSigGasConsumeDecorator(suite.accountKeeper, ante.DefaultSigVerificationGasConsumer) @@ -357,17 +360,17 @@ func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs return after - before, err } -func (suite *AnteTestSuite) TestIncrementSequenceDecorator() { - suite.SetupTest(true) // setup +func TestIncrementSequenceDecorator(t *testing.T) { + suite := SetupTestSuite(t, true) suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() priv, _, addr := testdata.KeyTestPubAddr() acc := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr) - suite.Require().NoError(acc.SetAccountNumber(uint64(50))) + require.NoError(t, acc.SetAccountNumber(uint64(50))) suite.accountKeeper.SetAccount(suite.ctx, acc) msgs := []sdk.Msg{testdata.NewTestMsg(addr)} - suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + require.NoError(t, suite.txBuilder.SetMsgs(msgs...)) privs := []cryptotypes.PrivKey{priv} accNums := []uint64{suite.accountKeeper.GetAccount(suite.ctx, addr).GetAccountNumber()} accSeqs := []uint64{suite.accountKeeper.GetAccount(suite.ctx, addr).GetSequence()} @@ -377,7 +380,7 @@ func (suite *AnteTestSuite) TestIncrementSequenceDecorator() { suite.txBuilder.SetGasLimit(gasLimit) tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) - suite.Require().NoError(err) + require.NoError(t, err) isd := ante.NewIncrementSequenceDecorator(suite.accountKeeper) antehandler := sdk.ChainAnteDecorators(isd) @@ -396,7 +399,7 @@ func (suite *AnteTestSuite) TestIncrementSequenceDecorator() { for i, tc := range testCases { _, err := antehandler(tc.ctx, tx, tc.simulate) - suite.Require().NoError(err, "unexpected error; tc #%d, %v", i, tc) - suite.Require().Equal(tc.expectedSeq, suite.accountKeeper.GetAccount(suite.ctx, addr).GetSequence()) + require.NoError(t, err, "unexpected error; tc #%d, %v", i, tc) + require.Equal(t, tc.expectedSeq, suite.accountKeeper.GetAccount(suite.ctx, addr).GetSequence()) } } diff --git a/x/auth/ante/testutil/expected_keepers_mocks.go b/x/auth/ante/testutil/expected_keepers_mocks.go new file mode 100644 index 000000000000..ff2803af07bf --- /dev/null +++ b/x/auth/ante/testutil/expected_keepers_mocks.go @@ -0,0 +1,127 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: x/auth/ante/expected_keepers.go + +// Package testutil is a generated GoMock package. +package testutil + +import ( + reflect "reflect" + + types "github.com/cosmos/cosmos-sdk/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" + gomock "github.com/golang/mock/gomock" +) + +// MockAccountKeeper is a mock of AccountKeeper interface. +type MockAccountKeeper struct { + ctrl *gomock.Controller + recorder *MockAccountKeeperMockRecorder +} + +// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper. +type MockAccountKeeperMockRecorder struct { + mock *MockAccountKeeper +} + +// NewMockAccountKeeper creates a new mock instance. +func NewMockAccountKeeper(ctrl *gomock.Controller) *MockAccountKeeper { + mock := &MockAccountKeeper{ctrl: ctrl} + mock.recorder = &MockAccountKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { + return m.recorder +} + +// GetAccount mocks base method. +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAccount", ctx, addr) + ret0, _ := ret[0].(types0.AccountI) + return ret0 +} + +// GetAccount indicates an expected call of GetAccount. +func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetAccount), ctx, addr) +} + +// GetModuleAddress mocks base method. +func (m *MockAccountKeeper) GetModuleAddress(moduleName string) types.AccAddress { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetModuleAddress", moduleName) + ret0, _ := ret[0].(types.AccAddress) + return ret0 +} + +// GetModuleAddress indicates an expected call of GetModuleAddress. +func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), moduleName) +} + +// GetParams mocks base method. +func (m *MockAccountKeeper) GetParams(ctx types.Context) types0.Params { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetParams", ctx) + ret0, _ := ret[0].(types0.Params) + return ret0 +} + +// GetParams indicates an expected call of GetParams. +func (mr *MockAccountKeeperMockRecorder) GetParams(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetParams", reflect.TypeOf((*MockAccountKeeper)(nil).GetParams), ctx) +} + +// SetAccount mocks base method. +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetAccount", ctx, acc) +} + +// SetAccount indicates an expected call of SetAccount. +func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetAccount), ctx, acc) +} + +// MockFeegrantKeeper is a mock of FeegrantKeeper interface. +type MockFeegrantKeeper struct { + ctrl *gomock.Controller + recorder *MockFeegrantKeeperMockRecorder +} + +// MockFeegrantKeeperMockRecorder is the mock recorder for MockFeegrantKeeper. +type MockFeegrantKeeperMockRecorder struct { + mock *MockFeegrantKeeper +} + +// NewMockFeegrantKeeper creates a new mock instance. +func NewMockFeegrantKeeper(ctrl *gomock.Controller) *MockFeegrantKeeper { + mock := &MockFeegrantKeeper{ctrl: ctrl} + mock.recorder = &MockFeegrantKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockFeegrantKeeper) EXPECT() *MockFeegrantKeeperMockRecorder { + return m.recorder +} + +// UseGrantedFees mocks base method. +func (m *MockFeegrantKeeper) UseGrantedFees(ctx types.Context, granter, grantee types.AccAddress, fee types.Coins, msgs []types.Msg) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UseGrantedFees", ctx, granter, grantee, fee, msgs) + ret0, _ := ret[0].(error) + return ret0 +} + +// UseGrantedFees indicates an expected call of UseGrantedFees. +func (mr *MockFeegrantKeeperMockRecorder) UseGrantedFees(ctx, granter, grantee, fee, msgs interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UseGrantedFees", reflect.TypeOf((*MockFeegrantKeeper)(nil).UseGrantedFees), ctx, granter, grantee, fee, msgs) +} diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go index 5167dac5365f..d996dcc3bddb 100644 --- a/x/auth/ante/testutil_test.go +++ b/x/auth/ante/testutil_test.go @@ -1,33 +1,27 @@ package ante_test import ( - "errors" - "fmt" "testing" - "github.com/cosmos/cosmos-sdk/codec" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - - "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/tx" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/keeper" - "github.com/cosmos/cosmos-sdk/x/auth/testutil" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + antetestutil "github.com/cosmos/cosmos-sdk/x/auth/ante/testutil" xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil" "github.com/cosmos/cosmos-sdk/x/auth/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper" ) // TestAccount represents an account used in the tests in x/auth/ante. @@ -38,91 +32,148 @@ type TestAccount struct { // AnteTestSuite is a test suite to be used with ante handler tests. type AnteTestSuite struct { - suite.Suite - - interfaceRegistry codectypes.InterfaceRegistry - anteHandler sdk.AnteHandler - ctx sdk.Context - clientCtx client.Context - txBuilder client.TxBuilder - accountKeeper keeper.AccountKeeper - bankKeeper bankkeeper.Keeper - feeGrantKeeper feegrantkeeper.Keeper -} - -func TestAnteTestSuite(t *testing.T) { - suite.Run(t, new(AnteTestSuite)) + anteHandler sdk.AnteHandler + ctx sdk.Context + clientCtx client.Context + txBuilder client.TxBuilder + accountKeeper keeper.AccountKeeper + bankKeeper *authtestutil.MockBankKeeper + feeGrantKeeper *antetestutil.MockFeegrantKeeper + encCfg moduletestutil.TestEncodingConfig } // SetupTest setups a new test, with new app, context, and anteHandler. -func (suite *AnteTestSuite) SetupTest(isCheckTx bool) { - var ( - txConfig client.TxConfig - legacyAmino *codec.LegacyAmino - ) +func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite { + suite := &AnteTestSuite{} + ctrl := gomock.NewController(t) + suite.bankKeeper = authtestutil.NewMockBankKeeper(ctrl) + + suite.feeGrantKeeper = antetestutil.NewMockFeegrantKeeper(ctrl) + + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test")) + suite.ctx = testCtx.Ctx.WithIsCheckTx(isCheckTx).WithBlockHeight(1) //app.BaseApp.NewContext(isCheckTx, tmproto.Header{}).WithBlockHeight(1) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) + + maccPerms := map[string][]string{ + "fee_collector": nil, + "mint": {"minter"}, + "bonded_tokens_pool": {"burner", "staking"}, + "not_bonded_tokens_pool": {"burner", "staking"}, + "multiPerm": {"burner", "minter", "staking"}, + "random": {"random"}, + } - app, err := simtestutil.Setup( - testutil.AppConfig, - &suite.accountKeeper, - &suite.bankKeeper, - &suite.feeGrantKeeper, - &suite.interfaceRegistry, - &txConfig, - &legacyAmino, + suite.accountKeeper = keeper.NewAccountKeeper( + suite.encCfg.Codec, key, types.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, types.NewModuleAddress("gov").String(), ) - suite.Require().NoError(err) - - suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{}).WithBlockHeight(1) - err = suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams()) - suite.Require().NoError(err) + suite.accountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName) + err := suite.accountKeeper.SetParams(suite.ctx, types.DefaultParams()) + require.NoError(t, err) // We're using TestMsg encoding in some tests, so register it here. - legacyAmino.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) - testdata.RegisterInterfaces(suite.interfaceRegistry) + suite.encCfg.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) + testdata.RegisterInterfaces(suite.encCfg.InterfaceRegistry) suite.clientCtx = client.Context{}. - WithTxConfig(txConfig) + WithTxConfig(suite.encCfg.TxConfig) anteHandler, err := ante.NewAnteHandler( ante.HandlerOptions{ AccountKeeper: suite.accountKeeper, BankKeeper: suite.bankKeeper, FeegrantKeeper: suite.feeGrantKeeper, - SignModeHandler: txConfig.SignModeHandler(), + SignModeHandler: suite.encCfg.TxConfig.SignModeHandler(), SigGasConsumer: ante.DefaultSigVerificationGasConsumer, }, ) - suite.Require().NoError(err) + require.NoError(t, err) suite.anteHandler = anteHandler + + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + + return suite } -// CreateTestAccounts creates `numAccs` accounts, and return all relevant -// information about them including their private keys. func (suite *AnteTestSuite) CreateTestAccounts(numAccs int) []TestAccount { var accounts []TestAccount for i := 0; i < numAccs; i++ { priv, _, addr := testdata.KeyTestPubAddr() acc := suite.accountKeeper.NewAccountWithAddress(suite.ctx, addr) - err := acc.SetAccountNumber(uint64(i)) - suite.Require().NoError(err) + acc.SetAccountNumber(uint64(i)) suite.accountKeeper.SetAccount(suite.ctx, acc) - someCoins := sdk.Coins{ - sdk.NewInt64Coin("atom", 10000000), - } - err = suite.bankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, someCoins) - suite.Require().NoError(err) - - err = suite.bankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr, someCoins) - suite.Require().NoError(err) - accounts = append(accounts, TestAccount{acc, priv}) } return accounts } +// TestCase represents a test case used in test tables. +type TestCase struct { + desc string + malleate func(*AnteTestSuite) TestCaseArgs + simulate bool + expPass bool + expErr error +} + +type TestCaseArgs struct { + chainID string + accNums []uint64 + accSeqs []uint64 + feeAmount sdk.Coins + gasLimit uint64 + msgs []sdk.Msg + privs []cryptotypes.PrivKey +} + +// DeliverMsgs constructs a tx and runs it through the ante handler. This is used to set the context for a test case, for +// example to test for replay protection. +func (suite *AnteTestSuite) DeliverMsgs(t *testing.T, privs []cryptotypes.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, accNums, accSeqs []uint64, chainID string, simulate bool) (sdk.Context, error) { + require.NoError(t, suite.txBuilder.SetMsgs(msgs...)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + tx, txErr := suite.CreateTestTx(privs, accNums, accSeqs, chainID) + require.NoError(t, txErr) + return suite.anteHandler(suite.ctx, tx, simulate) +} + +func (suite *AnteTestSuite) RunTestCase(t *testing.T, tc TestCase, args TestCaseArgs) { + require.NoError(t, suite.txBuilder.SetMsgs(args.msgs...)) + suite.txBuilder.SetFeeAmount(args.feeAmount) + suite.txBuilder.SetGasLimit(args.gasLimit) + + // 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(args.privs, args.accNums, args.accSeqs, args.chainID) + newCtx, anteErr := suite.anteHandler(suite.ctx, tx, tc.simulate) + + if tc.expPass { + require.NoError(t, txErr) + require.NoError(t, anteErr) + require.NotNil(t, newCtx) + + suite.ctx = newCtx + } else { + switch { + case txErr != nil: + require.Error(t, txErr) + require.ErrorIs(t, txErr, tc.expErr) + + case anteErr != nil: + require.Error(t, anteErr) + require.ErrorIs(t, anteErr, tc.expErr) + + default: + t.Fatal("expected one of txErr, anteErr to be an error") + } + } +} + // CreateTestTx is a helper function to create a tx given multiple inputs. func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { // First round: we gather all the signer infos. We use the "set empty @@ -169,48 +220,3 @@ func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums [] return suite.txBuilder.GetTx(), nil } - -// TestCase represents a test case used in test tables. -type TestCase struct { - desc string - malleate func() - simulate bool - expPass bool - expErr error -} - -// CreateTestTx is a helper function to create a tx given multiple inputs. -func (suite *AnteTestSuite) RunTestCase(privs []cryptotypes.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, accNums, accSeqs []uint64, chainID string, tc TestCase) { - suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { - suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) - suite.txBuilder.SetFeeAmount(feeAmount) - suite.txBuilder.SetGasLimit(gasLimit) - - // Theoretically speaking, ante handler unit tests should only test - // ante handlers, but here we sometimes also test the tx creation - // process. - tx, txErr := suite.CreateTestTx(privs, accNums, accSeqs, chainID) - newCtx, anteErr := suite.anteHandler(suite.ctx, tx, tc.simulate) - - if tc.expPass { - suite.Require().NoError(txErr) - suite.Require().NoError(anteErr) - suite.Require().NotNil(newCtx) - - suite.ctx = newCtx - } else { - switch { - case txErr != nil: - suite.Require().Error(txErr) - suite.Require().True(errors.Is(txErr, tc.expErr)) - - case anteErr != nil: - suite.Require().Error(anteErr) - suite.Require().True(errors.Is(anteErr, tc.expErr)) - - default: - suite.Fail("expected one of txErr,anteErr to be an error") - } - } - }) -} diff --git a/x/auth/client/testutil/cli_test.go b/x/auth/client/testutil/cli_test.go deleted file mode 100644 index e3365013ec00..000000000000 --- a/x/auth/client/testutil/cli_test.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/x/auth/testutil" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig) - require.NoError(t, err) - cfg.NumValidators = 2 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/auth/keeper/grpc_query_test.go b/x/auth/keeper/grpc_query_test.go index 3ecdcfe86f16..8b7f69e113e5 100644 --- a/x/auth/keeper/grpc_query_test.go +++ b/x/auth/keeper/grpc_query_test.go @@ -41,7 +41,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccounts() { addresses := make([]sdk.AccAddress, len(res.Accounts)) for i, acc := range res.Accounts { var account types.AccountI - err := suite.interfaceRegistry.UnpackAny(acc, &account) + err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) addresses[i] = account.GetAddress() } @@ -124,7 +124,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccount() { true, func(res *types.QueryAccountResponse) { var newAccount types.AccountI - err := suite.interfaceRegistry.UnpackAny(res.Account, &newAccount) + err := suite.encCfg.InterfaceRegistry.UnpackAny(res.Account, &newAccount) suite.Require().NoError(err) suite.Require().NotNil(newAccount) suite.Require().True(addr.Equals(newAccount.GetAddress())) @@ -277,7 +277,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { mintModuleExists := false for _, acc := range res.Accounts { var account types.AccountI - err := suite.interfaceRegistry.UnpackAny(acc, &account) + err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) moduleAccount, ok := account.(types.ModuleAccountI) @@ -300,7 +300,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { mintModuleExists := false for _, acc := range res.Accounts { var account types.AccountI - err := suite.interfaceRegistry.UnpackAny(acc, &account) + err := suite.encCfg.InterfaceRegistry.UnpackAny(acc, &account) suite.Require().NoError(err) moduleAccount, ok := account.(types.ModuleAccountI) @@ -331,7 +331,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { var moduleNames []string for _, any := range res.Accounts { var account types.AccountI - err := suite.interfaceRegistry.UnpackAny(any, &account) + err := suite.encCfg.InterfaceRegistry.UnpackAny(any, &account) suite.Require().NoError(err) moduleAccount, ok := account.(types.ModuleAccountI) suite.Require().True(ok) diff --git a/x/auth/keeper/keeper_test.go b/x/auth/keeper/keeper_test.go index d1f135ee9097..bc77a2648495 100644 --- a/x/auth/keeper/keeper_test.go +++ b/x/auth/keeper/keeper_test.go @@ -6,13 +6,11 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/runtime" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/keeper" - "github.com/cosmos/cosmos-sdk/x/auth/testutil" "github.com/cosmos/cosmos-sdk/x/auth/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -33,29 +31,39 @@ type KeeperTestSuite struct { ctx sdk.Context - app *runtime.App - queryClient types.QueryClient - legacyAmino *codec.LegacyAmino - interfaceRegistry codectypes.InterfaceRegistry - accountKeeper keeper.AccountKeeper - msgServer types.MsgServer + queryClient types.QueryClient + accountKeeper keeper.AccountKeeper + msgServer types.MsgServer + encCfg moduletestutil.TestEncodingConfig } func (suite *KeeperTestSuite) SetupTest() { - app, err := simtestutil.Setup( - testutil.AppConfig, - &suite.legacyAmino, - &suite.interfaceRegistry, - &suite.accountKeeper, - &suite.interfaceRegistry, + suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) + + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test")) + suite.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{}) + + maccPerms := map[string][]string{ + "fee_collector": nil, + "mint": {"minter"}, + "bonded_tokens_pool": {"burner", "staking"}, + "not_bonded_tokens_pool": {"burner", "staking"}, + multiPerm: {"burner", "minter", "staking"}, + randomPerm: {"random"}, + } + + suite.accountKeeper = keeper.NewAccountKeeper( + suite.encCfg.Codec, + key, + types.ProtoBaseAccount, + maccPerms, + "cosmos", + types.NewModuleAddress("gov").String(), ) - suite.Require().NoError(err) - suite.app = app - suite.ctx = app.BaseApp.NewContext(true, tmproto.Header{}) suite.msgServer = keeper.NewMsgServerImpl(suite.accountKeeper) - - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.interfaceRegistry) + queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.encCfg.InterfaceRegistry) types.RegisterQueryServer(queryHelper, suite.accountKeeper) suite.queryClient = types.NewQueryClient(queryHelper) } diff --git a/x/auth/keeper/querier.go b/x/auth/keeper/querier.go deleted file mode 100644 index 130aaacda9e9..000000000000 --- a/x/auth/keeper/querier.go +++ /dev/null @@ -1,61 +0,0 @@ -package keeper - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/types" -) - -// NewQuerier creates a querier for auth REST endpoints -func NewQuerier(k AccountKeeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryAccount: - return queryAccount(ctx, req, k, legacyQuerierCdc) - - case types.QueryParams: - return queryParams(ctx, k, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -func queryAccount(ctx sdk.Context, req abci.RequestQuery, k AccountKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryAccountRequest - if err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - addr, err := sdk.AccAddressFromBech32(params.Address) - if err != nil { - return nil, err - } - - account := k.GetAccount(ctx, addr) - if account == nil { - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "account %s does not exist", params.Address) - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, account) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryParams(ctx sdk.Context, k AccountKeeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - params := k.GetParams(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} diff --git a/x/auth/keeper/querier_test.go b/x/auth/keeper/querier_test.go deleted file mode 100644 index 7eef9c3b2e14..000000000000 --- a/x/auth/keeper/querier_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package keeper_test - -import ( - "fmt" - - "github.com/cosmos/cosmos-sdk/codec" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/testutil/testdata" - keep "github.com/cosmos/cosmos-sdk/x/auth/keeper" - "github.com/cosmos/cosmos-sdk/x/auth/types" -) - -func (suite *KeeperTestSuite) TestQueryAccount() { - ctx := suite.ctx - legacyQuerierCdc := codec.NewAminoCodec(suite.legacyAmino) - - req := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - - path := []string{types.QueryAccount} - querier := keep.NewQuerier(suite.accountKeeper, legacyQuerierCdc.LegacyAmino) - - bz, err := querier(ctx, []string{"other"}, req) - suite.Require().Error(err) - suite.Require().Nil(bz) - - req = abci.RequestQuery{ - Path: fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAccount), - Data: []byte{}, - } - res, err := querier(ctx, path, req) - suite.Require().Error(err) - suite.Require().Nil(res) - - req.Data = legacyQuerierCdc.MustMarshalJSON(&types.QueryAccountRequest{Address: ""}) - res, err = querier(ctx, path, req) - suite.Require().Error(err) - suite.Require().Nil(res) - - _, _, addr := testdata.KeyTestPubAddr() - req.Data = legacyQuerierCdc.MustMarshalJSON(&types.QueryAccountRequest{Address: addr.String()}) - res, err = querier(ctx, path, req) - suite.Require().Error(err) - suite.Require().Nil(res) - - suite.accountKeeper.SetAccount(ctx, suite.accountKeeper.NewAccountWithAddress(ctx, addr)) - res, err = querier(ctx, path, req) - suite.Require().NoError(err) - suite.Require().NotNil(res) - - res, err = querier(ctx, path, req) - suite.Require().NoError(err) - suite.Require().NotNil(res) - - var account types.AccountI - err2 := legacyQuerierCdc.LegacyAmino.UnmarshalJSON(res, &account) - suite.Require().Nil(err2) -} diff --git a/x/auth/module.go b/x/auth/module.go index 52052b362a83..2505e44bbc6a 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -118,21 +118,6 @@ func (AppModule) Name() string { // RegisterInvariants performs a no-op. func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the auth module. -func (AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the auth module's querier route name. -func (AppModule) QuerierRoute() string { - return types.QuerierRoute -} - -// LegacyQuerierHandler returns the auth module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.accountKeeper, legacyQuerierCdc) -} - // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { diff --git a/x/auth/signing/verify_test.go b/x/auth/signing/verify_test.go index 6e5d8f4f9fe3..fa06ef572084 100644 --- a/x/auth/signing/verify_test.go +++ b/x/auth/signing/verify_test.go @@ -5,22 +5,20 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/codec" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" + "github.com/cosmos/cosmos-sdk/testutil" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/signing" - authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil" "github.com/cosmos/cosmos-sdk/x/auth/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" ) @@ -33,29 +31,36 @@ func TestVerifySignature(t *testing.T) { chainId = "test-chain" ) - var ( - accountKeeper keeper.AccountKeeper - bankKeeper bankkeeper.Keeper - ) + encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) + key := sdk.NewKVStoreKey(types.StoreKey) - app, err := simtestutil.Setup(authtestutil.AppConfig, &accountKeeper, &bankKeeper) - require.NoError(t, err) + maccPerms := map[string][]string{ + "fee_collector": nil, + "mint": {"minter"}, + "bonded_tokens_pool": {"burner", "staking"}, + "not_bonded_tokens_pool": {"burner", "staking"}, + "multiPerm": {"burner", "minter", "staking"}, + "random": {"random"}, + } - ctx := app.BaseApp.NewContext(false, tmproto.Header{}).WithBlockHeight(1) + accountKeeper := keeper.NewAccountKeeper( + encCfg.Codec, + key, + types.ProtoBaseAccount, + maccPerms, + "cosmos", + types.NewModuleAddress("gov").String(), + ) - cdc := codec.NewLegacyAmino() - sdk.RegisterLegacyAminoCodec(cdc) - types.RegisterLegacyAminoCodec(cdc) - cdc.RegisterConcrete(testdata.TestMsg{}, "cosmos-sdk/Test", nil) + testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test")) + ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{}) + encCfg.Amino.RegisterConcrete(testdata.TestMsg{}, "cosmos-sdk/Test", nil) acc1 := accountKeeper.NewAccountWithAddress(ctx, addr) _ = accountKeeper.NewAccountWithAddress(ctx, addr1) accountKeeper.SetAccount(ctx, acc1) - balances := sdk.NewCoins(sdk.NewInt64Coin("atom", 200)) - require.NoError(t, testutil.FundAccount(bankKeeper, ctx, addr, balances)) acc, err := ante.GetSignerAcc(ctx, accountKeeper, addr) require.NoError(t, err) - require.NoError(t, testutil.FundAccount(bankKeeper, ctx, addr, balances)) msgs := []sdk.Msg{testdata.NewTestMsg(addr)} fee := legacytx.NewStdFee(50000, sdk.Coins{sdk.NewInt64Coin("atom", 150)}) @@ -71,7 +76,7 @@ func TestVerifySignature(t *testing.T) { require.NoError(t, err) stdSig := legacytx.StdSignature{PubKey: pubKey, Signature: signature} - sigV2, err := legacytx.StdSignatureToSignatureV2(cdc, stdSig) + sigV2, err := legacytx.StdSignatureToSignatureV2(encCfg.Amino, stdSig) require.NoError(t, err) handler := MakeTestHandlerMap() @@ -89,13 +94,13 @@ func TestVerifySignature(t *testing.T) { sig1, err := priv.Sign(multiSignBytes) require.NoError(t, err) stdSig1 := legacytx.StdSignature{PubKey: pubKey, Signature: sig1} - sig1V2, err := legacytx.StdSignatureToSignatureV2(cdc, stdSig1) + sig1V2, err := legacytx.StdSignatureToSignatureV2(encCfg.Amino, stdSig1) require.NoError(t, err) sig2, err := priv1.Sign(multiSignBytes) require.NoError(t, err) stdSig2 := legacytx.StdSignature{PubKey: pubKey, Signature: sig2} - sig2V2, err := legacytx.StdSignatureToSignatureV2(cdc, stdSig2) + sig2V2, err := legacytx.StdSignatureToSignatureV2(encCfg.Amino, stdSig2) require.NoError(t, err) err = multisig.AddSignatureFromPubKey(multisignature, sig1V2.Data, pkSet[0], pkSet) diff --git a/x/auth/testutil/app.yaml b/x/auth/testutil/app.yaml deleted file mode 100644 index d8a7275fd5de..000000000000 --- a/x/auth/testutil/app.yaml +++ /dev/null @@ -1,55 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: AuthApp - - begin_blockers: [staking, auth, bank, genutil, feegrant, params, vesting] - end_blockers: [staking, auth, bank, genutil, feegrant, params, vesting] - init_genesis: [auth, bank, staking, genutil, feegrant, params, vesting] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: mint - permissions: [minter] - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - account: multiple permissions account # dummy permissions - permissions: [burner, minter, staking] - - account: random permission - permissions: [random] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: feegrant - config: - "@type": cosmos.feegrant.module.v1.Module - - - name: vesting - config: - "@type": cosmos.vesting.module.v1.Module diff --git a/x/auth/testutil/app_config.go b/x/auth/testutil/app_config.go index f5d521c8ddad..9717d6c8d14e 100644 --- a/x/auth/testutil/app_config.go +++ b/x/auth/testutil/app_config.go @@ -1,22 +1,114 @@ package testutil import ( - _ "embed" - _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" _ "github.com/cosmos/cosmos-sdk/x/bank" _ "github.com/cosmos/cosmos-sdk/x/feegrant/module" _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/gov" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" "cosmossdk.io/core/appconfig" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" + genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" + stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1" + vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" ) -//go:embed app.yaml -var appConfig []byte +var AppConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ + { + Name: "runtime", + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "AuthApp", + BeginBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + vestingtypes.ModuleName, + }, + EndBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + vestingtypes.ModuleName, + }, + InitGenesis: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + stakingtypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + vestingtypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: "cosmos", + ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{ + {Account: authtypes.FeeCollectorName}, + {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, + {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: "multiple permissions account", Permissions: []string{authtypes.Minter, authtypes.Burner, stakingtypes.ModuleName}}, // dummy permissions + {Account: "random permission", Permissions: []string{"random"}}, + }, + }), + }, + { + Name: vestingtypes.ModuleName, + Config: appconfig.WrapAny(&vestingmodulev1.Module{}), + }, + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: stakingtypes.ModuleName, + Config: appconfig.WrapAny(&stakingmodulev1.Module{}), + }, + { + Name: paramstypes.ModuleName, + Config: appconfig.WrapAny(¶msmodulev1.Module{}), + }, + { + Name: "tx", + Config: appconfig.WrapAny(&txmodulev1.Module{}), + }, + { + Name: genutiltypes.ModuleName, + Config: appconfig.WrapAny(&genutilmodulev1.Module{}), + }, -var AppConfig = appconfig.LoadYAML(appConfig) + { + Name: feegrant.ModuleName, + Config: appconfig.WrapAny(&feegrantmodulev1.Module{}), + }, + }, +}) diff --git a/x/auth/testutil/expected_keepers_mocks.go b/x/auth/testutil/expected_keepers_mocks.go new file mode 100644 index 000000000000..97c2beed47e0 --- /dev/null +++ b/x/auth/testutil/expected_keepers_mocks.go @@ -0,0 +1,63 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: x/auth/types/expected_keepers.go + +// Package testutil is a generated GoMock package. +package testutil + +import ( + reflect "reflect" + + types "github.com/cosmos/cosmos-sdk/types" + gomock "github.com/golang/mock/gomock" +) + +// MockBankKeeper is a mock of BankKeeper interface. +type MockBankKeeper struct { + ctrl *gomock.Controller + recorder *MockBankKeeperMockRecorder +} + +// MockBankKeeperMockRecorder is the mock recorder for MockBankKeeper. +type MockBankKeeperMockRecorder struct { + mock *MockBankKeeper +} + +// NewMockBankKeeper creates a new mock instance. +func NewMockBankKeeper(ctrl *gomock.Controller) *MockBankKeeper { + mock := &MockBankKeeper{ctrl: ctrl} + mock.recorder = &MockBankKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBankKeeper) EXPECT() *MockBankKeeperMockRecorder { + return m.recorder +} + +// SendCoins mocks base method. +func (m *MockBankKeeper) SendCoins(ctx types.Context, from, to types.AccAddress, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoins", ctx, from, to, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoins indicates an expected call of SendCoins. +func (mr *MockBankKeeperMockRecorder) SendCoins(ctx, from, to, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoins", reflect.TypeOf((*MockBankKeeper)(nil).SendCoins), ctx, from, to, amt) +} + +// SendCoinsFromAccountToModule mocks base method. +func (m *MockBankKeeper) SendCoinsFromAccountToModule(ctx types.Context, senderAddr types.AccAddress, recipientModule string, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromAccountToModule indicates an expected call of SendCoinsFromAccountToModule. +func (mr *MockBankKeeperMockRecorder) SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromAccountToModule", reflect.TypeOf((*MockBankKeeper)(nil).SendCoinsFromAccountToModule), ctx, senderAddr, recipientModule, amt) +} diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index eb7cc44f7b1d..c9708f08b068 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -1,5 +1,3 @@ -// build +norace - package tx_test import ( diff --git a/x/auth/types/keys.go b/x/auth/types/keys.go index 0a3582ca294e..7dc4903ba34e 100644 --- a/x/auth/types/keys.go +++ b/x/auth/types/keys.go @@ -13,9 +13,6 @@ const ( // FeeCollectorName the root string for the fee collector account address FeeCollectorName = "fee_collector" - - // QuerierRoute is the querier route for auth - QuerierRoute = ModuleName ) var ( diff --git a/x/auth/types/params_legacy.go b/x/auth/types/params_legacy.go index 6131c56d11f1..d5ebfb29dc29 100644 --- a/x/auth/types/params_legacy.go +++ b/x/auth/types/params_legacy.go @@ -22,7 +22,7 @@ var _ paramtypes.ParamSet = &Params{} // ParamKeyTable for auth module // -// NOTE: Deprecated. +// Deprecated. func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } diff --git a/x/auth/vesting/client/testutil/cli_test.go b/x/auth/vesting/client/testutil/cli_test.go deleted file mode 100644 index 8c93153aadd9..000000000000 --- a/x/auth/vesting/client/testutil/cli_test.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/x/auth/vesting/testutil" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig) - require.NoError(t, err) - cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index b893e160c6fa..0fb256467c7a 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -92,25 +92,11 @@ func NewAppModule(ak keeper.AccountKeeper, bk types.BankKeeper) AppModule { // RegisterInvariants performs a no-op; there are no invariants to enforce. func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the module's message router and handler. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns an empty string as the module contains no query -// functionality. -func (AppModule) QuerierRoute() string { return "" } - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), NewMsgServerImpl(am.accountKeeper, am.bankKeeper)) } -// LegacyQuerierHandler performs a no-op. -func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { - return nil -} - // InitGenesis performs a no-op. func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} diff --git a/x/auth/vesting/testutil/app.yaml b/x/auth/vesting/testutil/app.yaml deleted file mode 100644 index 0d8e127b8170..000000000000 --- a/x/auth/vesting/testutil/app.yaml +++ /dev/null @@ -1,45 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: VestingApp - - begin_blockers: [staking, auth, bank, genutil, params, vesting] - end_blockers: [staking, auth, bank, genutil, params, vesting] - init_genesis: [auth, bank, staking, genutil, params, vesting] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: vesting - config: - "@type": cosmos.vesting.module.v1.Module diff --git a/x/auth/vesting/testutil/app_config.go b/x/auth/vesting/testutil/app_config.go deleted file mode 100644 index 1f6347c2b42a..000000000000 --- a/x/auth/vesting/testutil/app_config.go +++ /dev/null @@ -1,19 +0,0 @@ -package testutil - -import ( - _ "embed" - - "cosmossdk.io/core/appconfig" - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" - _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" -) - -//go:embed app.yaml -var appConfig []byte - -var AppConfig = appconfig.LoadYAML(appConfig) diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 6db8d7b29922..1ac901ba9972 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -4,6 +4,7 @@ import ( "errors" "time" + "cosmossdk.io/math" "sigs.k8s.io/yaml" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -69,7 +70,7 @@ func (bva *BaseVestingAccount) TrackDelegation(balance, vestingCoins, amount sdk // compute x and y per the specification, where: // X := min(max(V - DV, 0), D) // Y := D - X - x := sdk.MinInt(sdk.MaxInt(vestingAmt.Sub(delVestingAmt), sdk.ZeroInt()), coin.Amount) + x := sdk.MinInt(sdk.MaxInt(vestingAmt.Sub(delVestingAmt), math.ZeroInt()), coin.Amount) y := coin.Amount.Sub(x) if !x.IsZero() { diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index b00e8af358f3..8a773efa87b9 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -10,12 +10,13 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/auth/keeper" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/auth/vesting/testutil" + "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" ) @@ -32,10 +33,29 @@ type VestingAccountTestSuite struct { } func (s *VestingAccountTestSuite) SetupTest() { - app, err := simtestutil.Setup(testutil.AppConfig, &s.accountKeeper) - require.NoError(s.T(), err) + encCfg := moduletestutil.MakeTestEncodingConfig(vesting.AppModuleBasic{}) + + key := sdk.NewKVStoreKey(authtypes.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) + s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{}) + + maccPerms := map[string][]string{ + "fee_collector": nil, + "mint": {"minter"}, + "bonded_tokens_pool": {"burner", "staking"}, + "not_bonded_tokens_pool": {"burner", "staking"}, + "multiPerm": {"burner", "minter", "staking"}, + "random": {"random"}, + } - s.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) + s.accountKeeper = keeper.NewAccountKeeper( + encCfg.Codec, + key, + authtypes.ProtoBaseAccount, + maccPerms, + "cosmos", + authtypes.NewModuleAddress("gov").String(), + ) } func TestGetVestedCoinsContVestingAcc(t *testing.T) { diff --git a/x/authz/client/cli/tx.go b/x/authz/client/cli/tx.go index 8ebf8550d769..0e35e659235d 100644 --- a/x/authz/client/cli/tx.go +++ b/x/authz/client/cli/tx.go @@ -26,6 +26,7 @@ const ( FlagExpiration = "expiration" FlagAllowedValidators = "allowed-validators" FlagDenyValidators = "deny-validators" + FlagAllowList = "allow-list" delegate = "delegate" redelegate = "redelegate" unbond = "unbond" @@ -93,7 +94,18 @@ Examples: return fmt.Errorf("spend-limit should be greater than zero") } - authorization = bank.NewSendAuthorization(spendLimit) + allowList, err := cmd.Flags().GetStringSlice(FlagAllowList) + if err != nil { + return err + } + + allowed, err := bech32toAccAddresses(allowList) + if err != nil { + return err + } + + authorization = bank.NewSendAuthorization(spendLimit, allowed) + case "generic": msgType, err := cmd.Flags().GetString(FlagMsgType) if err != nil { @@ -140,12 +152,12 @@ Examples: delegateLimit = &spendLimit } - allowed, err := bech32toValidatorAddresses(allowValidators) + allowed, err := bech32toValAddresses(allowValidators) if err != nil { return err } - denied, err := bech32toValidatorAddresses(denyValidators) + denied, err := bech32toValAddresses(denyValidators) if err != nil { return err } @@ -184,6 +196,7 @@ Examples: cmd.Flags().String(FlagSpendLimit, "", "SpendLimit for Send Authorization, an array of Coins allowed spend") cmd.Flags().StringSlice(FlagAllowedValidators, []string{}, "Allowed validators addresses separated by ,") cmd.Flags().StringSlice(FlagDenyValidators, []string{}, "Deny validators addresses separated by ,") + cmd.Flags().StringSlice(FlagAllowList, []string{}, "Allowed addresses grantee is allowed to send funds separated by ,") cmd.Flags().Int64(FlagExpiration, 0, "Expire time as Unix timestamp. Set zero (0) for no expiry. Default is 0.") return cmd } @@ -273,7 +286,8 @@ Example: return cmd } -func bech32toValidatorAddresses(validators []string) ([]sdk.ValAddress, error) { +// bech32toValAddresses returns []ValAddress from a list of Bech32 string addresses. +func bech32toValAddresses(validators []string) ([]sdk.ValAddress, error) { vals := make([]sdk.ValAddress, len(validators)) for i, validator := range validators { addr, err := sdk.ValAddressFromBech32(validator) @@ -284,3 +298,16 @@ func bech32toValidatorAddresses(validators []string) ([]sdk.ValAddress, error) { } return vals, nil } + +// bech32toAccAddresses returns []AccAddress from a list of Bech32 string addresses. +func bech32toAccAddresses(accAddrs []string) ([]sdk.AccAddress, error) { + addrs := make([]sdk.AccAddress, len(accAddrs)) + for i, addr := range accAddrs { + accAddr, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return nil, err + } + addrs[i] = accAddr + } + return addrs, nil +} diff --git a/x/authz/client/testutil/grpc.go b/x/authz/client/testutil/grpc.go index 20a0f7c903fc..f29f858cb22a 100644 --- a/x/authz/client/testutil/grpc.go +++ b/x/authz/client/testutil/grpc.go @@ -195,7 +195,7 @@ func (s *IntegrationTestSuite) TestQueryGranterGrantsGRPC() { fmt.Sprintf("%s/cosmos/authz/v1beta1/grants/granter/%s", val.APIAddress, val.Address.String()), false, "", - 7, + 8, }, } for _, tc := range testCases { diff --git a/x/authz/client/testutil/query.go b/x/authz/client/testutil/query.go index 45921a054de6..f4326ad4173f 100644 --- a/x/authz/client/testutil/query.go +++ b/x/authz/client/testutil/query.go @@ -161,7 +161,18 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() { fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, false, - `{"@type":"/cosmos.bank.v1beta1.SendAuthorization","spend_limit":[{"denom":"stake","amount":"100"}]}`, + `{"@type":"/cosmos.bank.v1beta1.SendAuthorization","spend_limit":[{"denom":"stake","amount":"100"}],"allow_list":[]}`, + }, + { + "Valid txn with allowed list (json)", + []string{ + val.Address.String(), + s.grantee[3].String(), + typeMsgSend, + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + fmt.Sprintf(`{"@type":"/cosmos.bank.v1beta1.SendAuthorization","spend_limit":[{"denom":"stake","amount":"88"}],"allow_list":["%s"]}`, s.grantee[4]), }, } for _, tc := range testCases { @@ -221,7 +232,7 @@ func (s *IntegrationTestSuite) TestQueryGranterGrants() { }, false, "", - 7, + 8, }, { "valid case with pagination", diff --git a/x/authz/client/testutil/tx.go b/x/authz/client/testutil/tx.go index f6a6b0a714e1..537ac8319a9a 100644 --- a/x/authz/client/testutil/tx.go +++ b/x/authz/client/testutil/tx.go @@ -45,7 +45,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.Require().NoError(err) val := s.network.Validators[0] - s.grantee = make([]sdk.AccAddress, 3) + s.grantee = make([]sdk.AccAddress, 6) // Send some funds to the new account. // Create new account in the keyring. @@ -86,7 +86,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.grantee[2] = s.createAccount("grantee3") // grant send authorization to grantee3 - out, err = CreateGrant(val, []string{ + _, err = CreateGrant(val, []string{ s.grantee[2].String(), "send", fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), @@ -98,6 +98,30 @@ func (s *IntegrationTestSuite) SetupSuite() { }) s.Require().NoError(err) + // Create new accounts in the keyring. + s.grantee[3] = s.createAccount("grantee4") + s.msgSendExec(s.grantee[3]) + + s.grantee[4] = s.createAccount("grantee5") + s.grantee[5] = s.createAccount("grantee6") + + // grant send authorization with allow list to grantee4 + out, err = CreateGrant( + val, + []string{ + s.grantee[3].String(), + "send", + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, time.Now().Add(time.Minute*time.Duration(120)).Unix()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", cli.FlagAllowList, s.grantee[4]), + }, + ) + s.Require().NoError(err) + err = s.network.WaitForNextBlock() s.Require().NoError(err) @@ -404,6 +428,40 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { false, "", }, + { + "Valid tx send authorization with allow list", + []string{ + grantee.String(), + "send", + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", cli.FlagAllowList, s.grantee[1]), + }, + 0, + false, + "", + }, + { + "Invalid tx send authorization with duplicate allow list", + []string{ + grantee.String(), + "send", + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", cli.FlagAllowList, fmt.Sprintf("%s,%s", s.grantee[1], s.grantee[1])), + }, + 0, + true, + "duplicate entry", + }, { "Valid tx generic authorization", []string{ @@ -877,6 +935,86 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { } } +func (s *IntegrationTestSuite) TestExecSendAuthzWithAllowList() { + val := s.network.Validators[0] + grantee := s.grantee[3] + allowedAddr := s.grantee[4] + notAllowedAddr := s.grantee[5] + twoHours := time.Now().Add(time.Minute * time.Duration(120)).Unix() + + _, err := CreateGrant( + val, + []string{ + grantee.String(), + "send", + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", cli.FlagAllowList, allowedAddr), + }, + ) + s.Require().NoError(err) + + tokens := sdk.NewCoins( + sdk.NewCoin("stake", sdk.NewInt(12)), + ) + + validGeneratedTx, err := banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + allowedAddr, + tokens, + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), + ) + s.Require().NoError(err) + execMsg := testutil.WriteToNewTempFile(s.T(), validGeneratedTx.String()) + + invalidGeneratedTx, err := banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + notAllowedAddr, + tokens, + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), + ) + s.Require().NoError(err) + execMsg1 := testutil.WriteToNewTempFile(s.T(), invalidGeneratedTx.String()) + + // test sending to allowed address + args := []string{ + execMsg.Name(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + } + var response sdk.TxResponse + cmd := cli.NewCmdExecAuthorization() + out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) + + // test sending to not allowed address + args = []string{ + execMsg1.Name(), + fmt.Sprintf("--%s=%s", flags.FlagFrom, grantee.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + } + out, err = clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) + s.Require().NoError(err) + s.Contains(out.String(), fmt.Sprintf("cannot send to %s address", notAllowedAddr)) +} + func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { val := s.network.Validators[0] grantee := s.grantee[0] diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index 9acde8aa01a1..4083888440db 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -125,9 +125,10 @@ func (s *TestSuite) TestKeeperIter() { granteeAddr := addrs[1] granter2Addr := addrs[2] e := ctx.BlockTime().AddDate(1, 0, 0) + sendAuthz := banktypes.NewSendAuthorization(coins100, nil) - s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, banktypes.NewSendAuthorization(coins100), &e) - s.authzKeeper.SaveGrant(ctx, granteeAddr, granter2Addr, banktypes.NewSendAuthorization(coins100), &e) + s.authzKeeper.SaveGrant(ctx, granteeAddr, granterAddr, sendAuthz, &e) + s.authzKeeper.SaveGrant(ctx, granteeAddr, granter2Addr, sendAuthz, &e) s.authzKeeper.IterateGrants(ctx, func(granter, grantee sdk.AccAddress, grant authz.Grant) bool { s.Require().Equal(granteeAddr, grantee) @@ -144,7 +145,7 @@ func (s *TestSuite) TestDispatchAction() { granterAddr := addrs[0] granteeAddr := addrs[1] recipientAddr := addrs[2] - a := banktypes.NewSendAuthorization(coins100) + a := banktypes.NewSendAuthorization(coins100, nil) require.NoError(banktestutil.FundAccount(s.bankKeeper, s.ctx, granterAddr, coins1000)) diff --git a/x/authz/migrations/v046/store_test.go b/x/authz/migrations/v046/store_test.go index 0cefd65cf767..5d3241f452ef 100644 --- a/x/authz/migrations/v046/store_test.go +++ b/x/authz/migrations/v046/store_test.go @@ -35,6 +35,7 @@ func TestMigration(t *testing.T) { blockTime := ctx.BlockTime() oneDay := blockTime.AddDate(0, 0, 1) oneYear := blockTime.AddDate(1, 0, 0) + sendAuthz := banktypes.NewSendAuthorization(coins100, nil) grants := []struct { granter sdk.AccAddress @@ -47,7 +48,7 @@ func TestMigration(t *testing.T) { grantee1, sendMsgType, func() authz.Grant { - any, err := codectypes.NewAnyWithValue(banktypes.NewSendAuthorization(coins100)) + any, err := codectypes.NewAnyWithValue(sendAuthz) require.NoError(t, err) return authz.Grant{ Authorization: any, @@ -60,7 +61,7 @@ func TestMigration(t *testing.T) { grantee2, sendMsgType, func() authz.Grant { - any, err := codectypes.NewAnyWithValue(banktypes.NewSendAuthorization(coins100)) + any, err := codectypes.NewAnyWithValue(sendAuthz) require.NoError(t, err) return authz.Grant{ Authorization: any, diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index f1c447739a83..cc6deae50a85 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -44,9 +44,10 @@ func TestExpiredGrantsQueue(t *testing.T) { expiration := ctx.BlockTime().AddDate(0, 1, 0) expiration2 := expiration.AddDate(1, 0, 0) smallCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 10)) + sendAuthz := banktypes.NewSendAuthorization(smallCoins, nil) save := func(grantee sdk.AccAddress, exp *time.Time) { - err := authzKeeper.SaveGrant(ctx, grantee, granter, banktypes.NewSendAuthorization(smallCoins), exp) + err := authzKeeper.SaveGrant(ctx, grantee, granter, sendAuthz, exp) require.NoError(t, err, "Grant from %s", grantee.String()) } save(grantee1, &expiration) diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 29c12c7a5bc3..bced6e7a891d 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -128,23 +128,10 @@ func (AppModule) Name() string { // RegisterInvariants does nothing, there are no invariants to enforce func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the authz module. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - func (am AppModule) NewHandler() sdk.Handler { return nil } -// QuerierRoute returns the route we respond to for abci queries -func (AppModule) QuerierRoute() string { return "" } - -// LegacyQuerierHandler returns the authz module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return nil -} - // InitGenesis performs genesis initialization for the authz module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/authz/msgs_test.go b/x/authz/msgs_test.go index f1b357a2b974..5d7eb3c39fb9 100644 --- a/x/authz/msgs_test.go +++ b/x/authz/msgs_test.go @@ -174,7 +174,8 @@ func TestAminoJSON(t *testing.T) { require.NoError(t, err) grant, err := authz.NewGrant(blockTime, authz.NewGenericAuthorization(typeURL), &expiresAt) require.NoError(t, err) - sendGrant, err := authz.NewGrant(blockTime, banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000)))), &expiresAt) + sendAuthz := banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))), nil) + sendGrant, err := authz.NewGrant(blockTime, sendAuthz, &expiresAt) require.NoError(t, err) valAddr, err := sdk.ValAddressFromBech32("cosmosvaloper1xcy3els9ua75kdm783c3qu0rfa2eples6eavqq") require.NoError(t, err) diff --git a/x/authz/simulation/decoder_test.go b/x/authz/simulation/decoder_test.go index a5737ace5ee3..f197ac8c3716 100644 --- a/x/authz/simulation/decoder_test.go +++ b/x/authz/simulation/decoder_test.go @@ -26,7 +26,8 @@ func TestDecodeStore(t *testing.T) { now := time.Now().UTC() e := now.Add(1) - grant, _ := authz.NewGrant(now, banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewInt64Coin("foo", 123))), &e) + sendAuthz := banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewInt64Coin("foo", 123)), nil) + grant, _ := authz.NewGrant(now, sendAuthz, &e) grantBz, err := cdc.Marshal(&grant) require.NoError(t, err) kvPairs := kv.Pairs{ diff --git a/x/authz/simulation/genesis.go b/x/authz/simulation/genesis.go index 8c4609b7bb5c..e1443683bb18 100644 --- a/x/authz/simulation/genesis.go +++ b/x/authz/simulation/genesis.go @@ -37,7 +37,8 @@ func genGrant(r *rand.Rand, accounts []simtypes.Account, genT time.Time) []authz func generateRandomGrant(r *rand.Rand) *codectypes.Any { authorizations := make([]*codectypes.Any, 2) - authorizations[0] = newAnyAuthorization(banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))))) + sendAuthz := banktypes.NewSendAuthorization(sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))), nil) + authorizations[0] = newAnyAuthorization(sendAuthz) authorizations[1] = newAnyAuthorization(authz.NewGenericAuthorization(sdk.MsgTypeURL(&v1.MsgSubmitProposal{}))) return authorizations[r.Intn(len(authorizations))] @@ -57,7 +58,9 @@ func RandomizedGenState(simState *module.SimulationState) { var grants []authz.GrantAuthorization simState.AppParams.GetOrGenerate( simState.Cdc, "authz", &grants, simState.Rand, - func(r *rand.Rand) { grants = genGrant(r, simState.Accounts, simState.GenTimestamp) }, + func(r *rand.Rand) { + grants = genGrant(r, simState.Accounts, simState.GenTimestamp) + }, ) authzGrantsGenesis := authz.NewGenesisState(grants) diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index fdea8f349e3c..5418d6468d45 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -118,7 +118,9 @@ func SimulateMsgGrant(cdc *codec.ProtoCodec, ak authz.AccountKeeper, bk authz.Ba if !t1.Before(ctx.BlockTime()) { expiration = &t1 } - msg, err := authz.NewMsgGrant(granter.Address, grantee.Address, generateRandomAuthorization(r, spendLimit), expiration) + randomAuthz := generateRandomAuthorization(r, spendLimit) + + msg, err := authz.NewMsgGrant(granter.Address, grantee.Address, randomAuthz, expiration) if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, err.Error()), nil, err } @@ -148,7 +150,8 @@ func SimulateMsgGrant(cdc *codec.ProtoCodec, ak authz.AccountKeeper, bk authz.Ba func generateRandomAuthorization(r *rand.Rand, spendLimit sdk.Coins) authz.Authorization { authorizations := make([]authz.Authorization, 2) - authorizations[0] = banktype.NewSendAuthorization(spendLimit) + sendAuthz := banktype.NewSendAuthorization(spendLimit, nil) + authorizations[0] = sendAuthz authorizations[1] = authz.NewGenericAuthorization(sdk.MsgTypeURL(&banktype.MsgSend{})) return authorizations[r.Intn(len(authorizations))] diff --git a/x/authz/simulation/operations_test.go b/x/authz/simulation/operations_test.go index b599a7d88068..f2e1ce6dc50a 100644 --- a/x/authz/simulation/operations_test.go +++ b/x/authz/simulation/operations_test.go @@ -161,7 +161,7 @@ func (suite *SimTestSuite) TestSimulateRevoke() { granter := accounts[0] grantee := accounts[1] - a := banktypes.NewSendAuthorization(initCoins) + a := banktypes.NewSendAuthorization(initCoins, nil) expire := time.Now().Add(30 * time.Hour) err := suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire) @@ -196,7 +196,7 @@ func (suite *SimTestSuite) TestSimulateExec() { granter := accounts[0] grantee := accounts[1] - a := banktypes.NewSendAuthorization(initCoins) + a := banktypes.NewSendAuthorization(initCoins, nil) expire := suite.ctx.BlockTime().Add(1 * time.Hour) err := suite.authzKeeper.SaveGrant(suite.ctx, grantee.Address, granter.Address, a, &expire) diff --git a/x/authz/testutil/app.yaml b/x/authz/testutil/app.yaml deleted file mode 100644 index 1cc530e7de2d..000000000000 --- a/x/authz/testutil/app.yaml +++ /dev/null @@ -1,51 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - app_name: AuthzApp - begin_blockers: [mint, staking, auth, bank, genutil, authz, params] - end_blockers: [mint, staking, auth, bank, genutil, authz, params] - init_genesis: [auth, bank, staking, mint, genutil, authz, params] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: mint - permissions: [minter] - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - account: gov - permissions: [burner] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: authz - config: - "@type": cosmos.authz.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: mint - config: - "@type": cosmos.mint.module.v1.Module \ No newline at end of file diff --git a/x/authz/testutil/app_config.go b/x/authz/testutil/app_config.go index 104dbc12a93d..0a19fd6eb72e 100644 --- a/x/authz/testutil/app_config.go +++ b/x/authz/testutil/app_config.go @@ -1,8 +1,6 @@ package testutil import ( - _ "embed" - _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/authz/module" @@ -14,9 +12,102 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/staking" "cosmossdk.io/core/appconfig" -) + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -//go:embed app.yaml -var appConfig []byte + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + authzmodulev1 "cosmossdk.io/api/cosmos/authz/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" + paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" + stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1" +) -var AppConfig = appconfig.LoadYAML(appConfig) +var AppConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ + { + Name: "runtime", + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "AuthzApp", + BeginBlockers: []string{ + minttypes.ModuleName, + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + authz.ModuleName, + paramstypes.ModuleName, + }, + EndBlockers: []string{ + minttypes.ModuleName, + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + authz.ModuleName, + paramstypes.ModuleName, + }, + InitGenesis: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + stakingtypes.ModuleName, + minttypes.ModuleName, + genutiltypes.ModuleName, + authz.ModuleName, + paramstypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: "cosmos", + ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{ + {Account: authtypes.FeeCollectorName}, + {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, + {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: govtypes.ModuleName, Permissions: []string{authtypes.Burner}}, + }, + }), + }, + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: stakingtypes.ModuleName, + Config: appconfig.WrapAny(&stakingmodulev1.Module{}), + }, + { + Name: paramstypes.ModuleName, + Config: appconfig.WrapAny(¶msmodulev1.Module{}), + }, + { + Name: "tx", + Config: appconfig.WrapAny(&txmodulev1.Module{}), + }, + { + Name: genutiltypes.ModuleName, + Config: appconfig.WrapAny(&genutilmodulev1.Module{}), + }, + { + Name: authz.ModuleName, + Config: appconfig.WrapAny(&authzmodulev1.Module{}), + }, + { + Name: minttypes.ModuleName, + Config: appconfig.WrapAny(&mintmodulev1.Module{}), + }, + }, +}) diff --git a/x/bank/app_test.go b/x/bank/app_test.go index ef5621d34641..392728e989ab 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -10,6 +10,7 @@ import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -96,8 +97,8 @@ func TestSendNotEnoughBalance(t *testing.T) { sendMsg := types.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin("foocoin", 100)}) header := tmproto.Header{Height: app.LastBlockHeight() + 1} - txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{sendMsg}, "", []uint64{origAccNum}, []uint64{origSeq}, false, false, priv1) + txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig + _, _, err := simapp.SignCheckDeliver(t, txConfig, 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)}) @@ -171,8 +172,8 @@ func TestMsgMultiSendWithAccounts(t *testing.T) { for _, tc := range testCases { header := tmproto.Header{Height: app.LastBlockHeight() + 1} - txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig + _, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) if tc.expPass { require.NoError(t, err) } else { @@ -221,8 +222,8 @@ func TestMsgMultiSendMultipleOut(t *testing.T) { for _, tc := range testCases { header := tmproto.Header{Height: app.LastBlockHeight() + 1} - txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig + _, _, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) require.NoError(t, err) for _, eb := range tc.expectedBalances { @@ -273,8 +274,8 @@ func TestMsgMultiSendDependent(t *testing.T) { for _, tc := range testCases { header := tmproto.Header{Height: app.LastBlockHeight() + 1} - txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, tc.msgs, "", tc.accNums, tc.accSeqs, tc.expSimPass, tc.expPass, tc.privKeys...) + txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig + _, _, err := simapp.SignCheckDeliver(t, txConfig, 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/testutil/grpc.go b/x/bank/client/testutil/grpc.go index f09b26009011..f144ec7ce75f 100644 --- a/x/bank/client/testutil/grpc.go +++ b/x/bank/client/testutil/grpc.go @@ -3,6 +3,7 @@ package testutil import ( "fmt" + "cosmossdk.io/math" "github.com/gogo/protobuf/proto" "github.com/cosmos/cosmos-sdk/testutil" @@ -82,7 +83,7 @@ func (s *IntegrationTestSuite) TestTotalSupplyGRPCHandler() { }, &types.QuerySupplyOfResponse{}, &types.QuerySupplyOfResponse{ - Amount: sdk.NewCoin("foobar", sdk.ZeroInt()), + Amount: sdk.NewCoin("foobar", math.ZeroInt()), }, }, } diff --git a/x/bank/client/testutil/suite.go b/x/bank/client/testutil/suite.go index 73201fd5dacb..77efc07de9f1 100644 --- a/x/bank/client/testutil/suite.go +++ b/x/bank/client/testutil/suite.go @@ -144,7 +144,7 @@ func (s *IntegrationTestSuite) TestGetBalancesCmd() { }, false, &sdk.Coin{}, - NewCoin("foobar", sdk.ZeroInt()), + NewCoin("foobar", math.ZeroInt()), }, } @@ -214,7 +214,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { respType: &sdk.Coin{}, expected: &sdk.Coin{ Denom: "foobar", - Amount: sdk.ZeroInt(), + Amount: math.ZeroInt(), }, }, } diff --git a/x/bank/keeper/genesis_test.go b/x/bank/keeper/genesis_test.go index 0b70cfaac8db..1fe46852094d 100644 --- a/x/bank/keeper/genesis_test.go +++ b/x/bank/keeper/genesis_test.go @@ -7,35 +7,37 @@ import ( minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) -func (suite *IntegrationTestSuite) TestExportGenesis() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestExportGenesis() { + ctx := suite.ctx expectedMetadata := suite.getTestMetadata() expectedBalances, expTotalSupply := suite.getTestBalancesAndSupply() // Adding genesis supply to the expTotalSupply - genesisSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) + genesisSupply, _, err := suite.bankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) suite.Require().NoError(err) expTotalSupply = expTotalSupply.Add(genesisSupply...) for i := range []int{1, 2} { - app.BankKeeper.SetDenomMetaData(ctx, expectedMetadata[i]) + suite.bankKeeper.SetDenomMetaData(ctx, expectedMetadata[i]) accAddr, err1 := sdk.AccAddressFromBech32(expectedBalances[i].Address) if err1 != nil { panic(err1) } // set balances via mint and send + suite.mockMintCoins(mintAcc) suite. Require(). - NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, expectedBalances[i].Coins)) + NoError(suite.bankKeeper.MintCoins(ctx, minttypes.ModuleName, expectedBalances[i].Coins)) + suite.mockSendCoinsFromModuleToAccount(mintAcc, accAddr) suite. Require(). - NoError(app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, accAddr, expectedBalances[i].Coins)) + NoError(suite.bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, accAddr, expectedBalances[i].Coins)) } - suite.Require().NoError(app.BankKeeper.SetParams(ctx, types.DefaultParams())) + suite.Require().NoError(suite.bankKeeper.SetParams(ctx, types.DefaultParams())) - exportGenesis := app.BankKeeper.ExportGenesis(ctx) + exportGenesis := suite.bankKeeper.ExportGenesis(ctx) suite.Require().Len(exportGenesis.Params.SendEnabled, 0) suite.Require().Equal(types.DefaultParams().DefaultSendEnabled, exportGenesis.Params.DefaultSendEnabled) @@ -44,7 +46,7 @@ func (suite *IntegrationTestSuite) TestExportGenesis() { suite.Require().Equal(expectedMetadata, exportGenesis.DenomMetadata) } -func (suite *IntegrationTestSuite) getTestBalancesAndSupply() ([]types.Balance, sdk.Coins) { +func (suite *KeeperTestSuite) getTestBalancesAndSupply() ([]types.Balance, sdk.Coins) { addr2, _ := sdk.AccAddressFromBech32("cosmos1f9xjhxm0plzrh9cskf4qee4pc2xwp0n0556gh0") addr1, _ := sdk.AccAddressFromBech32("cosmos1t5u0jfg3ljsjrh2m9e47d4ny2hea7eehxrzdgd") addr1Balance := sdk.Coins{sdk.NewInt64Coin("testcoin3", 10)} @@ -59,11 +61,11 @@ func (suite *IntegrationTestSuite) getTestBalancesAndSupply() ([]types.Balance, }, totalSupply } -func (suite *IntegrationTestSuite) TestInitGenesis() { +func (suite *KeeperTestSuite) TestInitGenesis() { m := types.Metadata{Description: sdk.DefaultBondDenom, Base: sdk.DefaultBondDenom, Display: sdk.DefaultBondDenom} g := types.DefaultGenesisState() g.DenomMetadata = []types.Metadata{m} - bk := suite.app.BankKeeper + bk := suite.bankKeeper bk.InitGenesis(suite.ctx, g) m2, found := bk.GetDenomMetaData(suite.ctx, m.Base) @@ -71,7 +73,7 @@ func (suite *IntegrationTestSuite) TestInitGenesis() { suite.Require().Equal(m, m2) } -func (suite *IntegrationTestSuite) TestTotalSupply() { +func (suite *KeeperTestSuite) TestTotalSupply() { // Prepare some test data. defaultGenesis := types.DefaultGenesisState() balances := []types.Balance{ @@ -81,7 +83,7 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { } totalSupply := sdk.NewCoins(sdk.NewCoin("foocoin", sdk.NewInt(11)), sdk.NewCoin("barcoin", sdk.NewInt(21))) - genesisSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) + genesisSupply, _, err := suite.bankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) suite.Require().NoError(err) testcases := []struct { @@ -112,10 +114,10 @@ func (suite *IntegrationTestSuite) TestTotalSupply() { tc := tc suite.Run(tc.name, func() { if tc.expPanic { - suite.PanicsWithError(tc.expPanicMsg, func() { suite.app.BankKeeper.InitGenesis(suite.ctx, tc.genesis) }) + suite.PanicsWithError(tc.expPanicMsg, func() { suite.bankKeeper.InitGenesis(suite.ctx, tc.genesis) }) } else { - suite.app.BankKeeper.InitGenesis(suite.ctx, tc.genesis) - totalSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) + suite.bankKeeper.InitGenesis(suite.ctx, tc.genesis) + totalSupply, _, err := suite.bankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) suite.Require().NoError(err) // adding genesis supply to expected supply diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 8c7d3f6d51ed..3ea34a445212 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -92,7 +92,7 @@ func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpend balances := sdk.NewCoins() accountStore := k.getAccountStore(sdkCtx, addr) - zeroAmt := sdk.ZeroInt() + zeroAmt := math.ZeroInt() pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, _ []byte) error { balances = append(balances, sdk.NewCoin(string(key), zeroAmt)) diff --git a/x/bank/keeper/grpc_query_test.go b/x/bank/keeper/grpc_query_test.go index a67cf0401e18..38b37a4fb2ef 100644 --- a/x/bank/keeper/grpc_query_test.go +++ b/x/bank/keeper/grpc_query_test.go @@ -5,7 +5,6 @@ import ( "fmt" "time" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" @@ -16,8 +15,8 @@ import ( minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) -func (suite *IntegrationTestSuite) TestQueryBalance() { - app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient +func (suite *KeeperTestSuite) TestQueryBalance() { + ctx, queryClient := suite.ctx, suite.queryClient _, _, addr := testdata.KeyTestPubAddr() _, err := queryClient.Balance(gocontext.Background(), &types.QueryBalanceRequest{}) @@ -33,10 +32,9 @@ func (suite *IntegrationTestSuite) TestQueryBalance() { suite.True(res.Balance.IsZero()) origCoins := sdk.NewCoins(newFooCoin(50), newBarCoin(30)) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) - app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) + suite.mockFundAccount(addr) + suite.Require().NoError(testutil.FundAccount(suite.bankKeeper, ctx, addr, origCoins)) res, err = queryClient.Balance(gocontext.Background(), req) suite.Require().NoError(err) @@ -44,8 +42,8 @@ func (suite *IntegrationTestSuite) TestQueryBalance() { suite.True(res.Balance.IsEqual(newFooCoin(50))) } -func (suite *IntegrationTestSuite) TestQueryAllBalances() { - app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient +func (suite *KeeperTestSuite) TestQueryAllBalances() { + ctx, queryClient := suite.ctx, suite.queryClient _, _, addr := testdata.KeyTestPubAddr() _, err := queryClient.AllBalances(gocontext.Background(), &types.QueryAllBalancesRequest{}) suite.Require().Error(err) @@ -65,10 +63,9 @@ func (suite *IntegrationTestSuite) TestQueryAllBalances() { barCoins := newBarCoin(30) origCoins := sdk.NewCoins(fooCoins, barCoins) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) - app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) + suite.mockFundAccount(addr) + suite.Require().NoError(testutil.FundAccount(suite.bankKeeper, ctx, addr, origCoins)) res, err = queryClient.AllBalances(gocontext.Background(), req) suite.Require().NoError(err) @@ -89,10 +86,11 @@ func (suite *IntegrationTestSuite) TestQueryAllBalances() { suite.Nil(res.Pagination.NextKey) } -func (suite *IntegrationTestSuite) TestSpendableBalances() { - app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient +func (suite *KeeperTestSuite) TestSpendableBalances() { + ctx := suite.ctx _, _, addr := testdata.KeyTestPubAddr() ctx = ctx.WithBlockTime(time.Now()) + queryClient := suite.mockQueryClient(ctx) _, err := queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), &types.QuerySpendableBalancesRequest{}) suite.Require().Error(err) @@ -103,7 +101,9 @@ func (suite *IntegrationTestSuite) TestSpendableBalances() { CountTotal: false, } req := types.NewQuerySpendableBalancesRequest(addr, pageReq) + acc := authtypes.NewBaseAccountWithAddress(addr) + suite.mockSpendableCoins(ctx, acc) res, err := queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), req) suite.Require().NoError(err) suite.Require().NotNil(res) @@ -113,23 +113,21 @@ func (suite *IntegrationTestSuite) TestSpendableBalances() { barCoins := newBarCoin(30) origCoins := sdk.NewCoins(fooCoins, barCoins) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) - acc = vestingtypes.NewContinuousVestingAccount( - acc.(*authtypes.BaseAccount), + vacc := vestingtypes.NewContinuousVestingAccount( + acc, sdk.NewCoins(fooCoins), ctx.BlockTime().Unix(), ctx.BlockTime().Add(time.Hour).Unix(), ) - app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) + suite.mockFundAccount(addr) + suite.Require().NoError(testutil.FundAccount(suite.bankKeeper, suite.ctx, addr, origCoins)) // move time forward for some tokens to vest ctx = ctx.WithBlockTime(ctx.BlockTime().Add(30 * time.Minute)) - queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, app.BankKeeper) - queryClient = types.NewQueryClient(queryHelper) + queryClient = suite.mockQueryClient(ctx) + suite.mockSpendableCoins(ctx, vacc) res, err = queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), req) suite.Require().NoError(err) suite.Require().NotNil(res) @@ -139,35 +137,38 @@ func (suite *IntegrationTestSuite) TestSpendableBalances() { suite.EqualValues(25, res.Balances[1].Amount.Int64()) } -func (suite *IntegrationTestSuite) TestQueryTotalSupply() { - app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient +func (suite *KeeperTestSuite) TestQueryTotalSupply() { + ctx, queryClient := suite.ctx, suite.queryClient res, err := queryClient.TotalSupply(gocontext.Background(), &types.QueryTotalSupplyRequest{}) suite.Require().NoError(err) genesisSupply := res.Supply - testCoins := sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)) + + suite.mockMintCoins(mintAcc) suite. Require(). - NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, testCoins)) + NoError(suite.bankKeeper.MintCoins(ctx, minttypes.ModuleName, testCoins)) res, err = queryClient.TotalSupply(gocontext.Background(), &types.QueryTotalSupplyRequest{}) suite.Require().NoError(err) suite.Require().NotNil(res) expectedTotalSupply := genesisSupply.Add(testCoins...) - suite.Require().Equal(2, len(res.Supply)) + suite.Require().Equal(1, len(res.Supply)) suite.Require().Equal(res.Supply, expectedTotalSupply) } -func (suite *IntegrationTestSuite) TestQueryTotalSupplyOf() { - app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient +func (suite *KeeperTestSuite) TestQueryTotalSupplyOf() { + ctx, queryClient := suite.ctx, suite.queryClient test1Supply := sdk.NewInt64Coin("test1", 4000000) test2Supply := sdk.NewInt64Coin("test2", 700000000) expectedTotalSupply := sdk.NewCoins(test1Supply, test2Supply) + + suite.mockMintCoins(mintAcc) suite. Require(). - NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, expectedTotalSupply)) + NoError(suite.bankKeeper.MintCoins(ctx, minttypes.ModuleName, expectedTotalSupply)) _, err := queryClient.SupplyOf(gocontext.Background(), &types.QuerySupplyOfRequest{}) suite.Require().Error(err) @@ -179,14 +180,14 @@ func (suite *IntegrationTestSuite) TestQueryTotalSupplyOf() { suite.Require().Equal(test1Supply, res.Amount) } -func (suite *IntegrationTestSuite) TestQueryParams() { +func (suite *KeeperTestSuite) TestQueryParams() { res, err := suite.queryClient.Params(gocontext.Background(), &types.QueryParamsRequest{}) suite.Require().NoError(err) suite.Require().NotNil(res) - suite.Require().Equal(suite.app.BankKeeper.GetParams(suite.ctx), res.GetParams()) + suite.Require().Equal(suite.bankKeeper.GetParams(suite.ctx), res.GetParams()) } -func (suite *IntegrationTestSuite) QueryDenomsMetadataRequest() { +func (suite *KeeperTestSuite) QueryDenomsMetadataRequest() { var ( req *types.QueryDenomsMetadataRequest expMetadata = []types.Metadata{} @@ -254,8 +255,8 @@ func (suite *IntegrationTestSuite) QueryDenomsMetadataRequest() { Display: "eth", } - suite.app.BankKeeper.SetDenomMetaData(suite.ctx, metadataAtom) - suite.app.BankKeeper.SetDenomMetaData(suite.ctx, metadataEth) + suite.bankKeeper.SetDenomMetaData(suite.ctx, metadataAtom) + suite.bankKeeper.SetDenomMetaData(suite.ctx, metadataEth) expMetadata = []types.Metadata{metadataAtom, metadataEth} req = &types.QueryDenomsMetadataRequest{ Pagination: &query.PageRequest{ @@ -288,7 +289,7 @@ func (suite *IntegrationTestSuite) QueryDenomsMetadataRequest() { } } -func (suite *IntegrationTestSuite) QueryDenomMetadataRequest() { +func (suite *KeeperTestSuite) QueryDenomMetadataRequest() { var ( req *types.QueryDenomMetadataRequest expMetadata = types.Metadata{} @@ -336,7 +337,7 @@ func (suite *IntegrationTestSuite) QueryDenomMetadataRequest() { Display: "atom", } - suite.app.BankKeeper.SetDenomMetaData(suite.ctx, expMetadata) + suite.bankKeeper.SetDenomMetaData(suite.ctx, expMetadata) req = &types.QueryDenomMetadataRequest{ Denom: expMetadata.Base, } @@ -365,21 +366,23 @@ func (suite *IntegrationTestSuite) QueryDenomMetadataRequest() { } } -func (suite *IntegrationTestSuite) TestGRPCDenomOwners() { +func (suite *KeeperTestSuite) TestGRPCDenomOwners() { ctx := suite.ctx - authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) + keeper := suite.bankKeeper + + suite.mockMintCoins(mintAcc) suite.Require().NoError(keeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) for i := 0; i < 10; i++ { - acc := authKeeper.NewAccountWithAddress(ctx, authtypes.NewModuleAddress(fmt.Sprintf("account-%d", i))) - authKeeper.SetAccount(ctx, acc) + addr := sdk.AccAddress([]byte(fmt.Sprintf("account-%d", i))) bal := sdk.NewCoins(sdk.NewCoin( sdk.DefaultBondDenom, sdk.TokensFromConsensusPower(initialPower/10, sdk.DefaultPowerReduction), )) - suite.Require().NoError(keeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, acc.GetAddress(), bal)) + suite.mockSendCoinsFromModuleToAccount(mintAcc, addr) + suite.Require().NoError(keeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, bal)) } testCases := map[string]struct { @@ -413,7 +416,7 @@ func (suite *IntegrationTestSuite) TestGRPCDenomOwners() { expPass: true, numAddrs: 6, hasNext: true, - total: 13, + total: 10, }, "valid request - page 2": { req: &types.QueryDenomOwnersRequest{ @@ -425,9 +428,9 @@ func (suite *IntegrationTestSuite) TestGRPCDenomOwners() { }, }, expPass: true, - numAddrs: 7, + numAddrs: 4, hasNext: false, - total: 13, + total: 10, }, } @@ -454,8 +457,8 @@ func (suite *IntegrationTestSuite) TestGRPCDenomOwners() { suite.Require().True(true) } -func (suite *IntegrationTestSuite) TestQuerySendEnabled() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper +func (suite *KeeperTestSuite) TestQuerySendEnabled() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper bankKeeper.SetSendEnabled(ctx, "falsestcoin", false) bankKeeper.SetSendEnabled(ctx, "truestcoin", true) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index f294ed470c3a..a800b19d2387 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -6,8 +6,9 @@ import ( "testing" "time" + "cosmossdk.io/math" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" @@ -15,16 +16,17 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/types/query" - authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/bank/exported" "github.com/cosmos/cosmos-sdk/x/bank/keeper" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" - "github.com/cosmos/cosmos-sdk/x/bank/types" + banktestutil "github.com/cosmos/cosmos-sdk/x/bank/testutil" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -40,11 +42,21 @@ const ( ) var ( - holderAcc = authtypes.NewEmptyModuleAccount(holder) - burnerAcc = authtypes.NewEmptyModuleAccount(authtypes.Burner, authtypes.Burner) - minterAcc = authtypes.NewEmptyModuleAccount(authtypes.Minter, authtypes.Minter) - multiPermAcc = authtypes.NewEmptyModuleAccount(multiPerm, authtypes.Burner, authtypes.Minter, authtypes.Staking) - randomPermAcc = authtypes.NewEmptyModuleAccount(randomPerm, "random") + holderAcc = authtypes.NewEmptyModuleAccount(holder) + burnerAcc = authtypes.NewEmptyModuleAccount(authtypes.Burner, authtypes.Burner) + minterAcc = authtypes.NewEmptyModuleAccount(authtypes.Minter, authtypes.Minter) + mintAcc = authtypes.NewEmptyModuleAccount(minttypes.ModuleName, authtypes.Minter) + multiPermAcc = authtypes.NewEmptyModuleAccount(multiPerm, authtypes.Burner, authtypes.Minter, authtypes.Staking) + + baseAcc = authtypes.NewBaseAccountWithAddress(sdk.AccAddress([]byte("baseAcc"))) + + accAddrs = []sdk.AccAddress{ + sdk.AccAddress([]byte("addr1_______________")), + sdk.AccAddress([]byte("addr2_______________")), + sdk.AccAddress([]byte("addr3_______________")), + sdk.AccAddress([]byte("addr4_______________")), + sdk.AccAddress([]byte("addr5_______________")), + } // The default power validators are initialized to have within tests initTokens = sdk.TokensFromConsensusPower(initialPower, sdk.DefaultPowerReduction) @@ -59,81 +71,148 @@ func newBarCoin(amt int64) sdk.Coin { return sdk.NewInt64Coin(barDenom, amt) } -// nolint: interfacer -func getCoinsByName(ctx sdk.Context, bk keeper.Keeper, ak types.AccountKeeper, moduleName string) sdk.Coins { - moduleAddress := ak.GetModuleAddress(moduleName) - macc := ak.GetAccount(ctx, moduleAddress) - if macc == nil { - return sdk.Coins(nil) - } +type KeeperTestSuite struct { + suite.Suite - return bk.GetAllBalances(ctx, macc.GetAddress()) -} + ctx sdk.Context + bankKeeper keeper.BaseKeeper + authKeeper *banktestutil.MockAccountKeeper -type IntegrationTestSuite struct { - suite.Suite + queryClient banktypes.QueryClient + msgServer banktypes.MsgServer - app *simapp.SimApp - ctx sdk.Context - queryClient types.QueryClient - msgServer types.MsgServer + encCfg moduletestutil.TestEncodingConfig } -func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[string]bool) (authkeeper.AccountKeeper, keeper.BaseKeeper) { - app := suite.app - maccPerms := simapp.GetMaccPerms() - appCodec := simapp.MakeTestEncodingConfig().Codec - - maccPerms[holder] = nil - maccPerms[authtypes.Burner] = []string{authtypes.Burner} - maccPerms[authtypes.Minter] = []string{authtypes.Minter} - maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} - maccPerms[randomPerm] = []string{"random"} - authKeeper := authkeeper.NewAccountKeeper( - appCodec, app.GetKey(types.StoreKey), authtypes.ProtoBaseAccount, - maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - keeper := keeper.NewBaseKeeper( - appCodec, app.GetKey(types.StoreKey), authKeeper, blockedAddrs, authtypes.NewModuleAddress(govtypes.ModuleName).String(), +func (suite *KeeperTestSuite) SetupTest() { + key := sdk.NewKVStoreKey(banktypes.StoreKey) + testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test")) + ctx := testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: tmtime.Now()}) + encCfg := moduletestutil.MakeTestEncodingConfig() + + // gomock initializations + ctrl := gomock.NewController(suite.T()) + authKeeper := banktestutil.NewMockAccountKeeper(ctrl) + + suite.ctx = ctx + suite.authKeeper = authKeeper + suite.bankKeeper = keeper.NewBaseKeeper( + encCfg.Codec, + key, + suite.authKeeper, + map[string]bool{accAddrs[4].String(): true}, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - return authKeeper, keeper + banktypes.RegisterInterfaces(encCfg.InterfaceRegistry) + + queryHelper := baseapp.NewQueryServerTestHelper(ctx, encCfg.InterfaceRegistry) + banktypes.RegisterQueryServer(queryHelper, suite.bankKeeper) + queryClient := banktypes.NewQueryClient(queryHelper) + + suite.queryClient = queryClient + suite.msgServer = keeper.NewMsgServerImpl(suite.bankKeeper) + suite.encCfg = encCfg } -func (suite *IntegrationTestSuite) SetupTest() { - suite.app = simapp.Setup(suite.T(), false) - suite.ctx = suite.app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) +func (suite *KeeperTestSuite) mockQueryClient(ctx sdk.Context) banktypes.QueryClient { + queryHelper := baseapp.NewQueryServerTestHelper(ctx, suite.encCfg.InterfaceRegistry) + banktypes.RegisterQueryServer(queryHelper, suite.bankKeeper) + return banktypes.NewQueryClient(queryHelper) +} - suite.Require().NoError(suite.app.AccountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())) - suite.Require().NoError(suite.app.BankKeeper.SetParams(suite.ctx, types.DefaultParams())) +func (suite *KeeperTestSuite) mockMintCoins(moduleAcc *authtypes.ModuleAccount) { + suite.authKeeper.EXPECT().GetModuleAccount(suite.ctx, moduleAcc.Name).Return(moduleAcc) +} - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.app.InterfaceRegistry()) - types.RegisterQueryServer(queryHelper, suite.app.BankKeeper) - queryClient := types.NewQueryClient(queryHelper) - types.RegisterInterfaces(suite.app.InterfaceRegistry()) +func (suite *KeeperTestSuite) mockSendCoinsFromModuleToAccount(moduleAcc *authtypes.ModuleAccount, accAddr sdk.AccAddress) { + suite.authKeeper.EXPECT().GetModuleAddress(moduleAcc.Name).Return(moduleAcc.GetAddress()) + suite.authKeeper.EXPECT().GetAccount(suite.ctx, moduleAcc.GetAddress()).Return(moduleAcc) + suite.authKeeper.EXPECT().HasAccount(suite.ctx, accAddr).Return(true) +} - suite.queryClient = queryClient - suite.msgServer = keeper.NewMsgServerImpl(suite.app.BankKeeper) +func (suite *KeeperTestSuite) mockBurnCoins(moduleAcc *authtypes.ModuleAccount) { + suite.authKeeper.EXPECT().GetModuleAccount(suite.ctx, moduleAcc.Name).Return(moduleAcc) + suite.authKeeper.EXPECT().GetAccount(suite.ctx, moduleAcc.GetAddress()).Return(moduleAcc) } -func (suite *IntegrationTestSuite) TestSupply() { - ctx := suite.ctx +func (suite *KeeperTestSuite) mockSendCoinsFromModuleToModule(sender *authtypes.ModuleAccount, receiver *authtypes.ModuleAccount) { + suite.authKeeper.EXPECT().GetModuleAddress(sender.Name).Return(sender.GetAddress()) + suite.authKeeper.EXPECT().GetModuleAccount(suite.ctx, receiver.Name).Return(receiver) + suite.authKeeper.EXPECT().GetAccount(suite.ctx, sender.GetAddress()).Return(sender) + suite.authKeeper.EXPECT().HasAccount(suite.ctx, receiver.GetAddress()).Return(true) +} +func (suite *KeeperTestSuite) mockSendCoinsFromAccountToModule(acc *authtypes.BaseAccount, moduleAcc *authtypes.ModuleAccount) { + suite.authKeeper.EXPECT().GetModuleAccount(suite.ctx, moduleAcc.Name).Return(moduleAcc) + suite.authKeeper.EXPECT().GetAccount(suite.ctx, acc.GetAddress()).Return(acc) + suite.authKeeper.EXPECT().HasAccount(suite.ctx, moduleAcc.GetAddress()).Return(true) +} + +func (suite *KeeperTestSuite) mockSendCoins(ctx sdk.Context, sender authtypes.AccountI, receiver sdk.AccAddress) { + suite.authKeeper.EXPECT().GetAccount(ctx, sender.GetAddress()).Return(sender) + suite.authKeeper.EXPECT().HasAccount(ctx, receiver).Return(true) +} + +func (suite *KeeperTestSuite) mockFundAccount(receiver sdk.AccAddress) { + suite.mockMintCoins(mintAcc) + suite.mockSendCoinsFromModuleToAccount(mintAcc, receiver) +} + +func (suite *KeeperTestSuite) mockInputOutputCoins(inputs []authtypes.AccountI, outputs []sdk.AccAddress) { + for _, input := range inputs { + suite.authKeeper.EXPECT().GetAccount(suite.ctx, input.GetAddress()).Return(input) + } + for _, output := range outputs { + suite.authKeeper.EXPECT().HasAccount(suite.ctx, output).Return(true) + } +} + +func (suite *KeeperTestSuite) mockValidateBalance(acc authtypes.AccountI) { + suite.authKeeper.EXPECT().GetAccount(suite.ctx, acc.GetAddress()).Return(acc) +} + +func (suite *KeeperTestSuite) mockSpendableCoins(ctx sdk.Context, acc authtypes.AccountI) { + suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) +} + +func (suite *KeeperTestSuite) mockDelegateCoins(ctx sdk.Context, acc authtypes.AccountI, mAcc authtypes.AccountI) { + vacc, ok := acc.(banktypes.VestingAccount) + if ok { + suite.authKeeper.EXPECT().SetAccount(ctx, vacc) + } + suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) + suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) +} + +func (suite *KeeperTestSuite) mockUnDelegateCoins(ctx sdk.Context, acc authtypes.AccountI, mAcc authtypes.AccountI) { + vacc, ok := acc.(banktypes.VestingAccount) + if ok { + suite.authKeeper.EXPECT().SetAccount(ctx, vacc) + } + suite.authKeeper.EXPECT().GetAccount(ctx, acc.GetAddress()).Return(acc) + suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) + suite.authKeeper.EXPECT().GetAccount(ctx, mAcc.GetAddress()).Return(mAcc) +} + +func (suite *KeeperTestSuite) TestSupply() { + ctx := suite.ctx require := suite.Require() + keeper := suite.bankKeeper // add module accounts to supply keeper - authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) - genesisSupply, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) require.NoError(err) initialPower := int64(100) - initTokens := suite.app.StakingKeeper.TokensFromConsensusPower(ctx, initialPower) + initTokens := sdk.TokensFromConsensusPower(initialPower, sdk.DefaultPowerReduction) initCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens)) // set burnerAcc balance - authKeeper.SetModuleAccount(ctx, burnerAcc) + suite.mockMintCoins(minterAcc) require.NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) + + suite.mockSendCoinsFromModuleToAccount(minterAcc, burnerAcc.GetAddress()) require.NoError(keeper.SendCoinsFromModuleToAccount(ctx, authtypes.Minter, burnerAcc.GetAddress(), initCoins)) total, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) @@ -143,436 +222,432 @@ func (suite *IntegrationTestSuite) TestSupply() { require.Equal(expTotalSupply, total) // burning all supplied tokens - err = keeper.BurnCoins(ctx, authtypes.Burner, initCoins) - require.NoError(err) + suite.mockBurnCoins(burnerAcc) + require.NoError(keeper.BurnCoins(ctx, authtypes.Burner, initCoins)) total, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) require.NoError(err) require.Equal(total, genesisSupply) } -func (suite *IntegrationTestSuite) TestSendCoinsFromModuleToAccount_Blocklist() { +func (suite *KeeperTestSuite) TestSendCoinsFromModuleToAccount_Blocklist() { ctx := suite.ctx + require := suite.Require() + keeper := suite.bankKeeper - // add module accounts to supply keeper - addr1 := sdk.AccAddress([]byte("addr1_______________")) - _, keeper := suite.initKeepersWithmAccPerms(map[string]bool{addr1.String(): true}) + suite.mockMintCoins(mintAcc) + require.NoError(keeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) - suite.Require().NoError(keeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) - suite.Require().Error(keeper.SendCoinsFromModuleToAccount( - ctx, minttypes.ModuleName, addr1, initCoins, + suite.authKeeper.EXPECT().GetModuleAddress(mintAcc.Name).Return(mintAcc.GetAddress()) + require.Error(keeper.SendCoinsFromModuleToAccount( + ctx, minttypes.ModuleName, accAddrs[4], initCoins, )) } -func (suite *IntegrationTestSuite) TestSupply_SendCoins() { +func (suite *KeeperTestSuite) TestSupply_SendCoins() { ctx := suite.ctx - - // add module accounts to supply keeper - authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) - - baseAcc := authKeeper.NewAccountWithAddress(ctx, authtypes.NewModuleAddress("baseAcc")) + require := suite.Require() + authKeeper, keeper := suite.authKeeper, suite.bankKeeper // set initial balances - suite. - Require(). - NoError(keeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) - - suite. - Require(). - NoError(keeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, holderAcc.GetAddress(), initCoins)) + suite.mockMintCoins(mintAcc) + require.NoError(keeper.MintCoins(ctx, minttypes.ModuleName, initCoins)) - authKeeper.SetModuleAccount(ctx, holderAcc) - authKeeper.SetModuleAccount(ctx, burnerAcc) - authKeeper.SetAccount(ctx, baseAcc) + suite.mockSendCoinsFromModuleToAccount(mintAcc, holderAcc.GetAddress()) + require.NoError(keeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, holderAcc.GetAddress(), initCoins)) - suite.Require().Panics(func() { + authKeeper.EXPECT().GetModuleAddress("").Return(nil) + require.Panics(func() { _ = keeper.SendCoinsFromModuleToModule(ctx, "", holderAcc.GetName(), initCoins) // nolint:errcheck }) - suite.Require().Panics(func() { + authKeeper.EXPECT().GetModuleAddress(burnerAcc.Name).Return(burnerAcc.GetAddress()) + authKeeper.EXPECT().GetModuleAccount(ctx, "").Return(nil) + require.Panics(func() { _ = keeper.SendCoinsFromModuleToModule(ctx, authtypes.Burner, "", initCoins) // nolint:errcheck }) - suite.Require().Panics(func() { + authKeeper.EXPECT().GetModuleAddress("").Return(nil) + require.Panics(func() { _ = keeper.SendCoinsFromModuleToAccount(ctx, "", baseAcc.GetAddress(), initCoins) // nolint:errcheck }) - suite.Require().Error( + authKeeper.EXPECT().GetModuleAddress(holderAcc.Name).Return(holderAcc.GetAddress()) + authKeeper.EXPECT().GetAccount(suite.ctx, holderAcc.GetAddress()).Return(holderAcc) + require.Error( keeper.SendCoinsFromModuleToAccount(ctx, holderAcc.GetName(), baseAcc.GetAddress(), initCoins.Add(initCoins...)), ) - suite.Require().NoError( + suite.mockSendCoinsFromModuleToModule(holderAcc, burnerAcc) + require.NoError( keeper.SendCoinsFromModuleToModule(ctx, holderAcc.GetName(), authtypes.Burner, initCoins), ) - suite.Require().Equal(sdk.NewCoins().String(), getCoinsByName(ctx, keeper, authKeeper, holderAcc.GetName()).String()) - suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner)) - suite.Require().NoError( + require.Equal(sdk.NewCoins(), keeper.GetAllBalances(ctx, holderAcc.GetAddress())) + require.Equal(initCoins, keeper.GetAllBalances(ctx, burnerAcc.GetAddress())) + + suite.mockSendCoinsFromModuleToAccount(burnerAcc, baseAcc.GetAddress()) + require.NoError( keeper.SendCoinsFromModuleToAccount(ctx, authtypes.Burner, baseAcc.GetAddress(), initCoins), ) - suite.Require().Equal(sdk.NewCoins().String(), getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner).String()) - suite.Require().Equal(initCoins, keeper.GetAllBalances(ctx, baseAcc.GetAddress())) + require.Equal(sdk.NewCoins(), keeper.GetAllBalances(ctx, burnerAcc.GetAddress())) + require.Equal(initCoins, keeper.GetAllBalances(ctx, baseAcc.GetAddress())) - suite.Require().NoError(keeper.SendCoinsFromAccountToModule(ctx, baseAcc.GetAddress(), authtypes.Burner, initCoins)) - suite.Require().Equal(sdk.NewCoins().String(), keeper.GetAllBalances(ctx, baseAcc.GetAddress()).String()) - suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner)) + suite.mockSendCoinsFromAccountToModule(baseAcc, burnerAcc) + require.NoError(keeper.SendCoinsFromAccountToModule(ctx, baseAcc.GetAddress(), authtypes.Burner, initCoins)) + require.Equal(sdk.NewCoins(), keeper.GetAllBalances(ctx, baseAcc.GetAddress())) + require.Equal(initCoins, keeper.GetAllBalances(ctx, burnerAcc.GetAddress())) } -func (suite *IntegrationTestSuite) TestSupply_MintCoins() { +func (suite *KeeperTestSuite) TestSupply_MintCoins() { ctx := suite.ctx - - // add module accounts to supply keeper - authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) - - authKeeper.SetModuleAccount(ctx, burnerAcc) - authKeeper.SetModuleAccount(ctx, minterAcc) - authKeeper.SetModuleAccount(ctx, multiPermAcc) - authKeeper.SetModuleAccount(ctx, randomPermAcc) + require := suite.Require() + authKeeper, keeper := suite.authKeeper, suite.bankKeeper initialSupply, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) - suite.Require().NoError(err) + require.NoError(err) - suite.Require().Panics(func() { keeper.MintCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck - suite.Require().Panics(func() { keeper.MintCoins(ctx, authtypes.Burner, initCoins) }, "invalid permission") // nolint:errcheck + authKeeper.EXPECT().GetModuleAccount(ctx, "").Return(nil) + require.Panics(func() { _ = keeper.MintCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck - err = keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdk.NewInt(-10)}}) - suite.Require().Error(err, "insufficient coins") + suite.mockMintCoins(burnerAcc) + require.Panics(func() { _ = keeper.MintCoins(ctx, authtypes.Burner, initCoins) }, "invalid permission") // nolint:errcheck - suite.Require().Panics(func() { keeper.MintCoins(ctx, randomPerm, initCoins) }) // nolint:errcheck + suite.mockMintCoins(minterAcc) + require.Error(keeper.MintCoins(ctx, authtypes.Minter, sdk.Coins{sdk.Coin{Denom: "denom", Amount: sdk.NewInt(-10)}}), "insufficient coins") - err = keeper.MintCoins(ctx, authtypes.Minter, initCoins) - suite.Require().NoError(err) + authKeeper.EXPECT().GetModuleAccount(ctx, randomPerm).Return(nil) + require.Panics(func() { _ = keeper.MintCoins(ctx, randomPerm, initCoins) }) // nolint:errcheck + + suite.mockMintCoins(minterAcc) + require.NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) - suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, authtypes.Minter)) + require.Equal(initCoins, keeper.GetAllBalances(ctx, minterAcc.GetAddress())) totalSupply, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) - suite.Require().NoError(err) + require.NoError(err) - suite.Require().Equal(initialSupply.Add(initCoins...), totalSupply) + require.Equal(initialSupply.Add(initCoins...), totalSupply) // test same functionality on module account with multiple permissions initialSupply, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) - suite.Require().NoError(err) + require.NoError(err) - err = keeper.MintCoins(ctx, multiPermAcc.GetName(), initCoins) - suite.Require().NoError(err) + suite.mockMintCoins(multiPermAcc) + require.NoError(keeper.MintCoins(ctx, multiPermAcc.GetName(), initCoins)) totalSupply, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) - suite.Require().NoError(err) - suite.Require().Equal(initCoins, getCoinsByName(ctx, keeper, authKeeper, multiPermAcc.GetName())) - suite.Require().Equal(initialSupply.Add(initCoins...), totalSupply) - suite.Require().Panics(func() { keeper.MintCoins(ctx, authtypes.Burner, initCoins) }) // nolint:errcheck + require.NoError(err) + require.Equal(initCoins, keeper.GetAllBalances(ctx, multiPermAcc.GetAddress())) + require.Equal(initialSupply.Add(initCoins...), totalSupply) } -func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { +func (suite *KeeperTestSuite) TestSupply_BurnCoins() { ctx := suite.ctx - // add module accounts to supply keeper - authKeeper, keeper := suite.initKeepersWithmAccPerms(make(map[string]bool)) + require := suite.Require() + authKeeper, keeper := suite.authKeeper, suite.bankKeeper // set burnerAcc balance - authKeeper.SetModuleAccount(ctx, burnerAcc) - suite. - Require(). - NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) - suite. - Require(). - NoError(keeper.SendCoinsFromModuleToAccount(ctx, authtypes.Minter, burnerAcc.GetAddress(), initCoins)) + suite.mockMintCoins(minterAcc) + require.NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) + + suite.mockSendCoinsFromModuleToAccount(minterAcc, burnerAcc.GetAddress()) + require.NoError(keeper.SendCoinsFromModuleToAccount(ctx, authtypes.Minter, burnerAcc.GetAddress(), initCoins)) // inflate supply - suite. - Require(). - NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) + suite.mockMintCoins(minterAcc) + require.NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) + supplyAfterInflation, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) - suite.Require().NoError(err) - suite.Require().Panics(func() { keeper.BurnCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck - suite.Require().Panics(func() { keeper.BurnCoins(ctx, authtypes.Minter, initCoins) }, "invalid permission") // nolint:errcheck - suite.Require().Panics(func() { keeper.BurnCoins(ctx, randomPerm, supplyAfterInflation) }, "random permission") // nolint:errcheck - err = keeper.BurnCoins(ctx, authtypes.Burner, supplyAfterInflation) - suite.Require().Error(err, "insufficient coins") - - err = keeper.BurnCoins(ctx, authtypes.Burner, initCoins) - suite.Require().NoError(err) + require.NoError(err) + + authKeeper.EXPECT().GetModuleAccount(ctx, "").Return(nil) + require.Panics(func() { _ = keeper.BurnCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck + + authKeeper.EXPECT().GetModuleAccount(ctx, minterAcc.Name).Return(nil) + require.Panics(func() { _ = keeper.BurnCoins(ctx, authtypes.Minter, initCoins) }, "invalid permission") // nolint:errcheck + + authKeeper.EXPECT().GetModuleAccount(ctx, randomPerm).Return(nil) + require.Panics(func() { _ = keeper.BurnCoins(ctx, randomPerm, supplyAfterInflation) }, "random permission") // nolint:errcheck + + suite.mockBurnCoins(burnerAcc) + require.Error(keeper.BurnCoins(ctx, authtypes.Burner, supplyAfterInflation), "insufficient coins") + + suite.mockBurnCoins(burnerAcc) + require.NoError(keeper.BurnCoins(ctx, authtypes.Burner, initCoins)) + supplyAfterBurn, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) - suite.Require().NoError(err) - suite.Require().Equal(sdk.NewCoins().String(), getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner).String()) - suite.Require().Equal(supplyAfterInflation.Sub(initCoins...), supplyAfterBurn) + require.NoError(err) + require.Equal(sdk.NewCoins(), keeper.GetAllBalances(ctx, burnerAcc.GetAddress())) + require.Equal(supplyAfterInflation.Sub(initCoins...), supplyAfterBurn) // test same functionality on module account with multiple permissions - suite. - Require(). - NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) + suite.mockMintCoins(minterAcc) + require.NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins)) supplyAfterInflation, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) - suite.Require().NoError(err) - suite.Require().NoError(keeper.SendCoins(ctx, authtypes.NewModuleAddress(authtypes.Minter), multiPermAcc.GetAddress(), initCoins)) - authKeeper.SetModuleAccount(ctx, multiPermAcc) + require.NoError(err) + + suite.mockSendCoins(ctx, minterAcc, multiPermAcc.GetAddress()) + require.NoError(keeper.SendCoins(ctx, minterAcc.GetAddress(), multiPermAcc.GetAddress(), initCoins)) + + suite.mockBurnCoins(multiPermAcc) + require.NoError(keeper.BurnCoins(ctx, multiPermAcc.GetName(), initCoins)) - err = keeper.BurnCoins(ctx, multiPermAcc.GetName(), initCoins) - suite.Require().NoError(err) supplyAfterBurn, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) - suite.Require().NoError(err) - suite.Require().Equal(sdk.NewCoins().String(), getCoinsByName(ctx, keeper, authKeeper, multiPermAcc.GetName()).String()) - suite.Require().Equal(supplyAfterInflation.Sub(initCoins...), supplyAfterBurn) + require.NoError(err) + require.Equal(sdk.NewCoins(), keeper.GetAllBalances(ctx, multiPermAcc.GetAddress())) + require.Equal(supplyAfterInflation.Sub(initCoins...), supplyAfterBurn) } -func (suite *IntegrationTestSuite) TestSendCoinsNewAccount() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestSendCoinsNewAccount() { + ctx := suite.ctx + require := suite.Require() balances := sdk.NewCoins(newFooCoin(100), newBarCoin(50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) - app.AccountKeeper.SetAccount(ctx, acc1) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], balances)) - acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1) - suite.Require().Equal(balances, acc1Balances) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + acc1Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) + require.Equal(balances, acc1Balances) - addr2 := sdk.AccAddress([]byte("addr2_______________")) - - suite.Require().Nil(app.AccountKeeper.GetAccount(ctx, addr2)) - app.BankKeeper.GetAllBalances(ctx, addr2) - suite.Require().Empty(app.BankKeeper.GetAllBalances(ctx, addr2)) + suite.bankKeeper.GetAllBalances(ctx, accAddrs[1]) + require.Empty(suite.bankKeeper.GetAllBalances(ctx, accAddrs[1])) sendAmt := sdk.NewCoins(newFooCoin(50), newBarCoin(50)) - suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendAmt)) + suite.mockSendCoins(ctx, acc0, accAddrs[1]) + require.NoError(suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[1], sendAmt)) - acc2Balances := app.BankKeeper.GetAllBalances(ctx, addr2) - acc1Balances = app.BankKeeper.GetAllBalances(ctx, addr1) - suite.Require().Equal(sendAmt, acc2Balances) + acc2Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[1]) + acc1Balances = suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) + require.Equal(sendAmt, acc2Balances) updatedAcc1Bal := balances.Sub(sendAmt...) - suite.Require().Len(acc1Balances, len(updatedAcc1Bal)) - suite.Require().Equal(acc1Balances, updatedAcc1Bal) - suite.Require().NotNil(app.AccountKeeper.GetAccount(ctx, addr2)) + require.Len(acc1Balances, len(updatedAcc1Bal)) + require.Equal(acc1Balances, updatedAcc1Bal) } -func (suite *IntegrationTestSuite) TestInputOutputNewAccount() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestInputOutputNewAccount() { + ctx := suite.ctx + require := suite.Require() balances := sdk.NewCoins(newFooCoin(100), newBarCoin(50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) - app.AccountKeeper.SetAccount(ctx, acc1) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) - acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1) - suite.Require().Equal(balances, acc1Balances) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], balances)) - addr2 := sdk.AccAddress([]byte("addr2_______________")) + acc1Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) + require.Equal(balances, acc1Balances) - suite.Require().Nil(app.AccountKeeper.GetAccount(ctx, addr2)) - suite.Require().Empty(app.BankKeeper.GetAllBalances(ctx, addr2)) + require.Empty(suite.bankKeeper.GetAllBalances(ctx, accAddrs[1])) - inputs := []types.Input{ - {Address: addr1.String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, + suite.mockInputOutputCoins([]authtypes.AccountI{authtypes.NewBaseAccountWithAddress(accAddrs[0])}, []sdk.AccAddress{accAddrs[1]}) + inputs := []banktypes.Input{ + {Address: accAddrs[0].String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, } - outputs := []types.Output{ - {Address: addr2.String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, + outputs := []banktypes.Output{ + {Address: accAddrs[1].String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, } - suite.Require().NoError(app.BankKeeper.InputOutputCoins(ctx, inputs, outputs)) + require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) expected := sdk.NewCoins(newFooCoin(30), newBarCoin(10)) - acc2Balances := app.BankKeeper.GetAllBalances(ctx, addr2) - suite.Require().Equal(expected, acc2Balances) - suite.Require().NotNil(app.AccountKeeper.GetAccount(ctx, addr2)) + acc2Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[1]) + require.Equal(expected, acc2Balances) } -func (suite *IntegrationTestSuite) TestInputOutputCoins() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestInputOutputCoins() { + ctx := suite.ctx + require := suite.Require() balances := sdk.NewCoins(newFooCoin(90), newBarCoin(30)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) - app.AccountKeeper.SetAccount(ctx, acc1) - - addr2 := sdk.AccAddress([]byte("addr2_______________")) - acc2 := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) - app.AccountKeeper.SetAccount(ctx, acc2) - - addr3 := sdk.AccAddress([]byte("addr3_______________")) - acc3 := app.AccountKeeper.NewAccountWithAddress(ctx, addr3) - app.AccountKeeper.SetAccount(ctx, acc3) - - input := []types.Input{ - {Address: addr1.String(), Coins: sdk.NewCoins(newFooCoin(60), newBarCoin(20))}, + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + inputs := []banktypes.Input{ + {Address: accAddrs[0].String(), Coins: sdk.NewCoins(newFooCoin(60), newBarCoin(20))}, } - outputs := []types.Output{ - {Address: addr2.String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, - {Address: addr3.String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, + outputs := []banktypes.Output{ + {Address: accAddrs[1].String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, + {Address: accAddrs[2].String(), Coins: sdk.NewCoins(newFooCoin(30), newBarCoin(10))}, } - suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, input, []types.Output{})) - suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, input, outputs)) + require.Error(suite.bankKeeper.InputOutputCoins(ctx, inputs, []banktypes.Output{})) + + suite.authKeeper.EXPECT().GetAccount(suite.ctx, accAddrs[0]).Return(acc0) + require.Error(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], balances)) - insufficientInput := []types.Input{ + insufficientInputs := []banktypes.Input{ { - Address: addr1.String(), + Address: accAddrs[0].String(), Coins: sdk.NewCoins(newFooCoin(300), newBarCoin(100)), }, } - insufficientOutputs := []types.Output{ - {Address: addr2.String(), Coins: sdk.NewCoins(newFooCoin(300), newBarCoin(100))}, - {Address: addr3.String(), Coins: sdk.NewCoins(newFooCoin(300), newBarCoin(100))}, + insufficientOutputs := []banktypes.Output{ + {Address: accAddrs[1].String(), Coins: sdk.NewCoins(newFooCoin(300), newBarCoin(100))}, + {Address: accAddrs[2].String(), Coins: sdk.NewCoins(newFooCoin(300), newBarCoin(100))}, } - suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, insufficientInput, insufficientOutputs)) - suite.Require().NoError(app.BankKeeper.InputOutputCoins(ctx, input, outputs)) - acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1) + require.Error(suite.bankKeeper.InputOutputCoins(ctx, insufficientInputs, insufficientOutputs)) + + suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[1:3]) + require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) + + acc1Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) expected := sdk.NewCoins(newFooCoin(30), newBarCoin(10)) - suite.Require().Equal(expected, acc1Balances) + require.Equal(expected, acc1Balances) - acc2Balances := app.BankKeeper.GetAllBalances(ctx, addr2) - suite.Require().Equal(expected, acc2Balances) + acc2Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[1]) + require.Equal(expected, acc2Balances) - acc3Balances := app.BankKeeper.GetAllBalances(ctx, addr3) - suite.Require().Equal(expected, acc3Balances) + acc3Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[2]) + require.Equal(expected, acc3Balances) } -func (suite *IntegrationTestSuite) TestSendCoins() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestSendCoins() { + ctx := suite.ctx + require := suite.Require() balances := sdk.NewCoins(newFooCoin(100), newBarCoin(50)) - addr1 := sdk.AccAddress("addr1_______________") - acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) - app.AccountKeeper.SetAccount(ctx, acc1) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) - addr2 := sdk.AccAddress("addr2_______________") - acc2 := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) - app.AccountKeeper.SetAccount(ctx, acc2) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, balances)) + suite.mockFundAccount(accAddrs[1]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[1], balances)) sendAmt := sdk.NewCoins(newFooCoin(50), newBarCoin(25)) - suite.Require().Error(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendAmt)) + suite.authKeeper.EXPECT().GetAccount(suite.ctx, accAddrs[0]).Return(acc0) + require.Error(suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[1], sendAmt)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) - suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendAmt)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], balances)) + suite.mockSendCoins(ctx, acc0, accAddrs[1]) + require.NoError(suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[1], sendAmt)) - acc1Balances := app.BankKeeper.GetAllBalances(ctx, addr1) + acc1Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) expected := sdk.NewCoins(newFooCoin(50), newBarCoin(25)) - suite.Require().Equal(expected, acc1Balances) + require.Equal(expected, acc1Balances) - acc2Balances := app.BankKeeper.GetAllBalances(ctx, addr2) + acc2Balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[1]) expected = sdk.NewCoins(newFooCoin(150), newBarCoin(75)) - suite.Require().Equal(expected, acc2Balances) + require.Equal(expected, acc2Balances) // we sent all foo coins to acc2, so foo balance should be deleted for acc1 and bar should be still there var coins []sdk.Coin - app.BankKeeper.IterateAccountBalances(ctx, addr1, func(c sdk.Coin) (stop bool) { + suite.bankKeeper.IterateAccountBalances(ctx, accAddrs[0], func(c sdk.Coin) (stop bool) { coins = append(coins, c) return true }) - suite.Require().Len(coins, 1) - suite.Require().Equal(newBarCoin(25), coins[0], "expected only bar coins in the account balance, got: %v", coins) + require.Len(coins, 1) + require.Equal(newBarCoin(25), coins[0], "expected only bar coins in the account balance, got: %v", coins) } -func (suite *IntegrationTestSuite) TestValidateBalance() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestValidateBalance() { + ctx := suite.ctx + require := suite.Require() now := tmtime.Now() - ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + suite.authKeeper.EXPECT().GetAccount(suite.ctx, accAddrs[0]).Return(nil) + require.Error(suite.bankKeeper.ValidateBalance(ctx, accAddrs[0])) - suite.Require().Error(app.BankKeeper.ValidateBalance(ctx, addr1)) + balances := sdk.NewCoins(newFooCoin(100)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], balances)) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) - app.AccountKeeper.SetAccount(ctx, acc) + suite.mockValidateBalance(acc0) + require.NoError(suite.bankKeeper.ValidateBalance(ctx, accAddrs[0])) - balances := sdk.NewCoins(newFooCoin(100)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, balances)) - suite.Require().NoError(app.BankKeeper.ValidateBalance(ctx, addr1)) + acc1 := authtypes.NewBaseAccountWithAddress(accAddrs[1]) + vacc := vesting.NewContinuousVestingAccount(acc1, balances.Add(balances...), now.Unix(), endTime.Unix()) - bacc := authtypes.NewBaseAccountWithAddress(addr2) - vacc := vesting.NewContinuousVestingAccount(bacc, balances.Add(balances...), now.Unix(), endTime.Unix()) + suite.mockFundAccount(accAddrs[1]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[1], balances)) - app.AccountKeeper.SetAccount(ctx, vacc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, balances)) - suite.Require().Error(app.BankKeeper.ValidateBalance(ctx, addr2)) + suite.mockValidateBalance(vacc) + require.Error(suite.bankKeeper.ValidateBalance(ctx, accAddrs[1])) } -func (suite *IntegrationTestSuite) TestSendEnabled() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestSendEnabled() { + ctx := suite.ctx + require := suite.Require() enabled := true - params := types.DefaultParams() - suite.Require().Equal(enabled, params.DefaultSendEnabled) + params := banktypes.DefaultParams() + require.Equal(enabled, params.DefaultSendEnabled) - suite.Require().NoError(app.BankKeeper.SetParams(ctx, params)) + require.NoError(suite.bankKeeper.SetParams(ctx, params)) - bondCoin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt()) - fooCoin := sdk.NewCoin("foocoin", sdk.OneInt()) - barCoin := sdk.NewCoin("barcoin", sdk.OneInt()) + bondCoin := sdk.NewCoin(sdk.DefaultBondDenom, math.OneInt()) + fooCoin := sdk.NewCoin("foocoin", math.OneInt()) + barCoin := sdk.NewCoin("barcoin", math.OneInt()) // assert with default (all denom) send enabled both Bar and Bond Denom are enabled - suite.Require().Equal(enabled, app.BankKeeper.IsSendEnabledCoin(ctx, barCoin)) - suite.Require().Equal(enabled, app.BankKeeper.IsSendEnabledCoin(ctx, bondCoin)) + require.Equal(enabled, suite.bankKeeper.IsSendEnabledCoin(ctx, barCoin)) + require.Equal(enabled, suite.bankKeeper.IsSendEnabledCoin(ctx, bondCoin)) // Both coins should be send enabled. - err := app.BankKeeper.IsSendEnabledCoins(ctx, fooCoin, bondCoin) - suite.Require().NoError(err) + err := suite.bankKeeper.IsSendEnabledCoins(ctx, fooCoin, bondCoin) + require.NoError(err) // Set default send_enabled to !enabled, add a foodenom that overrides default as enabled params.DefaultSendEnabled = !enabled - suite.Require().NoError(app.BankKeeper.SetParams(ctx, params)) - app.BankKeeper.SetSendEnabled(ctx, fooCoin.Denom, enabled) + require.NoError(suite.bankKeeper.SetParams(ctx, params)) + suite.bankKeeper.SetSendEnabled(ctx, fooCoin.Denom, enabled) // Expect our specific override to be enabled, others to be !enabled. - suite.Require().Equal(enabled, app.BankKeeper.IsSendEnabledCoin(ctx, fooCoin)) - suite.Require().Equal(!enabled, app.BankKeeper.IsSendEnabledCoin(ctx, barCoin)) - suite.Require().Equal(!enabled, app.BankKeeper.IsSendEnabledCoin(ctx, bondCoin)) + require.Equal(enabled, suite.bankKeeper.IsSendEnabledCoin(ctx, fooCoin)) + require.Equal(!enabled, suite.bankKeeper.IsSendEnabledCoin(ctx, barCoin)) + require.Equal(!enabled, suite.bankKeeper.IsSendEnabledCoin(ctx, bondCoin)) // Foo coin should be send enabled. - err = app.BankKeeper.IsSendEnabledCoins(ctx, fooCoin) - suite.Require().NoError(err) + err = suite.bankKeeper.IsSendEnabledCoins(ctx, fooCoin) + require.NoError(err) // Expect an error when one coin is not send enabled. - err = app.BankKeeper.IsSendEnabledCoins(ctx, fooCoin, bondCoin) - suite.Require().Error(err) + err = suite.bankKeeper.IsSendEnabledCoins(ctx, fooCoin, bondCoin) + require.Error(err) // Expect an error when all coins are not send enabled. - err = app.BankKeeper.IsSendEnabledCoins(ctx, bondCoin, barCoin) - suite.Require().Error(err) + err = suite.bankKeeper.IsSendEnabledCoins(ctx, bondCoin, barCoin) + require.Error(err) } -func (suite *IntegrationTestSuite) TestHasBalance() { - app, ctx := suite.app, suite.ctx - addr := sdk.AccAddress([]byte("addr1_______________")) - - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) - app.AccountKeeper.SetAccount(ctx, acc) +func (suite *KeeperTestSuite) TestHasBalance() { + ctx := suite.ctx + require := suite.Require() balances := sdk.NewCoins(newFooCoin(100)) - suite.Require().False(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(99))) + require.False(suite.bankKeeper.HasBalance(ctx, accAddrs[0], newFooCoin(99))) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, balances)) - suite.Require().False(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(101))) - suite.Require().True(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(100))) - suite.Require().True(app.BankKeeper.HasBalance(ctx, addr, newFooCoin(1))) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], balances)) + require.False(suite.bankKeeper.HasBalance(ctx, accAddrs[0], newFooCoin(101))) + require.True(suite.bankKeeper.HasBalance(ctx, accAddrs[0], newFooCoin(100))) + require.True(suite.bankKeeper.HasBalance(ctx, accAddrs[0], newFooCoin(1))) } -func (suite *IntegrationTestSuite) TestMsgSendEvents() { - app, ctx := suite.app, suite.ctx - addr := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) +func (suite *KeeperTestSuite) TestMsgSendEvents() { + ctx := suite.ctx + require := suite.Require() - app.AccountKeeper.SetAccount(ctx, acc) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) newCoins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, newCoins)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], newCoins)) - suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr, addr2, newCoins)) + suite.mockSendCoins(ctx, acc0, accAddrs[1]) + require.NoError(suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[1], newCoins)) event1 := sdk.Event{ - Type: types.EventTypeTransfer, + Type: banktypes.EventTypeTransfer, Attributes: []abci.EventAttribute{}, } event1.Attributes = append( event1.Attributes, - abci.EventAttribute{Key: types.AttributeKeyRecipient, Value: addr2.String()}, + abci.EventAttribute{Key: banktypes.AttributeKeyRecipient, Value: accAddrs[1].String()}, ) event1.Attributes = append( event1.Attributes, - abci.EventAttribute{Key: types.AttributeKeySender, Value: addr.String()}, + abci.EventAttribute{Key: banktypes.AttributeKeySender, Value: accAddrs[0].String()}, ) event1.Attributes = append( event1.Attributes, @@ -585,55 +660,51 @@ func (suite *IntegrationTestSuite) TestMsgSendEvents() { } event2.Attributes = append( event2.Attributes, - abci.EventAttribute{Key: types.AttributeKeySender, Value: addr.String()}, + abci.EventAttribute{Key: banktypes.AttributeKeySender, Value: accAddrs[0].String()}, ) // events are shifted due to the funding account events events := ctx.EventManager().ABCIEvents() - suite.Require().Equal(10, len(events)) - suite.Require().Equal(abci.Event(event1), events[8]) - suite.Require().Equal(abci.Event(event2), events[9]) + require.Equal(10, len(events)) + require.Equal(abci.Event(event1), events[8]) + require.Equal(abci.Event(event2), events[9]) } -func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() { - app, ctx := suite.app, suite.ctx - - suite.Require().NoError(app.BankKeeper.SetParams(ctx, types.DefaultParams())) - - addr := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) - addr3 := sdk.AccAddress([]byte("addr3_______________")) - addr4 := sdk.AccAddress([]byte("addr4_______________")) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) - acc2 := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) +func (suite *KeeperTestSuite) TestMsgMultiSendEvents() { + ctx := suite.ctx + require := suite.Require() + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) - app.AccountKeeper.SetAccount(ctx, acc) - app.AccountKeeper.SetAccount(ctx, acc2) + require.NoError(suite.bankKeeper.SetParams(ctx, banktypes.DefaultParams())) coins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100)) newCoins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)) newCoins2 := sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)) - input := []types.Input{ - {Address: addr.String(), + inputs := []banktypes.Input{ + {Address: accAddrs[0].String(), Coins: coins, }, } - outputs := []types.Output{ - {Address: addr3.String(), Coins: newCoins}, - {Address: addr4.String(), Coins: newCoins2}, + outputs := []banktypes.Output{ + {Address: accAddrs[2].String(), Coins: newCoins}, + {Address: accAddrs[3].String(), Coins: newCoins2}, } - suite.Require().Error(app.BankKeeper.InputOutputCoins(ctx, input, outputs)) + suite.authKeeper.EXPECT().GetAccount(suite.ctx, accAddrs[0]).Return(acc0) + require.Error(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events := ctx.EventManager().ABCIEvents() - suite.Require().Equal(0, len(events)) + require.Equal(0, len(events)) + + // Set addr's coins but not accAddrs[1]'s coins + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100)))) - // Set addr's coins but not addr2's coins - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50), sdk.NewInt64Coin(barDenom, 100)))) - suite.Require().NoError(app.BankKeeper.InputOutputCoins(ctx, input, outputs)) + suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[2:4]) + require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() - suite.Require().Equal(12, len(events)) // 9 events because account funding causes extra minting + coin_spent + coin_recv events + require.Equal(12, len(events)) // 9 events because account funding causes extra minting + coin_spent + coin_recv events event1 := sdk.Event{ Type: sdk.EventTypeMessage, @@ -641,449 +712,431 @@ func (suite *IntegrationTestSuite) TestMsgMultiSendEvents() { } event1.Attributes = append( event1.Attributes, - abci.EventAttribute{Key: types.AttributeKeySender, Value: addr.String()}, + abci.EventAttribute{Key: banktypes.AttributeKeySender, Value: accAddrs[0].String()}, ) - suite.Require().Equal(abci.Event(event1), events[7]) + require.Equal(abci.Event(event1), events[7]) - // Set addr's coins and addr2's coins - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)))) + // Set addr's coins and accAddrs[1]'s coins + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)))) newCoins = sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr, sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)))) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)))) newCoins2 = sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)) - suite.Require().NoError(app.BankKeeper.InputOutputCoins(ctx, input, outputs)) + suite.mockInputOutputCoins([]authtypes.AccountI{acc0}, accAddrs[2:4]) + require.NoError(suite.bankKeeper.InputOutputCoins(ctx, inputs, outputs)) events = ctx.EventManager().ABCIEvents() - suite.Require().Equal(30, len(events)) // 27 due to account funding + coin_spent + coin_recv events + require.Equal(30, len(events)) // 27 due to account funding + coin_spent + coin_recv events event2 := sdk.Event{ - Type: types.EventTypeTransfer, + Type: banktypes.EventTypeTransfer, Attributes: []abci.EventAttribute{}, } event2.Attributes = append( event2.Attributes, - abci.EventAttribute{Key: types.AttributeKeyRecipient, Value: addr3.String()}, + abci.EventAttribute{Key: banktypes.AttributeKeyRecipient, Value: accAddrs[2].String()}, ) event2.Attributes = append( event2.Attributes, abci.EventAttribute{Key: sdk.AttributeKeyAmount, Value: newCoins.String()}) event3 := sdk.Event{ - Type: types.EventTypeTransfer, + Type: banktypes.EventTypeTransfer, Attributes: []abci.EventAttribute{}, } event3.Attributes = append( event3.Attributes, - abci.EventAttribute{Key: types.AttributeKeyRecipient, Value: addr4.String()}, + abci.EventAttribute{Key: banktypes.AttributeKeyRecipient, Value: accAddrs[3].String()}, ) event3.Attributes = append( event3.Attributes, abci.EventAttribute{Key: sdk.AttributeKeyAmount, Value: newCoins2.String()}, ) // events are shifted due to the funding account events - suite.Require().Equal(abci.Event(event1), events[25]) - suite.Require().Equal(abci.Event(event2), events[27]) - suite.Require().Equal(abci.Event(event3), events[29]) + require.Equal(abci.Event(event1), events[25]) + require.Equal(abci.Event(event2), events[27]) + require.Equal(abci.Event(event3), events[29]) } -func (suite *IntegrationTestSuite) TestSpendableCoins() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestSpendableCoins() { + ctx := suite.ctx + require := suite.Require() now := tmtime.Now() - ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) - delCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) + lockedCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) - addrModule := sdk.AccAddress([]byte("moduleAcc___________")) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + acc1 := authtypes.NewBaseAccountWithAddress(accAddrs[1]) + vacc := vesting.NewContinuousVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) - macc := app.AccountKeeper.NewAccountWithAddress(ctx, addrModule) - bacc := authtypes.NewBaseAccountWithAddress(addr1) - vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], origCoins)) - app.AccountKeeper.SetAccount(ctx, macc) - app.AccountKeeper.SetAccount(ctx, vacc) - app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.mockFundAccount(accAddrs[1]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[1], origCoins)) - suite.Require().Equal(origCoins, app.BankKeeper.SpendableCoins(ctx, addr2)) - suite.Require().Equal(origCoins[0], app.BankKeeper.SpendableCoin(ctx, addr2, "stake")) + suite.mockSpendableCoins(ctx, acc1) + require.Equal(origCoins, suite.bankKeeper.SpendableCoins(ctx, accAddrs[1])) + + suite.mockSpendableCoins(ctx, acc1) + require.Equal(origCoins[0], suite.bankKeeper.SpendableCoin(ctx, accAddrs[1], "stake")) ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) - suite.Require().NoError(app.BankKeeper.DelegateCoins(ctx, addr2, addrModule, delCoins)) - suite.Require().Equal(origCoins.Sub(delCoins...), app.BankKeeper.SpendableCoins(ctx, addr1)) - suite.Require().Equal(origCoins.Sub(delCoins...)[0], app.BankKeeper.SpendableCoin(ctx, addr1, "stake")) + suite.mockSpendableCoins(ctx, vacc) + require.Equal(origCoins.Sub(lockedCoins...), suite.bankKeeper.SpendableCoins(ctx, accAddrs[0])) + + suite.mockSpendableCoins(ctx, vacc) + require.Equal(origCoins.Sub(lockedCoins...)[0], suite.bankKeeper.SpendableCoin(ctx, accAddrs[0], "stake")) } -func (suite *IntegrationTestSuite) TestVestingAccountSend() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestVestingAccountSend() { + ctx := suite.ctx + require := suite.Require() now := tmtime.Now() - ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) sendCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) - - bacc := authtypes.NewBaseAccountWithAddress(addr1) - vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, now.Unix(), endTime.Unix()) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + vacc := vesting.NewContinuousVestingAccount(acc0, origCoins, now.Unix(), endTime.Unix()) - app.AccountKeeper.SetAccount(ctx, vacc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], origCoins)) // require that no coins be sendable at the beginning of the vesting schedule - suite.Require().Error(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins)) + suite.authKeeper.EXPECT().GetAccount(ctx, accAddrs[0]).Return(vacc) + require.Error(suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[1], sendCoins)) // receive some coins - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, sendCoins)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sendCoins)) // require that all vested coins are spendable plus any received ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) - suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins)) - suite.Require().Equal(origCoins, app.BankKeeper.GetAllBalances(ctx, addr1)) + suite.mockSendCoins(ctx, vacc, accAddrs[1]) + require.NoError(suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[1], sendCoins)) + require.Equal(origCoins, suite.bankKeeper.GetAllBalances(ctx, accAddrs[0])) } -func (suite *IntegrationTestSuite) TestPeriodicVestingAccountSend() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestPeriodicVestingAccountSend() { + ctx := suite.ctx + require := suite.Require() now := tmtime.Now() - ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) sendCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) periods := vesting.Periods{ vesting.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 50)}}, vesting.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 25)}}, vesting.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 25)}}, } - bacc := authtypes.NewBaseAccountWithAddress(addr1) - vacc := vesting.NewPeriodicVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), periods) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + vacc := vesting.NewPeriodicVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), periods) - app.AccountKeeper.SetAccount(ctx, vacc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], origCoins)) // require that no coins be sendable at the beginning of the vesting schedule - suite.Require().Error(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins)) + suite.authKeeper.EXPECT().GetAccount(ctx, accAddrs[0]).Return(vacc) + require.Error(suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[1], sendCoins)) // receive some coins - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, sendCoins)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], sendCoins)) // require that all vested coins are spendable plus any received ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) - suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr1, addr2, sendCoins)) - suite.Require().Equal(origCoins, app.BankKeeper.GetAllBalances(ctx, addr1)) + suite.mockSendCoins(ctx, vacc, accAddrs[1]) + require.NoError(suite.bankKeeper.SendCoins(ctx, accAddrs[0], accAddrs[1], sendCoins)) + require.Equal(origCoins, suite.bankKeeper.GetAllBalances(ctx, accAddrs[0])) } -func (suite *IntegrationTestSuite) TestVestingAccountReceive() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestVestingAccountReceive() { + ctx := suite.ctx + require := suite.Require() now := tmtime.Now() - ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) sendCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + acc1 := authtypes.NewBaseAccountWithAddress(accAddrs[1]) + vacc := vesting.NewContinuousVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) - bacc := authtypes.NewBaseAccountWithAddress(addr1) - vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], origCoins)) - app.AccountKeeper.SetAccount(ctx, vacc) - app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.mockFundAccount(accAddrs[1]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[1], origCoins)) // send some coins to the vesting account - suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr2, addr1, sendCoins)) + suite.mockSendCoins(ctx, acc1, accAddrs[0]) + require.NoError(suite.bankKeeper.SendCoins(ctx, accAddrs[1], accAddrs[0], sendCoins)) // require the coins are spendable - vacc = app.AccountKeeper.GetAccount(ctx, addr1).(*vesting.ContinuousVestingAccount) - balances := app.BankKeeper.GetAllBalances(ctx, addr1) - suite.Require().Equal(origCoins.Add(sendCoins...), balances) - suite.Require().Equal(balances.Sub(vacc.LockedCoins(now)...), sendCoins) + balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) + require.Equal(origCoins.Add(sendCoins...), balances) + require.Equal(balances.Sub(vacc.LockedCoins(now)...), sendCoins) // require coins are spendable plus any that have vested - suite.Require().Equal(balances.Sub(vacc.LockedCoins(now.Add(12*time.Hour))...), origCoins) + require.Equal(balances.Sub(vacc.LockedCoins(now.Add(12*time.Hour))...), origCoins) } -func (suite *IntegrationTestSuite) TestPeriodicVestingAccountReceive() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestPeriodicVestingAccountReceive() { + ctx := suite.ctx + require := suite.Require() now := tmtime.Now() - ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) sendCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) - - bacc := authtypes.NewBaseAccountWithAddress(addr1) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + acc1 := authtypes.NewBaseAccountWithAddress(accAddrs[1]) periods := vesting.Periods{ vesting.Period{Length: int64(12 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 50)}}, vesting.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 25)}}, vesting.Period{Length: int64(6 * 60 * 60), Amount: sdk.Coins{sdk.NewInt64Coin("stake", 25)}}, } - vacc := vesting.NewPeriodicVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), periods) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) + vacc := vesting.NewPeriodicVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), periods) - app.AccountKeeper.SetAccount(ctx, vacc) - app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], origCoins)) + + suite.mockFundAccount(accAddrs[1]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[1], origCoins)) // send some coins to the vesting account - suite.Require().NoError(app.BankKeeper.SendCoins(ctx, addr2, addr1, sendCoins)) + suite.mockSendCoins(ctx, acc1, accAddrs[0]) + require.NoError(suite.bankKeeper.SendCoins(ctx, accAddrs[1], accAddrs[0], sendCoins)) // require the coins are spendable - vacc = app.AccountKeeper.GetAccount(ctx, addr1).(*vesting.PeriodicVestingAccount) - balances := app.BankKeeper.GetAllBalances(ctx, addr1) - suite.Require().Equal(origCoins.Add(sendCoins...), balances) - suite.Require().Equal(balances.Sub(vacc.LockedCoins(now)...), sendCoins) + balances := suite.bankKeeper.GetAllBalances(ctx, accAddrs[0]) + require.Equal(origCoins.Add(sendCoins...), balances) + require.Equal(balances.Sub(vacc.LockedCoins(now)...), sendCoins) // require coins are spendable plus any that have vested - suite.Require().Equal(balances.Sub(vacc.LockedCoins(now.Add(12*time.Hour))...), origCoins) + require.Equal(balances.Sub(vacc.LockedCoins(now.Add(12*time.Hour))...), origCoins) } -func (suite *IntegrationTestSuite) TestDelegateCoins() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestDelegateCoins() { + ctx := suite.ctx + require := suite.Require() now := tmtime.Now() - ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) delCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) - addrModule := sdk.AccAddress([]byte("moduleAcc___________")) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + acc1 := authtypes.NewBaseAccountWithAddress(accAddrs[1]) + vacc := vesting.NewContinuousVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) - macc := app.AccountKeeper.NewAccountWithAddress(ctx, addrModule) // we don't need to define an actual module account bc we just need the address for testing - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) - bacc := authtypes.NewBaseAccountWithAddress(addr1) - vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], origCoins)) - app.AccountKeeper.SetAccount(ctx, vacc) - app.AccountKeeper.SetAccount(ctx, acc) - app.AccountKeeper.SetAccount(ctx, macc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.mockFundAccount(accAddrs[1]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[1], origCoins)) ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) // require the ability for a non-vesting account to delegate - suite.Require().NoError(app.BankKeeper.DelegateCoins(ctx, addr2, addrModule, delCoins)) - suite.Require().Equal(origCoins.Sub(delCoins...), app.BankKeeper.GetAllBalances(ctx, addr2)) - suite.Require().Equal(delCoins, app.BankKeeper.GetAllBalances(ctx, addrModule)) + suite.mockDelegateCoins(ctx, acc1, holderAcc) + require.NoError(suite.bankKeeper.DelegateCoins(ctx, accAddrs[1], holderAcc.GetAddress(), delCoins)) + require.Equal(origCoins.Sub(delCoins...), suite.bankKeeper.GetAllBalances(ctx, accAddrs[1])) + require.Equal(delCoins, suite.bankKeeper.GetAllBalances(ctx, holderAcc.GetAddress())) // require the ability for a vesting account to delegate - suite.Require().NoError(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, delCoins)) - suite.Require().Equal(delCoins, app.BankKeeper.GetAllBalances(ctx, addr1)) + suite.mockDelegateCoins(ctx, vacc, holderAcc) + require.NoError(suite.bankKeeper.DelegateCoins(ctx, accAddrs[0], holderAcc.GetAddress(), delCoins)) + require.Equal(delCoins, suite.bankKeeper.GetAllBalances(ctx, accAddrs[0])) // require that delegated vesting amount is equal to what was delegated with DelegateCoins - acc = app.AccountKeeper.GetAccount(ctx, addr1) - vestingAcc, ok := acc.(types.VestingAccount) - suite.Require().True(ok) - suite.Require().Equal(delCoins, vestingAcc.GetDelegatedVesting()) + require.Equal(delCoins, vacc.GetDelegatedVesting()) } -func (suite *IntegrationTestSuite) TestDelegateCoins_Invalid() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestDelegateCoins_Invalid() { + ctx := suite.ctx + require := suite.Require() origCoins := sdk.NewCoins(newFooCoin(100)) delCoins := sdk.NewCoins(newFooCoin(50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addrModule := sdk.AccAddress([]byte("moduleAcc___________")) - macc := app.AccountKeeper.NewAccountWithAddress(ctx, addrModule) // we don't need to define an actual module account bc we just need the address for testing - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) + suite.authKeeper.EXPECT().GetAccount(ctx, holderAcc.GetAddress()).Return(nil) + require.Error(suite.bankKeeper.DelegateCoins(ctx, accAddrs[0], holderAcc.GetAddress(), delCoins)) - suite.Require().Error(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, delCoins)) + suite.authKeeper.EXPECT().GetAccount(ctx, holderAcc.GetAddress()).Return(holderAcc) invalidCoins := sdk.Coins{sdk.Coin{Denom: "fooDenom", Amount: sdk.NewInt(-50)}} - suite.Require().Error(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, invalidCoins)) + require.Error(suite.bankKeeper.DelegateCoins(ctx, accAddrs[0], holderAcc.GetAddress(), invalidCoins)) - app.AccountKeeper.SetAccount(ctx, macc) - suite.Require().Error(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, delCoins)) - app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().Error(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, origCoins.Add(origCoins...))) + suite.authKeeper.EXPECT().GetAccount(ctx, holderAcc.GetAddress()).Return(holderAcc) + require.Error(suite.bankKeeper.DelegateCoins(ctx, accAddrs[0], holderAcc.GetAddress(), delCoins)) + + suite.authKeeper.EXPECT().GetAccount(ctx, holderAcc.GetAddress()).Return(holderAcc) + require.Error(suite.bankKeeper.DelegateCoins(ctx, accAddrs[0], holderAcc.GetAddress(), origCoins.Add(origCoins...))) } -func (suite *IntegrationTestSuite) TestUndelegateCoins() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestUndelegateCoins() { + ctx := suite.ctx + require := suite.Require() now := tmtime.Now() - ctx = ctx.WithBlockHeader(tmproto.Header{Time: now}) endTime := now.Add(24 * time.Hour) origCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) delCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addr2 := sdk.AccAddress([]byte("addr2_______________")) - addrModule := sdk.AccAddress([]byte("moduleAcc___________")) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + acc1 := authtypes.NewBaseAccountWithAddress(accAddrs[1]) + vacc := vesting.NewContinuousVestingAccount(acc0, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) - bacc := authtypes.NewBaseAccountWithAddress(addr1) - macc := app.AccountKeeper.NewAccountWithAddress(ctx, addrModule) // we don't need to define an actual module account bc we just need the address for testing + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], origCoins)) - vacc := vesting.NewContinuousVestingAccount(bacc, origCoins, ctx.BlockHeader().Time.Unix(), endTime.Unix()) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr2) - - app.AccountKeeper.SetAccount(ctx, vacc) - app.AccountKeeper.SetAccount(ctx, acc) - app.AccountKeeper.SetAccount(ctx, macc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr2, origCoins)) + suite.mockFundAccount(accAddrs[1]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[1], origCoins)) ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) // require the ability for a non-vesting account to delegate - err := app.BankKeeper.DelegateCoins(ctx, addr2, addrModule, delCoins) - suite.Require().NoError(err) + suite.mockDelegateCoins(ctx, acc1, holderAcc) + require.NoError(suite.bankKeeper.DelegateCoins(ctx, accAddrs[1], holderAcc.GetAddress(), delCoins)) - suite.Require().Equal(origCoins.Sub(delCoins...), app.BankKeeper.GetAllBalances(ctx, addr2)) - suite.Require().Equal(delCoins, app.BankKeeper.GetAllBalances(ctx, addrModule)) + require.Equal(origCoins.Sub(delCoins...), suite.bankKeeper.GetAllBalances(ctx, accAddrs[1])) + require.Equal(delCoins, suite.bankKeeper.GetAllBalances(ctx, holderAcc.GetAddress())) // require the ability for a non-vesting account to undelegate - suite.Require().NoError(app.BankKeeper.UndelegateCoins(ctx, addrModule, addr2, delCoins)) + suite.mockUnDelegateCoins(ctx, acc1, holderAcc) + require.NoError(suite.bankKeeper.UndelegateCoins(ctx, holderAcc.GetAddress(), accAddrs[1], delCoins)) - suite.Require().Equal(origCoins, app.BankKeeper.GetAllBalances(ctx, addr2)) - suite.Require().True(app.BankKeeper.GetAllBalances(ctx, addrModule).Empty()) + require.Equal(origCoins, suite.bankKeeper.GetAllBalances(ctx, accAddrs[1])) + require.True(suite.bankKeeper.GetAllBalances(ctx, holderAcc.GetAddress()).Empty()) // require the ability for a vesting account to delegate - suite.Require().NoError(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, delCoins)) + suite.mockDelegateCoins(ctx, acc0, holderAcc) + require.NoError(suite.bankKeeper.DelegateCoins(ctx, accAddrs[0], holderAcc.GetAddress(), delCoins)) - suite.Require().Equal(origCoins.Sub(delCoins...), app.BankKeeper.GetAllBalances(ctx, addr1)) - suite.Require().Equal(delCoins, app.BankKeeper.GetAllBalances(ctx, addrModule)) + require.Equal(origCoins.Sub(delCoins...), suite.bankKeeper.GetAllBalances(ctx, accAddrs[0])) + require.Equal(delCoins, suite.bankKeeper.GetAllBalances(ctx, holderAcc.GetAddress())) // require the ability for a vesting account to undelegate - suite.Require().NoError(app.BankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins)) + suite.mockUnDelegateCoins(ctx, vacc, holderAcc) + require.NoError(suite.bankKeeper.UndelegateCoins(ctx, holderAcc.GetAddress(), accAddrs[0], delCoins)) - suite.Require().Equal(origCoins, app.BankKeeper.GetAllBalances(ctx, addr1)) - suite.Require().True(app.BankKeeper.GetAllBalances(ctx, addrModule).Empty()) + require.Equal(origCoins, suite.bankKeeper.GetAllBalances(ctx, accAddrs[0])) + require.True(suite.bankKeeper.GetAllBalances(ctx, holderAcc.GetAddress()).Empty()) // require that delegated vesting amount is completely empty, since they were completely undelegated - acc = app.AccountKeeper.GetAccount(ctx, addr1) - vestingAcc, ok := acc.(types.VestingAccount) - suite.Require().True(ok) - suite.Require().Empty(vestingAcc.GetDelegatedVesting()) + require.Empty(vacc.GetDelegatedVesting()) } -func (suite *IntegrationTestSuite) TestUndelegateCoins_Invalid() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestUndelegateCoins_Invalid() { + ctx := suite.ctx + require := suite.Require() origCoins := sdk.NewCoins(newFooCoin(100)) delCoins := sdk.NewCoins(newFooCoin(50)) - addr1 := sdk.AccAddress([]byte("addr1_______________")) - addrModule := sdk.AccAddress([]byte("moduleAcc___________")) - macc := app.AccountKeeper.NewAccountWithAddress(ctx, addrModule) // we don't need to define an actual module account bc we just need the address for testing - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr1) + acc0 := authtypes.NewBaseAccountWithAddress(accAddrs[0]) + + suite.authKeeper.EXPECT().GetAccount(ctx, holderAcc.GetAddress()).Return(nil) + require.Error(suite.bankKeeper.UndelegateCoins(ctx, holderAcc.GetAddress(), accAddrs[0], delCoins)) - suite.Require().Error(app.BankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins)) + suite.mockFundAccount(accAddrs[0]) + require.NoError(banktestutil.FundAccount(suite.bankKeeper, ctx, accAddrs[0], origCoins)) - app.AccountKeeper.SetAccount(ctx, macc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, addr1, origCoins)) + suite.mockDelegateCoins(ctx, acc0, holderAcc) + require.NoError(suite.bankKeeper.DelegateCoins(ctx, accAddrs[0], holderAcc.GetAddress(), delCoins)) - suite.Require().Error(app.BankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins)) - app.AccountKeeper.SetAccount(ctx, acc) + suite.authKeeper.EXPECT().GetAccount(ctx, holderAcc.GetAddress()).Return(holderAcc) + suite.authKeeper.EXPECT().GetAccount(ctx, holderAcc.GetAddress()).Return(holderAcc) + suite.authKeeper.EXPECT().GetAccount(ctx, acc0.GetAddress()).Return(nil) + require.Error(suite.bankKeeper.UndelegateCoins(ctx, holderAcc.GetAddress(), accAddrs[0], delCoins)) - suite.Require().Error(app.BankKeeper.UndelegateCoins(ctx, addrModule, addr1, delCoins)) + suite.authKeeper.EXPECT().GetAccount(ctx, holderAcc.GetAddress()).Return(holderAcc) + suite.authKeeper.EXPECT().GetAccount(ctx, holderAcc.GetAddress()).Return(holderAcc) + require.Error(suite.bankKeeper.UndelegateCoins(ctx, holderAcc.GetAddress(), accAddrs[0], origCoins)) } -func (suite *IntegrationTestSuite) TestSetDenomMetaData() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestSetDenomMetaData() { + ctx := suite.ctx + require := suite.Require() metadata := suite.getTestMetadata() for i := range []int{1, 2} { - app.BankKeeper.SetDenomMetaData(ctx, metadata[i]) + suite.bankKeeper.SetDenomMetaData(ctx, metadata[i]) } - actualMetadata, found := app.BankKeeper.GetDenomMetaData(ctx, metadata[1].Base) - suite.Require().True(found) - found = app.BankKeeper.HasDenomMetaData(ctx, metadata[1].Base) - suite.Require().True(found) - suite.Require().Equal(metadata[1].GetBase(), actualMetadata.GetBase()) - suite.Require().Equal(metadata[1].GetDisplay(), actualMetadata.GetDisplay()) - suite.Require().Equal(metadata[1].GetDescription(), actualMetadata.GetDescription()) - suite.Require().Equal(metadata[1].GetDenomUnits()[1].GetDenom(), actualMetadata.GetDenomUnits()[1].GetDenom()) - suite.Require().Equal(metadata[1].GetDenomUnits()[1].GetExponent(), actualMetadata.GetDenomUnits()[1].GetExponent()) - suite.Require().Equal(metadata[1].GetDenomUnits()[1].GetAliases(), actualMetadata.GetDenomUnits()[1].GetAliases()) + actualMetadata, found := suite.bankKeeper.GetDenomMetaData(ctx, metadata[1].Base) + require.True(found) + found = suite.bankKeeper.HasDenomMetaData(ctx, metadata[1].Base) + require.True(found) + require.Equal(metadata[1].GetBase(), actualMetadata.GetBase()) + require.Equal(metadata[1].GetDisplay(), actualMetadata.GetDisplay()) + require.Equal(metadata[1].GetDescription(), actualMetadata.GetDescription()) + require.Equal(metadata[1].GetDenomUnits()[1].GetDenom(), actualMetadata.GetDenomUnits()[1].GetDenom()) + require.Equal(metadata[1].GetDenomUnits()[1].GetExponent(), actualMetadata.GetDenomUnits()[1].GetExponent()) + require.Equal(metadata[1].GetDenomUnits()[1].GetAliases(), actualMetadata.GetDenomUnits()[1].GetAliases()) } -func (suite *IntegrationTestSuite) TestIterateAllDenomMetaData() { - app, ctx := suite.app, suite.ctx +func (suite *KeeperTestSuite) TestIterateAllDenomMetaData() { + ctx := suite.ctx + require := suite.Require() expectedMetadata := suite.getTestMetadata() // set metadata for i := range []int{1, 2} { - app.BankKeeper.SetDenomMetaData(ctx, expectedMetadata[i]) + suite.bankKeeper.SetDenomMetaData(ctx, expectedMetadata[i]) } // retrieve metadata - actualMetadata := make([]types.Metadata, 0) - app.BankKeeper.IterateAllDenomMetaData(ctx, func(metadata types.Metadata) bool { + actualMetadata := make([]banktypes.Metadata, 0) + suite.bankKeeper.IterateAllDenomMetaData(ctx, func(metadata banktypes.Metadata) bool { actualMetadata = append(actualMetadata, metadata) return false }) // execute checks for i := range []int{1, 2} { - suite.Require().Equal(expectedMetadata[i].GetBase(), actualMetadata[i].GetBase()) - suite.Require().Equal(expectedMetadata[i].GetDisplay(), actualMetadata[i].GetDisplay()) - suite.Require().Equal(expectedMetadata[i].GetDescription(), actualMetadata[i].GetDescription()) - suite.Require().Equal(expectedMetadata[i].GetDenomUnits()[1].GetDenom(), actualMetadata[i].GetDenomUnits()[1].GetDenom()) - suite.Require().Equal(expectedMetadata[i].GetDenomUnits()[1].GetExponent(), actualMetadata[i].GetDenomUnits()[1].GetExponent()) - suite.Require().Equal(expectedMetadata[i].GetDenomUnits()[1].GetAliases(), actualMetadata[i].GetDenomUnits()[1].GetAliases()) + require.Equal(expectedMetadata[i].GetBase(), actualMetadata[i].GetBase()) + require.Equal(expectedMetadata[i].GetDisplay(), actualMetadata[i].GetDisplay()) + require.Equal(expectedMetadata[i].GetDescription(), actualMetadata[i].GetDescription()) + require.Equal(expectedMetadata[i].GetDenomUnits()[1].GetDenom(), actualMetadata[i].GetDenomUnits()[1].GetDenom()) + require.Equal(expectedMetadata[i].GetDenomUnits()[1].GetExponent(), actualMetadata[i].GetDenomUnits()[1].GetExponent()) + require.Equal(expectedMetadata[i].GetDenomUnits()[1].GetAliases(), actualMetadata[i].GetDenomUnits()[1].GetAliases()) } } -func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { - // replace account keeper and bank keeper otherwise the account keeper won't be aware of the - // existence of the new module account because GetModuleAccount checks for the existence via - // permissions map and not via state... weird - maccPerms := simapp.GetMaccPerms() - maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} - - suite.app.AccountKeeper = authkeeper.NewAccountKeeper( - suite.app.AppCodec(), suite.app.GetKey(authtypes.StoreKey), - authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey), - suite.app.AccountKeeper, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) +func (suite *KeeperTestSuite) TestBalanceTrackingEvents() { + require := suite.Require() - // set account with multiple permissions - suite.app.AccountKeeper.SetModuleAccount(suite.ctx, multiPermAcc) // mint coins - suite.Require().NoError( - suite.app.BankKeeper.MintCoins( + suite.mockMintCoins(multiPermAcc) + require.NoError( + suite.bankKeeper.MintCoins( suite.ctx, multiPermAcc.Name, sdk.NewCoins(sdk.NewCoin("utxo", sdk.NewInt(100000)))), ) // send coins to address - addr1 := sdk.AccAddress("addr1_______________") - suite.Require().NoError( - suite.app.BankKeeper.SendCoinsFromModuleToAccount( + suite.mockSendCoinsFromModuleToAccount(multiPermAcc, accAddrs[0]) + require.NoError( + suite.bankKeeper.SendCoinsFromModuleToAccount( suite.ctx, multiPermAcc.Name, - addr1, + accAddrs[0], sdk.NewCoins(sdk.NewCoin("utxo", sdk.NewInt(50000))), ), ) // burn coins from module account - suite.Require().NoError( - suite.app.BankKeeper.BurnCoins( + suite.mockBurnCoins(multiPermAcc) + require.NoError( + suite.bankKeeper.BurnCoins( suite.ctx, multiPermAcc.Name, sdk.NewCoins(sdk.NewInt64Coin("utxo", 1000)), @@ -1097,60 +1150,60 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { for _, e := range suite.ctx.EventManager().ABCIEvents() { switch e.Type { - case types.EventTypeCoinBurn: + case banktypes.EventTypeCoinBurn: burnedCoins, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) - suite.Require().NoError(err) + require.NoError(err) supply = supply.Sub(burnedCoins...) - case types.EventTypeCoinMint: + case banktypes.EventTypeCoinMint: mintedCoins, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) - suite.Require().NoError(err) + require.NoError(err) supply = supply.Add(mintedCoins...) - case types.EventTypeCoinSpent: + case banktypes.EventTypeCoinSpent: coinsSpent, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) - suite.Require().NoError(err) + require.NoError(err) spender, err := sdk.AccAddressFromBech32((string)(e.Attributes[0].Value)) - suite.Require().NoError(err) + require.NoError(err) balances[spender.String()] = balances[spender.String()].Sub(coinsSpent...) - case types.EventTypeCoinReceived: + case banktypes.EventTypeCoinReceived: coinsRecv, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) - suite.Require().NoError(err) + require.NoError(err) receiver, err := sdk.AccAddressFromBech32((string)(e.Attributes[0].Value)) - suite.Require().NoError(err) + require.NoError(err) balances[receiver.String()] = balances[receiver.String()].Add(coinsRecv...) } } // check balance and supply tracking - suite.Require().True(suite.app.BankKeeper.HasSupply(suite.ctx, "utxo")) - savedSupply := suite.app.BankKeeper.GetSupply(suite.ctx, "utxo") + require.True(suite.bankKeeper.HasSupply(suite.ctx, "utxo")) + savedSupply := suite.bankKeeper.GetSupply(suite.ctx, "utxo") utxoSupply := savedSupply - suite.Require().Equal(utxoSupply.Amount, supply.AmountOf("utxo")) + require.Equal(utxoSupply.Amount, supply.AmountOf("utxo")) // iterate accounts and check balances - suite.app.BankKeeper.IterateAllBalances(suite.ctx, func(address sdk.AccAddress, coin sdk.Coin) (stop bool) { + suite.bankKeeper.IterateAllBalances(suite.ctx, func(address sdk.AccAddress, coin sdk.Coin) (stop bool) { // if it's not utxo coin then skip if coin.Denom != "utxo" { return false } balance, exists := balances[address.String()] - suite.Require().True(exists) + require.True(exists) expectedUtxo := sdk.NewCoin("utxo", balance.AmountOf(coin.Denom)) - suite.Require().Equal(expectedUtxo.String(), coin.String()) + require.Equal(expectedUtxo.String(), coin.String()) return false }) } -func (suite *IntegrationTestSuite) getTestMetadata() []types.Metadata { - return []types.Metadata{ +func (suite *KeeperTestSuite) getTestMetadata() []banktypes.Metadata { + return []banktypes.Metadata{ { Name: "Cosmos Hub Atom", Symbol: "ATOM", Description: "The native staking token of the Cosmos Hub.", - DenomUnits: []*types.DenomUnit{ + DenomUnits: []*banktypes.DenomUnit{ {Denom: "uatom", Exponent: uint32(0), Aliases: []string{"microatom"}}, {Denom: "matom", Exponent: uint32(3), Aliases: []string{"milliatom"}}, {Denom: "atom", Exponent: uint32(6), Aliases: nil}, @@ -1162,7 +1215,7 @@ func (suite *IntegrationTestSuite) getTestMetadata() []types.Metadata { Name: "Token", Symbol: "TOKEN", Description: "The native staking token of the Token Hub.", - DenomUnits: []*types.DenomUnit{ + DenomUnits: []*banktypes.DenomUnit{ {Denom: "1token", Exponent: uint32(5), Aliases: []string{"decitoken"}}, {Denom: "2token", Exponent: uint32(4), Aliases: []string{"centitoken"}}, {Denom: "3token", Exponent: uint32(7), Aliases: []string{"dekatoken"}}, @@ -1173,18 +1226,9 @@ func (suite *IntegrationTestSuite) getTestMetadata() []types.Metadata { } } -func (suite *IntegrationTestSuite) TestMintCoinRestrictions() { +func (suite *KeeperTestSuite) TestMintCoinRestrictions() { type BankMintingRestrictionFn func(ctx sdk.Context, coins sdk.Coins) error - - maccPerms := simapp.GetMaccPerms() - maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking} - - suite.app.AccountKeeper = authkeeper.NewAccountKeeper( - suite.app.AppCodec(), suite.app.GetKey(authtypes.StoreKey), - authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - suite.app.AccountKeeper.SetModuleAccount(suite.ctx, multiPermAcc) + require := suite.Require() type testCase struct { coinsToTry sdk.Coin @@ -1201,7 +1245,7 @@ func (suite *IntegrationTestSuite) TestMintCoinRestrictions() { func(_ sdk.Context, coins sdk.Coins) error { for _, coin := range coins { if coin.Denom != fooDenom { - return fmt.Errorf("Module %s only has perms for minting %s coins, tried minting %s coins", types.ModuleName, fooDenom, coin.Denom) + return fmt.Errorf("Module %s only has perms for minting %s coins, tried minting %s coins", banktypes.ModuleName, fooDenom, coin.Denom) } } return nil @@ -1220,21 +1264,20 @@ func (suite *IntegrationTestSuite) TestMintCoinRestrictions() { } for _, test := range tests { - suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey), - suite.app.AccountKeeper, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ).WithMintCoinsRestriction(keeper.MintingRestrictionFn(test.restrictionFn)) + keeper := suite.bankKeeper.WithMintCoinsRestriction(keeper.MintingRestrictionFn(test.restrictionFn)) for _, testCase := range test.testCases { if testCase.expectPass { - suite.Require().NoError( - suite.app.BankKeeper.MintCoins( + suite.mockMintCoins(multiPermAcc) + require.NoError( + keeper.MintCoins( suite.ctx, multiPermAcc.Name, sdk.NewCoins(testCase.coinsToTry), ), ) } else { - suite.Require().Error( - suite.app.BankKeeper.MintCoins( + require.Error( + keeper.MintCoins( suite.ctx, multiPermAcc.Name, sdk.NewCoins(testCase.coinsToTry), @@ -1245,8 +1288,9 @@ func (suite *IntegrationTestSuite) TestMintCoinRestrictions() { } } -func (suite *IntegrationTestSuite) TestIsSendEnabledDenom() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper +func (suite *KeeperTestSuite) TestIsSendEnabledDenom() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper + require := suite.Require() defaultCoin := "defaultCoin" enabledCoin := "enabledCoin" @@ -1275,11 +1319,11 @@ func (suite *IntegrationTestSuite) TestIsSendEnabledDenom() { } for _, def := range []bool{true, false} { - params := types.Params{DefaultSendEnabled: def} - suite.Require().NoError(bankKeeper.SetParams(ctx, params)) + params := banktypes.Params{DefaultSendEnabled: def} + require.NoError(bankKeeper.SetParams(ctx, params)) for _, tc := range tests { suite.T().Run(fmt.Sprintf("%s default %t", tc.denom, def), func(t *testing.T) { - actual := suite.app.BankKeeper.IsSendEnabledDenom(suite.ctx, tc.denom) + actual := suite.bankKeeper.IsSendEnabledDenom(suite.ctx, tc.denom) exp := tc.exp if tc.expDef { exp = def @@ -1290,32 +1334,32 @@ func (suite *IntegrationTestSuite) TestIsSendEnabledDenom() { } } -func (suite *IntegrationTestSuite) TestGetSendEnabledEntry() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper +func (suite *KeeperTestSuite) TestGetSendEnabledEntry() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper - bankKeeper.SetAllSendEnabled(ctx, []*types.SendEnabled{ + bankKeeper.SetAllSendEnabled(ctx, []*banktypes.SendEnabled{ {Denom: "gettruecoin", Enabled: true}, {Denom: "getfalsecoin", Enabled: false}, }) tests := []struct { denom string - expSE types.SendEnabled + expSE banktypes.SendEnabled expF bool }{ { denom: "missing", - expSE: types.SendEnabled{}, + expSE: banktypes.SendEnabled{}, expF: false, }, { denom: "gettruecoin", - expSE: types.SendEnabled{Denom: "gettruecoin", Enabled: true}, + expSE: banktypes.SendEnabled{Denom: "gettruecoin", Enabled: true}, expF: true, }, { denom: "getfalsecoin", - expSE: types.SendEnabled{Denom: "getfalsecoin", Enabled: false}, + expSE: banktypes.SendEnabled{Denom: "getfalsecoin", Enabled: false}, expF: true, }, } @@ -1329,8 +1373,9 @@ func (suite *IntegrationTestSuite) TestGetSendEnabledEntry() { } } -func (suite *IntegrationTestSuite) TestSetSendEnabled() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper +func (suite *KeeperTestSuite) TestSetSendEnabled() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper + require := suite.Require() tests := []struct { name string @@ -1380,8 +1425,8 @@ func (suite *IntegrationTestSuite) TestSetSendEnabled() { } for _, def := range []bool{true, false} { - params := types.Params{DefaultSendEnabled: def} - suite.Require().NoError(bankKeeper.SetParams(ctx, params)) + params := banktypes.Params{DefaultSendEnabled: def} + require.NoError(bankKeeper.SetParams(ctx, params)) for _, tc := range tests { suite.T().Run(fmt.Sprintf("%s default %t", tc.name, def), func(t *testing.T) { bankKeeper.SetSendEnabled(ctx, tc.denom, tc.value) @@ -1392,12 +1437,13 @@ func (suite *IntegrationTestSuite) TestSetSendEnabled() { } } -func (suite *IntegrationTestSuite) TestSetAllSendEnabled() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper +func (suite *KeeperTestSuite) TestSetAllSendEnabled() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper + require := suite.Require() tests := []struct { name string - sendEnableds []*types.SendEnabled + sendEnableds []*banktypes.SendEnabled }{ { name: "nil", @@ -1405,44 +1451,44 @@ func (suite *IntegrationTestSuite) TestSetAllSendEnabled() { }, { name: "empty", - sendEnableds: []*types.SendEnabled{}, + sendEnableds: []*banktypes.SendEnabled{}, }, { name: "one true", - sendEnableds: []*types.SendEnabled{ + sendEnableds: []*banktypes.SendEnabled{ {Denom: "aonecoin", Enabled: true}, }, }, { name: "one false", - sendEnableds: []*types.SendEnabled{ + sendEnableds: []*banktypes.SendEnabled{ {Denom: "bonecoin", Enabled: false}, }, }, { name: "two true", - sendEnableds: []*types.SendEnabled{ + sendEnableds: []*banktypes.SendEnabled{ {Denom: "conecoin", Enabled: true}, {Denom: "ctwocoin", Enabled: true}, }, }, { name: "two true false", - sendEnableds: []*types.SendEnabled{ + sendEnableds: []*banktypes.SendEnabled{ {Denom: "donecoin", Enabled: true}, {Denom: "dtwocoin", Enabled: false}, }, }, { name: "two false true", - sendEnableds: []*types.SendEnabled{ + sendEnableds: []*banktypes.SendEnabled{ {Denom: "eonecoin", Enabled: false}, {Denom: "etwocoin", Enabled: true}, }, }, { name: "two false", - sendEnableds: []*types.SendEnabled{ + sendEnableds: []*banktypes.SendEnabled{ {Denom: "fonecoin", Enabled: false}, {Denom: "ftwocoin", Enabled: false}, }, @@ -1450,8 +1496,8 @@ func (suite *IntegrationTestSuite) TestSetAllSendEnabled() { } for _, def := range []bool{true, false} { - params := types.Params{DefaultSendEnabled: def} - suite.Require().NoError(bankKeeper.SetParams(ctx, params)) + params := banktypes.Params{DefaultSendEnabled: def} + require.NoError(bankKeeper.SetParams(ctx, params)) for _, tc := range tests { suite.T().Run(fmt.Sprintf("%s default %t", tc.name, def), func(t *testing.T) { bankKeeper.SetAllSendEnabled(ctx, tc.sendEnableds) @@ -1464,24 +1510,26 @@ func (suite *IntegrationTestSuite) TestSetAllSendEnabled() { } } -func (suite *IntegrationTestSuite) TestDeleteSendEnabled() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper +func (suite *KeeperTestSuite) TestDeleteSendEnabled() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper + require := suite.Require() for _, def := range []bool{true, false} { - params := types.Params{DefaultSendEnabled: def} - suite.Require().NoError(bankKeeper.SetParams(ctx, params)) + params := banktypes.Params{DefaultSendEnabled: def} + require.NoError(bankKeeper.SetParams(ctx, params)) suite.T().Run(fmt.Sprintf("default %t", def), func(t *testing.T) { denom := fmt.Sprintf("somerand%tcoin", !def) bankKeeper.SetSendEnabled(ctx, denom, !def) - require.Equal(t, !def, bankKeeper.IsSendEnabledDenom(ctx, denom)) + require.Equal(!def, bankKeeper.IsSendEnabledDenom(ctx, denom)) bankKeeper.DeleteSendEnabled(ctx, denom) - require.Equal(t, def, bankKeeper.IsSendEnabledDenom(ctx, denom)) + require.Equal(def, bankKeeper.IsSendEnabledDenom(ctx, denom)) }) } } -func (suite *IntegrationTestSuite) TestIterateSendEnabledEntries() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper +func (suite *KeeperTestSuite) TestIterateSendEnabledEntries() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper + require := suite.Require() suite.T().Run("no entries to iterate", func(t *testing.T) { count := 0 @@ -1502,8 +1550,8 @@ func (suite *IntegrationTestSuite) TestIterateSendEnabledEntries() { } for _, def := range []bool{true, false} { - params := types.Params{DefaultSendEnabled: def} - suite.Require().NoError(bankKeeper.SetParams(ctx, params)) + params := banktypes.Params{DefaultSendEnabled: def} + require.NoError(bankKeeper.SetParams(ctx, params)) var seen []string suite.T().Run(fmt.Sprintf("all denoms have expected values default %t", def), func(t *testing.T) { bankKeeper.IterateSendEnabledEntries(ctx, func(denom string, sendEnabled bool) (stop bool) { @@ -1535,8 +1583,9 @@ func (suite *IntegrationTestSuite) TestIterateSendEnabledEntries() { }) } -func (suite *IntegrationTestSuite) TestGetAllSendEnabledEntries() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper +func (suite *KeeperTestSuite) TestGetAllSendEnabledEntries() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper + require := suite.Require() suite.T().Run("no entries", func(t *testing.T) { actual := bankKeeper.GetAllSendEnabledEntries(ctx) @@ -1553,8 +1602,8 @@ func (suite *IntegrationTestSuite) TestGetAllSendEnabledEntries() { } for _, def := range []bool{true, false} { - params := types.Params{DefaultSendEnabled: def} - suite.Require().NoError(bankKeeper.SetParams(ctx, params)) + params := banktypes.Params{DefaultSendEnabled: def} + require.NoError(bankKeeper.SetParams(ctx, params)) var seen []string suite.T().Run(fmt.Sprintf("all denoms have expected values default %t", def), func(t *testing.T) { actual := bankKeeper.GetAllSendEnabledEntries(ctx) @@ -1590,37 +1639,38 @@ func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) { *ps.(*banktypes.Params) = ms.ps } -func (suite *IntegrationTestSuite) TestMigrator_Migrate3to4() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper +func (suite *KeeperTestSuite) TestMigrator_Migrate3to4() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper + require := suite.Require() for _, def := range []bool{true, false} { - params := types.Params{DefaultSendEnabled: def} - suite.Require().NoError(bankKeeper.SetParams(ctx, params)) + params := banktypes.Params{DefaultSendEnabled: def} + require.NoError(bankKeeper.SetParams(ctx, params)) suite.T().Run(fmt.Sprintf("default %t does not change", def), func(t *testing.T) { - legacySubspace := func(ps types.Params) mockSubspace { + legacySubspace := func(ps banktypes.Params) mockSubspace { return mockSubspace{ps: ps} }(banktypes.NewParams(def)) - migrator := keeper.NewMigrator(bankKeeper.(keeper.BaseKeeper), legacySubspace) - require.NoError(t, migrator.Migrate3to4(ctx)) + migrator := keeper.NewMigrator(bankKeeper, legacySubspace) + require.NoError(migrator.Migrate3to4(ctx)) actual := bankKeeper.GetParams(ctx) - assert.Equal(t, params.DefaultSendEnabled, actual.DefaultSendEnabled) + require.Equal(params.DefaultSendEnabled, actual.DefaultSendEnabled) }) } for _, def := range []bool{true, false} { - params := types.Params{ - SendEnabled: []*types.SendEnabled{ + params := banktypes.Params{ + SendEnabled: []*banktypes.SendEnabled{ {Denom: fmt.Sprintf("truecoin%t", def), Enabled: true}, {Denom: fmt.Sprintf("falsecoin%t", def), Enabled: false}, }, } - suite.Require().NoError(bankKeeper.SetParams(ctx, params)) + require.NoError(bankKeeper.SetParams(ctx, params)) suite.T().Run(fmt.Sprintf("default %t send enabled info moved to store", def), func(t *testing.T) { - legacySubspace := func(ps types.Params) mockSubspace { + legacySubspace := func(ps banktypes.Params) mockSubspace { return mockSubspace{ps: ps} }(banktypes.NewParams(def)) - migrator := keeper.NewMigrator(bankKeeper.(keeper.BaseKeeper), legacySubspace) - require.NoError(t, migrator.Migrate3to4(ctx)) + migrator := keeper.NewMigrator(bankKeeper, legacySubspace) + require.NoError(migrator.Migrate3to4(ctx)) newParams := bankKeeper.GetParams(ctx) assert.Len(t, newParams.SendEnabled, 0) for _, se := range params.SendEnabled { @@ -1631,14 +1681,15 @@ func (suite *IntegrationTestSuite) TestMigrator_Migrate3to4() { } } -func (suite *IntegrationTestSuite) TestSetParams() { - ctx, bankKeeper := suite.ctx, suite.app.BankKeeper - params := types.NewParams(true) - params.SendEnabled = []*types.SendEnabled{ +func (suite *KeeperTestSuite) TestSetParams() { + ctx, bankKeeper := suite.ctx, suite.bankKeeper + require := suite.Require() + params := banktypes.NewParams(true) + params.SendEnabled = []*banktypes.SendEnabled{ {Denom: "paramscointrue", Enabled: true}, {Denom: "paramscoinfalse", Enabled: false}, } - suite.Require().NoError(bankKeeper.SetParams(ctx, params)) + require.NoError(bankKeeper.SetParams(ctx, params)) suite.Run("stored params are as expected", func() { actual := bankKeeper.GetParams(ctx) @@ -1658,5 +1709,5 @@ func (suite *IntegrationTestSuite) TestSetParams() { } func TestKeeperTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) + suite.Run(t, new(KeeperTestSuite)) } diff --git a/x/bank/keeper/msg_server.go b/x/bank/keeper/msg_server.go index 7555dc506cb6..f0c4571976d1 100644 --- a/x/bank/keeper/msg_server.go +++ b/x/bank/keeper/msg_server.go @@ -7,7 +7,6 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/bank/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -86,7 +85,7 @@ func (k msgServer) MultiSend(goCtx context.Context, msg *types.MsgMultiSend) (*t accAddr := sdk.MustAccAddressFromBech32(out.Address) if k.BlockedAddr(accAddr) { - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive transactions", out.Address) + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to receive funds", out.Address) } } @@ -107,7 +106,7 @@ func (k msgServer) MultiSend(goCtx context.Context, msg *types.MsgMultiSend) (*t func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if k.GetAuthority() != req.Authority { - return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) + return nil, sdkerrors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.GetAuthority(), req.Authority) } ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/bank/keeper/msg_service_test.go b/x/bank/keeper/msg_service_test.go index 633c62a16d64..87b5c4b6fcb9 100644 --- a/x/bank/keeper/msg_service_test.go +++ b/x/bank/keeper/msg_service_test.go @@ -1,22 +1,24 @@ package keeper_test import ( - "github.com/cosmos/cosmos-sdk/x/bank/types" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) -func (suite *IntegrationTestSuite) TestMsgUpdateParams() { +func (suite *KeeperTestSuite) TestMsgUpdateParams() { // default params - params := types.DefaultParams() + params := banktypes.DefaultParams() testCases := []struct { name string - input *types.MsgUpdateParams + input *banktypes.MsgUpdateParams expErr bool expErrMsg string }{ { name: "invalid authority", - input: &types.MsgUpdateParams{ + input: &banktypes.MsgUpdateParams{ Authority: "invalid", Params: params, }, @@ -25,10 +27,10 @@ func (suite *IntegrationTestSuite) TestMsgUpdateParams() { }, { name: "send enabled param", - input: &types.MsgUpdateParams{ - Authority: suite.app.BankKeeper.GetAuthority(), - Params: types.Params{ - SendEnabled: []*types.SendEnabled{ + input: &banktypes.MsgUpdateParams{ + Authority: suite.bankKeeper.GetAuthority(), + Params: banktypes.Params{ + SendEnabled: []*banktypes.SendEnabled{ {Denom: "foo", Enabled: true}, }, }, @@ -37,8 +39,8 @@ func (suite *IntegrationTestSuite) TestMsgUpdateParams() { }, { name: "all good", - input: &types.MsgUpdateParams{ - Authority: suite.app.BankKeeper.GetAuthority(), + input: &banktypes.MsgUpdateParams{ + Authority: suite.bankKeeper.GetAuthority(), Params: params, }, expErr: false, @@ -59,3 +61,113 @@ func (suite *IntegrationTestSuite) TestMsgUpdateParams() { }) } } + +func (suite *KeeperTestSuite) TestMsgSend() { + origCoins := sdk.NewCoins(sdk.NewInt64Coin("sendableCoin", 100)) + suite.bankKeeper.SetSendEnabled(suite.ctx, origCoins.Denoms()[0], true) + + testCases := []struct { + name string + input *banktypes.MsgSend + expErr bool + expErrMsg string + }{ + { + name: "invalid send to blocked address", + input: &banktypes.MsgSend{ + FromAddress: minterAcc.GetAddress().String(), + ToAddress: accAddrs[4].String(), + Amount: origCoins, + }, + expErr: true, + expErrMsg: "is not allowed to receive funds", + }, + { + name: "all good", + input: &banktypes.MsgSend{ + FromAddress: minterAcc.GetAddress().String(), + ToAddress: baseAcc.Address, + Amount: origCoins, + }, + expErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.mockMintCoins(minterAcc) + suite.bankKeeper.MintCoins(suite.ctx, minterAcc.Name, origCoins) + if !tc.expErr { + suite.mockSendCoins(suite.ctx, minterAcc, baseAcc.GetAddress()) + } + _, err := suite.msgServer.Send(suite.ctx, tc.input) + if tc.expErr { + suite.Require().Error(err) + suite.Require().Contains(err.Error(), tc.expErrMsg) + } else { + suite.Require().NoError(err) + } + }) + } +} + +func (suite *KeeperTestSuite) TestMsgMultiSend() { + origDenom := "sendableCoin" + origCoins := sdk.NewCoins(sdk.NewInt64Coin(origDenom, 100)) + sendCoins := sdk.NewCoins(sdk.NewInt64Coin(origDenom, 50)) + suite.bankKeeper.SetSendEnabled(suite.ctx, origDenom, true) + + testCases := []struct { + name string + input *banktypes.MsgMultiSend + expErr bool + expErrMsg string + }{ + { + name: "invalid send to blocked address", + input: &banktypes.MsgMultiSend{ + Inputs: []banktypes.Input{ + {Address: minterAcc.GetAddress().String(), Coins: origCoins}, + }, + Outputs: []banktypes.Output{ + {Address: accAddrs[0].String(), Coins: sendCoins}, + {Address: accAddrs[4].String(), Coins: sendCoins}, + }, + }, + expErr: true, + expErrMsg: "is not allowed to receive funds", + }, + { + name: "invalid send to blocked address", + input: &banktypes.MsgMultiSend{ + Inputs: []banktypes.Input{ + {Address: minterAcc.GetAddress().String(), Coins: origCoins}, + }, + Outputs: []banktypes.Output{ + {Address: accAddrs[0].String(), Coins: sendCoins}, + {Address: accAddrs[1].String(), Coins: sendCoins}, + }, + }, + expErr: false, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + suite.mockMintCoins(minterAcc) + suite.bankKeeper.MintCoins(suite.ctx, minterAcc.Name, origCoins) + if !tc.expErr { + suite.mockInputOutputCoins([]authtypes.AccountI{minterAcc}, accAddrs[:2]) + } + _, err := suite.msgServer.MultiSend(suite.ctx, tc.input) + if tc.expErr { + suite.Require().Error(err) + suite.Require().Contains(err.Error(), tc.expErrMsg) + } else { + suite.Require().NoError(err) + } + }) + } +} diff --git a/x/bank/keeper/querier.go b/x/bank/keeper/querier.go deleted file mode 100644 index e64321b6c0a8..000000000000 --- a/x/bank/keeper/querier.go +++ /dev/null @@ -1,121 +0,0 @@ -package keeper - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/bank/types" -) - -// NewQuerier returns a new sdk.Keeper instance. -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryBalance: - return queryBalance(ctx, req, k, legacyQuerierCdc) - - case types.QueryAllBalances: - return queryAllBalance(ctx, req, k, legacyQuerierCdc) - - case types.QueryTotalSupply: - return queryTotalSupply(ctx, req, k, legacyQuerierCdc) - - case types.QuerySupplyOf: - return querySupplyOf(ctx, req, k, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0]) - } - } -} - -func queryBalance(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryBalanceRequest - - if err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - address, err := sdk.AccAddressFromBech32(params.Address) - if err != nil { - return nil, err - } - - balance := k.GetBalance(ctx, address, params.Denom) - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, balance) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryAllBalance(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryAllBalancesRequest - - if err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - address, err := sdk.AccAddressFromBech32(params.Address) - if err != nil { - return nil, err - } - - balances := k.GetAllBalances(ctx, address) - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, balances) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryTotalSupply(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryTotalSupplyRequest - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - totalSupply, pageRes, err := k.GetPaginatedTotalSupply(ctx, params.Pagination) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - supplyRes := &types.QueryTotalSupplyResponse{ - Supply: totalSupply, - Pagination: pageRes, - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, supplyRes) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func querySupplyOf(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QuerySupplyOfParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - amount := k.GetSupply(ctx, params.Denom) - supply := sdk.NewCoin(params.Denom, amount.Amount) - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, supply) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} diff --git a/x/bank/keeper/querier_test.go b/x/bank/keeper/querier_test.go deleted file mode 100644 index 7eba1f608a2b..000000000000 --- a/x/bank/keeper/querier_test.go +++ /dev/null @@ -1,169 +0,0 @@ -package keeper_test - -import ( - "fmt" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmos/cosmos-sdk/x/bank/keeper" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" - "github.com/cosmos/cosmos-sdk/x/bank/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -func (suite *IntegrationTestSuite) TestQuerier_QueryBalance() { - app, ctx := suite.app, suite.ctx - legacyAmino := app.LegacyAmino() - _, _, addr := testdata.KeyTestPubAddr() - req := abci.RequestQuery{ - Path: fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QueryBalance), - Data: []byte{}, - } - - querier := keeper.NewQuerier(app.BankKeeper, legacyAmino) - - res, err := querier(ctx, []string{types.QueryBalance}, req) - suite.Require().NotNil(err) - suite.Require().Nil(res) - - req.Data = legacyAmino.MustMarshalJSON(types.NewQueryBalanceRequest(addr, fooDenom)) - res, err = querier(ctx, []string{types.QueryBalance}, req) - suite.Require().NoError(err) - suite.Require().NotNil(res) - - var balance sdk.Coin - suite.Require().NoError(legacyAmino.UnmarshalJSON(res, &balance)) - suite.True(balance.IsZero()) - - origCoins := sdk.NewCoins(newFooCoin(50), newBarCoin(30)) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) - - app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) - - res, err = querier(ctx, []string{types.QueryBalance}, req) - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().NoError(legacyAmino.UnmarshalJSON(res, &balance)) - suite.True(balance.IsEqual(newFooCoin(50))) -} - -func (suite *IntegrationTestSuite) TestQuerier_QueryAllBalances() { - app, ctx := suite.app, suite.ctx - legacyAmino := app.LegacyAmino() - _, _, addr := testdata.KeyTestPubAddr() - req := abci.RequestQuery{ - Path: fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QueryAllBalances), - Data: []byte{}, - } - - querier := keeper.NewQuerier(app.BankKeeper, legacyAmino) - - res, err := querier(ctx, []string{types.QueryAllBalances}, req) - suite.Require().NotNil(err) - suite.Require().Nil(res) - - req.Data = legacyAmino.MustMarshalJSON(types.NewQueryAllBalancesRequest(addr, nil)) - res, err = querier(ctx, []string{types.QueryAllBalances}, req) - suite.Require().NoError(err) - suite.Require().NotNil(res) - - var balances sdk.Coins - suite.Require().NoError(legacyAmino.UnmarshalJSON(res, &balances)) - suite.True(balances.IsZero()) - - origCoins := sdk.NewCoins(newFooCoin(50), newBarCoin(30)) - acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) - - app.AccountKeeper.SetAccount(ctx, acc) - suite.Require().NoError(testutil.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), origCoins)) - res, err = querier(ctx, []string{types.QueryAllBalances}, req) - suite.Require().NoError(err) - suite.Require().NotNil(res) - suite.Require().NoError(legacyAmino.UnmarshalJSON(res, &balances)) - suite.True(balances.IsEqual(origCoins)) -} - -func (suite *IntegrationTestSuite) TestQuerier_QueryTotalSupply() { - app, ctx := suite.app, suite.ctx - legacyAmino := app.LegacyAmino() - - genesisSupply, _, err := suite.app.BankKeeper.GetPaginatedTotalSupply(suite.ctx, &query.PageRequest{Limit: query.MaxLimit}) - suite.Require().NoError(err) - - testCoins := sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)) - suite. - Require(). - NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, testCoins)) - - req := abci.RequestQuery{ - Path: fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QueryTotalSupply), - Data: []byte{}, - } - - querier := keeper.NewQuerier(app.BankKeeper, legacyAmino) - - res, err := querier(ctx, []string{types.QueryTotalSupply}, req) - suite.Require().NotNil(err) - suite.Require().Nil(res) - - req.Data = legacyAmino.MustMarshalJSON(types.QueryTotalSupplyRequest{Pagination: &query.PageRequest{ - Limit: 100, - }}) - res, err = querier(ctx, []string{types.QueryTotalSupply}, req) - suite.Require().NoError(err) - suite.Require().NotNil(res) - - var resp types.QueryTotalSupplyResponse - suite.Require().NoError(legacyAmino.UnmarshalJSON(res, &resp)) - - expectedTotalSupply := genesisSupply.Add(testCoins...) - suite.Require().Equal(expectedTotalSupply, resp.Supply) -} - -func (suite *IntegrationTestSuite) TestQuerier_QueryTotalSupplyOf() { - app, ctx := suite.app, suite.ctx - legacyAmino := app.LegacyAmino() - test1Supply := sdk.NewInt64Coin("test1", 4000000) - test2Supply := sdk.NewInt64Coin("test2", 700000000) - expectedTotalSupply := sdk.NewCoins(test1Supply, test2Supply) - suite. - Require(). - NoError(app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, expectedTotalSupply)) - - req := abci.RequestQuery{ - Path: fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QuerySupplyOf), - Data: []byte{}, - } - - querier := keeper.NewQuerier(app.BankKeeper, legacyAmino) - - res, err := querier(ctx, []string{types.QuerySupplyOf}, req) - suite.Require().NotNil(err) - suite.Require().Nil(res) - - req.Data = legacyAmino.MustMarshalJSON(types.NewQuerySupplyOfParams(test1Supply.Denom)) - res, err = querier(ctx, []string{types.QuerySupplyOf}, req) - suite.Require().NoError(err) - suite.Require().NotNil(res) - - var resp sdk.Coin - suite.Require().NoError(legacyAmino.UnmarshalJSON(res, &resp)) - suite.Require().Equal(test1Supply, resp) -} - -func (suite *IntegrationTestSuite) TestQuerierRouteNotFound() { - app, ctx := suite.app, suite.ctx - legacyAmino := app.LegacyAmino() - req := abci.RequestQuery{ - Path: fmt.Sprintf("custom/%s/invalid", types.ModuleName), - Data: []byte{}, - } - - querier := keeper.NewQuerier(app.BankKeeper, legacyAmino) - _, err := querier(ctx, []string{"invalid"}, req) - suite.Error(err) -} diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index 88ff044898c2..e21b5bcef41b 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -99,6 +99,7 @@ func (k BaseSendKeeper) GetParams(ctx sdk.Context) (params types.Params) { } // SetParams sets the total set of bank parameters. +//nolint:staticcheck // params.SendEnabled is deprecated but it should be here regardless. func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) error { // normally SendEnabled is deprecated but we still support it for backwards compatibility // using params.Validate() would fail due to the SendEnabled deprecation diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go index 35e640823762..32e146ecdd15 100644 --- a/x/bank/keeper/view.go +++ b/x/bank/keeper/view.go @@ -100,7 +100,7 @@ func (k BaseViewKeeper) GetAccountsBalances(ctx sdk.Context) []types.Balance { // by address. func (k BaseViewKeeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin { accountStore := k.getAccountStore(ctx, addr) - amount := sdk.ZeroInt() + amount := math.ZeroInt() bz := accountStore.Get([]byte(denom)) if bz == nil { return sdk.NewCoin(denom, amount) diff --git a/x/bank/migrations/v2/json_test.go b/x/bank/migrations/v2/json_test.go index 677a211fb8e9..ddf908e01982 100644 --- a/x/bank/migrations/v2/json_test.go +++ b/x/bank/migrations/v2/json_test.go @@ -7,14 +7,14 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" v2bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" "github.com/cosmos/cosmos-sdk/x/bank/types" ) func TestMigrateJSON(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() + encodingConfig := moduletestutil.MakeTestEncodingConfig() clientCtx := client.Context{}. WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). diff --git a/x/bank/migrations/v2/store.go b/x/bank/migrations/v2/store.go index 5431e7afa330..84a882d3d40b 100644 --- a/x/bank/migrations/v2/store.go +++ b/x/bank/migrations/v2/store.go @@ -1,6 +1,7 @@ package v2 import ( + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -62,7 +63,7 @@ func migrateBalanceKeys(store sdk.KVStore) { for ; oldStoreIter.Valid(); oldStoreIter.Next() { addr := v1.AddressFromBalancesStore(oldStoreIter.Key()) denom := oldStoreIter.Key()[v042auth.AddrLen:] - newStoreKey := append(CreateAccountBalancesPrefix(addr), denom...) + newStoreKey := types.CreatePrefixedAccountStoreKey(addr, denom) // Set new key on store. Values don't change. store.Set(newStoreKey, oldStoreIter.Value()) @@ -118,7 +119,7 @@ func pruneZeroSupply(store sdk.KVStore) error { defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var amount sdk.Int + var amount math.Int if err := amount.Unmarshal(iterator.Value()); err != nil { return err } diff --git a/x/bank/migrations/v2/store_test.go b/x/bank/migrations/v2/store_test.go index a142f2a516ad..96bd7e15e6e3 100644 --- a/x/bank/migrations/v2/store_test.go +++ b/x/bank/migrations/v2/store_test.go @@ -3,20 +3,21 @@ package v2_test import ( "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" v1bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v1" v2bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" "github.com/cosmos/cosmos-sdk/x/bank/types" ) func TestSupplyMigration(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig() bankKey := sdk.NewKVStoreKey("bank") ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(bankKey) @@ -41,7 +42,7 @@ func TestSupplyMigration(t *testing.T) { // New supply is indexed by denom. supplyStore := prefix.NewStore(store, types.SupplyKey) bz := supplyStore.Get([]byte("foo")) - var amount sdk.Int + var amount math.Int err = amount.Unmarshal(bz) require.NoError(t, err) @@ -67,7 +68,7 @@ func TestSupplyMigration(t *testing.T) { } func TestBalanceKeysMigration(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig() bankKey := sdk.NewKVStoreKey("bank") ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(bankKey) @@ -92,13 +93,13 @@ func TestBalanceKeysMigration(t *testing.T) { err = v2bank.MigrateStore(ctx, bankKey, encCfg.Codec) require.NoError(t, err) - newKey := append(types.CreateAccountBalancesPrefix(addr), []byte(fooCoin.Denom)...) + newKey := types.CreatePrefixedAccountStoreKey(addr, []byte(fooCoin.Denom)) // -7 because we replaced "balances" with 0x02, // +1 because we added length-prefix to address. require.Equal(t, len(oldFooKey)-7+1, len(newKey)) require.Nil(t, store.Get(oldFooKey)) require.Equal(t, fooBz, store.Get(newKey)) - newKeyFooBar := append(types.CreateAccountBalancesPrefix(addr), []byte(fooBarCoin.Denom)...) + newKeyFooBar := types.CreatePrefixedAccountStoreKey(addr, []byte(fooBarCoin.Denom)) require.Nil(t, store.Get(newKeyFooBar)) // after migration zero balances pruned from store. } diff --git a/x/bank/migrations/v3/store_test.go b/x/bank/migrations/v3/store_test.go index 88a411ef9029..4c418ffb0d05 100644 --- a/x/bank/migrations/v3/store_test.go +++ b/x/bank/migrations/v3/store_test.go @@ -3,20 +3,21 @@ package v3_test import ( "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" v2 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v2" v3 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v3" "github.com/cosmos/cosmos-sdk/x/bank/types" ) func TestMigrateStore(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig() bankKey := sdk.NewKVStoreKey("bank") ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(bankKey) @@ -41,7 +42,7 @@ func TestMigrateStore(t *testing.T) { for _, b := range balances { addrPrefixStore := prefix.NewStore(store, types.CreateAccountBalancesPrefix(addr)) bz := addrPrefixStore.Get([]byte(b.Denom)) - var expected sdk.Int + var expected math.Int require.NoError(t, expected.Unmarshal(bz)) require.Equal(t, expected, b.Amount) } @@ -54,7 +55,7 @@ func TestMigrateStore(t *testing.T) { } func TestMigrateDenomMetaData(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig() bankKey := sdk.NewKVStoreKey("bank") ctx := testutil.DefaultContext(bankKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(bankKey) @@ -64,9 +65,9 @@ func TestMigrateDenomMetaData(t *testing.T) { Symbol: "ATOM", Description: "The native staking token of the Cosmos Hub.", DenomUnits: []*types.DenomUnit{ - {"uatom", uint32(0), []string{"microatom"}}, - {"matom", uint32(3), []string{"milliatom"}}, - {"atom", uint32(6), nil}, + {Denom: "uatom", Exponent: uint32(0), Aliases: []string{"microatom"}}, + {Denom: "matom", Exponent: uint32(3), Aliases: []string{"milliatom"}}, + {Denom: "atom", Exponent: uint32(6), Aliases: nil}, }, Base: "uatom", Display: "atom", @@ -76,9 +77,9 @@ func TestMigrateDenomMetaData(t *testing.T) { Symbol: "TOKEN", Description: "The native staking token of the Token Hub.", DenomUnits: []*types.DenomUnit{ - {"1token", uint32(5), []string{"decitoken"}}, - {"2token", uint32(4), []string{"centitoken"}}, - {"3token", uint32(7), []string{"dekatoken"}}, + {Denom: "1token", Exponent: uint32(5), Aliases: []string{"decitoken"}}, + {Denom: "2token", Exponent: uint32(4), Aliases: []string{"centitoken"}}, + {Denom: "3token", Exponent: uint32(7), Aliases: []string{"dekatoken"}}, }, Base: "utoken", Display: "token", diff --git a/x/bank/module.go b/x/bank/module.go index a25dcfbb32fb..0ca4e015ebb7 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -146,19 +146,9 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) } -// Deprecated: Route returns the message routing key for the bank module. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - // QuerierRoute returns the bank module's querier route name. func (AppModule) QuerierRoute() string { return types.RouterKey } -// LegacyQuerierHandler returns the bank module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) -} - // InitGenesis performs genesis initialization for the bank module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index f5ab63b2bc7e..86ef2d496a46 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -177,7 +177,7 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { // random number of inputs/outputs between [1, 3] - inputs := make([]types.Input, r.Intn(1)+1) + inputs := make([]types.Input, r.Intn(1)+1) //nolint:staticcheck // SA4030: (*math/rand.Rand).Intn(n) generates a random value 0 <= x < n; that is, the generated values don't include n; r.Intn(1) therefore always returns 0 outputs := make([]types.Output, r.Intn(3)+1) // collect signer privKeys diff --git a/x/bank/spec/README.md b/x/bank/spec/README.md index ec5d1df2f3e5..ce0d9e8e0cf0 100644 --- a/x/bank/spec/README.md +++ b/x/bank/spec/README.md @@ -79,7 +79,7 @@ Each `ModuleAccount` has a different set of permissions that provide different object capabilities to perform certain actions. Permissions need to be registered upon the creation of the supply `Keeper` so that every time a `ModuleAccount` calls the allowed functions, the `Keeper` can lookup the -permissions to that specific account and perform or not the action. +permissions to that specific account and perform or not perform the action. The available permissions are: diff --git a/x/bank/testutil/expected_keepers_mocks.go b/x/bank/testutil/expected_keepers_mocks.go new file mode 100644 index 000000000000..c27addd028fd --- /dev/null +++ b/x/bank/testutil/expected_keepers_mocks.go @@ -0,0 +1,228 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: x/bank/types/expected_keepers.go + +// Package testutil is a generated GoMock package. +package testutil + +import ( + reflect "reflect" + + types "github.com/cosmos/cosmos-sdk/types" + types0 "github.com/cosmos/cosmos-sdk/x/auth/types" + gomock "github.com/golang/mock/gomock" +) + +// MockAccountKeeper is a mock of AccountKeeper interface. +type MockAccountKeeper struct { + ctrl *gomock.Controller + recorder *MockAccountKeeperMockRecorder +} + +// MockAccountKeeperMockRecorder is the mock recorder for MockAccountKeeper. +type MockAccountKeeperMockRecorder struct { + mock *MockAccountKeeper +} + +// NewMockAccountKeeper creates a new mock instance. +func NewMockAccountKeeper(ctrl *gomock.Controller) *MockAccountKeeper { + mock := &MockAccountKeeper{ctrl: ctrl} + mock.recorder = &MockAccountKeeperMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockAccountKeeper) EXPECT() *MockAccountKeeperMockRecorder { + return m.recorder +} + +// GetAccount mocks base method. +func (m *MockAccountKeeper) GetAccount(ctx types.Context, addr types.AccAddress) types0.AccountI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAccount", ctx, addr) + ret0, _ := ret[0].(types0.AccountI) + return ret0 +} + +// GetAccount indicates an expected call of GetAccount. +func (mr *MockAccountKeeperMockRecorder) GetAccount(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetAccount), ctx, addr) +} + +// GetAllAccounts mocks base method. +func (m *MockAccountKeeper) GetAllAccounts(ctx types.Context) []types0.AccountI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllAccounts", ctx) + ret0, _ := ret[0].([]types0.AccountI) + return ret0 +} + +// GetAllAccounts indicates an expected call of GetAllAccounts. +func (mr *MockAccountKeeperMockRecorder) GetAllAccounts(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllAccounts", reflect.TypeOf((*MockAccountKeeper)(nil).GetAllAccounts), ctx) +} + +// GetModuleAccount mocks base method. +func (m *MockAccountKeeper) GetModuleAccount(ctx types.Context, moduleName string) types0.ModuleAccountI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetModuleAccount", ctx, moduleName) + ret0, _ := ret[0].(types0.ModuleAccountI) + return ret0 +} + +// GetModuleAccount indicates an expected call of GetModuleAccount. +func (mr *MockAccountKeeperMockRecorder) GetModuleAccount(ctx, moduleName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAccount", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAccount), ctx, moduleName) +} + +// GetModuleAccountAndPermissions mocks base method. +func (m *MockAccountKeeper) GetModuleAccountAndPermissions(ctx types.Context, moduleName string) (types0.ModuleAccountI, []string) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetModuleAccountAndPermissions", ctx, moduleName) + ret0, _ := ret[0].(types0.ModuleAccountI) + ret1, _ := ret[1].([]string) + return ret0, ret1 +} + +// GetModuleAccountAndPermissions indicates an expected call of GetModuleAccountAndPermissions. +func (mr *MockAccountKeeperMockRecorder) GetModuleAccountAndPermissions(ctx, moduleName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAccountAndPermissions", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAccountAndPermissions), ctx, moduleName) +} + +// GetModuleAddress mocks base method. +func (m *MockAccountKeeper) GetModuleAddress(moduleName string) types.AccAddress { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetModuleAddress", moduleName) + ret0, _ := ret[0].(types.AccAddress) + return ret0 +} + +// GetModuleAddress indicates an expected call of GetModuleAddress. +func (mr *MockAccountKeeperMockRecorder) GetModuleAddress(moduleName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddress", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddress), moduleName) +} + +// GetModuleAddressAndPermissions mocks base method. +func (m *MockAccountKeeper) GetModuleAddressAndPermissions(moduleName string) (types.AccAddress, []string) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetModuleAddressAndPermissions", moduleName) + ret0, _ := ret[0].(types.AccAddress) + ret1, _ := ret[1].([]string) + return ret0, ret1 +} + +// GetModuleAddressAndPermissions indicates an expected call of GetModuleAddressAndPermissions. +func (mr *MockAccountKeeperMockRecorder) GetModuleAddressAndPermissions(moduleName interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModuleAddressAndPermissions", reflect.TypeOf((*MockAccountKeeper)(nil).GetModuleAddressAndPermissions), moduleName) +} + +// GetModulePermissions mocks base method. +func (m *MockAccountKeeper) GetModulePermissions() map[string]types0.PermissionsForAddress { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetModulePermissions") + ret0, _ := ret[0].(map[string]types0.PermissionsForAddress) + return ret0 +} + +// GetModulePermissions indicates an expected call of GetModulePermissions. +func (mr *MockAccountKeeperMockRecorder) GetModulePermissions() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetModulePermissions", reflect.TypeOf((*MockAccountKeeper)(nil).GetModulePermissions)) +} + +// HasAccount mocks base method. +func (m *MockAccountKeeper) HasAccount(ctx types.Context, addr types.AccAddress) bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "HasAccount", ctx, addr) + ret0, _ := ret[0].(bool) + return ret0 +} + +// HasAccount indicates an expected call of HasAccount. +func (mr *MockAccountKeeperMockRecorder) HasAccount(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasAccount", reflect.TypeOf((*MockAccountKeeper)(nil).HasAccount), ctx, addr) +} + +// IterateAccounts mocks base method. +func (m *MockAccountKeeper) IterateAccounts(ctx types.Context, process func(types0.AccountI) bool) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "IterateAccounts", ctx, process) +} + +// IterateAccounts indicates an expected call of IterateAccounts. +func (mr *MockAccountKeeperMockRecorder) IterateAccounts(ctx, process interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IterateAccounts", reflect.TypeOf((*MockAccountKeeper)(nil).IterateAccounts), ctx, process) +} + +// NewAccount mocks base method. +func (m *MockAccountKeeper) NewAccount(arg0 types.Context, arg1 types0.AccountI) types0.AccountI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NewAccount", arg0, arg1) + ret0, _ := ret[0].(types0.AccountI) + return ret0 +} + +// NewAccount indicates an expected call of NewAccount. +func (mr *MockAccountKeeperMockRecorder) NewAccount(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewAccount", reflect.TypeOf((*MockAccountKeeper)(nil).NewAccount), arg0, arg1) +} + +// NewAccountWithAddress mocks base method. +func (m *MockAccountKeeper) NewAccountWithAddress(ctx types.Context, addr types.AccAddress) types0.AccountI { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NewAccountWithAddress", ctx, addr) + ret0, _ := ret[0].(types0.AccountI) + return ret0 +} + +// NewAccountWithAddress indicates an expected call of NewAccountWithAddress. +func (mr *MockAccountKeeperMockRecorder) NewAccountWithAddress(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewAccountWithAddress", reflect.TypeOf((*MockAccountKeeper)(nil).NewAccountWithAddress), ctx, addr) +} + +// SetAccount mocks base method. +func (m *MockAccountKeeper) SetAccount(ctx types.Context, acc types0.AccountI) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetAccount", ctx, acc) +} + +// SetAccount indicates an expected call of SetAccount. +func (mr *MockAccountKeeperMockRecorder) SetAccount(ctx, acc interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetAccount), ctx, acc) +} + +// SetModuleAccount mocks base method. +func (m *MockAccountKeeper) SetModuleAccount(ctx types.Context, macc types0.ModuleAccountI) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetModuleAccount", ctx, macc) +} + +// SetModuleAccount indicates an expected call of SetModuleAccount. +func (mr *MockAccountKeeperMockRecorder) SetModuleAccount(ctx, macc interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetModuleAccount", reflect.TypeOf((*MockAccountKeeper)(nil).SetModuleAccount), ctx, macc) +} + +// ValidatePermissions mocks base method. +func (m *MockAccountKeeper) ValidatePermissions(macc types0.ModuleAccountI) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ValidatePermissions", macc) + ret0, _ := ret[0].(error) + return ret0 +} + +// ValidatePermissions indicates an expected call of ValidatePermissions. +func (mr *MockAccountKeeperMockRecorder) ValidatePermissions(macc interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ValidatePermissions", reflect.TypeOf((*MockAccountKeeper)(nil).ValidatePermissions), macc) +} diff --git a/x/bank/types/authz.pb.go b/x/bank/types/authz.pb.go index 904a7f9ce793..8a2f6ae3a8f3 100644 --- a/x/bank/types/authz.pb.go +++ b/x/bank/types/authz.pb.go @@ -32,6 +32,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Since: cosmos-sdk 0.43 type SendAuthorization struct { SpendLimit github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=spend_limit,json=spendLimit,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"spend_limit"` + // allow_list specifies an optional list of addresses to whom the grantee can send tokens on behalf of the + // granter. If omitted, any recipient is allowed. + // + // Since: cosmos-sdk 0.47 + AllowList []string `protobuf:"bytes,2,rep,name=allow_list,json=allowList,proto3" json:"allow_list,omitempty"` } func (m *SendAuthorization) Reset() { *m = SendAuthorization{} } @@ -74,6 +79,13 @@ func (m *SendAuthorization) GetSpendLimit() github_com_cosmos_cosmos_sdk_types.C return nil } +func (m *SendAuthorization) GetAllowList() []string { + if m != nil { + return m.AllowList + } + return nil +} + func init() { proto.RegisterType((*SendAuthorization)(nil), "cosmos.bank.v1beta1.SendAuthorization") } @@ -81,24 +93,25 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/authz.proto", fileDescriptor_a4d2a37888ea779f) } var fileDescriptor_a4d2a37888ea779f = []byte{ - // 257 bytes of a gzipped FileDescriptorProto + // 285 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x4f, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x4a, 0xcc, 0xcb, 0xd6, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x2c, 0x2d, 0xc9, 0xa8, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0x28, 0xd0, 0x03, 0x29, 0xd0, 0x83, 0x2a, 0x90, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0xcb, 0xeb, 0x83, 0x58, 0x10, 0xa5, 0x52, 0x92, 0x10, 0xa5, 0xf1, 0x10, 0x09, 0xa8, 0x3e, 0x88, 0x94, 0x1c, 0xdc, 0x9a, - 0xe2, 0x54, 0xb8, 0x35, 0xc9, 0xf9, 0x99, 0x79, 0x10, 0x79, 0xa5, 0x29, 0x8c, 0x5c, 0x82, 0xc1, + 0xe2, 0x54, 0xb8, 0x35, 0xc9, 0xf9, 0x99, 0x79, 0x10, 0x79, 0xa5, 0xcd, 0x8c, 0x5c, 0x82, 0xc1, 0xa9, 0x79, 0x29, 0x8e, 0xa5, 0x25, 0x19, 0xf9, 0x45, 0x99, 0x55, 0x89, 0x25, 0x99, 0xf9, 0x79, 0x42, 0x39, 0x5c, 0xdc, 0xc5, 0x05, 0xa9, 0x79, 0x29, 0xf1, 0x39, 0x99, 0xb9, 0x99, 0x25, 0x12, 0x8c, 0x0a, 0xcc, 0x1a, 0xdc, 0x46, 0x92, 0x7a, 0x70, 0x17, 0x15, 0xa7, 0xc2, 0x5c, 0xa4, 0xe7, 0x9c, 0x9f, 0x99, 0xe7, 0x64, 0x70, 0xe2, 0x9e, 0x3c, 0xc3, 0xaa, 0xfb, 0xf2, 0x1a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0x50, 0x67, 0x40, 0x29, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x92, 0xca, 0x82, 0xd4, 0x62, 0xb0, 0x86, 0xe2, 0x20, 0x2e, 0xb0, 0xf9, 0x3e, 0x20, 0xe3, - 0xad, 0x04, 0x4f, 0x6d, 0xd1, 0xe5, 0x45, 0x71, 0x80, 0x93, 0xf3, 0x89, 0x47, 0x72, 0x8c, 0x17, - 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, - 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x69, 0xe2, 0xb5, 0xa2, 0x02, 0x12, 0x9e, 0x60, 0x9b, 0x92, 0xd8, - 0xc0, 0x5e, 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x86, 0xc3, 0x2e, 0x6b, 0x01, 0x00, - 0x00, + 0x85, 0x64, 0xb9, 0xb8, 0x12, 0x73, 0x72, 0xf2, 0xcb, 0xe3, 0x73, 0x32, 0x8b, 0x4b, 0x24, 0x98, + 0x14, 0x98, 0x35, 0x38, 0x83, 0x38, 0xc1, 0x22, 0x3e, 0x99, 0xc5, 0x25, 0x56, 0x82, 0xa7, 0xb6, + 0xe8, 0xf2, 0xa2, 0xb8, 0xcf, 0xc9, 0xf9, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, + 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, + 0xa2, 0x34, 0xf1, 0xba, 0xa0, 0x02, 0x12, 0xdc, 0x60, 0x87, 0x24, 0xb1, 0x81, 0x43, 0xc0, 0x18, + 0x10, 0x00, 0x00, 0xff, 0xff, 0xbd, 0x94, 0xb9, 0xfa, 0x8a, 0x01, 0x00, 0x00, } func (m *SendAuthorization) Marshal() (dAtA []byte, err error) { @@ -121,6 +134,15 @@ func (m *SendAuthorization) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.AllowList) > 0 { + for iNdEx := len(m.AllowList) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AllowList[iNdEx]) + copy(dAtA[i:], m.AllowList[iNdEx]) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.AllowList[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } if len(m.SpendLimit) > 0 { for iNdEx := len(m.SpendLimit) - 1; iNdEx >= 0; iNdEx-- { { @@ -161,6 +183,12 @@ func (m *SendAuthorization) Size() (n int) { n += 1 + l + sovAuthz(uint64(l)) } } + if len(m.AllowList) > 0 { + for _, s := range m.AllowList { + l = len(s) + n += 1 + l + sovAuthz(uint64(l)) + } + } return n } @@ -233,6 +261,38 @@ func (m *SendAuthorization) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AllowList", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAuthz + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AllowList = append(m.AllowList, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAuthz(dAtA[iNdEx:]) diff --git a/x/bank/types/balance_test.go b/x/bank/types/balance_test.go index 5219388b7c2e..a69cf48268bf 100644 --- a/x/bank/types/balance_test.go +++ b/x/bank/types/balance_test.go @@ -4,6 +4,7 @@ import ( "bytes" "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -49,7 +50,7 @@ func TestBalanceValidate(t *testing.T) { bank.Balance{ Address: "cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t", Coins: sdk.Coins{ - sdk.Coin{Denom: "", Amount: sdk.OneInt()}, + sdk.Coin{Denom: "", Amount: math.OneInt()}, }, }, true, diff --git a/x/bank/types/errors.go b/x/bank/types/errors.go index 3fca352de3f4..13af3dc4c7aa 100644 --- a/x/bank/types/errors.go +++ b/x/bank/types/errors.go @@ -12,5 +12,6 @@ var ( ErrSendDisabled = sdkerrors.Register(ModuleName, 5, "send transactions are disabled") ErrDenomMetadataNotFound = sdkerrors.Register(ModuleName, 6, "client denom metadata not found") ErrInvalidKey = sdkerrors.Register(ModuleName, 7, "invalid key") - ErrMultipleSenders = sdkerrors.Register(ModuleName, 8, "multiple senders not allowed") + ErrDuplicateEntry = sdkerrors.Register(ModuleName, 8, "duplicate entry") + ErrMultipleSenders = sdkerrors.Register(ModuleName, 9, "multiple senders not allowed") ) diff --git a/x/bank/types/genesis_test.go b/x/bank/types/genesis_test.go index fff454bc59d5..074825c325cb 100644 --- a/x/bank/types/genesis_test.go +++ b/x/bank/types/genesis_test.go @@ -3,6 +3,7 @@ package types import ( "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -137,7 +138,7 @@ func TestGenesisStateValidate(t *testing.T) { { "invalid supply", GenesisState{ - Supply: sdk.Coins{sdk.Coin{Denom: "", Amount: sdk.OneInt()}}, + Supply: sdk.Coins{sdk.Coin{Denom: "", Amount: math.OneInt()}}, }, true, }, diff --git a/x/bank/types/keys.go b/x/bank/types/keys.go index 7fd89ac2b457..86033a51f3ef 100644 --- a/x/bank/types/keys.go +++ b/x/bank/types/keys.go @@ -16,9 +16,6 @@ const ( // RouterKey defines the module's message routing key RouterKey = ModuleName - // QuerierRoute defines the module's query routing key - QuerierRoute = ModuleName - // ModuleQueryPath defines the ABCI query path of the module ModuleQueryPath = "store/bank/key" ) @@ -68,6 +65,12 @@ func AddressAndDenomFromBalancesStore(key []byte) (sdk.AccAddress, string, error return key[1 : addrBound+1], string(key[addrBound+1:]), nil } +// CreatePrefixedAccountStoreKey returns the key for the given account and denomination. +// This method can be used when performing an ABCI query for the balance of an account. +func CreatePrefixedAccountStoreKey(addr []byte, denom []byte) []byte { + return append(CreateAccountBalancesPrefix(addr), denom...) +} + // CreateAccountBalancesPrefix creates the prefix for an account's balances. func CreateAccountBalancesPrefix(addr []byte) []byte { return append(BalancesPrefix, address.MustLengthPrefix(addr)...) diff --git a/x/bank/types/params.go b/x/bank/types/params.go index d38dd8eae309..bd93bf85797c 100644 --- a/x/bank/types/params.go +++ b/x/bank/types/params.go @@ -52,6 +52,7 @@ func (se SendEnabled) Validate() error { } // validateSendEnabledParams is used by the x/params module to validate the params for the bank module. +//nolint:deadcode,unused func validateSendEnabledParams(i interface{}) error { params, ok := i.([]*SendEnabled) if !ok { @@ -86,6 +87,7 @@ func (se SendEnabled) String() string { } // validateSendEnabled is used by the x/params module to validate a single SendEnabled entry. +//nolint:unused func validateSendEnabled(i interface{}) error { param, ok := i.(SendEnabled) if !ok { diff --git a/x/bank/types/params_legacy.go b/x/bank/types/params_legacy.go index c6831e634b70..668358b4df7a 100644 --- a/x/bank/types/params_legacy.go +++ b/x/bank/types/params_legacy.go @@ -4,18 +4,18 @@ import paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" var ( // KeySendEnabled is store's key for SendEnabled Params - // DEPRECATED: Use the SendEnabled functionality in the keeper. + // Deprecated: Use the SendEnabled functionality in the keeper. KeySendEnabled = []byte("SendEnabled") // KeyDefaultSendEnabled is store's key for the DefaultSendEnabled option KeyDefaultSendEnabled = []byte("DefaultSendEnabled") ) -// DEPRECATED: ParamKeyTable for bank module. +// Deprecated: ParamKeyTable for bank module. func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -// DEPRECATED: ParamSetPairs implements params.ParamSet +// Deprecated: ParamSetPairs implements params.ParamSet func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyDefaultSendEnabled, &p.DefaultSendEnabled, validateIsBool), diff --git a/x/bank/types/params_test.go b/x/bank/types/params_test.go index cbc74f961107..4e48166e70a1 100644 --- a/x/bank/types/params_test.go +++ b/x/bank/types/params_test.go @@ -3,6 +3,7 @@ package types import ( "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -18,7 +19,7 @@ func Test_validateSendEnabledParam(t *testing.T) { args args wantErr bool }{ - {"invalid type", args{sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt())}, true}, + {"invalid type", args{sdk.NewCoin(sdk.DefaultBondDenom, math.OneInt())}, true}, {"invalid empty denom send enabled", args{*NewSendEnabled("", true)}, true}, {"invalid empty denom send disabled", args{*NewSendEnabled("", false)}, true}, diff --git a/x/bank/types/send_authorization.go b/x/bank/types/send_authorization.go index 7eb90b594918..91b37def1c55 100644 --- a/x/bank/types/send_authorization.go +++ b/x/bank/types/send_authorization.go @@ -6,13 +6,21 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" ) +// TODO: Revisit this once we have propoer gas fee framework. +// Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 +const gasCostPerIteration = uint64(10) + var _ authz.Authorization = &SendAuthorization{} // NewSendAuthorization creates a new SendAuthorization object. -func NewSendAuthorization(spendLimit sdk.Coins) *SendAuthorization { - return &SendAuthorization{ - SpendLimit: spendLimit, - } +func NewSendAuthorization(spendLimit sdk.Coins, allowed []sdk.AccAddress) *SendAuthorization { + allowedAddrs := toBech32Addresses(allowed) + + a := SendAuthorization{} + a.AllowList = allowedAddrs + a.SpendLimit = spendLimit + + return &a } // MsgTypeURL implements Authorization.MsgTypeURL. @@ -26,6 +34,7 @@ func (a SendAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRes if !ok { return authz.AcceptResponse{}, sdkerrors.ErrInvalidType.Wrap("type mismatch") } + toAddr := mSend.ToAddress limitLeft, isNegative := a.SpendLimit.SafeSub(mSend.Amount...) if isNegative { return authz.AcceptResponse{}, sdkerrors.ErrInsufficientFunds.Wrapf("requested amount is more than spend limit") @@ -34,7 +43,22 @@ func (a SendAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRes return authz.AcceptResponse{Accept: true, Delete: true}, nil } - return authz.AcceptResponse{Accept: true, Delete: false, Updated: &SendAuthorization{SpendLimit: limitLeft}}, nil + isAddrExists := false + allowedList := a.GetAllowList() + + for _, addr := range allowedList { + ctx.GasMeter().ConsumeGas(gasCostPerIteration, "send authorization") + if addr == toAddr { + isAddrExists = true + break + } + } + + if len(allowedList) > 0 && !isAddrExists { + return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf("cannot send to %s address", toAddr) + } + + return authz.AcceptResponse{Accept: true, Delete: false, Updated: &SendAuthorization{SpendLimit: limitLeft, AllowList: allowedList}}, nil } // ValidateBasic implements Authorization.ValidateBasic. @@ -45,5 +69,25 @@ func (a SendAuthorization) ValidateBasic() error { if !a.SpendLimit.IsAllPositive() { return sdkerrors.ErrInvalidCoins.Wrapf("spend limit must be positive") } + + found := make(map[string]bool, 0) + for i := 0; i < len(a.AllowList); i++ { + if found[a.AllowList[i]] { + return ErrDuplicateEntry + } + found[a.AllowList[i]] = true + } return nil } + +func toBech32Addresses(allowed []sdk.AccAddress) []string { + if len(allowed) == 0 { + return nil + } + + allowedAddrs := make([]string, len(allowed)) + for i, addr := range allowed { + allowedAddrs[i] = addr.String() + } + return allowedAddrs +} diff --git a/x/bank/types/send_authorization_test.go b/x/bank/types/send_authorization_test.go index 5e058317f1e9..3143c6a82a74 100644 --- a/x/bank/types/send_authorization_test.go +++ b/x/bank/types/send_authorization_test.go @@ -1,28 +1,31 @@ package types_test import ( + fmt "fmt" "testing" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/bank/types" ) var ( - coins1000 = sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))) - coins500 = sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(500))) - fromAddr = sdk.AccAddress("_____from _____") - toAddr = sdk.AccAddress("_______to________") + coins1000 = sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000))) + coins500 = sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(500))) + fromAddr = sdk.AccAddress("_____from _____") + toAddr = sdk.AccAddress("_______to________") + unknownAddr = sdk.AccAddress("_____unknown_____") ) func TestSendAuthorization(t *testing.T) { - app := simapp.Setup(t, false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - authorization := types.NewSendAuthorization(coins1000) - + ctx := testutil.DefaultContextWithDB(t, sdk.NewKVStoreKey(types.StoreKey), sdk.NewTransientStoreKey("transient_test")).Ctx.WithBlockHeader(tmproto.Header{}) + allowList := make([]sdk.AccAddress, 1) + allowList[0] = toAddr + authorization := types.NewSendAuthorization(coins1000, nil) + t.Log("verify authorization returns valid method name") require.Equal(t, authorization.MsgTypeURL(), "/cosmos.bank.v1beta1.MsgSend") require.NoError(t, authorization.ValidateBasic()) @@ -36,7 +39,7 @@ func TestSendAuthorization(t *testing.T) { require.True(t, resp.Delete) require.Nil(t, resp.Updated) - authorization = types.NewSendAuthorization(coins1000) + authorization = types.NewSendAuthorization(coins1000, nil) require.Equal(t, authorization.MsgTypeURL(), "/cosmos.bank.v1beta1.MsgSend") require.NoError(t, authorization.ValidateBasic()) send = types.NewMsgSend(fromAddr, toAddr, coins500) @@ -47,7 +50,7 @@ func TestSendAuthorization(t *testing.T) { require.NoError(t, err) require.False(t, resp.Delete) require.NotNil(t, resp.Updated) - sendAuth := types.NewSendAuthorization(coins500) + sendAuth := types.NewSendAuthorization(coins500, nil) require.Equal(t, sendAuth.String(), resp.Updated.String()) t.Log("expect updated authorization nil after spending remaining amount") @@ -55,4 +58,17 @@ func TestSendAuthorization(t *testing.T) { require.NoError(t, err) require.True(t, resp.Delete) require.Nil(t, resp.Updated) + + t.Log("allow list and no address") + authzWithAllowList := types.NewSendAuthorization(coins1000, allowList) + require.Equal(t, authzWithAllowList.MsgTypeURL(), "/cosmos.bank.v1beta1.MsgSend") + require.NoError(t, authorization.ValidateBasic()) + send = types.NewMsgSend(fromAddr, unknownAddr, coins500) + require.NoError(t, authzWithAllowList.ValidateBasic()) + resp, err = authzWithAllowList.Accept(ctx, send) + require.False(t, resp.Accept) + require.False(t, resp.Delete) + require.Nil(t, resp.Updated) + require.Error(t, err) + require.Contains(t, err.Error(), fmt.Sprintf("cannot send to %s address", unknownAddr)) } diff --git a/x/capability/module.go b/x/capability/module.go index 959df84dfc31..23ecad8e7cd3 100644 --- a/x/capability/module.go +++ b/x/capability/module.go @@ -108,17 +108,6 @@ func (am AppModule) Name() string { return am.AppModuleBasic.Name() } -// Deprecated: Route returns the capability module's message routing key. -func (AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the capability module's query routing key. -func (AppModule) QuerierRoute() string { return "" } - -// LegacyQuerierHandler returns the capability module's Querier. -func (am AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { return nil } - // RegisterServices registers a GRPC query service to respond to the // module-specific GRPC queries. func (am AppModule) RegisterServices(module.Configurator) {} diff --git a/x/capability/testutil/app.yaml b/x/capability/testutil/app.yaml deleted file mode 100644 index c0bf0b059a6d..000000000000 --- a/x/capability/testutil/app.yaml +++ /dev/null @@ -1,46 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: CapabilityApp - - begin_blockers: [capability, staking, auth, bank, genutil, params] - end_blockers: [staking, capability, auth, bank, genutil, params] - init_genesis: [capability, auth, bank, staking, genutil, params] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: capability - config: - "@type": cosmos.capability.module.v1.Module - seal_keeper: true diff --git a/x/capability/testutil/app_config.go b/x/capability/testutil/app_config.go index 85678ee39ec6..bdc3954b95ba 100644 --- a/x/capability/testutil/app_config.go +++ b/x/capability/testutil/app_config.go @@ -1,9 +1,6 @@ package testutil import ( - _ "embed" - - "cosmossdk.io/core/appconfig" _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" @@ -11,9 +8,94 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" -) -//go:embed app.yaml -var appConfig []byte + "cosmossdk.io/core/appconfig" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + capabilitymodulev1 "cosmossdk.io/api/cosmos/capability/module/v1" + genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" + stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1" +) -var AppConfig = appconfig.LoadYAML(appConfig) +var AppConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ + { + Name: "runtime", + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "CapabilityApp", + BeginBlockers: []string{ + capabilitytypes.ModuleName, + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + EndBlockers: []string{ + stakingtypes.ModuleName, + capabilitytypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + InitGenesis: []string{ + capabilitytypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + stakingtypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: "cosmos", + ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{ + {Account: authtypes.FeeCollectorName}, + {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + }, + }), + }, + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: stakingtypes.ModuleName, + Config: appconfig.WrapAny(&stakingmodulev1.Module{}), + }, + { + Name: paramstypes.ModuleName, + Config: appconfig.WrapAny(¶msmodulev1.Module{}), + }, + { + Name: "tx", + Config: appconfig.WrapAny(&txmodulev1.Module{}), + }, + { + Name: genutiltypes.ModuleName, + Config: appconfig.WrapAny(&genutilmodulev1.Module{}), + }, + { + Name: capabilitytypes.ModuleName, + Config: appconfig.WrapAny(&capabilitymodulev1.Module{ + SealKeeper: true, + }), + }, + }, +}) diff --git a/x/crisis/module.go b/x/crisis/module.go index 0bf0e49bbcf0..0a0c2fe55824 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -132,17 +132,6 @@ func (AppModule) Name() string { // RegisterInvariants performs a no-op. func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the crisis module. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns no querier route. -func (AppModule) QuerierRoute() string { return "" } - -// LegacyQuerierHandler returns no sdk.Querier. -func (AppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Querier { return nil } - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), am.keeper) diff --git a/x/distribution/client/common/common.go b/x/distribution/client/common/common.go index a2d5fceda0bb..b8b363aea071 100644 --- a/x/distribution/client/common/common.go +++ b/x/distribution/client/common/common.go @@ -27,70 +27,6 @@ func QueryDelegationRewards(clientCtx client.Context, delAddr, valAddr string) ( return nil, 0, fmt.Errorf("failed to marshal params: %w", err) } - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryDelegationRewards) + route := fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QueryDelegationRewards) return clientCtx.QueryWithData(route, bz) } - -// QueryDelegatorValidators returns delegator's list of validators -// it submitted delegations to. -func QueryDelegatorValidators(clientCtx client.Context, delegatorAddr sdk.AccAddress) ([]byte, error) { - res, _, err := clientCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryDelegatorValidators), - clientCtx.LegacyAmino.MustMarshalJSON(types.NewQueryDelegatorParams(delegatorAddr)), - ) - return res, err -} - -// QueryValidatorCommission returns a validator's commission. -func QueryValidatorCommission(clientCtx client.Context, validatorAddr sdk.ValAddress) ([]byte, error) { - res, _, err := clientCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryValidatorCommission), - clientCtx.LegacyAmino.MustMarshalJSON(types.NewQueryValidatorCommissionParams(validatorAddr)), - ) - return res, err -} - -// WithdrawAllDelegatorRewards builds a multi-message slice to be used -// to withdraw all delegations rewards for the given delegator. -func WithdrawAllDelegatorRewards(clientCtx client.Context, delegatorAddr sdk.AccAddress) ([]sdk.Msg, error) { - // retrieve the comprehensive list of all validators which the - // delegator had submitted delegations to - bz, err := QueryDelegatorValidators(clientCtx, delegatorAddr) - if err != nil { - return nil, err - } - - var validators []sdk.ValAddress - if err := clientCtx.LegacyAmino.UnmarshalJSON(bz, &validators); err != nil { - return nil, err - } - - // build multi-message transaction - msgs := make([]sdk.Msg, 0, len(validators)) - for _, valAddr := range validators { - msg := types.NewMsgWithdrawDelegatorReward(delegatorAddr, valAddr) - if err := msg.ValidateBasic(); err != nil { - return nil, err - } - msgs = append(msgs, msg) - } - - return msgs, nil -} - -// WithdrawValidatorRewardsAndCommission builds a two-message message slice to be -// used to withdraw both validation's commission and self-delegation reward. -func WithdrawValidatorRewardsAndCommission(validatorAddr sdk.ValAddress) ([]sdk.Msg, error) { - commissionMsg := types.NewMsgWithdrawValidatorCommission(validatorAddr) - if err := commissionMsg.ValidateBasic(); err != nil { - return nil, err - } - - // build and validate MsgWithdrawDelegatorReward - rewardMsg := types.NewMsgWithdrawDelegatorReward(sdk.AccAddress(validatorAddr.Bytes()), validatorAddr) - if err := rewardMsg.ValidateBasic(); err != nil { - return nil, err - } - - return []sdk.Msg{commissionMsg, rewardMsg}, nil -} diff --git a/x/distribution/client/testutil/cli_test.go b/x/distribution/client/testutil/cli_test.go deleted file mode 100644 index d7ab22d41524..000000000000 --- a/x/distribution/client/testutil/cli_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package testutil - -import ( - "testing" - - "github.com/stretchr/testify/suite" -) - -func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) -} - -func TestGRPCQueryTestSuite(t *testing.T) { - suite.Run(t, new(GRPCQueryTestSuite)) -} - -func TestWithdrawAllSuite(t *testing.T) { - suite.Run(t, new(WithdrawAllTestSuite)) -} diff --git a/x/distribution/client/testutil/suite.go b/x/distribution/client/testutil/suite.go index 063b19e1729e..dac9c3a6dc73 100644 --- a/x/distribution/client/testutil/suite.go +++ b/x/distribution/client/testutil/suite.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "cosmossdk.io/math" "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" tmcli "github.com/tendermint/tendermint/libs/cli" @@ -540,14 +541,14 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { // can't use unpackAny as response types are not registered. err = s.cfg.Codec.Unmarshal(msgResponse.Value, &resp) s.Require().NoError(err) - s.Require().True(resp.Amount.IsAllGT(sdk.NewCoins(sdk.NewCoin("stake", sdk.OneInt()))), + s.Require().True(resp.Amount.IsAllGT(sdk.NewCoins(sdk.NewCoin("stake", math.OneInt()))), fmt.Sprintf("expected a positive coin value, got %v", resp.Amount)) case "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse": var resp distrtypes.MsgWithdrawValidatorCommissionResponse // can't use unpackAny as response types are not registered. err = s.cfg.Codec.Unmarshal(msgResponse.Value, &resp) s.Require().NoError(err) - s.Require().True(resp.Amount.IsAllGT(sdk.NewCoins(sdk.NewCoin("stake", sdk.OneInt()))), + s.Require().True(resp.Amount.IsAllGT(sdk.NewCoins(sdk.NewCoin("stake", math.OneInt()))), fmt.Sprintf("expected a positive coin value, got %v", resp.Amount)) } } @@ -626,14 +627,14 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { // can't use unpackAny as response types are not registered. err = s.cfg.Codec.Unmarshal(msgResponse.Value, &resp) s.Require().NoError(err) - s.Require().True(resp.Amount.IsAllGT(sdk.NewCoins(sdk.NewCoin("stake", sdk.OneInt()))), + s.Require().True(resp.Amount.IsAllGT(sdk.NewCoins(sdk.NewCoin("stake", math.OneInt()))), fmt.Sprintf("expected a positive coin value, got %v", resp.Amount)) case "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse": var resp distrtypes.MsgWithdrawValidatorCommissionResponse // can't use unpackAny as response types are not registered. err = s.cfg.Codec.Unmarshal(msgResponse.Value, &resp) s.Require().NoError(err) - s.Require().True(resp.Amount.IsAllGT(sdk.NewCoins(sdk.NewCoin("stake", sdk.OneInt()))), + s.Require().True(resp.Amount.IsAllGT(sdk.NewCoins(sdk.NewCoin("stake", math.OneInt()))), fmt.Sprintf("expected a positive coin value, got %v", resp.Amount)) } } diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 861b7f023e06..e426d1aaddfe 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -807,7 +808,7 @@ func Test100PercentCommissionReward(t *testing.T) { zeroRewards := sdk.Coins{ sdk.Coin{ Denom: denom, - Amount: sdk.ZeroInt(), + Amount: math.ZeroInt(), }, } require.True(t, rewards.IsEqual(zeroRewards)) diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index 453199037492..31de65efa37f 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + "cosmossdk.io/math" "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -101,7 +102,7 @@ func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddres baseDenom, _ := sdk.GetBaseDenom() rewards = sdk.Coins{sdk.Coin{ Denom: baseDenom, - Amount: sdk.ZeroInt(), + Amount: math.ZeroInt(), }} } diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index 7786928a43a7..ad3d101471c1 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -169,7 +170,7 @@ func TestFundCommunityPool(t *testing.T) { // reset fee pool distrKeeper.SetFeePool(ctx, types.InitialFeePool()) - addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, sdk.ZeroInt()) + addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 2, math.ZeroInt()) amount := sdk.NewCoins(sdk.NewInt64Coin("stake", 100)) require.NoError(t, banktestutil.FundAccount(bankKeeper, ctx, addr[0], amount)) diff --git a/x/distribution/keeper/querier.go b/x/distribution/keeper/querier.go deleted file mode 100644 index 71370e24ba51..000000000000 --- a/x/distribution/keeper/querier.go +++ /dev/null @@ -1,256 +0,0 @@ -package keeper - -import ( - "encoding/json" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/distribution/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -) - -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryParams: - return queryParams(ctx, path[1:], req, k, legacyQuerierCdc) - - case types.QueryValidatorOutstandingRewards: - return queryValidatorOutstandingRewards(ctx, path[1:], req, k, legacyQuerierCdc) - - case types.QueryValidatorCommission: - return queryValidatorCommission(ctx, path[1:], req, k, legacyQuerierCdc) - - case types.QueryValidatorSlashes: - return queryValidatorSlashes(ctx, path[1:], req, k, legacyQuerierCdc) - - case types.QueryDelegationRewards: - return queryDelegationRewards(ctx, path[1:], req, k, legacyQuerierCdc) - - case types.QueryDelegatorTotalRewards: - return queryDelegatorTotalRewards(ctx, path[1:], req, k, legacyQuerierCdc) - - case types.QueryDelegatorValidators: - return queryDelegatorValidators(ctx, path[1:], req, k, legacyQuerierCdc) - - case types.QueryWithdrawAddr: - return queryDelegatorWithdrawAddress(ctx, path[1:], req, k, legacyQuerierCdc) - - case types.QueryCommunityPool: - return queryCommunityPool(ctx, path[1:], req, k, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -func queryParams(ctx sdk.Context, _ []string, _ abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - params := k.GetParams(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryValidatorOutstandingRewards(ctx sdk.Context, _ []string, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryValidatorOutstandingRewardsParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - rewards := k.GetValidatorOutstandingRewards(ctx, params.ValidatorAddress) - if rewards.GetRewards() == nil { - rewards.Rewards = sdk.DecCoins{} - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, rewards) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryValidatorCommission(ctx sdk.Context, _ []string, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryValidatorCommissionParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - commission := k.GetValidatorAccumulatedCommission(ctx, params.ValidatorAddress) - if commission.Commission == nil { - commission.Commission = sdk.DecCoins{} - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, commission) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryValidatorSlashes(ctx sdk.Context, _ []string, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryValidatorSlashesParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - events := make([]types.ValidatorSlashEvent, 0) - k.IterateValidatorSlashEventsBetween(ctx, params.ValidatorAddress, params.StartingHeight, params.EndingHeight, - func(height uint64, event types.ValidatorSlashEvent) (stop bool) { - events = append(events, event) - return false - }, - ) - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, events) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryDelegationRewards(ctx sdk.Context, _ []string, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegationRewardsParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - // branch the context to isolate state changes - ctx, _ = ctx.CacheContext() - - val := k.stakingKeeper.Validator(ctx, params.ValidatorAddress) - if val == nil { - return nil, sdkerrors.Wrap(types.ErrNoValidatorExists, params.ValidatorAddress.String()) - } - - del := k.stakingKeeper.Delegation(ctx, params.DelegatorAddress, params.ValidatorAddress) - if del == nil { - return nil, types.ErrNoDelegationExists - } - - endingPeriod := k.IncrementValidatorPeriod(ctx, val) - rewards := k.CalculateDelegationRewards(ctx, val, del, endingPeriod) - if rewards == nil { - rewards = sdk.DecCoins{} - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, rewards) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryDelegatorTotalRewards(ctx sdk.Context, _ []string, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegatorParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - // branch the context to isolate state changes - ctx, _ = ctx.CacheContext() - - total := sdk.DecCoins{} - - var delRewards []types.DelegationDelegatorReward - - k.stakingKeeper.IterateDelegations( - ctx, params.DelegatorAddress, - func(_ int64, del stakingtypes.DelegationI) (stop bool) { - valAddr := del.GetValidatorAddr() - val := k.stakingKeeper.Validator(ctx, valAddr) - endingPeriod := k.IncrementValidatorPeriod(ctx, val) - delReward := k.CalculateDelegationRewards(ctx, val, del, endingPeriod) - - delRewards = append(delRewards, types.NewDelegationDelegatorReward(valAddr, delReward)) - total = total.Add(delReward...) - return false - }, - ) - - totalRewards := types.NewQueryDelegatorTotalRewardsResponse(delRewards, total) - - bz, err := json.Marshal(totalRewards) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryDelegatorValidators(ctx sdk.Context, _ []string, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegatorParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - // branch the context to isolate state changes - ctx, _ = ctx.CacheContext() - - var validators []sdk.ValAddress - - k.stakingKeeper.IterateDelegations( - ctx, params.DelegatorAddress, - func(_ int64, del stakingtypes.DelegationI) (stop bool) { - validators = append(validators, del.GetValidatorAddr()) - return false - }, - ) - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, validators) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryDelegatorWithdrawAddress(ctx sdk.Context, _ []string, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegatorWithdrawAddrParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - // branch the context to isolate state changes - ctx, _ = ctx.CacheContext() - withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, params.DelegatorAddress) - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, withdrawAddr) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryCommunityPool(ctx sdk.Context, _ []string, _ abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - pool := k.GetFeePoolCommunityCoins(ctx) - if pool == nil { - pool = sdk.DecCoins{} - } - - bz, err := legacyQuerierCdc.MarshalJSON(pool) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} diff --git a/x/distribution/keeper/querier_test.go b/x/distribution/keeper/querier_test.go deleted file mode 100644 index cc739bd6cf95..000000000000 --- a/x/distribution/keeper/querier_test.go +++ /dev/null @@ -1,218 +0,0 @@ -package keeper_test - -import ( - "strings" - "testing" - - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/codec" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - "github.com/cosmos/cosmos-sdk/x/distribution/keeper" - "github.com/cosmos/cosmos-sdk/x/distribution/testutil" - "github.com/cosmos/cosmos-sdk/x/distribution/types" - "github.com/cosmos/cosmos-sdk/x/staking" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - "github.com/cosmos/cosmos-sdk/x/staking/teststaking" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -) - -const custom = "custom" - -func getQueriedParams(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier) types.Params { - var params types.Params - - bz, err := querier(ctx, []string{types.QueryParams}, abci.RequestQuery{}) - require.Nil(t, err) - require.Nil(t, cdc.UnmarshalJSON(bz, ¶ms)) - - return params -} - -func getQueriedValidatorOutstandingRewards(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, validatorAddr sdk.ValAddress) sdk.DecCoins { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryValidatorOutstandingRewards}, "/"), - Data: cdc.MustMarshalJSON(types.NewQueryValidatorOutstandingRewardsParams(validatorAddr)), - } - - bz, err := querier(ctx, []string{types.QueryValidatorOutstandingRewards}, query) - require.Nil(t, err) - outstandingRewards := types.ValidatorOutstandingRewards{} - require.Nil(t, cdc.UnmarshalJSON(bz, &outstandingRewards)) - - return outstandingRewards.GetRewards() -} - -func getQueriedValidatorCommission(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, validatorAddr sdk.ValAddress) sdk.DecCoins { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryValidatorCommission}, "/"), - Data: cdc.MustMarshalJSON(types.NewQueryValidatorCommissionParams(validatorAddr)), - } - - bz, err := querier(ctx, []string{types.QueryValidatorCommission}, query) - require.Nil(t, err) - validatorCommission := types.ValidatorAccumulatedCommission{} - require.Nil(t, cdc.UnmarshalJSON(bz, &validatorCommission)) - - return validatorCommission.GetCommission() -} - -func getQueriedValidatorSlashes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, validatorAddr sdk.ValAddress, startHeight uint64, endHeight uint64) (slashes []types.ValidatorSlashEvent) { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryValidatorSlashes}, "/"), - Data: cdc.MustMarshalJSON(types.NewQueryValidatorSlashesParams(validatorAddr, startHeight, endHeight)), - } - - bz, err := querier(ctx, []string{types.QueryValidatorSlashes}, query) - require.Nil(t, err) - require.Nil(t, cdc.UnmarshalJSON(bz, &slashes)) - - return -} - -func getQueriedDelegationRewards(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) (rewards sdk.DecCoins) { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryDelegationRewards}, "/"), - Data: cdc.MustMarshalJSON(types.NewQueryDelegationRewardsParams(delegatorAddr, validatorAddr)), - } - - bz, err := querier(ctx, []string{types.QueryDelegationRewards}, query) - require.Nil(t, err) - require.Nil(t, cdc.UnmarshalJSON(bz, &rewards)) - - return -} - -func getQueriedDelegatorTotalRewards(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, delegatorAddr sdk.AccAddress) (response types.QueryDelegatorTotalRewardsResponse) { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryDelegatorTotalRewards}, "/"), - Data: cdc.MustMarshalJSON(types.NewQueryDelegatorParams(delegatorAddr)), - } - - bz, err := querier(ctx, []string{types.QueryDelegatorTotalRewards}, query) - require.Nil(t, err) - require.Nil(t, cdc.UnmarshalJSON(bz, &response)) - - return -} - -func getQueriedCommunityPool(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier) (ptr []byte) { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryCommunityPool}, ""), - Data: []byte{}, - } - - cp, err := querier(ctx, []string{types.QueryCommunityPool}, query) - require.Nil(t, err) - require.Nil(t, cdc.UnmarshalJSON(cp, &ptr)) - - return -} - -func TestQueries(t *testing.T) { - var ( - bankKeeper bankkeeper.Keeper - distrKeeper keeper.Keeper - stakingKeeper *stakingkeeper.Keeper - ) - - app, err := simtestutil.Setup(testutil.AppConfig, - &bankKeeper, - &distrKeeper, - &stakingKeeper, - ) - require.NoError(t, err) - - cdc := codec.NewLegacyAmino() - types.RegisterLegacyAminoCodec(cdc) - banktypes.RegisterLegacyAminoCodec(cdc) - - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - - // reset fee pool - distrKeeper.SetFeePool(ctx, types.InitialFeePool()) - - addr := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 1, sdk.NewInt(1000000000)) - valAddrs := simtestutil.ConvertAddrsToValAddrs(addr) - valOpAddr1 := valAddrs[0] - - querier := keeper.NewQuerier(distrKeeper, cdc) - - // test param queries - params := types.Params{ - CommunityTax: sdk.NewDecWithPrec(3, 1), - BaseProposerReward: sdk.NewDecWithPrec(2, 1), - BonusProposerReward: sdk.NewDecWithPrec(1, 1), - WithdrawAddrEnabled: true, - } - - require.NoError(t, distrKeeper.SetParams(ctx, params)) - - paramsRes := getQueriedParams(t, ctx, cdc, querier) - require.Equal(t, params.CommunityTax, paramsRes.CommunityTax) - require.Equal(t, params.BaseProposerReward, paramsRes.BaseProposerReward) - require.Equal(t, params.BonusProposerReward, paramsRes.BonusProposerReward) - require.Equal(t, params.WithdrawAddrEnabled, paramsRes.WithdrawAddrEnabled) - - // test outstanding rewards query - outstandingRewards := sdk.DecCoins{{Denom: "mytoken", Amount: sdk.NewDec(3)}, {Denom: "myothertoken", Amount: sdk.NewDecWithPrec(3, 7)}} - distrKeeper.SetValidatorOutstandingRewards(ctx, valOpAddr1, types.ValidatorOutstandingRewards{Rewards: outstandingRewards}) - retOutstandingRewards := getQueriedValidatorOutstandingRewards(t, ctx, cdc, querier, valOpAddr1) - require.Equal(t, outstandingRewards, retOutstandingRewards) - - // test validator commission query - commission := sdk.DecCoins{{Denom: "token1", Amount: sdk.NewDec(4)}, {Denom: "token2", Amount: sdk.NewDec(2)}} - distrKeeper.SetValidatorAccumulatedCommission(ctx, valOpAddr1, types.ValidatorAccumulatedCommission{Commission: commission}) - retCommission := getQueriedValidatorCommission(t, ctx, cdc, querier, valOpAddr1) - require.Equal(t, commission, retCommission) - - // test delegator's total rewards query - delRewards := getQueriedDelegatorTotalRewards(t, ctx, cdc, querier, sdk.AccAddress(valOpAddr1)) - require.Equal(t, types.QueryDelegatorTotalRewardsResponse{}, delRewards) - - // test validator slashes query with height range - slashOne := types.NewValidatorSlashEvent(3, sdk.NewDecWithPrec(5, 1)) - slashTwo := types.NewValidatorSlashEvent(7, sdk.NewDecWithPrec(6, 1)) - distrKeeper.SetValidatorSlashEvent(ctx, valOpAddr1, 3, 0, slashOne) - distrKeeper.SetValidatorSlashEvent(ctx, valOpAddr1, 7, 0, slashTwo) - slashes := getQueriedValidatorSlashes(t, ctx, cdc, querier, valOpAddr1, 0, 2) - require.Equal(t, 0, len(slashes)) - slashes = getQueriedValidatorSlashes(t, ctx, cdc, querier, valOpAddr1, 0, 5) - require.Equal(t, []types.ValidatorSlashEvent{slashOne}, slashes) - slashes = getQueriedValidatorSlashes(t, ctx, cdc, querier, valOpAddr1, 0, 10) - require.Equal(t, []types.ValidatorSlashEvent{slashOne, slashTwo}, slashes) - - // test delegation rewards query - tstaking := teststaking.NewHelper(t, ctx, stakingKeeper) - tstaking.Commission = stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0)) - tstaking.CreateValidator(valOpAddr1, valConsPk1, sdk.NewInt(100), true) - - staking.EndBlocker(ctx, stakingKeeper) - - val := stakingKeeper.Validator(ctx, valOpAddr1) - rewards := getQueriedDelegationRewards(t, ctx, cdc, querier, sdk.AccAddress(valOpAddr1), valOpAddr1) - require.True(t, rewards.IsZero()) - initial := int64(10) - ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) - tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial)}} - distrKeeper.AllocateTokensToValidator(ctx, val, tokens) - rewards = getQueriedDelegationRewards(t, ctx, cdc, querier, sdk.AccAddress(valOpAddr1), valOpAddr1) - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, rewards) - - // test delegator's total rewards query - delRewards = getQueriedDelegatorTotalRewards(t, ctx, cdc, querier, sdk.AccAddress(valOpAddr1)) - expectedDelReward := types.NewDelegationDelegatorReward(valOpAddr1, - sdk.DecCoins{sdk.NewInt64DecCoin("stake", 5)}) - wantDelRewards := types.NewQueryDelegatorTotalRewardsResponse( - []types.DelegationDelegatorReward{expectedDelReward}, expectedDelReward.Reward) - require.Equal(t, wantDelRewards, delRewards) - - // currently community pool hold nothing so we should return null - communityPool := getQueriedCommunityPool(t, ctx, cdc, querier) - require.Nil(t, communityPool) -} diff --git a/x/distribution/module.go b/x/distribution/module.go index 5b5eb0ac02e7..26372bd876c2 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -132,21 +132,6 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) } -// Deprecated: Route returns the message routing key for the distribution module. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the distribution module's querier route name. -func (AppModule) QuerierRoute() string { - return types.QuerierRoute -} - -// LegacyQuerierHandler returns the distribution module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) diff --git a/x/distribution/testutil/app.yaml b/x/distribution/testutil/app.yaml deleted file mode 100644 index 8d12b1783528..000000000000 --- a/x/distribution/testutil/app.yaml +++ /dev/null @@ -1,52 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: DistrApp - - begin_blockers: [mint, distribution, staking, auth, bank, genutil, params] - end_blockers: [staking, auth, bank, distribution, mint, genutil, params] - init_genesis: [auth, bank, distribution, staking, mint, genutil, params] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: distribution - - account: mint - permissions: [minter] - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: mint - config: - "@type": cosmos.mint.module.v1.Module - - - name: distribution - config: - "@type": cosmos.distribution.module.v1.Module diff --git a/x/distribution/testutil/app_config.go b/x/distribution/testutil/app_config.go index c3d70daa5dbc..67aff35b9b28 100644 --- a/x/distribution/testutil/app_config.go +++ b/x/distribution/testutil/app_config.go @@ -1,9 +1,6 @@ package testutil import ( - _ "embed" - - "cosmossdk.io/core/appconfig" _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" @@ -12,9 +9,103 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/mint" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" -) -//go:embed app.yaml -var appConfig []byte + "cosmossdk.io/core/appconfig" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" + genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" + paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" + stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1" +) -var AppConfig = appconfig.LoadYAML(appConfig) +var AppConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ + { + Name: "runtime", + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "DistrApp", + BeginBlockers: []string{ + minttypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + EndBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + minttypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + InitGenesis: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + minttypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: "cosmos", + ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{ + {Account: authtypes.FeeCollectorName}, + {Account: distrtypes.ModuleName}, + {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, + {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + }, + }), + }, + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: stakingtypes.ModuleName, + Config: appconfig.WrapAny(&stakingmodulev1.Module{}), + }, + { + Name: paramstypes.ModuleName, + Config: appconfig.WrapAny(¶msmodulev1.Module{}), + }, + { + Name: "tx", + Config: appconfig.WrapAny(&txmodulev1.Module{}), + }, + { + Name: genutiltypes.ModuleName, + Config: appconfig.WrapAny(&genutilmodulev1.Module{}), + }, + { + Name: distrtypes.ModuleName, + Config: appconfig.WrapAny(&distrmodulev1.Module{}), + }, + { + Name: minttypes.ModuleName, + Config: appconfig.WrapAny(&mintmodulev1.Module{}), + }, + }, +}) diff --git a/x/distribution/types/keys.go b/x/distribution/types/keys.go index e5e182f5ac8c..07fb3d6e2801 100644 --- a/x/distribution/types/keys.go +++ b/x/distribution/types/keys.go @@ -17,9 +17,6 @@ const ( // RouterKey is the message route for distribution RouterKey = ModuleName - - // QuerierRoute is the querier route for distribution - QuerierRoute = ModuleName ) // Keys for distribution store diff --git a/x/evidence/client/testutil/cli_test.go b/x/evidence/client/testutil/cli_test.go deleted file mode 100644 index 8d2b0278301d..000000000000 --- a/x/evidence/client/testutil/cli_test.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/x/evidence/testutil" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig) - require.NoError(t, err) - cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index a05bdbf66d03..aac0825a280b 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -10,7 +10,6 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -95,12 +94,10 @@ type KeeperTestSuite struct { func (suite *KeeperTestSuite) SetupTest() { var ( - legacyAmino *codec.LegacyAmino evidenceKeeper keeper.Keeper ) app, err := simtestutil.Setup(testutil.AppConfig, - &legacyAmino, &evidenceKeeper, &suite.interfaceRegistry, &suite.accountKeeper, @@ -115,7 +112,6 @@ func (suite *KeeperTestSuite) SetupTest() { evidenceKeeper.SetRouter(router) suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1}) - suite.querier = keeper.NewQuerier(evidenceKeeper, legacyAmino) suite.app = app for i, addr := range valAddresses { diff --git a/x/evidence/keeper/querier.go b/x/evidence/keeper/querier.go deleted file mode 100644 index c1ae20d4d9c1..000000000000 --- a/x/evidence/keeper/querier.go +++ /dev/null @@ -1,80 +0,0 @@ -package keeper - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/evidence/exported" - "github.com/cosmos/cosmos-sdk/x/evidence/types" - - abci "github.com/tendermint/tendermint/abci/types" -) - -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - var ( - res []byte - err error - ) - - switch path[0] { - case types.QueryEvidence: - res, err = queryEvidence(ctx, req, k, legacyQuerierCdc) - - case types.QueryAllEvidence: - res, err = queryAllEvidence(ctx, req, k, legacyQuerierCdc) - - default: - err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0]) - } - - return res, err - } -} - -func queryEvidence(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryEvidenceRequest - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - evidence, ok := k.GetEvidence(ctx, params.EvidenceHash) - if !ok { - return nil, sdkerrors.Wrap(types.ErrNoEvidenceExists, params.EvidenceHash.String()) - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, evidence) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryAllEvidence(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryAllEvidenceParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - evidence := k.GetAllEvidence(ctx) - - start, end := client.Paginate(len(evidence), params.Page, params.Limit, 100) - if start < 0 || end < 0 { - evidence = []exported.Evidence{} - } else { - evidence = evidence[start:end] - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, evidence) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} diff --git a/x/evidence/keeper/querier_test.go b/x/evidence/keeper/querier_test.go deleted file mode 100644 index e15412ba2b0e..000000000000 --- a/x/evidence/keeper/querier_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package keeper_test - -import ( - "strings" - - "cosmossdk.io/depinject" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/x/evidence/exported" - "github.com/cosmos/cosmos-sdk/x/evidence/testutil" - "github.com/cosmos/cosmos-sdk/x/evidence/types" - - abci "github.com/tendermint/tendermint/abci/types" -) - -const ( - custom = "custom" -) - -func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_Existing() { - ctx := suite.ctx.WithIsCheckTx(false) - numEvidence := 100 - - var legacyAmino *codec.LegacyAmino - err := depinject.Inject(testutil.AppConfig, &legacyAmino) - require.NoError(suite.T(), err) - - evidence := suite.populateEvidence(ctx, numEvidence) - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryEvidence}, "/"), - Data: legacyAmino.MustMarshalJSON(types.NewQueryEvidenceRequest(evidence[0].Hash())), - } - - bz, err := suite.querier(ctx, []string{types.QueryEvidence}, query) - suite.Nil(err) - suite.NotNil(bz) - - var e exported.Evidence - suite.Nil(legacyAmino.UnmarshalJSON(bz, &e)) - suite.Equal(evidence[0], e) -} - -func (suite *KeeperTestSuite) TestQuerier_QueryEvidence_NonExisting() { - ctx := suite.ctx.WithIsCheckTx(false) - numEvidence := 100 - - var cdc codec.Codec - err := depinject.Inject(testutil.AppConfig, &cdc) - require.NoError(suite.T(), err) - - suite.populateEvidence(ctx, numEvidence) - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryEvidence}, "/"), - Data: cdc.MustMarshalJSON(types.NewQueryEvidenceRequest([]byte("0000000000000000000000000000000000000000000000000000000000000000"))), - } - - bz, err := suite.querier(ctx, []string{types.QueryEvidence}, query) - suite.NotNil(err) - suite.Nil(bz) -} - -func (suite *KeeperTestSuite) TestQuerier_QueryAllEvidence() { - ctx := suite.ctx.WithIsCheckTx(false) - numEvidence := 100 - - var legacyAmino *codec.LegacyAmino - err := depinject.Inject(testutil.AppConfig, &legacyAmino) - require.NoError(suite.T(), err) - - suite.populateEvidence(ctx, numEvidence) - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryAllEvidence}, "/"), - Data: legacyAmino.MustMarshalJSON(types.NewQueryAllEvidenceParams(1, numEvidence)), - } - - bz, err := suite.querier(ctx, []string{types.QueryAllEvidence}, query) - suite.Nil(err) - suite.NotNil(bz) - - var e []exported.Evidence - suite.Nil(legacyAmino.UnmarshalJSON(bz, &e)) - suite.Len(e, numEvidence) -} - -func (suite *KeeperTestSuite) TestQuerier_QueryAllEvidence_InvalidPagination() { - ctx := suite.ctx.WithIsCheckTx(false) - numEvidence := 100 - - var legacyAmino *codec.LegacyAmino - err := depinject.Inject(testutil.AppConfig, &legacyAmino) - require.NoError(suite.T(), err) - - suite.populateEvidence(ctx, numEvidence) - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryAllEvidence}, "/"), - Data: legacyAmino.MustMarshalJSON(types.NewQueryAllEvidenceParams(0, numEvidence)), - } - - bz, err := suite.querier(ctx, []string{types.QueryAllEvidence}, query) - suite.Nil(err) - suite.NotNil(bz) - - var e []exported.Evidence - suite.Nil(legacyAmino.UnmarshalJSON(bz, &e)) - suite.Len(e, 0) -} diff --git a/x/evidence/module.go b/x/evidence/module.go index 009807e88166..03c9135a5000 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -126,21 +126,6 @@ func (am AppModule) Name() string { return am.AppModuleBasic.Name() } -// Deprecated: Route returns the evidence module's message routing key. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the evidence module's query routing key. -func (AppModule) QuerierRoute() string { - return types.QuerierRoute -} - -// LegacyQuerierHandler returns the evidence module's Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) diff --git a/x/evidence/testutil/app.yaml b/x/evidence/testutil/app.yaml deleted file mode 100644 index ef2f13a96858..000000000000 --- a/x/evidence/testutil/app.yaml +++ /dev/null @@ -1,52 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: EvidenceApp - - begin_blockers: [slashing, evidence, staking, auth, bank, genutil, params] - end_blockers: [staking, auth, bank, slashing, genutil, evidence, params] - init_genesis: [auth, bank, staking, slashing, genutil, evidence, params] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: mint - permissions: [minter] - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - account: nft - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: slashing - config: - "@type": cosmos.slashing.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: evidence - config: - "@type": cosmos.evidence.module.v1.Module diff --git a/x/evidence/testutil/app_config.go b/x/evidence/testutil/app_config.go index 4347a4ac9f0e..5c14e66a197f 100644 --- a/x/evidence/testutil/app_config.go +++ b/x/evidence/testutil/app_config.go @@ -1,9 +1,6 @@ package testutil import ( - _ "embed" - - "cosmossdk.io/core/appconfig" _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" @@ -12,9 +9,103 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/slashing" _ "github.com/cosmos/cosmos-sdk/x/staking" -) -//go:embed app.yaml -var appConfig []byte + "cosmossdk.io/core/appconfig" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + evidencemodulev1 "cosmossdk.io/api/cosmos/evidence/module/v1" + genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" + slashingmodulev1 "cosmossdk.io/api/cosmos/slashing/module/v1" + stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1" +) -var AppConfig = appconfig.LoadYAML(appConfig) +var AppConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ + { + Name: "runtime", + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "EvidenceApp", + BeginBlockers: []string{ + slashingtypes.ModuleName, + evidencetypes.ModuleName, + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + EndBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + slashingtypes.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + paramstypes.ModuleName, + }, + InitGenesis: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + stakingtypes.ModuleName, + slashingtypes.ModuleName, + genutiltypes.ModuleName, + evidencetypes.ModuleName, + paramstypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: "cosmos", + ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{ + {Account: authtypes.FeeCollectorName}, + {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, + {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + }, + }), + }, + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: stakingtypes.ModuleName, + Config: appconfig.WrapAny(&stakingmodulev1.Module{}), + }, + { + Name: slashingtypes.ModuleName, + Config: appconfig.WrapAny(&slashingmodulev1.Module{}), + }, + { + Name: paramstypes.ModuleName, + Config: appconfig.WrapAny(¶msmodulev1.Module{}), + }, + { + Name: "tx", + Config: appconfig.WrapAny(&txmodulev1.Module{}), + }, + { + Name: genutiltypes.ModuleName, + Config: appconfig.WrapAny(&genutilmodulev1.Module{}), + }, + { + Name: evidencetypes.ModuleName, + Config: appconfig.WrapAny(&evidencemodulev1.Module{}), + }, + }, +}) diff --git a/x/evidence/types/keys.go b/x/evidence/types/keys.go index 775fa2c021a1..fb8a5fddbaf9 100644 --- a/x/evidence/types/keys.go +++ b/x/evidence/types/keys.go @@ -9,9 +9,6 @@ const ( // RouterKey defines the module's message routing key RouterKey = ModuleName - - // QuerierRoute defines the module's query routing key - QuerierRoute = ModuleName ) // KVStore key prefixes diff --git a/x/feegrant/client/testutil/cli_test.go b/x/feegrant/client/testutil/cli_test.go deleted file mode 100644 index 0293e30e162a..000000000000 --- a/x/feegrant/client/testutil/cli_test.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/x/feegrant/testutil" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig) - require.NoError(t, err) - cfg.NumValidators = 3 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index d2b50f410d7e..402dc449e520 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -140,21 +140,6 @@ func (AppModule) Name() string { // RegisterInvariants registers the feegrant module invariants. func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the feegrant module. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// NewHandler returns an sdk.Handler for the feegrant module. -func (am AppModule) NewHandler() sdk.Handler { - return nil -} - -// QuerierRoute returns the feegrant module's querier route name. -func (AppModule) QuerierRoute() string { - return "" -} - // InitGenesis performs genesis initialization for the feegrant module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/feegrant/testutil/app.yaml b/x/feegrant/testutil/app.yaml deleted file mode 100644 index 72b6f3e9466a..000000000000 --- a/x/feegrant/testutil/app.yaml +++ /dev/null @@ -1,51 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: AuthApp - - begin_blockers: [staking, auth, bank, genutil, feegrant, params, vesting] - end_blockers: [staking, auth, bank, genutil, feegrant, params, vesting] - init_genesis: [auth, bank, staking, genutil, feegrant, params, vesting] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: mint - permissions: [minter] - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: feegrant - config: - "@type": cosmos.feegrant.module.v1.Module - - - name: vesting - config: - "@type": cosmos.vesting.module.v1.Module diff --git a/x/feegrant/testutil/app_config.go b/x/feegrant/testutil/app_config.go index 05a298c79c75..e1e2f021118a 100644 --- a/x/feegrant/testutil/app_config.go +++ b/x/feegrant/testutil/app_config.go @@ -1,9 +1,6 @@ package testutil import ( - _ "embed" - - "cosmossdk.io/core/appconfig" _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/auth/vesting" @@ -13,9 +10,103 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/mint" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" -) -//go:embed app.yaml -var appConfig []byte + "cosmossdk.io/core/appconfig" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1" + genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" + stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1" + vestingmodulev1 "cosmossdk.io/api/cosmos/vesting/module/v1" +) -var AppConfig = appconfig.LoadYAML(appConfig) +var AppConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ + { + Name: "runtime", + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "FeegrantApp", + BeginBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + vestingtypes.ModuleName, + }, + EndBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + vestingtypes.ModuleName, + }, + InitGenesis: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + stakingtypes.ModuleName, + genutiltypes.ModuleName, + feegrant.ModuleName, + paramstypes.ModuleName, + vestingtypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: "cosmos", + ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{ + {Account: authtypes.FeeCollectorName}, + {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, + {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + }, + }), + }, + { + Name: vestingtypes.ModuleName, + Config: appconfig.WrapAny(&vestingmodulev1.Module{}), + }, + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: stakingtypes.ModuleName, + Config: appconfig.WrapAny(&stakingmodulev1.Module{}), + }, + { + Name: paramstypes.ModuleName, + Config: appconfig.WrapAny(¶msmodulev1.Module{}), + }, + { + Name: "tx", + Config: appconfig.WrapAny(&txmodulev1.Module{}), + }, + { + Name: genutiltypes.ModuleName, + Config: appconfig.WrapAny(&genutilmodulev1.Module{}), + }, + { + Name: feegrant.ModuleName, + Config: appconfig.WrapAny(&feegrantmodulev1.Module{}), + }, + }, +}) diff --git a/x/genutil/client/testutil/suite.go b/x/genutil/client/testutil/suite.go index 755d20154eb3..e09937176ffb 100644 --- a/x/genutil/client/testutil/suite.go +++ b/x/genutil/client/testutil/suite.go @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/simapp" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil/client/cli" stakingcli "github.com/cosmos/cosmos-sdk/x/staking/client/cli" @@ -106,7 +106,7 @@ func (s *IntegrationTestSuite) TestGenTxCmd() { s.Run(tc.name, func() { cmd := cli.GenTxCmd( - simapp.ModuleBasics, + module.NewBasicManager(), val.ClientCtx.TxConfig, banktypes.GenesisBalancesIterator{}, val.ClientCtx.HomeDir) diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index 9b79895df0d9..4b0abee37b12 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -7,14 +7,15 @@ import ( "testing" "time" + "cosmossdk.io/math" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" - simappparams "github.com/cosmos/cosmos-sdk/simapp/params" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/bank/testutil" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -39,9 +40,8 @@ type GenTxTestSuite struct { ctx sdk.Context app *simapp.SimApp - encodingConfig simappparams.EncodingConfig - - msg1, msg2 *stakingtypes.MsgCreateValidator + encodingConfig moduletestutil.TestEncodingConfig + msg1, msg2 *stakingtypes.MsgCreateValidator } func (suite *GenTxTestSuite) SetupTest() { @@ -49,11 +49,16 @@ func (suite *GenTxTestSuite) SetupTest() { app := simapp.Setup(suite.T(), checkTx) suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{}) suite.app = app - suite.encodingConfig = simapp.MakeTestEncodingConfig() + suite.encodingConfig = moduletestutil.TestEncodingConfig{ + InterfaceRegistry: app.InterfaceRegistry(), + Codec: app.AppCodec(), + TxConfig: app.TxConfig(), + Amino: app.LegacyAmino(), + } var err error amount := sdk.NewInt64Coin(sdk.DefaultBondDenom, 50) - one := sdk.OneInt() + one := math.OneInt() suite.msg1, err = stakingtypes.NewMsgCreateValidator( sdk.ValAddress(pk1.Address()), pk1, amount, desc, comm, one) suite.NoError(err) diff --git a/x/genutil/types/genesis_state_test.go b/x/genutil/types/genesis_state_test.go index 9c225fd3f7c4..760f593ab3cb 100644 --- a/x/genutil/types/genesis_state_test.go +++ b/x/genutil/types/genesis_state_test.go @@ -4,15 +4,18 @@ import ( "encoding/json" "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -38,21 +41,21 @@ func TestValidateGenesisMultipleMessages(t *testing.T) { comm := stakingtypes.CommissionRates{} msg1, err := stakingtypes.NewMsgCreateValidator(sdk.ValAddress(pk1.Address()), pk1, - sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, sdk.OneInt()) + sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, math.OneInt()) require.NoError(t, err) msg2, err := stakingtypes.NewMsgCreateValidator(sdk.ValAddress(pk2.Address()), pk2, - sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, sdk.OneInt()) + sdk.NewInt64Coin(sdk.DefaultBondDenom, 50), desc, comm, math.OneInt()) require.NoError(t, err) - txGen := simapp.MakeTestEncodingConfig().TxConfig - txBuilder := txGen.NewTxBuilder() + txConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModuleBasic{}, genutil.AppModuleBasic{}).TxConfig + txBuilder := txConfig.NewTxBuilder() require.NoError(t, txBuilder.SetMsgs(msg1, msg2)) tx := txBuilder.GetTx() - genesisState := types.NewGenesisStateFromTx(txGen.TxJSONEncoder(), []sdk.Tx{tx}) + genesisState := types.NewGenesisStateFromTx(txConfig.TxJSONEncoder(), []sdk.Tx{tx}) - err = types.ValidateGenesis(genesisState, simapp.MakeTestEncodingConfig().TxConfig.TxJSONDecoder()) + err = types.ValidateGenesis(genesisState, txConfig.TxJSONDecoder()) require.Error(t, err) } @@ -61,15 +64,15 @@ func TestValidateGenesisBadMessage(t *testing.T) { msg1 := stakingtypes.NewMsgEditValidator(sdk.ValAddress(pk1.Address()), desc, nil, nil) - txGen := simapp.MakeTestEncodingConfig().TxConfig - txBuilder := txGen.NewTxBuilder() + txConfig := moduletestutil.MakeTestEncodingConfig(staking.AppModuleBasic{}, genutil.AppModuleBasic{}).TxConfig + txBuilder := txConfig.NewTxBuilder() err := txBuilder.SetMsgs(msg1) require.NoError(t, err) tx := txBuilder.GetTx() - genesisState := types.NewGenesisStateFromTx(txGen.TxJSONEncoder(), []sdk.Tx{tx}) + genesisState := types.NewGenesisStateFromTx(txConfig.TxJSONEncoder(), []sdk.Tx{tx}) - err = types.ValidateGenesis(genesisState, simapp.MakeTestEncodingConfig().TxConfig.TxJSONDecoder()) + err = types.ValidateGenesis(genesisState, txConfig.TxJSONDecoder()) require.Error(t, err) } diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index f0e002f12395..63eab4b4b433 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "cosmossdk.io/math" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -376,7 +377,7 @@ func createValidators(t *testing.T, stakingMsgSvr stakingtypes.MsgServer, ctx sd valTokens := sdk.TokensFromConsensusPower(powerAmt[i], sdk.DefaultPowerReduction) valCreateMsg, err := stakingtypes.NewMsgCreateValidator( addrs[i], pubkeys[i], sdk.NewCoin(sdk.DefaultBondDenom, valTokens), - TestDescription, TestCommissionRates, sdk.OneInt(), + TestDescription, TestCommissionRates, math.OneInt(), ) require.NoError(t, err) res, err := stakingMsgSvr.CreateValidator(sdk.WrapSDKContext(ctx), valCreateMsg) diff --git a/x/gov/client/utils/query_test.go b/x/gov/client/utils/query_test.go index 8bc1a8e42a4e..667a8831e607 100644 --- a/x/gov/client/utils/query_test.go +++ b/x/gov/client/utils/query_test.go @@ -11,9 +11,10 @@ import ( tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" + "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov/client/utils" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" ) @@ -75,7 +76,7 @@ func (mock TxSearchMock) Block(ctx context.Context, height *int64) (*coretypes.R } func TestGetPaginatedVotes(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig(gov.AppModuleBasic{}) type testCase struct { description string diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index 518ad8d8a9f0..a3a805333204 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -74,7 +74,7 @@ func TestImportExportQueues(t *testing.T) { } db := dbm.NewMemDB() - app2 := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, simapp.MakeTestEncodingConfig(), simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome)) + app2 := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, simtestutil.NewAppOptionsWithFlagHome(simapp.DefaultNodeHome)) app2.InitChain( abci.RequestInitChain{ diff --git a/x/gov/keeper/common_test.go b/x/gov/keeper/common_test.go index ab7e23d2d301..f29fa800ba44 100644 --- a/x/gov/keeper/common_test.go +++ b/x/gov/keeper/common_test.go @@ -9,6 +9,7 @@ import ( simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -41,7 +42,7 @@ func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, sdk.NewInt(30000000)) valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs) pks := simtestutil.CreateTestPubKeys(5) - cdc := simapp.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig().Codec app.StakingKeeper = stakingkeeper.NewKeeper( cdc, diff --git a/x/gov/keeper/querier.go b/x/gov/keeper/querier.go deleted file mode 100644 index e5aacbfb4464..000000000000 --- a/x/gov/keeper/querier.go +++ /dev/null @@ -1,231 +0,0 @@ -package keeper - -// DONTCOVER - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/gov/types" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" -) - -// NewQuerier creates a new gov Querier instance -func NewQuerier(keeper *Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - switch path[0] { - case v1.QueryParams: - return queryParams(ctx, path[1:], req, keeper, legacyQuerierCdc) - - case v1.QueryProposals: - return queryProposals(ctx, path[1:], req, keeper, legacyQuerierCdc) - - case v1.QueryProposal: - return queryProposal(ctx, path[1:], req, keeper, legacyQuerierCdc) - - case v1.QueryDeposits: - return queryDeposits(ctx, path[1:], req, keeper, legacyQuerierCdc) - - case v1.QueryDeposit: - return queryDeposit(ctx, path[1:], req, keeper, legacyQuerierCdc) - - case v1.QueryVotes: - return queryVotes(ctx, path[1:], req, keeper, legacyQuerierCdc) - - case v1.QueryVote: - return queryVote(ctx, path[1:], req, keeper, legacyQuerierCdc) - - case v1.QueryTally: - return queryTally(ctx, path[1:], req, keeper, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -func queryParams(ctx sdk.Context, path []string, req abci.RequestQuery, keeper *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - switch path[0] { - case v1.ParamDeposit: - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, keeper.GetDepositParams(ctx)) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - return bz, nil - - case v1.ParamVoting: - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, keeper.GetVotingParams(ctx)) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - return bz, nil - - case v1.ParamTallying: - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, keeper.GetTallyParams(ctx)) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - return bz, nil - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "%s is not a valid query request path", req.Path) - } -} - -func queryProposal(ctx sdk.Context, path []string, req abci.RequestQuery, keeper *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params v1.QueryProposalParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - proposal, ok := keeper.GetProposal(ctx, params.ProposalID) - if !ok { - return nil, sdkerrors.Wrapf(types.ErrUnknownProposal, "%d", params.ProposalID) - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, proposal) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryDeposit(ctx sdk.Context, path []string, req abci.RequestQuery, keeper *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params v1.QueryDepositParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - deposit, _ := keeper.GetDeposit(ctx, params.ProposalID, params.Depositor) - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, deposit) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryVote(ctx sdk.Context, path []string, req abci.RequestQuery, keeper *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params v1.QueryVoteParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - vote, _ := keeper.GetVote(ctx, params.ProposalID, params.Voter) - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, vote) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryDeposits(ctx sdk.Context, path []string, req abci.RequestQuery, keeper *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params v1.QueryProposalParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - deposits := keeper.GetDeposits(ctx, params.ProposalID) - if deposits == nil { - deposits = v1.Deposits{} - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, deposits) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryTally(ctx sdk.Context, path []string, req abci.RequestQuery, keeper *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params v1.QueryProposalParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - proposalID := params.ProposalID - - proposal, ok := keeper.GetProposal(ctx, proposalID) - if !ok { - return nil, sdkerrors.Wrapf(types.ErrUnknownProposal, "%d", proposalID) - } - - var tallyResult v1.TallyResult - - switch { - case proposal.Status == v1.StatusDepositPeriod: - tallyResult = v1.EmptyTallyResult() - - case proposal.Status == v1.StatusPassed || proposal.Status == v1.StatusRejected: - tallyResult = *proposal.FinalTallyResult - - default: - // proposal is in voting period - _, _, tallyResult = keeper.Tally(ctx, proposal) - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, tallyResult) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryVotes(ctx sdk.Context, path []string, req abci.RequestQuery, keeper *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params v1.QueryProposalVotesParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - votes := keeper.GetVotes(ctx, params.ProposalID) - if votes == nil { - votes = v1.Votes{} - } else { - start, end := client.Paginate(len(votes), params.Page, params.Limit, 100) - if start < 0 || end < 0 { - votes = v1.Votes{} - } else { - votes = votes[start:end] - } - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, votes) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryProposals(ctx sdk.Context, _ []string, req abci.RequestQuery, keeper *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params v1.QueryProposalsParams - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - proposals := keeper.GetProposalsFiltered(ctx, params) - if proposals == nil { - proposals = v1.Proposals{} - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, proposals) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go deleted file mode 100644 index d47d87f2a256..000000000000 --- a/x/gov/keeper/querier_test.go +++ /dev/null @@ -1,439 +0,0 @@ -package keeper_test - -import ( - "math/rand" - "strings" - "testing" - "time" - - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/gov/keeper" - "github.com/cosmos/cosmos-sdk/x/gov/types" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" -) - -const custom = "custom" - -func getQueriedParams(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier) (v1.DepositParams, v1.VotingParams, v1.TallyParams) { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryParams, v1.ParamDeposit}, "/"), - Data: []byte{}, - } - - bz, err := querier(ctx, []string{v1.QueryParams, v1.ParamDeposit}, query) - require.NoError(t, err) - require.NotNil(t, bz) - - var depositParams v1.DepositParams - require.NoError(t, cdc.UnmarshalJSON(bz, &depositParams)) - - query = abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryParams, v1.ParamVoting}, "/"), - Data: []byte{}, - } - - bz, err = querier(ctx, []string{v1.QueryParams, v1.ParamVoting}, query) - require.NoError(t, err) - require.NotNil(t, bz) - - var votingParams v1.VotingParams - require.NoError(t, cdc.UnmarshalJSON(bz, &votingParams)) - - query = abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryParams, v1.ParamTallying}, "/"), - Data: []byte{}, - } - - bz, err = querier(ctx, []string{v1.QueryParams, v1.ParamTallying}, query) - require.NoError(t, err) - require.NotNil(t, bz) - - var tallyParams v1.TallyParams - require.NoError(t, cdc.UnmarshalJSON(bz, &tallyParams)) - - return depositParams, votingParams, tallyParams -} - -func getQueriedProposals( - t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, - depositor, voter sdk.AccAddress, status v1.ProposalStatus, page, limit int, -) []*v1.Proposal { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryProposals}, "/"), - Data: cdc.MustMarshalJSON(v1.NewQueryProposalsParams(page, limit, status, voter, depositor)), - } - - bz, err := querier(ctx, []string{v1.QueryProposals}, query) - require.NoError(t, err) - require.NotNil(t, bz) - - var proposals v1.Proposals - require.NoError(t, cdc.UnmarshalJSON(bz, &proposals)) - - return proposals -} - -func getQueriedDeposit(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64, depositor sdk.AccAddress) v1.Deposit { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryDeposit}, "/"), - Data: cdc.MustMarshalJSON(v1.NewQueryDepositParams(proposalID, depositor)), - } - - bz, err := querier(ctx, []string{v1.QueryDeposit}, query) - require.NoError(t, err) - require.NotNil(t, bz) - - var deposit v1.Deposit - require.NoError(t, cdc.UnmarshalJSON(bz, &deposit)) - - return deposit -} - -func getQueriedDeposits(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64) []v1.Deposit { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryDeposits}, "/"), - Data: cdc.MustMarshalJSON(v1.NewQueryProposalParams(proposalID)), - } - - bz, err := querier(ctx, []string{v1.QueryDeposits}, query) - require.NoError(t, err) - require.NotNil(t, bz) - - var deposits []v1.Deposit - require.NoError(t, cdc.UnmarshalJSON(bz, &deposits)) - - return deposits -} - -func getQueriedVote(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64, voter sdk.AccAddress) v1.Vote { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryVote}, "/"), - Data: cdc.MustMarshalJSON(v1.NewQueryVoteParams(proposalID, voter)), - } - - bz, err := querier(ctx, []string{v1.QueryVote}, query) - require.NoError(t, err) - require.NotNil(t, bz) - - var vote v1.Vote - require.NoError(t, cdc.UnmarshalJSON(bz, &vote)) - - return vote -} - -func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64, page, limit int) []v1.Vote { - query := abci.RequestQuery{ - Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryVote}, "/"), - Data: cdc.MustMarshalJSON(v1.NewQueryProposalVotesParams(proposalID, page, limit)), - } - - bz, err := querier(ctx, []string{v1.QueryVotes}, query) - require.NoError(t, err) - require.NotNil(t, bz) - - var votes []v1.Vote - require.NoError(t, cdc.UnmarshalJSON(bz, &votes)) - - return votes -} - -func TestQueries(t *testing.T) { - app := simapp.Setup(t, false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - legacyQuerierCdc := app.LegacyAmino() - querier := keeper.NewQuerier(app.GovKeeper, legacyQuerierCdc) - - TestAddrs := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(20000001)) - - oneCoins := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)) - consCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10))) - - tp := TestProposal - - depositParams, _, _ := getQueriedParams(t, ctx, legacyQuerierCdc, querier) - - // TestAddrs[0] proposes (and deposits) proposals #1 and #2 - proposal1, err := app.GovKeeper.SubmitProposal(ctx, tp, "") - require.NoError(t, err) - deposit1 := v1.NewDeposit(proposal1.Id, TestAddrs[0], oneCoins) - depositer1, err := sdk.AccAddressFromBech32(deposit1.Depositor) - require.NoError(t, err) - _, err = app.GovKeeper.AddDeposit(ctx, deposit1.ProposalId, depositer1, deposit1.Amount) - require.NoError(t, err) - - proposal1.TotalDeposit = sdk.NewCoins(proposal1.TotalDeposit...).Add(deposit1.Amount...) - - proposal2, err := app.GovKeeper.SubmitProposal(ctx, tp, "") - require.NoError(t, err) - deposit2 := v1.NewDeposit(proposal2.Id, TestAddrs[0], consCoins) - depositer2, err := sdk.AccAddressFromBech32(deposit2.Depositor) - require.NoError(t, err) - _, err = app.GovKeeper.AddDeposit(ctx, deposit2.ProposalId, depositer2, deposit2.Amount) - require.NoError(t, err) - - proposal2.TotalDeposit = sdk.NewCoins(proposal2.TotalDeposit...).Add(deposit2.Amount...) - - // TestAddrs[1] proposes (and deposits) on proposal #3 - proposal3, err := app.GovKeeper.SubmitProposal(ctx, tp, "") - require.NoError(t, err) - deposit3 := v1.NewDeposit(proposal3.Id, TestAddrs[1], oneCoins) - depositer3, err := sdk.AccAddressFromBech32(deposit3.Depositor) - require.NoError(t, err) - - _, err = app.GovKeeper.AddDeposit(ctx, deposit3.ProposalId, depositer3, deposit3.Amount) - require.NoError(t, err) - - proposal3.TotalDeposit = sdk.NewCoins(proposal3.TotalDeposit...).Add(deposit3.Amount...) - - // TestAddrs[1] deposits on proposals #2 & #3 - deposit4 := v1.NewDeposit(proposal2.Id, TestAddrs[1], depositParams.MinDeposit) - depositer4, err := sdk.AccAddressFromBech32(deposit4.Depositor) - require.NoError(t, err) - _, err = app.GovKeeper.AddDeposit(ctx, deposit4.ProposalId, depositer4, deposit4.Amount) - require.NoError(t, err) - - proposal2.TotalDeposit = sdk.NewCoins(proposal2.TotalDeposit...).Add(deposit4.Amount...) - proposal2.Status = v1.StatusVotingPeriod - votingEndTime := ctx.BlockTime().Add(v1.DefaultPeriod) - proposal2.VotingEndTime = &votingEndTime - - deposit5 := v1.NewDeposit(proposal3.Id, TestAddrs[1], depositParams.MinDeposit) - depositer5, err := sdk.AccAddressFromBech32(deposit5.Depositor) - require.NoError(t, err) - _, err = app.GovKeeper.AddDeposit(ctx, deposit5.ProposalId, depositer5, deposit5.Amount) - require.NoError(t, err) - - proposal3.TotalDeposit = sdk.NewCoins(proposal3.TotalDeposit...).Add(deposit5.Amount...) - proposal3.Status = v1.StatusVotingPeriod - votingEndTime = ctx.BlockTime().Add(v1.DefaultPeriod) - proposal3.VotingEndTime = &votingEndTime - // total deposit of TestAddrs[1] on proposal #3 is worth the proposal deposit + individual deposit - deposit5.Amount = sdk.NewCoins(deposit5.Amount...).Add(deposit3.Amount...) - - // check deposits on proposal1 match individual deposits - - deposits := getQueriedDeposits(t, ctx, legacyQuerierCdc, querier, proposal1.Id) - require.Len(t, deposits, 1) - require.Equal(t, deposit1, deposits[0]) - - deposit := getQueriedDeposit(t, ctx, legacyQuerierCdc, querier, proposal1.Id, TestAddrs[0]) - require.Equal(t, deposit1, deposit) - - // check deposits on proposal2 match individual deposits - deposits = getQueriedDeposits(t, ctx, legacyQuerierCdc, querier, proposal2.Id) - require.Len(t, deposits, 2) - // NOTE order of deposits is determined by the addresses - require.Equal(t, deposit2, deposits[0]) - require.Equal(t, deposit4, deposits[1]) - - // check deposits on proposal3 match individual deposits - deposits = getQueriedDeposits(t, ctx, legacyQuerierCdc, querier, proposal3.Id) - require.Len(t, deposits, 1) - require.Equal(t, deposit5, deposits[0]) - - deposit = getQueriedDeposit(t, ctx, legacyQuerierCdc, querier, proposal3.Id, TestAddrs[1]) - require.Equal(t, deposit5, deposit) - - // Only proposal #1 should be in v1.Deposit Period - proposals := getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, nil, v1.StatusDepositPeriod, 1, 0) - require.Len(t, proposals, 1) - require.Equal(t, proposal1, *proposals[0]) - - // Only proposals #2 and #3 should be in Voting Period - proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, nil, v1.StatusVotingPeriod, 1, 0) - require.Len(t, proposals, 2) - checkEqualProposal(t, proposal2, *proposals[0]) - checkEqualProposal(t, proposal3, *proposals[1]) - - // Addrs[0] votes on proposals #2 & #3 - vote1 := v1.NewVote(proposal2.Id, TestAddrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), "") - vote2 := v1.NewVote(proposal3.Id, TestAddrs[0], v1.NewNonSplitVoteOption(v1.OptionYes), "") - app.GovKeeper.SetVote(ctx, vote1) - app.GovKeeper.SetVote(ctx, vote2) - - // Addrs[1] votes on proposal #3 - vote3 := v1.NewVote(proposal3.Id, TestAddrs[1], v1.NewNonSplitVoteOption(v1.OptionYes), "") - app.GovKeeper.SetVote(ctx, vote3) - - // Test query voted by TestAddrs[0] - proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, TestAddrs[0], v1.StatusNil, 1, 0) - checkEqualProposal(t, proposal2, *proposals[0]) - checkEqualProposal(t, proposal3, *proposals[1]) - - // Test query votes on v1.Proposal 2 - votes := getQueriedVotes(t, ctx, legacyQuerierCdc, querier, proposal2.Id, 1, 0) - require.Len(t, votes, 1) - checkEqualVotes(t, vote1, votes[0]) - - vote := getQueriedVote(t, ctx, legacyQuerierCdc, querier, proposal2.Id, TestAddrs[0]) - checkEqualVotes(t, vote1, vote) - - // Test query votes on v1.Proposal 3 - votes = getQueriedVotes(t, ctx, legacyQuerierCdc, querier, proposal3.Id, 1, 0) - require.Len(t, votes, 2) - checkEqualVotes(t, vote2, votes[0]) - checkEqualVotes(t, vote3, votes[1]) - - // Test query all proposals - proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, nil, v1.StatusNil, 1, 0) - checkEqualProposal(t, proposal1, *proposals[0]) - checkEqualProposal(t, proposal2, *proposals[1]) - checkEqualProposal(t, proposal3, *proposals[2]) - - // Test query voted by TestAddrs[1] - proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, nil, TestAddrs[1], v1.StatusNil, 1, 0) - require.Equal(t, proposal3.Id, proposals[0].Id) - - // Test query deposited by TestAddrs[0] - proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, TestAddrs[0], nil, v1.StatusNil, 1, 0) - require.Equal(t, proposal1.Id, proposals[0].Id) - - // Test query deposited by addr2 - proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, TestAddrs[1], nil, v1.StatusNil, 1, 0) - require.Equal(t, proposal2.Id, proposals[0].Id) - require.Equal(t, proposal3.Id, proposals[1].Id) - - // Test query voted AND deposited by addr1 - proposals = getQueriedProposals(t, ctx, legacyQuerierCdc, querier, TestAddrs[0], TestAddrs[0], v1.StatusNil, 1, 0) - require.Equal(t, proposal2.Id, proposals[0].Id) -} - -func TestPaginatedVotesQuery(t *testing.T) { - app := simapp.Setup(t, false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - legacyQuerierCdc := app.LegacyAmino() - - proposal := v1.Proposal{ - Id: 100, - Status: v1.StatusVotingPeriod, - } - - app.GovKeeper.SetProposal(ctx, proposal) - - votes := make([]v1.Vote, 20) - random := rand.New(rand.NewSource(time.Now().UnixNano())) - addrMap := make(map[string]struct{}) - genAddr := func() string { - addr := make(sdk.AccAddress, 20) - for { - random.Read(addr) - addrStr := addr.String() - if _, ok := addrMap[addrStr]; !ok { - addrMap[addrStr] = struct{}{} - return addrStr - } - } - } - for i := range votes { - vote := v1.Vote{ - ProposalId: proposal.Id, - Voter: genAddr(), - Options: v1.NewNonSplitVoteOption(v1.OptionYes), - } - votes[i] = vote - app.GovKeeper.SetVote(ctx, vote) - } - - querier := keeper.NewQuerier(app.GovKeeper, legacyQuerierCdc) - - // keeper preserves consistent order for each query, but this is not the insertion order - all := getQueriedVotes(t, ctx, legacyQuerierCdc, querier, proposal.Id, 1, 0) - require.Equal(t, len(all), len(votes)) - - type testCase struct { - description string - page int - limit int - votes []v1.Vote - } - for _, tc := range []testCase{ - { - description: "SkipAll", - page: 2, - limit: len(all), - }, - { - description: "GetFirstChunk", - page: 1, - limit: 10, - votes: all[:10], - }, - { - description: "GetSecondsChunk", - page: 2, - limit: 10, - votes: all[10:], - }, - { - description: "InvalidPage", - page: -1, - }, - } { - tc := tc - t.Run(tc.description, func(t *testing.T) { - votes := getQueriedVotes(t, ctx, legacyQuerierCdc, querier, proposal.Id, tc.page, tc.limit) - require.Equal(t, len(tc.votes), len(votes)) - for i := range votes { - require.Equal(t, tc.votes[i], votes[i]) - } - }) - } -} - -// checkEqualVotes checks that two votes are equal, without taking into account -// graceful fallback for `Option`. -// When querying, the keeper populates the `vote.Option` field when there's -// only 1 vote, this function checks equality of structs while skipping that -// field. -func checkEqualVotes(t *testing.T, vote1, vote2 v1.Vote) { - require.Equal(t, vote1.Options, vote2.Options) - require.Equal(t, vote1.Voter, vote2.Voter) - require.Equal(t, vote1.ProposalId, vote2.ProposalId) -} - -// checkEqualProposal checks that 2 proposals are equal. -// When decoding with Amino, there are weird cases where the voting times -// are actually equal, but `require.Equal()` says they are not: -// -// Diff: -// --- Expected -// +++ Actual -// @@ -68,3 +68,7 @@ -// }, -// - VotingStartTime: (*time.Time)(), -// + VotingStartTime: (*time.Time)({ -// + wall: (uint64) 0, -// + ext: (int64) 0, -// + loc: (*time.Location)() -// + }), -func checkEqualProposal(t *testing.T, p1, p2 v1.Proposal) { - require.Equal(t, p1.Id, p2.Id) - require.Equal(t, p1.Messages, p2.Messages) - require.Equal(t, p1.Status, p2.Status) - require.Equal(t, p1.FinalTallyResult, p2.FinalTallyResult) - require.Equal(t, p1.SubmitTime, p2.SubmitTime) - require.Equal(t, p1.DepositEndTime, p2.DepositEndTime) - require.Equal(t, p1.TotalDeposit, p2.TotalDeposit) - require.Equal(t, convertNilToDefault(p1.VotingStartTime), convertNilToDefault(p2.VotingStartTime)) - require.Equal(t, convertNilToDefault(p1.VotingEndTime), convertNilToDefault(p2.VotingEndTime)) -} - -// convertNilToDefault converts a (*time.Time)() into a (*time.Time)()). -// In proto structs dealing with time, we use *time.Time, which can be nil. -// However, when using Amino, a nil time is unmarshalled into -// (*time.Time)()), which is Jan 1st 1970. -// This function converts a nil time to a default time, to check that they are -// actually equal. -func convertNilToDefault(t *time.Time) *time.Time { - if t == nil { - return &time.Time{} - } - - return t -} diff --git a/x/gov/migrations/v043/json_test.go b/x/gov/migrations/v043/json_test.go index 4202752aada6..acde3a1b6436 100644 --- a/x/gov/migrations/v043/json_test.go +++ b/x/gov/migrations/v043/json_test.go @@ -7,14 +7,14 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) func TestMigrateJSON(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() + encodingConfig := moduletestutil.MakeTestEncodingConfig() clientCtx := client.Context{}. WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). diff --git a/x/gov/migrations/v043/store_test.go b/x/gov/migrations/v043/store_test.go index 1ae662d818eb..104e6046f21d 100644 --- a/x/gov/migrations/v043/store_test.go +++ b/x/gov/migrations/v043/store_test.go @@ -7,10 +7,10 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" v042gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -18,7 +18,7 @@ import ( ) func TestMigrateStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig().Codec govKey := sdk.NewKVStoreKey("gov") ctx := testutil.DefaultContext(govKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(govKey) diff --git a/x/gov/migrations/v046/json_test.go b/x/gov/migrations/v046/json_test.go index 518161b9e8b5..109af562dded 100644 --- a/x/gov/migrations/v046/json_test.go +++ b/x/gov/migrations/v046/json_test.go @@ -10,9 +10,10 @@ import ( "github.com/cosmos/cosmos-sdk/client" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/gov" v046 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v046" "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" @@ -20,7 +21,7 @@ import ( ) func TestMigrateJSON(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() + encodingConfig := moduletestutil.MakeTestEncodingConfig(gov.AppModuleBasic{}) clientCtx := client.Context{}. WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). diff --git a/x/gov/migrations/v046/store_test.go b/x/gov/migrations/v046/store_test.go index a9318f9390a9..7241815a6ff2 100644 --- a/x/gov/migrations/v046/store_test.go +++ b/x/gov/migrations/v046/store_test.go @@ -6,18 +6,20 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/gov" v042gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" v046gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v046" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/cosmos/cosmos-sdk/x/upgrade" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) func TestMigrateStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(upgrade.AppModuleBasic{}, gov.AppModuleBasic{}).Codec govKey := sdk.NewKVStoreKey("gov") ctx := testutil.DefaultContext(govKey, sdk.NewTransientStoreKey("transient_test")) store := ctx.KVStore(govKey) diff --git a/x/gov/module.go b/x/gov/module.go index dd95f7e18896..c5d1e563e454 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -239,21 +239,6 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper, am.bankKeeper) } -// Deprecated: Route returns the message routing key for the gov module. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the gov module's querier route name. -func (AppModule) QuerierRoute() string { - return types.QuerierRoute -} - -// LegacyQuerierHandler returns no sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { msgServer := keeper.NewMsgServerImpl(am.keeper) diff --git a/x/gov/module_test.go b/x/gov/module_test.go index f9c7c97137b6..b0d277162b40 100644 --- a/x/gov/module_test.go +++ b/x/gov/module_test.go @@ -20,13 +20,12 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { db := dbm.NewMemDB() - encCdc := simapp.MakeTestEncodingConfig() appOptions := make(simtestutil.AppOptionsMap, 0) appOptions[flags.FlagHome] = simapp.DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = 5 - app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, encCdc, appOptions) + app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, appOptions) genesisState := simapp.GenesisStateWithSingleValidator(t, app) stateBytes, err := tmjson.Marshal(genesisState) diff --git a/x/gov/simulation/decoder_test.go b/x/gov/simulation/decoder_test.go index 7d9ac2e5bc90..8f97b00afd4f 100644 --- a/x/gov/simulation/decoder_test.go +++ b/x/gov/simulation/decoder_test.go @@ -6,12 +6,14 @@ import ( "testing" "time" + "cosmossdk.io/math" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov/simulation" "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -23,7 +25,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Codec + cdc := moduletestutil.MakeTestEncodingConfig(gov.AppModuleBasic{}).Codec dec := simulation.NewDecodeStore(cdc) endTime := time.Now().UTC() @@ -36,7 +38,7 @@ func TestDecodeStore(t *testing.T) { proposalIDBz := make([]byte, 8) binary.LittleEndian.PutUint64(proposalIDBz, 1) - deposit := v1beta1.NewDeposit(1, delAddr1, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.OneInt()))) + deposit := v1beta1.NewDeposit(1, delAddr1, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, math.OneInt()))) vote := v1beta1.NewVote(1, delAddr1, v1beta1.NewNonSplitVoteOption(v1beta1.OptionYes)) proposalBzA, err := cdc.Marshal(&proposalA) diff --git a/x/gov/types/keys.go b/x/gov/types/keys.go index 7f58d8fdfbac..bbb964c674cd 100644 --- a/x/gov/types/keys.go +++ b/x/gov/types/keys.go @@ -18,9 +18,6 @@ const ( // RouterKey is the message route for gov RouterKey = ModuleName - - // QuerierRoute is the querier route for gov - QuerierRoute = ModuleName ) // Keys for governance store diff --git a/x/gov/types/v1/tally.go b/x/gov/types/v1/tally.go index 7a09625737ce..142745094f93 100644 --- a/x/gov/types/v1/tally.go +++ b/x/gov/types/v1/tally.go @@ -49,7 +49,7 @@ func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult { // EmptyTallyResult returns an empty TallyResult. func EmptyTallyResult() TallyResult { - return NewTallyResult(sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt()) + return NewTallyResult(math.ZeroInt(), math.ZeroInt(), math.ZeroInt(), math.ZeroInt()) } // Equals returns if two tally results are equal. diff --git a/x/gov/types/v1beta1/tally.go b/x/gov/types/v1beta1/tally.go index cf44f59b6c69..35a3338a4577 100644 --- a/x/gov/types/v1beta1/tally.go +++ b/x/gov/types/v1beta1/tally.go @@ -51,7 +51,7 @@ func NewTallyResultFromMap(results map[VoteOption]sdk.Dec) TallyResult { // EmptyTallyResult returns an empty TallyResult. func EmptyTallyResult() TallyResult { - return NewTallyResult(sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt()) + return NewTallyResult(math.ZeroInt(), math.ZeroInt(), math.ZeroInt(), math.ZeroInt()) } // Equals returns if two proposals are equal. diff --git a/x/group/client/testutil/cli_test.go b/x/group/client/testutil/cli_test.go deleted file mode 100644 index be88858caf3c..000000000000 --- a/x/group/client/testutil/cli_test.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/x/group/testutil" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig) - require.NoError(t, err) - cfg.NumValidators = 2 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/group/keeper/keeper.go b/x/group/keeper/keeper.go index 70868e59cc90..d7ea4157efe4 100644 --- a/x/group/keeper/keeper.go +++ b/x/group/keeper/keeper.go @@ -277,6 +277,7 @@ func (k Keeper) abortProposals(ctx sdk.Context, groupPolicyAddr sdk.AccAddress) return err } + //nolint:gosec // "implicit memory aliasing in the for loop (because of the pointer on &proposalInfo)" for _, proposalInfo := range proposals { // Mark all proposals still in the voting phase as aborted. if proposalInfo.Status == group.PROPOSAL_STATUS_SUBMITTED { @@ -321,6 +322,7 @@ func (k Keeper) pruneVotes(ctx sdk.Context, proposalID uint64) error { return err } + //nolint:gosec // "implicit memory aliasing in the for loop (because of the pointer on &v)" for _, v := range votes { err = k.voteTable.Delete(ctx.KVStore(k.key), &v) if err != nil { @@ -375,11 +377,13 @@ func (k Keeper) PruneProposals(ctx sdk.Context) error { // TallyProposalsAtVPEnd iterates over all proposals whose voting period // has ended, tallies their votes, prunes them, and updates the proposal's // `FinalTallyResult` field. + func (k Keeper) TallyProposalsAtVPEnd(ctx sdk.Context) error { proposals, err := k.proposalsByVPEnd(ctx, ctx.BlockTime()) if err != nil { return nil } + //nolint:gosec // "implicit memory aliasing in the for loop (because of the pointers in the loop)" for _, proposal := range proposals { policyInfo, err := k.getGroupPolicyInfo(ctx, proposal.GroupPolicyAddress) if err != nil { diff --git a/x/group/module/module.go b/x/group/module/module.go index 915b24970aba..c0ad9a540cf4 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -112,23 +112,10 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) } -// Deprecated: Route returns the message routing key for the group module. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - func (am AppModule) NewHandler() sdk.Handler { return nil } -// QuerierRoute returns the route we respond to for abci queries -func (AppModule) QuerierRoute() string { return "" } - -// LegacyQuerierHandler returns the group module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return nil -} - // InitGenesis performs genesis initialization for the group module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/group/testutil/app.yaml b/x/group/testutil/app.yaml deleted file mode 100644 index ae253b397ba8..000000000000 --- a/x/group/testutil/app.yaml +++ /dev/null @@ -1,51 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: GroupApp - - begin_blockers: [mint, staking, auth, bank, genutil, group, params] - end_blockers: [staking, auth, bank, mint, genutil, group, params] - init_genesis: [auth, bank, staking, mint, genutil, group, params] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: mint - permissions: [minter] - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: group - config: - "@type": cosmos.group.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: mint - config: - "@type": cosmos.mint.module.v1.Module diff --git a/x/group/testutil/app_config.go b/x/group/testutil/app_config.go index 56d7c797398f..ffba8ac1c66a 100644 --- a/x/group/testutil/app_config.go +++ b/x/group/testutil/app_config.go @@ -1,9 +1,10 @@ package testutil import ( - _ "embed" + "time" + + "google.golang.org/protobuf/types/known/durationpb" - "cosmossdk.io/core/appconfig" _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/authz" @@ -13,9 +14,100 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/mint" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" -) -//go:embed app.yaml -var appConfig []byte + "cosmossdk.io/core/appconfig" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + "github.com/cosmos/cosmos-sdk/x/group" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + groupmodulev1 "cosmossdk.io/api/cosmos/group/module/v1" + paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" + stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1" +) -var AppConfig = appconfig.LoadYAML(appConfig) +var AppConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ + { + Name: "runtime", + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "GroupApp", + BeginBlockers: []string{ + minttypes.ModuleName, + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + group.ModuleName, + paramstypes.ModuleName, + }, + EndBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + minttypes.ModuleName, + genutiltypes.ModuleName, + group.ModuleName, + paramstypes.ModuleName, + }, + InitGenesis: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + stakingtypes.ModuleName, + minttypes.ModuleName, + genutiltypes.ModuleName, + group.ModuleName, + paramstypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: "cosmos", + ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{ + {Account: authtypes.FeeCollectorName}, + {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, + {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + }, + }), + }, + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: stakingtypes.ModuleName, + Config: appconfig.WrapAny(&stakingmodulev1.Module{}), + }, + { + Name: paramstypes.ModuleName, + Config: appconfig.WrapAny(¶msmodulev1.Module{}), + }, + { + Name: "tx", + Config: appconfig.WrapAny(&txmodulev1.Module{}), + }, + { + Name: genutiltypes.ModuleName, + Config: appconfig.WrapAny(&genutilmodulev1.Module{}), + }, + { + Name: group.ModuleName, + Config: appconfig.WrapAny(&groupmodulev1.Module{ + MaxExecutionPeriod: durationpb.New(time.Second * 1209600), + MaxMetadataLen: 255, + }), + }, + }, +}) diff --git a/x/mint/client/testutil/cli_test.go b/x/mint/client/testutil/cli_test.go deleted file mode 100644 index 11fb6ff11e92..000000000000 --- a/x/mint/client/testutil/cli_test.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/x/mint/testutil" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig) - require.NoError(t, err) - cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/mint/keeper/querier.go b/x/mint/keeper/querier.go deleted file mode 100644 index 294445614a5f..000000000000 --- a/x/mint/keeper/querier.go +++ /dev/null @@ -1,62 +0,0 @@ -package keeper - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -// NewQuerier returns a minting Querier handler. -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, _ abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryParameters: - return queryParams(ctx, k, legacyQuerierCdc) - - case types.QueryInflation: - return queryInflation(ctx, k, legacyQuerierCdc) - - case types.QueryAnnualProvisions: - return queryAnnualProvisions(ctx, k, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -func queryParams(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - params := k.GetParams(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryInflation(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - minter := k.GetMinter(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, minter.Inflation) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryAnnualProvisions(ctx sdk.Context, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - minter := k.GetMinter(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, minter.AnnualProvisions) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} diff --git a/x/mint/keeper/querier_test.go b/x/mint/keeper/querier_test.go deleted file mode 100644 index 371bc510124f..000000000000 --- a/x/mint/keeper/querier_test.go +++ /dev/null @@ -1,122 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/testutil" - sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/cosmos/cosmos-sdk/x/mint" - "github.com/cosmos/cosmos-sdk/x/mint/keeper" - keep "github.com/cosmos/cosmos-sdk/x/mint/keeper" - minttestutil "github.com/cosmos/cosmos-sdk/x/mint/testutil" - "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -type MintKeeperTestSuite struct { - suite.Suite - - ctx sdk.Context - legacyAmino *codec.LegacyAmino - mintKeeper keeper.Keeper -} - -func (suite *MintKeeperTestSuite) SetupTest() { - encCfg := moduletestutil.MakeTestEncodingConfig(mint.AppModuleBasic{}) - key := sdk.NewKVStoreKey(types.StoreKey) - testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test")) - suite.ctx = testCtx.Ctx - - // gomock initializations - ctrl := gomock.NewController(suite.T()) - accountKeeper := minttestutil.NewMockAccountKeeper(ctrl) - bankKeeper := minttestutil.NewMockBankKeeper(ctrl) - stakingKeeper := minttestutil.NewMockStakingKeeper(ctrl) - - accountKeeper.EXPECT().GetModuleAddress(types.ModuleName).Return(sdk.AccAddress{}) - - suite.mintKeeper = keeper.NewKeeper( - encCfg.Codec, - key, - stakingKeeper, - accountKeeper, - bankKeeper, - authtypes.FeeCollectorName, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - err := suite.mintKeeper.SetParams(suite.ctx, types.DefaultParams()) - suite.Require().NoError(err) - suite.mintKeeper.SetMinter(suite.ctx, types.DefaultInitialMinter()) -} - -func (suite *MintKeeperTestSuite) TestNewQuerier(t *testing.T) { - querier := keep.NewQuerier(suite.mintKeeper, suite.legacyAmino) - - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - - _, err := querier(suite.ctx, []string{types.QueryParameters}, query) - require.NoError(t, err) - - _, err = querier(suite.ctx, []string{types.QueryInflation}, query) - require.NoError(t, err) - - _, err = querier(suite.ctx, []string{types.QueryAnnualProvisions}, query) - require.NoError(t, err) - - _, err = querier(suite.ctx, []string{"foo"}, query) - require.Error(t, err) -} - -func (suite *MintKeeperTestSuite) TestQueryParams(t *testing.T) { - querier := keep.NewQuerier(suite.mintKeeper, suite.legacyAmino) - - var params types.Params - - res, sdkErr := querier(suite.ctx, []string{types.QueryParameters}, abci.RequestQuery{}) - require.NoError(t, sdkErr) - - err := suite.legacyAmino.UnmarshalJSON(res, ¶ms) - require.NoError(t, err) - - require.Equal(t, suite.mintKeeper.GetParams(suite.ctx), params) -} - -func (suite *MintKeeperTestSuite) TestQueryInflation(t *testing.T) { - querier := keep.NewQuerier(suite.mintKeeper, suite.legacyAmino) - - var inflation sdk.Dec - - res, sdkErr := querier(suite.ctx, []string{types.QueryInflation}, abci.RequestQuery{}) - require.NoError(t, sdkErr) - - err := suite.legacyAmino.UnmarshalJSON(res, &inflation) - require.NoError(t, err) - - require.Equal(t, suite.mintKeeper.GetMinter(suite.ctx).Inflation, inflation) -} - -func (suite *MintKeeperTestSuite) TestQueryAnnualProvisions(t *testing.T) { - querier := keep.NewQuerier(suite.mintKeeper, suite.legacyAmino) - - var annualProvisions sdk.Dec - - res, sdkErr := querier(suite.ctx, []string{types.QueryAnnualProvisions}, abci.RequestQuery{}) - require.NoError(t, sdkErr) - - err := suite.legacyAmino.UnmarshalJSON(res, &annualProvisions) - require.NoError(t, err) - - require.Equal(t, suite.mintKeeper.GetMinter(suite.ctx).AnnualProvisions, annualProvisions) -} diff --git a/x/mint/module.go b/x/mint/module.go index 4d9781f3d437..6ee35876e854 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -137,19 +137,6 @@ func (AppModule) Name() string { // RegisterInvariants registers the mint module invariants. func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the mint module. -func (AppModule) Route() sdk.Route { return sdk.Route{} } - -// QuerierRoute returns the mint module's querier route name. -func (AppModule) QuerierRoute() string { - return types.QuerierRoute -} - -// LegacyQuerierHandler returns the mint module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) -} - // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index a59b6f09ccc7..75a0cacbb388 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + "cosmossdk.io/math" sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -50,7 +51,7 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, dec3, mintGenesis.Params.InflationMin) require.Equal(t, "stake", mintGenesis.Params.MintDenom) require.Equal(t, "0stake", mintGenesis.Minter.BlockProvision(mintGenesis.Params).String()) - require.Equal(t, "0.170000000000000000", mintGenesis.Minter.NextAnnualProvisions(mintGenesis.Params, sdk.OneInt()).String()) + require.Equal(t, "0.170000000000000000", mintGenesis.Minter.NextAnnualProvisions(mintGenesis.Params, math.OneInt()).String()) require.Equal(t, "0.169999926644441493", mintGenesis.Minter.NextInflationRate(mintGenesis.Params, sdk.OneDec()).String()) require.Equal(t, "0.170000000000000000", mintGenesis.Minter.Inflation.String()) require.Equal(t, "0.000000000000000000", mintGenesis.Minter.AnnualProvisions.String()) diff --git a/x/mint/testutil/app_config.go b/x/mint/testutil/app_config.go index 6f9b5813553d..47e4ed4de7fd 100644 --- a/x/mint/testutil/app_config.go +++ b/x/mint/testutil/app_config.go @@ -50,12 +50,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ genutiltypes.ModuleName, paramstypes.ModuleName, }, - OverrideStoreKeys: []*runtimev1alpha1.StoreKeyConfig{ - { - ModuleName: authtypes.ModuleName, - KvStoreKey: "acc", - }, - }, InitGenesis: []string{ authtypes.ModuleName, banktypes.ModuleName, diff --git a/x/mint/types/keys.go b/x/mint/types/keys.go index dc4699b5a9b8..69deb872680a 100644 --- a/x/mint/types/keys.go +++ b/x/mint/types/keys.go @@ -13,9 +13,6 @@ const ( // StoreKey is the default store key for mint StoreKey = ModuleName - // QuerierRoute is the querier route for the minting store. - QuerierRoute = StoreKey - // Query endpoints supported by the minting querier QueryParameters = "parameters" QueryInflation = "inflation" diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index 04de803a2e5e..c3da5385a8be 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -87,7 +87,7 @@ func TestBlockProvision(t *testing.T) { } // Benchmarking :) -// previously using sdk.Int operations: +// previously using math.Int operations: // BenchmarkBlockProvision-4 5000000 220 ns/op // // using sdk.Dec operations: (current implementation) diff --git a/x/mint/types/params_legacy.go b/x/mint/types/params_legacy.go index d9e5b17991d9..640ad2db223a 100644 --- a/x/mint/types/params_legacy.go +++ b/x/mint/types/params_legacy.go @@ -21,14 +21,14 @@ var ( // ParamTable for minting module. // -// NOTE: Deprecated. +// Deprecated. func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } // Implements params.ParamSet // -// NOTE: Deprecated. +// Deprecated. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyMintDenom, &p.MintDenom, validateMintDenom), diff --git a/x/nft/client/testutil/cli_test.go b/x/nft/client/testutil/cli_test.go deleted file mode 100644 index 98344ce91c70..000000000000 --- a/x/nft/client/testutil/cli_test.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/x/nft/testutil" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig) - require.NoError(t, err) - cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 51537ed7379d..b8054addf0d8 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -121,23 +121,10 @@ func (AppModule) Name() string { // RegisterInvariants does nothing, there are no invariants to enforce func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Route returns the message routing key for the staking module. -func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(nft.RouterKey, nil) -} - func (am AppModule) NewHandler() sdk.Handler { return nil } -// QuerierRoute returns the route we respond to for abci queries -func (AppModule) QuerierRoute() string { return "" } - -// LegacyQuerierHandler returns the nft module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return nil -} - // InitGenesis performs genesis initialization for the nft module. It returns // no validator updates. func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { diff --git a/x/nft/testutil/app_config.go b/x/nft/testutil/app_config.go index b93d56297796..467313f8d3d9 100644 --- a/x/nft/testutil/app_config.go +++ b/x/nft/testutil/app_config.go @@ -55,12 +55,6 @@ var AppConfig = appconfig.Compose(&appv1alpha1.Config{ nft.ModuleName, paramstypes.ModuleName, }, - OverrideStoreKeys: []*runtimev1alpha1.StoreKeyConfig{ - { - ModuleName: authtypes.ModuleName, - KvStoreKey: "acc", - }, - }, InitGenesis: []string{ authtypes.ModuleName, banktypes.ModuleName, diff --git a/x/params/client/testutil/cli_test.go b/x/params/client/testutil/cli_test.go deleted file mode 100644 index 58b3a48b45d0..000000000000 --- a/x/params/client/testutil/cli_test.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/x/params/testutil" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig) - require.NoError(t, err) - cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/params/keeper/keeper_test.go b/x/params/keeper/keeper_test.go index 6a7b32e657a0..2397330fdc9e 100644 --- a/x/params/keeper/keeper_test.go +++ b/x/params/keeper/keeper_test.go @@ -4,6 +4,7 @@ import ( "reflect" "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -189,7 +190,7 @@ func TestSubspace(t *testing.T) { {"uint16", uint16(1), uint16(0), new(uint16)}, {"uint32", uint32(1), uint32(0), new(uint32)}, {"uint64", uint64(1), uint64(0), new(uint64)}, - {"int", sdk.NewInt(1), *new(sdk.Int), new(sdk.Int)}, + {"int", sdk.NewInt(1), *new(math.Int), new(math.Int)}, {"uint", sdk.NewUint(1), *new(sdk.Uint), new(sdk.Uint)}, {"dec", sdk.NewDec(1), *new(sdk.Dec), new(sdk.Dec)}, {"struct", s{1}, s{0}, new(s)}, @@ -204,7 +205,7 @@ func TestSubspace(t *testing.T) { types.NewParamSetPair([]byte("uint16"), uint16(0), validateNoOp), types.NewParamSetPair([]byte("uint32"), uint32(0), validateNoOp), types.NewParamSetPair([]byte("uint64"), uint64(0), validateNoOp), - types.NewParamSetPair([]byte("int"), sdk.Int{}, validateNoOp), + types.NewParamSetPair([]byte("int"), math.Int{}, validateNoOp), types.NewParamSetPair([]byte("uint"), sdk.Uint{}, validateNoOp), types.NewParamSetPair([]byte("dec"), sdk.Dec{}, validateNoOp), types.NewParamSetPair([]byte("struct"), s{}, validateNoOp), diff --git a/x/params/keeper/querier.go b/x/params/keeper/querier.go deleted file mode 100644 index 9d6f3c3da69f..000000000000 --- a/x/params/keeper/querier.go +++ /dev/null @@ -1,47 +0,0 @@ -package keeper - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cosmos/cosmos-sdk/x/params/types/proposal" -) - -// NewQuerier returns a new querier handler for the x/params module. -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryParams: - return queryParams(ctx, req, k, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -func queryParams(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QuerySubspaceParams - - if err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - ss, ok := k.GetSubspace(params.Subspace) - if !ok { - return nil, sdkerrors.Wrap(proposal.ErrUnknownSubspace, params.Subspace) - } - - rawValue := ss.GetRaw(ctx, []byte(params.Key)) - resp := types.NewSubspaceParamsResponse(params.Subspace, params.Key, string(rawValue)) - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, resp) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} diff --git a/x/params/module.go b/x/params/module.go index 7d851f6fec09..d3385f500112 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -100,22 +100,9 @@ func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMess return []abci.ValidatorUpdate{} } -// Deprecated: Route returns the message routing key for the params module. -func (AppModule) Route() sdk.Route { - return sdk.Route{} -} - // GenerateGenesisState performs a no-op. func (AppModule) GenerateGenesisState(simState *module.SimulationState) {} -// QuerierRoute returns the x/param module's querier route name. -func (AppModule) QuerierRoute() string { return types.QuerierRoute } - -// LegacyQuerierHandler returns the x/params querier handler. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) -} - // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index d7c3ff391c08..c4f60970f0b0 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -1,9 +1,10 @@ package params_test import ( - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "testing" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" diff --git a/x/params/testutil/app.yaml b/x/params/testutil/app.yaml deleted file mode 100644 index d623a8ccf15c..000000000000 --- a/x/params/testutil/app.yaml +++ /dev/null @@ -1,41 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: ParamsApp - - begin_blockers: [staking, auth, bank, genutil, params] - end_blockers: [staking, auth, bank, genutil, params] - init_genesis: [auth, bank, staking, genutil, params] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module diff --git a/x/params/testutil/app_config.go b/x/params/testutil/app_config.go index 36fd9c861c62..133872dc0a60 100644 --- a/x/params/testutil/app_config.go +++ b/x/params/testutil/app_config.go @@ -1,18 +1,89 @@ package testutil import ( - _ "embed" - - "cosmossdk.io/core/appconfig" _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" _ "github.com/cosmos/cosmos-sdk/x/genutil" _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/staking" -) -//go:embed app.yaml -var appConfig []byte + "cosmossdk.io/core/appconfig" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" + stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1" +) -var AppConfig = appconfig.LoadYAML(appConfig) +var AppConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ + { + Name: "runtime", + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "ParamsApp", + BeginBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + EndBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + InitGenesis: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + stakingtypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: "cosmos", + ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{ + {Account: authtypes.FeeCollectorName}, + {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + }, + }), + }, + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: stakingtypes.ModuleName, + Config: appconfig.WrapAny(&stakingmodulev1.Module{}), + }, + { + Name: paramstypes.ModuleName, + Config: appconfig.WrapAny(¶msmodulev1.Module{}), + }, + { + Name: "tx", + Config: appconfig.WrapAny(&txmodulev1.Module{}), + }, + { + Name: genutiltypes.ModuleName, + Config: appconfig.WrapAny(&genutilmodulev1.Module{}), + }, + }, +}) diff --git a/x/params/types/keys.go b/x/params/types/keys.go index 25df79848dae..87c925383ccc 100644 --- a/x/params/types/keys.go +++ b/x/params/types/keys.go @@ -3,7 +3,4 @@ package types const ( // ModuleName defines the module name ModuleName = "params" - - // QuerierRoute defines the module's query routing key - QuerierRoute = ModuleName ) diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index e9ece2c690a1..72b1dc14ec47 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -4,6 +4,7 @@ import ( "errors" "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -12,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/slashing/types" @@ -64,13 +66,13 @@ func TestSlashingMsgs(t *testing.T) { commission := stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) createValidatorMsg, err := stakingtypes.NewMsgCreateValidator( - sdk.ValAddress(addr1), valKey.PubKey(), bondCoin, description, commission, sdk.OneInt(), + sdk.ValAddress(addr1), valKey.PubKey(), bondCoin, description, commission, math.OneInt(), ) require.NoError(t, err) header := tmproto.Header{Height: app.LastBlockHeight() + 1} - txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) + txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig + _, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) require.NoError(t, err) simapp.CheckBalance(t, app, addr1, sdk.Coins{genCoin.Sub(bondCoin)}) @@ -80,14 +82,14 @@ func TestSlashingMsgs(t *testing.T) { validator := checkValidator(t, app, addr1, true) require.Equal(t, sdk.ValAddress(addr1).String(), validator.OperatorAddress) require.Equal(t, stakingtypes.Bonded, validator.Status) - require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens())) + require.True(math.IntEq(t, bondTokens, validator.BondedTokens())) unjailMsg := &types.MsgUnjail{ValidatorAddr: sdk.ValAddress(addr1).String()} checkValidatorSigningInfo(t, app, sdk.ConsAddress(valAddr), true) // unjail should fail with unknown validator header = tmproto.Header{Height: app.LastBlockHeight() + 1} - _, res, err := simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{unjailMsg}, "", []uint64{0}, []uint64{1}, false, false, priv1) + _, res, err := simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{unjailMsg}, "", []uint64{0}, []uint64{1}, false, false, priv1) require.Error(t, err) require.Nil(t, res) require.True(t, errors.Is(types.ErrValidatorNotJailed, err)) diff --git a/x/slashing/client/testutil/cli_test.go b/x/slashing/client/testutil/cli_test.go deleted file mode 100644 index 64cd56ab94e8..000000000000 --- a/x/slashing/client/testutil/cli_test.go +++ /dev/null @@ -1,21 +0,0 @@ -//go:build norace -// +build norace - -package testutil - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/testutil/network" - "github.com/cosmos/cosmos-sdk/x/slashing/testutil" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg, err := network.DefaultConfigWithAppConfig(testutil.AppConfig) - require.NoError(t, err) - cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/slashing/module.go b/x/slashing/module.go index d554ff32e8c6..e0e5de62e324 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -128,23 +128,6 @@ func (AppModule) Name() string { // RegisterInvariants registers the slashing module invariants. func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the slashing module. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the slashing module's querier route name. -func (AppModule) QuerierRoute() string { - return types.QuerierRoute -} - -// LegacyQuerierHandler returns the slashing module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) { - return nil, fmt.Errorf("legacy querier not supported for the x/%s module", types.ModuleName) - } -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) diff --git a/x/slashing/spec/06_events.md b/x/slashing/spec/06_events.md index c7dbf5723efa..e171023ddc10 100644 --- a/x/slashing/spec/06_events.md +++ b/x/slashing/spec/06_events.md @@ -25,7 +25,7 @@ The slashing module emits the following events: | slash | power | {validatorPower} | | slash | reason | {slashReason} | | slash | jailed [0] | {validatorConsensusAddress} | -| slash | burned coins | {sdk.Int} | +| slash | burned coins | {math.Int} | * [0] Only included if the validator is jailed. diff --git a/x/slashing/testutil/app.yaml b/x/slashing/testutil/app.yaml deleted file mode 100644 index 723977c85608..000000000000 --- a/x/slashing/testutil/app.yaml +++ /dev/null @@ -1,59 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: SlashingApp - - begin_blockers: - [mint, distribution, staking, auth, bank, genutil, slashing, params] - end_blockers: - [staking, auth, bank, genutil, distribution, mint, slashing, params] - init_genesis: - [auth, bank, distribution, staking, mint, slashing, genutil, params] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: distribution - - account: mint - permissions: [minter] - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: slashing - config: - "@type": cosmos.slashing.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: mint - config: - "@type": cosmos.mint.module.v1.Module - - - name: distribution - config: - "@type": cosmos.distribution.module.v1.Module diff --git a/x/slashing/testutil/app_config.go b/x/slashing/testutil/app_config.go index 9a9069894d32..9b88072054f6 100644 --- a/x/slashing/testutil/app_config.go +++ b/x/slashing/testutil/app_config.go @@ -1,9 +1,6 @@ package testutil import ( - _ "embed" - - "cosmossdk.io/core/appconfig" _ "github.com/cosmos/cosmos-sdk/x/auth" _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" _ "github.com/cosmos/cosmos-sdk/x/bank" @@ -13,9 +10,113 @@ import ( _ "github.com/cosmos/cosmos-sdk/x/params" _ "github.com/cosmos/cosmos-sdk/x/slashing" _ "github.com/cosmos/cosmos-sdk/x/staking" + + "cosmossdk.io/core/appconfig" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" + appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" + authmodulev1 "cosmossdk.io/api/cosmos/auth/module/v1" + bankmodulev1 "cosmossdk.io/api/cosmos/bank/module/v1" + distrmodulev1 "cosmossdk.io/api/cosmos/distribution/module/v1" + genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1" + mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1" + paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1" + slashingmodulev1 "cosmossdk.io/api/cosmos/slashing/module/v1" + stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1" + txmodulev1 "cosmossdk.io/api/cosmos/tx/module/v1" ) -//go:embed app.yaml -var appConfig []byte +var AppConfig = appconfig.Compose(&appv1alpha1.Config{ + Modules: []*appv1alpha1.ModuleConfig{ + { + Name: "runtime", + Config: appconfig.WrapAny(&runtimev1alpha1.Module{ + AppName: "SlashingApp", + BeginBlockers: []string{ + minttypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + slashingtypes.ModuleName, + paramstypes.ModuleName, + }, + EndBlockers: []string{ + stakingtypes.ModuleName, + authtypes.ModuleName, + banktypes.ModuleName, + genutiltypes.ModuleName, + distrtypes.ModuleName, + minttypes.ModuleName, + slashingtypes.ModuleName, + paramstypes.ModuleName, + }, + InitGenesis: []string{ + authtypes.ModuleName, + banktypes.ModuleName, + distrtypes.ModuleName, + stakingtypes.ModuleName, + minttypes.ModuleName, + slashingtypes.ModuleName, + genutiltypes.ModuleName, + paramstypes.ModuleName, + }, + }), + }, + { + Name: authtypes.ModuleName, + Config: appconfig.WrapAny(&authmodulev1.Module{ + Bech32Prefix: "cosmos", + ModuleAccountPermissions: []*authmodulev1.ModuleAccountPermission{ + {Account: authtypes.FeeCollectorName}, + {Account: distrtypes.ModuleName}, + {Account: minttypes.ModuleName, Permissions: []string{authtypes.Minter}}, + {Account: stakingtypes.BondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + {Account: stakingtypes.NotBondedPoolName, Permissions: []string{authtypes.Burner, stakingtypes.ModuleName}}, + }, + }), + }, -var AppConfig = appconfig.LoadYAML(appConfig) + { + Name: banktypes.ModuleName, + Config: appconfig.WrapAny(&bankmodulev1.Module{}), + }, + { + Name: stakingtypes.ModuleName, + Config: appconfig.WrapAny(&stakingmodulev1.Module{}), + }, + { + Name: slashingtypes.ModuleName, + Config: appconfig.WrapAny(&slashingmodulev1.Module{}), + }, + { + Name: paramstypes.ModuleName, + Config: appconfig.WrapAny(¶msmodulev1.Module{}), + }, + { + Name: "tx", + Config: appconfig.WrapAny(&txmodulev1.Module{}), + }, + { + Name: genutiltypes.ModuleName, + Config: appconfig.WrapAny(&genutilmodulev1.Module{}), + }, + { + Name: minttypes.ModuleName, + Config: appconfig.WrapAny(&mintmodulev1.Module{}), + }, + { + Name: distrtypes.ModuleName, + Config: appconfig.WrapAny(&distrmodulev1.Module{}), + }, + }, +}) diff --git a/x/slashing/types/keys.go b/x/slashing/types/keys.go index bf4c1bc75852..02a86e167e28 100644 --- a/x/slashing/types/keys.go +++ b/x/slashing/types/keys.go @@ -17,9 +17,6 @@ const ( // RouterKey is the message route for slashing RouterKey = ModuleName - - // QuerierRoute is the querier route for slashing - QuerierRoute = ModuleName ) // Keys for slashing store diff --git a/x/slashing/types/params_legacy.go b/x/slashing/types/params_legacy.go index 15bb92159596..bd97023f6a47 100644 --- a/x/slashing/types/params_legacy.go +++ b/x/slashing/types/params_legacy.go @@ -20,14 +20,14 @@ var ( // ParamKeyTable for slashing module // -// NOTE: Deprecated. +// Deprecated. func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } // ParamSetPairs - Implements params.ParamSet // -// NOTE: Deprecated. +// Deprecated. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeySignedBlocksWindow, &p.SignedBlocksWindow, validateSignedBlocksWindow), diff --git a/x/staking/app_test.go b/x/staking/app_test.go index 5a3bd723cb9c..f7f43d8d1a46 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -3,12 +3,14 @@ package staking_test import ( "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -65,13 +67,13 @@ func TestStakingMsgs(t *testing.T) { // create validator description := types.NewDescription("foo_moniker", "", "", "", "") createValidatorMsg, err := types.NewMsgCreateValidator( - sdk.ValAddress(addr1), valKey.PubKey(), bondCoin, description, commissionRates, sdk.OneInt(), + sdk.ValAddress(addr1), valKey.PubKey(), bondCoin, description, commissionRates, math.OneInt(), ) require.NoError(t, err) header := tmproto.Header{Height: app.LastBlockHeight() + 1} - txGen := simapp.MakeTestEncodingConfig().TxConfig - _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) + txConfig := moduletestutil.MakeTestEncodingConfig().TxConfig + _, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{createValidatorMsg}, "", []uint64{0}, []uint64{0}, true, true, priv1) require.NoError(t, err) simapp.CheckBalance(t, app, addr1, sdk.Coins{genCoin.Sub(bondCoin)}) @@ -81,7 +83,7 @@ func TestStakingMsgs(t *testing.T) { validator := checkValidator(t, app, sdk.ValAddress(addr1), true) require.Equal(t, sdk.ValAddress(addr1).String(), validator.OperatorAddress) require.Equal(t, types.Bonded, validator.Status) - require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens())) + require.True(math.IntEq(t, bondTokens, validator.BondedTokens())) header = tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) @@ -91,7 +93,7 @@ func TestStakingMsgs(t *testing.T) { editValidatorMsg := types.NewMsgEditValidator(sdk.ValAddress(addr1), description, nil, nil) header = tmproto.Header{Height: app.LastBlockHeight() + 1} - _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{editValidatorMsg}, "", []uint64{0}, []uint64{1}, true, true, priv1) + _, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{editValidatorMsg}, "", []uint64{0}, []uint64{1}, true, true, priv1) require.NoError(t, err) validator = checkValidator(t, app, sdk.ValAddress(addr1), true) @@ -102,7 +104,7 @@ func TestStakingMsgs(t *testing.T) { delegateMsg := types.NewMsgDelegate(addr2, sdk.ValAddress(addr1), bondCoin) header = tmproto.Header{Height: app.LastBlockHeight() + 1} - _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{delegateMsg}, "", []uint64{1}, []uint64{0}, true, true, priv2) + _, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{delegateMsg}, "", []uint64{1}, []uint64{0}, true, true, priv2) require.NoError(t, err) simapp.CheckBalance(t, app, addr2, sdk.Coins{genCoin.Sub(bondCoin)}) @@ -111,7 +113,7 @@ func TestStakingMsgs(t *testing.T) { // begin unbonding beginUnbondingMsg := types.NewMsgUndelegate(addr2, sdk.ValAddress(addr1), bondCoin) header = tmproto.Header{Height: app.LastBlockHeight() + 1} - _, _, err = simapp.SignCheckDeliver(t, txGen, app.BaseApp, header, []sdk.Msg{beginUnbondingMsg}, "", []uint64{1}, []uint64{1}, true, true, priv2) + _, _, err = simapp.SignCheckDeliver(t, txConfig, app.BaseApp, header, []sdk.Msg{beginUnbondingMsg}, "", []uint64{1}, []uint64{1}, true, true, priv2) require.NoError(t, err) // delegation should exist anymore diff --git a/x/staking/common_test.go b/x/staking/common_test.go index bfd50af422cf..4286a5d510e3 100644 --- a/x/staking/common_test.go +++ b/x/staking/common_test.go @@ -1,11 +1,13 @@ package staking_test import ( - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "math/big" "testing" + "cosmossdk.io/math" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" @@ -58,7 +60,7 @@ func getBaseSimappWithCustomKeeper(t *testing.T) (*codec.LegacyAmino, *simapp.Si } // generateAddresses generates numAddrs of normal AccAddrs and ValAddrs -func generateAddresses(app *simapp.SimApp, ctx sdk.Context, numAddrs int, accAmount sdk.Int) ([]sdk.AccAddress, []sdk.ValAddress) { +func generateAddresses(app *simapp.SimApp, ctx sdk.Context, numAddrs int, accAmount math.Int) ([]sdk.AccAddress, []sdk.ValAddress) { addrDels := simapp.AddTestAddrsIncremental(app, ctx, numAddrs, accAmount) addrVals := simtestutil.ConvertAddrsToValAddrs(addrDels) diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index 6f4a8ad8bda0..2a1cfa637b8f 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -3,6 +3,7 @@ package staking_test import ( "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/assert" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -16,7 +17,7 @@ func TestValidateGenesis(t *testing.T) { genValidators1 := make([]types.Validator, 1, 5) pk := ed25519.GenPrivKey().PubKey() genValidators1[0] = teststaking.NewValidator(t, sdk.ValAddress(pk.Address()), pk) - genValidators1[0].Tokens = sdk.OneInt() + genValidators1[0].Tokens = math.OneInt() genValidators1[0].DelegatorShares = sdk.OneDec() tests := []struct { diff --git a/x/staking/keeper/common_test.go b/x/staking/keeper/common_test.go index ff11199d39f2..bd99456b62db 100644 --- a/x/staking/keeper/common_test.go +++ b/x/staking/keeper/common_test.go @@ -1,18 +1,21 @@ package keeper_test import ( - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "math/big" "testing" + "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/teststaking" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -50,3 +53,38 @@ func generateAddresses(app *simapp.SimApp, ctx sdk.Context, numAddrs int) ([]sdk return addrDels, addrVals } + +func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []types.Validator) { + addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, app.StakingKeeper.TokensFromConsensusPower(ctx, 300)) + valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs) + pks := simtestutil.CreateTestPubKeys(5) + cdc := moduletestutil.MakeTestEncodingConfig().Codec + app.StakingKeeper = keeper.NewKeeper( + cdc, + app.GetKey(types.StoreKey), + app.AccountKeeper, + app.BankKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + val1 := teststaking.NewValidator(t, valAddrs[0], pks[0]) + val2 := teststaking.NewValidator(t, valAddrs[1], pks[1]) + vals := []types.Validator{val1, val2} + + app.StakingKeeper.SetValidator(ctx, val1) + app.StakingKeeper.SetValidator(ctx, val2) + app.StakingKeeper.SetValidatorByConsAddr(ctx, val1) + app.StakingKeeper.SetValidatorByConsAddr(ctx, val2) + app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val1) + app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val2) + + _, err := app.StakingKeeper.Delegate(ctx, addrs[0], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[0]), types.Unbonded, val1, true) + require.NoError(t, err) + _, err = app.StakingKeeper.Delegate(ctx, addrs[1], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[1]), types.Unbonded, val2, true) + require.NoError(t, err) + _, err = app.StakingKeeper.Delegate(ctx, addrs[0], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[2]), types.Unbonded, val2, true) + require.NoError(t, err) + applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) + + return addrs, valAddrs, vals +} diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 2c6de7a59d66..376e0ac9122c 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -183,7 +183,7 @@ func (k Keeper) IterateUnbondingDelegations(ctx sdk.Context, fn func(index int64 // GetDelegatorUnbonding returns the total amount a delegator has unbonding. func (k Keeper) GetDelegatorUnbonding(ctx sdk.Context, delegator sdk.AccAddress) math.Int { - unbonding := sdk.ZeroInt() + unbonding := math.ZeroInt() k.IterateDelegatorUnbondingDelegations(ctx, delegator, func(ubd types.UnbondingDelegation) bool { for _, entry := range ubd.Entries { unbonding = unbonding.Add(entry.Balance) diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index a8ff9ed54d75..a2fc05c1619f 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "cosmossdk.io/math" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -33,7 +34,7 @@ func TestDelegation(t *testing.T) { valAddrs := simtestutil.ConvertAddrsToValAddrs(addrDels) // construct the validators - amts := []sdk.Int{sdk.NewInt(9), sdk.NewInt(8), sdk.NewInt(7)} + amts := []math.Int{sdk.NewInt(9), sdk.NewInt(8), sdk.NewInt(7)} var validators [3]types.Validator for i, amt := range amts { validators[i] = teststaking.NewValidator(t, valAddrs[i], PKs[i]) @@ -257,7 +258,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { require.Equal(t, startTokens, issuedShares.RoundInt()) validator = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validator, true) - require.True(sdk.IntEq(t, startTokens, validator.BondedTokens())) + require.True(math.IntEq(t, startTokens, validator.BondedTokens())) require.True(t, validator.IsBonded()) delegation := types.NewDelegation(addrDels[0], addrVals[0], issuedShares) @@ -278,8 +279,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded := app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded := app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, newBonded, oldBonded.SubRaw(int64(maxEntries)))) - require.True(sdk.IntEq(t, newNotBonded, oldNotBonded.AddRaw(int64(maxEntries)))) + require.True(math.IntEq(t, newBonded, oldBonded.SubRaw(int64(maxEntries)))) + require.True(math.IntEq(t, newNotBonded, oldNotBonded.AddRaw(int64(maxEntries)))) oldBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount oldNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount @@ -291,8 +292,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, newBonded, oldBonded)) - require.True(sdk.IntEq(t, newNotBonded, oldNotBonded)) + require.True(math.IntEq(t, newBonded, oldBonded)) + require.True(math.IntEq(t, newNotBonded, oldNotBonded)) // mature unbonding delegations ctx = ctx.WithBlockTime(completionTime) @@ -301,8 +302,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, newBonded, oldBonded)) - require.True(sdk.IntEq(t, newNotBonded, oldNotBonded.SubRaw(int64(maxEntries)))) + require.True(math.IntEq(t, newBonded, oldBonded)) + require.True(math.IntEq(t, newNotBonded, oldNotBonded.SubRaw(int64(maxEntries)))) oldNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount @@ -312,8 +313,8 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { newBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetBondedPool(ctx).GetAddress(), bondDenom).Amount newNotBonded = app.BankKeeper.GetBalance(ctx, app.StakingKeeper.GetNotBondedPool(ctx).GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, newBonded, oldBonded.SubRaw(1))) - require.True(sdk.IntEq(t, newNotBonded, oldNotBonded.AddRaw(1))) + require.True(math.IntEq(t, newBonded, oldBonded.SubRaw(1))) + require.True(math.IntEq(t, newNotBonded, oldNotBonded.AddRaw(1))) } //// test undelegating self delegation from a validator pushing it below MinSelfDelegation diff --git a/x/staking/keeper/genesis.go b/x/staking/keeper/genesis.go index 7a8a374374d0..908151c1d762 100644 --- a/x/staking/keeper/genesis.go +++ b/x/staking/keeper/genesis.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + "cosmossdk.io/math" abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,8 +16,8 @@ import ( // data. Finally, it updates the bonded validators. // Returns final validator set after applying all declaration and delegations func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []abci.ValidatorUpdate) { - bondedTokens := sdk.ZeroInt() - notBondedTokens := sdk.ZeroInt() + bondedTokens := math.ZeroInt() + notBondedTokens := math.ZeroInt() // We need to pretend to be "n blocks before genesis", where "n" is the // validator update delay, so that e.g. slashing periods are correctly diff --git a/x/staking/keeper/genesis_test.go b/x/staking/keeper/genesis_test.go index 908e301decfa..da97f8fa2e10 100644 --- a/x/staking/keeper/genesis_test.go +++ b/x/staking/keeper/genesis_test.go @@ -4,6 +4,7 @@ import ( "fmt" "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -171,7 +172,7 @@ func TestInitGenesisLargeValidatorSet(t *testing.T) { var err error - bondedPoolAmt := sdk.ZeroInt() + bondedPoolAmt := math.ZeroInt() for i := range validators { validators[i], err = types.NewValidator( sdk.ValAddress(addrs[i]), diff --git a/x/staking/keeper/grpc_query.go b/x/staking/keeper/grpc_query.go index ecb2802b7737..1389d7c05c92 100644 --- a/x/staking/keeper/grpc_query.go +++ b/x/staking/keeper/grpc_query.go @@ -532,3 +532,81 @@ func queryAllRedelegations(store sdk.KVStore, k Querier, req *types.QueryRedeleg return redels, res, err } + +// util + +func DelegationToDelegationResponse(ctx sdk.Context, k *Keeper, del types.Delegation) (types.DelegationResponse, error) { + val, found := k.GetValidator(ctx, del.GetValidatorAddr()) + if !found { + return types.DelegationResponse{}, types.ErrNoValidatorFound + } + + delegatorAddress, err := sdk.AccAddressFromBech32(del.DelegatorAddress) + if err != nil { + return types.DelegationResponse{}, err + } + + return types.NewDelegationResp( + delegatorAddress, + del.GetValidatorAddr(), + del.Shares, + sdk.NewCoin(k.BondDenom(ctx), val.TokensFromShares(del.Shares).TruncateInt()), + ), nil +} + +func DelegationsToDelegationResponses(ctx sdk.Context, k *Keeper, delegations types.Delegations) (types.DelegationResponses, error) { + resp := make(types.DelegationResponses, len(delegations)) + + for i, del := range delegations { + delResp, err := DelegationToDelegationResponse(ctx, k, del) + if err != nil { + return nil, err + } + + resp[i] = delResp + } + + return resp, nil +} + +func RedelegationsToRedelegationResponses(ctx sdk.Context, k *Keeper, redels types.Redelegations) (types.RedelegationResponses, error) { + resp := make(types.RedelegationResponses, len(redels)) + + for i, redel := range redels { + valSrcAddr, err := sdk.ValAddressFromBech32(redel.ValidatorSrcAddress) + if err != nil { + panic(err) + } + valDstAddr, err := sdk.ValAddressFromBech32(redel.ValidatorDstAddress) + if err != nil { + panic(err) + } + + delegatorAddress := sdk.MustAccAddressFromBech32(redel.DelegatorAddress) + + val, found := k.GetValidator(ctx, valDstAddr) + if !found { + return nil, types.ErrNoValidatorFound + } + + entryResponses := make([]types.RedelegationEntryResponse, len(redel.Entries)) + for j, entry := range redel.Entries { + entryResponses[j] = types.NewRedelegationEntryResponse( + entry.CreationHeight, + entry.CompletionTime, + entry.SharesDst, + entry.InitialBalance, + val.TokensFromShares(entry.SharesDst).TruncateInt(), + ) + } + + resp[i] = types.NewRedelegationResponse( + delegatorAddress, + valSrcAddr, + valDstAddr, + entryResponses, + ) + } + + return resp, nil +} diff --git a/x/staking/keeper/grpc_query_test.go b/x/staking/keeper/grpc_query_test.go index c746d0991693..6217fa0c8202 100644 --- a/x/staking/keeper/grpc_query_test.go +++ b/x/staking/keeper/grpc_query_test.go @@ -3,18 +3,10 @@ package keeper_test import ( gocontext "context" "fmt" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "testing" - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/simapp" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" - "github.com/cosmos/cosmos-sdk/x/staking/keeper" - "github.com/cosmos/cosmos-sdk/x/staking/teststaking" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -787,38 +779,3 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidatorUnbondingDelegations() { }) } } - -func createValidators(t *testing.T, ctx sdk.Context, app *simapp.SimApp, powers []int64) ([]sdk.AccAddress, []sdk.ValAddress, []types.Validator) { - addrs := simapp.AddTestAddrsIncremental(app, ctx, 5, app.StakingKeeper.TokensFromConsensusPower(ctx, 300)) - valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs) - pks := simtestutil.CreateTestPubKeys(5) - cdc := simapp.MakeTestEncodingConfig().Codec - app.StakingKeeper = keeper.NewKeeper( - cdc, - app.GetKey(types.StoreKey), - app.AccountKeeper, - app.BankKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - val1 := teststaking.NewValidator(t, valAddrs[0], pks[0]) - val2 := teststaking.NewValidator(t, valAddrs[1], pks[1]) - vals := []types.Validator{val1, val2} - - app.StakingKeeper.SetValidator(ctx, val1) - app.StakingKeeper.SetValidator(ctx, val2) - app.StakingKeeper.SetValidatorByConsAddr(ctx, val1) - app.StakingKeeper.SetValidatorByConsAddr(ctx, val2) - app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val1) - app.StakingKeeper.SetNewValidatorByPowerIndex(ctx, val2) - - _, err := app.StakingKeeper.Delegate(ctx, addrs[0], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[0]), types.Unbonded, val1, true) - require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, addrs[1], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[1]), types.Unbonded, val2, true) - require.NoError(t, err) - _, err = app.StakingKeeper.Delegate(ctx, addrs[0], app.StakingKeeper.TokensFromConsensusPower(ctx, powers[2]), types.Unbonded, val2, true) - require.NoError(t, err) - applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) - - return addrs, valAddrs, vals -} diff --git a/x/staking/keeper/historical_info_test.go b/x/staking/keeper/historical_info_test.go index 91cc506a324f..c1a5f35252a0 100644 --- a/x/staking/keeper/historical_info_test.go +++ b/x/staking/keeper/historical_info_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -14,7 +15,7 @@ import ( ) // IsValSetSorted reports whether valset is sorted. -func IsValSetSorted(data []types.Validator, powerReduction sdk.Int) bool { +func IsValSetSorted(data []types.Validator, powerReduction math.Int) bool { n := len(data) for i := n - 1; i > 0; i-- { if types.ValidatorsByVotingPower(data).Less(i, i-1, powerReduction) { diff --git a/x/staking/keeper/invariants.go b/x/staking/keeper/invariants.go index 0ac37e069f60..19668b86615f 100644 --- a/x/staking/keeper/invariants.go +++ b/x/staking/keeper/invariants.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" + "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -46,8 +47,8 @@ func AllInvariants(k *Keeper) sdk.Invariant { // reflects the tokens actively bonded and not bonded func ModuleAccountInvariants(k *Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { - bonded := sdk.ZeroInt() - notBonded := sdk.ZeroInt() + bonded := math.ZeroInt() + notBonded := math.ZeroInt() bondedPool := k.GetBondedPool(ctx) notBondedPool := k.GetNotBondedPool(ctx) bondDenom := k.BondDenom(ctx) diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index e37772c0165b..975ee64f9a1b 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -1,9 +1,10 @@ package keeper import ( - "cosmossdk.io/math" "fmt" + "cosmossdk.io/math" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/tendermint/tendermint/libs/log" @@ -47,7 +48,7 @@ func NewKeeper( // ensure that authority is a valid AccAddress if _, err := sdk.AccAddressFromBech32(authority); err != nil { - panic(fmt.Sprintf("authority is not a valid acc address")) + panic(("authority is not a valid acc address")) } return &Keeper{ @@ -80,7 +81,7 @@ func (k Keeper) GetLastTotalPower(ctx sdk.Context) math.Int { bz := store.Get(types.LastTotalPowerKey) if bz == nil { - return sdk.ZeroInt() + return math.ZeroInt() } ip := sdk.IntProto{} diff --git a/x/staking/keeper/migrations.go b/x/staking/keeper/migrations.go index 5e2ff5401d16..b34a7993bfc7 100644 --- a/x/staking/keeper/migrations.go +++ b/x/staking/keeper/migrations.go @@ -3,8 +3,8 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/exported" - "github.com/cosmos/cosmos-sdk/x/staking/migrations/v2" - "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3" + v2 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v2" + v3 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3" v4 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v4" ) diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index c5d609cf3db0..37ee9c3e89d7 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -2,10 +2,11 @@ package keeper import ( "context" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "strconv" "time" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "google.golang.org/grpc/codes" "google.golang.org/grpc/status" diff --git a/x/staking/keeper/querier.go b/x/staking/keeper/querier.go deleted file mode 100644 index 71e778c9b0fd..000000000000 --- a/x/staking/keeper/querier.go +++ /dev/null @@ -1,522 +0,0 @@ -package keeper - -import ( - "errors" - "strings" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/staking/types" -) - -// creates a querier for staking REST endpoints -func NewQuerier(k *Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - switch path[0] { - case types.QueryValidators: - return queryValidators(ctx, req, k, legacyQuerierCdc) - - case types.QueryValidator: - return queryValidator(ctx, req, k, legacyQuerierCdc) - - case types.QueryValidatorDelegations: - return queryValidatorDelegations(ctx, req, k, legacyQuerierCdc) - - case types.QueryValidatorUnbondingDelegations: - return queryValidatorUnbondingDelegations(ctx, req, k, legacyQuerierCdc) - - case types.QueryDelegation: - return queryDelegation(ctx, req, k, legacyQuerierCdc) - - case types.QueryUnbondingDelegation: - return queryUnbondingDelegation(ctx, req, k, legacyQuerierCdc) - - case types.QueryDelegatorDelegations: - return queryDelegatorDelegations(ctx, req, k, legacyQuerierCdc) - - case types.QueryDelegatorUnbondingDelegations: - return queryDelegatorUnbondingDelegations(ctx, req, k, legacyQuerierCdc) - - case types.QueryRedelegations: - return queryRedelegations(ctx, req, k, legacyQuerierCdc) - - case types.QueryDelegatorValidators: - return queryDelegatorValidators(ctx, req, k, legacyQuerierCdc) - - case types.QueryDelegatorValidator: - return queryDelegatorValidator(ctx, req, k, legacyQuerierCdc) - - case types.QueryHistoricalInfo: - return queryHistoricalInfo(ctx, req, k, legacyQuerierCdc) - - case types.QueryPool: - return queryPool(ctx, k, legacyQuerierCdc) - - case types.QueryParameters: - return queryParameters(ctx, k, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0]) - } - } -} - -func queryValidators(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryValidatorsParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - validators := k.GetAllValidators(ctx) - filteredVals := make(types.Validators, 0, len(validators)) - - for _, val := range validators { - if strings.EqualFold(val.GetStatus().String(), params.Status) { - filteredVals = append(filteredVals, val) - } - } - - start, end := client.Paginate(len(filteredVals), params.Page, params.Limit, int(k.GetParams(ctx).MaxValidators)) - if start < 0 || end < 0 { - filteredVals = []types.Validator{} - } else { - filteredVals = filteredVals[start:end] - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, filteredVals) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryValidator(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryValidatorParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - validator, found := k.GetValidator(ctx, params.ValidatorAddr) - if !found { - return nil, types.ErrNoValidatorFound - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, validator) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryValidatorDelegations(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryValidatorParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - delegations := k.GetValidatorDelegations(ctx, params.ValidatorAddr) - - start, end := client.Paginate(len(delegations), params.Page, params.Limit, int(k.GetParams(ctx).MaxValidators)) - if start < 0 || end < 0 { - delegations = []types.Delegation{} - } else { - delegations = delegations[start:end] - } - - delegationResps, err := DelegationsToDelegationResponses(ctx, k, delegations) - if err != nil { - return nil, err - } - - if delegationResps == nil { - delegationResps = types.DelegationResponses{} - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, delegationResps) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryValidatorUnbondingDelegations(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryValidatorParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - unbonds := k.GetUnbondingDelegationsFromValidator(ctx, params.ValidatorAddr) - if unbonds == nil { - unbonds = types.UnbondingDelegations{} - } - - start, end := client.Paginate(len(unbonds), params.Page, params.Limit, int(k.GetParams(ctx).MaxValidators)) - if start < 0 || end < 0 { - unbonds = types.UnbondingDelegations{} - } else { - unbonds = unbonds[start:end] - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, unbonds) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryDelegatorDelegations(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegatorParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - delegations := k.GetAllDelegatorDelegations(ctx, params.DelegatorAddr) - delegationResps, err := DelegationsToDelegationResponses(ctx, k, delegations) - if err != nil { - return nil, err - } - - if delegationResps == nil { - delegationResps = types.DelegationResponses{} - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, delegationResps) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryDelegatorUnbondingDelegations(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegatorParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - unbondingDelegations := k.GetAllUnbondingDelegations(ctx, params.DelegatorAddr) - if unbondingDelegations == nil { - unbondingDelegations = types.UnbondingDelegations{} - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, unbondingDelegations) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryDelegatorValidators(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegatorParams - - stakingParams := k.GetParams(ctx) - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - validators := k.GetDelegatorValidators(ctx, params.DelegatorAddr, stakingParams.MaxValidators) - if validators == nil { - validators = types.Validators{} - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, validators) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryDelegatorValidator(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegatorValidatorRequest - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - delAddr, err := sdk.AccAddressFromBech32(params.DelegatorAddr) - if err != nil { - return nil, err - } - - valAddr, err := sdk.ValAddressFromBech32(params.ValidatorAddr) - if err != nil { - return nil, err - } - - validator, err := k.GetDelegatorValidator(ctx, delAddr, valAddr) - if err != nil { - return nil, err - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, validator) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryDelegation(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegatorValidatorRequest - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - delAddr, err := sdk.AccAddressFromBech32(params.DelegatorAddr) - if err != nil { - return nil, err - } - - valAddr, err := sdk.ValAddressFromBech32(params.ValidatorAddr) - if err != nil { - return nil, err - } - - delegation, found := k.GetDelegation(ctx, delAddr, valAddr) - if !found { - return nil, types.ErrNoDelegation - } - - delegationResp, err := DelegationToDelegationResponse(ctx, k, delegation) - if err != nil { - return nil, err - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, delegationResp) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryUnbondingDelegation(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDelegatorValidatorRequest - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - delAddr, err := sdk.AccAddressFromBech32(params.DelegatorAddr) - if err != nil { - return nil, err - } - - valAddr, err := sdk.ValAddressFromBech32(params.ValidatorAddr) - if err != nil { - return nil, err - } - - unbond, found := k.GetUnbondingDelegation(ctx, delAddr, valAddr) - if !found { - return nil, types.ErrNoUnbondingDelegation - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, unbond) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryRedelegations(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryRedelegationParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - var redels []types.Redelegation - - switch { - case !params.DelegatorAddr.Empty() && !params.SrcValidatorAddr.Empty() && !params.DstValidatorAddr.Empty(): - redel, found := k.GetRedelegation(ctx, params.DelegatorAddr, params.SrcValidatorAddr, params.DstValidatorAddr) - if !found { - return nil, types.ErrNoRedelegation - } - - redels = []types.Redelegation{redel} - case params.DelegatorAddr.Empty() && !params.SrcValidatorAddr.Empty() && params.DstValidatorAddr.Empty(): - redels = k.GetRedelegationsFromSrcValidator(ctx, params.SrcValidatorAddr) - default: - redels = k.GetAllRedelegations(ctx, params.DelegatorAddr, params.SrcValidatorAddr, params.DstValidatorAddr) - } - - redelResponses, err := RedelegationsToRedelegationResponses(ctx, k, redels) - if err != nil { - return nil, err - } - - if redelResponses == nil { - redelResponses = types.RedelegationResponses{} - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, redelResponses) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryHistoricalInfo(ctx sdk.Context, req abci.RequestQuery, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryHistoricalInfoRequest - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - hi, found := k.GetHistoricalInfo(ctx, params.Height) - if !found { - return nil, types.ErrNoHistoricalInfo - } - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, hi) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryPool(ctx sdk.Context, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - bondDenom := k.BondDenom(ctx) - bondedPool := k.GetBondedPool(ctx) - notBondedPool := k.GetNotBondedPool(ctx) - - if bondedPool == nil || notBondedPool == nil { - return nil, errors.New("pool accounts haven't been set") - } - - pool := types.NewPool( - k.bankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount, - k.bankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount, - ) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, pool) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryParameters(ctx sdk.Context, k *Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - params := k.GetParams(ctx) - - res, err := codec.MarshalJSONIndent(legacyQuerierCdc, params) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -// util - -func DelegationToDelegationResponse(ctx sdk.Context, k *Keeper, del types.Delegation) (types.DelegationResponse, error) { - val, found := k.GetValidator(ctx, del.GetValidatorAddr()) - if !found { - return types.DelegationResponse{}, types.ErrNoValidatorFound - } - - delegatorAddress, err := sdk.AccAddressFromBech32(del.DelegatorAddress) - if err != nil { - return types.DelegationResponse{}, err - } - - return types.NewDelegationResp( - delegatorAddress, - del.GetValidatorAddr(), - del.Shares, - sdk.NewCoin(k.BondDenom(ctx), val.TokensFromShares(del.Shares).TruncateInt()), - ), nil -} - -func DelegationsToDelegationResponses(ctx sdk.Context, k *Keeper, delegations types.Delegations) (types.DelegationResponses, error) { - resp := make(types.DelegationResponses, len(delegations)) - - for i, del := range delegations { - delResp, err := DelegationToDelegationResponse(ctx, k, del) - if err != nil { - return nil, err - } - - resp[i] = delResp - } - - return resp, nil -} - -func RedelegationsToRedelegationResponses(ctx sdk.Context, k *Keeper, redels types.Redelegations) (types.RedelegationResponses, error) { - resp := make(types.RedelegationResponses, len(redels)) - - for i, redel := range redels { - valSrcAddr, err := sdk.ValAddressFromBech32(redel.ValidatorSrcAddress) - if err != nil { - panic(err) - } - valDstAddr, err := sdk.ValAddressFromBech32(redel.ValidatorDstAddress) - if err != nil { - panic(err) - } - - delegatorAddress := sdk.MustAccAddressFromBech32(redel.DelegatorAddress) - - val, found := k.GetValidator(ctx, valDstAddr) - if !found { - return nil, types.ErrNoValidatorFound - } - - entryResponses := make([]types.RedelegationEntryResponse, len(redel.Entries)) - for j, entry := range redel.Entries { - entryResponses[j] = types.NewRedelegationEntryResponse( - entry.CreationHeight, - entry.CompletionTime, - entry.SharesDst, - entry.InitialBalance, - val.TokensFromShares(entry.SharesDst).TruncateInt(), - ) - } - - resp[i] = types.NewRedelegationResponse( - delegatorAddress, - valSrcAddr, - valDstAddr, - entryResponses, - ) - } - - return resp, nil -} diff --git a/x/staking/keeper/querier_test.go b/x/staking/keeper/querier_test.go deleted file mode 100644 index b938efdd6344..000000000000 --- a/x/staking/keeper/querier_test.go +++ /dev/null @@ -1,754 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/simapp" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/staking/keeper" - "github.com/cosmos/cosmos-sdk/x/staking/teststaking" - "github.com/cosmos/cosmos-sdk/x/staking/types" -) - -func TestNewQuerier(t *testing.T) { - cdc, app, ctx := createTestInput(t) - - addrs := simapp.AddTestAddrs(app, ctx, 500, sdk.NewInt(10000)) - _, addrAcc2 := addrs[0], addrs[1] - addrVal1, _ := sdk.ValAddress(addrs[0]), sdk.ValAddress(addrs[1]) - - // Create Validators - amts := []sdk.Int{sdk.NewInt(9), sdk.NewInt(8)} - var validators [2]types.Validator - for i, amt := range amts { - validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i]) - validators[i], _ = validators[i].AddTokensFromDel(amt) - app.StakingKeeper.SetValidator(ctx, validators[i]) - app.StakingKeeper.SetValidatorByPowerIndex(ctx, validators[i]) - } - - header := tmproto.Header{ - ChainID: "HelloChain", - Height: 5, - } - hi := types.NewHistoricalInfo(header, validators[:], app.StakingKeeper.PowerReduction(ctx)) - app.StakingKeeper.SetHistoricalInfo(ctx, 5, &hi) - - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - - legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) - querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) - - bz, err := querier(ctx, []string{"other"}, query) - require.Error(t, err) - require.Nil(t, bz) - - _, err = querier(ctx, []string{"pool"}, query) - require.NoError(t, err) - - _, err = querier(ctx, []string{"parameters"}, query) - require.NoError(t, err) - - queryValParams := types.NewQueryValidatorParams(addrVal1, 0, 0) - bz, errRes := cdc.MarshalJSON(queryValParams) - require.NoError(t, errRes) - - query.Path = "/custom/staking/validator" - query.Data = bz - - _, err = querier(ctx, []string{"validator"}, query) - require.NoError(t, err) - - _, err = querier(ctx, []string{"validatorDelegations"}, query) - require.NoError(t, err) - - _, err = querier(ctx, []string{"validatorUnbondingDelegations"}, query) - require.NoError(t, err) - - queryDelParams := types.NewQueryDelegatorParams(addrAcc2) - bz, errRes = cdc.MarshalJSON(queryDelParams) - require.NoError(t, errRes) - - query.Path = "/custom/staking/validator" - query.Data = bz - - _, err = querier(ctx, []string{"delegatorDelegations"}, query) - require.NoError(t, err) - - _, err = querier(ctx, []string{"delegatorUnbondingDelegations"}, query) - require.NoError(t, err) - - _, err = querier(ctx, []string{"delegatorValidators"}, query) - require.NoError(t, err) - - bz, errRes = cdc.MarshalJSON(types.NewQueryRedelegationParams(nil, nil, nil)) - require.NoError(t, errRes) - query.Data = bz - - _, err = querier(ctx, []string{"redelegations"}, query) - require.NoError(t, err) - - queryHisParams := types.QueryHistoricalInfoRequest{Height: 5} - bz, errRes = cdc.MarshalJSON(queryHisParams) - require.NoError(t, errRes) - - query.Path = "/custom/staking/historicalInfo" - query.Data = bz - - _, err = querier(ctx, []string{"historicalInfo"}, query) - require.NoError(t, err) -} - -func TestQueryParametersPool(t *testing.T) { - cdc, app, ctx := createTestInput(t) - legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) - querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) - - bondDenom := sdk.DefaultBondDenom - - res, err := querier(ctx, []string{types.QueryParameters}, abci.RequestQuery{}) - require.NoError(t, err) - - var params types.Params - errRes := cdc.UnmarshalJSON(res, ¶ms) - require.NoError(t, errRes) - require.Equal(t, app.StakingKeeper.GetParams(ctx), params) - - res, err = querier(ctx, []string{types.QueryPool}, abci.RequestQuery{}) - require.NoError(t, err) - - var pool types.Pool - bondedPool := app.StakingKeeper.GetBondedPool(ctx) - notBondedPool := app.StakingKeeper.GetNotBondedPool(ctx) - require.NoError(t, cdc.UnmarshalJSON(res, &pool)) - require.Equal(t, app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount, pool.NotBondedTokens) - require.Equal(t, app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount, pool.BondedTokens) -} - -func TestQueryValidators(t *testing.T) { - cdc, app, ctx := createTestInput(t) - params := app.StakingKeeper.GetParams(ctx) - legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) - querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) - - addrs := simapp.AddTestAddrs(app, ctx, 500, app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)) - - // Create Validators - amts := []sdk.Int{sdk.NewInt(8), sdk.NewInt(7)} - status := []types.BondStatus{types.Unbonded, types.Unbonding} - var validators [2]types.Validator - for i, amt := range amts { - validators[i] = teststaking.NewValidator(t, sdk.ValAddress(addrs[i]), PKs[i]) - validators[i], _ = validators[i].AddTokensFromDel(amt) - validators[i] = validators[i].UpdateStatus(status[i]) - } - - app.StakingKeeper.SetValidator(ctx, validators[0]) - app.StakingKeeper.SetValidator(ctx, validators[1]) - - // Query Validators - queriedValidators := app.StakingKeeper.GetValidators(ctx, params.MaxValidators) - require.Len(t, queriedValidators, 3) - - for i, s := range status { - queryValsParams := types.NewQueryValidatorsParams(1, int(params.MaxValidators), s.String()) - bz, err := cdc.MarshalJSON(queryValsParams) - require.NoError(t, err) - - req := abci.RequestQuery{ - Path: fmt.Sprintf("/custom/%s/%s", types.QuerierRoute, types.QueryValidators), - Data: bz, - } - - res, err := querier(ctx, []string{types.QueryValidators}, req) - require.NoError(t, err) - - var validatorsResp []types.Validator - err = cdc.UnmarshalJSON(res, &validatorsResp) - require.NoError(t, err) - - require.Equal(t, 1, len(validatorsResp)) - require.Equal(t, validators[i].OperatorAddress, validatorsResp[0].OperatorAddress) - } - - // Query each validator - for _, validator := range validators { - queryParams := types.NewQueryValidatorParams(validator.GetOperator(), 0, 0) - bz, err := cdc.MarshalJSON(queryParams) - require.NoError(t, err) - - query := abci.RequestQuery{ - Path: "/custom/staking/validator", - Data: bz, - } - res, err := querier(ctx, []string{types.QueryValidator}, query) - require.NoError(t, err) - - var queriedValidator types.Validator - err = cdc.UnmarshalJSON(res, &queriedValidator) - require.NoError(t, err) - - require.True(t, validator.Equal(&queriedValidator)) - } -} - -func TestQueryDelegation(t *testing.T) { - cdc, app, ctx := createTestInput(t) - params := app.StakingKeeper.GetParams(ctx) - legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) - querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) - - addrs := simapp.AddTestAddrs(app, ctx, 2, app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)) - addrAcc1, addrAcc2 := addrs[0], addrs[1] - addrVal1, addrVal2 := sdk.ValAddress(addrAcc1), sdk.ValAddress(addrAcc2) - - pubKeys := simtestutil.CreateTestPubKeys(2) - pk1, pk2 := pubKeys[0], pubKeys[1] - - // Create Validators and Delegation - val1 := teststaking.NewValidator(t, addrVal1, pk1) - app.StakingKeeper.SetValidator(ctx, val1) - app.StakingKeeper.SetValidatorByPowerIndex(ctx, val1) - - val2 := teststaking.NewValidator(t, addrVal2, pk2) - app.StakingKeeper.SetValidator(ctx, val2) - app.StakingKeeper.SetValidatorByPowerIndex(ctx, val2) - - delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err := app.StakingKeeper.Delegate(ctx, addrAcc2, delTokens, types.Unbonded, val1, true) - require.NoError(t, err) - - // apply TM updates - applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) - - // Query Delegator bonded validators - queryParams := types.NewQueryDelegatorParams(addrAcc2) - bz, errRes := cdc.MarshalJSON(queryParams) - require.NoError(t, errRes) - - query := abci.RequestQuery{ - Path: "/custom/staking/delegatorValidators", - Data: bz, - } - - delValidators := app.StakingKeeper.GetDelegatorValidators(ctx, addrAcc2, params.MaxValidators) - - res, err := querier(ctx, []string{types.QueryDelegatorValidators}, query) - require.NoError(t, err) - - var validatorsResp types.Validators - errRes = cdc.UnmarshalJSON(res, &validatorsResp) - require.NoError(t, errRes) - - require.Equal(t, len(delValidators), len(validatorsResp)) - require.ElementsMatch(t, delValidators, validatorsResp) - - // error unknown request - query.Data = bz[:len(bz)-1] - - _, err = querier(ctx, []string{types.QueryDelegatorValidators}, query) - require.Error(t, err) - - // Query bonded validator - queryBondParams := types.QueryDelegatorValidatorRequest{DelegatorAddr: addrAcc2.String(), ValidatorAddr: addrVal1.String()} - bz, errRes = cdc.MarshalJSON(queryBondParams) - require.NoError(t, errRes) - - query = abci.RequestQuery{ - Path: "/custom/staking/delegatorValidator", - Data: bz, - } - - res, err = querier(ctx, []string{types.QueryDelegatorValidator}, query) - require.NoError(t, err) - - var validator types.Validator - errRes = cdc.UnmarshalJSON(res, &validator) - require.NoError(t, errRes) - require.True(t, validator.Equal(&delValidators[0])) - - // error unknown request - query.Data = bz[:len(bz)-1] - - _, err = querier(ctx, []string{types.QueryDelegatorValidator}, query) - require.Error(t, err) - - // Query delegation - - query = abci.RequestQuery{ - Path: "/custom/staking/delegation", - Data: bz, - } - - delegation, found := app.StakingKeeper.GetDelegation(ctx, addrAcc2, addrVal1) - require.True(t, found) - - res, err = querier(ctx, []string{types.QueryDelegation}, query) - require.NoError(t, err) - - var delegationRes types.DelegationResponse - errRes = cdc.UnmarshalJSON(res, &delegationRes) - require.NoError(t, errRes) - - require.Equal(t, delegation.ValidatorAddress, delegationRes.Delegation.ValidatorAddress) - require.Equal(t, delegation.DelegatorAddress, delegationRes.Delegation.DelegatorAddress) - require.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, delegation.Shares.TruncateInt()), delegationRes.Balance) - - // Query Delegator Delegations - bz, errRes = cdc.MarshalJSON(queryParams) - require.NoError(t, errRes) - - query = abci.RequestQuery{ - Path: "/custom/staking/delegatorDelegations", - Data: bz, - } - - res, err = querier(ctx, []string{types.QueryDelegatorDelegations}, query) - require.NoError(t, err) - - var delegatorDelegations types.DelegationResponses - errRes = cdc.UnmarshalJSON(res, &delegatorDelegations) - require.NoError(t, errRes) - require.Len(t, delegatorDelegations, 1) - require.Equal(t, delegation.ValidatorAddress, delegatorDelegations[0].Delegation.ValidatorAddress) - require.Equal(t, delegation.DelegatorAddress, delegatorDelegations[0].Delegation.DelegatorAddress) - require.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, delegation.Shares.TruncateInt()), delegatorDelegations[0].Balance) - - // error unknown request - query.Data = bz[:len(bz)-1] - - _, err = querier(ctx, []string{types.QueryDelegation}, query) - require.Error(t, err) - - // Query validator delegations - bz, errRes = cdc.MarshalJSON(types.NewQueryValidatorParams(addrVal1, 1, 100)) - require.NoError(t, errRes) - - query = abci.RequestQuery{ - Path: "custom/staking/validatorDelegations", - Data: bz, - } - - res, err = querier(ctx, []string{types.QueryValidatorDelegations}, query) - require.NoError(t, err) - - var delegationsRes types.DelegationResponses - errRes = cdc.UnmarshalJSON(res, &delegationsRes) - require.NoError(t, errRes) - require.Len(t, delegatorDelegations, 1) - require.Equal(t, delegation.ValidatorAddress, delegationsRes[0].Delegation.ValidatorAddress) - require.Equal(t, delegation.DelegatorAddress, delegationsRes[0].Delegation.DelegatorAddress) - require.Equal(t, sdk.NewCoin(sdk.DefaultBondDenom, delegation.Shares.TruncateInt()), delegationsRes[0].Balance) - - // Query unbonding delegation - unbondingTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - _, err = app.StakingKeeper.Undelegate(ctx, addrAcc2, val1.GetOperator(), sdk.NewDecFromInt(unbondingTokens)) - require.NoError(t, err) - - queryBondParams = types.QueryDelegatorValidatorRequest{DelegatorAddr: addrAcc2.String(), ValidatorAddr: addrVal1.String()} - bz, errRes = cdc.MarshalJSON(queryBondParams) - require.NoError(t, errRes) - - query = abci.RequestQuery{ - Path: "/custom/staking/unbondingDelegation", - Data: bz, - } - - unbond, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrAcc2, addrVal1) - require.True(t, found) - - res, err = querier(ctx, []string{types.QueryUnbondingDelegation}, query) - require.NoError(t, err) - - var unbondRes types.UnbondingDelegation - errRes = cdc.UnmarshalJSON(res, &unbondRes) - require.NoError(t, errRes) - - require.Equal(t, unbond, unbondRes) - - // error unknown request - query.Data = bz[:len(bz)-1] - - _, err = querier(ctx, []string{types.QueryUnbondingDelegation}, query) - require.Error(t, err) - - // Query Delegator Unbonding Delegations - - query = abci.RequestQuery{ - Path: "/custom/staking/delegatorUnbondingDelegations", - Data: bz, - } - - res, err = querier(ctx, []string{types.QueryDelegatorUnbondingDelegations}, query) - require.NoError(t, err) - - var delegatorUbds []types.UnbondingDelegation - errRes = cdc.UnmarshalJSON(res, &delegatorUbds) - require.NoError(t, errRes) - require.Equal(t, unbond, delegatorUbds[0]) - - // error unknown request - query.Data = bz[:len(bz)-1] - - _, err = querier(ctx, []string{types.QueryDelegatorUnbondingDelegations}, query) - require.Error(t, err) - - // Query redelegation - redelegationTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator(), sdk.NewDecFromInt(redelegationTokens)) - require.NoError(t, err) - redel, found := app.StakingKeeper.GetRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator()) - require.True(t, found) - - bz, errRes = cdc.MarshalJSON(types.NewQueryRedelegationParams(addrAcc2, val1.GetOperator(), val2.GetOperator())) - require.NoError(t, errRes) - - query = abci.RequestQuery{ - Path: "/custom/staking/redelegations", - Data: bz, - } - - res, err = querier(ctx, []string{types.QueryRedelegations}, query) - require.NoError(t, err) - - var redelRes types.RedelegationResponses - errRes = cdc.UnmarshalJSON(res, &redelRes) - require.NoError(t, errRes) - require.Len(t, redelRes, 1) - require.Equal(t, redel.DelegatorAddress, redelRes[0].Redelegation.DelegatorAddress) - require.Equal(t, redel.ValidatorSrcAddress, redelRes[0].Redelegation.ValidatorSrcAddress) - require.Equal(t, redel.ValidatorDstAddress, redelRes[0].Redelegation.ValidatorDstAddress) - require.Len(t, redel.Entries, len(redelRes[0].Entries)) -} - -func TestQueryValidatorDelegations_Pagination(t *testing.T) { - cases := []struct { - page int - limit int - expectedResults int - }{ - { - page: 1, - limit: 75, - expectedResults: 75, - }, - { - page: 2, - limit: 75, - expectedResults: 25, - }, - { - page: 1, - limit: 100, - expectedResults: 100, - }, - } - - cdc, app, ctx := createTestInput(t) - legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) - querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) - - addrs := simapp.AddTestAddrs(app, ctx, 100, app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)) - pubKeys := simtestutil.CreateTestPubKeys(1) - - valAddress := sdk.ValAddress(addrs[0]) - - val1 := teststaking.NewValidator(t, valAddress, pubKeys[0]) - app.StakingKeeper.SetValidator(ctx, val1) - app.StakingKeeper.SetValidatorByPowerIndex(ctx, val1) - - // Create Validators and Delegation - for _, addr := range addrs { - validator, found := app.StakingKeeper.GetValidator(ctx, valAddress) - if !found { - t.Error("expected validator not found") - } - - delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err := app.StakingKeeper.Delegate(ctx, addr, delTokens, types.Unbonded, validator, true) - require.NoError(t, err) - } - - // apply TM updates - applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) - - for _, c := range cases { - // Query Delegator bonded validators - queryParams := types.NewQueryDelegatorParams(addrs[0]) - bz, errRes := cdc.MarshalJSON(queryParams) - require.NoError(t, errRes) - - // Query valAddress delegations - bz, errRes = cdc.MarshalJSON(types.NewQueryValidatorParams(valAddress, c.page, c.limit)) - require.NoError(t, errRes) - - query := abci.RequestQuery{ - Path: "custom/staking/validatorDelegations", - Data: bz, - } - - res, err := querier(ctx, []string{types.QueryValidatorDelegations}, query) - require.NoError(t, err) - - var delegationsRes types.DelegationResponses - errRes = cdc.UnmarshalJSON(res, &delegationsRes) - require.NoError(t, errRes) - require.Len(t, delegationsRes, c.expectedResults) - } - - // Undelegate - for _, addr := range addrs { - delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err := app.StakingKeeper.Undelegate(ctx, addr, val1.GetOperator(), sdk.NewDecFromInt(delTokens)) - require.NoError(t, err) - } - - // apply TM updates - applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) - - for _, c := range cases { - // Query Unbonding delegations with pagination. - queryParams := types.NewQueryDelegatorParams(addrs[0]) - bz, errRes := cdc.MarshalJSON(queryParams) - require.NoError(t, errRes) - - bz, errRes = cdc.MarshalJSON(types.NewQueryValidatorParams(valAddress, c.page, c.limit)) - require.NoError(t, errRes) - query := abci.RequestQuery{ - Data: bz, - } - - unbondingDelegations := types.UnbondingDelegations{} - res, err := querier(ctx, []string{types.QueryValidatorUnbondingDelegations}, query) - require.NoError(t, err) - - errRes = cdc.UnmarshalJSON(res, &unbondingDelegations) - require.NoError(t, errRes) - require.Len(t, unbondingDelegations, c.expectedResults) - } -} - -func TestQueryRedelegations(t *testing.T) { - cdc, app, ctx := createTestInput(t) - legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) - querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) - - addrs := simapp.AddTestAddrs(app, ctx, 2, app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)) - addrAcc1, addrAcc2 := addrs[0], addrs[1] - addrVal1, addrVal2 := sdk.ValAddress(addrAcc1), sdk.ValAddress(addrAcc2) - - // Create Validators and Delegation - val1 := teststaking.NewValidator(t, addrVal1, PKs[0]) - val2 := teststaking.NewValidator(t, addrVal2, PKs[1]) - app.StakingKeeper.SetValidator(ctx, val1) - app.StakingKeeper.SetValidator(ctx, val2) - - delAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 100) - _, err := app.StakingKeeper.Delegate(ctx, addrAcc2, delAmount, types.Unbonded, val1, true) - require.NoError(t, err) - applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) - - rdAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator(), sdk.NewDecFromInt(rdAmount)) - require.NoError(t, err) - applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) - - redel, found := app.StakingKeeper.GetRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator()) - require.True(t, found) - - // delegator redelegations - queryDelegatorParams := types.NewQueryDelegatorParams(addrAcc2) - bz, errRes := cdc.MarshalJSON(queryDelegatorParams) - require.NoError(t, errRes) - - query := abci.RequestQuery{ - Path: "/custom/staking/redelegations", - Data: bz, - } - - res, err := querier(ctx, []string{types.QueryRedelegations}, query) - require.NoError(t, err) - - var redelRes types.RedelegationResponses - errRes = cdc.UnmarshalJSON(res, &redelRes) - require.NoError(t, errRes) - require.Len(t, redelRes, 1) - require.Equal(t, redel.DelegatorAddress, redelRes[0].Redelegation.DelegatorAddress) - require.Equal(t, redel.ValidatorSrcAddress, redelRes[0].Redelegation.ValidatorSrcAddress) - require.Equal(t, redel.ValidatorDstAddress, redelRes[0].Redelegation.ValidatorDstAddress) - require.Len(t, redel.Entries, len(redelRes[0].Entries)) - - // validator redelegations - queryValidatorParams := types.NewQueryValidatorParams(val1.GetOperator(), 0, 0) - bz, errRes = cdc.MarshalJSON(queryValidatorParams) - require.NoError(t, errRes) - - query = abci.RequestQuery{ - Path: "/custom/staking/redelegations", - Data: bz, - } - - res, err = querier(ctx, []string{types.QueryRedelegations}, query) - require.NoError(t, err) - - errRes = cdc.UnmarshalJSON(res, &redelRes) - require.NoError(t, errRes) - require.Len(t, redelRes, 1) - require.Equal(t, redel.DelegatorAddress, redelRes[0].Redelegation.DelegatorAddress) - require.Equal(t, redel.ValidatorSrcAddress, redelRes[0].Redelegation.ValidatorSrcAddress) - require.Equal(t, redel.ValidatorDstAddress, redelRes[0].Redelegation.ValidatorDstAddress) - require.Len(t, redel.Entries, len(redelRes[0].Entries)) -} - -func TestQueryUnbondingDelegation(t *testing.T) { - cdc, app, ctx := createTestInput(t) - legacyQuerierCdc := codec.NewAminoCodec(app.LegacyAmino()) - querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) - - addrs := simapp.AddTestAddrs(app, ctx, 2, app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)) - addrAcc1, addrAcc2 := addrs[0], addrs[1] - addrVal1 := sdk.ValAddress(addrAcc1) - - // Create Validators and Delegation - val1 := teststaking.NewValidator(t, addrVal1, PKs[0]) - app.StakingKeeper.SetValidator(ctx, val1) - - // delegate - delAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 100) - _, err := app.StakingKeeper.Delegate(ctx, addrAcc1, delAmount, types.Unbonded, val1, true) - require.NoError(t, err) - applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) - - // undelegate - undelAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err = app.StakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), sdk.NewDecFromInt(undelAmount)) - require.NoError(t, err) - applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) - - _, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrAcc1, val1.GetOperator()) - require.True(t, found) - - // - // found: query unbonding delegation by delegator and validator - // - queryValidatorParams := types.QueryDelegatorValidatorRequest{DelegatorAddr: addrAcc1.String(), ValidatorAddr: val1.GetOperator().String()} - bz, errRes := cdc.MarshalJSON(queryValidatorParams) - require.NoError(t, errRes) - query := abci.RequestQuery{ - Path: "/custom/staking/unbondingDelegation", - Data: bz, - } - res, err := querier(ctx, []string{types.QueryUnbondingDelegation}, query) - require.NoError(t, err) - require.NotNil(t, res) - var ubDel types.UnbondingDelegation - require.NoError(t, cdc.UnmarshalJSON(res, &ubDel)) - require.Equal(t, addrAcc1.String(), ubDel.DelegatorAddress) - require.Equal(t, val1.OperatorAddress, ubDel.ValidatorAddress) - require.Equal(t, 1, len(ubDel.Entries)) - - // - // not found: query unbonding delegation by delegator and validator - // - queryValidatorParams = types.QueryDelegatorValidatorRequest{DelegatorAddr: addrAcc2.String(), ValidatorAddr: val1.GetOperator().String()} - bz, errRes = cdc.MarshalJSON(queryValidatorParams) - require.NoError(t, errRes) - query = abci.RequestQuery{ - Path: "/custom/staking/unbondingDelegation", - Data: bz, - } - _, err = querier(ctx, []string{types.QueryUnbondingDelegation}, query) - require.Error(t, err) - - // - // found: query unbonding delegation by delegator and validator - // - queryDelegatorParams := types.NewQueryDelegatorParams(addrAcc1) - bz, errRes = cdc.MarshalJSON(queryDelegatorParams) - require.NoError(t, errRes) - query = abci.RequestQuery{ - Path: "/custom/staking/delegatorUnbondingDelegations", - Data: bz, - } - res, err = querier(ctx, []string{types.QueryDelegatorUnbondingDelegations}, query) - require.NoError(t, err) - require.NotNil(t, res) - var ubDels []types.UnbondingDelegation - require.NoError(t, cdc.UnmarshalJSON(res, &ubDels)) - require.Equal(t, 1, len(ubDels)) - require.Equal(t, addrAcc1.String(), ubDels[0].DelegatorAddress) - require.Equal(t, val1.OperatorAddress, ubDels[0].ValidatorAddress) - - // - // not found: query unbonding delegation by delegator and validator - // - queryDelegatorParams = types.NewQueryDelegatorParams(addrAcc2) - bz, errRes = cdc.MarshalJSON(queryDelegatorParams) - require.NoError(t, errRes) - query = abci.RequestQuery{ - Path: "/custom/staking/delegatorUnbondingDelegations", - Data: bz, - } - res, err = querier(ctx, []string{types.QueryDelegatorUnbondingDelegations}, query) - require.NoError(t, err) - require.NotNil(t, res) - require.NoError(t, cdc.UnmarshalJSON(res, &ubDels)) - require.Equal(t, 0, len(ubDels)) -} - -func TestQueryHistoricalInfo(t *testing.T) { - cdc, app, ctx := createTestInput(t) - legacyQuerierCdc := codec.NewAminoCodec(cdc) - querier := keeper.NewQuerier(app.StakingKeeper, legacyQuerierCdc.LegacyAmino) - - addrs := simapp.AddTestAddrs(app, ctx, 2, app.StakingKeeper.TokensFromConsensusPower(ctx, 10000)) - addrAcc1, addrAcc2 := addrs[0], addrs[1] - addrVal1, addrVal2 := sdk.ValAddress(addrAcc1), sdk.ValAddress(addrAcc2) - - // Create Validators and Delegation - val1 := teststaking.NewValidator(t, addrVal1, PKs[0]) - val2 := teststaking.NewValidator(t, addrVal2, PKs[1]) - vals := []types.Validator{val1, val2} - app.StakingKeeper.SetValidator(ctx, val1) - app.StakingKeeper.SetValidator(ctx, val2) - - header := tmproto.Header{ - ChainID: "HelloChain", - Height: 5, - } - hi := types.NewHistoricalInfo(header, vals, app.StakingKeeper.PowerReduction(ctx)) - app.StakingKeeper.SetHistoricalInfo(ctx, 5, &hi) - - queryHistoricalParams := types.QueryHistoricalInfoRequest{Height: 4} - bz, errRes := cdc.MarshalJSON(queryHistoricalParams) - require.NoError(t, errRes) - query := abci.RequestQuery{ - Path: "/custom/staking/historicalInfo", - Data: bz, - } - res, err := querier(ctx, []string{types.QueryHistoricalInfo}, query) - require.Error(t, err, "Invalid query passed") - require.Nil(t, res, "Invalid query returned non-nil result") - - queryHistoricalParams = types.QueryHistoricalInfoRequest{Height: 5} - bz, errRes = cdc.MarshalJSON(queryHistoricalParams) - require.NoError(t, errRes) - query.Data = bz - res, err = querier(ctx, []string{types.QueryHistoricalInfo}, query) - require.NoError(t, err, "Valid query passed") - require.NotNil(t, res, "Valid query returned nil result") - - var recv types.HistoricalInfo - require.NoError(t, cdc.UnmarshalJSON(res, &recv)) - require.Equal(t, hi, recv, "HistoricalInfo query returned wrong result") -} diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 0548213f010e..36ba0433a7a2 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -106,7 +106,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh // cannot decrease balance below zero tokensToBurn := sdk.MinInt(remainingSlashAmount, validator.Tokens) - tokensToBurn = sdk.MaxInt(tokensToBurn, sdk.ZeroInt()) // defensive. + tokensToBurn = sdk.MaxInt(tokensToBurn, math.ZeroInt()) // defensive. // we need to calculate the *effective* slash fraction for distribution if validator.Tokens.IsPositive() { @@ -170,8 +170,8 @@ func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation ty infractionHeight int64, slashFactor sdk.Dec, ) (totalSlashAmount math.Int) { now := ctx.BlockHeader().Time - totalSlashAmount = sdk.ZeroInt() - burnedAmount := sdk.ZeroInt() + totalSlashAmount = math.ZeroInt() + burnedAmount := math.ZeroInt() // perform slashing on all entries within the unbonding delegation for i, entry := range unbondingDelegation.Entries { @@ -224,8 +224,8 @@ func (k Keeper) SlashRedelegation(ctx sdk.Context, srcValidator types.Validator, infractionHeight int64, slashFactor sdk.Dec, ) (totalSlashAmount math.Int) { now := ctx.BlockHeader().Time - totalSlashAmount = sdk.ZeroInt() - bondedBurnedAmount, notBondedBurnedAmount := sdk.ZeroInt(), sdk.ZeroInt() + totalSlashAmount = math.ZeroInt() + bondedBurnedAmount, notBondedBurnedAmount := math.ZeroInt(), math.ZeroInt() // perform slashing on all entries within the redelegation for _, entry := range redelegation.Entries { diff --git a/x/staking/keeper/slash_test.go b/x/staking/keeper/slash_test.go index ea83aab9dce2..5d792618671f 100644 --- a/x/staking/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "cosmossdk.io/math" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -422,10 +423,10 @@ func TestSlashWithRedelegation(t *testing.T) { // burn bonded tokens from only from delegations bondedPoolBalance := app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(math.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) notBondedPoolBalance := app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(math.IntEq(t, oldNotBonded, notBondedPoolBalance)) oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount // read updating redelegation @@ -454,14 +455,14 @@ func TestSlashWithRedelegation(t *testing.T) { // seven bonded tokens burned bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(math.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(math.IntEq(t, oldNotBonded, notBondedPoolBalance)) bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(math.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(math.IntEq(t, oldNotBonded, notBondedPoolBalance)) oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount // read updating redelegation @@ -489,9 +490,9 @@ func TestSlashWithRedelegation(t *testing.T) { notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) + require.True(math.IntEq(t, oldBonded.Sub(burnAmount), bondedPoolBalance)) notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(math.IntEq(t, oldNotBonded, notBondedPoolBalance)) oldBonded = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount // read updating redelegation @@ -519,9 +520,9 @@ func TestSlashWithRedelegation(t *testing.T) { notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) bondedPoolBalance = app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded, bondedPoolBalance)) + require.True(math.IntEq(t, oldBonded, bondedPoolBalance)) notBondedPoolBalance = app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded, notBondedPoolBalance)) + require.True(math.IntEq(t, oldNotBonded, notBondedPoolBalance)) // read updating redelegation rd, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1]) @@ -587,10 +588,10 @@ func TestSlashBoth(t *testing.T) { notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) bondedPoolBalance := app.BankKeeper.GetBalance(ctx, bondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldBonded.Sub(burnedBondAmount), bondedPoolBalance)) + require.True(math.IntEq(t, oldBonded.Sub(burnedBondAmount), bondedPoolBalance)) notBondedPoolBalance := app.BankKeeper.GetBalance(ctx, notBondedPool.GetAddress(), bondDenom).Amount - require.True(sdk.IntEq(t, oldNotBonded.Sub(burnedNotBondedAmount), notBondedPoolBalance)) + require.True(math.IntEq(t, oldNotBonded.Sub(burnedNotBondedAmount), notBondedPoolBalance)) // read updating redelegation rdA, found = app.StakingKeeper.GetRedelegation(ctx, addrDels[0], addrVals[0], addrVals[1]) @@ -608,7 +609,7 @@ func TestSlashAmount(t *testing.T) { consAddr := sdk.ConsAddress(PKs[0].Address()) fraction := sdk.NewDecWithPrec(5, 1) burnedCoins := app.StakingKeeper.Slash(ctx, consAddr, ctx.BlockHeight(), 10, fraction) - require.True(t, burnedCoins.GT(sdk.ZeroInt())) + require.True(t, burnedCoins.GT(math.ZeroInt())) // test the case where the validator was not found, which should return no coins _, addrVals := generateAddresses(app, ctx, 100) diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index 867ca04a7099..db63c03ebf56 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -5,6 +5,7 @@ import ( "fmt" "sort" + "cosmossdk.io/math" gogotypes "github.com/gogo/protobuf/types" abci "github.com/tendermint/tendermint/abci/types" @@ -109,8 +110,8 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab params := k.GetParams(ctx) maxValidators := params.MaxValidators powerReduction := k.PowerReduction(ctx) - totalPower := sdk.ZeroInt() - amtFromBondedToNotBonded, amtFromNotBondedToBonded := sdk.ZeroInt(), sdk.ZeroInt() + totalPower := math.ZeroInt() + amtFromBondedToNotBonded, amtFromNotBondedToBonded := math.ZeroInt(), math.ZeroInt() // Retrieve the last validator set. // The persistent set is updated later in this function. diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index 49fac14a08d5..6204e954b648 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -5,6 +5,7 @@ import ( "testing" "time" + "cosmossdk.io/math" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" @@ -259,7 +260,7 @@ func TestValidatorBasics(t *testing.T) { for i, power := range powers { validators[i] = teststaking.NewValidator(t, addrVals[i], PKs[i]) validators[i].Status = types.Unbonded - validators[i].Tokens = sdk.ZeroInt() + validators[i].Tokens = math.ZeroInt() tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, power) validators[i], _ = validators[i].AddTokensFromDel(tokens) @@ -296,7 +297,7 @@ func TestValidatorBasics(t *testing.T) { require.Equal(t, 1, len(resVals)) assert.True(ValEq(t, validators[0], resVals[0])) assert.Equal(t, types.Bonded, validators[0].Status) - assert.True(sdk.IntEq(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 9), validators[0].BondedTokens())) + assert.True(math.IntEq(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 9), validators[0].BondedTokens())) // modify a records, save, and retrieve validators[0].Status = types.Bonded @@ -341,7 +342,7 @@ func TestValidatorBasics(t *testing.T) { "attempting to remove a validator which still contains tokens", func() { app.StakingKeeper.RemoveValidator(ctx, validators[1].GetOperator()) }) - validators[1].Tokens = sdk.ZeroInt() // ...remove all tokens + validators[1].Tokens = math.ZeroInt() // ...remove all tokens app.StakingKeeper.SetValidator(ctx, validators[1]) // ...set the validator app.StakingKeeper.RemoveValidator(ctx, validators[1].GetOperator()) // Now it can be removed. _, found = app.StakingKeeper.GetValidator(ctx, addrVals[1]) @@ -353,7 +354,7 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { app, ctx, addrs, _ := bootstrapValidatorTest(t, 1000, 20) // initialize some validators into the state - amts := []sdk.Int{ + amts := []math.Int{ sdk.NewIntFromUint64(0), app.StakingKeeper.PowerReduction(ctx).MulRaw(100), app.StakingKeeper.PowerReduction(ctx), @@ -447,7 +448,7 @@ func TestGetValidatorSortingMixed(t *testing.T) { app.StakingKeeper.SetParams(ctx, params) // initialize some validators into the state - amts := []sdk.Int{ + amts := []math.Int{ sdk.NewIntFromUint64(0), app.StakingKeeper.PowerReduction(ctx).MulRaw(100), app.StakingKeeper.PowerReduction(ctx), diff --git a/x/staking/migrations/v2/store.go b/x/staking/migrations/v2/store.go index 1691b676d393..2e1476fb0052 100644 --- a/x/staking/migrations/v2/store.go +++ b/x/staking/migrations/v2/store.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/address" v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v043" - "github.com/cosmos/cosmos-sdk/x/staking/migrations/v1" + v1 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v1" "github.com/cosmos/cosmos-sdk/x/staking/types" ) diff --git a/x/staking/migrations/v3/json_test.go b/x/staking/migrations/v3/json_test.go index a52a89ad1325..c111f366515e 100644 --- a/x/staking/migrations/v3/json_test.go +++ b/x/staking/migrations/v3/json_test.go @@ -7,13 +7,13 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + v3 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3" "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestMigrateJSON(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() + encodingConfig := moduletestutil.MakeTestEncodingConfig() clientCtx := client.Context{}. WithInterfaceRegistry(encodingConfig.InterfaceRegistry). WithTxConfig(encodingConfig.TxConfig). diff --git a/x/staking/migrations/v3/store_test.go b/x/staking/migrations/v3/store_test.go index f57ce3de6c7f..24c37b595cf1 100644 --- a/x/staking/migrations/v3/store_test.go +++ b/x/staking/migrations/v3/store_test.go @@ -5,16 +5,16 @@ import ( "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3" + v3 "github.com/cosmos/cosmos-sdk/x/staking/migrations/v3" "github.com/cosmos/cosmos-sdk/x/staking/types" ) func TestStoreMigration(t *testing.T) { - encCfg := simapp.MakeTestEncodingConfig() + encCfg := moduletestutil.MakeTestEncodingConfig() stakingKey := sdk.NewKVStoreKey("staking") tStakingKey := sdk.NewTransientStoreKey("transient_test") ctx := testutil.DefaultContext(stakingKey, tStakingKey) diff --git a/x/staking/module.go b/x/staking/module.go index 4b3f4c2f197e..6a2f74072478 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -4,11 +4,12 @@ import ( "context" "encoding/json" "fmt" + "math/rand" + "sort" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/staking/exported" - "math/rand" - "sort" gwruntime "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -136,21 +137,6 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { keeper.RegisterInvariants(ir, am.keeper) } -// Deprecated: Route returns the message routing key for the staking module. -func (am AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the staking module's querier route name. -func (AppModule) QuerierRoute() string { - return types.QuerierRoute -} - -// LegacyQuerierHandler returns the staking module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) @@ -160,11 +146,9 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { m := keeper.NewMigrator(am.keeper, am.legacySubspace) if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { panic(fmt.Sprintf("failed to migrate x/%s from version 1 to 2: %v", types.ModuleName, err)) - } if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil { panic(fmt.Sprintf("failed to migrate x/%s from version 2 to 3: %v", types.ModuleName, err)) - } if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil { panic(fmt.Sprintf("failed to migrate x/%s from version 3 to 4: %v", types.ModuleName, err)) diff --git a/x/staking/module_test.go b/x/staking/module_test.go index 12faab19e0c2..9c18bf3629e2 100644 --- a/x/staking/module_test.go +++ b/x/staking/module_test.go @@ -20,13 +20,12 @@ import ( func TestItCreatesModuleAccountOnInitBlock(t *testing.T) { db := dbm.NewMemDB() - encCdc := simapp.MakeTestEncodingConfig() appOptions := make(simtestutil.AppOptionsMap, 0) appOptions[flags.FlagHome] = simapp.DefaultNodeHome appOptions[server.FlagInvCheckPeriod] = 5 - app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, encCdc, appOptions) + app := simapp.NewSimApp(log.NewNopLogger(), db, nil, true, appOptions) genesisState := simapp.GenesisStateWithSingleValidator(t, app) stateBytes, err := tmjson.Marshal(genesisState) diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index 3d7546369d6b..3bd7a168894f 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -5,14 +5,15 @@ import ( "testing" "time" + "cosmossdk.io/math" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" + "github.com/cosmos/cosmos-sdk/types/module/testutil" "github.com/cosmos/cosmos-sdk/x/staking/simulation" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -32,19 +33,19 @@ func makeTestCodec() (cdc *codec.LegacyAmino) { } func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Codec + cdc := testutil.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) bondTime := time.Now().UTC() val, err := types.NewValidator(valAddr1, delPk1, types.NewDescription("test", "test", "test", "test", "test")) require.NoError(t, err) del := types.NewDelegation(delAddr1, valAddr1, sdk.OneDec()) - ubd := types.NewUnbondingDelegation(delAddr1, valAddr1, 15, bondTime, sdk.OneInt()) - red := types.NewRedelegation(delAddr1, valAddr1, valAddr1, 12, bondTime, sdk.OneInt(), sdk.OneDec()) + ubd := types.NewUnbondingDelegation(delAddr1, valAddr1, 15, bondTime, math.OneInt()) + red := types.NewRedelegation(delAddr1, valAddr1, valAddr1, 12, bondTime, math.OneInt(), sdk.OneDec()) kvPairs := kv.Pairs{ Pairs: []kv.Pair{ - {Key: types.LastTotalPowerKey, Value: cdc.MustMarshal(&sdk.IntProto{Int: sdk.OneInt()})}, + {Key: types.LastTotalPowerKey, Value: cdc.MustMarshal(&sdk.IntProto{Int: math.OneInt()})}, {Key: types.GetValidatorKey(valAddr1), Value: cdc.MustMarshal(&val)}, {Key: types.LastValidatorPowerKey, Value: valAddr1.Bytes()}, {Key: types.GetDelegationKey(delAddr1, valAddr1), Value: cdc.MustMarshal(&del)}, @@ -58,7 +59,7 @@ func TestDecodeStore(t *testing.T) { name string expectedLog string }{ - {"LastTotalPower", fmt.Sprintf("%v\n%v", sdk.OneInt(), sdk.OneInt())}, + {"LastTotalPower", fmt.Sprintf("%v\n%v", math.OneInt(), math.OneInt())}, {"Validator", fmt.Sprintf("%v\n%v", val, val)}, {"LastValidatorPower/ValidatorsByConsAddr/ValidatorsByPowerIndex", fmt.Sprintf("%v\n%v", valAddr1, valAddr1)}, {"Delegation", fmt.Sprintf("%v\n%v", del, del)}, diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 0eab097d1831..28704a13b843 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -4,6 +4,7 @@ import ( "fmt" "math/rand" + "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -159,7 +160,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k * simtypes.RandomDecAmount(r, maxCommission), ) - msg, err := types.NewMsgCreateValidator(address, simAccount.ConsKey.PubKey(), selfDelegation, description, commission, sdk.OneInt()) + msg, err := types.NewMsgCreateValidator(address, simAccount.ConsKey.PubKey(), selfDelegation, description, commission, math.OneInt()) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to create CreateValidator message"), nil, err } diff --git a/x/staking/spec/01_state.md b/x/staking/spec/01_state.md index 0eb3516da150..3c01cce247d5 100644 --- a/x/staking/spec/01_state.md +++ b/x/staking/spec/01_state.md @@ -13,7 +13,7 @@ Pool is used for tracking bonded and not-bonded token supply of the bond denomin LastTotalPower tracks the total amounts of bonded tokens recorded during the previous end block. Store entries prefixed with "Last" must remain unchanged until EndBlock. -* LastTotalPower: `0x12 -> ProtocolBuffer(sdk.Int)` +* LastTotalPower: `0x12 -> ProtocolBuffer(math.Int)` ## Params diff --git a/x/staking/teststaking/helper.go b/x/staking/teststaking/helper.go index b5457ea01eb7..f79bd2921580 100644 --- a/x/staking/teststaking/helper.go +++ b/x/staking/teststaking/helper.go @@ -51,7 +51,7 @@ func (sh *Helper) CreateValidatorWithValPower(addr sdk.ValAddress, pk cryptotype // CreateValidatorMsg returns a message used to create validator in this service. func (sh *Helper) CreateValidatorMsg(addr sdk.ValAddress, pk cryptotypes.PubKey, stakeAmount math.Int) *stakingtypes.MsgCreateValidator { coin := sdk.NewCoin(sh.Denom, stakeAmount) - msg, err := stakingtypes.NewMsgCreateValidator(addr, pk, coin, stakingtypes.Description{}, sh.Commission, sdk.OneInt()) + msg, err := stakingtypes.NewMsgCreateValidator(addr, pk, coin, stakingtypes.Description{}, sh.Commission, math.OneInt()) require.NoError(sh.t, err) return msg } @@ -62,7 +62,7 @@ func (sh *Helper) CreateValidatorWithMsg(ctx context.Context, msg *stakingtypes. } func (sh *Helper) createValidator(addr sdk.ValAddress, pk cryptotypes.PubKey, coin sdk.Coin, ok bool) { - msg, err := stakingtypes.NewMsgCreateValidator(addr, pk, coin, stakingtypes.Description{}, sh.Commission, sdk.OneInt()) + msg, err := stakingtypes.NewMsgCreateValidator(addr, pk, coin, stakingtypes.Description{}, sh.Commission, math.OneInt()) require.NoError(sh.t, err) res, err := sh.msgSrvr.CreateValidator(sdk.WrapSDKContext(sh.Ctx), msg) if ok { diff --git a/x/staking/types/keys.go b/x/staking/types/keys.go index 1b86e4e5b5a5..c56348789a66 100644 --- a/x/staking/types/keys.go +++ b/x/staking/types/keys.go @@ -21,9 +21,6 @@ const ( // StoreKey is the string store representation StoreKey = ModuleName - // QuerierRoute is the querier route for the staking module - QuerierRoute = ModuleName - // RouterKey is the msg router key for the staking module RouterKey = ModuleName ) diff --git a/x/staking/types/keys_test.go b/x/staking/types/keys_test.go index 20269e671baf..e5b96e484442 100644 --- a/x/staking/types/keys_test.go +++ b/x/staking/types/keys_test.go @@ -7,6 +7,7 @@ import ( "testing" "time" + "cosmossdk.io/math" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -26,7 +27,7 @@ var ( func TestGetValidatorPowerRank(t *testing.T) { valAddr1 := sdk.ValAddress(keysAddr1) val1 := newValidator(t, valAddr1, keysPK1) - val1.Tokens = sdk.ZeroInt() + val1.Tokens = math.ZeroInt() val2, val3, val4 := val1, val1, val1 val2.Tokens = sdk.TokensFromConsensusPower(1, sdk.DefaultPowerReduction) val3.Tokens = sdk.TokensFromConsensusPower(10, sdk.DefaultPowerReduction) diff --git a/x/staking/types/msg_test.go b/x/staking/types/msg_test.go index 49416dbb9cf4..338c0edc3eaa 100644 --- a/x/staking/types/msg_test.go +++ b/x/staking/types/msg_test.go @@ -1,11 +1,13 @@ package types_test import ( - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "testing" "time" + "cosmossdk.io/math" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" @@ -40,7 +42,7 @@ func TestMsgDecode(t *testing.T) { // now let's try to serialize the whole message commission1 := types.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) - msg, err := types.NewMsgCreateValidator(valAddr1, pk1, coinPos, types.Description{}, commission1, sdk.OneInt()) + msg, err := types.NewMsgCreateValidator(valAddr1, pk1, coinPos, types.Description{}, commission1, math.OneInt()) require.NoError(t, err) msgSerialized, err := cdc.MarshalInterface(msg) require.NoError(t, err) @@ -62,22 +64,22 @@ func TestMsgCreateValidator(t *testing.T) { tests := []struct { name, moniker, identity, website, securityContact, details string CommissionRates types.CommissionRates - minSelfDelegation sdk.Int + minSelfDelegation math.Int validatorAddr sdk.ValAddress pubkey cryptotypes.PubKey bond sdk.Coin expectPass bool }{ - {"basic good", "a", "b", "c", "d", "e", commission1, sdk.OneInt(), valAddr1, pk1, coinPos, true}, - {"partial description", "", "", "c", "", "", commission1, sdk.OneInt(), valAddr1, pk1, coinPos, true}, - {"empty description", "", "", "", "", "", commission2, sdk.OneInt(), valAddr1, pk1, coinPos, false}, - {"empty address", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), emptyAddr, pk1, coinPos, false}, - {"empty pubkey", "a", "b", "c", "d", "e", commission1, sdk.OneInt(), valAddr1, emptyPubkey, coinPos, false}, - {"empty bond", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), valAddr1, pk1, coinZero, false}, - {"nil bond", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), valAddr1, pk1, sdk.Coin{}, false}, - {"zero min self delegation", "a", "b", "c", "d", "e", commission1, sdk.ZeroInt(), valAddr1, pk1, coinPos, false}, + {"basic good", "a", "b", "c", "d", "e", commission1, math.OneInt(), valAddr1, pk1, coinPos, true}, + {"partial description", "", "", "c", "", "", commission1, math.OneInt(), valAddr1, pk1, coinPos, true}, + {"empty description", "", "", "", "", "", commission2, math.OneInt(), valAddr1, pk1, coinPos, false}, + {"empty address", "a", "b", "c", "d", "e", commission2, math.OneInt(), emptyAddr, pk1, coinPos, false}, + {"empty pubkey", "a", "b", "c", "d", "e", commission1, math.OneInt(), valAddr1, emptyPubkey, coinPos, false}, + {"empty bond", "a", "b", "c", "d", "e", commission2, math.OneInt(), valAddr1, pk1, coinZero, false}, + {"nil bond", "a", "b", "c", "d", "e", commission2, math.OneInt(), valAddr1, pk1, sdk.Coin{}, false}, + {"zero min self delegation", "a", "b", "c", "d", "e", commission1, math.ZeroInt(), valAddr1, pk1, coinPos, false}, {"negative min self delegation", "a", "b", "c", "d", "e", commission1, sdk.NewInt(-1), valAddr1, pk1, coinPos, false}, - {"delegation less than min self delegation", "a", "b", "c", "d", "e", commission1, coinPos.Amount.Add(sdk.OneInt()), valAddr1, pk1, coinPos, false}, + {"delegation less than min self delegation", "a", "b", "c", "d", "e", commission1, coinPos.Amount.Add(math.OneInt()), valAddr1, pk1, coinPos, false}, } for _, tc := range tests { @@ -98,13 +100,13 @@ func TestMsgEditValidator(t *testing.T) { name, moniker, identity, website, securityContact, details string validatorAddr sdk.ValAddress expectPass bool - minSelfDelegation sdk.Int + minSelfDelegation math.Int }{ - {"basic good", "a", "b", "c", "d", "e", valAddr1, true, sdk.OneInt()}, - {"partial description", "", "", "c", "", "", valAddr1, true, sdk.OneInt()}, - {"empty description", "", "", "", "", "", valAddr1, false, sdk.OneInt()}, - {"empty address", "a", "b", "c", "d", "e", emptyAddr, false, sdk.OneInt()}, - {"nil int", "a", "b", "c", "d", "e", emptyAddr, false, sdk.Int{}}, + {"basic good", "a", "b", "c", "d", "e", valAddr1, true, math.OneInt()}, + {"partial description", "", "", "c", "", "", valAddr1, true, math.OneInt()}, + {"empty description", "", "", "", "", "", valAddr1, false, math.OneInt()}, + {"empty address", "a", "b", "c", "d", "e", emptyAddr, false, math.OneInt()}, + {"nil int", "a", "b", "c", "d", "e", emptyAddr, false, math.Int{}}, } for _, tc := range tests { diff --git a/x/staking/types/params_legacy.go b/x/staking/types/params_legacy.go index 39a125ff4298..499dc7c2f768 100644 --- a/x/staking/types/params_legacy.go +++ b/x/staking/types/params_legacy.go @@ -14,13 +14,13 @@ var ( var _ paramtypes.ParamSet = (*Params)(nil) // ParamTable for staking module -// NOTE: Deprecated now params can be accesed on key `0x51` on the staking store. +// Deprecated: now params can be accesed on key `0x51` on the staking store. func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } // Implements params.ParamSet -// NOTE: Deprecated. +// Deprecated. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyUnbondingTime, &p.UnbondingTime, validateUnbondingTime), diff --git a/x/staking/types/tx.pb.go b/x/staking/types/tx.pb.go index 49d737dff750..97ea3ea7bcd3 100644 --- a/x/staking/types/tx.pb.go +++ b/x/staking/types/tx.pb.go @@ -751,7 +751,7 @@ type MsgClient interface { // // Since: cosmos-sdk 0.46 CancelUnbondingDelegation(ctx context.Context, in *MsgCancelUnbondingDelegation, opts ...grpc.CallOption) (*MsgCancelUnbondingDelegationResponse, error) - // UpdateParams defines a operation for updating the x/staking module + // UpdateParams defines an operation for updating the x/staking module // parameters. // Since: cosmos-sdk 0.47 UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) @@ -848,7 +848,7 @@ type MsgServer interface { // // Since: cosmos-sdk 0.46 CancelUnbondingDelegation(context.Context, *MsgCancelUnbondingDelegation) (*MsgCancelUnbondingDelegationResponse, error) - // UpdateParams defines a operation for updating the x/staking module + // UpdateParams defines an operation for updating the x/staking module // parameters. // Since: cosmos-sdk 0.47 UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index afcec7e168a1..10a1e7dd72c7 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -51,13 +51,13 @@ func NewValidator(operator sdk.ValAddress, pubKey cryptotypes.PubKey, descriptio ConsensusPubkey: pkAny, Jailed: false, Status: Unbonded, - Tokens: sdk.ZeroInt(), + Tokens: math.ZeroInt(), DelegatorShares: sdk.ZeroDec(), Description: description, UnbondingHeight: int64(0), UnbondingTime: time.Unix(0, 0).UTC(), Commission: NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.OneInt(), + MinSelfDelegation: math.OneInt(), }, nil } @@ -352,7 +352,7 @@ func (v Validator) BondedTokens() math.Int { return v.Tokens } - return sdk.ZeroInt() + return math.ZeroInt() } // ConsensusPower gets the consensus-engine power. Aa reduction of 10^6 from @@ -424,7 +424,7 @@ func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, math.Int) { if remainingShares.IsZero() { // last delegation share gets any trimmings issuedTokens = v.Tokens - v.Tokens = sdk.ZeroInt() + v.Tokens = math.ZeroInt() } else { // leave excess tokens in the validator // however fully use all the delegator shares diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index 6e3172e51db2..afccf5a119ab 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -5,6 +5,7 @@ import ( "sort" "testing" + "cosmossdk.io/math" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" tmtypes "github.com/tendermint/tendermint/types" @@ -105,7 +106,7 @@ func TestAddTokensValidatorBonded(t *testing.T) { validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) - assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.BondedTokens())) + assert.True(math.IntEq(t, sdk.NewInt(10), validator.BondedTokens())) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -116,7 +117,7 @@ func TestAddTokensValidatorUnbonding(t *testing.T) { assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) assert.Equal(t, types.Unbonding, validator.Status) - assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.Tokens)) + assert.True(math.IntEq(t, sdk.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -127,7 +128,7 @@ func TestAddTokensValidatorUnbonded(t *testing.T) { assert.True(sdk.DecEq(t, sdk.NewDec(10), delShares)) assert.Equal(t, types.Unbonded, validator.Status) - assert.True(sdk.IntEq(t, sdk.NewInt(10), validator.Tokens)) + assert.True(math.IntEq(t, sdk.NewInt(10), validator.Tokens)) assert.True(sdk.DecEq(t, sdk.NewDec(10), validator.DelegatorShares)) } @@ -151,7 +152,7 @@ func TestRemoveDelShares(t *testing.T) { validator := mkValidator(5102, sdk.NewDec(115)) _, tokens := validator.RemoveDelShares(sdk.NewDec(29)) - require.True(sdk.IntEq(t, sdk.NewInt(1286), tokens)) + require.True(math.IntEq(t, sdk.NewInt(1286), tokens)) } func TestAddTokensFromDel(t *testing.T) { @@ -160,12 +161,12 @@ func TestAddTokensFromDel(t *testing.T) { validator, shares := validator.AddTokensFromDel(sdk.NewInt(6)) require.True(sdk.DecEq(t, sdk.NewDec(6), shares)) require.True(sdk.DecEq(t, sdk.NewDec(6), validator.DelegatorShares)) - require.True(sdk.IntEq(t, sdk.NewInt(6), validator.Tokens)) + require.True(math.IntEq(t, sdk.NewInt(6), validator.Tokens)) validator, shares = validator.AddTokensFromDel(sdk.NewInt(3)) require.True(sdk.DecEq(t, sdk.NewDec(3), shares)) require.True(sdk.DecEq(t, sdk.NewDec(9), validator.DelegatorShares)) - require.True(sdk.IntEq(t, sdk.NewInt(9), validator.Tokens)) + require.True(math.IntEq(t, sdk.NewInt(9), validator.Tokens)) } func TestUpdateStatus(t *testing.T) { diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go index e7e3b0b6803a..1bcfe0a8fcef 100644 --- a/x/upgrade/abci_test.go +++ b/x/upgrade/abci_test.go @@ -8,53 +8,58 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "golang.org/x/exp/maps" - "cosmossdk.io/depinject" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/server" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/module" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govtypesv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/upgrade" "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - "github.com/cosmos/cosmos-sdk/x/upgrade/testutil" + "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) type TestSuite struct { + suite.Suite + module module.BeginBlockAppModule keeper keeper.Keeper - querier sdk.Querier - handler govtypes.Handler + handler govtypesv1beta1.Handler ctx sdk.Context + baseApp *baseapp.BaseApp + encCfg moduletestutil.TestEncodingConfig } var s TestSuite func setupTest(t *testing.T, height int64, skip map[int64]bool) TestSuite { - var ( - legacyAmino *codec.LegacyAmino - appOptions = make(simtestutil.AppOptionsMap, 0) - ) - appOptions[server.FlagUnsafeSkipUpgrades] = maps.Keys(skip) - appOptions[flags.FlagHome] = t.TempDir() + s.encCfg = moduletestutil.MakeTestEncodingConfig(upgrade.AppModuleBasic{}) + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) - appConfig := depinject.Configs(testutil.AppConfig, depinject.Supply(appOptions)) - app, err := simtestutil.Setup(appConfig, &s.keeper, &legacyAmino) - s.keeper.SetVersionSetter(app.BaseApp) - require.NoError(t, err) + s.baseApp = baseapp.NewBaseApp( + "upgrade", + log.NewNopLogger(), + testCtx.DB, + s.encCfg.TxConfig.TxDecoder(), + ) - s.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: height, Time: time.Now()}) + s.keeper = keeper.NewKeeper(skip, key, s.encCfg.Codec, t.TempDir(), nil, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + s.keeper.SetVersionSetter(s.baseApp) + + s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now(), Height: height}) s.module = upgrade.NewAppModule(s.keeper) - s.querier = s.module.LegacyQuerierHandler(legacyAmino) s.handler = upgrade.NewSoftwareUpgradeProposalHandler(s.keeper) return s } @@ -170,9 +175,9 @@ func TestHaltIfTooNew(t *testing.T) { func VerifyCleared(t *testing.T, newCtx sdk.Context) { t.Log("Verify that the upgrade plan has been cleared") - bz, err := s.querier(newCtx, []string{types.QueryCurrent}, abci.RequestQuery{}) - require.NoError(t, err) - require.Nil(t, bz, string(bz)) + plan, _ := s.keeper.GetUpgradePlan(newCtx) + expected := types.Plan{} + require.Equal(t, plan, expected) } func TestCanClear(t *testing.T) { diff --git a/x/upgrade/client/testutil/cli_test.go b/x/upgrade/client/testutil/cli_test.go deleted file mode 100644 index 039ec3ee2f58..000000000000 --- a/x/upgrade/client/testutil/cli_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package testutil - -import ( - "testing" - - "github.com/stretchr/testify/suite" - - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil/network" -) - -func TestIntegrationTestSuite(t *testing.T) { - cfg := network.DefaultConfig(simapp.NewTestNetworkFixture) - cfg.NumValidators = 1 - suite.Run(t, NewIntegrationTestSuite(cfg)) -} diff --git a/x/upgrade/client/testutil/suite.go b/x/upgrade/client/testutil/suite.go index 9e5eca3b2349..37b356f4aad0 100644 --- a/x/upgrade/client/testutil/suite.go +++ b/x/upgrade/client/testutil/suite.go @@ -4,9 +4,7 @@ import ( "fmt" "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/simapp" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" @@ -15,8 +13,12 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) -func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite { - return &IntegrationTestSuite{cfg: cfg} +func NewIntegrationTestSuite(cfg network.Config, keeper keeper.Keeper, ctx sdk.Context) *IntegrationTestSuite { + return &IntegrationTestSuite{ + cfg: cfg, + upgradeKeeper: keeper, + ctx: ctx, + } } type IntegrationTestSuite struct { @@ -31,14 +33,6 @@ type IntegrationTestSuite struct { func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") - app := simapp.Setup(s.T(), false) - s.upgradeKeeper = app.UpgradeKeeper - - s.ctx = app.BaseApp.NewContext(false, tmproto.Header{}) - - s.upgradeKeeper.SetVersionSetter(app.BaseApp) - s.upgradeKeeper.SetModuleVersionMap(s.ctx, app.ModuleManager.GetVersionMap()) - var err error s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg) s.Require().NoError(err) diff --git a/x/upgrade/keeper/grpc_query_test.go b/x/upgrade/keeper/grpc_query_test.go index 39600ba96fc4..6c98948411fa 100644 --- a/x/upgrade/keeper/grpc_query_test.go +++ b/x/upgrade/keeper/grpc_query_test.go @@ -6,17 +6,17 @@ import ( "testing" "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/upgrade" + "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - "github.com/cosmos/cosmos-sdk/x/upgrade/testutil" "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) @@ -26,19 +26,24 @@ type UpgradeTestSuite struct { upgradeKeeper keeper.Keeper ctx sdk.Context queryClient types.QueryClient + encCfg moduletestutil.TestEncodingConfig } func (suite *UpgradeTestSuite) SetupTest() { - var interfaceRegistry codectypes.InterfaceRegistry - app, err := simtestutil.Setup(testutil.AppConfig, &interfaceRegistry, &suite.upgradeKeeper) - suite.NoError(err) - suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{}) + suite.encCfg = moduletestutil.MakeTestEncodingConfig(upgrade.AppModuleBasic{}) + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(suite.T(), key, sdk.NewTransientStoreKey("transient_test")) + suite.ctx = testCtx.Ctx + + skipUpgradeHeights := make(map[int64]bool) - suite.upgradeKeeper.SetVersionSetter(app.BaseApp) - suite.upgradeKeeper.SetModuleVersionMap(suite.ctx, app.ModuleManager.GetVersionMap()) + suite.upgradeKeeper = keeper.NewKeeper(skipUpgradeHeights, key, suite.encCfg.Codec, "", nil, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + suite.upgradeKeeper.SetModuleVersionMap(suite.ctx, module.VersionMap{ + "bank": 0, + }) - queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, interfaceRegistry) + queryHelper := baseapp.NewQueryServerTestHelper(testCtx.Ctx, suite.encCfg.InterfaceRegistry) types.RegisterQueryServer(queryHelper, suite.upgradeKeeper) suite.queryClient = types.NewQueryClient(queryHelper) } diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index d2e8274f6c95..f087f12910fa 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -6,17 +6,19 @@ import ( "time" "github.com/stretchr/testify/suite" + "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "cosmossdk.io/depinject" "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/testutil" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/upgrade" "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" - "github.com/cosmos/cosmos-sdk/x/upgrade/testutil" "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) @@ -29,29 +31,34 @@ type KeeperTestSuite struct { ctx sdk.Context msgSrvr types.MsgServer addrs []sdk.AccAddress + encCfg moduletestutil.TestEncodingConfig } func (s *KeeperTestSuite) SetupTest() { - var ( - bankKeeper bankkeeper.Keeper - stakingKeeper *stakingkeeper.Keeper + + s.encCfg = moduletestutil.MakeTestEncodingConfig(upgrade.AppModuleBasic{}) + key := sdk.NewKVStoreKey(types.StoreKey) + testCtx := testutil.DefaultContextWithDB(s.T(), key, sdk.NewTransientStoreKey("transient_test")) + + s.baseApp = baseapp.NewBaseApp( + "upgrade", + log.NewNopLogger(), + testCtx.DB, + s.encCfg.TxConfig.TxDecoder(), ) + skipUpgradeHeights := make(map[int64]bool) + homeDir := filepath.Join(s.T().TempDir(), "x_upgrade_keeper_test") - appConfig := depinject.Configs(testutil.AppConfig, depinject.Supply(simtestutil.NewAppOptionsWithFlagHome(homeDir))) - app, err := simtestutil.Setup(appConfig, &s.upgradeKeeper, &bankKeeper, &stakingKeeper) - s.NoError(err) - s.upgradeKeeper.SetVersionSetter(app.BaseApp) + s.upgradeKeeper = keeper.NewKeeper(skipUpgradeHeights, key, s.encCfg.Codec, homeDir, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + s.upgradeKeeper.SetVersionSetter(s.baseApp) s.T().Log("home dir:", homeDir) s.homeDir = homeDir - s.ctx = app.BaseApp.NewContext(false, tmproto.Header{ - Time: time.Now(), - Height: 10, - }) + s.ctx = testCtx.Ctx.WithBlockHeader(tmproto.Header{Time: time.Now(), Height: 10}) + s.msgSrvr = keeper.NewMsgServerImpl(s.upgradeKeeper) - s.addrs = simtestutil.AddTestAddrsIncremental(bankKeeper, stakingKeeper, s.ctx, 1, sdk.NewInt(30000000)) - s.baseApp = app.BaseApp + s.addrs = simtestutil.CreateIncrementalAccounts(1) } func (s *KeeperTestSuite) TestReadUpgradeInfoFromDisk() { diff --git a/x/upgrade/keeper/querier.go b/x/upgrade/keeper/querier.go deleted file mode 100644 index 227d770f2068..000000000000 --- a/x/upgrade/keeper/querier.go +++ /dev/null @@ -1,64 +0,0 @@ -package keeper - -import ( - "encoding/binary" - - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/cosmos/cosmos-sdk/x/upgrade/types" - - abci "github.com/tendermint/tendermint/abci/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -// NewQuerier creates a querier for upgrade cli and REST endpoints -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) ([]byte, error) { - switch path[0] { - - case types.QueryCurrent: - return queryCurrent(ctx, req, k, legacyQuerierCdc) - - case types.QueryApplied: - return queryApplied(ctx, req, k, legacyQuerierCdc) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown %s query endpoint: %s", types.ModuleName, path[0]) - } - } -} - -func queryCurrent(ctx sdk.Context, _ abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - plan, has := k.GetUpgradePlan(ctx) - if !has { - return nil, nil - } - - res, err := legacyQuerierCdc.MarshalJSON(&plan) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return res, nil -} - -func queryApplied(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryAppliedPlanRequest - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - applied := k.GetDoneHeight(ctx, params.Name) - if applied == 0 { - return nil, nil - } - - bz := make([]byte, 8) - binary.BigEndian.PutUint64(bz, uint64(applied)) - - return bz, nil -} diff --git a/x/upgrade/module.go b/x/upgrade/module.go index a3138ddf8079..24de870db39c 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -96,19 +96,6 @@ func NewAppModule(keeper keeper.Keeper) AppModule { // RegisterInvariants does nothing, there are no invariants to enforce func (AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} -// Deprecated: Route returns the message routing key for the upgrade module. -func (AppModule) Route() sdk.Route { - return sdk.Route{} -} - -// QuerierRoute returns the route we respond to for abci queries -func (AppModule) QuerierRoute() string { return types.QuerierKey } - -// LegacyQuerierHandler registers a query handler to respond to the module-specific queries -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) -} - // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) diff --git a/x/upgrade/spec/05_resources.md b/x/upgrade/spec/05_resources.md new file mode 100644 index 000000000000..7652ca7cc40f --- /dev/null +++ b/x/upgrade/spec/05_resources.md @@ -0,0 +1,9 @@ + + +# Resources + +A list of (external) resources to learn more about the `x/upgrade` module. + +- [Cosmos Dev Series: Cosmos Blockchain Upgrade](https://medium.com/web3-surfers/cosmos-dev-series-cosmos-sdk-based-blockchain-upgrade-b5e99181554c) - The blog post that explains how software upgrades work in detail. \ No newline at end of file diff --git a/x/upgrade/spec/README.md b/x/upgrade/spec/README.md index 73ea2268ac78..3fa09906eabd 100644 --- a/x/upgrade/spec/README.md +++ b/x/upgrade/spec/README.md @@ -29,3 +29,4 @@ recover from. * [CLI](04_client.md#cli) * [REST](04_client.md#rest) * [gRPC](04_client.md#grpc) +5. **[Resources](05_resources.md)** diff --git a/x/upgrade/testutil/app.yaml b/x/upgrade/testutil/app.yaml deleted file mode 100644 index 5bc0bd1dacbb..000000000000 --- a/x/upgrade/testutil/app.yaml +++ /dev/null @@ -1,51 +0,0 @@ -modules: - - name: runtime - config: - "@type": cosmos.app.runtime.v1alpha1.Module - - app_name: UpgradeApp - - begin_blockers: [upgrade, mint, staking, auth, bank, genutil, params] - end_blockers: [staking, auth, bank, mint, genutil, params, upgrade] - init_genesis: [auth, bank, staking, mint, genutil, params, upgrade] - - - name: auth - config: - "@type": cosmos.auth.module.v1.Module - bech32_prefix: cosmos - module_account_permissions: - - account: fee_collector - - account: mint - permissions: [minter] - - account: bonded_tokens_pool - permissions: [burner, staking] - - account: not_bonded_tokens_pool - permissions: [burner, staking] - - - name: bank - config: - "@type": cosmos.bank.module.v1.Module - - - name: params - config: - "@type": cosmos.params.module.v1.Module - - - name: tx - config: - "@type": cosmos.tx.module.v1.Module - - - name: staking - config: - "@type": cosmos.staking.module.v1.Module - - - name: genutil - config: - "@type": cosmos.genutil.module.v1.Module - - - name: mint - config: - "@type": cosmos.mint.module.v1.Module - - - name: upgrade - config: - "@type": cosmos.upgrade.module.v1.Module diff --git a/x/upgrade/testutil/app_config.go b/x/upgrade/testutil/app_config.go deleted file mode 100644 index fb0517a4f7f8..000000000000 --- a/x/upgrade/testutil/app_config.go +++ /dev/null @@ -1,20 +0,0 @@ -package testutil - -import ( - _ "embed" - - "cosmossdk.io/core/appconfig" - _ "github.com/cosmos/cosmos-sdk/x/auth" - _ "github.com/cosmos/cosmos-sdk/x/auth/tx/module" - _ "github.com/cosmos/cosmos-sdk/x/bank" - _ "github.com/cosmos/cosmos-sdk/x/genutil" - _ "github.com/cosmos/cosmos-sdk/x/mint" - _ "github.com/cosmos/cosmos-sdk/x/params" - _ "github.com/cosmos/cosmos-sdk/x/staking" - _ "github.com/cosmos/cosmos-sdk/x/upgrade" -) - -//go:embed app.yaml -var appConfig []byte - -var AppConfig = appconfig.LoadYAML(appConfig) diff --git a/x/upgrade/types/keys.go b/x/upgrade/types/keys.go index 45128fc70495..0307fff10bfd 100644 --- a/x/upgrade/types/keys.go +++ b/x/upgrade/types/keys.go @@ -11,9 +11,6 @@ const ( // StoreKey is the prefix under which we store this module's data StoreKey = ModuleName - - // QuerierKey is used to handle abci_query requests - QuerierKey = ModuleName ) const (