diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a205981912b2..97cd90d025c9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/setup-go@v2.1.4 with: - go-version: 1.16 + go-version: 1.17 - uses: technote-space/get-diff-action@v5 id: git_diff with: diff --git a/.github/workflows/proto-docker.yml b/.github/workflows/proto-docker.yml deleted file mode 100644 index e59eeda18bca..000000000000 --- a/.github/workflows/proto-docker.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: Build & Push SDK Proto Builder -on: - pull_request: - push: - branches: - - master - paths: - - "contrib/devtools/dockerfile" - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Prepare - id: prep - run: | - DOCKER_IMAGE=tendermintdev/sdk-proto-gen - VERSION=noop - if [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/} - elif [[ $GITHUB_REF == refs/heads/* ]]; then - VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') - if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then - VERSION=latest - fi - fi - TAGS="${DOCKER_IMAGE}:${VERSION}" - echo ::set-output name=tags::${TAGS} - - - name: Set up QEMU - uses: docker/setup-qemu-action@master - with: - platforms: all - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Login to DockerHub - if: ${{ github.event_name != 'pull_request' }} - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUBTM_USERNAME }} - password: ${{ secrets.DOCKERHUBTM_TOKEN }} - - - name: Publish to Docker Hub - uses: docker/build-push-action@v2 - with: - context: ./contrib/devtools - file: ./contrib/devtools/dockerfile - platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.prep.outputs.tags }} diff --git a/.github/workflows/sims.yml b/.github/workflows/sims.yml index f239c877f050..21b7df21a4d7 100644 --- a/.github/workflows/sims.yml +++ b/.github/workflows/sims.yml @@ -15,7 +15,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - name: Display go version run: go version - run: make build @@ -26,7 +26,7 @@ jobs: steps: - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - name: Display go version run: go version - name: Install runsim @@ -43,7 +43,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - name: Display go version run: go version - uses: technote-space/get-diff-action@v4 @@ -69,7 +69,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - name: Display go version run: go version - uses: technote-space/get-diff-action@v4 @@ -97,7 +97,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - name: Display go version run: go version - uses: technote-space/get-diff-action@v4 @@ -125,7 +125,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - name: Display go version run: go version - uses: technote-space/get-diff-action@v4 diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 70365ef17923..19d2d9f1f5ed 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -15,7 +15,7 @@ jobs: - name: Install Go uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - name: Unshallow run: git fetch --prune --unshallow - name: Create release diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 782458272335..92de857521ec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - name: Display go version run: go version - name: install tparse @@ -32,7 +32,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - uses: technote-space/get-diff-action@v4 id: git_diff with: @@ -49,7 +49,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - name: Display go version run: go version - uses: technote-space/get-diff-action@v4 @@ -102,7 +102,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - uses: technote-space/get-diff-action@v4 with: PATTERNS: | @@ -180,7 +180,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - uses: technote-space/get-diff-action@v4 with: PATTERNS: | @@ -224,7 +224,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v2.1.3 with: - go-version: 1.16 + go-version: 1.17 - uses: technote-space/get-diff-action@v4 id: git_diff with: @@ -234,7 +234,7 @@ jobs: go.sum - name: start localnet run: | - make clean build-simd-linux localnet-start + make clean localnet-start if: env.GIT_DIFF - name: test liveness run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index a739b8767615..63f34326d9b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,23 +37,59 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## [v0.45.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.4) - 2022-04-25 + +### Bug Fixes + +* [\#11624](https://github.com/cosmos/cosmos-sdk/pull/11624) Handle the error returned from `NewNode` in the `server` package. +* [\#11724](https://github.com/cosmos/cosmos-sdk/pull/11724) Fix data race issues with `api.Server`. + +### Improvements + +* [\#11693](https://github.com/cosmos/cosmos-sdk/pull/11693) Add validation for gentx cmd. +* [\#11686](https://github.com/cosmos/cosmos-sdk/pull/11686) Update the min required Golang version to `1.17`. +* (x/auth/vesting) [\#11652](https://github.com/cosmos/cosmos-sdk/pull/11652) Add util functions for `Period(s)` + +## [v0.45.3](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.3) - 2022-04-12 + +### Improvements + +* [\#11562](https://github.com/cosmos/cosmos-sdk/pull/11562) Updated Tendermint to v0.34.19; `unsafe-reset-all` command has been moved to the `tendermint` sub-command. + +### Features + +* (x/upgrade) [\#11551](https://github.com/cosmos/cosmos-sdk/pull/11551) Update `ScheduleUpgrade` for chains to schedule an automated upgrade on `BeginBlock` without having to go though governance. + +## [v0.45.2](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.2) - 2022-04-05 + ### Features +* (tx) [#\11533](https://github.com/cosmos/cosmos-sdk/pull/11533) Register [`EIP191`](https://eips.ethereum.org/EIPS/eip-191) as an available `SignMode` for chains to use. +* [\#11430](https://github.com/cosmos/cosmos-sdk/pull/11430) Introduce a new `grpc-only` flag, such that when enabled, will start the node in a query-only mode. Note, gRPC MUST be enabled with this flag. +* (x/bank) [\#11417](https://github.com/cosmos/cosmos-sdk/pull/11417) Introduce a new `SpendableBalances` gRPC query that retrieves an account's total (paginated) spendable balances. * (x/bank) [\#10771](https://github.com/cosmos/cosmos-sdk/pull/10771) Add safety check on bank module perms to allow module-specific mint restrictions (e.g. only minting a certain denom). * (x/bank) [\#10771](https://github.com/cosmos/cosmos-sdk/pull/10771) Add `bank.BankKeeper.WithMintCoinsRestriction` function to restrict use of bank `MintCoins` usage. This function is not on the bank `Keeper` interface, so it's not API-breaking, but only additive on the keeper implementation. +* [\#10944](https://github.com/cosmos/cosmos-sdk/pull/10944) `x/authz` add all grants by grantee query * [\#11124](https://github.com/cosmos/cosmos-sdk/pull/11124) Add `GetAllVersions` to application store * (x/auth) [\#10880](https://github.com/cosmos/cosmos-sdk/pull/10880) Added a new query to the tx query service that returns a block with transactions fully decoded. - +* [#11314](https://github.com/cosmos/cosmos-sdk/pull/11314) Add state rollback command. +* (x/staking) [\#11596](https://github.com/cosmos/cosmos-sdk/pull/11596) Add (re)delegation getters ### Bug Fixes +* [\#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. +* (client) [\#11283](https://github.com/cosmos/cosmos-sdk/issues/11283) Support multiple keys for tx simulation and setting automatic gas for txs. * (store) [\#11177](https://github.com/cosmos/cosmos-sdk/pull/11177) Update the prune `everything` strategy to store the last two heights. * (store) [\#11117](https://github.com/cosmos/cosmos-sdk/pull/11117) Fix data race in store trace component +* (x/authz) [\#11252](https://github.com/cosmos/cosmos-sdk/pull/11252) Allow insufficient funds error for authz simulation +* (crypto) [\#11298](https://github.com/cosmos/cosmos-sdk/pull/11298) Fix cgo secp signature verification and update libscep256k1 library. ### Improvements * [\#9576](https://github.com/cosmos/cosmos-sdk/pull/9576) Add debug error message to query result when enabled * (types) [\#11200](https://github.com/cosmos/cosmos-sdk/pull/11200) Added `Min()` and `Max()` operations on sdk.Coins. +* [#11267](https://github.com/cosmos/cosmos-sdk/pull/11267) Add hooks to allow app modules to add things to state-sync (backport #10961). ## [v0.45.1](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.1) - 2022-02-03 @@ -102,7 +138,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes -* (std/codec) [/#10595](https://github.com/cosmos/cosmos-sdk/pull/10595) Add evidence to std/codec to be able to decode evidence in client interactions. +* (std/codec) [/#10595](https://github.com/cosmos/cosmos-sdk/pull/10595) Add evidence to std/codec to be able to decode evidence in client interactions. * (types) [\#9627](https://github.com/cosmos/cosmos-sdk/pull/9627) Fix nil pointer panic on `NewBigIntFromInt`. * [#10725](https://github.com/cosmos/cosmos-sdk/pull/10725) populate `ctx.ConsensusParams` for begin/end blockers. * [\#9829](https://github.com/cosmos/cosmos-sdk/pull/9829) Fixed Coin denom sorting not being checked during `Balance.Validate` check. Refactored the Validation logic to use `Coins.Validate` for `Balance.Coins` @@ -112,7 +148,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements -* (baseapp) [\#10631](https://github.com/cosmos/cosmos-sdk/pull/10631) Emit ante events even for the failed txs. +* (baseapp) [\#10631](https://github.com/cosmos/cosmos-sdk/pull/10631) Emit ante events even for the failed txs. ### Features diff --git a/Makefile b/Makefile index 598a4acb1678..049773edb69d 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,10 @@ ifeq (cleveldb,$(findstring cleveldb,$(COSMOS_BUILD_OPTIONS))) build_tags += gcc endif +ifeq (secp,$(findstring secp,$(COSMOS_BUILD_OPTIONS))) + build_tags += libsecp256k1_sdk +endif + whitespace := whitespace += $(whitespace) comma := , @@ -108,7 +112,7 @@ BUILD_TARGETS := build install build: BUILD_ARGS=-o $(BUILDDIR)/ build-linux: - GOOS=linux GOARCH=amd64 LEDGER_ENABLED=false $(MAKE) build + GOOS=linux GOARCH=$(if $(findstring aarch64,$(shell uname -m)) || $(findstring arm64,$(shell uname -m)),arm64,amd64) LEDGER_ENABLED=false $(MAKE) build $(BUILD_TARGETS): go.sum $(BUILDDIR)/ go $@ -mod=readonly $(BUILD_FLAGS) $(BUILD_ARGS) ./... @@ -116,33 +120,10 @@ $(BUILD_TARGETS): go.sum $(BUILDDIR)/ $(BUILDDIR)/: mkdir -p $(BUILDDIR)/ -build-simd-all: go.sum - $(DOCKER) rm latest-build || true - $(DOCKER) run --volume=$(CURDIR):/sources:ro \ - --env TARGET_PLATFORMS='linux/amd64 darwin/amd64 linux/arm64 windows/amd64' \ - --env APP=simd \ - --env VERSION=$(VERSION) \ - --env COMMIT=$(COMMIT) \ - --env LEDGER_ENABLED=$(LEDGER_ENABLED) \ - --name latest-build cosmossdk/rbuilder:latest - $(DOCKER) cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/ - -build-simd-linux: go.sum $(BUILDDIR)/ - $(DOCKER) rm latest-build || true - $(DOCKER) run --volume=$(CURDIR):/sources:ro \ - --env TARGET_PLATFORMS='linux/amd64' \ - --env APP=simd \ - --env VERSION=$(VERSION) \ - --env COMMIT=$(COMMIT) \ - --env LEDGER_ENABLED=false \ - --name latest-build cosmossdk/rbuilder:latest - $(DOCKER) cp -a latest-build:/home/builder/artifacts/ $(CURDIR)/ - cp artifacts/simd-*-linux-amd64 $(BUILDDIR)/simd - cosmovisor: $(MAKE) -C cosmovisor cosmovisor -.PHONY: build build-linux build-simd-all build-simd-linux cosmovisor +.PHONY: build build-linux cosmovisor mockgen_cmd=go run github.com/golang/mock/mockgen @@ -480,26 +461,40 @@ proto-update-deps: ### Localnet ### ############################################################################### -# Run a 4-node testnet locally -localnet-start: build-linux localnet-stop - $(if $(shell $(DOCKER) inspect -f '{{ .Id }}' cosmossdk/simd-env 2>/dev/null),$(info found image cosmossdk/simd-env),$(MAKE) -C contrib/images simd-env) - $(DOCKER) run --rm -v $(CURDIR)/localnet:/data cosmossdk/simd-env \ - testnet init-files --v 4 -o /data --starting-ip-address 192.168.10.2 --keyring-backend=test +localnet-build-env: + $(MAKE) -C contrib/images simd-env + +localnet-build-dlv: + $(MAKE) -C contrib/images simd-dlv + +localnet-build-nodes: + $(DOCKER) run --rm -v $(CURDIR)/.testnets:/data cosmossdk/simd \ + testnet init-files --v 4 -o /data --starting-ip-address 192.168.10.2 --keyring-backend=test docker-compose up -d localnet-stop: docker-compose down -.PHONY: localnet-start localnet-stop +# localnet-start will run a 4-node testnet locally. The nodes are +# based off the docker images in: ./contrib/images/simd-env +localnet-start: localnet-stop localnet-build-env localnet-build-nodes + +# localnet-debug will run a 4-node testnet locally in debug mode +# you can read more about the debug mode here: ./contrib/images/simd-dlv/README.md +localnet-debug: localnet-stop localnet-build-dlv localnet-build-nodes + +.PHONY: localnet-start localnet-stop localnet-debug localnet-build-env \ +localnet-build-dlv localnet-build-nodes ############################################################################### ### rosetta ### ############################################################################### -# builds rosetta test data dir + rosetta-data: -docker container rm data_dir_build docker build -t rosetta-ci:latest -f contrib/rosetta/node/Dockerfile . docker run --name data_dir_build -t rosetta-ci:latest sh /rosetta/data.sh docker cp data_dir_build:/tmp/data.tar.gz "$(CURDIR)/contrib/rosetta/node/data.tar.gz" docker container rm data_dir_build + .PHONY: rosetta-data diff --git a/README.md b/README.md index f9f6bedc51e2..43ccc56cc255 100644 --- a/README.md +++ b/README.md @@ -1,73 +1,84 @@ - - -
-

Cosmos SDK

-
- -![banner](docs/cosmos-sdk-image.jpg) - -
- - Version - - - License: Apache-2.0 - - - GoDoc - - - Go report card - - - Code Coverage - -
-
- - Lines Of Code - - - Discord - - - Imported by - - Sims - Lint Satus -
- -The Cosmos-SDK is a framework for building blockchain applications in Golang. -It is being used to build [`Gaia`](https://github.com/cosmos/gaia), the first implementation of the Cosmos Hub. - -**WARNING**: The SDK has mostly stabilized, but we are still making some -breaking changes. - -**Note**: Requires [Go 1.15+](https://golang.org/dl/) - -## Quick Start - -To learn how the SDK works from a high-level perspective, go to the [SDK Intro](./docs/intro/overview.md). - -If you want to get started quickly and learn how to build on top of the SDK, please follow the [SDK Application Tutorial](https://tutorials.cosmos.network/nameservice/tutorial/00-intro.html). You can also fork the tutorial's repository to get started building your own Cosmos SDK application. - -For more, please go to the [Cosmos SDK Docs](./docs/). - -## Cosmos Hub Mainnet - -The Cosmos Hub application, `gaia`, has moved to its [own repository](https://github.com/cosmos/gaia). Go there to join the Cosmos Hub mainnet and more. - -## Interblockchain Communication (IBC) - -The IBC module for the SDK has moved to its [own repository](https://github.com/cosmos/ibc-go). Go there to build and integrate with the IBC module. - -## Starport - -If you are starting a new app or a new module you can use [Starport](https://github.com/tendermint/starport) to help you get started and speed up development. If you have any questions or find a bug, feel free to open an issue in the repo. - -## Disambiguation - -This Cosmos-SDK project is not related to the [React-Cosmos](https://github.com/react-cosmos/react-cosmos) project (yet). Many thanks to Evan Coury and Ovidiu (@skidding) for this Github organization name. As per our agreement, this disambiguation notice will stay here. + + +
+

Cosmos SDK

+
+ +![banner](docs/cosmos-sdk-image.jpg) + +
+ + Version + + + License: Apache-2.0 + + + GoDoc + + + Go report card + + + Code Coverage + +
+
+ + Lines Of Code + + + Discord + + + Imported by + + Sims + Lint Satus +
+ +The Cosmos SDK is a framework for building blockchain applications. [Tendermint Core (BFT Consensus)](https://github.com/tendermint/tendermint) and the Cosmos SDK are written in the Golang programming language. Cosmos SDK is used to build [Gaia](https://github.com/cosmos/gaia), the first implementation of the Cosmos Hub. + +**WARNING**: The Cosmos SDK has mostly stabilized, but we are still making some +breaking changes. + +**Note**: Requires [Go 1.17+](https://golang.org/dl/) + +## Quick Start + +To learn how the Cosmos SDK works from a high-level perspective, see the Cosmos SDK [High-Level Intro](./docs/intro/overview.md). + +If you want to get started quickly and learn how to build on top of Cosmos SDK, visit [Cosmos SDK Tutorials](https://tutorials.cosmos.network). You can also fork the tutorial's repository to get started building your own Cosmos SDK application. + +For more information, see the [Cosmos SDK Documentation](./docs/). + +## Contributing + +See [CONTRIBUTING.md](./CONTRIBUTING.md) for details how to contribute and participate in our [dev calls](./CONTRIBUTING.md#teams-dev-calls). +If you want to follow the updates or learn more about the latest design then join our [Discord](https://discord.com/invite/cosmosnetwork). + +## Tools and Frameworks + +The Cosmos ecosystem is vast. We will only make a few notable mentions here. + ++ [Tools](https://v1.cosmos.network/tools): notable frameworks and modules. ++ [CosmJS](https://github.com/cosmos/cosmjs): the Swiss Army knife to power JavaScript based client solutions. + +### Cosmos Hub Mainnet + +The Cosmos Hub application, `gaia`, has moved to its own [cosmos/gaia repository](https://github.com/cosmos/gaia). Go there to join the Cosmos Hub mainnet and more. + +### Inter-Blockchain Communication (IBC) + +The IBC module for the Cosmos SDK has moved to its own [cosmos/ibc-go repository](https://github.com/cosmos/ibc-go). Go there to build and integrate with the IBC module. + +### Ignite CLI + +Ignite CLI is the all-in-one platform to build, launch, and maintain any crypto application on a sovereign and secured blockchain. If you are building a new app or a new module, use [Ignite CLI](https://github.com/ignite-hq/cli) to get started and speed up development. + +## Disambiguation + +This Cosmos SDK project is not related to the [React-Cosmos](https://github.com/react-cosmos/react-cosmos) project (yet). Many thanks to Evan Coury and Ovidiu (@skidding) for this Github organization name. As per our agreement, this disambiguation notice will stay here. diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 313c4105b324..90c0a5c0377c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,14 +1,10 @@ -# Cosmos SDK v0.45.0 Release Notes +# Cosmos SDK v0.45.4 Release Notes -This release introduces bug fixes and improvements on the Cosmos SDK v0.45 series: - -Highlights -+ Added the missing `iavl-cache-size` config parameter parsing to set a desired IAVL cache size. The default value is way to small for big chains, and causes OOM failures. -+ Added a check in `x/upgrade` module's `BeginBlock` preventing accidental binary downgrades -+ Fix: the `/cosmos/tx/v1beta1/txs/{hash}` endpoint returns correct return code (404) for a non existing tx. - -See the [Cosmos SDK v0.45.1 Changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.45.1/CHANGELOG.md) for the exhaustive list of all changes and check other fixes in 0.45.x release series. - -**Full Diff**: https://github.com/cosmos/cosmos-sdk/compare/v0.45.0...v0.45.1 +This release introduces a few bug fixes and improvements. Notably, it adds an +error check to the `NewNode` call in the `server` package, which would allow nodes +to sync correctly. +See the [Cosmos SDK v0.45.4 Changelog](https://github.com/cosmos/cosmos-sdk/blob/v0.45.4/CHANGELOG.md) +for the exhaustive list of all changes. +**Full Commit History**: https://github.com/cosmos/cosmos-sdk/compare/v0.45.3...v0.45.4 diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 3a73f6ef20d9..023610bc55af 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -273,6 +273,22 @@ func DefaultStoreLoader(ms sdk.CommitMultiStore) error { return ms.LoadLatestVersion() } +// CommitMultiStore returns the root multi-store. +// App constructor can use this to access the `cms`. +// UNSAFE: only safe to use during app initialization. +func (app *BaseApp) CommitMultiStore() sdk.CommitMultiStore { + if app.sealed { + panic("cannot call CommitMultiStore() after baseapp is sealed") + } + return app.cms +} + +// SnapshotManager returns the snapshot manager. +// application use this to register extra extension snapshotters. +func (app *BaseApp) SnapshotManager() *snapshots.Manager { + return app.snapshotManager +} + // LoadVersion loads the BaseApp application version. It will panic if called // more than once on a running baseapp. func (app *BaseApp) LoadVersion(version int64) error { diff --git a/client/cmd.go b/client/cmd.go index 0e401a9250f6..6ea3b3e66fba 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -250,7 +250,6 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err clientCtx = clientCtx.WithSignModeStr(flags.SignModeLegacyAminoJSON) } } - return clientCtx, nil } diff --git a/client/docs/swagger_legacy.yaml b/client/docs/swagger_legacy.yaml index dfd2f8a90c79..cd718851741e 100644 --- a/client/docs/swagger_legacy.yaml +++ b/client/docs/swagger_legacy.yaml @@ -9,25 +9,6 @@ tags: description: Search, encode, or broadcast transactions. - name: Tendermint RPC description: Tendermint APIs, such as query blocks, transactions and validatorset - - name: Auth - description: Authenticate accounts - - name: Bank - description: Create and broadcast transactions - - name: Staking - description: Stake module APIs - - name: Governance - description: Governance module APIs - - name: Slashing - description: Slashing module APIs - - name: Distribution - description: Fee distribution module APIs - - name: Supply - description: Supply module APIs - - name: version - - name: Mint - description: Minting module APIs - - name: Misc - description: Query app version schemes: - https host: api.cosmos.network @@ -217,1767 +198,6 @@ paths: description: Invalid height 500: description: Server internal error - /txs/{hash}: - get: - deprecated: true - summary: Get a Tx by hash - tags: - - Transactions - description: Retrieve a transaction using its hash. - produces: - - application/json - parameters: - - in: path - name: hash - description: Tx hash - required: true - type: string - x-example: BCBE20E8D46758B96AE5883B792858296AC06E51435490FBDCAE25A72B3CC76B - responses: - 200: - description: Tx with the provided hash - schema: - $ref: "#/definitions/TxQuery" - 500: - description: Internal Server Error - /txs: - get: - deprecated: true - tags: - - Transactions - summary: Search transactions - description: Search transactions by events. - produces: - - application/json - parameters: - - in: query - name: message.action - type: string - description: "transaction events such as 'message.action=send' which results in the following endpoint: 'GET /txs?message.action=send'. note that each module documents its own events. look for xx_events.md in the corresponding cosmos-sdk/docs/spec directory" - x-example: "send" - - in: query - name: message.sender - type: string - description: "transaction tags with sender: 'GET /txs?message.action=send&message.sender=cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv'" - x-example: "cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv" - - in: query - name: page - description: Page number - type: integer - x-example: 1 - - in: query - name: limit - description: Maximum number of items per page - type: integer - x-example: 1 - - in: query - name: tx.minheight - type: integer - description: "transactions on blocks with height greater or equal this value" - x-example: 25 - - in: query - name: tx.maxheight - type: integer - description: "transactions on blocks with height less than or equal this value" - x-example: 800000 - responses: - 200: - description: All txs matching the provided events - schema: - $ref: "#/definitions/PaginatedQueryTxs" - 400: - description: Invalid search events - 500: - description: Internal Server Error - post: - tags: - - Transactions - summary: Broadcast a signed tx - description: Broadcast a signed tx to a full node - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: txBroadcast - description: The tx must be a signed StdTx. The supported broadcast modes include `"block"`(return after tx commit), `"sync"`(return afer CheckTx) and `"async"`(return right away). - required: true - schema: - type: object - properties: - tx: - $ref: "#/definitions/StdTx" - mode: - type: string - example: block - responses: - 200: - description: Tx broadcasting result - schema: - $ref: "#/definitions/BroadcastTxCommitResult" - 500: - description: Internal Server Error - /txs/encode: - post: - deprecated: true - tags: - - Transactions - summary: Encode a transaction to the Amino wire format - description: Encode a transaction (signed or not) from JSON to base64-encoded Amino serialized bytes - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: tx - description: The tx to encode - required: true - schema: - type: object - properties: - tx: - $ref: "#/definitions/StdTx" - responses: - 200: - description: The tx was successfully decoded and re-encoded - schema: - type: object - properties: - tx: - type: string - example: The base64-encoded Amino-serialized bytes for the tx - 400: - description: The tx was malformated - 500: - description: Server internal error - /txs/decode: - post: - deprecated: true - tags: - - Transactions - summary: Decode a transaction from the Amino wire format - description: Decode a transaction (signed or not) from base64-encoded Amino serialized bytes to JSON - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: tx - description: The tx to decode - required: true - schema: - type: object - properties: - tx: - type: string - example: SvBiXe4KPqijYZoKFFHEzJ8c2HPAfv2EFUcIhx0yPagwEhTy0vPA+GGhCEslKXa4Af0uB+mfShoMCgVzdGFrZRIDMTAwEgQQwJoM - responses: - 200: - description: The tx was successfully decoded - schema: - $ref: "#/definitions/StdTx" - 400: - description: The tx was malformated - 500: - description: Server internal error - /bank/balances/{address}: - get: - deprecated: true - summary: Get the account balances - tags: - - Bank - produces: - - application/json - parameters: - - in: path - name: address - description: Account address in bech32 format - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - responses: - 200: - description: Account balances - schema: - type: array - items: - $ref: "#/definitions/Coin" - 500: - description: Server internal error - /bank/accounts/{address}/transfers: - post: - deprecated: true - summary: Send coins from one account to another - tags: - - Bank - consumes: - - application/json - produces: - - application/json - parameters: - - in: path - name: address - description: Account address in bech32 format - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - - in: body - name: account - description: The sender and tx information - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - amount: - type: array - items: - $ref: "#/definitions/Coin" - responses: - 202: - description: Tx was succesfully generated - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid request - 500: - description: Server internal error - /bank/total: - get: - deprecated: true - summary: Total supply of coins in the chain - tags: - - Bank - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: "#/definitions/Supply" - 500: - description: Internal Server Error - /bank/total/{denomination}: - parameters: - - in: path - name: denomination - description: Coin denomination - required: true - type: string - x-example: uatom - get: - deprecated: true - summary: Total supply of a single coin denomination - tags: - - Bank - produces: - - application/json - responses: - 200: - description: OK - schema: - type: string - 400: - description: Invalid coin denomination - 500: - description: Internal Server Error - /auth/accounts/{address}: - get: - deprecated: true - summary: Get the account information on blockchain - tags: - - Auth - produces: - - application/json - parameters: - - in: path - name: address - description: Account address - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - responses: - 200: - description: Account information on the blockchain - schema: - type: object - properties: - type: - type: string - value: - type: object - properties: - account_number: - type: string - address: - type: string - coins: - type: array - items: - $ref: "#/definitions/Coin" - public_key: - $ref: "#/definitions/PublicKey" - sequence: - type: string - 500: - description: Server internel error - /staking/delegators/{delegatorAddr}/delegations: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - get: - deprecated: true - summary: Get all delegations from a delegator - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Delegation" - 400: - description: Invalid delegator address - 500: - description: Internal Server Error - post: - summary: Submit delegation - parameters: - - in: body - name: delegation - description: Delegate an amount of liquid coins to a validator - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - delegator_address: - $ref: "#/definitions/Address" - validator_address: - $ref: "#/definitions/ValidatorAddress" - amount: - $ref: "#/definitions/Coin" - tags: - - Staking - consumes: - - application/json - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid delegator address or delegation request body - 401: - description: Key password is wrong - 500: - description: Internal Server Error - /staking/delegators/{delegatorAddr}/delegations/{validatorAddr}: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Query the current delegation between a delegator and a validator - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: "#/definitions/Delegation" - 400: - description: Invalid delegator address or validator address - 500: - description: Internal Server Error - /staking/delegators/{delegatorAddr}/unbonding_delegations: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - get: - deprecated: true - summary: Get all unbonding delegations from a delegator - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/UnbondingDelegation" - 400: - description: Invalid delegator address - 500: - description: Internal Server Error - post: - summary: Submit an unbonding delegation - parameters: - - in: body - name: delegation - description: Unbond an amount of bonded shares from a validator - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - delegator_address: - $ref: "#/definitions/Address" - validator_address: - $ref: "#/definitions/ValidatorAddress" - amount: - $ref: "#/definitions/Coin" - tags: - - Staking - consumes: - - application/json - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid delegator address or unbonding delegation request body - 401: - description: Key password is wrong - 500: - description: Internal Server Error - /staking/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Query all unbonding delegations between a delegator and a validator - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: "#/definitions/UnbondingDelegationPair" - 400: - description: Invalid delegator address or validator address - 500: - description: Internal Server Error - /staking/redelegations: - parameters: - - in: query - name: delegator - description: Bech32 AccAddress of Delegator - required: false - type: string - - in: query - name: validator_from - description: Bech32 ValAddress of SrcValidator - required: false - type: string - - in: query - name: validator_to - description: Bech32 ValAddress of DstValidator - required: false - type: string - get: - deprecated: true - summary: Get all redelegations (filter by query params) - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Redelegation" - 500: - description: Internal Server Error - /staking/delegators/{delegatorAddr}/redelegations: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - post: - deprecated: true - summary: Submit a redelegation - parameters: - - in: body - name: delegation - description: The sender and tx information - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - delegator_address: - $ref: "#/definitions/Address" - validator_src_addressess: - $ref: "#/definitions/ValidatorAddress" - validator_dst_address: - $ref: "#/definitions/ValidatorAddress" - shares: - type: string - example: "100" - tags: - - Staking - consumes: - - application/json - produces: - - application/json - responses: - 200: - description: Tx was succesfully generated - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid delegator address or redelegation request body - 500: - description: Internal Server Error - /staking/delegators/{delegatorAddr}/validators: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - get: - deprecated: true - summary: Query all validators that a delegator is bonded to - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Validator" - 400: - description: Invalid delegator address - 500: - description: Internal Server Error - /staking/delegators/{delegatorAddr}/validators/{validatorAddr}: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - - in: path - name: validatorAddr - description: Bech32 ValAddress of Delegator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Query a validator that a delegator is bonded to - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: "#/definitions/Validator" - 400: - description: Invalid delegator address or validator address - 500: - description: Internal Server Error - /staking/validators: - get: - deprecated: true - summary: Get all validator candidates. By default it returns only the bonded validators. - parameters: - - in: query - name: status - type: string - description: The validator bond status. Must be either 'bonded', 'unbonded', or 'unbonding'. - x-example: bonded - - in: query - name: page - description: The page number. - type: integer - x-example: 1 - - in: query - name: limit - description: The maximum number of items per page. - type: integer - x-example: 1 - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Validator" - 500: - description: Internal Server Error - /staking/validators/{validatorAddr}: - parameters: - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Query the information from a single validator - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: "#/definitions/Validator" - 400: - description: Invalid validator address - 500: - description: Internal Server Error - /staking/validators/{validatorAddr}/delegations: - parameters: - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Get all delegations from a validator - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Delegation" - 400: - description: Invalid validator address - 500: - description: Internal Server Error - /staking/validators/{validatorAddr}/unbonding_delegations: - parameters: - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Get all unbonding delegations from a validator - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/UnbondingDelegation" - 400: - description: Invalid validator address - 500: - description: Internal Server Error - /staking/pool: - get: - deprecated: true - summary: Get the current state of the staking pool - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - type: object - properties: - loose_tokens: - type: string - bonded_tokens: - type: string - inflation_last_time: - type: string - inflation: - type: string - date_last_commission_reset: - type: string - prev_bonded_shares: - type: string - 500: - description: Internal Server Error - /staking/parameters: - get: - deprecated: true - summary: Get the current staking parameter values - tags: - - Staking - produces: - - application/json - responses: - 200: - description: OK - schema: - type: object - properties: - inflation_rate_change: - type: string - inflation_max: - type: string - inflation_min: - type: string - goal_bonded: - type: string - unbonding_time: - type: string - max_validators: - type: integer - bond_denom: - type: string - 500: - description: Internal Server Error - # TODO: We need to either fix this route when the validator is not found or add a slashed validator in the contract tests - # /slashing/validators/{validatorPubKey}/signing_info: - # get: - # summary: Get sign info of given validator - # description: Get sign info of given validator - # produces: - # - application/json - # tags: - # - Slashing - # parameters: - # - type: string - # description: Bech32 validator public key - # name: validatorPubKey - # required: true - # in: path - # x-example: cosmosvalconspub1zcjduepq0vu2zgkgk49efa0nqwzndanq5m4c7pa3u4apz4g2r9gspqg6g9cs3k9cuf - # responses: - # 200: - # description: OK - # schema: - # $ref: "#/definitions/SigningInfo" - # 400: - # description: Invalid validator public key - # 500: - # description: Internal Server Error - /slashing/signing_infos: - get: - deprecated: true - summary: Get sign info of given all validators - description: Get sign info of all validators - produces: - - application/json - tags: - - Slashing - parameters: - - in: query - name: page - description: Page number - type: integer - required: true - x-example: 1 - - in: query - name: limit - description: Maximum number of items per page - type: integer - required: true - x-example: 5 - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/SigningInfo" - 400: - description: Invalid validator public key for one of the validators - 500: - description: Internal Server Error - /slashing/validators/{validatorAddr}/unjail: - post: - deprecated: true - summary: Unjail a jailed validator - description: Send transaction to unjail a jailed validator - consumes: - - application/json - produces: - - application/json - tags: - - Slashing - parameters: - - type: string - description: Bech32 validator address - name: validatorAddr - required: true - in: path - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - - description: "" - name: UnjailBody - in: body - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/StdTx" - responses: - 200: - description: Tx was succesfully generated - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid validator address or base_req - 500: - description: Internal Server Error - /slashing/parameters: - get: - deprecated: true - summary: Get the current slashing parameters - tags: - - Slashing - produces: - - application/json - responses: - 200: - description: OK - schema: - type: object - properties: - max_evidence_age: - type: string - signed_blocks_window: - type: string - min_signed_per_window: - type: string - double_sign_unbond_duration: - type: string - downtime_unbond_duration: - type: string - slash_fraction_double_sign: - type: string - slash_fraction_downtime: - type: string - 500: - description: Internal Server Error - /gov/proposals: - post: - deprecated: true - summary: Submit a proposal - description: Send transaction to submit a proposal - consumes: - - application/json - produces: - - application/json - tags: - - Governance - parameters: - - description: valid value of `"proposal_type"` can be `"text"`, `"parameter_change"`, `"software_upgrade"` - name: post_proposal_body - in: body - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - title: - type: string - description: - type: string - proposal_type: - type: string - example: "text" - proposer: - $ref: "#/definitions/Address" - initial_deposit: - type: array - items: - $ref: "#/definitions/Coin" - responses: - 200: - description: Tx was succesfully generated - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid proposal body - 500: - description: Internal Server Error - get: - deprecated: true - summary: Query proposals - description: Query proposals information with parameters - produces: - - application/json - tags: - - Governance - parameters: - - in: query - name: voter - description: voter address - required: false - type: string - - in: query - name: depositor - description: depositor address - required: false - type: string - - in: query - name: status - description: proposal status, valid values can be `"deposit_period"`, `"voting_period"`, `"passed"`, `"rejected"` - required: false - type: string - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/TextProposal" - 400: - description: Invalid query parameters - 500: - description: Internal Server Error - /gov/proposals/param_change: - post: - deprecated: true - summary: Generate a parameter change proposal transaction - description: Generate a parameter change proposal transaction - consumes: - - application/json - produces: - - application/json - tags: - - Governance - parameters: - - description: The parameter change proposal body that contains all parameter changes - name: post_proposal_body - in: body - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - title: - type: string - x-example: "Param Change" - description: - type: string - x-example: "Update max validators" - proposer: - $ref: "#/definitions/Address" - deposit: - type: array - items: - $ref: "#/definitions/Coin" - changes: - type: array - items: - $ref: "#/definitions/ParamChange" - responses: - 200: - description: The transaction was succesfully generated - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid proposal body - 500: - description: Internal Server Error - /gov/proposals/{proposalId}: - get: - deprecated: true - summary: Query a proposal - description: Query a proposal by id - produces: - - application/json - tags: - - Governance - parameters: - - type: string - name: proposalId - required: true - in: path - x-example: "2" - responses: - 200: - description: OK - schema: - $ref: "#/definitions/TextProposal" - 400: - description: Invalid proposal id - 500: - description: Internal Server Error - /gov/proposals/{proposalId}/proposer: - get: - deprecated: true - summary: Query proposer - description: Query for the proposer for a proposal - produces: - - application/json - tags: - - Governance - parameters: - - type: string - name: proposalId - required: true - in: path - x-example: "2" - responses: - 200: - description: OK - schema: - $ref: "#/definitions/Proposer" - 400: - description: Invalid proposal ID - 500: - description: Internal Server Error - /gov/proposals/{proposalId}/deposits: - get: - deprecated: true - summary: Query deposits - description: Query deposits by proposalId - produces: - - application/json - tags: - - Governance - parameters: - - type: string - name: proposalId - required: true - in: path - x-example: "2" - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Deposit" - 400: - description: Invalid proposal id - 500: - description: Internal Server Error - post: - deprecated: true - summary: Deposit tokens to a proposal - description: Send transaction to deposit tokens to a proposal - consumes: - - application/json - produces: - - application/json - tags: - - Governance - parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - x-example: "2" - - description: "" - name: post_deposit_body - in: body - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - depositor: - $ref: "#/definitions/Address" - amount: - type: array - items: - $ref: "#/definitions/Coin" - responses: - 200: - description: OK - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid proposal id or deposit body - 401: - description: Key password is wrong - 500: - description: Internal Server Error - /gov/proposals/{proposalId}/deposits/{depositor}: - get: - deprecated: true - summary: Query deposit - description: Query deposit by proposalId and depositor address - produces: - - application/json - tags: - - Governance - parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - x-example: "2" - - type: string - description: Bech32 depositor address - name: depositor - required: true - in: path - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - responses: - 200: - description: OK - schema: - $ref: "#/definitions/Deposit" - 400: - description: Invalid proposal id or depositor address - 404: - description: Found no deposit - 500: - description: Internal Server Error - /gov/proposals/{proposalId}/votes: - get: - deprecated: true - summary: Query voters - description: Query voters information by proposalId - produces: - - application/json - tags: - - Governance - parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - x-example: "2" - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Vote" - 400: - description: Invalid proposal id - 500: - description: Internal Server Error - post: - deprecated: true - summary: Vote a proposal - description: Send transaction to vote a proposal - consumes: - - application/json - produces: - - application/json - tags: - - Governance - parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - x-example: "2" - - description: valid value of `"option"` field can be `"yes"`, `"no"`, `"no_with_veto"` and `"abstain"` - name: post_vote_body - in: body - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - voter: - $ref: "#/definitions/Address" - option: - type: string - example: "yes" - responses: - 200: - description: OK - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid proposal id or vote body - 401: - description: Key password is wrong - 500: - description: Internal Server Error - /gov/proposals/{proposalId}/votes/{voter}: - get: - deprecated: true - summary: Query vote - description: Query vote information by proposal Id and voter address - produces: - - application/json - tags: - - Governance - parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - x-example: "2" - - type: string - description: Bech32 voter address - name: voter - required: true - in: path - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - responses: - 200: - description: OK - schema: - $ref: "#/definitions/Vote" - 400: - description: Invalid proposal id or voter address - 404: - description: Found no vote - 500: - description: Internal Server Error - /gov/proposals/{proposalId}/tally: - get: - deprecated: true - summary: Get a proposal's tally result at the current time - description: Gets a proposal's tally result at the current time. If the proposal is pending deposits (i.e status 'DepositPeriod') it returns an empty tally result. - produces: - - application/json - tags: - - Governance - parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - x-example: "2" - responses: - 200: - description: OK - schema: - $ref: "#/definitions/TallyResult" - 400: - description: Invalid proposal id - 500: - description: Internal Server Error - /gov/parameters/deposit: - get: - deprecated: true - summary: Query governance deposit parameters - description: Query governance deposit parameters. The max_deposit_period units are in nanoseconds. - produces: - - application/json - tags: - - Governance - responses: - 200: - description: OK - schema: - type: object - properties: - min_deposit: - type: array - items: - $ref: "#/definitions/Coin" - max_deposit_period: - type: string - example: "86400000000000" - 400: - description: is not a valid query request path - 404: - description: Found no deposit parameters - 500: - description: Internal Server Error - /gov/parameters/tallying: - get: - deprecated: true - summary: Query governance tally parameters - description: Query governance tally parameters - produces: - - application/json - tags: - - Governance - responses: - 200: - description: OK - schema: - properties: - threshold: - type: string - example: "0.5000000000" - veto: - type: string - example: "0.3340000000" - governance_penalty: - type: string - example: "0.0100000000" - 400: - description: is not a valid query request path - 404: - description: Found no tally parameters - 500: - description: Internal Server Error - /gov/parameters/voting: - get: - deprecated: true - summary: Query governance voting parameters - description: Query governance voting parameters. The voting_period units are in nanoseconds. - produces: - - application/json - tags: - - Governance - responses: - 200: - description: OK - schema: - properties: - voting_period: - type: string - example: "86400000000000" - 400: - description: is not a valid query request path - 404: - description: Found no voting parameters - 500: - description: Internal Server Error - /distribution/delegators/{delegatorAddr}/rewards: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf - get: - deprecated: true - summary: Get the total rewards balance from all delegations - description: Get the sum of all the rewards earned by delegations by a single delegator - produces: - - application/json - tags: - - Distribution - responses: - 200: - description: OK - schema: - $ref: "#/definitions/DelegatorTotalRewards" - 400: - description: Invalid delegator address - 500: - description: Internal Server Error - post: - deprecated: true - summary: Withdraw all the delegator's delegation rewards - description: Withdraw all the delegator's delegation rewards - tags: - - Distribution - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: Withdraw request body - schema: - properties: - base_req: - $ref: "#/definitions/BaseReq" - responses: - 200: - description: OK - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid delegator address - 401: - description: Key password is wrong - 500: - description: Internal Server Error - /distribution/delegators/{delegatorAddr}/rewards/{validatorAddr}: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Query a delegation reward - description: Query a single delegation reward by a delegator - tags: - - Distribution - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Coin" - 400: - description: Invalid delegator address - 500: - description: Internal Server Error - post: - deprecated: true - summary: Withdraw a delegation reward - description: Withdraw a delegator's delegation reward from a single validator - tags: - - Distribution - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: Withdraw request body - schema: - properties: - base_req: - $ref: "#/definitions/BaseReq" - responses: - 200: - description: OK - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid delegator address or delegation body - 401: - description: Key password is wrong - 500: - description: Internal Server Error - /distribution/delegators/{delegatorAddr}/withdraw_address: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: cosmos167w96tdvmazakdwkw2u57227eduula2cy572lf - get: - deprecated: true - summary: Get the rewards withdrawal address - description: Get the delegations' rewards withdrawal address. This is the address in which the user will receive the reward funds - tags: - - Distribution - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: "#/definitions/Address" - 400: - description: Invalid delegator address - 500: - description: Internal Server Error - post: - deprecated: true - summary: Replace the rewards withdrawal address - description: Replace the delegations' rewards withdrawal address for a new one. - tags: - - Distribution - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: Withdraw request body - schema: - properties: - base_req: - $ref: "#/definitions/BaseReq" - withdraw_address: - $ref: "#/definitions/Address" - responses: - 200: - description: OK - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid delegator or withdraw address - 401: - description: Key password is wrong - 500: - description: Internal Server Error - /distribution/validators/{validatorAddr}: - parameters: - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Validator distribution information - description: Query the distribution information of a single validator - tags: - - Distribution - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: "#/definitions/ValidatorDistInfo" - 400: - description: Invalid validator address - 500: - description: Internal Server Error - /distribution/validators/{validatorAddr}/outstanding_rewards: - parameters: - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Fee distribution outstanding rewards of a single validator - tags: - - Distribution - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Coin" - 500: - description: Internal Server Error - /distribution/validators/{validatorAddr}/rewards: - parameters: - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string - x-example: cosmosvaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - get: - deprecated: true - summary: Commission and self-delegation rewards of a single validator - description: Query the commission and self-delegation rewards of validator. - tags: - - Distribution - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Coin" - 400: - description: Invalid validator address - 500: - description: Internal Server Error - post: - deprecated: true - summary: Withdraw the validator's rewards - description: Withdraw the validator's self-delegation and commissions rewards - tags: - - Distribution - consumes: - - application/json - produces: - - application/json - parameters: - - in: body - name: Withdraw request body - schema: - properties: - base_req: - $ref: "#/definitions/BaseReq" - responses: - 200: - description: OK - schema: - $ref: "#/definitions/StdTx" - 400: - description: Invalid validator address - 401: - description: Key password is wrong - 500: - description: Internal Server Error - /distribution/community_pool: - get: - deprecated: true - summary: Community pool parameters - tags: - - Distribution - produces: - - application/json - responses: - 200: - description: OK - schema: - type: array - items: - $ref: "#/definitions/Coin" - 500: - description: Internal Server Error - /distribution/parameters: - get: - deprecated: true - summary: Fee distribution parameters - tags: - - Distribution - produces: - - application/json - responses: - 200: - description: OK - schema: - properties: - base_proposer_reward: - type: string - bonus_proposer_reward: - type: string - community_tax: - type: string - 500: - description: Internal Server Error - /minting/parameters: - get: - deprecated: true - summary: Minting module parameters - tags: - - Mint - produces: - - application/json - responses: - 200: - description: OK - schema: - properties: - mint_denom: - type: string - inflation_rate_change: - type: string - inflation_max: - type: string - inflation_min: - type: string - goal_bonded: - type: string - blocks_per_year: - type: string - 500: - description: Internal Server Error - /minting/inflation: - get: - deprecated: true - summary: Current minting inflation value - tags: - - Mint - produces: - - application/json - responses: - 200: - description: OK - schema: - type: string - 500: - description: Internal Server Error - /minting/annual-provisions: - get: - deprecated: true - summary: Current minting annual provisions value - tags: - - Mint - produces: - - application/json - responses: - 200: - description: OK - schema: - type: string - 500: - description: Internal Server Error definitions: CheckTxResult: type: object @@ -2037,17 +257,6 @@ definitions: tags: - "" - "" - BroadcastTxCommitResult: - type: object - properties: - check_tx: - $ref: "#/definitions/CheckTxResult" - deliver_tx: - $ref: "#/definitions/DeliverTxResult" - hash: - $ref: "#/definitions/Hash" - height: - type: integer KVPair: type: object properties: @@ -2077,93 +286,6 @@ definitions: Hash: type: string example: EE5F3404034C524501629B56E0DDC38FAD651F04 - TxQuery: - type: object - properties: - hash: - type: string - example: "D085138D913993919295FF4B0A9107F1F2CDE0D37A87CE0644E217CBF3B49656" - height: - type: number - example: 368 - tx: - $ref: "#/definitions/StdTx" - result: - type: object - properties: - log: - type: string - gas_wanted: - type: string - example: "200000" - gas_used: - type: string - example: "26354" - tags: - type: array - items: - $ref: "#/definitions/KVPair" - PaginatedQueryTxs: - type: object - properties: - total_count: - type: number - example: 1 - count: - type: number - example: 1 - page_number: - type: number - example: 1 - page_total: - type: number - example: 1 - limit: - type: number - example: 30 - txs: - type: array - items: - $ref: "#/definitions/TxQuery" - StdTx: - type: object - properties: - msg: - type: array - items: - $ref: "#/definitions/Msg" - fee: - type: object - properties: - gas: - type: string - amount: - type: array - items: - $ref: "#/definitions/Coin" - memo: - type: string - signature: - type: object - properties: - signature: - type: string - example: MEUCIQD02fsDPra8MtbRsyB1w7bqTM55Wu138zQbFcWx4+CFyAIge5WNPfKIuvzBZ69MyqHsqD8S1IwiEp+iUb6VSdtlpgY= - pub_key: - type: object - properties: - type: - type: string - example: "tendermint/PubKeySecp256k1" - value: - type: string - example: "Avz04VhtKJh8ACCVzlI8aTosGy0ikFXKIVHQ3jKMrosH" - account_number: - type: string - example: "0" - sequence: - type: string - example: "0" BlockID: type: object properties: @@ -2281,26 +403,6 @@ definitions: $ref: "#/definitions/BlockID" block: $ref: "#/definitions/Block" - DelegationDelegatorReward: - type: object - properties: - validator_address: - $ref: "#/definitions/ValidatorAddress" - reward: - type: array - items: - $ref: "#/definitions/Coin" - DelegatorTotalRewards: - type: object - properties: - rewards: - type: array - items: - $ref: "#/definitions/DelegationDelegatorReward" - total: - type: array - items: - $ref: "#/definitions/Coin" BaseReq: type: object properties: @@ -2348,214 +450,6 @@ definitions: proposer_priority: type: string example: "1000" - TextProposal: - type: object - properties: - proposal_id: - type: integer - title: - type: string - description: - type: string - proposal_type: - type: string - proposal_status: - type: string - final_tally_result: - $ref: "#/definitions/TallyResult" - submit_time: - type: string - total_deposit: - type: array - items: - $ref: "#/definitions/Coin" - voting_start_time: - type: string - Proposer: - type: object - properties: - proposal_id: - type: string - proposer: - type: string - Deposit: - type: object - properties: - amount: - type: array - items: - $ref: "#/definitions/Coin" - proposal_id: - type: string - depositor: - $ref: "#/definitions/Address" - TallyResult: - type: object - properties: - yes: - type: string - example: "0.0000000000" - abstain: - type: string - example: "0.0000000000" - no: - type: string - example: "0.0000000000" - no_with_veto: - type: string - example: "0.0000000000" - Vote: - type: object - properties: - voter: - type: string - proposal_id: - type: string - option: - type: string - Validator: - type: object - properties: - operator_address: - $ref: "#/definitions/ValidatorAddress" - consensus_pubkey: - type: string - example: cosmosvalconspub1zcjduepq0vu2zgkgk49efa0nqwzndanq5m4c7pa3u4apz4g2r9gspqg6g9cs3k9cuf - jailed: - type: boolean - status: - type: integer - tokens: - type: string - delegator_shares: - type: string - description: - type: object - properties: - moniker: - type: string - identity: - type: string - website: - type: string - security_contact: - type: string - details: - type: string - bond_height: - type: string - example: "0" - bond_intra_tx_counter: - type: integer - example: 0 - unbonding_height: - type: string - example: "0" - unbonding_time: - type: string - example: "1970-01-01T00:00:00Z" - commission: - type: object - properties: - rate: - type: string - example: "0" - max_rate: - type: string - example: "0" - max_change_rate: - type: string - example: "0" - update_time: - type: string - example: "1970-01-01T00:00:00Z" - Delegation: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - shares: - type: string - balance: - $ref: "#/definitions/Coin" - UnbondingDelegationPair: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - entries: - type: array - items: - $ref: "#/definitions/UnbondingEntries" - UnbondingEntries: - type: object - properties: - initial_balance: - type: string - balance: - type: string - creation_height: - type: string - min_time: - type: string - UnbondingDelegation: - type: object - properties: - delegator_address: - type: string - validator_address: - type: string - initial_balance: - type: string - balance: - type: string - creation_height: - type: integer - min_time: - type: integer - Redelegation: - type: object - properties: - delegator_address: - type: string - validator_src_address: - type: string - validator_dst_address: - type: string - entries: - type: array - items: - $ref: "#/definitions/Redelegation" - RedelegationEntry: - type: object - properties: - creation_height: - type: integer - completion_time: - type: integer - initial_balance: - type: string - balance: - type: string - shares_dst: - type: string - ValidatorDistInfo: - type: object - properties: - operator_address: - $ref: "#/definitions/ValidatorAddress" - self_bond_rewards: - type: array - items: - $ref: "#/definitions/Coin" - val_commission: - type: array - items: - $ref: "#/definitions/Coin" PublicKey: type: object properties: @@ -2574,24 +468,3 @@ definitions: type: string missed_blocks_counter: type: string - ParamChange: - type: object - properties: - subspace: - type: string - example: "staking" - key: - type: string - example: "MaxValidators" - subkey: - type: string - example: "" - value: - type: object - Supply: - type: object - properties: - total: - type: array - items: - $ref: "#/definitions/Coin" diff --git a/client/flags/flags.go b/client/flags/flags.go index 1c0e1585c0ff..cfc0242c1023 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -35,6 +35,8 @@ const ( SignModeDirect = "direct" // SignModeLegacyAminoJSON is the value of the --sign-mode flag for SIGN_MODE_LEGACY_AMINO_JSON SignModeLegacyAminoJSON = "amino-json" + // SignModeEIP191 is the value of the --sign-mode flag for SIGN_MODE_EIP_191 + SignModeEIP191 = "eip-191" ) // List of CLI flags diff --git a/client/tx/factory.go b/client/tx/factory.go index 2cb951922d0a..ebd43b7480ad 100644 --- a/client/tx/factory.go +++ b/client/tx/factory.go @@ -1,11 +1,17 @@ package tx import ( + "errors" + "fmt" + "os" + "github.com/spf13/pflag" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" ) @@ -39,6 +45,8 @@ func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory { signMode = signing.SignMode_SIGN_MODE_DIRECT case flags.SignModeLegacyAminoJSON: signMode = signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON + case flags.SignModeEIP191: + signMode = signing.SignMode_SIGN_MODE_EIP_191 } accNum, _ := flagSet.GetUint64(flags.FlagAccountNumber) @@ -189,3 +197,147 @@ func (f Factory) WithTimeoutHeight(height uint64) Factory { f.timeoutHeight = height return f } + +// BuildUnsignedTx builds a transaction to be signed given a set of messages. +// Once created, the fee, memo, and messages are set. +func (f Factory) BuildUnsignedTx(msgs ...sdk.Msg) (client.TxBuilder, error) { + if f.chainID == "" { + return nil, fmt.Errorf("chain ID required but not specified") + } + + fees := f.fees + + if !f.gasPrices.IsZero() { + if !fees.IsZero() { + return nil, errors.New("cannot provide both fees and gas prices") + } + + glDec := sdk.NewDec(int64(f.gas)) + + // Derive the fees based on the provided gas prices, where + // fee = ceil(gasPrice * gasLimit). + fees = make(sdk.Coins, len(f.gasPrices)) + + for i, gp := range f.gasPrices { + fee := gp.Amount.Mul(glDec) + fees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) + } + } + + tx := f.txConfig.NewTxBuilder() + + if err := tx.SetMsgs(msgs...); err != nil { + return nil, err + } + + tx.SetMemo(f.memo) + tx.SetFeeAmount(fees) + tx.SetGasLimit(f.gas) + tx.SetTimeoutHeight(f.TimeoutHeight()) + + return tx, nil +} + +// PrintUnsignedTx will generate an unsigned transaction and print it to the writer +// specified by ctx.Output. If simulation was requested, the gas will be +// simulated and also printed to the same writer before the transaction is +// printed. +func (f Factory) PrintUnsignedTx(clientCtx client.Context, msgs ...sdk.Msg) error { + if f.SimulateAndExecute() { + if clientCtx.Offline { + return errors.New("cannot estimate gas in offline mode") + } + + _, adjusted, err := CalculateGas(clientCtx, f, msgs...) + if err != nil { + return err + } + + f = f.WithGas(adjusted) + _, _ = fmt.Fprintf(os.Stderr, "%s\n", GasEstimateResponse{GasEstimate: f.Gas()}) + } + + unsignedTx, err := f.BuildUnsignedTx(msgs...) + if err != nil { + return err + } + + json, err := clientCtx.TxConfig.TxJSONEncoder()(unsignedTx.GetTx()) + if err != nil { + return err + } + + return clientCtx.PrintString(fmt.Sprintf("%s\n", json)) +} + +// BuildSimTx creates an unsigned tx with an empty single signature and returns +// the encoded transaction or an error if the unsigned transaction cannot be +// built. +func (f Factory) BuildSimTx(msgs ...sdk.Msg) ([]byte, error) { + txb, err := f.BuildUnsignedTx(msgs...) + if err != nil { + return nil, err + } + + // use the first element from the list of keys in order to generate a valid + // pubkey that supports multiple algorithms + + var pk cryptotypes.PubKey = &secp256k1.PubKey{} // use default public key type + + if f.keybase != nil { + infos, _ := f.keybase.List() + if len(infos) == 0 { + return nil, errors.New("cannot build signature for simulation, key infos slice is empty") + } + + // take the first info record just for simulation purposes + pk = infos[0].GetPubKey() + } + + // Create an empty signature literal as the ante handler will populate with a + // sentinel pubkey. + sig := signing.SignatureV2{ + PubKey: pk, + Data: &signing.SingleSignatureData{ + SignMode: f.signMode, + }, + Sequence: f.Sequence(), + } + if err := txb.SetSignatures(sig); err != nil { + return nil, err + } + + return f.txConfig.TxEncoder()(txb.GetTx()) +} + +// Prepare ensures the account defined by ctx.GetFromAddress() exists and +// if the account number and/or the account sequence number are zero (not set), +// they will be queried for and set on the provided Factory. A new Factory with +// the updated fields will be returned. +func (f Factory) Prepare(clientCtx client.Context) (Factory, error) { + fc := f + + from := clientCtx.GetFromAddress() + + if err := fc.accountRetriever.EnsureExists(clientCtx, from); err != nil { + return fc, err + } + + initNum, initSeq := fc.accountNumber, fc.sequence + if initNum == 0 || initSeq == 0 { + num, seq, err := fc.accountRetriever.GetAccountNumberSequence(clientCtx, from) + if err != nil { + return fc, err + } + + if initNum == 0 { + fc = fc.WithAccountNumber(num) + } + + if initSeq == 0 { + fc = fc.WithSequence(seq) + } + } + + return fc, nil +} diff --git a/client/tx/tx.go b/client/tx/tx.go index 8e20be369bfd..90c49514fa1a 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -14,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/input" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -221,66 +220,14 @@ func WriteGeneratedTxResponse( // transaction is initially created via the provided factory's generator. Once // created, the fee, memo, and messages are set. func BuildUnsignedTx(txf Factory, msgs ...sdk.Msg) (client.TxBuilder, error) { - if txf.chainID == "" { - return nil, fmt.Errorf("chain ID required but not specified") - } - - fees := txf.fees - - if !txf.gasPrices.IsZero() { - if !fees.IsZero() { - return nil, errors.New("cannot provide both fees and gas prices") - } - - glDec := sdk.NewDec(int64(txf.gas)) - - // Derive the fees based on the provided gas prices, where - // fee = ceil(gasPrice * gasLimit). - fees = make(sdk.Coins, len(txf.gasPrices)) - - for i, gp := range txf.gasPrices { - fee := gp.Amount.Mul(glDec) - fees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) - } - } - - tx := txf.txConfig.NewTxBuilder() - - if err := tx.SetMsgs(msgs...); err != nil { - return nil, err - } - - tx.SetMemo(txf.memo) - tx.SetFeeAmount(fees) - tx.SetGasLimit(txf.gas) - tx.SetTimeoutHeight(txf.TimeoutHeight()) - - return tx, nil + return txf.BuildUnsignedTx(msgs...) } // BuildSimTx creates an unsigned tx with an empty single signature and returns // the encoded transaction or an error if the unsigned transaction cannot be // built. func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error) { - txb, err := BuildUnsignedTx(txf, msgs...) - if err != nil { - return nil, err - } - - // Create an empty signature literal as the ante handler will populate with a - // sentinel pubkey. - sig := signing.SignatureV2{ - PubKey: &secp256k1.PubKey{}, - Data: &signing.SingleSignatureData{ - SignMode: txf.signMode, - }, - Sequence: txf.Sequence(), - } - if err := txb.SetSignatures(sig); err != nil { - return nil, err - } - - return txf.txConfig.TxEncoder()(txb.GetTx()) + return txf.BuildSimTx(msgs...) } // CalculateGas simulates the execution of a transaction and returns the diff --git a/client/tx/tx_test.go b/client/tx/tx_test.go index b095d05b9e5d..9a4c60d07708 100644 --- a/client/tx/tx_test.go +++ b/client/tx/tx_test.go @@ -45,6 +45,7 @@ func (m mockContext) Invoke(grpcCtx gocontext.Context, method string, req, reply return nil } + func (mockContext) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { panic("not implemented") } @@ -97,6 +98,13 @@ func TestCalculateGas(t *testing.T) { func TestBuildSimTx(t *testing.T) { txCfg := NewTestTxConfig() + kb, err := keyring.New(t.Name(), "test", t.TempDir(), nil) + require.NoError(t, err) + + path := hd.CreateHDPath(118, 0, 0).String() + _, _, err = kb.NewMnemonic("test_key1", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + require.NoError(t, err) + txf := tx.Factory{}. WithTxConfig(txCfg). WithAccountNumber(50). @@ -104,7 +112,8 @@ func TestBuildSimTx(t *testing.T) { WithFees("50stake"). WithMemo("memo"). WithChainID("test-chain"). - WithSignMode(txCfg.SignModeHandler().DefaultMode()) + WithSignMode(txCfg.SignModeHandler().DefaultMode()). + WithKeybase(kb) msg := banktypes.NewMsgSend(sdk.AccAddress("from"), sdk.AccAddress("to"), nil) bz, err := tx.BuildSimTx(txf, msg) @@ -113,6 +122,14 @@ func TestBuildSimTx(t *testing.T) { } func TestBuildUnsignedTx(t *testing.T) { + kb, err := keyring.New(t.Name(), "test", t.TempDir(), nil) + require.NoError(t, err) + + path := hd.CreateHDPath(118, 0, 0).String() + + _, _, err = kb.NewMnemonic("test_key1", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + require.NoError(t, err) + txf := tx.Factory{}. WithTxConfig(NewTestTxConfig()). WithAccountNumber(50). @@ -137,8 +154,8 @@ func TestSign(t *testing.T) { kr, err := keyring.New(t.Name(), "test", t.TempDir(), nil) requireT.NoError(err) - var from1 = "test_key1" - var from2 = "test_key2" + from1 := "test_key1" + from2 := "test_key2" // create a new key using a mnemonic generator and test if we can reuse seed to recreate that account _, seed, err := kr.NewMnemonic(from1, keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) @@ -169,6 +186,7 @@ func TestSign(t *testing.T) { WithSignMode(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) msg1 := banktypes.NewMsgSend(info1.GetAddress(), sdk.AccAddress("to"), nil) msg2 := banktypes.NewMsgSend(info2.GetAddress(), sdk.AccAddress("to"), nil) + txb, err := tx.BuildUnsignedTx(txfNoKeybase, msg1, msg2) requireT.NoError(err) txb2, err := tx.BuildUnsignedTx(txfNoKeybase, msg1, msg2) @@ -185,35 +203,71 @@ func TestSign(t *testing.T) { expectedPKs []cryptotypes.PubKey matchingSigs []int // if not nil, check matching signature against old ones. }{ - {"should fail if txf without keyring", - txfNoKeybase, txb, from1, true, nil, nil}, - {"should fail for non existing key", - txfAmino, txb, "unknown", true, nil, nil}, - {"amino: should succeed with keyring", - txfAmino, txbSimple, from1, true, []cryptotypes.PubKey{pubKey1}, nil}, - {"direct: should succeed with keyring", - txfDirect, txbSimple, from1, true, []cryptotypes.PubKey{pubKey1}, nil}, + { + "should fail if txf without keyring", + txfNoKeybase, txb, from1, true, nil, nil, + }, + { + "should fail for non existing key", + txfAmino, txb, "unknown", true, nil, nil, + }, + { + "amino: should succeed with keyring", + txfAmino, txbSimple, from1, true, + []cryptotypes.PubKey{pubKey1}, + nil, + }, + { + "direct: should succeed with keyring", + txfDirect, txbSimple, from1, true, + []cryptotypes.PubKey{pubKey1}, + nil, + }, /**** test double sign Amino mode ****/ - {"amino: should sign multi-signers tx", - txfAmino, txb, from1, true, []cryptotypes.PubKey{pubKey1}, nil}, - {"amino: should append a second signature and not overwrite", - txfAmino, txb, from2, false, []cryptotypes.PubKey{pubKey1, pubKey2}, []int{0, 0}}, - {"amino: should overwrite a signature", - txfAmino, txb, from2, true, []cryptotypes.PubKey{pubKey2}, []int{1, 0}}, + { + "amino: should sign multi-signers tx", + txfAmino, txb, from1, true, + []cryptotypes.PubKey{pubKey1}, + nil, + }, + { + "amino: should append a second signature and not overwrite", + txfAmino, txb, from2, false, + []cryptotypes.PubKey{pubKey1, pubKey2}, + []int{0, 0}, + }, + { + "amino: should overwrite a signature", + txfAmino, txb, from2, true, + []cryptotypes.PubKey{pubKey2}, + []int{1, 0}, + }, /**** test double sign Direct mode signing transaction with more than 2 signers should fail in DIRECT mode ****/ - {"direct: should fail to append a signature with different mode", - txfDirect, txb, from1, false, []cryptotypes.PubKey{}, nil}, - {"direct: should fail to sign multi-signers tx", - txfDirect, txb2, from1, false, []cryptotypes.PubKey{}, nil}, - {"direct: should fail to overwrite multi-signers tx", - txfDirect, txb2, from1, true, []cryptotypes.PubKey{}, nil}, + { + "direct: should fail to append a signature with different mode", + txfDirect, txb, from1, false, + []cryptotypes.PubKey{}, + nil, + }, + { + "direct: should fail to sign multi-signers tx", + txfDirect, txb2, from1, false, + []cryptotypes.PubKey{}, + nil, + }, + { + "direct: should fail to overwrite multi-signers tx", + txfDirect, txb2, from1, true, + []cryptotypes.PubKey{}, + nil, + }, } var prevSigs []signingtypes.SignatureV2 for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { + t.Run(tc.name, func(_ *testing.T) { err = tx.Sign(tc.txf, tc.from, tc.txb, tc.overwrite) if len(tc.expectedPKs) == 0 { requireT.Error(err) diff --git a/contrib/images/Makefile b/contrib/images/Makefile index 03d3f8be42e5..0c9364155113 100644 --- a/contrib/images/Makefile +++ b/contrib/images/Makefile @@ -1,7 +1,14 @@ all: simd-env -simd-env: - docker build --tag cosmossdk/simd-env -f simd-env/Dockerfile \ - $(shell git rev-parse --show-toplevel) +simd-env: simd-rmi + docker build --tag cosmossdk/simd -f simd-env/Dockerfile \ + $(shell git rev-parse --show-toplevel) -.PHONY: all simd-env +simd-dlv: simd-rmi + docker build --tag cosmossdk/simd -f simd-dlv/Dockerfile \ + $(shell git rev-parse --show-toplevel) + +simd-rmi: + docker rmi cosmossdk/simd 2>/dev/null; true + +.PHONY: all simd-env simd-dlv simd-rmi \ No newline at end of file diff --git a/contrib/images/simd-dlv/Dockerfile b/contrib/images/simd-dlv/Dockerfile new file mode 100644 index 000000000000..9d15d621d761 --- /dev/null +++ b/contrib/images/simd-dlv/Dockerfile @@ -0,0 +1,22 @@ +FROM golang:1.17-alpine AS build +RUN apk add build-base git linux-headers libc-dev +RUN go install github.com/go-delve/delve/cmd/dlv@latest +WORKDIR /work +COPY go.mod go.sum /work/ +RUN go mod download +COPY ./ /work +RUN LEDGER_ENABLED=false make COSMOS_BUILD_OPTIONS="debug,nostrip" clean build + +FROM alpine:3.14 AS run +RUN apk add bash curl jq +COPY contrib/images/simd-dlv/wrapper.sh /usr/bin/wrapper.sh + +VOLUME /simd +COPY --from=build /work/build/simd /simd/ +COPY --from=build /go/bin/dlv /usr/local/bin +WORKDIR /simd + +EXPOSE 26656 26657 2345 +ENTRYPOINT ["/usr/bin/wrapper.sh"] +CMD ["start", "--log_format", "plain"] +STOPSIGNAL SIGTERM diff --git a/contrib/images/simd-dlv/README.md b/contrib/images/simd-dlv/README.md new file mode 100644 index 000000000000..dcca3cde5c8b --- /dev/null +++ b/contrib/images/simd-dlv/README.md @@ -0,0 +1,37 @@ +# Remote Debugging with go-delve + +[Delve](https://github.com/go-delve/delve) is a debugger for the Go programming language. The goal of the project is to provide a simple, full featured debugging tool for Go. Delve should be easy to invoke and easy to use. Chances are if you're using a debugger, things aren't going your way. With that in mind, Delve should stay out of your way as much as possible. + +## Use-case + +Cosmos-SDK provides you with a local network to bootstrap a chain in your machine, but how does one debug a node or module? + +If we start a single node, we won't be able to debug transactions as the machine will be in bootstrapping phase trying to find peers to connect too, thats why we need to start a local network. + +But the current `localnet-start` does not provide us with debugging tools so that's why there is a different image for debugging a local network, that is to avoid any issues in the future were debugging won't be needed. + +Both `simd-env` and `simd-dlv` work and run the same, except that `simd-dlv` uses `go-delve` to run the binaries. + +## How to use + +The command to start a local network in debug mode is: + +```shell +# make localnet-debug +``` + +The command to stop the local network and destroy its containers is: + +```shell +# make localnet-stop +``` + +__note: this works the same for both `localnet-start` and `localnet-debug`__ + +Now, by default only `simdnode0` is run in debug mode, but you can run any of the other nodes in debug mode by changing the `DEBUG` environment variable to `1` in `docker-compose.yml`. + +## How to connect + +Delve will open a port on `2345` for `simdnode0` and it will increment for each of the other nodes that have `DEBUG` set to `1`. + +You can connect to the debugging server either through [GoLand IDE](https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html) or you can use [delve cli](https://github.com/go-delve/delve/blob/master/Documentation/usage/dlv_connect.md) command. diff --git a/contrib/images/simd-dlv/wrapper.sh b/contrib/images/simd-dlv/wrapper.sh new file mode 100755 index 000000000000..a1187ea7ec78 --- /dev/null +++ b/contrib/images/simd-dlv/wrapper.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env sh +set -euo pipefail +set -x + +DEBUG=${DEBUG:-0} +BINARY=/simd/${BINARY:-simd} +ID=${ID:-0} +LOG=${LOG:-simd.log} + +if ! [ -f "${BINARY}" ]; then + echo "The binary $(basename "${BINARY}") cannot be found. Please add the binary to the shared folder. Please use the BINARY environment variable if the name of the binary is not 'simd'" + exit 1 +fi + +export SIMDHOME="/data/node${ID}/simd" + +if [ "$DEBUG" -eq 1 ]; then + dlv --listen=:2345 --continue --headless=true --api-version=2 --accept-multiclient exec "${BINARY}" -- --home "${SIMDHOME}" "$@" +elif [ "$DEBUG" -eq 1 ] && [ -d "$(dirname "${SIMDHOME}"/"${LOG}")" ]; then + dlv --listen=:2345 --continue --headless=true --api-version=2 --accept-multiclient exec "${BINARY}" -- --home "${SIMDHOME}" "$@" | tee "${SIMDHOME}/${LOG}" +elif [ -d "$(dirname "${SIMDHOME}"/"${LOG}")" ]; then + "${BINARY}" --home "${SIMDHOME}" "$@" | tee "${SIMDHOME}/${LOG}" +else + "${BINARY}" --home "${SIMDHOME}" "$@" +fi \ No newline at end of file diff --git a/contrib/images/simd-env/Dockerfile b/contrib/images/simd-env/Dockerfile index b4443cdc8a8e..7c5fcf7644b4 100644 --- a/contrib/images/simd-env/Dockerfile +++ b/contrib/images/simd-env/Dockerfile @@ -2,7 +2,7 @@ FROM golang:1.17-alpine AS build RUN apk add build-base git linux-headers WORKDIR /work COPY go.mod go.sum /work/ -COPY db/go.mod db/go.sum /work/db/ + RUN go mod download COPY ./ /work RUN LEDGER_ENABLED=false make clean build diff --git a/contrib/rosetta/node/Dockerfile b/contrib/rosetta/node/Dockerfile index 0887f522f656..f3a9fb19d774 100644 --- a/contrib/rosetta/node/Dockerfile +++ b/contrib/rosetta/node/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.15-alpine as build +FROM golang:1.17-alpine as build RUN apk add --no-cache tar @@ -29,4 +29,3 @@ COPY --from=build /node/root /root/ WORKDIR /root/.simapp RUN chmod -R 0777 ./ - diff --git a/contrib/rosetta/rosetta-cli/Dockerfile b/contrib/rosetta/rosetta-cli/Dockerfile index f67070f6c42d..86ecfa7fa66f 100644 --- a/contrib/rosetta/rosetta-cli/Dockerfile +++ b/contrib/rosetta/rosetta-cli/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.15-alpine as build +FROM golang:1.17-alpine as build RUN apk add git gcc libc-dev --no-cache diff --git a/crypto/keys/secp256k1/internal/secp256k1/README.md b/crypto/keys/secp256k1/internal/secp256k1/README.md index d899ca27005a..b621008dff71 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/README.md +++ b/crypto/keys/secp256k1/internal/secp256k1/README.md @@ -1,3 +1,5 @@ -This package is copied from https://github.com/ethereum/go-ethereum/tree/729bf365b5f17325be9107b63b233da54100eec6/crypto/secp256k1 +# secp256k1 -Unlike the rest of go-ethereum it is MIT licensed so compatible with our Apache2.0 license. We opt to copy in here rather than depend on go-ethereum to avoid issues with vendoring of the GPL parts of that repository by downstream. + This package is copied from https://github.com/ethereum/go-ethereum/tree/8fddf27a989e246659fd018ea9be37b2b4f55326/crypto/secp256k1 + + Unlike the rest of go-ethereum it is [3-clause BSD](https://opensource.org/licenses/BSD-3-Clause) licensed so compatible with our Apache2.0 license. We opt to copy in here rather than depend on go-ethereum to avoid issues with vendoring of the GPL parts of that repository by downstream. diff --git a/crypto/keys/secp256k1/internal/secp256k1/curve.go b/crypto/keys/secp256k1/internal/secp256k1/curve.go index 7a2387365c6b..fa1b199a3484 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/curve.go +++ b/crypto/keys/secp256k1/internal/secp256k1/curve.go @@ -30,23 +30,13 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// nolint:gocritic package secp256k1 import ( "crypto/elliptic" "math/big" - "unsafe" ) -/* -#include "libsecp256k1/include/secp256k1.h" -extern int secp256k1_ext_scalar_mul(const secp256k1_context* ctx, - const unsigned char *point, - const unsigned char *scalar); -*/ -import "C" - const ( // number of bits in a big.Word wordBits = 32 << (uint64(^big.Word(0)) >> 63) @@ -119,6 +109,10 @@ func (BitCurve *BitCurve) IsOnCurve(x, y *big.Int) bool { // affineFromJacobian reverses the Jacobian transform. See the comment at the // top of the file. func (BitCurve *BitCurve) affineFromJacobian(x, y, z *big.Int) (xOut, yOut *big.Int) { + if z.Sign() == 0 { + return new(big.Int), new(big.Int) + } + zinv := new(big.Int).ModInverse(z, BitCurve.P) zinvsq := new(big.Int).Mul(zinv, zinv) @@ -132,7 +126,18 @@ func (BitCurve *BitCurve) affineFromJacobian(x, y, z *big.Int) (xOut, yOut *big. // Add returns the sum of (x1,y1) and (x2,y2) func (BitCurve *BitCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int) { + // If one point is at infinity, return the other point. + // Adding the point at infinity to any point will preserve the other point. + if x1.Sign() == 0 && y1.Sign() == 0 { + return x2, y2 + } + if x2.Sign() == 0 && y2.Sign() == 0 { + return x1, y1 + } z := new(big.Int).SetInt64(1) + if x1.Cmp(x2) == 0 && y1.Cmp(y2) == 0 { + return BitCurve.affineFromJacobian(BitCurve.doubleJacobian(x1, y1, z)) + } return BitCurve.affineFromJacobian(BitCurve.addJacobian(x1, y1, z, x2, y2, z)) } @@ -241,41 +246,6 @@ func (BitCurve *BitCurve) doubleJacobian(x, y, z *big.Int) (*big.Int, *big.Int, return x3, y3, z3 } -func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int, *big.Int) { - // Ensure scalar is exactly 32 bytes. We pad always, even if - // scalar is 32 bytes long, to avoid a timing side channel. - if len(scalar) > 32 { - panic("can't handle scalars > 256 bits") - } - // NOTE: potential timing issue - padded := make([]byte, 32) - copy(padded[32-len(scalar):], scalar) - scalar = padded - - // Do the multiplication in C, updating point. - point := make([]byte, 64) - readBits(Bx, point[:32]) - readBits(By, point[32:]) - - pointPtr := (*C.uchar)(unsafe.Pointer(&point[0])) - scalarPtr := (*C.uchar)(unsafe.Pointer(&scalar[0])) - res := C.secp256k1_ext_scalar_mul(context, pointPtr, scalarPtr) - - // Unpack the result and clear temporaries. - x := new(big.Int).SetBytes(point[:32]) - y := new(big.Int).SetBytes(point[32:]) - for i := range point { - point[i] = 0 - } - for i := range padded { - scalar[i] = 0 - } - if res != 1 { - return nil, nil - } - return x, y -} - // ScalarBaseMult returns k*G, where G is the base point of the group and k is // an integer in big-endian form. func (BitCurve *BitCurve) ScalarBaseMult(k []byte) (*big.Int, *big.Int) { diff --git a/crypto/keys/secp256k1/internal/secp256k1/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/dummy.go new file mode 100644 index 000000000000..4ad93ac48e2c --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/dummy.go @@ -0,0 +1,21 @@ +//go:build dummy +// +build dummy + +// This file is part of a workaround for `go mod vendor` which won't vendor +// C files if there's no Go file in the same directory. +// This would prevent the crypto/secp256k1/libsecp256k1/include/secp256k1.h file to be vendored. +// +// This Go file imports the c directory where there is another dummy.go file which +// is the second part of this workaround. +// +// These two files combined make it so `go mod vendor` behaves correctly. +// +// See this issue for reference: https://github.com/golang/go/issues/26366 + +package secp256k1 + +import ( + _ "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include" + _ "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src" + _ "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/recovery" +) diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/README.md b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/README.md index 687300173583..8cd344ea8123 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/README.md +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/README.md @@ -8,7 +8,6 @@ Optimized C library for EC operations on curve secp256k1. This library is a work in progress and is being used to research best practices. Use at your own risk. Features: - * secp256k1 ECDSA signing/verification and key generation. * Adding/multiplying private/public keys. * Serialization/parsing of private keys, public keys, signatures. @@ -20,43 +19,43 @@ Implementation details ---------------------- * General - * No runtime heap allocation. - * Extensive testing infrastructure. - * Structured to facilitate review and analysis. - * Intended to be portable to any system with a C89 compiler and uint64_t support. - * Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.") + * No runtime heap allocation. + * Extensive testing infrastructure. + * Structured to facilitate review and analysis. + * Intended to be portable to any system with a C89 compiler and uint64_t support. + * Expose only higher level interfaces to minimize the API surface and improve application security. ("Be difficult to use insecurely.") * Field operations - * Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1). - * Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys). - * Using 10 26-bit limbs. - * Field inverses and square roots using a sliding window over blocks of 1s (by Peter Dettman). + * Optimized implementation of arithmetic modulo the curve's field size (2^256 - 0x1000003D1). + * Using 5 52-bit limbs (including hand-optimized assembly for x86_64, by Diederik Huys). + * Using 10 26-bit limbs. + * Field inverses and square roots using a sliding window over blocks of 1s (by Peter Dettman). * Scalar operations - * Optimized implementation without data-dependent branches of arithmetic modulo the curve's order. - * Using 4 64-bit limbs (relying on __int128 support in the compiler). - * Using 8 32-bit limbs. + * Optimized implementation without data-dependent branches of arithmetic modulo the curve's order. + * Using 4 64-bit limbs (relying on __int128 support in the compiler). + * Using 8 32-bit limbs. * Group operations - * Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7). - * Use addition between points in Jacobian and affine coordinates where possible. - * Use a unified addition/doubling formula where necessary to avoid data-dependent branches. - * Point/x comparison without a field inversion by comparison in the Jacobian coordinate space. + * Point addition formula specifically simplified for the curve equation (y^2 = x^3 + 7). + * Use addition between points in Jacobian and affine coordinates where possible. + * Use a unified addition/doubling formula where necessary to avoid data-dependent branches. + * Point/x comparison without a field inversion by comparison in the Jacobian coordinate space. * Point multiplication for verification (a*P + b*G). - * Use wNAF notation for point multiplicands. - * Use a much larger window for multiples of G, using precomputed multiples. - * Use Shamir's trick to do the multiplication with the public key and the generator simultaneously. - * Optionally (off by default) use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones. + * Use wNAF notation for point multiplicands. + * Use a much larger window for multiples of G, using precomputed multiples. + * Use Shamir's trick to do the multiplication with the public key and the generator simultaneously. + * Optionally (off by default) use secp256k1's efficiently-computable endomorphism to split the P multiplicand into 2 half-sized ones. * Point multiplication for signing - * Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions. - * Access the table with branch-free conditional moves so memory access is uniform. - * No data-dependent branches - * The precomputed tables add and eventually subtract points for which no known scalar (private key) is known, preventing even an attacker with control over the private key used to control the data internally. + * Use a precomputed table of multiples of powers of 16 multiplied with the generator, so general multiplication becomes a series of additions. + * Access the table with branch-free conditional moves so memory access is uniform. + * No data-dependent branches + * The precomputed tables add and eventually subtract points for which no known scalar (private key) is known, preventing even an attacker with control over the private key used to control the data internally. Build steps ----------- libsecp256k1 is built using autotools: - ./autogen.sh - ./configure - make - ./tests - sudo make install # optional + $ ./autogen.sh + $ ./configure + $ make + $ ./tests + $ sudo make install # optional diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/dummy.go new file mode 100644 index 000000000000..fda594be9914 --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file crypto/secp256k1/dummy.go for more information. +package contrib diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/dummy.go new file mode 100644 index 000000000000..379b16992f47 --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file crypto/secp256k1/dummy.go for more information. +package libsecp256k1 diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include/dummy.go new file mode 100644 index 000000000000..5af540c73c4a --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file crypto/secp256k1/dummy.go for more information. +package include diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/asm/field_10x26_arm.s b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/asm/field_10x26_arm.s index 5df561f2fc93..5a9cc3ffcfda 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/asm/field_10x26_arm.s +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/asm/field_10x26_arm.s @@ -11,7 +11,7 @@ Note: - To avoid unnecessary loads and make use of available registers, two 'passes' have every time been interleaved, with the odd passes accumulating c' and d' - which will be added to c and d respectively in the the even passes + which will be added to c and d respectively in the even passes */ @@ -23,7 +23,7 @@ Note: .eabi_attribute 10, 0 @ Tag_FP_arch = none .eabi_attribute 24, 1 @ Tag_ABI_align_needed = 8-byte .eabi_attribute 25, 1 @ Tag_ABI_align_preserved = 8-byte, except leaf SP - .eabi_attribute 30, 2 @ Tag_ABI_optimization_goals = Agressive Speed + .eabi_attribute 30, 2 @ Tag_ABI_optimization_goals = Aggressive Speed .eabi_attribute 34, 1 @ Tag_CPU_unaligned_access = v6 .text diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/dummy.go new file mode 100644 index 000000000000..65868f38a8ea --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file crypto/secp256k1/dummy.go for more information. +package src diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/dummy.go new file mode 100644 index 000000000000..3c7a696439f0 --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file crypto/secp256k1/dummy.go for more information. +package module diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/ecdh/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/ecdh/dummy.go new file mode 100644 index 000000000000..b6fc38327ec8 --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/ecdh/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file crypto/secp256k1/dummy.go for more information. +package ecdh diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/recovery/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/recovery/dummy.go new file mode 100644 index 000000000000..b9491f0cb9f4 --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/recovery/dummy.go @@ -0,0 +1,7 @@ +// +build dummy + +// Package c contains only a C file. +// +// This Go file is part of a workaround for `go mod vendor`. +// Please see the file crypto/secp256k1/dummy.go for more information. +package recovery diff --git a/crypto/keys/secp256k1/internal/secp256k1/panic_cb.go b/crypto/keys/secp256k1/internal/secp256k1/panic_cb.go index 6d59a1d247ea..a30b04f51b42 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/panic_cb.go +++ b/crypto/keys/secp256k1/internal/secp256k1/panic_cb.go @@ -2,6 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be found in // the LICENSE file. +//go:build !gofuzz && cgo +// +build !gofuzz,cgo + package secp256k1 import "C" diff --git a/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_cgo.go b/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_cgo.go new file mode 100644 index 000000000000..8afa9d023b07 --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_cgo.go @@ -0,0 +1,57 @@ +// Copyright 2015 Jeffrey Wilcke, Felix Lange, Gustav Simonsson. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in +// the LICENSE file. + +//go:build !gofuzz && cgo +// +build !gofuzz,cgo + +package secp256k1 + +import ( + "math/big" + "unsafe" +) + +/* + +#include "libsecp256k1/include/secp256k1.h" + +extern int secp256k1_ext_scalar_mul(const secp256k1_context* ctx, const unsigned char *point, const unsigned char *scalar); + +*/ +import "C" + +func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int, *big.Int) { + // Ensure scalar is exactly 32 bytes. We pad always, even if + // scalar is 32 bytes long, to avoid a timing side channel. + if len(scalar) > 32 { + panic("can't handle scalars > 256 bits") + } + // NOTE: potential timing issue + padded := make([]byte, 32) + copy(padded[32-len(scalar):], scalar) + scalar = padded + + // Do the multiplication in C, updating point. + point := make([]byte, 64) + readBits(Bx, point[:32]) + readBits(By, point[32:]) + + pointPtr := (*C.uchar)(unsafe.Pointer(&point[0])) + scalarPtr := (*C.uchar)(unsafe.Pointer(&scalar[0])) + res := C.secp256k1_ext_scalar_mul(context, pointPtr, scalarPtr) + + // Unpack the result and clear temporaries. + x := new(big.Int).SetBytes(point[:32]) + y := new(big.Int).SetBytes(point[32:]) + for i := range point { + point[i] = 0 + } + for i := range padded { + scalar[i] = 0 + } + if res != 1 { + return nil, nil + } + return x, y +} diff --git a/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_nocgo.go b/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_nocgo.go new file mode 100644 index 000000000000..22f53ac6ae65 --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/scalar_mult_nocgo.go @@ -0,0 +1,14 @@ +// Copyright 2015 Jeffrey Wilcke, Felix Lange, Gustav Simonsson. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in +// the LICENSE file. + +//go:build gofuzz || !cgo +// +build gofuzz !cgo + +package secp256k1 + +import "math/big" + +func (BitCurve *BitCurve) ScalarMult(Bx, By *big.Int, scalar []byte) (*big.Int, *big.Int) { + panic("ScalarMult is not available when secp256k1 is built without cgo") +} diff --git a/crypto/keys/secp256k1/internal/secp256k1/secp256.go b/crypto/keys/secp256k1/internal/secp256k1/secp256.go index 35d0eef34ace..c9c01b3209af 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/secp256.go +++ b/crypto/keys/secp256k1/internal/secp256k1/secp256.go @@ -2,16 +2,28 @@ // Use of this source code is governed by a BSD-style license that can be found in // the LICENSE file. +//go:build !gofuzz && cgo +// +build !gofuzz,cgo + // Package secp256k1 wraps the bitcoin secp256k1 C library. package secp256k1 /* #cgo CFLAGS: -I./libsecp256k1 #cgo CFLAGS: -I./libsecp256k1/src/ + +#ifdef __SIZEOF_INT128__ +# define HAVE___INT128 +# define USE_FIELD_5X52 +# define USE_SCALAR_4X64 +#else +# define USE_FIELD_10X26 +# define USE_SCALAR_8X32 +#endif + +#define USE_ENDOMORPHISM #define USE_NUM_NONE -#define USE_FIELD_10X26 #define USE_FIELD_INV_BUILTIN -#define USE_SCALAR_8X32 #define USE_SCALAR_INV_BUILTIN #define NDEBUG #include "./libsecp256k1/src/secp256k1.c" diff --git a/crypto/keys/secp256k1/internal/secp256k1/secp256_test.go b/crypto/keys/secp256k1/internal/secp256k1/secp256_test.go new file mode 100644 index 000000000000..ef2a3a3790b4 --- /dev/null +++ b/crypto/keys/secp256k1/internal/secp256k1/secp256_test.go @@ -0,0 +1,238 @@ +// Copyright 2015 Jeffrey Wilcke, Felix Lange, Gustav Simonsson. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be found in +// the LICENSE file. + +package secp256k1 + +import ( + "bytes" + "crypto/ecdsa" + "crypto/elliptic" + "crypto/rand" + "encoding/hex" + "io" + "testing" +) + +const TestCount = 1000 + +func generateKeyPair() (pubkey, privkey []byte) { + key, err := ecdsa.GenerateKey(S256(), rand.Reader) + if err != nil { + panic(err) + } + pubkey = elliptic.Marshal(S256(), key.X, key.Y) + + privkey = make([]byte, 32) + blob := key.D.Bytes() + copy(privkey[32-len(blob):], blob) + + return pubkey, privkey +} + +func csprngEntropy(n int) []byte { + buf := make([]byte, n) + if _, err := io.ReadFull(rand.Reader, buf); err != nil { + panic("reading from crypto/rand failed: " + err.Error()) + } + return buf +} + +func randSig() []byte { + sig := csprngEntropy(65) + sig[32] &= 0x70 + sig[64] %= 4 + return sig +} + +// tests for malleability +// highest bit of signature ECDSA s value must be 0, in the 33th byte +func compactSigCheck(t *testing.T, sig []byte) { + var b = int(sig[32]) + if b < 0 { + t.Errorf("highest bit is negative: %d", b) + } + if ((b >> 7) == 1) != ((b & 0x80) == 0x80) { + t.Errorf("highest bit: %d bit >> 7: %d", b, b>>7) + } + if (b & 0x80) == 0x80 { + t.Errorf("highest bit: %d bit & 0x80: %d", b, b&0x80) + } +} + +func TestSignatureValidity(t *testing.T) { + pubkey, seckey := generateKeyPair() + msg := csprngEntropy(32) + sig, err := Sign(msg, seckey) + if err != nil { + t.Errorf("signature error: %s", err) + } + compactSigCheck(t, sig) + if len(pubkey) != 65 { + t.Errorf("pubkey length mismatch: want: 65 have: %d", len(pubkey)) + } + if len(seckey) != 32 { + t.Errorf("seckey length mismatch: want: 32 have: %d", len(seckey)) + } + if len(sig) != 65 { + t.Errorf("sig length mismatch: want: 65 have: %d", len(sig)) + } + recid := int(sig[64]) + if recid > 4 || recid < 0 { + t.Errorf("sig recid mismatch: want: within 0 to 4 have: %d", int(sig[64])) + } +} + +func TestInvalidRecoveryID(t *testing.T) { + _, seckey := generateKeyPair() + msg := csprngEntropy(32) + sig, _ := Sign(msg, seckey) + sig[64] = 99 + _, err := RecoverPubkey(msg, sig) + if err != ErrInvalidRecoveryID { + t.Fatalf("got %q, want %q", err, ErrInvalidRecoveryID) + } +} + +func TestSignAndRecover(t *testing.T) { + pubkey1, seckey := generateKeyPair() + msg := csprngEntropy(32) + sig, err := Sign(msg, seckey) + if err != nil { + t.Errorf("signature error: %s", err) + } + pubkey2, err := RecoverPubkey(msg, sig) + if err != nil { + t.Errorf("recover error: %s", err) + } + if !bytes.Equal(pubkey1, pubkey2) { + t.Errorf("pubkey mismatch: want: %x have: %x", pubkey1, pubkey2) + } +} + +func TestSignDeterministic(t *testing.T) { + _, seckey := generateKeyPair() + msg := make([]byte, 32) + copy(msg, "hi there") + + sig1, err := Sign(msg, seckey) + if err != nil { + t.Fatal(err) + } + sig2, err := Sign(msg, seckey) + if err != nil { + t.Fatal(err) + } + if !bytes.Equal(sig1, sig2) { + t.Fatal("signatures not equal") + } +} + +func TestRandomMessagesWithSameKey(t *testing.T) { + pubkey, seckey := generateKeyPair() + keys := func() ([]byte, []byte) { + return pubkey, seckey + } + signAndRecoverWithRandomMessages(t, keys) +} + +func TestRandomMessagesWithRandomKeys(t *testing.T) { + keys := func() ([]byte, []byte) { + pubkey, seckey := generateKeyPair() + return pubkey, seckey + } + signAndRecoverWithRandomMessages(t, keys) +} + +func signAndRecoverWithRandomMessages(t *testing.T, keys func() ([]byte, []byte)) { + for i := 0; i < TestCount; i++ { + pubkey1, seckey := keys() + msg := csprngEntropy(32) + sig, err := Sign(msg, seckey) + if err != nil { + t.Fatalf("signature error: %s", err) + } + if sig == nil { + t.Fatal("signature is nil") + } + compactSigCheck(t, sig) + + // TODO: why do we flip around the recovery id? + sig[len(sig)-1] %= 4 + + pubkey2, err := RecoverPubkey(msg, sig) + if err != nil { + t.Fatalf("recover error: %s", err) + } + if pubkey2 == nil { + t.Error("pubkey is nil") + } + if !bytes.Equal(pubkey1, pubkey2) { + t.Fatalf("pubkey mismatch: want: %x have: %x", pubkey1, pubkey2) + } + } +} + +func TestRecoveryOfRandomSignature(t *testing.T) { + pubkey1, _ := generateKeyPair() + msg := csprngEntropy(32) + + for i := 0; i < TestCount; i++ { + // recovery can sometimes work, but if so should always give wrong pubkey + pubkey2, _ := RecoverPubkey(msg, randSig()) + if bytes.Equal(pubkey1, pubkey2) { + t.Fatalf("iteration: %d: pubkey mismatch: do NOT want %x: ", i, pubkey2) + } + } +} + +func TestRandomMessagesAgainstValidSig(t *testing.T) { + pubkey1, seckey := generateKeyPair() + msg := csprngEntropy(32) + sig, _ := Sign(msg, seckey) + + for i := 0; i < TestCount; i++ { + msg = csprngEntropy(32) + pubkey2, _ := RecoverPubkey(msg, sig) + // recovery can sometimes work, but if so should always give wrong pubkey + if bytes.Equal(pubkey1, pubkey2) { + t.Fatalf("iteration: %d: pubkey mismatch: do NOT want %x: ", i, pubkey2) + } + } +} + +// Useful when the underlying libsecp256k1 API changes to quickly +// check only recover function without use of signature function +func TestRecoverSanity(t *testing.T) { + msg, _ := hex.DecodeString("ce0677bb30baa8cf067c88db9811f4333d131bf8bcf12fe7065d211dce971008") + sig, _ := hex.DecodeString("90f27b8b488db00b00606796d2987f6a5f59ae62ea05effe84fef5b8b0e549984a691139ad57a3f0b906637673aa2f63d1f55cb1a69199d4009eea23ceaddc9301") + pubkey1, _ := hex.DecodeString("04e32df42865e97135acfb65f3bae71bdc86f4d49150ad6a440b6f15878109880a0a2b2667f7e725ceea70c673093bf67663e0312623c8e091b13cf2c0f11ef652") + pubkey2, err := RecoverPubkey(msg, sig) + if err != nil { + t.Fatalf("recover error: %s", err) + } + if !bytes.Equal(pubkey1, pubkey2) { + t.Errorf("pubkey mismatch: want: %x have: %x", pubkey1, pubkey2) + } +} + +func BenchmarkSign(b *testing.B) { + _, seckey := generateKeyPair() + msg := csprngEntropy(32) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + Sign(msg, seckey) + } +} + +func BenchmarkRecover(b *testing.B) { + msg := csprngEntropy(32) + _, seckey := generateKeyPair() + sig, _ := Sign(msg, seckey) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + RecoverPubkey(msg, sig) + } +} diff --git a/crypto/keys/secp256k1/secp256k1_cgo.go b/crypto/keys/secp256k1/secp256k1_cgo.go index 42088483d3f9..a033b0ffd2b2 100644 --- a/crypto/keys/secp256k1/secp256k1_cgo.go +++ b/crypto/keys/secp256k1/secp256k1_cgo.go @@ -1,4 +1,5 @@ -// +build libsecp256k1 +//go:build libsecp256k1_sdk +// +build libsecp256k1_sdk package secp256k1 @@ -21,6 +22,6 @@ func (privKey *PrivKey) Sign(msg []byte) ([]byte, error) { // VerifySignature validates the signature. // The msg will be hashed prior to signature verification. -func (pubKey *PrivKey) VerifySignature(msg []byte, sig []byte) bool { - return secp256k1.VerifySignature(pubKey.Key, crypto.Sha256(msg), sig) +func (pubKey *PubKey) VerifySignature(msg []byte, sigStr []byte) bool { + return secp256k1.VerifySignature(pubKey.Bytes(), crypto.Sha256(msg), sigStr) } diff --git a/crypto/keys/secp256k1/secp256k1_cgo_test.go b/crypto/keys/secp256k1/secp256k1_cgo_test.go index bfaa76caf9db..2023175e8689 100644 --- a/crypto/keys/secp256k1/secp256k1_cgo_test.go +++ b/crypto/keys/secp256k1/secp256k1_cgo_test.go @@ -1,4 +1,5 @@ -// +build libsecp256k1 +//go:build libsecp256k1_sdk +// +build libsecp256k1_sdk package secp256k1 @@ -20,7 +21,7 @@ func TestPrivKeySecp256k1SignVerify(t *testing.T) { wantVerifyPasses bool }{ {name: "valid sign-verify round", privKey: priv, wantSignErr: false, wantVerifyPasses: true}, - {name: "invalid private key", privKey: &*PrivKey{Key: [32]byte{}}, wantSignErr: true, wantVerifyPasses: false}, + {name: "invalid private key", privKey: &PrivKey{Key: []byte{}}, wantSignErr: true, wantVerifyPasses: false}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -34,7 +35,7 @@ func TestPrivKeySecp256k1SignVerify(t *testing.T) { require.NotNil(t, got) pub := tt.privKey.PubKey() - assert.Equal(t, tt.wantVerifyPasses, pub.VerifyBytes(msg, got)) + assert.Equal(t, tt.wantVerifyPasses, pub.VerifySignature(msg, got)) }) } } diff --git a/crypto/keys/secp256k1/secp256k1_nocgo.go b/crypto/keys/secp256k1/secp256k1_nocgo.go index 26735b44229b..60fd9577978c 100644 --- a/crypto/keys/secp256k1/secp256k1_nocgo.go +++ b/crypto/keys/secp256k1/secp256k1_nocgo.go @@ -1,5 +1,5 @@ -//go:build !libsecp256k1 -// +build !libsecp256k1 +//go:build !libsecp256k1_sdk +// +build !libsecp256k1_sdk package secp256k1 diff --git a/crypto/keys/secp256k1/secp256k1_nocgo_test.go b/crypto/keys/secp256k1/secp256k1_nocgo_test.go index 4c2c856e13cc..060b2815a01e 100644 --- a/crypto/keys/secp256k1/secp256k1_nocgo_test.go +++ b/crypto/keys/secp256k1/secp256k1_nocgo_test.go @@ -1,4 +1,5 @@ -// +build !libsecp256k1 +//go:build !libsecp256k1_sdk +// +build !libsecp256k1_sdk package secp256k1 diff --git a/docker-compose.yml b/docker-compose.yml index a5ef517e547a..13851c894e9f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,64 +3,88 @@ version: "3" services: simdnode0: container_name: simdnode0 - image: "cosmossdk/simd-env" + image: "cosmossdk/simd" + environment: + - DEBUG=1 + - ID=0 + - LOG=${LOG:-simd.log} + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined ports: - "26656-26657:26656-26657" - "1317:1317" - "9090:9090" - environment: - - ID=0 - - LOG=${LOG:-simd.log} + - "2345:2345" volumes: - - ./localnet:/data:Z + - ./.testnets:/data:Z networks: localnet: ipv4_address: 192.168.10.2 simdnode1: container_name: simdnode1 - image: "cosmossdk/simd-env" + image: "cosmossdk/simd" + environment: + - DEBUG=0 + - ID=1 + - LOG=${LOG:-simd.log} + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined ports: - "26666-26667:26656-26657" - "1318:1317" - "9091:9090" - environment: - - ID=1 - - LOG=${LOG:-simd.log} + - "2346:2345" volumes: - - ./localnet:/data:Z + - ./.testnets:/data:Z networks: localnet: ipv4_address: 192.168.10.3 simdnode2: container_name: simdnode2 - image: "cosmossdk/simd-env" + image: "cosmossdk/simd" environment: + - DEBUG=0 - ID=2 - LOG=${LOG:-simd.log} + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined ports: - "26676-26677:26656-26657" - "1319:1317" - "9092:9090" + - "2347:2345" volumes: - - ./localnet:/data:Z + - ./.testnets:/data:Z networks: localnet: ipv4_address: 192.168.10.4 simdnode3: container_name: simdnode3 - image: "cosmossdk/simd-env" + image: "cosmossdk/simd" environment: + - DEBUG=0 - ID=3 - LOG=${LOG:-simd.log} + cap_add: + - SYS_PTRACE + security_opt: + - seccomp:unconfined ports: - "26686-26687:26656-26657" - "1320:1317" - "9093:9090" + - "2348:2345" volumes: - - ./localnet:/data:Z + - ./.testnets:/data:Z networks: localnet: ipv4_address: 192.168.10.5 @@ -71,4 +95,4 @@ networks: ipam: driver: default config: - - subnet: 192.168.10.0/16 + - subnet: 192.168.10.0/25 diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 9db03d5bf8d3..dc8edd435a2f 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -38,18 +38,14 @@ module.exports = { index: "cosmos-sdk" }, versions: [ - { - "label": "v0.39", - "key": "v0.39" - }, - { - "label": "v0.42", - "key": "v0.42" - }, { "label": "v0.44", "key": "v0.44" }, + { + "label": "v0.45", + "key": "v0.45" + }, { "label": "master", "key": "master" diff --git a/docs/README.md b/docs/README.md index d3caf5497404..657a46f7b5a1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -47,9 +47,9 @@ aside: false ## Get Started -- **[SDK Intro](./intro/overview.md)**: High-level overview of the Cosmos SDK. -- **[Starport](https://github.com/tendermint/starport/blob/develop/docs/README.md)**: A developer-friendly interface to the Cosmos SDK to scaffold a standard Cosmos SDK blockchain app. -- **[SDK Application Tutorial](https://github.com/cosmos/sdk-application-tutorial)**: A tutorial that showcases how to build a Cosmos SDK-based blockchain from scratch and explains the basic principles of the SDK in the process. +* **[Cosmos SDK Intro](./intro/overview.md)**: High-level overview of the Cosmos SDK. +* **[Ignite CLI](https://docs.ignite.com)**: A developer-friendly interface to the Cosmos SDK to scaffold, launch, and maintain any crypto application on a sovereign and secured blockchain. +* **[SDK Tutorials](https://tutorials.cosmos.network/)**: Tutorials that showcase how to build Cosmos SDK-based blockchains from scratch and explain the basic Cosmos SDK principles in the process. ## Reference diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index 07d5f649a19c..41a3b66c2406 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -29,6 +29,7 @@ - [cosmos/authz/v1beta1/authz.proto](#cosmos/authz/v1beta1/authz.proto) - [GenericAuthorization](#cosmos.authz.v1beta1.GenericAuthorization) - [Grant](#cosmos.authz.v1beta1.Grant) + - [GrantAuthorization](#cosmos.authz.v1beta1.GrantAuthorization) - [cosmos/authz/v1beta1/event.proto](#cosmos/authz/v1beta1/event.proto) - [EventGrant](#cosmos.authz.v1beta1.EventGrant) @@ -36,9 +37,12 @@ - [cosmos/authz/v1beta1/genesis.proto](#cosmos/authz/v1beta1/genesis.proto) - [GenesisState](#cosmos.authz.v1beta1.GenesisState) - - [GrantAuthorization](#cosmos.authz.v1beta1.GrantAuthorization) - [cosmos/authz/v1beta1/query.proto](#cosmos/authz/v1beta1/query.proto) + - [QueryGranteeGrantsRequest](#cosmos.authz.v1beta1.QueryGranteeGrantsRequest) + - [QueryGranteeGrantsResponse](#cosmos.authz.v1beta1.QueryGranteeGrantsResponse) + - [QueryGranterGrantsRequest](#cosmos.authz.v1beta1.QueryGranterGrantsRequest) + - [QueryGranterGrantsResponse](#cosmos.authz.v1beta1.QueryGranterGrantsResponse) - [QueryGrantsRequest](#cosmos.authz.v1beta1.QueryGrantsRequest) - [QueryGrantsResponse](#cosmos.authz.v1beta1.QueryGrantsResponse) @@ -99,6 +103,8 @@ - [QueryDenomsMetadataResponse](#cosmos.bank.v1beta1.QueryDenomsMetadataResponse) - [QueryParamsRequest](#cosmos.bank.v1beta1.QueryParamsRequest) - [QueryParamsResponse](#cosmos.bank.v1beta1.QueryParamsResponse) + - [QuerySpendableBalancesRequest](#cosmos.bank.v1beta1.QuerySpendableBalancesRequest) + - [QuerySpendableBalancesResponse](#cosmos.bank.v1beta1.QuerySpendableBalancesResponse) - [QuerySupplyOfRequest](#cosmos.bank.v1beta1.QuerySupplyOfRequest) - [QuerySupplyOfResponse](#cosmos.bank.v1beta1.QuerySupplyOfResponse) - [QueryTotalSupplyRequest](#cosmos.bank.v1beta1.QueryTotalSupplyRequest) @@ -159,6 +165,11 @@ - [cosmos/base/snapshots/v1beta1/snapshot.proto](#cosmos/base/snapshots/v1beta1/snapshot.proto) - [Metadata](#cosmos.base.snapshots.v1beta1.Metadata) - [Snapshot](#cosmos.base.snapshots.v1beta1.Snapshot) + - [SnapshotExtensionMeta](#cosmos.base.snapshots.v1beta1.SnapshotExtensionMeta) + - [SnapshotExtensionPayload](#cosmos.base.snapshots.v1beta1.SnapshotExtensionPayload) + - [SnapshotIAVLItem](#cosmos.base.snapshots.v1beta1.SnapshotIAVLItem) + - [SnapshotItem](#cosmos.base.snapshots.v1beta1.SnapshotItem) + - [SnapshotStoreItem](#cosmos.base.snapshots.v1beta1.SnapshotStoreItem) - [cosmos/base/store/v1beta1/commit_info.proto](#cosmos/base/store/v1beta1/commit_info.proto) - [CommitID](#cosmos.base.store.v1beta1.CommitID) @@ -168,11 +179,6 @@ - [cosmos/base/store/v1beta1/listening.proto](#cosmos/base/store/v1beta1/listening.proto) - [StoreKVPair](#cosmos.base.store.v1beta1.StoreKVPair) -- [cosmos/base/store/v1beta1/snapshot.proto](#cosmos/base/store/v1beta1/snapshot.proto) - - [SnapshotIAVLItem](#cosmos.base.store.v1beta1.SnapshotIAVLItem) - - [SnapshotItem](#cosmos.base.store.v1beta1.SnapshotItem) - - [SnapshotStoreItem](#cosmos.base.store.v1beta1.SnapshotStoreItem) - - [cosmos/base/tendermint/v1beta1/query.proto](#cosmos/base/tendermint/v1beta1/query.proto) - [GetBlockByHeightRequest](#cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest) - [GetBlockByHeightResponse](#cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse) @@ -919,6 +925,25 @@ the provide method with expiration time. + + + +### GrantAuthorization +GrantAuthorization extends a grant with both the addresses of the grantee and granter. +It is used in genesis.proto and query.proto + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `granter` | [string](#string) | | | +| `grantee` | [string](#string) | | | +| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | | +| `expiration` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | + + + + + @@ -1000,39 +1025,85 @@ GenesisState defines the authz module's genesis state. + + + - + + + -### GrantAuthorization -GrantAuthorization defines the GenesisState/GrantAuthorization type. + + + +

Top

+ +## cosmos/authz/v1beta1/query.proto +Since: cosmos-sdk 0.43 + + + + +### QueryGranteeGrantsRequest +QueryGranteeGrantsRequest is the request type for the Query/IssuedGrants RPC method. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `granter` | [string](#string) | | | | `grantee` | [string](#string) | | | -| `authorization` | [google.protobuf.Any](#google.protobuf.Any) | | | -| `expiration` | [google.protobuf.Timestamp](#google.protobuf.Timestamp) | | | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | - - + - +### QueryGranteeGrantsResponse +QueryGranteeGrantsResponse is the response type for the Query/GranteeGrants RPC method. - + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `grants` | [GrantAuthorization](#cosmos.authz.v1beta1.GrantAuthorization) | repeated | grants is a list of grants granted to the grantee. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | + + + + + + + + +### QueryGranterGrantsRequest +QueryGranterGrantsRequest is the request type for the Query/GranterGrants RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `granter` | [string](#string) | | | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an pagination for the request. | + + + + + + + + +### QueryGranterGrantsResponse +QueryGranterGrantsResponse is the response type for the Query/GranterGrants RPC method. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `grants` | [GrantAuthorization](#cosmos.authz.v1beta1.GrantAuthorization) | repeated | grants is a list of grants granted by the granter. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines an pagination for the response. | - -

Top

-## cosmos/authz/v1beta1/query.proto -Since: cosmos-sdk 0.43 @@ -1083,6 +1154,12 @@ Query defines the gRPC querier service. | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `Grants` | [QueryGrantsRequest](#cosmos.authz.v1beta1.QueryGrantsRequest) | [QueryGrantsResponse](#cosmos.authz.v1beta1.QueryGrantsResponse) | Returns list of `Authorization`, granted to the grantee by the granter. | GET|/cosmos/authz/v1beta1/grants| +| `GranterGrants` | [QueryGranterGrantsRequest](#cosmos.authz.v1beta1.QueryGranterGrantsRequest) | [QueryGranterGrantsResponse](#cosmos.authz.v1beta1.QueryGranterGrantsResponse) | GranterGrants returns list of `GrantAuthorization`, granted by granter. + +Since: cosmos-sdk 0.46 | GET|/cosmos/authz/v1beta1/grants/granter/{granter}| +| `GranteeGrants` | [QueryGranteeGrantsRequest](#cosmos.authz.v1beta1.QueryGranteeGrantsRequest) | [QueryGranteeGrantsResponse](#cosmos.authz.v1beta1.QueryGranteeGrantsResponse) | GranteeGrants returns a list of `GrantAuthorization` by grantee. + +Since: cosmos-sdk 0.46 | GET|/cosmos/authz/v1beta1/grants/grantee/{grantee}| @@ -1874,6 +1951,40 @@ QueryParamsResponse defines the response type for querying x/bank parameters. + + +### QuerySpendableBalancesRequest +QuerySpendableBalancesRequest defines the gRPC request structure for querying +an account's spendable balances. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | address is the address to query spendable balances for. | +| `pagination` | [cosmos.base.query.v1beta1.PageRequest](#cosmos.base.query.v1beta1.PageRequest) | | pagination defines an optional pagination for the request. | + + + + + + + + +### QuerySpendableBalancesResponse +QuerySpendableBalancesResponse defines the gRPC response structure for querying +an account's spendable balances. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `balances` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | repeated | balances is the spendable balances of all the coins. | +| `pagination` | [cosmos.base.query.v1beta1.PageResponse](#cosmos.base.query.v1beta1.PageResponse) | | pagination defines the pagination in the response. | + + + + + + ### QuerySupplyOfRequest @@ -1956,6 +2067,7 @@ Query defines the gRPC querier service. | ----------- | ------------ | ------------- | ------------| ------- | -------- | | `Balance` | [QueryBalanceRequest](#cosmos.bank.v1beta1.QueryBalanceRequest) | [QueryBalanceResponse](#cosmos.bank.v1beta1.QueryBalanceResponse) | Balance queries the balance of a single coin for a single account. | GET|/cosmos/bank/v1beta1/balances/{address}/by_denom| | `AllBalances` | [QueryAllBalancesRequest](#cosmos.bank.v1beta1.QueryAllBalancesRequest) | [QueryAllBalancesResponse](#cosmos.bank.v1beta1.QueryAllBalancesResponse) | AllBalances queries the balance of all coins for a single account. | GET|/cosmos/bank/v1beta1/balances/{address}| +| `SpendableBalances` | [QuerySpendableBalancesRequest](#cosmos.bank.v1beta1.QuerySpendableBalancesRequest) | [QuerySpendableBalancesResponse](#cosmos.bank.v1beta1.QuerySpendableBalancesResponse) | SpendableBalances queries the spenable balance of all coins for a single account. | GET|/cosmos/bank/v1beta1/spendable_balances/{address}| | `TotalSupply` | [QueryTotalSupplyRequest](#cosmos.bank.v1beta1.QueryTotalSupplyRequest) | [QueryTotalSupplyResponse](#cosmos.bank.v1beta1.QueryTotalSupplyResponse) | TotalSupply queries the total supply of all coins. | GET|/cosmos/bank/v1beta1/supply| | `SupplyOf` | [QuerySupplyOfRequest](#cosmos.bank.v1beta1.QuerySupplyOfRequest) | [QuerySupplyOfResponse](#cosmos.bank.v1beta1.QuerySupplyOfResponse) | SupplyOf queries the supply of a single coin. | GET|/cosmos/bank/v1beta1/supply/{denom}| | `Params` | [QueryParamsRequest](#cosmos.bank.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#cosmos.bank.v1beta1.QueryParamsResponse) | Params queries the parameters of x/bank module. | GET|/cosmos/bank/v1beta1/params| @@ -2630,68 +2742,83 @@ Snapshot contains Tendermint state sync snapshot info. - - + - +### SnapshotExtensionMeta +SnapshotExtensionMeta contains metadata about an external snapshotter. - + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `name` | [string](#string) | | | +| `format` | [uint32](#uint32) | | | - -

Top

-## cosmos/base/store/v1beta1/commit_info.proto + - +### SnapshotExtensionPayload +SnapshotExtensionPayload contains payloads of an external snapshotter. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `payload` | [bytes](#bytes) | | | -### CommitID -CommitID defines the committment information when a specific store is -committed. + + + + + + + +### SnapshotIAVLItem +SnapshotIAVLItem is an exported IAVL node. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `version` | [int64](#int64) | | | -| `hash` | [bytes](#bytes) | | | +| `key` | [bytes](#bytes) | | | +| `value` | [bytes](#bytes) | | | +| `version` | [int64](#int64) | | version is block height | +| `height` | [int32](#int32) | | height is depth of the tree. | - + -### CommitInfo -CommitInfo defines commit information used by the multi-store when committing -a version/height. +### SnapshotItem +SnapshotItem is an item contained in a rootmulti.Store snapshot. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `version` | [int64](#int64) | | | -| `store_infos` | [StoreInfo](#cosmos.base.store.v1beta1.StoreInfo) | repeated | | +| `store` | [SnapshotStoreItem](#cosmos.base.snapshots.v1beta1.SnapshotStoreItem) | | | +| `iavl` | [SnapshotIAVLItem](#cosmos.base.snapshots.v1beta1.SnapshotIAVLItem) | | | +| `extension` | [SnapshotExtensionMeta](#cosmos.base.snapshots.v1beta1.SnapshotExtensionMeta) | | | +| `extension_payload` | [SnapshotExtensionPayload](#cosmos.base.snapshots.v1beta1.SnapshotExtensionPayload) | | | - + -### StoreInfo -StoreInfo defines store-specific commit information. It contains a reference -between a store name and the commit ID. +### SnapshotStoreItem +SnapshotStoreItem contains metadata about a snapshotted store. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | | `name` | [string](#string) | | | -| `commit_id` | [CommitID](#cosmos.base.store.v1beta1.CommitID) | | | @@ -2707,94 +2834,96 @@ between a store name and the commit ID. - +

Top

-## cosmos/base/store/v1beta1/listening.proto +## cosmos/base/store/v1beta1/commit_info.proto - - -### StoreKVPair -StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes) -It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and -Deletes + -Since: cosmos-sdk 0.43 +### CommitID +CommitID defines the committment information when a specific store is +committed. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `store_key` | [string](#string) | | the store key for the KVStore this pair originates from | -| `delete` | [bool](#bool) | | true indicates a delete operation, false indicates a set operation | -| `key` | [bytes](#bytes) | | | -| `value` | [bytes](#bytes) | | | +| `version` | [int64](#int64) | | | +| `hash` | [bytes](#bytes) | | | - - + - +### CommitInfo +CommitInfo defines commit information used by the multi-store when committing +a version/height. - +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `version` | [int64](#int64) | | | +| `store_infos` | [StoreInfo](#cosmos.base.store.v1beta1.StoreInfo) | repeated | | - -

Top

-## cosmos/base/store/v1beta1/snapshot.proto - + -### SnapshotIAVLItem -SnapshotIAVLItem is an exported IAVL node. +### StoreInfo +StoreInfo defines store-specific commit information. It contains a reference +between a store name and the commit ID. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `key` | [bytes](#bytes) | | | -| `value` | [bytes](#bytes) | | | -| `version` | [int64](#int64) | | | -| `height` | [int32](#int32) | | | +| `name` | [string](#string) | | | +| `commit_id` | [CommitID](#cosmos.base.store.v1beta1.CommitID) | | | + - + -### SnapshotItem -SnapshotItem is an item contained in a rootmulti.Store snapshot. + + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `store` | [SnapshotStoreItem](#cosmos.base.store.v1beta1.SnapshotStoreItem) | | | -| `iavl` | [SnapshotIAVLItem](#cosmos.base.store.v1beta1.SnapshotIAVLItem) | | | + +

Top

+## cosmos/base/store/v1beta1/listening.proto - + -### SnapshotStoreItem -SnapshotStoreItem contains metadata about a snapshotted store. +### StoreKVPair +StoreKVPair is a KVStore KVPair used for listening to state changes (Sets and Deletes) +It optionally includes the StoreKey for the originating KVStore and a Boolean flag to distinguish between Sets and +Deletes + +Since: cosmos-sdk 0.43 | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `name` | [string](#string) | | | +| `store_key` | [string](#string) | | the store key for the KVStore this pair originates from | +| `delete` | [bool](#bool) | | true indicates a delete operation, false indicates a set operation | +| `key` | [bytes](#bytes) | | | +| `value` | [bytes](#bytes) | | | diff --git a/docs/versions b/docs/versions index aec06db250e3..a1007ab1de14 100644 --- a/docs/versions +++ b/docs/versions @@ -1,4 +1,3 @@ master master -launchpad/backports v0.39 -release/v0.42.x v0.42 release/v0.44.x v0.44 +release/v0.45.x v0.45 diff --git a/go.mod b/go.mod index b939c0857d4d..d9f848223cd2 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ -go 1.15 +go 1.17 module github.com/cosmos/cosmos-sdk require ( github.com/99designs/keyring v1.1.6 - github.com/armon/go-metrics v0.3.9 + github.com/armon/go-metrics v0.3.10 github.com/bgentry/speakeasy v0.1.0 github.com/btcsuite/btcd v0.22.0-beta github.com/coinbase/rosetta-sdk-go v0.7.0 @@ -26,44 +26,109 @@ require ( github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 github.com/improbable-eng/grpc-web v0.14.1 github.com/jhump/protoreflect v1.9.0 - github.com/kr/text v0.2.0 // indirect - github.com/lib/pq v1.10.2 // indirect github.com/magiconair/properties v1.8.5 github.com/mattn/go-isatty v0.0.14 - github.com/onsi/ginkgo v1.16.4 // indirect - github.com/onsi/gomega v1.13.0 // indirect github.com/otiai10/copy v1.6.0 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.11.0 - github.com/prometheus/common v0.29.0 + github.com/prometheus/client_golang v1.12.1 + github.com/prometheus/common v0.32.1 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 github.com/rs/zerolog v1.23.0 - github.com/spf13/cast v1.3.1 - github.com/spf13/cobra v1.2.1 + github.com/spf13/cast v1.4.1 + github.com/spf13/cobra v1.4.0 github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.8.1 - github.com/stretchr/testify v1.7.0 + github.com/spf13/viper v1.10.1 + github.com/stretchr/testify v1.7.1 github.com/tendermint/btcd v0.1.1 github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 github.com/tendermint/go-amino v0.16.0 - github.com/tendermint/tendermint v0.34.14 - github.com/tendermint/tm-db v0.6.4 - golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 + github.com/tendermint/tendermint v0.34.19 + github.com/tendermint/tm-db v0.6.6 + golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb - google.golang.org/grpc v1.44.0 + google.golang.org/grpc v1.45.0 google.golang.org/protobuf v1.27.1 gopkg.in/yaml.v2 v2.4.0 ) -// latest grpc doesn't work with with our modified proto compiler, so we need to enforce -// the following version across all dependencies. -replace google.golang.org/grpc => google.golang.org/grpc v1.33.2 +require ( + filippo.io/edwards25519 v1.0.0-beta.2 // indirect + github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect + github.com/DataDog/zstd v1.4.5 // indirect + github.com/Workiva/go-datastructures v1.0.53 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/cespare/xxhash v1.1.0 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/cosmos/ledger-go v0.9.2 // indirect + github.com/danieljoos/wincred v1.0.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect + github.com/dgraph-io/badger/v2 v2.2007.2 // indirect + github.com/dgraph-io/ristretto v0.0.3 // indirect + github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect + github.com/dustin/go-humanize v1.0.0 // indirect + github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect + github.com/felixge/httpsnoop v1.0.1 // indirect + github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/go-kit/kit v0.12.0 // indirect + github.com/go-kit/log v0.2.0 // indirect + github.com/go-logfmt/logfmt v0.5.1 // indirect + github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect + github.com/golang/snappy v0.0.3 // indirect + github.com/google/btree v1.0.0 // indirect + github.com/google/orderedcode v0.0.1 // indirect + github.com/gorilla/websocket v1.5.0 // indirect + github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect + github.com/gtank/merlin v0.1.1 // indirect + github.com/gtank/ristretto255 v0.1.2 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/jmhodges/levigo v1.0.0 // indirect + github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect + github.com/klauspost/compress v1.13.6 // indirect + github.com/lib/pq v1.10.4 // indirect + github.com/libp2p/go-buffer-pool v0.0.2 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect + github.com/minio/highwayhash v1.0.2 // indirect + github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/mtibben/percent v0.2.1 // indirect + github.com/onsi/ginkgo v1.16.4 // indirect + github.com/pelletier/go-toml v1.9.4 // indirect + github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/procfs v0.7.3 // indirect + github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect + github.com/rs/cors v1.8.2 // indirect + github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect + github.com/spf13/afero v1.6.0 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/subosito/gotenv v1.2.0 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect + github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect + github.com/zondax/hid v0.9.0 // indirect + go.etcd.io/bbolt v1.3.6 // indirect + golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b // indirect + golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect + golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect + golang.org/x/text v0.3.7 // indirect + gopkg.in/ini.v1 v1.66.2 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + nhooyr.io/websocket v1.8.6 // indirect +) -replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 +replace ( + github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 -replace github.com/99designs/keyring => github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 + // 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 + github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 -// Fix upstream GHSA-h395-qcrw-5vmq vulnerability. -// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 -replace github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 + // latest grpc doesn't work with with our modified proto compiler, so we need to enforce + // the following version across all dependencies. + google.golang.org/grpc => google.golang.org/grpc v1.33.2 +) diff --git a/go.sum b/go.sum index d18d9cbf97a1..43c29749f85a 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,4 @@ +bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= @@ -17,6 +18,14 @@ cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmW cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= +cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= +cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= +cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= +cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= +cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -26,6 +35,7 @@ cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM7 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/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -40,6 +50,9 @@ filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8f filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.19.0/go.mod h1:h6H6c8enJmmocHUbLiiGY6sx7f9i+X3m1CHdd5c6Rdw= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.11.0/go.mod h1:HcM1YX14R7CJcghJGOYCgdezslRSVzqwLf/q+4Y2r/0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.7.0/go.mod h1:yqy467j36fJxcRV2TzfVZ1pCb5vxm4BtZPUdYWe/Xo8= github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= @@ -55,17 +68,22 @@ github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= 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/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= +github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.5.0 h1:Elr9Wn+sGKPlkaBvwu4mTrxtmOp3F3yV9qhaHbXGjwU= github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= +github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY= +github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= 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= @@ -76,13 +94,16 @@ github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrU github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8= 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 h1:PLSK6pwn8mYdaoaCZEMsXBpBotr4HHn9abU0yMQt0NI= 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/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:eSYp2T6f0apnuW8TzhV3f6Aff2SE8Dwio++U4ha4yEM= -github.com/adlio/schema v1.1.13 h1:LeNMVg5Z1FX+Qgz8tJUijBLRdcpbFUElz+d1489On98= github.com/adlio/schema v1.1.13/go.mod h1:L5Z7tw+7lRK1Fnpi/LT/ooCP1elkXn0krMWBQHUhEDE= +github.com/adlio/schema v1.3.0 h1:eSVYLxYWbm/6ReZBCkLw4Fz7uqC+ZNoPvA39bOwi52A= +github.com/adlio/schema v1.3.0/go.mod h1:51QzxkpeFs6lRY11kPye26IaFPOV+HqEj01t5aXXKfs= 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= +github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -96,14 +117,21 @@ github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1: 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= -github.com/armon/go-metrics v0.3.9 h1:O2sNqxBdvq8Eq5xmzljcYzAORli6RWCvEym4cJf9m18= github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= +github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= +github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= 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/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.25.48/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.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= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -112,7 +140,6 @@ github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQ 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/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= @@ -135,14 +162,18 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= 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= +github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= 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 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= 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/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= 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= @@ -150,9 +181,14 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= 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/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +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-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= 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.0 h1:lmTO/JEpCvZgpbkOITL95rA80CPKb5CtMzLaqF2mCNg= @@ -160,8 +196,9 @@ github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq github.com/confio/ics23/go v0.6.6 h1:pkOy18YxxJ/r0XFDCnrl4Bjv6h4LkBSpLS6F38mrKL8= github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= -github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6 h1:NmTXa/uVnDyp0TY5MKi197+3HWcnYWfnHGyaFthlnGw= github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= +github.com/containerd/continuity v0.2.1 h1:/EeEo2EtN3umhbbgCveyjifoMYg0pS+nMMEemaYw634= +github.com/containerd/continuity v0.2.1/go.mod h1:wCYX+dRqZdImhGucXOqTQn05AhX6EUDaGEMUzTFFpLg= 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= @@ -189,6 +226,7 @@ github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9 github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= 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/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= @@ -200,6 +238,7 @@ 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/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= +github.com/denisenkom/go-mssqldb v0.12.0/go.mod h1:iiK0YP1ZeepvmBQk/QpLEhhTNJgfzrpArPY/aFvc9yU= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k= @@ -213,6 +252,7 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WA 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/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= @@ -231,7 +271,9 @@ github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFP github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8plZ0M9VMk4/oM= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= @@ -241,18 +283,24 @@ github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQD github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= +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= 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.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -264,15 +312,18 @@ 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 h1:dXFJfIHVvUcpSgDOV+Ne6t7jXri8Tfv2uOLHUZ2XNuo= 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= +github.com/go-kit/log v0.2.0 h1:7i2K3eKTos3Vc0enKCfnVcgHh2olr/MyfboYq7cAcFw= +github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= +github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= @@ -282,9 +333,10 @@ github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7a github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-zookeeper/zk v1.0.2/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= @@ -296,12 +348,17 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6 github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= 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/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/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 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= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -332,8 +389,9 @@ 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.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= 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/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -357,6 +415,7 @@ github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6 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= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -370,13 +429,17 @@ github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= +github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= +github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= @@ -387,11 +450,12 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z 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.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gotestyourself/gotestyourself v2.2.0+incompatible h1:AQwinXlbQR2HvPjQZOmDhRqsv5mZf+Jb1RnSLxcqZcI= +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/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= @@ -414,17 +478,27 @@ github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uM 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.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= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v0.16.2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= 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-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -440,15 +514,23 @@ 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/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 h1:uUjLpLt6bVvZ72SQc/B4dXcPBw4Vgd7soowdRl52qEM= github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87/go.mod h1:XGsKKeXxeRr95aEOgipvluMPlgjr7dGlk9ZTWOjcUcg= github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 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/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= +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= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/improbable-eng/grpc-web v0.14.1 h1:NrN4PY71A6tAz2sKDvC5JCauENWp0ykG8Oq1H3cpFvw= @@ -457,6 +539,7 @@ github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NH github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= 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/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= @@ -464,6 +547,8 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS github.com/jhump/protoreflect v1.9.0 h1:npqHz788dryJiR/l6K/RUQAyh2SwV91+d1dnh4RjO9w= github.com/jhump/protoreflect v1.9.0/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= @@ -474,15 +559,16 @@ github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u 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 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= @@ -490,8 +576,10 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.11.7 h1:0hzRabrMN4tSTvMfnL3SCv1ZGeAP23ynzodBgaHeMeg= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.13.4/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/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -507,39 +595,53 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+ github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= -github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= +github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= 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/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4= +github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= 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 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/minio/highwayhash v1.0.1 h1:dZ6IIu8Z14VlC0VpfKofAhCy74wu/Qb5gcn52yWoz/0= 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/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= @@ -548,15 +650,18 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu 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.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= +github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= @@ -568,10 +673,16 @@ github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= 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= github.com/neilotoole/errgroup v0.1.5/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= @@ -600,29 +711,33 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opencontainers/go-digest v1.0.0-rc1 h1:WzifXhOVOEOuFYOJAW6aQqW0TooG2iki3E3Ii+WN7gQ= github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= -github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI= +github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= +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 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= +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 h1:opHZMaswlyxz1OuGpBE53Dwe4/xF7EZTY0A2L/FpCOg= github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= +github.com/opencontainers/runc v1.0.3 h1:1hbqejyQWCJBvtKAfdO0b1FmaEf2z/bxnjqbARass5k= +github.com/opencontainers/runc v1.0.3/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= 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/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 h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= github.com/otiai10/copy v1.6.0 h1:IinKAryFFuPONZ7cm6T6E2QX/vcJwSnlaA5lfoaXIiQ= github.com/otiai10/copy v1.6.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= -github.com/otiai10/curr v1.0.0 h1:TJIWdbX0B+kpNagQrjgq8bCMrbhiuX73M2XwgtDMoOI= 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.2 h1:VYWnrP5fXmz1MXvjuUvcBrXSjGE6xjON+axB/UrpO3E= @@ -634,14 +749,17 @@ github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144T github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= 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.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= +github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= 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/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= +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/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= @@ -651,6 +769,7 @@ github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZ 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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= 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= @@ -659,8 +778,9 @@ github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeD 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 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= +github.com/prometheus/client_golang v1.12.1/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= @@ -678,8 +798,9 @@ github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB8 github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.15.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.29.0 h1:3jqPBvKT4OHAbje2Ql7KeaaSicDBCxMYwEJU1zRJceE= -github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= 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= @@ -688,8 +809,9 @@ github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+Gx 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.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= 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.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= @@ -706,15 +828,18 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= +github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.23.0 h1:UskrK+saS9P9Y789yNNulYKdARjPZuS35B8gJF2x60g= github.com/rs/zerolog v1.23.0/go.mod h1:6c7hFfxPOy7TacJc4Fcdi24/J0NKYGzjG8FWRI916Qo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sagikazarmark/crypt v0.4.0/go.mod h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= 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= @@ -730,9 +855,7 @@ github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrf github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPHbB5mVY2iO9KV3pTt/QbIkGaO8gQ2WrDbP4= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -741,16 +864,18 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= +github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= 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.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.2.1 h1:+KmjbUw1hriSNMF55oPrkZcb27aECyrj8V2ytv7kWDw= -github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= +github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= +github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= @@ -759,16 +884,19 @@ 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.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= 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.8.1 h1:Kq1fyeebqsBfbjZj4EL7gj2IO0mMaiyjYUWcUsl2O44= -github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= +github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk= +github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw= github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= 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= github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= @@ -778,8 +906,9 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= @@ -793,19 +922,25 @@ 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 h1:GCXmlS8Bqd2Ix3TQCpwYLUNHe+Y+QyJsm5YE+S/FkPo= github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0= -github.com/tendermint/tm-db v0.6.4 h1:3N2jlnYQkXNQclQwd/eKV/NzlqPlfK21cpRRIx80XXQ= +github.com/tendermint/tendermint v0.34.19 h1:y0P1qI5wSa9IRuhKnTDA6IUcOrLi1hXJuALR+R7HFEk= +github.com/tendermint/tendermint v0.34.19/go.mod h1:R5+wgIwSxMdKQcmOaeudL0Cjkr3HDkhpcdum6VeU3R4= github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw= +github.com/tendermint/tm-db v0.6.6 h1:EzhaOfR0bdKyATqcd5PNeyeq8r+V4bRPHBfyFdD9kGM= +github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI= github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI= github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/sjson v1.1.4/go.mod h1:wXpKXu8CtDjKAZ+3DrKY5ROCorDFahq8l0tey/Lx1fg= +github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= +github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= @@ -830,12 +965,17 @@ github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= 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.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0= 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/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= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= +go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= +go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= +go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= 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= @@ -845,17 +985,22 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -867,17 +1012,26 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190909091759-094676da4a83/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +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-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/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= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/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-20210817164053-32db794688a5 h1:HWj/xjIHfjYU5nVXpTM0s39J9CbLn7Cc5a7IC5rwsMQ= +golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 h1:3erb+vDS8lU1sxfDHF4/hhWyaXnhIaO+7RgL4fDZORA= +golang.org/x/crypto v0.0.0-20210915214749-c084706c2272/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= @@ -889,6 +1043,7 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= +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/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -915,6 +1070,7 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -930,6 +1086,7 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -964,10 +1121,17 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f h1:w6wWR0H+nyVpbSAQbzVEIACVyr/h8l/BEkY6Sokc7Eg= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/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-20211208012354-db4efeb81f4b h1:MWaHNqZy3KTpuTMAGvv+Kw+ylsEpmyJZizz1dqxnu28= +golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -979,8 +1143,12 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= 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= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1002,6 +1170,7 @@ golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5h 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= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1015,19 +1184,23 @@ golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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-20191210023423-ac6580df4449/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= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1047,6 +1220,7 @@ golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200824131525-c12d262b63d8/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= @@ -1056,6 +1230,7 @@ golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1064,12 +1239,25 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/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= +golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/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-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/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-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1080,13 +1268,18 @@ 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.4/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/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +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-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/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-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= @@ -1099,6 +1292,7 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1135,6 +1329,7 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= @@ -1144,11 +1339,18 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f 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/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/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= +gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= +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= @@ -1171,7 +1373,17 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= +google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= +google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= +google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= +google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= +google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= +google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= +google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= 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= @@ -1225,11 +1437,33 @@ google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= +google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= +google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= 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/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1249,6 +1483,7 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks 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/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= @@ -1256,8 +1491,8 @@ 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.62.0 h1:duBzk771uxoUuOlyRLkHsygud9+5lrlGjdFBb4mSKDU= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= +gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= @@ -1278,7 +1513,6 @@ 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.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= 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= @@ -1290,7 +1524,9 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/proto/cosmos/authz/v1beta1/authz.proto b/proto/cosmos/authz/v1beta1/authz.proto index 2c376905eb8b..05b1feefa4a0 100644 --- a/proto/cosmos/authz/v1beta1/authz.proto +++ b/proto/cosmos/authz/v1beta1/authz.proto @@ -25,3 +25,15 @@ message Grant { google.protobuf.Any authorization = 1 [(cosmos_proto.accepts_interface) = "Authorization"]; google.protobuf.Timestamp expiration = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = false]; } + +// GrantAuthorization extends a grant with both the addresses of the grantee and granter. +// It is used in genesis.proto and query.proto +// +// Since: cosmos-sdk 0.45.2 +message GrantAuthorization { + string granter = 1; + string grantee = 2; + + google.protobuf.Any authorization = 3 [(cosmos_proto.accepts_interface) = "Authorization"]; + google.protobuf.Timestamp expiration = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; +} diff --git a/proto/cosmos/authz/v1beta1/genesis.proto b/proto/cosmos/authz/v1beta1/genesis.proto index ea898694456a..310f62656f97 100644 --- a/proto/cosmos/authz/v1beta1/genesis.proto +++ b/proto/cosmos/authz/v1beta1/genesis.proto @@ -2,10 +2,8 @@ syntax = "proto3"; package cosmos.authz.v1beta1; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; +import "cosmos/authz/v1beta1/authz.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; @@ -13,12 +11,3 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/authz"; message GenesisState { repeated GrantAuthorization authorization = 1 [(gogoproto.nullable) = false]; } - -// GrantAuthorization defines the GenesisState/GrantAuthorization type. -message GrantAuthorization { - string granter = 1; - string grantee = 2; - - google.protobuf.Any authorization = 3 [(cosmos_proto.accepts_interface) = "Authorization"]; - google.protobuf.Timestamp expiration = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; -} diff --git a/proto/cosmos/authz/v1beta1/query.proto b/proto/cosmos/authz/v1beta1/query.proto index 428210de01e7..f668309bed69 100644 --- a/proto/cosmos/authz/v1beta1/query.proto +++ b/proto/cosmos/authz/v1beta1/query.proto @@ -14,6 +14,20 @@ service Query { rpc Grants(QueryGrantsRequest) returns (QueryGrantsResponse) { option (google.api.http).get = "/cosmos/authz/v1beta1/grants"; } + + // GranterGrants returns list of `GrantAuthorization`, granted by granter. + // + // Since: cosmos-sdk 0.45.2 + rpc GranterGrants(QueryGranterGrantsRequest) returns (QueryGranterGrantsResponse) { + option (google.api.http).get = "/cosmos/authz/v1beta1/grants/granter/{granter}"; + } + + // GranteeGrants returns a list of `GrantAuthorization` by grantee. + // + // Since: cosmos-sdk 0.45.2 + rpc GranteeGrants(QueryGranteeGrantsRequest) returns (QueryGranteeGrantsResponse) { + option (google.api.http).get = "/cosmos/authz/v1beta1/grants/grantee/{grantee}"; + } } // QueryGrantsRequest is the request type for the Query/Grants RPC method. @@ -29,7 +43,39 @@ message QueryGrantsRequest { // QueryGrantsResponse is the response type for the Query/Authorizations RPC method. message QueryGrantsResponse { // authorizations is a list of grants granted for grantee by granter. - repeated cosmos.authz.v1beta1.Grant grants = 1; + repeated Grant grants = 1; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGranterGrantsRequest is the request type for the Query/GranterGrants RPC method. +message QueryGranterGrantsRequest { + string granter = 1; + + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryGranterGrantsResponse is the response type for the Query/GranterGrants RPC method. +message QueryGranterGrantsResponse { + // grants is a list of grants granted by the granter. + repeated GrantAuthorization grants = 1; + // pagination defines an pagination for the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryGranteeGrantsRequest is the request type for the Query/IssuedGrants RPC method. +message QueryGranteeGrantsRequest { + string grantee = 1; + + // pagination defines an pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QueryGranteeGrantsResponse is the response type for the Query/GranteeGrants RPC method. +message QueryGranteeGrantsResponse { + // grants is a list of grants granted to the grantee. + repeated GrantAuthorization grants = 1; // pagination defines an pagination for the response. cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/proto/cosmos/bank/v1beta1/query.proto b/proto/cosmos/bank/v1beta1/query.proto index 520ba0696412..67cebd5fdd53 100644 --- a/proto/cosmos/bank/v1beta1/query.proto +++ b/proto/cosmos/bank/v1beta1/query.proto @@ -21,6 +21,12 @@ service Query { option (google.api.http).get = "/cosmos/bank/v1beta1/balances/{address}"; } + // SpendableBalances queries the spenable balance of all coins for a single + // account. + rpc SpendableBalances(QuerySpendableBalancesRequest) returns (QuerySpendableBalancesResponse) { + option (google.api.http).get = "/cosmos/bank/v1beta1/spendable_balances/{address}"; + } + // TotalSupply queries the total supply of all coins. rpc TotalSupply(QueryTotalSupplyRequest) returns (QueryTotalSupplyResponse) { option (google.api.http).get = "/cosmos/bank/v1beta1/supply"; @@ -88,6 +94,30 @@ message QueryAllBalancesResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } +// QuerySpendableBalancesRequest defines the gRPC request structure for querying +// an account's spendable balances. +message QuerySpendableBalancesRequest { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + // address is the address to query spendable balances for. + string address = 1; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +// QuerySpendableBalancesResponse defines the gRPC response structure for querying +// an account's spendable balances. +message QuerySpendableBalancesResponse { + // balances is the spendable balances of all the coins. + repeated cosmos.base.v1beta1.Coin balances = 1 + [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // method. message QueryTotalSupplyRequest { diff --git a/proto/cosmos/base/snapshots/v1beta1/snapshot.proto b/proto/cosmos/base/snapshots/v1beta1/snapshot.proto index 9ac5a7c31be4..1d2365bef652 100644 --- a/proto/cosmos/base/snapshots/v1beta1/snapshot.proto +++ b/proto/cosmos/base/snapshots/v1beta1/snapshot.proto @@ -17,4 +17,41 @@ message Snapshot { // Metadata contains SDK-specific snapshot metadata. message Metadata { repeated bytes chunk_hashes = 1; // SHA-256 chunk hashes -} \ No newline at end of file +} + +// SnapshotItem is an item contained in a rootmulti.Store snapshot. +message SnapshotItem { + // item is the specific type of snapshot item. + oneof item { + SnapshotStoreItem store = 1; + SnapshotIAVLItem iavl = 2 [(gogoproto.customname) = "IAVL"]; + SnapshotExtensionMeta extension = 3; + SnapshotExtensionPayload extension_payload = 4; + } +} + +// SnapshotStoreItem contains metadata about a snapshotted store. +message SnapshotStoreItem { + string name = 1; +} + +// SnapshotIAVLItem is an exported IAVL node. +message SnapshotIAVLItem { + bytes key = 1; + bytes value = 2; + // version is block height + int64 version = 3; + // height is depth of the tree. + int32 height = 4; +} + +// SnapshotExtensionMeta contains metadata about an external snapshotter. +message SnapshotExtensionMeta { + string name = 1; + uint32 format = 2; +} + +// SnapshotExtensionPayload contains payloads of an external snapshotter. +message SnapshotExtensionPayload { + bytes payload = 1; +} diff --git a/proto/cosmos/base/store/v1beta1/snapshot.proto b/proto/cosmos/base/store/v1beta1/snapshot.proto deleted file mode 100644 index 834855093b24..000000000000 --- a/proto/cosmos/base/store/v1beta1/snapshot.proto +++ /dev/null @@ -1,28 +0,0 @@ -syntax = "proto3"; -package cosmos.base.store.v1beta1; - -import "gogoproto/gogo.proto"; - -option go_package = "github.com/cosmos/cosmos-sdk/store/types"; - -// SnapshotItem is an item contained in a rootmulti.Store snapshot. -message SnapshotItem { - // item is the specific type of snapshot item. - oneof item { - SnapshotStoreItem store = 1; - SnapshotIAVLItem iavl = 2 [(gogoproto.customname) = "IAVL"]; - } -} - -// SnapshotStoreItem contains metadata about a snapshotted store. -message SnapshotStoreItem { - string name = 1; -} - -// SnapshotIAVLItem is an exported IAVL node. -message SnapshotIAVLItem { - bytes key = 1; - bytes value = 2; - int64 version = 3; - int32 height = 4; -} \ No newline at end of file diff --git a/proto/cosmos/tx/signing/v1beta1/signing.proto b/proto/cosmos/tx/signing/v1beta1/signing.proto index 4c1be40594d1..c76c231ad73f 100644 --- a/proto/cosmos/tx/signing/v1beta1/signing.proto +++ b/proto/cosmos/tx/signing/v1beta1/signing.proto @@ -24,6 +24,18 @@ enum SignMode { // SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses // Amino JSON and will be removed in the future SIGN_MODE_LEGACY_AMINO_JSON = 127; + + // SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos + // SDK. Ref: https://eips.ethereum.org/EIPS/eip-191 + // + // Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant, + // but is not implemented on the SDK by default. To enable EIP-191, you need + // to pass a custom `TxConfig` that has an implementation of + // `SignModeHandler` for EIP-191. The SDK may decide to fully support + // EIP-191 in the future. + // + // Since: cosmos-sdk 0.45.2 + SIGN_MODE_EIP_191 = 191; } // SignatureDescriptors wraps multiple SignatureDescriptor's. diff --git a/server/api/server.go b/server/api/server.go index c2987f860d1a..68d0450c3485 100644 --- a/server/api/server.go +++ b/server/api/server.go @@ -5,6 +5,7 @@ import ( "net" "net/http" "strings" + "sync" "time" "github.com/gogo/gateway" @@ -30,8 +31,13 @@ type Server struct { GRPCGatewayRouter *runtime.ServeMux ClientCtx client.Context - logger log.Logger - metrics *telemetry.Metrics + logger log.Logger + metrics *telemetry.Metrics + // Start() is blocking and generally called from a separate goroutine. + // Close() can be called asynchronously and access shared memory + // via the listener. Therefore, we sync access to Start and Close with + // this mutex to avoid data races. + mtx sync.Mutex listener net.Listener } @@ -83,9 +89,11 @@ func New(clientCtx client.Context, logger log.Logger) *Server { // and are delegated to the Tendermint JSON RPC server. The process is // non-blocking, so an external signal handler must be used. func (s *Server) Start(cfg config.Config) error { + s.mtx.Lock() if cfg.Telemetry.Enabled { m, err := telemetry.New(cfg.Telemetry) if err != nil { + s.mtx.Unlock() return err } @@ -101,6 +109,7 @@ func (s *Server) Start(cfg config.Config) error { listener, err := tmrpcserver.Listen(cfg.API.Address, tmCfg) if err != nil { + s.mtx.Unlock() return err } @@ -111,15 +120,19 @@ func (s *Server) Start(cfg config.Config) error { if cfg.API.EnableUnsafeCORS { allowAllCORS := handlers.CORS(handlers.AllowedHeaders([]string{"Content-Type"})) + s.mtx.Unlock() return tmrpcserver.Serve(s.listener, allowAllCORS(h), s.logger, tmCfg) } s.logger.Info("starting API server...") + s.mtx.Unlock() return tmrpcserver.Serve(s.listener, s.Router, s.logger, tmCfg) } // Close closes the API server. func (s *Server) Close() error { + s.mtx.Lock() + defer s.mtx.Unlock() return s.listener.Close() } diff --git a/server/mock/store.go b/server/mock/store.go index c8c233bb7c37..360bb8371877 100644 --- a/server/mock/store.go +++ b/server/mock/store.go @@ -3,8 +3,10 @@ package mock import ( "io" + protoio "github.com/gogo/protobuf/io" dbm "github.com/tendermint/tm-db" + snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" store "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -122,13 +124,13 @@ func (ms multiStore) SetInitialVersion(version int64) error { panic("not implemented") } -func (ms multiStore) Snapshot(height uint64, format uint32) (<-chan io.ReadCloser, error) { +func (ms multiStore) Snapshot(height uint64, protoWriter protoio.Writer) error { panic("not implemented") } func (ms multiStore) Restore( - height uint64, format uint32, chunks <-chan io.ReadCloser, ready chan<- struct{}, -) error { + height uint64, format uint32, protoReader protoio.Reader, +) (snapshottypes.SnapshotItem, error) { panic("not implemented") } diff --git a/server/rollback.go b/server/rollback.go new file mode 100644 index 000000000000..f10bcaead505 --- /dev/null +++ b/server/rollback.go @@ -0,0 +1,49 @@ +package server + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/store/rootmulti" + "github.com/spf13/cobra" + tmcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" +) + +// NewRollbackCmd creates a command to rollback tendermint and multistore state by one height. +func NewRollbackCmd(defaultNodeHome string) *cobra.Command { + cmd := &cobra.Command{ + Use: "rollback", + Short: "rollback cosmos-sdk and tendermint state by one height", + Long: ` +A state rollback is performed to recover from an incorrect application state transition, +when Tendermint has persisted an incorrect app hash and is thus unable to make +progress. Rollback overwrites a state at height n with the state at height n - 1. +The application also roll back to height n - 1. No blocks are removed, so upon +restarting Tendermint the transactions in block n will be re-executed against the +application. +`, + RunE: func(cmd *cobra.Command, args []string) error { + ctx := GetServerContextFromCmd(cmd) + cfg := ctx.Config + home := cfg.RootDir + db, err := openDB(home) + if err != nil { + return err + } + // rollback tendermint state + height, hash, err := tmcmd.RollbackState(ctx.Config) + if err != nil { + return fmt.Errorf("failed to rollback tendermint state: %w", err) + } + // rollback the multistore + cms := rootmulti.NewStore(db) + cms.RollbackToVersion(height) + + fmt.Printf("Rolled back state to height %d and hash %X", height, hash) + return nil + }, + } + + cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory") + return cmd +} diff --git a/server/start.go b/server/start.go index 6ff040da4b57..ff5922e07051 100644 --- a/server/start.go +++ b/server/start.go @@ -9,11 +9,7 @@ import ( "runtime/pprof" "time" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/spf13/cobra" - "google.golang.org/grpc" - "github.com/tendermint/tendermint/abci/server" tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" tmos "github.com/tendermint/tendermint/libs/os" @@ -22,21 +18,22 @@ import ( pvm "github.com/tendermint/tendermint/privval" "github.com/tendermint/tendermint/proxy" "github.com/tendermint/tendermint/rpc/client/local" - - "github.com/cosmos/cosmos-sdk/server/rosetta" - crgserver "github.com/cosmos/cosmos-sdk/server/rosetta/lib/server" + "google.golang.org/grpc" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server/api" "github.com/cosmos/cosmos-sdk/server/config" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" + "github.com/cosmos/cosmos-sdk/server/rosetta" + crgserver "github.com/cosmos/cosmos-sdk/server/rosetta/lib/server" "github.com/cosmos/cosmos-sdk/server/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" ) -// Tendermint full-node start flags const ( + // Tendermint full-node start flags flagWithTendermint = "with-tendermint" flagAddress = "address" flagTransport = "transport" @@ -56,22 +53,19 @@ const ( FlagPruningInterval = "pruning-interval" FlagIndexEvents = "index-events" FlagMinRetainBlocks = "min-retain-blocks" -) -// GRPC-related flags. -const ( + // state sync-related flags + FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval" + FlagStateSyncSnapshotKeepRecent = "state-sync.snapshot-keep-recent" + + // gRPC-related flags + flagGRPCOnly = "grpc-only" flagGRPCEnable = "grpc.enable" flagGRPCAddress = "grpc.address" flagGRPCWebEnable = "grpc-web.enable" flagGRPCWebAddress = "grpc-web.address" ) -// State sync-related flags. -const ( - FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval" - FlagStateSyncSnapshotKeepRecent = "state-sync.snapshot-keep-recent" -) - // StartCmd runs the service passed in, either stand-alone or in-process with // Tendermint. func StartCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command { @@ -99,6 +93,11 @@ will not be able to commit subsequent blocks. For profiling and benchmarking purposes, CPU profiling can be enabled via the '--cpu-profile' flag which accepts a path for the resulting pprof file. + +The node may be started in a 'query only' mode where only the gRPC and JSON HTTP +API services are enabled via the 'grpc-only' flag. In this mode, Tendermint is +bypassed and can be used when legacy queries are needed after an on-chain upgrade +is performed. Note, when enabled, gRPC will also be automatically enabled. `, PreRunE: func(cmd *cobra.Command, _ []string) error { serverCtx := GetServerContextFromCmd(cmd) @@ -123,8 +122,6 @@ which accepts a path for the resulting pprof file. return startStandAlone(serverCtx, appCreator) } - serverCtx.Logger.Info("starting ABCI with Tendermint") - // amino is needed here for backwards compatibility of REST routes err = startInProcess(serverCtx, clientCtx, appCreator) errCode, ok := err.(ErrorCode) @@ -156,6 +153,7 @@ which accepts a path for the resulting pprof file. cmd.Flags().Uint(FlagInvCheckPeriod, 0, "Assert registered invariants every N blocks") cmd.Flags().Uint64(FlagMinRetainBlocks, 0, "Minimum block height offset during ABCI commit to prune Tendermint blocks") + cmd.Flags().Bool(flagGRPCOnly, false, "Start the node in gRPC query only mode (no Tendermint process is started)") cmd.Flags().Bool(flagGRPCEnable, true, "Define if the gRPC server should be enabled") cmd.Flags().String(flagGRPCAddress, config.DefaultGRPCAddress, "the gRPC server address to listen on") @@ -210,7 +208,6 @@ func startStandAlone(ctx *Context, appCreator types.AppCreator) error { return WaitForQuitSignals() } -// legacyAminoCdc is used for the legacy REST API func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.AppCreator) error { cfg := ctx.Config home := cfg.RootDir @@ -260,30 +257,40 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App } genDocProvider := node.DefaultGenesisDocProviderFunc(cfg) - tmNode, err := node.NewNode( - cfg, - pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()), - nodeKey, - proxy.NewLocalClientCreator(app), - genDocProvider, - node.DefaultDBProvider, - node.DefaultMetricsProvider(cfg.Instrumentation), - ctx.Logger, + + var ( + tmNode *node.Node + gRPCOnly = ctx.Viper.GetBool(flagGRPCOnly) ) - if err != nil { - return err - } - ctx.Logger.Debug("initialization: tmNode created") - if err := tmNode.Start(); err != nil { - return err + if gRPCOnly { + ctx.Logger.Info("starting node in gRPC only mode; Tendermint is disabled") + config.GRPC.Enable = true + } else { + ctx.Logger.Info("starting node with ABCI Tendermint in-process") + + tmNode, err = node.NewNode( + cfg, + pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()), + nodeKey, + proxy.NewLocalClientCreator(app), + genDocProvider, + node.DefaultDBProvider, + node.DefaultMetricsProvider(cfg.Instrumentation), + ctx.Logger, + ) + if err != nil { + return err + } + if err := tmNode.Start(); err != nil { + return err + } } - ctx.Logger.Debug("initialization: tmNode started") // Add the tx service to the gRPC router. We only need to register this // service if API or gRPC is enabled, and avoid doing so in the general // case, because it spawns a new local tendermint RPC client. - if config.API.Enable || config.GRPC.Enable { + if (config.API.Enable || config.GRPC.Enable) && tmNode != nil { clientCtx = clientCtx.WithClient(local.New(tmNode)) app.RegisterTxService(clientCtx) @@ -297,9 +304,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App return err } - clientCtx := clientCtx. - WithHomeDir(home). - WithChainID(genDoc.ChainID) + clientCtx := clientCtx.WithHomeDir(home).WithChainID(genDoc.ChainID) apiSrv = api.New(clientCtx, ctx.Logger.With("module", "api-server")) app.RegisterAPIRoutes(apiSrv, config.API) @@ -314,6 +319,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App select { case err := <-errCh: return err + case <-time.After(types.ServerStartTime): // assume server started successfully } } @@ -322,11 +328,13 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App grpcSrv *grpc.Server grpcWebSrv *http.Server ) + if config.GRPC.Enable { grpcSrv, err = servergrpc.StartGRPCServer(clientCtx, app, config.GRPC.Address) if err != nil { return err } + if config.GRPCWeb.Enable { grpcWebSrv, err = servergrpc.StartGRPCWeb(grpcSrv, config) if err != nil { @@ -336,28 +344,40 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App } } + // At this point it is safe to block the process if we're in gRPC only mode as + // we do not need to start Rosetta or handle any Tendermint related processes. + if gRPCOnly { + // wait for signal capture and gracefully return + return WaitForQuitSignals() + } + var rosettaSrv crgserver.Server if config.Rosetta.Enable { offlineMode := config.Rosetta.Offline - if !config.GRPC.Enable { // If GRPC is not enabled rosetta cannot work in online mode, so it works in offline mode. + + // If GRPC is not enabled rosetta cannot work in online mode, so it works in + // offline mode. + if !config.GRPC.Enable { offlineMode = true } conf := &rosetta.Config{ - Blockchain: config.Rosetta.Blockchain, - Network: config.Rosetta.Network, - TendermintRPC: ctx.Config.RPC.ListenAddress, - GRPCEndpoint: config.GRPC.Address, - Addr: config.Rosetta.Address, - Retries: config.Rosetta.Retries, - Offline: offlineMode, + Blockchain: config.Rosetta.Blockchain, + Network: config.Rosetta.Network, + TendermintRPC: ctx.Config.RPC.ListenAddress, + GRPCEndpoint: config.GRPC.Address, + Addr: config.Rosetta.Address, + Retries: config.Rosetta.Retries, + Offline: offlineMode, + Codec: clientCtx.Codec.(*codec.ProtoCodec), + InterfaceRegistry: clientCtx.InterfaceRegistry, } - conf.WithCodec(clientCtx.InterfaceRegistry, clientCtx.Codec.(*codec.ProtoCodec)) rosettaSrv, err = rosetta.ServerFromConfig(conf) if err != nil { return err } + errCh := make(chan error) go func() { if err := rosettaSrv.Start(); err != nil { @@ -368,6 +388,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App select { case err := <-errCh: return err + case <-time.After(types.ServerStartTime): // assume server started successfully } } @@ -395,6 +416,6 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App ctx.Logger.Info("exiting...") }() - // Wait for SIGINT or SIGTERM signal + // wait for signal capture and gracefully return return WaitForQuitSignals() } diff --git a/server/tm_cmds.go b/server/tm_cmds.go index 35e202abc22e..575be6903aad 100644 --- a/server/tm_cmds.go +++ b/server/tm_cmds.go @@ -6,7 +6,6 @@ import ( "fmt" "github.com/spf13/cobra" - tcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" "github.com/tendermint/tendermint/p2p" pvm "github.com/tendermint/tendermint/privval" tversion "github.com/tendermint/tendermint/version" @@ -115,18 +114,3 @@ against which this app has been compiled. }, } } - -// UnsafeResetAllCmd - extension of the tendermint command, resets initialization -func UnsafeResetAllCmd() *cobra.Command { - return &cobra.Command{ - Use: "unsafe-reset-all", - Short: "Resets the blockchain database, removes address book files, and resets data/priv_validator_state.json to the genesis state", - RunE: func(cmd *cobra.Command, args []string) error { - serverCtx := GetServerContextFromCmd(cmd) - cfg := serverCtx.Config - - tcmd.ResetAll(cfg.DBDir(), cfg.P2P.AddrBookFile(), cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile(), serverCtx.Logger) - return nil - }, - } -} diff --git a/server/util.go b/server/util.go index bc9ab45df182..ec25470be72e 100644 --- a/server/util.go +++ b/server/util.go @@ -19,6 +19,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" + tmcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" tmcfg "github.com/tendermint/tendermint/config" tmlog "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" @@ -270,16 +271,19 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type ShowValidatorCmd(), ShowAddressCmd(), VersionCmd(), + tmcmd.ResetAllCmd, + tmcmd.ResetStateCmd, ) + startCmd := StartCmd(appCreator, defaultNodeHome) addStartFlags(startCmd) rootCmd.AddCommand( startCmd, - UnsafeResetAllCmd(), tendermintCmd, ExportCmd(appExport, defaultNodeHome), version.NewVersionCommand(), + NewRollbackCmd(defaultNodeHome), ) } diff --git a/simapp/README.md b/simapp/README.md index 4d00c0c2d166..b6170f52857a 100644 --- a/simapp/README.md +++ b/simapp/README.md @@ -16,7 +16,7 @@ in this testnet. `simd` binary inside a new `build` directory. The following instructions are run from inside the `build` directory. 2. If you've run `simd` before, you may need to reset your database before starting a new - testnet. You can reset your database with the following command: `$ ./simd unsafe-reset-all`. + testnet. You can reset your database with the following command: `$ ./simd tendermint unsafe-reset-all`. 3. `$ ./simd init [moniker] --chain-id [chain-id]`. This will initialize a new working directory at the default location `~/.simapp`. You need to provide a "moniker" and a "chain id". These two names can be anything, but you will need to use the same "chain id" in the following steps. diff --git a/snapshots/util.go b/snapshots/chunk.go similarity index 100% rename from snapshots/util.go rename to snapshots/chunk.go diff --git a/snapshots/util_test.go b/snapshots/chunk_test.go similarity index 100% rename from snapshots/util_test.go rename to snapshots/chunk_test.go diff --git a/snapshots/helpers_test.go b/snapshots/helpers_test.go index 705667919146..8c9a67b1b0e5 100644 --- a/snapshots/helpers_test.go +++ b/snapshots/helpers_test.go @@ -1,7 +1,9 @@ package snapshots_test import ( + "bufio" "bytes" + "compress/zlib" "crypto/sha256" "errors" "io" @@ -10,11 +12,14 @@ import ( "testing" "time" + protoio "github.com/gogo/protobuf/io" "github.com/stretchr/testify/require" db "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/snapshots/types" + snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) func checksums(slice [][]byte) [][]byte { @@ -57,45 +62,85 @@ func readChunks(chunks <-chan io.ReadCloser) [][]byte { return bodies } +// snapshotItems serialize a array of bytes as SnapshotItem_ExtensionPayload, and return the chunks. +func snapshotItems(items [][]byte) [][]byte { + // copy the same parameters from the code + snapshotChunkSize := uint64(10e6) + snapshotBufferSize := int(snapshotChunkSize) + + ch := make(chan io.ReadCloser) + go func() { + chunkWriter := snapshots.NewChunkWriter(ch, snapshotChunkSize) + bufWriter := bufio.NewWriterSize(chunkWriter, snapshotBufferSize) + zWriter, _ := zlib.NewWriterLevel(bufWriter, 7) + protoWriter := protoio.NewDelimitedWriter(zWriter) + for _, item := range items { + types.WriteExtensionItem(protoWriter, item) + } + protoWriter.Close() + zWriter.Close() + bufWriter.Flush() + chunkWriter.Close() + }() + + var chunks [][]byte + for chunkBody := range ch { + chunk, err := io.ReadAll(chunkBody) + if err != nil { + panic(err) + } + chunks = append(chunks, chunk) + } + return chunks +} + type mockSnapshotter struct { - chunks [][]byte + items [][]byte } func (m *mockSnapshotter) Restore( - height uint64, format uint32, chunks <-chan io.ReadCloser, ready chan<- struct{}, -) error { + height uint64, format uint32, protoReader protoio.Reader, +) (snapshottypes.SnapshotItem, error) { if format == 0 { - return types.ErrUnknownFormat + return snapshottypes.SnapshotItem{}, types.ErrUnknownFormat } - if m.chunks != nil { - return errors.New("already has contents") + if m.items != nil { + return snapshottypes.SnapshotItem{}, errors.New("already has contents") } - if ready != nil { - close(ready) + + m.items = [][]byte{} + for { + item := &snapshottypes.SnapshotItem{} + err := protoReader.ReadMsg(item) + if err == io.EOF { + break + } else if err != nil { + return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "invalid protobuf message") + } + payload := item.GetExtensionPayload() + if payload == nil { + return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "invalid protobuf message") + } + m.items = append(m.items, payload.Payload) } - m.chunks = [][]byte{} - for reader := range chunks { - chunk, err := ioutil.ReadAll(reader) - if err != nil { + return snapshottypes.SnapshotItem{}, nil +} + +func (m *mockSnapshotter) Snapshot(height uint64, protoWriter protoio.Writer) error { + for _, item := range m.items { + if err := types.WriteExtensionItem(protoWriter, item); err != nil { return err } - m.chunks = append(m.chunks, chunk) } - return nil } -func (m *mockSnapshotter) Snapshot(height uint64, format uint32) (<-chan io.ReadCloser, error) { - if format == 0 { - return nil, types.ErrUnknownFormat - } - ch := make(chan io.ReadCloser, len(m.chunks)) - for _, chunk := range m.chunks { - ch <- ioutil.NopCloser(bytes.NewReader(chunk)) - } - close(ch) - return ch, nil +func (m *mockSnapshotter) SnapshotFormat() uint32 { + return 1 +} +func (m *mockSnapshotter) SupportedFormats() []uint32 { + return []uint32{1} } // setupBusyManager creates a manager with an empty store that is busy creating a snapshot at height 1. @@ -138,15 +183,13 @@ func (m *hungSnapshotter) Close() { close(m.ch) } -func (m *hungSnapshotter) Snapshot(height uint64, format uint32) (<-chan io.ReadCloser, error) { +func (m *hungSnapshotter) Snapshot(height uint64, protoWriter protoio.Writer) error { <-m.ch - ch := make(chan io.ReadCloser, 1) - ch <- ioutil.NopCloser(bytes.NewReader([]byte{})) - return ch, nil + return nil } func (m *hungSnapshotter) Restore( - height uint64, format uint32, chunks <-chan io.ReadCloser, ready chan<- struct{}, -) error { + height uint64, format uint32, protoReader protoio.Reader, +) (snapshottypes.SnapshotItem, error) { panic("not implemented") } diff --git a/snapshots/manager.go b/snapshots/manager.go index 3cb96e65f42f..02878963d491 100644 --- a/snapshots/manager.go +++ b/snapshots/manager.go @@ -3,8 +3,11 @@ package snapshots import ( "bytes" "crypto/sha256" + "fmt" "io" "io/ioutil" + "math" + "sort" "sync" "github.com/cosmos/cosmos-sdk/snapshots/types" @@ -18,6 +21,8 @@ const ( opRestore operation = "restore" chunkBufferSize = 4 + + snapshotMaxItemSize = int(64e6) // SDK has no key/value size limit, so we set an arbitrary limit ) // operation represents a Manager operation. Only one operation can be in progress at a time. @@ -43,8 +48,9 @@ type restoreDone struct { // 2) io.ReadCloser streams automatically propagate IO errors, and can pass arbitrary // errors via io.Pipe.CloseWithError(). type Manager struct { - store *Store - target types.Snapshotter + store *Store + multistore types.Snapshotter + extensions map[string]types.ExtensionSnapshotter mtx sync.Mutex operation operation @@ -55,11 +61,36 @@ type Manager struct { } // NewManager creates a new manager. -func NewManager(store *Store, target types.Snapshotter) *Manager { +func NewManager(store *Store, multistore types.Snapshotter) *Manager { return &Manager{ - store: store, - target: target, + store: store, + multistore: multistore, + extensions: make(map[string]types.ExtensionSnapshotter), + } +} + +// NewManagerWithExtensions creates a new manager. +func NewManagerWithExtensions(store *Store, multistore types.Snapshotter, extensions map[string]types.ExtensionSnapshotter) *Manager { + return &Manager{ + store: store, + multistore: multistore, + extensions: extensions, + } +} + +// RegisterExtensions register extension snapshotters to manager +func (m *Manager) RegisterExtensions(extensions ...types.ExtensionSnapshotter) error { + for _, extension := range extensions { + name := extension.SnapshotName() + if _, ok := m.extensions[name]; ok { + return fmt.Errorf("duplicated snapshotter name: %s", name) + } + if !IsFormatSupported(extension, extension.SnapshotFormat()) { + return fmt.Errorf("snapshotter don't support it's own snapshot format: %s %d", name, extension.SnapshotFormat()) + } + m.extensions[name] = extension } + return nil } // begin starts an operation, or errors if one is in progress. It manages the mutex itself. @@ -100,6 +131,17 @@ func (m *Manager) endLocked() { m.restoreChunkIndex = 0 } +// sortedExtensionNames sort extension names for deterministic iteration. +func (m *Manager) sortedExtensionNames() []string { + names := make([]string, 0, len(m.extensions)) + for name := range m.extensions { + names = append(names, name) + } + + sort.Strings(names) + return names +} + // Create creates a snapshot and returns its metadata. func (m *Manager) Create(height uint64) (*types.Snapshot, error) { if m == nil { @@ -120,11 +162,45 @@ func (m *Manager) Create(height uint64) (*types.Snapshot, error) { "a more recent snapshot already exists at height %v", latest.Height) } - chunks, err := m.target.Snapshot(height, types.CurrentFormat) - if err != nil { - return nil, err + // Spawn goroutine to generate snapshot chunks and pass their io.ReadClosers through a channel + ch := make(chan io.ReadCloser) + go m.createSnapshot(height, ch) + + return m.store.Save(height, types.CurrentFormat, ch) +} + +// createSnapshot do the heavy work of snapshotting after the validations of request are done +// the produced chunks are written to the channel. +func (m *Manager) createSnapshot(height uint64, ch chan<- io.ReadCloser) { + streamWriter := NewStreamWriter(ch) + if streamWriter == nil { + return + } + defer streamWriter.Close() + if err := m.multistore.Snapshot(height, streamWriter); err != nil { + streamWriter.CloseWithError(err) + return + } + for _, name := range m.sortedExtensionNames() { + extension := m.extensions[name] + // write extension metadata + err := streamWriter.WriteMsg(&types.SnapshotItem{ + Item: &types.SnapshotItem_Extension{ + Extension: &types.SnapshotExtensionMeta{ + Name: name, + Format: extension.SnapshotFormat(), + }, + }, + }) + if err != nil { + streamWriter.CloseWithError(err) + return + } + if err := extension.Snapshot(height, streamWriter); err != nil { + streamWriter.CloseWithError(err) + return + } } - return m.store.Save(height, types.CurrentFormat, chunks) } // List lists snapshots, mirroring ABCI ListSnapshots. It can be concurrent with other operations. @@ -170,6 +246,19 @@ func (m *Manager) Restore(snapshot types.Snapshot) error { } m.mtx.Lock() defer m.mtx.Unlock() + + // check multistore supported format preemptive + if snapshot.Format != types.CurrentFormat { + return sdkerrors.Wrapf(types.ErrUnknownFormat, "snapshot format %v", snapshot.Format) + } + if snapshot.Height == 0 { + return sdkerrors.Wrap(sdkerrors.ErrLogic, "cannot restore snapshot at height 0") + } + if snapshot.Height > uint64(math.MaxInt64) { + return sdkerrors.Wrapf(types.ErrInvalidMetadata, + "snapshot height %v cannot exceed %v", snapshot.Height, int64(math.MaxInt64)) + } + err := m.beginLocked(opRestore) if err != nil { return err @@ -177,10 +266,10 @@ func (m *Manager) Restore(snapshot types.Snapshot) error { // Start an asynchronous snapshot restoration, passing chunks and completion status via channels. chChunks := make(chan io.ReadCloser, chunkBufferSize) - chReady := make(chan struct{}, 1) chDone := make(chan restoreDone, 1) + go func() { - err := m.target.Restore(snapshot.Height, snapshot.Format, chChunks, chReady) + err := m.restoreSnapshot(snapshot, chChunks) chDone <- restoreDone{ complete: err == nil, err: err, @@ -188,17 +277,6 @@ func (m *Manager) Restore(snapshot types.Snapshot) error { close(chDone) }() - // Check for any initial errors from the restore, before any chunks are fed. - select { - case done := <-chDone: - m.endLocked() - if done.err != nil { - return done.err - } - return sdkerrors.Wrap(sdkerrors.ErrLogic, "restore ended unexpectedly") - case <-chReady: - } - m.chRestore = chChunks m.chRestoreDone = chDone m.restoreChunkHashes = snapshot.Metadata.ChunkHashes @@ -206,6 +284,42 @@ func (m *Manager) Restore(snapshot types.Snapshot) error { return nil } +// restoreSnapshot do the heavy work of snapshot restoration after preliminary checks on request have passed. +func (m *Manager) restoreSnapshot(snapshot types.Snapshot, chChunks <-chan io.ReadCloser) error { + streamReader, err := NewStreamReader(chChunks) + if err != nil { + return err + } + defer streamReader.Close() + + next, err := m.multistore.Restore(snapshot.Height, snapshot.Format, streamReader) + if err != nil { + return sdkerrors.Wrap(err, "multistore restore") + } + for { + if next.Item == nil { + // end of stream + break + } + metadata := next.GetExtension() + if metadata == nil { + return sdkerrors.Wrapf(sdkerrors.ErrLogic, "unknown snapshot item %T", next.Item) + } + extension, ok := m.extensions[metadata.Name] + if !ok { + return sdkerrors.Wrapf(sdkerrors.ErrLogic, "unknown extension snapshotter %s", metadata.Name) + } + if !IsFormatSupported(extension, metadata.Format) { + return sdkerrors.Wrapf(types.ErrUnknownFormat, "format %v for extension %s", metadata.Format, metadata.Name) + } + next, err = extension.Restore(snapshot.Height, metadata.Format, streamReader) + if err != nil { + return sdkerrors.Wrapf(err, "extension %s restore", metadata.Name) + } + } + return nil +} + // RestoreChunk adds a chunk to an active snapshot restoration, mirroring ABCI ApplySnapshotChunk. // Chunks must be given until the restore is complete, returning true, or a chunk errors. func (m *Manager) RestoreChunk(chunk []byte) (bool, error) { @@ -257,3 +371,13 @@ func (m *Manager) RestoreChunk(chunk []byte) (bool, error) { } return false, nil } + +// IsFormatSupported returns if the snapshotter supports restoration from given format. +func IsFormatSupported(snapshotter types.ExtensionSnapshotter, format uint32) bool { + for _, i := range snapshotter.SupportedFormats() { + if i == format { + return true + } + } + return false +} diff --git a/snapshots/manager_test.go b/snapshots/manager_test.go index 6069666f14f5..256b5b2cc8fe 100644 --- a/snapshots/manager_test.go +++ b/snapshots/manager_test.go @@ -53,13 +53,15 @@ func TestManager_LoadChunk(t *testing.T) { func TestManager_Take(t *testing.T) { store := setupStore(t) + items := [][]byte{ + {1, 2, 3}, + {4, 5, 6}, + {7, 8, 9}, + } snapshotter := &mockSnapshotter{ - chunks: [][]byte{ - {1, 2, 3}, - {4, 5, 6}, - {7, 8, 9}, - }, + items: items, } + expectChunks := snapshotItems(items) manager := snapshots.NewManager(store, snapshotter) // nil manager should return error @@ -75,19 +77,18 @@ func TestManager_Take(t *testing.T) { require.NoError(t, err) assert.Equal(t, &types.Snapshot{ Height: 5, - Format: types.CurrentFormat, - Chunks: 3, - Hash: []uint8{0x47, 0xe4, 0xee, 0x7f, 0x21, 0x1f, 0x73, 0x26, 0x5d, 0xd1, 0x76, 0x58, 0xf6, 0xe2, 0x1c, 0x13, 0x18, 0xbd, 0x6c, 0x81, 0xf3, 0x75, 0x98, 0xe2, 0xa, 0x27, 0x56, 0x29, 0x95, 0x42, 0xef, 0xcf}, + Format: snapshotter.SnapshotFormat(), + Chunks: 1, + Hash: []uint8{0xcd, 0x17, 0x9e, 0x7f, 0x28, 0xb6, 0x82, 0x90, 0xc7, 0x25, 0xf3, 0x42, 0xac, 0x65, 0x73, 0x50, 0xaa, 0xa0, 0x10, 0x5c, 0x40, 0x8c, 0xd5, 0x1, 0xed, 0x82, 0xb5, 0xca, 0x8b, 0xe0, 0x83, 0xa2}, Metadata: types.Metadata{ - ChunkHashes: checksums([][]byte{ - {1, 2, 3}, {4, 5, 6}, {7, 8, 9}}), + ChunkHashes: checksums(expectChunks), }, }, snapshot) storeSnapshot, chunks, err := store.Load(snapshot.Height, snapshot.Format) require.NoError(t, err) assert.Equal(t, snapshot, storeSnapshot) - assert.Equal(t, [][]byte{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, readChunks(chunks)) + assert.Equal(t, expectChunks, readChunks(chunks)) // creating a snapshot while a different snapshot is being created should error manager = setupBusyManager(t) @@ -118,12 +119,14 @@ func TestManager_Restore(t *testing.T) { target := &mockSnapshotter{} manager := snapshots.NewManager(store, target) - chunks := [][]byte{ + expectItems := [][]byte{ {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, } + chunks := snapshotItems(expectItems) + // Restore errors on invalid format err := manager.Restore(types.Snapshot{ Height: 3, @@ -133,7 +136,7 @@ func TestManager_Restore(t *testing.T) { Metadata: types.Metadata{ChunkHashes: checksums(chunks)}, }) require.Error(t, err) - require.Equal(t, types.ErrUnknownFormat, err) + require.ErrorIs(t, err, types.ErrUnknownFormat) // Restore errors on no chunks err = manager.Restore(types.Snapshot{Height: 3, Format: 1, Hash: []byte{1, 2, 3}}) @@ -154,7 +157,7 @@ func TestManager_Restore(t *testing.T) { Height: 3, Format: 1, Hash: []byte{1, 2, 3}, - Chunks: 3, + Chunks: 1, Metadata: types.Metadata{ChunkHashes: checksums(chunks)}, }) require.NoError(t, err) @@ -182,7 +185,7 @@ func TestManager_Restore(t *testing.T) { } } - assert.Equal(t, chunks, target.chunks) + assert.Equal(t, expectItems, target.items) // Starting a new restore should fail now, because the target already has contents. err = manager.Restore(types.Snapshot{ @@ -197,12 +200,12 @@ func TestManager_Restore(t *testing.T) { // But if we clear out the target we should be able to start a new restore. This time we'll // fail it with a checksum error. That error should stop the operation, so that we can do // a prune operation right after. - target.chunks = nil + target.items = nil err = manager.Restore(types.Snapshot{ Height: 3, Format: 1, Hash: []byte{1, 2, 3}, - Chunks: 3, + Chunks: 1, Metadata: types.Metadata{ChunkHashes: checksums(chunks)}, }) require.NoError(t, err) diff --git a/snapshots/stream.go b/snapshots/stream.go new file mode 100644 index 000000000000..80cd5c3dfdcb --- /dev/null +++ b/snapshots/stream.go @@ -0,0 +1,109 @@ +package snapshots + +import ( + "bufio" + "compress/zlib" + "io" + + protoio "github.com/gogo/protobuf/io" + "github.com/gogo/protobuf/proto" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const ( + // Do not change chunk size without new snapshot format (must be uniform across nodes) + snapshotChunkSize = uint64(10e6) + snapshotBufferSize = int(snapshotChunkSize) + // Do not change compression level without new snapshot format (must be uniform across nodes) + snapshotCompressionLevel = 7 +) + +// StreamWriter set up a stream pipeline to serialize snapshot nodes: +// Exported Items -> delimited Protobuf -> zlib -> buffer -> chunkWriter -> chan io.ReadCloser +type StreamWriter struct { + chunkWriter *ChunkWriter + bufWriter *bufio.Writer + zWriter *zlib.Writer + protoWriter protoio.WriteCloser +} + +// NewStreamWriter set up a stream pipeline to serialize snapshot DB records. +func NewStreamWriter(ch chan<- io.ReadCloser) *StreamWriter { + chunkWriter := NewChunkWriter(ch, snapshotChunkSize) + bufWriter := bufio.NewWriterSize(chunkWriter, snapshotBufferSize) + zWriter, err := zlib.NewWriterLevel(bufWriter, snapshotCompressionLevel) + if err != nil { + chunkWriter.CloseWithError(sdkerrors.Wrap(err, "zlib failure")) + return nil + } + protoWriter := protoio.NewDelimitedWriter(zWriter) + return &StreamWriter{ + chunkWriter: chunkWriter, + bufWriter: bufWriter, + zWriter: zWriter, + protoWriter: protoWriter, + } +} + +// WriteMsg implements protoio.Write interface +func (sw *StreamWriter) WriteMsg(msg proto.Message) error { + return sw.protoWriter.WriteMsg(msg) +} + +// Close implements io.Closer interface +func (sw *StreamWriter) Close() error { + if err := sw.protoWriter.Close(); err != nil { + sw.chunkWriter.CloseWithError(err) + return err + } + if err := sw.zWriter.Close(); err != nil { + sw.chunkWriter.CloseWithError(err) + return err + } + if err := sw.bufWriter.Flush(); err != nil { + sw.chunkWriter.CloseWithError(err) + return err + } + return sw.chunkWriter.Close() +} + +// CloseWithError pass error to chunkWriter +func (sw *StreamWriter) CloseWithError(err error) { + sw.chunkWriter.CloseWithError(err) +} + +// StreamReader set up a restore stream pipeline +// chan io.ReadCloser -> chunkReader -> zlib -> delimited Protobuf -> ExportNode +type StreamReader struct { + chunkReader *ChunkReader + zReader io.ReadCloser + protoReader protoio.ReadCloser +} + +// NewStreamReader set up a restore stream pipeline. +func NewStreamReader(chunks <-chan io.ReadCloser) (*StreamReader, error) { + chunkReader := NewChunkReader(chunks) + zReader, err := zlib.NewReader(chunkReader) + if err != nil { + return nil, sdkerrors.Wrap(err, "zlib failure") + } + protoReader := protoio.NewDelimitedReader(zReader, snapshotMaxItemSize) + return &StreamReader{ + chunkReader: chunkReader, + zReader: zReader, + protoReader: protoReader, + }, nil +} + +// ReadMsg implements protoio.Reader interface +func (sr *StreamReader) ReadMsg(msg proto.Message) error { + return sr.protoReader.ReadMsg(msg) +} + +// Close implements io.Closer interface +func (sr *StreamReader) Close() error { + sr.protoReader.Close() + sr.zReader.Close() + return sr.chunkReader.Close() +} diff --git a/snapshots/types/snapshot.pb.go b/snapshots/types/snapshot.pb.go index f37192f9c569..c7e427343346 100644 --- a/snapshots/types/snapshot.pb.go +++ b/snapshots/types/snapshot.pb.go @@ -145,9 +145,342 @@ func (m *Metadata) GetChunkHashes() [][]byte { return nil } +// SnapshotItem is an item contained in a rootmulti.Store snapshot. +type SnapshotItem struct { + // item is the specific type of snapshot item. + // + // Types that are valid to be assigned to Item: + // *SnapshotItem_Store + // *SnapshotItem_IAVL + // *SnapshotItem_Extension + // *SnapshotItem_ExtensionPayload + Item isSnapshotItem_Item `protobuf_oneof:"item"` +} + +func (m *SnapshotItem) Reset() { *m = SnapshotItem{} } +func (m *SnapshotItem) String() string { return proto.CompactTextString(m) } +func (*SnapshotItem) ProtoMessage() {} +func (*SnapshotItem) Descriptor() ([]byte, []int) { + return fileDescriptor_dd7a3c9b0a19e1ee, []int{2} +} +func (m *SnapshotItem) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotItem.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SnapshotItem) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotItem.Merge(m, src) +} +func (m *SnapshotItem) XXX_Size() int { + return m.Size() +} +func (m *SnapshotItem) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotItem.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotItem proto.InternalMessageInfo + +type isSnapshotItem_Item interface { + isSnapshotItem_Item() + MarshalTo([]byte) (int, error) + Size() int +} + +type SnapshotItem_Store struct { + Store *SnapshotStoreItem `protobuf:"bytes,1,opt,name=store,proto3,oneof" json:"store,omitempty"` +} +type SnapshotItem_IAVL struct { + IAVL *SnapshotIAVLItem `protobuf:"bytes,2,opt,name=iavl,proto3,oneof" json:"iavl,omitempty"` +} +type SnapshotItem_Extension struct { + Extension *SnapshotExtensionMeta `protobuf:"bytes,3,opt,name=extension,proto3,oneof" json:"extension,omitempty"` +} +type SnapshotItem_ExtensionPayload struct { + ExtensionPayload *SnapshotExtensionPayload `protobuf:"bytes,4,opt,name=extension_payload,json=extensionPayload,proto3,oneof" json:"extension_payload,omitempty"` +} + +func (*SnapshotItem_Store) isSnapshotItem_Item() {} +func (*SnapshotItem_IAVL) isSnapshotItem_Item() {} +func (*SnapshotItem_Extension) isSnapshotItem_Item() {} +func (*SnapshotItem_ExtensionPayload) isSnapshotItem_Item() {} + +func (m *SnapshotItem) GetItem() isSnapshotItem_Item { + if m != nil { + return m.Item + } + return nil +} + +func (m *SnapshotItem) GetStore() *SnapshotStoreItem { + if x, ok := m.GetItem().(*SnapshotItem_Store); ok { + return x.Store + } + return nil +} + +func (m *SnapshotItem) GetIAVL() *SnapshotIAVLItem { + if x, ok := m.GetItem().(*SnapshotItem_IAVL); ok { + return x.IAVL + } + return nil +} + +func (m *SnapshotItem) GetExtension() *SnapshotExtensionMeta { + if x, ok := m.GetItem().(*SnapshotItem_Extension); ok { + return x.Extension + } + return nil +} + +func (m *SnapshotItem) GetExtensionPayload() *SnapshotExtensionPayload { + if x, ok := m.GetItem().(*SnapshotItem_ExtensionPayload); ok { + return x.ExtensionPayload + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*SnapshotItem) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*SnapshotItem_Store)(nil), + (*SnapshotItem_IAVL)(nil), + (*SnapshotItem_Extension)(nil), + (*SnapshotItem_ExtensionPayload)(nil), + } +} + +// SnapshotStoreItem contains metadata about a snapshotted store. +type SnapshotStoreItem struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (m *SnapshotStoreItem) Reset() { *m = SnapshotStoreItem{} } +func (m *SnapshotStoreItem) String() string { return proto.CompactTextString(m) } +func (*SnapshotStoreItem) ProtoMessage() {} +func (*SnapshotStoreItem) Descriptor() ([]byte, []int) { + return fileDescriptor_dd7a3c9b0a19e1ee, []int{3} +} +func (m *SnapshotStoreItem) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotStoreItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotStoreItem.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SnapshotStoreItem) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotStoreItem.Merge(m, src) +} +func (m *SnapshotStoreItem) XXX_Size() int { + return m.Size() +} +func (m *SnapshotStoreItem) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotStoreItem.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotStoreItem proto.InternalMessageInfo + +func (m *SnapshotStoreItem) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +// SnapshotIAVLItem is an exported IAVL node. +type SnapshotIAVLItem struct { + Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + // version is block height + Version int64 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"` + // height is depth of the tree. + Height int32 `protobuf:"varint,4,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *SnapshotIAVLItem) Reset() { *m = SnapshotIAVLItem{} } +func (m *SnapshotIAVLItem) String() string { return proto.CompactTextString(m) } +func (*SnapshotIAVLItem) ProtoMessage() {} +func (*SnapshotIAVLItem) Descriptor() ([]byte, []int) { + return fileDescriptor_dd7a3c9b0a19e1ee, []int{4} +} +func (m *SnapshotIAVLItem) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotIAVLItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotIAVLItem.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SnapshotIAVLItem) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotIAVLItem.Merge(m, src) +} +func (m *SnapshotIAVLItem) XXX_Size() int { + return m.Size() +} +func (m *SnapshotIAVLItem) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotIAVLItem.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotIAVLItem proto.InternalMessageInfo + +func (m *SnapshotIAVLItem) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *SnapshotIAVLItem) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (m *SnapshotIAVLItem) GetVersion() int64 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *SnapshotIAVLItem) GetHeight() int32 { + if m != nil { + return m.Height + } + return 0 +} + +// SnapshotExtensionMeta contains metadata about an external snapshotter. +type SnapshotExtensionMeta struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Format uint32 `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"` +} + +func (m *SnapshotExtensionMeta) Reset() { *m = SnapshotExtensionMeta{} } +func (m *SnapshotExtensionMeta) String() string { return proto.CompactTextString(m) } +func (*SnapshotExtensionMeta) ProtoMessage() {} +func (*SnapshotExtensionMeta) Descriptor() ([]byte, []int) { + return fileDescriptor_dd7a3c9b0a19e1ee, []int{5} +} +func (m *SnapshotExtensionMeta) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotExtensionMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotExtensionMeta.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SnapshotExtensionMeta) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotExtensionMeta.Merge(m, src) +} +func (m *SnapshotExtensionMeta) XXX_Size() int { + return m.Size() +} +func (m *SnapshotExtensionMeta) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotExtensionMeta.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotExtensionMeta proto.InternalMessageInfo + +func (m *SnapshotExtensionMeta) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *SnapshotExtensionMeta) GetFormat() uint32 { + if m != nil { + return m.Format + } + return 0 +} + +// SnapshotExtensionPayload contains payloads of an external snapshotter. +type SnapshotExtensionPayload struct { + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` +} + +func (m *SnapshotExtensionPayload) Reset() { *m = SnapshotExtensionPayload{} } +func (m *SnapshotExtensionPayload) String() string { return proto.CompactTextString(m) } +func (*SnapshotExtensionPayload) ProtoMessage() {} +func (*SnapshotExtensionPayload) Descriptor() ([]byte, []int) { + return fileDescriptor_dd7a3c9b0a19e1ee, []int{6} +} +func (m *SnapshotExtensionPayload) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SnapshotExtensionPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SnapshotExtensionPayload.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SnapshotExtensionPayload) XXX_Merge(src proto.Message) { + xxx_messageInfo_SnapshotExtensionPayload.Merge(m, src) +} +func (m *SnapshotExtensionPayload) XXX_Size() int { + return m.Size() +} +func (m *SnapshotExtensionPayload) XXX_DiscardUnknown() { + xxx_messageInfo_SnapshotExtensionPayload.DiscardUnknown(m) +} + +var xxx_messageInfo_SnapshotExtensionPayload proto.InternalMessageInfo + +func (m *SnapshotExtensionPayload) GetPayload() []byte { + if m != nil { + return m.Payload + } + return nil +} + func init() { proto.RegisterType((*Snapshot)(nil), "cosmos.base.snapshots.v1beta1.Snapshot") proto.RegisterType((*Metadata)(nil), "cosmos.base.snapshots.v1beta1.Metadata") + proto.RegisterType((*SnapshotItem)(nil), "cosmos.base.snapshots.v1beta1.SnapshotItem") + proto.RegisterType((*SnapshotStoreItem)(nil), "cosmos.base.snapshots.v1beta1.SnapshotStoreItem") + proto.RegisterType((*SnapshotIAVLItem)(nil), "cosmos.base.snapshots.v1beta1.SnapshotIAVLItem") + proto.RegisterType((*SnapshotExtensionMeta)(nil), "cosmos.base.snapshots.v1beta1.SnapshotExtensionMeta") + proto.RegisterType((*SnapshotExtensionPayload)(nil), "cosmos.base.snapshots.v1beta1.SnapshotExtensionPayload") } func init() { @@ -155,25 +488,40 @@ func init() { } var fileDescriptor_dd7a3c9b0a19e1ee = []byte{ - // 288 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0x31, 0x4e, 0xc3, 0x30, - 0x14, 0x86, 0x63, 0x1a, 0xaa, 0xc8, 0x0d, 0x8b, 0x85, 0x90, 0x85, 0x84, 0x09, 0x5d, 0xc8, 0xd0, - 0x3a, 0x2a, 0xdc, 0xa0, 0x03, 0x82, 0x81, 0x25, 0x6c, 0x2c, 0xc8, 0x49, 0x4d, 0x5c, 0x55, 0xa9, - 0xa3, 0x3e, 0x17, 0x89, 0x5b, 0x70, 0x15, 0x6e, 0xd1, 0xb1, 0x23, 0x13, 0x42, 0xc9, 0x45, 0x50, - 0x1c, 0x13, 0x31, 0x75, 0xca, 0xfb, 0xbf, 0x7c, 0x4f, 0xcf, 0xfa, 0xf1, 0x24, 0xd7, 0x50, 0x6a, - 0x48, 0x32, 0x01, 0x32, 0x81, 0xb5, 0xa8, 0x40, 0x69, 0x03, 0xc9, 0xdb, 0x2c, 0x93, 0x46, 0xcc, - 0x7a, 0xc2, 0xab, 0x8d, 0x36, 0x9a, 0x5c, 0x74, 0x36, 0x6f, 0x6d, 0xde, 0xdb, 0xdc, 0xd9, 0xe7, - 0xa7, 0x85, 0x2e, 0xb4, 0x35, 0x93, 0x76, 0xea, 0x96, 0xc6, 0x9f, 0x08, 0x07, 0x4f, 0xce, 0x25, - 0x67, 0x78, 0xa8, 0xe4, 0xb2, 0x50, 0x86, 0xa2, 0x08, 0xc5, 0x7e, 0xea, 0x52, 0xcb, 0x5f, 0xf5, - 0xa6, 0x14, 0x86, 0x1e, 0x45, 0x28, 0x3e, 0x49, 0x5d, 0x6a, 0x79, 0xae, 0xb6, 0xeb, 0x15, 0xd0, - 0x41, 0xc7, 0xbb, 0x44, 0x08, 0xf6, 0x95, 0x00, 0x45, 0xfd, 0x08, 0xc5, 0x61, 0x6a, 0x67, 0xf2, - 0x80, 0x83, 0x52, 0x1a, 0xb1, 0x10, 0x46, 0xd0, 0xe3, 0x08, 0xc5, 0xa3, 0x9b, 0x6b, 0x7e, 0xf0, - 0xc1, 0xfc, 0xd1, 0xe9, 0x73, 0x7f, 0xf7, 0x7d, 0xe9, 0xa5, 0xfd, 0xfa, 0x78, 0x8a, 0x83, 0xbf, - 0x7f, 0xe4, 0x0a, 0x87, 0xf6, 0xe8, 0x4b, 0x7b, 0x44, 0x02, 0x45, 0xd1, 0x20, 0x0e, 0xd3, 0x91, - 0x65, 0xf7, 0x16, 0xcd, 0xef, 0x76, 0x35, 0x43, 0xfb, 0x9a, 0xa1, 0x9f, 0x9a, 0xa1, 0x8f, 0x86, - 0x79, 0xfb, 0x86, 0x79, 0x5f, 0x0d, 0xf3, 0x9e, 0x27, 0xc5, 0xd2, 0xa8, 0x6d, 0xc6, 0x73, 0x5d, - 0x26, 0xae, 0xea, 0xee, 0x33, 0x85, 0xc5, 0xea, 0x5f, 0xe1, 0xe6, 0xbd, 0x92, 0x90, 0x0d, 0x6d, - 0x63, 0xb7, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb8, 0x89, 0x2e, 0x8f, 0x96, 0x01, 0x00, 0x00, + // 513 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xd1, 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4, 0x6d, 0xa2, 0xeb, 0x60, 0x0a, 0xad, 0xeb, 0xa1, + 0xe0, 0x16, 0xd4, 0x26, 0x6c, 0xa5, 0x65, 0x2e, 0x51, 0x25, 0xde, 0x85, 0xfa, 0x92, 0x4e, 0x17, + 0x4c, 0xc7, 0xec, 0x12, 0x03, 0xb0, 0x07, 0x0f, 0x96, 0x6c, 0x5e, 0x05, 0x55, 0x23, 0x25, 0xbc, + 0xb2, 0xc6, 0xea, 0x8e, 0xf5, 0x72, 0x8d, 0x83, 0xd7, 0xf0, 0xe8, 0xc6, 0xb0, 0x6e, 0x1a, 0xed, + 0xb6, 0x9d, 0x0f, 0x8e, 0xc1, 0xbb, 0x2d, 0x13, 0x35, 0x52, 0x99, 0xae, 0x19, 0xbf, 0x84, 0xbd, + 0xb7, 0xe7, 0x6b, 0x1f, 0x5d, 0xac, 0x7d, 0xf4, 0x73, 0xed, 0xa3, 0x6f, 0x1b, 0xdf, 0xba, 0xd8, + 0xf8, 0xd6, 0x8f, 0x8d, 0x6f, 0x7d, 0x39, 0x18, 0xa7, 0x32, 0x59, 0x0c, 0xc2, 0x21, 0xcf, 0xa2, + 0xe2, 0xb9, 0x9b, 0x9f, 0x43, 0x31, 0x9a, 0x5c, 0x79, 0xf4, 0x72, 0x35, 0x63, 0x62, 0xd0, 0xd0, + 0xaf, 0xf6, 0xc5, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x90, 0xf8, 0x1f, 0x1a, 0x04, 0x00, + 0x00, } func (m *Snapshot) Marshal() (dAtA []byte, err error) { @@ -263,63 +611,974 @@ func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintSnapshot(dAtA []byte, offset int, v uint64) int { - offset -= sovSnapshot(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *SnapshotItem) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *Snapshot) Size() (n int) { - if m == nil { - return 0 - } + +func (m *SnapshotItem) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if m.Height != 0 { - n += 1 + sovSnapshot(uint64(m.Height)) + if m.Item != nil { + { + size := m.Item.Size() + i -= size + if _, err := m.Item.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } } - if m.Format != 0 { - n += 1 + sovSnapshot(uint64(m.Format)) + return len(dAtA) - i, nil +} + +func (m *SnapshotItem_Store) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotItem_Store) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Store != nil { + { + size, err := m.Store.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSnapshot(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - if m.Chunks != 0 { - n += 1 + sovSnapshot(uint64(m.Chunks)) + return len(dAtA) - i, nil +} +func (m *SnapshotItem_IAVL) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotItem_IAVL) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.IAVL != nil { + { + size, err := m.IAVL.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSnapshot(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovSnapshot(uint64(l)) + return len(dAtA) - i, nil +} +func (m *SnapshotItem_Extension) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotItem_Extension) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Extension != nil { + { + size, err := m.Extension.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSnapshot(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *SnapshotItem_ExtensionPayload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotItem_ExtensionPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.ExtensionPayload != nil { + { + size, err := m.ExtensionPayload.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSnapshot(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} +func (m *SnapshotStoreItem) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SnapshotStoreItem) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotStoreItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SnapshotIAVLItem) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SnapshotIAVLItem) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotIAVLItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintSnapshot(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x20 + } + if m.Version != 0 { + i = encodeVarintSnapshot(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x18 + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x12 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SnapshotExtensionMeta) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SnapshotExtensionMeta) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotExtensionMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Format != 0 { + i = encodeVarintSnapshot(dAtA, i, uint64(m.Format)) + i-- + dAtA[i] = 0x10 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *SnapshotExtensionPayload) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SnapshotExtensionPayload) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SnapshotExtensionPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintSnapshot(dAtA []byte, offset int, v uint64) int { + offset -= sovSnapshot(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Snapshot) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovSnapshot(uint64(m.Height)) + } + if m.Format != 0 { + n += 1 + sovSnapshot(uint64(m.Format)) + } + if m.Chunks != 0 { + n += 1 + sovSnapshot(uint64(m.Chunks)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovSnapshot(uint64(l)) + } + l = m.Metadata.Size() + n += 1 + l + sovSnapshot(uint64(l)) + return n +} + +func (m *Metadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ChunkHashes) > 0 { + for _, b := range m.ChunkHashes { + l = len(b) + n += 1 + l + sovSnapshot(uint64(l)) + } + } + return n +} + +func (m *SnapshotItem) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Item != nil { + n += m.Item.Size() + } + return n +} + +func (m *SnapshotItem_Store) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Store != nil { + l = m.Store.Size() + n += 1 + l + sovSnapshot(uint64(l)) + } + return n +} +func (m *SnapshotItem_IAVL) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.IAVL != nil { + l = m.IAVL.Size() + n += 1 + l + sovSnapshot(uint64(l)) + } + return n +} +func (m *SnapshotItem_Extension) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Extension != nil { + l = m.Extension.Size() + n += 1 + l + sovSnapshot(uint64(l)) + } + return n +} +func (m *SnapshotItem_ExtensionPayload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ExtensionPayload != nil { + l = m.ExtensionPayload.Size() + n += 1 + l + sovSnapshot(uint64(l)) + } + return n +} +func (m *SnapshotStoreItem) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovSnapshot(uint64(l)) + } + return n +} + +func (m *SnapshotIAVLItem) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovSnapshot(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovSnapshot(uint64(l)) + } + if m.Version != 0 { + n += 1 + sovSnapshot(uint64(m.Version)) + } + if m.Height != 0 { + n += 1 + sovSnapshot(uint64(m.Height)) + } + return n +} + +func (m *SnapshotExtensionMeta) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovSnapshot(uint64(l)) + } + if m.Format != 0 { + n += 1 + sovSnapshot(uint64(m.Format)) + } + return n +} + +func (m *SnapshotExtensionPayload) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovSnapshot(uint64(l)) + } + return n +} + +func sovSnapshot(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSnapshot(x uint64) (n int) { + return sovSnapshot(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Snapshot) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: Snapshot: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) + } + m.Format = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Format |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Chunks", wireType) + } + m.Chunks = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Chunks |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) + if m.Hash == nil { + m.Hash = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Metadata) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: Metadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChunkHashes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChunkHashes = append(m.ChunkHashes, make([]byte, postIndex-iNdEx)) + copy(m.ChunkHashes[len(m.ChunkHashes)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SnapshotItem) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: SnapshotItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SnapshotItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Store", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &SnapshotStoreItem{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Item = &SnapshotItem_Store{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field IAVL", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &SnapshotIAVLItem{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Item = &SnapshotItem_IAVL{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Extension", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &SnapshotExtensionMeta{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Item = &SnapshotItem_Extension{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExtensionPayload", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &SnapshotExtensionPayload{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Item = &SnapshotItem_ExtensionPayload{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } } - l = m.Metadata.Size() - n += 1 + l + sovSnapshot(uint64(l)) - return n -} -func (m *Metadata) Size() (n int) { - if m == nil { - return 0 + if iNdEx > l { + return io.ErrUnexpectedEOF } - var l int - _ = l - if len(m.ChunkHashes) > 0 { - for _, b := range m.ChunkHashes { - l = len(b) - n += 1 + l + sovSnapshot(uint64(l)) + return nil +} +func (m *SnapshotStoreItem) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: SnapshotStoreItem: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SnapshotStoreItem: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + 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 ErrInvalidLengthSnapshot + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSnapshot + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - return n -} -func sovSnapshot(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozSnapshot(x uint64) (n int) { - return sovSnapshot(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *Snapshot) Unmarshal(dAtA []byte) error { +func (m *SnapshotIAVLItem) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -342,17 +1601,17 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Snapshot: wiretype end group for non-group") + return fmt.Errorf("proto: SnapshotIAVLItem: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SnapshotIAVLItem: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) } - m.Height = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSnapshot @@ -362,16 +1621,31 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) } - m.Format = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSnapshot @@ -381,16 +1655,31 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Format |= uint32(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLengthSnapshot + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSnapshot + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex case 3: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Chunks", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) } - m.Chunks = 0 + m.Version = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSnapshot @@ -400,16 +1689,16 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Chunks |= uint32(b&0x7F) << shift + m.Version |= int64(b&0x7F) << shift if b < 0x80 { break } } case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } - var byteLen int + m.Height = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSnapshot @@ -419,31 +1708,66 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.Height |= int32(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthSnapshot + default: + iNdEx = preIndex + skippy, err := skipSnapshot(dAtA[iNdEx:]) + if err != nil { + return err } - postIndex := iNdEx + byteLen - if postIndex < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthSnapshot } - if postIndex > l { + if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } - m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...) - if m.Hash == nil { - m.Hash = []byte{} + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *SnapshotExtensionMeta) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot } - iNdEx = postIndex - case 5: + if iNdEx >= l { + return 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 fmt.Errorf("proto: SnapshotExtensionMeta: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SnapshotExtensionMeta: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowSnapshot @@ -453,25 +1777,43 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthSnapshot } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthSnapshot } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) + } + m.Format = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSnapshot + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Format |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipSnapshot(dAtA[iNdEx:]) @@ -493,7 +1835,7 @@ func (m *Snapshot) Unmarshal(dAtA []byte) error { } return nil } -func (m *Metadata) Unmarshal(dAtA []byte) error { +func (m *SnapshotExtensionPayload) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -516,15 +1858,15 @@ func (m *Metadata) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Metadata: wiretype end group for non-group") + return fmt.Errorf("proto: SnapshotExtensionPayload: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: SnapshotExtensionPayload: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChunkHashes", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { @@ -551,8 +1893,10 @@ func (m *Metadata) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChunkHashes = append(m.ChunkHashes, make([]byte, postIndex-iNdEx)) - copy(m.ChunkHashes[len(m.ChunkHashes)-1], dAtA[iNdEx:postIndex]) + m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) + if m.Payload == nil { + m.Payload = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex diff --git a/snapshots/types/snapshotter.go b/snapshots/types/snapshotter.go index 1ebd763b5d75..f747920d13ad 100644 --- a/snapshots/types/snapshotter.go +++ b/snapshots/types/snapshotter.go @@ -1,16 +1,35 @@ package types -import "io" +import ( + protoio "github.com/gogo/protobuf/io" +) // Snapshotter is something that can create and restore snapshots, consisting of streamed binary // chunks - all of which must be read from the channel and closed. If an unsupported format is // given, it must return ErrUnknownFormat (possibly wrapped with fmt.Errorf). type Snapshotter interface { - // Snapshot creates a state snapshot, returning a channel of snapshot chunk readers. - Snapshot(height uint64, format uint32) (<-chan io.ReadCloser, error) + // Snapshot writes snapshot items into the protobuf writer. + Snapshot(height uint64, protoWriter protoio.Writer) error - // Restore restores a state snapshot, taking snapshot chunk readers as input. + // Restore restores a state snapshot from the protobuf items read from the reader. // If the ready channel is non-nil, it returns a ready signal (by being closed) once the // restorer is ready to accept chunks. - Restore(height uint64, format uint32, chunks <-chan io.ReadCloser, ready chan<- struct{}) error + Restore(height uint64, format uint32, protoReader protoio.Reader) (SnapshotItem, error) +} + +// ExtensionSnapshotter is an extension Snapshotter that is appended to the snapshot stream. +// ExtensionSnapshotter has an unique name and manages it's own internal formats. +type ExtensionSnapshotter interface { + Snapshotter + + // SnapshotName returns the name of snapshotter, it should be unique in the manager. + SnapshotName() string + + // SnapshotFormat returns the default format the extension snapshotter use to encode the + // payloads when taking a snapshot. + // It's defined within the extension, different from the global format for the whole state-sync snapshot. + SnapshotFormat() uint32 + + // SupportedFormats returns a list of formats it can restore from. + SupportedFormats() []uint32 } diff --git a/snapshots/types/util.go b/snapshots/types/util.go new file mode 100644 index 000000000000..125ea6fb4610 --- /dev/null +++ b/snapshots/types/util.go @@ -0,0 +1,16 @@ +package types + +import ( + protoio "github.com/gogo/protobuf/io" +) + +// WriteExtensionItem writes an item payload for current extention snapshotter. +func WriteExtensionItem(protoWriter protoio.Writer, item []byte) error { + return protoWriter.WriteMsg(&SnapshotItem{ + Item: &SnapshotItem_ExtensionPayload{ + ExtensionPayload: &SnapshotExtensionPayload{ + Payload: item, + }, + }, + }) +} diff --git a/store/rootmulti/snapshot_test.go b/store/rootmulti/snapshot_test.go new file mode 100644 index 000000000000..cbdb481a05f7 --- /dev/null +++ b/store/rootmulti/snapshot_test.go @@ -0,0 +1,308 @@ +package rootmulti_test + +import ( + "crypto/sha256" + "encoding/binary" + "encoding/hex" + "errors" + "fmt" + "io" + "math/rand" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/snapshots" + snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" + "github.com/cosmos/cosmos-sdk/store/iavl" + "github.com/cosmos/cosmos-sdk/store/rootmulti" + "github.com/cosmos/cosmos-sdk/store/types" + dbm "github.com/tendermint/tm-db" +) + +func newMultiStoreWithGeneratedData(db dbm.DB, stores uint8, storeKeys uint64) *rootmulti.Store { + multiStore := rootmulti.NewStore(db) + r := rand.New(rand.NewSource(49872768940)) // Fixed seed for deterministic tests + + keys := []*types.KVStoreKey{} + for i := uint8(0); i < stores; i++ { + key := types.NewKVStoreKey(fmt.Sprintf("store%v", i)) + multiStore.MountStoreWithDB(key, types.StoreTypeIAVL, nil) + keys = append(keys, key) + } + multiStore.LoadLatestVersion() + + for _, key := range keys { + store := multiStore.GetCommitKVStore(key).(*iavl.Store) + for i := uint64(0); i < storeKeys; i++ { + k := make([]byte, 8) + v := make([]byte, 1024) + binary.BigEndian.PutUint64(k, i) + _, err := r.Read(v) + if err != nil { + panic(err) + } + store.Set(k, v) + } + } + + multiStore.Commit() + multiStore.LoadLatestVersion() + + return multiStore +} + +func newMultiStoreWithMixedMounts(db dbm.DB) *rootmulti.Store { + store := rootmulti.NewStore(db) + store.MountStoreWithDB(types.NewKVStoreKey("iavl1"), types.StoreTypeIAVL, nil) + store.MountStoreWithDB(types.NewKVStoreKey("iavl2"), types.StoreTypeIAVL, nil) + store.MountStoreWithDB(types.NewKVStoreKey("iavl3"), types.StoreTypeIAVL, nil) + store.MountStoreWithDB(types.NewTransientStoreKey("trans1"), types.StoreTypeTransient, nil) + store.LoadLatestVersion() + + return store +} + +func newMultiStoreWithMixedMountsAndBasicData(db dbm.DB) *rootmulti.Store { + store := newMultiStoreWithMixedMounts(db) + store1 := store.GetStoreByName("iavl1").(types.CommitKVStore) + store2 := store.GetStoreByName("iavl2").(types.CommitKVStore) + trans1 := store.GetStoreByName("trans1").(types.KVStore) + + store1.Set([]byte("a"), []byte{1}) + store1.Set([]byte("b"), []byte{1}) + store2.Set([]byte("X"), []byte{255}) + store2.Set([]byte("A"), []byte{101}) + trans1.Set([]byte("x1"), []byte{91}) + store.Commit() + + store1.Set([]byte("b"), []byte{2}) + store1.Set([]byte("c"), []byte{3}) + store2.Set([]byte("B"), []byte{102}) + store.Commit() + + store2.Set([]byte("C"), []byte{103}) + store2.Delete([]byte("X")) + trans1.Set([]byte("x2"), []byte{92}) + store.Commit() + + return store +} + +func assertStoresEqual(t *testing.T, expect, actual types.CommitKVStore, msgAndArgs ...interface{}) { + assert.Equal(t, expect.LastCommitID(), actual.LastCommitID()) + expectIter := expect.Iterator(nil, nil) + expectMap := map[string][]byte{} + for ; expectIter.Valid(); expectIter.Next() { + expectMap[string(expectIter.Key())] = expectIter.Value() + } + require.NoError(t, expectIter.Error()) + + actualIter := expect.Iterator(nil, nil) + actualMap := map[string][]byte{} + for ; actualIter.Valid(); actualIter.Next() { + actualMap[string(actualIter.Key())] = actualIter.Value() + } + require.NoError(t, actualIter.Error()) + + assert.Equal(t, expectMap, actualMap, msgAndArgs...) +} + +func TestMultistoreSnapshot_Checksum(t *testing.T) { + // Chunks from different nodes must fit together, so all nodes must produce identical chunks. + // This checksum test makes sure that the byte stream remains identical. If the test fails + // without having changed the data (e.g. because the Protobuf or zlib encoding changes), + // snapshottypes.CurrentFormat must be bumped. + store := newMultiStoreWithGeneratedData(dbm.NewMemDB(), 5, 10000) + version := uint64(store.LastCommitID().Version) + + testcases := []struct { + format uint32 + chunkHashes []string + }{ + {1, []string{ + "503e5b51b657055b77e88169fadae543619368744ad15f1de0736c0a20482f24", + "e1a0daaa738eeb43e778aefd2805e3dd720798288a410b06da4b8459c4d8f72e", + "aa048b4ee0f484965d7b3b06822cf0772cdcaad02f3b1b9055e69f2cb365ef3c", + "7921eaa3ed4921341e504d9308a9877986a879fe216a099c86e8db66fcba4c63", + "a4a864e6c02c9fca5837ec80dc84f650b25276ed7e4820cf7516ced9f9901b86", + "ca2879ac6e7205d257440131ba7e72bef784cd61642e32b847729e543c1928b9", + }}, + } + for _, tc := range testcases { + tc := tc + t.Run(fmt.Sprintf("Format %v", tc.format), func(t *testing.T) { + ch := make(chan io.ReadCloser) + go func() { + streamWriter := snapshots.NewStreamWriter(ch) + defer streamWriter.Close() + require.NotNil(t, streamWriter) + err := store.Snapshot(version, streamWriter) + require.NoError(t, err) + }() + hashes := []string{} + hasher := sha256.New() + for chunk := range ch { + hasher.Reset() + _, err := io.Copy(hasher, chunk) + require.NoError(t, err) + hashes = append(hashes, hex.EncodeToString(hasher.Sum(nil))) + } + assert.Equal(t, tc.chunkHashes, hashes, + "Snapshot output for format %v has changed", tc.format) + }) + } +} + +func TestMultistoreSnapshot_Errors(t *testing.T) { + store := newMultiStoreWithMixedMountsAndBasicData(dbm.NewMemDB()) + + testcases := map[string]struct { + height uint64 + expectType error + }{ + "0 height": {0, nil}, + "unknown height": {9, nil}, + } + for name, tc := range testcases { + tc := tc + t.Run(name, func(t *testing.T) { + err := store.Snapshot(tc.height, nil) + require.Error(t, err) + if tc.expectType != nil { + assert.True(t, errors.Is(err, tc.expectType)) + } + }) + } +} + +func TestMultistoreSnapshotRestore(t *testing.T) { + source := newMultiStoreWithMixedMountsAndBasicData(dbm.NewMemDB()) + target := newMultiStoreWithMixedMounts(dbm.NewMemDB()) + version := uint64(source.LastCommitID().Version) + require.EqualValues(t, 3, version) + dummyExtensionItem := snapshottypes.SnapshotItem{ + Item: &snapshottypes.SnapshotItem_Extension{ + Extension: &snapshottypes.SnapshotExtensionMeta{ + Name: "test", + Format: 1, + }, + }, + } + + chunks := make(chan io.ReadCloser, 100) + go func() { + streamWriter := snapshots.NewStreamWriter(chunks) + require.NotNil(t, streamWriter) + defer streamWriter.Close() + err := source.Snapshot(version, streamWriter) + require.NoError(t, err) + // write an extension metadata + err = streamWriter.WriteMsg(&dummyExtensionItem) + require.NoError(t, err) + }() + + streamReader, err := snapshots.NewStreamReader(chunks) + require.NoError(t, err) + nextItem, err := target.Restore(version, snapshottypes.CurrentFormat, streamReader) + require.NoError(t, err) + require.Equal(t, *dummyExtensionItem.GetExtension(), *nextItem.GetExtension()) + + assert.Equal(t, source.LastCommitID(), target.LastCommitID()) + for key, sourceStore := range source.GetStores() { + targetStore := target.GetStoreByName(key.Name()).(types.CommitKVStore) + switch sourceStore.GetStoreType() { + case types.StoreTypeTransient: + assert.False(t, targetStore.Iterator(nil, nil).Valid(), + "transient store %v not empty", key.Name()) + default: + assertStoresEqual(t, sourceStore, targetStore, "store %q not equal", key.Name()) + } + } +} + +func benchmarkMultistoreSnapshot(b *testing.B, stores uint8, storeKeys uint64) { + b.Skip("Noisy with slow setup time, please see https://github.com/cosmos/cosmos-sdk/issues/8855.") + + b.ReportAllocs() + b.StopTimer() + source := newMultiStoreWithGeneratedData(dbm.NewMemDB(), stores, storeKeys) + version := source.LastCommitID().Version + require.EqualValues(b, 1, version) + b.StartTimer() + + for i := 0; i < b.N; i++ { + target := rootmulti.NewStore(dbm.NewMemDB()) + for key := range source.GetStores() { + target.MountStoreWithDB(key, types.StoreTypeIAVL, nil) + } + err := target.LoadLatestVersion() + require.NoError(b, err) + require.EqualValues(b, 0, target.LastCommitID().Version) + + chunks := make(chan io.ReadCloser) + go func() { + streamWriter := snapshots.NewStreamWriter(chunks) + require.NotNil(b, streamWriter) + err := source.Snapshot(uint64(version), streamWriter) + require.NoError(b, err) + }() + for reader := range chunks { + _, err := io.Copy(io.Discard, reader) + require.NoError(b, err) + err = reader.Close() + require.NoError(b, err) + } + } +} + +func benchmarkMultistoreSnapshotRestore(b *testing.B, stores uint8, storeKeys uint64) { + b.Skip("Noisy with slow setup time, please see https://github.com/cosmos/cosmos-sdk/issues/8855.") + + b.ReportAllocs() + b.StopTimer() + source := newMultiStoreWithGeneratedData(dbm.NewMemDB(), stores, storeKeys) + version := uint64(source.LastCommitID().Version) + require.EqualValues(b, 1, version) + b.StartTimer() + + for i := 0; i < b.N; i++ { + target := rootmulti.NewStore(dbm.NewMemDB()) + for key := range source.GetStores() { + target.MountStoreWithDB(key, types.StoreTypeIAVL, nil) + } + err := target.LoadLatestVersion() + require.NoError(b, err) + require.EqualValues(b, 0, target.LastCommitID().Version) + + chunks := make(chan io.ReadCloser) + go func() { + writer := snapshots.NewStreamWriter(chunks) + require.NotNil(b, writer) + err := source.Snapshot(version, writer) + require.NoError(b, err) + }() + reader, err := snapshots.NewStreamReader(chunks) + require.NoError(b, err) + _, err = target.Restore(version, snapshottypes.CurrentFormat, reader) + require.NoError(b, err) + require.Equal(b, source.LastCommitID(), target.LastCommitID()) + } +} + +func BenchmarkMultistoreSnapshot100K(b *testing.B) { + benchmarkMultistoreSnapshot(b, 10, 10000) +} + +func BenchmarkMultistoreSnapshot1M(b *testing.B) { + benchmarkMultistoreSnapshot(b, 10, 100000) +} + +func BenchmarkMultistoreSnapshotRestore100K(b *testing.B) { + benchmarkMultistoreSnapshotRestore(b, 10, 10000) +} + +func BenchmarkMultistoreSnapshotRestore1M(b *testing.B) { + benchmarkMultistoreSnapshotRestore(b, 10, 100000) +} diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 05d8631e8c05..c2ed1872be36 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -1,8 +1,6 @@ package rootmulti import ( - "bufio" - "compress/zlib" "encoding/binary" "fmt" "io" @@ -18,7 +16,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" dbm "github.com/tendermint/tm-db" - "github.com/cosmos/cosmos-sdk/snapshots" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store/cachemulti" "github.com/cosmos/cosmos-sdk/store/dbadapter" @@ -35,11 +32,6 @@ const ( latestVersionKey = "s/latest" pruneHeightsKey = "s/pruneheights" commitInfoKeyFmt = "s/%d" // s/ - - // Do not change chunk size without new snapshot format (must be uniform across nodes) - snapshotChunkSize = uint64(10e6) - snapshotBufferSize = int(snapshotChunkSize) - snapshotMaxItemSize = int(64e6) // SDK has no key/value size limit, so we set an arbitrary limit ) // Store is composed of many CommitStores. Name contrasts with @@ -154,6 +146,11 @@ func (rs *Store) GetCommitKVStore(key types.StoreKey) types.CommitKVStore { return rs.stores[key] } +// GetStores returns mounted stores +func (rs *Store) GetStores() map[types.StoreKey]types.CommitKVStore { + return rs.stores +} + // LoadLatestVersionAndUpgrade implements CommitMultiStore func (rs *Store) LoadLatestVersionAndUpgrade(upgrades *types.StoreUpgrades) error { ver := getLatestVersion(rs.db) @@ -549,11 +546,11 @@ func (rs *Store) GetKVStore(key types.StoreKey) types.KVStore { return store } -// getStoreByName performs a lookup of a StoreKey given a store name typically +// GetStoreByName performs a lookup of a StoreKey given a store name typically // provided in a path. The StoreKey is then used to perform a lookup and return // a Store. If the Store is wrapped in an inter-block cache, it will be unwrapped // prior to being returned. If the StoreKey does not exist, nil is returned. -func (rs *Store) getStoreByName(name string) types.Store { +func (rs *Store) GetStoreByName(name string) types.Store { key := rs.keysByName[name] if key == nil { return nil @@ -573,7 +570,7 @@ func (rs *Store) Query(req abci.RequestQuery) abci.ResponseQuery { return sdkerrors.QueryResult(err) } - store := rs.getStoreByName(storeName) + store := rs.GetStoreByName(storeName) if store == nil { return sdkerrors.QueryResult(sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "no such store: %s", storeName)) } @@ -658,15 +655,12 @@ func parsePath(path string) (storeName string, subpath string, err error) { // identical across nodes such that chunks from different sources fit together. If the output for a // given format changes (at the byte level), the snapshot format must be bumped - see // TestMultistoreSnapshot_Checksum test. -func (rs *Store) Snapshot(height uint64, format uint32) (<-chan io.ReadCloser, error) { - if format != snapshottypes.CurrentFormat { - return nil, sdkerrors.Wrapf(snapshottypes.ErrUnknownFormat, "format %v", format) - } +func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error { if height == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "cannot snapshot height 0") + return sdkerrors.Wrap(sdkerrors.ErrLogic, "cannot snapshot height 0") } if height > uint64(rs.LastCommitID().Version) { - return nil, sdkerrors.Wrapf(sdkerrors.ErrLogic, "cannot snapshot future height %v", height) + return sdkerrors.Wrapf(sdkerrors.ErrLogic, "cannot snapshot future height %v", height) } // Collect stores to snapshot (only IAVL stores are supported) @@ -683,7 +677,7 @@ func (rs *Store) Snapshot(height uint64, format uint32) (<-chan io.ReadCloser, e // Non-persisted stores shouldn't be snapshotted continue default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrLogic, + return sdkerrors.Wrapf(sdkerrors.ErrLogic, "don't know how to snapshot store %q of type %T", key.Name(), store) } } @@ -691,160 +685,99 @@ func (rs *Store) Snapshot(height uint64, format uint32) (<-chan io.ReadCloser, e return strings.Compare(stores[i].name, stores[j].name) == -1 }) - // Spawn goroutine to generate snapshot chunks and pass their io.ReadClosers through a channel - ch := make(chan io.ReadCloser) - go func() { - // Set up a stream pipeline to serialize snapshot nodes: - // ExportNode -> delimited Protobuf -> zlib -> buffer -> chunkWriter -> chan io.ReadCloser - chunkWriter := snapshots.NewChunkWriter(ch, snapshotChunkSize) - defer chunkWriter.Close() - bufWriter := bufio.NewWriterSize(chunkWriter, snapshotBufferSize) - defer func() { - if err := bufWriter.Flush(); err != nil { - chunkWriter.CloseWithError(err) - } - }() - zWriter, err := zlib.NewWriterLevel(bufWriter, 7) + // Export each IAVL store. Stores are serialized as a stream of SnapshotItem Protobuf + // messages. The first item contains a SnapshotStore with store metadata (i.e. name), + // and the following messages contain a SnapshotNode (i.e. an ExportNode). Store changes + // are demarcated by new SnapshotStore items. + for _, store := range stores { + exporter, err := store.Export(int64(height)) if err != nil { - chunkWriter.CloseWithError(sdkerrors.Wrap(err, "zlib failure")) - return + return err } - defer func() { - if err := zWriter.Close(); err != nil { - chunkWriter.CloseWithError(err) - } - }() - protoWriter := protoio.NewDelimitedWriter(zWriter) - defer func() { - if err := protoWriter.Close(); err != nil { - chunkWriter.CloseWithError(err) - } - }() - - // Export each IAVL store. Stores are serialized as a stream of SnapshotItem Protobuf - // messages. The first item contains a SnapshotStore with store metadata (i.e. name), - // and the following messages contain a SnapshotNode (i.e. an ExportNode). Store changes - // are demarcated by new SnapshotStore items. - for _, store := range stores { - exporter, err := store.Export(int64(height)) - if err != nil { - chunkWriter.CloseWithError(err) - return + defer exporter.Close() + err = protoWriter.WriteMsg(&snapshottypes.SnapshotItem{ + Item: &snapshottypes.SnapshotItem_Store{ + Store: &snapshottypes.SnapshotStoreItem{ + Name: store.name, + }, + }, + }) + if err != nil { + return err + } + + for { + node, err := exporter.Next() + if err == iavltree.ExportDone { + break + } else if err != nil { + return err } - defer exporter.Close() - err = protoWriter.WriteMsg(&types.SnapshotItem{ - Item: &types.SnapshotItem_Store{ - Store: &types.SnapshotStoreItem{ - Name: store.name, + err = protoWriter.WriteMsg(&snapshottypes.SnapshotItem{ + Item: &snapshottypes.SnapshotItem_IAVL{ + IAVL: &snapshottypes.SnapshotIAVLItem{ + Key: node.Key, + Value: node.Value, + Height: int32(node.Height), + Version: node.Version, }, }, }) if err != nil { - chunkWriter.CloseWithError(err) - return + return err } - - for { - node, err := exporter.Next() - if err == iavltree.ExportDone { - break - } else if err != nil { - chunkWriter.CloseWithError(err) - return - } - err = protoWriter.WriteMsg(&types.SnapshotItem{ - Item: &types.SnapshotItem_IAVL{ - IAVL: &types.SnapshotIAVLItem{ - Key: node.Key, - Value: node.Value, - Height: int32(node.Height), - Version: node.Version, - }, - }, - }) - if err != nil { - chunkWriter.CloseWithError(err) - return - } - } - exporter.Close() } - }() + exporter.Close() + } - return ch, nil + return nil } // Restore implements snapshottypes.Snapshotter. +// returns next snapshot item and error. func (rs *Store) Restore( - height uint64, format uint32, chunks <-chan io.ReadCloser, ready chan<- struct{}, -) error { - if format != snapshottypes.CurrentFormat { - return sdkerrors.Wrapf(snapshottypes.ErrUnknownFormat, "format %v", format) - } - if height == 0 { - return sdkerrors.Wrap(sdkerrors.ErrLogic, "cannot restore snapshot at height 0") - } - if height > uint64(math.MaxInt64) { - return sdkerrors.Wrapf(snapshottypes.ErrInvalidMetadata, - "snapshot height %v cannot exceed %v", height, int64(math.MaxInt64)) - } - - // Signal readiness. Must be done before the readers below are set up, since the zlib - // reader reads from the stream on initialization, potentially causing deadlocks. - if ready != nil { - close(ready) - } - - // Set up a restore stream pipeline - // chan io.ReadCloser -> chunkReader -> zlib -> delimited Protobuf -> ExportNode - chunkReader := snapshots.NewChunkReader(chunks) - defer chunkReader.Close() - zReader, err := zlib.NewReader(chunkReader) - if err != nil { - return sdkerrors.Wrap(err, "zlib failure") - } - defer zReader.Close() - protoReader := protoio.NewDelimitedReader(zReader, snapshotMaxItemSize) - defer protoReader.Close() - + height uint64, format uint32, protoReader protoio.Reader, +) (snapshottypes.SnapshotItem, error) { // Import nodes into stores. The first item is expected to be a SnapshotItem containing // a SnapshotStoreItem, telling us which store to import into. The following items will contain // SnapshotNodeItem (i.e. ExportNode) until we reach the next SnapshotStoreItem or EOF. var importer *iavltree.Importer + var snapshotItem snapshottypes.SnapshotItem +loop: for { - item := &types.SnapshotItem{} - err := protoReader.ReadMsg(item) + snapshotItem = snapshottypes.SnapshotItem{} + err := protoReader.ReadMsg(&snapshotItem) if err == io.EOF { break } else if err != nil { - return sdkerrors.Wrap(err, "invalid protobuf message") + return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "invalid protobuf message") } - switch item := item.Item.(type) { - case *types.SnapshotItem_Store: + switch item := snapshotItem.Item.(type) { + case *snapshottypes.SnapshotItem_Store: if importer != nil { err = importer.Commit() if err != nil { - return sdkerrors.Wrap(err, "IAVL commit failed") + return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "IAVL commit failed") } importer.Close() } - store, ok := rs.getStoreByName(item.Store.Name).(*iavl.Store) + store, ok := rs.GetStoreByName(item.Store.Name).(*iavl.Store) if !ok || store == nil { - return sdkerrors.Wrapf(sdkerrors.ErrLogic, "cannot import into non-IAVL store %q", item.Store.Name) + return snapshottypes.SnapshotItem{}, sdkerrors.Wrapf(sdkerrors.ErrLogic, "cannot import into non-IAVL store %q", item.Store.Name) } importer, err = store.Import(int64(height)) if err != nil { - return sdkerrors.Wrap(err, "import failed") + return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "import failed") } defer importer.Close() - case *types.SnapshotItem_IAVL: + case *snapshottypes.SnapshotItem_IAVL: if importer == nil { - return sdkerrors.Wrap(sdkerrors.ErrLogic, "received IAVL node item before store item") + return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(sdkerrors.ErrLogic, "received IAVL node item before store item") } if item.IAVL.Height > math.MaxInt8 { - return sdkerrors.Wrapf(sdkerrors.ErrLogic, "node height %v cannot exceed %v", + return snapshottypes.SnapshotItem{}, sdkerrors.Wrapf(sdkerrors.ErrLogic, "node height %v cannot exceed %v", item.IAVL.Height, math.MaxInt8) } node := &iavltree.ExportNode{ @@ -863,24 +796,24 @@ func (rs *Store) Restore( } err := importer.Add(node) if err != nil { - return sdkerrors.Wrap(err, "IAVL node import failed") + return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "IAVL node import failed") } default: - return sdkerrors.Wrapf(sdkerrors.ErrLogic, "unknown snapshot item %T", item) + break loop } } if importer != nil { err := importer.Commit() if err != nil { - return sdkerrors.Wrap(err, "IAVL commit failed") + return snapshottypes.SnapshotItem{}, sdkerrors.Wrap(err, "IAVL commit failed") } importer.Close() } flushMetadata(rs.db, int64(height), rs.buildCommitInfo(int64(height)), []int64{}) - return rs.LoadLatestVersion() + return snapshotItem, rs.LoadLatestVersion() } func (rs *Store) loadCommitStoreFromParams(key types.StoreKey, id types.CommitID, params storeParams) (types.CommitKVStore, error) { @@ -960,6 +893,30 @@ func (rs *Store) buildCommitInfo(version int64) *types.CommitInfo { } } +// RollbackToVersion delete the versions after `target` and update the latest version. +func (rs *Store) RollbackToVersion(target int64) int64 { + if target < 0 { + panic("Negative rollback target") + } + current := getLatestVersion(rs.db) + if target >= current { + return current + } + for ; current > target; current-- { + rs.pruneHeights = append(rs.pruneHeights, current) + } + rs.pruneStores() + + // update latest height + bz, err := gogotypes.StdInt64Marshal(current) + if err != nil { + panic(err) + } + + rs.db.Set([]byte(latestVersionKey), bz) + return current +} + type storeParams struct { key types.StoreKey db dbm.DB diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index afe59a6b6a3a..e2fe5835727f 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -2,25 +2,16 @@ package rootmulti import ( "bytes" - "crypto/sha256" - "encoding/binary" - "encoding/hex" - "errors" "fmt" - "io" - "io/ioutil" - "math/rand" "testing" "time" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" codecTypes "github.com/cosmos/cosmos-sdk/codec/types" - snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store/cachemulti" "github.com/cosmos/cosmos-sdk/store/iavl" sdkmaps "github.com/cosmos/cosmos-sdk/store/internal/maps" @@ -87,7 +78,7 @@ func TestCacheMultiStoreWithVersion(t *testing.T) { k, v := []byte("wind"), []byte("blows") - store1 := ms.getStoreByName("store1").(types.KVStore) + store1 := ms.GetStoreByName("store1").(types.KVStore) store1.Set(k, v) cID := ms.Commit() @@ -124,7 +115,7 @@ func TestHashStableWithEmptyCommit(t *testing.T) { k, v := []byte("wind"), []byte("blows") - store1 := ms.getStoreByName("store1").(types.KVStore) + store1 := ms.GetStoreByName("store1").(types.KVStore) store1.Set(k, v) cID := ms.Commit() @@ -148,11 +139,11 @@ func TestMultistoreCommitLoad(t *testing.T) { checkStore(t, store, commitID, commitID) // Make sure we can get stores by name. - s1 := store.getStoreByName("store1") + s1 := store.GetStoreByName("store1") require.NotNil(t, s1) - s3 := store.getStoreByName("store3") + s3 := store.GetStoreByName("store3") require.NotNil(t, s3) - s77 := store.getStoreByName("store77") + s77 := store.GetStoreByName("store77") require.Nil(t, s77) // Make a few commits and check them. @@ -192,21 +183,21 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { // write some data in all stores k1, v1 := []byte("first"), []byte("store") - s1, _ := store.getStoreByName("store1").(types.KVStore) + s1, _ := store.GetStoreByName("store1").(types.KVStore) require.NotNil(t, s1) s1.Set(k1, v1) k2, v2 := []byte("second"), []byte("restore") - s2, _ := store.getStoreByName("store2").(types.KVStore) + s2, _ := store.GetStoreByName("store2").(types.KVStore) require.NotNil(t, s2) s2.Set(k2, v2) k3, v3 := []byte("third"), []byte("dropped") - s3, _ := store.getStoreByName("store3").(types.KVStore) + s3, _ := store.GetStoreByName("store3").(types.KVStore) require.NotNil(t, s3) s3.Set(k3, v3) - s4, _ := store.getStoreByName("store4").(types.KVStore) + s4, _ := store.GetStoreByName("store4").(types.KVStore) require.Nil(t, s4) // do one commit @@ -229,7 +220,7 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { checkStore(t, store, commitID, commitID) // let's query data to see it was saved properly - s2, _ = store.getStoreByName("store2").(types.KVStore) + s2, _ = store.GetStoreByName("store2").(types.KVStore) require.NotNil(t, s2) require.Equal(t, v2, s2.Get(k2)) @@ -239,17 +230,17 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { require.Nil(t, err) // s1 was not changed - s1, _ = restore.getStoreByName("store1").(types.KVStore) + s1, _ = restore.GetStoreByName("store1").(types.KVStore) require.NotNil(t, s1) require.Equal(t, v1, s1.Get(k1)) // store3 is mounted, but data deleted are gone - s3, _ = restore.getStoreByName("store3").(types.KVStore) + s3, _ = restore.GetStoreByName("store3").(types.KVStore) require.NotNil(t, s3) require.Nil(t, s3.Get(k3)) // data was deleted // store4 is mounted, with empty data - s4, _ = restore.getStoreByName("store4").(types.KVStore) + s4, _ = restore.GetStoreByName("store4").(types.KVStore) require.NotNil(t, s4) iterator := s4.Iterator(nil, nil) @@ -267,11 +258,11 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { s4.Set(k4, v4) // store2 is no longer mounted - st2 := restore.getStoreByName("store2") + st2 := restore.GetStoreByName("store2") require.Nil(t, st2) // restore2 has the old data - rs2, _ := restore.getStoreByName("restore2").(types.KVStore) + rs2, _ := restore.GetStoreByName("restore2").(types.KVStore) require.NotNil(t, rs2) require.Equal(t, v2, rs2.Get(k2)) @@ -285,15 +276,15 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { require.Equal(t, migratedID, reload.LastCommitID()) // query this new store - rl1, _ := reload.getStoreByName("store1").(types.KVStore) + rl1, _ := reload.GetStoreByName("store1").(types.KVStore) require.NotNil(t, rl1) require.Equal(t, v1, rl1.Get(k1)) - rl2, _ := reload.getStoreByName("restore2").(types.KVStore) + rl2, _ := reload.GetStoreByName("restore2").(types.KVStore) require.NotNil(t, rl2) require.Equal(t, v2, rl2.Get(k2)) - rl4, _ := reload.getStoreByName("store4").(types.KVStore) + rl4, _ := reload.GetStoreByName("store4").(types.KVStore) require.NotNil(t, rl4) require.Equal(t, v4, rl4.Get(k4)) @@ -345,15 +336,15 @@ func TestMultiStoreRestart(t *testing.T) { for i := 1; i < 3; i++ { // Set and commit data in one store. - store1 := multi.getStoreByName("store1").(types.KVStore) + store1 := multi.GetStoreByName("store1").(types.KVStore) store1.Set([]byte(k), []byte(fmt.Sprintf("%s:%d", v, i))) // ... and another. - store2 := multi.getStoreByName("store2").(types.KVStore) + store2 := multi.GetStoreByName("store2").(types.KVStore) store2.Set([]byte(k2), []byte(fmt.Sprintf("%s:%d", v2, i))) // ... and another. - store3 := multi.getStoreByName("store3").(types.KVStore) + store3 := multi.GetStoreByName("store3").(types.KVStore) store3.Set([]byte(k3), []byte(fmt.Sprintf("%s:%d", v3, i))) multi.Commit() @@ -364,11 +355,11 @@ func TestMultiStoreRestart(t *testing.T) { } // Set and commit data in one store. - store1 := multi.getStoreByName("store1").(types.KVStore) + store1 := multi.GetStoreByName("store1").(types.KVStore) store1.Set([]byte(k), []byte(fmt.Sprintf("%s:%d", v, 3))) // ... and another. - store2 := multi.getStoreByName("store2").(types.KVStore) + store2 := multi.GetStoreByName("store2").(types.KVStore) store2.Set([]byte(k2), []byte(fmt.Sprintf("%s:%d", v2, 3))) multi.Commit() @@ -378,7 +369,7 @@ func TestMultiStoreRestart(t *testing.T) { require.NotEqual(t, initCid, flushedCinfo, "CID is different after flush to disk") // ... and another. - store3 := multi.getStoreByName("store3").(types.KVStore) + store3 := multi.GetStoreByName("store3").(types.KVStore) store3.Set([]byte(k3), []byte(fmt.Sprintf("%s:%d", v3, 3))) multi.Commit() @@ -395,16 +386,16 @@ func TestMultiStoreRestart(t *testing.T) { require.Equal(t, int64(4), reloadedCid.Version, "Reloaded CID is not the same as last flushed CID") // Check that store1 and store2 retained date from 3rd commit - store1 = multi.getStoreByName("store1").(types.KVStore) + store1 = multi.GetStoreByName("store1").(types.KVStore) val := store1.Get([]byte(k)) require.Equal(t, []byte(fmt.Sprintf("%s:%d", v, 3)), val, "Reloaded value not the same as last flushed value") - store2 = multi.getStoreByName("store2").(types.KVStore) + store2 = multi.GetStoreByName("store2").(types.KVStore) val2 := store2.Get([]byte(k2)) require.Equal(t, []byte(fmt.Sprintf("%s:%d", v2, 3)), val2, "Reloaded value not the same as last flushed value") // Check that store3 still has data from last commit even though update happened on 2nd commit - store3 = multi.getStoreByName("store3").(types.KVStore) + store3 = multi.GetStoreByName("store3").(types.KVStore) val3 := store3.Get([]byte(k3)) require.Equal(t, []byte(fmt.Sprintf("%s:%d", v3, 3)), val3, "Reloaded value not the same as last flushed value") } @@ -422,15 +413,15 @@ func TestMultiStoreQuery(t *testing.T) { cid := multi.Commit() // Make sure we can get by name. - garbage := multi.getStoreByName("bad-name") + garbage := multi.GetStoreByName("bad-name") require.Nil(t, garbage) // Set and commit data in one store. - store1 := multi.getStoreByName("store1").(types.KVStore) + store1 := multi.GetStoreByName("store1").(types.KVStore) store1.Set(k, v) // ... and another. - store2 := multi.getStoreByName("store2").(types.KVStore) + store2 := multi.GetStoreByName("store2").(types.KVStore) store2.Set(k2, v2) // Commit the multistore. @@ -553,121 +544,6 @@ func TestMultiStore_PruningRestart(t *testing.T) { } } -func TestMultistoreSnapshot_Checksum(t *testing.T) { - // Chunks from different nodes must fit together, so all nodes must produce identical chunks. - // This checksum test makes sure that the byte stream remains identical. If the test fails - // without having changed the data (e.g. because the Protobuf or zlib encoding changes), - // snapshottypes.CurrentFormat must be bumped. - store := newMultiStoreWithGeneratedData(dbm.NewMemDB(), 5, 10000) - version := uint64(store.LastCommitID().Version) - - testcases := []struct { - format uint32 - chunkHashes []string - }{ - {1, []string{ - "503e5b51b657055b77e88169fadae543619368744ad15f1de0736c0a20482f24", - "e1a0daaa738eeb43e778aefd2805e3dd720798288a410b06da4b8459c4d8f72e", - "aa048b4ee0f484965d7b3b06822cf0772cdcaad02f3b1b9055e69f2cb365ef3c", - "7921eaa3ed4921341e504d9308a9877986a879fe216a099c86e8db66fcba4c63", - "a4a864e6c02c9fca5837ec80dc84f650b25276ed7e4820cf7516ced9f9901b86", - "ca2879ac6e7205d257440131ba7e72bef784cd61642e32b847729e543c1928b9", - }}, - } - for _, tc := range testcases { - tc := tc - t.Run(fmt.Sprintf("Format %v", tc.format), func(t *testing.T) { - chunks, err := store.Snapshot(version, tc.format) - require.NoError(t, err) - hashes := []string{} - hasher := sha256.New() - for chunk := range chunks { - hasher.Reset() - _, err := io.Copy(hasher, chunk) - require.NoError(t, err) - hashes = append(hashes, hex.EncodeToString(hasher.Sum(nil))) - } - assert.Equal(t, tc.chunkHashes, hashes, - "Snapshot output for format %v has changed", tc.format) - }) - } -} - -func TestMultistoreSnapshot_Errors(t *testing.T) { - store := newMultiStoreWithMixedMountsAndBasicData(dbm.NewMemDB()) - - testcases := map[string]struct { - height uint64 - format uint32 - expectType error - }{ - "0 height": {0, snapshottypes.CurrentFormat, nil}, - "0 format": {1, 0, snapshottypes.ErrUnknownFormat}, - "unknown height": {9, snapshottypes.CurrentFormat, nil}, - "unknown format": {1, 9, snapshottypes.ErrUnknownFormat}, - } - for name, tc := range testcases { - tc := tc - t.Run(name, func(t *testing.T) { - _, err := store.Snapshot(tc.height, tc.format) - require.Error(t, err) - if tc.expectType != nil { - assert.True(t, errors.Is(err, tc.expectType)) - } - }) - } -} - -func TestMultistoreRestore_Errors(t *testing.T) { - store := newMultiStoreWithMixedMounts(dbm.NewMemDB()) - - testcases := map[string]struct { - height uint64 - format uint32 - expectType error - }{ - "0 height": {0, snapshottypes.CurrentFormat, nil}, - "0 format": {1, 0, snapshottypes.ErrUnknownFormat}, - "unknown format": {1, 9, snapshottypes.ErrUnknownFormat}, - } - for name, tc := range testcases { - tc := tc - t.Run(name, func(t *testing.T) { - err := store.Restore(tc.height, tc.format, nil, nil) - require.Error(t, err) - if tc.expectType != nil { - assert.True(t, errors.Is(err, tc.expectType)) - } - }) - } -} - -func TestMultistoreSnapshotRestore(t *testing.T) { - source := newMultiStoreWithMixedMountsAndBasicData(dbm.NewMemDB()) - target := newMultiStoreWithMixedMounts(dbm.NewMemDB()) - version := uint64(source.LastCommitID().Version) - require.EqualValues(t, 3, version) - - chunks, err := source.Snapshot(version, snapshottypes.CurrentFormat) - require.NoError(t, err) - ready := make(chan struct{}) - err = target.Restore(version, snapshottypes.CurrentFormat, chunks, ready) - require.NoError(t, err) - assert.EqualValues(t, struct{}{}, <-ready) - - assert.Equal(t, source.LastCommitID(), target.LastCommitID()) - for key, sourceStore := range source.stores { - targetStore := target.getStoreByName(key.Name()).(types.CommitKVStore) - switch sourceStore.GetStoreType() { - case types.StoreTypeTransient: - assert.False(t, targetStore.Iterator(nil, nil).Valid(), - "transient store %v not empty", key.Name()) - default: - assertStoresEqual(t, sourceStore, targetStore, "store %q not equal", key.Name()) - } - } -} - func TestSetInitialVersion(t *testing.T) { db := dbm.NewMemDB() multi := newMultiStoreWithMounts(db, types.PruneNothing) @@ -855,79 +731,6 @@ func TestTraceConcurrency(t *testing.T) { stopW <- struct{}{} } -func BenchmarkMultistoreSnapshot100K(b *testing.B) { - benchmarkMultistoreSnapshot(b, 10, 10000) -} - -func BenchmarkMultistoreSnapshot1M(b *testing.B) { - benchmarkMultistoreSnapshot(b, 10, 100000) -} - -func BenchmarkMultistoreSnapshotRestore100K(b *testing.B) { - benchmarkMultistoreSnapshotRestore(b, 10, 10000) -} - -func BenchmarkMultistoreSnapshotRestore1M(b *testing.B) { - benchmarkMultistoreSnapshotRestore(b, 10, 100000) -} - -func benchmarkMultistoreSnapshot(b *testing.B, stores uint8, storeKeys uint64) { - b.Skip("Noisy with slow setup time, please see https://github.com/cosmos/cosmos-sdk/issues/8855.") - - b.ReportAllocs() - b.StopTimer() - source := newMultiStoreWithGeneratedData(dbm.NewMemDB(), stores, storeKeys) - version := source.LastCommitID().Version - require.EqualValues(b, 1, version) - b.StartTimer() - - for i := 0; i < b.N; i++ { - target := NewStore(dbm.NewMemDB()) - for key := range source.stores { - target.MountStoreWithDB(key, types.StoreTypeIAVL, nil) - } - err := target.LoadLatestVersion() - require.NoError(b, err) - require.EqualValues(b, 0, target.LastCommitID().Version) - - chunks, err := source.Snapshot(uint64(version), snapshottypes.CurrentFormat) - require.NoError(b, err) - for reader := range chunks { - _, err := io.Copy(ioutil.Discard, reader) - require.NoError(b, err) - err = reader.Close() - require.NoError(b, err) - } - } -} - -func benchmarkMultistoreSnapshotRestore(b *testing.B, stores uint8, storeKeys uint64) { - b.Skip("Noisy with slow setup time, please see https://github.com/cosmos/cosmos-sdk/issues/8855.") - - b.ReportAllocs() - b.StopTimer() - source := newMultiStoreWithGeneratedData(dbm.NewMemDB(), stores, storeKeys) - version := uint64(source.LastCommitID().Version) - require.EqualValues(b, 1, version) - b.StartTimer() - - for i := 0; i < b.N; i++ { - target := NewStore(dbm.NewMemDB()) - for key := range source.stores { - target.MountStoreWithDB(key, types.StoreTypeIAVL, nil) - } - err := target.LoadLatestVersion() - require.NoError(b, err) - require.EqualValues(b, 0, target.LastCommitID().Version) - - chunks, err := source.Snapshot(version, snapshottypes.CurrentFormat) - require.NoError(b, err) - err = target.Restore(version, snapshottypes.CurrentFormat, chunks, nil) - require.NoError(b, err) - require.Equal(b, source.LastCommitID(), target.LastCommitID()) - } -} - //----------------------------------------------------------------------- // utils @@ -948,75 +751,6 @@ func newMultiStoreWithMounts(db dbm.DB, pruningOpts types.PruningOptions) *Store return store } -func newMultiStoreWithMixedMounts(db dbm.DB) *Store { - store := NewStore(db) - store.MountStoreWithDB(types.NewKVStoreKey("iavl1"), types.StoreTypeIAVL, nil) - store.MountStoreWithDB(types.NewKVStoreKey("iavl2"), types.StoreTypeIAVL, nil) - store.MountStoreWithDB(types.NewKVStoreKey("iavl3"), types.StoreTypeIAVL, nil) - store.MountStoreWithDB(types.NewTransientStoreKey("trans1"), types.StoreTypeTransient, nil) - store.LoadLatestVersion() - - return store -} - -func newMultiStoreWithMixedMountsAndBasicData(db dbm.DB) *Store { - store := newMultiStoreWithMixedMounts(db) - store1 := store.getStoreByName("iavl1").(types.CommitKVStore) - store2 := store.getStoreByName("iavl2").(types.CommitKVStore) - trans1 := store.getStoreByName("trans1").(types.KVStore) - - store1.Set([]byte("a"), []byte{1}) - store1.Set([]byte("b"), []byte{1}) - store2.Set([]byte("X"), []byte{255}) - store2.Set([]byte("A"), []byte{101}) - trans1.Set([]byte("x1"), []byte{91}) - store.Commit() - - store1.Set([]byte("b"), []byte{2}) - store1.Set([]byte("c"), []byte{3}) - store2.Set([]byte("B"), []byte{102}) - store.Commit() - - store2.Set([]byte("C"), []byte{103}) - store2.Delete([]byte("X")) - trans1.Set([]byte("x2"), []byte{92}) - store.Commit() - - return store -} - -func newMultiStoreWithGeneratedData(db dbm.DB, stores uint8, storeKeys uint64) *Store { - multiStore := NewStore(db) - r := rand.New(rand.NewSource(49872768940)) // Fixed seed for deterministic tests - - keys := []*types.KVStoreKey{} - for i := uint8(0); i < stores; i++ { - key := types.NewKVStoreKey(fmt.Sprintf("store%v", i)) - multiStore.MountStoreWithDB(key, types.StoreTypeIAVL, nil) - keys = append(keys, key) - } - multiStore.LoadLatestVersion() - - for _, key := range keys { - store := multiStore.stores[key].(*iavl.Store) - for i := uint64(0); i < storeKeys; i++ { - k := make([]byte, 8) - v := make([]byte, 1024) - binary.BigEndian.PutUint64(k, i) - _, err := r.Read(v) - if err != nil { - panic(err) - } - store.Set(k, v) - } - } - - multiStore.Commit() - multiStore.LoadLatestVersion() - - return multiStore -} - func newMultiStoreWithModifiedMounts(db dbm.DB, pruningOpts types.PruningOptions) (*Store, *types.StoreUpgrades) { store := NewStore(db) store.pruningOpts = pruningOpts @@ -1038,25 +772,6 @@ func newMultiStoreWithModifiedMounts(db dbm.DB, pruningOpts types.PruningOptions return store, upgrades } -func assertStoresEqual(t *testing.T, expect, actual types.CommitKVStore, msgAndArgs ...interface{}) { - assert.Equal(t, expect.LastCommitID(), actual.LastCommitID()) - expectIter := expect.Iterator(nil, nil) - expectMap := map[string][]byte{} - for ; expectIter.Valid(); expectIter.Next() { - expectMap[string(expectIter.Key())] = expectIter.Value() - } - require.NoError(t, expectIter.Error()) - - actualIter := expect.Iterator(nil, nil) - actualMap := map[string][]byte{} - for ; actualIter.Valid(); actualIter.Next() { - actualMap[string(actualIter.Key())] = actualIter.Value() - } - require.NoError(t, actualIter.Error()) - - assert.Equal(t, expectMap, actualMap, msgAndArgs...) -} - func checkStore(t *testing.T, store *Store, expect, got types.CommitID) { require.Equal(t, expect, got) require.Equal(t, expect, store.LastCommitID()) diff --git a/store/types/snapshot.pb.go b/store/types/snapshot.pb.go deleted file mode 100644 index 6f001da1bf28..000000000000 --- a/store/types/snapshot.pb.go +++ /dev/null @@ -1,944 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/base/store/v1beta1/snapshot.proto - -package types - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// SnapshotItem is an item contained in a rootmulti.Store snapshot. -type SnapshotItem struct { - // item is the specific type of snapshot item. - // - // Types that are valid to be assigned to Item: - // *SnapshotItem_Store - // *SnapshotItem_IAVL - Item isSnapshotItem_Item `protobuf_oneof:"item"` -} - -func (m *SnapshotItem) Reset() { *m = SnapshotItem{} } -func (m *SnapshotItem) String() string { return proto.CompactTextString(m) } -func (*SnapshotItem) ProtoMessage() {} -func (*SnapshotItem) Descriptor() ([]byte, []int) { - return fileDescriptor_9c55879db4cc4502, []int{0} -} -func (m *SnapshotItem) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotItem.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SnapshotItem) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotItem.Merge(m, src) -} -func (m *SnapshotItem) XXX_Size() int { - return m.Size() -} -func (m *SnapshotItem) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotItem.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotItem proto.InternalMessageInfo - -type isSnapshotItem_Item interface { - isSnapshotItem_Item() - MarshalTo([]byte) (int, error) - Size() int -} - -type SnapshotItem_Store struct { - Store *SnapshotStoreItem `protobuf:"bytes,1,opt,name=store,proto3,oneof" json:"store,omitempty"` -} -type SnapshotItem_IAVL struct { - IAVL *SnapshotIAVLItem `protobuf:"bytes,2,opt,name=iavl,proto3,oneof" json:"iavl,omitempty"` -} - -func (*SnapshotItem_Store) isSnapshotItem_Item() {} -func (*SnapshotItem_IAVL) isSnapshotItem_Item() {} - -func (m *SnapshotItem) GetItem() isSnapshotItem_Item { - if m != nil { - return m.Item - } - return nil -} - -func (m *SnapshotItem) GetStore() *SnapshotStoreItem { - if x, ok := m.GetItem().(*SnapshotItem_Store); ok { - return x.Store - } - return nil -} - -func (m *SnapshotItem) GetIAVL() *SnapshotIAVLItem { - if x, ok := m.GetItem().(*SnapshotItem_IAVL); ok { - return x.IAVL - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*SnapshotItem) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*SnapshotItem_Store)(nil), - (*SnapshotItem_IAVL)(nil), - } -} - -// SnapshotStoreItem contains metadata about a snapshotted store. -type SnapshotStoreItem struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (m *SnapshotStoreItem) Reset() { *m = SnapshotStoreItem{} } -func (m *SnapshotStoreItem) String() string { return proto.CompactTextString(m) } -func (*SnapshotStoreItem) ProtoMessage() {} -func (*SnapshotStoreItem) Descriptor() ([]byte, []int) { - return fileDescriptor_9c55879db4cc4502, []int{1} -} -func (m *SnapshotStoreItem) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotStoreItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotStoreItem.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SnapshotStoreItem) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotStoreItem.Merge(m, src) -} -func (m *SnapshotStoreItem) XXX_Size() int { - return m.Size() -} -func (m *SnapshotStoreItem) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotStoreItem.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotStoreItem proto.InternalMessageInfo - -func (m *SnapshotStoreItem) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -// SnapshotIAVLItem is an exported IAVL node. -type SnapshotIAVLItem struct { - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - Version int64 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"` - Height int32 `protobuf:"varint,4,opt,name=height,proto3" json:"height,omitempty"` -} - -func (m *SnapshotIAVLItem) Reset() { *m = SnapshotIAVLItem{} } -func (m *SnapshotIAVLItem) String() string { return proto.CompactTextString(m) } -func (*SnapshotIAVLItem) ProtoMessage() {} -func (*SnapshotIAVLItem) Descriptor() ([]byte, []int) { - return fileDescriptor_9c55879db4cc4502, []int{2} -} -func (m *SnapshotIAVLItem) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotIAVLItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotIAVLItem.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *SnapshotIAVLItem) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotIAVLItem.Merge(m, src) -} -func (m *SnapshotIAVLItem) XXX_Size() int { - return m.Size() -} -func (m *SnapshotIAVLItem) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotIAVLItem.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotIAVLItem proto.InternalMessageInfo - -func (m *SnapshotIAVLItem) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *SnapshotIAVLItem) GetValue() []byte { - if m != nil { - return m.Value - } - return nil -} - -func (m *SnapshotIAVLItem) GetVersion() int64 { - if m != nil { - return m.Version - } - return 0 -} - -func (m *SnapshotIAVLItem) GetHeight() int32 { - if m != nil { - return m.Height - } - return 0 -} - -func init() { - proto.RegisterType((*SnapshotItem)(nil), "cosmos.base.store.v1beta1.SnapshotItem") - proto.RegisterType((*SnapshotStoreItem)(nil), "cosmos.base.store.v1beta1.SnapshotStoreItem") - proto.RegisterType((*SnapshotIAVLItem)(nil), "cosmos.base.store.v1beta1.SnapshotIAVLItem") -} - -func init() { - proto.RegisterFile("cosmos/base/store/v1beta1/snapshot.proto", fileDescriptor_9c55879db4cc4502) -} - -var fileDescriptor_9c55879db4cc4502 = []byte{ - // 324 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xc1, 0x4a, 0xc3, 0x30, - 0x18, 0xc7, 0x1b, 0xd7, 0x4d, 0xfd, 0xdc, 0x61, 0x86, 0x21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x99, 0x9d, 0xfb, - 0x33, 0xe8, 0xfc, 0xd4, 0xe2, 0x0e, 0x34, 0xa6, 0x62, 0x6d, 0xb1, 0x36, 0x33, 0x23, 0xee, 0x42, - 0xb3, 0xe4, 0xb3, 0x95, 0xb0, 0x4b, 0xb6, 0x99, 0x0b, 0x38, 0x80, 0xfd, 0x52, 0x2c, 0x55, 0x2e, - 0xe7, 0x41, 0xa3, 0x87, 0xa2, 0x06, 0xdb, 0x45, 0x7c, 0x02, 0xad, 0x4c, 0xe4, 0x69, 0xa6, 0x03, - 0xbf, 0x87, 0xa2, 0x26, 0xab, 0x53, 0x1c, 0xbf, 0x57, 0x21, 0xda, 0x54, 0x21, 0xfa, 0xaa, 0x42, - 0xf4, 0xba, 0x0d, 0xbd, 0xcd, 0x36, 0xf4, 0x3e, 0xb6, 0xa1, 0xf7, 0x1c, 0xa5, 0xb9, 0xce, 0x56, - 0x09, 0x99, 0xc8, 0x82, 0xd6, 0x27, 0x74, 0x9f, 0x6b, 0xf5, 0x32, 0xad, 0x0f, 0xa9, 0xd7, 0x0b, - 0xa1, 0x92, 0x96, 0xbd, 0xc6, 0xed, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x75, 0x87, 0x24, 0x7b, - 0xea, 0x01, 0x00, 0x00, -} - -func (m *SnapshotItem) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SnapshotItem) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Item != nil { - { - size := m.Item.Size() - i -= size - if _, err := m.Item.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *SnapshotItem_Store) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotItem_Store) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Store != nil { - { - size, err := m.Store.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSnapshot(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *SnapshotItem_IAVL) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotItem_IAVL) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.IAVL != nil { - { - size, err := m.IAVL.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSnapshot(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *SnapshotStoreItem) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SnapshotStoreItem) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotStoreItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SnapshotIAVLItem) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *SnapshotIAVLItem) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotIAVLItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintSnapshot(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x20 - } - if m.Version != 0 { - i = encodeVarintSnapshot(dAtA, i, uint64(m.Version)) - i-- - dAtA[i] = 0x18 - } - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintSnapshot(dAtA []byte, offset int, v uint64) int { - offset -= sovSnapshot(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *SnapshotItem) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Item != nil { - n += m.Item.Size() - } - return n -} - -func (m *SnapshotItem_Store) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Store != nil { - l = m.Store.Size() - n += 1 + l + sovSnapshot(uint64(l)) - } - return n -} -func (m *SnapshotItem_IAVL) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.IAVL != nil { - l = m.IAVL.Size() - n += 1 + l + sovSnapshot(uint64(l)) - } - return n -} -func (m *SnapshotStoreItem) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovSnapshot(uint64(l)) - } - return n -} - -func (m *SnapshotIAVLItem) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovSnapshot(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovSnapshot(uint64(l)) - } - if m.Version != 0 { - n += 1 + sovSnapshot(uint64(m.Version)) - } - if m.Height != 0 { - n += 1 + sovSnapshot(uint64(m.Height)) - } - return n -} - -func sovSnapshot(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozSnapshot(x uint64) (n int) { - return sovSnapshot(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *SnapshotItem) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return 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 fmt.Errorf("proto: SnapshotItem: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotItem: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Store", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SnapshotStoreItem{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Item = &SnapshotItem_Store{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IAVL", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SnapshotIAVLItem{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Item = &SnapshotItem_IAVL{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SnapshotStoreItem) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return 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 fmt.Errorf("proto: SnapshotStoreItem: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotStoreItem: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - 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 ErrInvalidLengthSnapshot - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SnapshotIAVLItem) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return 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 fmt.Errorf("proto: SnapshotIAVLItem: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotIAVLItem: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - m.Version = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Version |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipSnapshot(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowSnapshot - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowSnapshot - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowSnapshot - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthSnapshot - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupSnapshot - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthSnapshot - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthSnapshot = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowSnapshot = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupSnapshot = fmt.Errorf("proto: unexpected end of group") -) diff --git a/types/coin.go b/types/coin.go index af8ef0ae7cc3..20ae56fead2e 100644 --- a/types/coin.go +++ b/types/coin.go @@ -814,13 +814,13 @@ func ParseCoinNormalized(coinStr string) (coin Coin, err error) { return coin, nil } -// ParseCoinsNormalized will parse out a list of coins separated by commas, and normalize them by converting to smallest -// unit. If the parsing is successuful, the provided coins will be sanitized by removing zero coins and sorting the coin +// ParseCoinsNormalized will parse out a list of coins separated by commas, and normalize them by converting to the smallest +// unit. If the parsing is successful, the provided coins will be sanitized by removing zero coins and sorting the coin // set. Lastly a validation of the coin set is executed. If the check passes, ParseCoinsNormalized will return the // sanitized coins. -// Otherwise it will return an error. +// Otherwise, it will return an error. // If an empty string is provided to ParseCoinsNormalized, it returns nil Coins. -// ParseCoinsNormalized supports decimal coins as inputs, and truncate them to int after converted to smallest unit. +// ParseCoinsNormalized supports decimal coins as inputs, and truncate them to int after converted to the smallest unit. // Expected format: "{amount0}{denomination},...,{amountN}{denominationN}" func ParseCoinsNormalized(coinStr string) (Coins, error) { coins, err := ParseDecCoins(coinStr) diff --git a/types/decimal.go b/types/decimal.go index a6d2868969a1..467a50335bfa 100644 --- a/types/decimal.go +++ b/types/decimal.go @@ -179,8 +179,8 @@ func NewDecFromStr(str string) (Dec, error) { if !ok { return Dec{}, fmt.Errorf("failed to set decimal string: %s", combinedStr) } - if combined.BitLen() > maxBitLen { - return Dec{}, fmt.Errorf("decimal out of range; bitLen: got %d, max %d", combined.BitLen(), maxBitLen) + if combined.BitLen() > maxDecBitLen { + return Dec{}, fmt.Errorf("decimal out of range; bitLen: got %d, max %d", combined.BitLen(), maxDecBitLen) } if neg { combined = new(big.Int).Neg(combined) @@ -744,8 +744,8 @@ func (d *Dec) Unmarshal(data []byte) error { return err } - if d.i.BitLen() > maxBitLen { - return fmt.Errorf("decimal out of range; got: %d, max: %d", d.i.BitLen(), maxBitLen) + if d.i.BitLen() > maxDecBitLen { + return fmt.Errorf("decimal out of range; got: %d, max: %d", d.i.BitLen(), maxDecBitLen) } return nil diff --git a/types/decimal_test.go b/types/decimal_test.go index 16a1561cb3ee..dd703ceec2c7 100644 --- a/types/decimal_test.go +++ b/types/decimal_test.go @@ -30,8 +30,14 @@ func (s *decimalTestSuite) mustNewDecFromStr(str string) (d sdk.Dec) { } func (s *decimalTestSuite) TestNewDecFromStr() { - largeBigInt, success := new(big.Int).SetString("3144605511029693144278234343371835", 10) - s.Require().True(success) + largeBigInt, ok := new(big.Int).SetString("3144605511029693144278234343371835", 10) + s.Require().True(ok) + + largerBigInt, ok := new(big.Int).SetString("88888888888888888888888888888888888888888888888888888888888888888888844444440", 10) + s.Require().True(ok) + + largestBigInt, ok := new(big.Int).SetString("133499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535", 10) + s.Require().True(ok) tests := []struct { decimalStr string @@ -57,7 +63,9 @@ func (s *decimalTestSuite) TestNewDecFromStr() { {"foobar", true, sdk.Dec{}}, {"0.foobar", true, sdk.Dec{}}, {"0.foobar.", true, sdk.Dec{}}, - {"88888888888888888888888888888888888888888888888888888888888888888888844444440", true, sdk.Dec{}}, + {"88888888888888888888888888888888888888888888888888888888888888888888844444440", false, sdk.NewDecFromBigInt(largerBigInt)}, + {"133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535", false, sdk.NewDecFromBigIntWithPrec(largestBigInt, 18)}, + {"133499189745056880149688856635597007162669032647290798121690100488888732861291", true, sdk.Dec{}}, } for tcIndex, tc := range tests { @@ -441,6 +449,12 @@ func (s *decimalTestSuite) TestDecSortableBytes() { } func (s *decimalTestSuite) TestDecEncoding() { + largestBigInt, ok := new(big.Int).SetString("133499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535", 10) + s.Require().True(ok) + + smallestBigInt, ok := new(big.Int).SetString("-133499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535", 10) + s.Require().True(ok) + testCases := []struct { input sdk.Dec rawBz string @@ -476,6 +490,18 @@ func (s *decimalTestSuite) TestDecEncoding() { "\"-1.414213562373095049\"", "\"-1.414213562373095049\"\n", }, + { + sdk.NewDecFromBigIntWithPrec(largestBigInt, 18), + "313333343939313839373435303536383830313439363838383536363335353937303037313632363639303332363437323930373938313231363930313030343838383838373332383631323930303334333736343335313330343333353335", + "\"133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"", + "\"133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"\n", + }, + { + sdk.NewDecFromBigIntWithPrec(smallestBigInt, 18), + "2D313333343939313839373435303536383830313439363838383536363335353937303037313632363639303332363437323930373938313231363930313030343838383838373332383631323930303334333736343335313330343333353335", + "\"-133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"", + "\"-133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"\n", + }, } for _, tc := range testCases { diff --git a/types/module/module.go b/types/module/module.go index c1955c8b8498..16695db09b22 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -359,7 +359,7 @@ func (m *Manager) assertNoForgottenModules(setOrderFnName string, moduleNames [] } if len(missing) != 0 { panic(fmt.Sprintf( - "%s: all modules must be defined when setting SetOrderMigrations, missing: %v", setOrderFnName, missing)) + "%s: all modules must be defined when setting %s, missing: %v", setOrderFnName, setOrderFnName, missing)) } } diff --git a/types/tx/signing/signing.pb.go b/types/tx/signing/signing.pb.go index f06a270c7cbd..dbf86219f6d3 100644 --- a/types/tx/signing/signing.pb.go +++ b/types/tx/signing/signing.pb.go @@ -41,6 +41,11 @@ const ( // SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses // Amino JSON and will be removed in the future SignMode_SIGN_MODE_LEGACY_AMINO_JSON SignMode = 127 + // SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos + // SDK. Ref: https://eips.ethereum.org/EIPS/eip-191 + // + // Since: cosmos-sdk 0.45 + SignMode_SIGN_MODE_EIP_191 SignMode = 191 ) var SignMode_name = map[int32]string{ @@ -48,6 +53,7 @@ var SignMode_name = map[int32]string{ 1: "SIGN_MODE_DIRECT", 2: "SIGN_MODE_TEXTUAL", 127: "SIGN_MODE_LEGACY_AMINO_JSON", + 191: "SIGN_MODE_EIP_191", } var SignMode_value = map[string]int32{ @@ -55,6 +61,7 @@ var SignMode_value = map[string]int32{ "SIGN_MODE_DIRECT": 1, "SIGN_MODE_TEXTUAL": 2, "SIGN_MODE_LEGACY_AMINO_JSON": 127, + "SIGN_MODE_EIP_191": 191, } func (x SignMode) String() string { @@ -391,41 +398,43 @@ func init() { } var fileDescriptor_9a54958ff3d0b1b9 = []byte{ - // 544 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0xed, 0x26, 0x8d, 0xd2, 0x29, 0x42, 0x61, 0x49, 0xa5, 0xc4, 0x20, 0x13, 0x95, 0x03, - 0x11, 0x52, 0xd6, 0x6a, 0x72, 0x40, 0x70, 0xcb, 0x1f, 0x93, 0x86, 0x36, 0x09, 0xd8, 0xa9, 0x04, - 0x5c, 0x2c, 0xdb, 0xd9, 0x1a, 0xab, 0xb1, 0xd7, 0x78, 0xd7, 0xa8, 0x3e, 0xf1, 0x0a, 0xbc, 0x06, - 0xcf, 0xc1, 0x85, 0x63, 0x8f, 0x1c, 0x51, 0xf2, 0x0c, 0xdc, 0x51, 0xec, 0x38, 0x09, 0x52, 0x11, - 0x22, 0x27, 0x6b, 0x66, 0xbe, 0xfd, 0xcd, 0xb7, 0x9a, 0x59, 0xc3, 0x13, 0x9b, 0x32, 0x8f, 0x32, - 0x85, 0x5f, 0x2b, 0xcc, 0x75, 0x7c, 0xd7, 0x77, 0x94, 0x4f, 0x27, 0x16, 0xe1, 0xe6, 0x49, 0x16, - 0xe3, 0x20, 0xa4, 0x9c, 0xa2, 0x6a, 0x2a, 0xc4, 0xfc, 0x1a, 0x67, 0x85, 0x95, 0x50, 0x6a, 0xac, - 0x18, 0x76, 0x18, 0x07, 0x9c, 0x2a, 0x5e, 0x34, 0xe3, 0x2e, 0x73, 0x37, 0xa0, 0x2c, 0x91, 0x92, - 0xa4, 0xaa, 0x43, 0xa9, 0x33, 0x23, 0x4a, 0x12, 0x59, 0xd1, 0xa5, 0x62, 0xfa, 0x71, 0x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0x40, 0xb6, 0x7f, 0x0c, 0x56, 0x21, 0x79, - 0x01, 0xad, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x86, 0x87, 0x55, 0xbf, 0x34, 0x04, 0x00, 0x00, + // 573 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0xc7, 0xed, 0x26, 0xad, 0xda, 0xe9, 0xa7, 0x4f, 0x66, 0x49, 0x51, 0x6a, 0x90, 0xa9, 0xca, + 0x81, 0x0a, 0xa9, 0x6b, 0xa5, 0x3d, 0xa0, 0x72, 0x73, 0x13, 0x93, 0x9a, 0x36, 0x69, 0xb1, 0x53, + 0xa9, 0x70, 0xb1, 0x6c, 0x67, 0x6b, 0xac, 0xc6, 0x5e, 0xe3, 0x5d, 0xa3, 0xfa, 0xc4, 0x2b, 0xf0, + 0x12, 0x1c, 0x78, 0x0a, 0x0e, 0x5c, 0x38, 0xf6, 0xc8, 0x11, 0x25, 0xcf, 0xc0, 0x1d, 0xc5, 0x8e, + 0x93, 0x80, 0x8a, 0x10, 0x39, 0x59, 0x33, 0xf3, 0xdf, 0xdf, 0xfc, 0x57, 0x33, 0x6b, 0x78, 0xec, + 0x51, 0x16, 0x52, 0xa6, 0xf2, 0x6b, 0x95, 0x05, 0x7e, 0x14, 0x44, 0xbe, 0xfa, 0xae, 0xe1, 0x12, + 0xee, 0x34, 0xca, 0x18, 0xc7, 0x09, 0xe5, 0x14, 0x6d, 0x16, 0x42, 0xcc, 0xaf, 0x71, 0x59, 0x98, + 0x08, 0xe5, 0xdd, 0x09, 0xc3, 0x4b, 0xb2, 0x98, 0x53, 0x35, 0x4c, 0x07, 0x3c, 0x60, 0xc1, 0x0c, + 0x54, 0x26, 0x0a, 0x92, 0xbc, 0xe9, 0x53, 0xea, 0x0f, 0x88, 0x9a, 0x47, 0x6e, 0x7a, 0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19, 0x29, 0xc2, 0xb7, 0x91, + 0x22, 0xbc, 0xde, 0xf5, 0x03, 0xfe, 0x26, 0x75, 0xb1, 0x47, 0x43, 0xb5, 0x7c, 0xf6, 0xf9, 0x67, + 0x97, 0xf5, 0xaf, 0x54, 0x9e, 0xc5, 0x64, 0xfe, 0x5f, 0xe2, 0xae, 0xe4, 0x8f, 0x66, 0xff, 0x67, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x02, 0x3d, 0xad, 0x03, 0x67, 0x04, 0x00, 0x00, } func (m *SignatureDescriptors) Marshal() (dAtA []byte, err error) { diff --git a/x/auth/client/cli/tx_sign.go b/x/auth/client/cli/tx_sign.go index 34483f9c935b..670a5f98609a 100644 --- a/x/auth/client/cli/tx_sign.go +++ b/x/auth/client/cli/tx_sign.go @@ -9,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" authclient "github.com/cosmos/cosmos-sdk/x/auth/client" ) @@ -234,9 +235,13 @@ func makeSignCmd() func(cmd *cobra.Command, args []string) error { overwrite, _ := f.GetBool(flagOverwrite) if multisig != "" { - multisigAddr, _, _, err := client.GetFromFields(txFactory.Keybase(), multisig, clientCtx.GenerateOnly) + multisigAddr, err := sdk.AccAddressFromBech32(multisig) if err != nil { - return fmt.Errorf("error getting account from keybase: %w", err) + // Bech32 decode error, maybe it's a name, we try to fetch from keyring + multisigAddr, _, _, err = client.GetFromFields(txFactory.Keybase(), multisig, clientCtx.GenerateOnly) + if err != nil { + return fmt.Errorf("error getting account from keybase: %w", err) + } } err = authclient.SignTxWithSignerAddress( txF, clientCtx, multisigAddr, fromName, txBuilder, clientCtx.Offline, overwrite) diff --git a/x/auth/client/testutil/suite.go b/x/auth/client/testutil/suite.go index 626e0130f42a..07b70900ce94 100644 --- a/x/auth/client/testutil/suite.go +++ b/x/auth/client/testutil/suite.go @@ -811,6 +811,47 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() { s.Require().NoError(s.network.WaitForNextBlock()) } +func (s *IntegrationTestSuite) TestSignWithMultisig() { + val1 := s.network.Validators[0] + + // Generate a account for signing. + account1, err := val1.ClientCtx.Keyring.Key("newAccount1") + s.Require().NoError(err) + + addr1 := account1.GetAddress() + s.Require().NoError(err) + + // Create an address that is not in the keyring, will be used to simulate `--multisig` + multisig := "cosmos1hd6fsrvnz6qkp87s3u86ludegq97agxsdkwzyh" + multisigAddr, err := sdk.AccAddressFromBech32(multisig) + s.Require().NoError(err) + + // Generate a transaction for testing --multisig with an address not in the keyring. + multisigTx, err := bankcli.MsgSendExec( + val1.ClientCtx, + val1.Address, + val1.Address, + sdk.NewCoins( + sdk.NewInt64Coin(s.cfg.BondDenom, 5), + ), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), + 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) + + // Save multi tx to file + multiGeneratedTx2File := testutil.WriteToNewTempFile(s.T(), multisigTx.String()) + + // Sign using multisig. We're signing a tx on behalf of the multisig address, + // even though the tx signer is NOT the multisig address. This is fine though, + // as the main point of this test is to test the `--multisig` flag with an address + // that is not in the keyring. + _, err = TxSignExec(val1.ClientCtx, addr1, multiGeneratedTx2File.Name(), "--multisig", multisigAddr.String()) + s.Require().Contains(err.Error(), "tx intended signer does not match the given signer") +} + func (s *IntegrationTestSuite) TestCLIMultisign() { val1 := s.network.Validators[0] diff --git a/x/auth/tx/config.go b/x/auth/tx/config.go index 8402423dbf77..b80e8dde0889 100644 --- a/x/auth/tx/config.go +++ b/x/auth/tx/config.go @@ -23,9 +23,16 @@ type config struct { // NewTxConfig returns a new protobuf TxConfig using the provided ProtoCodec and sign modes. The // first enabled sign mode will become the default sign mode. +// NOTE: Use NewTxConfigWithHandler to provide a custom signing handler in case the sign mode +// is not supported by default (eg: SignMode_SIGN_MODE_EIP_191). func NewTxConfig(protoCodec codec.ProtoCodecMarshaler, enabledSignModes []signingtypes.SignMode) client.TxConfig { + return NewTxConfigWithHandler(protoCodec, makeSignModeHandler(enabledSignModes)) +} + +// NewTxConfig returns a new protobuf TxConfig using the provided ProtoCodec and signing handler. +func NewTxConfigWithHandler(protoCodec codec.ProtoCodecMarshaler, handler signing.SignModeHandler) client.TxConfig { return &config{ - handler: makeSignModeHandler(enabledSignModes), + handler: handler, decoder: DefaultTxDecoder(protoCodec), encoder: DefaultTxEncoder(), jsonDecoder: DefaultJSONTxDecoder(protoCodec), diff --git a/x/auth/vesting/types/period.go b/x/auth/vesting/types/period.go index a3b32fcaf7b3..045c142a3ce7 100644 --- a/x/auth/vesting/types/period.go +++ b/x/auth/vesting/types/period.go @@ -3,23 +3,55 @@ package types import ( "fmt" "strings" + "time" yaml "gopkg.in/yaml.v2" + + sdk "github.com/cosmos/cosmos-sdk/types" ) // Periods stores all vesting periods passed as part of a PeriodicVestingAccount type Periods []Period -// String Period implements stringer interface +// Duration is converts the period Length from seconds to a time.Duration +func (p Period) Duration() time.Duration { + return time.Duration(p.Length) * time.Second +} + +// String implements the fmt.Stringer interface func (p Period) String() string { out, _ := yaml.Marshal(p) return string(out) } -// String Periods implements stringer interface -func (vp Periods) String() string { - periodsListString := make([]string, len(vp)) - for _, period := range vp { +// TotalLength return the total length in seconds for a period +func (p Periods) TotalLength() int64 { + var total int64 + for _, period := range p { + total += period.Length + } + return total +} + +// TotalDuration returns the total duration of the period +func (p Periods) TotalDuration() time.Duration { + len := p.TotalLength() + return time.Duration(len) * time.Second +} + +// TotalDuration returns the sum of coins for the period +func (p Periods) TotalAmount() sdk.Coins { + total := sdk.Coins{} + for _, period := range p { + total = total.Add(period.Amount...) + } + return total +} + +// String implements the fmt.Stringer interface +func (p Periods) String() string { + periodsListString := make([]string, len(p)) + for _, period := range p { periodsListString = append(periodsListString, period.String()) } diff --git a/x/authz/authz.pb.go b/x/authz/authz.pb.go index 34fe197e01db..772152fe565f 100644 --- a/x/authz/authz.pb.go +++ b/x/authz/authz.pb.go @@ -109,15 +109,58 @@ func (m *Grant) XXX_DiscardUnknown() { var xxx_messageInfo_Grant proto.InternalMessageInfo +// GrantAuthorization extends a grant with both the addresses of the grantee and granter. +// It is used in genesis.proto and query.proto +type GrantAuthorization struct { + Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` + Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` + Authorization *types.Any `protobuf:"bytes,3,opt,name=authorization,proto3" json:"authorization,omitempty"` + Expiration time.Time `protobuf:"bytes,4,opt,name=expiration,proto3,stdtime" json:"expiration"` +} + +func (m *GrantAuthorization) Reset() { *m = GrantAuthorization{} } +func (m *GrantAuthorization) String() string { return proto.CompactTextString(m) } +func (*GrantAuthorization) ProtoMessage() {} +func (*GrantAuthorization) Descriptor() ([]byte, []int) { + return fileDescriptor_544dc2e84b61c637, []int{2} +} +func (m *GrantAuthorization) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GrantAuthorization) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GrantAuthorization.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GrantAuthorization) XXX_Merge(src proto.Message) { + xxx_messageInfo_GrantAuthorization.Merge(m, src) +} +func (m *GrantAuthorization) XXX_Size() int { + return m.Size() +} +func (m *GrantAuthorization) XXX_DiscardUnknown() { + xxx_messageInfo_GrantAuthorization.DiscardUnknown(m) +} + +var xxx_messageInfo_GrantAuthorization proto.InternalMessageInfo + func init() { proto.RegisterType((*GenericAuthorization)(nil), "cosmos.authz.v1beta1.GenericAuthorization") proto.RegisterType((*Grant)(nil), "cosmos.authz.v1beta1.Grant") + proto.RegisterType((*GrantAuthorization)(nil), "cosmos.authz.v1beta1.GrantAuthorization") } func init() { proto.RegisterFile("cosmos/authz/v1beta1/authz.proto", fileDescriptor_544dc2e84b61c637) } var fileDescriptor_544dc2e84b61c637 = []byte{ - // 303 bytes of a gzipped FileDescriptorProto + // 343 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x48, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x2c, 0x2d, 0xc9, 0xa8, 0xd2, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0x84, 0xf0, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0x44, 0x20, 0x2a, 0xf4, 0x20, 0x62, 0x50, @@ -132,11 +175,14 @@ var fileDescriptor_544dc2e84b61c637 = []byte{ 0x41, 0x6c, 0xd6, 0x83, 0xd9, 0xac, 0xe7, 0x98, 0x57, 0xe9, 0x24, 0x78, 0x0a, 0xdd, 0xa4, 0x20, 0x54, 0xdd, 0x42, 0x2e, 0x5c, 0x5c, 0xa9, 0x15, 0x05, 0x99, 0x45, 0x10, 0xb3, 0x98, 0xc0, 0x66, 0x49, 0x61, 0x98, 0x15, 0x02, 0xf3, 0xbc, 0x13, 0xc7, 0x89, 0x7b, 0xf2, 0x0c, 0x13, 0xee, 0xcb, - 0x33, 0x06, 0x21, 0xe9, 0x73, 0x72, 0x3a, 0xf1, 0x50, 0x8e, 0xe1, 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, 0x54, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, - 0xa1, 0x81, 0x0c, 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x2b, 0x20, 0x11, 0x95, 0xc4, 0x06, 0xb6, - 0xcd, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, 0x6e, 0xbe, 0xf1, 0x5a, 0xcd, 0x01, 0x00, 0x00, + 0x33, 0x06, 0x21, 0xe9, 0x53, 0xba, 0xcb, 0xc8, 0x25, 0x04, 0x76, 0x1e, 0xaa, 0xd7, 0x24, 0xb8, + 0xd8, 0xd3, 0x41, 0xa2, 0xa9, 0x45, 0x50, 0xef, 0xc1, 0xb8, 0x08, 0x99, 0x54, 0xb0, 0x9d, 0x70, + 0x99, 0x54, 0x4c, 0xff, 0x31, 0x53, 0xd1, 0x7f, 0x2c, 0xe4, 0xf9, 0xcf, 0xc9, 0xe9, 0xc4, 0x43, + 0x39, 0x86, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, + 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x49, 0xcf, 0x2c, + 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0x85, 0x26, 0x22, 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, + 0x5f, 0x01, 0x49, 0x88, 0x49, 0x6c, 0x60, 0xdb, 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xf5, + 0xd2, 0x8f, 0xb0, 0xad, 0x02, 0x00, 0x00, } func (m *GenericAuthorization) Marshal() (dAtA []byte, err error) { @@ -212,6 +258,63 @@ func (m *Grant) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *GrantAuthorization) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GrantAuthorization) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GrantAuthorization) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Expiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Expiration):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintAuthz(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x22 + if m.Authorization != nil { + { + size, err := m.Authorization.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintAuthz(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0x12 + } + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintAuthz(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintAuthz(dAtA []byte, offset int, v uint64) int { offset -= sovAuthz(v) base := offset @@ -251,6 +354,29 @@ func (m *Grant) Size() (n int) { return n } +func (m *GrantAuthorization) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovAuthz(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovAuthz(uint64(l)) + } + if m.Authorization != nil { + l = m.Authorization.Size() + n += 1 + l + sovAuthz(uint64(l)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Expiration) + n += 1 + l + sovAuthz(uint64(l)) + return n +} + func sovAuthz(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -458,6 +584,189 @@ func (m *Grant) Unmarshal(dAtA []byte) error { } return nil } +func (m *GrantAuthorization) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: GrantAuthorization: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GrantAuthorization: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", 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.Granter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", 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.Grantee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Authorization", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthz + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Authorization == nil { + m.Authorization = &types.Any{} + } + if err := m.Authorization.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAuthz + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAuthz + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAuthz + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Expiration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAuthz(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAuthz + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipAuthz(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/authz/client/cli/query.go b/x/authz/client/cli/query.go index c8772b2aaa46..dfc997c445e4 100644 --- a/x/authz/client/cli/query.go +++ b/x/authz/client/cli/query.go @@ -27,6 +27,8 @@ func GetQueryCmd() *cobra.Command { authorizationQueryCmd.AddCommand( GetCmdQueryGrants(), + GetQueryGranterGrants(), + GetQueryGranteeGrants(), ) return authorizationQueryCmd @@ -91,3 +93,99 @@ $ %s query %s grants cosmos1skjw.. cosmos1skjwj.. %s flags.AddPaginationFlagsToCmd(cmd, "grants") return cmd } + +func GetQueryGranterGrants() *cobra.Command { + cmd := &cobra.Command{ + Use: "granter-grants [granter-addr]", + Args: cobra.ExactArgs(1), + Short: "query authorization grants granted by granter", + Long: strings.TrimSpace( + fmt.Sprintf(`Query authorization grants granted by granter. +Examples: +$ %s q %s granter-grants cosmos1skj.. +`, + version.AppName, authz.ModuleName), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + granter, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := authz.NewQueryClient(clientCtx) + res, err := queryClient.GranterGrants( + cmd.Context(), + &authz.QueryGranterGrantsRequest{ + Granter: granter.String(), + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "granter-grants") + return cmd +} + +func GetQueryGranteeGrants() *cobra.Command { + cmd := &cobra.Command{ + Use: "grantee-grants [grantee-addr]", + Args: cobra.ExactArgs(1), + Short: "query authorization grants granted to a grantee", + Long: strings.TrimSpace( + fmt.Sprintf(`Query authorization grants granted to a grantee. +Examples: +$ %s q %s grantee-grants cosmos1skj.. +`, + version.AppName, authz.ModuleName), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + grantee, err := sdk.AccAddressFromBech32(args[0]) + if err != nil { + return err + } + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := authz.NewQueryClient(clientCtx) + res, err := queryClient.GranteeGrants( + cmd.Context(), + &authz.QueryGranteeGrantsRequest{ + Grantee: grantee.String(), + Pagination: pageReq, + }, + ) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "grantee-grants") + return cmd +} diff --git a/x/authz/client/rest/grpc_query_test.go b/x/authz/client/rest/grpc_query_test.go index 614e283a15ed..af6e940d75d5 100644 --- a/x/authz/client/rest/grpc_query_test.go +++ b/x/authz/client/rest/grpc_query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package rest_test @@ -218,7 +219,9 @@ func (s *IntegrationTestSuite) TestQueryGrantsGRPC() { tc := tc s.Run(tc.name, func() { tc.preRun() - resp, _ := rest.GetRequest(tc.url) + resp, err := rest.GetRequest(tc.url) + s.Require().NoError(err) + if tc.expectErr { s.Require().Contains(string(resp), tc.errMsg) } else { @@ -232,6 +235,108 @@ func (s *IntegrationTestSuite) TestQueryGrantsGRPC() { } } -func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) +func (s *IntegrationTestSuite) TestQueryGranterGrantsGRPC() { + val := s.network.Validators[0] + grantee := s.grantee[1] + require := s.Require() + + testCases := []struct { + name string + url string + expectErr bool + errMsg string + numItems int + }{ + { + "invalid account address", + fmt.Sprintf("%s/cosmos/authz/v1beta1/grants/granter/%s", val.APIAddress, "invalid address"), + true, + "decoding bech32 failed", + 0, + }, + { + "no authorizations found", + fmt.Sprintf("%s/cosmos/authz/v1beta1/grants/granter/%s", val.APIAddress, grantee.String()), + false, + "", + 0, + }, + { + "valid query", + fmt.Sprintf("%s/cosmos/authz/v1beta1/grants/granter/%s", val.APIAddress, val.Address.String()), + false, + "", + 7, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + resp, err := rest.GetRequest(tc.url) + require.NoError(err) + + if tc.expectErr { + require.Contains(string(resp), tc.errMsg) + } else { + var authorizations authz.QueryGranterGrantsResponse + err := val.ClientCtx.Codec.UnmarshalJSON(resp, &authorizations) + require.NoError(err) + // FIXME: https://github.com/cosmos/cosmos-sdk/issues/10965 + require.Len(authorizations.Grants, tc.numItems) + } + + }) + } +} + +func (s *IntegrationTestSuite) TestQueryGranteeGrantsGRPC() { + val := s.network.Validators[0] + grantee := s.grantee[1] + require := s.Require() + + testCases := []struct { + name string + url string + expectErr bool + errMsg string + numItems int + }{ + { + "invalid account address", + fmt.Sprintf("%s/cosmos/authz/v1beta1/grants/grantee/%s", val.APIAddress, "invalid address"), + true, + "decoding bech32 failed", + 0, + }, + { + "no authorizations found", + fmt.Sprintf("%s/cosmos/authz/v1beta1/grants/grantee/%s", val.APIAddress, val.Address.String()), + false, + "", + 0, + }, + { + "valid query", + fmt.Sprintf("%s/cosmos/authz/v1beta1/grants/grantee/%s", val.APIAddress, grantee.String()), + false, + "", + 1, + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + resp, err := rest.GetRequest(tc.url) + require.NoError(err) + + if tc.expectErr { + require.Contains(string(resp), tc.errMsg) + } else { + var authorizations authz.QueryGranteeGrantsResponse + err := val.ClientCtx.Codec.UnmarshalJSON(resp, &authorizations) + require.NoError(err) + // FIXME: https://github.com/cosmos/cosmos-sdk/issues/10965 + require.Len(authorizations.Grants, tc.numItems) + } + + }) + } } diff --git a/x/authz/client/testutil/cli_test.go b/x/authz/client/testutil/cli_test.go index 3c083e694726..5b3ef61c5a45 100644 --- a/x/authz/client/testutil/cli_test.go +++ b/x/authz/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/authz/genesis.pb.go b/x/authz/genesis.pb.go index eb6b63d4c72b..56f2157a92ee 100644 --- a/x/authz/genesis.pb.go +++ b/x/authz/genesis.pb.go @@ -5,23 +5,17 @@ package authz import ( fmt "fmt" - types "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/regen-network/cosmos-proto" - _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" - time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf -var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -74,78 +68,8 @@ func (m *GenesisState) GetAuthorization() []GrantAuthorization { return nil } -// GrantAuthorization defines the GenesisState/GrantAuthorization type. -type GrantAuthorization struct { - Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` - Grantee string `protobuf:"bytes,2,opt,name=grantee,proto3" json:"grantee,omitempty"` - Authorization *types.Any `protobuf:"bytes,3,opt,name=authorization,proto3" json:"authorization,omitempty"` - Expiration time.Time `protobuf:"bytes,4,opt,name=expiration,proto3,stdtime" json:"expiration"` -} - -func (m *GrantAuthorization) Reset() { *m = GrantAuthorization{} } -func (m *GrantAuthorization) String() string { return proto.CompactTextString(m) } -func (*GrantAuthorization) ProtoMessage() {} -func (*GrantAuthorization) Descriptor() ([]byte, []int) { - return fileDescriptor_4c2fbb971da7c892, []int{1} -} -func (m *GrantAuthorization) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GrantAuthorization) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GrantAuthorization.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *GrantAuthorization) XXX_Merge(src proto.Message) { - xxx_messageInfo_GrantAuthorization.Merge(m, src) -} -func (m *GrantAuthorization) XXX_Size() int { - return m.Size() -} -func (m *GrantAuthorization) XXX_DiscardUnknown() { - xxx_messageInfo_GrantAuthorization.DiscardUnknown(m) -} - -var xxx_messageInfo_GrantAuthorization proto.InternalMessageInfo - -func (m *GrantAuthorization) GetGranter() string { - if m != nil { - return m.Granter - } - return "" -} - -func (m *GrantAuthorization) GetGrantee() string { - if m != nil { - return m.Grantee - } - return "" -} - -func (m *GrantAuthorization) GetAuthorization() *types.Any { - if m != nil { - return m.Authorization - } - return nil -} - -func (m *GrantAuthorization) GetExpiration() time.Time { - if m != nil { - return m.Expiration - } - return time.Time{} -} - func init() { proto.RegisterType((*GenesisState)(nil), "cosmos.authz.v1beta1.GenesisState") - proto.RegisterType((*GrantAuthorization)(nil), "cosmos.authz.v1beta1.GrantAuthorization") } func init() { @@ -153,29 +77,20 @@ func init() { } var fileDescriptor_4c2fbb971da7c892 = []byte{ - // 337 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xbb, 0x6e, 0xc2, 0x30, - 0x14, 0x8d, 0x0b, 0xea, 0xc3, 0x94, 0xa1, 0x11, 0x43, 0xca, 0x60, 0x10, 0xea, 0x90, 0x05, 0x5b, - 0xd0, 0xbd, 0x12, 0x51, 0x25, 0xa6, 0x2e, 0x94, 0xa9, 0x4b, 0xe5, 0x80, 0x6b, 0xac, 0x36, 0x31, - 0x8a, 0x4d, 0x05, 0x7c, 0x05, 0x1f, 0xd3, 0x8f, 0x40, 0x9d, 0x18, 0xbb, 0xf4, 0x21, 0xf8, 0x91, - 0x2a, 0x76, 0xa2, 0xf2, 0xe8, 0x94, 0x7b, 0x73, 0xce, 0x3d, 0xe7, 0xf8, 0xda, 0xb0, 0x31, 0x90, - 0x2a, 0x92, 0x8a, 0xd0, 0x89, 0x1e, 0xcd, 0xc9, 0x6b, 0x2b, 0x64, 0x9a, 0xb6, 0x08, 0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b6, 0xe6, 0x82, 0x9b, 0xe5, 0x1a, 0x81, 0xd5, 0x1a, 0x81, 0x9f, 0x35, - 0x02, 0x8b, 0x0d, 0x72, 0x56, 0x1b, 0xe4, 0x7c, 0x6c, 0x90, 0xf3, 0x70, 0xc5, 0x85, 0x1e, 0x4d, - 0x42, 0x3c, 0x90, 0x51, 0xb6, 0xf8, 0xec, 0xd3, 0x54, 0xc3, 0x67, 0x32, 0xb5, 0xcf, 0x23, 0x3c, - 0x36, 0x4e, 0xd7, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7c, 0xdb, 0x6c, 0xcb, 0x35, 0x02, 0x00, - 0x00, + // 206 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4a, 0xce, 0x2f, 0xce, + 0xcd, 0x2f, 0xd6, 0x4f, 0x2c, 0x2d, 0xc9, 0xa8, 0xd2, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, + 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, + 0x81, 0xa8, 0xd1, 0x03, 0xab, 0xd1, 0x83, 0xaa, 0x91, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, + 0xd0, 0x07, 0xb1, 0x20, 0x6a, 0xa5, 0x14, 0xb0, 0x9a, 0x07, 0xd1, 0x09, 0x56, 0xa1, 0x94, 0xc2, + 0xc5, 0xe3, 0x0e, 0x31, 0x3e, 0xb8, 0x24, 0xb1, 0x24, 0x55, 0x28, 0x84, 0x8b, 0x17, 0x24, 0x9d, + 0x5f, 0x94, 0x59, 0x95, 0x58, 0x92, 0x99, 0x9f, 0x27, 0xc1, 0xa8, 0xc0, 0xac, 0xc1, 0x6d, 0xa4, + 0xa1, 0x87, 0xcd, 0x56, 0x3d, 0xf7, 0xa2, 0xc4, 0xbc, 0x12, 0x47, 0x64, 0xf5, 0x4e, 0x2c, 0x27, + 0xee, 0xc9, 0x33, 0x04, 0xa1, 0x1a, 0xe2, 0x64, 0x77, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, + 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, + 0x72, 0x0c, 0x51, 0x2a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x50, + 0xc7, 0x42, 0x28, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x0a, 0x88, 0x5b, 0x93, 0xd8, 0xc0, 0x8e, 0x35, + 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xb9, 0xd2, 0x41, 0x42, 0x20, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -215,63 +130,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *GrantAuthorization) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GrantAuthorization) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GrantAuthorization) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Expiration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Expiration):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintGenesis(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x22 - if m.Authorization != nil { - { - size, err := m.Authorization.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if len(m.Grantee) > 0 { - i -= len(m.Grantee) - copy(dAtA[i:], m.Grantee) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Grantee))) - i-- - dAtA[i] = 0x12 - } - if len(m.Granter) > 0 { - i -= len(m.Granter) - copy(dAtA[i:], m.Granter) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Granter))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -298,29 +156,6 @@ func (m *GenesisState) Size() (n int) { return n } -func (m *GrantAuthorization) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Granter) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - l = len(m.Grantee) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - if m.Authorization != nil { - l = m.Authorization.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Expiration) - n += 1 + l + sovGenesis(uint64(l)) - return n -} - func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -411,189 +246,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } -func (m *GrantAuthorization) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return 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 fmt.Errorf("proto: GrantAuthorization: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GrantAuthorization: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Granter = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Grantee = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Authorization", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Authorization == nil { - m.Authorization = &types.Any{} - } - if err := m.Authorization.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Expiration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Expiration, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/authz/keeper/grpc_query.go b/x/authz/keeper/grpc_query.go index 76091daaf7e9..6b114c19ba46 100644 --- a/x/authz/keeper/grpc_query.go +++ b/x/authz/keeper/grpc_query.go @@ -90,6 +90,109 @@ func (k Keeper) Grants(c context.Context, req *authz.QueryGrantsRequest) (*authz }, nil } +// GranterGrants implements the Query/GranterGrants gRPC method. +func (k Keeper) GranterGrants(c context.Context, req *authz.QueryGranterGrantsRequest) (*authz.QueryGranterGrantsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + granter, err := sdk.AccAddressFromBech32(req.Granter) + if err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(c) + store := ctx.KVStore(k.storeKey) + authzStore := prefix.NewStore(store, grantStoreKey(nil, granter, "")) + + var grants []*authz.GrantAuthorization + pageRes, err := query.FilteredPaginate(authzStore, req.Pagination, func(key []byte, value []byte, + accumulate bool) (bool, error) { + auth, err := unmarshalAuthorization(k.cdc, value) + if err != nil { + return false, err + } + + auth1 := auth.GetAuthorization() + if accumulate { + any, err := codectypes.NewAnyWithValue(auth1) + if err != nil { + return false, status.Errorf(codes.Internal, err.Error()) + } + + grantee := firstAddressFromGrantStoreKey(key) + grants = append(grants, &authz.GrantAuthorization{ + Granter: granter.String(), + Grantee: grantee.String(), + Authorization: any, + Expiration: auth.Expiration, + }) + } + return true, nil + }) + if err != nil { + return nil, err + } + + return &authz.QueryGranterGrantsResponse{ + Grants: grants, + Pagination: pageRes, + }, nil +} + +// GranteeGrants implements the Query/GranteeGrants gRPC method. +func (k Keeper) GranteeGrants(c context.Context, req *authz.QueryGranteeGrantsRequest) (*authz.QueryGranteeGrantsResponse, error) { + if req == nil { + return nil, status.Errorf(codes.InvalidArgument, "empty request") + } + + grantee, err := sdk.AccAddressFromBech32(req.Grantee) + if err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(c) + store := prefix.NewStore(ctx.KVStore(k.storeKey), GrantKey) + + var authorizations []*authz.GrantAuthorization + pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key []byte, value []byte, + accumulate bool) (bool, error) { + auth, err := unmarshalAuthorization(k.cdc, value) + if err != nil { + return false, err + } + + granter, g := addressesFromGrantStoreKey(append(GrantKey, key...)) + if !g.Equals(grantee) { + return false, nil + } + + auth1 := auth.GetAuthorization() + if accumulate { + any, err := codectypes.NewAnyWithValue(auth1) + if err != nil { + return false, status.Errorf(codes.Internal, err.Error()) + } + + authorizations = append(authorizations, &authz.GrantAuthorization{ + Authorization: any, + Expiration: auth.Expiration, + Granter: granter.String(), + Grantee: grantee.String(), + }) + } + return true, nil + }) + if err != nil { + return nil, err + } + + return &authz.QueryGranteeGrantsResponse{ + Grants: authorizations, + Pagination: pageRes, + }, nil +} + // unmarshal an authorization from a store value func unmarshalAuthorization(cdc codec.BinaryCodec, value []byte) (v authz.Grant, err error) { err = cdc.Unmarshal(value, &v) diff --git a/x/authz/keeper/grpc_query_test.go b/x/authz/keeper/grpc_query_test.go index 37ddb7cf84c0..f10163b27a24 100644 --- a/x/authz/keeper/grpc_query_test.go +++ b/x/authz/keeper/grpc_query_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" "github.com/cosmos/cosmos-sdk/x/authz" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -162,3 +163,155 @@ func (suite *TestSuite) TestGRPCQueryAuthorizations() { }) } } + +func (suite *TestSuite) TestGRPCQueryGranterGrants() { + require := suite.Require() + app, ctx, queryClient, addrs := suite.app, suite.ctx, suite.queryClient, suite.addrs + + testCases := []struct { + msg string + preRun func() + expError bool + request authz.QueryGranterGrantsRequest + numItems int + }{ + { + "fail invalid granter addr", + func() {}, + true, + authz.QueryGranterGrantsRequest{}, + 0, + }, + { + "valid case, single authorization", + func() { + now := ctx.BlockHeader().Time + newCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100)) + authorization := &banktypes.SendAuthorization{SpendLimit: newCoins} + err := app.AuthzKeeper.SaveGrant(ctx, addrs[1], addrs[0], authorization, now.Add(time.Hour)) + require.NoError(err) + }, + false, + authz.QueryGranterGrantsRequest{ + Granter: addrs[0].String(), + }, + 1, + }, + { + "valid case, multiple authorization", + func() { + now := ctx.BlockHeader().Time + newCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100)) + authorization := &banktypes.SendAuthorization{SpendLimit: newCoins} + err := app.AuthzKeeper.SaveGrant(ctx, addrs[2], addrs[0], authorization, now.Add(time.Hour)) + require.NoError(err) + }, + false, + authz.QueryGranterGrantsRequest{ + Granter: addrs[0].String(), + }, + 2, + }, + { + "valid case, pagination", + func() {}, + false, + authz.QueryGranterGrantsRequest{ + Granter: addrs[0].String(), + Pagination: &query.PageRequest{ + Limit: 1, + }, + }, + 1, + }, + } + + for _, tc := range testCases { + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + tc.preRun() + result, err := queryClient.GranterGrants(gocontext.Background(), &tc.request) + if tc.expError { + require.Error(err) + } else { + require.NoError(err) + require.Len(result.Grants, tc.numItems) + } + }) + } +} + +func (suite *TestSuite) TestGRPCQueryGranteeGrants() { + require := suite.Require() + app, ctx, queryClient, addrs := suite.app, suite.ctx, suite.queryClient, suite.addrs + + testCases := []struct { + msg string + preRun func() + expError bool + request authz.QueryGranteeGrantsRequest + numItems int + }{ + { + "fail invalid granter addr", + func() {}, + true, + authz.QueryGranteeGrantsRequest{}, + 0, + }, + { + "valid case, single authorization", + func() { + now := ctx.BlockHeader().Time + newCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100)) + authorization := &banktypes.SendAuthorization{SpendLimit: newCoins} + err := app.AuthzKeeper.SaveGrant(ctx, addrs[0], addrs[1], authorization, now.Add(time.Hour)) + require.NoError(err) + }, + false, + authz.QueryGranteeGrantsRequest{ + Grantee: addrs[0].String(), + }, + 1, + }, + { + "valid case, multiple authorization", + func() { + now := ctx.BlockHeader().Time + newCoins := sdk.NewCoins(sdk.NewInt64Coin("steak", 100)) + authorization := &banktypes.SendAuthorization{SpendLimit: newCoins} + err := app.AuthzKeeper.SaveGrant(ctx, addrs[0], addrs[2], authorization, now.Add(time.Hour)) + require.NoError(err) + }, + false, + authz.QueryGranteeGrantsRequest{ + Grantee: addrs[0].String(), + }, + 2, + }, + { + "valid case, pagination", + func() {}, + false, + authz.QueryGranteeGrantsRequest{ + Grantee: addrs[0].String(), + Pagination: &query.PageRequest{ + Limit: 1, + }, + }, + 1, + }, + } + + for _, tc := range testCases { + suite.Run(fmt.Sprintf("Case %s", tc.msg), func() { + tc.preRun() + result, err := queryClient.GranteeGrants(gocontext.Background(), &tc.request) + if tc.expError { + require.Error(err) + } else { + require.NoError(err) + require.Len(result.Grants, tc.numItems) + } + }) + } +} diff --git a/x/authz/keeper/keys.go b/x/authz/keeper/keys.go index 3bdd02138efb..0ffd7ba32cc1 100644 --- a/x/authz/keeper/keys.go +++ b/x/authz/keeper/keys.go @@ -45,3 +45,9 @@ func addressesFromGrantStoreKey(key []byte) (granterAddr, granteeAddr sdk.AccAdd return granterAddr, granteeAddr } + +// firstAddressFromGrantStoreKey parses the first address only +func firstAddressFromGrantStoreKey(key []byte) sdk.AccAddress { + addrLen := key[0] + return sdk.AccAddress(key[1 : 1+addrLen]) +} diff --git a/x/authz/query.pb.go b/x/authz/query.pb.go index 3e332ef64453..e7b570453896 100644 --- a/x/authz/query.pb.go +++ b/x/authz/query.pb.go @@ -155,39 +155,268 @@ func (m *QueryGrantsResponse) GetPagination() *query.PageResponse { return nil } +// QueryGranterGrantsRequest is the request type for the Query/GranterGrants RPC method. +type QueryGranterGrantsRequest struct { + Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` + // pagination defines an pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGranterGrantsRequest) Reset() { *m = QueryGranterGrantsRequest{} } +func (m *QueryGranterGrantsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGranterGrantsRequest) ProtoMessage() {} +func (*QueryGranterGrantsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_376d714ffdeb1545, []int{2} +} +func (m *QueryGranterGrantsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGranterGrantsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGranterGrantsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGranterGrantsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGranterGrantsRequest.Merge(m, src) +} +func (m *QueryGranterGrantsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGranterGrantsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGranterGrantsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGranterGrantsRequest proto.InternalMessageInfo + +func (m *QueryGranterGrantsRequest) GetGranter() string { + if m != nil { + return m.Granter + } + return "" +} + +func (m *QueryGranterGrantsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGranterGrantsResponse is the response type for the Query/GranterGrants RPC method. +type QueryGranterGrantsResponse struct { + // grants is a list of grants granted by the granter. + Grants []*GrantAuthorization `protobuf:"bytes,1,rep,name=grants,proto3" json:"grants,omitempty"` + // pagination defines an pagination for the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGranterGrantsResponse) Reset() { *m = QueryGranterGrantsResponse{} } +func (m *QueryGranterGrantsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGranterGrantsResponse) ProtoMessage() {} +func (*QueryGranterGrantsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_376d714ffdeb1545, []int{3} +} +func (m *QueryGranterGrantsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGranterGrantsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGranterGrantsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGranterGrantsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGranterGrantsResponse.Merge(m, src) +} +func (m *QueryGranterGrantsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGranterGrantsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGranterGrantsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGranterGrantsResponse proto.InternalMessageInfo + +func (m *QueryGranterGrantsResponse) GetGrants() []*GrantAuthorization { + if m != nil { + return m.Grants + } + return nil +} + +func (m *QueryGranterGrantsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGranteeGrantsRequest is the request type for the Query/IssuedGrants RPC method. +type QueryGranteeGrantsRequest struct { + Grantee string `protobuf:"bytes,1,opt,name=grantee,proto3" json:"grantee,omitempty"` + // pagination defines an pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGranteeGrantsRequest) Reset() { *m = QueryGranteeGrantsRequest{} } +func (m *QueryGranteeGrantsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGranteeGrantsRequest) ProtoMessage() {} +func (*QueryGranteeGrantsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_376d714ffdeb1545, []int{4} +} +func (m *QueryGranteeGrantsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGranteeGrantsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGranteeGrantsRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGranteeGrantsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGranteeGrantsRequest.Merge(m, src) +} +func (m *QueryGranteeGrantsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGranteeGrantsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGranteeGrantsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGranteeGrantsRequest proto.InternalMessageInfo + +func (m *QueryGranteeGrantsRequest) GetGrantee() string { + if m != nil { + return m.Grantee + } + return "" +} + +func (m *QueryGranteeGrantsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryGranteeGrantsResponse is the response type for the Query/GranteeGrants RPC method. +type QueryGranteeGrantsResponse struct { + // grants is a list of grants granted to the grantee. + Grants []*GrantAuthorization `protobuf:"bytes,1,rep,name=grants,proto3" json:"grants,omitempty"` + // pagination defines an pagination for the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGranteeGrantsResponse) Reset() { *m = QueryGranteeGrantsResponse{} } +func (m *QueryGranteeGrantsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGranteeGrantsResponse) ProtoMessage() {} +func (*QueryGranteeGrantsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_376d714ffdeb1545, []int{5} +} +func (m *QueryGranteeGrantsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGranteeGrantsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGranteeGrantsResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QueryGranteeGrantsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGranteeGrantsResponse.Merge(m, src) +} +func (m *QueryGranteeGrantsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGranteeGrantsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGranteeGrantsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGranteeGrantsResponse proto.InternalMessageInfo + +func (m *QueryGranteeGrantsResponse) GetGrants() []*GrantAuthorization { + if m != nil { + return m.Grants + } + return nil +} + +func (m *QueryGranteeGrantsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryGrantsRequest)(nil), "cosmos.authz.v1beta1.QueryGrantsRequest") proto.RegisterType((*QueryGrantsResponse)(nil), "cosmos.authz.v1beta1.QueryGrantsResponse") + proto.RegisterType((*QueryGranterGrantsRequest)(nil), "cosmos.authz.v1beta1.QueryGranterGrantsRequest") + proto.RegisterType((*QueryGranterGrantsResponse)(nil), "cosmos.authz.v1beta1.QueryGranterGrantsResponse") + proto.RegisterType((*QueryGranteeGrantsRequest)(nil), "cosmos.authz.v1beta1.QueryGranteeGrantsRequest") + proto.RegisterType((*QueryGranteeGrantsResponse)(nil), "cosmos.authz.v1beta1.QueryGranteeGrantsResponse") } func init() { proto.RegisterFile("cosmos/authz/v1beta1/query.proto", fileDescriptor_376d714ffdeb1545) } var fileDescriptor_376d714ffdeb1545 = []byte{ - // 381 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4f, 0xf2, 0x30, - 0x18, 0xc7, 0x29, 0xbc, 0x2f, 0xc6, 0xe2, 0xa9, 0x7a, 0x58, 0x90, 0x2c, 0x0b, 0x21, 0x3a, 0x4d, - 0xec, 0x02, 0xdc, 0x3d, 0x78, 0x90, 0xab, 0x2e, 0x7a, 0xf1, 0x42, 0x3a, 0x6c, 0xca, 0x22, 0x5b, - 0xc7, 0xda, 0x19, 0xf1, 0xa8, 0x67, 0x13, 0x13, 0xbe, 0x89, 0x9f, 0xc2, 0x23, 0x89, 0x17, 0x8f, - 0x06, 0xfc, 0x20, 0x86, 0xb6, 0x08, 0xc4, 0x25, 0x7a, 0x5a, 0xb6, 0xe7, 0xf7, 0xfc, 0x9f, 0x5f, - 0x9f, 0x15, 0x3a, 0x3d, 0x2e, 0x22, 0x2e, 0x3c, 0x92, 0xc9, 0xfe, 0xbd, 0x77, 0xdb, 0x0c, 0xa8, - 0x24, 0x4d, 0x6f, 0x98, 0xd1, 0x74, 0x84, 0x93, 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x04, 0xe0, 0x7f, - 0x65, 0x85, 0x1e, 0x01, 0x2c, 0x6b, 0x35, 0xe4, 0xe6, 0x2b, 0xfc, 0x5c, 0x79, 0xf5, 0xe0, 0x0f, - 0xa4, 0x9e, 0x5a, 0x6f, 0x3c, 0xbc, 0x7d, 0x8e, 0x8b, 0x36, 0xaa, 0x79, 0xb9, 0xff, 0x57, 0x1f, - 0xec, 0xe4, 0xf8, 0x75, 0x6a, 0x83, 0xc9, 0xd4, 0x06, 0x1f, 0x53, 0x1b, 0x3c, 0xcf, 0xec, 0xc2, - 0x64, 0x66, 0x17, 0xde, 0x67, 0x76, 0xe1, 0xaa, 0xc1, 0x42, 0xd9, 0xcf, 0x02, 0xdc, 0xe3, 0xd1, - 0x22, 0x41, 0x3f, 0x8e, 0xc4, 0xf5, 0x8d, 0x77, 0xa7, 0xe3, 0x82, 0xb2, 0xba, 0x21, 0xed, 0xaf, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xf2, 0x52, 0x9e, 0x65, 0xc7, 0x02, 0x00, 0x00, + // 495 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x94, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xc7, 0xeb, 0x16, 0x8a, 0xf0, 0xe0, 0x62, 0x38, 0x84, 0x30, 0x45, 0x51, 0x35, 0x41, 0x41, + 0xc2, 0xde, 0x3a, 0x89, 0x23, 0x02, 0x0e, 0xdb, 0x15, 0x2a, 0xb8, 0x70, 0x99, 0xdc, 0xf1, 0xc9, + 0x8d, 0x68, 0xe3, 0xcc, 0x76, 0x10, 0x1d, 0xea, 0x05, 0x5e, 0x00, 0x69, 0x0f, 0x81, 0xc4, 0x91, + 0xa7, 0xe0, 0x38, 0x89, 0x0b, 0x47, 0xd4, 0x22, 0xf1, 0x1a, 0xa8, 0xb6, 0x4b, 0x9b, 0x91, 0x6d, + 0x01, 0x34, 0x69, 0x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+ 0x70, 0x1a, 0xd5, 0xbe, 0x4d, 0xa3, 0xda, 0x8b, 0x35, 0x91, 0x98, 0x7e, 0xde, 0xa3, 0xbb, 0x72, + 0x38, 0xef, 0xe9, 0x7e, 0xee, 0xe9, 0x97, 0xaf, 0xd8, 0x1b, 0x37, 0xa0, 0xd7, 0xb4, 0xb7, 0xf9, + 0xe6, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6b, 0x01, 0xa4, 0x75, 0x73, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -204,6 +433,14 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Returns list of `Authorization`, granted to the grantee by the granter. Grants(ctx context.Context, in *QueryGrantsRequest, opts ...grpc.CallOption) (*QueryGrantsResponse, error) + // GranterGrants returns list of `GrantAuthorization`, granted by granter. + // + // Since: cosmos-sdk 0.46 + GranterGrants(ctx context.Context, in *QueryGranterGrantsRequest, opts ...grpc.CallOption) (*QueryGranterGrantsResponse, error) + // GranteeGrants returns a list of `GrantAuthorization` by grantee. + // + // Since: cosmos-sdk 0.46 + GranteeGrants(ctx context.Context, in *QueryGranteeGrantsRequest, opts ...grpc.CallOption) (*QueryGranteeGrantsResponse, error) } type queryClient struct { @@ -223,10 +460,36 @@ func (c *queryClient) Grants(ctx context.Context, in *QueryGrantsRequest, opts . return out, nil } +func (c *queryClient) GranterGrants(ctx context.Context, in *QueryGranterGrantsRequest, opts ...grpc.CallOption) (*QueryGranterGrantsResponse, error) { + out := new(QueryGranterGrantsResponse) + err := c.cc.Invoke(ctx, "/cosmos.authz.v1beta1.Query/GranterGrants", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GranteeGrants(ctx context.Context, in *QueryGranteeGrantsRequest, opts ...grpc.CallOption) (*QueryGranteeGrantsResponse, error) { + out := new(QueryGranteeGrantsResponse) + err := c.cc.Invoke(ctx, "/cosmos.authz.v1beta1.Query/GranteeGrants", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Returns list of `Authorization`, granted to the grantee by the granter. Grants(context.Context, *QueryGrantsRequest) (*QueryGrantsResponse, error) + // GranterGrants returns list of `GrantAuthorization`, granted by granter. + // + // Since: cosmos-sdk 0.46 + GranterGrants(context.Context, *QueryGranterGrantsRequest) (*QueryGranterGrantsResponse, error) + // GranteeGrants returns a list of `GrantAuthorization` by grantee. + // + // Since: cosmos-sdk 0.46 + GranteeGrants(context.Context, *QueryGranteeGrantsRequest) (*QueryGranteeGrantsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -236,6 +499,12 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Grants(ctx context.Context, req *QueryGrantsRequest) (*QueryGrantsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Grants not implemented") } +func (*UnimplementedQueryServer) GranterGrants(ctx context.Context, req *QueryGranterGrantsRequest) (*QueryGranterGrantsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GranterGrants not implemented") +} +func (*UnimplementedQueryServer) GranteeGrants(ctx context.Context, req *QueryGranteeGrantsRequest) (*QueryGranteeGrantsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GranteeGrants not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -259,6 +528,42 @@ func _Query_Grants_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_GranterGrants_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGranterGrantsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GranterGrants(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.authz.v1beta1.Query/GranterGrants", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GranterGrants(ctx, req.(*QueryGranterGrantsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GranteeGrants_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGranteeGrantsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GranteeGrants(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.authz.v1beta1.Query/GranteeGrants", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GranteeGrants(ctx, req.(*QueryGranteeGrantsRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.authz.v1beta1.Query", HandlerType: (*QueryServer)(nil), @@ -267,6 +572,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Grants", Handler: _Query_Grants_Handler, }, + { + MethodName: "GranterGrants", + Handler: _Query_GranterGrants_Handler, + }, + { + MethodName: "GranteeGrants", + Handler: _Query_GranteeGrants_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/authz/v1beta1/query.proto", @@ -377,68 +690,624 @@ func (m *QueryGrantsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *QueryGranterGrantsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *QueryGrantsRequest) Size() (n int) { - if m == nil { - return 0 - } + +func (m *QueryGranterGrantsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGranterGrantsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Granter) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.Grantee) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.MsgTypeUrl) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if len(m.Granter) > 0 { + i -= len(m.Granter) + copy(dAtA[i:], m.Granter) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Granter))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *QueryGrantsResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGranterGrantsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - if len(m.Grants) > 0 { - for _, e := range m.Grants { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + return dAtA[:n], nil +} + +func (m *QueryGranterGrantsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGranterGrantsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Grants) > 0 { + for iNdEx := len(m.Grants) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Grants[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryGranteeGrantsRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGranteeGrantsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGranteeGrantsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Grantee) > 0 { + i -= len(m.Grantee) + copy(dAtA[i:], m.Grantee) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Grantee))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGranteeGrantsResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QueryGranteeGrantsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGranteeGrantsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Grants) > 0 { + for iNdEx := len(m.Grants) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Grants[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryGrantsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.MsgTypeUrl) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGrantsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Grants) > 0 { + for _, e := range m.Grants { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGranterGrantsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Granter) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGranterGrantsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Grants) > 0 { + for _, e := range m.Grants { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGranteeGrantsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Grantee) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGranteeGrantsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Grants) > 0 { + for _, e := range m.Grants { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryGrantsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: QueryGrantsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGrantsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Granter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Granter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grantee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrl", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGrantsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: QueryGrantsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGrantsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grants", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grants = append(m.Grants, &Grant{}) + if err := m.Grants[len(m.Grants)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *QueryGrantsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryGranterGrantsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -461,10 +1330,10 @@ func (m *QueryGrantsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGrantsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGranterGrantsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGrantsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGranterGrantsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -501,9 +1370,9 @@ func (m *QueryGrantsRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowQuery @@ -513,27 +1382,201 @@ func (m *QueryGrantsRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthQuery } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthQuery } if postIndex > l { return io.ErrUnexpectedEOF } - m.Grantee = string(dAtA[iNdEx:postIndex]) + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGranterGrantsResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: QueryGranterGrantsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGranterGrantsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MsgTypeUrl", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Grants", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Grants = append(m.Grants, &GrantAuthorization{}) + if err := m.Grants[len(m.Grants)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGranteeGrantsRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: QueryGranteeGrantsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGranteeGrantsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Grantee", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -561,9 +1604,9 @@ func (m *QueryGrantsRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MsgTypeUrl = string(dAtA[iNdEx:postIndex]) + m.Grantee = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } @@ -620,7 +1663,7 @@ func (m *QueryGrantsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGrantsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryGranteeGrantsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -643,10 +1686,10 @@ func (m *QueryGrantsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGrantsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGranteeGrantsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGrantsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGranteeGrantsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -678,7 +1721,7 @@ func (m *QueryGrantsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Grants = append(m.Grants, &Grant{}) + m.Grants = append(m.Grants, &GrantAuthorization{}) if err := m.Grants[len(m.Grants)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/authz/query.pb.gw.go b/x/authz/query.pb.gw.go index 3278cb6baa3c..500a9b4a62d2 100644 --- a/x/authz/query.pb.gw.go +++ b/x/authz/query.pb.gw.go @@ -67,6 +67,150 @@ func local_request_Query_Grants_0(ctx context.Context, marshaler runtime.Marshal } +var ( + filter_Query_GranterGrants_0 = &utilities.DoubleArray{Encoding: map[string]int{"granter": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_GranterGrants_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGranterGrantsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["granter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "granter") + } + + protoReq.Granter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "granter", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GranterGrants_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GranterGrants(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GranterGrants_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGranterGrantsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["granter"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "granter") + } + + protoReq.Granter, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "granter", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GranterGrants_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GranterGrants(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_GranteeGrants_0 = &utilities.DoubleArray{Encoding: map[string]int{"grantee": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_GranteeGrants_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGranteeGrantsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["grantee"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "grantee") + } + + protoReq.Grantee, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "grantee", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GranteeGrants_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GranteeGrants(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GranteeGrants_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGranteeGrantsRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["grantee"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "grantee") + } + + protoReq.Grantee, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "grantee", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GranteeGrants_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GranteeGrants(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -93,6 +237,46 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_GranterGrants_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GranterGrants_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GranterGrants_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GranteeGrants_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GranteeGrants_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GranteeGrants_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -154,13 +338,61 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_GranterGrants_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GranterGrants_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GranterGrants_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GranteeGrants_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GranteeGrants_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GranteeGrants_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } var ( pattern_Query_Grants_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "authz", "v1beta1", "grants"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GranterGrants_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "authz", "v1beta1", "grants", "granter"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_GranteeGrants_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "authz", "v1beta1", "grants", "grantee"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Grants_0 = runtime.ForwardResponseMessage + + forward_Query_GranterGrants_0 = runtime.ForwardResponseMessage + + forward_Query_GranteeGrants_0 = runtime.ForwardResponseMessage ) diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index b2a5f20d4d90..9b8e060f0766 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -1,11 +1,8 @@ package simulation import ( - "fmt" "math/rand" - "github.com/gogo/protobuf/proto" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -227,6 +224,10 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "no grant found"), nil, nil } + if targetGrant.Expiration.Before(ctx.BlockHeader().Time) { + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "grant expired"), nil, nil + } + grantee, ok := simtypes.FindAccount(accs, granteeAddr) if !ok { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgRevoke, "Account not found"), nil, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "grantee account not found") @@ -236,42 +237,42 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe return simtypes.NoOpMsg(authz.ModuleName, TypeMsgRevoke, "Account not found"), nil, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "granter account not found") } - if targetGrant.Expiration.Before(ctx.BlockHeader().Time) { - return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "grant expired"), nil, nil - } - - coins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(int64(simtypes.RandIntBetween(r, 100, 1000000))))) - + granterspendableCoins := bk.SpendableCoins(ctx, granterAddr) + coins := simtypes.RandSubsetCoins(r, granterspendableCoins) // Check send_enabled status of each sent coin denom if err := bk.IsSendEnabledCoins(ctx, coins...); err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, nil } - if targetGrant.Authorization.TypeUrl == fmt.Sprintf("/%s", proto.MessageName(&banktype.SendAuthorization{})) { - sendAuthorization := targetGrant.GetAuthorization().(*banktype.SendAuthorization) - if sendAuthorization.SpendLimit.IsAllLT(coins) { - return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "over spend limit"), nil, nil - } + msg := []sdk.Msg{banktype.NewMsgSend(granterAddr, granteeAddr, coins)} + authorization := targetGrant.GetAuthorization() + + sendAuth, ok := authorization.(*banktype.SendAuthorization) + if !ok { + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "not a send authorization"), nil, nil } - granterspendableCoins := bk.SpendableCoins(ctx, granterAddr) - if granterspendableCoins.IsAllLTE(coins) { - return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "insufficient funds"), nil, nil + _, err := sendAuth.Accept(ctx, msg[0]) + if err != nil { + if sdkerrors.ErrInsufficientFunds.Is(err) { + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, nil + } else { + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, err + } } + msgExec := authz.NewMsgExec(granteeAddr, msg) granteeSpendableCoins := bk.SpendableCoins(ctx, granteeAddr) fees, err := simtypes.RandomFees(r, ctx, granteeSpendableCoins) if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "fee error"), nil, err } - msg := authz.NewMsgExec(granteeAddr, []sdk.Msg{banktype.NewMsgSend(granterAddr, granteeAddr, coins)}) txCfg := simappparams.MakeTestEncodingConfig().TxConfig granteeAcc := ak.GetAccount(ctx, granteeAddr) - tx, err := helpers.GenTx( txCfg, - []sdk.Msg{&msg}, + []sdk.Msg{&msgExec}, fees, helpers.DefaultGenTxGas, chainID, @@ -288,10 +289,10 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, err } - err = msg.UnpackInterfaces(cdc) + err = msgExec.UnpackInterfaces(cdc) if err != nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, "unmarshal error"), nil, err } - return simtypes.NewOperationMsg(&msg, true, "success", nil), nil, nil + return simtypes.NewOperationMsg(&msgExec, true, "success", nil), nil, nil } } diff --git a/x/bank/client/cli/query.go b/x/bank/client/cli/query.go index 4019bb738d9a..a9cdadb9753d 100644 --- a/x/bank/client/cli/query.go +++ b/x/bank/client/cli/query.go @@ -208,6 +208,7 @@ To query for the total supply of a specific coin denomination use: cmd.Flags().String(FlagDenom, "", "The specific balance denomination to query for") flags.AddQueryFlagsToCmd(cmd) + flags.AddPaginationFlagsToCmd(cmd, "all supply totals") return cmd } diff --git a/x/bank/client/testutil/suite.go b/x/bank/client/testutil/suite.go index 19be5401c672..445612881e37 100644 --- a/x/bank/client/testutil/suite.go +++ b/x/bank/client/testutil/suite.go @@ -184,7 +184,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryTotalSupply() { sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), s.cfg.AccountTokens), sdk.NewCoin(s.cfg.BondDenom, s.cfg.StakingTokens.Add(sdk.NewInt(10))), ), - Pagination: &query.PageResponse{Total: 2}, + Pagination: &query.PageResponse{Total: 0}, }, }, { diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 02655aa2f595..e8576d12d629 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -76,6 +76,42 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances return &types.QueryAllBalancesResponse{Balances: balances, Pagination: pageRes}, nil } +// SpendableBalances implements a gRPC query handler for retrieving an account's +// spendable balances. +func (k BaseKeeper) SpendableBalances(ctx context.Context, req *types.QuerySpendableBalancesRequest) (*types.QuerySpendableBalancesResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + + addr, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "invalid address: %s", err.Error()) + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + + balances := sdk.NewCoins() + accountStore := k.getAccountStore(sdkCtx, addr) + zeroAmt := sdk.ZeroInt() + + pageRes, err := query.Paginate(accountStore, req.Pagination, func(key, value []byte) error { + balances = append(balances, sdk.NewCoin(string(key), zeroAmt)) + return nil + }) + if err != nil { + return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + } + + result := sdk.NewCoins() + spendable := k.SpendableCoins(sdkCtx, addr) + + for _, c := range balances { + result = append(result, sdk.NewCoin(c.Denom, spendable.AmountOf(c.Denom))) + } + + return &types.QuerySpendableBalancesResponse{Balances: result, Pagination: pageRes}, nil +} + // TotalSupply implements the Query/TotalSupply gRPC method func (k BaseKeeper) TotalSupply(ctx context.Context, req *types.QueryTotalSupplyRequest) (*types.QueryTotalSupplyResponse, error) { sdkCtx := sdk.UnwrapSDKContext(ctx) diff --git a/x/bank/keeper/grpc_query_test.go b/x/bank/keeper/grpc_query_test.go index 181506a6d7fb..affc6f822d4a 100644 --- a/x/bank/keeper/grpc_query_test.go +++ b/x/bank/keeper/grpc_query_test.go @@ -3,15 +3,17 @@ package keeper_test import ( gocontext "context" "fmt" + "time" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" - - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/bank/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) func (suite *IntegrationTestSuite) TestQueryBalance() { @@ -86,6 +88,56 @@ func (suite *IntegrationTestSuite) TestQueryAllBalances() { suite.Nil(res.Pagination.NextKey) } +func (suite *IntegrationTestSuite) TestSpendableBalances() { + app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient + _, _, addr := testdata.KeyTestPubAddr() + ctx = ctx.WithBlockTime(time.Now()) + + _, err := queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), &types.QuerySpendableBalancesRequest{}) + suite.Require().Error(err) + + pageReq := &query.PageRequest{ + Key: nil, + Limit: 2, + CountTotal: false, + } + req := types.NewQuerySpendableBalancesRequest(addr, pageReq) + + res, err := queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), req) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.True(res.Balances.IsZero()) + + fooCoins := newFooCoin(50) + barCoins := newBarCoin(30) + + origCoins := sdk.NewCoins(fooCoins, barCoins) + acc := app.AccountKeeper.NewAccountWithAddress(ctx, addr) + acc = vestingtypes.NewContinuousVestingAccount( + acc.(*authtypes.BaseAccount), + sdk.NewCoins(fooCoins), + ctx.BlockTime().Unix(), + ctx.BlockTime().Add(time.Hour).Unix(), + ) + + app.AccountKeeper.SetAccount(ctx, acc) + suite.Require().NoError(simapp.FundAccount(app.BankKeeper, ctx, acc.GetAddress(), 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) + + res, err = queryClient.SpendableBalances(sdk.WrapSDKContext(ctx), req) + suite.Require().NoError(err) + suite.Require().NotNil(res) + suite.Equal(2, res.Balances.Len()) + suite.Nil(res.Pagination.NextKey) + suite.EqualValues(30, res.Balances[0].Amount.Int64()) + suite.EqualValues(25, res.Balances[1].Amount.Int64()) +} + func (suite *IntegrationTestSuite) TestQueryTotalSupply() { app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient expectedTotalSupply := sdk.NewCoins(sdk.NewInt64Coin("test", 400000000)) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index ac7877346a9f..e4deabc8acbb 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -5,11 +5,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/types/query" - - "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -18,11 +13,14 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "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" + "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/bank/keeper" "github.com/cosmos/cosmos-sdk/x/bank/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" ) const ( @@ -97,7 +95,7 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str func (suite *IntegrationTestSuite) SetupTest() { app := simapp.Setup(false) - ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) app.BankKeeper.SetParams(ctx, types.DefaultParams()) diff --git a/x/bank/types/querier.go b/x/bank/types/querier.go index 1ef0093386e4..117b87f17c68 100644 --- a/x/bank/types/querier.go +++ b/x/bank/types/querier.go @@ -25,6 +25,13 @@ func NewQueryAllBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *Qu return &QueryAllBalancesRequest{Address: addr.String(), Pagination: req} } +// NewQuerySpendableBalancesRequest creates a new instance of a +// QuerySpendableBalancesRequest. +// nolint:interfacer +func NewQuerySpendableBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QuerySpendableBalancesRequest { + return &QuerySpendableBalancesRequest{Address: addr.String(), Pagination: req} +} + // QueryTotalSupplyParams defines the params for the following queries: // // - 'custom/bank/totalSupply' diff --git a/x/bank/types/query.pb.go b/x/bank/types/query.pb.go index 0b9ebea6cb6d..e81ca6b3b6fc 100644 --- a/x/bank/types/query.pb.go +++ b/x/bank/types/query.pb.go @@ -216,6 +216,104 @@ func (m *QueryAllBalancesResponse) GetPagination() *query.PageResponse { return nil } +// QuerySpendableBalancesRequest defines the gRPC request structure for querying +// an account's spendable balances. +type QuerySpendableBalancesRequest struct { + // address is the address to query spendable balances for. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySpendableBalancesRequest) Reset() { *m = QuerySpendableBalancesRequest{} } +func (m *QuerySpendableBalancesRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySpendableBalancesRequest) ProtoMessage() {} +func (*QuerySpendableBalancesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6fc1939682df13, []int{4} +} +func (m *QuerySpendableBalancesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpendableBalancesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpendableBalancesRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySpendableBalancesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpendableBalancesRequest.Merge(m, src) +} +func (m *QuerySpendableBalancesRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySpendableBalancesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpendableBalancesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpendableBalancesRequest proto.InternalMessageInfo + +// QuerySpendableBalancesResponse defines the gRPC response structure for querying +// an account's spendable balances. +type QuerySpendableBalancesResponse struct { + // balances is the spendable balances of all the coins. + Balances github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=balances,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"balances"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySpendableBalancesResponse) Reset() { *m = QuerySpendableBalancesResponse{} } +func (m *QuerySpendableBalancesResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySpendableBalancesResponse) ProtoMessage() {} +func (*QuerySpendableBalancesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_9c6fc1939682df13, []int{5} +} +func (m *QuerySpendableBalancesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySpendableBalancesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySpendableBalancesResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *QuerySpendableBalancesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySpendableBalancesResponse.Merge(m, src) +} +func (m *QuerySpendableBalancesResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySpendableBalancesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySpendableBalancesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySpendableBalancesResponse proto.InternalMessageInfo + +func (m *QuerySpendableBalancesResponse) GetBalances() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Balances + } + return nil +} + +func (m *QuerySpendableBalancesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + // QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC // method. type QueryTotalSupplyRequest struct { @@ -229,7 +327,7 @@ func (m *QueryTotalSupplyRequest) Reset() { *m = QueryTotalSupplyRequest func (m *QueryTotalSupplyRequest) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyRequest) ProtoMessage() {} func (*QueryTotalSupplyRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{4} + return fileDescriptor_9c6fc1939682df13, []int{6} } func (m *QueryTotalSupplyRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -273,7 +371,7 @@ func (m *QueryTotalSupplyResponse) Reset() { *m = QueryTotalSupplyRespon func (m *QueryTotalSupplyResponse) String() string { return proto.CompactTextString(m) } func (*QueryTotalSupplyResponse) ProtoMessage() {} func (*QueryTotalSupplyResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{5} + return fileDescriptor_9c6fc1939682df13, []int{7} } func (m *QueryTotalSupplyResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -326,7 +424,7 @@ func (m *QuerySupplyOfRequest) Reset() { *m = QuerySupplyOfRequest{} } func (m *QuerySupplyOfRequest) String() string { return proto.CompactTextString(m) } func (*QuerySupplyOfRequest) ProtoMessage() {} func (*QuerySupplyOfRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{6} + return fileDescriptor_9c6fc1939682df13, []int{8} } func (m *QuerySupplyOfRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -372,7 +470,7 @@ func (m *QuerySupplyOfResponse) Reset() { *m = QuerySupplyOfResponse{} } func (m *QuerySupplyOfResponse) String() string { return proto.CompactTextString(m) } func (*QuerySupplyOfResponse) ProtoMessage() {} func (*QuerySupplyOfResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{7} + return fileDescriptor_9c6fc1939682df13, []int{9} } func (m *QuerySupplyOfResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -416,7 +514,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{8} + return fileDescriptor_9c6fc1939682df13, []int{10} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -454,7 +552,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{9} + return fileDescriptor_9c6fc1939682df13, []int{11} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -500,7 +598,7 @@ func (m *QueryDenomsMetadataRequest) Reset() { *m = QueryDenomsMetadataR func (m *QueryDenomsMetadataRequest) String() string { return proto.CompactTextString(m) } func (*QueryDenomsMetadataRequest) ProtoMessage() {} func (*QueryDenomsMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{10} + return fileDescriptor_9c6fc1939682df13, []int{12} } func (m *QueryDenomsMetadataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -549,7 +647,7 @@ func (m *QueryDenomsMetadataResponse) Reset() { *m = QueryDenomsMetadata func (m *QueryDenomsMetadataResponse) String() string { return proto.CompactTextString(m) } func (*QueryDenomsMetadataResponse) ProtoMessage() {} func (*QueryDenomsMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{11} + return fileDescriptor_9c6fc1939682df13, []int{13} } func (m *QueryDenomsMetadataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -602,7 +700,7 @@ func (m *QueryDenomMetadataRequest) Reset() { *m = QueryDenomMetadataReq func (m *QueryDenomMetadataRequest) String() string { return proto.CompactTextString(m) } func (*QueryDenomMetadataRequest) ProtoMessage() {} func (*QueryDenomMetadataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{12} + return fileDescriptor_9c6fc1939682df13, []int{14} } func (m *QueryDenomMetadataRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -649,7 +747,7 @@ func (m *QueryDenomMetadataResponse) Reset() { *m = QueryDenomMetadataRe func (m *QueryDenomMetadataResponse) String() string { return proto.CompactTextString(m) } func (*QueryDenomMetadataResponse) ProtoMessage() {} func (*QueryDenomMetadataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_9c6fc1939682df13, []int{13} + return fileDescriptor_9c6fc1939682df13, []int{15} } func (m *QueryDenomMetadataResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -690,6 +788,8 @@ func init() { proto.RegisterType((*QueryBalanceResponse)(nil), "cosmos.bank.v1beta1.QueryBalanceResponse") proto.RegisterType((*QueryAllBalancesRequest)(nil), "cosmos.bank.v1beta1.QueryAllBalancesRequest") proto.RegisterType((*QueryAllBalancesResponse)(nil), "cosmos.bank.v1beta1.QueryAllBalancesResponse") + proto.RegisterType((*QuerySpendableBalancesRequest)(nil), "cosmos.bank.v1beta1.QuerySpendableBalancesRequest") + proto.RegisterType((*QuerySpendableBalancesResponse)(nil), "cosmos.bank.v1beta1.QuerySpendableBalancesResponse") proto.RegisterType((*QueryTotalSupplyRequest)(nil), "cosmos.bank.v1beta1.QueryTotalSupplyRequest") proto.RegisterType((*QueryTotalSupplyResponse)(nil), "cosmos.bank.v1beta1.QueryTotalSupplyResponse") proto.RegisterType((*QuerySupplyOfRequest)(nil), "cosmos.bank.v1beta1.QuerySupplyOfRequest") @@ -705,59 +805,63 @@ func init() { func init() { proto.RegisterFile("cosmos/bank/v1beta1/query.proto", fileDescriptor_9c6fc1939682df13) } var fileDescriptor_9c6fc1939682df13 = []byte{ - // 829 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0x4d, 0x6b, 0x13, 0x5b, - 0x18, 0xce, 0xe9, 0xbd, 0x4d, 0xd3, 0x37, 0xdc, 0xbb, 0x38, 0xcd, 0xe5, 0xa6, 0xd3, 0xdb, 0xe4, - 0x32, 0xd5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 0xa5, 0x6a, 0xb7, 0x76, 0x68, 0x04, 0xda, 0x1d, 0x28, 0xed, 0xba, 0xa6, 0x49, 0xed, 0xca, 0x10, - 0x65, 0x3c, 0xf2, 0x3b, 0x94, 0x93, 0xad, 0x47, 0xa7, 0x5b, 0x56, 0xbe, 0xdb, 0x82, 0xc4, 0xe6, - 0x7d, 0x25, 0x5a, 0x67, 0x27, 0x90, 0x6f, 0x27, 0xf4, 0x02, 0xfc, 0xd3, 0x93, 0x2d, 0x49, 0x5f, - 0x80, 0x28, 0xa9, 0xd3, 0xa6, 0xe3, 0x0d, 0xdd, 0x84, 0xfc, 0x9f, 0x6d, 0xd2, 0x45, 0x99, 0xae, - 0x27, 0x00, 0xf3, 0x8e, 0x05, 0xd2, 0x20, 0x75, 0xb5, 0x08, 0x7a, 0x41, 0xae, 0xb0, 0x8a, 0xca, - 0x29, 0x97, 0x20, 0xea, 0xf2, 0x88, 0x9c, 0x32, 0x63, 0x04, 0xf8, 0x93, 0x21, 0x8a, 0xd4, 0x1c, - 0x51, 0xa0, 0x57, 0x40, 0xe3, 0x1d, 0xaf, 0xb6, 0x79, 0xb0, 0x9b, 0x96, 0x47, 0x2a, 0xc4, 0x23, - 0x23, 0x7e, 0x45, 0xf4, 0xf7, 0x08, 0x66, 0x02, 0xc7, 0x48, 0x02, 0xeb, 0x30, 0x59, 0x97, 0x31, - 0xb5, 0x58, 0xb3, 0x81, 0x1c, 0x54, 0xa5, 0x64, 0x71, 0x52, 0x35, 0xba, 0x93, 0x5f, 0x85, 0xe9, - 0x13, 0xa8, 0xbd, 0x82, 0x04, 0x1f, 0xff, 0x3d, 0xbf, 0x88, 0x7d, 0xe4, 0xae, 0x40, 0x4c, 0xc1, - 0x94, 0x12, 0x86, 0xe2, 0xd6, 0x29, 0xca, 0x7d, 0x8c, 0xc1, 0x38, 0xef, 0x8f, 0x5f, 0x23, 0x98, - 0x90, 0xa6, 0x84, 0x33, 0x81, 0x4d, 0x02, 0x1c, 0x5e, 0x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xd6, - 0x2c, 0xc7, 0x3a, 0x8f, 0xcf, 0x84, 0xc1, 0x9a, 0xdf, 0x38, 0x38, 0x4a, 0xa1, 0xc3, 0xa3, 0x14, - 0xfa, 0x7e, 0x94, 0x42, 0x2f, 0x8f, 0x53, 0x91, 0xc3, 0xe3, 0x54, 0xe4, 0xcb, 0x71, 0x2a, 0x72, - 0x77, 0x71, 0xe0, 0x67, 0xf5, 0x91, 0x68, 0xcb, 0xbf, 0xae, 0xa5, 0x28, 0xff, 0xeb, 0xb8, 0xf6, - 0x2b, 0x00, 0x00, 0xff, 0xff, 0xb5, 0x6f, 0x29, 0xd7, 0x12, 0x0b, 0x00, 0x00, + // 896 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x97, 0x5d, 0x6b, 0x23, 0x55, + 0x18, 0xc7, 0x73, 0xaa, 0x4d, 0xd3, 0x27, 0x28, 0x78, 0x1a, 0x31, 0x9d, 0xda, 0x89, 0x4c, 0xb5, + 0x4d, 0x6b, 0x3a, 0xd3, 0x24, 0x82, 0xd6, 0x1b, 0x69, 0x2a, 0x7a, 0x21, 0xd2, 0x98, 0x7a, 0x25, + 0x48, 0x39, 0x49, 0xc6, 0x31, 0x34, 0x99, 0x33, 0xcd, 0x99, 0x88, 0xa1, 0x14, 0x44, 0x10, 0x04, + 0x41, 0x05, 0x6f, 0x04, 0x6f, 0xea, 0x8d, 0xa0, 0x5f, 0xc0, 0xaf, 0xd0, 0x8b, 0xbd, 0x28, 0xbb, + 0x37, 0x7b, 0xb5, 0xbb, 0xb4, 0x7b, 0xb1, 0x37, 0xfb, 0x1d, 0x96, 0x9c, 0x97, 0x74, 0x92, 0x4c, + 0x92, 0x59, 0xc8, 0xb2, 0xec, 0x55, 0x93, 0x33, 0xcf, 0xcb, 0xef, 0xf9, 0x9f, 0x33, 0xff, 0x93, + 0x42, 0xa6, 0x46, 0x59, 0x8b, 0x32, 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x4a, 0x47, 0x97, + 0x57, 0x3a, 0x7a, 0x70, 0xa5, 0xa3, 0xdf, 0xaf, 0xf5, 0xd8, 0xe5, 0xb5, 0x1e, 0xbb, 0x7b, 0xad, + 0xc7, 0xbe, 0xda, 0x9c, 0xf8, 0x83, 0xe0, 0x7b, 0x51, 0x96, 0xff, 0x2e, 0xa8, 0xc6, 0xf9, 0xff, + 0x15, 0xc5, 0x27, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd1, 0xfd, 0x88, 0xa1, 0x2f, 0x0d, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -776,6 +880,9 @@ type QueryClient interface { Balance(ctx context.Context, in *QueryBalanceRequest, opts ...grpc.CallOption) (*QueryBalanceResponse, error) // AllBalances queries the balance of all coins for a single account. AllBalances(ctx context.Context, in *QueryAllBalancesRequest, opts ...grpc.CallOption) (*QueryAllBalancesResponse, error) + // SpendableBalances queries the spenable balance of all coins for a single + // account. + SpendableBalances(ctx context.Context, in *QuerySpendableBalancesRequest, opts ...grpc.CallOption) (*QuerySpendableBalancesResponse, error) // TotalSupply queries the total supply of all coins. TotalSupply(ctx context.Context, in *QueryTotalSupplyRequest, opts ...grpc.CallOption) (*QueryTotalSupplyResponse, error) // SupplyOf queries the supply of a single coin. @@ -814,6 +921,15 @@ func (c *queryClient) AllBalances(ctx context.Context, in *QueryAllBalancesReque return out, nil } +func (c *queryClient) SpendableBalances(ctx context.Context, in *QuerySpendableBalancesRequest, opts ...grpc.CallOption) (*QuerySpendableBalancesResponse, error) { + out := new(QuerySpendableBalancesResponse) + err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/SpendableBalances", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *queryClient) TotalSupply(ctx context.Context, in *QueryTotalSupplyRequest, opts ...grpc.CallOption) (*QueryTotalSupplyResponse, error) { out := new(QueryTotalSupplyResponse) err := c.cc.Invoke(ctx, "/cosmos.bank.v1beta1.Query/TotalSupply", in, out, opts...) @@ -865,6 +981,9 @@ type QueryServer interface { Balance(context.Context, *QueryBalanceRequest) (*QueryBalanceResponse, error) // AllBalances queries the balance of all coins for a single account. AllBalances(context.Context, *QueryAllBalancesRequest) (*QueryAllBalancesResponse, error) + // SpendableBalances queries the spenable balance of all coins for a single + // account. + SpendableBalances(context.Context, *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error) // TotalSupply queries the total supply of all coins. TotalSupply(context.Context, *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) // SupplyOf queries the supply of a single coin. @@ -887,6 +1006,9 @@ func (*UnimplementedQueryServer) Balance(ctx context.Context, req *QueryBalanceR func (*UnimplementedQueryServer) AllBalances(ctx context.Context, req *QueryAllBalancesRequest) (*QueryAllBalancesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AllBalances not implemented") } +func (*UnimplementedQueryServer) SpendableBalances(ctx context.Context, req *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SpendableBalances not implemented") +} func (*UnimplementedQueryServer) TotalSupply(ctx context.Context, req *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TotalSupply not implemented") } @@ -943,6 +1065,24 @@ func _Query_AllBalances_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Query_SpendableBalances_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySpendableBalancesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).SpendableBalances(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.bank.v1beta1.Query/SpendableBalances", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).SpendableBalances(ctx, req.(*QuerySpendableBalancesRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Query_TotalSupply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryTotalSupplyRequest) if err := dec(in); err != nil { @@ -1045,6 +1185,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "AllBalances", Handler: _Query_AllBalances_Handler, }, + { + MethodName: "SpendableBalances", + Handler: _Query_SpendableBalances_Handler, + }, { MethodName: "TotalSupply", Handler: _Query_TotalSupply_Handler, @@ -1233,6 +1377,97 @@ func (m *QueryAllBalancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *QuerySpendableBalancesRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySpendableBalancesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpendableBalancesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QuerySpendableBalancesResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *QuerySpendableBalancesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySpendableBalancesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Balances) > 0 { + for iNdEx := len(m.Balances) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Balances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryTotalSupplyRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1660,6 +1895,42 @@ func (m *QueryAllBalancesResponse) Size() (n int) { return n } +func (m *QuerySpendableBalancesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySpendableBalancesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Balances) > 0 { + for _, e := range m.Balances { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QueryTotalSupplyRequest) Size() (n int) { if m == nil { return 0 @@ -2236,6 +2507,244 @@ func (m *QueryAllBalancesResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QuerySpendableBalancesRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: QuerySpendableBalancesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpendableBalancesRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySpendableBalancesResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return 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 fmt.Errorf("proto: QuerySpendableBalancesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySpendableBalancesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balances", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Balances = append(m.Balances, types.Coin{}) + if err := m.Balances[len(m.Balances)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryTotalSupplyRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/bank/types/query.pb.gw.go b/x/bank/types/query.pb.gw.go index 4cd12b258912..a6ea74de978b 100644 --- a/x/bank/types/query.pb.gw.go +++ b/x/bank/types/query.pb.gw.go @@ -175,6 +175,78 @@ func local_request_Query_AllBalances_0(ctx context.Context, marshaler runtime.Ma } +var ( + filter_Query_SpendableBalances_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_SpendableBalances_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySpendableBalancesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpendableBalances_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.SpendableBalances(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_SpendableBalances_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySpendableBalancesRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_SpendableBalances_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.SpendableBalances(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_Query_TotalSupply_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -419,6 +491,26 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_SpendableBalances_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_SpendableBalances_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_SpendableBalances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_TotalSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -600,6 +692,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_SpendableBalances_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_SpendableBalances_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_SpendableBalances_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_Query_TotalSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -708,6 +820,8 @@ var ( pattern_Query_AllBalances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "balances", "address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_SpendableBalances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "spendable_balances", "address"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_TotalSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "bank", "v1beta1", "supply"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_SupplyOf_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "bank", "v1beta1", "supply", "denom"}, "", runtime.AssumeColonVerbOpt(false))) @@ -724,6 +838,8 @@ var ( forward_Query_AllBalances_0 = runtime.ForwardResponseMessage + forward_Query_SpendableBalances_0 = runtime.ForwardResponseMessage + forward_Query_TotalSupply_0 = runtime.ForwardResponseMessage forward_Query_SupplyOf_0 = runtime.ForwardResponseMessage diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index be347b745b05..379ff1a3fccd 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -162,6 +162,10 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o w := bytes.NewBuffer([]byte{}) clientCtx = clientCtx.WithOutput(w) + if err = msg.ValidateBasic(); err != nil { + return err + } + if err = authclient.PrintUnsignedStdTx(txBldr, clientCtx, []sdk.Msg{msg}); err != nil { return errors.Wrap(err, "failed to print unsigned std tx") } diff --git a/x/genutil/client/testutil/suite.go b/x/genutil/client/testutil/suite.go index 084a5f530f8d..5ef4d7ca2c5b 100644 --- a/x/genutil/client/testutil/suite.go +++ b/x/genutil/client/testutil/suite.go @@ -1,18 +1,16 @@ package testutil import ( - "context" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "github.com/stretchr/testify/suite" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -48,84 +46,97 @@ func (s *IntegrationTestSuite) TearDownSuite() { func (s *IntegrationTestSuite) TestGenTxCmd() { val := s.network.Validators[0] - dir := s.T().TempDir() - - cmd := cli.GenTxCmd( - simapp.ModuleBasics, - val.ClientCtx.TxConfig, banktypes.GenesisBalancesIterator{}, val.ClientCtx.HomeDir) - - _, out := testutil.ApplyMockIO(cmd) - clientCtx := val.ClientCtx.WithOutput(out) - - ctx := context.Background() - ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) - + clientCtx := val.ClientCtx amount := sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(12)) - genTxFile := filepath.Join(dir, "myTx") - cmd.SetArgs([]string{ - fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), - fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, genTxFile), - val.Moniker, - amount.String(), - }) - - err := cmd.ExecuteContext(ctx) - s.Require().NoError(err) - - // validate generated transaction. - open, err := os.Open(genTxFile) - s.Require().NoError(err) - - all, err := ioutil.ReadAll(open) - s.Require().NoError(err) - - tx, err := val.ClientCtx.TxConfig.TxJSONDecoder()(all) - s.Require().NoError(err) - - msgs := tx.GetMsgs() - s.Require().Len(msgs, 1) - - s.Require().Equal(sdk.MsgTypeURL(&types.MsgCreateValidator{}), sdk.MsgTypeURL(msgs[0])) - s.Require().Equal([]sdk.AccAddress{val.Address}, msgs[0].GetSigners()) - s.Require().Equal(amount, msgs[0].(*types.MsgCreateValidator).Value) - s.Require().NoError(tx.ValidateBasic()) -} - -func (s *IntegrationTestSuite) TestGenTxCmdPubkey() { - val := s.network.Validators[0] - dir := s.T().TempDir() - - cmd := cli.GenTxCmd( - simapp.ModuleBasics, - val.ClientCtx.TxConfig, - banktypes.GenesisBalancesIterator{}, - val.ClientCtx.HomeDir, - ) - - _, out := testutil.ApplyMockIO(cmd) - clientCtx := val.ClientCtx.WithOutput(out) - ctx := context.Background() - ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) - - amount := sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(12)) - genTxFile := filepath.Join(dir, "myTx") - - cmd.SetArgs([]string{ - fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), - fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, genTxFile), - fmt.Sprintf("--%s={\"key\":\"BOIkjkFruMpfOFC9oNPhiJGfmY2pHF/gwHdLDLnrnS0=\"}", stakingcli.FlagPubKey), - val.Moniker, - amount.String(), - }) - s.Require().Error(cmd.ExecuteContext(ctx)) - - cmd.SetArgs([]string{ - fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), - fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, genTxFile), - fmt.Sprintf("--%s={\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"BOIkjkFruMpfOFC9oNPhiJGfmY2pHF/gwHdLDLnrnS0=\"}", stakingcli.FlagPubKey), - val.Moniker, - amount.String(), - }) - s.Require().NoError(cmd.ExecuteContext(ctx)) + tests := []struct { + name string + args []string + expError bool + }{ + { + name: "invalid commission rate returns error", + args: []string{ + fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), + fmt.Sprintf("--%s=1", stakingcli.FlagCommissionRate), + val.Moniker, + amount.String(), + }, + expError: true, + }, + { + name: "valid gentx", + args: []string{ + fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), + val.Moniker, + amount.String(), + }, + expError: false, + }, + { + name: "invalid pubkey", + args: []string{ + fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), + fmt.Sprintf("--%s={\"key\":\"BOIkjkFruMpfOFC9oNPhiJGfmY2pHF/gwHdLDLnrnS0=\"}", stakingcli.FlagPubKey), + val.Moniker, + amount.String(), + }, + expError: true, + }, + { + name: "valid pubkey flag", + args: []string{ + fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), + fmt.Sprintf("--%s={\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"BOIkjkFruMpfOFC9oNPhiJGfmY2pHF/gwHdLDLnrnS0=\"}", stakingcli.FlagPubKey), + val.Moniker, + amount.String(), + }, + expError: false, + }, + } + + for _, tc := range tests { + tc := tc + + dir := s.T().TempDir() + genTxFile := filepath.Join(dir, "myTx") + tc.args = append(tc.args, fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, genTxFile)) + + s.Run(tc.name, func() { + cmd := cli.GenTxCmd( + simapp.ModuleBasics, + val.ClientCtx.TxConfig, + banktypes.GenesisBalancesIterator{}, + val.ClientCtx.HomeDir) + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expError { + s.Require().Error(err) + + _, err = os.Open(genTxFile) + s.Require().Error(err) + } else { + s.Require().NoError(err, "test: %s\noutput: %s", tc.name, out.String()) + + // validate generated transaction. + open, err := os.Open(genTxFile) + s.Require().NoError(err) + + all, err := io.ReadAll(open) + s.Require().NoError(err) + + tx, err := val.ClientCtx.TxConfig.TxJSONDecoder()(all) + s.Require().NoError(err) + + msgs := tx.GetMsgs() + s.Require().Len(msgs, 1) + + s.Require().Equal(sdk.MsgTypeURL(&types.MsgCreateValidator{}), sdk.MsgTypeURL(msgs[0])) + s.Require().True(val.Address.Equals(msgs[0].GetSigners()[0])) + s.Require().Equal(amount, msgs[0].(*types.MsgCreateValidator).Value) + s.Require().NoError(tx.ValidateBasic()) + } + }) + } } diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index 8de5bc4afe41..35390d823e9b 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -64,7 +64,7 @@ func (suite *GenTxTestSuite) setAccountBalance(addr sdk.AccAddress, amount int64 acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) suite.app.AccountKeeper.SetAccount(suite.ctx, acc) - err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 25)}) + err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, amount)}) suite.Require().NoError(err) bankGenesisState := suite.app.BankKeeper.ExportGenesis(suite.ctx) @@ -230,7 +230,7 @@ func (suite *GenTxTestSuite) TestDeliverGenTxs() { "success", func() { _ = suite.setAccountBalance(addr1, 50) - _ = suite.setAccountBalance(addr2, 0) + _ = suite.setAccountBalance(addr2, 1) msg := banktypes.NewMsgSend(addr1, addr2, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1)}) tx, err := helpers.GenTx( diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 6ed92e37aab9..438e160d1454 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking/types" ) -// return a specific delegation +// GetDelegation returns a specific delegation. func (k Keeper) GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation types.Delegation, found bool) { store := ctx.KVStore(k.storeKey) @@ -26,7 +26,7 @@ func (k Keeper) GetDelegation(ctx sdk.Context, return delegation, true } -// IterateAllDelegations iterate through all of the delegations +// IterateAllDelegations iterates through all of the delegations. func (k Keeper) IterateAllDelegations(ctx sdk.Context, cb func(delegation types.Delegation) (stop bool)) { store := ctx.KVStore(k.storeKey) @@ -41,7 +41,7 @@ func (k Keeper) IterateAllDelegations(ctx sdk.Context, cb func(delegation types. } } -// GetAllDelegations returns all delegations used during genesis dump +// GetAllDelegations returns all delegations used during genesis dump. func (k Keeper) GetAllDelegations(ctx sdk.Context) (delegations []types.Delegation) { k.IterateAllDelegations(ctx, func(delegation types.Delegation) bool { delegations = append(delegations, delegation) @@ -51,7 +51,8 @@ func (k Keeper) GetAllDelegations(ctx sdk.Context) (delegations []types.Delegati return delegations } -// return all delegations to a specific validator. Useful for querier. +// GetValidatorDelegations returns all delegations to a specific validator. +// Useful for querier. func (k Keeper) GetValidatorDelegations(ctx sdk.Context, valAddr sdk.ValAddress) (delegations []types.Delegation) { //nolint:interfacer store := ctx.KVStore(k.storeKey) @@ -68,7 +69,8 @@ func (k Keeper) GetValidatorDelegations(ctx sdk.Context, valAddr sdk.ValAddress) return delegations } -// return a given amount of all the delegations from a delegator +// GetDelegatorDelegations returns a given amount of all the delegations from a +// delegator. func (k Keeper) GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) (delegations []types.Delegation) { delegations = make([]types.Delegation, maxRetrieve) @@ -88,7 +90,7 @@ func (k Keeper) GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddres return delegations[:i] // trim if the array length < maxRetrieve } -// set a delegation +// SetDelegation sets a delegation. func (k Keeper) SetDelegation(ctx sdk.Context, delegation types.Delegation) { delegatorAddress, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) if err != nil { @@ -100,7 +102,7 @@ func (k Keeper) SetDelegation(ctx sdk.Context, delegation types.Delegation) { store.Set(types.GetDelegationKey(delegatorAddress, delegation.GetValidatorAddr()), b) } -// remove a delegation +// RemoveDelegation removes a delegation. func (k Keeper) RemoveDelegation(ctx sdk.Context, delegation types.Delegation) { delegatorAddress, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) if err != nil { @@ -112,7 +114,7 @@ func (k Keeper) RemoveDelegation(ctx sdk.Context, delegation types.Delegation) { store.Delete(types.GetDelegationKey(delegatorAddress, delegation.GetValidatorAddr())) } -// return a given amount of all the delegator unbonding-delegations +// GetUnbondingDelegations returns a given amount of all the delegator unbonding-delegations. func (k Keeper) GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) (unbondingDelegations []types.UnbondingDelegation) { unbondingDelegations = make([]types.UnbondingDelegation, maxRetrieve) @@ -133,7 +135,7 @@ func (k Keeper) GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddres return unbondingDelegations[:i] // trim if the array length < maxRetrieve } -// return a unbonding delegation +// GetUnbondingDelegation returns a unbonding delegation. func (k Keeper) GetUnbondingDelegation( ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, ) (ubd types.UnbondingDelegation, found bool) { @@ -150,7 +152,8 @@ func (k Keeper) GetUnbondingDelegation( return ubd, true } -// return all unbonding delegations from a particular validator +// GetUnbondingDelegationsFromValidator returns all unbonding delegations from a +// particular validator. func (k Keeper) GetUnbondingDelegationsFromValidator(ctx sdk.Context, valAddr sdk.ValAddress) (ubds []types.UnbondingDelegation) { store := ctx.KVStore(k.storeKey) @@ -167,7 +170,7 @@ func (k Keeper) GetUnbondingDelegationsFromValidator(ctx sdk.Context, valAddr sd return ubds } -// iterate through all of the unbonding delegations +// IterateUnbondingDelegations iterates through all of the unbonding delegations. func (k Keeper) IterateUnbondingDelegations(ctx sdk.Context, fn func(index int64, ubd types.UnbondingDelegation) (stop bool)) { store := ctx.KVStore(k.storeKey) @@ -183,7 +186,85 @@ func (k Keeper) IterateUnbondingDelegations(ctx sdk.Context, fn func(index int64 } } -// HasMaxUnbondingDelegationEntries - check if unbonding delegation has maximum number of entries +// GetDelegatorUnbonding returns the total amount a delegator has unbonding. +func (k Keeper) GetDelegatorUnbonding(ctx sdk.Context, delegator sdk.AccAddress) sdk.Int { + unbonding := sdk.ZeroInt() + k.IterateDelegatorUnbondingDelegations(ctx, delegator, func(ubd types.UnbondingDelegation) bool { + for _, entry := range ubd.Entries { + unbonding = unbonding.Add(entry.Balance) + } + return false + }) + return unbonding +} + +// IterateDelegatorUnbondingDelegations iterates through a delegator's unbonding delegations. +func (k Keeper) IterateDelegatorUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress, cb func(ubd types.UnbondingDelegation) (stop bool)) { + store := ctx.KVStore(k.storeKey) + + iterator := sdk.KVStorePrefixIterator(store, types.GetUBDsKey(delegator)) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + ubd := types.MustUnmarshalUBD(k.cdc, iterator.Value()) + if cb(ubd) { + break + } + } +} + +// GetDelegatorBonded returs the total amount a delegator has bonded. +func (k Keeper) GetDelegatorBonded(ctx sdk.Context, delegator sdk.AccAddress) sdk.Int { + bonded := sdk.ZeroDec() + + k.IterateDelegatorDelegations(ctx, delegator, func(delegation types.Delegation) bool { + validatorAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress) + if err != nil { + panic(err) // shouldn't happen + } + validator, found := k.GetValidator(ctx, validatorAddr) + if found { + shares := delegation.Shares + tokens := validator.TokensFromSharesTruncated(shares) + bonded = bonded.Add(tokens) + } + return false + }) + return bonded.RoundInt() +} + +// IterateDelegatorDelegations iterates through one delegator's delegations. +func (k Keeper) IterateDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, cb func(delegation types.Delegation) (stop bool)) { + store := ctx.KVStore(k.storeKey) + delegatorPrefixKey := types.GetDelegationsKey(delegator) + iterator := sdk.KVStorePrefixIterator(store, delegatorPrefixKey) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + delegation := types.MustUnmarshalDelegation(k.cdc, iterator.Value()) + if cb(delegation) { + break + } + } +} + +// IterateDelegatorRedelegations iterates through one delegator's redelegations. +func (k Keeper) IterateDelegatorRedelegations(ctx sdk.Context, delegator sdk.AccAddress, cb func(red types.Redelegation) (stop bool)) { + store := ctx.KVStore(k.storeKey) + delegatorPrefixKey := types.GetREDsKey(delegator) + + iterator := sdk.KVStorePrefixIterator(store, delegatorPrefixKey) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + red := types.MustUnmarshalRED(k.cdc, iterator.Value()) + if cb(red) { + break + } + } +} + +// HasMaxUnbondingDelegationEntries - check if unbonding delegation has maximum number of entries. func (k Keeper) HasMaxUnbondingDelegationEntries(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) bool { ubd, found := k.GetUnbondingDelegation(ctx, delegatorAddr, validatorAddr) @@ -194,7 +275,7 @@ func (k Keeper) HasMaxUnbondingDelegationEntries(ctx sdk.Context, return len(ubd.Entries) >= int(k.MaxEntries(ctx)) } -// set the unbonding delegation and associated index +// SetUnbondingDelegation sets the unbonding delegation and associated index. func (k Keeper) SetUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDelegation) { delegatorAddress, err := sdk.AccAddressFromBech32(ubd.DelegatorAddress) if err != nil { @@ -211,7 +292,7 @@ func (k Keeper) SetUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDeleg store.Set(types.GetUBDByValIndexKey(delegatorAddress, addr), []byte{}) // index, store empty bytes } -// remove the unbonding delegation object and associated index +// RemoveUnbondingDelegation removes the unbonding delegation object and associated index. func (k Keeper) RemoveUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDelegation) { delegatorAddress, err := sdk.AccAddressFromBech32(ubd.DelegatorAddress) if err != nil { @@ -229,7 +310,7 @@ func (k Keeper) RemoveUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDe } // SetUnbondingDelegationEntry adds an entry to the unbonding delegation at -// the given addresses. It creates the unbonding delegation if it does not exist +// the given addresses. It creates the unbonding delegation if it does not exist. func (k Keeper) SetUnbondingDelegationEntry( ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, creationHeight int64, minTime time.Time, balance sdk.Int, @@ -248,8 +329,9 @@ func (k Keeper) SetUnbondingDelegationEntry( // unbonding delegation queue timeslice operations -// gets a specific unbonding queue timeslice. A timeslice is a slice of DVPairs -// corresponding to unbonding delegations that expire at a certain time. +// GetUBDQueueTimeSlice gets a specific unbonding queue timeslice. A timeslice +// is a slice of DVPairs corresponding to unbonding delegations that expire at a +// certain time. func (k Keeper) GetUBDQueueTimeSlice(ctx sdk.Context, timestamp time.Time) (dvPairs []types.DVPair) { store := ctx.KVStore(k.storeKey) @@ -264,14 +346,15 @@ func (k Keeper) GetUBDQueueTimeSlice(ctx sdk.Context, timestamp time.Time) (dvPa return pairs.Pairs } -// Sets a specific unbonding queue timeslice. +// SetUBDQueueTimeSlice sets a specific unbonding queue timeslice. func (k Keeper) SetUBDQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys []types.DVPair) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&types.DVPairs{Pairs: keys}) store.Set(types.GetUnbondingDelegationTimeKey(timestamp), bz) } -// Insert an unbonding delegation to the appropriate timeslice in the unbonding queue +// InsertUBDQueue inserts an unbonding delegation to the appropriate timeslice +// in the unbonding queue. func (k Keeper) InsertUBDQueue(ctx sdk.Context, ubd types.UnbondingDelegation, completionTime time.Time) { dvPair := types.DVPair{DelegatorAddress: ubd.DelegatorAddress, ValidatorAddress: ubd.ValidatorAddress} @@ -285,15 +368,15 @@ func (k Keeper) InsertUBDQueue(ctx sdk.Context, ubd types.UnbondingDelegation, } } -// Returns all the unbonding queue timeslices from time 0 until endTime +// UBDQueueIterator returns all the unbonding queue timeslices from time 0 until endTime. func (k Keeper) UBDQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { store := ctx.KVStore(k.storeKey) return store.Iterator(types.UnbondingQueueKey, sdk.InclusiveEndBytes(types.GetUnbondingDelegationTimeKey(endTime))) } -// Returns a concatenated list of all the timeslices inclusively previous to -// currTime, and deletes the timeslices from the queue +// DequeueAllMatureUBDQueue returns a concatenated list of all the timeslices inclusively previous to +// currTime, and deletes the timeslices from the queue. func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, currTime time.Time) (matureUnbonds []types.DVPair) { store := ctx.KVStore(k.storeKey) @@ -314,7 +397,7 @@ func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, currTime time.Time) (m return matureUnbonds } -// return a given amount of all the delegator redelegations +// GetRedelegations returns a given amount of all the delegator redelegations. func (k Keeper) GetRedelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) (redelegations []types.Redelegation) { redelegations = make([]types.Redelegation, maxRetrieve) @@ -335,7 +418,7 @@ func (k Keeper) GetRedelegations(ctx sdk.Context, delegator sdk.AccAddress, return redelegations[:i] // trim if the array length < maxRetrieve } -// return a redelegation +// GetRedelegation returns a redelegation. func (k Keeper) GetRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) (red types.Redelegation, found bool) { store := ctx.KVStore(k.storeKey) @@ -351,7 +434,8 @@ func (k Keeper) GetRedelegation(ctx sdk.Context, return red, true } -// return all redelegations from a particular validator +// GetRedelegationsFromSrcValidator returns all redelegations from a particular +// validator. func (k Keeper) GetRedelegationsFromSrcValidator(ctx sdk.Context, valAddr sdk.ValAddress) (reds []types.Redelegation) { store := ctx.KVStore(k.storeKey) @@ -368,7 +452,7 @@ func (k Keeper) GetRedelegationsFromSrcValidator(ctx sdk.Context, valAddr sdk.Va return reds } -// check if validator is receiving a redelegation +// HasReceivingRedelegation checks if validator is receiving a redelegation. func (k Keeper) HasReceivingRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool { store := ctx.KVStore(k.storeKey) @@ -380,7 +464,7 @@ func (k Keeper) HasReceivingRedelegation(ctx sdk.Context, return iterator.Valid() } -// HasMaxRedelegationEntries - redelegation has maximum number of entries +// HasMaxRedelegationEntries checks if redelegation has maximum number of entries. func (k Keeper) HasMaxRedelegationEntries(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorSrcAddr, validatorDstAddr sdk.ValAddress) bool { @@ -392,7 +476,7 @@ func (k Keeper) HasMaxRedelegationEntries(ctx sdk.Context, return len(red.Entries) >= int(k.MaxEntries(ctx)) } -// set a redelegation and associated index +// SetRedelegation set a redelegation and associated index. func (k Keeper) SetRedelegation(ctx sdk.Context, red types.Redelegation) { delegatorAddress, err := sdk.AccAddressFromBech32(red.DelegatorAddress) if err != nil { @@ -415,8 +499,8 @@ func (k Keeper) SetRedelegation(ctx sdk.Context, red types.Redelegation) { store.Set(types.GetREDByValDstIndexKey(delegatorAddress, valSrcAddr, valDestAddr), []byte{}) } -// SetUnbondingDelegationEntry adds an entry to the unbonding delegation at -// the given addresses. It creates the unbonding delegation if it does not exist +// SetRedelegationEntry adds an entry to the unbonding delegation at the given +// addresses. It creates the unbonding delegation if it does not exist. func (k Keeper) SetRedelegationEntry(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorSrcAddr, validatorDstAddr sdk.ValAddress, creationHeight int64, @@ -435,7 +519,7 @@ func (k Keeper) SetRedelegationEntry(ctx sdk.Context, return red } -// iterate through all redelegations +// IterateRedelegations iterates through all redelegations. func (k Keeper) IterateRedelegations(ctx sdk.Context, fn func(index int64, red types.Redelegation) (stop bool)) { store := ctx.KVStore(k.storeKey) @@ -451,7 +535,7 @@ func (k Keeper) IterateRedelegations(ctx sdk.Context, fn func(index int64, red t } } -// remove a redelegation object and associated index +// RemoveRedelegation removes a redelegation object and associated index. func (k Keeper) RemoveRedelegation(ctx sdk.Context, red types.Redelegation) { delegatorAddress, err := sdk.AccAddressFromBech32(red.DelegatorAddress) if err != nil { @@ -474,8 +558,9 @@ func (k Keeper) RemoveRedelegation(ctx sdk.Context, red types.Redelegation) { // redelegation queue timeslice operations -// Gets a specific redelegation queue timeslice. A timeslice is a slice of DVVTriplets corresponding to redelegations -// that expire at a certain time. +// GetRedelegationQueueTimeSlice gets a specific redelegation queue timeslice. A +// timeslice is a slice of DVVTriplets corresponding to redelegations that +// expire at a certain time. func (k Keeper) GetRedelegationQueueTimeSlice(ctx sdk.Context, timestamp time.Time) (dvvTriplets []types.DVVTriplet) { store := ctx.KVStore(k.storeKey) @@ -490,14 +575,15 @@ func (k Keeper) GetRedelegationQueueTimeSlice(ctx sdk.Context, timestamp time.Ti return triplets.Triplets } -// Sets a specific redelegation queue timeslice. +// SetRedelegationQueueTimeSlice sets a specific redelegation queue timeslice. func (k Keeper) SetRedelegationQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys []types.DVVTriplet) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(&types.DVVTriplets{Triplets: keys}) store.Set(types.GetRedelegationTimeKey(timestamp), bz) } -// Insert an redelegation delegation to the appropriate timeslice in the redelegation queue +// InsertRedelegationQueue insert an redelegation delegation to the appropriate +// timeslice in the redelegation queue. func (k Keeper) InsertRedelegationQueue(ctx sdk.Context, red types.Redelegation, completionTime time.Time) { timeSlice := k.GetRedelegationQueueTimeSlice(ctx, completionTime) @@ -514,14 +600,16 @@ func (k Keeper) InsertRedelegationQueue(ctx sdk.Context, red types.Redelegation, } } -// Returns all the redelegation queue timeslices from time 0 until endTime +// RedelegationQueueIterator returns all the redelegation queue timeslices from +// time 0 until endTime. func (k Keeper) RedelegationQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterator { store := ctx.KVStore(k.storeKey) return store.Iterator(types.RedelegationQueueKey, sdk.InclusiveEndBytes(types.GetRedelegationTimeKey(endTime))) } -// Returns a concatenated list of all the timeslices inclusively previous to -// currTime, and deletes the timeslices from the queue +// DequeueAllMatureRedelegationQueue returns a concatenated list of all the +// timeslices inclusively previous to currTime, and deletes the timeslices from +// the queue. func (k Keeper) DequeueAllMatureRedelegationQueue(ctx sdk.Context, currTime time.Time) (matureRedelegations []types.DVVTriplet) { store := ctx.KVStore(k.storeKey) @@ -626,7 +714,7 @@ func (k Keeper) Delegate( return newShares, nil } -// Unbond a particular delegation and perform associated store operations. +// Unbond unbonds a particular delegation and perform associated store operations. func (k Keeper) Unbond( ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, shares sdk.Dec, ) (amount sdk.Int, err error) { @@ -800,7 +888,8 @@ func (k Keeper) CompleteUnbonding(ctx sdk.Context, delAddr sdk.AccAddress, valAd return balances, nil } -// begin unbonding / redelegation; create a redelegation record +// BeginRedelegation begins unbonding / redelegation and creates a redelegation +// record. func (k Keeper) BeginRedelegation( ctx sdk.Context, delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, sharesAmount sdk.Dec, ) (completionTime time.Time, err error) { diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index cac61af1fbe2..f44a88a2ca4a 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -107,6 +107,11 @@ func TestDelegation(t *testing.T) { require.Len(t, resDels, 2) } + // test total bonded for single delegator + expBonded := bond1to1.Shares.Add(bond2to1.Shares).Add(bond1to3.Shares) + resDelBond := app.StakingKeeper.GetDelegatorBonded(ctx, addrDels[0]) + require.Equal(t, expBonded, sdk.NewDecFromInt(resDelBond)) + // delete a record app.StakingKeeper.RemoveDelegation(ctx, bond2to3) _, found = app.StakingKeeper.GetDelegation(ctx, addrDels[1], valAddrs[2]) @@ -152,7 +157,8 @@ func TestUnbondingDelegation(t *testing.T) { require.Equal(t, ubd, resUnbond) // modify a records, save, and retrieve - ubd.Entries[0].Balance = sdk.NewInt(21) + expUnbond := sdk.NewInt(21) + ubd.Entries[0].Balance = expUnbond app.StakingKeeper.SetUnbondingDelegation(ctx, ubd) resUnbonds := app.StakingKeeper.GetUnbondingDelegations(ctx, delAddrs[0], 5) @@ -165,6 +171,9 @@ func TestUnbondingDelegation(t *testing.T) { require.True(t, found) require.Equal(t, ubd, resUnbond) + resDelUnbond := app.StakingKeeper.GetDelegatorUnbonding(ctx, delAddrs[0]) + require.Equal(t, expUnbond, resDelUnbond) + // delete a record app.StakingKeeper.RemoveUnbondingDelegation(ctx, ubd) _, found = app.StakingKeeper.GetUnbondingDelegation(ctx, delAddrs[0], valAddrs[0]) diff --git a/x/staking/types/staking.pb.go b/x/staking/types/staking.pb.go index d1f7e96137b3..5740d1abf237 100644 --- a/x/staking/types/staking.pb.go +++ b/x/staking/types/staking.pb.go @@ -1140,120 +1140,112 @@ func init() { } var fileDescriptor_64c30c6cf92913c9 = []byte{ - // 1808 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0x4f, 0x6c, 0x23, 0x57, - 0x19, 0xf7, 0xc4, 0xae, 0x63, 0x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x99, 0xa6, 0x49, 0xa5, 0xb5, 0x65, 0x72, 0x8d, 0xd9, 0x20, 0x60, 0x2e, + 0x65, 0x43, 0xfb, 0x90, 0xd0, 0xe1, 0xa1, 0x28, 0x17, 0xea, 0xd6, 0xb5, 0x85, 0x5e, 0x29, 0xde, + 0xbf, 0xa5, 0xb6, 0xd1, 0x6d, 0x58, 0x4d, 0x44, 0x55, 0xed, 0x2c, 0x5d, 0xa0, 0x76, 0x56, 0x62, + 0x5d, 0x79, 0x8a, 0x6e, 0x01, 0x24, 0x85, 0x59, 0x06, 0x05, 0xd4, 0xf8, 0xec, 0xea, 0x36, 0x2e, + 0xa4, 0x74, 0x91, 0x07, 0x57, 0x7c, 0xca, 0x6c, 0x4e, 0xbc, 0x03, 0xdb, 0x50, 0x25, 0x21, 0x8b, + 0x97, 0x10, 0xda, 0x75, 0x9f, 0xb2, 0x3e, 0xf1, 0x0e, 0xda, 0x31, 0xec, 0xf6, 0xf2, 0xdb, 0x0f, + 0x6b, 0x19, 0x53, 0x4b, 0x99, 0x46, 0x17, 0x96, 0xf7, 0xb1, 0x67, 0xca, 0x80, 0x70, 0xf4, 0x1a, + 0x2c, 0xe1, 0x68, 0x51, 0xb6, 0xea, 0x0b, 0x67, 0x96, 0x51, 0x22, 0xaa, 0xab, 0xf3, 0xd7, 0x7f, + 0xab, 0x5b, 0x8d, 0xdf, 0x59, 0x90, 0x6f, 0xef, 0x77, 0x31, 0x0d, 0x51, 0x07, 0xd6, 0x93, 0x84, + 0x3a, 0x6f, 0x6d, 0x26, 0x39, 0x18, 0x15, 0x67, 0x07, 0xd6, 0xef, 0x45, 0xe5, 0x1e, 0xc3, 0x64, + 0x3f, 0x0b, 0x26, 0x56, 0x31, 0xfb, 0x53, 0x8e, 0x77, 0x60, 0x51, 0x5b, 0xc9, 0xd1, 0x36, 0x3c, + 0x37, 0x92, 0x1f, 0xca, 0xdf, 0xe2, 0x56, 0x75, 0x6e, 0x22, 0x2a, 0x79, 0x13, 0x40, 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x94, 0xe8, 0x15, 0x00, 0x00, } func (this *Pool) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) { diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go index 731de6af8a51..b38b6e21d425 100644 --- a/x/upgrade/abci_test.go +++ b/x/upgrade/abci_test.go @@ -64,14 +64,14 @@ func TestRequireName(t *testing.T) { s := setupTest(10, map[int64]bool{}) err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{}}) - require.NotNil(t, err) + require.Error(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } func TestRequireFutureBlock(t *testing.T) { s := setupTest(10, map[int64]bool{}) - err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight()}}) - require.NotNil(t, err) + err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() - 1}}) + require.Error(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } @@ -79,7 +79,7 @@ func TestDoHeightUpgrade(t *testing.T) { s := setupTest(10, map[int64]bool{}) t.Log("Verify can schedule an upgrade") err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) - require.Nil(t, err) + require.NoError(t, err) VerifyDoUpgrade(t) } @@ -88,9 +88,9 @@ func TestCanOverwriteScheduleUpgrade(t *testing.T) { s := setupTest(10, map[int64]bool{}) t.Log("Can overwrite plan") err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "bad_test", Height: s.ctx.BlockHeight() + 10}}) - require.Nil(t, err) + require.NoError(t, err) err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) - require.Nil(t, err) + require.NoError(t, err) VerifyDoUpgrade(t) } @@ -137,7 +137,7 @@ func TestHaltIfTooNew(t *testing.T) { s := setupTest(10, map[int64]bool{}) t.Log("Verify that we don't panic with registered plan not in database at all") var called int - s.keeper.SetUpgradeHandler("future", func(ctx sdk.Context, plan types.Plan, vm module.VersionMap) (module.VersionMap, error) { + s.keeper.SetUpgradeHandler("future", func(_ sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) { called++ return vm, nil }) @@ -180,10 +180,10 @@ func TestCanClear(t *testing.T) { s := setupTest(10, map[int64]bool{}) t.Log("Verify upgrade is scheduled") err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 100}}) - require.Nil(t, err) + require.NoError(t, err) err = s.handler(s.ctx, &types.CancelSoftwareUpgradeProposal{Title: "cancel"}) - require.Nil(t, err) + require.NoError(t, err) VerifyCleared(t, s.ctx) } @@ -192,11 +192,11 @@ func TestCantApplySameUpgradeTwice(t *testing.T) { s := setupTest(10, map[int64]bool{}) height := s.ctx.BlockHeader().Height + 1 err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: height}}) - require.Nil(t, err) + require.NoError(t, err) VerifyDoUpgrade(t) t.Log("Verify an executed upgrade \"test\" can't be rescheduled") err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: height}}) - require.NotNil(t, err) + require.Error(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } @@ -242,9 +242,7 @@ func VerifySet(t *testing.T, skipUpgradeHeights map[int64]bool) { } func TestContains(t *testing.T) { - var ( - skipOne int64 = 11 - ) + var skipOne int64 = 11 s := setupTest(10, map[int64]bool{skipOne: true}) VerifySet(t, map[int64]bool{skipOne: true}) @@ -303,7 +301,7 @@ func TestUpgradeSkippingOne(t *testing.T) { req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: skipOne}}) - require.Nil(t, err) + require.NoError(t, err) t.Log("Verify if skip upgrade flag clears upgrade plan in one case and does upgrade on another") VerifySet(t, map[int64]bool{skipOne: true}) @@ -316,7 +314,7 @@ func TestUpgradeSkippingOne(t *testing.T) { t.Log("Verify the second proposal is not skipped") err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop2", Plan: types.Plan{Name: "test2", Height: skipTwo}}) - require.Nil(t, err) + require.NoError(t, err) // Setting block height of proposal test2 newCtx = newCtx.WithBlockHeight(skipTwo) VerifyDoUpgradeWithCtx(t, newCtx, "test2") @@ -338,7 +336,7 @@ func TestUpgradeSkippingOnlyTwo(t *testing.T) { req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: skipOne}}) - require.Nil(t, err) + require.NoError(t, err) t.Log("Verify if skip upgrade flag clears upgrade plan in both cases and does third upgrade") VerifySet(t, map[int64]bool{skipOne: true, skipTwo: true}) @@ -351,7 +349,7 @@ func TestUpgradeSkippingOnlyTwo(t *testing.T) { // A new proposal with height in skipUpgradeHeights err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop2", Plan: types.Plan{Name: "test2", Height: skipTwo}}) - require.Nil(t, err) + require.NoError(t, err) // Setting block height of proposal test2 newCtx = newCtx.WithBlockHeight(skipTwo) require.NotPanics(t, func() { @@ -360,7 +358,7 @@ func TestUpgradeSkippingOnlyTwo(t *testing.T) { t.Log("Verify a new proposal is not skipped") err = s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop3", Plan: types.Plan{Name: "test3", Height: skipThree}}) - require.Nil(t, err) + require.NoError(t, err) newCtx = newCtx.WithBlockHeight(skipThree) VerifyDoUpgradeWithCtx(t, newCtx, "test3") @@ -375,7 +373,7 @@ func TestUpgradeWithoutSkip(t *testing.T) { newCtx := s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1).WithBlockTime(time.Now()) req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "prop", Plan: types.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) - require.Nil(t, err) + require.NoError(t, err) t.Log("Verify if upgrade happens without skip upgrade") require.Panics(t, func() { s.module.BeginBlock(newCtx, req) @@ -438,7 +436,7 @@ func TestBinaryVersion(t *testing.T) { }) err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "Upgrade test", Plan: types.Plan{Name: "test0", Height: s.ctx.BlockHeight() + 2}}) - require.Nil(t, err) + require.NoError(t, err) newCtx := s.ctx.WithBlockHeight(12) s.keeper.ApplyUpgrade(newCtx, types.Plan{ @@ -455,7 +453,7 @@ func TestBinaryVersion(t *testing.T) { "test panic: upgrade needed", func() (sdk.Context, abci.RequestBeginBlock) { err := s.handler(s.ctx, &types.SoftwareUpgradeProposal{Title: "Upgrade test", Plan: types.Plan{Name: "test2", Height: 13}}) - require.Nil(t, err) + require.NoError(t, err) newCtx := s.ctx.WithBlockHeight(13) req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index 7dee3efd56c9..4d2c834991d7 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -171,7 +171,9 @@ func (k Keeper) ScheduleUpgrade(ctx sdk.Context, plan types.Plan) error { return err } - if plan.Height <= ctx.BlockHeight() { + // NOTE: allow for the possibility of chains to schedule upgrades in begin block of the same block + // as a strategy for emergency hard fork recoveries + if plan.Height < ctx.BlockHeight() { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "upgrade cannot be scheduled in the past") } @@ -375,7 +377,7 @@ func (k Keeper) DumpUpgradeInfoWithInfoToDisk(height int64, name string, info st return err } - return ioutil.WriteFile(upgradeInfoFilePath, bz, 0600) + return os.WriteFile(upgradeInfoFilePath, bz, 0o600) } // GetUpgradeInfoPath returns the upgrade info file path