diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 10b85328b61b..4b9db54900af 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -4,5 +4,4 @@ # most precedence. # Primary repo maintainers -* @aaronc @alexanderbez - +* @cosmos/sdk-core-dev diff --git a/.github/ISSUE_TEMPLATE/module-readiness-checklist.md b/.github/ISSUE_TEMPLATE/module-readiness-checklist.md index 2d14413ad971..4d696f78d9db 100644 --- a/.github/ISSUE_TEMPLATE/module-readiness-checklist.md +++ b/.github/ISSUE_TEMPLATE/module-readiness-checklist.md @@ -10,13 +10,13 @@ This checklist is to be used for tracking the final internal audit of new Cosmos ### Release Candidate Checklist -The following checklist should be gone through once the module has been fully implemented. This audit should be performed directly on `master`, or preferably on a `alpha` or `beta` release tag that includes the module. +The following checklist should be gone through once the module has been fully implemented. This audit should be performed directly on `main`, or preferably on a `alpha` or `beta` release tag that includes the module. The module **should not** be included in any Release Candidate tag until it has passed this checklist. - [ ] API audit (at least 1 person) (@assignee) - [ ] Are Msg and Query methods and types well-named and organized? - - [ ] Is everything well documented (inline godoc as well as [`/spec/` folder](https://github.com/cosmos/cosmos-sdk/blob/master/docs/spec/SPEC-SPEC.md) in module directory) + - [ ] Is everything well documented (inline godoc as well as [`/spec/` folder](https://github.com/cosmos/cosmos-sdk/blob/main/docs/spec/SPEC-SPEC.md) in module directory) - [ ] State machine audit (at least 2 people) (@assignee1, @assignee2) - [ ] Read through MsgServer code and verify correctness upon visual inspection - [ ] Ensure all state machine code which could be confusing is properly commented diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index dd537fce565b..5306d0890f29 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -23,10 +23,10 @@ I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change -- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) +- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification -- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) -- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) +- [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules) +- [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification @@ -47,4 +47,4 @@ I have... - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage -- [ ] manually tested (if applicable) \ No newline at end of file +- [ ] manually tested (if applicable) diff --git a/.github/PULL_REQUEST_TEMPLATE/docs.md b/.github/PULL_REQUEST_TEMPLATE/docs.md index e6a10d37eca0..8233f83261c0 100644 --- a/.github/PULL_REQUEST_TEMPLATE/docs.md +++ b/.github/PULL_REQUEST_TEMPLATE/docs.md @@ -15,9 +15,9 @@ please add links to any relevant follow up issues.* I have... - [ ] included the correct `docs:` prefix in the PR title -- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) +- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification -- [ ] followed the [documentation writing guidelines](https://github.com/cosmos/cosmos-sdk/blob/master/docs/DOC_WRITING_GUIDELINES.md) +- [ ] followed the [documentation writing guidelines](https://github.com/cosmos/cosmos-sdk/blob/main/docs/DOC_WRITING_GUIDELINES.md) - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed diff --git a/.github/PULL_REQUEST_TEMPLATE/other.md b/.github/PULL_REQUEST_TEMPLATE/other.md index f98b5a068efd..b4f19151b34e 100644 --- a/.github/PULL_REQUEST_TEMPLATE/other.md +++ b/.github/PULL_REQUEST_TEMPLATE/other.md @@ -15,7 +15,7 @@ please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title -- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) +- [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed @@ -29,4 +29,4 @@ I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed all author checklist items have been addressed -- [ ] confirmed that this PR does not change production code \ No newline at end of file +- [ ] confirmed that this PR does not change production code diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 03c1c079ff76..b2766ba8d185 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -18,7 +18,7 @@ updates: interval: daily open-pull-requests-limit: 10 labels: - - automerge + - "A:automerge" - dependencies - package-ecosystem: gomod directory: "/db" @@ -26,7 +26,7 @@ updates: interval: daily open-pull-requests-limit: 10 labels: - - automerge + - "A:automerge" - dependencies - package-ecosystem: gomod directory: "/api" @@ -34,7 +34,7 @@ updates: interval: daily open-pull-requests-limit: 10 labels: - - automerge + - "A:automerge" - dependencies - package-ecosystem: gomod directory: "/orm" @@ -42,7 +42,7 @@ updates: interval: daily open-pull-requests-limit: 10 labels: - - automerge + - "A:automerge" - dependencies - package-ecosystem: gomod directory: "/container" @@ -50,7 +50,7 @@ updates: interval: daily open-pull-requests-limit: 10 labels: - - automerge + - "A:automerge" - dependencies - package-ecosystem: gomod directory: "/cosmovisor" @@ -58,5 +58,5 @@ updates: interval: daily open-pull-requests-limit: 10 labels: - - automerge + - "A:automerge" - dependencies diff --git a/.github/workflows/atlas.yml b/.github/workflows/atlas.yml index 65ac5897053b..5c59de030807 100644 --- a/.github/workflows/atlas.yml +++ b/.github/workflows/atlas.yml @@ -3,7 +3,7 @@ name: Atlas on: push: branches: - - master + - main paths: - "x/**/atlas/*" pull_request: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 6b080ef60380..968b24c94448 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,8 +2,14 @@ name: "CodeQL" on: pull_request: - paths: - - "**.go" + paths: + - "**.go" + push: + branches: + - main + - release/** + paths: + - "**.go" jobs: analyze: @@ -15,37 +21,37 @@ jobs: security-events: write steps: - - name: Checkout repository - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - with: - go-version: 1.17 - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: 'go' - queries: crypto-com/cosmos-sdk-codeql@main,security-and-quality - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). - # If this step fails, then you should remove it and run the build manually (see below) - - name: Autobuild - uses: github/codeql-action/autobuild@v1 - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - #- run: | - # make bootstrap - # make release - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + - name: Checkout repository + uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: 1.18 + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: "go" + queries: crypto-com/cosmos-sdk-codeql@main,security-and-quality + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/cosmovisor-release.yml b/.github/workflows/cosmovisor-release.yml index 006f43803132..1a7100d5a780 100644 --- a/.github/workflows/cosmovisor-release.yml +++ b/.github/workflows/cosmovisor-release.yml @@ -13,7 +13,7 @@ jobs: fetch-depth: 0 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 # get 'v*.*.*' part from 'cosmovisor/v*.*.*' and save to $GITHUB_ENV - name: Set env run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/cosmovisor/}" >> $GITHUB_ENV @@ -24,7 +24,7 @@ jobs: git tag -d ${{ env.RELEASE_VERSION }} || echo "No such a tag exists before" git tag ${{ env.RELEASE_VERSION }} HEAD - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 + uses: goreleaser/goreleaser-action@v3 with: # stick to version v0.179.0(https://github.com/cosmos/cosmos-sdk/issues/11125) version: v0.179.0 diff --git a/.github/workflows/dependencies-review.yml b/.github/workflows/dependencies-review.yml new file mode 100644 index 000000000000..52926d574274 --- /dev/null +++ b/.github/workflows/dependencies-review.yml @@ -0,0 +1,14 @@ +name: "Dependency Review" +on: [pull_request] + +permissions: + contents: read + +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: "Checkout Repository" + uses: actions/checkout@v3 + - name: "Dependency Review" + uses: actions/dependency-review-action@v1 diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 55e925fd0487..68b3b4e72fcc 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -1,12 +1,13 @@ name: Deploy docs # This job builds and deploys documenation to github pages. -# It runs on every push to master with a change in the docs folder. +# It runs on every push to main with a change in the docs folder. on: push: branches: - - master + - main paths: - "docs/**" + - "x/**/*.md" jobs: build-and-deploy: @@ -26,7 +27,7 @@ jobs: make build-docs LEDGER_ENABLED=false - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@v4.3.0 + uses: JamesIves/github-pages-deploy-action@v4.3.3 with: branch: gh-pages folder: ~/output diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 35f253f0a6d9..6b80a78cad1b 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,10 +1,10 @@ name: Build & Push -# Build & Push builds the simapp docker image on every push to master and +# Build & Push builds the simapp docker image on every push to main and # and pushes the image to https://hub.docker.com/r/interchainio/simapp/tags on: push: branches: - - master + - main tags: - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10 - "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5 @@ -42,17 +42,17 @@ jobs: echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Login to DockerHub if: ${{ github.event_name != 'pull_request' }} - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Publish to Docker Hub - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.prep.outputs.tags }} diff --git a/.github/workflows/lint-pr.yml b/.github/workflows/lint-pr.yml index c6bdb5b563ee..17b1a410dc5e 100644 --- a/.github/workflows/lint-pr.yml +++ b/.github/workflows/lint-pr.yml @@ -11,6 +11,6 @@ jobs: main: runs-on: ubuntu-latest steps: - - uses: amannn/action-semantic-pull-request@v4.2.0 + - uses: amannn/action-semantic-pull-request@v4.5.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 84e48f4d4978..056f53b1adda 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,12 +1,12 @@ name: Lint # Lint runs golangci-lint over the entire cosmos-sdk repository -# This workflow is run on every pull request and push to master +# This workflow is run on every pull request and push to main # The `golangci` will pass without running if no *.{go, mod, sum} files have been changed. on: pull_request: push: branches: - - master + - main jobs: golangci: name: golangci-lint @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - uses: technote-space/get-diff-action@v6.0.1 id: git_diff with: diff --git a/.github/workflows/proto-docker.yml b/.github/workflows/proto-docker.yml index 21568c7af8aa..dbab7a21cc05 100644 --- a/.github/workflows/proto-docker.yml +++ b/.github/workflows/proto-docker.yml @@ -2,24 +2,24 @@ name: Build & Push SDK Proto Builder on: push: branches: - - master + - main paths: - "contrib/devtools/dockerfile" permissions: contents: read - + jobs: build: runs-on: ubuntu-latest steps: - # set VERSION to new version when making changes, when merged to master the image will automatically be pushed + # set VERSION to new version when making changes, when merged to main the image will automatically be pushed - uses: actions/checkout@v3 - name: Prepare id: prep run: | DOCKER_IMAGE=tendermintdev/sdk-proto-gen - VERSION=v0.6 + VERSION=latest TAGS="${DOCKER_IMAGE}:${VERSION}" echo ::set-output name=tags::${TAGS} @@ -29,19 +29,18 @@ jobs: platforms: all - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + uses: docker/setup-buildx-action@v2 - name: Login to DockerHub - uses: docker/login-action@v1 + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKERHUBTM_USERNAME }} password: ${{ secrets.DOCKERHUBTM_TOKEN }} - name: Publish to Docker Hub - uses: docker/build-push-action@v2 + uses: docker/build-push-action@v3 with: context: ./contrib/devtools - file: ./contrib/devtools/dockerfile platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.prep.outputs.tags }} diff --git a/.github/workflows/proto-registry.yml b/.github/workflows/proto-registry.yml index 47a8f9c92ab3..c5be0bc8e4b5 100644 --- a/.github/workflows/proto-registry.yml +++ b/.github/workflows/proto-registry.yml @@ -4,18 +4,17 @@ name: Buf-Push on: push: branches: - - master + - main paths: - - 'proto/**' + - "proto/**" jobs: push: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1.3.1 + - uses: bufbuild/buf-setup-action@v1.4.0 - uses: bufbuild/buf-push-action@v1 with: - input: 'proto' + input: "proto" buf_token: ${{ secrets.BUF_TOKEN }} - diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index 16009920feea..8a350668e881 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -4,12 +4,12 @@ name: Protobuf on: pull_request: paths: - - 'proto/**' + - "proto/**" push: branches: - - master + - main paths: - - 'proto/**' + - "proto/**" jobs: lint: @@ -17,7 +17,7 @@ jobs: timeout-minutes: 5 steps: - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1.3.1 + - uses: bufbuild/buf-setup-action@v1.4.0 - uses: bufbuild/buf-lint-action@v1 with: input: 'proto' @@ -26,8 +26,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1.3.1 + - uses: bufbuild/buf-setup-action@v1.4.0 - uses: bufbuild/buf-breaking-action@v1 with: - input: 'proto' - against: 'https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto' + input: "proto" + against: "https://github.com/${{ github.repository }}.git#branch=${{ github.event.pull_request.base.ref }},ref=HEAD~1,subdir=proto" diff --git a/.github/workflows/tag.yml b/.github/workflows/release.yml similarity index 80% rename from .github/workflows/tag.yml rename to .github/workflows/release.yml index e85dae0be4d3..2a2eb0369991 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/release.yml @@ -15,12 +15,12 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Unshallow run: git fetch --prune --unshallow - name: Create release - uses: goreleaser/goreleaser-action@v2.7.0 + uses: goreleaser/goreleaser-action@v3 with: - args: release --rm-dist --release-notes ./RELEASE_CHANGELOG.md + args: release --rm-dist --release-notes ./RELEASE_NOTES.md env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/sims.yml b/.github/workflows/sims.yml index 7ac5c1d0a5dc..d7e97454a7b5 100644 --- a/.github/workflows/sims.yml +++ b/.github/workflows/sims.yml @@ -11,10 +11,10 @@ jobs: cleanup-runs: runs-on: ubuntu-latest steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + - uses: rokroskar/workflow-run-cleanup-action@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" build: runs-on: ubuntu-latest if: "!contains(github.event.head_commit.message, 'skip-sims')" @@ -22,7 +22,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Display go version run: go version - run: make build @@ -33,11 +33,11 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Display go version run: go version - name: Install runsim - run: export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0 + run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 - uses: actions/cache@v3 with: path: ~/go/bin @@ -51,26 +51,16 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Display go version run: go version - - uses: technote-space/get-diff-action@v6.0.1 - with: - SUFFIX_FILTER: | - **/**.go - go.mod - go.sum - SET_ENV_NAME_INSERTIONS: 1 - SET_ENV_NAME_LINES: 1 - uses: actions/cache@v3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary - if: env.GIT_DIFF - name: test-sim-import-export run: | make test-sim-import-export - if: env.GIT_DIFF test-sim-after-import: runs-on: ubuntu-latest @@ -80,26 +70,16 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Display go version run: go version - - uses: technote-space/get-diff-action@v6.0.1 - with: - SUFFIX_FILTER: | - **/**.go - go.mod - go.sum - SET_ENV_NAME_INSERTIONS: 1 - SET_ENV_NAME_LINES: 1 - uses: actions/cache@v3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary - if: env.GIT_DIFF - name: test-sim-after-import run: | make test-sim-after-import - if: env.GIT_DIFF test-sim-multi-seed-short: runs-on: ubuntu-latest @@ -109,23 +89,13 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Display go version run: go version - - uses: technote-space/get-diff-action@v6.0.1 - with: - SUFFIX_FILTER: | - **/**.go - go.mod - go.sum - SET_ENV_NAME_INSERTIONS: 1 - SET_ENV_NAME_LINES: 1 - uses: actions/cache@v3 with: path: ~/go/bin key: ${{ runner.os }}-go-runsim-binary - if: env.GIT_DIFF - name: test-sim-multi-seed-short run: | make test-sim-multi-seed-short - if: env.GIT_DIFF diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index d493cc250382..0c8717cded91 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -7,7 +7,7 @@ jobs: stale: runs-on: ubuntu-latest steps: - - uses: actions/stale@v4 + - uses: actions/stale@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-pr-message: "This pull request has been automatically marked as stale because it has not had diff --git a/.github/workflows/test-race.yml b/.github/workflows/test-race.yml index abc5c68d7277..1b92805875d2 100644 --- a/.github/workflows/test-race.yml +++ b/.github/workflows/test-race.yml @@ -1,35 +1,34 @@ name: Tests Race # Tests Race workflow runs unit tests with the race detector -# This workflow is run on pushes to master & every Pull Requests where a .go, .mod, .sum have been changed +# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed on: pull_request: push: branches: - - master + - main permissions: contents: read - + jobs: cleanup-runs: runs-on: ubuntu-latest steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + - uses: rokroskar/workflow-run-cleanup-action@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" install-tparse: runs-on: ubuntu-latest steps: - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Display go version run: go version - name: install tparse - run: | - export GO111MODULE="on" && go get github.com/mfridman/tparse@v0.8.3 + run: go install github.com/mfridman/tparse@v0.8.3 - uses: actions/cache@v3 with: path: ~/go/bin @@ -41,7 +40,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - uses: technote-space/get-diff-action@v6.0.1 id: git_diff with: @@ -61,25 +60,25 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Create a file with all core Cosmos SDK pkgs run: go list ./... > pkgs.txt - name: Split pkgs into 4 files run: split -d -n l/4 pkgs.txt pkgs.txt.part. # cache multiple - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-00" path: ./pkgs.txt.part.00 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-01" path: ./pkgs.txt.part.01 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-02" path: ./pkgs.txt.part.02 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-03" path: ./pkgs.txt.part.03 @@ -95,14 +94,14 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - uses: technote-space/get-diff-action@v6.0.1 with: PATTERNS: | **/**.go go.mod go.sum - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-${{ matrix.part }}" if: env.GIT_DIFF @@ -110,7 +109,7 @@ jobs: run: | xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -timeout 30m -race -tags='cgo ledger test_ledger_mock' if: env.GIT_DIFF - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-${{ matrix.part }}-race-output" path: ./${{ matrix.part }}-race-output.txt diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 36b7c950b09c..b5234cc89eba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,23 +1,23 @@ name: Tests / Code Coverage # Tests / Code Coverage workflow runs unit tests and uploads a code coverage report -# This workflow is run on pushes to master & every Pull Requests where a .go, .mod, .sum have been changed +# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed on: pull_request: push: branches: - - master + - main permissions: contents: read - + jobs: cleanup-runs: runs-on: ubuntu-latest steps: - - uses: rokroskar/workflow-run-cleanup-action@master - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + - uses: rokroskar/workflow-run-cleanup-action@master + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'" build: runs-on: ubuntu-latest strategy: @@ -27,7 +27,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - uses: technote-space/get-diff-action@v6.0.1 id: git_diff with: @@ -48,7 +48,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - uses: technote-space/get-diff-action@v6.0.1 id: git_diff with: @@ -60,7 +60,7 @@ jobs: # GIT_DIFF is passed to the scripts run: bash scripts/module-tests.sh if: env.GIT_DIFF - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-go-submodules-coverage" path: ./coverage-go-submod-profile.out @@ -71,25 +71,25 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Create a file with all core Cosmos SDK pkgs - run: go list ./... > pkgs.txt + run: go list ./... > pkgs.txt - name: Split pkgs into 4 files run: split -d -n l/4 pkgs.txt pkgs.txt.part. # cache multiple - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-00" path: ./pkgs.txt.part.00 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-01" path: ./pkgs.txt.part.01 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-02" path: ./pkgs.txt.part.02 - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-03" path: ./pkgs.txt.part.03 @@ -105,14 +105,14 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - uses: technote-space/get-diff-action@v6.0.1 with: PATTERNS: | **/**.go go.mod go.sum - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-${{ matrix.part }}" if: env.GIT_DIFF @@ -120,7 +120,7 @@ jobs: run: | cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='norace ledger test_ledger_mock' if: env.GIT_DIFF - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v3 with: name: "${{ github.sha }}-${{ matrix.part }}-coverage" path: ./${{ matrix.part }}profile.out @@ -136,26 +136,27 @@ jobs: **/**.go go.mod go.sum - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-00-coverage" if: env.GIT_DIFF - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-01-coverage" if: env.GIT_DIFF - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-02-coverage" if: env.GIT_DIFF - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-03-coverage" if: env.GIT_DIFF - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v3 with: name: "${{ github.sha }}-go-submodules-coverage" if: env.GIT_DIFF + continue-on-error: true - run: | cat ./*profile.out | grep -v "mode: atomic" >> coverage.txt if: env.GIT_DIFF @@ -200,7 +201,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - uses: technote-space/get-diff-action@v6.0.1 id: git_diff with: @@ -216,18 +217,18 @@ jobs: run: | ./contrib/localnet_liveness.sh 100 5 50 localhost if: env.GIT_DIFF - + install-runsim: runs-on: ubuntu-latest needs: build steps: - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Display go version run: go version - name: Install runsim - run: export GO111MODULE="on" && go get github.com/cosmos/tools/cmd/runsim@v1.0.0 + run: go install github.com/cosmos/tools/cmd/runsim@v1.0.0 - uses: actions/cache@v3 with: path: ~/go/bin @@ -240,7 +241,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-go@v3 with: - go-version: 1.17 + go-version: 1.18 - name: Display go version run: go version - uses: technote-space/get-diff-action@v6.0.1 diff --git a/.mergify.yml b/.mergify.yml index f43e68bc80a4..107930132efe 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -4,11 +4,11 @@ queue_rules: - "#approved-reviews-by>1" pull_request_rules: - - name: automerge to master with label automerge and branch protection passing + - name: automerge to main with label automerge and branch protection passing conditions: - "#approved-reviews-by>1" - - base=master - - label=automerge + - base=main + - label=A:automerge actions: queue: name: default @@ -18,7 +18,7 @@ pull_request_rules: {{ body }} - name: backport patches to v0.46.x branch conditions: - - base=master + - base=main - label=backport/0.46.x actions: backport: @@ -26,7 +26,7 @@ pull_request_rules: - release/v0.46.x - name: backport patches to v0.45.x branch conditions: - - base=master + - base=main - label=backport/0.45.x actions: backport: @@ -34,7 +34,7 @@ pull_request_rules: - release/v0.45.x - name: backport patches to v0.44.x branch conditions: - - base=master + - base=main - label=backport/0.44.x actions: backport: @@ -42,7 +42,7 @@ pull_request_rules: - release/v0.44.x - name: backport patches to v0.42.x branch conditions: - - base=master + - base=main - label=backport/0.42.x (Stargate) actions: backport: diff --git a/CHANGELOG.md b/CHANGELOG.md index 38e240cd7770..cd82a461657b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,14 +39,19 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (types) [#11985](https://github.com/cosmos/cosmos-sdk/pull/11985) Add a `Priority` field on `sdk.Context`, which represents the CheckTx priority field. It is only used during CheckTx. +* (gRPC) [#11889](https://github.com/cosmos/cosmos-sdk/pull/11889) Support custom read and write gRPC options in `app.toml`. See `max-recv-msg-size` and `max-send-msg-size` respectively. +* (cli) [\#11738](https://github.com/cosmos/cosmos-sdk/pull/11738) Add `tx auth multi-sign` as alias of `tx auth multisign` for consistency with `multi-send`. +* (cli) [\#11738](https://github.com/cosmos/cosmos-sdk/pull/11738) Add `tx bank multi-send` command for bulk send of coins to multiple accounts. +* (grpc) [\#11642](https://github.com/cosmos/cosmos-sdk/pull/11642) Implement `ABCIQuery` in the Tendermint gRPC service, which proxies ABCI `Query` requests directly to the application. +* (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. * (cli) [\#11548](https://github.com/cosmos/cosmos-sdk/pull/11548) Add Tendermint's `inspect` command to the `tendermint` sub-command. * (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. * (x/genutil) [\#11500](https://github.com/cosmos/cosmos-sdk/pull/11500) Fix GenTx validation and adjust error messages * [\#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/upgrade) [\#11116](https://github.com/cosmos/cosmos-sdk/pull/11116) `MsgSoftwareUpgrade` and has been added to support v1beta2 msgs-based gov proposals. * (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. * [\#11441](https://github.com/cosmos/cosmos-sdk/pull/11441) Added a new method, `IsLTE`, for `types.Coin`. This method is used to check if a `types.Coin` is less than or equal to another `types.Coin`. -* (x/upgrade) [\#11116](https://github.com/cosmos/cosmos-sdk/pull/11116) `MsgSoftwareUpgrade` and has been added to support v1beta2 msgs-based gov proposals. +* (x/upgrade) [\#11116](https://github.com/cosmos/cosmos-sdk/pull/11116) `MsgSoftwareUpgrade` and `MsgCancelUpgrade` have been added to support v1beta2 msgs-based gov proposals. * [\#11308](https://github.com/cosmos/cosmos-sdk/pull/11308) Added a mandatory metadata field to Vote in x/gov v1beta2. * [\#10977](https://github.com/cosmos/cosmos-sdk/pull/10977) Now every cosmos message protobuf definition must be extended with a ``cosmos.msg.v1.signer`` option to signal the signer fields in a language agnostic way. * [\#10710](https://github.com/cosmos/cosmos-sdk/pull/10710) Chain-id shouldn't be required for creating a transaction with both --generate-only and --offline flags. @@ -58,7 +63,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#9533](https://github.com/cosmos/cosmos-sdk/pull/9533) Added a new gRPC method, `DenomOwners`, in `x/bank` to query for all account holders of a specific denomination. * (bank) [\#9618](https://github.com/cosmos/cosmos-sdk/pull/9618) Update bank.Metadata: add URI and URIHash attributes. * (store) [\#8664](https://github.com/cosmos/cosmos-sdk/pull/8664) Implementation of ADR-038 file StreamingService -* [\#9837](https://github.com/cosmos/cosmos-sdk/issues/9837) `--generate-only` flag will accept the keyname now. +* [\#9837](https://github.com/cosmos/cosmos-sdk/issues/9837) `--generate-only` flag can be used with a keyname from the keyring. * [\#10326](https://github.com/cosmos/cosmos-sdk/pull/10326) `x/authz` add all grants by granter query. * [\#10944](https://github.com/cosmos/cosmos-sdk/pull/10944) `x/authz` add all grants by grantee query * [\#10348](https://github.com/cosmos/cosmos-sdk/pull/10348) Add `fee.{payer,granter}` and `tip` fields to StdSignDoc for signing tipped transactions. @@ -78,19 +83,28 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#11179](https://github.com/cosmos/cosmos-sdk/pull/11179) Add state rollback command. * [\#10794](https://github.com/cosmos/cosmos-sdk/pull/10794) ADR-040: Add State Sync to V2 Store * [\#11234](https://github.com/cosmos/cosmos-sdk/pull/11234) Add `GRPCClient` field to Client Context. If `GRPCClient` field is set to nil, the `Invoke` method would use ABCI query, otherwise use gprc. -* [\#10962](https://github.com/cosmos/cosmos-sdk/pull/10962) ADR-040: Add state migration from iavl (v1Store) to smt (v2Store) +* [\#10962](https://github.com/cosmos/cosmos-sdk/pull/10962) ADR-040: Add state migration from iavl (v1Store) to smt (v2Store) * (types) [\#10948](https://github.com/cosmos/cosmos-sdk/issues/10948) Add `app-db-backend` to the `app.toml` config to replace the compile-time `types.DBbackend` variable. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) Support grant with no expire time. +* (rosetta) [\#11590](https://github.com/cosmos/cosmos-sdk/pull/11590) Add fee suggestion for rosetta and enable offline mode. Also force set events about Fees to Success to pass reconciliation test. +* (types) [\#11959](https://github.com/cosmos/cosmos-sdk/pull/11959) Added `sdk.Coins.Find` helper method to find a coin by denom. * [\#10174](https://github.com/cosmos/cosmos-sdk/pull/10174) ADR-040: Refactor App to use `v2.MultiStore` - ### API Breaking Changes +* (x/auth/ante) [#11985](https://github.com/cosmos/cosmos-sdk/pull/11985) The `MempoolFeeDecorator` has been removed. Instead, the `DeductFeeDecorator` takes a new argument of type `TxFeeChecker`, to define custom fee models. If `nil` is passed to this `TxFeeChecker` argument, then it will default to `checkTxFeeWithValidatorMinGasPrices`, which is the exact same behavior as the old `MempoolFeeDecorator` (i.e. checking fees against validator's own min gas price). +* (x/auth/ante) [#11985](https://github.com/cosmos/cosmos-sdk/pull/11985) The `ExtensionOptionsDecorator` takes an argument of type `ExtensionOptionChecker`. For backwards-compatibility, you can pass `nil`, which defaults to the old behavior of rejecting all tx extensions. +* (crypto/keyring) [#11932](https://github.com/cosmos/cosmos-sdk/pull/11932) Remove `Unsafe*` interfaces from keyring package. Please use interface casting if you wish to access those unsafe functions. +* (types) [#11881](https://github.com/cosmos/cosmos-sdk/issues/11881) Rename `AccAddressFromHex` to `AccAddressFromHexUnsafe`. +* (types) [#11788](https://github.com/cosmos/cosmos-sdk/pull/11788) The `Int` and `Uint` types have been moved to their own dedicated module, `math`. Aliases are kept in the SDK's root `types` package, however, it is encouraged to utilize the new `math` module. As a result, the `Int#ToDec` API has been removed. +* (grpc) [\#11642](https://github.com/cosmos/cosmos-sdk/pull/11642) The `RegisterTendermintService` method in the `tmservice` package now requires a `abciQueryFn` query function parameter. +* [\#11496](https://github.com/cosmos/cosmos-sdk/pull/11496) Refactor abstractions for snapshot and pruning; snapshot intervals eventually pruned; unit tests. +* (types) [\#11689](https://github.com/cosmos/cosmos-sdk/pull/11689) Make `Coins#Sub` and `Coins#SafeSub` consistent with `Coins#Add`. * (store)[\#11152](https://github.com/cosmos/cosmos-sdk/pull/11152) Remove `keep-every` from pruning options. * [\#10950](https://github.com/cosmos/cosmos-sdk/pull/10950) Add `envPrefix` parameter to `cmd.Execute`. * (x/mint) [\#10441](https://github.com/cosmos/cosmos-sdk/pull/10441) The `NewAppModule` function now accepts an inflation calculation function as an argument. * [\#10295](https://github.com/cosmos/cosmos-sdk/pull/10295) Remove store type aliases from /types -* [\#9695](https://github.com/cosmos/cosmos-sdk/pull/9695) Migrate keys from `Info` -> `Record` +* [\#9695](https://github.com/cosmos/cosmos-sdk/pull/9695) Migrate keys from `Info` (serialized as amino) -> `Record` (serialized as proto) * Add new `codec.Codec` argument in: * `keyring.NewInMemory` * `keyring.New` @@ -128,19 +142,14 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#10248](https://github.com/cosmos/cosmos-sdk/pull/10248) Remove unused `KeyPowerReduction` variable from x/staking types. * (x/bank) [\#9832](https://github.com/cosmos/cosmos-sdk/pull/9832) `AddressFromBalancesStore` renamed to `AddressAndDenomFromBalancesStore`. * (tests) [\#9938](https://github.com/cosmos/cosmos-sdk/pull/9938) `simapp.Setup` accepts additional `testing.T` argument. -* (baseapp) [\#9920](https://github.com/cosmos/cosmos-sdk/pull/9920) BaseApp `{Check,Deliver,Simulate}Tx` methods are now replaced by a middleware stack. - * Replace the Antehandler interface with the `tx.Handler` and `tx.Middleware` interfaces. - * Replace `baseapp.SetAnteHandler` with `baseapp.SetTxHandler`. - * Move Msg routers from BaseApp to middlewares. - * Move Baseapp panic recovery into a middleware. - * Rename simulation helper methods `baseapp.{Check,Deliver}` to `baseapp.Sim{Check,Deliver}**`. +* (baseapp) [\#11979](https://github.com/cosmos/cosmos-sdk/pull/11979) Rename baseapp simulation helper methods `baseapp.{Check,Deliver}` to `baseapp.Sim{Check,Deliver}`. * (x/gov) [\#10373](https://github.com/cosmos/cosmos-sdk/pull/10373) Removed gov `keeper.{MustMarshal, MustUnmarshal}`. * [\#10348](https://github.com/cosmos/cosmos-sdk/pull/10348) StdSignBytes takes a new argument of type `*tx.Tip` for signing over tips using LEGACY_AMINO_JSON. * [\#10208](https://github.com/cosmos/cosmos-sdk/pull/10208) The `x/auth/signing.Tx` interface now also includes a new `GetTip() *tx.Tip` method for verifying tipped transactions. The `x/auth/types` expected BankKeeper interface now expects the `SendCoins` method too. * [\#10612](https://github.com/cosmos/cosmos-sdk/pull/10612) `baseapp.NewBaseApp` constructor function doesn't take the `sdk.TxDecoder` anymore. This logic has been moved into the TxDecoderMiddleware. * [\#10692](https://github.com/cosmos/cosmos-sdk/pull/10612) `SignerData` takes 2 new fields, `Address` and `PubKey`, which need to get populated when using SIGN_MODE_DIRECT_AUX. * [\#10748](https://github.com/cosmos/cosmos-sdk/pull/10748) Move legacy `x/gov` api to `v1beta1` directory. -* [\#10816](https://github.com/cosmos/cosmos-sdk/pull/10816) Reuse blocked addresses from the bank module. No need to pass them to distribution. +* [\#10816](https://github.com/cosmos/cosmos-sdk/pull/10816) Reuse blocked addresses from the bank module. No need to pass them to distribution. * [\#10852](https://github.com/cosmos/cosmos-sdk/pull/10852) Move `x/gov/types` to `x/gov/types/v1beta2`. * [\#10922](https://github.com/cosmos/cosmos-sdk/pull/10922), [/#10957](https://github.com/cosmos/cosmos-sdk/pull/10957) Move key `server.Generate*` functions to testutil and support custom mnemonics in in-process testing network. Moved `TestMnemonic` from `testutil` package to `testdata`. * (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). @@ -153,10 +162,13 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `types/errors.New` now is an alias for `types/errors.Register` and should only be used in initialization code. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) `authz.NewMsgGrant` `expiration` is now a pointer. When `nil` is used then no expiration will be set (grant won't expire). * (x/distribution)[\#11457](https://github.com/cosmos/cosmos-sdk/pull/11457) Add amount field to `distr.MsgWithdrawDelegatorRewardResponse` and `distr.MsgWithdrawValidatorCommissionResponse`. +* [\#11334](https://github.com/cosmos/cosmos-sdk/pull/11334) Move `x/gov/types/v1beta2` to `x/gov/types/v1`. * (x/auth/middleware) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to be extensible on tx fee logic. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, make the logic extensible using the `TxFeeChecker` option, the current fee logic is preserved by the default `checkTxFeeWithValidatorMinGasPrices` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` which is extensible with the `ExtensionOptionChecker` option. Unpack the tx extension options `Any`s to interface `TxExtensionOptionI`. +* (migrations) [#11556](https://github.com/cosmos/cosmos-sdk/pull/11556#issuecomment-1091385011) Remove migration code from 0.42 and below. To use previous migrations, checkout previous versions of the cosmos-sdk. ### Client Breaking Changes +* [\#11797](https://github.com/cosmos/cosmos-sdk/pull/11797) Remove all RegisterRESTRoutes (previously deprecated) * [\#11089](https://github.com/cosmos/cosmos-sdk/pull/11089]) interacting with the node through `grpc.Dial` requires clients to pass a codec refer to [doc](docs/run-node/interact-node.md). * [\#9594](https://github.com/cosmos/cosmos-sdk/pull/9594) Remove legacy REST API. Please see the [REST Endpoints Migration guide](https://docs.cosmos.network/master/migrations/rest.html) to migrate to the new REST endpoints. * [\#9995](https://github.com/cosmos/cosmos-sdk/pull/9995) Increased gas cost for creating proposals. @@ -166,16 +178,19 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### CLI Breaking Changes -* [\#9695](https://github.com/cosmos/cosmos-sdk/pull/9695) ` keys migrate` CLI command now takes no arguments +* (cli) [\#11818](https://github.com/cosmos/cosmos-sdk/pull/11818) CLI transactions preview now respect the chosen `--output` flag format (json or text). +* [\#9695](https://github.com/cosmos/cosmos-sdk/pull/9695) ` keys migrate` CLI command now takes no arguments. * [\#9246](https://github.com/cosmos/cosmos-sdk/pull/9246) Removed the CLI flag `--setup-config-only` from the `testnet` command and added the subcommand `init-files`. * [\#9780](https://github.com/cosmos/cosmos-sdk/pull/9780) Use sigs.k8s.io for yaml, which might lead to minor YAML output changes * [\#10625](https://github.com/cosmos/cosmos-sdk/pull/10625) Rename `--fee-account` CLI flag to `--fee-granter` * [\#10684](https://github.com/cosmos/cosmos-sdk/pull/10684) Rename `edit-validator` command's `--moniker` flag to `--new-moniker` -* [\#11116](https://github.com/cosmos/cosmos-sdk/pull/11116) `software-upgrade` and `cancel-software-upgrade` gov proposal commands have changed to `legacy-software-upgrade` and `legacy-cancel-software-upgrade`. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) Changed the default value of the `--expiration` `tx grant` CLI Flag: was now + 1year, update: null (no expire date). ### Improvements +* [\#11696](https://github.com/cosmos/cosmos-sdk/pull/11696) Rename `helpers.GenTx` to `GenSignedMockTx` to avoid confusion with genutil's `GenTxCmd`. +* (x/auth/vesting) [\#11652](https://github.com/cosmos/cosmos-sdk/pull/11652) Add util functions for `Period(s)` +* [\#11630](https://github.com/cosmos/cosmos-sdk/pull/11630) Add SafeSub method to sdk.Coin. * [\#11511](https://github.com/cosmos/cosmos-sdk/pull/11511) Add api server flags to start command. * [\#11484](https://github.com/cosmos/cosmos-sdk/pull/11484) Implement getter for keyring backend option. * [\#11449](https://github.com/cosmos/cosmos-sdk/pull/11449) Improved error messages when node isn't synced. @@ -203,11 +218,21 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (types) [\#11200](https://github.com/cosmos/cosmos-sdk/pull/11200) Added `Min()` and `Max()` operations on sdk.Coins. * (gov) [\#11287](https://github.com/cosmos/cosmos-sdk/pull/11287) Fix error message when no flags are provided while executing `submit-legacy-proposal` transaction. * (x/auth) [\#11482](https://github.com/cosmos/cosmos-sdk/pull/11482) Improve panic message when attempting to register a method handler for a message that does not implement sdk.Msg +* (x/staking) [\#11596](https://github.com/cosmos/cosmos-sdk/pull/11596) Add (re)delegation getters +* (errors) [\#11960](https://github.com/cosmos/cosmos-sdk/pull/11960) Removed 'redacted' error message from defaultErrEncoder +* (ante) [#12013](https://github.com/cosmos/cosmos-sdk/pull/12013) Index ante events for failed tx. ### Bug Fixes +* [#11969](https://github.com/cosmos/cosmos-sdk/pull/11969) Fix the panic error in `x/upgrade` when `AppVersion` is not set. +* (tests) [\#11940](https://github.com/cosmos/cosmos-sdk/pull/11940) Fix some client tests in the `x/gov` module +* [\#11772](https://github.com/cosmos/cosmos-sdk/pull/11772) Limit types.Dec length to avoid overflow. +* [\#11724](https://github.com/cosmos/cosmos-sdk/pull/11724) Fix data race issues with api.Server +* [\#11693](https://github.com/cosmos/cosmos-sdk/pull/11693) Add validation for gentx cmd. +* [\#11645](https://github.com/cosmos/cosmos-sdk/pull/11645) Fix `--home` flag ignored when running help. +* [\#11558](https://github.com/cosmos/cosmos-sdk/pull/11558) Fix `--dry-run` not working when using tx command. * [\#11354](https://github.com/cosmos/cosmos-sdk/pull/11355) Added missing pagination flag for `bank q total` query. -* [\#11197](https://github.com/cosmos/cosmos-sdk/pull/11197) Signing with multisig now works with multisig address which is not in the keyring. +* [\#11197](https://github.com/cosmos/cosmos-sdk/pull/11197) Signing with multisig now works with multisig address which is not in the keyring. * (makefile) [\#11285](https://github.com/cosmos/cosmos-sdk/pull/11285) Fix lint-fix make target. * (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. @@ -249,9 +274,17 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (cli) [\#11337](https://github.com/cosmos/cosmos-sdk/pull/11337) Fixes `show-adress` cli cmd * (crypto) [\#11298](https://github.com/cosmos/cosmos-sdk/pull/11298) Fix cgo secp signature verification and update libscep256k1 library. * (x/authz) [\#11512](https://github.com/cosmos/cosmos-sdk/pull/11512) Fix response of a panic to error, when subtracting balances. +* (rosetta) [\#11590](https://github.com/cosmos/cosmos-sdk/pull/11590) `/block` returns an error with nil pointer when a request has both of index and hash and increase timeout for huge genesis. +* (x/feegrant) [\#11813](https://github.com/cosmos/cosmos-sdk/pull/11813) Fix pagination total count in `AllowancesByGranter` query. +* (simapp) [\#11855](https://github.com/cosmos/cosmos-sdk/pull/11855) Use `sdkmath.Int` instead of `int64` for `SimulationState.InitialStake`. +* (x/capability) [\#11737](https://github.com/cosmos/cosmos-sdk/pull/11737) Use a fixed length encoding of `Capability` pointer for `FwdCapabilityKey` +* [\#11983](https://github.com/cosmos/cosmos-sdk/pull/11983) (x/feegrant, x/authz) rename grants query commands to `grants-by-grantee`, `grants-by-granter` cmds. ### State Machine Breaking +* (baseapp) [\#11985](https://github.com/cosmos/cosmos-sdk/pull/11985) Add a `postHandler` to baseapp. This `postHandler` is like antehandler, but is run _after_ the `runMsgs` execution. It is in the same store branch that `runMsgs`, meaning that both `runMsgs` and `postHandler` +* (x/gov) [#11998](https://github.com/cosmos/cosmos-sdk/pull/11998) Tweak the `x/gov` `ModuleAccountInvariant` invariant to ensure deposits are `<=` total module account balance instead of strictly equal. +* (x/upgrade) [\#11800](https://github.com/cosmos/cosmos-sdk/pull/11800) Fix `GetLastCompleteUpgrade` to properly return the latest upgrade. * [\#10564](https://github.com/cosmos/cosmos-sdk/pull/10564) Fix bug when updating allowance inside AllowedMsgAllowance * (x/auth)[\#9596](https://github.com/cosmos/cosmos-sdk/pull/9596) Enable creating periodic vesting accounts with a transactions instead of requiring them to be created in genesis. * (x/bank) [\#9611](https://github.com/cosmos/cosmos-sdk/pull/9611) Introduce a new index to act as a reverse index between a denomination and address allowing to query for @@ -260,22 +293,76 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/bank) [\#9890](https://github.com/cosmos/cosmos-sdk/pull/9890) Remove duplicate denom from denom metadata key. * (x/upgrade) [\#10189](https://github.com/cosmos/cosmos-sdk/issues/10189) Removed potential sources of non-determinism in upgrades * [\#10422](https://github.com/cosmos/cosmos-sdk/pull/10422) and [\#10529](https://github.com/cosmos/cosmos-sdk/pull/10529) Add `MinCommissionRate` param to `x/staking` module. -* [#10763](https://github.com/cosmos/cosmos-sdk/pull/10763) modify the fields in `TallyParams` to use `string` instead of `bytes` +* (x/gov) [#10763](https://github.com/cosmos/cosmos-sdk/pull/10763) modify the fields in `TallyParams` to use `string` instead of `bytes` * [#10770](https://github.com/cosmos/cosmos-sdk/pull/10770) revert tx when block gas limit exceeded -* [\#10868](https://github.com/cosmos/cosmos-sdk/pull/10868) Bump gov to v1beta2. Both v1beta1 and v1beta2 queries and Msgs are accepted. -* [\#11011](https://github.com/cosmos/cosmos-sdk/pull/11011) Remove burning of deposits when qourum is not reached on a governance proposal and when the deposit is not fully met. +* (x/gov) [\#10868](https://github.com/cosmos/cosmos-sdk/pull/10868) Bump gov to v1beta2. Both v1beta1 and v1beta2 queries and Msgs are accepted. +* [\#11011](https://github.com/cosmos/cosmos-sdk/pull/11011) Remove burning of deposits when qourum is not reached on a governance proposal and when the deposit is not fully met. * [\#11019](https://github.com/cosmos/cosmos-sdk/pull/11019) Add `MsgCreatePermanentLockedAccount` and CLI method for creating permanent locked account * (x/staking) [\#10885] (https://github.com/cosmos/cosmos-sdk/pull/10885) Add new `CancelUnbondingDelegation` - transaction to `x/staking` module. Delegators can now cancel unbonding delegation entry and re-delegate back to validator. + transaction to `x/staking` module. Delegators can now cancel unbonding delegation entry and delegate back to validator. * (x/feegrant) [\#10830](https://github.com/cosmos/cosmos-sdk/pull/10830) Expired allowances will be pruned from state. * (x/authz,x/feegrant) [\#11214](https://github.com/cosmos/cosmos-sdk/pull/11214) Fix Amino JSON encoding of authz and feegrant Msgs to be consistent with other modules. * (authz)[\#11060](https://github.com/cosmos/cosmos-sdk/pull/11060) Support grant with no expire time. +* (x/gov) [\#10868](https://github.com/cosmos/cosmos-sdk/pull/10868) Bump gov to v1. ### Deprecated * (x/upgrade) [\#9906](https://github.com/cosmos/cosmos-sdk/pull/9906) Deprecate `UpgradeConsensusState` gRPC query since this functionality is only used for IBC, which now has its own [IBC replacement](https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54) * (types) [\#10948](https://github.com/cosmos/cosmos-sdk/issues/10948) Deprecate the types.DBBackend variable and types.NewLevelDB function. They are replaced by a new entry in `app.toml`: `app-db-backend` and `tendermint/tm-db`s `NewDB` function. If `app-db-backend` is defined, then it is used. Otherwise, if `types.DBBackend` is defined, it is used (until removed: [\#11241](https://github.com/cosmos/cosmos-sdk/issues/11241)). Otherwise, Tendermint config's `db-backend` is used. +## [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. + +### 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 + +### Bug Fixes + +* (grpc) [\#10985](https://github.com/cosmos/cosmos-sdk/pull/10992) The `/cosmos/tx/v1beta1/txs/{hash}` endpoint returns a 404 when a tx does not exist. +* [\#10990](https://github.com/cosmos/cosmos-sdk/pull/10990) Fixes missing `iavl-cache-size` config parsing in `GetConfig` method. +* [#11222](https://github.com/cosmos/cosmos-sdk/pull/11222) reject query with block height in the future + +### Improvements + +* [\#10407](https://github.com/cosmos/cosmos-sdk/pull/10407) Added validation to `x/upgrade` module's `BeginBlock` to check accidental binary downgrades +* [\#10768](https://github.com/cosmos/cosmos-sdk/pull/10768) Extra logging in in-place store migrations. + ## [v0.45.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.45.0) - 2022-01-18 ### State Machine Breaking @@ -291,7 +378,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#10561](https://github.com/cosmos/cosmos-sdk/pull/10561) The `CommitMultiStore` interface contains a new `SetIAVLCacheSize` method * [\#10922](https://github.com/cosmos/cosmos-sdk/pull/10922), [/#10956](https://github.com/cosmos/cosmos-sdk/pull/10956) Deprecate key `server.Generate*` functions and move them to `testutil` and support custom mnemonics in in-process testing network. Moved `TestMnemonic` from `testutil` package to `testdata`. -* [\#11049](https://github.com/cosmos/cosmos-sdk/pull/11049) Add custom tendermint config variables into root command. Allows App developers to set config.toml variables. +* [\#11049](https://github.com/cosmos/cosmos-sdk/pull/11049) Add custom tendermint config variables into root command. Allows App developers to set config.toml variables. ### Features @@ -310,17 +397,58 @@ 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` * [\#10061](https://github.com/cosmos/cosmos-sdk/pull/10061) and [\#10515](https://github.com/cosmos/cosmos-sdk/pull/10515) Ensure that `LegacyAminoPubKey` struct correctly unmarshals from JSON +## [v0.44.8](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.8) - 2022-04-12 + +### Improvements + +* [\#11563](https://github.com/cosmos/cosmos-sdk/pull/11563) Updated Tendermint to v0.34.19; `unsafe-reset-all` command has been moved to the `tendermint` sub-command. + +## [v0.44.7](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.7) - 2022-04-04 + +### Features + +* (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. + +### Bug Fixes + +* [\#11354](https://github.com/cosmos/cosmos-sdk/pull/11355) Added missing pagination flag for `bank q total` query. +* (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 + +### Improvements + +* [\#9576](https://github.com/cosmos/cosmos-sdk/pull/9576) Add debug error message to query result when enabled + +## [v0.44.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.6) - 2022-02-02 + +### Features + +* [\#11124](https://github.com/cosmos/cosmos-sdk/pull/11124) Add `GetAllVersions` to application store + +### Bug Fixes + +* (grpc) [\#10985](https://github.com/cosmos/cosmos-sdk/pull/10992) The `/cosmos/tx/v1beta1/txs/{hash}` endpoint returns a 404 when a tx does not exist. +* (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. +* [#10725](https://github.com/cosmos/cosmos-sdk/pull/10725) populate `ctx.ConsensusParams` for begin/end blockers. +* [\#10061](https://github.com/cosmos/cosmos-sdk/pull/10061) and [\#10515](https://github.com/cosmos/cosmos-sdk/pull/10515) Ensure that `LegacyAminoPubKey` struct correctly unmarshals from JSON + +### Improvements + +* [#10823](https://github.com/cosmos/cosmos-sdk/pull/10823) updated ambiguous cli description for creating feegrant. + ## [v0.44.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.44.5) - 2021-12-02 ### 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. * (store) [\#10741](https://github.com/cosmos/cosmos-sdk/pull/10741) Significantly speedup iterator creation after delete heavy workloads. Significantly improves IBC migration times. ### Bug Fixes @@ -1096,7 +1224,7 @@ sure you are aware of any relevant breaking changes. * (x/auth/vesting) [\#7209](https://github.com/cosmos/cosmos-sdk/pull/7209) Create new `MsgCreateVestingAccount` message type along with CLI handler that allows for the creation of delayed and continuous vesting types. * (x/capability) [\#5828](https://github.com/cosmos/cosmos-sdk/pull/5828) Capability module integration as outlined in [ADR 3 - Dynamic Capability Store](https://github.com/cosmos/tree/master/docs/architecture/adr-003-dynamic-capability-store.md). * (x/crisis) `x/crisis` has a new function: `AddModuleInitFlags`, which will register optional crisis module flags for the start command. - * (x/ibc) [\#5277](https://github.com/cosmos/cosmos-sdk/pull/5277) `x/ibc` changes from IBC alpha. For more details check the the [`x/ibc/core/spec`](https://github.com/cosmos/cosmos-sdk/tree/master/x/ibc/core/spec) directory, or the ICS specs below: + * (x/ibc) [\#5277](https://github.com/cosmos/cosmos-sdk/pull/5277) `x/ibc` changes from IBC alpha. For more details check the [`x/ibc/core/spec`](https://github.com/cosmos/cosmos-sdk/tree/master/x/ibc/core/spec) directory, or the ICS specs below: * [ICS 002 - Client Semantics](https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics) subpackage * [ICS 003 - Connection Semantics](https://github.com/cosmos/ics/blob/master/spec/ics-003-connection-semantics) subpackage * [ICS 004 - Channel and Packet Semantics](https://github.com/cosmos/ics/blob/master/spec/ics-004-channel-and-packet-semantics) subpackage diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7c2621f9b310..05f3ff79d0c2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,11 +25,11 @@ Thank you for considering making contributions to the Cosmos SDK and related repositories! -Contributing to this repo can mean many things such as participating in +Contributing to this repo can mean many things, such as participating in discussion or proposing code changes. To ensure a smooth workflow for all contributors, the general procedure for contributing has been established: -1. Start by browsing [new issues](https://github.com/cosmos/cosmos-sdk/issues) and [discussions](https://github.com/cosmos/cosmos-sdk/discussions). If you are looking for something interesting or if you have something in your mind, there is a chance it was has been discussed. +1. Start by browsing [new issues](https://github.com/cosmos/cosmos-sdk/issues) and [discussions](https://github.com/cosmos/cosmos-sdk/discussions). If you are looking for something interesting or if you have something in your mind, there is a chance it had been discussed. * Looking for a good place to start contributing? How about checking out some [good first issues](https://github.com/cosmos/cosmos-sdk/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)? 2. Determine whether a GitHub issue or discussion is more appropriate for your needs: 1. If want to propose something new that requires specification or an additional design, or you would like to change a process, start with a [new discussion](https://github.com/cosmos/cosmos-sdk/discussions/new). With discussions, we can better handle the design process using discussion threads. A discussion usually leads to one or more issues. @@ -69,16 +69,16 @@ If you would like to join one of those calls, then please contact us on [Discord ## Architecture Decision Records (ADR) -When proposing an architecture decision for the Cosmos SDK, please start by opening an [issue](https://github.com/cosmos/cosmos-sdk/issues/new/choose) or a [discussion](https://github.com/cosmos/cosmos-sdk/discussions/new) with a summary of the proposal. Once the proposal has been discussed and there is rough alignment on a high-level approach to the design, the [ADR creation process](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/PROCESS.md) can begin. We are following this process to ensure all involved parties are in agreement before any party begins coding the proposed implementation. If you would like to see examples of how these are written, please refer to the current [ADRs](https://github.com/cosmos/cosmos-sdk/tree/master/docs/architecture). +When proposing an architecture decision for the Cosmos SDK, please start by opening an [issue](https://github.com/cosmos/cosmos-sdk/issues/new/choose) or a [discussion](https://github.com/cosmos/cosmos-sdk/discussions/new) with a summary of the proposal. Once the proposal has been discussed and there is rough alignment on a high-level approach to the design, the [ADR creation process](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/PROCESS.md) can begin. We are following this process to ensure all involved parties are in agreement before any party begins coding the proposed implementation. If you would like to see examples of how these are written, please refer to the current [ADRs](https://github.com/cosmos/cosmos-sdk/tree/main/docs/architecture). ## Development Procedure -* The latest state of development is on `master`. -* `master` must never fail `make lint test test-race`. -* No `--force` onto `master` (except when reverting a broken commit, which should seldom happen). -* Create a branch to start a wok: +* The latest state of development is on `main`. +* `main` must never fail `make lint test test-race`. +* No `--force` onto `main` (except when reverting a broken commit, which should seldom happen). +* Create a branch to start work: * Fork the repo (core developers must create a branch directly in the Cosmos SDK repo), - branch from the HEAD of `master`, make some commits, and submit a PR to `master`. + branch from the HEAD of `main`, make some commits, and submit a PR to `main`. * For core developers working within the `cosmos-sdk` repo, follow branch name conventions to ensure a clear ownership of branches: `{moniker}/{issue#}-branch-name`. * See [Branching Model](#branching-model-and-release) for more details. @@ -90,7 +90,7 @@ When proposing an architecture decision for the Cosmos SDK, please start by open before each commit is available in the `contrib/githooks/` directory. * Follow the [CODING GUIDELINES](CODING_GUIDELINES.md), which defines criteria for designing and coding a software. -Code is merged into master through pull request procedure. +Code is merged into main through pull request procedure. ### Testing @@ -100,7 +100,7 @@ Tests can be executed by running `make test` at the top level of the Cosmos SDK Before submitting a pull request: -* merge the latest master `git merge origin/master`, +* merge the latest main `git merge origin/main`, * run `make lint test` to ensure that all checks and tests pass. Then: @@ -117,9 +117,9 @@ PRs must have a category prefix that is based on the type of changes being made [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification. Additionally, each PR should only address a single issue. -Pull requests are merged automatically using [`automerge` action](https://mergify.io/features/auto-merge). +Pull requests are merged automatically using [`A:automerge` action](https://mergify.io/features/auto-merge). -NOTE: when merging, GitHub will squash commits and rebase on top of the master. +NOTE: when merging, GitHub will squash commits and rebase on top of the main. ### Pull Request Templates @@ -169,7 +169,7 @@ When writing documentation, follow the [Documentation Writing Guidelines](./docs We use [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependency versions. -The master branch of every Cosmos repository should just build with `go get`, +The main branch of every Cosmos repository should just build with `go get`, which means they should be kept up-to-date with their dependencies, so we can get away with telling people they can just `go get` our software. @@ -180,7 +180,7 @@ build, in which case we can fall back on `go mod tidy -v`. We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use in Cosmos SDK. -For determinstic behavior around Protobuf tooling, everything is containerized using Docker. Make sure to have Docker installed on your machine, or head to [Docker's website](https://docs.docker.com/get-docker/) to install it. +For deterministic behavior around Protobuf tooling, everything is containerized using Docker. Make sure to have Docker installed on your machine, or head to [Docker's website](https://docs.docker.com/get-docker/) to install it. For formatting code in `.proto` files, you can run `make proto-format` command. @@ -215,15 +215,15 @@ The Cosmos SDK utilizes [semantic versioning](https://semver.org/). ### PR Targeting -Ensure that you base and target your PR on the `master` branch. +Ensure that you base and target your PR on the `main` branch. -All feature additions and all bug fixes must be targeted against `master`. Exception is for bug fixes which are only related to a released version. In that case, the related bug fix PRs must target against the release branch. +All feature additions and all bug fixes must be targeted against `main`. Exception is for bug fixes which are only related to a released version. In that case, the related bug fix PRs must target against the release branch. -If needed, we backport a commit from `master` to a release branch (excluding consensus breaking feature, API breaking and similar). +If needed, we backport a commit from `main` to a release branch (excluding consensus breaking feature, API breaking and similar). ## Code Owner Membership -In the ethos of open source projects, and out of necessity to keep the code +In the ethos of open-source projects, and out of necessity to keep the code alive, the core contributor team will strive to permit special repo privileges to developers who show an aptitude towards developing with this code base. @@ -243,7 +243,7 @@ The other code owners should then all approve this PR to publicly display their Only if unanimous consensus is reached among all the existing code-owners will an invitation be extended to a new potential-member. Likewise, when an existing member is suggested to be removed/or have their privileges reduced, the member -in question must agree on the decision for their removal or else no action +in question must agree to the decision for their removal or else no action should be taken. If however, a code-owner is demonstrably shown to intentionally have had acted maliciously or grossly negligent, code-owner privileges may be stripped with no prior warning or consent from the member in question. @@ -273,9 +273,9 @@ is broken up into three distinct stages: **Strategy Discovery**, **Concept Appro * Architecture Decision Records (ADRs) may be proposed by any contributors or maintainers of the Cosmos SDK, and should follow the guidelines outlined in the - [ADR Creation Process](https://github.com/cosmos/cosmos-sdk/blob/master/docs/architecture/PROCESS.md) + [ADR Creation Process](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/PROCESS.md) * After proposal, a time bound period for Request for Comment (RFC) on ADRs commences -* ADRs are intended to be iterative, and may be merged into `master` while still in a `Proposed` status +* ADRs are intended to be iterative, and may be merged into `main` while still in a `Proposed` status #### Time Bound Period diff --git a/Dockerfile b/Dockerfile index ffcbeccbc15f..026f222c594a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ # > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys add foo # > docker run -it -p 26657:26657 -p 26656:26656 -v ~/.simappcli:/root/.simapp simapp simd keys list # TODO: demo connecting rest-server (or is this in server now?) -FROM golang:alpine AS build-env +FROM golang:1.18-alpine AS build-env # Install minimum necessary dependencies ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3 diff --git a/Makefile b/Makefile index 3b73786892c0..49ffdc1668aa 100644 --- a/Makefile +++ b/Makefile @@ -193,7 +193,7 @@ godocs: # This builds a docs site for each branch/tag in `./docs/versions` # and copies each site to a version prefixed path. The last entry inside -# the `versions` file will be the default root index.html. +# the `versions` file will be the default root index.html (and it should be main). build-docs: @cd docs && \ while read -r branch path_prefix; do \ @@ -202,6 +202,7 @@ build-docs: mkdir -p ~/output/$${path_prefix} ; \ cp -r .vuepress/dist/* ~/output/$${path_prefix}/ ; \ cp ~/output/$${path_prefix}/index.html ~/output ; \ + cp ~/output/$${path_prefix}/404.html ~/output ; \ done < versions ; @echo $(DOCS_DOMAIN) > ~/output/CNAME @@ -395,7 +396,7 @@ devdoc-update: ### Protobuf ### ############################################################################### -protoVer=v0.6 +protoVer=v0.7 protoImageName=tendermintdev/sdk-proto-gen:$(protoVer) containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer) containerProtoGenAny=$(PROJECT_NAME)-proto-gen-any-$(protoVer) @@ -430,7 +431,7 @@ proto-lint: @$(DOCKER_BUF) lint --error-format=json proto-check-breaking: - @$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=master + @$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc6/proto/tendermint diff --git a/README.md b/README.md index 390abf34aa20..1462fa2eee04 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,7 @@ parent: ![banner](docs/cosmos-sdk-image.jpg)
- - Version - - + License: Apache-2.0 @@ -23,7 +20,7 @@ parent: Go report card - Code Coverage + Code Coverage
@@ -45,7 +42,7 @@ The Cosmos SDK is a framework for building blockchain applications. [Tendermint **WARNING**: The Cosmos SDK has mostly stabilized, but we are still making some breaking changes. -**Note**: Requires [Go 1.17+](https://golang.org/dl/) +**Note**: Requires [Go 1.18+](https://go.dev/dl) ## Quick Start @@ -75,9 +72,9 @@ The Cosmos Hub application, `gaia`, has moved to its own [cosmos/gaia repository 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. -### Starport +### Ignite CLI -Starport 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 [Starport](https://github.com/tendermint/starport) to get started and speed up development. +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 diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md index ca4b7c5ce7f6..76b9156d47da 100644 --- a/RELEASE_PROCESS.md +++ b/RELEASE_PROCESS.md @@ -12,25 +12,26 @@ Before making a new _major_ release we do beta and release candidate releases. F v1.0.0-beta1 → v1.0.0-beta2 → ... → v1.0.0-rc1 → v1.0.0-rc2 → ... → v1.0.0 ``` -* Release a first beta version on the `master` branch and freeze `master` from receiving any new features. After beta is released, we focus on releasing the release candidate: +* Release a first beta version on the `main` branch and freeze `main` from receiving any new features. After beta is released, we focus on releasing the release candidate: * finish audits and reviews * kick off a large round of simulation testing (e.g. 400 seeds for 2k blocks) * perform functional tests * add more tests * release new beta version as the bugs are discovered and fixed. -* After the team feels that the `master` works fine we create a `release/vY` branch (going forward known a release branch), where `Y` is the version number, with the patch part substituted to `x` (eg: 0.42.x, 1.0.x). Ensure the release branch is protected so that pushes against the release branch are permitted only by the release manager or release coordinator. +* After the team feels that the `main` works fine we create a `release/vY` branch (going forward known a release branch), where `Y` is the version number, with the patch part substituted to `x` (eg: 0.42.x, 1.0.x). Ensure the release branch is protected so that pushes against the release branch are permitted only by the release manager or release coordinator. * **PRs targeting this branch can be merged _only_ when exceptional circumstances arise** - * update the GitHub mergify integration by adding instructions for automatically backporting commits from `master` to the `release/vY` using the `backport/Y` label. + * update the GitHub mergify integration by adding instructions for automatically backporting commits from `main` to the `release/vY` using the `backport/Y` label. * In the release branch, prepare a new version section in the `CHANGELOG.md` * All links must be link-ified: `$ python ./scripts/linkify_changelog.py CHANGELOG.md` * Copy the entries into a `RELEASE_CHANGELOG.md`, this is needed so the bot knows which entries to add to the release page on GitHub. * Create a new annotated git tag for a release candidate (eg: `git tag -a v1.1.0-rc1`) in the release branch. - * from this point we unfreeze master. + * from this point we unfreeze main. * the SDK teams collaborate and do their best to run testnets in order to validate the release. - * when bugs are found, create a PR for `master`, and backport fixes to the release branch. + * when bugs are found, create a PR for `main`, and backport fixes to the release branch. * create new release candidate tags after bugs are fixed. * After the team feels the release branch is stable and everything works, create a full release: * update `CHANGELOG.md`. + * run `gofumpt -w -l .` to format the code. * create a new annotated git tag (eg `git -a v1.1.0`) in the release branch. * Create a GitHub release. @@ -47,7 +48,7 @@ A _patch release_ is an increment of the patch number (eg: `v1.2.0` → `v1.2.1` **Patch release must not break API nor consensus.** -Updates to the release branch should come from `master` by backporting PRs (usually done by automatic cherry pick followed by a PRs to the release branch). The backports must be marked using `backport/Y` label in PR for master. +Updates to the release branch should come from `main` by backporting PRs (usually done by automatic cherry pick followed by a PRs to the release branch). The backports must be marked using `backport/Y` label in PR for main. It is the PR author's responsibility to fix merge conflicts, update changelog entries, and ensure CI passes. If a PR originates from an external contributor, a core team member assumes responsibility to perform this process instead of the original author. @@ -82,8 +83,8 @@ and must follow the [Patch Release Procedure][CONTRIBUTING.md#patch-release-proc ### Rationale -Unlike in-development `master` branch snapshots, **Cosmos-SDK** releases are subject to much wider adoption, -and by a significantly different demographic of users. During development, changes in the `master` branch +Unlike in-development `main` branch snapshots, **Cosmos-SDK** releases are subject to much wider adoption, +and by a significantly different demographic of users. During development, changes in the `main` branch affect SDK users, application developers, early adopters, and other advanced users that elect to use unstable experimental software at their own risk. @@ -97,13 +98,13 @@ poorly tested code. We never assume that any change, no matter how little or non of regression risks. Therefore, the requirements for stable changes are different than those that are candidates to be merged in -the `master` branch. When preparing future major releases, our aim is to design the most elegant, user-friendly and +the `main` branch. When preparing future major releases, our aim is to design the most elegant, user-friendly and maintainable SDK possible which often entails fundamental changes to the SDK's architecture design, rearranging and/or renaming packages as well as reducing code duplication so that we maintain common functions and data structures in one place rather than leaving them scattered all over the code base. However, once a release is published, the -priority is to minimise the risk caused by changes that are not strictly required to fix qualifying bugs; this tends to -be correlated with minimising the size of such changes. As such, the same bug may need to be fixed in different -ways in stable releases and `master` branch. +priority is to minimize the risk caused by changes that are not strictly required to fix qualifying bugs; this tends to +be correlated with minimizing the size of such changes. As such, the same bug may need to be fixed in different +ways in stable releases and `main` branch. ### Migrations @@ -157,7 +158,7 @@ As rule of thumb, the following changes will **NOT** be automatically accepted i ### Stable Release Exception - Procedure -1. Check that the bug is either fixed or not reproducible in `master`. It is, in general, not appropriate to release bug fixes for stable releases without first testing them in `master`. Please apply the label [v0.43](https://github.com/cosmos/cosmos-sdk/milestone/26) to the issue. +1. Check that the bug is either fixed or not reproducible in `main`. It is, in general, not appropriate to release bug fixes for stable releases without first testing them in `main`. Please apply the label [v0.43](https://github.com/cosmos/cosmos-sdk/milestone/26) to the issue. 2. Add a comment to the issue and ensure it contains the following information (see the bug template below): * **[Impact]** An explanation of the bug on users and justification for backporting the fix to the stable release. diff --git a/SECURITY.md b/SECURITY.md index b2a83a0dc574..c6bc9179b35f 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -17,34 +17,32 @@ in for Tendermint and other lower-level libraries (eg. [IAVL](https://github.com ### Core packages -* [`/baseapp`](https://github.com/cosmos/cosmos-sdk/tree/master/baseapp) -* [`/crypto`](https://github.com/cosmos/cosmos-sdk/tree/master/crypto) -* [`/types`](https://github.com/cosmos/cosmos-sdk/tree/master/types) -* [`/store`](https://github.com/cosmos/cosmos-sdk/tree/master/store) +* [`/baseapp`](https://github.com/cosmos/cosmos-sdk/tree/main/baseapp) +* [`/crypto`](https://github.com/cosmos/cosmos-sdk/tree/main/crypto) +* [`/types`](https://github.com/cosmos/cosmos-sdk/tree/main/types) +* [`/store`](https://github.com/cosmos/cosmos-sdk/tree/main/store) ### Modules -* [`x/auth`](https://github.com/cosmos/cosmos-sdk/tree/master/x/auth) -* [`x/bank`](https://github.com/cosmos/cosmos-sdk/tree/master/x/bank) -* [`x/capability`](https://github.com/cosmos/cosmos-sdk/tree/master/x/capability) -* [`x/staking`](https://github.com/cosmos/cosmos-sdk/tree/master/x/staking) -* [`x/slashing`](https://github.com/cosmos/cosmos-sdk/tree/master/x/slashing) -* [`x/evidence`](https://github.com/cosmos/cosmos-sdk/tree/master/x/evidence) -* [`x/distribution`](https://github.com/cosmos/cosmos-sdk/tree/master/x/distribution) -* [`x/ibc`](https://github.com/cosmos/cosmos-sdk/tree/master/x/ibc) -* [`x/ibc-transfer`](https://github.com/cosmos/cosmos-sdk/tree/master/x/ibc-transfer) -* [`x/mint`](https://github.com/cosmos/cosmos-sdk/tree/master/x/mint) +* [`x/auth`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth) +* [`x/bank`](https://github.com/cosmos/cosmos-sdk/tree/main/x/bank) +* [`x/capability`](https://github.com/cosmos/cosmos-sdk/tree/main/x/capability) +* [`x/staking`](https://github.com/cosmos/cosmos-sdk/tree/main/x/staking) +* [`x/slashing`](https://github.com/cosmos/cosmos-sdk/tree/main/x/slashing) +* [`x/evidence`](https://github.com/cosmos/cosmos-sdk/tree/main/x/evidence) +* [`x/distribution`](https://github.com/cosmos/cosmos-sdk/tree/main/x/distribution) +* [`x/mint`](https://github.com/cosmos/cosmos-sdk/tree/main/x/mint) We are interested in bugs in other modules, however the above are most likely to have significant vulnerabilities, due to the complexity / nuance involved. We -also recommend you to read the [specification](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/README.md) of each module before digging into +also recommend you to read the [specification](https://github.com/cosmos/cosmos-sdk/blob/main/docs/building-modules/README.md) of each module before digging into the code. ### How we process Tx parameters * Integer operations on tx parameters, especially `sdk.Int` / `sdk.Dec` * Gas calculation & parameter choices -* Tx signature verification (see [`x/auth/ante`](https://github.com/cosmos/cosmos-sdk/tree/master/x/auth/ante)) +* Tx signature verification (see [`x/auth/ante`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth/ante)) * Possible Node DoS vectors (perhaps due to gas weighting / non constant timing) ### Handling private keys @@ -59,7 +57,7 @@ The Cosmos SDK team uses the following disclosure process: 1. After a security report is received, the Cosmos SDK team works to verify the issue and confirm its severity level using Common Vulnerability Scoring System (CVSS). 1. The Cosmos SDK team collaborates with the Tendermint and Gaia teams to determine the vulnerability’s potential impact on the Cosmos Hub and partners. -1. Patches are prepared in private repositories for eligible releases of Cosmos SDK. See [Stable Release Policy](https://github.com/cosmos/cosmos-sdk/blob/master/RELEASE_PROCESS.md#stable-release-policy) for a list of eligible releases. +1. Patches are prepared in private repositories for eligible releases of Cosmos SDK. See [Stable Release Policy](https://github.com/cosmos/cosmos-sdk/blob/main/RELEASE_PROCESS.md#stable-release-policy) for a list of eligible releases. 1. If it is determined that a CVE-ID is required, we request a CVE through a CVE Numbering Authority. 1. We notify the community that a security release is coming to give users time to prepare their systems for the update. Notifications can include forum posts, tweets, and emails to partners and validators. 1. 24 hours after the notification, fixes are applied publicly and new releases are issued. diff --git a/api/cosmos/app/module/v1alpha1/module.pulsar.go b/api/cosmos/app/module/v1alpha1/module.pulsar.go index 7ad00374d030..96e92b72f47d 100644 --- a/api/cosmos/app/module/v1alpha1/module.pulsar.go +++ b/api/cosmos/app/module/v1alpha1/module.pulsar.go @@ -2,9 +2,9 @@ package modulev1alpha1 import ( + _ "cosmossdk.io/api/cosmos/app/v1alpha1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/app/v1alpha1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -423,12 +423,11 @@ var file_cosmos_app_module_v1alpha1_module_proto_rawDesc = []byte{ 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x70, 0x12, 0x15, 0x0a, 0x13, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, - 0x61, 0x31, 0x42, 0x84, 0x02, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x61, 0x31, 0x42, 0xf4, 0x01, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x4d, 0xaa, 0x02, 0x1a, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, diff --git a/api/cosmos/app/v1alpha1/config.pulsar.go b/api/cosmos/app/v1alpha1/config.pulsar.go index ada2a09a13f4..e27c5b6bfbe9 100644 --- a/api/cosmos/app/v1alpha1/config.pulsar.go +++ b/api/cosmos/app/v1alpha1/config.pulsar.go @@ -1135,12 +1135,11 @@ var file_cosmos_app_v1alpha1_config_proto_rawDesc = []byte{ 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x41, 0x6e, 0x79, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0xd6, 0x01, 0x0a, 0x17, + 0x41, 0x6e, 0x79, 0x52, 0x06, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0xc6, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x61, 0x70, 0x70, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x70, 0x2e, 0x56, 0x31, 0x61, 0x6c, diff --git a/api/cosmos/app/v1alpha1/module.pulsar.go b/api/cosmos/app/v1alpha1/module.pulsar.go index a00331b63cce..1da2fea9ce20 100644 --- a/api/cosmos/app/v1alpha1/module.pulsar.go +++ b/api/cosmos/app/v1alpha1/module.pulsar.go @@ -1617,10 +1617,8 @@ type ModuleDescriptor struct { unknownFields protoimpl.UnknownFields // go_import names the package that should be imported by an app to load the - // module in the runtime module registry. Either go_import must be defined here - // or the go_package option must be defined at the file level to indicate - // to users where to location the module implementation. go_import takes - // precedence over go_package when both are defined. + // module in the runtime module registry. It is required to make debugging + // of configuration errors easier for users. GoImport string `protobuf:"bytes,1,opt,name=go_import,json=goImport,proto3" json:"go_import,omitempty"` // use_package refers to a protobuf package that this module // uses and exposes to the world. In an app, only one module should "use" @@ -1694,8 +1692,8 @@ type PackageReference struct { // present in a previous version. // // A package should indicate its revision with a source code comment - // above the package declaration in one of its fields containing the - // test "Revision N" where N is an integer revision. All packages start + // above the package declaration in one of its files containing the + // text "Revision N" where N is an integer revision. All packages start // at revision 0 the first time they are released in a module. // // When a new version of a module is released and items are added to existing @@ -1856,11 +1854,10 @@ var file_cosmos_app_v1alpha1_module_proto_rawDesc = []byte{ 0xa2, 0x1b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x25, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x06, 0x6d, - 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x42, 0xd6, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x42, 0xc6, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, + 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x61, 0x70, 0x70, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, diff --git a/api/cosmos/app/v1alpha1/query.pulsar.go b/api/cosmos/app/v1alpha1/query.pulsar.go index fd85cae0bf8a..7de26bd84a94 100644 --- a/api/cosmos/app/v1alpha1/query.pulsar.go +++ b/api/cosmos/app/v1alpha1/query.pulsar.go @@ -901,11 +901,10 @@ var file_cosmos_app_v1alpha1_query_proto_rawDesc = []byte{ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x42, 0xd5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x22, 0x00, 0x42, 0xc5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0a, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x61, 0x70, 0x70, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, diff --git a/api/cosmos/auth/v1beta1/auth.pulsar.go b/api/cosmos/auth/v1beta1/auth.pulsar.go index a22455468af0..a1332e3a67a9 100644 --- a/api/cosmos/auth/v1beta1/auth.pulsar.go +++ b/api/cosmos/auth/v1beta1/auth.pulsar.go @@ -2080,12 +2080,11 @@ var file_cosmos_auth_v1beta1_auth_proto_rawDesc = []byte{ 0xde, 0x1f, 0x16, 0x53, 0x69, 0x67, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x63, 0x70, 0x32, 0x35, 0x36, 0x6b, 0x31, 0x52, 0x16, 0x73, 0x69, 0x67, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x43, 0x6f, 0x73, 0x74, 0x53, 0x65, 0x63, 0x70, 0x32, 0x35, 0x36, 0x6b, - 0x31, 0x3a, 0x08, 0x98, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x01, 0x42, 0xd4, 0x01, 0x0a, 0x17, + 0x31, 0x3a, 0x08, 0x98, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x01, 0x42, 0xc4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x09, 0x41, 0x75, 0x74, 0x68, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, diff --git a/api/cosmos/auth/v1beta1/genesis.pulsar.go b/api/cosmos/auth/v1beta1/genesis.pulsar.go index 3e35fa7a5560..9f4af0ae4f73 100644 --- a/api/cosmos/auth/v1beta1/genesis.pulsar.go +++ b/api/cosmos/auth/v1beta1/genesis.pulsar.go @@ -665,11 +665,10 @@ var file_cosmos_auth_v1beta1_genesis_proto_rawDesc = []byte{ 0x72, 0x61, 0x6d, 0x73, 0x12, 0x30, 0x0a, 0x08, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x61, 0x63, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x42, 0xd7, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x73, 0x42, 0xc7, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, + 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, diff --git a/api/cosmos/auth/v1beta1/query.pulsar.go b/api/cosmos/auth/v1beta1/query.pulsar.go index 38d7bed61743..aeb2a9f8164e 100644 --- a/api/cosmos/auth/v1beta1/query.pulsar.go +++ b/api/cosmos/auth/v1beta1/query.pulsar.go @@ -2,10 +2,10 @@ package authv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -6119,6 +6119,8 @@ func (x *QueryAccountRequest) GetAddress() string { } // QueryModuleAccountsRequest is the request type for the Query/ModuleAccounts RPC method. +// +// Since: cosmos-sdk 0.46 type QueryModuleAccountsRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6247,6 +6249,8 @@ func (*QueryParamsRequest) Descriptor() ([]byte, []int) { } // QueryModuleAccountsResponse is the response type for the Query/ModuleAccounts RPC method. +// +// Since: cosmos-sdk 0.46 type QueryModuleAccountsResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6282,7 +6286,9 @@ func (x *QueryModuleAccountsResponse) GetAccounts() []*anypb.Any { return nil } -// Bech32PrefixRequest is the request type for Bech32Prefix rpc method +// Bech32PrefixRequest is the request type for Bech32Prefix rpc method. +// +// Since: cosmos-sdk 0.46 type Bech32PrefixRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6309,7 +6315,9 @@ func (*Bech32PrefixRequest) Descriptor() ([]byte, []int) { return file_cosmos_auth_v1beta1_query_proto_rawDescGZIP(), []int{8} } -// Bech32PrefixResponse is the response type for Bech32Prefix rpc method +// Bech32PrefixResponse is the response type for Bech32Prefix rpc method. +// +// Since: cosmos-sdk 0.46 type Bech32PrefixResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6345,7 +6353,9 @@ func (x *Bech32PrefixResponse) GetBech32Prefix() string { return "" } -// AddressBytesToStringRequest is the request type for AddressString rpc method +// AddressBytesToStringRequest is the request type for AddressString rpc method. +// +// Since: cosmos-sdk 0.46 type AddressBytesToStringRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6381,7 +6391,9 @@ func (x *AddressBytesToStringRequest) GetAddressBytes() []byte { return nil } -// AddressBytesToStringResponse is the response type for AddressString rpc method +// AddressBytesToStringResponse is the response type for AddressString rpc method. +// +// Since: cosmos-sdk 0.46 type AddressBytesToStringResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6417,7 +6429,9 @@ func (x *AddressBytesToStringResponse) GetAddressString() string { return "" } -// AddressStringToBytesRequest is the request type for AccountBytes rpc method +// AddressStringToBytesRequest is the request type for AccountBytes rpc method. +// +// Since: cosmos-sdk 0.46 type AddressStringToBytesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6453,7 +6467,9 @@ func (x *AddressStringToBytesRequest) GetAddressString() string { return "" } -// AddressStringToBytesResponse is the response type for AddressBytes rpc method +// AddressStringToBytesResponse is the response type for AddressBytes rpc method. +// +// Since: cosmos-sdk 0.46 type AddressStringToBytesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6639,11 +6655,10 @@ var file_cosmos_auth_v1beta1_query_proto_rawDesc = []byte{ 0x2e, 0x12, 0x2c, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x62, 0x65, 0x63, 0x68, 0x33, 0x32, 0x2f, 0x7b, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x7d, 0x42, - 0xd5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, + 0xc5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, - 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x2e, diff --git a/api/cosmos/auth/v1beta1/query_grpc.pb.go b/api/cosmos/auth/v1beta1/query_grpc.pb.go index 842ee3392559..f016a932e9f4 100644 --- a/api/cosmos/auth/v1beta1/query_grpc.pb.go +++ b/api/cosmos/auth/v1beta1/query_grpc.pb.go @@ -31,12 +31,20 @@ type QueryClient interface { // Params queries all parameters. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // ModuleAccounts returns all the existing module accounts. + // + // Since: cosmos-sdk 0.46 ModuleAccounts(ctx context.Context, in *QueryModuleAccountsRequest, opts ...grpc.CallOption) (*QueryModuleAccountsResponse, error) - // Bech32 queries bech32Prefix + // Bech32Prefix queries bech32Prefix + // + // Since: cosmos-sdk 0.46 Bech32Prefix(ctx context.Context, in *Bech32PrefixRequest, opts ...grpc.CallOption) (*Bech32PrefixResponse, error) // AddressBytesToString converts Account Address bytes to string + // + // Since: cosmos-sdk 0.46 AddressBytesToString(ctx context.Context, in *AddressBytesToStringRequest, opts ...grpc.CallOption) (*AddressBytesToStringResponse, error) // AddressStringToBytes converts Address string to bytes + // + // Since: cosmos-sdk 0.46 AddressStringToBytes(ctx context.Context, in *AddressStringToBytesRequest, opts ...grpc.CallOption) (*AddressStringToBytesResponse, error) } @@ -124,12 +132,20 @@ type QueryServer interface { // Params queries all parameters. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // ModuleAccounts returns all the existing module accounts. + // + // Since: cosmos-sdk 0.46 ModuleAccounts(context.Context, *QueryModuleAccountsRequest) (*QueryModuleAccountsResponse, error) - // Bech32 queries bech32Prefix + // Bech32Prefix queries bech32Prefix + // + // Since: cosmos-sdk 0.46 Bech32Prefix(context.Context, *Bech32PrefixRequest) (*Bech32PrefixResponse, error) // AddressBytesToString converts Account Address bytes to string + // + // Since: cosmos-sdk 0.46 AddressBytesToString(context.Context, *AddressBytesToStringRequest) (*AddressBytesToStringResponse, error) // AddressStringToBytes converts Address string to bytes + // + // Since: cosmos-sdk 0.46 AddressStringToBytes(context.Context, *AddressStringToBytesRequest) (*AddressStringToBytesResponse, error) mustEmbedUnimplementedQueryServer() } diff --git a/api/cosmos/authz/v1beta1/authz.pulsar.go b/api/cosmos/authz/v1beta1/authz.pulsar.go index eb34ad4a6db1..40a01208e1ae 100644 --- a/api/cosmos/authz/v1beta1/authz.pulsar.go +++ b/api/cosmos/authz/v1beta1/authz.pulsar.go @@ -2318,11 +2318,10 @@ var file_cosmos_authz_v1beta1_authz_proto_rawDesc = []byte{ 0x6e, 0x22, 0x34, 0x0a, 0x0e, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x51, 0x75, 0x65, 0x75, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x22, 0x0a, 0x0d, 0x6d, 0x73, 0x67, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x5f, 0x75, 0x72, 0x6c, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0b, 0x6d, 0x73, 0x67, 0x54, - 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, 0x73, 0x42, 0xe0, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, + 0x79, 0x70, 0x65, 0x55, 0x72, 0x6c, 0x73, 0x42, 0xd0, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, + 0x50, 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, diff --git a/api/cosmos/authz/v1beta1/event.pulsar.go b/api/cosmos/authz/v1beta1/event.pulsar.go index 2b021c96d15c..88a142363ea2 100644 --- a/api/cosmos/authz/v1beta1/event.pulsar.go +++ b/api/cosmos/authz/v1beta1/event.pulsar.go @@ -1261,11 +1261,10 @@ var file_cosmos_authz_v1beta1_event_proto_rawDesc = []byte{ 0x65, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x67, - 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x42, 0xdc, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x42, 0xcc, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, + 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, 0x6f, diff --git a/api/cosmos/authz/v1beta1/genesis.pulsar.go b/api/cosmos/authz/v1beta1/genesis.pulsar.go index eeaa312004f4..ea322c85efa4 100644 --- a/api/cosmos/authz/v1beta1/genesis.pulsar.go +++ b/api/cosmos/authz/v1beta1/genesis.pulsar.go @@ -574,12 +574,11 @@ var file_cosmos_authz_v1beta1_genesis_proto_rawDesc = []byte{ 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x6f, - 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xde, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, + 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xce, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x56, diff --git a/api/cosmos/authz/v1beta1/query.pulsar.go b/api/cosmos/authz/v1beta1/query.pulsar.go index 468b464fba8c..0f776d3cde17 100644 --- a/api/cosmos/authz/v1beta1/query.pulsar.go +++ b/api/cosmos/authz/v1beta1/query.pulsar.go @@ -2,10 +2,10 @@ package authzv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -3774,11 +3774,10 @@ var file_cosmos_authz_v1beta1_query_proto_rawDesc = []byte{ 0x12, 0x2e, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x73, 0x2f, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x2f, 0x7b, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x65, 0x7d, - 0x42, 0xdc, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x42, 0xcc, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, - 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x42, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, diff --git a/api/cosmos/authz/v1beta1/tx.pulsar.go b/api/cosmos/authz/v1beta1/tx.pulsar.go index 3b6ab52d3cbf..936cb890f5e1 100644 --- a/api/cosmos/authz/v1beta1/tx.pulsar.go +++ b/api/cosmos/authz/v1beta1/tx.pulsar.go @@ -2,10 +2,10 @@ package authzv1beta1 import ( + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -3204,11 +3204,10 @@ var file_cosmos_authz_v1beta1_tx_proto_rawDesc = []byte{ 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x1a, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, - 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xdd, 0x01, 0x0a, 0x18, 0x63, 0x6f, + 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xcd, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, + 0x01, 0x5a, 0x32, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x75, 0x74, 0x68, 0x7a, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x41, 0x58, 0xaa, 0x02, 0x14, 0x43, 0x6f, diff --git a/api/cosmos/bank/v1beta1/authz.pulsar.go b/api/cosmos/bank/v1beta1/authz.pulsar.go index a8b9e390b26d..f00963c1459b 100644 --- a/api/cosmos/bank/v1beta1/authz.pulsar.go +++ b/api/cosmos/bank/v1beta1/authz.pulsar.go @@ -2,10 +2,10 @@ package bankv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -581,12 +581,11 @@ var file_cosmos_bank_v1beta1_authz_proto_rawDesc = []byte{ 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x0a, 0x73, 0x70, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x3a, 0x11, 0xca, 0xb4, 0x2d, - 0x0d, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xd5, + 0x0d, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0xc5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x41, 0x75, 0x74, 0x68, - 0x7a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x7a, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x2e, 0x56, diff --git a/api/cosmos/bank/v1beta1/bank.pulsar.go b/api/cosmos/bank/v1beta1/bank.pulsar.go index bda917676195..47b1a6e629be 100644 --- a/api/cosmos/bank/v1beta1/bank.pulsar.go +++ b/api/cosmos/bank/v1beta1/bank.pulsar.go @@ -2,11 +2,11 @@ package bankv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -4665,11 +4665,10 @@ var file_cosmos_bank_v1beta1_bank_proto_rawDesc = []byte{ 0xde, 0x1f, 0x03, 0x55, 0x52, 0x49, 0x52, 0x03, 0x75, 0x72, 0x69, 0x12, 0x26, 0x0a, 0x08, 0x75, 0x72, 0x69, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x42, 0x0b, 0xe2, 0xde, 0x1f, 0x07, 0x55, 0x52, 0x49, 0x48, 0x61, 0x73, 0x68, 0x52, 0x07, 0x75, 0x72, 0x69, 0x48, - 0x61, 0x73, 0x68, 0x42, 0xd4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x61, 0x73, 0x68, 0x42, 0xc4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, - 0x09, 0x42, 0x61, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x09, 0x42, 0x61, 0x6e, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, diff --git a/api/cosmos/bank/v1beta1/genesis.pulsar.go b/api/cosmos/bank/v1beta1/genesis.pulsar.go index fe5dd78ae3da..6d8e6a99e4c0 100644 --- a/api/cosmos/bank/v1beta1/genesis.pulsar.go +++ b/api/cosmos/bank/v1beta1/genesis.pulsar.go @@ -2,10 +2,10 @@ package bankv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -1591,11 +1591,10 @@ var file_cosmos_bank_v1beta1_genesis_proto_rawDesc = []byte{ 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x73, 0x52, 0x05, 0x63, 0x6f, 0x69, 0x6e, 0x73, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8, - 0xa0, 0x1f, 0x00, 0x42, 0xd7, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0xa0, 0x1f, 0x00, 0x42, 0xc7, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, + 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, diff --git a/api/cosmos/bank/v1beta1/query.pulsar.go b/api/cosmos/bank/v1beta1/query.pulsar.go index 5447b5b4f51c..407bd7ae9448 100644 --- a/api/cosmos/bank/v1beta1/query.pulsar.go +++ b/api/cosmos/bank/v1beta1/query.pulsar.go @@ -2,11 +2,11 @@ package bankv1beta1 import ( + v1beta11 "cosmossdk.io/api/cosmos/base/query/v1beta1" + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta11 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -9359,6 +9359,8 @@ func (x *QueryAllBalancesResponse) GetPagination() *v1beta11.PageResponse { // QuerySpendableBalancesRequest defines the gRPC request structure for querying // an account's spendable balances. +// +// Since: cosmos-sdk 0.46 type QuerySpendableBalancesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -9406,6 +9408,8 @@ func (x *QuerySpendableBalancesRequest) GetPagination() *v1beta11.PageRequest { // QuerySpendableBalancesResponse defines the gRPC response structure for querying // an account's spendable balances. +// +// Since: cosmos-sdk 0.46 type QuerySpendableBalancesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -9887,6 +9891,8 @@ func (x *QueryDenomOwnersRequest) GetPagination() *v1beta11.PageRequest { // DenomOwner defines structure representing an account that owns or holds a // particular denominated token. It contains the account address and account // balance of the denominated token. +// +// Since: cosmos-sdk 0.46 type DenomOwner struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -9933,6 +9939,8 @@ func (x *DenomOwner) GetBalance() *v1beta1.Coin { } // QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query. +// +// Since: cosmos-sdk 0.46 type QueryDenomOwnersResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -10228,12 +10236,11 @@ var file_cosmos_bank_v1beta1_query_proto_rawDesc = []byte{ 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x12, 0x29, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x5f, 0x6f, 0x77, - 0x6e, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x7d, 0x42, 0xd5, 0x01, 0x0a, + 0x6e, 0x65, 0x72, 0x73, 0x2f, 0x7b, 0x64, 0x65, 0x6e, 0x6f, 0x6d, 0x7d, 0x42, 0xc5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x2e, 0x56, 0x31, 0x62, diff --git a/api/cosmos/bank/v1beta1/query_grpc.pb.go b/api/cosmos/bank/v1beta1/query_grpc.pb.go index 6d46447f1ae7..db0da3c7d94c 100644 --- a/api/cosmos/bank/v1beta1/query_grpc.pb.go +++ b/api/cosmos/bank/v1beta1/query_grpc.pb.go @@ -28,6 +28,8 @@ type QueryClient interface { AllBalances(ctx context.Context, in *QueryAllBalancesRequest, opts ...grpc.CallOption) (*QueryAllBalancesResponse, error) // SpendableBalances queries the spenable balance of all coins for a single // account. + // + // Since: cosmos-sdk 0.46 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) @@ -42,6 +44,8 @@ type QueryClient interface { DenomsMetadata(ctx context.Context, in *QueryDenomsMetadataRequest, opts ...grpc.CallOption) (*QueryDenomsMetadataResponse, error) // DenomOwners queries for all account addresses that own a particular token // denomination. + // + // Since: cosmos-sdk 0.46 DenomOwners(ctx context.Context, in *QueryDenomOwnersRequest, opts ...grpc.CallOption) (*QueryDenomOwnersResponse, error) } @@ -144,6 +148,8 @@ type QueryServer interface { AllBalances(context.Context, *QueryAllBalancesRequest) (*QueryAllBalancesResponse, error) // SpendableBalances queries the spenable balance of all coins for a single // account. + // + // Since: cosmos-sdk 0.46 SpendableBalances(context.Context, *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error) // TotalSupply queries the total supply of all coins. TotalSupply(context.Context, *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) @@ -158,6 +164,8 @@ type QueryServer interface { DenomsMetadata(context.Context, *QueryDenomsMetadataRequest) (*QueryDenomsMetadataResponse, error) // DenomOwners queries for all account addresses that own a particular token // denomination. + // + // Since: cosmos-sdk 0.46 DenomOwners(context.Context, *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error) mustEmbedUnimplementedQueryServer() } diff --git a/api/cosmos/bank/v1beta1/tx.pulsar.go b/api/cosmos/bank/v1beta1/tx.pulsar.go index c6c95f934903..b56f4a194c4f 100644 --- a/api/cosmos/bank/v1beta1/tx.pulsar.go +++ b/api/cosmos/bank/v1beta1/tx.pulsar.go @@ -2,11 +2,11 @@ package bankv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -2199,11 +2199,10 @@ var file_cosmos_bank_v1beta1_tx_proto_rawDesc = []byte{ 0x6c, 0x74, 0x69, 0x53, 0x65, 0x6e, 0x64, 0x1a, 0x29, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0xd2, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x65, 0x42, 0xc2, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x6e, 0x6b, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, - 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x6e, 0x6b, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x6e, 0x6b, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x6e, 0x6b, 0x2e, diff --git a/api/cosmos/base/abci/v1beta1/abci.pulsar.go b/api/cosmos/base/abci/v1beta1/abci.pulsar.go index 8373606f820c..ef32b3d52e3c 100644 --- a/api/cosmos/base/abci/v1beta1/abci.pulsar.go +++ b/api/cosmos/base/abci/v1beta1/abci.pulsar.go @@ -2,9 +2,9 @@ package abciv1beta1 import ( + abci "cosmossdk.io/api/tendermint/abci" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - abci "github.com/cosmos/cosmos-sdk/api/tendermint/abci" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -6579,7 +6579,7 @@ type TxResponse struct { Timestamp string `protobuf:"bytes,12,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Events defines all the events emitted by processing a transaction. Note, // these events include those emitted by processing all the messages and those - // emitted from the ante handler. Whereas Logs contains the events, with + // emitted from the middleware. Whereas Logs contains the events, with // additional metadata, emitted only by processing the messages. // // Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 @@ -7299,12 +7299,11 @@ var file_cosmos_base_abci_v1beta1_abci_proto_rawDesc = []byte{ 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x61, 0x62, 0x63, 0x69, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x54, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x03, 0x74, 0x78, 0x73, - 0x3a, 0x04, 0x80, 0xdc, 0x20, 0x01, 0x42, 0xf7, 0x01, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x3a, 0x04, 0x80, 0xdc, 0x20, 0x01, 0x42, 0xe7, 0x01, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x61, 0x62, 0x63, 0x69, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x09, 0x41, 0x62, 0x63, 0x69, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x45, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x35, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x61, 0x62, 0x63, 0x69, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x61, 0x62, 0x63, 0x69, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x41, 0xaa, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x2e, diff --git a/api/cosmos/base/kv/v1beta1/kv.pulsar.go b/api/cosmos/base/kv/v1beta1/kv.pulsar.go index 661bbf471481..1403c88f929e 100644 --- a/api/cosmos/base/kv/v1beta1/kv.pulsar.go +++ b/api/cosmos/base/kv/v1beta1/kv.pulsar.go @@ -1103,11 +1103,10 @@ var file_cosmos_base_kv_v1beta1_kv_proto_rawDesc = []byte{ 0x72, 0x73, 0x22, 0x2e, 0x0a, 0x04, 0x50, 0x61, 0x69, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x42, 0xe3, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x75, 0x65, 0x42, 0xd3, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x6b, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x42, 0x07, 0x4b, 0x76, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x41, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x31, 0x42, 0x07, 0x4b, 0x76, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x6b, 0x76, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6b, 0x76, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x4b, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, diff --git a/api/cosmos/base/query/v1beta1/pagination.pulsar.go b/api/cosmos/base/query/v1beta1/pagination.pulsar.go index ec8b00853c3e..3548e128b274 100644 --- a/api/cosmos/base/query/v1beta1/pagination.pulsar.go +++ b/api/cosmos/base/query/v1beta1/pagination.pulsar.go @@ -1285,12 +1285,11 @@ var file_cosmos_base_query_v1beta1_pagination_proto_rawDesc = []byte{ 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x07, 0x6e, 0x65, 0x78, 0x74, 0x4b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x74, 0x6f, - 0x74, 0x61, 0x6c, 0x42, 0x80, 0x02, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x74, 0x61, 0x6c, 0x42, 0xf0, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0f, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x37, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x71, 0x75, 0x65, 0x72, 0x79, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x51, 0xaa, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, diff --git a/api/cosmos/base/reflection/v1beta1/reflection.pulsar.go b/api/cosmos/base/reflection/v1beta1/reflection.pulsar.go index 47e397297249..f886d9174051 100644 --- a/api/cosmos/base/reflection/v1beta1/reflection.pulsar.go +++ b/api/cosmos/base/reflection/v1beta1/reflection.pulsar.go @@ -1955,12 +1955,11 @@ var file_cosmos_base_reflection_v1beta1_reflection_proto_rawDesc = []byte{ 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x7d, 0x2f, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x73, 0x42, 0xa3, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x6e, 0x73, 0x42, 0x93, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0f, 0x52, 0x65, 0x66, 0x6c, 0x65, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x51, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x41, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, diff --git a/api/cosmos/base/reflection/v2alpha1/reflection.pulsar.go b/api/cosmos/base/reflection/v2alpha1/reflection.pulsar.go index 65385e6c1605..c0910852b765 100644 --- a/api/cosmos/base/reflection/v2alpha1/reflection.pulsar.go +++ b/api/cosmos/base/reflection/v2alpha1/reflection.pulsar.go @@ -13583,12 +13583,11 @@ var file_cosmos_base_reflection_v2alpha1_reflection_proto_rawDesc = []byte{ 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61, 0x70, 0x70, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x2f, 0x74, 0x78, 0x5f, 0x64, 0x65, 0x73, 0x63, - 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x42, 0xaa, 0x02, 0x0a, 0x23, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x42, 0x9a, 0x02, 0x0a, 0x23, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0f, 0x52, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x53, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, + 0x01, 0x5a, 0x43, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x32, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x72, 0x65, 0x66, 0x6c, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x32, diff --git a/api/cosmos/base/snapshots/v1beta1/snapshot.pulsar.go b/api/cosmos/base/snapshots/v1beta1/snapshot.pulsar.go index e17853f53792..42b0ba1e0f67 100644 --- a/api/cosmos/base/snapshots/v1beta1/snapshot.pulsar.go +++ b/api/cosmos/base/snapshots/v1beta1/snapshot.pulsar.go @@ -5112,6 +5112,8 @@ func (x *Metadata) GetChunkHashes() [][]byte { } // SnapshotItem is an item contained in a rootmulti.Store snapshot. +// +// Since: cosmos-sdk 0.46 type SnapshotItem struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -5239,6 +5241,8 @@ func (*SnapshotItem_Kv) isSnapshotItem_Item() {} func (*SnapshotItem_Schema) isSnapshotItem_Item() {} // SnapshotStoreItem contains metadata about a snapshotted store. +// +// Since: cosmos-sdk 0.46 type SnapshotStoreItem struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -5275,6 +5279,8 @@ func (x *SnapshotStoreItem) GetName() string { } // SnapshotIAVLItem is an exported IAVL node. +// +// Since: cosmos-sdk 0.46 type SnapshotIAVLItem struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -5337,6 +5343,8 @@ func (x *SnapshotIAVLItem) GetHeight() int32 { } // SnapshotExtensionMeta contains metadata about an external snapshotter. +// +// Since: cosmos-sdk 0.46 type SnapshotExtensionMeta struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -5381,6 +5389,8 @@ func (x *SnapshotExtensionMeta) GetFormat() uint32 { } // SnapshotExtensionPayload contains payloads of an external snapshotter. +// +// Since: cosmos-sdk 0.46 type SnapshotExtensionPayload struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -5417,6 +5427,8 @@ func (x *SnapshotExtensionPayload) GetPayload() []byte { } // SnapshotKVItem is an exported Key/Value Pair +// +// Since: cosmos-sdk 0.46 type SnapshotKVItem struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -5461,6 +5473,8 @@ func (x *SnapshotKVItem) GetValue() []byte { } // SnapshotSchema is an exported schema of smt store +// +// Since: cosmos-sdk 0.46 type SnapshotSchema struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -5574,13 +5588,12 @@ var file_cosmos_base_snapshots_v1beta1_snapshot_proto_rawDesc = []byte{ 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x24, 0x0a, 0x0e, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, - 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x42, 0x9a, 0x02, 0x0a, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0c, 0x52, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x42, 0x8a, 0x02, 0x0a, 0x21, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0d, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x4f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, - 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, + 0x6f, 0x50, 0x01, 0x5a, 0x3f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, 0x73, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x53, 0xaa, 0x02, 0x1d, 0x43, 0x6f, 0x73, diff --git a/api/cosmos/base/store/v1beta1/commit_info.pulsar.go b/api/cosmos/base/store/v1beta1/commit_info.pulsar.go index db9fe3973b12..7d47e79e2c66 100644 --- a/api/cosmos/base/store/v1beta1/commit_info.pulsar.go +++ b/api/cosmos/base/store/v1beta1/commit_info.pulsar.go @@ -1698,12 +1698,11 @@ var file_cosmos_base_store_v1beta1_commit_info_proto_rawDesc = []byte{ 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x44, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, - 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0x80, 0x02, 0x0a, + 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0xf0, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0f, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, + 0x01, 0x5a, 0x37, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x53, diff --git a/api/cosmos/base/store/v1beta1/listening.pulsar.go b/api/cosmos/base/store/v1beta1/listening.pulsar.go index aa56031d245c..3ab973ac3937 100644 --- a/api/cosmos/base/store/v1beta1/listening.pulsar.go +++ b/api/cosmos/base/store/v1beta1/listening.pulsar.go @@ -709,12 +709,11 @@ var file_cosmos_base_store_v1beta1_listening_proto_rawDesc = []byte{ 0x28, 0x08, 0x52, 0x06, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x42, 0xff, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x75, 0x65, 0x42, 0xef, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0e, 0x4c, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x69, 0x6e, 0x67, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x47, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x37, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x53, 0xaa, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, diff --git a/api/cosmos/base/tendermint/v1beta1/query.pulsar.go b/api/cosmos/base/tendermint/v1beta1/query.pulsar.go index 19730fd63b19..053f5f9b5534 100644 --- a/api/cosmos/base/tendermint/v1beta1/query.pulsar.go +++ b/api/cosmos/base/tendermint/v1beta1/query.pulsar.go @@ -2,12 +2,13 @@ package tendermintv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" + p2p "cosmossdk.io/api/tendermint/p2p" + types "cosmossdk.io/api/tendermint/types" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" - p2p "github.com/cosmos/cosmos-sdk/api/tendermint/p2p" - types "github.com/cosmos/cosmos-sdk/api/tendermint/types" + _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -7687,6 +7688,2543 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods { } } +var ( + md_ABCIQueryRequest protoreflect.MessageDescriptor + fd_ABCIQueryRequest_data protoreflect.FieldDescriptor + fd_ABCIQueryRequest_path protoreflect.FieldDescriptor + fd_ABCIQueryRequest_height protoreflect.FieldDescriptor + fd_ABCIQueryRequest_prove protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_base_tendermint_v1beta1_query_proto_init() + md_ABCIQueryRequest = File_cosmos_base_tendermint_v1beta1_query_proto.Messages().ByName("ABCIQueryRequest") + fd_ABCIQueryRequest_data = md_ABCIQueryRequest.Fields().ByName("data") + fd_ABCIQueryRequest_path = md_ABCIQueryRequest.Fields().ByName("path") + fd_ABCIQueryRequest_height = md_ABCIQueryRequest.Fields().ByName("height") + fd_ABCIQueryRequest_prove = md_ABCIQueryRequest.Fields().ByName("prove") +} + +var _ protoreflect.Message = (*fastReflection_ABCIQueryRequest)(nil) + +type fastReflection_ABCIQueryRequest ABCIQueryRequest + +func (x *ABCIQueryRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_ABCIQueryRequest)(x) +} + +func (x *ABCIQueryRequest) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_ABCIQueryRequest_messageType fastReflection_ABCIQueryRequest_messageType +var _ protoreflect.MessageType = fastReflection_ABCIQueryRequest_messageType{} + +type fastReflection_ABCIQueryRequest_messageType struct{} + +func (x fastReflection_ABCIQueryRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_ABCIQueryRequest)(nil) +} +func (x fastReflection_ABCIQueryRequest_messageType) New() protoreflect.Message { + return new(fastReflection_ABCIQueryRequest) +} +func (x fastReflection_ABCIQueryRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ABCIQueryRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ABCIQueryRequest) Descriptor() protoreflect.MessageDescriptor { + return md_ABCIQueryRequest +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_ABCIQueryRequest) Type() protoreflect.MessageType { + return _fastReflection_ABCIQueryRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ABCIQueryRequest) New() protoreflect.Message { + return new(fastReflection_ABCIQueryRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ABCIQueryRequest) Interface() protoreflect.ProtoMessage { + return (*ABCIQueryRequest)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_ABCIQueryRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Data) != 0 { + value := protoreflect.ValueOfBytes(x.Data) + if !f(fd_ABCIQueryRequest_data, value) { + return + } + } + if x.Path != "" { + value := protoreflect.ValueOfString(x.Path) + if !f(fd_ABCIQueryRequest_path, value) { + return + } + } + if x.Height != int64(0) { + value := protoreflect.ValueOfInt64(x.Height) + if !f(fd_ABCIQueryRequest_height, value) { + return + } + } + if x.Prove != false { + value := protoreflect.ValueOfBool(x.Prove) + if !f(fd_ABCIQueryRequest_prove, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_ABCIQueryRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.data": + return len(x.Data) != 0 + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.path": + return x.Path != "" + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.height": + return x.Height != int64(0) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.prove": + return x.Prove != false + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryRequest")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryRequest does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ABCIQueryRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.data": + x.Data = nil + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.path": + x.Path = "" + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.height": + x.Height = int64(0) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.prove": + x.Prove = false + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryRequest")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryRequest does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_ABCIQueryRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.data": + value := x.Data + return protoreflect.ValueOfBytes(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.path": + value := x.Path + return protoreflect.ValueOfString(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.height": + value := x.Height + return protoreflect.ValueOfInt64(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.prove": + value := x.Prove + return protoreflect.ValueOfBool(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryRequest")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryRequest does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ABCIQueryRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.data": + x.Data = value.Bytes() + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.path": + x.Path = value.Interface().(string) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.height": + x.Height = value.Int() + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.prove": + x.Prove = value.Bool() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryRequest")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryRequest does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ABCIQueryRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.data": + panic(fmt.Errorf("field data of message cosmos.base.tendermint.v1beta1.ABCIQueryRequest is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.path": + panic(fmt.Errorf("field path of message cosmos.base.tendermint.v1beta1.ABCIQueryRequest is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.height": + panic(fmt.Errorf("field height of message cosmos.base.tendermint.v1beta1.ABCIQueryRequest is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.prove": + panic(fmt.Errorf("field prove of message cosmos.base.tendermint.v1beta1.ABCIQueryRequest is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryRequest")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryRequest does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_ABCIQueryRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.data": + return protoreflect.ValueOfBytes(nil) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.path": + return protoreflect.ValueOfString("") + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.height": + return protoreflect.ValueOfInt64(int64(0)) + case "cosmos.base.tendermint.v1beta1.ABCIQueryRequest.prove": + return protoreflect.ValueOfBool(false) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryRequest")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryRequest does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_ABCIQueryRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.base.tendermint.v1beta1.ABCIQueryRequest", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_ABCIQueryRequest) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ABCIQueryRequest) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_ABCIQueryRequest) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_ABCIQueryRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ABCIQueryRequest) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Data) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Path) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Height != 0 { + n += 1 + runtime.Sov(uint64(x.Height)) + } + if x.Prove { + n += 2 + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*ABCIQueryRequest) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Prove { + i-- + if x.Prove { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if x.Height != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Height)) + i-- + dAtA[i] = 0x18 + } + if len(x.Path) > 0 { + i -= len(x.Path) + copy(dAtA[i:], x.Path) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Path))) + i-- + dAtA[i] = 0x12 + } + if len(x.Data) > 0 { + i -= len(x.Data) + copy(dAtA[i:], x.Data) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Data))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*ABCIQueryRequest) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ABCIQueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ABCIQueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Data = append(x.Data[:0], dAtA[iNdEx:postIndex]...) + if x.Data == nil { + x.Data = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Path", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Path = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + x.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Prove", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.Prove = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_ABCIQueryResponse protoreflect.MessageDescriptor + fd_ABCIQueryResponse_code protoreflect.FieldDescriptor + fd_ABCIQueryResponse_log protoreflect.FieldDescriptor + fd_ABCIQueryResponse_info protoreflect.FieldDescriptor + fd_ABCIQueryResponse_index protoreflect.FieldDescriptor + fd_ABCIQueryResponse_key protoreflect.FieldDescriptor + fd_ABCIQueryResponse_value protoreflect.FieldDescriptor + fd_ABCIQueryResponse_proof_ops protoreflect.FieldDescriptor + fd_ABCIQueryResponse_height protoreflect.FieldDescriptor + fd_ABCIQueryResponse_codespace protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_base_tendermint_v1beta1_query_proto_init() + md_ABCIQueryResponse = File_cosmos_base_tendermint_v1beta1_query_proto.Messages().ByName("ABCIQueryResponse") + fd_ABCIQueryResponse_code = md_ABCIQueryResponse.Fields().ByName("code") + fd_ABCIQueryResponse_log = md_ABCIQueryResponse.Fields().ByName("log") + fd_ABCIQueryResponse_info = md_ABCIQueryResponse.Fields().ByName("info") + fd_ABCIQueryResponse_index = md_ABCIQueryResponse.Fields().ByName("index") + fd_ABCIQueryResponse_key = md_ABCIQueryResponse.Fields().ByName("key") + fd_ABCIQueryResponse_value = md_ABCIQueryResponse.Fields().ByName("value") + fd_ABCIQueryResponse_proof_ops = md_ABCIQueryResponse.Fields().ByName("proof_ops") + fd_ABCIQueryResponse_height = md_ABCIQueryResponse.Fields().ByName("height") + fd_ABCIQueryResponse_codespace = md_ABCIQueryResponse.Fields().ByName("codespace") +} + +var _ protoreflect.Message = (*fastReflection_ABCIQueryResponse)(nil) + +type fastReflection_ABCIQueryResponse ABCIQueryResponse + +func (x *ABCIQueryResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_ABCIQueryResponse)(x) +} + +func (x *ABCIQueryResponse) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_ABCIQueryResponse_messageType fastReflection_ABCIQueryResponse_messageType +var _ protoreflect.MessageType = fastReflection_ABCIQueryResponse_messageType{} + +type fastReflection_ABCIQueryResponse_messageType struct{} + +func (x fastReflection_ABCIQueryResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_ABCIQueryResponse)(nil) +} +func (x fastReflection_ABCIQueryResponse_messageType) New() protoreflect.Message { + return new(fastReflection_ABCIQueryResponse) +} +func (x fastReflection_ABCIQueryResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ABCIQueryResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ABCIQueryResponse) Descriptor() protoreflect.MessageDescriptor { + return md_ABCIQueryResponse +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_ABCIQueryResponse) Type() protoreflect.MessageType { + return _fastReflection_ABCIQueryResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ABCIQueryResponse) New() protoreflect.Message { + return new(fastReflection_ABCIQueryResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ABCIQueryResponse) Interface() protoreflect.ProtoMessage { + return (*ABCIQueryResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_ABCIQueryResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Code != uint32(0) { + value := protoreflect.ValueOfUint32(x.Code) + if !f(fd_ABCIQueryResponse_code, value) { + return + } + } + if x.Log != "" { + value := protoreflect.ValueOfString(x.Log) + if !f(fd_ABCIQueryResponse_log, value) { + return + } + } + if x.Info != "" { + value := protoreflect.ValueOfString(x.Info) + if !f(fd_ABCIQueryResponse_info, value) { + return + } + } + if x.Index != int64(0) { + value := protoreflect.ValueOfInt64(x.Index) + if !f(fd_ABCIQueryResponse_index, value) { + return + } + } + if len(x.Key) != 0 { + value := protoreflect.ValueOfBytes(x.Key) + if !f(fd_ABCIQueryResponse_key, value) { + return + } + } + if len(x.Value) != 0 { + value := protoreflect.ValueOfBytes(x.Value) + if !f(fd_ABCIQueryResponse_value, value) { + return + } + } + if x.ProofOps != nil { + value := protoreflect.ValueOfMessage(x.ProofOps.ProtoReflect()) + if !f(fd_ABCIQueryResponse_proof_ops, value) { + return + } + } + if x.Height != int64(0) { + value := protoreflect.ValueOfInt64(x.Height) + if !f(fd_ABCIQueryResponse_height, value) { + return + } + } + if x.Codespace != "" { + value := protoreflect.ValueOfString(x.Codespace) + if !f(fd_ABCIQueryResponse_codespace, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_ABCIQueryResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.code": + return x.Code != uint32(0) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.log": + return x.Log != "" + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.info": + return x.Info != "" + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.index": + return x.Index != int64(0) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.key": + return len(x.Key) != 0 + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.value": + return len(x.Value) != 0 + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.proof_ops": + return x.ProofOps != nil + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.height": + return x.Height != int64(0) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.codespace": + return x.Codespace != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryResponse")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ABCIQueryResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.code": + x.Code = uint32(0) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.log": + x.Log = "" + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.info": + x.Info = "" + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.index": + x.Index = int64(0) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.key": + x.Key = nil + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.value": + x.Value = nil + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.proof_ops": + x.ProofOps = nil + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.height": + x.Height = int64(0) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.codespace": + x.Codespace = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryResponse")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_ABCIQueryResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.code": + value := x.Code + return protoreflect.ValueOfUint32(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.log": + value := x.Log + return protoreflect.ValueOfString(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.info": + value := x.Info + return protoreflect.ValueOfString(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.index": + value := x.Index + return protoreflect.ValueOfInt64(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.key": + value := x.Key + return protoreflect.ValueOfBytes(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.value": + value := x.Value + return protoreflect.ValueOfBytes(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.proof_ops": + value := x.ProofOps + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.height": + value := x.Height + return protoreflect.ValueOfInt64(value) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.codespace": + value := x.Codespace + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryResponse")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ABCIQueryResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.code": + x.Code = uint32(value.Uint()) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.log": + x.Log = value.Interface().(string) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.info": + x.Info = value.Interface().(string) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.index": + x.Index = value.Int() + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.key": + x.Key = value.Bytes() + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.value": + x.Value = value.Bytes() + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.proof_ops": + x.ProofOps = value.Message().Interface().(*ProofOps) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.height": + x.Height = value.Int() + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.codespace": + x.Codespace = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryResponse")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ABCIQueryResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.proof_ops": + if x.ProofOps == nil { + x.ProofOps = new(ProofOps) + } + return protoreflect.ValueOfMessage(x.ProofOps.ProtoReflect()) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.code": + panic(fmt.Errorf("field code of message cosmos.base.tendermint.v1beta1.ABCIQueryResponse is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.log": + panic(fmt.Errorf("field log of message cosmos.base.tendermint.v1beta1.ABCIQueryResponse is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.info": + panic(fmt.Errorf("field info of message cosmos.base.tendermint.v1beta1.ABCIQueryResponse is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.index": + panic(fmt.Errorf("field index of message cosmos.base.tendermint.v1beta1.ABCIQueryResponse is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.key": + panic(fmt.Errorf("field key of message cosmos.base.tendermint.v1beta1.ABCIQueryResponse is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.value": + panic(fmt.Errorf("field value of message cosmos.base.tendermint.v1beta1.ABCIQueryResponse is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.height": + panic(fmt.Errorf("field height of message cosmos.base.tendermint.v1beta1.ABCIQueryResponse is not mutable")) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.codespace": + panic(fmt.Errorf("field codespace of message cosmos.base.tendermint.v1beta1.ABCIQueryResponse is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryResponse")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryResponse does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_ABCIQueryResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.code": + return protoreflect.ValueOfUint32(uint32(0)) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.log": + return protoreflect.ValueOfString("") + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.info": + return protoreflect.ValueOfString("") + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.index": + return protoreflect.ValueOfInt64(int64(0)) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.key": + return protoreflect.ValueOfBytes(nil) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.value": + return protoreflect.ValueOfBytes(nil) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.proof_ops": + m := new(ProofOps) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.height": + return protoreflect.ValueOfInt64(int64(0)) + case "cosmos.base.tendermint.v1beta1.ABCIQueryResponse.codespace": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ABCIQueryResponse")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ABCIQueryResponse does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_ABCIQueryResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.base.tendermint.v1beta1.ABCIQueryResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_ABCIQueryResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ABCIQueryResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_ABCIQueryResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_ABCIQueryResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ABCIQueryResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Code != 0 { + n += 1 + runtime.Sov(uint64(x.Code)) + } + l = len(x.Log) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Info) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Index != 0 { + n += 1 + runtime.Sov(uint64(x.Index)) + } + l = len(x.Key) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Value) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.ProofOps != nil { + l = options.Size(x.ProofOps) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Height != 0 { + n += 1 + runtime.Sov(uint64(x.Height)) + } + l = len(x.Codespace) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*ABCIQueryResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Codespace) > 0 { + i -= len(x.Codespace) + copy(dAtA[i:], x.Codespace) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Codespace))) + i-- + dAtA[i] = 0x52 + } + if x.Height != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Height)) + i-- + dAtA[i] = 0x48 + } + if x.ProofOps != nil { + encoded, err := options.Marshal(x.ProofOps) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x42 + } + if len(x.Value) > 0 { + i -= len(x.Value) + copy(dAtA[i:], x.Value) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Value))) + i-- + dAtA[i] = 0x3a + } + if len(x.Key) > 0 { + i -= len(x.Key) + copy(dAtA[i:], x.Key) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Key))) + i-- + dAtA[i] = 0x32 + } + if x.Index != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Index)) + i-- + dAtA[i] = 0x28 + } + if len(x.Info) > 0 { + i -= len(x.Info) + copy(dAtA[i:], x.Info) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Info))) + i-- + dAtA[i] = 0x22 + } + if len(x.Log) > 0 { + i -= len(x.Log) + copy(dAtA[i:], x.Log) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Log))) + i-- + dAtA[i] = 0x1a + } + if x.Code != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Code)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*ABCIQueryResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ABCIQueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ABCIQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + x.Code = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Code |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Log", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Log = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Info", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Info = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + x.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Index |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Key = append(x.Key[:0], dAtA[iNdEx:postIndex]...) + if x.Key == nil { + x.Key = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Value = append(x.Value[:0], dAtA[iNdEx:postIndex]...) + if x.Value == nil { + x.Value = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ProofOps", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.ProofOps == nil { + x.ProofOps = &ProofOps{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.ProofOps); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 9: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + x.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Codespace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Codespace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_ProofOp protoreflect.MessageDescriptor + fd_ProofOp_type protoreflect.FieldDescriptor + fd_ProofOp_key protoreflect.FieldDescriptor + fd_ProofOp_data protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_base_tendermint_v1beta1_query_proto_init() + md_ProofOp = File_cosmos_base_tendermint_v1beta1_query_proto.Messages().ByName("ProofOp") + fd_ProofOp_type = md_ProofOp.Fields().ByName("type") + fd_ProofOp_key = md_ProofOp.Fields().ByName("key") + fd_ProofOp_data = md_ProofOp.Fields().ByName("data") +} + +var _ protoreflect.Message = (*fastReflection_ProofOp)(nil) + +type fastReflection_ProofOp ProofOp + +func (x *ProofOp) ProtoReflect() protoreflect.Message { + return (*fastReflection_ProofOp)(x) +} + +func (x *ProofOp) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_ProofOp_messageType fastReflection_ProofOp_messageType +var _ protoreflect.MessageType = fastReflection_ProofOp_messageType{} + +type fastReflection_ProofOp_messageType struct{} + +func (x fastReflection_ProofOp_messageType) Zero() protoreflect.Message { + return (*fastReflection_ProofOp)(nil) +} +func (x fastReflection_ProofOp_messageType) New() protoreflect.Message { + return new(fastReflection_ProofOp) +} +func (x fastReflection_ProofOp_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ProofOp +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ProofOp) Descriptor() protoreflect.MessageDescriptor { + return md_ProofOp +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_ProofOp) Type() protoreflect.MessageType { + return _fastReflection_ProofOp_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ProofOp) New() protoreflect.Message { + return new(fastReflection_ProofOp) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ProofOp) Interface() protoreflect.ProtoMessage { + return (*ProofOp)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_ProofOp) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Type_ != "" { + value := protoreflect.ValueOfString(x.Type_) + if !f(fd_ProofOp_type, value) { + return + } + } + if len(x.Key) != 0 { + value := protoreflect.ValueOfBytes(x.Key) + if !f(fd_ProofOp_key, value) { + return + } + } + if len(x.Data) != 0 { + value := protoreflect.ValueOfBytes(x.Data) + if !f(fd_ProofOp_data, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_ProofOp) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOp.type": + return x.Type_ != "" + case "cosmos.base.tendermint.v1beta1.ProofOp.key": + return len(x.Key) != 0 + case "cosmos.base.tendermint.v1beta1.ProofOp.data": + return len(x.Data) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOp")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOp does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ProofOp) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOp.type": + x.Type_ = "" + case "cosmos.base.tendermint.v1beta1.ProofOp.key": + x.Key = nil + case "cosmos.base.tendermint.v1beta1.ProofOp.data": + x.Data = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOp")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOp does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_ProofOp) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOp.type": + value := x.Type_ + return protoreflect.ValueOfString(value) + case "cosmos.base.tendermint.v1beta1.ProofOp.key": + value := x.Key + return protoreflect.ValueOfBytes(value) + case "cosmos.base.tendermint.v1beta1.ProofOp.data": + value := x.Data + return protoreflect.ValueOfBytes(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOp")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOp does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ProofOp) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOp.type": + x.Type_ = value.Interface().(string) + case "cosmos.base.tendermint.v1beta1.ProofOp.key": + x.Key = value.Bytes() + case "cosmos.base.tendermint.v1beta1.ProofOp.data": + x.Data = value.Bytes() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOp")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOp does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ProofOp) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOp.type": + panic(fmt.Errorf("field type of message cosmos.base.tendermint.v1beta1.ProofOp is not mutable")) + case "cosmos.base.tendermint.v1beta1.ProofOp.key": + panic(fmt.Errorf("field key of message cosmos.base.tendermint.v1beta1.ProofOp is not mutable")) + case "cosmos.base.tendermint.v1beta1.ProofOp.data": + panic(fmt.Errorf("field data of message cosmos.base.tendermint.v1beta1.ProofOp is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOp")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOp does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_ProofOp) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOp.type": + return protoreflect.ValueOfString("") + case "cosmos.base.tendermint.v1beta1.ProofOp.key": + return protoreflect.ValueOfBytes(nil) + case "cosmos.base.tendermint.v1beta1.ProofOp.data": + return protoreflect.ValueOfBytes(nil) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOp")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOp does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_ProofOp) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.base.tendermint.v1beta1.ProofOp", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_ProofOp) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ProofOp) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_ProofOp) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_ProofOp) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ProofOp) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Type_) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Key) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Data) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*ProofOp) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Data) > 0 { + i -= len(x.Data) + copy(dAtA[i:], x.Data) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Data))) + i-- + dAtA[i] = 0x1a + } + if len(x.Key) > 0 { + i -= len(x.Key) + copy(dAtA[i:], x.Key) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Key))) + i-- + dAtA[i] = 0x12 + } + if len(x.Type_) > 0 { + i -= len(x.Type_) + copy(dAtA[i:], x.Type_) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Type_))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*ProofOp) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ProofOp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ProofOp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Type_", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Type_ = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Key = append(x.Key[:0], dAtA[iNdEx:postIndex]...) + if x.Key == nil { + x.Key = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Data = append(x.Data[:0], dAtA[iNdEx:postIndex]...) + if x.Data == nil { + x.Data = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_ProofOps_1_list)(nil) + +type _ProofOps_1_list struct { + list *[]*ProofOp +} + +func (x *_ProofOps_1_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_ProofOps_1_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_ProofOps_1_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*ProofOp) + (*x.list)[i] = concreteValue +} + +func (x *_ProofOps_1_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*ProofOp) + *x.list = append(*x.list, concreteValue) +} + +func (x *_ProofOps_1_list) AppendMutable() protoreflect.Value { + v := new(ProofOp) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_ProofOps_1_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_ProofOps_1_list) NewElement() protoreflect.Value { + v := new(ProofOp) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_ProofOps_1_list) IsValid() bool { + return x.list != nil +} + +var ( + md_ProofOps protoreflect.MessageDescriptor + fd_ProofOps_ops protoreflect.FieldDescriptor +) + +func init() { + file_cosmos_base_tendermint_v1beta1_query_proto_init() + md_ProofOps = File_cosmos_base_tendermint_v1beta1_query_proto.Messages().ByName("ProofOps") + fd_ProofOps_ops = md_ProofOps.Fields().ByName("ops") +} + +var _ protoreflect.Message = (*fastReflection_ProofOps)(nil) + +type fastReflection_ProofOps ProofOps + +func (x *ProofOps) ProtoReflect() protoreflect.Message { + return (*fastReflection_ProofOps)(x) +} + +func (x *ProofOps) slowProtoReflect() protoreflect.Message { + mi := &file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_ProofOps_messageType fastReflection_ProofOps_messageType +var _ protoreflect.MessageType = fastReflection_ProofOps_messageType{} + +type fastReflection_ProofOps_messageType struct{} + +func (x fastReflection_ProofOps_messageType) Zero() protoreflect.Message { + return (*fastReflection_ProofOps)(nil) +} +func (x fastReflection_ProofOps_messageType) New() protoreflect.Message { + return new(fastReflection_ProofOps) +} +func (x fastReflection_ProofOps_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ProofOps +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ProofOps) Descriptor() protoreflect.MessageDescriptor { + return md_ProofOps +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_ProofOps) Type() protoreflect.MessageType { + return _fastReflection_ProofOps_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ProofOps) New() protoreflect.Message { + return new(fastReflection_ProofOps) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ProofOps) Interface() protoreflect.ProtoMessage { + return (*ProofOps)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_ProofOps) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.Ops) != 0 { + value := protoreflect.ValueOfList(&_ProofOps_1_list{list: &x.Ops}) + if !f(fd_ProofOps_ops, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_ProofOps) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOps.ops": + return len(x.Ops) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOps")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOps does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ProofOps) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOps.ops": + x.Ops = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOps")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOps does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_ProofOps) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOps.ops": + if len(x.Ops) == 0 { + return protoreflect.ValueOfList(&_ProofOps_1_list{}) + } + listValue := &_ProofOps_1_list{list: &x.Ops} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOps")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOps does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ProofOps) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOps.ops": + lv := value.List() + clv := lv.(*_ProofOps_1_list) + x.Ops = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOps")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOps does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ProofOps) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOps.ops": + if x.Ops == nil { + x.Ops = []*ProofOp{} + } + value := &_ProofOps_1_list{list: &x.Ops} + return protoreflect.ValueOfList(value) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOps")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOps does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_ProofOps) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "cosmos.base.tendermint.v1beta1.ProofOps.ops": + list := []*ProofOp{} + return protoreflect.ValueOfList(&_ProofOps_1_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.base.tendermint.v1beta1.ProofOps")) + } + panic(fmt.Errorf("message cosmos.base.tendermint.v1beta1.ProofOps does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_ProofOps) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in cosmos.base.tendermint.v1beta1.ProofOps", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_ProofOps) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ProofOps) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_ProofOps) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_ProofOps) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ProofOps) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if len(x.Ops) > 0 { + for _, e := range x.Ops { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*ProofOps) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.Ops) > 0 { + for iNdEx := len(x.Ops) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Ops[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*ProofOps) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ProofOps: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ProofOps: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Ops", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Ops = append(x.Ops, &ProofOp{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Ops[len(x.Ops)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -8381,6 +10919,263 @@ func (x *Module) GetSum() string { return "" } +// ABCIQueryRequest defines the request structure for the ABCIQuery gRPC query. +type ABCIQueryRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + Prove bool `protobuf:"varint,4,opt,name=prove,proto3" json:"prove,omitempty"` +} + +func (x *ABCIQueryRequest) Reset() { + *x = ABCIQueryRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ABCIQueryRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ABCIQueryRequest) ProtoMessage() {} + +// Deprecated: Use ABCIQueryRequest.ProtoReflect.Descriptor instead. +func (*ABCIQueryRequest) Descriptor() ([]byte, []int) { + return file_cosmos_base_tendermint_v1beta1_query_proto_rawDescGZIP(), []int{15} +} + +func (x *ABCIQueryRequest) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +func (x *ABCIQueryRequest) GetPath() string { + if x != nil { + return x.Path + } + return "" +} + +func (x *ABCIQueryRequest) GetHeight() int64 { + if x != nil { + return x.Height + } + return 0 +} + +func (x *ABCIQueryRequest) GetProve() bool { + if x != nil { + return x.Prove + } + return false +} + +// ABCIQueryResponse defines the response structure for the ABCIQuery gRPC query. +// +// Note: This type is a duplicate of the ResponseQuery proto type defined in +// Tendermint. +type ABCIQueryResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code uint32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + Log string `protobuf:"bytes,3,opt,name=log,proto3" json:"log,omitempty"` // nondeterministic + Info string `protobuf:"bytes,4,opt,name=info,proto3" json:"info,omitempty"` // nondeterministic + Index int64 `protobuf:"varint,5,opt,name=index,proto3" json:"index,omitempty"` + Key []byte `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"` + ProofOps *ProofOps `protobuf:"bytes,8,opt,name=proof_ops,json=proofOps,proto3" json:"proof_ops,omitempty"` + Height int64 `protobuf:"varint,9,opt,name=height,proto3" json:"height,omitempty"` + Codespace string `protobuf:"bytes,10,opt,name=codespace,proto3" json:"codespace,omitempty"` +} + +func (x *ABCIQueryResponse) Reset() { + *x = ABCIQueryResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ABCIQueryResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ABCIQueryResponse) ProtoMessage() {} + +// Deprecated: Use ABCIQueryResponse.ProtoReflect.Descriptor instead. +func (*ABCIQueryResponse) Descriptor() ([]byte, []int) { + return file_cosmos_base_tendermint_v1beta1_query_proto_rawDescGZIP(), []int{16} +} + +func (x *ABCIQueryResponse) GetCode() uint32 { + if x != nil { + return x.Code + } + return 0 +} + +func (x *ABCIQueryResponse) GetLog() string { + if x != nil { + return x.Log + } + return "" +} + +func (x *ABCIQueryResponse) GetInfo() string { + if x != nil { + return x.Info + } + return "" +} + +func (x *ABCIQueryResponse) GetIndex() int64 { + if x != nil { + return x.Index + } + return 0 +} + +func (x *ABCIQueryResponse) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *ABCIQueryResponse) GetValue() []byte { + if x != nil { + return x.Value + } + return nil +} + +func (x *ABCIQueryResponse) GetProofOps() *ProofOps { + if x != nil { + return x.ProofOps + } + return nil +} + +func (x *ABCIQueryResponse) GetHeight() int64 { + if x != nil { + return x.Height + } + return 0 +} + +func (x *ABCIQueryResponse) GetCodespace() string { + if x != nil { + return x.Codespace + } + return "" +} + +// ProofOp defines an operation used for calculating Merkle root. The data could +// be arbitrary format, providing nessecary data for example neighbouring node +// hash. +// +// Note: This type is a duplicate of the ProofOp proto type defined in Tendermint. +type ProofOp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Type_ string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *ProofOp) Reset() { + *x = ProofOp{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProofOp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProofOp) ProtoMessage() {} + +// Deprecated: Use ProofOp.ProtoReflect.Descriptor instead. +func (*ProofOp) Descriptor() ([]byte, []int) { + return file_cosmos_base_tendermint_v1beta1_query_proto_rawDescGZIP(), []int{17} +} + +func (x *ProofOp) GetType_() string { + if x != nil { + return x.Type_ + } + return "" +} + +func (x *ProofOp) GetKey() []byte { + if x != nil { + return x.Key + } + return nil +} + +func (x *ProofOp) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + +// ProofOps is Merkle proof defined by the list of ProofOps. +// +// Note: This type is a duplicate of the ProofOps proto type defined in Tendermint. +type ProofOps struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Ops []*ProofOp `protobuf:"bytes,1,rep,name=ops,proto3" json:"ops,omitempty"` +} + +func (x *ProofOps) Reset() { + *x = ProofOps{} + if protoimpl.UnsafeEnabled { + mi := &file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ProofOps) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ProofOps) ProtoMessage() {} + +// Deprecated: Use ProofOps.ProtoReflect.Descriptor instead. +func (*ProofOps) Descriptor() ([]byte, []int) { + return file_cosmos_base_tendermint_v1beta1_query_proto_rawDescGZIP(), []int{18} +} + +func (x *ProofOps) GetOps() []*ProofOp { + if x != nil { + return x.Ops + } + return nil +} + var File_cosmos_base_tendermint_v1beta1_query_proto protoreflect.FileDescriptor var file_cosmos_base_tendermint_v1beta1_query_proto_rawDesc = []byte{ @@ -8388,227 +11183,270 @@ var file_cosmos_base_tendermint_v1beta1_query_proto_rawDesc = []byte{ 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, - 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x1a, 0x19, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, - 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, - 0x74, 0x2f, 0x70, 0x32, 0x70, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x1a, 0x1c, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, - 0x1c, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, 0x70, 0x65, - 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, - 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x01, 0x0a, 0x1e, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, - 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, - 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, + 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x1a, 0x14, 0x67, 0x6f, + 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, 0x74, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x70, 0x32, 0x70, 0x2f, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, + 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x74, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, + 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x70, + 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x19, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x80, 0x01, 0x0a, 0x1e, 0x47, + 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x42, 0x79, + 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, + 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, + 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xd8, 0x01, + 0x0a, 0x1f, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, + 0x74, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, + 0x69, 0x67, 0x68, 0x74, 0x12, 0x49, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, + 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, + 0x47, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0a, 0x70, 0x61, 0x67, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xd8, 0x01, 0x0a, 0x1f, 0x47, 0x65, 0x74, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x42, 0x79, 0x48, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x49, - 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, - 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0a, 0x76, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x47, 0x0a, 0x0a, 0x70, 0x61, 0x67, - 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, - 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x22, 0x66, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, - 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, - 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x0a, - 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xd6, 0x01, 0x0a, 0x1d, 0x47, - 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, - 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, - 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, - 0x49, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, - 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0a, - 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x12, 0x47, 0x0a, 0x0a, 0x70, 0x61, - 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x22, 0xbe, 0x01, 0x0a, 0x09, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, - 0x72, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x2d, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x70, 0x75, - 0x62, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x76, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x70, - 0x6f, 0x77, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x76, 0x6f, 0x74, 0x69, - 0x6e, 0x67, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x11, 0x70, 0x72, 0x6f, 0x70, 0x6f, - 0x73, 0x65, 0x72, 0x5f, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x10, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x50, 0x72, 0x69, 0x6f, - 0x72, 0x69, 0x74, 0x79, 0x22, 0x31, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, - 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x7f, 0x0a, 0x18, 0x47, 0x65, 0x74, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, - 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, - 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x2d, 0x0a, 0x05, 0x62, 0x6c, 0x6f, - 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, - 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x42, 0x6c, 0x6f, 0x63, - 0x6b, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x17, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x4c, - 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x22, 0x7d, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, - 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x62, - 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, - 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, - 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, - 0x64, 0x12, 0x2d, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, - 0x70, 0x65, 0x73, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, - 0x22, 0x13, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2e, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x53, 0x79, 0x6e, 0x63, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, - 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x79, - 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x22, 0x14, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0xaa, 0x01, 0x0a, 0x13, - 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x09, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, - 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, - 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x5c, 0x0a, 0x13, 0x61, 0x70, - 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, 0x61, + 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x66, 0x0a, 0x1c, 0x47, 0x65, 0x74, 0x4c, + 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x46, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, + 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x22, 0xd6, 0x01, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x68, 0x65, 0x69, 0x67, + 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x48, + 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x49, 0x0a, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, + 0x6f, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, + 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, + 0x61, 0x74, 0x6f, 0x72, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, + 0x12, 0x47, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, + 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, + 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x52, 0x0a, 0x70, + 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0xbe, 0x01, 0x0a, 0x09, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x2d, 0x0a, 0x07, 0x70, + 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, + 0x6e, 0x79, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x76, 0x6f, + 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x0b, 0x76, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x12, 0x2b, 0x0a, + 0x11, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x5f, 0x70, 0x72, 0x69, 0x6f, 0x72, 0x69, + 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x10, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, + 0x65, 0x72, 0x50, 0x72, 0x69, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x22, 0x31, 0x0a, 0x17, 0x47, 0x65, + 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x22, 0x7f, 0x0a, + 0x18, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x08, 0x62, 0x6c, 0x6f, + 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x74, 0x65, + 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x42, + 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x52, 0x07, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, + 0x2d, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, + 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, + 0x73, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x17, + 0x0a, 0x15, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x7d, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4c, 0x61, + 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x34, 0x0a, 0x08, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, + 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x44, 0x52, 0x07, + 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x49, 0x64, 0x12, 0x2d, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, + 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, + 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x22, 0x13, 0x0a, 0x11, 0x47, 0x65, 0x74, 0x53, 0x79, 0x6e, + 0x63, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x2e, 0x0a, 0x12, 0x47, + 0x65, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x07, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x22, 0x14, 0x0a, 0x12, 0x47, + 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x22, 0xaa, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, + 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x09, 0x6e, 0x6f, 0x64, + 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x32, 0x70, 0x2e, 0x4e, 0x6f, + 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, 0x6e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, + 0x12, 0x5c, 0x0a, 0x13, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2b, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x56, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x12, 0x61, 0x70, 0x70, 0x6c, + 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa8, + 0x02, 0x0a, 0x0b, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, + 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x61, 0x70, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x69, 0x74, 0x5f, 0x63, + 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x69, 0x74, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, + 0x74, 0x61, 0x67, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, + 0x64, 0x54, 0x61, 0x67, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x6f, 0x5f, 0x76, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x6f, 0x56, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x45, 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x64, 0x65, + 0x70, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, + 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x44, 0x65, 0x70, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x73, 0x64, 0x6b, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x53, + 0x64, 0x6b, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x48, 0x0a, 0x06, 0x4d, 0x6f, 0x64, + 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x73, 0x75, 0x6d, 0x22, 0x68, 0x0a, 0x10, 0x41, 0x42, 0x43, 0x49, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, + 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x6f, 0x76, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x70, 0x72, 0x6f, 0x76, 0x65, 0x22, 0x8e, 0x02, + 0x0a, 0x11, 0x41, 0x42, 0x43, 0x49, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x6f, 0x67, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6c, 0x6f, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x69, 0x6e, 0x66, + 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x14, 0x0a, + 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x69, 0x6e, + 0x64, 0x65, 0x78, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0c, + 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x45, 0x0a, 0x09, 0x70, + 0x72, 0x6f, 0x6f, 0x66, 0x5f, 0x6f, 0x70, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, + 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4f, 0x70, 0x73, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x6f, 0x66, 0x4f, + 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x09, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x06, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, + 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x63, + 0x6f, 0x64, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x4a, 0x04, 0x08, 0x02, 0x10, 0x03, 0x22, 0x43, + 0x0a, 0x07, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4f, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, + 0x61, 0x74, 0x61, 0x22, 0x4b, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4f, 0x70, 0x73, 0x12, + 0x3f, 0x0a, 0x03, 0x6f, 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x72, + 0x6f, 0x6f, 0x66, 0x4f, 0x70, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x03, 0x6f, 0x70, 0x73, + 0x32, 0xaf, 0x0a, 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa9, 0x01, 0x0a, + 0x0b, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x32, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, + 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x33, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x31, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x12, 0x29, 0x2f, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, + 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x6e, + 0x6f, 0x64, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0xa4, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, + 0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x31, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, - 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x12, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0xa8, 0x02, 0x0a, 0x0b, 0x56, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x19, 0x0a, 0x08, - 0x61, 0x70, 0x70, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x61, 0x70, 0x70, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x1d, 0x0a, 0x0a, 0x67, 0x69, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x69, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, - 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x74, 0x61, 0x67, 0x73, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x54, 0x61, 0x67, 0x73, 0x12, - 0x1d, 0x0a, 0x0a, 0x67, 0x6f, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x67, 0x6f, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x45, - 0x0a, 0x0a, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x64, 0x65, 0x70, 0x73, 0x18, 0x07, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, + 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x79, 0x6e, 0x63, + 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, + 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, + 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2f, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x29, 0x12, 0x27, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x12, + 0xb6, 0x01, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x12, 0x35, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x09, 0x62, 0x75, 0x69, 0x6c, - 0x64, 0x44, 0x65, 0x70, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, - 0x73, 0x64, 0x6b, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x10, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x53, 0x64, 0x6b, 0x56, 0x65, 0x72, 0x73, - 0x69, 0x6f, 0x6e, 0x22, 0x48, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x73, - 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x75, 0x6d, 0x32, 0x88, 0x09, - 0x0a, 0x07, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0xa9, 0x01, 0x0a, 0x0b, 0x47, 0x65, - 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x32, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, + 0x63, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, - 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4e, 0x6f, - 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x33, 0x2e, + 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, + 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x35, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2f, 0x12, 0x2d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, + 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, + 0x73, 0x2f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0xbe, 0x01, 0x0a, 0x10, 0x47, 0x65, 0x74, + 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x37, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, - 0x65, 0x74, 0x4e, 0x6f, 0x64, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x31, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x12, 0x29, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, - 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x6e, 0x6f, 0x64, 0x65, - 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0xa4, 0x01, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x53, 0x79, 0x6e, - 0x63, 0x69, 0x6e, 0x67, 0x12, 0x31, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, - 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x32, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x79, 0x6e, 0x63, - 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2f, 0x82, 0xd3, 0xe4, - 0x93, 0x02, 0x29, 0x12, 0x27, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, - 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x2f, 0x73, 0x79, 0x6e, 0x63, 0x69, 0x6e, 0x67, 0x12, 0xb6, 0x01, 0x0a, - 0x0e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x12, - 0x35, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, - 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x36, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, - 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x35, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2f, 0x12, 0x2d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, - 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x6c, - 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0xbe, 0x01, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, - 0x63, 0x6b, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x37, 0x2e, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, - 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, - 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x38, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, + 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x37, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x12, 0x2f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, + 0x2f, 0x7b, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x7d, 0x12, 0xd2, 0x01, 0x0a, 0x15, 0x47, 0x65, + 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, + 0x53, 0x65, 0x74, 0x12, 0x3c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, - 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x42, 0x79, 0x48, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x37, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x12, 0x2f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, - 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x2f, 0x7b, 0x68, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x7d, 0x12, 0xd2, 0x01, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x4c, 0x61, - 0x74, 0x65, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, - 0x12, 0x3c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, - 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, - 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3d, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, - 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, - 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3c, 0x82, - 0xd3, 0xe4, 0x93, 0x02, 0x36, 0x12, 0x34, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, - 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, - 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, - 0x73, 0x65, 0x74, 0x73, 0x2f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0xda, 0x01, 0x0a, 0x17, - 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x42, - 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x3e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, - 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, - 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x38, - 0x12, 0x36, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, - 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x65, 0x74, 0x73, 0x2f, - 0x7b, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x7d, 0x42, 0x9e, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, - 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x51, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, - 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, - 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0xa2, 0x02, 0x03, 0x43, 0x42, 0x54, 0xaa, 0x02, 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x42, 0x61, 0x73, 0x65, 0x2e, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, - 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, - 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xe2, 0x02, 0x2a, 0x43, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, - 0x74, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x21, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, - 0x42, 0x61, 0x73, 0x65, 0x3a, 0x3a, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, - 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, + 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, 0x61, + 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x3d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, + 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x56, 0x61, 0x6c, 0x69, + 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x3c, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x36, 0x12, 0x34, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, + 0x74, 0x6f, 0x72, 0x73, 0x65, 0x74, 0x73, 0x2f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x12, 0xda, + 0x01, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, + 0x65, 0x74, 0x42, 0x79, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x3e, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, + 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x42, 0x79, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3f, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, + 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x74, 0x56, + 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x42, 0x79, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x3e, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x38, 0x12, 0x36, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, + 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x73, 0x65, + 0x74, 0x73, 0x2f, 0x7b, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x7d, 0x12, 0xa4, 0x01, 0x0a, 0x09, + 0x41, 0x42, 0x43, 0x49, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x30, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, + 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x41, 0x42, 0x43, 0x49, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x31, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x41, 0x42, 0x43, + 0x49, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x32, + 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2c, 0x12, 0x2a, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61, 0x62, 0x63, 0x69, 0x5f, 0x71, 0x75, 0x65, + 0x72, 0x79, 0x42, 0x8e, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, + 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x41, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, + 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, + 0x69, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x54, + 0xaa, 0x02, 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x2e, 0x54, + 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0xca, 0x02, 0x1e, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, 0x5c, + 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0xe2, 0x02, 0x2a, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x42, 0x61, 0x73, 0x65, + 0x5c, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x5c, 0x56, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, + 0x02, 0x21, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x42, 0x61, 0x73, 0x65, 0x3a, 0x3a, + 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -8623,7 +11461,7 @@ func file_cosmos_base_tendermint_v1beta1_query_proto_rawDescGZIP() []byte { return file_cosmos_base_tendermint_v1beta1_query_proto_rawDescData } -var file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 19) var file_cosmos_base_tendermint_v1beta1_query_proto_goTypes = []interface{}{ (*GetValidatorSetByHeightRequest)(nil), // 0: cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest (*GetValidatorSetByHeightResponse)(nil), // 1: cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse @@ -8640,45 +11478,53 @@ var file_cosmos_base_tendermint_v1beta1_query_proto_goTypes = []interface{}{ (*GetNodeInfoResponse)(nil), // 12: cosmos.base.tendermint.v1beta1.GetNodeInfoResponse (*VersionInfo)(nil), // 13: cosmos.base.tendermint.v1beta1.VersionInfo (*Module)(nil), // 14: cosmos.base.tendermint.v1beta1.Module - (*v1beta1.PageRequest)(nil), // 15: cosmos.base.query.v1beta1.PageRequest - (*v1beta1.PageResponse)(nil), // 16: cosmos.base.query.v1beta1.PageResponse - (*anypb.Any)(nil), // 17: google.protobuf.Any - (*types.BlockID)(nil), // 18: tendermint.types.BlockID - (*types.Block)(nil), // 19: tendermint.types.Block - (*p2p.NodeInfo)(nil), // 20: tendermint.p2p.NodeInfo + (*ABCIQueryRequest)(nil), // 15: cosmos.base.tendermint.v1beta1.ABCIQueryRequest + (*ABCIQueryResponse)(nil), // 16: cosmos.base.tendermint.v1beta1.ABCIQueryResponse + (*ProofOp)(nil), // 17: cosmos.base.tendermint.v1beta1.ProofOp + (*ProofOps)(nil), // 18: cosmos.base.tendermint.v1beta1.ProofOps + (*v1beta1.PageRequest)(nil), // 19: cosmos.base.query.v1beta1.PageRequest + (*v1beta1.PageResponse)(nil), // 20: cosmos.base.query.v1beta1.PageResponse + (*anypb.Any)(nil), // 21: google.protobuf.Any + (*types.BlockID)(nil), // 22: tendermint.types.BlockID + (*types.Block)(nil), // 23: tendermint.types.Block + (*p2p.NodeInfo)(nil), // 24: tendermint.p2p.NodeInfo } var file_cosmos_base_tendermint_v1beta1_query_proto_depIdxs = []int32{ - 15, // 0: cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest + 19, // 0: cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest 4, // 1: cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse.validators:type_name -> cosmos.base.tendermint.v1beta1.Validator - 16, // 2: cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse - 15, // 3: cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest + 20, // 2: cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse + 19, // 3: cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest.pagination:type_name -> cosmos.base.query.v1beta1.PageRequest 4, // 4: cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse.validators:type_name -> cosmos.base.tendermint.v1beta1.Validator - 16, // 5: cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse - 17, // 6: cosmos.base.tendermint.v1beta1.Validator.pub_key:type_name -> google.protobuf.Any - 18, // 7: cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse.block_id:type_name -> tendermint.types.BlockID - 19, // 8: cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse.block:type_name -> tendermint.types.Block - 18, // 9: cosmos.base.tendermint.v1beta1.GetLatestBlockResponse.block_id:type_name -> tendermint.types.BlockID - 19, // 10: cosmos.base.tendermint.v1beta1.GetLatestBlockResponse.block:type_name -> tendermint.types.Block - 20, // 11: cosmos.base.tendermint.v1beta1.GetNodeInfoResponse.node_info:type_name -> tendermint.p2p.NodeInfo + 20, // 5: cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse.pagination:type_name -> cosmos.base.query.v1beta1.PageResponse + 21, // 6: cosmos.base.tendermint.v1beta1.Validator.pub_key:type_name -> google.protobuf.Any + 22, // 7: cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse.block_id:type_name -> tendermint.types.BlockID + 23, // 8: cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse.block:type_name -> tendermint.types.Block + 22, // 9: cosmos.base.tendermint.v1beta1.GetLatestBlockResponse.block_id:type_name -> tendermint.types.BlockID + 23, // 10: cosmos.base.tendermint.v1beta1.GetLatestBlockResponse.block:type_name -> tendermint.types.Block + 24, // 11: cosmos.base.tendermint.v1beta1.GetNodeInfoResponse.node_info:type_name -> tendermint.p2p.NodeInfo 13, // 12: cosmos.base.tendermint.v1beta1.GetNodeInfoResponse.application_version:type_name -> cosmos.base.tendermint.v1beta1.VersionInfo 14, // 13: cosmos.base.tendermint.v1beta1.VersionInfo.build_deps:type_name -> cosmos.base.tendermint.v1beta1.Module - 11, // 14: cosmos.base.tendermint.v1beta1.Service.GetNodeInfo:input_type -> cosmos.base.tendermint.v1beta1.GetNodeInfoRequest - 9, // 15: cosmos.base.tendermint.v1beta1.Service.GetSyncing:input_type -> cosmos.base.tendermint.v1beta1.GetSyncingRequest - 7, // 16: cosmos.base.tendermint.v1beta1.Service.GetLatestBlock:input_type -> cosmos.base.tendermint.v1beta1.GetLatestBlockRequest - 5, // 17: cosmos.base.tendermint.v1beta1.Service.GetBlockByHeight:input_type -> cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest - 2, // 18: cosmos.base.tendermint.v1beta1.Service.GetLatestValidatorSet:input_type -> cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest - 0, // 19: cosmos.base.tendermint.v1beta1.Service.GetValidatorSetByHeight:input_type -> cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest - 12, // 20: cosmos.base.tendermint.v1beta1.Service.GetNodeInfo:output_type -> cosmos.base.tendermint.v1beta1.GetNodeInfoResponse - 10, // 21: cosmos.base.tendermint.v1beta1.Service.GetSyncing:output_type -> cosmos.base.tendermint.v1beta1.GetSyncingResponse - 8, // 22: cosmos.base.tendermint.v1beta1.Service.GetLatestBlock:output_type -> cosmos.base.tendermint.v1beta1.GetLatestBlockResponse - 6, // 23: cosmos.base.tendermint.v1beta1.Service.GetBlockByHeight:output_type -> cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse - 3, // 24: cosmos.base.tendermint.v1beta1.Service.GetLatestValidatorSet:output_type -> cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse - 1, // 25: cosmos.base.tendermint.v1beta1.Service.GetValidatorSetByHeight:output_type -> cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse - 20, // [20:26] is the sub-list for method output_type - 14, // [14:20] is the sub-list for method input_type - 14, // [14:14] is the sub-list for extension type_name - 14, // [14:14] is the sub-list for extension extendee - 0, // [0:14] is the sub-list for field type_name + 18, // 14: cosmos.base.tendermint.v1beta1.ABCIQueryResponse.proof_ops:type_name -> cosmos.base.tendermint.v1beta1.ProofOps + 17, // 15: cosmos.base.tendermint.v1beta1.ProofOps.ops:type_name -> cosmos.base.tendermint.v1beta1.ProofOp + 11, // 16: cosmos.base.tendermint.v1beta1.Service.GetNodeInfo:input_type -> cosmos.base.tendermint.v1beta1.GetNodeInfoRequest + 9, // 17: cosmos.base.tendermint.v1beta1.Service.GetSyncing:input_type -> cosmos.base.tendermint.v1beta1.GetSyncingRequest + 7, // 18: cosmos.base.tendermint.v1beta1.Service.GetLatestBlock:input_type -> cosmos.base.tendermint.v1beta1.GetLatestBlockRequest + 5, // 19: cosmos.base.tendermint.v1beta1.Service.GetBlockByHeight:input_type -> cosmos.base.tendermint.v1beta1.GetBlockByHeightRequest + 2, // 20: cosmos.base.tendermint.v1beta1.Service.GetLatestValidatorSet:input_type -> cosmos.base.tendermint.v1beta1.GetLatestValidatorSetRequest + 0, // 21: cosmos.base.tendermint.v1beta1.Service.GetValidatorSetByHeight:input_type -> cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest + 15, // 22: cosmos.base.tendermint.v1beta1.Service.ABCIQuery:input_type -> cosmos.base.tendermint.v1beta1.ABCIQueryRequest + 12, // 23: cosmos.base.tendermint.v1beta1.Service.GetNodeInfo:output_type -> cosmos.base.tendermint.v1beta1.GetNodeInfoResponse + 10, // 24: cosmos.base.tendermint.v1beta1.Service.GetSyncing:output_type -> cosmos.base.tendermint.v1beta1.GetSyncingResponse + 8, // 25: cosmos.base.tendermint.v1beta1.Service.GetLatestBlock:output_type -> cosmos.base.tendermint.v1beta1.GetLatestBlockResponse + 6, // 26: cosmos.base.tendermint.v1beta1.Service.GetBlockByHeight:output_type -> cosmos.base.tendermint.v1beta1.GetBlockByHeightResponse + 3, // 27: cosmos.base.tendermint.v1beta1.Service.GetLatestValidatorSet:output_type -> cosmos.base.tendermint.v1beta1.GetLatestValidatorSetResponse + 1, // 28: cosmos.base.tendermint.v1beta1.Service.GetValidatorSetByHeight:output_type -> cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse + 16, // 29: cosmos.base.tendermint.v1beta1.Service.ABCIQuery:output_type -> cosmos.base.tendermint.v1beta1.ABCIQueryResponse + 23, // [23:30] is the sub-list for method output_type + 16, // [16:23] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_cosmos_base_tendermint_v1beta1_query_proto_init() } @@ -8867,6 +11713,54 @@ func file_cosmos_base_tendermint_v1beta1_query_proto_init() { return nil } } + file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ABCIQueryRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ABCIQueryResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProofOp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cosmos_base_tendermint_v1beta1_query_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ProofOps); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -8874,7 +11768,7 @@ func file_cosmos_base_tendermint_v1beta1_query_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cosmos_base_tendermint_v1beta1_query_proto_rawDesc, NumEnums: 0, - NumMessages: 15, + NumMessages: 19, NumExtensions: 0, NumServices: 1, }, diff --git a/api/cosmos/base/tendermint/v1beta1/query_grpc.pb.go b/api/cosmos/base/tendermint/v1beta1/query_grpc.pb.go index 189f936086a9..b21c4f7f8459 100644 --- a/api/cosmos/base/tendermint/v1beta1/query_grpc.pb.go +++ b/api/cosmos/base/tendermint/v1beta1/query_grpc.pb.go @@ -34,6 +34,12 @@ type ServiceClient interface { GetLatestValidatorSet(ctx context.Context, in *GetLatestValidatorSetRequest, opts ...grpc.CallOption) (*GetLatestValidatorSetResponse, error) // GetValidatorSetByHeight queries validator-set at a given height. GetValidatorSetByHeight(ctx context.Context, in *GetValidatorSetByHeightRequest, opts ...grpc.CallOption) (*GetValidatorSetByHeightResponse, error) + // ABCIQuery defines a query handler that supports ABCI queries directly to the + // application, bypassing Tendermint completely. The ABCI query must contain + // a valid and supported path, including app, custom, p2p, and store. + // + // Since: cosmos-sdk 0.46 + ABCIQuery(ctx context.Context, in *ABCIQueryRequest, opts ...grpc.CallOption) (*ABCIQueryResponse, error) } type serviceClient struct { @@ -98,6 +104,15 @@ func (c *serviceClient) GetValidatorSetByHeight(ctx context.Context, in *GetVali return out, nil } +func (c *serviceClient) ABCIQuery(ctx context.Context, in *ABCIQueryRequest, opts ...grpc.CallOption) (*ABCIQueryResponse, error) { + out := new(ABCIQueryResponse) + err := c.cc.Invoke(ctx, "/cosmos.base.tendermint.v1beta1.Service/ABCIQuery", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ServiceServer is the server API for Service service. // All implementations must embed UnimplementedServiceServer // for forward compatibility @@ -114,6 +129,12 @@ type ServiceServer interface { GetLatestValidatorSet(context.Context, *GetLatestValidatorSetRequest) (*GetLatestValidatorSetResponse, error) // GetValidatorSetByHeight queries validator-set at a given height. GetValidatorSetByHeight(context.Context, *GetValidatorSetByHeightRequest) (*GetValidatorSetByHeightResponse, error) + // ABCIQuery defines a query handler that supports ABCI queries directly to the + // application, bypassing Tendermint completely. The ABCI query must contain + // a valid and supported path, including app, custom, p2p, and store. + // + // Since: cosmos-sdk 0.46 + ABCIQuery(context.Context, *ABCIQueryRequest) (*ABCIQueryResponse, error) mustEmbedUnimplementedServiceServer() } @@ -139,6 +160,9 @@ func (UnimplementedServiceServer) GetLatestValidatorSet(context.Context, *GetLat func (UnimplementedServiceServer) GetValidatorSetByHeight(context.Context, *GetValidatorSetByHeightRequest) (*GetValidatorSetByHeightResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetValidatorSetByHeight not implemented") } +func (UnimplementedServiceServer) ABCIQuery(context.Context, *ABCIQueryRequest) (*ABCIQueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ABCIQuery not implemented") +} func (UnimplementedServiceServer) mustEmbedUnimplementedServiceServer() {} // UnsafeServiceServer may be embedded to opt out of forward compatibility for this service. @@ -260,6 +284,24 @@ func _Service_GetValidatorSetByHeight_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +func _Service_ABCIQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ABCIQueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).ABCIQuery(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.base.tendermint.v1beta1.Service/ABCIQuery", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).ABCIQuery(ctx, req.(*ABCIQueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + // Service_ServiceDesc is the grpc.ServiceDesc for Service service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -291,6 +333,10 @@ var Service_ServiceDesc = grpc.ServiceDesc{ MethodName: "GetValidatorSetByHeight", Handler: _Service_GetValidatorSetByHeight_Handler, }, + { + MethodName: "ABCIQuery", + Handler: _Service_ABCIQuery_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/base/tendermint/v1beta1/query.proto", diff --git a/api/cosmos/base/v1beta1/coin.pulsar.go b/api/cosmos/base/v1beta1/coin.pulsar.go index 52162e9cd3c7..51913f4d508a 100644 --- a/api/cosmos/base/v1beta1/coin.pulsar.go +++ b/api/cosmos/base/v1beta1/coin.pulsar.go @@ -2028,11 +2028,10 @@ var file_cosmos_base_v1beta1_coin_proto_rawDesc = []byte{ 0x22, 0x37, 0x0a, 0x08, 0x44, 0x65, 0x63, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2b, 0x0a, 0x03, 0x64, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, 0xc8, 0xde, 0x1f, 0x00, 0xda, 0xde, 0x1f, 0x03, 0x44, 0x65, 0x63, 0xd2, 0xb4, 0x2d, 0x0a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x44, 0x65, 0x63, 0x52, 0x03, 0x64, 0x65, 0x63, 0x42, 0xdc, 0x01, 0x0a, 0x17, 0x63, 0x6f, + 0x2e, 0x44, 0x65, 0x63, 0x52, 0x03, 0x64, 0x65, 0x63, 0x42, 0xcc, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x09, 0x43, 0x6f, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, + 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x62, 0x61, 0x73, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x42, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, diff --git a/api/cosmos/capability/v1beta1/capability.pulsar.go b/api/cosmos/capability/v1beta1/capability.pulsar.go index fe02b64b3c73..bb8c8638b7f9 100644 --- a/api/cosmos/capability/v1beta1/capability.pulsar.go +++ b/api/cosmos/capability/v1beta1/capability.pulsar.go @@ -1547,12 +1547,11 @@ var file_cosmos_capability_v1beta1_capability_proto_rawDesc = []byte{ 0x6e, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x42, 0x04, 0xc8, 0xde, - 0x1f, 0x00, 0x52, 0x06, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x73, 0x42, 0x84, 0x02, 0x0a, 0x1d, 0x63, + 0x1f, 0x00, 0x52, 0x06, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x73, 0x42, 0xf4, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0f, 0x43, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, + 0x3c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, diff --git a/api/cosmos/capability/v1beta1/genesis.pulsar.go b/api/cosmos/capability/v1beta1/genesis.pulsar.go index 4d2fee4c4140..823ad3458e9b 100644 --- a/api/cosmos/capability/v1beta1/genesis.pulsar.go +++ b/api/cosmos/capability/v1beta1/genesis.pulsar.go @@ -1170,12 +1170,11 @@ var file_cosmos_capability_v1beta1_genesis_proto_rawDesc = []byte{ 0x6f, 0x73, 0x2e, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x4f, 0x77, 0x6e, 0x65, 0x72, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x6f, 0x77, 0x6e, 0x65, 0x72, - 0x73, 0x42, 0x81, 0x02, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x42, 0xf1, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x4c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, - 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x61, 0x70, + 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x63, 0x61, 0x70, 0x61, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, diff --git a/api/cosmos/crisis/v1beta1/genesis.pulsar.go b/api/cosmos/crisis/v1beta1/genesis.pulsar.go index 2eb440839d5d..902ae1cb0a47 100644 --- a/api/cosmos/crisis/v1beta1/genesis.pulsar.go +++ b/api/cosmos/crisis/v1beta1/genesis.pulsar.go @@ -2,9 +2,9 @@ package crisisv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -515,12 +515,11 @@ var file_cosmos_crisis_v1beta1_genesis_proto_rawDesc = []byte{ 0x65, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x74, - 0x61, 0x6e, 0x74, 0x46, 0x65, 0x65, 0x42, 0xe5, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x61, 0x6e, 0x74, 0x46, 0x65, 0x65, 0x42, 0xd5, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x69, 0x73, 0x69, 0x73, diff --git a/api/cosmos/crisis/v1beta1/tx.pulsar.go b/api/cosmos/crisis/v1beta1/tx.pulsar.go index 574ef5f116d1..13a5f6f51adb 100644 --- a/api/cosmos/crisis/v1beta1/tx.pulsar.go +++ b/api/cosmos/crisis/v1beta1/tx.pulsar.go @@ -2,10 +2,10 @@ package crisisv1beta1 import ( + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -1043,11 +1043,10 @@ var file_cosmos_crisis_v1beta1_tx_proto_rawDesc = []byte{ 0x31, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0xe0, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x65, 0x42, 0xd0, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x63, 0x72, 0x69, 0x73, 0x69, 0x73, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x58, 0xaa, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, diff --git a/api/cosmos/crypto/ed25519/keys.pulsar.go b/api/cosmos/crypto/ed25519/keys.pulsar.go index f4373f44a3aa..0369058c077b 100644 --- a/api/cosmos/crypto/ed25519/keys.pulsar.go +++ b/api/cosmos/crypto/ed25519/keys.pulsar.go @@ -962,12 +962,11 @@ var file_cosmos_crypto_ed25519_keys_proto_rawDesc = []byte{ 0x3a, 0x0a, 0x07, 0x50, 0x72, 0x69, 0x76, 0x4b, 0x65, 0x79, 0x12, 0x2f, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x1d, 0xfa, 0xde, 0x1f, 0x19, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0x2e, 0x50, 0x72, 0x69, 0x76, - 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x42, 0xd4, 0x01, 0x0a, 0x19, + 0x61, 0x74, 0x65, 0x4b, 0x65, 0x79, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x42, 0xc4, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0x42, 0x09, 0x4b, 0x65, 0x79, 0x73, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x26, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x65, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x45, 0xaa, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x45, 0x64, 0x32, 0x35, 0x35, 0x31, 0x39, 0xca, 0x02, 0x15, 0x43, diff --git a/api/cosmos/crypto/hd/v1/hd.pulsar.go b/api/cosmos/crypto/hd/v1/hd.pulsar.go index 0933470be443..6cc8df992e21 100644 --- a/api/cosmos/crypto/hd/v1/hd.pulsar.go +++ b/api/cosmos/crypto/hd/v1/hd.pulsar.go @@ -615,6 +615,8 @@ func (x *fastReflection_BIP44Params) ProtoMethods() *protoiface.Methods { } } +// Since: cosmos-sdk 0.46 + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -719,12 +721,11 @@ var file_cosmos_crypto_hd_v1_hd_proto_rawDesc = []byte{ 0x61, 0x6e, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x61, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0xd0, 0x01, + 0x73, 0x73, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0xc0, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x68, 0x64, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x48, 0x64, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x39, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x29, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x68, 0x64, 0x2f, 0x76, 0x31, 0x3b, 0x68, 0x64, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x48, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x48, 0x64, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x13, 0x43, 0x6f, diff --git a/api/cosmos/crypto/keyring/v1/record.pulsar.go b/api/cosmos/crypto/keyring/v1/record.pulsar.go index 11a6ba5fc009..7a330c9c247d 100644 --- a/api/cosmos/crypto/keyring/v1/record.pulsar.go +++ b/api/cosmos/crypto/keyring/v1/record.pulsar.go @@ -2,9 +2,9 @@ package keyringv1 import ( + v1 "cosmossdk.io/api/cosmos/crypto/hd/v1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - v1 "github.com/cosmos/cosmos-sdk/api/cosmos/crypto/hd/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -945,16 +945,14 @@ func (x *fastReflection_Record) ProtoMethods() *protoiface.Methods { } var ( - md_Record_Local protoreflect.MessageDescriptor - fd_Record_Local_priv_key protoreflect.FieldDescriptor - fd_Record_Local_priv_key_type protoreflect.FieldDescriptor + md_Record_Local protoreflect.MessageDescriptor + fd_Record_Local_priv_key protoreflect.FieldDescriptor ) func init() { file_cosmos_crypto_keyring_v1_record_proto_init() md_Record_Local = File_cosmos_crypto_keyring_v1_record_proto.Messages().ByName("Record").Messages().ByName("Local") fd_Record_Local_priv_key = md_Record_Local.Fields().ByName("priv_key") - fd_Record_Local_priv_key_type = md_Record_Local.Fields().ByName("priv_key_type") } var _ protoreflect.Message = (*fastReflection_Record_Local)(nil) @@ -1028,12 +1026,6 @@ func (x *fastReflection_Record_Local) Range(f func(protoreflect.FieldDescriptor, return } } - if x.PrivKeyType != "" { - value := protoreflect.ValueOfString(x.PrivKeyType) - if !f(fd_Record_Local_priv_key_type, value) { - return - } - } } // Has reports whether a field is populated. @@ -1051,8 +1043,6 @@ func (x *fastReflection_Record_Local) Has(fd protoreflect.FieldDescriptor) bool switch fd.FullName() { case "cosmos.crypto.keyring.v1.Record.Local.priv_key": return x.PrivKey != nil - case "cosmos.crypto.keyring.v1.Record.Local.priv_key_type": - return x.PrivKeyType != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crypto.keyring.v1.Record.Local")) @@ -1071,8 +1061,6 @@ func (x *fastReflection_Record_Local) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { case "cosmos.crypto.keyring.v1.Record.Local.priv_key": x.PrivKey = nil - case "cosmos.crypto.keyring.v1.Record.Local.priv_key_type": - x.PrivKeyType = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crypto.keyring.v1.Record.Local")) @@ -1092,9 +1080,6 @@ func (x *fastReflection_Record_Local) Get(descriptor protoreflect.FieldDescripto case "cosmos.crypto.keyring.v1.Record.Local.priv_key": value := x.PrivKey return protoreflect.ValueOfMessage(value.ProtoReflect()) - case "cosmos.crypto.keyring.v1.Record.Local.priv_key_type": - value := x.PrivKeyType - return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crypto.keyring.v1.Record.Local")) @@ -1117,8 +1102,6 @@ func (x *fastReflection_Record_Local) Set(fd protoreflect.FieldDescriptor, value switch fd.FullName() { case "cosmos.crypto.keyring.v1.Record.Local.priv_key": x.PrivKey = value.Message().Interface().(*anypb.Any) - case "cosmos.crypto.keyring.v1.Record.Local.priv_key_type": - x.PrivKeyType = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crypto.keyring.v1.Record.Local")) @@ -1144,8 +1127,6 @@ func (x *fastReflection_Record_Local) Mutable(fd protoreflect.FieldDescriptor) p x.PrivKey = new(anypb.Any) } return protoreflect.ValueOfMessage(x.PrivKey.ProtoReflect()) - case "cosmos.crypto.keyring.v1.Record.Local.priv_key_type": - panic(fmt.Errorf("field priv_key_type of message cosmos.crypto.keyring.v1.Record.Local is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crypto.keyring.v1.Record.Local")) @@ -1162,8 +1143,6 @@ func (x *fastReflection_Record_Local) NewField(fd protoreflect.FieldDescriptor) case "cosmos.crypto.keyring.v1.Record.Local.priv_key": m := new(anypb.Any) return protoreflect.ValueOfMessage(m.ProtoReflect()) - case "cosmos.crypto.keyring.v1.Record.Local.priv_key_type": - return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.crypto.keyring.v1.Record.Local")) @@ -1237,10 +1216,6 @@ func (x *fastReflection_Record_Local) ProtoMethods() *protoiface.Methods { l = options.Size(x.PrivKey) n += 1 + l + runtime.Sov(uint64(l)) } - l = len(x.PrivKeyType) - if l > 0 { - n += 1 + l + runtime.Sov(uint64(l)) - } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -1270,13 +1245,6 @@ func (x *fastReflection_Record_Local) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.PrivKeyType) > 0 { - i -= len(x.PrivKeyType) - copy(dAtA[i:], x.PrivKeyType) - i = runtime.EncodeVarint(dAtA, i, uint64(len(x.PrivKeyType))) - i-- - dAtA[i] = 0x12 - } if x.PrivKey != nil { encoded, err := options.Marshal(x.PrivKey) if err != nil { @@ -1376,38 +1344,6 @@ func (x *fastReflection_Record_Local) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } iNdEx = postIndex - case 2: - if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PrivKeyType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow - } - if iNdEx >= l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength - } - if postIndex > l { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF - } - x.PrivKeyType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -2590,6 +2526,8 @@ func (x *fastReflection_Record_Offline) ProtoMethods() *protoiface.Methods { } } +// Since: cosmos-sdk 0.46 + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -2697,22 +2635,22 @@ type isRecord_Item interface { } type Record_Local_ struct { - // local stores the public information about a locally stored key + // local stores the private key locally. Local *Record_Local `protobuf:"bytes,3,opt,name=local,proto3,oneof"` } type Record_Ledger_ struct { - // ledger stores the public information about a Ledger key + // ledger stores the information about a Ledger key. Ledger *Record_Ledger `protobuf:"bytes,4,opt,name=ledger,proto3,oneof"` } type Record_Multi_ struct { - // Multi does not store any information. + // Multi does not store any other information. Multi *Record_Multi `protobuf:"bytes,5,opt,name=multi,proto3,oneof"` } type Record_Offline_ struct { - // Offline does not store any information. + // Offline does not store any other information. Offline *Record_Offline `protobuf:"bytes,6,opt,name=offline,proto3,oneof"` } @@ -2731,8 +2669,7 @@ type Record_Local struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - PrivKey *anypb.Any `protobuf:"bytes,1,opt,name=priv_key,json=privKey,proto3" json:"priv_key,omitempty"` - PrivKeyType string `protobuf:"bytes,2,opt,name=priv_key_type,json=privKeyType,proto3" json:"priv_key_type,omitempty"` + PrivKey *anypb.Any `protobuf:"bytes,1,opt,name=priv_key,json=privKey,proto3" json:"priv_key,omitempty"` } func (x *Record_Local) Reset() { @@ -2762,13 +2699,6 @@ func (x *Record_Local) GetPrivKey() *anypb.Any { return nil } -func (x *Record_Local) GetPrivKeyType() string { - if x != nil { - return x.PrivKeyType - } - return "" -} - // Ledger item type Record_Ledger struct { state protoimpl.MessageState @@ -2871,7 +2801,7 @@ var file_cosmos_crypto_keyring_v1_record_proto_rawDesc = []byte{ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x68, 0x64, 0x2f, 0x76, 0x31, 0x2f, 0x68, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x8e, 0x04, 0x0a, 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, + 0x22, 0xea, 0x03, 0x0a, 0x06, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, @@ -2892,35 +2822,31 @@ var file_cosmos_crypto_keyring_v1_record_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x6b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x2e, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x2e, 0x4f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x48, 0x00, 0x52, 0x07, - 0x6f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x1a, 0x5c, 0x0a, 0x05, 0x4c, 0x6f, 0x63, 0x61, 0x6c, + 0x6f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x1a, 0x38, 0x0a, 0x05, 0x4c, 0x6f, 0x63, 0x61, 0x6c, 0x12, 0x2f, 0x0a, 0x08, 0x70, 0x72, 0x69, 0x76, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x07, 0x70, 0x72, 0x69, 0x76, 0x4b, 0x65, - 0x79, 0x12, 0x22, 0x0a, 0x0d, 0x70, 0x72, 0x69, 0x76, 0x5f, 0x6b, 0x65, 0x79, 0x5f, 0x74, 0x79, - 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x4b, 0x65, - 0x79, 0x54, 0x79, 0x70, 0x65, 0x1a, 0x3e, 0x0a, 0x06, 0x4c, 0x65, 0x64, 0x67, 0x65, 0x72, 0x12, - 0x34, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x68, 0x64, - 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x49, 0x50, 0x34, 0x34, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x1a, 0x07, 0x0a, 0x05, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x1a, 0x09, - 0x0a, 0x07, 0x4f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x69, 0x74, 0x65, - 0x6d, 0x42, 0xf7, 0x01, 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x6b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2e, - 0x76, 0x31, 0x42, 0x0b, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x43, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, - 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, - 0x6f, 0x2f, 0x6b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x3b, 0x6b, 0x65, 0x79, - 0x72, 0x69, 0x6e, 0x67, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x4b, 0xaa, 0x02, 0x18, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x4b, 0x65, 0x79, - 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x5c, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5c, 0x4b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x5c, - 0x56, 0x31, 0xe2, 0x02, 0x24, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x72, 0x79, 0x70, - 0x74, 0x6f, 0x5c, 0x4b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, - 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x3a, 0x3a, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x3a, 0x3a, 0x4b, 0x65, 0x79, 0x72, - 0x69, 0x6e, 0x67, 0x3a, 0x3a, 0x56, 0x31, 0xc8, 0xe1, 0x1e, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x79, 0x1a, 0x3e, 0x0a, 0x06, 0x4c, 0x65, 0x64, 0x67, 0x65, 0x72, 0x12, 0x34, 0x0a, 0x04, 0x70, + 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x68, 0x64, 0x2e, 0x76, 0x31, 0x2e, + 0x42, 0x49, 0x50, 0x34, 0x34, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x04, 0x70, 0x61, 0x74, + 0x68, 0x1a, 0x07, 0x0a, 0x05, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x1a, 0x09, 0x0a, 0x07, 0x4f, 0x66, + 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x42, 0x06, 0x0a, 0x04, 0x69, 0x74, 0x65, 0x6d, 0x42, 0xe7, 0x01, + 0x0a, 0x1c, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, + 0x70, 0x74, 0x6f, 0x2e, 0x6b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x42, 0x0b, + 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x6b, 0x65, + 0x79, 0x72, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x3b, 0x6b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, + 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x4b, 0xaa, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x4b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, + 0x2e, 0x56, 0x31, 0xca, 0x02, 0x18, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x72, 0x79, + 0x70, 0x74, 0x6f, 0x5c, 0x4b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0xe2, 0x02, + 0x24, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x5c, 0x4b, + 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, + 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x3a, 0x3a, 0x4b, 0x65, 0x79, 0x72, 0x69, 0x6e, 0x67, 0x3a, + 0x3a, 0x56, 0x31, 0xc8, 0xe1, 0x1e, 0x00, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/cosmos/crypto/multisig/keys.pulsar.go b/api/cosmos/crypto/multisig/keys.pulsar.go index be9d932c4c6d..7bb7a67def16 100644 --- a/api/cosmos/crypto/multisig/keys.pulsar.go +++ b/api/cosmos/crypto/multisig/keys.pulsar.go @@ -632,12 +632,11 @@ var file_cosmos_crypto_multisig_keys_proto_rawDesc = []byte{ 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x0b, 0xe2, 0xde, 0x1f, 0x07, 0x50, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x73, 0x52, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, - 0x65, 0x79, 0x73, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xda, 0x01, 0x0a, 0x1a, 0x63, 0x6f, + 0x65, 0x79, 0x73, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x42, 0xca, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x42, 0x09, 0x4b, 0x65, 0x79, 0x73, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x37, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x27, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x4d, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0xca, 0x02, 0x16, diff --git a/api/cosmos/crypto/multisig/v1beta1/multisig.pulsar.go b/api/cosmos/crypto/multisig/v1beta1/multisig.pulsar.go index 3a94da45fe1f..66aebea2627c 100644 --- a/api/cosmos/crypto/multisig/v1beta1/multisig.pulsar.go +++ b/api/cosmos/crypto/multisig/v1beta1/multisig.pulsar.go @@ -1079,12 +1079,11 @@ var file_cosmos_crypto_multisig_v1beta1_multisig_proto_rawDesc = []byte{ 0x74, 0x6f, 0x72, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0f, 0x65, 0x78, 0x74, 0x72, 0x61, 0x42, 0x69, 0x74, 0x73, 0x53, 0x74, 0x6f, 0x72, 0x65, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6c, 0x65, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x65, 0x6c, 0x65, - 0x6d, 0x73, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0x9f, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, + 0x6d, 0x73, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0x8f, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0d, 0x4d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x4f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, + 0x5a, 0x3f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x73, 0x69, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, diff --git a/api/cosmos/crypto/secp256k1/keys.pulsar.go b/api/cosmos/crypto/secp256k1/keys.pulsar.go index dee51b3d5f66..7697a8acfc2a 100644 --- a/api/cosmos/crypto/secp256k1/keys.pulsar.go +++ b/api/cosmos/crypto/secp256k1/keys.pulsar.go @@ -958,11 +958,10 @@ var file_cosmos_crypto_secp256k1_keys_proto_rawDesc = []byte{ 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x22, 0x1b, 0x0a, 0x07, 0x50, 0x72, 0x69, 0x76, 0x4b, 0x65, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x42, 0xe0, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x65, 0x79, 0x42, 0xd0, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x73, 0x65, 0x63, 0x70, 0x32, 0x35, 0x36, 0x6b, 0x31, 0x42, 0x09, 0x4b, 0x65, 0x79, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, + 0x28, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x73, 0x65, 0x63, 0x70, 0x32, 0x35, 0x36, 0x6b, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x53, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, diff --git a/api/cosmos/crypto/secp256r1/keys.pulsar.go b/api/cosmos/crypto/secp256r1/keys.pulsar.go index b2d9fc79656f..347e5a10885c 100644 --- a/api/cosmos/crypto/secp256r1/keys.pulsar.go +++ b/api/cosmos/crypto/secp256r1/keys.pulsar.go @@ -960,12 +960,11 @@ var file_cosmos_crypto_secp256r1_keys_proto_rawDesc = []byte{ 0x65, 0x63, 0x64, 0x73, 0x61, 0x50, 0x4b, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x2e, 0x0a, 0x07, 0x50, 0x72, 0x69, 0x76, 0x4b, 0x65, 0x79, 0x12, 0x23, 0x0a, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x42, 0x0b, 0xda, 0xde, 0x1f, 0x07, 0x65, 0x63, 0x64, - 0x73, 0x61, 0x53, 0x4b, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x42, 0xec, 0x01, 0x0a, + 0x73, 0x61, 0x53, 0x4b, 0x52, 0x06, 0x73, 0x65, 0x63, 0x72, 0x65, 0x74, 0x42, 0xdc, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x73, 0x65, 0x63, 0x70, 0x32, 0x35, 0x36, 0x72, 0x31, 0x42, 0x09, 0x4b, 0x65, - 0x79, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x79, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2f, 0x73, 0x65, 0x63, 0x70, 0x32, 0x35, 0x36, 0x72, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x43, 0x53, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x53, 0x65, 0x63, 0x70, 0x32, 0x35, diff --git a/api/cosmos/distribution/v1beta1/distribution.pulsar.go b/api/cosmos/distribution/v1beta1/distribution.pulsar.go index a681cb4e6b08..60b5d9814057 100644 --- a/api/cosmos/distribution/v1beta1/distribution.pulsar.go +++ b/api/cosmos/distribution/v1beta1/distribution.pulsar.go @@ -2,10 +2,10 @@ package distributionv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -7339,12 +7339,11 @@ var file_cosmos_distribution_v1beta1_distribution_proto_rawDesc = []byte{ 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x6d, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0x98, 0xa0, - 0x1f, 0x01, 0x42, 0x98, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x1f, 0x01, 0x42, 0x88, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x11, 0x44, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, - 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x50, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, diff --git a/api/cosmos/distribution/v1beta1/genesis.pulsar.go b/api/cosmos/distribution/v1beta1/genesis.pulsar.go index 88cf6565db21..a005a8f1238c 100644 --- a/api/cosmos/distribution/v1beta1/genesis.pulsar.go +++ b/api/cosmos/distribution/v1beta1/genesis.pulsar.go @@ -2,10 +2,10 @@ package distributionv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -5984,12 +5984,11 @@ var file_cosmos_distribution_v1beta1_genesis_proto_rawDesc = []byte{ 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x63, 0x6f, 0x72, 0x64, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x14, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x6f, 0x72, 0x53, 0x6c, 0x61, 0x73, 0x68, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x3a, 0x08, 0x88, - 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x42, 0x93, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, + 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x42, 0x83, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, - 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x50, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, diff --git a/api/cosmos/distribution/v1beta1/query.pulsar.go b/api/cosmos/distribution/v1beta1/query.pulsar.go index fbbdc2bc5141..a354c084f7c7 100644 --- a/api/cosmos/distribution/v1beta1/query.pulsar.go +++ b/api/cosmos/distribution/v1beta1/query.pulsar.go @@ -2,11 +2,11 @@ package distributionv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" + v1beta11 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" - v1beta11 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -9325,12 +9325,11 @@ var file_cosmos_distribution_v1beta1_query_proto_rawDesc = []byte{ 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x33, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2d, 0x12, 0x2b, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, - 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x42, 0x8d, 0x02, 0x0a, + 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x5f, 0x70, 0x6f, 0x6f, 0x6c, 0x42, 0xfd, 0x01, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x50, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, + 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x40, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, diff --git a/api/cosmos/distribution/v1beta1/tx.pulsar.go b/api/cosmos/distribution/v1beta1/tx.pulsar.go index bda576fda0d2..eebf41d9e62f 100644 --- a/api/cosmos/distribution/v1beta1/tx.pulsar.go +++ b/api/cosmos/distribution/v1beta1/tx.pulsar.go @@ -2,11 +2,11 @@ package distributionv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -4094,11 +4094,10 @@ var file_cosmos_distribution_v1beta1_tx_proto_rawDesc = []byte{ 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x46, 0x75, 0x6e, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x74, 0x79, 0x50, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x42, 0x8e, 0x02, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x42, 0xfe, 0x01, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x50, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, + 0x40, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, diff --git a/api/cosmos/evidence/v1beta1/evidence.pulsar.go b/api/cosmos/evidence/v1beta1/evidence.pulsar.go index c23f58e6ccbe..b73310940bc6 100644 --- a/api/cosmos/evidence/v1beta1/evidence.pulsar.go +++ b/api/cosmos/evidence/v1beta1/evidence.pulsar.go @@ -709,11 +709,10 @@ var file_cosmos_evidence_v1beta1_evidence_proto_rawDesc = []byte{ 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x10, 0x63, 0x6f, 0x6e, 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x0c, 0x88, 0xa0, 0x1f, 0x00, 0x98, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, - 0x00, 0x42, 0xf8, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x00, 0x42, 0xe8, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0d, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, + 0x50, 0x01, 0x5a, 0x38, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, diff --git a/api/cosmos/evidence/v1beta1/genesis.pulsar.go b/api/cosmos/evidence/v1beta1/genesis.pulsar.go index b862fa7d6dfa..41bf5951f0e2 100644 --- a/api/cosmos/evidence/v1beta1/genesis.pulsar.go +++ b/api/cosmos/evidence/v1beta1/genesis.pulsar.go @@ -569,12 +569,11 @@ var file_cosmos_evidence_v1beta1_genesis_proto_rawDesc = []byte{ 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, 0x30, 0x0a, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, - 0x41, 0x6e, 0x79, 0x52, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x42, 0xf3, 0x01, + 0x41, 0x6e, 0x79, 0x52, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x42, 0xe3, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, - 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x45, 0x58, 0xaa, 0x02, 0x17, diff --git a/api/cosmos/evidence/v1beta1/query.pulsar.go b/api/cosmos/evidence/v1beta1/query.pulsar.go index 2c142859f3fc..bfb4b2b7d9ac 100644 --- a/api/cosmos/evidence/v1beta1/query.pulsar.go +++ b/api/cosmos/evidence/v1beta1/query.pulsar.go @@ -2,9 +2,9 @@ package evidencev1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -2116,12 +2116,11 @@ var file_cosmos_evidence_v1beta1_query_proto_rawDesc = []byte{ 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x12, 0x21, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x65, - 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x42, 0xf1, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, + 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x42, 0xe1, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x45, 0x58, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x45, diff --git a/api/cosmos/evidence/v1beta1/tx.pulsar.go b/api/cosmos/evidence/v1beta1/tx.pulsar.go index ea8fc10499d1..a58621c7ca24 100644 --- a/api/cosmos/evidence/v1beta1/tx.pulsar.go +++ b/api/cosmos/evidence/v1beta1/tx.pulsar.go @@ -2,10 +2,10 @@ package evidencev1beta1 import ( + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -1066,11 +1066,10 @@ var file_cosmos_evidence_v1beta1_tx_proto_rawDesc = []byte{ 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x42, 0xf2, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x42, 0xe2, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x45, 0x58, 0xaa, 0x02, 0x17, 0x43, 0x6f, diff --git a/api/cosmos/feegrant/v1beta1/feegrant.pulsar.go b/api/cosmos/feegrant/v1beta1/feegrant.pulsar.go index 4136d147cf2f..858ad4675ba6 100644 --- a/api/cosmos/feegrant/v1beta1/feegrant.pulsar.go +++ b/api/cosmos/feegrant/v1beta1/feegrant.pulsar.go @@ -2,10 +2,10 @@ package feegrantv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -2908,12 +2908,11 @@ var file_cosmos_feegrant_v1beta1_feegrant_proto_rawDesc = []byte{ 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x11, 0xca, 0xb4, 0x2d, 0x0d, 0x46, 0x65, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x49, 0x52, 0x09, 0x61, 0x6c, 0x6c, 0x6f, 0x77, - 0x61, 0x6e, 0x63, 0x65, 0x42, 0xf4, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, + 0x61, 0x6e, 0x63, 0x65, 0x42, 0xe4, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0d, 0x46, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x46, 0x58, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x46, diff --git a/api/cosmos/feegrant/v1beta1/genesis.pulsar.go b/api/cosmos/feegrant/v1beta1/genesis.pulsar.go index 35a76faa792f..bd5d09f47b53 100644 --- a/api/cosmos/feegrant/v1beta1/genesis.pulsar.go +++ b/api/cosmos/feegrant/v1beta1/genesis.pulsar.go @@ -574,12 +574,11 @@ var file_cosmos_feegrant_v1beta1_genesis_proto_rawDesc = []byte{ 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x0a, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x61, - 0x6e, 0x63, 0x65, 0x73, 0x42, 0xf3, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, + 0x6e, 0x63, 0x65, 0x73, 0x42, 0xe3, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x46, 0x58, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x46, 0x65, diff --git a/api/cosmos/feegrant/v1beta1/query.pulsar.go b/api/cosmos/feegrant/v1beta1/query.pulsar.go index 5b9d4ed9e87a..e6e62a22666c 100644 --- a/api/cosmos/feegrant/v1beta1/query.pulsar.go +++ b/api/cosmos/feegrant/v1beta1/query.pulsar.go @@ -2,10 +2,10 @@ package feegrantv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -3268,6 +3268,8 @@ func (x *QueryAllowancesResponse) GetPagination() *v1beta1.PageResponse { } // QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. +// +// Since: cosmos-sdk 0.46 type QueryAllowancesByGranterRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -3313,6 +3315,8 @@ func (x *QueryAllowancesByGranterRequest) GetPagination() *v1beta1.PageRequest { } // QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. +// +// Since: cosmos-sdk 0.46 type QueryAllowancesByGranterResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -3462,11 +3466,10 @@ var file_cosmos_feegrant_v1beta1_query_proto_rawDesc = []byte{ 0xd3, 0xe4, 0x93, 0x02, 0x2b, 0x12, 0x29, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x69, 0x73, 0x73, 0x75, 0x65, 0x64, 0x2f, 0x7b, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x7d, - 0x42, 0xf1, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x42, 0xe1, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, + 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x46, 0x58, 0xaa, 0x02, diff --git a/api/cosmos/feegrant/v1beta1/query_grpc.pb.go b/api/cosmos/feegrant/v1beta1/query_grpc.pb.go index 64cef481bdaa..a9f57a6360e9 100644 --- a/api/cosmos/feegrant/v1beta1/query_grpc.pb.go +++ b/api/cosmos/feegrant/v1beta1/query_grpc.pb.go @@ -27,7 +27,8 @@ type QueryClient interface { // Allowances returns all the grants for address. Allowances(ctx context.Context, in *QueryAllowancesRequest, opts ...grpc.CallOption) (*QueryAllowancesResponse, error) // AllowancesByGranter returns all the grants given by an address - // Since v0.46 + // + // Since: cosmos-sdk 0.46 AllowancesByGranter(ctx context.Context, in *QueryAllowancesByGranterRequest, opts ...grpc.CallOption) (*QueryAllowancesByGranterResponse, error) } @@ -75,7 +76,8 @@ type QueryServer interface { // Allowances returns all the grants for address. Allowances(context.Context, *QueryAllowancesRequest) (*QueryAllowancesResponse, error) // AllowancesByGranter returns all the grants given by an address - // Since v0.46 + // + // Since: cosmos-sdk 0.46 AllowancesByGranter(context.Context, *QueryAllowancesByGranterRequest) (*QueryAllowancesByGranterResponse, error) mustEmbedUnimplementedQueryServer() } diff --git a/api/cosmos/feegrant/v1beta1/tx.pulsar.go b/api/cosmos/feegrant/v1beta1/tx.pulsar.go index 723d4319fb73..3d38f4af96b8 100644 --- a/api/cosmos/feegrant/v1beta1/tx.pulsar.go +++ b/api/cosmos/feegrant/v1beta1/tx.pulsar.go @@ -2,10 +2,10 @@ package feegrantv1beta1 import ( + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -1997,11 +1997,10 @@ var file_cosmos_feegrant_v1beta1_tx_proto_rawDesc = []byte{ 0x33, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x76, 0x6f, 0x6b, 0x65, 0x41, 0x6c, 0x6c, 0x6f, 0x77, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xee, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xde, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, + 0x38, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x66, 0x65, 0x65, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x46, 0x58, 0xaa, diff --git a/api/cosmos/genutil/v1beta1/genesis.pulsar.go b/api/cosmos/genutil/v1beta1/genesis.pulsar.go index b709cc2b5854..892cd73ee3cc 100644 --- a/api/cosmos/genutil/v1beta1/genesis.pulsar.go +++ b/api/cosmos/genutil/v1beta1/genesis.pulsar.go @@ -556,12 +556,11 @@ var file_cosmos_genutil_v1beta1_genesis_proto_rawDesc = []byte{ 0x01, 0x20, 0x03, 0x28, 0x0c, 0x42, 0x26, 0xea, 0xde, 0x1f, 0x06, 0x67, 0x65, 0x6e, 0x74, 0x78, 0x73, 0xfa, 0xde, 0x1f, 0x18, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x2e, 0x52, 0x61, 0x77, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x06, 0x67, - 0x65, 0x6e, 0x54, 0x78, 0x73, 0x42, 0xec, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, + 0x65, 0x6e, 0x54, 0x78, 0x73, 0x42, 0xdc, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x65, 0x6e, 0x75, 0x74, 0x69, 0x6c, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x65, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x65, 0x6e, 0x75, 0x74, 0x69, 0x6c, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x67, 0x65, 0x6e, 0x75, 0x74, 0x69, 0x6c, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x65, 0x6e, 0x75, diff --git a/api/cosmos/gov/v1/genesis.pulsar.go b/api/cosmos/gov/v1/genesis.pulsar.go index 90ad1407781a..147979b91962 100644 --- a/api/cosmos/gov/v1/genesis.pulsar.go +++ b/api/cosmos/gov/v1/genesis.pulsar.go @@ -1206,11 +1206,10 @@ var file_cosmos_gov_v1_genesis_proto_rawDesc = []byte{ 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x6c, 0x6c, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x0b, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x50, 0x61, - 0x72, 0x61, 0x6d, 0x73, 0x42, 0xad, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, + 0x72, 0x61, 0x6d, 0x73, 0x42, 0x9d, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, - 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, + 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x6f, 0x76, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x6f, 0x76, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, diff --git a/api/cosmos/gov/v1/gov.pulsar.go b/api/cosmos/gov/v1/gov.pulsar.go index d3190cb35cfb..3506e799b877 100644 --- a/api/cosmos/gov/v1/gov.pulsar.go +++ b/api/cosmos/gov/v1/gov.pulsar.go @@ -2,10 +2,10 @@ package govv1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -5886,11 +5886,10 @@ var file_cosmos_gov_v1_gov_proto_rawDesc = []byte{ 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x04, 0x12, 0x1a, 0x0a, 0x16, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, - 0x44, 0x10, 0x05, 0x42, 0xa9, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x44, 0x10, 0x05, 0x42, 0x99, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x47, 0x6f, 0x76, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x6f, 0x76, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x6f, 0x76, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x6f, 0x76, 0x5c, 0x56, diff --git a/api/cosmos/gov/v1/query.pulsar.go b/api/cosmos/gov/v1/query.pulsar.go index 6d6351b72e13..7ec60a60d831 100644 --- a/api/cosmos/gov/v1/query.pulsar.go +++ b/api/cosmos/gov/v1/query.pulsar.go @@ -2,10 +2,10 @@ package govv1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -8722,11 +8722,10 @@ var file_cosmos_gov_v1_query_proto_rawDesc = []byte{ 0x22, 0x34, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2e, 0x12, 0x2c, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x73, 0x2f, 0x7b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x7d, - 0x2f, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x42, 0xab, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x2f, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x42, 0x9b, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, + 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x6f, 0x76, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x6f, 0x76, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, diff --git a/api/cosmos/gov/v1/tx.pulsar.go b/api/cosmos/gov/v1/tx.pulsar.go index 69c4b1f0f76c..bd8e57422aab 100644 --- a/api/cosmos/gov/v1/tx.pulsar.go +++ b/api/cosmos/gov/v1/tx.pulsar.go @@ -2,11 +2,11 @@ package govv1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -5514,11 +5514,10 @@ var file_cosmos_gov_v1_tx_proto_rawDesc = []byte{ 0x76, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x1a, 0x21, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0xa8, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x65, 0x42, 0x98, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, - 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, + 0x6f, 0x50, 0x01, 0x5a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x6f, 0x76, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x6f, 0x76, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x6f, 0x76, 0x5c, 0x56, 0x31, 0xe2, diff --git a/api/cosmos/gov/v1beta1/genesis.pulsar.go b/api/cosmos/gov/v1beta1/genesis.pulsar.go index de1083e347f3..418f8270917f 100644 --- a/api/cosmos/gov/v1beta1/genesis.pulsar.go +++ b/api/cosmos/gov/v1beta1/genesis.pulsar.go @@ -1213,12 +1213,11 @@ var file_cosmos_gov_v1beta1_genesis_proto_rawDesc = []byte{ 0x61, 0x6d, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x54, 0x61, 0x6c, 0x6c, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, - 0x52, 0x0b, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xd0, 0x01, + 0x52, 0x0b, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xc0, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, - 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x67, 0x6f, 0x76, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x6f, 0x76, 0x2e, 0x56, 0x31, 0x62, 0x65, diff --git a/api/cosmos/gov/v1beta1/gov.pulsar.go b/api/cosmos/gov/v1beta1/gov.pulsar.go index 0dbe85e61535..f0fb3139c2f3 100644 --- a/api/cosmos/gov/v1beta1/gov.pulsar.go +++ b/api/cosmos/gov/v1beta1/gov.pulsar.go @@ -2,10 +2,10 @@ package govv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -6334,11 +6334,10 @@ var file_cosmos_gov_v1beta1_gov_proto_rawDesc = []byte{ 0x65, 0x64, 0x12, 0x2c, 0x0a, 0x16, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x45, 0x44, 0x10, 0x05, 0x1a, 0x10, 0x8a, 0x9d, 0x20, 0x0c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x46, 0x61, 0x69, 0x6c, 0x65, 0x64, - 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x42, 0xd8, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x42, 0xc8, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x42, 0x08, 0x47, 0x6f, 0x76, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x31, 0x42, 0x08, 0x47, 0x6f, 0x76, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x67, 0x6f, 0x76, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x6f, 0x76, diff --git a/api/cosmos/gov/v1beta1/query.pulsar.go b/api/cosmos/gov/v1beta1/query.pulsar.go index 9684b840fa02..cd26db04c596 100644 --- a/api/cosmos/gov/v1beta1/query.pulsar.go +++ b/api/cosmos/gov/v1beta1/query.pulsar.go @@ -2,10 +2,10 @@ package govv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -8740,11 +8740,10 @@ var file_cosmos_gov_v1beta1_query_proto_rawDesc = []byte{ 0x93, 0x02, 0x33, 0x12, 0x31, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x73, 0x2f, 0x7b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x7d, - 0x2f, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x42, 0xce, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x2f, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x42, 0xbe, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x67, 0x6f, 0x76, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, diff --git a/api/cosmos/gov/v1beta1/tx.pulsar.go b/api/cosmos/gov/v1beta1/tx.pulsar.go index 06f185b840aa..cabd5494e697 100644 --- a/api/cosmos/gov/v1beta1/tx.pulsar.go +++ b/api/cosmos/gov/v1beta1/tx.pulsar.go @@ -2,11 +2,11 @@ package govv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -4303,12 +4303,11 @@ var file_cosmos_gov_v1beta1_tx_proto_rawDesc = []byte{ 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x44, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x1a, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x44, 0x65, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xcb, 0x01, + 0x70, 0x6f, 0x73, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xbb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x6f, 0x76, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, - 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, + 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x6f, 0x76, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x67, 0x6f, 0x76, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x6f, 0x76, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, diff --git a/api/cosmos/group/v1/events.pulsar.go b/api/cosmos/group/v1/events.pulsar.go index cde73c963885..5352013f75c7 100644 --- a/api/cosmos/group/v1/events.pulsar.go +++ b/api/cosmos/group/v1/events.pulsar.go @@ -2877,6 +2877,7 @@ var ( md_EventExec protoreflect.MessageDescriptor fd_EventExec_proposal_id protoreflect.FieldDescriptor fd_EventExec_result protoreflect.FieldDescriptor + fd_EventExec_logs protoreflect.FieldDescriptor ) func init() { @@ -2884,6 +2885,7 @@ func init() { md_EventExec = File_cosmos_group_v1_events_proto.Messages().ByName("EventExec") fd_EventExec_proposal_id = md_EventExec.Fields().ByName("proposal_id") fd_EventExec_result = md_EventExec.Fields().ByName("result") + fd_EventExec_logs = md_EventExec.Fields().ByName("logs") } var _ protoreflect.Message = (*fastReflection_EventExec)(nil) @@ -2963,6 +2965,12 @@ func (x *fastReflection_EventExec) Range(f func(protoreflect.FieldDescriptor, pr return } } + if x.Logs != "" { + value := protoreflect.ValueOfString(x.Logs) + if !f(fd_EventExec_logs, value) { + return + } + } } // Has reports whether a field is populated. @@ -2982,6 +2990,8 @@ func (x *fastReflection_EventExec) Has(fd protoreflect.FieldDescriptor) bool { return x.ProposalId != uint64(0) case "cosmos.group.v1.EventExec.result": return x.Result != 0 + case "cosmos.group.v1.EventExec.logs": + return x.Logs != "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.EventExec")) @@ -3002,6 +3012,8 @@ func (x *fastReflection_EventExec) Clear(fd protoreflect.FieldDescriptor) { x.ProposalId = uint64(0) case "cosmos.group.v1.EventExec.result": x.Result = 0 + case "cosmos.group.v1.EventExec.logs": + x.Logs = "" default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.EventExec")) @@ -3024,6 +3036,9 @@ func (x *fastReflection_EventExec) Get(descriptor protoreflect.FieldDescriptor) case "cosmos.group.v1.EventExec.result": value := x.Result return protoreflect.ValueOfEnum((protoreflect.EnumNumber)(value)) + case "cosmos.group.v1.EventExec.logs": + value := x.Logs + return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.EventExec")) @@ -3048,6 +3063,8 @@ func (x *fastReflection_EventExec) Set(fd protoreflect.FieldDescriptor, value pr x.ProposalId = value.Uint() case "cosmos.group.v1.EventExec.result": x.Result = (ProposalExecutorResult)(value.Enum()) + case "cosmos.group.v1.EventExec.logs": + x.Logs = value.Interface().(string) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.EventExec")) @@ -3072,6 +3089,8 @@ func (x *fastReflection_EventExec) Mutable(fd protoreflect.FieldDescriptor) prot panic(fmt.Errorf("field proposal_id of message cosmos.group.v1.EventExec is not mutable")) case "cosmos.group.v1.EventExec.result": panic(fmt.Errorf("field result of message cosmos.group.v1.EventExec is not mutable")) + case "cosmos.group.v1.EventExec.logs": + panic(fmt.Errorf("field logs of message cosmos.group.v1.EventExec is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.EventExec")) @@ -3089,6 +3108,8 @@ func (x *fastReflection_EventExec) NewField(fd protoreflect.FieldDescriptor) pro return protoreflect.ValueOfUint64(uint64(0)) case "cosmos.group.v1.EventExec.result": return protoreflect.ValueOfEnum(0) + case "cosmos.group.v1.EventExec.logs": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.EventExec")) @@ -3164,6 +3185,10 @@ func (x *fastReflection_EventExec) ProtoMethods() *protoiface.Methods { if x.Result != 0 { n += 1 + runtime.Sov(uint64(x.Result)) } + l = len(x.Logs) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -3193,6 +3218,13 @@ func (x *fastReflection_EventExec) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if len(x.Logs) > 0 { + i -= len(x.Logs) + copy(dAtA[i:], x.Logs) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Logs))) + i-- + dAtA[i] = 0x1a + } if x.Result != 0 { i = runtime.EncodeVarint(dAtA, i, uint64(x.Result)) i-- @@ -3290,6 +3322,38 @@ func (x *fastReflection_EventExec) ProtoMethods() *protoiface.Methods { break } } + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Logs = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -4077,6 +4141,8 @@ type EventExec struct { ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` // result is the proposal execution result. Result ProposalExecutorResult `protobuf:"varint,2,opt,name=result,proto3,enum=cosmos.group.v1.ProposalExecutorResult" json:"result,omitempty"` + // logs contains error logs in case the execution result is FAILURE. + Logs string `protobuf:"bytes,3,opt,name=logs,proto3" json:"logs,omitempty"` } func (x *EventExec) Reset() { @@ -4113,6 +4179,13 @@ func (x *EventExec) GetResult() ProposalExecutorResult { return ProposalExecutorResult_PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED } +func (x *EventExec) GetLogs() string { + if x != nil { + return x.Logs + } + return "" +} + // EventLeaveGroup is an event emitted when group member leaves the group. type EventLeaveGroup struct { state protoimpl.MessageState @@ -4194,32 +4267,32 @@ var file_cosmos_group_v1_events_proto_rawDesc = []byte{ 0x6c, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x56, 0x6f, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, - 0x64, 0x22, 0x6d, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1f, - 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x64, 0x12, - 0x3f, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, - 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, - 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x22, 0x60, 0x0a, 0x0f, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x32, - 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x42, 0xba, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x45, 0x76, 0x65, 0x6e, - 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x72, 0x6f, 0x75, - 0x70, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0f, 0x43, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1b, - 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x5c, 0x56, 0x31, 0x5c, - 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x43, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x3a, 0x3a, 0x56, 0x31, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x22, 0x81, 0x01, 0x0a, 0x09, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x45, 0x78, 0x65, 0x63, 0x12, + 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x64, + 0x12, 0x3f, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, + 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, + 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x45, 0x78, 0x65, 0x63, 0x75, + 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6c, 0x6f, 0x67, 0x73, 0x22, 0x60, 0x0a, 0x0f, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x4c, 0x65, + 0x61, 0x76, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x49, 0x64, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, + 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0xaa, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x42, + 0x0b, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, + 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x76, 0x31, + 0x3b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, + 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x56, 0x31, + 0xca, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x5c, + 0x56, 0x31, 0xe2, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/api/cosmos/group/v1/genesis.pulsar.go b/api/cosmos/group/v1/genesis.pulsar.go index f3fc2f2dd643..df985263a9ae 100644 --- a/api/cosmos/group/v1/genesis.pulsar.go +++ b/api/cosmos/group/v1/genesis.pulsar.go @@ -1353,12 +1353,11 @@ var file_cosmos_group_v1_genesis_proto_rawDesc = []byte{ 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x73, 0x12, 0x2b, 0x0a, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, - 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x52, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x42, 0xbb, + 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x52, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x73, 0x42, 0xab, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, diff --git a/api/cosmos/group/v1/query.pulsar.go b/api/cosmos/group/v1/query.pulsar.go index e43ad72db731..af0b70baf143 100644 --- a/api/cosmos/group/v1/query.pulsar.go +++ b/api/cosmos/group/v1/query.pulsar.go @@ -2,10 +2,10 @@ package groupv1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -14304,11 +14304,10 @@ var file_cosmos_group_v1_query_proto_rawDesc = []byte{ 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x30, 0x12, 0x2e, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x73, 0x2f, 0x7b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x7d, - 0x2f, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x42, 0xb9, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x2f, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x42, 0xa9, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x42, 0x0a, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x28, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x56, 0x31, 0xca, 0x02, diff --git a/api/cosmos/group/v1/tx.pulsar.go b/api/cosmos/group/v1/tx.pulsar.go index f309d16cb784..dfb7fee50d85 100644 --- a/api/cosmos/group/v1/tx.pulsar.go +++ b/api/cosmos/group/v1/tx.pulsar.go @@ -2,10 +2,10 @@ package groupv1 import ( + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -19,7 +19,7 @@ import ( var _ protoreflect.List = (*_MsgCreateGroup_2_list)(nil) type _MsgCreateGroup_2_list struct { - list *[]*Member + list *[]*MemberRequest } func (x *_MsgCreateGroup_2_list) Len() int { @@ -35,18 +35,18 @@ func (x *_MsgCreateGroup_2_list) Get(i int) protoreflect.Value { func (x *_MsgCreateGroup_2_list) Set(i int, value protoreflect.Value) { valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Member) + concreteValue := valueUnwrapped.Interface().(*MemberRequest) (*x.list)[i] = concreteValue } func (x *_MsgCreateGroup_2_list) Append(value protoreflect.Value) { valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Member) + concreteValue := valueUnwrapped.Interface().(*MemberRequest) *x.list = append(*x.list, concreteValue) } func (x *_MsgCreateGroup_2_list) AppendMutable() protoreflect.Value { - v := new(Member) + v := new(MemberRequest) *x.list = append(*x.list, v) return protoreflect.ValueOfMessage(v.ProtoReflect()) } @@ -59,7 +59,7 @@ func (x *_MsgCreateGroup_2_list) Truncate(n int) { } func (x *_MsgCreateGroup_2_list) NewElement() protoreflect.Value { - v := new(Member) + v := new(MemberRequest) return protoreflect.ValueOfMessage(v.ProtoReflect()) } @@ -286,7 +286,7 @@ func (x *fastReflection_MsgCreateGroup) Mutable(fd protoreflect.FieldDescriptor) switch fd.FullName() { case "cosmos.group.v1.MsgCreateGroup.members": if x.Members == nil { - x.Members = []*Member{} + x.Members = []*MemberRequest{} } value := &_MsgCreateGroup_2_list{list: &x.Members} return protoreflect.ValueOfList(value) @@ -310,7 +310,7 @@ func (x *fastReflection_MsgCreateGroup) NewField(fd protoreflect.FieldDescriptor case "cosmos.group.v1.MsgCreateGroup.admin": return protoreflect.ValueOfString("") case "cosmos.group.v1.MsgCreateGroup.members": - list := []*Member{} + list := []*MemberRequest{} return protoreflect.ValueOfList(&_MsgCreateGroup_2_list{list: &list}) case "cosmos.group.v1.MsgCreateGroup.metadata": return protoreflect.ValueOfString("") @@ -566,7 +566,7 @@ func (x *fastReflection_MsgCreateGroup) ProtoMethods() *protoiface.Methods { if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Members = append(x.Members, &Member{}) + x.Members = append(x.Members, &MemberRequest{}) if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Members[len(x.Members)-1]); err != nil { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } @@ -1045,7 +1045,7 @@ func (x *fastReflection_MsgCreateGroupResponse) ProtoMethods() *protoiface.Metho var _ protoreflect.List = (*_MsgUpdateGroupMembers_3_list)(nil) type _MsgUpdateGroupMembers_3_list struct { - list *[]*Member + list *[]*MemberRequest } func (x *_MsgUpdateGroupMembers_3_list) Len() int { @@ -1061,18 +1061,18 @@ func (x *_MsgUpdateGroupMembers_3_list) Get(i int) protoreflect.Value { func (x *_MsgUpdateGroupMembers_3_list) Set(i int, value protoreflect.Value) { valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Member) + concreteValue := valueUnwrapped.Interface().(*MemberRequest) (*x.list)[i] = concreteValue } func (x *_MsgUpdateGroupMembers_3_list) Append(value protoreflect.Value) { valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Member) + concreteValue := valueUnwrapped.Interface().(*MemberRequest) *x.list = append(*x.list, concreteValue) } func (x *_MsgUpdateGroupMembers_3_list) AppendMutable() protoreflect.Value { - v := new(Member) + v := new(MemberRequest) *x.list = append(*x.list, v) return protoreflect.ValueOfMessage(v.ProtoReflect()) } @@ -1085,7 +1085,7 @@ func (x *_MsgUpdateGroupMembers_3_list) Truncate(n int) { } func (x *_MsgUpdateGroupMembers_3_list) NewElement() protoreflect.Value { - v := new(Member) + v := new(MemberRequest) return protoreflect.ValueOfMessage(v.ProtoReflect()) } @@ -1312,7 +1312,7 @@ func (x *fastReflection_MsgUpdateGroupMembers) Mutable(fd protoreflect.FieldDesc switch fd.FullName() { case "cosmos.group.v1.MsgUpdateGroupMembers.member_updates": if x.MemberUpdates == nil { - x.MemberUpdates = []*Member{} + x.MemberUpdates = []*MemberRequest{} } value := &_MsgUpdateGroupMembers_3_list{list: &x.MemberUpdates} return protoreflect.ValueOfList(value) @@ -1338,7 +1338,7 @@ func (x *fastReflection_MsgUpdateGroupMembers) NewField(fd protoreflect.FieldDes case "cosmos.group.v1.MsgUpdateGroupMembers.group_id": return protoreflect.ValueOfUint64(uint64(0)) case "cosmos.group.v1.MsgUpdateGroupMembers.member_updates": - list := []*Member{} + list := []*MemberRequest{} return protoreflect.ValueOfList(&_MsgUpdateGroupMembers_3_list{list: &list}) default: if fd.IsExtension() { @@ -1608,7 +1608,7 @@ func (x *fastReflection_MsgUpdateGroupMembers) ProtoMethods() *protoiface.Method if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.MemberUpdates = append(x.MemberUpdates, &Member{}) + x.MemberUpdates = append(x.MemberUpdates, &MemberRequest{}) if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.MemberUpdates[len(x.MemberUpdates)-1]); err != nil { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } @@ -5362,7 +5362,7 @@ func (x *fastReflection_MsgUpdateGroupPolicyAdmin) ProtoMethods() *protoiface.Me var _ protoreflect.List = (*_MsgCreateGroupWithPolicy_2_list)(nil) type _MsgCreateGroupWithPolicy_2_list struct { - list *[]*Member + list *[]*MemberRequest } func (x *_MsgCreateGroupWithPolicy_2_list) Len() int { @@ -5378,18 +5378,18 @@ func (x *_MsgCreateGroupWithPolicy_2_list) Get(i int) protoreflect.Value { func (x *_MsgCreateGroupWithPolicy_2_list) Set(i int, value protoreflect.Value) { valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Member) + concreteValue := valueUnwrapped.Interface().(*MemberRequest) (*x.list)[i] = concreteValue } func (x *_MsgCreateGroupWithPolicy_2_list) Append(value protoreflect.Value) { valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Member) + concreteValue := valueUnwrapped.Interface().(*MemberRequest) *x.list = append(*x.list, concreteValue) } func (x *_MsgCreateGroupWithPolicy_2_list) AppendMutable() protoreflect.Value { - v := new(Member) + v := new(MemberRequest) *x.list = append(*x.list, v) return protoreflect.ValueOfMessage(v.ProtoReflect()) } @@ -5402,7 +5402,7 @@ func (x *_MsgCreateGroupWithPolicy_2_list) Truncate(n int) { } func (x *_MsgCreateGroupWithPolicy_2_list) NewElement() protoreflect.Value { - v := new(Member) + v := new(MemberRequest) return protoreflect.ValueOfMessage(v.ProtoReflect()) } @@ -5680,7 +5680,7 @@ func (x *fastReflection_MsgCreateGroupWithPolicy) Mutable(fd protoreflect.FieldD switch fd.FullName() { case "cosmos.group.v1.MsgCreateGroupWithPolicy.members": if x.Members == nil { - x.Members = []*Member{} + x.Members = []*MemberRequest{} } value := &_MsgCreateGroupWithPolicy_2_list{list: &x.Members} return protoreflect.ValueOfList(value) @@ -5713,7 +5713,7 @@ func (x *fastReflection_MsgCreateGroupWithPolicy) NewField(fd protoreflect.Field case "cosmos.group.v1.MsgCreateGroupWithPolicy.admin": return protoreflect.ValueOfString("") case "cosmos.group.v1.MsgCreateGroupWithPolicy.members": - list := []*Member{} + list := []*MemberRequest{} return protoreflect.ValueOfList(&_MsgCreateGroupWithPolicy_2_list{list: &list}) case "cosmos.group.v1.MsgCreateGroupWithPolicy.group_metadata": return protoreflect.ValueOfString("") @@ -6018,7 +6018,7 @@ func (x *fastReflection_MsgCreateGroupWithPolicy) ProtoMethods() *protoiface.Met if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Members = append(x.Members, &Member{}) + x.Members = append(x.Members, &MemberRequest{}) if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Members[len(x.Members)-1]); err != nil { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err } @@ -12300,12 +12300,14 @@ func (x *fastReflection_MsgExec) ProtoMethods() *protoiface.Methods { } var ( - md_MsgExecResponse protoreflect.MessageDescriptor + md_MsgExecResponse protoreflect.MessageDescriptor + fd_MsgExecResponse_result protoreflect.FieldDescriptor ) func init() { file_cosmos_group_v1_tx_proto_init() md_MsgExecResponse = File_cosmos_group_v1_tx_proto.Messages().ByName("MsgExecResponse") + fd_MsgExecResponse_result = md_MsgExecResponse.Fields().ByName("result") } var _ protoreflect.Message = (*fastReflection_MsgExecResponse)(nil) @@ -12373,6 +12375,12 @@ func (x *fastReflection_MsgExecResponse) Interface() protoreflect.ProtoMessage { // While iterating, mutating operations may only be performed // on the current field descriptor. func (x *fastReflection_MsgExecResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Result != 0 { + value := protoreflect.ValueOfEnum((protoreflect.EnumNumber)(x.Result)) + if !f(fd_MsgExecResponse_result, value) { + return + } + } } // Has reports whether a field is populated. @@ -12388,6 +12396,8 @@ func (x *fastReflection_MsgExecResponse) Range(f func(protoreflect.FieldDescript // a repeated field is populated if it is non-empty. func (x *fastReflection_MsgExecResponse) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { + case "cosmos.group.v1.MsgExecResponse.result": + return x.Result != 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MsgExecResponse")) @@ -12404,6 +12414,8 @@ func (x *fastReflection_MsgExecResponse) Has(fd protoreflect.FieldDescriptor) bo // Clear is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgExecResponse) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { + case "cosmos.group.v1.MsgExecResponse.result": + x.Result = 0 default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MsgExecResponse")) @@ -12420,6 +12432,9 @@ func (x *fastReflection_MsgExecResponse) Clear(fd protoreflect.FieldDescriptor) // of the value; to obtain a mutable reference, use Mutable. func (x *fastReflection_MsgExecResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { + case "cosmos.group.v1.MsgExecResponse.result": + value := x.Result + return protoreflect.ValueOfEnum((protoreflect.EnumNumber)(value)) default: if descriptor.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MsgExecResponse")) @@ -12440,6 +12455,8 @@ func (x *fastReflection_MsgExecResponse) Get(descriptor protoreflect.FieldDescri // Set is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgExecResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { + case "cosmos.group.v1.MsgExecResponse.result": + x.Result = (ProposalExecutorResult)(value.Enum()) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MsgExecResponse")) @@ -12460,6 +12477,8 @@ func (x *fastReflection_MsgExecResponse) Set(fd protoreflect.FieldDescriptor, va // Mutable is a mutating operation and unsafe for concurrent use. func (x *fastReflection_MsgExecResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "cosmos.group.v1.MsgExecResponse.result": + panic(fmt.Errorf("field result of message cosmos.group.v1.MsgExecResponse is not mutable")) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MsgExecResponse")) @@ -12473,6 +12492,8 @@ func (x *fastReflection_MsgExecResponse) Mutable(fd protoreflect.FieldDescriptor // For lists, maps, and messages, this returns a new, empty, mutable value. func (x *fastReflection_MsgExecResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { + case "cosmos.group.v1.MsgExecResponse.result": + return protoreflect.ValueOfEnum(0) default: if fd.IsExtension() { panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MsgExecResponse")) @@ -12542,6 +12563,9 @@ func (x *fastReflection_MsgExecResponse) ProtoMethods() *protoiface.Methods { var n int var l int _ = l + if x.Result != 0 { + n += 1 + runtime.Sov(uint64(x.Result)) + } if x.unknownFields != nil { n += len(x.unknownFields) } @@ -12571,6 +12595,11 @@ func (x *fastReflection_MsgExecResponse) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } + if x.Result != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Result)) + i-- + dAtA[i] = 0x10 + } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) } else { @@ -12620,6 +12649,25 @@ func (x *fastReflection_MsgExecResponse) ProtoMethods() *protoiface.Methods { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MsgExecResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + x.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Result |= ProposalExecutorResult(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := runtime.Skip(dAtA[iNdEx:]) @@ -13556,7 +13604,7 @@ type MsgCreateGroup struct { // admin is the account address of the group admin. Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` // members defines the group members. - Members []*Member `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` + Members []*MemberRequest `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` // metadata is any arbitrary metadata to attached to the group. Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` } @@ -13588,7 +13636,7 @@ func (x *MsgCreateGroup) GetAdmin() string { return "" } -func (x *MsgCreateGroup) GetMembers() []*Member { +func (x *MsgCreateGroup) GetMembers() []*MemberRequest { if x != nil { return x.Members } @@ -13651,7 +13699,7 @@ type MsgUpdateGroupMembers struct { GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` // member_updates is the list of members to update, // set weight to 0 to remove a member. - MemberUpdates []*Member `protobuf:"bytes,3,rep,name=member_updates,json=memberUpdates,proto3" json:"member_updates,omitempty"` + MemberUpdates []*MemberRequest `protobuf:"bytes,3,rep,name=member_updates,json=memberUpdates,proto3" json:"member_updates,omitempty"` } func (x *MsgUpdateGroupMembers) Reset() { @@ -13688,7 +13736,7 @@ func (x *MsgUpdateGroupMembers) GetGroupId() uint64 { return 0 } -func (x *MsgUpdateGroupMembers) GetMemberUpdates() []*Member { +func (x *MsgUpdateGroupMembers) GetMemberUpdates() []*MemberRequest { if x != nil { return x.MemberUpdates } @@ -14051,7 +14099,7 @@ type MsgCreateGroupWithPolicy struct { // admin is the account address of the group and group policy admin. Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` // members defines the group members. - Members []*Member `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` + Members []*MemberRequest `protobuf:"bytes,2,rep,name=members,proto3" json:"members,omitempty"` // group_metadata is any arbitrary metadata attached to the group. GroupMetadata string `protobuf:"bytes,3,opt,name=group_metadata,json=groupMetadata,proto3" json:"group_metadata,omitempty"` // group_policy_metadata is any arbitrary metadata attached to the group policy. @@ -14090,7 +14138,7 @@ func (x *MsgCreateGroupWithPolicy) GetAdmin() string { return "" } -func (x *MsgCreateGroupWithPolicy) GetMembers() []*Member { +func (x *MsgCreateGroupWithPolicy) GetMembers() []*MemberRequest { if x != nil { return x.Members } @@ -14700,6 +14748,9 @@ type MsgExecResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + // result is the final result of the proposal execution. + Result ProposalExecutorResult `protobuf:"varint,2,opt,name=result,proto3,enum=cosmos.group.v1.ProposalExecutorResult" json:"result,omitempty"` } func (x *MsgExecResponse) Reset() { @@ -14722,6 +14773,13 @@ func (*MsgExecResponse) Descriptor() ([]byte, []int) { return file_cosmos_group_v1_tx_proto_rawDescGZIP(), []int{25} } +func (x *MsgExecResponse) GetResult() ProposalExecutorResult { + if x != nil { + return x.Result + } + return ProposalExecutorResult_PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED +} + // MsgLeaveGroup is the Msg/LeaveGroup request type. type MsgLeaveGroup struct { state protoimpl.MessageState @@ -14808,128 +14866,81 @@ var file_cosmos_group_v1_tx_proto_rawDesc = []byte{ 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1b, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x73, 0x67, - 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa1, 0x01, + 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa8, 0x01, 0x0a, 0x0e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, - 0x12, 0x37, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, - 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x22, 0x33, 0x0a, 0x16, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x22, 0xb4, 0x01, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, - 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, - 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, - 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x44, 0x0a, 0x0e, 0x6d, - 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, - 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x42, 0x04, 0xc8, 0xde, - 0x1f, 0x00, 0x52, 0x0d, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x73, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x1f, 0x0a, - 0x1d, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, - 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa3, - 0x01, 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, - 0x70, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, - 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, - 0x64, 0x12, 0x35, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x08, - 0x6e, 0x65, 0x77, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x1d, 0x0a, 0x1b, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0x8b, 0x01, 0x0a, 0x16, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2e, - 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, - 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x19, - 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, - 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x22, 0x20, 0x0a, 0x1e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0xe0, 0x01, 0x0a, 0x14, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2e, 0x0a, 0x05, + 0x12, 0x3e, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, + 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, + 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x0a, 0x82, 0xe7, + 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x33, 0x0a, 0x16, 0x4d, 0x73, 0x67, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x22, 0xbb, 0x01, + 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x49, 0x64, 0x12, 0x4b, 0x0a, 0x0e, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x5f, 0x75, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, + 0x52, 0x0d, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x73, 0x3a, + 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x1f, 0x0a, 0x1d, 0x4d, + 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, + 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa3, 0x01, 0x0a, + 0x13, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, + 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, + 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, + 0x35, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x6e, 0x65, + 0x77, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, + 0x69, 0x6e, 0x22, 0x1d, 0x0a, 0x1b, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x8b, 0x01, 0x0a, 0x16, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x12, 0x51, 0x0a, 0x0f, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x5f, - 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, - 0x6e, 0x79, 0x42, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0e, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x3a, 0x0e, 0x88, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, - 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x52, 0x0a, 0x1c, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xda, 0x01, 0x0a, 0x19, 0x4d, - 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, - 0x69, 0x63, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x4a, 0x0a, 0x14, 0x67, 0x72, 0x6f, 0x75, - 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, - 0x52, 0x12, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x12, 0x35, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, - 0x67, 0x52, 0x08, 0x6e, 0x65, 0x77, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, - 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0xf4, 0x02, 0x0a, 0x18, 0x4d, 0x73, 0x67, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x50, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x37, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x42, 0x04, - 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x25, 0x0a, - 0x0e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x12, 0x32, 0x0a, 0x15, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x13, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x31, 0x0a, 0x15, 0x67, 0x72, 0x6f, 0x75, - 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, 0x73, 0x5f, 0x61, 0x64, 0x6d, 0x69, - 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x41, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x51, 0x0a, 0x0f, 0x64, - 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x06, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x12, 0xca, 0xb4, 0x2d, 0x0e, - 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0e, - 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x3a, 0x0e, - 0x88, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x89, - 0x01, 0x0a, 0x20, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, - 0x70, 0x57, 0x69, 0x74, 0x68, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x4a, - 0x0a, 0x14, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, - 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, - 0x69, 0x63, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x23, 0x0a, 0x21, 0x4d, 0x73, - 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, - 0x63, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x83, 0x02, 0x0a, 0x22, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, - 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, + 0x61, 0x74, 0x61, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, + 0x20, 0x0a, 0x1e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0xf0, 0x01, 0x0a, 0x14, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, + 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x61, 0x0a, 0x0f, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, + 0x42, 0x22, 0xca, 0xb4, 0x2d, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0e, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x3a, 0x0e, 0x88, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, + 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x52, 0x0a, 0x1c, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, + 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0xda, 0x01, 0x0a, 0x19, 0x4d, 0x73, 0x67, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, + 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x4a, 0x0a, 0x14, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, @@ -14937,200 +14948,254 @@ var file_cosmos_group_v1_tx_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x12, 0x51, 0x0a, 0x0f, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x70, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, - 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, - 0x79, 0x42, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0e, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x3a, 0x0e, 0x88, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x05, - 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x2c, 0x0a, 0x2a, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, + 0x73, 0x73, 0x12, 0x35, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, + 0x08, 0x6e, 0x65, 0x77, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, + 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x8b, 0x03, 0x0a, 0x18, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, + 0x69, 0x6e, 0x12, 0x3e, 0x0a, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x73, 0x12, 0x25, 0x0a, 0x0e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x6d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x32, 0x0a, 0x15, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x31, 0x0a, + 0x15, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, 0x73, + 0x5f, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x12, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x73, 0x41, 0x64, 0x6d, 0x69, 0x6e, + 0x12, 0x61, 0x0a, 0x0f, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, + 0x22, 0xca, 0xb4, 0x2d, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x52, 0x0e, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x3a, 0x0e, 0x88, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, + 0x6d, 0x69, 0x6e, 0x22, 0x89, 0x01, 0x0a, 0x20, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, + 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x49, 0x64, 0x12, 0x4a, 0x0a, 0x14, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, + 0x69, 0x63, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, + 0x23, 0x0a, 0x21, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x93, 0x02, 0x0a, 0x22, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x44, 0x65, 0x63, - 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x22, 0xc2, 0x01, 0x0a, 0x1c, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, - 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x4a, 0x0a, 0x14, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, - 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x67, 0x72, - 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x0a, 0x82, 0xe7, - 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x26, 0x0a, 0x24, 0x4d, 0x73, 0x67, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x8a, 0x02, 0x0a, 0x11, 0x4d, 0x73, 0x67, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x72, - 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x4a, 0x0a, 0x14, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, - 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x73, 0x18, - 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x73, - 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x30, 0x0a, 0x08, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, - 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, - 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x12, 0x29, - 0x0a, 0x04, 0x65, 0x78, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x45, - 0x78, 0x65, 0x63, 0x52, 0x04, 0x65, 0x78, 0x65, 0x63, 0x3a, 0x12, 0x88, 0xa0, 0x1f, 0x00, 0x82, - 0xe7, 0xb0, 0x2a, 0x09, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x73, 0x22, 0x3c, 0x0a, - 0x19, 0x4d, 0x73, 0x67, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, - 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, - 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, - 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x64, 0x22, 0x78, 0x0a, 0x13, 0x4d, - 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, - 0x61, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, - 0x6c, 0x49, 0x64, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x0c, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x61, 0x64, - 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x1d, 0x0a, 0x1b, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, - 0x64, 0x72, 0x61, 0x77, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xe2, 0x01, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x56, 0x6f, 0x74, 0x65, - 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, - 0x64, 0x12, 0x2e, 0x0a, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x76, 0x6f, 0x74, 0x65, - 0x72, 0x12, 0x33, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x0e, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, - 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x12, 0x29, 0x0a, 0x04, 0x65, 0x78, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, - 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, - 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x52, 0x04, 0x65, 0x78, 0x65, 0x63, 0x3a, 0x0a, 0x82, - 0xe7, 0xb0, 0x2a, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x22, 0x11, 0x0a, 0x0f, 0x4d, 0x73, 0x67, - 0x56, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6d, 0x0a, 0x07, - 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, - 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, - 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x64, 0x12, 0x34, 0x0a, 0x08, 0x65, 0x78, 0x65, 0x63, - 0x75, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x2e, 0x0a, 0x05, 0x61, + 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x3a, 0x0b, - 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x22, 0x11, 0x0a, 0x0f, 0x4d, - 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x6c, - 0x0a, 0x0d, 0x4d, 0x73, 0x67, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, - 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, - 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, - 0x65, 0x73, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x3a, 0x0c, - 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x17, 0x0a, 0x15, - 0x4d, 0x73, 0x67, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x2a, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x14, 0x0a, - 0x10, 0x45, 0x58, 0x45, 0x43, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x58, 0x45, 0x43, 0x5f, 0x54, 0x52, 0x59, 0x10, - 0x01, 0x32, 0xc3, 0x0b, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x57, 0x0a, 0x0b, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x1f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x1a, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, - 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x6c, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, - 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, - 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, - 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, - 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x66, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, - 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, - 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x73, + 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x4a, 0x0a, 0x14, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x12, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x61, 0x0a, 0x0f, 0x64, 0x65, 0x63, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x22, 0xca, 0xb4, 0x2d, 0x1e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0e, 0x64, 0x65, 0x63, 0x69, + 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x3a, 0x0e, 0x88, 0xa0, 0x1f, 0x00, + 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x2c, 0x0a, 0x2a, 0x4d, 0x73, + 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xc2, 0x01, 0x0a, 0x1c, 0x4d, 0x73, 0x67, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, + 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, + 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x4a, 0x0a, 0x14, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x52, 0x12, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x22, 0x26, 0x0a, + 0x24, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x8a, 0x02, 0x0a, 0x11, 0x4d, 0x73, 0x67, 0x53, 0x75, 0x62, + 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x4a, 0x0a, 0x14, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x12, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x70, 0x6f, + 0x73, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x70, + 0x6f, 0x73, 0x65, 0x72, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, + 0x61, 0x12, 0x30, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x04, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x73, 0x12, 0x29, 0x0a, 0x04, 0x65, 0x78, 0x65, 0x63, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x52, 0x04, 0x65, 0x78, 0x65, 0x63, 0x3a, 0x12, + 0x88, 0xa0, 0x1f, 0x00, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, + 0x72, 0x73, 0x22, 0x3c, 0x0a, 0x19, 0x4d, 0x73, 0x67, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, + 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x64, + 0x22, 0x78, 0x0a, 0x13, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x50, + 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, + 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, + 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x64, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x3a, 0x0c, 0x82, 0xe7, + 0xb0, 0x2a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x22, 0x1d, 0x0a, 0x1b, 0x4d, 0x73, + 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, + 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xe2, 0x01, 0x0a, 0x07, 0x4d, 0x73, + 0x67, 0x56, 0x6f, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, + 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, + 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, + 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x4f, 0x70, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x29, 0x0a, 0x04, 0x65, 0x78, 0x65, 0x63, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x15, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x52, 0x04, 0x65, 0x78, + 0x65, 0x63, 0x3a, 0x0a, 0x82, 0xe7, 0xb0, 0x2a, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x22, 0x11, + 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x56, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x22, 0x6d, 0x0a, 0x07, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x12, 0x1f, 0x0a, 0x0b, + 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x64, 0x12, 0x34, 0x0a, + 0x08, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x08, 0x65, 0x78, 0x65, 0x63, 0x75, + 0x74, 0x6f, 0x72, 0x3a, 0x0b, 0x82, 0xe7, 0xb0, 0x2a, 0x06, 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, + 0x22, 0x52, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x3f, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x45, 0x78, + 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x06, 0x72, 0x65, + 0x73, 0x75, 0x6c, 0x74, 0x22, 0x6c, 0x0a, 0x0d, 0x4d, 0x73, 0x67, 0x4c, 0x65, 0x61, 0x76, 0x65, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x49, 0x64, 0x3a, 0x0c, 0x82, 0xe7, 0xb0, 0x2a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x22, 0x17, 0x0a, 0x15, 0x4d, 0x73, 0x67, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2a, 0x2a, 0x0a, 0x04, 0x45, + 0x78, 0x65, 0x63, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x58, 0x45, 0x43, 0x5f, 0x55, 0x4e, 0x53, 0x50, + 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x58, 0x45, + 0x43, 0x5f, 0x54, 0x52, 0x59, 0x10, 0x01, 0x32, 0xc3, 0x0b, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, + 0x57, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x1f, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, + 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x1a, + 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, + 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6c, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x26, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, + 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x1a, 0x2e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x66, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x64, 0x6d, 0x69, 0x6e, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6f, 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, - 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, - 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, - 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x69, 0x0a, 0x11, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x25, + 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, + 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6f, + 0x0a, 0x13, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x2f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, - 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x1a, 0x2d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x75, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, - 0x6f, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x29, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, - 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x57, 0x69, - 0x74, 0x68, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x1a, 0x31, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, + 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x69, 0x0a, 0x11, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x12, 0x25, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x1a, 0x2d, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, + 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x75, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x50, 0x6f, 0x6c, - 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x78, 0x0a, 0x16, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x2a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, - 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x6d, 0x69, - 0x6e, 0x1a, 0x32, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, - 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x93, 0x01, 0x0a, 0x1f, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x69, 0x63, 0x79, 0x12, 0x29, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x57, 0x69, 0x74, 0x68, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x1a, 0x31, + 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, + 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x57, + 0x69, 0x74, 0x68, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x78, 0x0a, 0x16, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x2a, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, + 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, + 0x63, 0x79, 0x41, 0x64, 0x6d, 0x69, 0x6e, 0x1a, 0x32, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, + 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, + 0x6d, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x93, 0x01, 0x0a, 0x1f, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, + 0x79, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, + 0x33, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, + 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x1a, 0x3b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x44, 0x65, 0x63, 0x69, 0x73, - 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x33, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x1a, 0x3b, + 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x81, 0x01, 0x0a, 0x19, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, + 0x2d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, + 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x35, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, - 0x69, 0x63, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x81, 0x01, 0x0a, 0x19, - 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, - 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x2d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x35, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x60, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, - 0x6c, 0x12, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, - 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x1a, 0x2a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x75, 0x62, 0x6d, 0x69, - 0x74, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x66, 0x0a, 0x10, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x50, 0x72, 0x6f, - 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, - 0x72, 0x61, 0x77, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x60, 0x0a, 0x0e, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, + 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x75, 0x62, + 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x1a, 0x2a, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, + 0x67, 0x53, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x66, 0x0a, 0x10, 0x57, 0x69, 0x74, 0x68, 0x64, + 0x72, 0x61, 0x77, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, - 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x04, 0x56, 0x6f, 0x74, - 0x65, 0x12, 0x18, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x56, 0x6f, 0x74, 0x65, 0x1a, 0x20, 0x2e, 0x63, 0x6f, + 0x6c, 0x1a, 0x2c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x57, 0x69, 0x74, 0x68, 0x64, 0x72, 0x61, 0x77, 0x50, + 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x42, 0x0a, 0x04, 0x56, 0x6f, 0x74, 0x65, 0x12, 0x18, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x56, 0x6f, 0x74, + 0x65, 0x1a, 0x20, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, + 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x56, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x18, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, - 0x67, 0x56, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, - 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x18, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, - 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x1a, - 0x20, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, - 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x54, 0x0a, 0x0a, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, - 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, - 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x1a, - 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, - 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4c, 0x65, 0x61, 0x76, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xb6, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x42, - 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x72, 0x6f, - 0x75, 0x70, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0f, 0x43, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0f, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x5c, 0x56, 0x31, 0xe2, 0x02, - 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x5c, 0x56, 0x31, - 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x43, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x3a, 0x3a, 0x56, 0x31, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x67, 0x45, 0x78, 0x65, 0x63, 0x1a, 0x20, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x45, 0x78, 0x65, 0x63, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x0a, 0x4c, 0x65, 0x61, 0x76, 0x65, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x1e, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4c, 0x65, 0x61, 0x76, 0x65, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x1a, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x4c, 0x65, 0x61, 0x76, 0x65, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xa6, 0x01, + 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x28, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, + 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, + 0x76, 0x31, 0x3b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, + 0xaa, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x2e, + 0x56, 0x31, 0xca, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, + 0x74, 0x61, 0xea, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x47, 0x72, 0x6f, + 0x75, 0x70, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -15177,54 +15242,56 @@ var file_cosmos_group_v1_tx_proto_goTypes = []interface{}{ (*MsgExecResponse)(nil), // 26: cosmos.group.v1.MsgExecResponse (*MsgLeaveGroup)(nil), // 27: cosmos.group.v1.MsgLeaveGroup (*MsgLeaveGroupResponse)(nil), // 28: cosmos.group.v1.MsgLeaveGroupResponse - (*Member)(nil), // 29: cosmos.group.v1.Member + (*MemberRequest)(nil), // 29: cosmos.group.v1.MemberRequest (*anypb.Any)(nil), // 30: google.protobuf.Any (VoteOption)(0), // 31: cosmos.group.v1.VoteOption + (ProposalExecutorResult)(0), // 32: cosmos.group.v1.ProposalExecutorResult } var file_cosmos_group_v1_tx_proto_depIdxs = []int32{ - 29, // 0: cosmos.group.v1.MsgCreateGroup.members:type_name -> cosmos.group.v1.Member - 29, // 1: cosmos.group.v1.MsgUpdateGroupMembers.member_updates:type_name -> cosmos.group.v1.Member + 29, // 0: cosmos.group.v1.MsgCreateGroup.members:type_name -> cosmos.group.v1.MemberRequest + 29, // 1: cosmos.group.v1.MsgUpdateGroupMembers.member_updates:type_name -> cosmos.group.v1.MemberRequest 30, // 2: cosmos.group.v1.MsgCreateGroupPolicy.decision_policy:type_name -> google.protobuf.Any - 29, // 3: cosmos.group.v1.MsgCreateGroupWithPolicy.members:type_name -> cosmos.group.v1.Member + 29, // 3: cosmos.group.v1.MsgCreateGroupWithPolicy.members:type_name -> cosmos.group.v1.MemberRequest 30, // 4: cosmos.group.v1.MsgCreateGroupWithPolicy.decision_policy:type_name -> google.protobuf.Any 30, // 5: cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy.decision_policy:type_name -> google.protobuf.Any 30, // 6: cosmos.group.v1.MsgSubmitProposal.messages:type_name -> google.protobuf.Any 0, // 7: cosmos.group.v1.MsgSubmitProposal.exec:type_name -> cosmos.group.v1.Exec 31, // 8: cosmos.group.v1.MsgVote.option:type_name -> cosmos.group.v1.VoteOption 0, // 9: cosmos.group.v1.MsgVote.exec:type_name -> cosmos.group.v1.Exec - 1, // 10: cosmos.group.v1.Msg.CreateGroup:input_type -> cosmos.group.v1.MsgCreateGroup - 3, // 11: cosmos.group.v1.Msg.UpdateGroupMembers:input_type -> cosmos.group.v1.MsgUpdateGroupMembers - 5, // 12: cosmos.group.v1.Msg.UpdateGroupAdmin:input_type -> cosmos.group.v1.MsgUpdateGroupAdmin - 7, // 13: cosmos.group.v1.Msg.UpdateGroupMetadata:input_type -> cosmos.group.v1.MsgUpdateGroupMetadata - 9, // 14: cosmos.group.v1.Msg.CreateGroupPolicy:input_type -> cosmos.group.v1.MsgCreateGroupPolicy - 12, // 15: cosmos.group.v1.Msg.CreateGroupWithPolicy:input_type -> cosmos.group.v1.MsgCreateGroupWithPolicy - 11, // 16: cosmos.group.v1.Msg.UpdateGroupPolicyAdmin:input_type -> cosmos.group.v1.MsgUpdateGroupPolicyAdmin - 15, // 17: cosmos.group.v1.Msg.UpdateGroupPolicyDecisionPolicy:input_type -> cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy - 17, // 18: cosmos.group.v1.Msg.UpdateGroupPolicyMetadata:input_type -> cosmos.group.v1.MsgUpdateGroupPolicyMetadata - 19, // 19: cosmos.group.v1.Msg.SubmitProposal:input_type -> cosmos.group.v1.MsgSubmitProposal - 21, // 20: cosmos.group.v1.Msg.WithdrawProposal:input_type -> cosmos.group.v1.MsgWithdrawProposal - 23, // 21: cosmos.group.v1.Msg.Vote:input_type -> cosmos.group.v1.MsgVote - 25, // 22: cosmos.group.v1.Msg.Exec:input_type -> cosmos.group.v1.MsgExec - 27, // 23: cosmos.group.v1.Msg.LeaveGroup:input_type -> cosmos.group.v1.MsgLeaveGroup - 2, // 24: cosmos.group.v1.Msg.CreateGroup:output_type -> cosmos.group.v1.MsgCreateGroupResponse - 4, // 25: cosmos.group.v1.Msg.UpdateGroupMembers:output_type -> cosmos.group.v1.MsgUpdateGroupMembersResponse - 6, // 26: cosmos.group.v1.Msg.UpdateGroupAdmin:output_type -> cosmos.group.v1.MsgUpdateGroupAdminResponse - 8, // 27: cosmos.group.v1.Msg.UpdateGroupMetadata:output_type -> cosmos.group.v1.MsgUpdateGroupMetadataResponse - 10, // 28: cosmos.group.v1.Msg.CreateGroupPolicy:output_type -> cosmos.group.v1.MsgCreateGroupPolicyResponse - 13, // 29: cosmos.group.v1.Msg.CreateGroupWithPolicy:output_type -> cosmos.group.v1.MsgCreateGroupWithPolicyResponse - 14, // 30: cosmos.group.v1.Msg.UpdateGroupPolicyAdmin:output_type -> cosmos.group.v1.MsgUpdateGroupPolicyAdminResponse - 16, // 31: cosmos.group.v1.Msg.UpdateGroupPolicyDecisionPolicy:output_type -> cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicyResponse - 18, // 32: cosmos.group.v1.Msg.UpdateGroupPolicyMetadata:output_type -> cosmos.group.v1.MsgUpdateGroupPolicyMetadataResponse - 20, // 33: cosmos.group.v1.Msg.SubmitProposal:output_type -> cosmos.group.v1.MsgSubmitProposalResponse - 22, // 34: cosmos.group.v1.Msg.WithdrawProposal:output_type -> cosmos.group.v1.MsgWithdrawProposalResponse - 24, // 35: cosmos.group.v1.Msg.Vote:output_type -> cosmos.group.v1.MsgVoteResponse - 26, // 36: cosmos.group.v1.Msg.Exec:output_type -> cosmos.group.v1.MsgExecResponse - 28, // 37: cosmos.group.v1.Msg.LeaveGroup:output_type -> cosmos.group.v1.MsgLeaveGroupResponse - 24, // [24:38] is the sub-list for method output_type - 10, // [10:24] is the sub-list for method input_type - 10, // [10:10] is the sub-list for extension type_name - 10, // [10:10] is the sub-list for extension extendee - 0, // [0:10] is the sub-list for field type_name + 32, // 10: cosmos.group.v1.MsgExecResponse.result:type_name -> cosmos.group.v1.ProposalExecutorResult + 1, // 11: cosmos.group.v1.Msg.CreateGroup:input_type -> cosmos.group.v1.MsgCreateGroup + 3, // 12: cosmos.group.v1.Msg.UpdateGroupMembers:input_type -> cosmos.group.v1.MsgUpdateGroupMembers + 5, // 13: cosmos.group.v1.Msg.UpdateGroupAdmin:input_type -> cosmos.group.v1.MsgUpdateGroupAdmin + 7, // 14: cosmos.group.v1.Msg.UpdateGroupMetadata:input_type -> cosmos.group.v1.MsgUpdateGroupMetadata + 9, // 15: cosmos.group.v1.Msg.CreateGroupPolicy:input_type -> cosmos.group.v1.MsgCreateGroupPolicy + 12, // 16: cosmos.group.v1.Msg.CreateGroupWithPolicy:input_type -> cosmos.group.v1.MsgCreateGroupWithPolicy + 11, // 17: cosmos.group.v1.Msg.UpdateGroupPolicyAdmin:input_type -> cosmos.group.v1.MsgUpdateGroupPolicyAdmin + 15, // 18: cosmos.group.v1.Msg.UpdateGroupPolicyDecisionPolicy:input_type -> cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicy + 17, // 19: cosmos.group.v1.Msg.UpdateGroupPolicyMetadata:input_type -> cosmos.group.v1.MsgUpdateGroupPolicyMetadata + 19, // 20: cosmos.group.v1.Msg.SubmitProposal:input_type -> cosmos.group.v1.MsgSubmitProposal + 21, // 21: cosmos.group.v1.Msg.WithdrawProposal:input_type -> cosmos.group.v1.MsgWithdrawProposal + 23, // 22: cosmos.group.v1.Msg.Vote:input_type -> cosmos.group.v1.MsgVote + 25, // 23: cosmos.group.v1.Msg.Exec:input_type -> cosmos.group.v1.MsgExec + 27, // 24: cosmos.group.v1.Msg.LeaveGroup:input_type -> cosmos.group.v1.MsgLeaveGroup + 2, // 25: cosmos.group.v1.Msg.CreateGroup:output_type -> cosmos.group.v1.MsgCreateGroupResponse + 4, // 26: cosmos.group.v1.Msg.UpdateGroupMembers:output_type -> cosmos.group.v1.MsgUpdateGroupMembersResponse + 6, // 27: cosmos.group.v1.Msg.UpdateGroupAdmin:output_type -> cosmos.group.v1.MsgUpdateGroupAdminResponse + 8, // 28: cosmos.group.v1.Msg.UpdateGroupMetadata:output_type -> cosmos.group.v1.MsgUpdateGroupMetadataResponse + 10, // 29: cosmos.group.v1.Msg.CreateGroupPolicy:output_type -> cosmos.group.v1.MsgCreateGroupPolicyResponse + 13, // 30: cosmos.group.v1.Msg.CreateGroupWithPolicy:output_type -> cosmos.group.v1.MsgCreateGroupWithPolicyResponse + 14, // 31: cosmos.group.v1.Msg.UpdateGroupPolicyAdmin:output_type -> cosmos.group.v1.MsgUpdateGroupPolicyAdminResponse + 16, // 32: cosmos.group.v1.Msg.UpdateGroupPolicyDecisionPolicy:output_type -> cosmos.group.v1.MsgUpdateGroupPolicyDecisionPolicyResponse + 18, // 33: cosmos.group.v1.Msg.UpdateGroupPolicyMetadata:output_type -> cosmos.group.v1.MsgUpdateGroupPolicyMetadataResponse + 20, // 34: cosmos.group.v1.Msg.SubmitProposal:output_type -> cosmos.group.v1.MsgSubmitProposalResponse + 22, // 35: cosmos.group.v1.Msg.WithdrawProposal:output_type -> cosmos.group.v1.MsgWithdrawProposalResponse + 24, // 36: cosmos.group.v1.Msg.Vote:output_type -> cosmos.group.v1.MsgVoteResponse + 26, // 37: cosmos.group.v1.Msg.Exec:output_type -> cosmos.group.v1.MsgExecResponse + 28, // 38: cosmos.group.v1.Msg.LeaveGroup:output_type -> cosmos.group.v1.MsgLeaveGroupResponse + 25, // [25:39] is the sub-list for method output_type + 11, // [11:25] is the sub-list for method input_type + 11, // [11:11] is the sub-list for extension type_name + 11, // [11:11] is the sub-list for extension extendee + 0, // [0:11] is the sub-list for field type_name } func init() { file_cosmos_group_v1_tx_proto_init() } diff --git a/api/cosmos/group/v1/tx_grpc.pb.go b/api/cosmos/group/v1/tx_grpc.pb.go index a53f8a42c695..7c65460019ce 100644 --- a/api/cosmos/group/v1/tx_grpc.pb.go +++ b/api/cosmos/group/v1/tx_grpc.pb.go @@ -42,7 +42,7 @@ type MsgClient interface { UpdateGroupPolicyMetadata(ctx context.Context, in *MsgUpdateGroupPolicyMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupPolicyMetadataResponse, error) // SubmitProposal submits a new proposal. SubmitProposal(ctx context.Context, in *MsgSubmitProposal, opts ...grpc.CallOption) (*MsgSubmitProposalResponse, error) - // WithdrawProposal aborts a proposal. + // WithdrawProposal withdraws a proposal. WithdrawProposal(ctx context.Context, in *MsgWithdrawProposal, opts ...grpc.CallOption) (*MsgWithdrawProposalResponse, error) // Vote allows a voter to vote on a proposal. Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) @@ -210,7 +210,7 @@ type MsgServer interface { UpdateGroupPolicyMetadata(context.Context, *MsgUpdateGroupPolicyMetadata) (*MsgUpdateGroupPolicyMetadataResponse, error) // SubmitProposal submits a new proposal. SubmitProposal(context.Context, *MsgSubmitProposal) (*MsgSubmitProposalResponse, error) - // WithdrawProposal aborts a proposal. + // WithdrawProposal withdraws a proposal. WithdrawProposal(context.Context, *MsgWithdrawProposal) (*MsgWithdrawProposalResponse, error) // Vote allows a voter to vote on a proposal. Vote(context.Context, *MsgVote) (*MsgVoteResponse, error) diff --git a/api/cosmos/group/v1/types.pulsar.go b/api/cosmos/group/v1/types.pulsar.go index 2a5b9980d55a..87f51790f3ee 100644 --- a/api/cosmos/group/v1/types.pulsar.go +++ b/api/cosmos/group/v1/types.pulsar.go @@ -644,77 +644,30 @@ func (x *fastReflection_Member) ProtoMethods() *protoiface.Methods { } } -var _ protoreflect.List = (*_Members_1_list)(nil) - -type _Members_1_list struct { - list *[]*Member -} - -func (x *_Members_1_list) Len() int { - if x.list == nil { - return 0 - } - return len(*x.list) -} - -func (x *_Members_1_list) Get(i int) protoreflect.Value { - return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) -} - -func (x *_Members_1_list) Set(i int, value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Member) - (*x.list)[i] = concreteValue -} - -func (x *_Members_1_list) Append(value protoreflect.Value) { - valueUnwrapped := value.Message() - concreteValue := valueUnwrapped.Interface().(*Member) - *x.list = append(*x.list, concreteValue) -} - -func (x *_Members_1_list) AppendMutable() protoreflect.Value { - v := new(Member) - *x.list = append(*x.list, v) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_Members_1_list) Truncate(n int) { - for i := n; i < len(*x.list); i++ { - (*x.list)[i] = nil - } - *x.list = (*x.list)[:n] -} - -func (x *_Members_1_list) NewElement() protoreflect.Value { - v := new(Member) - return protoreflect.ValueOfMessage(v.ProtoReflect()) -} - -func (x *_Members_1_list) IsValid() bool { - return x.list != nil -} - var ( - md_Members protoreflect.MessageDescriptor - fd_Members_members protoreflect.FieldDescriptor + md_MemberRequest protoreflect.MessageDescriptor + fd_MemberRequest_address protoreflect.FieldDescriptor + fd_MemberRequest_weight protoreflect.FieldDescriptor + fd_MemberRequest_metadata protoreflect.FieldDescriptor ) func init() { file_cosmos_group_v1_types_proto_init() - md_Members = File_cosmos_group_v1_types_proto.Messages().ByName("Members") - fd_Members_members = md_Members.Fields().ByName("members") + md_MemberRequest = File_cosmos_group_v1_types_proto.Messages().ByName("MemberRequest") + fd_MemberRequest_address = md_MemberRequest.Fields().ByName("address") + fd_MemberRequest_weight = md_MemberRequest.Fields().ByName("weight") + fd_MemberRequest_metadata = md_MemberRequest.Fields().ByName("metadata") } -var _ protoreflect.Message = (*fastReflection_Members)(nil) +var _ protoreflect.Message = (*fastReflection_MemberRequest)(nil) -type fastReflection_Members Members +type fastReflection_MemberRequest MemberRequest -func (x *Members) ProtoReflect() protoreflect.Message { - return (*fastReflection_Members)(x) +func (x *MemberRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_MemberRequest)(x) } -func (x *Members) slowProtoReflect() protoreflect.Message { +func (x *MemberRequest) slowProtoReflect() protoreflect.Message { mi := &file_cosmos_group_v1_types_proto_msgTypes[1] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -726,43 +679,43 @@ func (x *Members) slowProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -var _fastReflection_Members_messageType fastReflection_Members_messageType -var _ protoreflect.MessageType = fastReflection_Members_messageType{} +var _fastReflection_MemberRequest_messageType fastReflection_MemberRequest_messageType +var _ protoreflect.MessageType = fastReflection_MemberRequest_messageType{} -type fastReflection_Members_messageType struct{} +type fastReflection_MemberRequest_messageType struct{} -func (x fastReflection_Members_messageType) Zero() protoreflect.Message { - return (*fastReflection_Members)(nil) +func (x fastReflection_MemberRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_MemberRequest)(nil) } -func (x fastReflection_Members_messageType) New() protoreflect.Message { - return new(fastReflection_Members) +func (x fastReflection_MemberRequest_messageType) New() protoreflect.Message { + return new(fastReflection_MemberRequest) } -func (x fastReflection_Members_messageType) Descriptor() protoreflect.MessageDescriptor { - return md_Members +func (x fastReflection_MemberRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_MemberRequest } // Descriptor returns message descriptor, which contains only the protobuf // type information for the message. -func (x *fastReflection_Members) Descriptor() protoreflect.MessageDescriptor { - return md_Members +func (x *fastReflection_MemberRequest) Descriptor() protoreflect.MessageDescriptor { + return md_MemberRequest } // Type returns the message type, which encapsulates both Go and protobuf // type information. If the Go type information is not needed, // it is recommended that the message descriptor be used instead. -func (x *fastReflection_Members) Type() protoreflect.MessageType { - return _fastReflection_Members_messageType +func (x *fastReflection_MemberRequest) Type() protoreflect.MessageType { + return _fastReflection_MemberRequest_messageType } // New returns a newly allocated and mutable empty message. -func (x *fastReflection_Members) New() protoreflect.Message { - return new(fastReflection_Members) +func (x *fastReflection_MemberRequest) New() protoreflect.Message { + return new(fastReflection_MemberRequest) } // Interface unwraps the message reflection interface and // returns the underlying ProtoMessage interface. -func (x *fastReflection_Members) Interface() protoreflect.ProtoMessage { - return (*Members)(x) +func (x *fastReflection_MemberRequest) Interface() protoreflect.ProtoMessage { + return (*MemberRequest)(x) } // Range iterates over every populated field in an undefined order, @@ -770,10 +723,22 @@ func (x *fastReflection_Members) Interface() protoreflect.ProtoMessage { // Range returns immediately if f returns false. // While iterating, mutating operations may only be performed // on the current field descriptor. -func (x *fastReflection_Members) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { - if len(x.Members) != 0 { - value := protoreflect.ValueOfList(&_Members_1_list{list: &x.Members}) - if !f(fd_Members_members, value) { +func (x *fastReflection_MemberRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Address != "" { + value := protoreflect.ValueOfString(x.Address) + if !f(fd_MemberRequest_address, value) { + return + } + } + if x.Weight != "" { + value := protoreflect.ValueOfString(x.Weight) + if !f(fd_MemberRequest_weight, value) { + return + } + } + if x.Metadata != "" { + value := protoreflect.ValueOfString(x.Metadata) + if !f(fd_MemberRequest_metadata, value) { return } } @@ -790,15 +755,19 @@ func (x *fastReflection_Members) Range(f func(protoreflect.FieldDescriptor, prot // In other cases (aside from the nullable cases above), // a proto3 scalar field is populated if it contains a non-zero value, and // a repeated field is populated if it is non-empty. -func (x *fastReflection_Members) Has(fd protoreflect.FieldDescriptor) bool { +func (x *fastReflection_MemberRequest) Has(fd protoreflect.FieldDescriptor) bool { switch fd.FullName() { - case "cosmos.group.v1.Members.members": - return len(x.Members) != 0 + case "cosmos.group.v1.MemberRequest.address": + return x.Address != "" + case "cosmos.group.v1.MemberRequest.weight": + return x.Weight != "" + case "cosmos.group.v1.MemberRequest.metadata": + return x.Metadata != "" default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.Members")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MemberRequest")) } - panic(fmt.Errorf("message cosmos.group.v1.Members does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.group.v1.MemberRequest does not contain field %s", fd.FullName())) } } @@ -808,15 +777,19 @@ func (x *fastReflection_Members) Has(fd protoreflect.FieldDescriptor) bool { // associated with the given field number. // // Clear is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_Members) Clear(fd protoreflect.FieldDescriptor) { +func (x *fastReflection_MemberRequest) Clear(fd protoreflect.FieldDescriptor) { switch fd.FullName() { - case "cosmos.group.v1.Members.members": - x.Members = nil + case "cosmos.group.v1.MemberRequest.address": + x.Address = "" + case "cosmos.group.v1.MemberRequest.weight": + x.Weight = "" + case "cosmos.group.v1.MemberRequest.metadata": + x.Metadata = "" default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.Members")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MemberRequest")) } - panic(fmt.Errorf("message cosmos.group.v1.Members does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.group.v1.MemberRequest does not contain field %s", fd.FullName())) } } @@ -826,19 +799,22 @@ func (x *fastReflection_Members) Clear(fd protoreflect.FieldDescriptor) { // the default value of a bytes scalar is guaranteed to be a copy. // For unpopulated composite types, it returns an empty, read-only view // of the value; to obtain a mutable reference, use Mutable. -func (x *fastReflection_Members) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_MemberRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { switch descriptor.FullName() { - case "cosmos.group.v1.Members.members": - if len(x.Members) == 0 { - return protoreflect.ValueOfList(&_Members_1_list{}) - } - listValue := &_Members_1_list{list: &x.Members} - return protoreflect.ValueOfList(listValue) + case "cosmos.group.v1.MemberRequest.address": + value := x.Address + return protoreflect.ValueOfString(value) + case "cosmos.group.v1.MemberRequest.weight": + value := x.Weight + return protoreflect.ValueOfString(value) + case "cosmos.group.v1.MemberRequest.metadata": + value := x.Metadata + return protoreflect.ValueOfString(value) default: if descriptor.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.Members")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MemberRequest")) } - panic(fmt.Errorf("message cosmos.group.v1.Members does not contain field %s", descriptor.FullName())) + panic(fmt.Errorf("message cosmos.group.v1.MemberRequest does not contain field %s", descriptor.FullName())) } } @@ -852,17 +828,19 @@ func (x *fastReflection_Members) Get(descriptor protoreflect.FieldDescriptor) pr // empty, read-only value, then it panics. // // Set is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_Members) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { +func (x *fastReflection_MemberRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { switch fd.FullName() { - case "cosmos.group.v1.Members.members": - lv := value.List() - clv := lv.(*_Members_1_list) - x.Members = *clv.list + case "cosmos.group.v1.MemberRequest.address": + x.Address = value.Interface().(string) + case "cosmos.group.v1.MemberRequest.weight": + x.Weight = value.Interface().(string) + case "cosmos.group.v1.MemberRequest.metadata": + x.Metadata = value.Interface().(string) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.Members")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MemberRequest")) } - panic(fmt.Errorf("message cosmos.group.v1.Members does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.group.v1.MemberRequest does not contain field %s", fd.FullName())) } } @@ -876,45 +854,48 @@ func (x *fastReflection_Members) Set(fd protoreflect.FieldDescriptor, value prot // It panics if the field does not contain a composite type. // // Mutable is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_Members) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_MemberRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.group.v1.Members.members": - if x.Members == nil { - x.Members = []*Member{} - } - value := &_Members_1_list{list: &x.Members} - return protoreflect.ValueOfList(value) + case "cosmos.group.v1.MemberRequest.address": + panic(fmt.Errorf("field address of message cosmos.group.v1.MemberRequest is not mutable")) + case "cosmos.group.v1.MemberRequest.weight": + panic(fmt.Errorf("field weight of message cosmos.group.v1.MemberRequest is not mutable")) + case "cosmos.group.v1.MemberRequest.metadata": + panic(fmt.Errorf("field metadata of message cosmos.group.v1.MemberRequest is not mutable")) default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.Members")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MemberRequest")) } - panic(fmt.Errorf("message cosmos.group.v1.Members does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.group.v1.MemberRequest does not contain field %s", fd.FullName())) } } // NewField returns a new value that is assignable to the field // for the given descriptor. For scalars, this returns the default value. // For lists, maps, and messages, this returns a new, empty, mutable value. -func (x *fastReflection_Members) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { +func (x *fastReflection_MemberRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { switch fd.FullName() { - case "cosmos.group.v1.Members.members": - list := []*Member{} - return protoreflect.ValueOfList(&_Members_1_list{list: &list}) + case "cosmos.group.v1.MemberRequest.address": + return protoreflect.ValueOfString("") + case "cosmos.group.v1.MemberRequest.weight": + return protoreflect.ValueOfString("") + case "cosmos.group.v1.MemberRequest.metadata": + return protoreflect.ValueOfString("") default: if fd.IsExtension() { - panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.Members")) + panic(fmt.Errorf("proto3 declared messages do not support extensions: cosmos.group.v1.MemberRequest")) } - panic(fmt.Errorf("message cosmos.group.v1.Members does not contain field %s", fd.FullName())) + panic(fmt.Errorf("message cosmos.group.v1.MemberRequest does not contain field %s", fd.FullName())) } } // WhichOneof reports which field within the oneof is populated, // returning nil if none are populated. // It panics if the oneof descriptor does not belong to this message. -func (x *fastReflection_Members) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { +func (x *fastReflection_MemberRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { switch d.FullName() { default: - panic(fmt.Errorf("%s is not a oneof field in cosmos.group.v1.Members", d.FullName())) + panic(fmt.Errorf("%s is not a oneof field in cosmos.group.v1.MemberRequest", d.FullName())) } panic("unreachable") } @@ -922,7 +903,7 @@ func (x *fastReflection_Members) WhichOneof(d protoreflect.OneofDescriptor) prot // GetUnknown retrieves the entire list of unknown fields. // The caller may only mutate the contents of the RawFields // if the mutated bytes are stored back into the message with SetUnknown. -func (x *fastReflection_Members) GetUnknown() protoreflect.RawFields { +func (x *fastReflection_MemberRequest) GetUnknown() protoreflect.RawFields { return x.unknownFields } @@ -933,7 +914,7 @@ func (x *fastReflection_Members) GetUnknown() protoreflect.RawFields { // An empty RawFields may be passed to clear the fields. // // SetUnknown is a mutating operation and unsafe for concurrent use. -func (x *fastReflection_Members) SetUnknown(fields protoreflect.RawFields) { +func (x *fastReflection_MemberRequest) SetUnknown(fields protoreflect.RawFields) { x.unknownFields = fields } @@ -945,7 +926,7 @@ func (x *fastReflection_Members) SetUnknown(fields protoreflect.RawFields) { // message type, but the details are implementation dependent. // Validity is not part of the protobuf data model, and may not // be preserved in marshaling or other operations. -func (x *fastReflection_Members) IsValid() bool { +func (x *fastReflection_MemberRequest) IsValid() bool { return x != nil } @@ -955,9 +936,9 @@ func (x *fastReflection_Members) IsValid() bool { // The returned methods type is identical to // "google.golang.org/protobuf/runtime/protoiface".Methods. // Consult the protoiface package documentation for details. -func (x *fastReflection_Members) ProtoMethods() *protoiface.Methods { +func (x *fastReflection_MemberRequest) ProtoMethods() *protoiface.Methods { size := func(input protoiface.SizeInput) protoiface.SizeOutput { - x := input.Message.Interface().(*Members) + x := input.Message.Interface().(*MemberRequest) if x == nil { return protoiface.SizeOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -969,11 +950,17 @@ func (x *fastReflection_Members) ProtoMethods() *protoiface.Methods { var n int var l int _ = l - if len(x.Members) > 0 { - for _, e := range x.Members { - l = options.Size(e) - n += 1 + l + runtime.Sov(uint64(l)) - } + l = len(x.Address) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Weight) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Metadata) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) } if x.unknownFields != nil { n += len(x.unknownFields) @@ -985,7 +972,7 @@ func (x *fastReflection_Members) ProtoMethods() *protoiface.Methods { } marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { - x := input.Message.Interface().(*Members) + x := input.Message.Interface().(*MemberRequest) if x == nil { return protoiface.MarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1004,21 +991,26 @@ func (x *fastReflection_Members) ProtoMethods() *protoiface.Methods { i -= len(x.unknownFields) copy(dAtA[i:], x.unknownFields) } - if len(x.Members) > 0 { - for iNdEx := len(x.Members) - 1; iNdEx >= 0; iNdEx-- { - encoded, err := options.Marshal(x.Members[iNdEx]) - if err != nil { - return protoiface.MarshalOutput{ - NoUnkeyedLiterals: input.NoUnkeyedLiterals, - Buf: input.Buf, - }, err - } - i -= len(encoded) - copy(dAtA[i:], encoded) - i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) - i-- - dAtA[i] = 0xa - } + if len(x.Metadata) > 0 { + i -= len(x.Metadata) + copy(dAtA[i:], x.Metadata) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Metadata))) + i-- + dAtA[i] = 0x1a + } + if len(x.Weight) > 0 { + i -= len(x.Weight) + copy(dAtA[i:], x.Weight) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Weight))) + i-- + dAtA[i] = 0x12 + } + if len(x.Address) > 0 { + i -= len(x.Address) + copy(dAtA[i:], x.Address) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Address))) + i-- + dAtA[i] = 0xa } if input.Buf != nil { input.Buf = append(input.Buf, dAtA...) @@ -1031,7 +1023,7 @@ func (x *fastReflection_Members) ProtoMethods() *protoiface.Methods { }, nil } unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { - x := input.Message.Interface().(*Members) + x := input.Message.Interface().(*MemberRequest) if x == nil { return protoiface.UnmarshalOutput{ NoUnkeyedLiterals: input.NoUnkeyedLiterals, @@ -1063,17 +1055,17 @@ func (x *fastReflection_Members) ProtoMethods() *protoiface.Methods { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Members: wiretype end group for non-group") + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MemberRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Members: illegal tag %d (wire type %d)", fieldNum, wire) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: MemberRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow @@ -1083,25 +1075,87 @@ func (x *fastReflection_Members) ProtoMethods() *protoiface.Methods { } 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 protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength } if postIndex > l { return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF } - x.Members = append(x.Members, &Member{}) - if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Members[len(x.Members)-1]); err != nil { - return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + x.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Weight = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Metadata = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -7356,7 +7410,7 @@ func (ProposalExecutorResult) EnumDescriptor() ([]byte, []int) { } // Member represents a group member with an account address, -// non-zero weight and metadata. +// non-zero weight, metadata and added_at timestamp. type Member struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -7420,18 +7474,24 @@ func (x *Member) GetAddedAt() *timestamppb.Timestamp { return nil } -// Members defines a repeated slice of Member objects. -type Members struct { +// MemberRequest represents a group member to be used in Msg server requests. +// Contrary to `Member`, it doesn't have any `added_at` field +// since this field cannot be set as part of requests. +type MemberRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // members is the list of members. - Members []*Member `protobuf:"bytes,1,rep,name=members,proto3" json:"members,omitempty"` + // address is the member's account address. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // weight is the member's voting weight that should be greater than 0. + Weight string `protobuf:"bytes,2,opt,name=weight,proto3" json:"weight,omitempty"` + // metadata is any arbitrary metadata attached to the member. + Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` } -func (x *Members) Reset() { - *x = Members{} +func (x *MemberRequest) Reset() { + *x = MemberRequest{} if protoimpl.UnsafeEnabled { mi := &file_cosmos_group_v1_types_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -7439,22 +7499,36 @@ func (x *Members) Reset() { } } -func (x *Members) String() string { +func (x *MemberRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Members) ProtoMessage() {} +func (*MemberRequest) ProtoMessage() {} -// Deprecated: Use Members.ProtoReflect.Descriptor instead. -func (*Members) Descriptor() ([]byte, []int) { +// Deprecated: Use MemberRequest.ProtoReflect.Descriptor instead. +func (*MemberRequest) Descriptor() ([]byte, []int) { return file_cosmos_group_v1_types_proto_rawDescGZIP(), []int{1} } -func (x *Members) GetMembers() []*Member { +func (x *MemberRequest) GetAddress() string { if x != nil { - return x.Members + return x.Address } - return nil + return "" +} + +func (x *MemberRequest) GetWeight() string { + if x != nil { + return x.Weight + } + return "" +} + +func (x *MemberRequest) GetMetadata() string { + if x != nil { + return x.Metadata + } + return "" } // ThresholdDecisionPolicy is a decision policy where a proposal passes when it @@ -7881,7 +7955,7 @@ type Proposal struct { // at this point, and the `final_tally_result`and `status` fields will be // accordingly updated. VotingPeriodEnd *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=voting_period_end,json=votingPeriodEnd,proto3" json:"voting_period_end,omitempty"` - // executor_result is the final result based on the votes and election rule. Initial value is NotRun. + // executor_result is the final result of the proposal execution. Initial value is NotRun. ExecutorResult ProposalExecutorResult `protobuf:"varint,11,opt,name=executor_result,json=executorResult,proto3,enum=cosmos.group.v1.ProposalExecutorResult" json:"executor_result,omitempty"` // messages is a list of `sdk.Msg`s that will be executed if the proposal passes. Messages []*anypb.Any `protobuf:"bytes,12,rep,name=messages,proto3" json:"messages,omitempty"` @@ -8154,199 +8228,202 @@ var file_cosmos_group_v1_types_proto_rawDesc = []byte{ 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x07, 0x61, 0x64, 0x64, 0x65, 0x64, 0x41, 0x74, 0x22, - 0x42, 0x0a, 0x07, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x73, 0x12, 0x37, 0x0a, 0x07, 0x6d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, - 0x6d, 0x62, 0x65, 0x72, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x07, 0x6d, 0x65, 0x6d, 0x62, - 0x65, 0x72, 0x73, 0x22, 0x8d, 0x01, 0x0a, 0x17, 0x54, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, - 0x64, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, - 0x1c, 0x0a, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x12, 0x40, 0x0a, - 0x07, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, - 0x2e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x57, - 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x52, 0x07, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x3a, - 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, - 0x69, 0x63, 0x79, 0x22, 0x90, 0x01, 0x0a, 0x18, 0x50, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, - 0x67, 0x65, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, - 0x12, 0x40, 0x0a, 0x07, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, - 0x63, 0x79, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x52, 0x07, 0x77, 0x69, 0x6e, 0x64, 0x6f, - 0x77, 0x73, 0x3a, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, - 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0xb8, 0x01, 0x0a, 0x15, 0x44, 0x65, 0x63, 0x69, 0x73, - 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, - 0x12, 0x48, 0x0a, 0x0d, 0x76, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x98, 0xdf, 0x1f, 0x01, 0x52, 0x0c, 0x76, 0x6f, - 0x74, 0x69, 0x6e, 0x67, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, 0x55, 0x0a, 0x14, 0x6d, 0x69, - 0x6e, 0x5f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x65, 0x72, 0x69, - 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x98, 0xdf, 0x1f, 0x01, 0x52, 0x12, 0x6d, - 0x69, 0x6e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, 0x50, 0x65, 0x72, 0x69, 0x6f, - 0x64, 0x22, 0xe9, 0x01, 0x0a, 0x09, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x12, - 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, - 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, - 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, - 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x77, - 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x74, 0x6f, 0x74, - 0x61, 0x6c, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x43, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, - 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, - 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, - 0x1f, 0x01, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x22, 0x59, 0x0a, - 0x0b, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x08, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x06, 0x6d, 0x65, 0x6d, 0x62, 0x65, - 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, - 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xe8, 0x02, 0x0a, 0x0f, 0x47, 0x72, 0x6f, - 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x32, 0x0a, 0x07, - 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, - 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, - 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, - 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x05, 0x61, - 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, - 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, - 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, - 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, - 0x6e, 0x12, 0x51, 0x0a, 0x0f, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x5f, 0x70, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, - 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, - 0x42, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0e, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, - 0x6c, 0x69, 0x63, 0x79, 0x12, 0x43, 0x0a, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, - 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, - 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, - 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x09, - 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8, - 0xa0, 0x1f, 0x01, 0x22, 0xbf, 0x05, 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, - 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, - 0x12, 0x4a, 0x0a, 0x14, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, - 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, - 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, - 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, + 0x77, 0x0a, 0x0d, 0x4d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x36, 0x0a, 0x09, 0x70, 0x72, 0x6f, 0x70, - 0x6f, 0x73, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, - 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, - 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x73, - 0x12, 0x45, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x0a, 0x73, 0x75, 0x62, - 0x6d, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x67, 0x72, 0x6f, 0x75, 0x70, - 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0c, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x30, 0x0a, 0x14, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x76, 0x65, 0x72, - 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, 0x12, 0x67, 0x72, 0x6f, 0x75, - 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x37, - 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, - 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, - 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x50, 0x0a, 0x12, 0x66, 0x69, 0x6e, 0x61, 0x6c, - 0x5f, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x09, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, - 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x6c, 0x6c, 0x79, 0x52, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x10, 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x54, 0x61, - 0x6c, 0x6c, 0x79, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x50, 0x0a, 0x11, 0x76, 0x6f, 0x74, - 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x65, 0x6e, 0x64, 0x18, 0x0a, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, - 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x0f, 0x76, 0x6f, 0x74, 0x69, - 0x6e, 0x67, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x45, 0x6e, 0x64, 0x12, 0x50, 0x0a, 0x0f, 0x65, - 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x0b, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, - 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x45, - 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x52, 0x0e, 0x65, - 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x30, 0x0a, - 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x22, 0x8d, 0x01, 0x0a, 0x17, 0x54, 0x68, 0x72, + 0x65, 0x73, 0x68, 0x6f, 0x6c, 0x64, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, 0x6c, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, 0x6f, + 0x6c, 0x64, 0x12, 0x40, 0x0a, 0x07, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, + 0x6c, 0x69, 0x63, 0x79, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x52, 0x07, 0x77, 0x69, 0x6e, + 0x64, 0x6f, 0x77, 0x73, 0x3a, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0x90, 0x01, 0x0a, 0x18, 0x50, 0x65, 0x72, + 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, + 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x63, 0x65, + 0x6e, 0x74, 0x61, 0x67, 0x65, 0x12, 0x40, 0x0a, 0x07, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, + 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x57, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x52, 0x07, + 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x3a, 0x12, 0xca, 0xb4, 0x2d, 0x0e, 0x44, 0x65, 0x63, + 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x22, 0xb8, 0x01, 0x0a, 0x15, + 0x44, 0x65, 0x63, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x57, 0x69, + 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x12, 0x48, 0x0a, 0x0d, 0x76, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x5f, + 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, + 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x98, 0xdf, 0x1f, + 0x01, 0x52, 0x0c, 0x76, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x12, + 0x55, 0x0a, 0x14, 0x6d, 0x69, 0x6e, 0x5f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x98, 0xdf, + 0x1f, 0x01, 0x52, 0x12, 0x6d, 0x69, 0x6e, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x69, 0x6f, 0x6e, + 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x22, 0xe9, 0x01, 0x0a, 0x09, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x02, 0x69, 0x64, 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, + 0x64, 0x6d, 0x69, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x21, 0x0a, 0x0c, 0x74, 0x6f, + 0x74, 0x61, 0x6c, 0x5f, 0x77, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0b, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x57, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x43, 0x0a, + 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, + 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, + 0x41, 0x74, 0x22, 0x59, 0x0a, 0x0b, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4d, 0x65, 0x6d, 0x62, 0x65, + 0x72, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, 0x12, 0x2f, 0x0a, 0x06, + 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x4d, + 0x65, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x06, 0x6d, 0x65, 0x6d, 0x62, 0x65, 0x72, 0x22, 0xf8, 0x02, + 0x0a, 0x0f, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x49, 0x6e, 0x66, + 0x6f, 0x12, 0x32, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x49, 0x64, + 0x12, 0x2e, 0x0a, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x42, + 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x61, 0x64, 0x6d, 0x69, 0x6e, + 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x18, 0x0a, 0x07, + 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x61, 0x0a, 0x0f, 0x64, 0x65, 0x63, 0x69, 0x73, 0x69, + 0x6f, 0x6e, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, - 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x3a, - 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x9d, 0x01, 0x0a, 0x0b, 0x54, 0x61, 0x6c, 0x6c, 0x79, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x79, 0x65, 0x73, 0x5f, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x79, 0x65, 0x73, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x62, 0x73, 0x74, 0x61, 0x69, 0x6e, 0x5f, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x61, 0x62, 0x73, 0x74, 0x61, - 0x69, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x6f, 0x5f, 0x63, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6e, 0x6f, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x12, 0x6e, 0x6f, 0x5f, 0x77, 0x69, 0x74, 0x68, 0x5f, 0x76, 0x65, - 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, - 0x6e, 0x6f, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x74, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x3a, - 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0xef, 0x01, 0x0a, 0x04, 0x56, 0x6f, 0x74, 0x65, 0x12, 0x1f, - 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x49, 0x64, 0x12, - 0x2e, 0x0a, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, - 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x12, - 0x33, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, - 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, - 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x06, 0x6f, 0x70, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x12, 0x45, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, - 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, - 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, 0x0a, 0x73, 0x75, 0x62, - 0x6d, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x2a, 0x8f, 0x01, 0x0a, 0x0a, 0x56, 0x6f, 0x74, 0x65, - 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x17, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, - 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, - 0x44, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, - 0x4f, 0x4e, 0x5f, 0x59, 0x45, 0x53, 0x10, 0x01, 0x12, 0x17, 0x0a, 0x13, 0x56, 0x4f, 0x54, 0x45, - 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x42, 0x53, 0x54, 0x41, 0x49, 0x4e, 0x10, - 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, - 0x5f, 0x4e, 0x4f, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, - 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4e, 0x4f, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x5f, 0x56, 0x45, 0x54, - 0x4f, 0x10, 0x04, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x2a, 0xce, 0x01, 0x0a, 0x0e, 0x50, 0x72, - 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1f, 0x0a, 0x1b, - 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, - 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1d, 0x0a, - 0x19, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, - 0x5f, 0x53, 0x55, 0x42, 0x4d, 0x49, 0x54, 0x54, 0x45, 0x44, 0x10, 0x01, 0x12, 0x1c, 0x0a, 0x18, - 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, - 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, 0x1c, 0x0a, 0x18, 0x50, 0x52, - 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x52, 0x45, - 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x03, 0x12, 0x1b, 0x0a, 0x17, 0x50, 0x52, 0x4f, 0x50, - 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x41, 0x42, 0x4f, 0x52, - 0x54, 0x45, 0x44, 0x10, 0x04, 0x12, 0x1d, 0x0a, 0x19, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, - 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x57, 0x49, 0x54, 0x48, 0x44, 0x52, 0x41, - 0x57, 0x4e, 0x10, 0x05, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x2a, 0xba, 0x01, 0x0a, 0x16, 0x50, - 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x28, 0x0a, 0x24, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, - 0x4c, 0x5f, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, - 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, - 0x24, 0x0a, 0x20, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x45, 0x58, 0x45, 0x43, - 0x55, 0x54, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x4e, 0x4f, 0x54, 0x5f, - 0x52, 0x55, 0x4e, 0x10, 0x01, 0x12, 0x24, 0x0a, 0x20, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, - 0x4c, 0x5f, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, - 0x54, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x02, 0x12, 0x24, 0x0a, 0x20, 0x50, - 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x4f, 0x52, - 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x46, 0x41, 0x49, 0x4c, 0x55, 0x52, 0x45, 0x10, - 0x03, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x42, 0xb9, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x42, - 0x0a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2f, 0x76, 0x31, 0x3b, - 0x67, 0x72, 0x6f, 0x75, 0x70, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x47, 0x58, 0xaa, 0x02, 0x0f, - 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x56, 0x31, 0xca, - 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x5c, 0x56, - 0x31, 0xe2, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, 0x6f, 0x75, 0x70, - 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, - 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x3a, - 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x42, 0x22, 0xca, 0xb4, 0x2d, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x63, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x0e, 0x64, 0x65, 0x63, 0x69, 0x73, + 0x69, 0x6f, 0x6e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x43, 0x0a, 0x0a, 0x63, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x64, 0x5f, 0x61, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, + 0xdf, 0x1f, 0x01, 0x52, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x41, 0x74, 0x3a, 0x08, + 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x01, 0x22, 0xbf, 0x05, 0x0a, 0x08, 0x50, 0x72, 0x6f, + 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x4a, 0x0a, 0x14, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, + 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x12, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, + 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x36, 0x0a, + 0x09, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x65, 0x72, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x09, + 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x70, 0x72, 0x6f, 0x70, + 0x6f, 0x73, 0x65, 0x72, 0x73, 0x12, 0x45, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, + 0x52, 0x0a, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x23, 0x0a, 0x0d, + 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x0c, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x30, 0x0a, 0x14, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x70, 0x6f, 0x6c, 0x69, 0x63, + 0x79, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x12, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x56, 0x65, 0x72, 0x73, + 0x69, 0x6f, 0x6e, 0x12, 0x37, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x50, 0x0a, 0x12, + 0x66, 0x69, 0x6e, 0x61, 0x6c, 0x5f, 0x74, 0x61, 0x6c, 0x6c, 0x79, 0x5f, 0x72, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x61, 0x6c, 0x6c, 0x79, + 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x10, 0x66, 0x69, + 0x6e, 0x61, 0x6c, 0x54, 0x61, 0x6c, 0x6c, 0x79, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x50, + 0x0a, 0x11, 0x76, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, + 0x65, 0x6e, 0x64, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, + 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, 0x52, + 0x0f, 0x76, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x45, 0x6e, 0x64, + 0x12, 0x50, 0x0a, 0x0f, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x5f, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x27, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x72, 0x6f, 0x70, + 0x6f, 0x73, 0x61, 0x6c, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x52, 0x0e, 0x65, 0x78, 0x65, 0x63, 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x12, 0x30, 0x0a, 0x08, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x0c, + 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x73, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0x9d, 0x01, 0x0a, 0x0b, 0x54, + 0x61, 0x6c, 0x6c, 0x79, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x79, 0x65, + 0x73, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x79, + 0x65, 0x73, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x61, 0x62, 0x73, 0x74, 0x61, + 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, + 0x61, 0x62, 0x73, 0x74, 0x61, 0x69, 0x6e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x19, 0x0a, 0x08, + 0x6e, 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x6e, 0x6f, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2b, 0x0a, 0x12, 0x6e, 0x6f, 0x5f, 0x77, 0x69, + 0x74, 0x68, 0x5f, 0x76, 0x65, 0x74, 0x6f, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6e, 0x6f, 0x57, 0x69, 0x74, 0x68, 0x56, 0x65, 0x74, 0x6f, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x04, 0x88, 0xa0, 0x1f, 0x00, 0x22, 0xef, 0x01, 0x0a, 0x04, 0x56, + 0x6f, 0x74, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x70, 0x6f, 0x73, + 0x61, 0x6c, 0x49, 0x64, 0x12, 0x2e, 0x0a, 0x05, 0x76, 0x6f, 0x74, 0x65, 0x72, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x05, 0x76, + 0x6f, 0x74, 0x65, 0x72, 0x12, 0x33, 0x0a, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x06, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x45, 0x0a, 0x0b, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x42, 0x08, 0xc8, 0xde, 0x1f, 0x00, 0x90, 0xdf, 0x1f, 0x01, + 0x52, 0x0a, 0x73, 0x75, 0x62, 0x6d, 0x69, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x2a, 0x8f, 0x01, 0x0a, + 0x0a, 0x56, 0x6f, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x17, 0x56, + 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, + 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x13, 0x0a, 0x0f, 0x56, 0x4f, 0x54, 0x45, + 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x59, 0x45, 0x53, 0x10, 0x01, 0x12, 0x17, 0x0a, + 0x13, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x42, 0x53, + 0x54, 0x41, 0x49, 0x4e, 0x10, 0x02, 0x12, 0x12, 0x0a, 0x0e, 0x56, 0x4f, 0x54, 0x45, 0x5f, 0x4f, + 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4e, 0x4f, 0x10, 0x03, 0x12, 0x1c, 0x0a, 0x18, 0x56, 0x4f, + 0x54, 0x45, 0x5f, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x4e, 0x4f, 0x5f, 0x57, 0x49, 0x54, + 0x48, 0x5f, 0x56, 0x45, 0x54, 0x4f, 0x10, 0x04, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x2a, 0xce, + 0x01, 0x0a, 0x0e, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x53, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x12, 0x1f, 0x0a, 0x1b, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, + 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, + 0x10, 0x00, 0x12, 0x1d, 0x0a, 0x19, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, + 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x53, 0x55, 0x42, 0x4d, 0x49, 0x54, 0x54, 0x45, 0x44, 0x10, + 0x01, 0x12, 0x1c, 0x0a, 0x18, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, + 0x41, 0x54, 0x55, 0x53, 0x5f, 0x41, 0x43, 0x43, 0x45, 0x50, 0x54, 0x45, 0x44, 0x10, 0x02, 0x12, + 0x1c, 0x0a, 0x18, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, + 0x55, 0x53, 0x5f, 0x52, 0x45, 0x4a, 0x45, 0x43, 0x54, 0x45, 0x44, 0x10, 0x03, 0x12, 0x1b, 0x0a, + 0x17, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, + 0x5f, 0x41, 0x42, 0x4f, 0x52, 0x54, 0x45, 0x44, 0x10, 0x04, 0x12, 0x1d, 0x0a, 0x19, 0x50, 0x52, + 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x57, 0x49, + 0x54, 0x48, 0x44, 0x52, 0x41, 0x57, 0x4e, 0x10, 0x05, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x2a, + 0xba, 0x01, 0x0a, 0x16, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x45, 0x78, 0x65, 0x63, + 0x75, 0x74, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x12, 0x28, 0x0a, 0x24, 0x50, 0x52, + 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x4f, 0x52, 0x5f, + 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, + 0x45, 0x44, 0x10, 0x00, 0x12, 0x24, 0x0a, 0x20, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, + 0x5f, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, + 0x5f, 0x4e, 0x4f, 0x54, 0x5f, 0x52, 0x55, 0x4e, 0x10, 0x01, 0x12, 0x24, 0x0a, 0x20, 0x50, 0x52, + 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x45, 0x58, 0x45, 0x43, 0x55, 0x54, 0x4f, 0x52, 0x5f, + 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x53, 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x02, + 0x12, 0x24, 0x0a, 0x20, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x5f, 0x45, 0x58, 0x45, + 0x43, 0x55, 0x54, 0x4f, 0x52, 0x5f, 0x52, 0x45, 0x53, 0x55, 0x4c, 0x54, 0x5f, 0x46, 0x41, 0x49, + 0x4c, 0x55, 0x52, 0x45, 0x10, 0x03, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x42, 0xa9, 0x01, 0x0a, + 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, + 0x50, 0x01, 0x5a, 0x28, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x2f, 0x76, 0x31, 0x3b, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, + 0x47, 0x58, 0xaa, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x47, 0x72, 0x6f, 0x75, + 0x70, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0f, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x1b, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, + 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -8368,7 +8445,7 @@ var file_cosmos_group_v1_types_proto_goTypes = []interface{}{ (ProposalStatus)(0), // 1: cosmos.group.v1.ProposalStatus (ProposalExecutorResult)(0), // 2: cosmos.group.v1.ProposalExecutorResult (*Member)(nil), // 3: cosmos.group.v1.Member - (*Members)(nil), // 4: cosmos.group.v1.Members + (*MemberRequest)(nil), // 4: cosmos.group.v1.MemberRequest (*ThresholdDecisionPolicy)(nil), // 5: cosmos.group.v1.ThresholdDecisionPolicy (*PercentageDecisionPolicy)(nil), // 6: cosmos.group.v1.PercentageDecisionPolicy (*DecisionPolicyWindows)(nil), // 7: cosmos.group.v1.DecisionPolicyWindows @@ -8384,28 +8461,27 @@ var file_cosmos_group_v1_types_proto_goTypes = []interface{}{ } var file_cosmos_group_v1_types_proto_depIdxs = []int32{ 14, // 0: cosmos.group.v1.Member.added_at:type_name -> google.protobuf.Timestamp - 3, // 1: cosmos.group.v1.Members.members:type_name -> cosmos.group.v1.Member - 7, // 2: cosmos.group.v1.ThresholdDecisionPolicy.windows:type_name -> cosmos.group.v1.DecisionPolicyWindows - 7, // 3: cosmos.group.v1.PercentageDecisionPolicy.windows:type_name -> cosmos.group.v1.DecisionPolicyWindows - 15, // 4: cosmos.group.v1.DecisionPolicyWindows.voting_period:type_name -> google.protobuf.Duration - 15, // 5: cosmos.group.v1.DecisionPolicyWindows.min_execution_period:type_name -> google.protobuf.Duration - 14, // 6: cosmos.group.v1.GroupInfo.created_at:type_name -> google.protobuf.Timestamp - 3, // 7: cosmos.group.v1.GroupMember.member:type_name -> cosmos.group.v1.Member - 16, // 8: cosmos.group.v1.GroupPolicyInfo.decision_policy:type_name -> google.protobuf.Any - 14, // 9: cosmos.group.v1.GroupPolicyInfo.created_at:type_name -> google.protobuf.Timestamp - 14, // 10: cosmos.group.v1.Proposal.submit_time:type_name -> google.protobuf.Timestamp - 1, // 11: cosmos.group.v1.Proposal.status:type_name -> cosmos.group.v1.ProposalStatus - 12, // 12: cosmos.group.v1.Proposal.final_tally_result:type_name -> cosmos.group.v1.TallyResult - 14, // 13: cosmos.group.v1.Proposal.voting_period_end:type_name -> google.protobuf.Timestamp - 2, // 14: cosmos.group.v1.Proposal.executor_result:type_name -> cosmos.group.v1.ProposalExecutorResult - 16, // 15: cosmos.group.v1.Proposal.messages:type_name -> google.protobuf.Any - 0, // 16: cosmos.group.v1.Vote.option:type_name -> cosmos.group.v1.VoteOption - 14, // 17: cosmos.group.v1.Vote.submit_time:type_name -> google.protobuf.Timestamp - 18, // [18:18] is the sub-list for method output_type - 18, // [18:18] is the sub-list for method input_type - 18, // [18:18] is the sub-list for extension type_name - 18, // [18:18] is the sub-list for extension extendee - 0, // [0:18] is the sub-list for field type_name + 7, // 1: cosmos.group.v1.ThresholdDecisionPolicy.windows:type_name -> cosmos.group.v1.DecisionPolicyWindows + 7, // 2: cosmos.group.v1.PercentageDecisionPolicy.windows:type_name -> cosmos.group.v1.DecisionPolicyWindows + 15, // 3: cosmos.group.v1.DecisionPolicyWindows.voting_period:type_name -> google.protobuf.Duration + 15, // 4: cosmos.group.v1.DecisionPolicyWindows.min_execution_period:type_name -> google.protobuf.Duration + 14, // 5: cosmos.group.v1.GroupInfo.created_at:type_name -> google.protobuf.Timestamp + 3, // 6: cosmos.group.v1.GroupMember.member:type_name -> cosmos.group.v1.Member + 16, // 7: cosmos.group.v1.GroupPolicyInfo.decision_policy:type_name -> google.protobuf.Any + 14, // 8: cosmos.group.v1.GroupPolicyInfo.created_at:type_name -> google.protobuf.Timestamp + 14, // 9: cosmos.group.v1.Proposal.submit_time:type_name -> google.protobuf.Timestamp + 1, // 10: cosmos.group.v1.Proposal.status:type_name -> cosmos.group.v1.ProposalStatus + 12, // 11: cosmos.group.v1.Proposal.final_tally_result:type_name -> cosmos.group.v1.TallyResult + 14, // 12: cosmos.group.v1.Proposal.voting_period_end:type_name -> google.protobuf.Timestamp + 2, // 13: cosmos.group.v1.Proposal.executor_result:type_name -> cosmos.group.v1.ProposalExecutorResult + 16, // 14: cosmos.group.v1.Proposal.messages:type_name -> google.protobuf.Any + 0, // 15: cosmos.group.v1.Vote.option:type_name -> cosmos.group.v1.VoteOption + 14, // 16: cosmos.group.v1.Vote.submit_time:type_name -> google.protobuf.Timestamp + 17, // [17:17] is the sub-list for method output_type + 17, // [17:17] is the sub-list for method input_type + 17, // [17:17] is the sub-list for extension type_name + 17, // [17:17] is the sub-list for extension extendee + 0, // [0:17] is the sub-list for field type_name } func init() { file_cosmos_group_v1_types_proto_init() } @@ -8427,7 +8503,7 @@ func file_cosmos_group_v1_types_proto_init() { } } file_cosmos_group_v1_types_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Members); i { + switch v := v.(*MemberRequest); i { case 0: return &v.state case 1: diff --git a/api/cosmos/mint/v1beta1/genesis.pulsar.go b/api/cosmos/mint/v1beta1/genesis.pulsar.go index 56d77e1d350a..51e6ad46aab8 100644 --- a/api/cosmos/mint/v1beta1/genesis.pulsar.go +++ b/api/cosmos/mint/v1beta1/genesis.pulsar.go @@ -604,11 +604,10 @@ var file_cosmos_mint_v1beta1_genesis_proto_rawDesc = []byte{ 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, - 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xd7, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, + 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xc7, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, + 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6d, 0x69, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4d, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, diff --git a/api/cosmos/mint/v1beta1/mint.pulsar.go b/api/cosmos/mint/v1beta1/mint.pulsar.go index 0d54bed5d149..a7a67703c5d3 100644 --- a/api/cosmos/mint/v1beta1/mint.pulsar.go +++ b/api/cosmos/mint/v1beta1/mint.pulsar.go @@ -1416,11 +1416,10 @@ var file_cosmos_mint_v1beta1_mint_proto_rawDesc = []byte{ 0x6f, 0x61, 0x6c, 0x42, 0x6f, 0x6e, 0x64, 0x65, 0x64, 0x12, 0x26, 0x0a, 0x0f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x5f, 0x70, 0x65, 0x72, 0x5f, 0x79, 0x65, 0x61, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x73, 0x50, 0x65, 0x72, 0x59, 0x65, 0x61, - 0x72, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0xd4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, + 0x72, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0xc4, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x09, 0x4d, 0x69, 0x6e, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, + 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6d, 0x69, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4d, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, diff --git a/api/cosmos/mint/v1beta1/query.pulsar.go b/api/cosmos/mint/v1beta1/query.pulsar.go index a63353a12c89..8d1c5da47cde 100644 --- a/api/cosmos/mint/v1beta1/query.pulsar.go +++ b/api/cosmos/mint/v1beta1/query.pulsar.go @@ -2633,12 +2633,11 @@ var file_cosmos_mint_v1beta1_query_proto_rawDesc = []byte{ 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x12, 0x26, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61, 0x6e, 0x6e, 0x75, 0x61, 0x6c, 0x5f, 0x70, - 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0xd5, 0x01, 0x0a, 0x17, 0x63, 0x6f, + 0x72, 0x6f, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x42, 0xc5, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, - 0x6f, 0x50, 0x01, 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, - 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x69, 0x6e, + 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6d, 0x69, 0x6e, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4d, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x4d, 0x69, 0x6e, 0x74, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, diff --git a/api/cosmos/msg/v1/msg.pulsar.go b/api/cosmos/msg/v1/msg.pulsar.go index cd11d0dfeae5..241805ad2c40 100644 --- a/api/cosmos/msg/v1/msg.pulsar.go +++ b/api/cosmos/msg/v1/msg.pulsar.go @@ -59,11 +59,10 @@ var file_cosmos_msg_v1_msg_proto_rawDesc = []byte{ 0x67, 0x6e, 0x65, 0x72, 0x12, 0x1f, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xf0, 0x8c, 0xa6, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x06, - 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x42, 0xa9, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x73, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x42, 0x99, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6d, 0x73, 0x67, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x4d, 0x73, - 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x73, 0x67, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x73, 0x67, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4d, 0x58, 0xaa, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x4d, 0x73, 0x67, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5c, 0x4d, 0x73, diff --git a/api/cosmos/nft/v1beta1/event.pulsar.go b/api/cosmos/nft/v1beta1/event.pulsar.go index 3aa4241f7e50..e67deb473677 100644 --- a/api/cosmos/nft/v1beta1/event.pulsar.go +++ b/api/cosmos/nft/v1beta1/event.pulsar.go @@ -1919,12 +1919,11 @@ var file_cosmos_nft_v1beta1_event_proto_rawDesc = []byte{ 0x6c, 0x61, 0x73, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6c, 0x61, 0x73, 0x73, 0x49, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x42, 0xce, 0x01, 0x0a, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x42, 0xbe, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6e, 0x66, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6e, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6e, 0x66, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6e, 0x66, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4e, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x4e, 0x66, 0x74, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, diff --git a/api/cosmos/nft/v1beta1/genesis.pulsar.go b/api/cosmos/nft/v1beta1/genesis.pulsar.go index f94f08bb87f6..98980a0e4b03 100644 --- a/api/cosmos/nft/v1beta1/genesis.pulsar.go +++ b/api/cosmos/nft/v1beta1/genesis.pulsar.go @@ -1326,12 +1326,11 @@ var file_cosmos_nft_v1beta1_genesis_proto_rawDesc = []byte{ 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x04, 0x6e, 0x66, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6e, 0x66, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x2e, 0x4e, 0x46, 0x54, 0x52, 0x04, 0x6e, 0x66, 0x74, 0x73, 0x42, 0xd0, 0x01, 0x0a, 0x16, 0x63, + 0x2e, 0x4e, 0x46, 0x54, 0x52, 0x04, 0x6e, 0x66, 0x74, 0x73, 0x42, 0xc0, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6e, 0x66, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6e, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6e, 0x66, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6e, 0x66, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4e, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x4e, 0x66, 0x74, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, diff --git a/api/cosmos/nft/v1beta1/nft.pulsar.go b/api/cosmos/nft/v1beta1/nft.pulsar.go index 5918506e15f3..e5ef55c3564b 100644 --- a/api/cosmos/nft/v1beta1/nft.pulsar.go +++ b/api/cosmos/nft/v1beta1/nft.pulsar.go @@ -1728,11 +1728,10 @@ var file_cosmos_nft_v1beta1_nft_proto_rawDesc = []byte{ 0x01, 0x28, 0x09, 0x52, 0x07, 0x75, 0x72, 0x69, 0x48, 0x61, 0x73, 0x68, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, - 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0xcc, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0xbc, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6e, 0x66, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x42, 0x08, 0x4e, 0x66, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x31, 0x42, 0x08, 0x4e, 0x66, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6e, 0x66, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6e, 0x66, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4e, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x4e, 0x66, 0x74, diff --git a/api/cosmos/nft/v1beta1/query.pulsar.go b/api/cosmos/nft/v1beta1/query.pulsar.go index be066f518cf5..f045f70942a5 100644 --- a/api/cosmos/nft/v1beta1/query.pulsar.go +++ b/api/cosmos/nft/v1beta1/query.pulsar.go @@ -2,9 +2,9 @@ package nftv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -7263,11 +7263,10 @@ var file_cosmos_nft_v1beta1_query_proto_rawDesc = []byte{ 0x79, 0x43, 0x6c, 0x61, 0x73, 0x73, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x23, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x1d, 0x12, 0x1b, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6e, 0x66, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6c, - 0x61, 0x73, 0x73, 0x65, 0x73, 0x42, 0xce, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, + 0x61, 0x73, 0x73, 0x65, 0x73, 0x42, 0xbe, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6e, 0x66, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, + 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6e, 0x66, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6e, 0x66, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4e, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x4e, 0x66, diff --git a/api/cosmos/nft/v1beta1/tx.pulsar.go b/api/cosmos/nft/v1beta1/tx.pulsar.go index d40d4a76c8ff..e81e86377edb 100644 --- a/api/cosmos/nft/v1beta1/tx.pulsar.go +++ b/api/cosmos/nft/v1beta1/tx.pulsar.go @@ -2,9 +2,9 @@ package nftv1beta1 import ( + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -1106,11 +1106,10 @@ var file_cosmos_nft_v1beta1_tx_proto_rawDesc = []byte{ 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x1a, 0x23, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6e, 0x66, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xcb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xbb, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6e, 0x66, 0x74, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, - 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3e, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, + 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2e, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6e, 0x66, 0x74, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x6e, 0x66, 0x74, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4e, 0x58, 0xaa, 0x02, 0x12, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x4e, 0x66, 0x74, 0x2e, 0x56, diff --git a/api/cosmos/orm/module/v1alpha1/module.pulsar.go b/api/cosmos/orm/module/v1alpha1/module.pulsar.go index ca381bb9cebe..61a3f50016b3 100644 --- a/api/cosmos/orm/module/v1alpha1/module.pulsar.go +++ b/api/cosmos/orm/module/v1alpha1/module.pulsar.go @@ -2,9 +2,9 @@ package modulev1alpha1 import ( + _ "cosmossdk.io/api/cosmos/app/v1alpha1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/app/v1alpha1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -423,12 +423,11 @@ var file_cosmos_orm_module_v1alpha1_module_proto_rawDesc = []byte{ 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x32, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x28, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x22, 0x0a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x6f, 0x72, 0x6d, 0x42, 0x84, 0x02, 0x0a, 0x1e, + 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x6f, 0x72, 0x6d, 0x42, 0xf4, 0x01, 0x0a, 0x1e, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6f, 0x72, 0x6d, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, - 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4a, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3a, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6f, 0x72, 0x6d, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4f, 0x4d, 0xaa, diff --git a/api/cosmos/orm/v1/orm.pulsar.go b/api/cosmos/orm/v1/orm.pulsar.go index 5fa1bcba696f..0c35ac5acf45 100644 --- a/api/cosmos/orm/v1/orm.pulsar.go +++ b/api/cosmos/orm/v1/orm.pulsar.go @@ -2192,7 +2192,7 @@ type SecondaryIndexDescriptor struct { // Index keys are prefixed by the varint encoded table id and the varint // encoded index id plus any additional prefix specified by the schema. // - // In addition the the field segments, non-unique index keys are suffixed with + // In addition the field segments, non-unique index keys are suffixed with // any additional primary key fields not present in the index fields so that the // primary key can be reconstructed. Unique indexes instead of being suffixed // store the remaining primary key fields in the value.. @@ -2361,11 +2361,10 @@ var file_cosmos_orm_v1_orm_proto_rawDesc = []byte{ 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xef, 0xb3, 0xea, 0x31, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6f, 0x72, 0x6d, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x74, 0x6f, 0x6e, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, - 0x6f, 0x72, 0x52, 0x09, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x74, 0x6f, 0x6e, 0x42, 0xa9, 0x01, + 0x6f, 0x72, 0x52, 0x09, 0x73, 0x69, 0x6e, 0x67, 0x6c, 0x65, 0x74, 0x6f, 0x6e, 0x42, 0x99, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6f, 0x72, 0x6d, 0x2e, 0x76, 0x31, 0x42, 0x08, 0x4f, 0x72, 0x6d, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, + 0x24, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6f, 0x72, 0x6d, 0x2f, 0x76, 0x31, 0x3b, 0x6f, 0x72, 0x6d, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4f, 0x58, 0xaa, 0x02, 0x0d, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x4f, 0x72, 0x6d, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x43, 0x6f, diff --git a/api/cosmos/orm/v1alpha1/schema.pulsar.go b/api/cosmos/orm/v1alpha1/schema.pulsar.go index 5d22e96a35fe..5448367d13d1 100644 --- a/api/cosmos/orm/v1alpha1/schema.pulsar.go +++ b/api/cosmos/orm/v1alpha1/schema.pulsar.go @@ -1353,11 +1353,10 @@ var file_cosmos_orm_v1alpha1_schema_proto_rawDesc = []byte{ 0x6d, 0x6f, 0x73, 0x2e, 0x6f, 0x72, 0x6d, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f, 0x72, 0x52, 0x0c, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x53, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x42, 0xd6, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x42, 0xc6, 0x01, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x6f, 0x72, 0x6d, 0x2e, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x42, 0x0b, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x40, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, + 0x5a, 0x30, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6f, 0x72, 0x6d, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x3b, 0x6f, 0x72, 0x6d, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x4f, 0x58, 0xaa, 0x02, 0x13, 0x43, 0x6f, 0x73, 0x6d, 0x6f, diff --git a/api/cosmos/params/v1beta1/params.pulsar.go b/api/cosmos/params/v1beta1/params.pulsar.go index 3a318f417b51..c913653d2af4 100644 --- a/api/cosmos/params/v1beta1/params.pulsar.go +++ b/api/cosmos/params/v1beta1/params.pulsar.go @@ -1324,12 +1324,11 @@ var file_cosmos_params_v1beta1_params_proto_rawDesc = []byte{ 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x75, 0x62, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0xe8, 0x01, 0x0a, + 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x04, 0x98, 0xa0, 0x1f, 0x00, 0x42, 0xd8, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, - 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6d, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x34, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x50, 0x58, 0xaa, 0x02, 0x15, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x50, diff --git a/api/cosmos/params/v1beta1/query.pulsar.go b/api/cosmos/params/v1beta1/query.pulsar.go index d7052371c9f6..639b86eb3fe0 100644 --- a/api/cosmos/params/v1beta1/query.pulsar.go +++ b/api/cosmos/params/v1beta1/query.pulsar.go @@ -2425,6 +2425,8 @@ func (x *QueryParamsResponse) GetParam() *ParamChange { // QuerySubspacesRequest defines a request type for querying for all registered // subspaces and all keys for a subspace. +// +// Since: cosmos-sdk 0.46 type QuerySubspacesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2453,6 +2455,8 @@ func (*QuerySubspacesRequest) Descriptor() ([]byte, []int) { // QuerySubspacesResponse defines the response types for querying for all // registered subspaces and all keys for a subspace. +// +// Since: cosmos-sdk 0.46 type QuerySubspacesResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2490,6 +2494,8 @@ func (x *QuerySubspacesResponse) GetSubspaces() []*Subspace { // Subspace defines a parameter subspace name and all the keys that exist for // the subspace. +// +// Since: cosmos-sdk 0.46 type Subspace struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -2584,11 +2590,10 @@ var file_cosmos_params_v1beta1_query_proto_rawDesc = []byte{ 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x28, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x22, 0x12, 0x20, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x73, 0x75, 0x62, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x73, 0x42, 0xe3, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x63, 0x65, 0x73, 0x42, 0xd3, 0x01, 0x0a, 0x19, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, + 0x34, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x50, 0x58, 0xaa, 0x02, 0x15, 0x43, 0x6f, diff --git a/api/cosmos/params/v1beta1/query_grpc.pb.go b/api/cosmos/params/v1beta1/query_grpc.pb.go index dbc06a6a28a5..da2762cf1179 100644 --- a/api/cosmos/params/v1beta1/query_grpc.pb.go +++ b/api/cosmos/params/v1beta1/query_grpc.pb.go @@ -26,6 +26,8 @@ type QueryClient interface { // key. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // Subspaces queries for all registered subspaces and all keys for a subspace. + // + // Since: cosmos-sdk 0.46 Subspaces(ctx context.Context, in *QuerySubspacesRequest, opts ...grpc.CallOption) (*QuerySubspacesResponse, error) } @@ -63,6 +65,8 @@ type QueryServer interface { // key. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // Subspaces queries for all registered subspaces and all keys for a subspace. + // + // Since: cosmos-sdk 0.46 Subspaces(context.Context, *QuerySubspacesRequest) (*QuerySubspacesResponse, error) mustEmbedUnimplementedQueryServer() } diff --git a/api/cosmos/slashing/v1beta1/genesis.pulsar.go b/api/cosmos/slashing/v1beta1/genesis.pulsar.go index 3e03a678cca0..490d3d584d3e 100644 --- a/api/cosmos/slashing/v1beta1/genesis.pulsar.go +++ b/api/cosmos/slashing/v1beta1/genesis.pulsar.go @@ -2502,11 +2502,10 @@ var file_cosmos_slashing_v1beta1_genesis_proto_rawDesc = []byte{ 0x63, 0x6b, 0x12, 0x14, 0x0a, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x69, 0x73, 0x73, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x6d, 0x69, 0x73, 0x73, 0x65, 0x64, - 0x42, 0xf3, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x42, 0xe3, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, + 0x5a, 0x38, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, diff --git a/api/cosmos/slashing/v1beta1/query.pulsar.go b/api/cosmos/slashing/v1beta1/query.pulsar.go index 40acdfbe3df0..fb9261815c18 100644 --- a/api/cosmos/slashing/v1beta1/query.pulsar.go +++ b/api/cosmos/slashing/v1beta1/query.pulsar.go @@ -2,10 +2,10 @@ package slashingv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -2990,12 +2990,11 @@ var file_cosmos_slashing_v1beta1_query_proto_rawDesc = []byte{ 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2e, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x28, 0x12, 0x26, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x73, 0x69, 0x67, 0x6e, - 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x42, 0xf1, 0x01, 0x0a, 0x1b, 0x63, 0x6f, + 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x73, 0x42, 0xe1, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, 0xaa, 0x02, 0x17, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, diff --git a/api/cosmos/slashing/v1beta1/slashing.pulsar.go b/api/cosmos/slashing/v1beta1/slashing.pulsar.go index 4e161201bcb0..c0f54d6f77ab 100644 --- a/api/cosmos/slashing/v1beta1/slashing.pulsar.go +++ b/api/cosmos/slashing/v1beta1/slashing.pulsar.go @@ -1623,12 +1623,11 @@ var file_cosmos_slashing_v1beta1_slashing_proto_rawDesc = []byte{ 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x44, 0x65, 0x63, 0x52, 0x15, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x46, 0x72, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x77, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x42, 0xf8, 0x01, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x77, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x42, 0xe8, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0d, 0x53, - 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, + 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, 0xaa, 0x02, diff --git a/api/cosmos/slashing/v1beta1/tx.pulsar.go b/api/cosmos/slashing/v1beta1/tx.pulsar.go index ac3a6b811212..dcb0668d8196 100644 --- a/api/cosmos/slashing/v1beta1/tx.pulsar.go +++ b/api/cosmos/slashing/v1beta1/tx.pulsar.go @@ -2,10 +2,10 @@ package slashingv1beta1 import ( + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -893,11 +893,10 @@ var file_cosmos_slashing_v1beta1_tx_proto_rawDesc = []byte{ 0x6e, 0x6a, 0x61, 0x69, 0x6c, 0x1a, 0x2a, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x6e, 0x6a, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x42, 0xf2, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x65, 0x42, 0xe2, 0x01, 0x0a, 0x1b, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x48, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x38, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x6c, 0x61, 0x73, 0x68, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, 0xaa, 0x02, 0x17, 0x43, diff --git a/api/cosmos/staking/v1beta1/authz.pulsar.go b/api/cosmos/staking/v1beta1/authz.pulsar.go index 9c7fd6d84029..d238c4986ca8 100644 --- a/api/cosmos/staking/v1beta1/authz.pulsar.go +++ b/api/cosmos/staking/v1beta1/authz.pulsar.go @@ -2,10 +2,10 @@ package stakingv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -1455,12 +1455,11 @@ var file_cosmos_staking_v1beta1_authz_proto_rawDesc = []byte{ 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x55, 0x4e, 0x44, 0x45, 0x4c, 0x45, 0x47, 0x41, 0x54, 0x45, 0x10, 0x02, 0x12, 0x21, 0x0a, 0x1d, 0x41, 0x55, 0x54, 0x48, 0x4f, 0x52, 0x49, 0x5a, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x52, 0x45, 0x44, 0x45, 0x4c, - 0x45, 0x47, 0x41, 0x54, 0x45, 0x10, 0x03, 0x42, 0xea, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, + 0x45, 0x47, 0x41, 0x54, 0x45, 0x10, 0x03, 0x42, 0xda, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x41, 0x75, 0x74, 0x68, 0x7a, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x74, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x53, 0x74, 0x61, 0x6b, diff --git a/api/cosmos/staking/v1beta1/genesis.pulsar.go b/api/cosmos/staking/v1beta1/genesis.pulsar.go index e2131703420a..5e423b11973c 100644 --- a/api/cosmos/staking/v1beta1/genesis.pulsar.go +++ b/api/cosmos/staking/v1beta1/genesis.pulsar.go @@ -1945,12 +1945,11 @@ var file_cosmos_staking_v1beta1_genesis_proto_rawDesc = []byte{ 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x3a, - 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x42, 0xec, 0x01, 0x0a, 0x1a, 0x63, 0x6f, + 0x08, 0x88, 0xa0, 0x1f, 0x00, 0xe8, 0xa0, 0x1f, 0x00, 0x42, 0xdc, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x47, 0x65, 0x6e, 0x65, 0x73, 0x69, - 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, diff --git a/api/cosmos/staking/v1beta1/query.pulsar.go b/api/cosmos/staking/v1beta1/query.pulsar.go index 83c06d6653ca..e965f29fb1bd 100644 --- a/api/cosmos/staking/v1beta1/query.pulsar.go +++ b/api/cosmos/staking/v1beta1/query.pulsar.go @@ -2,10 +2,10 @@ package stakingv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" _ "github.com/gogo/protobuf/gogoproto" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" @@ -13829,7 +13829,7 @@ type QueryValidatorResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // validator defines the the validator info. + // validator defines the validator info. Validator *Validator `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` } @@ -14566,7 +14566,7 @@ type QueryDelegatorValidatorsResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // validators defines the the validators' info of a delegator. + // validators defines the validators' info of a delegator. Validators []*Validator `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators,omitempty"` // pagination defines the pagination in the response. Pagination *v1beta1.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` @@ -14660,7 +14660,7 @@ type QueryDelegatorValidatorResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - // validator defines the the validator info. + // validator defines the validator info. Validator *Validator `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` } @@ -15349,12 +15349,11 @@ var file_cosmos_staking_v1beta1_query_proto_rawDesc = []byte{ 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x26, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x20, 0x12, 0x1e, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xea, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, + 0x31, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0xda, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, - 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, - 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, + 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, + 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x53, 0x74, 0x61, diff --git a/api/cosmos/staking/v1beta1/staking.pulsar.go b/api/cosmos/staking/v1beta1/staking.pulsar.go index 2749d9b921c8..7e027f3b670a 100644 --- a/api/cosmos/staking/v1beta1/staking.pulsar.go +++ b/api/cosmos/staking/v1beta1/staking.pulsar.go @@ -2,11 +2,11 @@ package stakingv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + types "cosmossdk.io/api/tendermint/types" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" - types "github.com/cosmos/cosmos-sdk/api/tendermint/types" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -12089,6 +12089,8 @@ type Validator struct { // commission defines the commission parameters. Commission *Commission `protobuf:"bytes,10,opt,name=commission,proto3" json:"commission,omitempty"` // min_self_delegation is the validator's self declared minimum self delegation. + // + // Since: cosmos-sdk 0.46 MinSelfDelegation string `protobuf:"bytes,11,opt,name=min_self_delegation,json=minSelfDelegation,proto3" json:"min_self_delegation,omitempty"` } @@ -13316,12 +13318,11 @@ var file_cosmos_staking_v1beta1_staking_proto_rawDesc = []byte{ 0x0d, 0x8a, 0x9d, 0x20, 0x09, 0x55, 0x6e, 0x62, 0x6f, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x12, 0x22, 0x0a, 0x12, 0x42, 0x4f, 0x4e, 0x44, 0x5f, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x42, 0x4f, 0x4e, 0x44, 0x45, 0x44, 0x10, 0x03, 0x1a, 0x0a, 0x8a, 0x9d, 0x20, 0x06, 0x42, 0x6f, 0x6e, 0x64, - 0x65, 0x64, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x42, 0xec, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, + 0x65, 0x64, 0x1a, 0x04, 0x88, 0xa3, 0x1e, 0x00, 0x42, 0xdc, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x53, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, - 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, + 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x53, diff --git a/api/cosmos/staking/v1beta1/tx.pulsar.go b/api/cosmos/staking/v1beta1/tx.pulsar.go index 61067f5c7468..a2ff599dec41 100644 --- a/api/cosmos/staking/v1beta1/tx.pulsar.go +++ b/api/cosmos/staking/v1beta1/tx.pulsar.go @@ -2,11 +2,11 @@ package stakingv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -6649,6 +6649,8 @@ func (x *MsgUndelegateResponse) GetCompletionTime() *timestamppb.Timestamp { } // MsgCancelUnbondingDelegation defines the SDK message for performing a cancel unbonding delegation for delegator +// +// Since: cosmos-sdk 0.46 type MsgCancelUnbondingDelegation struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6711,6 +6713,8 @@ func (x *MsgCancelUnbondingDelegation) GetCreationHeight() int64 { } // MsgCancelUnbondingDelegationResponse +// +// Since: cosmos-sdk 0.46 type MsgCancelUnbondingDelegationResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -6955,11 +6959,10 @@ var file_cosmos_staking_v1beta1_tx_proto_rawDesc = []byte{ 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x55, 0x6e, 0x62, 0x6f, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x42, 0xe7, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, + 0x42, 0xd7, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, - 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, + 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x74, 0x61, 0x6b, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x53, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, diff --git a/api/cosmos/staking/v1beta1/tx_grpc.pb.go b/api/cosmos/staking/v1beta1/tx_grpc.pb.go index e230b495d7c9..e9361597b88e 100644 --- a/api/cosmos/staking/v1beta1/tx_grpc.pb.go +++ b/api/cosmos/staking/v1beta1/tx_grpc.pb.go @@ -37,6 +37,8 @@ type MsgClient interface { Undelegate(ctx context.Context, in *MsgUndelegate, opts ...grpc.CallOption) (*MsgUndelegateResponse, error) // CancelUnbondingDelegation defines a method for performing canceling the unbonding delegation // and delegate back to previous validator. + // + // Since: cosmos-sdk 0.46 CancelUnbondingDelegation(ctx context.Context, in *MsgCancelUnbondingDelegation, opts ...grpc.CallOption) (*MsgCancelUnbondingDelegationResponse, error) } @@ -121,6 +123,8 @@ type MsgServer interface { Undelegate(context.Context, *MsgUndelegate) (*MsgUndelegateResponse, error) // CancelUnbondingDelegation defines a method for performing canceling the unbonding delegation // and delegate back to previous validator. + // + // Since: cosmos-sdk 0.46 CancelUnbondingDelegation(context.Context, *MsgCancelUnbondingDelegation) (*MsgCancelUnbondingDelegationResponse, error) mustEmbedUnimplementedMsgServer() } diff --git a/api/cosmos/tx/signing/v1beta1/signing.pulsar.go b/api/cosmos/tx/signing/v1beta1/signing.pulsar.go index 2f4ee5d2153f..6920cd0dc1f5 100644 --- a/api/cosmos/tx/signing/v1beta1/signing.pulsar.go +++ b/api/cosmos/tx/signing/v1beta1/signing.pulsar.go @@ -2,9 +2,9 @@ package signingv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/crypto/multisig/v1beta1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/crypto/multisig/v1beta1" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" protoimpl "google.golang.org/protobuf/runtime/protoimpl" @@ -2738,7 +2738,13 @@ const ( // 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 + // 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 SignMode_SIGN_MODE_EIP_191 SignMode = 191 ) @@ -3118,12 +3124,11 @@ var file_cosmos_tx_signing_v1beta1_signing_proto_rawDesc = []byte{ 0x1b, 0x53, 0x49, 0x47, 0x4e, 0x5f, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x4c, 0x45, 0x47, 0x41, 0x43, 0x59, 0x5f, 0x41, 0x4d, 0x49, 0x4e, 0x4f, 0x5f, 0x4a, 0x53, 0x4f, 0x4e, 0x10, 0x7f, 0x12, 0x16, 0x0a, 0x11, 0x53, 0x49, 0x47, 0x4e, 0x5f, 0x4d, 0x4f, 0x44, 0x45, 0x5f, 0x45, 0x49, 0x50, 0x5f, - 0x31, 0x39, 0x31, 0x10, 0xbf, 0x01, 0x42, 0xff, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, + 0x31, 0x39, 0x31, 0x10, 0xbf, 0x01, 0x42, 0xef, 0x01, 0x0a, 0x1d, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x53, 0x69, 0x67, 0x6e, 0x69, 0x6e, - 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x49, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x39, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, 0x2f, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x73, 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, 0x53, 0xaa, 0x02, 0x19, 0x43, 0x6f, 0x73, 0x6d, diff --git a/api/cosmos/tx/v1beta1/service.pulsar.go b/api/cosmos/tx/v1beta1/service.pulsar.go index ec4afdbe92bd..deb06a619cd5 100644 --- a/api/cosmos/tx/v1beta1/service.pulsar.go +++ b/api/cosmos/tx/v1beta1/service.pulsar.go @@ -2,11 +2,11 @@ package txv1beta1 import ( + v1beta11 "cosmossdk.io/api/cosmos/base/abci/v1beta1" + v1beta1 "cosmossdk.io/api/cosmos/base/query/v1beta1" + types "cosmossdk.io/api/tendermint/types" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta11 "github.com/cosmos/cosmos-sdk/api/cosmos/base/abci/v1beta1" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" - types "github.com/cosmos/cosmos-sdk/api/tendermint/types" _ "google.golang.org/genproto/googleapis/api/annotations" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -6176,11 +6176,10 @@ var file_cosmos_tx_v1beta1_service_proto_rawDesc = []byte{ 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2d, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x27, 0x12, 0x25, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x74, 0x78, 0x73, 0x2f, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x2f, 0x7b, 0x68, 0x65, 0x69, - 0x67, 0x68, 0x74, 0x7d, 0x42, 0xc9, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, + 0x67, 0x68, 0x74, 0x7d, 0x42, 0xb9, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, - 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, + 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2c, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x78, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, 0x58, 0xaa, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x54, 0x78, 0x2e, 0x56, diff --git a/api/cosmos/tx/v1beta1/tx.pulsar.go b/api/cosmos/tx/v1beta1/tx.pulsar.go index d39c5e6efe46..4aafaae31e4f 100644 --- a/api/cosmos/tx/v1beta1/tx.pulsar.go +++ b/api/cosmos/tx/v1beta1/tx.pulsar.go @@ -2,12 +2,12 @@ package txv1beta1 import ( + v1beta12 "cosmossdk.io/api/cosmos/base/v1beta1" + v1beta11 "cosmossdk.io/api/cosmos/crypto/multisig/v1beta1" + v1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta12 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" - v1beta11 "github.com/cosmos/cosmos-sdk/api/cosmos/crypto/multisig/v1beta1" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/tx/signing/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -8814,11 +8814,11 @@ type AuxSignerData struct { // AuxSignerData across different chains, the bech32 prefix of the target // chain (where the final transaction is broadcasted) should be used. Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - // sign_doc is the SIGN_MOD_DIRECT_AUX sign doc that the auxiliary signer + // sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the auxiliary signer // signs. Note: we use the same sign doc even if we're signing with // LEGACY_AMINO_JSON. SignDoc *SignDocDirectAux `protobuf:"bytes,2,opt,name=sign_doc,json=signDoc,proto3" json:"sign_doc,omitempty"` - // mode is the signing mode of the single signer + // mode is the signing mode of the single signer. Mode v1beta1.SignMode `protobuf:"varint,3,opt,name=mode,proto3,enum=cosmos.tx.signing.v1beta1.SignMode" json:"mode,omitempty"` // sig is the signature of the sign doc. Sig []byte `protobuf:"bytes,4,opt,name=sig,proto3" json:"sig,omitempty"` @@ -9114,11 +9114,10 @@ var file_cosmos_tx_v1beta1_tx_proto_rawDesc = []byte{ 0x69, 0x67, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, 0x67, 0x6e, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x6d, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x03, 0x73, 0x69, 0x67, 0x42, - 0xc4, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, + 0xb4, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x3c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, + 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2c, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x74, 0x78, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x54, 0x58, 0xaa, 0x02, 0x11, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x54, 0x78, 0x2e, 0x56, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xca, 0x02, 0x11, 0x43, diff --git a/api/cosmos/upgrade/v1beta1/query.pulsar.go b/api/cosmos/upgrade/v1beta1/query.pulsar.go index 742960c8a6e0..ec2d4738f74f 100644 --- a/api/cosmos/upgrade/v1beta1/query.pulsar.go +++ b/api/cosmos/upgrade/v1beta1/query.pulsar.go @@ -4635,11 +4635,10 @@ var file_cosmos_upgrade_v1beta1_query_proto_rawDesc = []byte{ 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x29, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x23, 0x12, 0x21, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x61, 0x75, 0x74, 0x68, 0x6f, - 0x72, 0x69, 0x74, 0x79, 0x42, 0xea, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, + 0x72, 0x69, 0x74, 0x79, 0x42, 0xda, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, - 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, + 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x55, 0x58, 0xaa, diff --git a/api/cosmos/upgrade/v1beta1/query_grpc.pb.go b/api/cosmos/upgrade/v1beta1/query_grpc.pb.go index 69626cd2fbdb..b8c7cb3dbb1f 100644 --- a/api/cosmos/upgrade/v1beta1/query_grpc.pb.go +++ b/api/cosmos/upgrade/v1beta1/query_grpc.pb.go @@ -39,6 +39,8 @@ type QueryClient interface { // Since: cosmos-sdk 0.43 ModuleVersions(ctx context.Context, in *QueryModuleVersionsRequest, opts ...grpc.CallOption) (*QueryModuleVersionsResponse, error) // Returns the account with authority to conduct upgrades + // + // Since: cosmos-sdk 0.46 Authority(ctx context.Context, in *QueryAuthorityRequest, opts ...grpc.CallOption) (*QueryAuthorityResponse, error) } @@ -117,6 +119,8 @@ type QueryServer interface { // Since: cosmos-sdk 0.43 ModuleVersions(context.Context, *QueryModuleVersionsRequest) (*QueryModuleVersionsResponse, error) // Returns the account with authority to conduct upgrades + // + // Since: cosmos-sdk 0.46 Authority(context.Context, *QueryAuthorityRequest) (*QueryAuthorityResponse, error) mustEmbedUnimplementedQueryServer() } diff --git a/api/cosmos/upgrade/v1beta1/tx.pulsar.go b/api/cosmos/upgrade/v1beta1/tx.pulsar.go index a042d5c25772..0410fa81fc9a 100644 --- a/api/cosmos/upgrade/v1beta1/tx.pulsar.go +++ b/api/cosmos/upgrade/v1beta1/tx.pulsar.go @@ -2,10 +2,10 @@ package upgradev1beta1 import ( + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -1646,6 +1646,8 @@ func (x *fastReflection_MsgCancelUpgradeResponse) ProtoMethods() *protoiface.Met } } +// Since: cosmos-sdk 0.46 + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -1850,12 +1852,11 @@ var file_cosmos_upgrade_v1beta1_tx_proto_rawDesc = []byte{ 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x1a, 0x30, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x55, - 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xe7, + 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xd7, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x07, 0x54, - 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x55, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, diff --git a/api/cosmos/upgrade/v1beta1/upgrade.pulsar.go b/api/cosmos/upgrade/v1beta1/upgrade.pulsar.go index 16d231f8347b..63b1502fe9a9 100644 --- a/api/cosmos/upgrade/v1beta1/upgrade.pulsar.go +++ b/api/cosmos/upgrade/v1beta1/upgrade.pulsar.go @@ -2524,11 +2524,10 @@ var file_cosmos_upgrade_v1beta1_upgrade_proto_rawDesc = []byte{ 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x08, 0x98, 0xa0, 0x1f, 0x01, 0xe8, - 0xa0, 0x1f, 0x01, 0x42, 0xf0, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0xa0, 0x1f, 0x01, 0x42, 0xe0, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x55, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, + 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x75, 0x70, 0x67, 0x72, 0x61, 0x64, 0x65, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x55, 0x58, diff --git a/api/cosmos/vesting/v1beta1/tx.pulsar.go b/api/cosmos/vesting/v1beta1/tx.pulsar.go index 32f2db2779f9..bdd73bd28b68 100644 --- a/api/cosmos/vesting/v1beta1/tx.pulsar.go +++ b/api/cosmos/vesting/v1beta1/tx.pulsar.go @@ -2,11 +2,11 @@ package vestingv1beta1 import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + _ "cosmossdk.io/api/cosmos/msg/v1" fmt "fmt" _ "github.com/cosmos/cosmos-proto" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" - _ "github.com/cosmos/cosmos-sdk/api/cosmos/msg/v1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -3211,6 +3211,8 @@ func (*MsgCreateVestingAccountResponse) Descriptor() ([]byte, []int) { // MsgCreatePermanentLockedAccount defines a message that enables creating a permanent // locked account. +// +// Since: cosmos-sdk 0.46 type MsgCreatePermanentLockedAccount struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -3263,6 +3265,8 @@ func (x *MsgCreatePermanentLockedAccount) GetAmount() []*v1beta1.Coin { } // MsgCreatePermanentLockedAccountResponse defines the Msg/CreatePermanentLockedAccount response type. +// +// Since: cosmos-sdk 0.46 type MsgCreatePermanentLockedAccountResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -3291,6 +3295,8 @@ func (*MsgCreatePermanentLockedAccountResponse) Descriptor() ([]byte, []int) { // MsgCreateVestingAccount defines a message that enables creating a vesting // account. +// +// Since: cosmos-sdk 0.46 type MsgCreatePeriodicVestingAccount struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -3352,6 +3358,8 @@ func (x *MsgCreatePeriodicVestingAccount) GetVestingPeriods() []*Period { // MsgCreateVestingAccountResponse defines the Msg/CreatePeriodicVestingAccount // response type. +// +// Since: cosmos-sdk 0.46 type MsgCreatePeriodicVestingAccountResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -3480,11 +3488,10 @@ var file_cosmos_vesting_v1beta1_tx_proto_rawDesc = []byte{ 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x69, 0x63, 0x56, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0xe7, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x65, 0x42, 0xd7, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x76, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, - 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x46, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, + 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x76, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x76, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x56, 0x58, 0xaa, 0x02, 0x16, 0x43, 0x6f, 0x73, diff --git a/api/cosmos/vesting/v1beta1/tx_grpc.pb.go b/api/cosmos/vesting/v1beta1/tx_grpc.pb.go index 0bf68137e9c8..02814722c7dc 100644 --- a/api/cosmos/vesting/v1beta1/tx_grpc.pb.go +++ b/api/cosmos/vesting/v1beta1/tx_grpc.pb.go @@ -27,9 +27,13 @@ type MsgClient interface { CreateVestingAccount(ctx context.Context, in *MsgCreateVestingAccount, opts ...grpc.CallOption) (*MsgCreateVestingAccountResponse, error) // CreatePermanentLockedAccount defines a method that enables creating a permanent // locked account. + // + // Since: cosmos-sdk 0.46 CreatePermanentLockedAccount(ctx context.Context, in *MsgCreatePermanentLockedAccount, opts ...grpc.CallOption) (*MsgCreatePermanentLockedAccountResponse, error) // CreatePeriodicVestingAccount defines a method that enables creating a // periodic vesting account. + // + // Since: cosmos-sdk 0.46 CreatePeriodicVestingAccount(ctx context.Context, in *MsgCreatePeriodicVestingAccount, opts ...grpc.CallOption) (*MsgCreatePeriodicVestingAccountResponse, error) } @@ -77,9 +81,13 @@ type MsgServer interface { CreateVestingAccount(context.Context, *MsgCreateVestingAccount) (*MsgCreateVestingAccountResponse, error) // CreatePermanentLockedAccount defines a method that enables creating a permanent // locked account. + // + // Since: cosmos-sdk 0.46 CreatePermanentLockedAccount(context.Context, *MsgCreatePermanentLockedAccount) (*MsgCreatePermanentLockedAccountResponse, error) // CreatePeriodicVestingAccount defines a method that enables creating a // periodic vesting account. + // + // Since: cosmos-sdk 0.46 CreatePeriodicVestingAccount(context.Context, *MsgCreatePeriodicVestingAccount) (*MsgCreatePeriodicVestingAccountResponse, error) mustEmbedUnimplementedMsgServer() } diff --git a/api/cosmos/vesting/v1beta1/vesting.pulsar.go b/api/cosmos/vesting/v1beta1/vesting.pulsar.go index 56fa413d811b..b4f946b0987a 100644 --- a/api/cosmos/vesting/v1beta1/vesting.pulsar.go +++ b/api/cosmos/vesting/v1beta1/vesting.pulsar.go @@ -2,10 +2,10 @@ package vestingv1beta1 import ( + v1beta11 "cosmossdk.io/api/cosmos/auth/v1beta1" + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta11 "github.com/cosmos/cosmos-sdk/api/cosmos/auth/v1beta1" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -3825,11 +3825,10 @@ var file_cosmos_vesting_v1beta1_vesting_proto_rawDesc = []byte{ 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x04, 0xd0, 0xde, 0x1f, 0x01, 0x52, 0x12, 0x62, 0x61, 0x73, 0x65, 0x56, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x3a, 0x08, 0x88, 0xa0, 0x1f, 0x00, 0x98, 0xa0, 0x1f, - 0x00, 0x42, 0xec, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x00, 0x42, 0xdc, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x76, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x42, 0x0c, 0x56, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, - 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, + 0x5a, 0x36, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x76, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x3b, 0x76, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0xa2, 0x02, 0x03, 0x43, 0x56, 0x58, 0xaa, 0x02, diff --git a/api/go.mod b/api/go.mod index 88704c18b38e..140a0cf95713 100644 --- a/api/go.mod +++ b/api/go.mod @@ -1,12 +1,12 @@ -module github.com/cosmos/cosmos-sdk/api +module cosmossdk.io/api -go 1.17 +go 1.18 require ( github.com/cosmos/cosmos-proto v1.0.0-alpha7 github.com/gogo/protobuf v1.3.2 google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb - google.golang.org/grpc v1.45.0 + google.golang.org/grpc v1.46.2 google.golang.org/protobuf v1.28.0 ) diff --git a/api/go.sum b/api/go.sum index fb206487a5ba..7442b632d3ee 100644 --- a/api/go.sum +++ b/api/go.sum @@ -11,8 +11,8 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= @@ -22,7 +22,7 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -100,6 +100,7 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -136,8 +137,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8 google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= 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= diff --git a/api/tendermint/abci/types.pulsar.go b/api/tendermint/abci/types.pulsar.go index da32b60a7402..25815c59ee2f 100644 --- a/api/tendermint/abci/types.pulsar.go +++ b/api/tendermint/abci/types.pulsar.go @@ -2,10 +2,10 @@ package abci import ( + crypto "cosmossdk.io/api/tendermint/crypto" + types "cosmossdk.io/api/tendermint/types" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - crypto "github.com/cosmos/cosmos-sdk/api/tendermint/crypto" - types "github.com/cosmos/cosmos-sdk/api/tendermint/types" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -30333,11 +30333,10 @@ var file_tendermint_abci_types_proto_rawDesc = []byte{ 0x68, 0x6f, 0x74, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x1a, 0x2b, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x61, 0x62, 0x63, 0x69, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x53, 0x6e, 0x61, 0x70, 0x73, 0x68, 0x6f, 0x74, - 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x42, 0xb0, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, + 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x42, 0xa0, 0x01, 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x61, 0x62, 0x63, 0x69, 0x42, 0x0a, 0x54, - 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, + 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x20, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x61, 0x62, 0x63, 0x69, 0xa2, 0x02, 0x03, 0x54, 0x41, 0x58, 0xaa, 0x02, 0x0f, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x41, 0x62, 0x63, 0x69, 0xca, 0x02, 0x0f, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, diff --git a/api/tendermint/crypto/keys.pulsar.go b/api/tendermint/crypto/keys.pulsar.go index 956c671974a9..59a1fba64b9f 100644 --- a/api/tendermint/crypto/keys.pulsar.go +++ b/api/tendermint/crypto/keys.pulsar.go @@ -638,11 +638,10 @@ var file_tendermint_crypto_keys_proto_rawDesc = []byte{ 0x12, 0x1e, 0x0a, 0x09, 0x73, 0x65, 0x63, 0x70, 0x32, 0x35, 0x36, 0x6b, 0x31, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x09, 0x73, 0x65, 0x63, 0x70, 0x32, 0x35, 0x36, 0x6b, 0x31, 0x3a, 0x08, 0xe8, 0xa0, 0x1f, 0x01, 0xe8, 0xa1, 0x1f, 0x01, 0x42, 0x05, 0x0a, 0x03, 0x73, 0x75, - 0x6d, 0x42, 0xbb, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x6d, 0x42, 0xab, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x42, 0x09, 0x4b, 0x65, 0x79, - 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, - 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, + 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0xa2, 0x02, 0x03, 0x54, 0x43, 0x58, 0xaa, 0x02, 0x11, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0xca, 0x02, 0x11, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, diff --git a/api/tendermint/crypto/proof.pulsar.go b/api/tendermint/crypto/proof.pulsar.go index 6171f92e59a4..9a934eb0fa72 100644 --- a/api/tendermint/crypto/proof.pulsar.go +++ b/api/tendermint/crypto/proof.pulsar.go @@ -3039,12 +3039,11 @@ var file_tendermint_crypto_proof_proto_rawDesc = []byte{ 0x0a, 0x08, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x4f, 0x70, 0x73, 0x12, 0x32, 0x0a, 0x03, 0x6f, 0x70, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x6f, - 0x66, 0x4f, 0x70, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x03, 0x6f, 0x70, 0x73, 0x42, 0xbc, + 0x66, 0x4f, 0x70, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x03, 0x6f, 0x70, 0x73, 0x42, 0xac, 0x01, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x42, 0x0a, 0x50, 0x72, 0x6f, 0x6f, 0x66, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x22, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x63, 0x72, 0x79, 0x70, 0x74, 0x6f, 0xa2, 0x02, 0x03, 0x54, 0x43, 0x58, 0xaa, 0x02, 0x11, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0xca, 0x02, 0x11, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, diff --git a/api/tendermint/libs/bits/types.pulsar.go b/api/tendermint/libs/bits/types.pulsar.go index df60fe39b4c3..652d5c9366a5 100644 --- a/api/tendermint/libs/bits/types.pulsar.go +++ b/api/tendermint/libs/bits/types.pulsar.go @@ -661,12 +661,11 @@ var file_tendermint_libs_bits_types_proto_rawDesc = []byte{ 0x69, 0x62, 0x73, 0x2e, 0x62, 0x69, 0x74, 0x73, 0x22, 0x34, 0x0a, 0x08, 0x42, 0x69, 0x74, 0x41, 0x72, 0x72, 0x61, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x69, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x62, 0x69, 0x74, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6c, 0x65, 0x6d, - 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x04, 0x52, 0x05, 0x65, 0x6c, 0x65, 0x6d, 0x73, 0x42, 0xcf, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x04, 0x52, 0x05, 0x65, 0x6c, 0x65, 0x6d, 0x73, 0x42, 0xbf, 0x01, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x6c, 0x69, 0x62, 0x73, 0x2e, 0x62, 0x69, 0x74, 0x73, 0x42, 0x0a, 0x54, 0x79, 0x70, - 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, - 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, + 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x25, 0x63, 0x6f, 0x73, 0x6d, 0x6f, + 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x6c, 0x69, 0x62, 0x73, 0x2f, 0x62, 0x69, 0x74, 0x73, 0xa2, 0x02, 0x03, 0x54, 0x4c, 0x42, 0xaa, 0x02, 0x14, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x4c, 0x69, 0x62, 0x73, 0x2e, 0x42, 0x69, 0x74, 0x73, 0xca, 0x02, 0x14, diff --git a/api/tendermint/p2p/types.pulsar.go b/api/tendermint/p2p/types.pulsar.go index 8176cb8a9acd..43e74c353091 100644 --- a/api/tendermint/p2p/types.pulsar.go +++ b/api/tendermint/p2p/types.pulsar.go @@ -3536,11 +3536,10 @@ var file_tendermint_p2p_types_proto_rawDesc = []byte{ 0x74, 0x44, 0x69, 0x61, 0x6c, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x64, 0x69, 0x61, 0x6c, 0x5f, 0x66, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0c, 0x64, 0x69, 0x61, 0x6c, 0x46, 0x61, 0x69, 0x6c, 0x75, 0x72, 0x65, - 0x73, 0x42, 0xaa, 0x01, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, + 0x73, 0x42, 0x9a, 0x01, 0x0a, 0x12, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x70, 0x32, 0x70, 0x42, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x1f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x70, 0x32, 0x70, 0xa2, 0x02, 0x03, 0x54, 0x50, 0x58, 0xaa, 0x02, 0x0e, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x50, 0x32, 0x70, 0xca, 0x02, 0x0e, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x5c, 0x50, 0x32, 0x70, 0xe2, diff --git a/api/tendermint/types/block.pulsar.go b/api/tendermint/types/block.pulsar.go index 9639ebe621cb..f40331701f66 100644 --- a/api/tendermint/types/block.pulsar.go +++ b/api/tendermint/types/block.pulsar.go @@ -783,11 +783,10 @@ var file_tendermint_types_block_proto_rawDesc = []byte{ 0x61, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x0a, 0x6c, 0x61, 0x73, 0x74, - 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x42, 0xb6, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, + 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x42, 0xa6, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x42, - 0x0a, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x0a, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0xa2, 0x02, 0x03, 0x54, 0x54, 0x58, 0xaa, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x73, 0xca, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, diff --git a/api/tendermint/types/evidence.pulsar.go b/api/tendermint/types/evidence.pulsar.go index 8e27a6b0fe89..e05e4cee6184 100644 --- a/api/tendermint/types/evidence.pulsar.go +++ b/api/tendermint/types/evidence.pulsar.go @@ -2846,11 +2846,10 @@ var file_tendermint_types_evidence_proto_rawDesc = []byte{ 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x2e, 0x45, 0x76, 0x69, 0x64, 0x65, 0x6e, 0x63, 0x65, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x08, 0x65, 0x76, 0x69, 0x64, 0x65, 0x6e, - 0x63, 0x65, 0x42, 0xb9, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, + 0x63, 0x65, 0x42, 0xa9, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x42, 0x0d, 0x45, 0x76, 0x69, - 0x64, 0x65, 0x6e, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, - 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, + 0x64, 0x65, 0x6e, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0xa2, 0x02, 0x03, 0x54, 0x54, 0x58, 0xaa, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x73, 0xca, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, 0x65, diff --git a/api/tendermint/types/params.pulsar.go b/api/tendermint/types/params.pulsar.go index 050500b6fcc2..dfba5e23f085 100644 --- a/api/tendermint/types/params.pulsar.go +++ b/api/tendermint/types/params.pulsar.go @@ -3427,12 +3427,11 @@ var file_tendermint_types_params_proto_rawDesc = []byte{ 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0d, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x6d, 0x61, 0x78, 0x5f, 0x67, 0x61, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x47, 0x61, 0x73, 0x42, 0xbb, + 0x03, 0x52, 0x0b, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x47, 0x61, 0x73, 0x42, 0xab, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x42, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x50, - 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, + 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0xa2, 0x02, 0x03, 0x54, 0x54, 0x58, 0xaa, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x73, 0xca, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x5c, diff --git a/api/tendermint/types/types.pulsar.go b/api/tendermint/types/types.pulsar.go index ad92c06a38e3..cff75f4ba542 100644 --- a/api/tendermint/types/types.pulsar.go +++ b/api/tendermint/types/types.pulsar.go @@ -2,10 +2,10 @@ package types import ( + crypto "cosmossdk.io/api/tendermint/crypto" + version "cosmossdk.io/api/tendermint/version" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - crypto "github.com/cosmos/cosmos-sdk/api/tendermint/crypto" - version "github.com/cosmos/cosmos-sdk/api/tendermint/version" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -9555,11 +9555,10 @@ var file_tendermint_types_types_proto_rawDesc = []byte{ 0x47, 0x4e, 0x45, 0x44, 0x5f, 0x4d, 0x53, 0x47, 0x5f, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x50, 0x52, 0x4f, 0x50, 0x4f, 0x53, 0x41, 0x4c, 0x10, 0x20, 0x1a, 0x10, 0x8a, 0x9d, 0x20, 0x0c, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x54, 0x79, 0x70, 0x65, 0x1a, 0x08, 0x88, 0xa3, 0x1e, 0x00, - 0xa8, 0xa4, 0x1e, 0x01, 0x42, 0xb6, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, + 0xa8, 0xa4, 0x1e, 0x01, 0x42, 0xa6, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x42, 0x0a, 0x54, - 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, - 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, + 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0xa2, 0x02, 0x03, 0x54, 0x54, 0x58, 0xaa, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x73, 0xca, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, diff --git a/api/tendermint/types/validator.pulsar.go b/api/tendermint/types/validator.pulsar.go index c7386b03783f..ca3ea4d754ed 100644 --- a/api/tendermint/types/validator.pulsar.go +++ b/api/tendermint/types/validator.pulsar.go @@ -2,9 +2,9 @@ package types import ( + crypto "cosmossdk.io/api/tendermint/crypto" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - crypto "github.com/cosmos/cosmos-sdk/api/tendermint/crypto" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" @@ -1920,11 +1920,10 @@ var file_tendermint_types_validator_proto_rawDesc = []byte{ 0x63, 0x4b, 0x65, 0x79, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x76, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x70, 0x6f, 0x77, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x76, 0x6f, 0x74, 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x77, 0x65, 0x72, 0x42, - 0xba, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, + 0xaa, 0x01, 0x0a, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x74, 0x79, 0x70, 0x65, 0x73, 0x42, 0x0e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, - 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, - 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, + 0x74, 0x6f, 0x72, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x74, 0x79, 0x70, 0x65, 0x73, 0xa2, 0x02, 0x03, 0x54, 0x54, 0x58, 0xaa, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x73, 0xca, 0x02, 0x10, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, diff --git a/api/tendermint/version/types.pulsar.go b/api/tendermint/version/types.pulsar.go index 3c4236409cd4..72c65fdf2d25 100644 --- a/api/tendermint/version/types.pulsar.go +++ b/api/tendermint/version/types.pulsar.go @@ -1053,11 +1053,10 @@ var file_tendermint_version_types_proto_rawDesc = []byte{ 0x73, 0x65, 0x6e, 0x73, 0x75, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x05, 0x62, 0x6c, 0x6f, 0x63, 0x6b, 0x12, 0x10, 0x0a, 0x03, 0x61, 0x70, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x61, 0x70, 0x70, 0x3a, 0x04, - 0xe8, 0xa0, 0x1f, 0x01, 0x42, 0xc2, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, + 0xe8, 0xa0, 0x1f, 0x01, 0x42, 0xb2, 0x01, 0x0a, 0x16, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, - 0x0a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x61, 0x70, 0x69, 0x2f, + 0x0a, 0x54, 0x79, 0x70, 0x65, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x23, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2f, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0xa2, 0x02, 0x03, 0x54, 0x56, 0x58, 0xaa, 0x02, 0x12, 0x54, 0x65, 0x6e, 0x64, 0x65, 0x72, 0x6d, 0x69, 0x6e, 0x74, 0x2e, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0xca, 0x02, 0x12, diff --git a/baseapp/abci.go b/baseapp/abci.go index f599d215dc62..29680cb86b31 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -17,9 +17,17 @@ import ( "github.com/cosmos/cosmos-sdk/codec" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" + "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" +) + +// Supported ABCI Query prefixes +const ( + QueryPathApp = "app" + QueryPathCustom = "custom" + QueryPathP2P = "p2p" + QueryPathStore = "store" ) // InitChain implements the ABCI interface. It runs the initialization logic @@ -201,7 +209,6 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg // EndBlock implements the ABCI interface. func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBlock) { - if app.deliverState.ms.TracingEnabled() { app.deliverState.ms.SetTracingContext(nil) } @@ -232,7 +239,6 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc // will contain releveant error information. Regardless of tx execution outcome, // the ResponseCheckTx will contain relevant gas execution context. func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { - var mode runTxMode switch { @@ -246,18 +252,19 @@ func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { panic(fmt.Sprintf("unknown RequestCheckTx type: %s", req.Type)) } - ctx := app.getContextForTx(mode, req.Tx) - res, checkRes, err := app.txHandler.CheckTx(ctx, tx.Request{TxBytes: req.Tx}, tx.RequestCheckTx{Type: req.Type}) + gInfo, result, anteEvents, priority, err := app.runTx(mode, req.Tx) if err != nil { - return sdkerrors.ResponseCheckTx(err, uint64(res.GasUsed), uint64(res.GasWanted), app.trace) + return sdkerrors.ResponseCheckTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, anteEvents, app.trace) } - abciRes, err := convertTxResponseToCheckTx(res, checkRes) - if err != nil { - return sdkerrors.ResponseCheckTx(err, uint64(res.GasUsed), uint64(res.GasWanted), app.trace) + return abci.ResponseCheckTx{ + GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints? + GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints? + Log: result.Log, + Data: result.Data, + Events: sdk.MarkEventsToIndex(result.Events, app.indexEvents), + Priority: priority, } - - return abciRes } // DeliverTx implements the ABCI interface and executes a tx in DeliverTx mode. @@ -266,30 +273,29 @@ func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { // Regardless of tx execution outcome, the ResponseDeliverTx will contain relevant // gas execution context. func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx { + gInfo := sdk.GasInfo{} + resultStr := "successful" - var abciRes abci.ResponseDeliverTx defer func() { - for _, streamingListener := range app.abciListeners { - if err := streamingListener.ListenDeliverTx(app.deliverState.ctx, req, abciRes); err != nil { - app.logger.Error("DeliverTx listening hook failed", "err", err) - } - } + telemetry.IncrCounter(1, "tx", "count") + telemetry.IncrCounter(1, "tx", resultStr) + telemetry.SetGauge(float32(gInfo.GasUsed), "tx", "gas", "used") + telemetry.SetGauge(float32(gInfo.GasWanted), "tx", "gas", "wanted") }() - ctx := app.getContextForTx(runTxModeDeliver, req.Tx) - res, err := app.txHandler.DeliverTx(ctx, tx.Request{TxBytes: req.Tx}) + gInfo, result, anteEvents, _, err := app.runTx(runTxModeDeliver, req.Tx) if err != nil { - abciRes = sdkerrors.ResponseDeliverTx(err, uint64(res.GasUsed), uint64(res.GasWanted), app.trace) - return abciRes + resultStr = "failed" + return sdkerrors.ResponseDeliverTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, sdk.MarkEventsToIndex(anteEvents, app.indexEvents), app.trace) } - abciRes, err = convertTxResponseToDeliverTx(res) - if err != nil { - return sdkerrors.ResponseDeliverTx(err, uint64(res.GasUsed), uint64(res.GasWanted), app.trace) + return abci.ResponseDeliverTx{ + GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints? + GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints? + Log: result.Log, + Data: result.Data, + Events: sdk.MarkEventsToIndex(result.Events, app.indexEvents), } - - return abciRes - } // Commit implements the ABCI interface. It will commit all state that exists in @@ -300,7 +306,6 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx // against that height and gracefully halt if it matches the latest committed // height. func (app *BaseApp) Commit() (res abci.ResponseCommit) { - header := app.deliverState.ctx.BlockHeader() retainHeight := app.GetBlockRetentionHeight(header.Height) @@ -338,9 +343,7 @@ func (app *BaseApp) Commit() (res abci.ResponseCommit) { app.halt() } - if app.snapshotInterval > 0 && uint64(header.Height)%app.snapshotInterval == 0 { - go app.snapshot(header.Height) - } + go app.snapshotManager.SnapshotIfApplicable(header.Height) return abci.ResponseCommit{ Data: commitID.Hash, @@ -370,40 +373,9 @@ func (app *BaseApp) halt() { os.Exit(0) } -// snapshot takes a snapshot of the current state and prunes any old snapshottypes. -func (app *BaseApp) snapshot(height int64) { - if app.snapshotManager == nil { - app.logger.Info("snapshot manager not configured") - return - } - - app.logger.Info("creating state snapshot", "height", height) - - snapshot, err := app.snapshotManager.Create(uint64(height)) - if err != nil { - app.logger.Error("failed to create state snapshot", "height", height, "err", err) - return - } - - app.logger.Info("completed state snapshot", "height", height, "format", snapshot.Format) - - if app.snapshotKeepRecent > 0 { - app.logger.Debug("pruning state snapshots") - - pruned, err := app.snapshotManager.Prune(app.snapshotKeepRecent) - if err != nil { - app.logger.Error("Failed to prune state snapshots", "err", err) - return - } - - app.logger.Debug("pruned state snapshots", "pruned", pruned) - } -} - // Query implements the ABCI interface. It delegates to CommitMultiStore if it // implements Queryable. func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) { - // Add panic recovery for all queries. // ref: https://github.com/cosmos/cosmos-sdk/pull/8039 defer func() { @@ -423,23 +395,23 @@ func (app *BaseApp) Query(req abci.RequestQuery) (res abci.ResponseQuery) { return app.handleQueryGRPC(grpcHandler, req) } - path := splitPath(req.Path) + path := SplitABCIQueryPath(req.Path) if len(path) == 0 { sdkerrors.QueryResult(sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, "no query path provided"), app.trace) } switch path[0] { - // "/app" prefix for special application queries - case "app": + case QueryPathApp: + // "/app" prefix for special application queries return handleQueryApp(app, path, req) - case "store": + case QueryPathStore: return handleQueryStore(app, path, req) - case "p2p": + case QueryPathP2P: return handleQueryP2P(app, path) - case "custom": + case QueryPathCustom: return handleQueryCustom(app, path, req) } @@ -718,9 +690,11 @@ func (app *BaseApp) GetBlockRetentionHeight(commitHeight int64) int64 { retentionHeight = commitHeight - cp.Evidence.MaxAgeNumBlocks } - if app.snapshotInterval > 0 && app.snapshotKeepRecent > 0 { - v := commitHeight - int64((app.snapshotInterval * uint64(app.snapshotKeepRecent))) - retentionHeight = minNonZero(retentionHeight, v) + if app.snapshotManager != nil { + snapshotRetentionHeights := app.snapshotManager.GetSnapshotBlockRetentionHeights() + if snapshotRetentionHeights > 0 { + retentionHeight = minNonZero(retentionHeight, commitHeight-snapshotRetentionHeights) + } } v := commitHeight - int64(app.minRetainBlocks) @@ -869,10 +843,10 @@ func handleQueryCustom(app *BaseApp, path []string, req abci.RequestQuery) abci. } } -// splitPath splits a string path using the delimiter '/'. +// SplitABCIQueryPath splits a string path using the delimiter '/'. // // e.g. "this/is/funny" becomes []string{"this", "is", "funny"} -func splitPath(requestPath string) (path []string) { +func SplitABCIQueryPath(requestPath string) (path []string) { path = strings.Split(requestPath, "/") // first element is empty string @@ -882,37 +856,3 @@ func splitPath(requestPath string) (path []string) { return path } - -// makeABCIData generates the Data field to be sent to ABCI Check/DeliverTx. -func makeABCIData(txRes tx.Response) ([]byte, error) { - return proto.Marshal(&sdk.TxMsgData{MsgResponses: txRes.MsgResponses}) -} - -// convertTxResponseToCheckTx converts a tx.Response into a abci.ResponseCheckTx. -func convertTxResponseToCheckTx(txRes tx.Response, checkRes tx.ResponseCheckTx) (abci.ResponseCheckTx, error) { - data, err := makeABCIData(txRes) - if err != nil { - return abci.ResponseCheckTx{}, nil - } - - return abci.ResponseCheckTx{ - Data: data, - Log: txRes.Log, - Events: txRes.Events, - Priority: checkRes.Priority, - }, nil -} - -// convertTxResponseToDeliverTx converts a tx.Response into a abci.ResponseDeliverTx. -func convertTxResponseToDeliverTx(txRes tx.Response) (abci.ResponseDeliverTx, error) { - data, err := makeABCIData(txRes) - if err != nil { - return abci.ResponseDeliverTx{}, nil - } - - return abci.ResponseDeliverTx{ - Data: data, - Log: txRes.Log, - Events: txRes.Events, - }, nil -} diff --git a/baseapp/abci_test.go b/baseapp/abci_test.go index d43396108408..fa00c3d0abfc 100644 --- a/baseapp/abci_test.go +++ b/baseapp/abci_test.go @@ -1,4 +1,4 @@ -package baseapp_test +package baseapp import ( "testing" @@ -8,86 +8,96 @@ import ( tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmprototypes "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/db/memdb" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" + "github.com/cosmos/cosmos-sdk/snapshots" + snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" + "github.com/cosmos/cosmos-sdk/testutil" ) func TestGetBlockRentionHeight(t *testing.T) { logger := defaultLogger() name := t.Name() + snapshotStore, err := snapshots.NewStore(memdb.NewDB(), testutil.GetTempDir(t)) + require.NoError(t, err) + testCases := map[string]struct { - bapp *baseapp.BaseApp + bapp *BaseApp maxAgeBlocks int64 commitHeight int64 expected int64 }{ "defaults": { - bapp: baseapp.NewBaseApp(name, logger, memdb.NewDB()), + bapp: NewBaseApp(name, logger, memdb.NewDB(), nil), maxAgeBlocks: 0, commitHeight: 499000, expected: 0, }, "pruning unbonding time only": { - bapp: baseapp.NewBaseApp(name, logger, memdb.NewDB(), baseapp.SetMinRetainBlocks(1)), + bapp: NewBaseApp(name, logger, memdb.NewDB(), nil, SetMinRetainBlocks(1)), maxAgeBlocks: 362880, commitHeight: 499000, expected: 136120, }, "pruning iavl snapshot only": { - bapp: baseapp.NewBaseApp( - name, logger, memdb.NewDB(), - baseapp.SetMinRetainBlocks(1), + bapp: NewBaseApp( + name, logger, memdb.NewDB(), nil, + SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)), + SetMinRetainBlocks(1), + SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(10000, 1)), ), maxAgeBlocks: 0, commitHeight: 499000, - expected: 498999, + expected: 489000, }, "pruning state sync snapshot only": { - bapp: baseapp.NewBaseApp( - name, logger, memdb.NewDB(), - baseapp.SetSnapshotInterval(50000), - baseapp.SetSnapshotKeepRecent(3), - baseapp.SetMinRetainBlocks(1), + bapp: NewBaseApp( + name, logger, memdb.NewDB(), nil, + SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(50000, 3)), + SetMinRetainBlocks(1), ), maxAgeBlocks: 0, commitHeight: 499000, expected: 349000, }, "pruning min retention only": { - bapp: baseapp.NewBaseApp( - name, logger, memdb.NewDB(), - baseapp.SetMinRetainBlocks(400000), + bapp: NewBaseApp( + name, logger, memdb.NewDB(), nil, + SetMinRetainBlocks(400000), ), maxAgeBlocks: 0, commitHeight: 499000, expected: 99000, }, "pruning all conditions": { - bapp: baseapp.NewBaseApp( - name, logger, memdb.NewDB(), - baseapp.SetMinRetainBlocks(400000), - baseapp.SetSnapshotInterval(50000), baseapp.SetSnapshotKeepRecent(3), + bapp: NewBaseApp( + name, logger, memdb.NewDB(), nil, + SetPruning(pruningtypes.NewCustomPruningOptions(0, 0)), + SetMinRetainBlocks(400000), + SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(50000, 3)), ), maxAgeBlocks: 362880, commitHeight: 499000, expected: 99000, }, "no pruning due to no persisted state": { - bapp: baseapp.NewBaseApp( - name, logger, memdb.NewDB(), - baseapp.SetMinRetainBlocks(400000), - baseapp.SetSnapshotInterval(50000), baseapp.SetSnapshotKeepRecent(3), + bapp: NewBaseApp( + name, logger, memdb.NewDB(), nil, + SetPruning(pruningtypes.NewCustomPruningOptions(0, 0)), + SetMinRetainBlocks(400000), + SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(50000, 3)), ), maxAgeBlocks: 362880, commitHeight: 10000, expected: 0, }, "disable pruning": { - bapp: baseapp.NewBaseApp( - name, logger, memdb.NewDB(), - baseapp.SetMinRetainBlocks(0), - baseapp.SetSnapshotInterval(50000), baseapp.SetSnapshotKeepRecent(3), + bapp: NewBaseApp( + name, logger, memdb.NewDB(), nil, + SetPruning(pruningtypes.NewCustomPruningOptions(0, 0)), + SetMinRetainBlocks(0), + SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(50000, 3)), ), maxAgeBlocks: 362880, commitHeight: 499000, @@ -99,7 +109,6 @@ func TestGetBlockRentionHeight(t *testing.T) { tc := tc tc.bapp.SetParamStore(newParamStore(memdb.NewDB())) - require.NoError(t, tc.bapp.Init()) tc.bapp.InitChain(abci.RequestInitChain{ ConsensusParams: &tmprototypes.ConsensusParams{ Evidence: &tmprototypes.EvidenceParams{ @@ -125,7 +134,7 @@ func TestBaseAppCreateQueryContext(t *testing.T) { logger := defaultLogger() db := memdb.NewDB() name := t.Name() - app := baseapp.NewBaseApp(name, logger, db) + app := NewBaseApp(name, logger, db, nil) app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 1}}) app.Commit() @@ -147,7 +156,7 @@ func TestBaseAppCreateQueryContext(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - _, err := app.CreateQueryContext(tc.height, tc.prove) + _, err := app.createQueryContext(tc.height, tc.prove) if tc.expErr { require.Error(t, err) } else { diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 92651c1cc19f..1339779c4535 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -1,20 +1,24 @@ package baseapp import ( - "context" "fmt" + "strings" + "github.com/gogo/protobuf/proto" abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/crypto/tmhash" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" dbm "github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/snapshots" stypes "github.com/cosmos/cosmos-sdk/store/v2alpha1" "github.com/cosmos/cosmos-sdk/store/v2alpha1/multi" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" ) const ( @@ -27,9 +31,7 @@ const ( OptionOrderAfterStore ) -var ( - _ abci.Application = (*BaseApp)(nil) -) +var _ abci.Application = (*BaseApp)(nil) type ( // Enum mode for app.runTx @@ -67,11 +69,15 @@ type BaseApp struct { // nolint: maligned db dbm.DBConnection storeOpts []StoreOption // options to configure root store store sdk.CommitMultiStore // Main (uncached) state + router sdk.Router // handle any kind of legacy message queryRouter sdk.QueryRouter // router for redirecting query calls grpcQueryRouter *GRPCQueryRouter // router for redirecting gRPC query calls + msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages interfaceRegistry types.InterfaceRegistry + txDecoder sdk.TxDecoder // unmarshal []byte into sdk.Tx - txHandler tx.Handler // txHandler for {Deliver,Check}Tx and simulations + anteHandler sdk.AnteHandler // ante handler for fee and auth + postHandler sdk.AnteHandler // post handler, optional, e.g. for tips initChainer sdk.InitChainer // initialize state with validators and state blob beginBlocker sdk.BeginBlocker // logic to run before any txs endBlocker sdk.EndBlocker // logic to run after all txs, and to determine valset changes @@ -80,9 +86,7 @@ type BaseApp struct { // nolint: maligned fauxMerkleMode bool // if true, IAVL MountStores uses MountStoresDB for simulation speed. // manages snapshots, i.e. dumps of app state at certain intervals - snapshotManager *snapshots.Manager - snapshotInterval uint64 // block interval between state sync snapshots - snapshotKeepRecent uint32 // recent state sync snapshots to keep + snapshotManager *snapshots.Manager // volatile states: // @@ -136,6 +140,9 @@ type BaseApp struct { // nolint: maligned // if BaseApp is passed to the upgrade keeper's NewKeeper method. appVersion uint64 + // recovery handler for app.runTx method + runTxRecoveryMiddleware recoveryMiddleware + // trace set will return full stack traces for errors in ABCI Log field trace bool @@ -163,18 +170,18 @@ func (opt StoreOption) Order() OptionOrder { return OptionOrderDefault } // // NOTE: The db is used to store the version number for now. func NewBaseApp( - name string, - logger log.Logger, - db dbm.DBConnection, - options ...AppOption, + name string, logger log.Logger, db dbm.DBConnection, txDecoder sdk.TxDecoder, options ...AppOption, ) *BaseApp { app := &BaseApp{ - logger: logger, - name: name, - db: db, - queryRouter: NewQueryRouter(), - grpcQueryRouter: NewGRPCQueryRouter(), - fauxMerkleMode: false, + logger: logger, + name: name, + db: db, + router: NewRouter(), + queryRouter: NewQueryRouter(), + grpcQueryRouter: NewGRPCQueryRouter(), + msgServiceRouter: NewMsgServiceRouter(), + txDecoder: txDecoder, + fauxMerkleMode: false, } var afterStoreOpts []AppOption @@ -193,6 +200,9 @@ func NewBaseApp( for _, option := range afterStoreOpts { option.Apply(app) } + + app.runTxRecoveryMiddleware = newDefaultRecoveryMiddleware() + return app } @@ -238,6 +248,9 @@ func (app *BaseApp) loadStore() error { return nil } +// MsgServiceRouter returns the MsgServiceRouter of a BaseApp. +func (app *BaseApp) MsgServiceRouter() *MsgServiceRouter { return app.msgServiceRouter } + func (app *BaseApp) CloseStore() error { return app.store.Close() } @@ -252,8 +265,10 @@ func (app *BaseApp) LastBlockHeight() int64 { return app.store.LastCommitID().Version } -// Init sets the check state and seals the app. It will panic if -// called more than once on a running BaseApp. +// Init initializes the app. It seals the app, preventing any +// further modifications. In addition, it validates the app against +// the earlier provided settings. Returns an error if validation fails. +// nil otherwise. Panics if the app is already sealed. func (app *BaseApp) Init() error { if app.sealed { panic("cannot call Init: baseapp already sealed") @@ -262,7 +277,7 @@ func (app *BaseApp) Init() error { // needed for the export command which inits from store but never calls initchain app.setCheckState(tmproto.Header{}) app.Seal() - return nil + return app.store.GetPruning().Validate() } func (app *BaseApp) setMinGasPrices(gasPrices sdk.DecCoins) { @@ -293,6 +308,17 @@ func (app *BaseApp) setIndexEvents(ie []string) { } } +// Router returns the legacy router of the BaseApp. +func (app *BaseApp) Router() sdk.Router { + if app.sealed { + // We cannot return a Router when the app is sealed because we can't have + // any routes modified which would cause unexpected routing behavior. + panic("Router() on sealed BaseApp") + } + + return app.router +} + // QueryRouter returns the QueryRouter of a BaseApp. func (app *BaseApp) QueryRouter() sdk.QueryRouter { return app.queryRouter } @@ -359,6 +385,13 @@ func (app *BaseApp) GetConsensusParams(ctx sdk.Context) *tmproto.ConsensusParams return cp } +// AddRunTxRecoveryHandler adds custom app.runTx method panic handlers. +func (app *BaseApp) AddRunTxRecoveryHandler(handlers ...RecoveryHandler) { + for _, h := range handlers { + app.runTxRecoveryMiddleware = newRecoveryMiddleware(h, app.runTxRecoveryMiddleware) + } +} + // StoreConsensusParams sets the consensus parameters to the baseapp's param store. func (app *BaseApp) StoreConsensusParams(ctx sdk.Context, cp *tmproto.ConsensusParams) { if app.paramStore == nil { @@ -426,6 +459,22 @@ func (app *BaseApp) validateHeight(req abci.RequestBeginBlock) error { return nil } +// validateBasicTxMsgs executes basic validator calls for messages. +func validateBasicTxMsgs(msgs []sdk.Msg) error { + if len(msgs) == 0 { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "must contain at least one message") + } + + for _, msg := range msgs { + err := msg.ValidateBasic() + if err != nil { + return err + } + } + + return nil +} + // Returns the applications's deliverState if app is in runTxModeDeliver, // otherwise it returns the application's checkstate. func (app *BaseApp) getState(mode runTxMode) *state { @@ -437,7 +486,7 @@ func (app *BaseApp) getState(mode runTxMode) *state { } // retrieve the context for the tx w/ txBytes and other memoized values. -func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) context.Context { +func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) sdk.Context { ctx := app.getState(mode).ctx. WithTxBytes(txBytes). WithVoteInfos(app.voteInfos) @@ -452,5 +501,258 @@ func (app *BaseApp) getContextForTx(mode runTxMode, txBytes []byte) context.Cont ctx, _ = ctx.CacheContext() } - return sdk.WrapSDKContext(ctx) + return ctx +} + +// cacheTxContext returns a new context based off of the provided context with +// a branched multi-store. +func (app *BaseApp) cacheTxContext(ctx sdk.Context, txBytes []byte) (sdk.Context, sdk.CacheMultiStore) { + ms := ctx.MultiStore() + // TODO: https://github.com/cosmos/cosmos-sdk/issues/2824 + msCache := ms.CacheWrap() + if msCache.TracingEnabled() { + msCache.SetTracingContext( + sdk.TraceContext( + map[string]interface{}{ + "txHash": fmt.Sprintf("%X", tmhash.Sum(txBytes)), + }, + ), + ) + } + + return ctx.WithMultiStore(msCache), msCache +} + +// runTx processes a transaction within a given execution mode, encoded transaction +// bytes, and the decoded transaction itself. All state transitions occur through +// a cached Context depending on the mode provided. State only gets persisted +// if all messages get executed successfully and the execution mode is DeliverTx. +// Note, gas execution info is always returned. A reference to a Result is +// returned if the tx does not run out of gas and if all the messages are valid +// and execute successfully. An error is returned otherwise. +func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, result *sdk.Result, anteEvents []abci.Event, priority int64, err error) { + // NOTE: GasWanted should be returned by the AnteHandler. GasUsed is + // determined by the GasMeter. We need access to the context to get the gas + // meter so we initialize upfront. + var gasWanted uint64 + + ctx := app.getContextForTx(mode, txBytes) + ms := ctx.MultiStore() + + // only run the tx if there is block gas remaining + if mode == runTxModeDeliver && ctx.BlockGasMeter().IsOutOfGas() { + return gInfo, nil, nil, 0, sdkerrors.Wrap(sdkerrors.ErrOutOfGas, "no block gas left to run tx") + } + + defer func() { + if r := recover(); r != nil { + recoveryMW := newOutOfGasRecoveryMiddleware(gasWanted, ctx, app.runTxRecoveryMiddleware) + err, result = processRecovery(r, recoveryMW), nil + } + + gInfo = sdk.GasInfo{GasWanted: gasWanted, GasUsed: ctx.GasMeter().GasConsumed()} + }() + + blockGasConsumed := false + // consumeBlockGas makes sure block gas is consumed at most once. It must happen after + // tx processing, and must be execute even if tx processing fails. Hence we use trick with `defer` + consumeBlockGas := func() { + if !blockGasConsumed { + blockGasConsumed = true + ctx.BlockGasMeter().ConsumeGas( + ctx.GasMeter().GasConsumedToLimit(), "block gas meter", + ) + } + } + + // If BlockGasMeter() panics it will be caught by the above recover and will + // return an error - in any case BlockGasMeter will consume gas past the limit. + // + // NOTE: This must exist in a separate defer function for the above recovery + // to recover from this one. + if mode == runTxModeDeliver { + defer consumeBlockGas() + } + + tx, err := app.txDecoder(txBytes) + if err != nil { + return sdk.GasInfo{}, nil, nil, 0, err + } + + msgs := tx.GetMsgs() + if err := validateBasicTxMsgs(msgs); err != nil { + return sdk.GasInfo{}, nil, nil, 0, err + } + + if app.anteHandler != nil { + var ( + anteCtx sdk.Context + msCache sdk.CacheMultiStore + ) + + // Branch context before AnteHandler call in case it aborts. + // This is required for both CheckTx and DeliverTx. + // Ref: https://github.com/cosmos/cosmos-sdk/issues/2772 + // + // NOTE: Alternatively, we could require that AnteHandler ensures that + // writes do not happen if aborted/failed. This may have some + // performance benefits, but it'll be more difficult to get right. + anteCtx, msCache = app.cacheTxContext(ctx, txBytes) + anteCtx = anteCtx.WithEventManager(sdk.NewEventManager()) + newCtx, err := app.anteHandler(anteCtx, tx, mode == runTxModeSimulate) + + if !newCtx.IsZero() { + // At this point, newCtx.MultiStore() is a store branch, or something else + // replaced by the AnteHandler. We want the original multistore. + // + // Also, in the case of the tx aborting, we need to track gas consumed via + // the instantiated gas meter in the AnteHandler, so we update the context + // prior to returning. + ctx = newCtx.WithMultiStore(ms) + } + + events := ctx.EventManager().Events() + + // GasMeter expected to be set in AnteHandler + gasWanted = ctx.GasMeter().Limit() + + if err != nil { + return gInfo, nil, nil, 0, err + } + + priority = ctx.Priority() + msCache.Write() + anteEvents = events.ToABCIEvents() + } + + // Create a new Context based off of the existing Context with a MultiStore branch + // in case message processing fails. At this point, the MultiStore + // is a branch of a branch. + runMsgCtx, msCache := app.cacheTxContext(ctx, txBytes) + + // Attempt to execute all messages and only update state if all messages pass + // and we're in DeliverTx. Note, runMsgs will never return a reference to a + // Result if any single message fails or does not have a registered Handler. + result, err = app.runMsgs(runMsgCtx, msgs, mode) + if err == nil { + // Run optional postHandlers. + // + // Note: If the postHandler fails, we also revert the runMsgs state. + if app.postHandler != nil { + newCtx, err := app.postHandler(runMsgCtx, tx, mode == runTxModeSimulate) + if err != nil { + return gInfo, nil, nil, priority, err + } + + result.Events = append(result.Events, newCtx.EventManager().ABCIEvents()...) + } + + if mode == runTxModeDeliver { + // When block gas exceeds, it'll panic and won't commit the cached store. + consumeBlockGas() + + msCache.Write() + + if len(anteEvents) > 0 { + // append the events in the order of occurrence + result.Events = append(anteEvents, result.Events...) + } + } + } + + return gInfo, result, anteEvents, priority, err +} + +// runMsgs iterates through a list of messages and executes them with the provided +// Context and execution mode. Messages will only be executed during simulation +// and DeliverTx. An error is returned if any single message fails or if a +// Handler does not exist for a given message route. Otherwise, a reference to a +// Result is returned. The caller must not commit state if an error is returned. +func (app *BaseApp) runMsgs(ctx sdk.Context, msgs []sdk.Msg, mode runTxMode) (*sdk.Result, error) { + msgLogs := make(sdk.ABCIMessageLogs, 0, len(msgs)) + events := sdk.EmptyEvents() + var msgResponses []*codectypes.Any + + // NOTE: GasWanted is determined by the AnteHandler and GasUsed by the GasMeter. + for i, msg := range msgs { + // skip actual execution for (Re)CheckTx mode + if mode == runTxModeCheck || mode == runTxModeReCheck { + break + } + + var ( + msgResult *sdk.Result + eventMsgName string // name to use as value in event `message.action` + err error + ) + + if handler := app.msgServiceRouter.Handler(msg); handler != nil { + // ADR 031 request type routing + msgResult, err = handler(ctx, msg) + eventMsgName = sdk.MsgTypeURL(msg) + } else if legacyMsg, ok := msg.(legacytx.LegacyMsg); ok { + // legacy sdk.Msg routing + // Assuming that the app developer has migrated all their Msgs to + // proto messages and has registered all `Msg services`, then this + // path should never be called, because all those Msgs should be + // registered within the `msgServiceRouter` already. + msgRoute := legacyMsg.Route() + eventMsgName = legacyMsg.Type() + handler := app.router.Route(ctx, msgRoute) + if handler == nil { + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s; message index: %d", msgRoute, i) + } + + msgResult, err = handler(ctx, msg) + } else { + return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg) + } + + if err != nil { + return nil, sdkerrors.Wrapf(err, "failed to execute message; message index: %d", i) + } + + msgEvents := sdk.Events{ + sdk.NewEvent(sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyAction, eventMsgName)), + } + msgEvents = msgEvents.AppendEvents(msgResult.GetEvents()) + + // append message events, data and logs + // + // Note: Each message result's data must be length-prefixed in order to + // separate each result. + events = events.AppendEvents(msgEvents) + + // Each individual sdk.Result that went through the MsgServiceRouter + // (which should represent 99% of the Msgs now, since everyone should + // be using protobuf Msgs) has exactly one Msg response, set inside + // `WrapServiceResult`. We take that Msg response, and aggregate it + // into an array. + if len(msgResult.MsgResponses) > 0 { + msgResponse := msgResult.MsgResponses[0] + if msgResponse == nil { + return nil, sdkerrors.ErrLogic.Wrapf("got nil Msg response at index %d for msg %s", i, sdk.MsgTypeURL(msg)) + } + msgResponses = append(msgResponses, msgResponse) + } + + msgLogs = append(msgLogs, sdk.NewABCIMessageLog(uint32(i), msgResult.Log, msgEvents)) + } + + data, err := makeABCIData(msgResponses) + if err != nil { + return nil, sdkerrors.Wrap(err, "failed to marshal tx data") + } + + return &sdk.Result{ + Data: data, + Log: strings.TrimSpace(msgLogs.String()), + Events: events.ToABCIEvents(), + MsgResponses: msgResponses, + }, nil +} + +// makeABCIData generates the Data field to be sent to ABCI Check/DeliverTx. +func makeABCIData(msgResponses []*codectypes.Any) ([]byte, error) { + return proto.Marshal(&sdk.TxMsgData{MsgResponses: msgResponses}) } diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 5180b9129c52..acb60a92a0df 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -1,23 +1,16 @@ -package baseapp_test +package baseapp import ( "bytes" - "context" "encoding/binary" "encoding/json" "fmt" - "math" "math/rand" - "os" "strings" "sync" "testing" "time" - "google.golang.org/protobuf/proto" - - "github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar" - "github.com/gogo/protobuf/jsonpb" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -25,22 +18,20 @@ import ( "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" dbm "github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/db/memdb" - "github.com/cosmos/cosmos-sdk/simapp" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/snapshots" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" stypes "github.com/cosmos/cosmos-sdk/store/v2alpha1" "github.com/cosmos/cosmos-sdk/store/v2alpha1/multi" + "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" ) @@ -48,13 +39,11 @@ var ( capKey1 = sdk.NewKVStoreKey("key1") capKey2 = sdk.NewKVStoreKey("key2") - encCfg = simapp.MakeTestEncodingConfig() + // testTxPriority is the CheckTx priority that we set in the test + // antehandler. + testTxPriority = int64(42) ) -func init() { - registerTestCodec(encCfg.Amino) -} - type paramStore struct { db *memdb.MemDB rw dbm.DBReadWriter @@ -64,6 +53,14 @@ func newParamStore(db *memdb.MemDB) *paramStore { return ¶mStore{db: db, rw: db.ReadWriter()} } +type setupConfig struct { + blocks uint64 + blockTxs int + snapshotInterval uint64 + snapshotKeepRecent uint32 + pruningOpts pruningtypes.PruningOptions +} + func (ps *paramStore) Set(_ sdk.Context, key []byte, value interface{}) { bz, err := json.Marshal(value) if err != nil { @@ -98,35 +95,40 @@ func (ps *paramStore) Get(_ sdk.Context, key []byte, ptr interface{}) { } func defaultLogger() log.Logger { - logger, _ := log.NewDefaultLogger("plain", "info", false) - return logger.With("module", "sdk/app") + return log.MustNewDefaultLogger("plain", "info", false).With("module", "sdk/app") } -func newBaseApp(name string, options ...baseapp.AppOption) *baseapp.BaseApp { +func newBaseApp(name string, options ...AppOption) *BaseApp { logger := defaultLogger() db := memdb.NewDB() codec := codec.NewLegacyAmino() registerTestCodec(codec) - return baseapp.NewBaseApp(name, logger, db, options...) + return NewBaseApp(name, logger, db, testTxDecoder(codec), options...) } func registerTestCodec(cdc *codec.LegacyAmino) { + // register Tx, Msg + sdk.RegisterLegacyAminoCodec(cdc) + // register test types cdc.RegisterConcrete(&txTest{}, "cosmos-sdk/baseapp/txTest", nil) - legacy.RegisterAminoMsg(cdc, &msgCounter{}, "cosmos-sdk/baseapp/msgCounter") - legacy.RegisterAminoMsg(cdc, &msgCounter2{}, "cosmos-sdk/baseapp/msgCounter2") - legacy.RegisterAminoMsg(cdc, &msgKeyValue{}, "cosmos-sdk/baseapp/msgKeyValue") - legacy.RegisterAminoMsg(cdc, &msgNoRoute{}, "cosmos-sdk/baseapp/msgNoRoute") + cdc.RegisterConcrete(&msgCounter{}, "cosmos-sdk/baseapp/msgCounter", nil) + cdc.RegisterConcrete(&msgCounter2{}, "cosmos-sdk/baseapp/msgCounter2", nil) + cdc.RegisterConcrete(&msgKeyValue{}, "cosmos-sdk/baseapp/msgKeyValue", nil) + cdc.RegisterConcrete(&msgNoRoute{}, "cosmos-sdk/baseapp/msgNoRoute", nil) } // aminoTxEncoder creates a amino TxEncoder for testing purposes. -func aminoTxEncoder(cdc *codec.LegacyAmino) sdk.TxEncoder { +func aminoTxEncoder() sdk.TxEncoder { + cdc := codec.NewLegacyAmino() + registerTestCodec(cdc) + return legacytx.StdTxConfig{Cdc: cdc}.TxEncoder() } // simple one store baseapp -func setupBaseApp(t *testing.T, options ...baseapp.AppOption) *baseapp.BaseApp { - options = append(options, baseapp.SetSubstores(capKey1, capKey2)) +func setupBaseApp(t *testing.T, options ...AppOption) *BaseApp { + options = append(options, SetSubstores(capKey1, capKey2)) app := newBaseApp(t.Name(), options...) require.Equal(t, t.Name(), app.Name()) @@ -138,72 +140,34 @@ func setupBaseApp(t *testing.T, options ...baseapp.AppOption) *baseapp.BaseApp { return app } -// testTxHandler is a tx.Handler used for the mock app, it does not -// contain any signature verification logic. -func testTxHandler(options middleware.TxHandlerOptions, customTxHandlerMiddleware handlerFun) tx.Handler { - return middleware.ComposeMiddlewares( - middleware.NewRunMsgsTxHandler(options.MsgServiceRouter, options.LegacyRouter), - middleware.NewTxDecoderMiddleware(options.TxDecoder), - middleware.GasTxMiddleware, - middleware.RecoveryTxMiddleware, - middleware.NewIndexEventsTxMiddleware(options.IndexEvents), - middleware.ValidateBasicMiddleware, - middleware.ConsumeBlockGasMiddleware, - CustomTxHandlerMiddleware(customTxHandlerMiddleware), - ) -} - // simple one store baseapp with data and snapshots. Each tx is 1 MB in size (uncompressed). -func setupBaseAppWithSnapshots(t *testing.T, blocks uint, blockTxs int, options ...baseapp.AppOption) (*baseapp.BaseApp, func()) { +func setupBaseAppWithSnapshots(t *testing.T, config *setupConfig) (*BaseApp, error) { codec := codec.NewLegacyAmino() registerTestCodec(codec) - routerOpt := baseapp.AppOptionFunc(func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() - legacyRouter.AddRoute(sdk.NewRoute(routeMsgKeyValue, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + routerOpt := func(bapp *BaseApp) { + bapp.Router().AddRoute(sdk.NewRoute(routeMsgKeyValue, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { kv := msg.(*msgKeyValue) - bapp.Store().GetKVStore(capKey2).Set(kv.Key, kv.Value) - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return nil, err - } - - return &sdk.Result{ - MsgResponses: []*codectypes.Any{any}, - }, nil + bapp.store.GetKVStore(capKey2).Set(kv.Key, kv.Value) + return &sdk.Result{}, nil })) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { return ctx, nil }, - ) - bapp.SetTxHandler(txHandler) - }) + } - snapshotInterval := uint64(2) snapshotTimeout := 1 * time.Minute - snapshotDir, err := os.MkdirTemp("", "baseapp") - require.NoError(t, err) - snapshotStore, err := snapshots.NewStore(memdb.NewDB(), snapshotDir) + snapshotStore, err := snapshots.NewStore(memdb.NewDB(), testutil.GetTempDir(t)) require.NoError(t, err) - teardown := func() { - os.RemoveAll(snapshotDir) - } - app := setupBaseApp(t, append(options, - baseapp.SetSnapshotStore(snapshotStore), - baseapp.SetSnapshotInterval(snapshotInterval), - routerOpt)...) + app := setupBaseApp(t, + AppOptionFunc(routerOpt), + SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(config.snapshotInterval, uint32(config.snapshotKeepRecent))), + SetPruning(config.pruningOpts)) app.InitChain(abci.RequestInitChain{}) r := rand.New(rand.NewSource(3920758213583)) keyCounter := 0 - for height := int64(1); height <= int64(blocks); height++ { + for height := int64(1); height <= int64(config.blocks); height++ { app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: height}}) - for txNum := 0; txNum < blockTxs; txNum++ { + for txNum := 0; txNum < config.blockTxs; txNum++ { tx := txTest{Msgs: []sdk.Msg{}} for msgNum := 0; msgNum < 100; msgNum++ { key := []byte(fmt.Sprintf("%v", keyCounter)) @@ -213,7 +177,7 @@ func setupBaseAppWithSnapshots(t *testing.T, blocks uint, blockTxs int, options tx.Msgs = append(tx.Msgs, msgKeyValue{Key: key, Value: value}) keyCounter++ } - txBytes, err := encCfg.Amino.Marshal(tx) + txBytes, err := codec.Marshal(tx) require.NoError(t, err) resp := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) require.True(t, resp.IsOK(), "%v", resp.String()) @@ -222,7 +186,7 @@ func setupBaseAppWithSnapshots(t *testing.T, blocks uint, blockTxs int, options app.Commit() // Wait for snapshot to be taken, since it happens asynchronously. - if uint64(height)%snapshotInterval == 0 { + if config.snapshotInterval > 0 && uint64(height)%config.snapshotInterval == 0 { start := time.Now() for { if time.Since(start) > snapshotTimeout { @@ -238,72 +202,26 @@ func setupBaseAppWithSnapshots(t *testing.T, blocks uint, blockTxs int, options } } - return app, teardown + return app, nil } func TestMountStores(t *testing.T) { app := setupBaseApp(t) // check both stores - store1 := app.Store().GetKVStore(capKey1) + store1 := app.store.GetKVStore(capKey1) require.NotNil(t, store1) - store2 := app.Store().GetKVStore(capKey2) + store2 := app.store.GetKVStore(capKey2) require.NotNil(t, store2) } -type MockTxHandler struct { - T *testing.T -} - -func (th MockTxHandler) CheckTx(goCtx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - require.NotNil(th.T, ctx.ConsensusParams()) - return tx.Response{}, tx.ResponseCheckTx{}, nil -} - -func (th MockTxHandler) DeliverTx(goCtx context.Context, req tx.Request) (tx.Response, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - require.NotNil(th.T, ctx.ConsensusParams()) - return tx.Response{}, nil -} - -func (th MockTxHandler) SimulateTx(goCtx context.Context, req tx.Request) (tx.Response, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - require.NotNil(th.T, ctx.ConsensusParams()) - return tx.Response{}, nil -} - -func TestConsensusParamsNotNil(t *testing.T) { - app := setupBaseApp(t, baseapp.AppOptionFunc(func(app *baseapp.BaseApp) { - app.SetBeginBlocker(func(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - require.NotNil(t, ctx.ConsensusParams()) - return abci.ResponseBeginBlock{} - }) - }), baseapp.AppOptionFunc(func(app *baseapp.BaseApp) { - app.SetEndBlocker(func(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock { - require.NotNil(t, ctx.ConsensusParams()) - return abci.ResponseEndBlock{} - }) - }), baseapp.AppOptionFunc(func(app *baseapp.BaseApp) { - app.SetTxHandler(MockTxHandler{T: t}) - })) - - header := tmproto.Header{Height: 1} - app.BeginBlock(abci.RequestBeginBlock{Header: header}) - app.EndBlock(abci.RequestEndBlock{Height: header.Height}) - app.CheckTx(abci.RequestCheckTx{}) - app.DeliverTx(abci.RequestDeliverTx{}) - app.Simulate([]byte{}) -} - // Test that we can make commits and then reload old versions. -// Test that LoadLatestVersion actually does. func TestLoadVersion(t *testing.T) { logger := defaultLogger() - pruningOpt := baseapp.SetPruning(stypes.PruneNothing) + pruningOpt := SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) db := memdb.NewDB() name := t.Name() - app := baseapp.NewBaseApp(name, logger, db, pruningOpt) + app := NewBaseApp(name, logger, db, nil, pruningOpt) // make a cap key and mount the store err := app.Init() // needed to make stores non-nil @@ -330,7 +248,7 @@ func TestLoadVersion(t *testing.T) { app.CloseStore() // reload with latest version - app = baseapp.NewBaseApp(name, logger, db, pruningOpt) + app = NewBaseApp(name, logger, db, nil, pruningOpt) err = app.Init() require.Nil(t, err) testLoadVersionHelper(t, app, int64(2), commitID2) @@ -339,7 +257,7 @@ func TestLoadVersion(t *testing.T) { func initStore(t *testing.T, db dbm.DBConnection, storeKey string, k, v []byte) { key := sdk.NewKVStoreKey(storeKey) opts := multi.DefaultStoreParams() - opts.Pruning = stypes.PruneNothing + opts.Pruning = pruningtypes.NewPruningOptions(pruningtypes.PruningNothing) require.NoError(t, opts.RegisterSubstore(key, stypes.StoreTypePersistent)) rs, err := multi.NewV1MultiStoreAsV2(db, opts) require.NoError(t, err) @@ -356,7 +274,7 @@ func initStore(t *testing.T, db dbm.DBConnection, storeKey string, k, v []byte) func checkStore(t *testing.T, db dbm.DBConnection, ver int64, storeKey string, k, v []byte) { opts := multi.DefaultStoreParams() - opts.Pruning = stypes.PruneNothing + opts.Pruning = pruningtypes.NewPruningOptions(pruningtypes.PruningNothing) key := sdk.NewKVStoreKey(storeKey) require.NoError(t, opts.RegisterSubstore(key, stypes.StoreTypePersistent)) rs, err := multi.NewV1MultiStoreAsV2(db, opts) @@ -372,10 +290,10 @@ func checkStore(t *testing.T, db dbm.DBConnection, ver int64, storeKey string, k func TestVersionSetterGetter(t *testing.T) { logger := defaultLogger() - pruningOpt := baseapp.SetPruning(stypes.PruneDefault) + pruningOpt := SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningDefault)) db := memdb.NewDB() name := t.Name() - app := baseapp.NewBaseApp(name, logger, db, pruningOpt) + app := NewBaseApp(name, logger, db, nil, pruningOpt) require.Equal(t, "", app.Version()) res := app.Query(abci.RequestQuery{Path: "app/version"}) require.True(t, res.IsOK()) @@ -391,15 +309,13 @@ func TestVersionSetterGetter(t *testing.T) { func TestLoadVersionPruning(t *testing.T) { logger := log.NewNopLogger() - pruningOptions := stypes.PruningOptions{ - KeepRecent: 2, - Interval: 1, - } - pruningOpt := baseapp.SetPruning(pruningOptions) - schemaOpt := baseapp.SetSubstores(sdk.NewKVStoreKey("key1")) + pruningOptions := pruningtypes.NewCustomPruningOptions(10, 15) + pruningOpt := SetPruning(pruningOptions) + capKey := sdk.NewKVStoreKey("key1") + schemaOpt := SetSubstores(capKey) db := memdb.NewDB() name := t.Name() - app := baseapp.NewBaseApp(name, logger, db, pruningOpt, schemaOpt) + app := NewBaseApp(name, logger, db, nil, pruningOpt) err := app.Init() // needed to make stores non-nil require.Nil(t, err) @@ -425,25 +341,25 @@ func TestLoadVersionPruning(t *testing.T) { // TODO: behavior change - // CacheMultiStoreWithVersion returned no error on missing version (?) for _, v := range []int64{1, 2, 4} { - _, err = app.Store().GetVersion(v) + _, err = app.store.GetVersion(v) require.NoError(t, err, "version=%v", v) } for _, v := range []int64{3, 5, 6, 7} { - _, err = app.Store().GetVersion(v) + _, err = app.store.GetVersion(v) require.NoError(t, err, "version=%v", v) } require.NoError(t, app.CloseStore()) // reload app, check it loads last version - app = baseapp.NewBaseApp(name, logger, db, pruningOpt, schemaOpt) + app = NewBaseApp(name, logger, db, nil, pruningOpt, schemaOpt) err = app.Init() require.Nil(t, err) testLoadVersionHelper(t, app, int64(7), lastCommitID) } -func testLoadVersionHelper(t *testing.T, app *baseapp.BaseApp, expectedHeight int64, expectedID stypes.CommitID) { +func testLoadVersionHelper(t *testing.T, app *BaseApp, expectedHeight int64, expectedID storetypes.CommitID) { lastHeight := app.LastBlockHeight() lastID := app.LastCommitID() require.Equal(t, expectedHeight, lastHeight) @@ -453,12 +369,29 @@ func testLoadVersionHelper(t *testing.T, app *baseapp.BaseApp, expectedHeight in func TestOptionFunction(t *testing.T) { logger := defaultLogger() db := memdb.NewDB() - bap := baseapp.NewBaseApp("starting name", logger, db, testChangeNameHelper("new name")) - require.Equal(t, bap.Name(), "new name", "BaseApp should have had name changed via option function") + bap := NewBaseApp("starting name", logger, db, nil, testChangeNameHelper("new name")) + require.Equal(t, "new name", bap.Name(), "BaseApp should have had name changed via option function") } -func testChangeNameHelper(name string) baseapp.AppOptionFunc { - return func(bap *baseapp.BaseApp) { bap.SetName(name) } +func testChangeNameHelper(name string) AppOptionFunc { + return func(bap *BaseApp) { bap.SetName(name) } +} + +// Test that txs can be unmarshalled and read and that +// correct error codes are returned when not +func TestTxDecoder(t *testing.T) { + codec := codec.NewLegacyAmino() + registerTestCodec(codec) + + app := newBaseApp(t.Name()) + tx := newTxCounter(1, 0) + txBytes := codec.MustMarshal(tx) + + dTx, err := app.txDecoder(txBytes) + require.NoError(t, err) + + cTx := dTx.(txTest) + require.Equal(t, tx.Counter, cTx.Counter) } // Test that Info returns the latest committed state. @@ -498,7 +431,7 @@ func TestBaseAppOptionSeal(t *testing.T) { app.SetEndBlocker(nil) }) require.Panics(t, func() { - app.SetTxHandler(nil) + app.SetAnteHandler(nil) }) require.Panics(t, func() { app.SetAddrPeerFilter(nil) @@ -509,12 +442,15 @@ func TestBaseAppOptionSeal(t *testing.T) { require.Panics(t, func() { app.SetFauxMerkleMode() }) + require.Panics(t, func() { + app.SetRouter(NewRouter()) + }) } func TestSetMinGasPrices(t *testing.T) { minGasPrices := sdk.DecCoins{sdk.NewInt64DecCoin("stake", 5000)} - app := newBaseApp(t.Name(), baseapp.SetMinGasPrices(minGasPrices.String())) - require.Equal(t, minGasPrices, app.MinGasPrices()) + app := newBaseApp(t.Name(), SetMinGasPrices(minGasPrices.String())) + require.Equal(t, minGasPrices, app.minGasPrices) } func TestInitChainer(t *testing.T) { @@ -525,8 +461,8 @@ func TestInitChainer(t *testing.T) { logger := defaultLogger() capKey := sdk.NewKVStoreKey("main") capKey2 := sdk.NewKVStoreKey("key2") - schemaOpt := baseapp.SetSubstores(capKey, capKey2) - app := baseapp.NewBaseApp(name, logger, db, schemaOpt) + schemaOpt := SetSubstores(capKey, capKey2) + app := NewBaseApp(name, logger, db, nil, schemaOpt) // set a value in the store on init chain key, value := []byte("hello"), []byte("goodbye") @@ -566,10 +502,10 @@ func TestInitChainer(t *testing.T) { ) // assert that chainID is set correctly in InitChain - chainID := app.DeliverState().Context().ChainID() + chainID := app.deliverState.ctx.ChainID() require.Equal(t, "test-chain-id", chainID, "ChainID in deliverState not set correctly in InitChain") - chainID = app.CheckState().Context().ChainID() + chainID = app.checkState.ctx.ChainID() require.Equal(t, "test-chain-id", chainID, "ChainID in checkState not set correctly in InitChain") app.Commit() @@ -580,7 +516,7 @@ func TestInitChainer(t *testing.T) { require.NoError(t, app.CloseStore()) // reload app - app = baseapp.NewBaseApp(name, logger, db, schemaOpt) + app = NewBaseApp(name, logger, db, nil, schemaOpt) app.SetInitChainer(initChainer) err = app.Init() @@ -604,7 +540,7 @@ func TestInitChain_WithInitialHeight(t *testing.T) { name := t.Name() db := memdb.NewDB() logger := defaultLogger() - app := baseapp.NewBaseApp(name, logger, db) + app := NewBaseApp(name, logger, db, nil) app.InitChain( abci.RequestInitChain{ @@ -620,7 +556,7 @@ func TestBeginBlock_WithInitialHeight(t *testing.T) { name := t.Name() db := memdb.NewDB() logger := defaultLogger() - app := baseapp.NewBaseApp(name, logger, db) + app := NewBaseApp(name, logger, db, nil) app.InitChain( abci.RequestInitChain{ @@ -651,7 +587,6 @@ type txTest struct { Msgs []sdk.Msg Counter int64 FailOnAnte bool - GasLimit uint64 } func (tx *txTest) setFailOnAnte(fail bool) { @@ -660,7 +595,7 @@ func (tx *txTest) setFailOnAnte(fail bool) { func (tx *txTest) setFailOnHandler(fail bool) { for i, msg := range tx.Msgs { - tx.Msgs[i] = &msgCounter{msg.(*msgCounter).Counter, fail} + tx.Msgs[i] = msgCounter{msg.(msgCounter).Counter, fail} } } @@ -668,12 +603,6 @@ func (tx *txTest) setFailOnHandler(fail bool) { func (tx txTest) GetMsgs() []sdk.Msg { return tx.Msgs } func (tx txTest) ValidateBasic() error { return nil } -// Implements GasTx -func (tx txTest) GetGas() uint64 { return tx.GasLimit } - -// Implements TxWithTimeoutHeight -func (tx txTest) GetTimeoutHeight() uint64 { return 0 } - const ( routeMsgCounter = "msgCounter" routeMsgCounter2 = "msgCounter2" @@ -688,29 +617,29 @@ type msgCounter struct { } // dummy implementation of proto.Message -func (msg *msgCounter) Reset() {} -func (msg *msgCounter) String() string { return "TODO" } -func (msg *msgCounter) ProtoMessage() {} +func (msg msgCounter) Reset() {} +func (msg msgCounter) String() string { return "TODO" } +func (msg msgCounter) ProtoMessage() {} // Implements Msg -func (msg *msgCounter) Route() string { return routeMsgCounter } -func (msg *msgCounter) Type() string { return "counter1" } -func (msg *msgCounter) GetSignBytes() []byte { return nil } -func (msg *msgCounter) GetSigners() []sdk.AccAddress { return nil } -func (msg *msgCounter) ValidateBasic() error { +func (msg msgCounter) Route() string { return routeMsgCounter } +func (msg msgCounter) Type() string { return "counter1" } +func (msg msgCounter) GetSignBytes() []byte { return nil } +func (msg msgCounter) GetSigners() []sdk.AccAddress { return nil } +func (msg msgCounter) ValidateBasic() error { if msg.Counter >= 0 { return nil } return sdkerrors.Wrap(sdkerrors.ErrInvalidSequence, "counter should be a non-negative integer") } -func newTxCounter(counter int64, msgCounters ...int64) txTest { +func newTxCounter(counter int64, msgCounters ...int64) *txTest { msgs := make([]sdk.Msg, 0, len(msgCounters)) for _, c := range msgCounters { - msgs = append(msgs, &msgCounter{c, false}) + msgs = append(msgs, msgCounter{c, false}) } - return txTest{msgs, counter, false, math.MaxUint64} + return &txTest{msgs, counter, false} } // a msg we dont know how to route @@ -789,7 +718,7 @@ func testTxDecoder(cdc *codec.LegacyAmino) sdk.TxDecoder { } } -func customHandlerTxTest(t *testing.T, capKey stypes.StoreKey, storeKey []byte) handlerFun { +func anteHandlerTxTest(t *testing.T, capKey storetypes.StoreKey, storeKey []byte) sdk.AnteHandler { return func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { store := ctx.KVStore(capKey) txTest := tx.(txTest) @@ -804,9 +733,11 @@ func customHandlerTxTest(t *testing.T, capKey stypes.StoreKey, storeKey []byte) } ctx.EventManager().EmitEvents( - counterEvent("post_handlers", txTest.Counter), + counterEvent("ante_handler", txTest.Counter), ) + ctx = ctx.WithPriority(testTxPriority) + return ctx, nil } } @@ -847,14 +778,6 @@ func handlerMsgCounter(t *testing.T, capKey stypes.StoreKey, deliverKey []byte) } res.Events = ctx.EventManager().Events().ToABCIEvents() - - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return nil, err - } - - res.MsgResponses = []*codectypes.Any{any} - return res, nil } } @@ -886,7 +809,7 @@ func incrementingCounter(t *testing.T, store sdk.KVStore, counterKey []byte, cou return &sdk.Result{}, nil } -// --------------------------------------------------------------------- +//--------------------------------------------------------------------- // Tx processing - CheckTx, DeliverTx, SimulateTx. // These tests use the serialized tx as input, while most others will use the // Check(), Deliver(), Simulate() methods directly. @@ -900,54 +823,51 @@ func TestCheckTx(t *testing.T) { // This ensures changes to the kvstore persist across successive CheckTx. counterKey := []byte("counter-key") - txHandlerOpt := baseapp.AppOptionFunc(func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + anteOpt := func(bapp *BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, counterKey)) } + routerOpt := func(bapp *BaseApp) { // TODO: can remove this once CheckTx doesnt process msgs. - legacyRouter.AddRoute(sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - return &sdk.Result{}, nil - })) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - customHandlerTxTest(t, capKey1, counterKey), - ) - bapp.SetTxHandler(txHandler) - }) + bapp.Router().AddRoute(sdk.NewRoute(routeMsgCounter, + func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + return &sdk.Result{}, nil + })) + } - app := setupBaseApp(t, txHandlerOpt) + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) nTxs := int64(5) app.InitChain(abci.RequestInitChain{}) + // Create same codec used in txDecoder + codec := codec.NewLegacyAmino() + registerTestCodec(codec) + for i := int64(0); i < nTxs; i++ { tx := newTxCounter(i, 0) // no messages - txBytes, err := encCfg.Amino.Marshal(tx) + txBytes, err := codec.Marshal(tx) require.NoError(t, err) r := app.CheckTx(abci.RequestCheckTx{Tx: txBytes}) + require.Equal(t, testTxPriority, r.Priority) require.Empty(t, r.GetEvents()) - require.True(t, r.IsOK(), fmt.Sprintf("%+v", r)) + require.True(t, r.IsOK(), fmt.Sprintf("%v", r)) } - checkStateStore := app.CheckState().Context().KVStore(capKey1) + checkStateStore := app.checkState.ctx.KVStore(capKey1) storedCounter := getIntFromStore(checkStateStore, counterKey) - // Ensure storedCounter + // Ensure AnteHandler ran require.Equal(t, nTxs, storedCounter) // If a block is committed, CheckTx state should be reset. header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header, Hash: []byte("hash")}) - require.NotNil(t, app.CheckState().Context().BlockGasMeter(), "block gas meter should have been set to checkState") - require.NotEmpty(t, app.CheckState().Context().HeaderHash()) + require.NotNil(t, app.checkState.ctx.BlockGasMeter(), "block gas meter should have been set to checkState") + require.NotEmpty(t, app.checkState.ctx.HeaderHash()) app.EndBlock(abci.RequestEndBlock{}) app.Commit() - checkStateStore = app.CheckState().Context().KVStore(capKey1) + checkStateStore = app.checkState.ctx.KVStore(capKey1) storedBytes := checkStateStore.Get(counterKey) require.Nil(t, storedBytes) } @@ -955,27 +875,24 @@ func TestCheckTx(t *testing.T) { // Test that successive DeliverTx can see each others' effects // on the store, both within and across blocks. func TestDeliverTx(t *testing.T) { - // test increments in the post txHandler + // test increments in the ante anteKey := []byte("ante-key") + anteOpt := func(bapp *BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } + // test increments in the handler deliverKey := []byte("deliver-key") - txHandlerOpt := baseapp.AppOptionFunc(func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + routerOpt := func(bapp *BaseApp) { r := sdk.NewRoute(routeMsgCounter, handlerMsgCounter(t, capKey1, deliverKey)) - legacyRouter.AddRoute(r) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - customHandlerTxTest(t, capKey1, anteKey), - ) - bapp.SetTxHandler(txHandler) - }) - app := setupBaseApp(t, txHandlerOpt) + bapp.Router().AddRoute(r) + } + + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) app.InitChain(abci.RequestInitChain{}) + // Create same codec used in txDecoder + codec := codec.NewLegacyAmino() + registerTestCodec(codec) + nBlocks := 3 txPerHeight := 5 @@ -987,14 +904,14 @@ func TestDeliverTx(t *testing.T) { counter := int64(blockN*txPerHeight + i) tx := newTxCounter(counter, counter) - txBytes, err := encCfg.Amino.Marshal(tx) + txBytes, err := codec.Marshal(tx) require.NoError(t, err) res := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) require.True(t, res.IsOK(), fmt.Sprintf("%v", res)) events := res.GetEvents() require.Len(t, events, 3, "should contain ante handler, message type and counter events respectively") - require.Equal(t, sdk.MarkEventsToIndex(counterEvent("post_handlers", counter).ToABCIEvents(), map[string]struct{}{})[0], events[0], "ante handler event") + require.Equal(t, sdk.MarkEventsToIndex(counterEvent("ante_handler", counter).ToABCIEvents(), map[string]struct{}{})[0], events[0], "ante handler event") require.Equal(t, sdk.MarkEventsToIndex(counterEvent(sdk.EventTypeMessage, counter).ToABCIEvents(), map[string]struct{}{})[0], events[2], "msg handler update counter event") } @@ -1013,27 +930,23 @@ func TestMultiMsgCheckTx(t *testing.T) { func TestMultiMsgDeliverTx(t *testing.T) { // increment the tx counter anteKey := []byte("ante-key") + anteOpt := func(bapp *BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } + // increment the msg counter deliverKey := []byte("deliver-key") deliverKey2 := []byte("deliver-key2") - - txHandlerOpt := func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + routerOpt := func(bapp *BaseApp) { r1 := sdk.NewRoute(routeMsgCounter, handlerMsgCounter(t, capKey1, deliverKey)) r2 := sdk.NewRoute(routeMsgCounter2, handlerMsgCounter(t, capKey1, deliverKey2)) - legacyRouter.AddRoute(r1) - legacyRouter.AddRoute(r2) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - customHandlerTxTest(t, capKey1, anteKey), - ) - bapp.SetTxHandler(txHandler) + bapp.Router().AddRoute(r1) + bapp.Router().AddRoute(r2) } - app := setupBaseApp(t, baseapp.AppOptionFunc(txHandlerOpt)) + + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) + + // Create same codec used in txDecoder + codec := codec.NewLegacyAmino() + registerTestCodec(codec) // run a multi-msg tx // with all msgs the same route @@ -1041,12 +954,12 @@ func TestMultiMsgDeliverTx(t *testing.T) { header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) tx := newTxCounter(0, 0, 1, 2) - txBytes, err := encCfg.Amino.Marshal(tx) + txBytes, err := codec.Marshal(tx) require.NoError(t, err) res := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) require.True(t, res.IsOK(), fmt.Sprintf("%v", res)) - store := app.DeliverState().Context().KVStore(capKey1) + store := app.deliverState.ctx.KVStore(capKey1) // tx counter only incremented once txCounter := getIntFromStore(store, anteKey) @@ -1061,12 +974,12 @@ func TestMultiMsgDeliverTx(t *testing.T) { tx = newTxCounter(1, 3) tx.Msgs = append(tx.Msgs, msgCounter2{0}) tx.Msgs = append(tx.Msgs, msgCounter2{1}) - txBytes, err = encCfg.Amino.Marshal(tx) + txBytes, err = codec.Marshal(tx) require.NoError(t, err) res = app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) require.True(t, res.IsOK(), fmt.Sprintf("%v", res)) - store = app.DeliverState().Context().KVStore(capKey1) + store = app.deliverState.ctx.KVStore(capKey1) // tx counter only incremented once txCounter = getIntFromStore(store, anteKey) @@ -1093,35 +1006,29 @@ func TestConcurrentCheckDeliver(t *testing.T) { func TestSimulateTx(t *testing.T) { gasConsumed := uint64(5) - txHandlerOpt := func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + anteOpt := func(bapp *BaseApp) { + bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasConsumed)) + return + }) + } + + routerOpt := func(bapp *BaseApp) { r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx.GasMeter().ConsumeGas(gasConsumed, "test") - // Return dummy MsgResponse for msgCounter. - any, err := codectypes.NewAnyWithValue(&testdata.Dog{}) - if err != nil { - return nil, err - } - - return &sdk.Result{ - MsgResponses: []*codectypes.Any{any}, - }, nil + return &sdk.Result{}, nil }) - legacyRouter.AddRoute(r) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { return ctx, nil }, - ) - bapp.SetTxHandler(txHandler) + bapp.Router().AddRoute(r) } - app := setupBaseApp(t, baseapp.AppOptionFunc(txHandlerOpt)) + + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) app.InitChain(abci.RequestInitChain{}) + // Create same codec used in txDecoder + cdc := codec.NewLegacyAmino() + registerTestCodec(cdc) + nBlocks := 3 for blockN := 0; blockN < nBlocks; blockN++ { count := int64(blockN + 1) @@ -1129,8 +1036,7 @@ func TestSimulateTx(t *testing.T) { app.BeginBlock(abci.RequestBeginBlock{Header: header}) tx := newTxCounter(count, count) - tx.GasLimit = gasConsumed - txBytes, err := encCfg.Amino.Marshal(tx) + txBytes, err := cdc.Marshal(tx) require.Nil(t, err) // simulate a message, check gas reported @@ -1167,32 +1073,19 @@ func TestSimulateTx(t *testing.T) { } func TestRunInvalidTransaction(t *testing.T) { - txHandlerOpt := func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + anteOpt := func(bapp *BaseApp) { + bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + return + }) + } + routerOpt := func(bapp *BaseApp) { r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return nil, err - } - - return &sdk.Result{ - MsgResponses: []*codectypes.Any{any}, - }, nil + return &sdk.Result{}, nil }) - legacyRouter.AddRoute(r) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { - return - }, - ) - bapp.SetTxHandler(txHandler) + bapp.Router().AddRoute(r) } - app := setupBaseApp(t, baseapp.AppOptionFunc(txHandlerOpt)) + + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) @@ -1200,7 +1093,8 @@ func TestRunInvalidTransaction(t *testing.T) { // transaction with no messages { emptyTx := &txTest{} - _, result, err := app.SimDeliver(aminoTxEncoder(encCfg.Amino), emptyTx) + _, result, err := app.SimDeliver(aminoTxEncoder(), emptyTx) + require.Error(t, err) require.Nil(t, result) space, code, _ := sdkerrors.ABCIInfo(err, false) @@ -1211,7 +1105,7 @@ func TestRunInvalidTransaction(t *testing.T) { // transaction where ValidateBasic fails { testCases := []struct { - tx txTest + tx *txTest fail bool }{ {newTxCounter(0, 0), false}, @@ -1226,7 +1120,7 @@ func TestRunInvalidTransaction(t *testing.T) { for _, testCase := range testCases { tx := testCase.tx - _, _, err := app.SimDeliver(aminoTxEncoder(encCfg.Amino), tx) + _, result, err := app.SimDeliver(aminoTxEncoder(), tx) if testCase.fail { require.Error(t, err) @@ -1235,15 +1129,15 @@ func TestRunInvalidTransaction(t *testing.T) { require.EqualValues(t, sdkerrors.ErrInvalidSequence.Codespace(), space, err) require.EqualValues(t, sdkerrors.ErrInvalidSequence.ABCICode(), code, err) } else { - require.NoError(t, err) + require.NotNil(t, result) } } } // transaction with no known route { - unknownRouteTx := txTest{[]sdk.Msg{&msgNoRoute{}}, 0, false, math.MaxUint64} - _, result, err := app.SimDeliver(aminoTxEncoder(encCfg.Amino), unknownRouteTx) + unknownRouteTx := txTest{[]sdk.Msg{msgNoRoute{}}, 0, false} + _, result, err := app.SimDeliver(aminoTxEncoder(), unknownRouteTx) require.Error(t, err) require.Nil(t, result) @@ -1251,8 +1145,8 @@ func TestRunInvalidTransaction(t *testing.T) { require.EqualValues(t, sdkerrors.ErrUnknownRequest.Codespace(), space, err) require.EqualValues(t, sdkerrors.ErrUnknownRequest.ABCICode(), code, err) - unknownRouteTx = txTest{[]sdk.Msg{&msgCounter{}, &msgNoRoute{}}, 0, false, math.MaxUint64} - _, result, err = app.SimDeliver(aminoTxEncoder(encCfg.Amino), unknownRouteTx) + unknownRouteTx = txTest{[]sdk.Msg{msgCounter{}, msgNoRoute{}}, 0, false} + _, result, err = app.SimDeliver(aminoTxEncoder(), unknownRouteTx) require.Error(t, err) require.Nil(t, result) @@ -1264,14 +1158,12 @@ func TestRunInvalidTransaction(t *testing.T) { // Transaction with an unregistered message { tx := newTxCounter(0, 0) - tx.Msgs = append(tx.Msgs, &msgNoDecode{}) + tx.Msgs = append(tx.Msgs, msgNoDecode{}) - // new codec so we can encode the tx, but we shouldn't be able to decode, - // because baseapp's codec is not aware of msgNoDecode. + // new codec so we can encode the tx, but we shouldn't be able to decode newCdc := codec.NewLegacyAmino() - sdk.RegisterLegacyAminoCodec(newCdc) // register Tx, Msg registerTestCodec(newCdc) - legacy.RegisterAminoMsg(newCdc, &msgNoDecode{}, "cosmos-sdk/baseapp/msgNoDecode") + newCdc.RegisterConcrete(&msgNoDecode{}, "cosmos-sdk/baseapp/msgNoDecode", nil) txBytes, err := newCdc.Marshal(tx) require.NoError(t, err) @@ -1285,46 +1177,49 @@ func TestRunInvalidTransaction(t *testing.T) { // Test that transactions exceeding gas limits fail func TestTxGasLimits(t *testing.T) { gasGranted := uint64(10) + anteOpt := func(bapp *BaseApp) { + bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasGranted)) + + // AnteHandlers must have their own defer/recover in order for the BaseApp + // to know how much gas was used! This is because the GasMeter is created in + // the AnteHandler, but if it panics the context won't be set properly in + // runTx's recover call. + defer func() { + if r := recover(); r != nil { + switch rType := r.(type) { + case sdk.ErrorOutOfGas: + err = sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, "out of gas in location: %v", rType.Descriptor) + default: + panic(r) + } + } + }() + + count := tx.(txTest).Counter + newCtx.GasMeter().ConsumeGas(uint64(count), "counter-ante") + + return newCtx, nil + }) - ante := func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { - count := tx.(txTest).Counter - ctx.GasMeter().ConsumeGas(uint64(count), "counter-ante") - return ctx, nil } - txHandlerOpt := func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + routerOpt := func(bapp *BaseApp) { r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { count := msg.(*msgCounter).Counter ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler") - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return nil, err - } - - return &sdk.Result{ - MsgResponses: []*codectypes.Any{any}, - }, nil + return &sdk.Result{}, nil }) - legacyRouter.AddRoute(r) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - ante, - ) - - bapp.SetTxHandler(txHandler) + bapp.Router().AddRoute(r) } - app := setupBaseApp(t, baseapp.AppOptionFunc(txHandlerOpt)) + + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) header := tmproto.Header{Height: 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) testCases := []struct { - tx txTest + tx *txTest gasUsed uint64 fail bool }{ @@ -1349,8 +1244,7 @@ func TestTxGasLimits(t *testing.T) { for i, tc := range testCases { tx := tc.tx - tx.GasLimit = gasGranted - gInfo, result, err := app.SimDeliver(aminoTxEncoder(encCfg.Amino), tx) + gInfo, result, err := app.SimDeliver(aminoTxEncoder(), tx) // check gas used and wanted require.Equal(t, tc.gasUsed, gInfo.GasUsed, fmt.Sprintf("tc #%d; gas: %v, result: %v, err: %s", i, gInfo, result, err)) @@ -1369,131 +1263,66 @@ func TestTxGasLimits(t *testing.T) { } } -// Test that transactions exceeding gas limits fail -func TestMaxBlockGasLimits(t *testing.T) { - gasGranted := uint64(10) - ante := func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { - count := tx.(txTest).Counter - ctx.GasMeter().ConsumeGas(uint64(count), "counter-ante") +// Test custom panic handling within app.DeliverTx method +func TestCustomRunTxPanicHandler(t *testing.T) { + const customPanicMsg = "test panic" + anteErr := sdkerrors.Register("fakeModule", 100500, "fakeError") - return ctx, nil + anteOpt := func(bapp *BaseApp) { + bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + panic(sdkerrors.Wrap(anteErr, "anteHandler")) + }) } - - txHandlerOpt := func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + routerOpt := func(bapp *BaseApp) { r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - count := msg.(*msgCounter).Counter - ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler") - - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return nil, err - } - - return &sdk.Result{ - MsgResponses: []*codectypes.Any{any}, - }, nil + return &sdk.Result{}, nil }) - legacyRouter.AddRoute(r) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - ante, - ) - bapp.SetTxHandler(txHandler) - } - app := setupBaseApp(t, baseapp.AppOptionFunc(txHandlerOpt)) - - app.InitChain(abci.RequestInitChain{ - ConsensusParams: &tmproto.ConsensusParams{ - Block: &tmproto.BlockParams{ - MaxGas: 100, - }, - }, - }) - - testCases := []struct { - tx txTest - numDelivers int - gasUsedPerDeliver uint64 - fail bool - failAfterDeliver int - }{ - {newTxCounter(0, 0), 0, 0, false, 0}, - {newTxCounter(9, 1), 2, 10, false, 0}, - {newTxCounter(10, 0), 3, 10, false, 0}, - {newTxCounter(10, 0), 10, 10, false, 0}, - {newTxCounter(2, 7), 11, 9, false, 0}, - {newTxCounter(10, 0), 10, 10, false, 0}, // hit the limit but pass - - {newTxCounter(10, 0), 11, 10, true, 10}, - {newTxCounter(10, 0), 15, 10, true, 10}, - {newTxCounter(9, 0), 12, 9, true, 11}, // fly past the limit + bapp.Router().AddRoute(r) } - for i, tc := range testCases { - tx := tc.tx - tx.GasLimit = gasGranted + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) - // reset the block gas - header := tmproto.Header{Height: app.LastBlockHeight() + 1} - app.BeginBlock(abci.RequestBeginBlock{Header: header}) + header := tmproto.Header{Height: 1} + app.BeginBlock(abci.RequestBeginBlock{Header: header}) - // execute the transaction multiple times - for j := 0; j < tc.numDelivers; j++ { - _, result, err := app.SimDeliver(aminoTxEncoder(encCfg.Amino), tx) + app.AddRunTxRecoveryHandler(func(recoveryObj interface{}) error { + err, ok := recoveryObj.(error) + if !ok { + return nil + } - ctx := app.DeliverState().Context() + if anteErr.Is(err) { + panic(customPanicMsg) + } else { + return nil + } + }) - // check for failed transactions - if tc.fail && (j+1) > tc.failAfterDeliver { - require.Error(t, err, fmt.Sprintf("tc #%d; result: %v, err: %s", i, result, err)) - require.Nil(t, result, fmt.Sprintf("tc #%d; result: %v, err: %s", i, result, err)) + // Transaction should panic with custom handler above + { + tx := newTxCounter(0, 0) - space, code, _ := sdkerrors.ABCIInfo(err, false) - require.EqualValues(t, sdkerrors.ErrOutOfGas.Codespace(), space, err) - require.EqualValues(t, sdkerrors.ErrOutOfGas.ABCICode(), code, err) - require.True(t, ctx.BlockGasMeter().IsOutOfGas()) - } else { - // check gas used and wanted - blockGasUsed := ctx.BlockGasMeter().GasConsumed() - expBlockGasUsed := tc.gasUsedPerDeliver * uint64(j+1) - require.Equal( - t, expBlockGasUsed, blockGasUsed, - fmt.Sprintf("%d,%d: %v, %v, %v, %v", i, j, tc, expBlockGasUsed, blockGasUsed, result), - ) - - require.NotNil(t, result, fmt.Sprintf("tc #%d; currDeliver: %d, result: %v, err: %s", i, j, result, err)) - require.False(t, ctx.BlockGasMeter().IsPastLimit()) - } - } + require.PanicsWithValue(t, customPanicMsg, func() { app.SimDeliver(aminoTxEncoder(), tx) }) } } -func TestBaseAppMiddleware(t *testing.T) { +func TestBaseAppAnteHandler(t *testing.T) { anteKey := []byte("ante-key") - deliverKey := []byte("deliver-key") + anteOpt := func(bapp *BaseApp) { + bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) + } - txHandlerOpt := func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + deliverKey := []byte("deliver-key") + routerOpt := func(bapp *BaseApp) { r := sdk.NewRoute(routeMsgCounter, handlerMsgCounter(t, capKey1, deliverKey)) - legacyRouter.AddRoute(r) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - customHandlerTxTest(t, capKey1, anteKey), - ) - bapp.SetTxHandler(txHandler) + bapp.Router().AddRoute(r) } - app := setupBaseApp(t, baseapp.AppOptionFunc(txHandlerOpt)) + + cdc := codec.NewLegacyAmino() + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) app.InitChain(abci.RequestInitChain{}) + registerTestCodec(cdc) header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) @@ -1501,16 +1330,16 @@ func TestBaseAppMiddleware(t *testing.T) { // execute a tx that will fail ante handler execution // // NOTE: State should not be mutated here. This will be implicitly checked by - // the next txs ante handler execution (customHandlerTxTest). + // the next txs ante handler execution (anteHandlerTxTest). tx := newTxCounter(0, 0) tx.setFailOnAnte(true) - txBytes, err := encCfg.Amino.Marshal(tx) + txBytes, err := cdc.Marshal(tx) require.NoError(t, err) res := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) require.Empty(t, res.Events) require.False(t, res.IsOK(), fmt.Sprintf("%v", res)) - ctx := app.DeliverState().Context() + ctx := app.getState(runTxModeDeliver).ctx store := ctx.KVStore(capKey1) require.Equal(t, int64(0), getIntFromStore(store, anteKey)) @@ -1519,14 +1348,15 @@ func TestBaseAppMiddleware(t *testing.T) { tx = newTxCounter(0, 0) tx.setFailOnHandler(true) - txBytes, err = encCfg.Amino.Marshal(tx) + txBytes, err = cdc.Marshal(tx) require.NoError(t, err) res = app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) - require.Empty(t, res.Events) + // should emit ante event + require.NotEmpty(t, res.Events) require.False(t, res.IsOK(), fmt.Sprintf("%v", res)) - ctx = app.DeliverState().Context() + ctx = app.getState(runTxModeDeliver).ctx store = ctx.KVStore(capKey1) require.Equal(t, int64(1), getIntFromStore(store, anteKey)) require.Equal(t, int64(0), getIntFromStore(store, deliverKey)) @@ -1535,14 +1365,14 @@ func TestBaseAppMiddleware(t *testing.T) { // implicitly checked by previous tx executions tx = newTxCounter(1, 0) - txBytes, err = encCfg.Amino.Marshal(tx) + txBytes, err = cdc.Marshal(tx) require.NoError(t, err) res = app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) require.NotEmpty(t, res.Events) require.True(t, res.IsOK(), fmt.Sprintf("%v", res)) - ctx = app.DeliverState().Context() + ctx = app.getState(runTxModeDeliver).ctx store = ctx.KVStore(capKey1) require.Equal(t, int64(2), getIntFromStore(store, anteKey)) require.Equal(t, int64(1), getIntFromStore(store, deliverKey)) @@ -1554,36 +1384,45 @@ func TestBaseAppMiddleware(t *testing.T) { func TestGasConsumptionBadTx(t *testing.T) { gasWanted := uint64(5) - ante := func(ctx sdk.Context, tx sdk.Tx, simulate bool) (sdk.Context, error) { - txTest := tx.(txTest) - ctx.GasMeter().ConsumeGas(uint64(txTest.Counter), "counter-ante") - if txTest.FailOnAnte { - return ctx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "ante handler failure") - } + anteOpt := func(bapp *BaseApp) { + bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + newCtx = ctx.WithGasMeter(sdk.NewGasMeter(gasWanted)) + + defer func() { + if r := recover(); r != nil { + switch rType := r.(type) { + case sdk.ErrorOutOfGas: + log := fmt.Sprintf("out of gas in location: %v", rType.Descriptor) + err = sdkerrors.Wrap(sdkerrors.ErrOutOfGas, log) + default: + panic(r) + } + } + }() - return ctx, nil + txTest := tx.(txTest) + newCtx.GasMeter().ConsumeGas(uint64(txTest.Counter), "counter-ante") + if txTest.FailOnAnte { + return newCtx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "ante handler failure") + } + + return + }) } - txHandlerOpt := func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + routerOpt := func(bapp *BaseApp) { r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { count := msg.(*msgCounter).Counter ctx.GasMeter().ConsumeGas(uint64(count), "counter-handler") return &sdk.Result{}, nil }) - legacyRouter.AddRoute(r) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - ante, - ) - bapp.SetTxHandler(txHandler) + bapp.Router().AddRoute(r) } - app := setupBaseApp(t, baseapp.AppOptionFunc(txHandlerOpt)) + cdc := codec.NewLegacyAmino() + registerTestCodec(cdc) + + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) app.InitChain(abci.RequestInitChain{ ConsensusParams: &tmproto.ConsensusParams{ Block: &tmproto.BlockParams{ @@ -1598,9 +1437,8 @@ func TestGasConsumptionBadTx(t *testing.T) { app.BeginBlock(abci.RequestBeginBlock{Header: header}) tx := newTxCounter(5, 0) - tx.GasLimit = gasWanted tx.setFailOnAnte(true) - txBytes, err := encCfg.Amino.Marshal(tx) + txBytes, err := cdc.Marshal(tx) require.NoError(t, err) res := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) @@ -1608,7 +1446,7 @@ func TestGasConsumptionBadTx(t *testing.T) { // require next tx to fail due to black gas limit tx = newTxCounter(5, 0) - txBytes, err = encCfg.Amino.Marshal(tx) + txBytes, err = cdc.Marshal(tx) require.NoError(t, err) res = app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) @@ -1618,37 +1456,24 @@ func TestGasConsumptionBadTx(t *testing.T) { // Test that we can only query from the latest committed state. func TestQuery(t *testing.T) { key, value := []byte("hello"), []byte("goodbye") + anteOpt := func(bapp *BaseApp) { + bapp.SetAnteHandler(func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { + store := ctx.KVStore(capKey1) + store.Set(key, value) + return + }) + } - txHandlerOpt := func(bapp *baseapp.BaseApp) { - legacyRouter := middleware.NewLegacyRouter() + routerOpt := func(bapp *BaseApp) { r := sdk.NewRoute(routeMsgCounter, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { store := ctx.KVStore(capKey1) store.Set(key, value) - - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return nil, err - } - return &sdk.Result{ - MsgResponses: []*codectypes.Any{any}, - }, nil + return &sdk.Result{}, nil }) - legacyRouter.AddRoute(r) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: testTxDecoder(encCfg.Amino), - }, - func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) { - store := ctx.KVStore(capKey1) - store.Set(key, value) - return - }, - ) - bapp.SetTxHandler(txHandler) + bapp.Router().AddRoute(r) } - app := setupBaseApp(t, baseapp.AppOptionFunc(txHandlerOpt)) + + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) app.InitChain(abci.RequestInitChain{}) @@ -1666,7 +1491,7 @@ func TestQuery(t *testing.T) { require.Equal(t, 0, len(res.Value)) // query is still empty after a CheckTx - _, resTx, err := app.SimCheck(aminoTxEncoder(encCfg.Amino), tx) + _, resTx, err := app.SimCheck(aminoTxEncoder(), tx) require.NoError(t, err) require.NotNil(t, resTx) res = app.Query(query) @@ -1676,7 +1501,7 @@ func TestQuery(t *testing.T) { header := tmproto.Header{Height: app.LastBlockHeight() + 1} app.BeginBlock(abci.RequestBeginBlock{Header: header}) - _, resTx, err = app.SimDeliver(aminoTxEncoder(encCfg.Amino), tx) + _, resTx, err = app.SimDeliver(aminoTxEncoder(), tx) require.NoError(t, err) require.NotNil(t, resTx) res = app.Query(query) @@ -1689,14 +1514,14 @@ func TestQuery(t *testing.T) { } func TestGRPCQuery(t *testing.T) { - grpcQueryOpt := func(bapp *baseapp.BaseApp) { + grpcQueryOpt := func(bapp *BaseApp) { testdata.RegisterQueryServer( bapp.GRPCQueryRouter(), testdata.QueryImpl{}, ) } - app := setupBaseApp(t, baseapp.AppOptionFunc(grpcQueryOpt)) + app := setupBaseApp(t, AppOptionFunc(grpcQueryOpt)) app.GRPCQueryRouter().SetInterfaceRegistry(codectypes.NewInterfaceRegistry()) app.InitChain(abci.RequestInitChain{}) @@ -1723,58 +1548,23 @@ func TestGRPCQuery(t *testing.T) { require.Equal(t, "Hello foo!", res.Greeting) } -func TestGRPCQueryPulsar(t *testing.T) { - grpcQueryOpt := func(bapp *baseapp.BaseApp) { - testdata_pulsar.RegisterQueryServer( - bapp.GRPCQueryRouter(), - testdata_pulsar.QueryImpl{}, - ) - } - - app := setupBaseApp(t, baseapp.AppOptionFunc(grpcQueryOpt)) - app.GRPCQueryRouter().SetInterfaceRegistry(codectypes.NewInterfaceRegistry()) - - app.InitChain(abci.RequestInitChain{}) - header := tmproto.Header{Height: app.LastBlockHeight() + 1} - app.BeginBlock(abci.RequestBeginBlock{Header: header}) - app.Commit() - - req := &testdata_pulsar.SayHelloRequest{Name: "foo"} - reqBz, err := proto.Marshal(req) - require.NoError(t, err) - - reqQuery := abci.RequestQuery{ - Data: reqBz, - Path: "/testdata.Query/SayHello", - } - - resQuery := app.Query(reqQuery) - - require.Equal(t, abci.CodeTypeOK, resQuery.Code, resQuery) - - var res testdata_pulsar.SayHelloResponse - err = proto.Unmarshal(resQuery.Value, &res) - require.NoError(t, err) - require.Equal(t, "Hello foo!", res.Greeting) -} - // Test p2p filter queries func TestP2PQuery(t *testing.T) { - addrPeerFilterOpt := func(bapp *baseapp.BaseApp) { + addrPeerFilterOpt := func(bapp *BaseApp) { bapp.SetAddrPeerFilter(func(addrport string) abci.ResponseQuery { require.Equal(t, "1.1.1.1:8000", addrport) return abci.ResponseQuery{Code: uint32(3)} }) } - idPeerFilterOpt := func(bapp *baseapp.BaseApp) { + idPeerFilterOpt := func(bapp *BaseApp) { bapp.SetIDPeerFilter(func(id string) abci.ResponseQuery { require.Equal(t, "testid", id) return abci.ResponseQuery{Code: uint32(4)} }) } - app := setupBaseApp(t, baseapp.AppOptionFunc(addrPeerFilterOpt), baseapp.AppOptionFunc(idPeerFilterOpt)) + app := setupBaseApp(t, AppOptionFunc(addrPeerFilterOpt), AppOptionFunc(idPeerFilterOpt)) addrQuery := abci.RequestQuery{ Path: "/p2p/filter/addr/1.1.1.1:8000", @@ -1795,23 +1585,29 @@ func TestGetMaximumBlockGas(t *testing.T) { ctx := app.NewContext(true, tmproto.Header{}) app.StoreConsensusParams(ctx, &tmproto.ConsensusParams{Block: &tmproto.BlockParams{MaxGas: 0}}) - require.Equal(t, uint64(0), app.GetMaximumBlockGas(ctx)) + require.Equal(t, uint64(0), app.getMaximumBlockGas(ctx)) app.StoreConsensusParams(ctx, &tmproto.ConsensusParams{Block: &tmproto.BlockParams{MaxGas: -1}}) - require.Equal(t, uint64(0), app.GetMaximumBlockGas(ctx)) + require.Equal(t, uint64(0), app.getMaximumBlockGas(ctx)) app.StoreConsensusParams(ctx, &tmproto.ConsensusParams{Block: &tmproto.BlockParams{MaxGas: 5000000}}) - require.Equal(t, uint64(5000000), app.GetMaximumBlockGas(ctx)) + require.Equal(t, uint64(5000000), app.getMaximumBlockGas(ctx)) app.StoreConsensusParams(ctx, &tmproto.ConsensusParams{Block: &tmproto.BlockParams{MaxGas: -5000000}}) - require.Panics(t, func() { app.GetMaximumBlockGas(ctx) }) + require.Panics(t, func() { app.getMaximumBlockGas(ctx) }) } func TestListSnapshots(t *testing.T) { - t.Skip("disabled pending MultiStore snapshot implementation") + setupConfig := &setupConfig{ + blocks: 5, + blockTxs: 4, + snapshotInterval: 2, + snapshotKeepRecent: 2, + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), + } - app, teardown := setupBaseAppWithSnapshots(t, 5, 4) - defer teardown() + app, err := setupBaseAppWithSnapshots(t, setupConfig) + require.NoError(t, err) resp := app.ListSnapshots(abci.RequestListSnapshots{}) for _, s := range resp.Snapshots { @@ -1826,11 +1622,148 @@ func TestListSnapshots(t *testing.T) { }}, resp) } -func TestLoadSnapshotChunk(t *testing.T) { - t.Skip("disabled pending MultiStore snapshot implementation") +func TestSnapshotWithPruning(t *testing.T) { + testcases := map[string]struct { + config *setupConfig + expectedSnapshots []*abci.Snapshot + expectedErr error + }{ + "prune nothing with snapshot": { + config: &setupConfig{ + blocks: 20, + blockTxs: 2, + snapshotInterval: 5, + snapshotKeepRecent: 1, + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), + }, + expectedSnapshots: []*abci.Snapshot{ + {Height: 20, Format: 2, Chunks: 5}, + }, + }, + "prune everything with snapshot": { + config: &setupConfig{ + blocks: 20, + blockTxs: 2, + snapshotInterval: 5, + snapshotKeepRecent: 1, + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningEverything), + }, + expectedSnapshots: []*abci.Snapshot{ + {Height: 20, Format: 2, Chunks: 5}, + }, + }, + "default pruning with snapshot": { + config: &setupConfig{ + blocks: 20, + blockTxs: 2, + snapshotInterval: 5, + snapshotKeepRecent: 1, + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningDefault), + }, + expectedSnapshots: []*abci.Snapshot{ + {Height: 20, Format: 2, Chunks: 5}, + }, + }, + "custom": { + config: &setupConfig{ + blocks: 25, + blockTxs: 2, + snapshotInterval: 5, + snapshotKeepRecent: 2, + pruningOpts: pruningtypes.NewCustomPruningOptions(12, 12), + }, + expectedSnapshots: []*abci.Snapshot{ + {Height: 25, Format: 2, Chunks: 6}, + {Height: 20, Format: 2, Chunks: 5}, + }, + }, + "no snapshots": { + config: &setupConfig{ + blocks: 10, + blockTxs: 2, + snapshotInterval: 0, // 0 implies disable snapshots + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), + }, + expectedSnapshots: []*abci.Snapshot{}, + }, + "keep all snapshots": { + config: &setupConfig{ + blocks: 10, + blockTxs: 2, + snapshotInterval: 3, + snapshotKeepRecent: 0, // 0 implies keep all snapshots + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), + }, + expectedSnapshots: []*abci.Snapshot{ + {Height: 9, Format: 2, Chunks: 2}, + {Height: 6, Format: 2, Chunks: 2}, + {Height: 3, Format: 2, Chunks: 1}, + }, + }, + } - app, teardown := setupBaseAppWithSnapshots(t, 2, 5) - defer teardown() + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + app, err := setupBaseAppWithSnapshots(t, tc.config) + + if tc.expectedErr != nil { + require.Error(t, err) + require.Equal(t, tc.expectedErr.Error(), err.Error()) + return + } + require.NoError(t, err) + + resp := app.ListSnapshots(abci.RequestListSnapshots{}) + for _, s := range resp.Snapshots { + assert.NotEmpty(t, s.Hash) + assert.NotEmpty(t, s.Metadata) + s.Hash = nil + s.Metadata = nil + } + fmt.Println(resp) + assert.Equal(t, abci.ResponseListSnapshots{Snapshots: tc.expectedSnapshots}, resp) + + // Validate that heights were pruned correctly by querying the state at the last height that should be present relative to latest + // and the first height that should be pruned. + // + // Exceptions: + // * Prune nothing: should be able to query all heights (we only test first and latest) + // * Prune default: should be able to query all heights (we only test first and latest) + // * The reason for default behaving this way is that we only commit 20 heights but default has 100_000 keep-recent + var lastExistingHeight int64 + if tc.config.pruningOpts.GetPruningStrategy() == pruningtypes.PruningNothing || tc.config.pruningOpts.GetPruningStrategy() == pruningtypes.PruningDefault { + lastExistingHeight = 1 + } else { + // Integer division rounds down so by multiplying back we get the last height at which we pruned + lastExistingHeight = int64((tc.config.blocks/tc.config.pruningOpts.Interval)*tc.config.pruningOpts.Interval - tc.config.pruningOpts.KeepRecent) + } + + // Query 1 + res := app.Query(abci.RequestQuery{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight}) + require.NotNil(t, res, "height: %d", lastExistingHeight) + require.NotNil(t, res.Value, "height: %d", lastExistingHeight) + + // Query 2 + res = app.Query(abci.RequestQuery{Path: fmt.Sprintf("/store/%s/key", capKey2.Name()), Data: []byte("0"), Height: lastExistingHeight - 1}) + require.NotNil(t, res, "height: %d", lastExistingHeight-1) + if tc.config.pruningOpts.GetPruningStrategy() == pruningtypes.PruningNothing || tc.config.pruningOpts.GetPruningStrategy() == pruningtypes.PruningDefault { + // With prune nothing or default, we query height 0 which translates to the latest height. + require.NotNil(t, res.Value, "height: %d", lastExistingHeight-1) + } + }) + } +} + +func TestLoadSnapshotChunk(t *testing.T) { + setupConfig := &setupConfig{ + blocks: 2, + blockTxs: 5, + snapshotInterval: 2, + snapshotKeepRecent: 2, + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), + } + app, err := setupBaseAppWithSnapshots(t, setupConfig) + require.NoError(t, err) testcases := map[string]struct { height uint64 @@ -1864,11 +1797,16 @@ func TestLoadSnapshotChunk(t *testing.T) { } func TestOfferSnapshot_Errors(t *testing.T) { - t.Skip("disabled pending MultiStore snapshot implementation") - // Set up app before test cases, since it's fairly expensive. - app, teardown := setupBaseAppWithSnapshots(t, 0, 0) - defer teardown() + setupConfig := &setupConfig{ + blocks: 0, + blockTxs: 0, + snapshotInterval: 2, + snapshotKeepRecent: 2, + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), + } + app, err := setupBaseAppWithSnapshots(t, setupConfig) + require.NoError(t, err) m := snapshottypes.Metadata{ChunkHashes: [][]byte{{1}, {2}, {3}}} metadata, err := m.Marshal() @@ -1922,13 +1860,25 @@ func TestOfferSnapshot_Errors(t *testing.T) { } func TestApplySnapshotChunk(t *testing.T) { - t.Skip("disabled pending MultiStore snapshot implementation") - - source, teardown := setupBaseAppWithSnapshots(t, 4, 10) - defer teardown() + setupConfig1 := &setupConfig{ + blocks: 4, + blockTxs: 10, + snapshotInterval: 2, + snapshotKeepRecent: 2, + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), + } + source, err := setupBaseAppWithSnapshots(t, setupConfig1) + require.NoError(t, err) - target, teardown := setupBaseAppWithSnapshots(t, 0, 0) - defer teardown() + setupConfig2 := &setupConfig{ + blocks: 0, + blockTxs: 0, + snapshotInterval: 2, + snapshotKeepRecent: 2, + pruningOpts: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), + } + target, err := setupBaseAppWithSnapshots(t, setupConfig2) + require.NoError(t, err) // Fetch latest snapshot to restore respList := source.ListSnapshots(abci.RequestListSnapshots{}) @@ -1995,22 +1945,25 @@ func (rtr *testCustomRouter) Route(ctx sdk.Context, path string) sdk.Handler { } func TestWithRouter(t *testing.T) { + // test increments in the ante + anteKey := []byte("ante-key") + anteOpt := func(bapp *BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } + // test increments in the handler deliverKey := []byte("deliver-key") - - txHandlerOpt := func(bapp *baseapp.BaseApp) { - customRouter := &testCustomRouter{routes: sync.Map{}} + routerOpt := func(bapp *BaseApp) { + bapp.SetRouter(&testCustomRouter{routes: sync.Map{}}) r := sdk.NewRoute(routeMsgCounter, handlerMsgCounter(t, capKey1, deliverKey)) - customRouter.AddRoute(r) - txHandler := middleware.ComposeMiddlewares( - middleware.NewRunMsgsTxHandler(middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), customRouter), - middleware.NewTxDecoderMiddleware(testTxDecoder(encCfg.Amino)), - ) - bapp.SetTxHandler(txHandler) + bapp.Router().AddRoute(r) } - app := setupBaseApp(t, baseapp.AppOptionFunc(txHandlerOpt)) + + app := setupBaseApp(t, AppOptionFunc(anteOpt), AppOptionFunc(routerOpt)) app.InitChain(abci.RequestInitChain{}) + // Create same codec used in txDecoder + codec := codec.NewLegacyAmino() + registerTestCodec(codec) + nBlocks := 3 txPerHeight := 5 @@ -2022,7 +1975,7 @@ func TestWithRouter(t *testing.T) { counter := int64(blockN*txPerHeight + i) tx := newTxCounter(counter, counter) - txBytes, err := encCfg.Amino.Marshal(tx) + txBytes, err := codec.Marshal(tx) require.NoError(t, err) res := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) @@ -2045,7 +1998,7 @@ func TestBaseApp_EndBlock(t *testing.T) { }, } - app := baseapp.NewBaseApp(name, logger, db) + app := NewBaseApp(name, logger, db, nil) app.SetParamStore(newParamStore(memdb.NewDB())) app.InitChain(abci.RequestInitChain{ ConsensusParams: cp, diff --git a/baseapp/block_gas_test.go b/baseapp/block_gas_test.go new file mode 100644 index 000000000000..a402a0bb9549 --- /dev/null +++ b/baseapp/block_gas_test.go @@ -0,0 +1,201 @@ +package baseapp_test + +import ( + "fmt" + "math" + "testing" + + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + tmjson "github.com/tendermint/tendermint/libs/json" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/db/memdb" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + txtypes "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" +) + +var blockMaxGas = uint64(simapp.DefaultConsensusParams.Block.MaxGas) + +func TestBaseApp_BlockGas(t *testing.T) { + testcases := []struct { + name string + gasToConsume uint64 // gas to consume in the msg execution + panicTx bool // panic explicitly in tx execution + expErr bool + }{ + {"less than block gas meter", 10, false, false}, + {"more than block gas meter", blockMaxGas, false, true}, + {"more than block gas meter", uint64(float64(blockMaxGas) * 1.2), false, true}, + {"consume MaxUint64", math.MaxUint64, false, true}, + {"consume MaxGasWanted", txtypes.MaxGasWanted, false, true}, + {"consume block gas when paniced", 10, true, true}, + } + for _, tc := range testcases { + t.Run(tc.name, func(t *testing.T) { + var app *simapp.SimApp + routerOpt := func(bapp *baseapp.BaseApp) { + route := (&testdata.TestMsg{}).Route() + bapp.Router().AddRoute(sdk.NewRoute(route, func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + _, ok := msg.(*testdata.TestMsg) + if !ok { + return &sdk.Result{}, fmt.Errorf("Wrong Msg type, expected %T, got %T", (*testdata.TestMsg)(nil), msg) + } + ctx.KVStore(app.GetKey(banktypes.ModuleName)).Set([]byte("ok"), []byte("ok")) + ctx.GasMeter().ConsumeGas(tc.gasToConsume, "TestMsg") + if tc.panicTx { + panic("panic in tx execution") + } + return &sdk.Result{}, nil + })) + } + encCfg := simapp.MakeTestEncodingConfig() + encCfg.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) + encCfg.InterfaceRegistry.RegisterImplementations((*sdk.Msg)(nil), + &testdata.TestMsg{}, + ) + app = simapp.NewSimApp(log.NewNopLogger(), memdb.NewDB(), nil, true, map[int64]bool{}, "", 0, encCfg, simapp.EmptyAppOptions{}, baseapp.AppOptionFunc(routerOpt)) + genState := simapp.GenesisStateWithSingleValidator(t, app) + stateBytes, err := tmjson.MarshalIndent(genState, "", " ") + require.NoError(t, err) + app.InitChain(abci.RequestInitChain{ + Validators: []abci.ValidatorUpdate{}, + ConsensusParams: simapp.DefaultConsensusParams, + AppStateBytes: stateBytes, + }) + + ctx := app.NewContext(false, tmproto.Header{}) + + // tx fee + feeCoin := sdk.NewCoin("atom", sdk.NewInt(150)) + feeAmount := sdk.NewCoins(feeCoin) + + // test account and fund + priv1, _, addr1 := testdata.KeyTestPubAddr() + err = app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, feeAmount) + require.NoError(t, err) + err = app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr1, feeAmount) + require.NoError(t, err) + require.Equal(t, feeCoin.Amount, app.BankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount) + seq, _ := app.AccountKeeper.GetSequence(ctx, addr1) + require.Equal(t, uint64(0), seq) + + // msg and signatures + msg := testdata.NewTestMsg(addr1) + + txBuilder := encCfg.TxConfig.NewTxBuilder() + require.NoError(t, txBuilder.SetMsgs(msg)) + txBuilder.SetFeeAmount(feeAmount) + txBuilder.SetGasLimit(txtypes.MaxGasWanted) // tx validation checks that gasLimit can't be bigger than this + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{7}, []uint64{0} + _, txBytes, err := createTestTx(encCfg.TxConfig, txBuilder, privs, accNums, accSeqs, ctx.ChainID()) + require.NoError(t, err) + + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 1}}) + rsp := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) + + // check result + ctx = app.GetContextForDeliverTx(txBytes) + okValue := ctx.KVStore(app.GetKey(banktypes.ModuleName)).Get([]byte("ok")) + + if tc.expErr { + if tc.panicTx { + require.Equal(t, sdkerrors.ErrPanic.ABCICode(), rsp.Code) + } else { + require.Equal(t, sdkerrors.ErrOutOfGas.ABCICode(), rsp.Code) + } + require.Empty(t, okValue) + } else { + require.Equal(t, uint32(0), rsp.Code) + require.Equal(t, []byte("ok"), okValue) + } + // check block gas is always consumed + baseGas := uint64(63724) // baseGas is the gas consumed before tx msg + expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas) + if expGasConsumed > txtypes.MaxGasWanted { + // capped by gasLimit + expGasConsumed = txtypes.MaxGasWanted + } + require.Equal(t, expGasConsumed, ctx.BlockGasMeter().GasConsumed()) + // tx fee is always deducted + require.Equal(t, int64(0), app.BankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount.Int64()) + // sender's sequence is always increased + seq, err = app.AccountKeeper.GetSequence(ctx, addr1) + require.NoError(t, err) + require.Equal(t, uint64(1), seq) + }) + } +} + +func createTestTx(txConfig client.TxConfig, txBuilder client.TxBuilder, privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, []byte, error) { + // First round: we gather all the signer infos. We use the "set empty + // signature" hack to do that. + var sigsV2 []signing.SignatureV2 + for i, priv := range privs { + sigV2 := signing.SignatureV2{ + PubKey: priv.PubKey(), + Data: &signing.SingleSignatureData{ + SignMode: txConfig.SignModeHandler().DefaultMode(), + Signature: nil, + }, + Sequence: accSeqs[i], + } + + sigsV2 = append(sigsV2, sigV2) + } + err := txBuilder.SetSignatures(sigsV2...) + if err != nil { + return nil, nil, err + } + + // Second round: all signer infos are set, so each signer can sign. + sigsV2 = []signing.SignatureV2{} + for i, priv := range privs { + signerData := xauthsigning.SignerData{ + Address: sdk.AccAddress(priv.PubKey().Bytes()).String(), + ChainID: chainID, + AccountNumber: accNums[i], + Sequence: accSeqs[i], + } + sigV2, err := tx.SignWithPrivKey( + txConfig.SignModeHandler().DefaultMode(), signerData, + txBuilder, priv, txConfig, accSeqs[i]) + if err != nil { + return nil, nil, err + } + + sigsV2 = append(sigsV2, sigV2) + } + err = txBuilder.SetSignatures(sigsV2...) + if err != nil { + return nil, nil, err + } + + txBytes, err := txConfig.TxEncoder()(txBuilder.GetTx()) + if err != nil { + return nil, nil, err + } + + return txBuilder.GetTx(), txBytes, nil +} + +func addUint64Saturating(a, b uint64) uint64 { + if math.MaxUint64-a < b { + return math.MaxUint64 + } + + return a + b +} diff --git a/baseapp/custom_txhandler_test.go b/baseapp/custom_txhandler_test.go deleted file mode 100644 index 4a2a4c4f82a6..000000000000 --- a/baseapp/custom_txhandler_test.go +++ /dev/null @@ -1,116 +0,0 @@ -package baseapp_test - -import ( - "context" - "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/tendermint/tendermint/crypto/tmhash" -) - -type handlerFun func(ctx sdk.Context, tx sdk.Tx, simulate bool) (newCtx sdk.Context, err error) - -type customTxHandler struct { - handler handlerFun - next tx.Handler -} - -var _ tx.Handler = customTxHandler{} - -// CustomTxMiddleware is being used in tests for testing -// custom pre-`runMsgs` logic (also called antehandlers before). -func CustomTxHandlerMiddleware(handler handlerFun) tx.Middleware { - return func(txHandler tx.Handler) tx.Handler { - return customTxHandler{ - handler: handler, - next: txHandler, - } - } -} - -// CheckTx implements tx.Handler.CheckTx method. -func (txh customTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - sdkCtx, err := txh.runHandler(ctx, req.Tx, req.TxBytes, false) - if err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return txh.next.CheckTx(sdk.WrapSDKContext(sdkCtx), req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx method. -func (txh customTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - sdkCtx, err := txh.runHandler(ctx, req.Tx, req.TxBytes, false) - if err != nil { - return tx.Response{}, err - } - - return txh.next.DeliverTx(sdk.WrapSDKContext(sdkCtx), req) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (txh customTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - sdkCtx, err := txh.runHandler(ctx, req.Tx, req.TxBytes, true) - if err != nil { - return tx.Response{}, err - } - - return txh.next.SimulateTx(sdk.WrapSDKContext(sdkCtx), req) -} - -func (txh customTxHandler) runHandler(ctx context.Context, tx sdk.Tx, txBytes []byte, isSimulate bool) (sdk.Context, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - if txh.handler == nil { - return sdkCtx, nil - } - - store := sdkCtx.MultiStore() - - // Branch context before Handler call in case it aborts. - // This is required for both CheckTx and DeliverTx. - // Ref: https://github.com/cosmos/cosmos-sdk/issues/2772 - // - // NOTE: Alternatively, we could require that Handler ensures that - // writes do not happen if aborted/failed. This may have some - // performance benefits, but it'll be more difficult to get right. - cacheCtx, storeCache := cacheTxContext(sdkCtx, txBytes) - cacheCtx = cacheCtx.WithEventManager(sdk.NewEventManager()) - newCtx, err := txh.handler(cacheCtx, tx, isSimulate) - if err != nil { - return sdk.Context{}, err - } - - if !newCtx.IsZero() { - // At this point, newCtx.MultiStore() is a store branch, or something else - // replaced by the Handler. We want the original multistore. - // - // Also, in the case of the tx aborting, we need to track gas consumed via - // the instantiated gas meter in the Handler, so we update the context - // prior to returning. - sdkCtx = newCtx.WithMultiStore(store) - } - - storeCache.Write() - - return sdkCtx, nil -} - -// cacheTxContext returns a new context based off of the provided context with -// a branched multi-store. -func cacheTxContext(sdkCtx sdk.Context, txBytes []byte) (sdk.Context, sdk.CacheMultiStore) { - store := sdkCtx.MultiStore() - // TODO: https://github.com/cosmos/cosmos-sdk/issues/2824 - storeCache := store.CacheWrap() - if storeCache.TracingEnabled() { - storeCache.SetTracingContext( - sdk.TraceContext( - map[string]interface{}{ - "txHash": fmt.Sprintf("%X", tmhash.Sum(txBytes)), - }, - ), - ) - } - - return sdkCtx.WithMultiStore(storeCache), storeCache -} diff --git a/baseapp/grpcrouter.go b/baseapp/grpcrouter.go index 59c9ff519c6c..3e3e54691a7f 100644 --- a/baseapp/grpcrouter.go +++ b/baseapp/grpcrouter.go @@ -3,16 +3,13 @@ package baseapp import ( "fmt" - "google.golang.org/grpc/encoding" - - "github.com/cosmos/cosmos-sdk/codec" - - "github.com/cosmos/cosmos-sdk/client/grpc/reflection" - gogogrpc "github.com/gogo/protobuf/grpc" abci "github.com/tendermint/tendermint/abci/types" "google.golang.org/grpc" + "google.golang.org/grpc/encoding" + "github.com/cosmos/cosmos-sdk/client/grpc/reflection" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/baseapp/grpcrouter_test.go b/baseapp/grpcrouter_test.go index 6e9cedcc201b..cfeb997d3573 100644 --- a/baseapp/grpcrouter_test.go +++ b/baseapp/grpcrouter_test.go @@ -5,8 +5,6 @@ import ( "sync" "testing" - "github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar" - "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/libs/log" @@ -15,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/db/memdb" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" + "github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -56,8 +55,7 @@ func TestRegisterQueryServiceTwice(t *testing.T) { // Setup baseapp. db := memdb.NewDB() encCfg := simapp.MakeTestEncodingConfig() - logger, _ := log.NewDefaultLogger("plain", "info", false) - app := baseapp.NewBaseApp("test", logger, db) + app := baseapp.NewBaseApp("test", log.MustNewDefaultLogger("plain", "info", false), db, encCfg.TxConfig.TxDecoder()) app.SetInterfaceRegistry(encCfg.InterfaceRegistry) testdata.RegisterInterfaces(encCfg.InterfaceRegistry) diff --git a/baseapp/grpcserver.go b/baseapp/grpcserver.go index 68cc14e66545..9b4626cd142c 100644 --- a/baseapp/grpcserver.go +++ b/baseapp/grpcserver.go @@ -61,7 +61,9 @@ func (app *BaseApp) RegisterGRPCServer(server gogogrpc.Server) { grpcCtx = context.WithValue(grpcCtx, sdk.SdkContextKey, sdkCtx) md = metadata.Pairs(grpctypes.GRPCBlockHeightHeader, strconv.FormatInt(height, 10)) - grpc.SetHeader(grpcCtx, md) + if err = grpc.SetHeader(grpcCtx, md); err != nil { + app.logger.Error("failed to set gRPC header", "err", err) + } return handler(grpcCtx, req) } diff --git a/x/auth/middleware/msg_service_router.go b/baseapp/msg_service_router.go similarity index 94% rename from x/auth/middleware/msg_service_router.go rename to baseapp/msg_service_router.go index 79aea3350c91..f6c8d4b21ce7 100644 --- a/x/auth/middleware/msg_service_router.go +++ b/baseapp/msg_service_router.go @@ -1,4 +1,4 @@ -package middleware +package baseapp import ( "context" @@ -22,10 +22,9 @@ type MsgServiceRouter struct { var _ gogogrpc.Server = &MsgServiceRouter{} // NewMsgServiceRouter creates a new MsgServiceRouter. -func NewMsgServiceRouter(registry codectypes.InterfaceRegistry) *MsgServiceRouter { +func NewMsgServiceRouter() *MsgServiceRouter { return &MsgServiceRouter{ - interfaceRegistry: registry, - routes: map[string]MsgServiceHandler{}, + routes: map[string]MsgServiceHandler{}, } } @@ -130,6 +129,11 @@ func (msr *MsgServiceRouter) RegisterService(sd *grpc.ServiceDesc, handler inter } } +// SetInterfaceRegistry sets the interface registry for the router. +func (msr *MsgServiceRouter) SetInterfaceRegistry(interfaceRegistry codectypes.InterfaceRegistry) { + msr.interfaceRegistry = interfaceRegistry +} + func noopDecoder(_ interface{}) error { return nil } func noopInterceptor(_ context.Context, _ interface{}, _ *grpc.UnaryServerInfo, _ grpc.UnaryHandler) (interface{}, error) { return nil, nil diff --git a/baseapp/msg_service_router_test.go b/baseapp/msg_service_router_test.go new file mode 100644 index 000000000000..82899caaaaa5 --- /dev/null +++ b/baseapp/msg_service_router_test.go @@ -0,0 +1,121 @@ +package baseapp_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/db/memdb" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" +) + +func TestRegisterMsgService(t *testing.T) { + db := memdb.NewDB() + + // Create an encoding config that doesn't register testdata Msg services. + encCfg := simapp.MakeTestEncodingConfig() + app := baseapp.NewBaseApp("test", log.MustNewDefaultLogger("plain", "info", false), db, encCfg.TxConfig.TxDecoder()) + app.SetInterfaceRegistry(encCfg.InterfaceRegistry) + require.Panics(t, func() { + testdata.RegisterMsgServer( + app.MsgServiceRouter(), + testdata.MsgServerImpl{}, + ) + }) + + // Register testdata Msg services, and rerun `RegisterService`. + testdata.RegisterInterfaces(encCfg.InterfaceRegistry) + require.NotPanics(t, func() { + testdata.RegisterMsgServer( + app.MsgServiceRouter(), + testdata.MsgServerImpl{}, + ) + }) +} + +func TestRegisterMsgServiceTwice(t *testing.T) { + // Setup baseapp. + db := memdb.NewDB() + encCfg := simapp.MakeTestEncodingConfig() + app := baseapp.NewBaseApp("test", log.MustNewDefaultLogger("plain", "info", false), db, encCfg.TxConfig.TxDecoder()) + app.SetInterfaceRegistry(encCfg.InterfaceRegistry) + testdata.RegisterInterfaces(encCfg.InterfaceRegistry) + + // First time registering service shouldn't panic. + require.NotPanics(t, func() { + testdata.RegisterMsgServer( + app.MsgServiceRouter(), + testdata.MsgServerImpl{}, + ) + }) + + // Second time should panic. + require.Panics(t, func() { + testdata.RegisterMsgServer( + app.MsgServiceRouter(), + testdata.MsgServerImpl{}, + ) + }) +} + +func TestMsgService(t *testing.T) { + priv, _, _ := testdata.KeyTestPubAddr() + encCfg := simapp.MakeTestEncodingConfig() + testdata.RegisterInterfaces(encCfg.InterfaceRegistry) + db := memdb.NewDB() + app := baseapp.NewBaseApp("test", log.MustNewDefaultLogger("plain", "info", false), db, encCfg.TxConfig.TxDecoder()) + app.SetInterfaceRegistry(encCfg.InterfaceRegistry) + testdata.RegisterMsgServer( + app.MsgServiceRouter(), + testdata.MsgServerImpl{}, + ) + _ = app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 1}}) + + msg := testdata.MsgCreateDog{Dog: &testdata.Dog{Name: "Spot"}} + txBuilder := encCfg.TxConfig.NewTxBuilder() + txBuilder.SetFeeAmount(testdata.NewTestFeeAmount()) + txBuilder.SetGasLimit(testdata.NewTestGasLimit()) + err := txBuilder.SetMsgs(&msg) + require.NoError(t, err) + + // First round: we gather all the signer infos. We use the "set empty + // signature" hack to do that. + sigV2 := signing.SignatureV2{ + PubKey: priv.PubKey(), + Data: &signing.SingleSignatureData{ + SignMode: encCfg.TxConfig.SignModeHandler().DefaultMode(), + Signature: nil, + }, + Sequence: 0, + } + + err = txBuilder.SetSignatures(sigV2) + require.NoError(t, err) + + // Second round: all signer infos are set, so each signer can sign. + signerData := authsigning.SignerData{ + ChainID: "test", + AccountNumber: 0, + Sequence: 0, + } + sigV2, err = tx.SignWithPrivKey( + encCfg.TxConfig.SignModeHandler().DefaultMode(), signerData, + txBuilder, priv, encCfg.TxConfig, 0) + require.NoError(t, err) + err = txBuilder.SetSignatures(sigV2) + require.NoError(t, err) + + // Send the tx to the app + txBytes, err := encCfg.TxConfig.TxEncoder()(txBuilder.GetTx()) + require.NoError(t, err) + res := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) + require.Equal(t, abci.CodeTypeOK, res.Code, "res=%+v", res) +} diff --git a/baseapp/options.go b/baseapp/options.go index 776e98c455aa..0bfe5fe0c95c 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -5,18 +5,19 @@ import ( "io" "github.com/cosmos/cosmos-sdk/codec/types" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/snapshots" + snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" storetypes "github.com/cosmos/cosmos-sdk/store/v2alpha1" "github.com/cosmos/cosmos-sdk/store/v2alpha1/multi" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" ) // File for storing in-package BaseApp optional functions, // for options that need access to non-exported fields of the BaseApp // SetPruning sets a pruning option on the multistore associated with the app -func SetPruning(opts sdk.PruningOptions) StoreOption { +func SetPruning(opts pruningtypes.PruningOptions) StoreOption { return func(config *multi.StoreParams, _ uint64) error { config.Pruning = opts; return nil } } @@ -67,24 +68,6 @@ func SetInterBlockCache(cache sdk.MultiStorePersistentCache) AppOptionFunc { return func(app *BaseApp) { app.storeOpts = append(app.storeOpts, opt) } } -// SetSnapshotInterval sets the snapshot interval. -func SetSnapshotInterval(interval uint64) AppOptionFunc { - return func(app *BaseApp) { app.SetSnapshotInterval(interval) } -} - -// SetSnapshotKeepRecent sets the recent snapshots to keep. -func SetSnapshotKeepRecent(keepRecent uint32) AppOptionFunc { - return func(app *BaseApp) { app.SetSnapshotKeepRecent(keepRecent) } -} - -// SetSnapshotStore sets the snapshot store. -func SetSnapshotStore(snapshotStore *snapshots.Store) AppOptionOrdered { - return AppOptionOrdered{ - func(app *BaseApp) { app.SetSnapshotStore(snapshotStore) }, - OptionOrderAfterStore, - } -} - // SetSubstores registers substores according to app configuration func SetSubstores(keys ...storetypes.StoreKey) StoreOption { return func(config *multi.StoreParams, _ uint64) error { @@ -101,6 +84,14 @@ func SetSubstores(keys ...storetypes.StoreKey) StoreOption { } } +// SetSnapshot sets the snapshot store. +func SetSnapshot(snapshotStore *snapshots.Store, opts snapshottypes.SnapshotOptions) AppOption { + return AppOptionOrdered{ + func(app *BaseApp) { app.SetSnapshot(snapshotStore, opts) }, + OptionOrderAfterStore, + } +} + func (app *BaseApp) SetName(name string) { if app.sealed { panic("SetName() on sealed BaseApp") @@ -155,12 +146,20 @@ func (app *BaseApp) SetEndBlocker(endBlocker sdk.EndBlocker) { app.endBlocker = endBlocker } -func (app *BaseApp) SetTxHandler(txHandler tx.Handler) { +func (app *BaseApp) SetAnteHandler(ah sdk.AnteHandler) { if app.sealed { - panic("SetTxHandler() on sealed BaseApp") + panic("SetAnteHandler() on sealed BaseApp") } - app.txHandler = txHandler + app.anteHandler = ah +} + +func (app *BaseApp) SetPostHandler(ph sdk.AnteHandler) { + if app.sealed { + panic("SetPostHandler() on sealed BaseApp") + } + + app.postHandler = ph } func (app *BaseApp) SetAddrPeerFilter(pf sdk.PeerFilter) { @@ -197,38 +196,32 @@ func (app *BaseApp) SetCommitMultiStoreTracer(w io.Writer) { app.storeOpts = append(app.storeOpts, opt) } -// SetSnapshotStore sets the snapshot store. -func (app *BaseApp) SetSnapshotStore(snapshotStore *snapshots.Store) { +// SetRouter allows us to customize the router. +func (app *BaseApp) SetRouter(router sdk.Router) { if app.sealed { - panic("SetSnapshotStore() on sealed BaseApp") + panic("SetRouter() on sealed BaseApp") } - if snapshotStore == nil { - app.snapshotManager = nil - return - } - app.snapshotManager = snapshots.NewManager(snapshotStore, app.store, nil) + app.router = router } -// SetSnapshotInterval sets the snapshot interval. -func (app *BaseApp) SetSnapshotInterval(snapshotInterval uint64) { +// SetSnapshot sets the snapshot store and options. +func (app *BaseApp) SetSnapshot(snapshotStore *snapshots.Store, opts snapshottypes.SnapshotOptions) { if app.sealed { - panic("SetSnapshotInterval() on sealed BaseApp") + panic("SetSnapshot() on sealed BaseApp") } - app.snapshotInterval = snapshotInterval -} - -// SetSnapshotKeepRecent sets the number of recent snapshots to keep. -func (app *BaseApp) SetSnapshotKeepRecent(snapshotKeepRecent uint32) { - if app.sealed { - panic("SetSnapshotKeepRecent() on sealed BaseApp") + if snapshotStore == nil || opts.Interval == snapshottypes.SnapshotIntervalOff { + app.snapshotManager = nil + return } - app.snapshotKeepRecent = snapshotKeepRecent + app.store.SetSnapshotInterval(opts.Interval) + app.snapshotManager = snapshots.NewManager(snapshotStore, opts, app.store, nil, app.logger) } // SetInterfaceRegistry sets the InterfaceRegistry. func (app *BaseApp) SetInterfaceRegistry(registry types.InterfaceRegistry) { app.interfaceRegistry = registry app.grpcQueryRouter.SetInterfaceRegistry(registry) + app.msgServiceRouter.SetInterfaceRegistry(registry) } // SetStreamingService is used to set a streaming service into the BaseApp hooks and load the listeners into the multistore diff --git a/baseapp/queryrouter_test.go b/baseapp/queryrouter_test.go index 4b38f6458641..c7637f17000e 100644 --- a/baseapp/queryrouter_test.go +++ b/baseapp/queryrouter_test.go @@ -1,4 +1,4 @@ -package baseapp_test +package baseapp import ( "testing" @@ -7,7 +7,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -16,7 +15,7 @@ var testQuerier = func(_ sdk.Context, _ []string, _ abci.RequestQuery) ([]byte, } func TestQueryRouter(t *testing.T) { - qr := baseapp.NewQueryRouter() + qr := NewQueryRouter() // require panic on invalid route require.Panics(t, func() { diff --git a/baseapp/recovery.go b/baseapp/recovery.go new file mode 100644 index 000000000000..7f0687800c65 --- /dev/null +++ b/baseapp/recovery.go @@ -0,0 +1,77 @@ +package baseapp + +import ( + "fmt" + "runtime/debug" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// RecoveryHandler handles recovery() object. +// Return a non-nil error if recoveryObj was processed. +// Return nil if recoveryObj was not processed. +type RecoveryHandler func(recoveryObj interface{}) error + +// recoveryMiddleware is wrapper for RecoveryHandler to create chained recovery handling. +// returns (recoveryMiddleware, nil) if recoveryObj was not processed and should be passed to the next middleware in chain. +// returns (nil, error) if recoveryObj was processed and middleware chain processing should be stopped. +type recoveryMiddleware func(recoveryObj interface{}) (recoveryMiddleware, error) + +// processRecovery processes recoveryMiddleware chain for recovery() object. +// Chain processing stops on non-nil error or when chain is processed. +func processRecovery(recoveryObj interface{}, middleware recoveryMiddleware) error { + if middleware == nil { + return nil + } + + next, err := middleware(recoveryObj) + if err != nil { + return err + } + + return processRecovery(recoveryObj, next) +} + +// newRecoveryMiddleware creates a RecoveryHandler middleware. +func newRecoveryMiddleware(handler RecoveryHandler, next recoveryMiddleware) recoveryMiddleware { + return func(recoveryObj interface{}) (recoveryMiddleware, error) { + if err := handler(recoveryObj); err != nil { + return nil, err + } + + return next, nil + } +} + +// newOutOfGasRecoveryMiddleware creates a standard OutOfGas recovery middleware for app.runTx method. +func newOutOfGasRecoveryMiddleware(gasWanted uint64, ctx sdk.Context, next recoveryMiddleware) recoveryMiddleware { + handler := func(recoveryObj interface{}) error { + err, ok := recoveryObj.(sdk.ErrorOutOfGas) + if !ok { + return nil + } + + return sdkerrors.Wrap( + sdkerrors.ErrOutOfGas, fmt.Sprintf( + "out of gas in location: %v; gasWanted: %d, gasUsed: %d", + err.Descriptor, gasWanted, ctx.GasMeter().GasConsumed(), + ), + ) + } + + return newRecoveryMiddleware(handler, next) +} + +// newDefaultRecoveryMiddleware creates a default (last in chain) recovery middleware for app.runTx method. +func newDefaultRecoveryMiddleware() recoveryMiddleware { + handler := func(recoveryObj interface{}) error { + return sdkerrors.Wrap( + sdkerrors.ErrPanic, fmt.Sprintf( + "recovered: %v\nstack:\n%v", recoveryObj, string(debug.Stack()), + ), + ) + } + + return newRecoveryMiddleware(handler, nil) +} diff --git a/baseapp/recovery_test.go b/baseapp/recovery_test.go new file mode 100644 index 000000000000..b75892c63818 --- /dev/null +++ b/baseapp/recovery_test.go @@ -0,0 +1,64 @@ +package baseapp + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" +) + +// Test that recovery chain produces expected error at specific middleware layer +func TestRecoveryChain(t *testing.T) { + createError := func(id int) error { + return fmt.Errorf("error from id: %d", id) + } + + createHandler := func(id int, handle bool) RecoveryHandler { + return func(_ interface{}) error { + if handle { + return createError(id) + } + return nil + } + } + + // check recovery chain [1] -> 2 -> 3 + { + mw := newRecoveryMiddleware(createHandler(3, false), nil) + mw = newRecoveryMiddleware(createHandler(2, false), mw) + mw = newRecoveryMiddleware(createHandler(1, true), mw) + receivedErr := processRecovery(nil, mw) + + require.Equal(t, createError(1), receivedErr) + } + + // check recovery chain 1 -> [2] -> 3 + { + mw := newRecoveryMiddleware(createHandler(3, false), nil) + mw = newRecoveryMiddleware(createHandler(2, true), mw) + mw = newRecoveryMiddleware(createHandler(1, false), mw) + receivedErr := processRecovery(nil, mw) + + require.Equal(t, createError(2), receivedErr) + } + + // check recovery chain 1 -> 2 -> [3] + { + mw := newRecoveryMiddleware(createHandler(3, true), nil) + mw = newRecoveryMiddleware(createHandler(2, false), mw) + mw = newRecoveryMiddleware(createHandler(1, false), mw) + receivedErr := processRecovery(nil, mw) + + require.Equal(t, createError(3), receivedErr) + } + + // check recovery chain 1 -> 2 -> 3 + { + mw := newRecoveryMiddleware(createHandler(3, false), nil) + mw = newRecoveryMiddleware(createHandler(2, false), mw) + mw = newRecoveryMiddleware(createHandler(1, false), mw) + receivedErr := processRecovery(nil, mw) + + require.Nil(t, receivedErr) + } +} diff --git a/x/auth/middleware/legacy_router.go b/baseapp/router.go similarity index 71% rename from x/auth/middleware/legacy_router.go rename to baseapp/router.go index caf4424c9829..7e2e70a0c6f3 100644 --- a/x/auth/middleware/legacy_router.go +++ b/baseapp/router.go @@ -1,4 +1,4 @@ -package middleware +package baseapp import ( "fmt" @@ -6,22 +6,22 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -type LegacyRouter struct { +type Router struct { routes map[string]sdk.Handler } -var _ sdk.Router = NewLegacyRouter() +var _ sdk.Router = NewRouter() // NewRouter returns a reference to a new router. -func NewLegacyRouter() *LegacyRouter { - return &LegacyRouter{ +func NewRouter() *Router { + return &Router{ routes: make(map[string]sdk.Handler), } } // AddRoute adds a route path to the router with a given handler. The route must // be alphanumeric. -func (rtr *LegacyRouter) AddRoute(route sdk.Route) sdk.Router { +func (rtr *Router) AddRoute(route sdk.Route) sdk.Router { if !sdk.IsAlphaNumeric(route.Path()) { panic("route expressions can only contain alphanumeric characters") } @@ -36,6 +36,6 @@ func (rtr *LegacyRouter) AddRoute(route sdk.Route) sdk.Router { // Route returns a handler for a given route path. // // TODO: Handle expressive matches. -func (rtr *LegacyRouter) Route(_ sdk.Context, path string) sdk.Handler { +func (rtr *Router) Route(_ sdk.Context, path string) sdk.Handler { return rtr.routes[path] } diff --git a/x/auth/middleware/legacy_router_test.go b/baseapp/router_test.go similarity index 79% rename from x/auth/middleware/legacy_router_test.go rename to baseapp/router_test.go index 97517dcdf9b5..1e11dc0ca089 100644 --- a/x/auth/middleware/legacy_router_test.go +++ b/baseapp/router_test.go @@ -1,4 +1,4 @@ -package middleware_test +package baseapp import ( "testing" @@ -6,15 +6,14 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" ) var testHandler = func(_ sdk.Context, _ sdk.Msg) (*sdk.Result, error) { return &sdk.Result{}, nil } -func TestLegacyRouter(t *testing.T) { - rtr := middleware.NewLegacyRouter() +func TestRouter(t *testing.T) { + rtr := NewRouter() // require panic on invalid route require.Panics(t, func() { diff --git a/baseapp/test_helpers.go b/baseapp/test_helpers.go index 67b02d5f5fac..ebb2af388421 100644 --- a/baseapp/test_helpers.go +++ b/baseapp/test_helpers.go @@ -1,82 +1,40 @@ package baseapp import ( - abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/store/v2alpha1/multi" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" ) // SimCheck defines a CheckTx helper function that used in tests and simulations. -func (app *BaseApp) SimCheck(txEncoder sdk.TxEncoder, sdkTx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { - // CheckTx expects tx bytes as argument, so we encode the tx argument into - // bytes. Note that CheckTx will actually decode those bytes again. But since +func (app *BaseApp) SimCheck(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { + // runTx expects tx bytes as argument, so we encode the tx argument into + // bytes. Note that runTx will actually decode those bytes again. But since // this helper is only used in tests/simulation, it's fine. - bz, err := txEncoder(sdkTx) + bz, err := txEncoder(tx) if err != nil { return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) } - - ctx := app.getContextForTx(runTxModeDeliver, bz) - res, _, err := app.txHandler.CheckTx(ctx, tx.Request{Tx: sdkTx, TxBytes: bz}, tx.RequestCheckTx{Type: abci.CheckTxType_New}) - gInfo := sdk.GasInfo{GasWanted: uint64(res.GasWanted), GasUsed: uint64(res.GasUsed)} - if err != nil { - return gInfo, nil, err - } - - data, err := makeABCIData(res) - if err != nil { - return gInfo, nil, err - } - - return gInfo, &sdk.Result{Data: data, Log: res.Log, Events: res.Events, MsgResponses: res.MsgResponses}, nil + gasInfo, result, _, _, err := app.runTx(runTxModeCheck, bz) + return gasInfo, result, err } // Simulate executes a tx in simulate mode to get result and gas info. func (app *BaseApp) Simulate(txBytes []byte) (sdk.GasInfo, *sdk.Result, error) { - ctx := app.getContextForTx(runTxModeSimulate, txBytes) - res, err := app.txHandler.SimulateTx(ctx, tx.Request{TxBytes: txBytes}) - gasInfo := sdk.GasInfo{ - GasWanted: res.GasWanted, - GasUsed: res.GasUsed, - } - if err != nil { - return gasInfo, nil, err - } - - data, err := makeABCIData(res) - if err != nil { - return gasInfo, nil, err - } - - return gasInfo, &sdk.Result{Data: data, Log: res.Log, Events: res.Events, MsgResponses: res.MsgResponses}, nil + gasInfo, result, _, _, err := app.runTx(runTxModeSimulate, txBytes) + return gasInfo, result, err } -// SimDeliver defines a DeliverTx helper function that used in tests and -// simulations. -func (app *BaseApp) SimDeliver(txEncoder sdk.TxEncoder, sdkTx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { +func (app *BaseApp) SimDeliver(txEncoder sdk.TxEncoder, tx sdk.Tx) (sdk.GasInfo, *sdk.Result, error) { // See comment for Check(). - bz, err := txEncoder(sdkTx) + bz, err := txEncoder(tx) if err != nil { return sdk.GasInfo{}, nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%s", err) } - - ctx := app.getContextForTx(runTxModeDeliver, bz) - res, err := app.txHandler.DeliverTx(ctx, tx.Request{Tx: sdkTx, TxBytes: bz}) - gInfo := sdk.GasInfo{GasWanted: uint64(res.GasWanted), GasUsed: uint64(res.GasUsed)} - if err != nil { - return gInfo, nil, err - } - - data, err := makeABCIData(res) - if err != nil { - return gInfo, nil, err - } - - return gInfo, &sdk.Result{Data: data, Log: res.Log, Events: res.Events, MsgResponses: res.MsgResponses}, nil + gasInfo, result, _, _, err := app.runTx(runTxModeDeliver, bz) + return gasInfo, result, err } // Context with current {check, deliver}State of the app used by tests. @@ -101,3 +59,7 @@ func (app *BaseApp) NewContextAt(isCheckTx bool, header tmproto.Header, height i } return sdk.NewContext(view.CacheWrap(), header, isCheckTx, app.logger), nil } + +func (app *BaseApp) GetContextForDeliverTx(txBytes []byte) sdk.Context { + return app.getContextForTx(runTxModeDeliver, txBytes) +} diff --git a/baseapp/util_test.go b/baseapp/util_test.go index 520e1e66edce..0f77d26ebd08 100644 --- a/baseapp/util_test.go +++ b/baseapp/util_test.go @@ -1,8 +1,8 @@ package baseapp import ( + "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) // TODO: Can be removed once we move all middleware tests into x/auth/middleware @@ -31,10 +31,18 @@ func (app *BaseApp) Store() types.CommitMultiStore { return app.store } +// GetSnapshotManager() is an exported method to be able to access baseapp's snapshot +// manager in tests. +// +// This method is only accessible in baseapp tests. +func (app *BaseApp) GetSnapshotManager() *snapshots.Manager { + return app.snapshotManager +} + // GetMaximumBlockGas return maximum blocks gas. // // This method is only accessible in baseapp tests. -func (app *BaseApp) GetMaximumBlockGas(ctx sdk.Context) uint64 { +func (app *BaseApp) GetMaximumBlockGas(ctx types.Context) uint64 { return app.getMaximumBlockGas(ctx) } @@ -48,13 +56,13 @@ func (app *BaseApp) GetName() string { // CreateQueryContext calls app's createQueryContext. // // This method is only accessible in baseapp tests. -func (app *BaseApp) CreateQueryContext(height int64, prove bool) (sdk.Context, error) { +func (app *BaseApp) CreateQueryContext(height int64, prove bool) (types.Context, error) { return app.createQueryContext(height, prove) } // MinGasPrices returns minGasPrices. // // This method is only accessible in baseapp tests. -func (app *BaseApp) MinGasPrices() sdk.DecCoins { +func (app *BaseApp) MinGasPrices() types.DecCoins { return app.minGasPrices } diff --git a/client/broadcast_test.go b/client/broadcast_test.go index 424c7d364753..32b9b42c1fca 100644 --- a/client/broadcast_test.go +++ b/client/broadcast_test.go @@ -66,5 +66,4 @@ func TestBroadcastError(t *testing.T) { require.Equal(t, txHash, resp.TxHash) } } - } diff --git a/client/cmd.go b/client/cmd.go index 90d7689d5e2f..ce6faba09e06 100644 --- a/client/cmd.go +++ b/client/cmd.go @@ -248,7 +248,7 @@ func readTxCommandFlags(clientCtx Context, flagSet *pflag.FlagSet) (Context, err if clientCtx.From == "" || flagSet.Changed(flags.FlagFrom) { from, _ := flagSet.GetString(flags.FlagFrom) - fromAddr, fromName, keyType, err := GetFromFields(clientCtx.Keyring, from, clientCtx.GenerateOnly) + fromAddr, fromName, keyType, err := GetFromFields(clientCtx, clientCtx.Keyring, from) if err != nil { return clientCtx, err } diff --git a/client/cmd_test.go b/client/cmd_test.go index 65161fe4752b..81d5719ccfb6 100644 --- a/client/cmd_test.go +++ b/client/cmd_test.go @@ -70,6 +70,7 @@ func TestSetCmdClientContextHandler(t *testing.T) { } c.Flags().String(flags.FlagChainID, "", "network chain ID") + c.Flags().String(flags.FlagHome, "", "home dir") return c } @@ -91,6 +92,14 @@ func TestSetCmdClientContextHandler(t *testing.T) { fmt.Sprintf("--%s=new-chain-id", flags.FlagChainID), }, }, + { + "flags set with space", + initClientCtx.WithHomeDir("/tmp/dir"), + []string{ + fmt.Sprintf("--%s", flags.FlagHome), + "/tmp/dir", + }, + }, } for _, tc := range testCases { diff --git a/client/config/config_test.go b/client/config/config_test.go index 41817a59d2df..3f5c5902820b 100644 --- a/client/config/config_test.go +++ b/client/config/config_test.go @@ -3,19 +3,18 @@ package config_test import ( "bytes" "fmt" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "io" "os" "testing" - "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/config" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/x/staking/client/cli" + "github.com/stretchr/testify/require" ) const ( @@ -32,9 +31,9 @@ func initClientContext(t *testing.T, envVar string) (client.Context, func()) { WithViper(""). WithCodec(codec.NewProtoCodec(codectypes.NewInterfaceRegistry())) - clientCtx.Viper.BindEnv(nodeEnv) + require.NoError(t, clientCtx.Viper.BindEnv(nodeEnv)) if envVar != "" { - os.Setenv(nodeEnv, envVar) + require.NoError(t, os.Setenv(nodeEnv, envVar)) } clientCtx, err := config.ReadFromClientConfig(clientCtx) @@ -46,7 +45,7 @@ func initClientContext(t *testing.T, envVar string) (client.Context, func()) { func TestConfigCmd(t *testing.T) { clientCtx, cleanup := initClientContext(t, testNode1) defer func() { - os.Unsetenv(nodeEnv) + _ = os.Unsetenv(nodeEnv) cleanup() }() @@ -60,7 +59,7 @@ func TestConfigCmd(t *testing.T) { b := bytes.NewBufferString("") cmd.SetOut(b) cmd.SetArgs([]string{"node"}) - cmd.Execute() + require.NoError(t, cmd.Execute()) out, err := io.ReadAll(b) require.NoError(t, err) require.Equal(t, string(out), testNode1+"\n") @@ -89,7 +88,7 @@ func TestConfigCmdEnvFlag(t *testing.T) { clientCtx, cleanup := initClientContext(t, tc.envVar) defer func() { if tc.envVar != "" { - os.Unsetenv(nodeEnv) + _ = os.Unsetenv(nodeEnv) } cleanup() }() diff --git a/client/config/toml.go b/client/config/toml.go index a26cf78e6f17..97c8b00b42c5 100644 --- a/client/config/toml.go +++ b/client/config/toml.go @@ -42,7 +42,7 @@ func writeConfigToFile(configFilePath string, config *ClientConfig) error { return err } - return os.WriteFile(configFilePath, buffer.Bytes(), 0600) + return os.WriteFile(configFilePath, buffer.Bytes(), 0o600) } // ensureConfigPath creates a directory configPath if it does not exist diff --git a/client/context.go b/client/context.go index 380b08924ac4..be5c84af6070 100644 --- a/client/context.go +++ b/client/context.go @@ -2,6 +2,8 @@ package client import ( "bufio" + "encoding/json" + "fmt" "io" "os" @@ -52,9 +54,9 @@ type Context struct { FeePayer sdk.AccAddress FeeGranter sdk.AccAddress Viper *viper.Viper - + // IsAux is true when the signer is an auxiliary signer (e.g. the tipper). - IsAux bool + IsAux bool // TODO: Deprecated (remove). LegacyAmino *codec.LegacyAmino @@ -304,6 +306,12 @@ func (ctx Context) PrintObjectLegacy(toPrint interface{}) error { return ctx.printOutput(out) } +// PrintRaw is a variant of PrintProto that doesn't require a proto.Message type +// and uses a raw JSON message. No marshaling is performed. +func (ctx Context) PrintRaw(toPrint json.RawMessage) error { + return ctx.printOutput(toPrint) +} + func (ctx Context) printOutput(out []byte) error { var err error if ctx.OutputFormat == "text" { @@ -334,16 +342,31 @@ func (ctx Context) printOutput(out []byte) error { return nil } -// GetFromFields returns a from account address, account name and keyring type, given either -// an address or key name. If genOnly is true, only a valid Bech32 cosmos -// address is returned. -func GetFromFields(kr keyring.Keyring, from string, genOnly bool) (sdk.AccAddress, string, keyring.KeyType, error) { +// GetFromFields returns a from account address, account name and keyring type, given either an address or key name. +// If clientCtx.Simulate is true the keystore is not accessed and a valid address must be provided +// If clientCtx.GenerateOnly is true the keystore is only accessed if a key name is provided +func GetFromFields(clientCtx Context, kr keyring.Keyring, from string) (sdk.AccAddress, string, keyring.KeyType, error) { if from == "" { return nil, "", 0, nil } + addr, err := sdk.AccAddressFromBech32(from) + switch { + case clientCtx.Simulate: + if err != nil { + return nil, "", 0, fmt.Errorf("a valid bech32 address must be provided in simulation mode: %w", err) + } + + return addr, "", 0, nil + + case clientCtx.GenerateOnly: + if err == nil { + return addr, "", 0, nil + } + } + var k *keyring.Record - if addr, err := sdk.AccAddressFromBech32(from); err == nil { + if err == nil { k, err = kr.KeyByAddress(addr) if err != nil { return nil, "", 0, err @@ -355,7 +378,7 @@ func GetFromFields(kr keyring.Keyring, from string, genOnly bool) (sdk.AccAddres } } - addr, err := k.GetAddress() + addr, err = k.GetAddress() if err != nil { return nil, "", 0, err } @@ -365,7 +388,7 @@ func GetFromFields(kr keyring.Keyring, from string, genOnly bool) (sdk.AccAddres // NewKeyringFromBackend gets a Keyring object from a backend func NewKeyringFromBackend(ctx Context, backend string) (keyring.Keyring, error) { - if ctx.GenerateOnly || ctx.Simulate { + if ctx.Simulate { backend = keyring.BackendMemory } diff --git a/client/context_test.go b/client/context_test.go index d500bc97783b..82feeebe4dfe 100644 --- a/client/context_test.go +++ b/client/context_test.go @@ -3,7 +3,9 @@ package client_test import ( "bytes" "context" + "encoding/json" "os" + "strings" "testing" "github.com/spf13/viper" @@ -13,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/testutil/network" "github.com/cosmos/cosmos-sdk/testutil/testdata" @@ -23,7 +26,7 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -func TestContext_PrintObject(t *testing.T) { +func TestContext_PrintProto(t *testing.T) { ctx := client.Context{} animal := &testdata.Dog{ @@ -37,9 +40,7 @@ func TestContext_PrintObject(t *testing.T) { X: 10, } - // // proto - // registry := testdata.NewTestInterfaceRegistry() ctx = ctx.WithCodec(codec.NewProtoCodec(registry)) @@ -66,15 +67,28 @@ func TestContext_PrintObject(t *testing.T) { size: big x: "10" `, buf.String()) +} + +func TestContext_PrintObjectLegacy(t *testing.T) { + ctx := client.Context{} + + animal := &testdata.Dog{ + Size_: "big", + Name: "Spot", + } + any, err := types.NewAnyWithValue(animal) + require.NoError(t, err) + hasAnimal := &testdata.HasAnimal{ + Animal: any, + X: 10, + } - // // amino - // amino := testdata.NewTestAmino() ctx = ctx.WithLegacyAmino(&codec.LegacyAmino{Amino: amino}) // json - buf = &bytes.Buffer{} + buf := &bytes.Buffer{} ctx = ctx.WithOutput(buf) ctx.OutputFormat = "json" err = ctx.PrintObjectLegacy(hasAnimal) @@ -101,6 +115,35 @@ value: `, buf.String()) } +func TestContext_PrintRaw(t *testing.T) { + ctx := client.Context{} + hasAnimal := json.RawMessage(`{"animal":{"@type":"/testdata.Dog","size":"big","name":"Spot"},"x":"10"}`) + + // json + buf := &bytes.Buffer{} + ctx = ctx.WithOutput(buf) + ctx.OutputFormat = "json" + err := ctx.PrintRaw(hasAnimal) + require.NoError(t, err) + require.Equal(t, + `{"animal":{"@type":"/testdata.Dog","size":"big","name":"Spot"},"x":"10"} +`, buf.String()) + + // yaml + buf = &bytes.Buffer{} + ctx = ctx.WithOutput(buf) + ctx.OutputFormat = "text" + err = ctx.PrintRaw(hasAnimal) + require.NoError(t, err) + require.Equal(t, + `animal: + '@type': /testdata.Dog + name: Spot + size: big +x: "10" +`, buf.String()) +} + func TestCLIQueryConn(t *testing.T) { cfg := network.DefaultConfig() cfg.NumValidators = 1 @@ -114,3 +157,107 @@ func TestCLIQueryConn(t *testing.T) { require.NoError(t, err) require.Equal(t, "hello", res.Message) } + +func TestGetFromFields(t *testing.T) { + cfg := network.DefaultConfig() + path := hd.CreateHDPath(118, 0, 0).String() + + testCases := []struct { + clientCtx client.Context + keyring func() keyring.Keyring + from string + expectedErr string + }{ + { + keyring: func() keyring.Keyring { + kb := keyring.NewInMemory(cfg.Codec) + + _, _, err := kb.NewMnemonic("alice", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + require.NoError(t, err) + + return kb + }, + from: "alice", + }, + { + keyring: func() keyring.Keyring { + kb, err := keyring.New(t.Name(), keyring.BackendTest, t.TempDir(), nil, cfg.Codec) + require.NoError(t, err) + + _, _, err = kb.NewMnemonic("alice", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + require.NoError(t, err) + + return kb + }, + from: "alice", + }, + { + keyring: func() keyring.Keyring { + return keyring.NewInMemory(cfg.Codec) + }, + from: "cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5", + expectedErr: "key with address cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5 not found: key not found", + }, + { + keyring: func() keyring.Keyring { + kb, err := keyring.New(t.Name(), keyring.BackendTest, t.TempDir(), nil, cfg.Codec) + require.NoError(t, err) + return kb + }, + from: "alice", + expectedErr: "alice.info: key not found", + }, + { + keyring: func() keyring.Keyring { + return keyring.NewInMemory(cfg.Codec) + }, + from: "cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5", + clientCtx: client.Context{}.WithSimulation(true), + }, + { + keyring: func() keyring.Keyring { + return keyring.NewInMemory(cfg.Codec) + }, + from: "alice", + clientCtx: client.Context{}.WithSimulation(true), + expectedErr: "a valid bech32 address must be provided in simulation mode", + }, + { + keyring: func() keyring.Keyring { + return keyring.NewInMemory(cfg.Codec) + }, + from: "cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5", + clientCtx: client.Context{}.WithGenerateOnly(true), + }, + { + keyring: func() keyring.Keyring { + return keyring.NewInMemory(cfg.Codec) + }, + from: "alice", + clientCtx: client.Context{}.WithGenerateOnly(true), + expectedErr: "alice.info: key not found", + }, + { + keyring: func() keyring.Keyring { + kb, err := keyring.New(t.Name(), keyring.BackendTest, t.TempDir(), nil, cfg.Codec) + require.NoError(t, err) + + _, _, err = kb.NewMnemonic("alice", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) + require.NoError(t, err) + + return kb + }, + clientCtx: client.Context{}.WithGenerateOnly(true), + from: "alice", + }, + } + + for _, tc := range testCases { + _, _, _, err := client.GetFromFields(tc.clientCtx, tc.keyring(), tc.from) + if tc.expectedErr == "" { + require.NoError(t, err) + } else { + require.True(t, strings.HasPrefix(err.Error(), tc.expectedErr)) + } + } +} diff --git a/client/debug/main.go b/client/debug/main.go index 05a1b311337c..5eb795ffb9ed 100644 --- a/client/debug/main.go +++ b/client/debug/main.go @@ -20,9 +20,7 @@ import ( legacybech32 "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" ) -var ( - flagPubkeyType = "type" -) +var flagPubkeyType = "type" // Cmd creates a main CLI command func Cmd() *cobra.Command { @@ -178,7 +176,6 @@ $ %s debug pubkey-raw cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg cmd.Println("Bech32 Acc:", accPub) cmd.Println("Bech32 Validator Operator:", valPub) if pubkeyType == "ed25519" { - cmd.Println("Bech32 Validator Consensus:", consensusPub) } @@ -200,7 +197,6 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg `, version.AppName), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - addrString := args[0] var addr []byte @@ -216,7 +212,6 @@ $ %s debug addr cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg if err3 != nil { return fmt.Errorf("expected hex or bech32. Got errors: hex: %v, bech32 acc: %v, bech32 val: %v", err, err2, err3) - } } } diff --git a/client/docs/swagger-ui/swagger.yaml b/client/docs/swagger-ui/swagger.yaml index 7f51b93de897..82c326158d01 100644 --- a/client/docs/swagger-ui/swagger.yaml +++ b/client/docs/swagger-ui/swagger.yaml @@ -11102,7 +11102,7 @@ paths: bonded shares multiplied by exchange rate. - description: validators defines the the validators' info of a delegator. + description: validators defines the validators' info of a delegator. pagination: description: pagination defines the pagination in the response. type: object @@ -27979,7 +27979,7 @@ definitions: exchange rate. Voting power can be calculated as total bonded shares multiplied by exchange rate. - description: validators defines the the validators' info of a delegator. + description: validators defines the validators' info of a delegator. pagination: description: pagination defines the pagination in the response. type: object diff --git a/client/flags/flags.go b/client/flags/flags.go index 669c487e604d..b120e2fb7262 100644 --- a/client/flags/flags.go +++ b/client/flags/flags.go @@ -95,7 +95,9 @@ func AddQueryFlagsToCmd(cmd *cobra.Command) { cmd.Flags().Int64(FlagHeight, 0, "Use a specific height to query state at (this can error if the node is pruning state)") cmd.Flags().StringP(tmcli.OutputFlag, "o", "text", "Output format (text|json)") - cmd.MarkFlagRequired(FlagChainID) + // some base commands does not require chainID e.g `simd testnet` while subcommands do + // hence the flag should not be required for those commands + _ = cmd.MarkFlagRequired(FlagChainID) } // AddTxFlagsToCmd adds common flags to a module tx command. @@ -112,8 +114,8 @@ func AddTxFlagsToCmd(cmd *cobra.Command) { cmd.Flags().Bool(FlagUseLedger, false, "Use a connected Ledger device") cmd.Flags().Float64(FlagGasAdjustment, DefaultGasAdjustment, "adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored ") cmd.Flags().StringP(FlagBroadcastMode, "b", BroadcastSync, "Transaction broadcasting mode (sync|async|block)") - cmd.Flags().Bool(FlagDryRun, false, "ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it") - cmd.Flags().Bool(FlagGenerateOnly, false, "Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase is not accessible)") + cmd.Flags().Bool(FlagDryRun, false, "ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible)") + cmd.Flags().Bool(FlagGenerateOnly, false, "Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name)") cmd.Flags().Bool(FlagOffline, false, "Offline mode (does not allow any online functionality)") cmd.Flags().BoolP(FlagSkipConfirmation, "y", false, "Skip tx broadcasting prompt confirmation") cmd.Flags().String(FlagKeyringBackend, DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test|memory)") diff --git a/client/grpc/tmservice/block.go b/client/grpc/tmservice/block.go index 3bed4268f303..6f3b1e556993 100644 --- a/client/grpc/tmservice/block.go +++ b/client/grpc/tmservice/block.go @@ -2,6 +2,7 @@ package tmservice import ( "context" + "github.com/cosmos/cosmos-sdk/client" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/tendermint/tendermint/rpc/coretypes" diff --git a/client/grpc/tmservice/query.pb.go b/client/grpc/tmservice/query.pb.go index 77c6eaee8c19..2b57ec34431d 100644 --- a/client/grpc/tmservice/query.pb.go +++ b/client/grpc/tmservice/query.pb.go @@ -9,6 +9,7 @@ import ( _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" query "github.com/cosmos/cosmos-sdk/types/query" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" p2p "github.com/tendermint/tendermint/proto/tendermint/p2p" @@ -852,6 +853,299 @@ func (m *Module) GetSum() string { return "" } +// ABCIQueryRequest defines the request structure for the ABCIQuery gRPC query. +type ABCIQueryRequest struct { + Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` + Path string `protobuf:"bytes,2,opt,name=path,proto3" json:"path,omitempty"` + Height int64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + Prove bool `protobuf:"varint,4,opt,name=prove,proto3" json:"prove,omitempty"` +} + +func (m *ABCIQueryRequest) Reset() { *m = ABCIQueryRequest{} } +func (m *ABCIQueryRequest) String() string { return proto.CompactTextString(m) } +func (*ABCIQueryRequest) ProtoMessage() {} +func (*ABCIQueryRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_40c93fb3ef485c5d, []int{15} +} +func (m *ABCIQueryRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ABCIQueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ABCIQueryRequest.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 *ABCIQueryRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ABCIQueryRequest.Merge(m, src) +} +func (m *ABCIQueryRequest) XXX_Size() int { + return m.Size() +} +func (m *ABCIQueryRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ABCIQueryRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ABCIQueryRequest proto.InternalMessageInfo + +func (m *ABCIQueryRequest) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +func (m *ABCIQueryRequest) GetPath() string { + if m != nil { + return m.Path + } + return "" +} + +func (m *ABCIQueryRequest) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *ABCIQueryRequest) GetProve() bool { + if m != nil { + return m.Prove + } + return false +} + +// ABCIQueryResponse defines the response structure for the ABCIQuery gRPC query. +// +// Note: This type is a duplicate of the ResponseQuery proto type defined in +// Tendermint. +type ABCIQueryResponse struct { + Code uint32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"` + Log string `protobuf:"bytes,3,opt,name=log,proto3" json:"log,omitempty"` + Info string `protobuf:"bytes,4,opt,name=info,proto3" json:"info,omitempty"` + Index int64 `protobuf:"varint,5,opt,name=index,proto3" json:"index,omitempty"` + Key []byte `protobuf:"bytes,6,opt,name=key,proto3" json:"key,omitempty"` + Value []byte `protobuf:"bytes,7,opt,name=value,proto3" json:"value,omitempty"` + ProofOps *ProofOps `protobuf:"bytes,8,opt,name=proof_ops,json=proofOps,proto3" json:"proof_ops,omitempty"` + Height int64 `protobuf:"varint,9,opt,name=height,proto3" json:"height,omitempty"` + Codespace string `protobuf:"bytes,10,opt,name=codespace,proto3" json:"codespace,omitempty"` +} + +func (m *ABCIQueryResponse) Reset() { *m = ABCIQueryResponse{} } +func (m *ABCIQueryResponse) String() string { return proto.CompactTextString(m) } +func (*ABCIQueryResponse) ProtoMessage() {} +func (*ABCIQueryResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_40c93fb3ef485c5d, []int{16} +} +func (m *ABCIQueryResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ABCIQueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ABCIQueryResponse.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 *ABCIQueryResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ABCIQueryResponse.Merge(m, src) +} +func (m *ABCIQueryResponse) XXX_Size() int { + return m.Size() +} +func (m *ABCIQueryResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ABCIQueryResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ABCIQueryResponse proto.InternalMessageInfo + +func (m *ABCIQueryResponse) GetCode() uint32 { + if m != nil { + return m.Code + } + return 0 +} + +func (m *ABCIQueryResponse) GetLog() string { + if m != nil { + return m.Log + } + return "" +} + +func (m *ABCIQueryResponse) GetInfo() string { + if m != nil { + return m.Info + } + return "" +} + +func (m *ABCIQueryResponse) GetIndex() int64 { + if m != nil { + return m.Index + } + return 0 +} + +func (m *ABCIQueryResponse) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *ABCIQueryResponse) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + +func (m *ABCIQueryResponse) GetProofOps() *ProofOps { + if m != nil { + return m.ProofOps + } + return nil +} + +func (m *ABCIQueryResponse) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *ABCIQueryResponse) GetCodespace() string { + if m != nil { + return m.Codespace + } + return "" +} + +// ProofOp defines an operation used for calculating Merkle root. The data could +// be arbitrary format, providing nessecary data for example neighbouring node +// hash. +// +// Note: This type is a duplicate of the ProofOp proto type defined in Tendermint. +type ProofOp struct { + Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"` + Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *ProofOp) Reset() { *m = ProofOp{} } +func (m *ProofOp) String() string { return proto.CompactTextString(m) } +func (*ProofOp) ProtoMessage() {} +func (*ProofOp) Descriptor() ([]byte, []int) { + return fileDescriptor_40c93fb3ef485c5d, []int{17} +} +func (m *ProofOp) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProofOp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProofOp.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 *ProofOp) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProofOp.Merge(m, src) +} +func (m *ProofOp) XXX_Size() int { + return m.Size() +} +func (m *ProofOp) XXX_DiscardUnknown() { + xxx_messageInfo_ProofOp.DiscardUnknown(m) +} + +var xxx_messageInfo_ProofOp proto.InternalMessageInfo + +func (m *ProofOp) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *ProofOp) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *ProofOp) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +// ProofOps is Merkle proof defined by the list of ProofOps. +// +// Note: This type is a duplicate of the ProofOps proto type defined in Tendermint. +type ProofOps struct { + Ops []ProofOp `protobuf:"bytes,1,rep,name=ops,proto3" json:"ops"` +} + +func (m *ProofOps) Reset() { *m = ProofOps{} } +func (m *ProofOps) String() string { return proto.CompactTextString(m) } +func (*ProofOps) ProtoMessage() {} +func (*ProofOps) Descriptor() ([]byte, []int) { + return fileDescriptor_40c93fb3ef485c5d, []int{18} +} +func (m *ProofOps) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProofOps) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProofOps.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 *ProofOps) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProofOps.Merge(m, src) +} +func (m *ProofOps) XXX_Size() int { + return m.Size() +} +func (m *ProofOps) XXX_DiscardUnknown() { + xxx_messageInfo_ProofOps.DiscardUnknown(m) +} + +var xxx_messageInfo_ProofOps proto.InternalMessageInfo + +func (m *ProofOps) GetOps() []ProofOp { + if m != nil { + return m.Ops + } + return nil +} + func init() { proto.RegisterType((*GetValidatorSetByHeightRequest)(nil), "cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightRequest") proto.RegisterType((*GetValidatorSetByHeightResponse)(nil), "cosmos.base.tendermint.v1beta1.GetValidatorSetByHeightResponse") @@ -868,6 +1162,10 @@ func init() { proto.RegisterType((*GetNodeInfoResponse)(nil), "cosmos.base.tendermint.v1beta1.GetNodeInfoResponse") proto.RegisterType((*VersionInfo)(nil), "cosmos.base.tendermint.v1beta1.VersionInfo") proto.RegisterType((*Module)(nil), "cosmos.base.tendermint.v1beta1.Module") + proto.RegisterType((*ABCIQueryRequest)(nil), "cosmos.base.tendermint.v1beta1.ABCIQueryRequest") + proto.RegisterType((*ABCIQueryResponse)(nil), "cosmos.base.tendermint.v1beta1.ABCIQueryResponse") + proto.RegisterType((*ProofOp)(nil), "cosmos.base.tendermint.v1beta1.ProofOp") + proto.RegisterType((*ProofOps)(nil), "cosmos.base.tendermint.v1beta1.ProofOps") } func init() { @@ -875,75 +1173,91 @@ func init() { } var fileDescriptor_40c93fb3ef485c5d = []byte{ - // 1086 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4d, 0x6f, 0x1b, 0xc5, - 0x1f, 0xce, 0xda, 0x6d, 0x1c, 0xff, 0xfc, 0xd7, 0x5f, 0xe9, 0x24, 0x34, 0x1b, 0x2b, 0x35, 0xc1, - 0x87, 0x36, 0x21, 0x64, 0x57, 0x76, 0x9b, 0xb4, 0x87, 0x52, 0xd4, 0x50, 0x70, 0x23, 0x4a, 0x15, - 0xad, 0x11, 0x07, 0x84, 0xb4, 0x5a, 0x7b, 0x27, 0x9b, 0x91, 0xed, 0x9d, 0xe9, 0xce, 0xd8, 0xc8, - 0x42, 0x15, 0x88, 0x13, 0x47, 0x24, 0xbe, 0x02, 0x07, 0xe0, 0x8c, 0x38, 0xf6, 0xcc, 0xb1, 0x2a, - 0x12, 0xaa, 0x38, 0xa1, 0x84, 0x0f, 0x82, 0x76, 0x66, 0xd6, 0xde, 0x6d, 0x92, 0xda, 0xce, 0x01, - 0x89, 0xd3, 0xce, 0xfc, 0x5e, 0x9f, 0xe7, 0x99, 0x97, 0x1d, 0x78, 0xbb, 0x4d, 0x79, 0x8f, 0x72, - 0xbb, 0xe5, 0x71, 0x6c, 0x0b, 0x1c, 0xfa, 0x38, 0xea, 0x91, 0x50, 0xd8, 0x83, 0x5a, 0x0b, 0x0b, - 0xaf, 0x66, 0x3f, 0xe9, 0xe3, 0x68, 0x68, 0xb1, 0x88, 0x0a, 0x8a, 0x2a, 0x2a, 0xd6, 0x8a, 0x63, - 0xad, 0x71, 0xac, 0xa5, 0x63, 0xcb, 0xab, 0x01, 0xa5, 0x41, 0x17, 0xdb, 0x32, 0xba, 0xd5, 0x3f, - 0xb4, 0xbd, 0x50, 0xa7, 0x96, 0xd7, 0xb4, 0xcb, 0x63, 0xc4, 0xf6, 0xc2, 0x90, 0x0a, 0x4f, 0x10, - 0x1a, 0x72, 0xed, 0x2d, 0xa7, 0x1a, 0xb3, 0x3a, 0xb3, 0xc5, 0x90, 0xe1, 0xc4, 0xb7, 0x96, 0xf2, - 0x49, 0xbb, 0xdd, 0xea, 0xd2, 0x76, 0xe7, 0x5c, 0x6f, 0x3a, 0x37, 0x43, 0x4e, 0x32, 0x19, 0xf1, - 0x62, 0x5e, 0x40, 0x42, 0x09, 0x42, 0xc7, 0xae, 0xaa, 0x58, 0x57, 0xce, 0x6c, 0xcd, 0x54, 0x4e, - 0xaa, 0x5f, 0x1b, 0x50, 0x69, 0x60, 0xf1, 0xa9, 0xd7, 0x25, 0xbe, 0x27, 0x68, 0xd4, 0xc4, 0x62, - 0x6f, 0xf8, 0x10, 0x93, 0xe0, 0x48, 0x38, 0xf8, 0x49, 0x1f, 0x73, 0x81, 0xae, 0xc2, 0xfc, 0x91, - 0x34, 0x98, 0xc6, 0xba, 0xb1, 0x91, 0x77, 0xf4, 0x0c, 0x7d, 0x08, 0x30, 0xee, 0x64, 0xe6, 0xd6, - 0x8d, 0x8d, 0x52, 0xfd, 0xba, 0x95, 0xd6, 0x51, 0x09, 0xac, 0x61, 0x59, 0x07, 0x5e, 0x80, 0x75, - 0x4d, 0x27, 0x95, 0x59, 0x7d, 0x69, 0xc0, 0x9b, 0xe7, 0x42, 0xe0, 0x8c, 0x86, 0x1c, 0xa3, 0xb7, - 0xe0, 0x7f, 0x52, 0x1a, 0x37, 0x83, 0xa4, 0x24, 0x6d, 0x2a, 0x14, 0xed, 0x03, 0x0c, 0x92, 0x12, - 0xdc, 0xcc, 0xad, 0xe7, 0x37, 0x4a, 0xf5, 0x4d, 0xeb, 0xf5, 0xcb, 0x6a, 0x8d, 0x9a, 0x3a, 0xa9, - 0x64, 0xd4, 0xc8, 0x30, 0xcb, 0x4b, 0x66, 0x37, 0x26, 0x32, 0x53, 0x50, 0x33, 0xd4, 0x0e, 0x61, - 0xad, 0x81, 0xc5, 0x23, 0x4f, 0x60, 0x9e, 0xe1, 0x97, 0x48, 0x9b, 0x95, 0xd0, 0xb8, 0xb0, 0x84, - 0x7f, 0x18, 0x70, 0xed, 0x9c, 0x46, 0xff, 0x6d, 0x01, 0x9f, 0x19, 0x50, 0x1c, 0xb5, 0x40, 0x75, - 0x28, 0x78, 0xbe, 0x1f, 0x61, 0xce, 0x25, 0xfe, 0xe2, 0x9e, 0xf9, 0xe2, 0x97, 0xed, 0x65, 0x5d, - 0xf6, 0xbe, 0xf2, 0x34, 0x45, 0x44, 0xc2, 0xc0, 0x49, 0x02, 0xd1, 0x36, 0x14, 0x58, 0xbf, 0xe5, - 0x76, 0xf0, 0x50, 0x6f, 0xd1, 0x65, 0x4b, 0x9d, 0x57, 0x2b, 0x39, 0xca, 0xd6, 0xfd, 0x70, 0xe8, - 0xcc, 0xb3, 0x7e, 0xeb, 0x23, 0x3c, 0x8c, 0x75, 0x1a, 0x50, 0x41, 0xc2, 0xc0, 0x65, 0xf4, 0x0b, - 0x1c, 0x49, 0xec, 0x79, 0xa7, 0xa4, 0x6c, 0x07, 0xb1, 0x09, 0x6d, 0xc1, 0x15, 0x16, 0x51, 0x46, - 0x39, 0x8e, 0x5c, 0x16, 0x11, 0x1a, 0x11, 0x31, 0x34, 0x2f, 0xc9, 0xb8, 0xc5, 0xc4, 0x71, 0xa0, - 0xed, 0xd5, 0x1a, 0xac, 0x34, 0xb0, 0xd8, 0x8b, 0x65, 0x9e, 0xf2, 0x5c, 0x55, 0xbf, 0x02, 0xf3, - 0x74, 0x8a, 0x5e, 0xc6, 0x5b, 0xb0, 0xa0, 0x96, 0x91, 0xf8, 0x7a, 0xbb, 0xac, 0xa6, 0x57, 0x45, - 0x5d, 0x10, 0x32, 0x75, 0xff, 0x81, 0x53, 0x90, 0xa1, 0xfb, 0x3e, 0xda, 0x86, 0xcb, 0x72, 0xa8, - 0x15, 0x58, 0x39, 0x27, 0xc5, 0x51, 0x51, 0xd5, 0x15, 0x78, 0x63, 0xb4, 0x99, 0x94, 0x43, 0x21, - 0xae, 0x3e, 0x85, 0xab, 0xaf, 0x3a, 0xfe, 0x4d, 0x5c, 0x4b, 0x70, 0xa5, 0x81, 0x45, 0x73, 0x18, - 0xb6, 0xe3, 0x15, 0xd6, 0x98, 0x2c, 0x40, 0x69, 0xa3, 0xc6, 0x63, 0x42, 0x81, 0x2b, 0x93, 0x84, - 0xb3, 0xe0, 0x24, 0xd3, 0xea, 0xb2, 0x8c, 0x7f, 0x4c, 0x7d, 0xbc, 0x1f, 0x1e, 0xd2, 0xa4, 0xca, - 0xcf, 0x06, 0x2c, 0x65, 0xcc, 0xba, 0xce, 0x0e, 0x14, 0x43, 0xea, 0x63, 0x97, 0x84, 0x87, 0x54, - 0x13, 0x33, 0xd3, 0x28, 0x59, 0x9d, 0x59, 0xa3, 0xa4, 0x85, 0x50, 0x8f, 0xd0, 0xe7, 0xb0, 0xe4, - 0x31, 0xd6, 0x25, 0x6d, 0xb9, 0x8b, 0xdd, 0x01, 0x8e, 0xf8, 0xf8, 0x8e, 0xdc, 0x9a, 0x78, 0xa6, - 0x54, 0xb8, 0xac, 0x89, 0x52, 0x75, 0xb4, 0xbd, 0xfa, 0x63, 0x0e, 0x4a, 0xa9, 0x18, 0x84, 0xe0, - 0x52, 0xe8, 0xf5, 0xb0, 0x3a, 0x13, 0x8e, 0x1c, 0xa3, 0x55, 0x58, 0xf0, 0x18, 0x73, 0xa5, 0x3d, - 0x27, 0xed, 0x05, 0x8f, 0xb1, 0xc7, 0xb1, 0xcb, 0x84, 0x42, 0x02, 0x28, 0xaf, 0x3c, 0x7a, 0x8a, - 0xae, 0x01, 0x04, 0x44, 0xb8, 0x6d, 0xda, 0xeb, 0x11, 0x21, 0xb7, 0x74, 0xd1, 0x29, 0x06, 0x44, - 0xbc, 0x2f, 0x0d, 0xb1, 0xbb, 0xd5, 0x27, 0x5d, 0xdf, 0x15, 0x5e, 0xc0, 0xcd, 0xcb, 0xca, 0x2d, - 0x2d, 0x9f, 0x78, 0x01, 0x97, 0xd9, 0x74, 0xc4, 0x75, 0x5e, 0x67, 0x53, 0x8d, 0x14, 0x7d, 0x90, - 0x64, 0xfb, 0x98, 0x71, 0xb3, 0x20, 0xaf, 0x97, 0xeb, 0x93, 0xa4, 0xf8, 0x98, 0xfa, 0xfd, 0x2e, - 0xd6, 0x5d, 0x1e, 0x60, 0xc6, 0xd1, 0x3b, 0x80, 0xf4, 0xdf, 0x8c, 0xfb, 0x9d, 0x51, 0xb7, 0x05, - 0xd9, 0x6d, 0x51, 0x79, 0x9a, 0x7e, 0x27, 0x91, 0xea, 0x21, 0xcc, 0xab, 0x12, 0xb1, 0x48, 0xcc, - 0x13, 0x47, 0x89, 0x48, 0xf1, 0x38, 0xad, 0x44, 0x2e, 0xab, 0xc4, 0x22, 0xe4, 0x79, 0xbf, 0xa7, - 0xf5, 0x89, 0x87, 0xf5, 0x6f, 0x8b, 0x50, 0x68, 0xe2, 0x68, 0x40, 0xda, 0x18, 0xfd, 0x64, 0x40, - 0x29, 0xb5, 0x5b, 0x50, 0x7d, 0x12, 0x8d, 0xd3, 0x3b, 0xae, 0x7c, 0x73, 0xa6, 0x1c, 0xb5, 0x1d, - 0xab, 0xb5, 0x6f, 0x7e, 0xff, 0xfb, 0xfb, 0xdc, 0x16, 0xda, 0xb4, 0x27, 0x3c, 0x6d, 0x46, 0x9b, - 0x16, 0xfd, 0x60, 0x00, 0x8c, 0x0f, 0x08, 0xaa, 0x4d, 0xd1, 0x36, 0x7b, 0xc2, 0xca, 0xf5, 0x59, - 0x52, 0x34, 0x50, 0x5b, 0x02, 0xdd, 0x44, 0x37, 0x26, 0x01, 0xd5, 0xc7, 0x12, 0xfd, 0x6a, 0xc0, - 0xff, 0xb3, 0x77, 0x0b, 0xda, 0x99, 0xa2, 0xef, 0xe9, 0x4b, 0xaa, 0xbc, 0x3b, 0x6b, 0x9a, 0x86, - 0xbc, 0x23, 0x21, 0xdb, 0x68, 0x7b, 0x12, 0x64, 0x79, 0x19, 0x71, 0xbb, 0x2b, 0x6b, 0xa0, 0x67, - 0x06, 0x2c, 0xbe, 0x7a, 0x5d, 0xa3, 0xdb, 0x53, 0x60, 0x38, 0xeb, 0x9f, 0x50, 0xbe, 0x33, 0x7b, - 0xa2, 0x86, 0x7f, 0x5b, 0xc2, 0xaf, 0x21, 0x7b, 0x4a, 0xf8, 0x5f, 0xaa, 0xbf, 0xcd, 0x53, 0xf4, - 0xc2, 0x48, 0x5d, 0xf7, 0xe9, 0xb7, 0x03, 0xba, 0x3b, 0xb5, 0x92, 0x67, 0xbc, 0x6d, 0xca, 0xef, - 0x5e, 0x30, 0x5b, 0xf3, 0xb9, 0x2b, 0xf9, 0xec, 0xa2, 0x5b, 0x93, 0xf8, 0x8c, 0x9f, 0x1d, 0x58, - 0x8c, 0x56, 0xe5, 0x4f, 0x43, 0xfe, 0x77, 0xcf, 0x7a, 0x53, 0xa2, 0x7b, 0x53, 0x00, 0x7b, 0xcd, - 0x7b, 0xb8, 0xfc, 0xde, 0x85, 0xf3, 0x35, 0xb5, 0x7b, 0x92, 0xda, 0x1d, 0xb4, 0x3b, 0x1b, 0xb5, - 0x64, 0xc5, 0xf6, 0x1e, 0xfd, 0x76, 0x5c, 0x31, 0x9e, 0x1f, 0x57, 0x8c, 0xbf, 0x8e, 0x2b, 0xc6, - 0x77, 0x27, 0x95, 0xb9, 0xe7, 0x27, 0x95, 0xb9, 0x97, 0x27, 0x95, 0xb9, 0xcf, 0xea, 0x01, 0x11, - 0x47, 0xfd, 0x96, 0xd5, 0xa6, 0xbd, 0xa4, 0xb6, 0xfa, 0x6c, 0x73, 0xbf, 0x63, 0xb7, 0xbb, 0x04, - 0x87, 0xc2, 0x0e, 0x22, 0xd6, 0xb6, 0x45, 0x8f, 0xab, 0xcb, 0xac, 0x35, 0x2f, 0xdf, 0x41, 0x37, - 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x57, 0x4d, 0x47, 0x88, 0x2e, 0x0d, 0x00, 0x00, + // 1343 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0xcf, 0x6f, 0x13, 0xc7, + 0x17, 0xcf, 0xda, 0x21, 0xb6, 0x9f, 0xf9, 0x7e, 0x15, 0x86, 0x14, 0x8c, 0x15, 0x0c, 0xf5, 0x01, + 0xc2, 0x8f, 0xec, 0xd6, 0xe6, 0xe7, 0x81, 0x82, 0x08, 0xd0, 0x90, 0x42, 0x69, 0xba, 0xa9, 0x7a, + 0xa8, 0x2a, 0x59, 0x6b, 0xef, 0x64, 0xb3, 0x8a, 0xbd, 0x33, 0xec, 0x8c, 0xdd, 0x5a, 0x15, 0x6a, + 0xd5, 0x3f, 0xa0, 0xaa, 0xd4, 0x7f, 0x81, 0x43, 0xdb, 0x4b, 0x2f, 0x55, 0x8f, 0x9c, 0x39, 0x22, + 0x2a, 0x55, 0xa8, 0x87, 0xaa, 0x82, 0xfe, 0x21, 0xd5, 0xbc, 0x99, 0x5d, 0xaf, 0x81, 0x60, 0x27, + 0x87, 0x4a, 0x3d, 0x79, 0xf6, 0xfd, 0xfc, 0x7c, 0xde, 0x9b, 0x79, 0x33, 0x86, 0xd3, 0x1d, 0x26, + 0x7a, 0x4c, 0x38, 0x6d, 0x4f, 0x50, 0x47, 0xd2, 0xc8, 0xa7, 0x71, 0x2f, 0x8c, 0xa4, 0x33, 0x68, + 0xb4, 0xa9, 0xf4, 0x1a, 0xce, 0xfd, 0x3e, 0x8d, 0x87, 0x36, 0x8f, 0x99, 0x64, 0xa4, 0xa6, 0x6d, + 0x6d, 0x65, 0x6b, 0x8f, 0x6c, 0x6d, 0x63, 0x5b, 0x5d, 0x08, 0x58, 0xc0, 0xd0, 0xd4, 0x51, 0x2b, + 0xed, 0x55, 0x3d, 0x12, 0x30, 0x16, 0x74, 0xa9, 0x83, 0x5f, 0xed, 0xfe, 0xa6, 0xe3, 0x45, 0x26, + 0x60, 0x75, 0xd1, 0xa8, 0x3c, 0x1e, 0x3a, 0x5e, 0x14, 0x31, 0xe9, 0xc9, 0x90, 0x45, 0xc2, 0x68, + 0xab, 0x19, 0x38, 0xbc, 0xc9, 0x1d, 0x39, 0xe4, 0x34, 0xd1, 0x2d, 0x66, 0x74, 0x28, 0x77, 0xda, + 0x5d, 0xd6, 0xd9, 0xde, 0x51, 0x9b, 0xf5, 0x1d, 0xa3, 0x8c, 0xfc, 0x52, 0xb6, 0xdc, 0x0b, 0xc2, + 0x08, 0x41, 0x24, 0xe0, 0xb5, 0x6d, 0x4b, 0xb3, 0x32, 0xfc, 0xf1, 0xa3, 0xfe, 0xb5, 0x05, 0xb5, + 0x55, 0x2a, 0x3f, 0xf1, 0xba, 0xa1, 0xef, 0x49, 0x16, 0x6f, 0x50, 0xb9, 0x32, 0xbc, 0x4d, 0xc3, + 0x60, 0x4b, 0xba, 0xf4, 0x7e, 0x9f, 0x0a, 0x49, 0x0e, 0xc1, 0xdc, 0x16, 0x0a, 0x2a, 0xd6, 0x71, + 0x6b, 0x29, 0xef, 0x9a, 0x2f, 0xf2, 0x1e, 0xc0, 0x28, 0x53, 0x25, 0x77, 0xdc, 0x5a, 0x2a, 0x37, + 0x4f, 0xd8, 0xd9, 0xea, 0xea, 0xb2, 0x1b, 0x58, 0xf6, 0xba, 0x17, 0x50, 0x13, 0xd3, 0xcd, 0x78, + 0xd6, 0x9f, 0x59, 0x70, 0x6c, 0x47, 0x08, 0x82, 0xb3, 0x48, 0x50, 0xf2, 0x36, 0xec, 0xc7, 0xd2, + 0xb4, 0xc6, 0x90, 0x94, 0x51, 0xa6, 0x4d, 0xc9, 0x1a, 0xc0, 0x20, 0x09, 0x21, 0x2a, 0xb9, 0xe3, + 0xf9, 0xa5, 0x72, 0xf3, 0x94, 0xfd, 0xe6, 0x66, 0xdb, 0x69, 0x52, 0x37, 0xe3, 0x4c, 0x56, 0xc7, + 0x98, 0xe5, 0x91, 0xd9, 0xc9, 0x89, 0xcc, 0x34, 0xd4, 0x31, 0x6a, 0x9b, 0xb0, 0xb8, 0x4a, 0xe5, + 0x5d, 0x4f, 0x52, 0x31, 0xc6, 0x2f, 0x29, 0xed, 0x78, 0x09, 0xad, 0x3d, 0x97, 0xf0, 0x77, 0x0b, + 0x8e, 0xee, 0x90, 0xe8, 0xbf, 0x5d, 0xc0, 0x47, 0x16, 0x94, 0xd2, 0x14, 0xa4, 0x09, 0x05, 0xcf, + 0xf7, 0x63, 0x2a, 0x04, 0xe2, 0x2f, 0xad, 0x54, 0x9e, 0xfe, 0xb2, 0xbc, 0x60, 0xc2, 0x5e, 0xd7, + 0x9a, 0x0d, 0x19, 0x87, 0x51, 0xe0, 0x26, 0x86, 0x64, 0x19, 0x0a, 0xbc, 0xdf, 0x6e, 0x6d, 0xd3, + 0xa1, 0xd9, 0xa2, 0x0b, 0xb6, 0x3e, 0xaf, 0x76, 0x72, 0x94, 0xed, 0xeb, 0xd1, 0xd0, 0x9d, 0xe3, + 0xfd, 0xf6, 0x1d, 0x3a, 0x54, 0x75, 0x1a, 0x30, 0x19, 0x46, 0x41, 0x8b, 0xb3, 0xcf, 0x69, 0x8c, + 0xd8, 0xf3, 0x6e, 0x59, 0xcb, 0xd6, 0x95, 0x88, 0x9c, 0x81, 0x03, 0x3c, 0x66, 0x9c, 0x09, 0x1a, + 0xb7, 0x78, 0x1c, 0xb2, 0x38, 0x94, 0xc3, 0xca, 0x2c, 0xda, 0xcd, 0x27, 0x8a, 0x75, 0x23, 0xaf, + 0x37, 0xe0, 0xf0, 0x2a, 0x95, 0x2b, 0xaa, 0xcc, 0x53, 0x9e, 0xab, 0xfa, 0x57, 0x50, 0x79, 0xd5, + 0xc5, 0xb4, 0xf1, 0x3c, 0x14, 0x75, 0x1b, 0x43, 0xdf, 0x6c, 0x97, 0x23, 0xd9, 0xae, 0xe8, 0x01, + 0x81, 0xae, 0x6b, 0x37, 0xdd, 0x02, 0x9a, 0xae, 0xf9, 0x64, 0x19, 0xf6, 0xe1, 0xd2, 0x54, 0xe0, + 0xf0, 0x0e, 0x2e, 0xae, 0xb6, 0xaa, 0x1f, 0x86, 0xb7, 0xd2, 0xcd, 0xa4, 0x15, 0x1a, 0x71, 0xfd, + 0x01, 0x1c, 0x7a, 0x59, 0xf1, 0x6f, 0xe2, 0x3a, 0x08, 0x07, 0x56, 0xa9, 0xdc, 0x18, 0x46, 0x1d, + 0xd5, 0x61, 0x83, 0xc9, 0x06, 0x92, 0x15, 0x1a, 0x3c, 0x15, 0x28, 0x08, 0x2d, 0x42, 0x38, 0x45, + 0x37, 0xf9, 0xac, 0x2f, 0xa0, 0xfd, 0x3d, 0xe6, 0xd3, 0xb5, 0x68, 0x93, 0x25, 0x51, 0x7e, 0xb2, + 0xe0, 0xe0, 0x98, 0xd8, 0xc4, 0xb9, 0x00, 0xa5, 0x88, 0xf9, 0xb4, 0x15, 0x46, 0x9b, 0xcc, 0x10, + 0xab, 0x64, 0x51, 0xf2, 0x26, 0xb7, 0x53, 0xa7, 0x62, 0x64, 0x56, 0xe4, 0x33, 0x38, 0xe8, 0x71, + 0xde, 0x0d, 0x3b, 0xb8, 0x8b, 0x5b, 0x03, 0x1a, 0x8b, 0xd1, 0x8c, 0x3c, 0x33, 0xf1, 0x4c, 0x69, + 0x73, 0x8c, 0x49, 0x32, 0x71, 0x8c, 0xbc, 0xfe, 0x43, 0x0e, 0xca, 0x19, 0x1b, 0x42, 0x60, 0x36, + 0xf2, 0x7a, 0x54, 0x9f, 0x09, 0x17, 0xd7, 0xe4, 0x08, 0x14, 0x3d, 0xce, 0x5b, 0x28, 0xcf, 0xa1, + 0xbc, 0xe0, 0x71, 0x7e, 0x4f, 0xa9, 0x2a, 0x50, 0x48, 0x00, 0xe5, 0xb5, 0xc6, 0x7c, 0x92, 0xa3, + 0x00, 0x41, 0x28, 0x5b, 0x1d, 0xd6, 0xeb, 0x85, 0x12, 0xb7, 0x74, 0xc9, 0x2d, 0x05, 0xa1, 0xbc, + 0x81, 0x02, 0xa5, 0x6e, 0xf7, 0xc3, 0xae, 0xdf, 0x92, 0x5e, 0x20, 0x2a, 0xfb, 0xb4, 0x1a, 0x25, + 0x1f, 0x7b, 0x81, 0x40, 0x6f, 0x96, 0x72, 0x9d, 0x33, 0xde, 0xcc, 0x20, 0x25, 0xb7, 0x12, 0x6f, + 0x9f, 0x72, 0x51, 0x29, 0xe0, 0x78, 0x39, 0x31, 0xa9, 0x14, 0x1f, 0x30, 0xbf, 0xdf, 0xa5, 0x26, + 0xcb, 0x4d, 0xca, 0x05, 0x39, 0x0b, 0xc4, 0xdc, 0x66, 0xc2, 0xdf, 0x4e, 0xb3, 0x15, 0x31, 0xdb, + 0xbc, 0xd6, 0x6c, 0xf8, 0xdb, 0x49, 0xa9, 0x6e, 0xc3, 0x9c, 0x0e, 0xa1, 0x8a, 0xc4, 0x3d, 0xb9, + 0x95, 0x14, 0x49, 0xad, 0xb3, 0x95, 0xc8, 0x8d, 0x57, 0x62, 0x1e, 0xf2, 0xa2, 0xdf, 0x33, 0xf5, + 0x51, 0xcb, 0xfa, 0x16, 0xcc, 0x5f, 0x5f, 0xb9, 0xb1, 0xf6, 0x91, 0x9a, 0x5b, 0xc9, 0x09, 0x26, + 0x30, 0xeb, 0x7b, 0xd2, 0xc3, 0x98, 0xfb, 0x5d, 0x5c, 0xa7, 0x79, 0x72, 0x99, 0x3c, 0xa3, 0x93, + 0x9e, 0x1f, 0xbb, 0x41, 0x17, 0x60, 0x1f, 0x8f, 0xd9, 0x80, 0x62, 0xa9, 0x8b, 0xae, 0xfe, 0xa8, + 0x7f, 0x9b, 0x83, 0x03, 0x99, 0x54, 0x66, 0x27, 0x12, 0x98, 0xed, 0x30, 0x5f, 0x37, 0xf9, 0x7f, + 0x2e, 0xae, 0x15, 0xca, 0x2e, 0x0b, 0x12, 0x94, 0x5d, 0x16, 0x28, 0x2b, 0xdc, 0xaa, 0xba, 0x77, + 0xb8, 0x56, 0x59, 0xc2, 0xc8, 0xa7, 0x5f, 0x60, 0xc7, 0xf2, 0xae, 0xfe, 0x50, 0xbe, 0x6a, 0x26, + 0xce, 0x21, 0x74, 0xb5, 0x54, 0x76, 0x03, 0xaf, 0xdb, 0xa7, 0x95, 0x02, 0xca, 0xf4, 0x07, 0xb9, + 0x05, 0x25, 0x1e, 0x33, 0xb6, 0xd9, 0x62, 0x5c, 0x60, 0x99, 0xcb, 0xcd, 0xa5, 0x49, 0x5d, 0x5b, + 0x57, 0x0e, 0x1f, 0x72, 0xe1, 0x16, 0xb9, 0x59, 0x65, 0x4a, 0x50, 0x1a, 0x2b, 0xc1, 0x22, 0x94, + 0x14, 0x15, 0xc1, 0xbd, 0x0e, 0xad, 0x80, 0xde, 0x33, 0xa9, 0xe0, 0xfd, 0xd9, 0x62, 0x6e, 0x3e, + 0x5f, 0xbf, 0x01, 0x05, 0x13, 0x51, 0xf1, 0x53, 0x83, 0x21, 0xe9, 0xa2, 0x5a, 0x27, 0x4c, 0x72, + 0x23, 0x26, 0x49, 0x5f, 0xf2, 0xa3, 0xbe, 0xd4, 0xef, 0x40, 0x31, 0x81, 0x45, 0xae, 0x41, 0x5e, + 0xb1, 0xb1, 0x70, 0x0f, 0x9e, 0x9c, 0x92, 0xcd, 0xca, 0xec, 0xe3, 0x3f, 0x8f, 0xcd, 0xb8, 0xca, + 0xb3, 0xf9, 0x33, 0x40, 0x61, 0x83, 0xc6, 0x83, 0xb0, 0x43, 0xc9, 0x8f, 0x16, 0x94, 0x33, 0xa3, + 0x83, 0x34, 0x27, 0xc5, 0x7b, 0x75, 0xfc, 0x54, 0xcf, 0xed, 0xca, 0x47, 0xef, 0x88, 0x7a, 0xe3, + 0x9b, 0xdf, 0xfe, 0xfe, 0x3e, 0x77, 0x86, 0x9c, 0x72, 0x26, 0xbc, 0x7e, 0xd3, 0x09, 0x46, 0x1e, + 0x5a, 0x00, 0xa3, 0x69, 0x49, 0x1a, 0x53, 0xa4, 0x1d, 0x1f, 0xb7, 0xd5, 0xe6, 0x6e, 0x5c, 0x0c, + 0x50, 0x07, 0x81, 0x9e, 0x22, 0x27, 0x27, 0x01, 0x35, 0x33, 0x9a, 0xfc, 0x6a, 0xc1, 0xff, 0xc7, + 0x2f, 0x1a, 0x72, 0x61, 0x8a, 0xbc, 0xaf, 0xde, 0x58, 0xd5, 0x8b, 0xbb, 0x75, 0x33, 0x90, 0x2f, + 0x20, 0x64, 0x87, 0x2c, 0x4f, 0x82, 0x8c, 0x37, 0x93, 0x70, 0xba, 0x18, 0x83, 0x3c, 0xb2, 0x60, + 0xfe, 0xe5, 0xbb, 0x9b, 0x5c, 0x9a, 0x02, 0xc3, 0xeb, 0x1e, 0x08, 0xd5, 0xcb, 0xbb, 0x77, 0x34, + 0xf0, 0x2f, 0x21, 0xfc, 0x06, 0x71, 0xa6, 0x84, 0xff, 0xa5, 0x3e, 0x8d, 0x0f, 0xc8, 0x53, 0x2b, + 0x73, 0xf7, 0x67, 0x1f, 0x92, 0xe4, 0xca, 0xd4, 0x95, 0x7c, 0xcd, 0x43, 0xb7, 0xfa, 0xee, 0x1e, + 0xbd, 0x0d, 0x9f, 0x2b, 0xc8, 0xe7, 0x22, 0x39, 0x3f, 0x89, 0xcf, 0xe8, 0x0d, 0x4a, 0x65, 0xda, + 0x95, 0x3f, 0x2c, 0x7c, 0x84, 0xbd, 0xee, 0x0f, 0x06, 0xb9, 0x3a, 0x05, 0xb0, 0x37, 0xfc, 0x39, + 0xaa, 0x5e, 0xdb, 0xb3, 0xbf, 0xa1, 0x76, 0x15, 0xa9, 0x5d, 0x26, 0x17, 0x77, 0x47, 0x2d, 0xed, + 0xd8, 0x43, 0x0b, 0x4a, 0xe9, 0x6d, 0x41, 0xde, 0x99, 0x04, 0xe7, 0xe5, 0x3b, 0xac, 0xda, 0xd8, + 0x85, 0x87, 0x81, 0xdc, 0x44, 0xc8, 0x67, 0xc9, 0xe9, 0x49, 0x90, 0xbd, 0x76, 0x27, 0x6c, 0xe1, + 0x4b, 0x7f, 0xe5, 0xee, 0xe3, 0xe7, 0x35, 0xeb, 0xc9, 0xf3, 0x9a, 0xf5, 0xd7, 0xf3, 0x9a, 0xf5, + 0xdd, 0x8b, 0xda, 0xcc, 0x93, 0x17, 0xb5, 0x99, 0x67, 0x2f, 0x6a, 0x33, 0x9f, 0x36, 0x83, 0x50, + 0x6e, 0xf5, 0xdb, 0x76, 0x87, 0xf5, 0x92, 0x78, 0xfa, 0x67, 0x59, 0xf8, 0xdb, 0x4e, 0xa7, 0x1b, + 0xd2, 0x48, 0x3a, 0x41, 0xcc, 0x3b, 0x8e, 0xec, 0x09, 0x3d, 0x73, 0xdb, 0x73, 0xf8, 0x76, 0x3f, + 0xf7, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x05, 0xb1, 0xf9, 0xc8, 0xf8, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -970,6 +1284,12 @@ type ServiceClient interface { GetLatestValidatorSet(ctx context.Context, in *GetLatestValidatorSetRequest, opts ...grpc.CallOption) (*GetLatestValidatorSetResponse, error) // GetValidatorSetByHeight queries validator-set at a given height. GetValidatorSetByHeight(ctx context.Context, in *GetValidatorSetByHeightRequest, opts ...grpc.CallOption) (*GetValidatorSetByHeightResponse, error) + // ABCIQuery defines a query handler that supports ABCI queries directly to the + // application, bypassing Tendermint completely. The ABCI query must contain + // a valid and supported path, including app, custom, p2p, and store. + // + // Since: cosmos-sdk 0.46 + ABCIQuery(ctx context.Context, in *ABCIQueryRequest, opts ...grpc.CallOption) (*ABCIQueryResponse, error) } type serviceClient struct { @@ -1034,6 +1354,15 @@ func (c *serviceClient) GetValidatorSetByHeight(ctx context.Context, in *GetVali return out, nil } +func (c *serviceClient) ABCIQuery(ctx context.Context, in *ABCIQueryRequest, opts ...grpc.CallOption) (*ABCIQueryResponse, error) { + out := new(ABCIQueryResponse) + err := c.cc.Invoke(ctx, "/cosmos.base.tendermint.v1beta1.Service/ABCIQuery", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // ServiceServer is the server API for Service service. type ServiceServer interface { // GetNodeInfo queries the current node info. @@ -1048,6 +1377,12 @@ type ServiceServer interface { GetLatestValidatorSet(context.Context, *GetLatestValidatorSetRequest) (*GetLatestValidatorSetResponse, error) // GetValidatorSetByHeight queries validator-set at a given height. GetValidatorSetByHeight(context.Context, *GetValidatorSetByHeightRequest) (*GetValidatorSetByHeightResponse, error) + // ABCIQuery defines a query handler that supports ABCI queries directly to the + // application, bypassing Tendermint completely. The ABCI query must contain + // a valid and supported path, including app, custom, p2p, and store. + // + // Since: cosmos-sdk 0.46 + ABCIQuery(context.Context, *ABCIQueryRequest) (*ABCIQueryResponse, error) } // UnimplementedServiceServer can be embedded to have forward compatible implementations. @@ -1072,6 +1407,9 @@ func (*UnimplementedServiceServer) GetLatestValidatorSet(ctx context.Context, re func (*UnimplementedServiceServer) GetValidatorSetByHeight(ctx context.Context, req *GetValidatorSetByHeightRequest) (*GetValidatorSetByHeightResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetValidatorSetByHeight not implemented") } +func (*UnimplementedServiceServer) ABCIQuery(ctx context.Context, req *ABCIQueryRequest) (*ABCIQueryResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ABCIQuery not implemented") +} func RegisterServiceServer(s grpc1.Server, srv ServiceServer) { s.RegisterService(&_Service_serviceDesc, srv) @@ -1185,6 +1523,24 @@ func _Service_GetValidatorSetByHeight_Handler(srv interface{}, ctx context.Conte return interceptor(ctx, in, info, handler) } +func _Service_ABCIQuery_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ABCIQueryRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ServiceServer).ABCIQuery(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.base.tendermint.v1beta1.Service/ABCIQuery", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ServiceServer).ABCIQuery(ctx, req.(*ABCIQueryRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Service_serviceDesc = grpc.ServiceDesc{ ServiceName: "cosmos.base.tendermint.v1beta1.Service", HandlerType: (*ServiceServer)(nil), @@ -1213,6 +1569,10 @@ var _Service_serviceDesc = grpc.ServiceDesc{ MethodName: "GetValidatorSetByHeight", Handler: _Service_GetValidatorSetByHeight_Handler, }, + { + MethodName: "ABCIQuery", + Handler: _Service_ABCIQuery_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "cosmos/base/tendermint/v1beta1/query.proto", @@ -1854,39 +2214,257 @@ func (m *Module) 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 *ABCIQueryRequest) 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 *GetValidatorSetByHeightRequest) Size() (n int) { - if m == nil { - return 0 - } + +func (m *ABCIQueryRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ABCIQueryRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l + if m.Prove { + i-- + if m.Prove { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } if m.Height != 0 { - n += 1 + sovQuery(uint64(m.Height)) + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if len(m.Path) > 0 { + i -= len(m.Path) + copy(dAtA[i:], m.Path) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Path))) + i-- + dAtA[i] = 0x12 } - return n + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *GetValidatorSetByHeightResponse) Size() (n int) { - if m == nil { - return 0 +func (m *ABCIQueryResponse) 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 + return dAtA[:n], nil +} + +func (m *ABCIQueryResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ABCIQueryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Codespace) > 0 { + i -= len(m.Codespace) + copy(dAtA[i:], m.Codespace) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Codespace))) + i-- + dAtA[i] = 0x52 + } + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x48 + } + if m.ProofOps != nil { + { + size, err := m.ProofOps.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x3a + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x32 + } + if m.Index != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x28 + } + if len(m.Info) > 0 { + i -= len(m.Info) + copy(dAtA[i:], m.Info) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Info))) + i-- + dAtA[i] = 0x22 + } + if len(m.Log) > 0 { + i -= len(m.Log) + copy(dAtA[i:], m.Log) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Log))) + i-- + dAtA[i] = 0x1a + } + if m.Code != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Code)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ProofOp) 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 *ProofOp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProofOp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x1a + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x12 + } + if len(m.Type) > 0 { + i -= len(m.Type) + copy(dAtA[i:], m.Type) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Type))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ProofOps) 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 *ProofOps) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProofOps) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ops) > 0 { + for iNdEx := len(m.Ops) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Ops[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 *GetValidatorSetByHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *GetValidatorSetByHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l if m.BlockHeight != 0 { n += 1 + sovQuery(uint64(m.BlockHeight)) } @@ -2127,6 +2705,107 @@ func (m *Module) Size() (n int) { return n } +func (m *ABCIQueryRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Data) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Path) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + if m.Prove { + n += 2 + } + return n +} + +func (m *ABCIQueryResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Code != 0 { + n += 1 + sovQuery(uint64(m.Code)) + } + l = len(m.Log) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Info) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Index != 0 { + n += 1 + sovQuery(uint64(m.Index)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.ProofOps != nil { + l = m.ProofOps.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + l = len(m.Codespace) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *ProofOp) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Type) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *ProofOps) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Ops) > 0 { + for _, e := range m.Ops { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3867,6 +4546,702 @@ func (m *Module) Unmarshal(dAtA []byte) error { } return nil } +func (m *ABCIQueryRequest) 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: ABCIQueryRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ABCIQueryRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Path", 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.Path = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Prove", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Prove = bool(v != 0) + 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 *ABCIQueryResponse) 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: ABCIQueryResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ABCIQueryResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) + } + m.Code = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Code |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Log", 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.Log = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Info", 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.Info = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 7: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProofOps", 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.ProofOps == nil { + m.ProofOps = &ProofOps{} + } + if err := m.ProofOps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Codespace", 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.Codespace = string(dAtA[iNdEx:postIndex]) + 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 *ProofOp) 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: ProofOp: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProofOp: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", 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.Type = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + 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 *ProofOps) 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: ProofOps: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProofOps: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ops", 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.Ops = append(m.Ops, ProofOp{}) + if err := m.Ops[len(m.Ops)-1].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 skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/client/grpc/tmservice/query.pb.gw.go b/client/grpc/tmservice/query.pb.gw.go index e7c294221045..36727c4ca4e7 100644 --- a/client/grpc/tmservice/query.pb.gw.go +++ b/client/grpc/tmservice/query.pb.gw.go @@ -249,6 +249,42 @@ func local_request_Service_GetValidatorSetByHeight_0(ctx context.Context, marsha } +var ( + filter_Service_ABCIQuery_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Service_ABCIQuery_0(ctx context.Context, marshaler runtime.Marshaler, client ServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABCIQueryRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Service_ABCIQuery_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.ABCIQuery(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Service_ABCIQuery_0(ctx context.Context, marshaler runtime.Marshaler, server ServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ABCIQueryRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Service_ABCIQuery_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.ABCIQuery(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterServiceHandlerServer registers the http handlers for service Service to "mux". // UnaryRPC :call ServiceServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -393,6 +429,29 @@ func RegisterServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, se }) + mux.Handle("GET", pattern_Service_ABCIQuery_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + 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_Service_ABCIQuery_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Service_ABCIQuery_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -554,6 +613,26 @@ func RegisterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, cl }) + mux.Handle("GET", pattern_Service_ABCIQuery_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_Service_ABCIQuery_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Service_ABCIQuery_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -569,6 +648,8 @@ var ( pattern_Service_GetLatestValidatorSet_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5}, []string{"cosmos", "base", "tendermint", "v1beta1", "validatorsets", "latest"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Service_GetValidatorSetByHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 1, 0, 4, 1, 5, 5}, []string{"cosmos", "base", "tendermint", "v1beta1", "validatorsets", "height"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Service_ABCIQuery_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"cosmos", "base", "tendermint", "v1beta1", "abci_query"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -583,4 +664,6 @@ var ( forward_Service_GetLatestValidatorSet_0 = runtime.ForwardResponseMessage forward_Service_GetValidatorSetByHeight_0 = runtime.ForwardResponseMessage + + forward_Service_ABCIQuery_0 = runtime.ForwardResponseMessage ) diff --git a/client/grpc/tmservice/service.go b/client/grpc/tmservice/service.go index 7404c79e70e8..f5384036b83b 100644 --- a/client/grpc/tmservice/service.go +++ b/client/grpc/tmservice/service.go @@ -5,9 +5,11 @@ import ( gogogrpc "github.com/gogo/protobuf/grpc" "github.com/grpc-ecosystem/grpc-gateway/runtime" + abci "github.com/tendermint/tendermint/abci/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/rpc" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -16,20 +18,31 @@ import ( "github.com/cosmos/cosmos-sdk/version" ) -// This is the struct that we will implement all the handlers on. -type queryServer struct { - clientCtx client.Context - interfaceRegistry codectypes.InterfaceRegistry -} +var ( + _ ServiceServer = queryServer{} + _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} +) -var _ ServiceServer = queryServer{} -var _ codectypes.UnpackInterfacesMessage = &GetLatestValidatorSetResponse{} +type ( + abciQueryFn = func(abci.RequestQuery) abci.ResponseQuery + + queryServer struct { + clientCtx client.Context + interfaceRegistry codectypes.InterfaceRegistry + queryFn abciQueryFn + } +) // NewQueryServer creates a new tendermint query server. -func NewQueryServer(clientCtx client.Context, interfaceRegistry codectypes.InterfaceRegistry) ServiceServer { +func NewQueryServer( + clientCtx client.Context, + interfaceRegistry codectypes.InterfaceRegistry, + queryFn abciQueryFn, +) ServiceServer { return queryServer{ clientCtx: clientCtx, interfaceRegistry: interfaceRegistry, + queryFn: queryFn, } } @@ -39,6 +52,7 @@ func (s queryServer) GetSyncing(ctx context.Context, _ *GetSyncingRequest) (*Get if err != nil { return nil, err } + return &GetSyncingResponse{ Syncing: status.SyncInfo.CatchingUp, }, nil @@ -78,6 +92,7 @@ func (s queryServer) GetBlockByHeight(ctx context.Context, req *GetBlockByHeight if err != nil { return nil, err } + return &GetBlockByHeightResponse{ BlockId: &protoBlockID, Block: protoBlock, @@ -90,6 +105,7 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *GetLatestVa if err != nil { return nil, err } + return validatorsOutput(ctx, s.clientCtx, nil, page, limit) } @@ -101,6 +117,7 @@ func (m *GetLatestValidatorSetResponse) UnpackInterfaces(unpacker codectypes.Any return err } } + return nil } @@ -115,13 +132,16 @@ func (s queryServer) GetValidatorSetByHeight(ctx context.Context, req *GetValida if err != nil { return nil, status.Error(codes.Internal, "failed to parse chain height") } + if req.Height > chainHeight { return nil, status.Error(codes.InvalidArgument, "requested block height is bigger then the chain length") } + r, err := validatorsOutput(ctx, s.clientCtx, &req.Height, page, limit) if err != nil { return nil, err } + return &GetValidatorSetByHeightResponse{ BlockHeight: r.BlockHeight, Validators: r.Validators, @@ -134,6 +154,7 @@ func validatorsOutput(ctx context.Context, cctx client.Context, height *int64, p if err != nil { return nil, err } + resp := GetLatestValidatorSetResponse{ BlockHeight: vs.BlockHeight, Validators: make([]*Validator, len(vs.Validators)), @@ -141,11 +162,13 @@ func validatorsOutput(ctx context.Context, cctx client.Context, height *int64, p Total: vs.Total, }, } + for i, v := range vs.Validators { anyPub, err := codectypes.NewAnyWithValue(v.PubKey) if err != nil { return nil, err } + resp.Validators[i] = &Validator{ Address: v.Address.String(), ProposerPriority: v.ProposerPriority, @@ -153,6 +176,7 @@ func validatorsOutput(ctx context.Context, cctx client.Context, height *int64, p VotingPower: v.VotingPower, } } + return &resp, nil } @@ -192,20 +216,45 @@ func (s queryServer) GetNodeInfo(ctx context.Context, req *GetNodeInfoRequest) ( return &resp, nil } +func (s queryServer) ABCIQuery(ctx context.Context, req *ABCIQueryRequest) (*ABCIQueryResponse, error) { + if s.queryFn == nil { + return nil, status.Error(codes.Internal, "ABCI Query handler undefined") + } + if req == nil { + return nil, status.Error(codes.InvalidArgument, "empty request") + } + if len(req.Path) == 0 { + return nil, status.Error(codes.InvalidArgument, "empty query path") + } + + if path := baseapp.SplitABCIQueryPath(req.Path); len(path) > 0 { + switch path[0] { + case baseapp.QueryPathApp, baseapp.QueryPathStore, baseapp.QueryPathP2P, baseapp.QueryPathCustom: + // valid path + + default: + // Otherwise, error as to prevent either valid gRPC service requests or + // bogus ABCI queries. + return nil, status.Errorf(codes.InvalidArgument, "unsupported ABCI query path: %s", req.Path) + } + } + + res := s.queryFn(req.ToABCIRequestQuery()) + return FromABCIResponseQuery(res), nil +} + // RegisterTendermintService registers the tendermint queries on the gRPC router. func RegisterTendermintService( - qrt gogogrpc.Server, clientCtx client.Context, - interfaceRegistry codectypes.InterfaceRegistry, + server gogogrpc.Server, + iRegistry codectypes.InterfaceRegistry, + queryFn abciQueryFn, ) { - RegisterServiceServer( - qrt, - NewQueryServer(clientCtx, interfaceRegistry), - ) + RegisterServiceServer(server, NewQueryServer(clientCtx, iRegistry, queryFn)) } // RegisterGRPCGatewayRoutes mounts the tendermint service's GRPC-gateway routes on the // given Mux. func RegisterGRPCGatewayRoutes(clientConn gogogrpc.ClientConn, mux *runtime.ServeMux) { - RegisterServiceHandlerClient(context.Background(), mux, NewServiceClient(clientConn)) + _ = RegisterServiceHandlerClient(context.Background(), mux, NewServiceClient(clientConn)) } diff --git a/client/grpc/tmservice/service_test.go b/client/grpc/tmservice/service_test.go index 5d3811d01585..35934f934629 100644 --- a/client/grpc/tmservice/service_test.go +++ b/client/grpc/tmservice/service_test.go @@ -19,12 +19,15 @@ import ( type IntegrationTestSuite struct { suite.Suite - cfg network.Config - network *network.Network - + cfg network.Config + network *network.Network queryClient tmservice.ServiceClient } +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") @@ -110,7 +113,7 @@ func (s IntegrationTestSuite) TestQueryLatestValidatorSet() { s.Require().Equal(true, ok) s.Require().Equal(content, val.PubKey) - //with pagination + // with pagination _, err = s.queryClient.GetLatestValidatorSet(context.Background(), &tmservice.GetLatestValidatorSetRequest{Pagination: &qtypes.PageRequest{ Offset: 0, Limit: 10, @@ -254,6 +257,91 @@ func (s IntegrationTestSuite) TestValidatorSetByHeight_GRPCGateway() { } } -func TestIntegrationTestSuite(t *testing.T) { - suite.Run(t, new(IntegrationTestSuite)) +func (s IntegrationTestSuite) TestABCIQuery() { + testCases := []struct { + name string + req *tmservice.ABCIQueryRequest + expectErr bool + expectedCode uint32 + validQuery bool + }{ + { + name: "valid request with proof", + req: &tmservice.ABCIQueryRequest{ + Path: "/store/gov/key", + Data: []byte{0x03}, + Prove: true, + }, + validQuery: true, + }, + { + name: "valid request without proof", + req: &tmservice.ABCIQueryRequest{ + Path: "/store/gov/key", + Data: []byte{0x03}, + Prove: false, + }, + validQuery: true, + }, + { + name: "request with invalid path", + req: &tmservice.ABCIQueryRequest{ + Path: "/foo/bar", + Data: []byte{0x03}, + }, + expectErr: true, + }, + { + name: "request with invalid path recursive", + req: &tmservice.ABCIQueryRequest{ + Path: "/cosmos.base.tendermint.v1beta1.Service/ABCIQuery", + Data: s.cfg.Codec.MustMarshal(&tmservice.ABCIQueryRequest{ + Path: "/cosmos.base.tendermint.v1beta1.Service/ABCIQuery", + }), + }, + expectErr: true, + }, + { + name: "request with invalid broadcast tx path", + req: &tmservice.ABCIQueryRequest{ + Path: "/cosmos.tx.v1beta1.Service/BroadcastTx", + Data: []byte{0x00}, + }, + expectErr: true, + }, + { + name: "request with invalid data", + req: &tmservice.ABCIQueryRequest{ + Path: "/store/gov/key", + Data: []byte{0x0044, 0x00}, + }, + validQuery: false, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + res, err := s.queryClient.ABCIQuery(context.Background(), tc.req) + if tc.expectErr { + s.Require().Error(err) + s.Require().Nil(res) + } else { + s.Require().NoError(err) + s.Require().NotNil(res) + s.Require().Equal(res.Code, tc.expectedCode) + } + + if tc.validQuery { + s.Require().Greater(res.Height, int64(0)) + s.Require().Greater(len(res.Key), 0, "expected non-empty key") + s.Require().Greater(len(res.Value), 0, "expected non-empty value") + } + + if tc.req.Prove { + s.Require().Greater(len(res.ProofOps.Ops), 0, "expected proofs") + } + }) + } } diff --git a/client/grpc/tmservice/types.go b/client/grpc/tmservice/types.go new file mode 100644 index 000000000000..00724557d9ce --- /dev/null +++ b/client/grpc/tmservice/types.go @@ -0,0 +1,47 @@ +package tmservice + +import ( + abci "github.com/tendermint/tendermint/abci/types" +) + +// ToABCIRequestQuery converts a gRPC ABCIQueryRequest type to an ABCI +// RequestQuery type. +func (req *ABCIQueryRequest) ToABCIRequestQuery() abci.RequestQuery { + return abci.RequestQuery{ + Data: req.Data, + Path: req.Path, + Height: req.Height, + Prove: req.Prove, + } +} + +// FromABCIResponseQuery converts an ABCI ResponseQuery type to a gRPC +// ABCIQueryResponse type. +func FromABCIResponseQuery(res abci.ResponseQuery) *ABCIQueryResponse { + var proofOps *ProofOps + + if res.ProofOps != nil { + proofOps = &ProofOps{ + Ops: make([]ProofOp, len(res.ProofOps.Ops)), + } + for i, proofOp := range res.ProofOps.Ops { + proofOps.Ops[i] = ProofOp{ + Type: proofOp.Type, + Key: proofOp.Key, + Data: proofOp.Data, + } + } + } + + return &ABCIQueryResponse{ + Code: res.Code, + Log: res.Log, + Info: res.Info, + Index: res.Index, + Key: res.Key, + Value: res.Value, + ProofOps: proofOps, + Height: res.Height, + Codespace: res.Codespace, + } +} diff --git a/client/grpc_query.go b/client/grpc_query.go index 15c0725f2e57..dd0f5ab11335 100644 --- a/client/grpc_query.go +++ b/client/grpc_query.go @@ -4,11 +4,12 @@ import ( gocontext "context" "errors" "fmt" + "reflect" + "strconv" + "github.com/cosmos/cosmos-sdk/codec" proto "github.com/gogo/protobuf/proto" "google.golang.org/grpc/encoding" - "reflect" - "strconv" gogogrpc "github.com/gogo/protobuf/grpc" abci "github.com/tendermint/tendermint/abci/types" diff --git a/client/grpc_query_test.go b/client/grpc_query_test.go index b63937ac2337..faff1ad5dc64 100644 --- a/client/grpc_query_test.go +++ b/client/grpc_query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package client_test diff --git a/client/input/input.go b/client/input/input.go index 57b04b40186a..31daa99be32f 100644 --- a/client/input/input.go +++ b/client/input/input.go @@ -2,6 +2,7 @@ package input import ( "bufio" + "errors" "fmt" "io" "os" @@ -41,7 +42,7 @@ func GetPassword(prompt string, buf *bufio.Reader) (pass string, err error) { // If the input is not recognized, it returns false and a nil error. func GetConfirmation(prompt string, r *bufio.Reader, w io.Writer) (bool, error) { if inputIsTty() { - fmt.Fprintf(w, "%s [y/N]: ", prompt) + _, _ = fmt.Fprintf(w, "%s [y/N]: ", prompt) } response, err := readLineFromBuf(r) @@ -83,12 +84,25 @@ func inputIsTty() bool { return isatty.IsTerminal(os.Stdin.Fd()) || isatty.IsCygwinTerminal(os.Stdin.Fd()) } -// readLineFromBuf reads one line from stdin. +// readLineFromBuf reads one line from reader. // Subsequent calls reuse the same buffer, so we don't lose // any input when reading a password twice (to verify) func readLineFromBuf(buf *bufio.Reader) (string, error) { pass, err := buf.ReadString('\n') - if err != nil { + + switch { + case errors.Is(err, io.EOF): + // If by any chance the error is EOF, but we were actually able to read + // something from the reader then don't return the EOF error. + // If we didn't read anything from the reader and got the EOF error, then + // it's safe to return EOF back to the caller. + if len(pass) > 0 { + // exit the switch statement + break + } + return "", err + + case err != nil: return "", err } diff --git a/client/input/input_test.go b/client/input/input_test.go new file mode 100644 index 000000000000..3132afcdfaa4 --- /dev/null +++ b/client/input/input_test.go @@ -0,0 +1,56 @@ +package input + +import ( + "bufio" + "errors" + "io" + "testing" + + "github.com/stretchr/testify/require" +) + +type fakeReader struct { + fnc func(p []byte) (int, error) +} + +func (f fakeReader) Read(p []byte) (int, error) { + return f.fnc(p) +} + +var _ io.Reader = fakeReader{} + +func TestReadLineFromBuf(t *testing.T) { + var fr fakeReader + + t.Run("it correctly returns the password when reader returns EOF", func(t *testing.T) { + fr.fnc = func(p []byte) (int, error) { + return copy(p, []byte("hello")), io.EOF + } + buf := bufio.NewReader(fr) + + pass, err := readLineFromBuf(buf) + require.NoError(t, err) + require.Equal(t, "hello", pass) + }) + + t.Run("it returns EOF if reader has been exhausted", func(t *testing.T) { + fr.fnc = func(p []byte) (int, error) { + return 0, io.EOF + } + buf := bufio.NewReader(fr) + + _, err := readLineFromBuf(buf) + require.ErrorIs(t, err, io.EOF) + }) + + t.Run("it returns the error if it's not EOF regardles if it read something or not", func(t *testing.T) { + expectedErr := errors.New("oh no") + fr.fnc = func(p []byte) (int, error) { + return copy(p, []byte("hello")), expectedErr + } + buf := bufio.NewReader(fr) + + _, err := readLineFromBuf(buf) + require.ErrorIs(t, err, expectedErr) + }) +} diff --git a/client/keys/add.go b/client/keys/add.go index 4591062e5182..76d15b8b9a9e 100644 --- a/client/keys/add.go +++ b/client/keys/add.go @@ -292,14 +292,15 @@ func printCreate(cmd *cobra.Command, k *keyring.Record, showMnemonic bool, mnemo switch outputFormat { case OutputFormatText: cmd.PrintErrln() - printKeyringRecord(cmd.OutOrStdout(), k, keyring.MkAccKeyOutput, outputFormat) + if err := printKeyringRecord(cmd.OutOrStdout(), k, keyring.MkAccKeyOutput, outputFormat); err != nil { + return err + } // print mnemonic unless requested not to. if showMnemonic { - fmt.Fprintln(cmd.ErrOrStderr(), "\n**Important** write this mnemonic phrase in a safe place.") - fmt.Fprintln(cmd.ErrOrStderr(), "It is the only way to recover your account if you ever forget your password.") - fmt.Fprintln(cmd.ErrOrStderr(), "") - fmt.Fprintln(cmd.ErrOrStderr(), mnemonic) + if _, err := fmt.Fprintln(cmd.ErrOrStderr(), fmt.Sprintf("\n**Important** write this mnemonic phrase in a safe place.\nIt is the only way to recover your account if you ever forget your password.\n\n%s\n", mnemonic)); err != nil { + return fmt.Errorf("failed to print mnemonic: %v", err) + } } case OutputFormatJSON: out, err := keyring.MkAccKeyOutput(k) diff --git a/client/keys/export.go b/client/keys/export.go index 13491b5e839a..7e2f7250d38f 100644 --- a/client/keys/export.go +++ b/client/keys/export.go @@ -2,6 +2,7 @@ package keys import ( "bufio" + "encoding/hex" "fmt" "github.com/spf13/cobra" @@ -9,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/input" "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/crypto/types" ) const ( @@ -75,7 +77,7 @@ func exportUnsafeUnarmored(cmd *cobra.Command, uid string, buf *bufio.Reader, kr return nil } - hexPrivKey, err := keyring.NewUnsafe(kr).UnsafeExportPrivKeyHex(uid) + hexPrivKey, err := unsafeExportPrivKeyHex(kr.(unsafeExporter), uid) if err != nil { return err } @@ -84,3 +86,20 @@ func exportUnsafeUnarmored(cmd *cobra.Command, uid string, buf *bufio.Reader, kr return nil } + +// unsafeExporter is implemented by key stores that support unsafe export +// of private keys' material. +type unsafeExporter interface { + // ExportPrivateKeyObject returns a private key in unarmored format. + ExportPrivateKeyObject(uid string) (types.PrivKey, error) +} + +// unsafeExportPrivKeyHex exports private keys in unarmored hexadecimal format. +func unsafeExportPrivKeyHex(ks unsafeExporter, uid string) (privkey string, err error) { + priv, err := ks.ExportPrivateKeyObject(uid) + if err != nil { + return "", err + } + + return hex.EncodeToString(priv.Bytes()), nil +} diff --git a/client/keys/export_test.go b/client/keys/export_test.go index 1bc6d695b6bb..0a8aa2d20ab1 100644 --- a/client/keys/export_test.go +++ b/client/keys/export_test.go @@ -89,9 +89,7 @@ func Test_runExportCmd(t *testing.T) { // create a key kb, err := keyring.New(sdk.KeyringServiceName(), tc.keyringBackend, kbHome, bufio.NewReader(mockInBuf), cdc) require.NoError(t, err) - t.Cleanup(func() { - kb.Delete("keyname1") // nolint:errcheck - }) + t.Cleanup(cleanupKeys(t, kb, "keyname1")) path := sdk.GetConfig().GetFullBIP44Path() _, err = kb.NewAccount("keyname1", testdata.TestMnemonic, "", path, hd.Secp256k1) diff --git a/client/keys/import_test.go b/client/keys/import_test.go index b481285200dc..416992c2c55a 100644 --- a/client/keys/import_test.go +++ b/client/keys/import_test.go @@ -91,13 +91,10 @@ HbP+c6JmeJy9JXe2rbbF1QtCX1gLqGcDQPBXiCtFvP7/8wTZtVOPj8vREzhZ9ElO WithCodec(cdc) ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx) - t.Cleanup(func() { - kb.Delete("keyname1") // nolint:errcheck - }) + t.Cleanup(cleanupKeys(t, kb, "keyname1")) keyfile := filepath.Join(kbHome, "key.asc") - - require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0644)) + require.NoError(t, os.WriteFile(keyfile, []byte(armoredKey), 0o644)) defer func() { _ = os.RemoveAll(kbHome) diff --git a/client/keys/list.go b/client/keys/list.go index 9156c0c2ac00..73c2e91c22af 100644 --- a/client/keys/list.go +++ b/client/keys/list.go @@ -34,8 +34,7 @@ func runListCmd(cmd *cobra.Command, _ []string) error { } if ok, _ := cmd.Flags().GetBool(flagListNames); !ok { - printKeyringRecords(cmd.OutOrStdout(), records, clientCtx.OutputFormat) - return nil + return printKeyringRecords(cmd.OutOrStdout(), records, clientCtx.OutputFormat) } for _, k := range records { diff --git a/client/keys/list_test.go b/client/keys/list_test.go index e71a4fbe218c..548413efad06 100644 --- a/client/keys/list_test.go +++ b/client/keys/list_test.go @@ -5,7 +5,6 @@ import ( "fmt" "testing" - "github.com/spf13/cobra" "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client" @@ -18,6 +17,16 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +func cleanupKeys(t *testing.T, kb keyring.Keyring, keys ...string) func() { + return func() { + for _, k := range keys { + if err := kb.Delete(k); err != nil { + t.Log("can't delete KB key ", k, err) + } + } + } +} + func Test_runListCmd(t *testing.T) { cmd := ListKeysCmd() cmd.Flags().AddFlagSet(Commands("home").PersistentFlags()) @@ -33,18 +42,11 @@ func Test_runListCmd(t *testing.T) { clientCtx := client.Context{}.WithKeyring(kb) ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx) - path := "" //sdk.GetConfig().GetFullBIP44Path() + path := "" // sdk.GetConfig().GetFullBIP44Path() _, err = kb.NewAccount("something", testdata.TestMnemonic, "", path, hd.Secp256k1) require.NoError(t, err) - t.Cleanup(func() { - kb.Delete("something") // nolint:errcheck - }) - - type args struct { - cmd *cobra.Command - args []string - } + t.Cleanup(cleanupKeys(t, kb, "something")) testData := []struct { name string diff --git a/client/keys/migrate.go b/client/keys/migrate.go index ff6cde2244a3..f76206f6ed9f 100644 --- a/client/keys/migrate.go +++ b/client/keys/migrate.go @@ -34,10 +34,10 @@ func runMigrateCmd(cmd *cobra.Command, _ []string) error { return err } - if _, err = clientCtx.Keyring.MigrateAll(); err != nil { + if err = clientCtx.Keyring.MigrateAll(); err != nil { return err } - cmd.Println("Keys migration has been successfully executed") + cmd.Println("Keys migration has been successfully executed.") return nil } diff --git a/client/keys/migrate_test.go b/client/keys/migrate_test.go index 48eefb168661..b105db7cb747 100644 --- a/client/keys/migrate_test.go +++ b/client/keys/migrate_test.go @@ -43,7 +43,6 @@ func (s *MigrateTestSuite) SetupSuite() { } func (s *MigrateTestSuite) Test_runListAndShowCmd() { - // adding LegacyInfo item into keyring multi := multisig.NewLegacyAminoPubKey( 1, []cryptotypes.PubKey{ @@ -55,12 +54,12 @@ func (s *MigrateTestSuite) Test_runListAndShowCmd() { serializedLegacyMultiInfo := keyring.MarshalInfo(legacyMultiInfo) item := design99keyring.Item{ - Key: s.appName, + Key: s.appName + ".info", Data: serializedLegacyMultiInfo, - Description: "SDK kerying version", + Description: "SDK keyring version", } - //run test simd keys list - to see that the migrated key is there + // run test simd keys list - to see that the migrated key is there cmd := ListKeysCmd() cmd.Flags().AddFlagSet(Commands("home").PersistentFlags()) diff --git a/client/keys/show.go b/client/keys/show.go index d97b4a67d842..28f2abbb9f3c 100644 --- a/client/keys/show.go +++ b/client/keys/show.go @@ -128,9 +128,14 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) { if isShowPubKey { out = ko.PubKey } - fmt.Fprintln(cmd.OutOrStdout(), out) + + if _, err := fmt.Fprintln(cmd.OutOrStdout(), out); err != nil { + return err + } default: - printKeyringRecord(cmd.OutOrStdout(), k, bechKeyOut, outputFormat) + if err := printKeyringRecord(cmd.OutOrStdout(), k, bechKeyOut, outputFormat); err != nil { + return err + } } if isShowDevice { diff --git a/client/keys/show_test.go b/client/keys/show_test.go index ad86ecac525a..4045b0d3c482 100644 --- a/client/keys/show_test.go +++ b/client/keys/show_test.go @@ -72,8 +72,8 @@ func Test_runShowCmd(t *testing.T) { fakeKeyName2 := "runShowCmd_Key2" t.Cleanup(func() { - kb.Delete("runShowCmd_Key1") - kb.Delete("runShowCmd_Key2") + cleanupKeys(t, kb, "runShowCmd_Key1") + cleanupKeys(t, kb, "runShowCmd_Key2") }) path := hd.NewFundraiserParams(1, sdk.CoinType, 0).String() diff --git a/client/keys/utils.go b/client/keys/utils.go index 8af8221f0295..114e6315c9ae 100644 --- a/client/keys/utils.go +++ b/client/keys/utils.go @@ -17,53 +17,69 @@ const ( type bechKeyOutFn func(k *cryptokeyring.Record) (cryptokeyring.KeyOutput, error) -func printKeyringRecord(w io.Writer, k *cryptokeyring.Record, bechKeyOut bechKeyOutFn, output string) { +func printKeyringRecord(w io.Writer, k *cryptokeyring.Record, bechKeyOut bechKeyOutFn, output string) error { ko, err := bechKeyOut(k) if err != nil { - panic(err) + return err } switch output { case OutputFormatText: - printTextRecords(w, []cryptokeyring.KeyOutput{ko}) + if err := printTextRecords(w, []cryptokeyring.KeyOutput{ko}); err != nil { + return err + } case OutputFormatJSON: out, err := KeysCdc.MarshalJSON(ko) if err != nil { - panic(err) + return err } - fmt.Fprintln(w, string(out)) + if _, err := fmt.Fprintln(w, string(out)); err != nil { + return err + } } + + return nil } -func printKeyringRecords(w io.Writer, records []*cryptokeyring.Record, output string) { +func printKeyringRecords(w io.Writer, records []*cryptokeyring.Record, output string) error { kos, err := cryptokeyring.MkAccKeysOutput(records) if err != nil { - panic(err) + return err } switch output { case OutputFormatText: - printTextRecords(w, kos) + if err := printTextRecords(w, kos); err != nil { + return err + } case OutputFormatJSON: // TODO https://github.com/cosmos/cosmos-sdk/issues/8046 // Replace AminoCdc with Proto JSON out, err := KeysCdc.MarshalJSON(kos) if err != nil { - panic(err) + return err } - fmt.Fprintf(w, "%s", out) + if _, err := fmt.Fprintf(w, "%s", out); err != nil { + return err + } } + + return nil } -func printTextRecords(w io.Writer, kos []cryptokeyring.KeyOutput) { +func printTextRecords(w io.Writer, kos []cryptokeyring.KeyOutput) error { out, err := yaml.Marshal(&kos) if err != nil { - panic(err) + return err + } + + if _, err := fmt.Fprintln(w, string(out)); err != nil { + return err } - fmt.Fprintln(w, string(out)) + return nil } diff --git a/client/query_test.go b/client/query_test.go index 14cc25ba9d97..04532f566ba3 100644 --- a/client/query_test.go +++ b/client/query_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package client_test @@ -11,7 +12,6 @@ import ( ) func (s *IntegrationTestSuite) TestQueryABCIHeight() { - testCases := []struct { name string reqHeight int64 diff --git a/client/tx/aux_builder.go b/client/tx/aux_builder.go index 7b6086f6de0f..da8dd1fb9c08 100644 --- a/client/tx/aux_builder.go +++ b/client/tx/aux_builder.go @@ -121,14 +121,14 @@ func (b *AuxTxBuilder) SetSignMode(mode signing.SignMode) error { return nil } -// SetTip sets an optional tip. +// SetTip sets an optional tip in the AuxSignerData. func (b *AuxTxBuilder) SetTip(tip *tx.Tip) { b.checkEmptyFields() b.auxSignerData.SignDoc.Tip = tip } -// SetSignature sets the aux signer's signature. +// SetSignature sets the aux signer's signature in the AuxSignerData. func (b *AuxTxBuilder) SetSignature(sig []byte) { b.checkEmptyFields() diff --git a/client/tx/aux_builder_test.go b/client/tx/aux_builder_test.go index 385c98f4c456..ae4dd0541093 100644 --- a/client/tx/aux_builder_test.go +++ b/client/tx/aux_builder_test.go @@ -60,7 +60,7 @@ func TestAuxTxBuilder(t *testing.T) { { "GetSignBytes pubkey should not be nil", func() error { - b.SetMsgs(msg1) + require.NoError(t, b.SetMsgs(msg1)) _, err := b.GetSignBytes() return err @@ -70,8 +70,8 @@ func TestAuxTxBuilder(t *testing.T) { { "GetSignBytes invalid sign mode", func() error { - b.SetMsgs(msg1) - b.SetPubKey(pub1) + require.NoError(t, b.SetMsgs(msg1)) + require.NoError(t, b.SetPubKey(pub1)) _, err := b.GetSignBytes() return err @@ -81,13 +81,12 @@ func TestAuxTxBuilder(t *testing.T) { { "GetSignBytes tipper should not be nil (if tip is set)", func() error { - b.SetMsgs(msg1) - b.SetPubKey(pub1) + require.NoError(t, b.SetMsgs(msg1)) + require.NoError(t, b.SetPubKey(pub1)) b.SetTip(&typestx.Tip{}) - err := b.SetSignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX) - require.NoError(t, err) + require.NoError(t, b.SetSignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX)) - _, err = b.GetSignBytes() + _, err := b.GetSignBytes() return err }, true, "tipper cannot be empty", @@ -95,13 +94,12 @@ func TestAuxTxBuilder(t *testing.T) { { "GetSignBytes works for DIRECT_AUX", func() error { - b.SetMsgs(msg1) - b.SetPubKey(pub1) + require.NoError(t, b.SetMsgs(msg1)) + require.NoError(t, b.SetPubKey(pub1)) b.SetTip(tip) - err := b.SetSignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX) - require.NoError(t, err) + require.NoError(t, b.SetSignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX)) - _, err = b.GetSignBytes() + _, err := b.GetSignBytes() return err }, false, "", @@ -109,13 +107,12 @@ func TestAuxTxBuilder(t *testing.T) { { "GetAuxSignerData address should not be empty", func() error { - b.SetMsgs(msg1) - b.SetPubKey(pub1) + require.NoError(t, b.SetMsgs(msg1)) + require.NoError(t, b.SetPubKey(pub1)) b.SetTip(tip) - err := b.SetSignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX) - require.NoError(t, err) + require.NoError(t, b.SetSignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX)) - _, err = b.GetSignBytes() + _, err := b.GetSignBytes() require.NoError(t, err) _, err = b.GetAuxSignerData() @@ -126,14 +123,13 @@ func TestAuxTxBuilder(t *testing.T) { { "GetAuxSignerData signature should not be empty", func() error { - b.SetMsgs(msg1) - b.SetPubKey(pub1) + require.NoError(t, b.SetMsgs(msg1)) + require.NoError(t, b.SetPubKey(pub1)) b.SetTip(tip) b.SetAddress(addr1.String()) - err := b.SetSignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX) - require.NoError(t, err) + require.NoError(t, b.SetSignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX)) - _, err = b.GetSignBytes() + _, err := b.GetSignBytes() require.NoError(t, err) _, err = b.GetAuxSignerData() @@ -149,8 +145,8 @@ func TestAuxTxBuilder(t *testing.T) { b.SetTimeoutHeight(timeoutHeight) b.SetMemo(memo) b.SetChainID(chainID) - b.SetMsgs(msg1) - b.SetPubKey(pub1) + require.NoError(t, b.SetMsgs(msg1)) + require.NoError(t, b.SetPubKey(pub1)) b.SetTip(tip) b.SetAddress(addr1.String()) err := b.SetSignMode(signing.SignMode_SIGN_MODE_DIRECT_AUX) @@ -172,8 +168,8 @@ func TestAuxTxBuilder(t *testing.T) { { "GetSignBytes works for LEGACY_AMINO_JSON", func() error { - b.SetMsgs(msg1) - b.SetPubKey(pub1) + require.NoError(t, b.SetMsgs(msg1)) + require.NoError(t, b.SetPubKey(pub1)) b.SetTip(tip) b.SetAddress(addr1.String()) err := b.SetSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) @@ -192,8 +188,8 @@ func TestAuxTxBuilder(t *testing.T) { b.SetTimeoutHeight(timeoutHeight) b.SetMemo(memo) b.SetChainID(chainID) - b.SetMsgs(msg1) - b.SetPubKey(pub1) + require.NoError(t, b.SetMsgs(msg1)) + require.NoError(t, b.SetPubKey(pub1)) b.SetTip(tip) b.SetAddress(addr1.String()) err := b.SetSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) diff --git a/client/tx/legacy.go b/client/tx/legacy.go index 7a46e194aaa5..c07982a3fe4d 100644 --- a/client/tx/legacy.go +++ b/client/tx/legacy.go @@ -20,7 +20,6 @@ func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (legacytx.StdTx, err := CopyTx(tx, builder, true) if err != nil { - return legacytx.StdTx{}, err } diff --git a/client/tx/tx.go b/client/tx/tx.go index b90da0b84be0..4605d4991ce4 100644 --- a/client/tx/tx.go +++ b/client/tx/tx.go @@ -3,6 +3,7 @@ package tx import ( "bufio" "context" + "encoding/json" "errors" "fmt" "os" @@ -87,12 +88,14 @@ func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error { } if !clientCtx.SkipConfirm { - out, err := clientCtx.TxConfig.TxJSONEncoder()(tx.GetTx()) + txBytes, err := clientCtx.TxConfig.TxJSONEncoder()(tx.GetTx()) if err != nil { return err } - _, _ = fmt.Fprintf(os.Stderr, "%s\n\n", out) + if err := clientCtx.PrintRaw(json.RawMessage(txBytes)); err != nil { + _, _ = fmt.Fprintf(os.Stderr, "%s\n", txBytes) + } buf := bufio.NewReader(os.Stdin) ok, err := input.GetConfirmation("confirm transaction before signing and broadcasting", buf, os.Stderr) @@ -337,7 +340,7 @@ func (gr GasEstimateResponse) String() string { // makeAuxSignerData generates an AuxSignerData from the client inputs. func makeAuxSignerData(clientCtx client.Context, f Factory, msgs ...sdk.Msg) (tx.AuxSignerData, error) { b := NewAuxTxBuilder() - fromAddress, name, _, err := client.GetFromFields(clientCtx.Keyring, clientCtx.From, false) + fromAddress, name, _, err := client.GetFromFields(clientCtx, clientCtx.Keyring, clientCtx.From) if err != nil { return tx.AuxSignerData{}, err } @@ -361,14 +364,10 @@ func makeAuxSignerData(clientCtx client.Context, f Factory, msgs ...sdk.Msg) (tx } if f.tip != nil { - if f.tip.Tipper == "" { - return tx.AuxSignerData{}, sdkerrors.Wrap(errors.New("tipper flag required"), "tipper") - } else { - if _, err := sdk.AccAddressFromBech32(f.tip.Tipper); err != nil { - return tx.AuxSignerData{}, sdkerrors.ErrInvalidAddress.Wrap("tipper must be a bech32 address") - } - b.SetTip(f.tip) + if _, err := sdk.AccAddressFromBech32(f.tip.Tipper); err != nil { + return tx.AuxSignerData{}, sdkerrors.ErrInvalidAddress.Wrap("tipper must be a bech32 address") } + b.SetTip(f.tip) } err = b.SetSignMode(f.SignMode()) diff --git a/client/v2/Makefile b/client/v2/Makefile new file mode 100644 index 000000000000..6868d1941a36 --- /dev/null +++ b/client/v2/Makefile @@ -0,0 +1,2 @@ +codegen: + @(cd internal; buf generate) diff --git a/client/v2/cli/builder.go b/client/v2/cli/builder.go new file mode 100644 index 000000000000..992fc9df4e74 --- /dev/null +++ b/client/v2/cli/builder.go @@ -0,0 +1,19 @@ +package cli + +import ( + "context" + + "google.golang.org/grpc" + + "github.com/cosmos/cosmos-sdk/client/v2/cli/flag" +) + +// Builder manages options for building CLI commands. +type Builder struct { + // flag.Builder embeds the flag builder and its options. + flag.Builder + + // GetClientConn specifies how CLI commands will resolve a grpc.ClientConnInterface + // from a given context. + GetClientConn func(context.Context) grpc.ClientConnInterface +} diff --git a/client/v2/cli/flag/address.go b/client/v2/cli/flag/address.go new file mode 100644 index 000000000000..f2008e4b3251 --- /dev/null +++ b/client/v2/cli/flag/address.go @@ -0,0 +1,40 @@ +package flag + +import ( + "context" + + "github.com/spf13/pflag" + "google.golang.org/protobuf/reflect/protoreflect" +) + +type addressStringType struct{} + +func (a addressStringType) NewValue(_ context.Context, _ *Builder) pflag.Value { + return &addressValue{} +} + +func (a addressStringType) DefaultValue() string { + return "" +} + +type addressValue struct { + value string +} + +func (a addressValue) Get() protoreflect.Value { + return protoreflect.ValueOfString(a.value) +} + +func (a addressValue) String() string { + return a.value +} + +func (a *addressValue) Set(s string) error { + a.value = s + // TODO handle bech32 validation + return nil +} + +func (a addressValue) Type() string { + return "bech32 account address key name" +} diff --git a/client/v2/cli/flag/builder.go b/client/v2/cli/flag/builder.go new file mode 100644 index 000000000000..2969314e84db --- /dev/null +++ b/client/v2/cli/flag/builder.go @@ -0,0 +1,47 @@ +package flag + +import ( + "google.golang.org/protobuf/reflect/protodesc" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" +) + +// Builder manages options for building pflag flags for protobuf messages. +type Builder struct { + // TypeResolver specifies how protobuf types will be resolved. If it is + // nil protoregistry.GlobalTypes will be used. + TypeResolver interface { + protoregistry.MessageTypeResolver + protoregistry.ExtensionTypeResolver + } + + // FileResolver specifies how protobuf file descriptors will be resolved. If it is + // nil protoregistry.GlobalFiles will be used. + FileResolver protodesc.Resolver + + messageFlagTypes map[protoreflect.FullName]Type + scalarFlagTypes map[string]Type +} + +func (b *Builder) init() { + if b.messageFlagTypes == nil { + b.messageFlagTypes = map[protoreflect.FullName]Type{} + b.messageFlagTypes["google.protobuf.Timestamp"] = timestampType{} + b.messageFlagTypes["google.protobuf.Duration"] = durationType{} + } + + if b.scalarFlagTypes == nil { + b.scalarFlagTypes = map[string]Type{} + b.scalarFlagTypes["cosmos.AddressString"] = addressStringType{} + } +} + +func (b *Builder) DefineMessageFlagType(messageName protoreflect.FullName, flagType Type) { + b.init() + b.messageFlagTypes[messageName] = flagType +} + +func (b *Builder) DefineScalarFlagType(scalarName string, flagType Type) { + b.init() + b.scalarFlagTypes[scalarName] = flagType +} diff --git a/client/v2/cli/flag/duration.go b/client/v2/cli/flag/duration.go new file mode 100644 index 000000000000..d40f3ad6eab7 --- /dev/null +++ b/client/v2/cli/flag/duration.go @@ -0,0 +1,52 @@ +package flag + +import ( + "context" + "time" + + "github.com/spf13/pflag" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/known/durationpb" +) + +type durationType struct{} + +func (t durationType) NewValue(context.Context, *Builder) pflag.Value { + return &durationValue{} +} + +func (t durationType) DefaultValue() string { + return "" +} + +type durationValue struct { + value *durationpb.Duration +} + +func (t durationValue) Get() protoreflect.Value { + if t.value == nil { + return protoreflect.Value{} + } + return protoreflect.ValueOfMessage(t.value.ProtoReflect()) +} + +func (v durationValue) String() string { + if v.value == nil { + return "" + } + return v.value.AsDuration().String() +} + +func (v *durationValue) Set(s string) error { + dur, err := time.ParseDuration(s) + if err != nil { + return err + } + + v.value = durationpb.New(dur) + return nil +} + +func (v durationValue) Type() string { + return "duration" +} diff --git a/client/v2/cli/flag/enum.go b/client/v2/cli/flag/enum.go new file mode 100644 index 000000000000..65dd6fb813c6 --- /dev/null +++ b/client/v2/cli/flag/enum.go @@ -0,0 +1,74 @@ +package flag + +import ( + "context" + "fmt" + "strings" + + "github.com/iancoleman/strcase" + "github.com/spf13/pflag" + "google.golang.org/protobuf/reflect/protoreflect" +) + +type enumType struct { + enum protoreflect.EnumDescriptor +} + +func (b enumType) NewValue(context.Context, *Builder) pflag.Value { + val := &enumValue{ + enum: b.enum, + valMap: map[string]protoreflect.EnumValueDescriptor{}, + } + n := b.enum.Values().Len() + for i := 0; i < n; i++ { + valDesc := b.enum.Values().Get(i) + val.valMap[enumValueName(b.enum, valDesc)] = valDesc + } + return val +} + +func (b enumType) DefaultValue() string { + defValue := "" + if def := b.enum.Values().ByNumber(0); def != nil { + defValue = enumValueName(b.enum, def) + } + return defValue +} + +type enumValue struct { + enum protoreflect.EnumDescriptor + value protoreflect.EnumNumber + valMap map[string]protoreflect.EnumValueDescriptor +} + +func (e enumValue) Get() protoreflect.Value { + return protoreflect.ValueOfEnum(e.value) +} + +func enumValueName(enum protoreflect.EnumDescriptor, enumValue protoreflect.EnumValueDescriptor) string { + name := string(enumValue.Name()) + name = strings.TrimPrefix(name, strcase.ToScreamingSnake(string(enum.Name()))+"_") + return strcase.ToKebab(name) +} + +func (e enumValue) String() string { + return enumValueName(e.enum, e.enum.Values().ByNumber(e.value)) +} + +func (e *enumValue) Set(s string) error { + valDesc, ok := e.valMap[s] + if !ok { + return fmt.Errorf("%s is not a valid value for enum %s", s, e.enum.FullName()) + } + e.value = valDesc.Number() + return nil +} + +func (e enumValue) Type() string { + var vals []string + n := e.enum.Values().Len() + for i := 0; i < n; i++ { + vals = append(vals, enumValueName(e.enum, e.enum.Values().Get(i))) + } + return fmt.Sprintf("%s (%s)", e.enum.Name(), strings.Join(vals, " | ")) +} diff --git a/client/v2/cli/flag/field.go b/client/v2/cli/flag/field.go new file mode 100644 index 000000000000..c894e0610e48 --- /dev/null +++ b/client/v2/cli/flag/field.go @@ -0,0 +1,128 @@ +package flag + +import ( + "context" + "fmt" + + cosmos_proto "github.com/cosmos/cosmos-proto" + "github.com/spf13/pflag" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + "github.com/cosmos/cosmos-sdk/client/v2/internal/util" +) + +// FieldValueBinder wraps a flag value in a way that allows it to be bound +// to a particular field in a protobuf message. +type FieldValueBinder interface { + Bind(message protoreflect.Message, field protoreflect.FieldDescriptor) +} + +// Options specifies options for specific flags. +type Options struct { + // Prefix is a prefix to prepend to all flags. + Prefix string +} + +// AddFieldFlag adds a flag for the provided field to the flag set. +func (b *Builder) AddFieldFlag(ctx context.Context, flagSet *pflag.FlagSet, field protoreflect.FieldDescriptor, options Options) FieldValueBinder { + if field.Kind() == protoreflect.MessageKind && field.Message().FullName() == "cosmos.base.query.v1beta1.PageRequest" { + return b.bindPageRequest(ctx, flagSet, field) + } + + name := options.Prefix + util.DescriptorKebabName(field) + usage := util.DescriptorDocs(field) + shorthand := "" + + if typ := b.resolveFlagType(field); typ != nil { + val := typ.NewValue(ctx, b) + flagSet.AddFlag(&pflag.Flag{ + Name: name, + Shorthand: shorthand, + Usage: usage, + DefValue: typ.DefaultValue(), + Value: val, + }) + switch val := val.(type) { + case SimpleValue: + return simpleValueBinder{val} + case ListValue: + return listValueBinder{val} + default: + panic(fmt.Errorf("%T does not implement SimpleValue or ListValue", val)) + } + } + + if field.IsList() { + if value := bindSimpleListFlag(flagSet, field.Kind(), name, shorthand, usage); value != nil { + return listValueBinder{value} + } + return nil + } + + if value := bindSimpleFlag(flagSet, field.Kind(), name, shorthand, usage); value != nil { + return simpleValueBinder{value} + } + + return nil +} + +func (b *Builder) resolveFlagType(field protoreflect.FieldDescriptor) Type { + typ := b.resolveFlagTypeBasic(field) + if field.IsList() { + if typ != nil { + return compositeListType{simpleType: typ} + } + + return nil + } + + return typ +} + +func (b *Builder) resolveFlagTypeBasic(field protoreflect.FieldDescriptor) Type { + scalar := proto.GetExtension(field.Options(), cosmos_proto.E_Scalar) + if scalar != nil { + b.init() + if typ, ok := b.scalarFlagTypes[scalar.(string)]; ok { + return typ + } + } + + switch field.Kind() { + case protoreflect.EnumKind: + return enumType{enum: field.Enum()} + case protoreflect.MessageKind: + b.init() + if flagType, ok := b.messageFlagTypes[field.Message().FullName()]; ok { + return flagType + } + + return jsonMessageFlagType{ + messageDesc: field.Message(), + } + default: + return nil + } +} + +type simpleValueBinder struct { + SimpleValue +} + +func (s simpleValueBinder) Bind(message protoreflect.Message, field protoreflect.FieldDescriptor) { + val := s.Get() + if val.IsValid() { + message.Set(field, val) + } else { + message.Clear(field) + } +} + +type listValueBinder struct { + ListValue +} + +func (s listValueBinder) Bind(message protoreflect.Message, field protoreflect.FieldDescriptor) { + s.AppendTo(message.NewField(field).List()) +} diff --git a/client/v2/cli/flag/list.go b/client/v2/cli/flag/list.go new file mode 100644 index 000000000000..28f3b8fe7f6f --- /dev/null +++ b/client/v2/cli/flag/list.go @@ -0,0 +1,107 @@ +package flag + +import ( + "context" + "fmt" + + "github.com/spf13/pflag" + "google.golang.org/protobuf/reflect/protoreflect" +) + +func bindSimpleListFlag(flagSet *pflag.FlagSet, kind protoreflect.Kind, name, shorthand, usage string) ListValue { + switch kind { + case protoreflect.StringKind: + val := flagSet.StringSliceP(name, shorthand, nil, usage) + return listValue(func(list protoreflect.List) { + for _, x := range *val { + list.Append(protoreflect.ValueOfString(x)) + } + }) + case protoreflect.BytesKind: + // TODO + return nil + case protoreflect.Uint32Kind, protoreflect.Fixed32Kind, + protoreflect.Uint64Kind, protoreflect.Fixed64Kind: + val := flagSet.UintSliceP(name, shorthand, nil, usage) + return listValue(func(list protoreflect.List) { + for _, x := range *val { + list.Append(protoreflect.ValueOfUint64(uint64(x))) + } + }) + case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind, + protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: + val := flagSet.IntSliceP(name, shorthand, nil, usage) + return listValue(func(list protoreflect.List) { + for _, x := range *val { + list.Append(protoreflect.ValueOfInt64(int64(x))) + } + }) + case protoreflect.BoolKind: + val := flagSet.BoolSliceP(name, shorthand, nil, usage) + return listValue(func(list protoreflect.List) { + for _, x := range *val { + list.Append(protoreflect.ValueOfBool(x)) + } + }) + default: + return nil + } +} + +type listValue func(protoreflect.List) + +func (f listValue) AppendTo(list protoreflect.List) { + f(list) +} + +type compositeListType struct { + simpleType Type +} + +func (t compositeListType) NewValue(ctx context.Context, opts *Builder) pflag.Value { + return &compositeListValue{ + simpleType: t.simpleType, + values: nil, + ctx: ctx, + opts: opts, + } +} + +func (t compositeListType) DefaultValue() string { + return "" +} + +type compositeListValue struct { + simpleType Type + values []protoreflect.Value + ctx context.Context + opts *Builder +} + +func (c compositeListValue) AppendTo(list protoreflect.List) { + for _, value := range c.values { + list.Append(value) + } +} + +func (c compositeListValue) String() string { + if len(c.values) == 0 { + return "" + } + + return fmt.Sprintf("%+v", c.values) +} + +func (c *compositeListValue) Set(val string) error { + simpleVal := c.simpleType.NewValue(c.ctx, c.opts) + err := simpleVal.Set(val) + if err != nil { + return err + } + c.values = append(c.values, simpleVal.(SimpleValue).Get()) + return nil +} + +func (c compositeListValue) Type() string { + return fmt.Sprintf("%s (repeated)", c.simpleType.NewValue(c.ctx, c.opts).Type()) +} diff --git a/client/v2/cli/flag/message.go b/client/v2/cli/flag/message.go new file mode 100644 index 000000000000..4883b8933cd7 --- /dev/null +++ b/client/v2/cli/flag/message.go @@ -0,0 +1,64 @@ +package flag + +import ( + "context" + "fmt" + + "github.com/spf13/pflag" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + "github.com/cosmos/cosmos-sdk/client/v2/internal/util" +) + +type jsonMessageFlagType struct { + messageDesc protoreflect.MessageDescriptor +} + +func (j jsonMessageFlagType) NewValue(_ context.Context, builder *Builder) pflag.Value { + return &jsonMessageFlagValue{ + messageType: util.ResolveMessageType(builder.TypeResolver, j.messageDesc), + jsonMarshalOptions: protojson.MarshalOptions{Resolver: builder.TypeResolver}, + jsonUnmarshalOptions: protojson.UnmarshalOptions{Resolver: builder.TypeResolver}, + } +} + +func (j jsonMessageFlagType) DefaultValue() string { + return "" +} + +type jsonMessageFlagValue struct { + jsonMarshalOptions protojson.MarshalOptions + jsonUnmarshalOptions protojson.UnmarshalOptions + messageType protoreflect.MessageType + message proto.Message +} + +func (j jsonMessageFlagValue) Get() protoreflect.Value { + if j.message == nil { + return protoreflect.Value{} + } + return protoreflect.ValueOfMessage(j.message.ProtoReflect()) +} + +func (j jsonMessageFlagValue) String() string { + if j.message == nil { + return "" + } + + bz, err := j.jsonMarshalOptions.Marshal(j.message) + if err != nil { + return err.Error() + } + return string(bz) +} + +func (j *jsonMessageFlagValue) Set(s string) error { + j.message = j.messageType.New().Interface() + return j.jsonUnmarshalOptions.Unmarshal([]byte(s), j.message) +} + +func (j jsonMessageFlagValue) Type() string { + return fmt.Sprintf("%s (json)", j.messageType.Descriptor().FullName()) +} diff --git a/client/v2/cli/flag/pagination.go b/client/v2/cli/flag/pagination.go new file mode 100644 index 000000000000..b4e77b8941eb --- /dev/null +++ b/client/v2/cli/flag/pagination.go @@ -0,0 +1,20 @@ +package flag + +import ( + "context" + + "github.com/spf13/pflag" + "google.golang.org/protobuf/reflect/protoreflect" + + "github.com/cosmos/cosmos-sdk/client/v2/internal/util" +) + +func (b *Builder) bindPageRequest(ctx context.Context, flagSet *pflag.FlagSet, field protoreflect.FieldDescriptor) FieldValueBinder { + handler := b.AddMessageFlags( + ctx, + flagSet, + util.ResolveMessageType(b.TypeResolver, field.Message()), + Options{Prefix: "page-"}, + ) + return simpleValueBinder{handler} +} diff --git a/client/v2/cli/flag/register.go b/client/v2/cli/flag/register.go new file mode 100644 index 000000000000..c0d15c17d49a --- /dev/null +++ b/client/v2/cli/flag/register.go @@ -0,0 +1,59 @@ +package flag + +import ( + "context" + "fmt" + + "github.com/spf13/pflag" + "google.golang.org/protobuf/reflect/protoreflect" +) + +// AddMessageFlags adds flags for each field in the message to the flag set. +func (b *Builder) AddMessageFlags(ctx context.Context, set *pflag.FlagSet, messageType protoreflect.MessageType, options Options) *MessageBinder { + fields := messageType.Descriptor().Fields() + numFields := fields.Len() + handler := &MessageBinder{ + messageType: messageType, + } + for i := 0; i < numFields; i++ { + field := fields.Get(i) + binder := b.AddFieldFlag(ctx, set, field, options) + if binder == nil { + fmt.Printf("unable to bind field %s to a flag, support will be added soon\n", field) + continue + } + handler.flagFieldPairs = append(handler.flagFieldPairs, struct { + binder FieldValueBinder + field protoreflect.FieldDescriptor + }{binder: binder, field: field}) + } + return handler +} + +// MessageBinder binds multiple flags in a flag set to a protobuf message. +type MessageBinder struct { + flagFieldPairs []struct { + binder FieldValueBinder + field protoreflect.FieldDescriptor + } + messageType protoreflect.MessageType +} + +// BuildMessage builds and returns a new message for the bound flags. +func (m MessageBinder) BuildMessage() protoreflect.Message { + msg := m.messageType.New() + m.Bind(msg) + return msg +} + +// Bind binds the flag values to an existing protobuf message. +func (m MessageBinder) Bind(msg protoreflect.Message) { + for _, pair := range m.flagFieldPairs { + pair.binder.Bind(msg, pair.field) + } +} + +// Get calls BuildMessage and wraps the result in a protoreflect.Value. +func (m MessageBinder) Get() protoreflect.Value { + return protoreflect.ValueOfMessage(m.BuildMessage()) +} diff --git a/client/v2/cli/flag/simple.go b/client/v2/cli/flag/simple.go new file mode 100644 index 000000000000..6caf25c6cae0 --- /dev/null +++ b/client/v2/cli/flag/simple.go @@ -0,0 +1,54 @@ +package flag + +import ( + "github.com/spf13/pflag" + "google.golang.org/protobuf/reflect/protoreflect" +) + +func bindSimpleFlag(flagSet *pflag.FlagSet, kind protoreflect.Kind, name, shorthand, usage string) SimpleValue { + switch kind { + case protoreflect.BytesKind: + val := flagSet.BytesBase64P(name, shorthand, nil, usage) + return simpleValue(func() protoreflect.Value { + return protoreflect.ValueOfBytes(*val) + }) + case protoreflect.StringKind: + val := flagSet.StringP(name, shorthand, "", usage) + return simpleValue(func() protoreflect.Value { + return protoreflect.ValueOfString(*val) + }) + case protoreflect.Uint32Kind, protoreflect.Fixed32Kind: + val := flagSet.Uint32P(name, shorthand, 0, usage) + return simpleValue(func() protoreflect.Value { + return protoreflect.ValueOfUint32(*val) + }) + case protoreflect.Uint64Kind, protoreflect.Fixed64Kind: + val := flagSet.Uint64P(name, shorthand, 0, usage) + return simpleValue(func() protoreflect.Value { + return protoreflect.ValueOfUint64(*val) + }) + case protoreflect.Int32Kind, protoreflect.Sint32Kind, protoreflect.Sfixed32Kind: + val := flagSet.Int32P(name, shorthand, 0, usage) + return simpleValue(func() protoreflect.Value { + return protoreflect.ValueOfInt32(*val) + }) + case protoreflect.Int64Kind, protoreflect.Sint64Kind, protoreflect.Sfixed64Kind: + val := flagSet.Int64P(name, shorthand, 0, usage) + return simpleValue(func() protoreflect.Value { + return protoreflect.ValueOfInt64(*val) + }) + case protoreflect.BoolKind: + val := flagSet.BoolP(name, shorthand, false, usage) + return simpleValue(func() protoreflect.Value { + return protoreflect.ValueOfBool(*val) + }) + default: + return nil + } +} + +type simpleValue func() protoreflect.Value + +func (f simpleValue) Get() protoreflect.Value { + return f() +} diff --git a/client/v2/cli/flag/timestamp.go b/client/v2/cli/flag/timestamp.go new file mode 100644 index 000000000000..e9386bad3b9c --- /dev/null +++ b/client/v2/cli/flag/timestamp.go @@ -0,0 +1,51 @@ +package flag + +import ( + "context" + "time" + + "github.com/spf13/pflag" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/known/timestamppb" +) + +type timestampType struct{} + +func (t timestampType) NewValue(context.Context, *Builder) pflag.Value { + return ×tampValue{} +} + +func (t timestampType) DefaultValue() string { + return "" +} + +type timestampValue struct { + value *timestamppb.Timestamp +} + +func (t timestampValue) Get() protoreflect.Value { + if t.value == nil { + return protoreflect.Value{} + } + return protoreflect.ValueOfMessage(t.value.ProtoReflect()) +} + +func (v timestampValue) String() string { + if v.value == nil { + return "" + } + return v.value.AsTime().Format(time.RFC3339) +} + +func (v *timestampValue) Set(s string) error { + t, err := time.Parse(time.RFC3339, s) + if err != nil { + return err + } + v.value = timestamppb.New(t) + return nil +} + +func (v timestampValue) Type() string { + return "timestamp (RFC 3339)" +} diff --git a/client/v2/cli/flag/type.go b/client/v2/cli/flag/type.go new file mode 100644 index 000000000000..62fce2a6bcd2 --- /dev/null +++ b/client/v2/cli/flag/type.go @@ -0,0 +1,17 @@ +package flag + +import ( + "context" + + "github.com/spf13/pflag" +) + +// Type specifies a custom flag type. +type Type interface { + // NewValue returns a new pflag.Value which must also implement either + // SimpleValue or ListValue. + NewValue(context.Context, *Builder) pflag.Value + + // DefaultValue is the default value for this type. + DefaultValue() string +} diff --git a/client/v2/cli/flag/value.go b/client/v2/cli/flag/value.go new file mode 100644 index 000000000000..304139e642a2 --- /dev/null +++ b/client/v2/cli/flag/value.go @@ -0,0 +1,17 @@ +package flag + +import ( + "google.golang.org/protobuf/reflect/protoreflect" +) + +// SimpleValue wraps a simple (non-list and non-map) protobuf value. +type SimpleValue interface { + // Get returns the value. + Get() protoreflect.Value +} + +// ListValue wraps a protobuf list/repeating value. +type ListValue interface { + // AppendTo appends the values to the provided list. + AppendTo(protoreflect.List) +} diff --git a/client/v2/cli/query.go b/client/v2/cli/query.go new file mode 100644 index 000000000000..28c02a4a79b8 --- /dev/null +++ b/client/v2/cli/query.go @@ -0,0 +1,87 @@ +package cli + +import ( + "fmt" + + "github.com/iancoleman/strcase" + "github.com/spf13/cobra" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + + "github.com/cosmos/cosmos-sdk/client/v2/cli/flag" + "github.com/cosmos/cosmos-sdk/client/v2/internal/util" +) + +// AddQueryServiceCommands adds a sub-command to the provided command for each +// method in the specified service and returns the command. +func (b *Builder) AddQueryServiceCommands(command *cobra.Command, serviceName protoreflect.FullName) *cobra.Command { + resolver := b.FileResolver + if resolver == nil { + resolver = protoregistry.GlobalFiles + } + descriptor, err := resolver.FindDescriptorByName(serviceName) + if err != nil { + panic(err) + } + + service := descriptor.(protoreflect.ServiceDescriptor) + methods := service.Methods() + n := methods.Len() + for i := 0; i < n; i++ { + cmd := b.CreateQueryMethodCommand(methods.Get(i)) + command.AddCommand(cmd) + } + return command +} + +// CreateQueryMethodCommand creates a gRPC query command for the given service method. +func (b *Builder) CreateQueryMethodCommand(descriptor protoreflect.MethodDescriptor) *cobra.Command { + serviceDescriptor := descriptor.Parent().(protoreflect.ServiceDescriptor) + docs := util.DescriptorDocs(descriptor) + getClientConn := b.GetClientConn + methodName := fmt.Sprintf("/%s/%s", serviceDescriptor.FullName(), descriptor.Name()) + + inputDesc := descriptor.Input() + inputType := util.ResolveMessageType(b.TypeResolver, inputDesc) + outputType := util.ResolveMessageType(b.TypeResolver, descriptor.Output()) + cmd := &cobra.Command{ + Use: protoNameToCliName(descriptor.Name()), + Long: docs, + } + + binder := b.AddMessageFlags(cmd.Context(), cmd.Flags(), inputType, flag.Options{}) + + jsonMarshalOptions := protojson.MarshalOptions{ + Indent: " ", + UseProtoNames: true, + UseEnumNumbers: false, + EmitUnpopulated: true, + Resolver: b.TypeResolver, + } + + cmd.RunE = func(cmd *cobra.Command, args []string) error { + ctx := cmd.Context() + clientConn := getClientConn(ctx) + input := binder.BuildMessage() + output := outputType.New() + err := clientConn.Invoke(ctx, methodName, input.Interface(), output.Interface()) + if err != nil { + return err + } + + bz, err := jsonMarshalOptions.Marshal(output.Interface()) + if err != nil { + return err + } + + _, err = fmt.Fprintln(cmd.OutOrStdout(), string(bz)) + return err + } + + return cmd +} + +func protoNameToCliName(name protoreflect.Name) string { + return strcase.ToKebab(string(name)) +} diff --git a/client/v2/cli/query_test.go b/client/v2/cli/query_test.go new file mode 100644 index 000000000000..6d6c96c49f74 --- /dev/null +++ b/client/v2/cli/query_test.go @@ -0,0 +1,117 @@ +package cli + +import ( + "bytes" + "context" + "net" + "testing" + + "github.com/spf13/cobra" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/testing/protocmp" + "gotest.tools/v3/assert" + "gotest.tools/v3/golden" + + "github.com/cosmos/cosmos-sdk/client/v2/internal/testpb" +) + +func testExec(t *testing.T, args ...string) *testClientConn { + server := grpc.NewServer() + testpb.RegisterQueryServer(server, &testEchoServer{}) + listener, err := net.Listen("tcp", "127.0.0.1:0") + assert.NilError(t, err) + go server.Serve(listener) + defer server.GracefulStop() + clientConn, err := grpc.Dial(listener.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials())) + assert.NilError(t, err) + defer clientConn.Close() + + conn := &testClientConn{ + ClientConn: clientConn, + t: t, + out: &bytes.Buffer{}, + } + b := &Builder{ + GetClientConn: func(ctx context.Context) grpc.ClientConnInterface { + return conn + }, + } + cmd := b.AddQueryServiceCommands(&cobra.Command{Use: "test"}, protoreflect.FullName(testpb.Query_ServiceDesc.ServiceName)) + cmd.SetArgs(args) + cmd.SetOut(conn.out) + assert.NilError(t, cmd.Execute()) + return conn +} + +func TestEcho(t *testing.T) { + conn := testExec(t, + "echo", + "--a-bool", + "--an-enum", "one", + "--a-message", `{"bar":"abc", "baz":-3}`, + "--duration", "4h3s", + "--u-32", "27", + "--u-64", "3267246890", + "--i-32", "-253", + "--i-64", "-234602347", + "--str", "def", + "--timestamp", "2019-01-02T00:01:02Z", + "--a-coin", `{"denom":"foo","amount":"100000"}`, + "--an-address", "cosmossdghdsfoi2134sdgh", + "--bz", "c2RncXdlZndkZ3NkZw==", + "--page-count-total", + "--page-key", "MTIzNTQ4N3NnaGRhcw==", + "--page-limit", "1000", + "--page-offset", "10", + "--page-reverse", + "--bools", "true", + "--bools", "false,false,true", + "--enums", "one", + "--enums", "five", + "--enums", "two", + "--strings", "abc", + "--strings", "xyz", + "--strings", "xyz,qrs", + "--durations", "3s", + "--durations", "5s", + "--durations", "10h", + "--some-messages", "{}", + "--some-messages", `{"bar":"baz"}`, + "--some-messages", `{"baz":-1}`, + "--uints", "1,2,3", + "--uints", "4", + ) + assert.DeepEqual(t, conn.lastRequest, conn.lastResponse.(*testpb.EchoResponse).Request, protocmp.Transform()) +} + +func TestHelp(t *testing.T) { + conn := testExec(t, "echo", "-h") + golden.Assert(t, conn.out.String(), "help.golden") +} + +type testClientConn struct { + *grpc.ClientConn + t *testing.T + lastRequest interface{} + lastResponse interface{} + out *bytes.Buffer +} + +func (t *testClientConn) Invoke(ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption) error { + err := t.ClientConn.Invoke(ctx, method, args, reply, opts...) + t.lastRequest = args + t.lastResponse = reply + return err +} + +type testEchoServer struct { + testpb.UnimplementedQueryServer +} + +func (t testEchoServer) Echo(_ context.Context, request *testpb.EchoRequest) (*testpb.EchoResponse, error) { + return &testpb.EchoResponse{Request: request}, nil +} + +var _ testpb.QueryServer = testEchoServer{} diff --git a/client/v2/cli/testdata/help.golden b/client/v2/cli/testdata/help.golden new file mode 100644 index 000000000000..bcb9c087fdc9 --- /dev/null +++ b/client/v2/cli/testdata/help.golden @@ -0,0 +1,29 @@ +Usage: + test echo [flags] + +Flags: + --a-bool + --a-coin cosmos.base.v1beta1.Coin (json) + --a-message testpb.AMessage (json) + --an-address bech32 account address key name + --an-enum Enum (unspecified | one | two | five | neg-three) (default unspecified) + --bools bools (default []) + --bz bytesBase64 + --duration duration + --durations duration (repeated) + --enums Enum (unspecified | one | two | five | neg-three) (repeated) + -h, --help help for echo + --i-32 int32 + --i-64 int + --page-count-total + --page-key bytesBase64 + --page-limit uint + --page-offset uint + --page-reverse + --some-messages testpb.AMessage (json) (repeated) + --str string + --strings strings + --timestamp timestamp (RFC 3339) + --u-32 uint32 + --u-64 uint + --uints uints (default []) diff --git a/client/v2/go.mod b/client/v2/go.mod new file mode 100644 index 000000000000..ea6fe6cbdc72 --- /dev/null +++ b/client/v2/go.mod @@ -0,0 +1,26 @@ +module github.com/cosmos/cosmos-sdk/client/v2 + +go 1.18 + +require ( + github.com/cosmos/cosmos-sdk/api v0.1.0 + github.com/iancoleman/strcase v0.2.0 + github.com/spf13/cobra v1.4.0 + github.com/spf13/pflag v1.0.5 + google.golang.org/grpc v1.45.0 + google.golang.org/protobuf v1.28.0 + gotest.tools/v3 v3.1.0 +) + +require ( + github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.6 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect + golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/text v0.3.5 // indirect + google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect +) diff --git a/client/v2/go.sum b/client/v2/go.sum new file mode 100644 index 000000000000..8ff37c70268b --- /dev/null +++ b/client/v2/go.sum @@ -0,0 +1,181 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= +github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= +github.com/cosmos/cosmos-sdk/api v0.1.0 h1:xfSKM0e9p+EJTMQnf5PbWE6VT8ruxTABIJ64Rd064dE= +github.com/cosmos/cosmos-sdk/api v0.1.0/go.mod h1:CupqQBskAOiTXO1XDZ/wrtWzN/wTxUvbQmOqdUhR8wI= +github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0= +github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q= +github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +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= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw= +google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +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= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.1.0 h1:rVV8Tcg/8jHUkPUorwjaMTtemIMVXfIPKiOqnhEhakk= +gotest.tools/v3 v3.1.0/go.mod h1:fHy7eyTmJFO5bQbUsEGQ1v4m2J3Jz9eWL54TP2/ZuYQ= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= diff --git a/client/v2/internal/buf.gen.yaml b/client/v2/internal/buf.gen.yaml new file mode 100644 index 000000000000..488595470999 --- /dev/null +++ b/client/v2/internal/buf.gen.yaml @@ -0,0 +1,16 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: github.com/cosmos/cosmos-sdk/client/v2/internal + except: + - buf.build/cosmos/cosmos-proto + override: + buf.build/cosmos/cosmos-sdk: cosmossdk.io/api +plugins: + - name: go-pulsar + out: . + opt: paths=source_relative + - name: go-grpc + out: . + opt: paths=source_relative diff --git a/client/v2/internal/buf.lock b/client/v2/internal/buf.lock new file mode 100644 index 000000000000..3278c9b656d8 --- /dev/null +++ b/client/v2/internal/buf.lock @@ -0,0 +1,23 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: cosmos + repository: cosmos-proto + branch: main + commit: 1935555c206d4afb9e94615dfd0fad31 + - remote: buf.build + owner: cosmos + repository: cosmos-sdk + branch: main + commit: 86d2a697b026488089f13a71ceb3815c + - remote: buf.build + owner: cosmos + repository: gogo-proto + branch: main + commit: bee5511075b7499da6178d9e4aaa628b + - remote: buf.build + owner: googleapis + repository: googleapis + branch: main + commit: 40f07f5b563941f2b20b991a7aedd53d diff --git a/client/v2/internal/buf.yaml b/client/v2/internal/buf.yaml new file mode 100644 index 000000000000..96af160bf130 --- /dev/null +++ b/client/v2/internal/buf.yaml @@ -0,0 +1,12 @@ +version: v1 +deps: + - buf.build/cosmos/cosmos-sdk + - buf.build/cosmos/cosmos-proto +lint: + use: + - DEFAULT + except: + - PACKAGE_VERSION_SUFFIX +breaking: + ignore: + - testpb diff --git a/client/v2/internal/testpb/query.proto b/client/v2/internal/testpb/query.proto new file mode 100644 index 000000000000..062953a358f3 --- /dev/null +++ b/client/v2/internal/testpb/query.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; + +package testpb; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +service Query { + // Echo returns the request in the response + rpc Echo(EchoRequest) returns (EchoResponse); +} + +message EchoRequest { + // u32 is an uint32 + uint32 u32 = 1; + uint64 u64 = 2; + string str = 3; + bytes bz = 4; + google.protobuf.Timestamp timestamp = 5; + google.protobuf.Duration duration = 6; + int32 i32 = 7; + int64 i64 = 10; + bool a_bool = 15; + Enum an_enum = 16; + AMessage a_message = 17; + cosmos.base.v1beta1.Coin a_coin = 18; + string an_address = 19 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + cosmos.base.query.v1beta1.PageRequest page = 20; + repeated bool bools = 21; + repeated uint32 uints = 22; + repeated string strings = 23; + repeated Enum enums = 24; + repeated google.protobuf.Duration durations = 25; + repeated AMessage some_messages = 26; +} + +enum Enum { + ENUM_UNSPECIFIED = 0; + ENUM_ONE = 1; + ENUM_TWO = 2; + ENUM_FIVE = 5; + ENUM_NEG_THREE = -3; +} + +message AMessage { + string bar = 1; + int32 baz = 2; +} + +message EchoResponse { + EchoRequest request = 1; +} \ No newline at end of file diff --git a/client/v2/internal/testpb/query.pulsar.go b/client/v2/internal/testpb/query.pulsar.go new file mode 100644 index 000000000000..33b424acd2d9 --- /dev/null +++ b/client/v2/internal/testpb/query.pulsar.go @@ -0,0 +1,3631 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package testpb + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + runtime "github.com/cosmos/cosmos-proto/runtime" + v1beta11 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" + v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/v1beta1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + durationpb "google.golang.org/protobuf/types/known/durationpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + io "io" + reflect "reflect" + sync "sync" +) + +var _ protoreflect.List = (*_EchoRequest_21_list)(nil) + +type _EchoRequest_21_list struct { + list *[]bool +} + +func (x *_EchoRequest_21_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_EchoRequest_21_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfBool((*x.list)[i]) +} + +func (x *_EchoRequest_21_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Bool() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_EchoRequest_21_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Bool() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_EchoRequest_21_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message EchoRequest at list field Bools as it is not of Message kind")) +} + +func (x *_EchoRequest_21_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_EchoRequest_21_list) NewElement() protoreflect.Value { + v := false + return protoreflect.ValueOfBool(v) +} + +func (x *_EchoRequest_21_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_EchoRequest_22_list)(nil) + +type _EchoRequest_22_list struct { + list *[]uint32 +} + +func (x *_EchoRequest_22_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_EchoRequest_22_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfUint32((*x.list)[i]) +} + +func (x *_EchoRequest_22_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Uint() + concreteValue := (uint32)(valueUnwrapped) + (*x.list)[i] = concreteValue +} + +func (x *_EchoRequest_22_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Uint() + concreteValue := (uint32)(valueUnwrapped) + *x.list = append(*x.list, concreteValue) +} + +func (x *_EchoRequest_22_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message EchoRequest at list field Uints as it is not of Message kind")) +} + +func (x *_EchoRequest_22_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_EchoRequest_22_list) NewElement() protoreflect.Value { + v := uint32(0) + return protoreflect.ValueOfUint32(v) +} + +func (x *_EchoRequest_22_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_EchoRequest_23_list)(nil) + +type _EchoRequest_23_list struct { + list *[]string +} + +func (x *_EchoRequest_23_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_EchoRequest_23_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfString((*x.list)[i]) +} + +func (x *_EchoRequest_23_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + (*x.list)[i] = concreteValue +} + +func (x *_EchoRequest_23_list) Append(value protoreflect.Value) { + valueUnwrapped := value.String() + concreteValue := valueUnwrapped + *x.list = append(*x.list, concreteValue) +} + +func (x *_EchoRequest_23_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message EchoRequest at list field Strings as it is not of Message kind")) +} + +func (x *_EchoRequest_23_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_EchoRequest_23_list) NewElement() protoreflect.Value { + v := "" + return protoreflect.ValueOfString(v) +} + +func (x *_EchoRequest_23_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_EchoRequest_24_list)(nil) + +type _EchoRequest_24_list struct { + list *[]Enum +} + +func (x *_EchoRequest_24_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_EchoRequest_24_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfEnum((protoreflect.EnumNumber)((*x.list)[i])) +} + +func (x *_EchoRequest_24_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Enum() + concreteValue := (Enum)(valueUnwrapped) + (*x.list)[i] = concreteValue +} + +func (x *_EchoRequest_24_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Enum() + concreteValue := (Enum)(valueUnwrapped) + *x.list = append(*x.list, concreteValue) +} + +func (x *_EchoRequest_24_list) AppendMutable() protoreflect.Value { + panic(fmt.Errorf("AppendMutable can not be called on message EchoRequest at list field Enums as it is not of Message kind")) +} + +func (x *_EchoRequest_24_list) Truncate(n int) { + *x.list = (*x.list)[:n] +} + +func (x *_EchoRequest_24_list) NewElement() protoreflect.Value { + v := 0 + return protoreflect.ValueOfEnum((protoreflect.EnumNumber)(v)) +} + +func (x *_EchoRequest_24_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_EchoRequest_25_list)(nil) + +type _EchoRequest_25_list struct { + list *[]*durationpb.Duration +} + +func (x *_EchoRequest_25_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_EchoRequest_25_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_EchoRequest_25_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*durationpb.Duration) + (*x.list)[i] = concreteValue +} + +func (x *_EchoRequest_25_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*durationpb.Duration) + *x.list = append(*x.list, concreteValue) +} + +func (x *_EchoRequest_25_list) AppendMutable() protoreflect.Value { + v := new(durationpb.Duration) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_EchoRequest_25_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_EchoRequest_25_list) NewElement() protoreflect.Value { + v := new(durationpb.Duration) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_EchoRequest_25_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_EchoRequest_26_list)(nil) + +type _EchoRequest_26_list struct { + list *[]*AMessage +} + +func (x *_EchoRequest_26_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_EchoRequest_26_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_EchoRequest_26_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*AMessage) + (*x.list)[i] = concreteValue +} + +func (x *_EchoRequest_26_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*AMessage) + *x.list = append(*x.list, concreteValue) +} + +func (x *_EchoRequest_26_list) AppendMutable() protoreflect.Value { + v := new(AMessage) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_EchoRequest_26_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_EchoRequest_26_list) NewElement() protoreflect.Value { + v := new(AMessage) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_EchoRequest_26_list) IsValid() bool { + return x.list != nil +} + +var ( + md_EchoRequest protoreflect.MessageDescriptor + fd_EchoRequest_u32 protoreflect.FieldDescriptor + fd_EchoRequest_u64 protoreflect.FieldDescriptor + fd_EchoRequest_str protoreflect.FieldDescriptor + fd_EchoRequest_bz protoreflect.FieldDescriptor + fd_EchoRequest_timestamp protoreflect.FieldDescriptor + fd_EchoRequest_duration protoreflect.FieldDescriptor + fd_EchoRequest_i32 protoreflect.FieldDescriptor + fd_EchoRequest_i64 protoreflect.FieldDescriptor + fd_EchoRequest_a_bool protoreflect.FieldDescriptor + fd_EchoRequest_an_enum protoreflect.FieldDescriptor + fd_EchoRequest_a_message protoreflect.FieldDescriptor + fd_EchoRequest_a_coin protoreflect.FieldDescriptor + fd_EchoRequest_an_address protoreflect.FieldDescriptor + fd_EchoRequest_page protoreflect.FieldDescriptor + fd_EchoRequest_bools protoreflect.FieldDescriptor + fd_EchoRequest_uints protoreflect.FieldDescriptor + fd_EchoRequest_strings protoreflect.FieldDescriptor + fd_EchoRequest_enums protoreflect.FieldDescriptor + fd_EchoRequest_durations protoreflect.FieldDescriptor + fd_EchoRequest_some_messages protoreflect.FieldDescriptor +) + +func init() { + file_testpb_query_proto_init() + md_EchoRequest = File_testpb_query_proto.Messages().ByName("EchoRequest") + fd_EchoRequest_u32 = md_EchoRequest.Fields().ByName("u32") + fd_EchoRequest_u64 = md_EchoRequest.Fields().ByName("u64") + fd_EchoRequest_str = md_EchoRequest.Fields().ByName("str") + fd_EchoRequest_bz = md_EchoRequest.Fields().ByName("bz") + fd_EchoRequest_timestamp = md_EchoRequest.Fields().ByName("timestamp") + fd_EchoRequest_duration = md_EchoRequest.Fields().ByName("duration") + fd_EchoRequest_i32 = md_EchoRequest.Fields().ByName("i32") + fd_EchoRequest_i64 = md_EchoRequest.Fields().ByName("i64") + fd_EchoRequest_a_bool = md_EchoRequest.Fields().ByName("a_bool") + fd_EchoRequest_an_enum = md_EchoRequest.Fields().ByName("an_enum") + fd_EchoRequest_a_message = md_EchoRequest.Fields().ByName("a_message") + fd_EchoRequest_a_coin = md_EchoRequest.Fields().ByName("a_coin") + fd_EchoRequest_an_address = md_EchoRequest.Fields().ByName("an_address") + fd_EchoRequest_page = md_EchoRequest.Fields().ByName("page") + fd_EchoRequest_bools = md_EchoRequest.Fields().ByName("bools") + fd_EchoRequest_uints = md_EchoRequest.Fields().ByName("uints") + fd_EchoRequest_strings = md_EchoRequest.Fields().ByName("strings") + fd_EchoRequest_enums = md_EchoRequest.Fields().ByName("enums") + fd_EchoRequest_durations = md_EchoRequest.Fields().ByName("durations") + fd_EchoRequest_some_messages = md_EchoRequest.Fields().ByName("some_messages") +} + +var _ protoreflect.Message = (*fastReflection_EchoRequest)(nil) + +type fastReflection_EchoRequest EchoRequest + +func (x *EchoRequest) ProtoReflect() protoreflect.Message { + return (*fastReflection_EchoRequest)(x) +} + +func (x *EchoRequest) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_query_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_EchoRequest_messageType fastReflection_EchoRequest_messageType +var _ protoreflect.MessageType = fastReflection_EchoRequest_messageType{} + +type fastReflection_EchoRequest_messageType struct{} + +func (x fastReflection_EchoRequest_messageType) Zero() protoreflect.Message { + return (*fastReflection_EchoRequest)(nil) +} +func (x fastReflection_EchoRequest_messageType) New() protoreflect.Message { + return new(fastReflection_EchoRequest) +} +func (x fastReflection_EchoRequest_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_EchoRequest +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_EchoRequest) Descriptor() protoreflect.MessageDescriptor { + return md_EchoRequest +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_EchoRequest) Type() protoreflect.MessageType { + return _fastReflection_EchoRequest_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_EchoRequest) New() protoreflect.Message { + return new(fastReflection_EchoRequest) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_EchoRequest) Interface() protoreflect.ProtoMessage { + return (*EchoRequest)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_EchoRequest) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.U32 != uint32(0) { + value := protoreflect.ValueOfUint32(x.U32) + if !f(fd_EchoRequest_u32, value) { + return + } + } + if x.U64 != uint64(0) { + value := protoreflect.ValueOfUint64(x.U64) + if !f(fd_EchoRequest_u64, value) { + return + } + } + if x.Str != "" { + value := protoreflect.ValueOfString(x.Str) + if !f(fd_EchoRequest_str, value) { + return + } + } + if len(x.Bz) != 0 { + value := protoreflect.ValueOfBytes(x.Bz) + if !f(fd_EchoRequest_bz, value) { + return + } + } + if x.Timestamp != nil { + value := protoreflect.ValueOfMessage(x.Timestamp.ProtoReflect()) + if !f(fd_EchoRequest_timestamp, value) { + return + } + } + if x.Duration != nil { + value := protoreflect.ValueOfMessage(x.Duration.ProtoReflect()) + if !f(fd_EchoRequest_duration, value) { + return + } + } + if x.I32 != int32(0) { + value := protoreflect.ValueOfInt32(x.I32) + if !f(fd_EchoRequest_i32, value) { + return + } + } + if x.I64 != int64(0) { + value := protoreflect.ValueOfInt64(x.I64) + if !f(fd_EchoRequest_i64, value) { + return + } + } + if x.ABool != false { + value := protoreflect.ValueOfBool(x.ABool) + if !f(fd_EchoRequest_a_bool, value) { + return + } + } + if x.AnEnum != 0 { + value := protoreflect.ValueOfEnum((protoreflect.EnumNumber)(x.AnEnum)) + if !f(fd_EchoRequest_an_enum, value) { + return + } + } + if x.AMessage != nil { + value := protoreflect.ValueOfMessage(x.AMessage.ProtoReflect()) + if !f(fd_EchoRequest_a_message, value) { + return + } + } + if x.ACoin != nil { + value := protoreflect.ValueOfMessage(x.ACoin.ProtoReflect()) + if !f(fd_EchoRequest_a_coin, value) { + return + } + } + if x.AnAddress != "" { + value := protoreflect.ValueOfString(x.AnAddress) + if !f(fd_EchoRequest_an_address, value) { + return + } + } + if x.Page != nil { + value := protoreflect.ValueOfMessage(x.Page.ProtoReflect()) + if !f(fd_EchoRequest_page, value) { + return + } + } + if len(x.Bools) != 0 { + value := protoreflect.ValueOfList(&_EchoRequest_21_list{list: &x.Bools}) + if !f(fd_EchoRequest_bools, value) { + return + } + } + if len(x.Uints) != 0 { + value := protoreflect.ValueOfList(&_EchoRequest_22_list{list: &x.Uints}) + if !f(fd_EchoRequest_uints, value) { + return + } + } + if len(x.Strings) != 0 { + value := protoreflect.ValueOfList(&_EchoRequest_23_list{list: &x.Strings}) + if !f(fd_EchoRequest_strings, value) { + return + } + } + if len(x.Enums) != 0 { + value := protoreflect.ValueOfList(&_EchoRequest_24_list{list: &x.Enums}) + if !f(fd_EchoRequest_enums, value) { + return + } + } + if len(x.Durations) != 0 { + value := protoreflect.ValueOfList(&_EchoRequest_25_list{list: &x.Durations}) + if !f(fd_EchoRequest_durations, value) { + return + } + } + if len(x.SomeMessages) != 0 { + value := protoreflect.ValueOfList(&_EchoRequest_26_list{list: &x.SomeMessages}) + if !f(fd_EchoRequest_some_messages, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_EchoRequest) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "testpb.EchoRequest.u32": + return x.U32 != uint32(0) + case "testpb.EchoRequest.u64": + return x.U64 != uint64(0) + case "testpb.EchoRequest.str": + return x.Str != "" + case "testpb.EchoRequest.bz": + return len(x.Bz) != 0 + case "testpb.EchoRequest.timestamp": + return x.Timestamp != nil + case "testpb.EchoRequest.duration": + return x.Duration != nil + case "testpb.EchoRequest.i32": + return x.I32 != int32(0) + case "testpb.EchoRequest.i64": + return x.I64 != int64(0) + case "testpb.EchoRequest.a_bool": + return x.ABool != false + case "testpb.EchoRequest.an_enum": + return x.AnEnum != 0 + case "testpb.EchoRequest.a_message": + return x.AMessage != nil + case "testpb.EchoRequest.a_coin": + return x.ACoin != nil + case "testpb.EchoRequest.an_address": + return x.AnAddress != "" + case "testpb.EchoRequest.page": + return x.Page != nil + case "testpb.EchoRequest.bools": + return len(x.Bools) != 0 + case "testpb.EchoRequest.uints": + return len(x.Uints) != 0 + case "testpb.EchoRequest.strings": + return len(x.Strings) != 0 + case "testpb.EchoRequest.enums": + return len(x.Enums) != 0 + case "testpb.EchoRequest.durations": + return len(x.Durations) != 0 + case "testpb.EchoRequest.some_messages": + return len(x.SomeMessages) != 0 + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoRequest")) + } + panic(fmt.Errorf("message testpb.EchoRequest does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EchoRequest) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "testpb.EchoRequest.u32": + x.U32 = uint32(0) + case "testpb.EchoRequest.u64": + x.U64 = uint64(0) + case "testpb.EchoRequest.str": + x.Str = "" + case "testpb.EchoRequest.bz": + x.Bz = nil + case "testpb.EchoRequest.timestamp": + x.Timestamp = nil + case "testpb.EchoRequest.duration": + x.Duration = nil + case "testpb.EchoRequest.i32": + x.I32 = int32(0) + case "testpb.EchoRequest.i64": + x.I64 = int64(0) + case "testpb.EchoRequest.a_bool": + x.ABool = false + case "testpb.EchoRequest.an_enum": + x.AnEnum = 0 + case "testpb.EchoRequest.a_message": + x.AMessage = nil + case "testpb.EchoRequest.a_coin": + x.ACoin = nil + case "testpb.EchoRequest.an_address": + x.AnAddress = "" + case "testpb.EchoRequest.page": + x.Page = nil + case "testpb.EchoRequest.bools": + x.Bools = nil + case "testpb.EchoRequest.uints": + x.Uints = nil + case "testpb.EchoRequest.strings": + x.Strings = nil + case "testpb.EchoRequest.enums": + x.Enums = nil + case "testpb.EchoRequest.durations": + x.Durations = nil + case "testpb.EchoRequest.some_messages": + x.SomeMessages = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoRequest")) + } + panic(fmt.Errorf("message testpb.EchoRequest does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_EchoRequest) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "testpb.EchoRequest.u32": + value := x.U32 + return protoreflect.ValueOfUint32(value) + case "testpb.EchoRequest.u64": + value := x.U64 + return protoreflect.ValueOfUint64(value) + case "testpb.EchoRequest.str": + value := x.Str + return protoreflect.ValueOfString(value) + case "testpb.EchoRequest.bz": + value := x.Bz + return protoreflect.ValueOfBytes(value) + case "testpb.EchoRequest.timestamp": + value := x.Timestamp + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "testpb.EchoRequest.duration": + value := x.Duration + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "testpb.EchoRequest.i32": + value := x.I32 + return protoreflect.ValueOfInt32(value) + case "testpb.EchoRequest.i64": + value := x.I64 + return protoreflect.ValueOfInt64(value) + case "testpb.EchoRequest.a_bool": + value := x.ABool + return protoreflect.ValueOfBool(value) + case "testpb.EchoRequest.an_enum": + value := x.AnEnum + return protoreflect.ValueOfEnum((protoreflect.EnumNumber)(value)) + case "testpb.EchoRequest.a_message": + value := x.AMessage + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "testpb.EchoRequest.a_coin": + value := x.ACoin + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "testpb.EchoRequest.an_address": + value := x.AnAddress + return protoreflect.ValueOfString(value) + case "testpb.EchoRequest.page": + value := x.Page + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "testpb.EchoRequest.bools": + if len(x.Bools) == 0 { + return protoreflect.ValueOfList(&_EchoRequest_21_list{}) + } + listValue := &_EchoRequest_21_list{list: &x.Bools} + return protoreflect.ValueOfList(listValue) + case "testpb.EchoRequest.uints": + if len(x.Uints) == 0 { + return protoreflect.ValueOfList(&_EchoRequest_22_list{}) + } + listValue := &_EchoRequest_22_list{list: &x.Uints} + return protoreflect.ValueOfList(listValue) + case "testpb.EchoRequest.strings": + if len(x.Strings) == 0 { + return protoreflect.ValueOfList(&_EchoRequest_23_list{}) + } + listValue := &_EchoRequest_23_list{list: &x.Strings} + return protoreflect.ValueOfList(listValue) + case "testpb.EchoRequest.enums": + if len(x.Enums) == 0 { + return protoreflect.ValueOfList(&_EchoRequest_24_list{}) + } + listValue := &_EchoRequest_24_list{list: &x.Enums} + return protoreflect.ValueOfList(listValue) + case "testpb.EchoRequest.durations": + if len(x.Durations) == 0 { + return protoreflect.ValueOfList(&_EchoRequest_25_list{}) + } + listValue := &_EchoRequest_25_list{list: &x.Durations} + return protoreflect.ValueOfList(listValue) + case "testpb.EchoRequest.some_messages": + if len(x.SomeMessages) == 0 { + return protoreflect.ValueOfList(&_EchoRequest_26_list{}) + } + listValue := &_EchoRequest_26_list{list: &x.SomeMessages} + return protoreflect.ValueOfList(listValue) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoRequest")) + } + panic(fmt.Errorf("message testpb.EchoRequest does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EchoRequest) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "testpb.EchoRequest.u32": + x.U32 = uint32(value.Uint()) + case "testpb.EchoRequest.u64": + x.U64 = value.Uint() + case "testpb.EchoRequest.str": + x.Str = value.Interface().(string) + case "testpb.EchoRequest.bz": + x.Bz = value.Bytes() + case "testpb.EchoRequest.timestamp": + x.Timestamp = value.Message().Interface().(*timestamppb.Timestamp) + case "testpb.EchoRequest.duration": + x.Duration = value.Message().Interface().(*durationpb.Duration) + case "testpb.EchoRequest.i32": + x.I32 = int32(value.Int()) + case "testpb.EchoRequest.i64": + x.I64 = value.Int() + case "testpb.EchoRequest.a_bool": + x.ABool = value.Bool() + case "testpb.EchoRequest.an_enum": + x.AnEnum = (Enum)(value.Enum()) + case "testpb.EchoRequest.a_message": + x.AMessage = value.Message().Interface().(*AMessage) + case "testpb.EchoRequest.a_coin": + x.ACoin = value.Message().Interface().(*v1beta1.Coin) + case "testpb.EchoRequest.an_address": + x.AnAddress = value.Interface().(string) + case "testpb.EchoRequest.page": + x.Page = value.Message().Interface().(*v1beta11.PageRequest) + case "testpb.EchoRequest.bools": + lv := value.List() + clv := lv.(*_EchoRequest_21_list) + x.Bools = *clv.list + case "testpb.EchoRequest.uints": + lv := value.List() + clv := lv.(*_EchoRequest_22_list) + x.Uints = *clv.list + case "testpb.EchoRequest.strings": + lv := value.List() + clv := lv.(*_EchoRequest_23_list) + x.Strings = *clv.list + case "testpb.EchoRequest.enums": + lv := value.List() + clv := lv.(*_EchoRequest_24_list) + x.Enums = *clv.list + case "testpb.EchoRequest.durations": + lv := value.List() + clv := lv.(*_EchoRequest_25_list) + x.Durations = *clv.list + case "testpb.EchoRequest.some_messages": + lv := value.List() + clv := lv.(*_EchoRequest_26_list) + x.SomeMessages = *clv.list + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoRequest")) + } + panic(fmt.Errorf("message testpb.EchoRequest does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EchoRequest) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "testpb.EchoRequest.timestamp": + if x.Timestamp == nil { + x.Timestamp = new(timestamppb.Timestamp) + } + return protoreflect.ValueOfMessage(x.Timestamp.ProtoReflect()) + case "testpb.EchoRequest.duration": + if x.Duration == nil { + x.Duration = new(durationpb.Duration) + } + return protoreflect.ValueOfMessage(x.Duration.ProtoReflect()) + case "testpb.EchoRequest.a_message": + if x.AMessage == nil { + x.AMessage = new(AMessage) + } + return protoreflect.ValueOfMessage(x.AMessage.ProtoReflect()) + case "testpb.EchoRequest.a_coin": + if x.ACoin == nil { + x.ACoin = new(v1beta1.Coin) + } + return protoreflect.ValueOfMessage(x.ACoin.ProtoReflect()) + case "testpb.EchoRequest.page": + if x.Page == nil { + x.Page = new(v1beta11.PageRequest) + } + return protoreflect.ValueOfMessage(x.Page.ProtoReflect()) + case "testpb.EchoRequest.bools": + if x.Bools == nil { + x.Bools = []bool{} + } + value := &_EchoRequest_21_list{list: &x.Bools} + return protoreflect.ValueOfList(value) + case "testpb.EchoRequest.uints": + if x.Uints == nil { + x.Uints = []uint32{} + } + value := &_EchoRequest_22_list{list: &x.Uints} + return protoreflect.ValueOfList(value) + case "testpb.EchoRequest.strings": + if x.Strings == nil { + x.Strings = []string{} + } + value := &_EchoRequest_23_list{list: &x.Strings} + return protoreflect.ValueOfList(value) + case "testpb.EchoRequest.enums": + if x.Enums == nil { + x.Enums = []Enum{} + } + value := &_EchoRequest_24_list{list: &x.Enums} + return protoreflect.ValueOfList(value) + case "testpb.EchoRequest.durations": + if x.Durations == nil { + x.Durations = []*durationpb.Duration{} + } + value := &_EchoRequest_25_list{list: &x.Durations} + return protoreflect.ValueOfList(value) + case "testpb.EchoRequest.some_messages": + if x.SomeMessages == nil { + x.SomeMessages = []*AMessage{} + } + value := &_EchoRequest_26_list{list: &x.SomeMessages} + return protoreflect.ValueOfList(value) + case "testpb.EchoRequest.u32": + panic(fmt.Errorf("field u32 of message testpb.EchoRequest is not mutable")) + case "testpb.EchoRequest.u64": + panic(fmt.Errorf("field u64 of message testpb.EchoRequest is not mutable")) + case "testpb.EchoRequest.str": + panic(fmt.Errorf("field str of message testpb.EchoRequest is not mutable")) + case "testpb.EchoRequest.bz": + panic(fmt.Errorf("field bz of message testpb.EchoRequest is not mutable")) + case "testpb.EchoRequest.i32": + panic(fmt.Errorf("field i32 of message testpb.EchoRequest is not mutable")) + case "testpb.EchoRequest.i64": + panic(fmt.Errorf("field i64 of message testpb.EchoRequest is not mutable")) + case "testpb.EchoRequest.a_bool": + panic(fmt.Errorf("field a_bool of message testpb.EchoRequest is not mutable")) + case "testpb.EchoRequest.an_enum": + panic(fmt.Errorf("field an_enum of message testpb.EchoRequest is not mutable")) + case "testpb.EchoRequest.an_address": + panic(fmt.Errorf("field an_address of message testpb.EchoRequest is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoRequest")) + } + panic(fmt.Errorf("message testpb.EchoRequest does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_EchoRequest) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "testpb.EchoRequest.u32": + return protoreflect.ValueOfUint32(uint32(0)) + case "testpb.EchoRequest.u64": + return protoreflect.ValueOfUint64(uint64(0)) + case "testpb.EchoRequest.str": + return protoreflect.ValueOfString("") + case "testpb.EchoRequest.bz": + return protoreflect.ValueOfBytes(nil) + case "testpb.EchoRequest.timestamp": + m := new(timestamppb.Timestamp) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "testpb.EchoRequest.duration": + m := new(durationpb.Duration) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "testpb.EchoRequest.i32": + return protoreflect.ValueOfInt32(int32(0)) + case "testpb.EchoRequest.i64": + return protoreflect.ValueOfInt64(int64(0)) + case "testpb.EchoRequest.a_bool": + return protoreflect.ValueOfBool(false) + case "testpb.EchoRequest.an_enum": + return protoreflect.ValueOfEnum(0) + case "testpb.EchoRequest.a_message": + m := new(AMessage) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "testpb.EchoRequest.a_coin": + m := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "testpb.EchoRequest.an_address": + return protoreflect.ValueOfString("") + case "testpb.EchoRequest.page": + m := new(v1beta11.PageRequest) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "testpb.EchoRequest.bools": + list := []bool{} + return protoreflect.ValueOfList(&_EchoRequest_21_list{list: &list}) + case "testpb.EchoRequest.uints": + list := []uint32{} + return protoreflect.ValueOfList(&_EchoRequest_22_list{list: &list}) + case "testpb.EchoRequest.strings": + list := []string{} + return protoreflect.ValueOfList(&_EchoRequest_23_list{list: &list}) + case "testpb.EchoRequest.enums": + list := []Enum{} + return protoreflect.ValueOfList(&_EchoRequest_24_list{list: &list}) + case "testpb.EchoRequest.durations": + list := []*durationpb.Duration{} + return protoreflect.ValueOfList(&_EchoRequest_25_list{list: &list}) + case "testpb.EchoRequest.some_messages": + list := []*AMessage{} + return protoreflect.ValueOfList(&_EchoRequest_26_list{list: &list}) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoRequest")) + } + panic(fmt.Errorf("message testpb.EchoRequest does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_EchoRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.EchoRequest", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_EchoRequest) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EchoRequest) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_EchoRequest) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_EchoRequest) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*EchoRequest) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.U32 != 0 { + n += 1 + runtime.Sov(uint64(x.U32)) + } + if x.U64 != 0 { + n += 1 + runtime.Sov(uint64(x.U64)) + } + l = len(x.Str) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.Bz) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Timestamp != nil { + l = options.Size(x.Timestamp) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Duration != nil { + l = options.Size(x.Duration) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.I32 != 0 { + n += 1 + runtime.Sov(uint64(x.I32)) + } + if x.I64 != 0 { + n += 1 + runtime.Sov(uint64(x.I64)) + } + if x.ABool { + n += 2 + } + if x.AnEnum != 0 { + n += 2 + runtime.Sov(uint64(x.AnEnum)) + } + if x.AMessage != nil { + l = options.Size(x.AMessage) + n += 2 + l + runtime.Sov(uint64(l)) + } + if x.ACoin != nil { + l = options.Size(x.ACoin) + n += 2 + l + runtime.Sov(uint64(l)) + } + l = len(x.AnAddress) + if l > 0 { + n += 2 + l + runtime.Sov(uint64(l)) + } + if x.Page != nil { + l = options.Size(x.Page) + n += 2 + l + runtime.Sov(uint64(l)) + } + if len(x.Bools) > 0 { + n += 2 + runtime.Sov(uint64(len(x.Bools))) + len(x.Bools)*1 + } + if len(x.Uints) > 0 { + l = 0 + for _, e := range x.Uints { + l += runtime.Sov(uint64(e)) + } + n += 2 + runtime.Sov(uint64(l)) + l + } + if len(x.Strings) > 0 { + for _, s := range x.Strings { + l = len(s) + n += 2 + l + runtime.Sov(uint64(l)) + } + } + if len(x.Enums) > 0 { + l = 0 + for _, e := range x.Enums { + l += runtime.Sov(uint64(e)) + } + n += 2 + runtime.Sov(uint64(l)) + l + } + if len(x.Durations) > 0 { + for _, e := range x.Durations { + l = options.Size(e) + n += 2 + l + runtime.Sov(uint64(l)) + } + } + if len(x.SomeMessages) > 0 { + for _, e := range x.SomeMessages { + l = options.Size(e) + n += 2 + l + runtime.Sov(uint64(l)) + } + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*EchoRequest) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.SomeMessages) > 0 { + for iNdEx := len(x.SomeMessages) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.SomeMessages[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xd2 + } + } + if len(x.Durations) > 0 { + for iNdEx := len(x.Durations) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Durations[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xca + } + } + if len(x.Enums) > 0 { + var pksize2 int + for _, num := range x.Enums { + pksize2 += runtime.Sov(uint64(num)) + } + i -= pksize2 + j1 := i + for _, num1 := range x.Enums { + num := uint64(num1) + for num >= 1<<7 { + dAtA[j1] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j1++ + } + dAtA[j1] = uint8(num) + j1++ + } + i = runtime.EncodeVarint(dAtA, i, uint64(pksize2)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xc2 + } + if len(x.Strings) > 0 { + for iNdEx := len(x.Strings) - 1; iNdEx >= 0; iNdEx-- { + i -= len(x.Strings[iNdEx]) + copy(dAtA[i:], x.Strings[iNdEx]) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Strings[iNdEx]))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xba + } + } + if len(x.Uints) > 0 { + var pksize4 int + for _, num := range x.Uints { + pksize4 += runtime.Sov(uint64(num)) + } + i -= pksize4 + j3 := i + for _, num := range x.Uints { + for num >= 1<<7 { + dAtA[j3] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j3++ + } + dAtA[j3] = uint8(num) + j3++ + } + i = runtime.EncodeVarint(dAtA, i, uint64(pksize4)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xb2 + } + if len(x.Bools) > 0 { + for iNdEx := len(x.Bools) - 1; iNdEx >= 0; iNdEx-- { + i-- + if x.Bools[iNdEx] { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + } + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Bools))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xaa + } + if x.Page != nil { + encoded, err := options.Marshal(x.Page) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0xa2 + } + if len(x.AnAddress) > 0 { + i -= len(x.AnAddress) + copy(dAtA[i:], x.AnAddress) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AnAddress))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x9a + } + if x.ACoin != nil { + encoded, err := options.Marshal(x.ACoin) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x92 + } + if x.AMessage != nil { + encoded, err := options.Marshal(x.AMessage) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a + } + if x.AnEnum != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.AnEnum)) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x80 + } + if x.ABool { + i-- + if x.ABool { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x78 + } + if x.I64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.I64)) + i-- + dAtA[i] = 0x50 + } + if x.I32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.I32)) + i-- + dAtA[i] = 0x38 + } + if x.Duration != nil { + encoded, err := options.Marshal(x.Duration) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x32 + } + if x.Timestamp != nil { + encoded, err := options.Marshal(x.Timestamp) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x2a + } + if len(x.Bz) > 0 { + i -= len(x.Bz) + copy(dAtA[i:], x.Bz) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Bz))) + i-- + dAtA[i] = 0x22 + } + if len(x.Str) > 0 { + i -= len(x.Str) + copy(dAtA[i:], x.Str) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Str))) + i-- + dAtA[i] = 0x1a + } + if x.U64 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.U64)) + i-- + dAtA[i] = 0x10 + } + if x.U32 != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.U32)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*EchoRequest) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EchoRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EchoRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field U32", wireType) + } + x.U32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.U32 |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field U64", wireType) + } + x.U64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.U64 |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Str", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Str = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Bz", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Bz = append(x.Bz[:0], dAtA[iNdEx:postIndex]...) + if x.Bz == nil { + x.Bz = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Timestamp == nil { + x.Timestamp = ×tamppb.Timestamp{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Timestamp); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Duration == nil { + x.Duration = &durationpb.Duration{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Duration); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field I32", wireType) + } + x.I32 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.I32 |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 10: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field I64", wireType) + } + x.I64 = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.I64 |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ABool", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.ABool = bool(v != 0) + case 16: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AnEnum", wireType) + } + x.AnEnum = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.AnEnum |= Enum(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 17: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AMessage", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.AMessage == nil { + x.AMessage = &AMessage{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.AMessage); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 18: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ACoin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.ACoin == nil { + x.ACoin = &v1beta1.Coin{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.ACoin); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 19: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AnAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.AnAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 20: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Page", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Page == nil { + x.Page = &v1beta11.PageRequest{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Page); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 21: + if wireType == 0 { + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.Bools = append(x.Bools, bool(v != 0)) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + var elementCount int + elementCount = packedLen + if elementCount != 0 && len(x.Bools) == 0 { + x.Bools = make([]bool, 0, elementCount) + } + for iNdEx < postIndex { + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.Bools = append(x.Bools, bool(v != 0)) + } + } else { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Bools", wireType) + } + case 22: + if wireType == 0 { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.Uints = append(x.Uints, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(x.Uints) == 0 { + x.Uints = make([]uint32, 0, elementCount) + } + for iNdEx < postIndex { + var v uint32 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.Uints = append(x.Uints, v) + } + } else { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Uints", wireType) + } + case 23: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Strings", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Strings = append(x.Strings, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 24: + if wireType == 0 { + var v Enum + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= Enum(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.Enums = append(x.Enums, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + var elementCount int + if elementCount != 0 && len(x.Enums) == 0 { + x.Enums = make([]Enum, 0, elementCount) + } + for iNdEx < postIndex { + var v Enum + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= Enum(b&0x7F) << shift + if b < 0x80 { + break + } + } + x.Enums = append(x.Enums, v) + } + } else { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Enums", wireType) + } + case 25: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Durations", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Durations = append(x.Durations, &durationpb.Duration{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Durations[len(x.Durations)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 26: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SomeMessages", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.SomeMessages = append(x.SomeMessages, &AMessage{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.SomeMessages[len(x.SomeMessages)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_AMessage protoreflect.MessageDescriptor + fd_AMessage_bar protoreflect.FieldDescriptor + fd_AMessage_baz protoreflect.FieldDescriptor +) + +func init() { + file_testpb_query_proto_init() + md_AMessage = File_testpb_query_proto.Messages().ByName("AMessage") + fd_AMessage_bar = md_AMessage.Fields().ByName("bar") + fd_AMessage_baz = md_AMessage.Fields().ByName("baz") +} + +var _ protoreflect.Message = (*fastReflection_AMessage)(nil) + +type fastReflection_AMessage AMessage + +func (x *AMessage) ProtoReflect() protoreflect.Message { + return (*fastReflection_AMessage)(x) +} + +func (x *AMessage) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_query_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_AMessage_messageType fastReflection_AMessage_messageType +var _ protoreflect.MessageType = fastReflection_AMessage_messageType{} + +type fastReflection_AMessage_messageType struct{} + +func (x fastReflection_AMessage_messageType) Zero() protoreflect.Message { + return (*fastReflection_AMessage)(nil) +} +func (x fastReflection_AMessage_messageType) New() protoreflect.Message { + return new(fastReflection_AMessage) +} +func (x fastReflection_AMessage_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_AMessage +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_AMessage) Descriptor() protoreflect.MessageDescriptor { + return md_AMessage +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_AMessage) Type() protoreflect.MessageType { + return _fastReflection_AMessage_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_AMessage) New() protoreflect.Message { + return new(fastReflection_AMessage) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_AMessage) Interface() protoreflect.ProtoMessage { + return (*AMessage)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_AMessage) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Bar != "" { + value := protoreflect.ValueOfString(x.Bar) + if !f(fd_AMessage_bar, value) { + return + } + } + if x.Baz != int32(0) { + value := protoreflect.ValueOfInt32(x.Baz) + if !f(fd_AMessage_baz, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_AMessage) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "testpb.AMessage.bar": + return x.Bar != "" + case "testpb.AMessage.baz": + return x.Baz != int32(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.AMessage")) + } + panic(fmt.Errorf("message testpb.AMessage does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_AMessage) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "testpb.AMessage.bar": + x.Bar = "" + case "testpb.AMessage.baz": + x.Baz = int32(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.AMessage")) + } + panic(fmt.Errorf("message testpb.AMessage does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_AMessage) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "testpb.AMessage.bar": + value := x.Bar + return protoreflect.ValueOfString(value) + case "testpb.AMessage.baz": + value := x.Baz + return protoreflect.ValueOfInt32(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.AMessage")) + } + panic(fmt.Errorf("message testpb.AMessage does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_AMessage) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "testpb.AMessage.bar": + x.Bar = value.Interface().(string) + case "testpb.AMessage.baz": + x.Baz = int32(value.Int()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.AMessage")) + } + panic(fmt.Errorf("message testpb.AMessage does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_AMessage) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "testpb.AMessage.bar": + panic(fmt.Errorf("field bar of message testpb.AMessage is not mutable")) + case "testpb.AMessage.baz": + panic(fmt.Errorf("field baz of message testpb.AMessage is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.AMessage")) + } + panic(fmt.Errorf("message testpb.AMessage does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_AMessage) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "testpb.AMessage.bar": + return protoreflect.ValueOfString("") + case "testpb.AMessage.baz": + return protoreflect.ValueOfInt32(int32(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.AMessage")) + } + panic(fmt.Errorf("message testpb.AMessage does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_AMessage) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.AMessage", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_AMessage) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_AMessage) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_AMessage) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_AMessage) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*AMessage) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Bar) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.Baz != 0 { + n += 1 + runtime.Sov(uint64(x.Baz)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*AMessage) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Baz != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Baz)) + i-- + dAtA[i] = 0x10 + } + if len(x.Bar) > 0 { + i -= len(x.Bar) + copy(dAtA[i:], x.Bar) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Bar))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*AMessage) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: AMessage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: AMessage: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Bar", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Bar = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Baz", wireType) + } + x.Baz = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Baz |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_EchoResponse protoreflect.MessageDescriptor + fd_EchoResponse_request protoreflect.FieldDescriptor +) + +func init() { + file_testpb_query_proto_init() + md_EchoResponse = File_testpb_query_proto.Messages().ByName("EchoResponse") + fd_EchoResponse_request = md_EchoResponse.Fields().ByName("request") +} + +var _ protoreflect.Message = (*fastReflection_EchoResponse)(nil) + +type fastReflection_EchoResponse EchoResponse + +func (x *EchoResponse) ProtoReflect() protoreflect.Message { + return (*fastReflection_EchoResponse)(x) +} + +func (x *EchoResponse) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_query_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_EchoResponse_messageType fastReflection_EchoResponse_messageType +var _ protoreflect.MessageType = fastReflection_EchoResponse_messageType{} + +type fastReflection_EchoResponse_messageType struct{} + +func (x fastReflection_EchoResponse_messageType) Zero() protoreflect.Message { + return (*fastReflection_EchoResponse)(nil) +} +func (x fastReflection_EchoResponse_messageType) New() protoreflect.Message { + return new(fastReflection_EchoResponse) +} +func (x fastReflection_EchoResponse_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_EchoResponse +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_EchoResponse) Descriptor() protoreflect.MessageDescriptor { + return md_EchoResponse +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_EchoResponse) Type() protoreflect.MessageType { + return _fastReflection_EchoResponse_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_EchoResponse) New() protoreflect.Message { + return new(fastReflection_EchoResponse) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_EchoResponse) Interface() protoreflect.ProtoMessage { + return (*EchoResponse)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_EchoResponse) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Request != nil { + value := protoreflect.ValueOfMessage(x.Request.ProtoReflect()) + if !f(fd_EchoResponse_request, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_EchoResponse) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "testpb.EchoResponse.request": + return x.Request != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoResponse")) + } + panic(fmt.Errorf("message testpb.EchoResponse does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EchoResponse) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "testpb.EchoResponse.request": + x.Request = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoResponse")) + } + panic(fmt.Errorf("message testpb.EchoResponse does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_EchoResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "testpb.EchoResponse.request": + value := x.Request + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoResponse")) + } + panic(fmt.Errorf("message testpb.EchoResponse does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EchoResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "testpb.EchoResponse.request": + x.Request = value.Message().Interface().(*EchoRequest) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoResponse")) + } + panic(fmt.Errorf("message testpb.EchoResponse does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EchoResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "testpb.EchoResponse.request": + if x.Request == nil { + x.Request = new(EchoRequest) + } + return protoreflect.ValueOfMessage(x.Request.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoResponse")) + } + panic(fmt.Errorf("message testpb.EchoResponse does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_EchoResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "testpb.EchoResponse.request": + m := new(EchoRequest) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.EchoResponse")) + } + panic(fmt.Errorf("message testpb.EchoResponse does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_EchoResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.EchoResponse", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_EchoResponse) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_EchoResponse) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_EchoResponse) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_EchoResponse) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*EchoResponse) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Request != nil { + l = options.Size(x.Request) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*EchoResponse) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Request != nil { + encoded, err := options.Marshal(x.Request) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*EchoResponse) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EchoResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: EchoResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Request", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.Request == nil { + x.Request = &EchoRequest{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Request); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: testpb/query.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Enum int32 + +const ( + Enum_ENUM_UNSPECIFIED Enum = 0 + Enum_ENUM_ONE Enum = 1 + Enum_ENUM_TWO Enum = 2 + Enum_ENUM_FIVE Enum = 5 + Enum_ENUM_NEG_THREE Enum = -3 +) + +// Enum value maps for Enum. +var ( + Enum_name = map[int32]string{ + 0: "ENUM_UNSPECIFIED", + 1: "ENUM_ONE", + 2: "ENUM_TWO", + 5: "ENUM_FIVE", + -3: "ENUM_NEG_THREE", + } + Enum_value = map[string]int32{ + "ENUM_UNSPECIFIED": 0, + "ENUM_ONE": 1, + "ENUM_TWO": 2, + "ENUM_FIVE": 5, + "ENUM_NEG_THREE": -3, + } +) + +func (x Enum) Enum() *Enum { + p := new(Enum) + *p = x + return p +} + +func (x Enum) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Enum) Descriptor() protoreflect.EnumDescriptor { + return file_testpb_query_proto_enumTypes[0].Descriptor() +} + +func (Enum) Type() protoreflect.EnumType { + return &file_testpb_query_proto_enumTypes[0] +} + +func (x Enum) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Enum.Descriptor instead. +func (Enum) EnumDescriptor() ([]byte, []int) { + return file_testpb_query_proto_rawDescGZIP(), []int{0} +} + +type EchoRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // u32 is an uint32 + U32 uint32 `protobuf:"varint,1,opt,name=u32,proto3" json:"u32,omitempty"` + U64 uint64 `protobuf:"varint,2,opt,name=u64,proto3" json:"u64,omitempty"` + Str string `protobuf:"bytes,3,opt,name=str,proto3" json:"str,omitempty"` + Bz []byte `protobuf:"bytes,4,opt,name=bz,proto3" json:"bz,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Duration *durationpb.Duration `protobuf:"bytes,6,opt,name=duration,proto3" json:"duration,omitempty"` + I32 int32 `protobuf:"varint,7,opt,name=i32,proto3" json:"i32,omitempty"` + I64 int64 `protobuf:"varint,10,opt,name=i64,proto3" json:"i64,omitempty"` + ABool bool `protobuf:"varint,15,opt,name=a_bool,json=aBool,proto3" json:"a_bool,omitempty"` + AnEnum Enum `protobuf:"varint,16,opt,name=an_enum,json=anEnum,proto3,enum=testpb.Enum" json:"an_enum,omitempty"` + AMessage *AMessage `protobuf:"bytes,17,opt,name=a_message,json=aMessage,proto3" json:"a_message,omitempty"` + ACoin *v1beta1.Coin `protobuf:"bytes,18,opt,name=a_coin,json=aCoin,proto3" json:"a_coin,omitempty"` + AnAddress string `protobuf:"bytes,19,opt,name=an_address,json=anAddress,proto3" json:"an_address,omitempty"` + Page *v1beta11.PageRequest `protobuf:"bytes,20,opt,name=page,proto3" json:"page,omitempty"` + Bools []bool `protobuf:"varint,21,rep,packed,name=bools,proto3" json:"bools,omitempty"` + Uints []uint32 `protobuf:"varint,22,rep,packed,name=uints,proto3" json:"uints,omitempty"` + Strings []string `protobuf:"bytes,23,rep,name=strings,proto3" json:"strings,omitempty"` + Enums []Enum `protobuf:"varint,24,rep,packed,name=enums,proto3,enum=testpb.Enum" json:"enums,omitempty"` + Durations []*durationpb.Duration `protobuf:"bytes,25,rep,name=durations,proto3" json:"durations,omitempty"` + SomeMessages []*AMessage `protobuf:"bytes,26,rep,name=some_messages,json=someMessages,proto3" json:"some_messages,omitempty"` +} + +func (x *EchoRequest) Reset() { + *x = EchoRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_query_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EchoRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EchoRequest) ProtoMessage() {} + +// Deprecated: Use EchoRequest.ProtoReflect.Descriptor instead. +func (*EchoRequest) Descriptor() ([]byte, []int) { + return file_testpb_query_proto_rawDescGZIP(), []int{0} +} + +func (x *EchoRequest) GetU32() uint32 { + if x != nil { + return x.U32 + } + return 0 +} + +func (x *EchoRequest) GetU64() uint64 { + if x != nil { + return x.U64 + } + return 0 +} + +func (x *EchoRequest) GetStr() string { + if x != nil { + return x.Str + } + return "" +} + +func (x *EchoRequest) GetBz() []byte { + if x != nil { + return x.Bz + } + return nil +} + +func (x *EchoRequest) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *EchoRequest) GetDuration() *durationpb.Duration { + if x != nil { + return x.Duration + } + return nil +} + +func (x *EchoRequest) GetI32() int32 { + if x != nil { + return x.I32 + } + return 0 +} + +func (x *EchoRequest) GetI64() int64 { + if x != nil { + return x.I64 + } + return 0 +} + +func (x *EchoRequest) GetABool() bool { + if x != nil { + return x.ABool + } + return false +} + +func (x *EchoRequest) GetAnEnum() Enum { + if x != nil { + return x.AnEnum + } + return Enum_ENUM_UNSPECIFIED +} + +func (x *EchoRequest) GetAMessage() *AMessage { + if x != nil { + return x.AMessage + } + return nil +} + +func (x *EchoRequest) GetACoin() *v1beta1.Coin { + if x != nil { + return x.ACoin + } + return nil +} + +func (x *EchoRequest) GetAnAddress() string { + if x != nil { + return x.AnAddress + } + return "" +} + +func (x *EchoRequest) GetPage() *v1beta11.PageRequest { + if x != nil { + return x.Page + } + return nil +} + +func (x *EchoRequest) GetBools() []bool { + if x != nil { + return x.Bools + } + return nil +} + +func (x *EchoRequest) GetUints() []uint32 { + if x != nil { + return x.Uints + } + return nil +} + +func (x *EchoRequest) GetStrings() []string { + if x != nil { + return x.Strings + } + return nil +} + +func (x *EchoRequest) GetEnums() []Enum { + if x != nil { + return x.Enums + } + return nil +} + +func (x *EchoRequest) GetDurations() []*durationpb.Duration { + if x != nil { + return x.Durations + } + return nil +} + +func (x *EchoRequest) GetSomeMessages() []*AMessage { + if x != nil { + return x.SomeMessages + } + return nil +} + +type AMessage struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Bar string `protobuf:"bytes,1,opt,name=bar,proto3" json:"bar,omitempty"` + Baz int32 `protobuf:"varint,2,opt,name=baz,proto3" json:"baz,omitempty"` +} + +func (x *AMessage) Reset() { + *x = AMessage{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_query_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AMessage) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AMessage) ProtoMessage() {} + +// Deprecated: Use AMessage.ProtoReflect.Descriptor instead. +func (*AMessage) Descriptor() ([]byte, []int) { + return file_testpb_query_proto_rawDescGZIP(), []int{1} +} + +func (x *AMessage) GetBar() string { + if x != nil { + return x.Bar + } + return "" +} + +func (x *AMessage) GetBaz() int32 { + if x != nil { + return x.Baz + } + return 0 +} + +type EchoResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Request *EchoRequest `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` +} + +func (x *EchoResponse) Reset() { + *x = EchoResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_query_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *EchoResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*EchoResponse) ProtoMessage() {} + +// Deprecated: Use EchoResponse.ProtoReflect.Descriptor instead. +func (*EchoResponse) Descriptor() ([]byte, []int) { + return file_testpb_query_proto_rawDescGZIP(), []int{2} +} + +func (x *EchoResponse) GetRequest() *EchoRequest { + if x != nil { + return x.Request + } + return nil +} + +var File_testpb_query_proto protoreflect.FileDescriptor + +var file_testpb_query_proto_rawDesc = []byte{ + 0x0a, 0x12, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x1a, 0x1f, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, + 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2f, 0x76, 0x31, 0x62, 0x65, + 0x74, 0x61, 0x31, 0x2f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, + 0x65, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xd6, 0x05, 0x0a, 0x0b, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x33, 0x32, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x03, 0x75, 0x33, 0x32, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x36, 0x34, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x03, 0x75, 0x36, 0x34, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x74, 0x72, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x74, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x62, 0x7a, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x02, 0x62, 0x7a, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, + 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, + 0x74, 0x61, 0x6d, 0x70, 0x12, 0x35, 0x0a, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x52, 0x08, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x69, + 0x33, 0x32, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x69, 0x33, 0x32, 0x12, 0x10, 0x0a, + 0x03, 0x69, 0x36, 0x34, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x69, 0x36, 0x34, 0x12, + 0x15, 0x0a, 0x06, 0x61, 0x5f, 0x62, 0x6f, 0x6f, 0x6c, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x05, 0x61, 0x42, 0x6f, 0x6f, 0x6c, 0x12, 0x25, 0x0a, 0x07, 0x61, 0x6e, 0x5f, 0x65, 0x6e, 0x75, + 0x6d, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, + 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x06, 0x61, 0x6e, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x2d, 0x0a, + 0x09, 0x61, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x11, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x10, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x41, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x52, 0x08, 0x61, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x30, 0x0a, 0x06, + 0x61, 0x5f, 0x63, 0x6f, 0x69, 0x6e, 0x18, 0x12, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x52, 0x05, 0x61, 0x43, 0x6f, 0x69, 0x6e, 0x12, 0x37, + 0x0a, 0x0a, 0x61, 0x6e, 0x5f, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x13, 0x20, 0x01, + 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, + 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, 0x6e, + 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x3a, 0x0a, 0x04, 0x70, 0x61, 0x67, 0x65, 0x18, + 0x14, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x26, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, + 0x61, 0x73, 0x65, 0x2e, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x70, + 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x62, 0x6f, 0x6f, 0x6c, 0x73, 0x18, 0x15, 0x20, 0x03, + 0x28, 0x08, 0x52, 0x05, 0x62, 0x6f, 0x6f, 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x75, 0x69, 0x6e, + 0x74, 0x73, 0x18, 0x16, 0x20, 0x03, 0x28, 0x0d, 0x52, 0x05, 0x75, 0x69, 0x6e, 0x74, 0x73, 0x12, + 0x18, 0x0a, 0x07, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x17, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x07, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x22, 0x0a, 0x05, 0x65, 0x6e, 0x75, + 0x6d, 0x73, 0x18, 0x18, 0x20, 0x03, 0x28, 0x0e, 0x32, 0x0c, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, + 0x62, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x52, 0x05, 0x65, 0x6e, 0x75, 0x6d, 0x73, 0x12, 0x37, 0x0a, + 0x09, 0x64, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x19, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x19, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x44, 0x75, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x09, 0x64, 0x75, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x35, 0x0a, 0x0d, 0x73, 0x6f, 0x6d, 0x65, 0x5f, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18, 0x1a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, + 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x41, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, + 0x0c, 0x73, 0x6f, 0x6d, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x22, 0x2e, 0x0a, + 0x08, 0x41, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x61, 0x72, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x62, 0x61, 0x72, 0x12, 0x10, 0x0a, 0x03, 0x62, + 0x61, 0x7a, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x62, 0x61, 0x7a, 0x22, 0x3d, 0x0a, + 0x0c, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2d, 0x0a, + 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, + 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2a, 0x64, 0x0a, 0x04, + 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x55, 0x4e, 0x53, + 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, + 0x55, 0x4d, 0x5f, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, 0x55, 0x4d, + 0x5f, 0x54, 0x57, 0x4f, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x46, + 0x49, 0x56, 0x45, 0x10, 0x05, 0x12, 0x1b, 0x0a, 0x0e, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x4e, 0x45, + 0x47, 0x5f, 0x54, 0x48, 0x52, 0x45, 0x45, 0x10, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0x01, 0x32, 0x3a, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x31, 0x0a, 0x04, 0x45, + 0x63, 0x68, 0x6f, 0x12, 0x13, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2e, 0x45, 0x63, 0x68, + 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, + 0x62, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x88, + 0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x42, 0x0a, 0x51, + 0x75, 0x65, 0x72, 0x79, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x2f, 0x76, 0x32, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, + 0x74, 0x70, 0x62, 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, + 0x70, 0x62, 0xca, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xe2, 0x02, 0x12, 0x54, 0x65, + 0x73, 0x74, 0x70, 0x62, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0xea, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_testpb_query_proto_rawDescOnce sync.Once + file_testpb_query_proto_rawDescData = file_testpb_query_proto_rawDesc +) + +func file_testpb_query_proto_rawDescGZIP() []byte { + file_testpb_query_proto_rawDescOnce.Do(func() { + file_testpb_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_testpb_query_proto_rawDescData) + }) + return file_testpb_query_proto_rawDescData +} + +var file_testpb_query_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_testpb_query_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_testpb_query_proto_goTypes = []interface{}{ + (Enum)(0), // 0: testpb.Enum + (*EchoRequest)(nil), // 1: testpb.EchoRequest + (*AMessage)(nil), // 2: testpb.AMessage + (*EchoResponse)(nil), // 3: testpb.EchoResponse + (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp + (*durationpb.Duration)(nil), // 5: google.protobuf.Duration + (*v1beta1.Coin)(nil), // 6: cosmos.base.v1beta1.Coin + (*v1beta11.PageRequest)(nil), // 7: cosmos.base.query.v1beta1.PageRequest +} +var file_testpb_query_proto_depIdxs = []int32{ + 4, // 0: testpb.EchoRequest.timestamp:type_name -> google.protobuf.Timestamp + 5, // 1: testpb.EchoRequest.duration:type_name -> google.protobuf.Duration + 0, // 2: testpb.EchoRequest.an_enum:type_name -> testpb.Enum + 2, // 3: testpb.EchoRequest.a_message:type_name -> testpb.AMessage + 6, // 4: testpb.EchoRequest.a_coin:type_name -> cosmos.base.v1beta1.Coin + 7, // 5: testpb.EchoRequest.page:type_name -> cosmos.base.query.v1beta1.PageRequest + 0, // 6: testpb.EchoRequest.enums:type_name -> testpb.Enum + 5, // 7: testpb.EchoRequest.durations:type_name -> google.protobuf.Duration + 2, // 8: testpb.EchoRequest.some_messages:type_name -> testpb.AMessage + 1, // 9: testpb.EchoResponse.request:type_name -> testpb.EchoRequest + 1, // 10: testpb.Query.Echo:input_type -> testpb.EchoRequest + 3, // 11: testpb.Query.Echo:output_type -> testpb.EchoResponse + 11, // [11:12] is the sub-list for method output_type + 10, // [10:11] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name +} + +func init() { file_testpb_query_proto_init() } +func file_testpb_query_proto_init() { + if File_testpb_query_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_testpb_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EchoRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testpb_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AMessage); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testpb_query_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*EchoResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_testpb_query_proto_rawDesc, + NumEnums: 1, + NumMessages: 3, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_testpb_query_proto_goTypes, + DependencyIndexes: file_testpb_query_proto_depIdxs, + EnumInfos: file_testpb_query_proto_enumTypes, + MessageInfos: file_testpb_query_proto_msgTypes, + }.Build() + File_testpb_query_proto = out.File + file_testpb_query_proto_rawDesc = nil + file_testpb_query_proto_goTypes = nil + file_testpb_query_proto_depIdxs = nil +} diff --git a/client/v2/internal/testpb/query_grpc.pb.go b/client/v2/internal/testpb/query_grpc.pb.go new file mode 100644 index 000000000000..56d177ddc86f --- /dev/null +++ b/client/v2/internal/testpb/query_grpc.pb.go @@ -0,0 +1,107 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc (unknown) +// source: testpb/query.proto + +package testpb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type QueryClient interface { + // Echo returns the request in the response + Echo(ctx context.Context, in *EchoRequest, opts ...grpc.CallOption) (*EchoResponse, error) +} + +type queryClient struct { + cc grpc.ClientConnInterface +} + +func NewQueryClient(cc grpc.ClientConnInterface) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Echo(ctx context.Context, in *EchoRequest, opts ...grpc.CallOption) (*EchoResponse, error) { + out := new(EchoResponse) + err := c.cc.Invoke(ctx, "/testpb.Query/Echo", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +// All implementations must embed UnimplementedQueryServer +// for forward compatibility +type QueryServer interface { + // Echo returns the request in the response + Echo(context.Context, *EchoRequest) (*EchoResponse, error) + mustEmbedUnimplementedQueryServer() +} + +// UnimplementedQueryServer must be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (UnimplementedQueryServer) Echo(context.Context, *EchoRequest) (*EchoResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Echo not implemented") +} +func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {} + +// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to QueryServer will +// result in compilation errors. +type UnsafeQueryServer interface { + mustEmbedUnimplementedQueryServer() +} + +func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) { + s.RegisterService(&Query_ServiceDesc, srv) +} + +func _Query_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(EchoRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Echo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/testpb.Query/Echo", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Echo(ctx, req.(*EchoRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Query_ServiceDesc is the grpc.ServiceDesc for Query service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Query_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "testpb.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Echo", + Handler: _Query_Echo_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "testpb/query.proto", +} diff --git a/client/v2/internal/util/util.go b/client/v2/internal/util/util.go new file mode 100644 index 000000000000..18b8d53006a4 --- /dev/null +++ b/client/v2/internal/util/util.go @@ -0,0 +1,29 @@ +package util + +import ( + "github.com/iancoleman/strcase" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/dynamicpb" +) + +func DescriptorKebabName(descriptor protoreflect.Descriptor) string { + return strcase.ToKebab(string(descriptor.Name())) +} + +func DescriptorDocs(descriptor protoreflect.Descriptor) string { + return descriptor.ParentFile().SourceLocations().ByDescriptor(descriptor).LeadingComments +} + +func ResolveMessageType(resolver protoregistry.MessageTypeResolver, descriptor protoreflect.MessageDescriptor) protoreflect.MessageType { + if resolver == nil { + resolver = protoregistry.GlobalTypes + } + + typ, err := resolver.FindMessageByName(descriptor.FullName()) + if err == nil { + return typ + } + + return dynamicpb.NewMessageType(descriptor) +} diff --git a/codec/amino.go b/codec/amino.go index fe22fd14fbd4..506e598dab3c 100644 --- a/codec/amino.go +++ b/codec/amino.go @@ -47,7 +47,6 @@ func MarshalJSONIndent(cdc *LegacyAmino, obj interface{}) ([]byte, error) { if err = json.Indent(&out, bz, "", " "); err != nil { return nil, err } - return out.Bytes(), nil } diff --git a/codec/amino_codec_test.go b/codec/amino_codec_test.go index c2f09710ae2b..460ef8ca4184 100644 --- a/codec/amino_codec_test.go +++ b/codec/amino_codec_test.go @@ -121,7 +121,7 @@ func TestAminoCodecUnpackAnyFails(t *testing.T) { func TestAminoCodecFullDecodeAndEncode(t *testing.T) { // This tx comes from https://github.com/cosmos/cosmos-sdk/issues/8117. txSigned := `{"type":"cosmos-sdk/StdTx","value":{"msg":[{"type":"cosmos-sdk/MsgCreateValidator","value":{"description":{"moniker":"fulltest","identity":"satoshi","website":"example.com","details":"example inc"},"commission":{"rate":"0.500000000000000000","max_rate":"1.000000000000000000","max_change_rate":"0.200000000000000000"},"min_self_delegation":"1000000","delegator_address":"cosmos14pt0q5cwf38zt08uu0n6yrstf3rndzr5057jys","validator_address":"cosmosvaloper14pt0q5cwf38zt08uu0n6yrstf3rndzr52q28gr","pubkey":{"type":"tendermint/PubKeyEd25519","value":"CYrOiM3HtS7uv1B1OAkknZnFYSRpQYSYII8AtMMtev0="},"value":{"denom":"umuon","amount":"700000000"}}}],"fee":{"amount":[{"denom":"umuon","amount":"6000"}],"gas":"160000"},"signatures":[{"pub_key":{"type":"tendermint/PubKeySecp256k1","value":"AwAOXeWgNf1FjMaayrSnrOOKz+Fivr6DiI/i0x0sZCHw"},"signature":"RcnfS/u2yl7uIShTrSUlDWvsXo2p2dYu6WJC8VDVHMBLEQZWc8bsINSCjOnlsIVkUNNe1q/WCA9n3Gy1+0zhYA=="}],"memo":"","timeout_height":"0"}}` - var legacyCdc = simapp.MakeTestEncodingConfig().Amino + legacyCdc := simapp.MakeTestEncodingConfig().Amino var tx legacytx.StdTx err := legacyCdc.UnmarshalJSON([]byte(txSigned), &tx) require.NoError(t, err) diff --git a/codec/any_test.go b/codec/any_test.go index 92bb9d0d5004..8b4b96a7fb5b 100644 --- a/codec/any_test.go +++ b/codec/any_test.go @@ -79,7 +79,7 @@ func TestMarshalProtoPubKey(t *testing.T) { var pkI cryptotypes.PubKey err = ccfg.InterfaceRegistry.UnpackAny(&pkAny2, &pkI) require.NoError(err) - var pk2 = pkAny2.GetCachedValue().(cryptotypes.PubKey) + pk2 := pkAny2.GetCachedValue().(cryptotypes.PubKey) require.True(pk2.Equals(pk)) // **** test binary serialization **** @@ -92,7 +92,7 @@ func TestMarshalProtoPubKey(t *testing.T) { require.NoError(err) err = ccfg.InterfaceRegistry.UnpackAny(&pkAny3, &pkI) require.NoError(err) - var pk3 = pkAny3.GetCachedValue().(cryptotypes.PubKey) + pk3 := pkAny3.GetCachedValue().(cryptotypes.PubKey) require.True(pk3.Equals(pk)) } diff --git a/codec/codec_common_test.go b/codec/codec_common_test.go index 59af923d7920..d9a8c756ec3f 100644 --- a/codec/codec_common_test.go +++ b/codec/codec_common_test.go @@ -28,7 +28,7 @@ func testInterfaceMarshaling(require *require.Assertions, cdc interfaceMarshaler var animal testdata.Animal if isAminoBin { require.PanicsWithValue("Unmarshal expects a pointer", func() { - cdc.unmarshal(bz, animal) + _ = cdc.unmarshal(bz, animal) }) } else { err = cdc.unmarshal(bz, animal) @@ -104,7 +104,8 @@ func testMarshaling(t *testing.T, cdc codec.Codec) { &testdata.Cat{}, false, true, - }} + }, + } if _, ok := cdc.(*codec.AminoCodec); ok { testCases = append(testCases, testCase{ "any marshaling", @@ -123,7 +124,8 @@ func testMarshaling(t *testing.T, cdc codec.Codec) { func(i codec.ProtoMarshaler) ([]byte, error) { return cdc.MarshalJSON(i) }, func(i codec.ProtoMarshaler) []byte { return cdc.MustMarshalJSON(i) }, func(bz []byte, ptr codec.ProtoMarshaler) error { return cdc.UnmarshalJSON(bz, ptr) }, - func(bz []byte, ptr codec.ProtoMarshaler) { cdc.MustUnmarshalJSON(bz, ptr) }} + func(bz []byte, ptr codec.ProtoMarshaler) { cdc.MustUnmarshalJSON(bz, ptr) }, + } t.Run(tc.name+"_BinaryBare", func(t *testing.T) { testMarshalingTestCase(require.New(t), tc, m1) }) diff --git a/codec/proto_codec.go b/codec/proto_codec.go index faccd9528181..05bdf1b05210 100644 --- a/codec/proto_codec.go +++ b/codec/proto_codec.go @@ -29,8 +29,10 @@ type ProtoCodec struct { interfaceRegistry types.InterfaceRegistry } -var _ Codec = &ProtoCodec{} -var _ ProtoCodecMarshaler = &ProtoCodec{} +var ( + _ Codec = &ProtoCodec{} + _ ProtoCodecMarshaler = &ProtoCodec{} +) // NewProtoCodec returns a reference to a new ProtoCodec func NewProtoCodec(interfaceRegistry types.InterfaceRegistry) *ProtoCodec { diff --git a/codec/proto_codec_test.go b/codec/proto_codec_test.go index 40d810deefc1..6e83501cf501 100644 --- a/codec/proto_codec_test.go +++ b/codec/proto_codec_test.go @@ -99,8 +99,8 @@ func mustAny(msg proto.Message) *types.Any { } func BenchmarkProtoCodecMarshalLengthPrefixed(b *testing.B) { - var pCdc = codec.NewProtoCodec(types.NewInterfaceRegistry()) - var msg = &testdata.HasAnimal{ + pCdc := codec.NewProtoCodec(types.NewInterfaceRegistry()) + msg := &testdata.HasAnimal{ X: 1000, Animal: mustAny(&testdata.HasAnimal{ X: 2000, diff --git a/codec/types/any_internal_test.go b/codec/types/any_internal_test.go index b3e847965d59..f03e8247f67a 100644 --- a/codec/types/any_internal_test.go +++ b/codec/types/any_internal_test.go @@ -23,8 +23,10 @@ type Animal interface { Greet() string } -var _ Animal = (*Dog)(nil) -var _ proto.Message = (*Dog)(nil) +var ( + _ Animal = (*Dog)(nil) + _ proto.Message = (*Dog)(nil) +) func TestAnyPackUnpack(t *testing.T) { registry := NewInterfaceRegistry() diff --git a/codec/types/any_test.go b/codec/types/any_test.go index b9ddbe72ec39..59eaef9c160a 100644 --- a/codec/types/any_test.go +++ b/codec/types/any_test.go @@ -28,6 +28,15 @@ var eom = &errOnMarshal{} // Ensure that returning an error doesn't suddenly allocate and waste bytes. // See https://github.com/cosmos/cosmos-sdk/issues/8537 func TestNewAnyWithCustomTypeURLWithErrorNoAllocation(t *testing.T) { + // This tests continues to fail inconsistently. + // + // Example: https://github.com/cosmos/cosmos-sdk/pull/9246/checks?check_run_id=2643313958#step:6:118 + // Ref: https://github.com/cosmos/cosmos-sdk/issues/9010 + t.SkipNow() + + // make sure we're not in the middle of a GC. + runtime.GC() + var ms1, ms2 runtime.MemStats runtime.ReadMemStats(&ms1) any, err := types.NewAnyWithValue(eom) diff --git a/codec/unknownproto/benchmarks_test.go b/codec/unknownproto/benchmarks_test.go index 373dda7acfd5..c38f5c47a2b8 100644 --- a/codec/unknownproto/benchmarks_test.go +++ b/codec/unknownproto/benchmarks_test.go @@ -45,6 +45,7 @@ func init() { func BenchmarkRejectUnknownFields_serial(b *testing.B) { benchmarkRejectUnknownFields(b, false) } + func BenchmarkRejectUnknownFields_parallel(b *testing.B) { benchmarkRejectUnknownFields(b, true) } @@ -82,9 +83,11 @@ func benchmarkRejectUnknownFields(b *testing.B, parallel bool) { func BenchmarkProtoUnmarshal_serial(b *testing.B) { benchmarkProtoUnmarshal(b, false) } + func BenchmarkProtoUnmarshal_parallel(b *testing.B) { benchmarkProtoUnmarshal(b, true) } + func benchmarkProtoUnmarshal(b *testing.B, parallel bool) { b.ReportAllocs() diff --git a/codec/unknownproto/unknown_fields.go b/codec/unknownproto/unknown_fields.go index 36b745e1e04b..3af40ffed15b 100644 --- a/codec/unknownproto/unknown_fields.go +++ b/codec/unknownproto/unknown_fields.go @@ -162,8 +162,10 @@ func RejectUnknownFields(bz []byte, msg proto.Message, allowUnknownNonCriticals return hasUnknownNonCriticals, nil } -var protoMessageForTypeNameMu sync.RWMutex -var protoMessageForTypeNameCache = make(map[string]proto.Message) +var ( + protoMessageForTypeNameMu sync.RWMutex + protoMessageForTypeNameCache = make(map[string]proto.Message) +) // protoMessageForTypeName takes in a fully qualified name e.g. testdata.TestVersionFD1 // and returns a corresponding empty protobuf message that serves the prototype for typechecking. @@ -382,8 +384,10 @@ type descriptorMatch struct { desc *descriptor.DescriptorProto } -var descprotoCacheMu sync.RWMutex -var descprotoCache = make(map[reflect.Type]*descriptorMatch) +var ( + descprotoCacheMu sync.RWMutex + descprotoCache = make(map[reflect.Type]*descriptorMatch) +) // getDescriptorInfo retrieves the mapping of field numbers to their respective field descriptors. func getDescriptorInfo(desc descriptorIface, msg proto.Message) (map[int32]*descriptor.FieldDescriptorProto, *descriptor.DescriptorProto, error) { diff --git a/container/Makefile b/container/Makefile new file mode 100644 index 000000000000..8ac9e88558aa --- /dev/null +++ b/container/Makefile @@ -0,0 +1,4 @@ +update-testdata-examples: + go test . -test.update-golden + dot -Tsvg testdata/example.dot > testdata/example.svg + dot -Tsvg testdata/example_error.dot > testdata/example_error.svg diff --git a/container/README.md b/container/README.md new file mode 100644 index 000000000000..7534573a655f --- /dev/null +++ b/container/README.md @@ -0,0 +1,34 @@ +# Cosmos SDK Dependency Injection `container` Module + +## Overview + +TODO + +## Usage + +TODO + +## Debugging + +Issues with resolving dependencies in the container can be done with logs +and [Graphviz](https://graphviz.org) renderings of the container tree. By default, whenever there is an error, logs will +be printed to stderr and a rendering of the dependency graph in Graphviz DOT format will be saved to +`debug_container.dot`. + +Here is an example Graphviz rendering of a successful build of a dependency graph: +![Graphviz Example](./testdata/example.svg) + +Rectangles represent functions, ovals represent types, rounded rectangles represent modules and the single hexagon +represents the function which called `Build`. Black-colored shapes mark functions and types that were called/resolved +without an error. Gray-colored nodes mark functions and types that could have been called/resolved in the container but +were left unused. + +Here is an example Graphviz rendering of a dependency graph build which failed: +![Graphviz Error Example](./testdata/example_error.svg) + +Graphviz DOT files can be converted into SVG's for viewing in a web browser using the `dot` command-line tool, ex: +``` +> dot -Tsvg debug_container.dot > debug_container.svg +``` + +Many other tools including some IDEs support working with DOT files. \ No newline at end of file diff --git a/container/build.go b/container/build.go new file mode 100644 index 000000000000..92a891a40565 --- /dev/null +++ b/container/build.go @@ -0,0 +1,83 @@ +package container + +// Build builds the container specified by containerConfig and extracts the +// requested outputs from the container or returns an error. It is the single +// entry point for building and running a dependency injection container. +// Each of the values specified as outputs must be pointers to types that +// can be provided by the container. +// +// Ex: +// var x int +// Build(Provide(func() int { return 1 }), &x) +// +// Build uses the debug mode provided by AutoDebug which means there will be +// verbose debugging information if there is an error and nothing upon success. +// Use BuildDebug to configure debug behavior. +func Build(containerConfig Config, outputs ...interface{}) error { + loc := LocationFromCaller(1) + return build(loc, AutoDebug(), containerConfig, outputs...) +} + +// BuildDebug is a version of Build which takes an optional DebugOption for +// logging and visualization. +func BuildDebug(debugOpt DebugOption, config Config, outputs ...interface{}) error { + loc := LocationFromCaller(1) + return build(loc, debugOpt, config, outputs...) +} + +func build(loc Location, debugOpt DebugOption, config Config, outputs ...interface{}) error { + cfg, err := newDebugConfig() + if err != nil { + return err + } + + // debug cleanup + defer func() { + for _, f := range cfg.cleanup { + f() + } + }() + + err = doBuild(cfg, loc, debugOpt, config, outputs...) + if err != nil { + cfg.logf("Error: %v", err) + if cfg.onError != nil { + err2 := cfg.onError.applyConfig(cfg) + if err2 != nil { + return err2 + } + } + return err + } else { + if cfg.onSuccess != nil { + err2 := cfg.onSuccess.applyConfig(cfg) + if err2 != nil { + return err2 + } + } + return nil + } +} + +func doBuild(cfg *debugConfig, loc Location, debugOpt DebugOption, config Config, outputs ...interface{}) error { + defer cfg.generateGraph() // always generate graph on exit + + if debugOpt != nil { + err := debugOpt.applyConfig(cfg) + if err != nil { + return err + } + } + + cfg.logf("Registering providers") + cfg.indentLogger() + ctr := newContainer(cfg) + err := config.apply(ctr) + if err != nil { + cfg.logf("Failed registering providers because of: %+v", err) + return err + } + cfg.dedentLogger() + + return ctr.build(loc, outputs...) +} diff --git a/container/option.go b/container/config.go similarity index 57% rename from container/option.go rename to container/config.go index 156a27cd6264..9440fab3026d 100644 --- a/container/option.go +++ b/container/config.go @@ -6,26 +6,26 @@ import ( "github.com/pkg/errors" ) -// Option is a functional option for a container. -type Option interface { +// Config is a functional configuration of a container. +type Config interface { apply(*container) error } -// Provide creates a container option which registers the provided dependency +// Provide defines a container configuration which registers the provided dependency // injection providers. Each provider will be called at most once with the // exception of module-scoped providers which are called at most once per module // (see ModuleKey). -func Provide(providers ...interface{}) Option { - return containerOption(func(ctr *container) error { +func Provide(providers ...interface{}) Config { + return containerConfig(func(ctr *container) error { return provide(ctr, nil, providers) }) } -// ProvideInModule creates a container option which registers the provided dependency +// ProvideInModule defines container configuration which registers the provided dependency // injection providers that are to be run in the named module. Each provider // will be called at most once. -func ProvideInModule(moduleName string, providers ...interface{}) Option { - return containerOption(func(ctr *container) error { +func ProvideInModule(moduleName string, providers ...interface{}) Config { + return containerConfig(func(ctr *container) error { if moduleName == "" { return errors.Errorf("expected non-empty module name") } @@ -48,9 +48,9 @@ func provide(ctr *container, key *moduleKey, providers []interface{}) error { return nil } -func Supply(values ...interface{}) Option { +func Supply(values ...interface{}) Config { loc := LocationFromCaller(1) - return containerOption(func(ctr *container) error { + return containerConfig(func(ctr *container) error { for _, v := range values { err := ctr.supply(reflect.ValueOf(v), loc) if err != nil { @@ -61,17 +61,17 @@ func Supply(values ...interface{}) Option { }) } -// Error creates an option which causes the dependency injection container to +// Error defines configuration which causes the dependency injection container to // fail immediately. -func Error(err error) Option { - return containerOption(func(*container) error { +func Error(err error) Config { + return containerConfig(func(*container) error { return errors.WithStack(err) }) } -// Options creates an option which bundles together other options. -func Options(opts ...Option) Option { - return containerOption(func(ctr *container) error { +// Configs defines a configuration which bundles together multiple Config definitions. +func Configs(opts ...Config) Config { + return containerConfig(func(ctr *container) error { for _, opt := range opts { err := opt.apply(ctr) if err != nil { @@ -82,10 +82,10 @@ func Options(opts ...Option) Option { }) } -type containerOption func(*container) error +type containerConfig func(*container) error -func (c containerOption) apply(ctr *container) error { +func (c containerConfig) apply(ctr *container) error { return c(ctr) } -var _ Option = (*containerOption)(nil) +var _ Config = (*containerConfig)(nil) diff --git a/container/container.go b/container/container.go index 700b6b88ceb8..484419757f9d 100644 --- a/container/container.go +++ b/container/container.go @@ -5,8 +5,9 @@ import ( "fmt" "reflect" - "github.com/goccy/go-graphviz/cgraph" "github.com/pkg/errors" + + "github.com/cosmos/cosmos-sdk/container/internal/graphviz" ) type container struct { @@ -38,10 +39,8 @@ func newContainer(cfg *debugConfig) *container { func (c *container) call(provider *ProviderDescriptor, moduleKey *moduleKey) ([]reflect.Value, error) { loc := provider.Location - graphNode, err := c.locationGraphNode(loc, moduleKey) - if err != nil { - return nil, err - } + graphNode := c.locationGraphNode(loc, moduleKey) + markGraphNodeAsFailed(graphNode) if c.callerMap[loc] { @@ -83,22 +82,18 @@ func (c *container) getResolver(typ reflect.Type) (resolver, error) { } elemType := typ - if isAutoGroupSliceType(elemType) || isOnePerModuleMapType(elemType) { + if isManyPerContainerSliceType(elemType) || isOnePerModuleMapType(elemType) { elemType = elemType.Elem() } - var typeGraphNode *cgraph.Node - var err error + var typeGraphNode *graphviz.Node - if isAutoGroupType(elemType) { - c.logf("Registering resolver for auto-group type %v", elemType) + if isManyPerContainerType(elemType) { + c.logf("Registering resolver for many-per-container type %v", elemType) sliceType := reflect.SliceOf(elemType) - typeGraphNode, err = c.typeGraphNode(sliceType) - if err != nil { - return nil, err - } - typeGraphNode.SetComment("auto-group") + typeGraphNode = c.typeGraphNode(sliceType) + typeGraphNode.SetComment("many-per-container") r := &groupResolver{ typ: elemType, @@ -112,10 +107,7 @@ func (c *container) getResolver(typ reflect.Type) (resolver, error) { c.logf("Registering resolver for one-per-module type %v", elemType) mapType := reflect.MapOf(stringType, elemType) - typeGraphNode, err = c.typeGraphNode(mapType) - if err != nil { - return nil, err - } + typeGraphNode = c.typeGraphNode(mapType) typeGraphNode.SetComment("one-per-module") r := &onePerModuleResolver{ @@ -133,21 +125,24 @@ func (c *container) getResolver(typ reflect.Type) (resolver, error) { return c.resolvers[typ], nil } -func (c *container) addNode(provider *ProviderDescriptor, key *moduleKey) (interface{}, error) { - providerGraphNode, err := c.locationGraphNode(provider.Location, key) - if err != nil { - return nil, err - } +var stringType = reflect.TypeOf("") +func (c *container) addNode(provider *ProviderDescriptor, key *moduleKey) (interface{}, error) { + providerGraphNode := c.locationGraphNode(provider.Location, key) hasModuleKeyParam := false + hasOwnModuleKeyParam := false for _, in := range provider.Inputs { typ := in.Type if typ == moduleKeyType { hasModuleKeyParam = true } - if isAutoGroupType(typ) { - return nil, fmt.Errorf("auto-group type %v can't be used as an input parameter", typ) + if typ == ownModuleKeyType { + hasOwnModuleKeyParam = true + } + + if isManyPerContainerType(typ) { + return nil, fmt.Errorf("many-per-container type %v can't be used as an input parameter", typ) } else if isOnePerModuleType(typ) { return nil, fmt.Errorf("one-per-module type %v can't be used as an input parameter", typ) } @@ -157,11 +152,11 @@ func (c *container) addNode(provider *ProviderDescriptor, key *moduleKey) (inter return nil, err } - var typeGraphNode *cgraph.Node + var typeGraphNode *graphviz.Node if vr != nil { typeGraphNode = vr.typeGraphNode() } else { - typeGraphNode, err = c.typeGraphNode(typ) + typeGraphNode = c.typeGraphNode(typ) if err != nil { return nil, err } @@ -170,7 +165,7 @@ func (c *container) addNode(provider *ProviderDescriptor, key *moduleKey) (inter c.addGraphEdge(typeGraphNode, providerGraphNode) } - if key != nil || !hasModuleKeyParam { + if !hasModuleKeyParam { c.logf("Registering %s", provider.Location.String()) c.indentLogger() defer c.dedentLogger() @@ -189,8 +184,8 @@ func (c *container) addNode(provider *ProviderDescriptor, key *moduleKey) (inter typ, typ.Elem()) } - // auto-group slices of auto-group types - if isAutoGroupSliceType(typ) { + // many-per-container slices of many-per-container types + if isManyPerContainerSliceType(typ) { typ = typ.Elem() } @@ -208,15 +203,12 @@ func (c *container) addNode(provider *ProviderDescriptor, key *moduleKey) (inter } else { c.logf("Registering resolver for simple type %v", typ) - typeGraphNode, err := c.typeGraphNode(typ) - if err != nil { - return nil, err - } - + typeGraphNode := c.typeGraphNode(typ) vr = &simpleResolver{ - node: sp, - typ: typ, - graphNode: typeGraphNode, + node: sp, + typ: typ, + graphNode: typeGraphNode, + idxInValues: i, } c.resolvers[typ] = vr } @@ -226,6 +218,11 @@ func (c *container) addNode(provider *ProviderDescriptor, key *moduleKey) (inter return sp, nil } else { + if hasOwnModuleKeyParam { + return nil, errors.Errorf("%T and %T must not be declared as dependencies on the same provided", + ModuleKey{}, OwnModuleKey{}) + } + c.logf("Registering module-scoped provider: %s", provider.Location.String()) c.indentLogger() defer c.dedentLogger() @@ -247,11 +244,7 @@ func (c *container) addNode(provider *ProviderDescriptor, key *moduleKey) (inter typ, provider.Location, existing.describeLocation()) } - typeGraphNode, err := c.typeGraphNode(typ) - if err != nil { - return reflect.Value{}, err - } - + typeGraphNode := c.typeGraphNode(typ) c.resolvers[typ] = &moduleDepResolver{ typ: typ, idxInValues: i, @@ -269,17 +262,9 @@ func (c *container) addNode(provider *ProviderDescriptor, key *moduleKey) (inter func (c *container) supply(value reflect.Value, location Location) error { typ := value.Type() - locGrapNode, err := c.locationGraphNode(location, nil) - if err != nil { - return err - } + locGrapNode := c.locationGraphNode(location, nil) markGraphNodeAsUsed(locGrapNode) - - typeGraphNode, err := c.typeGraphNode(typ) - if err != nil { - return err - } - + typeGraphNode := c.typeGraphNode(typ) c.addGraphEdge(locGrapNode, typeGraphNode) if existing, ok := c.resolvers[typ]; ok { @@ -299,10 +284,7 @@ func (c *container) supply(value reflect.Value, location Location) error { func (c *container) resolve(in ProviderInput, moduleKey *moduleKey, caller Location) (reflect.Value, error) { c.resolveStack = append(c.resolveStack, resolveFrame{loc: caller, typ: in.Type}) - typeGraphNode, err := c.typeGraphNode(in.Type) - if err != nil { - return reflect.Value{}, err - } + typeGraphNode := c.typeGraphNode(in.Type) if in.Type == moduleKeyType { if moduleKey == nil { @@ -313,6 +295,15 @@ func (c *container) resolve(in ProviderInput, moduleKey *moduleKey, caller Locat return reflect.ValueOf(ModuleKey{moduleKey}), nil } + if in.Type == ownModuleKeyType { + if moduleKey == nil { + return reflect.Value{}, errors.Errorf("trying to resolve %T for %s but not inside of any module's scope", moduleKey, caller) + } + c.logf("Providing OwnModuleKey %s", moduleKey.name) + markGraphNodeAsUsed(typeGraphNode) + return reflect.ValueOf(OwnModuleKey{moduleKey}), nil + } + vr, err := c.getResolver(in.Type) if err != nil { return reflect.Value{}, err @@ -342,20 +333,46 @@ func (c *container) resolve(in ProviderInput, moduleKey *moduleKey, caller Locat return res, nil } -func (c *container) run(invoker interface{}) error { - rctr, err := ExtractProviderDescriptor(invoker) - if err != nil { - return err +func (c *container) build(loc Location, outputs ...interface{}) error { + var providerIn []ProviderInput + for _, output := range outputs { + typ := reflect.TypeOf(output) + if typ.Kind() != reflect.Pointer { + return fmt.Errorf("output type must be a pointer, %s is invalid", typ) + } + + providerIn = append(providerIn, ProviderInput{Type: typ.Elem()}) } - if len(rctr.Outputs) > 0 { - return errors.Errorf("invoker function cannot have return values other than error: %s", rctr.Location) + desc := ProviderDescriptor{ + Inputs: providerIn, + Outputs: nil, + Fn: func(values []reflect.Value) ([]reflect.Value, error) { + if len(values) != len(outputs) { + return nil, fmt.Errorf("internal error, unexpected number of values") + } + + for i, output := range outputs { + val := reflect.ValueOf(output) + val.Elem().Set(values[i]) + } + + return nil, nil + }, + Location: loc, + } + callerGraphNode := c.locationGraphNode(loc, nil) + callerGraphNode.SetShape("hexagon") + + desc, err := expandStructArgsProvider(desc) + if err != nil { + return err } - c.logf("Registering invoker") + c.logf("Registering outputs") c.indentLogger() - node, err := c.addNode(&rctr, nil) + node, err := c.addNode(&desc, nil) if err != nil { return err } @@ -397,10 +414,13 @@ func (c container) formatResolveStack() string { return buf.String() } -func markGraphNodeAsUsed(node *cgraph.Node) { +func markGraphNodeAsUsed(node *graphviz.Node) { node.SetColor("black") + node.SetPenWidth("1.5") + node.SetFontColor("black") } -func markGraphNodeAsFailed(node *cgraph.Node) { +func markGraphNodeAsFailed(node *graphviz.Node) { node.SetColor("red") + node.SetFontColor("red") } diff --git a/container/container_test.go b/container/container_test.go index 15d8d1a3b6d9..19ca76a26c09 100644 --- a/container/container_test.go +++ b/container/container_test.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/stretchr/testify/require" + "gotest.tools/v3/golden" "github.com/cosmos/cosmos-sdk/container" ) @@ -15,14 +16,13 @@ type KVStoreKey struct { name string } -type ModuleKey string - type MsgClientA struct { - key ModuleKey + key string } type KeeperA struct { - key KVStoreKey + key KVStoreKey + name string } type KeeperB struct { @@ -40,24 +40,20 @@ type Command struct { Run func() } -func (Command) IsAutoGroupType() {} +func (Command) IsManyPerContainerType() {} func ProvideKVStoreKey(moduleKey container.ModuleKey) KVStoreKey { return KVStoreKey{name: moduleKey.Name()} } -func ProvideModuleKey(moduleKey container.ModuleKey) (ModuleKey, error) { - return ModuleKey(moduleKey.Name()), nil -} - -func ProvideMsgClientA(_ container.ModuleKey, key ModuleKey) MsgClientA { - return MsgClientA{key} +func ProvideMsgClientA(key container.ModuleKey) MsgClientA { + return MsgClientA{key.Name()} } type ModuleA struct{} -func (ModuleA) Provide(key KVStoreKey) (KeeperA, Handler, Command) { - return KeeperA{key}, Handler{}, Command{} +func (ModuleA) Provide(key KVStoreKey, moduleKey container.OwnModuleKey) (KeeperA, Handler, Command) { + return KeeperA{key: key, name: container.ModuleKey(moduleKey).Name()}, Handler{}, Command{} } type ModuleB struct{} @@ -76,7 +72,7 @@ type BProvides struct { Commands []Command } -func (ModuleB) Provide(dependencies BDependencies, _ container.ModuleKey) (BProvides, Handler, error) { +func (ModuleB) Provide(dependencies BDependencies) (BProvides, Handler, error) { return BProvides{ KeeperB: KeeperB{ key: dependencies.Key, @@ -86,32 +82,43 @@ func (ModuleB) Provide(dependencies BDependencies, _ container.ModuleKey) (BProv }, Handler{}, nil } +var scenarioConfig = container.Configs( + container.Provide(ProvideMsgClientA), + container.ProvideInModule("runtime", ProvideKVStoreKey), + container.ProvideInModule("a", wrapMethod0(ModuleA{})), + container.ProvideInModule("b", wrapMethod0(ModuleB{})), +) + func TestScenario(t *testing.T) { + var ( + handlers map[string]Handler + commands []Command + a KeeperA + b KeeperB + ) require.NoError(t, - container.Run( - func(handlers map[string]Handler, commands []Command, a KeeperA, b KeeperB) { - require.Len(t, handlers, 2) - require.Equal(t, Handler{}, handlers["a"]) - require.Equal(t, Handler{}, handlers["b"]) - require.Len(t, commands, 3) - require.Equal(t, KeeperA{ - key: KVStoreKey{name: "a"}, - }, a) - require.Equal(t, KeeperB{ - key: KVStoreKey{name: "b"}, - msgClientA: MsgClientA{ - key: "b", - }, - }, b) - }, - container.Provide( - ProvideKVStoreKey, - ProvideModuleKey, - ProvideMsgClientA, - ), - container.ProvideInModule("a", wrapMethod0(ModuleA{})), - container.ProvideInModule("b", wrapMethod0(ModuleB{})), + container.Build( + scenarioConfig, + &handlers, + &commands, + &a, + &b, )) + + require.Len(t, handlers, 2) + require.Equal(t, Handler{}, handlers["a"]) + require.Equal(t, Handler{}, handlers["b"]) + require.Len(t, commands, 3) + require.Equal(t, KeeperA{ + key: KVStoreKey{name: "a"}, + name: "a", + }, a) + require.Equal(t, KeeperB{ + key: KVStoreKey{name: "b"}, + msgClientA: MsgClientA{ + key: "b", + }, + }, b) } func wrapMethod0(module interface{}) interface{} { @@ -130,28 +137,30 @@ func wrapMethod0(module interface{}) interface{} { } func TestResolveError(t *testing.T) { - require.Error(t, container.Run( - func(x string) {}, + var x string + require.Error(t, container.Build( container.Provide( func(x float64) string { return fmt.Sprintf("%f", x) }, func(x int) float64 { return float64(x) }, func(x float32) int { return int(x) }, ), + &x, )) } func TestCyclic(t *testing.T) { - require.Error(t, container.Run( - func(x string) {}, + var x string + require.Error(t, container.Build( container.Provide( func(x int) float64 { return float64(x) }, func(x float64) (int, string) { return int(x), "hi" }, ), + &x, )) } func TestErrorOption(t *testing.T) { - err := container.Run(func() {}, container.Error(fmt.Errorf("an error"))) + err := container.Build(container.Error(fmt.Errorf("an error"))) require.Error(t, err) } @@ -160,11 +169,8 @@ func TestBadCtr(t *testing.T) { require.Error(t, err) } -func TestInvoker(t *testing.T) { - require.NoError(t, container.Run(func() {})) - require.NoError(t, container.Run(func() error { return nil })) - require.Error(t, container.Run(func() error { return fmt.Errorf("error") })) - require.Error(t, container.Run(func() int { return 0 })) +func TestTrivial(t *testing.T) { + require.NoError(t, container.Build(container.Configs())) } func TestErrorFunc(t *testing.T) { @@ -178,119 +184,136 @@ func TestErrorFunc(t *testing.T) { ) require.NoError(t, err) + var x int require.Error(t, - container.Run( - func(x int) { - }, + container.Build( container.Provide(func() (int, error) { return 0, fmt.Errorf("the error") }), + &x, )) - - require.Error(t, - container.Run(func() error { - return fmt.Errorf("the error") - }), "the error") } func TestSimple(t *testing.T) { + var x int require.NoError(t, - container.Run( - func(x int) { - require.Equal(t, 1, x) - }, + container.Build( container.Provide( func() int { return 1 }, ), + &x, ), ) require.Error(t, - container.Run(func(int) {}, + container.Build( container.Provide( func() int { return 0 }, func() int { return 1 }, ), + &x, ), ) } func TestModuleScoped(t *testing.T) { + var x int require.Error(t, - container.Run(func(int) {}, + container.Build( container.Provide( func(container.ModuleKey) int { return 0 }, ), + &x, ), ) + var y float64 require.Error(t, - container.Run(func(float64) {}, - container.Provide( - func(container.ModuleKey) int { return 0 }, - func() int { return 1 }, - ), - container.ProvideInModule("a", - func(x int) float64 { return float64(x) }, + container.Build( + container.Configs( + container.Provide( + func(container.ModuleKey) int { return 0 }, + func() int { return 1 }, + ), + container.ProvideInModule("a", + func(x int) float64 { return float64(x) }, + ), ), + &y, ), ) require.Error(t, - container.Run(func(float64) {}, - container.Provide( - func() int { return 0 }, - func(container.ModuleKey) int { return 1 }, - ), - container.ProvideInModule("a", - func(x int) float64 { return float64(x) }, + container.Build( + container.Configs( + container.Provide( + func() int { return 0 }, + func(container.ModuleKey) int { return 1 }, + ), + container.ProvideInModule("a", + func(x int) float64 { return float64(x) }, + ), ), + &y, ), ) require.Error(t, - container.Run(func(float64) {}, - container.Provide( - func(container.ModuleKey) int { return 0 }, - func(container.ModuleKey) int { return 1 }, - ), - container.ProvideInModule("a", - func(x int) float64 { return float64(x) }, + container.Build( + container.Configs( + container.Provide( + func(container.ModuleKey) int { return 0 }, + func(container.ModuleKey) int { return 1 }, + ), + container.ProvideInModule("a", + func(x int) float64 { return float64(x) }, + ), ), + &y, ), ) require.NoError(t, - container.Run(func(float64) {}, - container.Provide( - func(container.ModuleKey) int { return 0 }, - ), - container.ProvideInModule("a", - func(x int) float64 { return float64(x) }, + container.Build( + container.Configs( + container.Provide( + func(container.ModuleKey) int { return 0 }, + ), + container.ProvideInModule("a", + func(x int) float64 { return float64(x) }, + ), ), + &y, ), ) require.Error(t, - container.Run(func(float64) {}, - container.Provide( - func(container.ModuleKey) int { return 0 }, - ), - container.ProvideInModule("", - func(x int) float64 { return float64(x) }, + container.Build( + container.Configs( + container.Provide( + func(container.ModuleKey) int { return 0 }, + ), + container.ProvideInModule("", + func(x int) float64 { return float64(x) }, + ), ), + &y, ), ) + var z float32 require.NoError(t, - container.Run(func(float64, float32) {}, - container.Provide( - func(container.ModuleKey) int { return 0 }, - ), - container.ProvideInModule("a", - func(x int) float64 { return float64(x) }, - func(x int) float32 { return float32(x) }, + container.Build( + container.Configs( + container.Provide( + func(container.ModuleKey) int { return 0 }, + ), + container.ProvideInModule("a", + func(x int) float64 { return float64(x) }, + func(x int) float32 { return float32(x) }, + ), ), + &y, &z, ), "use module dep twice", ) @@ -301,94 +324,96 @@ type OnePerModuleInt int func (OnePerModuleInt) IsOnePerModuleType() {} func TestOnePerModule(t *testing.T) { + var x OnePerModuleInt require.Error(t, - container.Run( - func(OnePerModuleInt) {}, - ), + container.Build(container.Configs(), &x), "bad input type", ) + var y map[string]OnePerModuleInt + var z string require.NoError(t, - container.Run( - func(x map[string]OnePerModuleInt, y string) { - require.Equal(t, map[string]OnePerModuleInt{ - "a": 3, - "b": 4, - }, x) - require.Equal(t, "7", y) - }, - container.ProvideInModule("a", - func() OnePerModuleInt { return 3 }, - ), - container.ProvideInModule("b", - func() OnePerModuleInt { return 4 }, + container.Build( + container.Configs( + container.ProvideInModule("a", + func() OnePerModuleInt { return 3 }, + ), + container.ProvideInModule("b", + func() OnePerModuleInt { return 4 }, + ), + container.Provide(func(x map[string]OnePerModuleInt) string { + sum := 0 + for _, v := range x { + sum += int(v) + } + return fmt.Sprintf("%d", sum) + }), ), - container.Provide(func(x map[string]OnePerModuleInt) string { - sum := 0 - for _, v := range x { - sum += int(v) - } - return fmt.Sprintf("%d", sum) - }), + &y, + &z, ), ) + require.Equal(t, map[string]OnePerModuleInt{ + "a": 3, + "b": 4, + }, y) + require.Equal(t, "7", z) + + var m map[string]OnePerModuleInt require.Error(t, - container.Run( - func(map[string]OnePerModuleInt) {}, + container.Build( container.ProvideInModule("a", func() OnePerModuleInt { return 0 }, func() OnePerModuleInt { return 0 }, ), + &m, ), "duplicate", ) require.Error(t, - container.Run( - func(map[string]OnePerModuleInt) {}, + container.Build( container.Provide( func() OnePerModuleInt { return 0 }, ), + &m, ), "out of scope", ) require.Error(t, - container.Run( - func(map[string]OnePerModuleInt) {}, + container.Build( container.Provide( func() map[string]OnePerModuleInt { return nil }, ), + &m, ), "bad return type", ) require.NoError(t, - container.Run( - func(map[string]OnePerModuleInt) {}, + container.Build( + container.Configs(), + &m, ), "no providers", ) } -type AutoGroupInt int +type ManyPerContainerInt int -func (AutoGroupInt) IsAutoGroupType() {} +func (ManyPerContainerInt) IsManyPerContainerType() {} -func TestAutoGroup(t *testing.T) { +func TestManyPerContainer(t *testing.T) { + var xs []ManyPerContainerInt + var sum string require.NoError(t, - container.Run( - func(xs []AutoGroupInt, sum string) { - require.Len(t, xs, 2) - require.Contains(t, xs, AutoGroupInt(4)) - require.Contains(t, xs, AutoGroupInt(9)) - require.Equal(t, "13", sum) - }, + container.Build( container.Provide( - func() AutoGroupInt { return 4 }, - func() AutoGroupInt { return 9 }, - func(xs []AutoGroupInt) string { + func() ManyPerContainerInt { return 4 }, + func() ManyPerContainerInt { return 9 }, + func(xs []ManyPerContainerInt) string { sum := 0 for _, x := range xs { sum += int(x) @@ -396,55 +421,71 @@ func TestAutoGroup(t *testing.T) { return fmt.Sprintf("%d", sum) }, ), + &xs, + &sum, ), ) + require.Len(t, xs, 2) + require.Contains(t, xs, ManyPerContainerInt(4)) + require.Contains(t, xs, ManyPerContainerInt(9)) + require.Equal(t, "13", sum) + var z ManyPerContainerInt require.Error(t, - container.Run( - func(AutoGroupInt) {}, + container.Build( container.Provide( - func() AutoGroupInt { return 0 }, + func() ManyPerContainerInt { return 0 }, ), + &z, ), "bad input type", ) require.NoError(t, - container.Run( - func([]AutoGroupInt) {}, + container.Build( + container.Configs(), + &xs, ), "no providers", ) } func TestSupply(t *testing.T) { + var x int require.NoError(t, - container.Run(func(x int) { - require.Equal(t, 3, x) - }, + container.Build( container.Supply(3), + &x, ), ) + require.Equal(t, 3, x) require.Error(t, - container.Run(func(x int) {}, - container.Supply(3), - container.Provide(func() int { return 4 }), + container.Build( + container.Configs( + container.Supply(3), + container.Provide(func() int { return 4 }), + ), + &x, ), "can't supply then provide", ) require.Error(t, - container.Run(func(x int) {}, - container.Supply(3), - container.Provide(func() int { return 4 }), + container.Build( + container.Configs( + container.Supply(3), + container.Provide(func() int { return 4 }), + ), + &x, ), "can't provide then supply", ) require.Error(t, - container.Run(func(x int) {}, + container.Build( container.Supply(3, 4), + &x, ), "can't supply twice", ) @@ -461,47 +502,47 @@ type TestOutput struct { container.Out X string + Y int64 } func TestStructArgs(t *testing.T) { - require.Error(t, container.Run( - func(input TestInput) {}, - )) + var input TestInput + require.Error(t, container.Build(container.Configs(), &input)) - require.NoError(t, container.Run( - func(input TestInput) { - require.Equal(t, 0, input.X) - require.Equal(t, 1.3, input.Y) - }, + require.NoError(t, container.Build( container.Supply(1.3), + &input, )) + require.Equal(t, 0, input.X) + require.Equal(t, 1.3, input.Y) - require.NoError(t, container.Run( - func(input TestInput) { - require.Equal(t, 1, input.X) - require.Equal(t, 1.3, input.Y) - }, + require.NoError(t, container.Build( container.Supply(1.3, 1), + &input, )) + require.Equal(t, 1, input.X) + require.Equal(t, 1.3, input.Y) - require.NoError(t, container.Run( - func(x string) { - require.Equal(t, "A", x) - }, + var x string + var y int64 + require.NoError(t, container.Build( container.Provide(func() (TestOutput, error) { - return TestOutput{X: "A"}, nil + return TestOutput{X: "A", Y: -10}, nil }), + &x, &y, )) + require.Equal(t, "A", x) + require.Equal(t, int64(-10), y) - require.Error(t, container.Run( - func(x string) {}, + require.Error(t, container.Build( container.Provide(func() (TestOutput, error) { return TestOutput{}, fmt.Errorf("error") }), + &x, )) } -func TestLogging(t *testing.T) { +func TestDebugOptions(t *testing.T) { var logOut string var dotGraph string @@ -516,8 +557,7 @@ func TestLogging(t *testing.T) { require.NoError(t, err) defer os.Remove(graphfile.Name()) - require.NoError(t, container.RunDebug( - func() {}, + require.NoError(t, container.BuildDebug( container.DebugOptions( container.Logger(func(s string) { logOut += s @@ -526,9 +566,10 @@ func TestLogging(t *testing.T) { dotGraph = g }), container.LogVisualizer(), - container.FileVisualizer(graphfile.Name(), "svg"), + container.FileVisualizer(graphfile.Name()), container.StdoutLogger(), ), + container.Configs(), )) require.Contains(t, logOut, "digraph") @@ -540,5 +581,56 @@ func TestLogging(t *testing.T) { graphfileContents, err := os.ReadFile(graphfile.Name()) require.NoError(t, err) - require.Contains(t, string(graphfileContents), " %q%s;\n", indent, e.from.name, e.to.name, e.Attributes.String()) + return err +} diff --git a/container/internal/graphviz/graph.go b/container/internal/graphviz/graph.go new file mode 100644 index 000000000000..d2ae90545f48 --- /dev/null +++ b/container/internal/graphviz/graph.go @@ -0,0 +1,156 @@ +// Package graphviz +package graphviz + +import ( + "bytes" + "fmt" + "io" + + "github.com/cosmos/cosmos-sdk/container/internal/util" +) + +// Graph represents a graphviz digraph. +type Graph struct { + *Attributes + + // name is the optional name of this graph + name string + + // parent is non-nil if this is a sub-graph + parent *Graph + + // allNodes includes all nodes in the graph and its sub-graphs. + // It is set to the same map in parent and sub-graphs. + allNodes map[string]*Node + + // myNodes are the nodes in this graph (whether it's a root or sub-graph) + myNodes map[string]*Node + + subgraphs map[string]*Graph + + edges []*Edge +} + +// NewGraph creates a new Graph instance. +func NewGraph() *Graph { + return &Graph{ + Attributes: NewAttributes(), + name: "", + parent: nil, + allNodes: map[string]*Node{}, + myNodes: map[string]*Node{}, + subgraphs: map[string]*Graph{}, + edges: nil, + } +} + +// FindOrCreateNode finds or creates the node with the provided name. +func (g *Graph) FindOrCreateNode(name string) (node *Node, found bool) { + if node, ok := g.allNodes[name]; ok { + return node, true + } + + node = &Node{ + Attributes: NewAttributes(), + name: name, + } + g.allNodes[name] = node + g.myNodes[name] = node + return node, false +} + +// FindOrCreateSubGraph finds or creates the subgraph with the provided name. +func (g *Graph) FindOrCreateSubGraph(name string) (graph *Graph, found bool) { + if sub, ok := g.subgraphs[name]; ok { + return sub, true + } + + n := &Graph{ + Attributes: NewAttributes(), + name: name, + parent: g, + allNodes: g.allNodes, + myNodes: map[string]*Node{}, + subgraphs: map[string]*Graph{}, + edges: nil, + } + g.subgraphs[name] = n + return n, false +} + +// CreateEdge creates a new graphviz edge. +func (g *Graph) CreateEdge(from, to *Node) *Edge { + edge := &Edge{ + Attributes: NewAttributes(), + from: from, + to: to, + } + g.edges = append(g.edges, edge) + return edge +} + +// RenderDOT renders the graph to DOT format. +func (g *Graph) RenderDOT(w io.Writer) error { + return g.render(w, "") +} + +func (g *Graph) render(w io.Writer, indent string) error { + if g.parent == nil { + _, err := fmt.Fprintf(w, "%sdigraph %q {\n", indent, g.name) + if err != nil { + return err + } + } else { + _, err := fmt.Fprintf(w, "%ssubgraph %q {\n", indent, g.name) + if err != nil { + return err + } + } + + { + subIndent := indent + " " + + if attrStr := g.Attributes.String(); attrStr != "" { + _, err := fmt.Fprintf(w, "%sgraph %s;\n", subIndent, attrStr) + if err != nil { + return err + } + } + + // we do map iteration in sorted order so that outputs are stable and + // can be used in tests + err := util.IterateMapOrdered(g.subgraphs, func(_ string, subgraph *Graph) error { + return subgraph.render(w, subIndent+" ") + }) + if err != nil { + return err + } + + err = util.IterateMapOrdered(g.myNodes, func(_ string, node *Node) error { + return node.render(w, subIndent) + }) + if err != nil { + return err + } + + for _, edge := range g.edges { + err := edge.render(w, subIndent) + if err != nil { + return err + } + } + } + + _, err := fmt.Fprintf(w, "%s}\n\n", indent) + return err +} + +// String returns the graph in DOT format. +func (g *Graph) String() string { + buf := &bytes.Buffer{} + err := g.RenderDOT(buf) + if err != nil { + panic(err) + } + return buf.String() +} diff --git a/container/internal/graphviz/node.go b/container/internal/graphviz/node.go new file mode 100644 index 000000000000..d464aad869f8 --- /dev/null +++ b/container/internal/graphviz/node.go @@ -0,0 +1,17 @@ +package graphviz + +import ( + "fmt" + "io" +) + +// Node represents a graphviz node. +type Node struct { + *Attributes + name string +} + +func (n Node) render(w io.Writer, indent string) error { + _, err := fmt.Fprintf(w, "%s%q%s;\n", indent, n.name, n.Attributes.String()) + return err +} diff --git a/container/internal/util/util.go b/container/internal/util/util.go new file mode 100644 index 000000000000..3a9a95120da0 --- /dev/null +++ b/container/internal/util/util.go @@ -0,0 +1,26 @@ +package util + +import ( + "golang.org/x/exp/constraints" + "golang.org/x/exp/maps" + "golang.org/x/exp/slices" +) + +// IterateMapOrdered iterates over the map with keys sorted in ascending order +// calling forEach for each key-value pair as long as forEach does not return an error. +func IterateMapOrdered[K constraints.Ordered, V any](m map[K]V, forEach func(k K, v V) error) error { + keys := OrderedMapKeys(m) + for _, k := range keys { + if err := forEach(k, m[k]); err != nil { + return err + } + } + return nil +} + +// OrderedMapKeys returns the map keys in ascending order. +func OrderedMapKeys[K constraints.Ordered, V any](m map[K]V) []K { + keys := maps.Keys(m) + slices.Sort(keys) + return keys +} diff --git a/container/module_dep.go b/container/module_dep.go index 7aecc9c1d118..261d3afed79d 100644 --- a/container/module_dep.go +++ b/container/module_dep.go @@ -3,7 +3,7 @@ package container import ( "reflect" - "github.com/goccy/go-graphviz/cgraph" + "github.com/cosmos/cosmos-sdk/container/internal/graphviz" ) type moduleDepProvider struct { @@ -17,7 +17,7 @@ type moduleDepResolver struct { idxInValues int node *moduleDepProvider valueMap map[*moduleKey]reflect.Value - graphNode *cgraph.Node + graphNode *graphviz.Node } func (s moduleDepResolver) describeLocation() string { @@ -52,6 +52,6 @@ func (s moduleDepResolver) addNode(p *simpleProvider, _ int) error { return duplicateDefinitionError(s.typ, p.provider.Location, s.node.provider.Location.String()) } -func (s moduleDepResolver) typeGraphNode() *cgraph.Node { +func (s moduleDepResolver) typeGraphNode() *graphviz.Node { return s.graphNode } diff --git a/container/module_key.go b/container/module_key.go index 79777dc09357..1b57983bf7d7 100644 --- a/container/module_key.go +++ b/container/module_key.go @@ -6,14 +6,17 @@ import ( // ModuleKey is a special type used to scope a provider to a "module". // -// Special module-scoped providers can be used with Provide by declaring a -// provider with an input parameter of type ModuleKey. These providers -// may construct a unique value of a dependency for each module and will -// be called at most once per module. +// Special module-scoped providers can be used with Provide and ProvideInModule +// by declaring a provider with an input parameter of type ModuleKey. These +// providers may construct a unique value of a dependency for each module and +// will be called at most once per module. // -// Providers passed to ProvideInModule can also declare an input parameter -// of type ModuleKey to retrieve their module key but these providers will be -// called at most once. +// When being used with ProvideInModule, the provider will not receive its +// own ModuleKey but rather the key of the module requesting the dependency +// so that modules can provide module-scoped dependencies to other modules. +// +// In order for a module to retrieve their own module key they can define +// a provider which requires the OwnModuleKey type and DOES NOT require ModuleKey. type ModuleKey struct { *moduleKey } @@ -28,4 +31,8 @@ func (k ModuleKey) Name() string { var moduleKeyType = reflect.TypeOf(ModuleKey{}) -var stringType = reflect.TypeOf("") +// OwnModuleKey is a type which can be used in a module to retrieve its own +// ModuleKey. It MUST NOT be used together with a ModuleKey dependency. +type OwnModuleKey ModuleKey + +var ownModuleKeyType = reflect.TypeOf((*OwnModuleKey)(nil)).Elem() diff --git a/container/one_per_module.go b/container/one_per_module.go index e5cab4fb63f7..9c525eed6994 100644 --- a/container/one_per_module.go +++ b/container/one_per_module.go @@ -4,9 +4,9 @@ import ( "fmt" "reflect" - "github.com/goccy/go-graphviz/cgraph" - "github.com/pkg/errors" + + "github.com/cosmos/cosmos-sdk/container/internal/graphviz" ) // OnePerModuleType marks a type which @@ -34,7 +34,7 @@ type onePerModuleResolver struct { idxMap map[*moduleKey]int resolved bool values reflect.Value - graphNode *cgraph.Node + graphNode *graphviz.Node } type mapOfOnePerModuleResolver struct { @@ -101,6 +101,6 @@ func (o *mapOfOnePerModuleResolver) addNode(s *simpleProvider, _ int) error { return errors.Errorf("%v is a one-per-module type and thus %v can't be used as an output parameter in %s", o.typ, o.mapType, s.provider.Location) } -func (o onePerModuleResolver) typeGraphNode() *cgraph.Node { +func (o onePerModuleResolver) typeGraphNode() *graphviz.Node { return o.graphNode } diff --git a/container/resolver.go b/container/resolver.go index 7583358e042f..3e573556fab1 100644 --- a/container/resolver.go +++ b/container/resolver.go @@ -3,12 +3,12 @@ package container import ( "reflect" - "github.com/goccy/go-graphviz/cgraph" + "github.com/cosmos/cosmos-sdk/container/internal/graphviz" ) type resolver interface { addNode(*simpleProvider, int) error resolve(*container, *moduleKey, Location) (reflect.Value, error) describeLocation() string - typeGraphNode() *cgraph.Node + typeGraphNode() *graphviz.Node } diff --git a/container/run.go b/container/run.go deleted file mode 100644 index 12d1b9e2f113..000000000000 --- a/container/run.go +++ /dev/null @@ -1,44 +0,0 @@ -package container - -// Run runs the provided invoker function with values provided by the provided -// options. It is the single entry point for building and running a dependency -// injection container. Invoker should be a function taking one or more -// dependencies from the container, optionally returning an error. -// -// Ex: -// Run(func (x int) error { println(x) }, Provide(func() int { return 1 })) -func Run(invoker interface{}, opts ...Option) error { - return RunDebug(invoker, nil, opts...) -} - -// RunDebug is a version of Run which takes an optional DebugOption for -// logging and visualization. -func RunDebug(invoker interface{}, debugOpt DebugOption, opts ...Option) error { - opt := Options(opts...) - - cfg, err := newDebugConfig() - if err != nil { - return err - } - - defer cfg.generateGraph() // always generate graph on exit - - if debugOpt != nil { - err = debugOpt.applyConfig(cfg) - if err != nil { - return err - } - } - - cfg.logf("Registering providers") - cfg.indentLogger() - ctr := newContainer(cfg) - err = opt.apply(ctr) - if err != nil { - cfg.logf("Failed registering providers because of: %+v", err) - return err - } - cfg.dedentLogger() - - return ctr.run(invoker) -} diff --git a/container/simple.go b/container/simple.go index e62744c6084f..da9d35343e1b 100644 --- a/container/simple.go +++ b/container/simple.go @@ -3,7 +3,7 @@ package container import ( "reflect" - "github.com/goccy/go-graphviz/cgraph" + "github.com/cosmos/cosmos-sdk/container/internal/graphviz" ) type simpleProvider struct { @@ -19,7 +19,7 @@ type simpleResolver struct { resolved bool typ reflect.Type value reflect.Value - graphNode *cgraph.Node + graphNode *graphviz.Node } func (s *simpleResolver) describeLocation() string { @@ -62,6 +62,6 @@ func (s simpleResolver) addNode(p *simpleProvider, _ int) error { return duplicateDefinitionError(s.typ, p.provider.Location, s.node.provider.Location.String()) } -func (s simpleResolver) typeGraphNode() *cgraph.Node { +func (s simpleResolver) typeGraphNode() *graphviz.Node { return s.graphNode } diff --git a/container/struct_args.go b/container/struct_args.go index 985d950d4648..e3e52128d12b 100644 --- a/container/struct_args.go +++ b/container/struct_args.go @@ -36,12 +36,11 @@ type isOut interface{ isOut() } var isOutType = reflect.TypeOf((*isOut)(nil)).Elem() func expandStructArgsProvider(provider ProviderDescriptor) (ProviderDescriptor, error) { - var foundStructArgs bool + var structArgsInInput bool var newIn []ProviderInput - for _, in := range provider.Inputs { if in.Type.AssignableTo(isInType) { - foundStructArgs = true + structArgsInInput = true inTypes, err := structArgsInTypes(in.Type) if err != nil { return ProviderDescriptor{}, err @@ -52,17 +51,9 @@ func expandStructArgsProvider(provider ProviderDescriptor) (ProviderDescriptor, } } - var newOut []ProviderOutput - for _, out := range provider.Outputs { - if out.Type.AssignableTo(isOutType) { - foundStructArgs = true - newOut = append(newOut, structArgsOutTypes(out.Type)...) - } else { - newOut = append(newOut, out) - } - } + newOut, structArgsInOutput := expandStructArgsOutTypes(provider.Outputs) - if foundStructArgs { + if structArgsInInput || structArgsInOutput { return ProviderDescriptor{ Inputs: newIn, Outputs: newOut, @@ -137,6 +128,20 @@ func structArgsInTypes(typ reflect.Type) ([]ProviderInput, error) { return res, nil } +func expandStructArgsOutTypes(outputs []ProviderOutput) ([]ProviderOutput, bool) { + foundStructArgs := false + var newOut []ProviderOutput + for _, out := range outputs { + if out.Type.AssignableTo(isOutType) { + foundStructArgs = true + newOut = append(newOut, structArgsOutTypes(out.Type)...) + } else { + newOut = append(newOut, out) + } + } + return newOut, foundStructArgs +} + func structArgsOutTypes(typ reflect.Type) []ProviderOutput { n := typ.NumField() var res []ProviderOutput diff --git a/container/supply.go b/container/supply.go index d75ad5980398..e6a1db0b5026 100644 --- a/container/supply.go +++ b/container/supply.go @@ -3,14 +3,14 @@ package container import ( "reflect" - "github.com/goccy/go-graphviz/cgraph" + "github.com/cosmos/cosmos-sdk/container/internal/graphviz" ) type supplyResolver struct { typ reflect.Type value reflect.Value loc Location - graphNode *cgraph.Node + graphNode *graphviz.Node } func (s supplyResolver) describeLocation() string { @@ -26,6 +26,6 @@ func (s supplyResolver) resolve(c *container, _ *moduleKey, caller Location) (re return s.value, nil } -func (s supplyResolver) typeGraphNode() *cgraph.Node { +func (s supplyResolver) typeGraphNode() *graphviz.Node { return s.graphNode } diff --git a/container/testdata/example.dot b/container/testdata/example.dot new file mode 100644 index 000000000000..a9ba2413ac05 --- /dev/null +++ b/container/testdata/example.dot @@ -0,0 +1,43 @@ +digraph "" { + subgraph "cluster_a" { + graph [fontsize="12.0", label="Module: a", penwidth="0.5", style="rounded"]; + "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide"[color="lightgrey", fontcolor="dimgrey", penwidth="0.5", shape="box"]; + } + + subgraph "cluster_b" { + graph [fontsize="12.0", label="Module: b", penwidth="0.5", style="rounded"]; + "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide"[color="black", fontcolor="black", penwidth="1.5", shape="box"]; + } + + subgraph "cluster_runtime" { + graph [fontsize="12.0", label="Module: runtime", penwidth="0.5", style="rounded"]; + "github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey"[color="black", fontcolor="black", penwidth="1.5", shape="box"]; + } + + "[]github.com/cosmos/cosmos-sdk/container_test.Command"[color="lightgrey", comment="many-per-container", fontcolor="dimgrey", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container.ModuleKey"[color="black", fontcolor="black", penwidth="1.5"]; + "github.com/cosmos/cosmos-sdk/container.OwnModuleKey"[color="lightgrey", fontcolor="dimgrey", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container_test.KVStoreKey"[color="black", fontcolor="black", penwidth="1.5"]; + "github.com/cosmos/cosmos-sdk/container_test.KeeperA"[color="lightgrey", fontcolor="dimgrey", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container_test.KeeperB"[color="black", fontcolor="black", penwidth="1.5"]; + "github.com/cosmos/cosmos-sdk/container_test.MsgClientA"[color="black", fontcolor="black", penwidth="1.5"]; + "github.com/cosmos/cosmos-sdk/container_test.ProvideMsgClientA"[color="black", fontcolor="black", penwidth="1.5", shape="box"]; + "github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput"[color="black", fontcolor="black", penwidth="1.5", shape="hexagon"]; + "map[string]github.com/cosmos/cosmos-sdk/container_test.Handler"[color="lightgrey", comment="one-per-module", fontcolor="dimgrey", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container.ModuleKey" -> "github.com/cosmos/cosmos-sdk/container_test.ProvideMsgClientA"; + "github.com/cosmos/cosmos-sdk/container_test.ProvideMsgClientA" -> "github.com/cosmos/cosmos-sdk/container_test.MsgClientA"; + "github.com/cosmos/cosmos-sdk/container.ModuleKey" -> "github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey"; + "github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey" -> "github.com/cosmos/cosmos-sdk/container_test.KVStoreKey"; + "github.com/cosmos/cosmos-sdk/container_test.KVStoreKey" -> "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide"; + "github.com/cosmos/cosmos-sdk/container.OwnModuleKey" -> "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide" -> "github.com/cosmos/cosmos-sdk/container_test.KeeperA"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide" -> "map[string]github.com/cosmos/cosmos-sdk/container_test.Handler"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide" -> "[]github.com/cosmos/cosmos-sdk/container_test.Command"; + "github.com/cosmos/cosmos-sdk/container_test.KVStoreKey" -> "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide"; + "github.com/cosmos/cosmos-sdk/container_test.MsgClientA" -> "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide" -> "github.com/cosmos/cosmos-sdk/container_test.KeeperB"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide" -> "[]github.com/cosmos/cosmos-sdk/container_test.Command"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide" -> "map[string]github.com/cosmos/cosmos-sdk/container_test.Handler"; + "github.com/cosmos/cosmos-sdk/container_test.KeeperB" -> "github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput"; +} + diff --git a/container/testdata/example.svg b/container/testdata/example.svg new file mode 100644 index 000000000000..a324b637cd01 --- /dev/null +++ b/container/testdata/example.svg @@ -0,0 +1,197 @@ + + + + + + + + +cluster_a + +Module: a + + +cluster_b + +Module: b + + +cluster_runtime + +Module: runtime + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide + + + + +[]github.com/cosmos/cosmos-sdk/container_test.Command + +[]github.com/cosmos/cosmos-sdk/container_test.Command + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide->[]github.com/cosmos/cosmos-sdk/container_test.Command + + + + + +github.com/cosmos/cosmos-sdk/container_test.KeeperA + +github.com/cosmos/cosmos-sdk/container_test.KeeperA + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide->github.com/cosmos/cosmos-sdk/container_test.KeeperA + + + + + + +map[string]github.com/cosmos/cosmos-sdk/container_test.Handler + +map[string]github.com/cosmos/cosmos-sdk/container_test.Handler + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide->map[string]github.com/cosmos/cosmos-sdk/container_test.Handler + + + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide->[]github.com/cosmos/cosmos-sdk/container_test.Command + + + + + +github.com/cosmos/cosmos-sdk/container_test.KeeperB + +github.com/cosmos/cosmos-sdk/container_test.KeeperB + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide->github.com/cosmos/cosmos-sdk/container_test.KeeperB + + + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide->map[string]github.com/cosmos/cosmos-sdk/container_test.Handler + + + + + +github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey + +github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey + + + +github.com/cosmos/cosmos-sdk/container_test.KVStoreKey + +github.com/cosmos/cosmos-sdk/container_test.KVStoreKey + + + +github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey->github.com/cosmos/cosmos-sdk/container_test.KVStoreKey + + + + + +github.com/cosmos/cosmos-sdk/container.ModuleKey + +github.com/cosmos/cosmos-sdk/container.ModuleKey + + + +github.com/cosmos/cosmos-sdk/container.ModuleKey->github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey + + + + + +github.com/cosmos/cosmos-sdk/container_test.ProvideMsgClientA + +github.com/cosmos/cosmos-sdk/container_test.ProvideMsgClientA + + + +github.com/cosmos/cosmos-sdk/container.ModuleKey->github.com/cosmos/cosmos-sdk/container_test.ProvideMsgClientA + + + + + +github.com/cosmos/cosmos-sdk/container.OwnModuleKey + +github.com/cosmos/cosmos-sdk/container.OwnModuleKey + + + +github.com/cosmos/cosmos-sdk/container.OwnModuleKey->github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide + + + + + +github.com/cosmos/cosmos-sdk/container_test.KVStoreKey->github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide + + + + + +github.com/cosmos/cosmos-sdk/container_test.KVStoreKey->github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide + + + + + +github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput + +github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput + + + +github.com/cosmos/cosmos-sdk/container_test.KeeperB->github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput + + + + + +github.com/cosmos/cosmos-sdk/container_test.MsgClientA + +github.com/cosmos/cosmos-sdk/container_test.MsgClientA + + + +github.com/cosmos/cosmos-sdk/container_test.MsgClientA->github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide + + + + + +github.com/cosmos/cosmos-sdk/container_test.ProvideMsgClientA->github.com/cosmos/cosmos-sdk/container_test.MsgClientA + + + + + diff --git a/container/testdata/example_error.dot b/container/testdata/example_error.dot new file mode 100644 index 000000000000..089a413d71e2 --- /dev/null +++ b/container/testdata/example_error.dot @@ -0,0 +1,40 @@ +digraph "" { + subgraph "cluster_a" { + graph [fontsize="12.0", label="Module: a", penwidth="0.5", style="rounded"]; + "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide"[color="lightgrey", fontcolor="dimgrey", penwidth="0.5", shape="box"]; + } + + subgraph "cluster_b" { + graph [fontsize="12.0", label="Module: b", penwidth="0.5", style="rounded"]; + "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide"[color="red", fontcolor="red", penwidth="0.5", shape="box"]; + } + + subgraph "cluster_runtime" { + graph [fontsize="12.0", label="Module: runtime", penwidth="0.5", style="rounded"]; + "github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey"[color="black", fontcolor="black", penwidth="1.5", shape="box"]; + } + + "[]github.com/cosmos/cosmos-sdk/container_test.Command"[color="lightgrey", comment="many-per-container", fontcolor="dimgrey", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container.ModuleKey"[color="black", fontcolor="black", penwidth="1.5"]; + "github.com/cosmos/cosmos-sdk/container.OwnModuleKey"[color="lightgrey", fontcolor="dimgrey", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container_test.KVStoreKey"[color="black", fontcolor="black", penwidth="1.5"]; + "github.com/cosmos/cosmos-sdk/container_test.KeeperA"[color="lightgrey", fontcolor="dimgrey", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container_test.KeeperB"[color="red", fontcolor="red", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container_test.MsgClientA"[color="red", fontcolor="red", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput"[color="red", fontcolor="red", penwidth="0.5", shape="hexagon"]; + "map[string]github.com/cosmos/cosmos-sdk/container_test.Handler"[color="lightgrey", comment="one-per-module", fontcolor="dimgrey", penwidth="0.5"]; + "github.com/cosmos/cosmos-sdk/container.ModuleKey" -> "github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey"; + "github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey" -> "github.com/cosmos/cosmos-sdk/container_test.KVStoreKey"; + "github.com/cosmos/cosmos-sdk/container_test.KVStoreKey" -> "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide"; + "github.com/cosmos/cosmos-sdk/container.OwnModuleKey" -> "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide" -> "github.com/cosmos/cosmos-sdk/container_test.KeeperA"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide" -> "map[string]github.com/cosmos/cosmos-sdk/container_test.Handler"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide" -> "[]github.com/cosmos/cosmos-sdk/container_test.Command"; + "github.com/cosmos/cosmos-sdk/container_test.KVStoreKey" -> "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide"; + "github.com/cosmos/cosmos-sdk/container_test.MsgClientA" -> "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide" -> "github.com/cosmos/cosmos-sdk/container_test.KeeperB"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide" -> "[]github.com/cosmos/cosmos-sdk/container_test.Command"; + "github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide" -> "map[string]github.com/cosmos/cosmos-sdk/container_test.Handler"; + "github.com/cosmos/cosmos-sdk/container_test.KeeperB" -> "github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput"; +} + diff --git a/container/testdata/example_error.svg b/container/testdata/example_error.svg new file mode 100644 index 000000000000..6897a23dc9da --- /dev/null +++ b/container/testdata/example_error.svg @@ -0,0 +1,179 @@ + + + + + + + + +cluster_a + +Module: a + + +cluster_b + +Module: b + + +cluster_runtime + +Module: runtime + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide + + + + +[]github.com/cosmos/cosmos-sdk/container_test.Command + +[]github.com/cosmos/cosmos-sdk/container_test.Command + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide->[]github.com/cosmos/cosmos-sdk/container_test.Command + + + + + +github.com/cosmos/cosmos-sdk/container_test.KeeperA + +github.com/cosmos/cosmos-sdk/container_test.KeeperA + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide->github.com/cosmos/cosmos-sdk/container_test.KeeperA + + + + + + +map[string]github.com/cosmos/cosmos-sdk/container_test.Handler + +map[string]github.com/cosmos/cosmos-sdk/container_test.Handler + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide->map[string]github.com/cosmos/cosmos-sdk/container_test.Handler + + + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide->[]github.com/cosmos/cosmos-sdk/container_test.Command + + + + + +github.com/cosmos/cosmos-sdk/container_test.KeeperB + +github.com/cosmos/cosmos-sdk/container_test.KeeperB + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide->github.com/cosmos/cosmos-sdk/container_test.KeeperB + + + + + +github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide->map[string]github.com/cosmos/cosmos-sdk/container_test.Handler + + + + + +github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey + +github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey + + + +github.com/cosmos/cosmos-sdk/container_test.KVStoreKey + +github.com/cosmos/cosmos-sdk/container_test.KVStoreKey + + + +github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey->github.com/cosmos/cosmos-sdk/container_test.KVStoreKey + + + + + +github.com/cosmos/cosmos-sdk/container.ModuleKey + +github.com/cosmos/cosmos-sdk/container.ModuleKey + + + +github.com/cosmos/cosmos-sdk/container.ModuleKey->github.com/cosmos/cosmos-sdk/container_test.ProvideKVStoreKey + + + + + +github.com/cosmos/cosmos-sdk/container.OwnModuleKey + +github.com/cosmos/cosmos-sdk/container.OwnModuleKey + + + +github.com/cosmos/cosmos-sdk/container.OwnModuleKey->github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide + + + + + +github.com/cosmos/cosmos-sdk/container_test.KVStoreKey->github.com/cosmos/cosmos-sdk/container_test.ModuleA.Provide + + + + + +github.com/cosmos/cosmos-sdk/container_test.KVStoreKey->github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide + + + + + +github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput + +github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput + + + +github.com/cosmos/cosmos-sdk/container_test.KeeperB->github.com/cosmos/cosmos-sdk/container_test.TestGraphAndLogOutput + + + + + +github.com/cosmos/cosmos-sdk/container_test.MsgClientA + +github.com/cosmos/cosmos-sdk/container_test.MsgClientA + + + +github.com/cosmos/cosmos-sdk/container_test.MsgClientA->github.com/cosmos/cosmos-sdk/container_test.ModuleB.Provide + + + + + diff --git a/contrib/devtools/Dockerfile b/contrib/devtools/Dockerfile index c1873ec70f1d..05bed5ac81bf 100644 --- a/contrib/devtools/Dockerfile +++ b/contrib/devtools/Dockerfile @@ -1,10 +1,10 @@ ## To test locally: # docker build --pull --rm -f "contrib/devtools/Dockerfile" -t cosmossdk-proto:latest "contrib/devtools" -# docker run -v $(pwd):/workspace --workdir /workspace cosmossdk-proto sh ./scripts/protocgen.sh +# docker run --rm -v $(pwd):/workspace --workdir /workspace cosmossdk-proto sh ./scripts/protocgen.sh FROM bufbuild/buf:1.1.0 as BUILDER -FROM golang:1.17-alpine +FROM golang:1.18-alpine RUN apk add --no-cache \ nodejs \ @@ -17,15 +17,22 @@ ENV GOLANG_PROTOBUF_VERSION=1.28.0 \ GRPC_GATEWAY_VERSION=1.16.0 -RUN GO111MODULE=on go get github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest \ - google.golang.org/protobuf/cmd/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} \ - github.com/gogo/protobuf/protoc-gen-gogo@v${GOGO_PROTOBUF_VERSION} \ - github.com/gogo/protobuf/protoc-gen-gogofast@v${GOGO_PROTOBUF_VERSION} \ - github.com/gogo/protobuf/protoc-gen-gogofaster@v${GOGO_PROTOBUF_VERSION} \ - github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION} \ - github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v${GRPC_GATEWAY_VERSION} \ - github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest +RUN go install github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest +RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} +RUN go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION} \ + github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v${GRPC_GATEWAY_VERSION} +# install all gogo protobuf binaries +RUN git clone https://github.com/regen-network/protobuf.git; \ + cd protobuf; \ + go mod download; \ + make install + +# we need to use git clone because we use 'replace' directive in go.mod +# protoc-gen-gocosmos was moved to to in cosmos/gogoproto but pending a migration there. +RUN git clone https://github.com/regen-network/cosmos-proto.git; \ + cd cosmos-proto/protoc-gen-gocosmos; \ + go install . RUN npm install -g swagger-combine diff --git a/contrib/devtools/Makefile b/contrib/devtools/Makefile index 2e3741fd852f..f8a5de4edd37 100644 --- a/contrib/devtools/Makefile +++ b/contrib/devtools/Makefile @@ -57,28 +57,20 @@ tools-stamp: statik runsim # in a row. touch $@ -# Install the runsim binary with a temporary workaround of entering an outside -# directory as the "go get" command ignores the -mod option and will polute the -# go.{mod, sum} files. -# -# ref: https://github.com/golang/go/issues/30515 +# Install the runsim binary statik: $(STATIK) $(STATIK): @echo "Installing statik..." - @(cd /tmp && go get github.com/rakyll/statik@v0.1.6) + @go install github.com/rakyll/statik@v0.1.6 -# Install the runsim binary with a temporary workaround of entering an outside -# directory as the "go get" command ignores the -mod option and will polute the -# go.{mod, sum} files. -# -# ref: https://github.com/golang/go/issues/30515 +# Install the runsim binary runsim: $(RUNSIM) $(RUNSIM): @echo "Installing runsim..." - @(cd /tmp && go get github.com/cosmos/tools/cmd/runsim@v1.0.0) + @go install github.com/cosmos/tools/cmd/runsim@v1.0.0 tools-clean: rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM) rm -f tools-stamp -.PHONY: tools-clean statik runsim +.PHONY: tools-clean statik runsim \ No newline at end of file diff --git a/contrib/images/simd-dlv/Dockerfile b/contrib/images/simd-dlv/Dockerfile index 89ebcea94a8f..e88fc4da0d9e 100644 --- a/contrib/images/simd-dlv/Dockerfile +++ b/contrib/images/simd-dlv/Dockerfile @@ -1,14 +1,19 @@ -FROM golang:1.17-alpine AS build +FROM golang:1.18-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/ COPY db/go.mod db/go.sum /work/db/ +COPY errors/go.mod errors/go.sum /work/errors/ +COPY math/go.mod math/go.sum /work/math/ + RUN go mod download COPY ./ /work RUN LEDGER_ENABLED=false make COSMOS_BUILD_OPTIONS="debug,nostrip" clean build -FROM alpine:3.14 AS run +FROM alpine AS run RUN apk add bash curl jq COPY contrib/images/simd-dlv/wrapper.sh /usr/bin/wrapper.sh @@ -20,4 +25,4 @@ WORKDIR /simd EXPOSE 26656 26657 2345 ENTRYPOINT ["/usr/bin/wrapper.sh"] CMD ["start", "--log_format", "plain"] -STOPSIGNAL SIGTERM \ No newline at end of file +STOPSIGNAL SIGTERM diff --git a/contrib/images/simd-env/Dockerfile b/contrib/images/simd-env/Dockerfile index e8bab917afb2..0d3565375837 100644 --- a/contrib/images/simd-env/Dockerfile +++ b/contrib/images/simd-env/Dockerfile @@ -1,15 +1,18 @@ -FROM golang:1.17-alpine AS build +FROM golang:1.18-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/ COPY errors/go.mod errors/go.sum /work/errors/ +COPY math/go.mod math/go.sum /work/math/ RUN go mod download COPY ./ /work RUN LEDGER_ENABLED=false make clean build -FROM alpine:3.14 AS run +FROM alpine AS run RUN apk add bash curl jq COPY contrib/images/simd-env/wrapper.sh /usr/bin/wrapper.sh diff --git a/contrib/rosetta/rosetta-ci/Dockerfile b/contrib/rosetta/rosetta-ci/Dockerfile index b6a8d9936cc5..d4cfc58528e9 100644 --- a/contrib/rosetta/rosetta-ci/Dockerfile +++ b/contrib/rosetta/rosetta-ci/Dockerfile @@ -1,6 +1,6 @@ -FROM golang:1.17-alpine as build +FROM golang:1.18-alpine as build -RUN apk add --no-cache tar +RUN apk add --no-cache tar git # prepare node data WORKDIR /node @@ -13,7 +13,7 @@ COPY . ./ RUN go build -o simd ./simapp/simd/ FROM alpine -RUN apk add gcc libc-dev python3 --no-cache +RUN apk add gcc git libc-dev python3 --no-cache ENV PATH=$PATH:/bin diff --git a/contrib/rosetta/rosetta-cli/Dockerfile b/contrib/rosetta/rosetta-cli/Dockerfile index 012be0551c31..da6ef2879239 100644 --- a/contrib/rosetta/rosetta-cli/Dockerfile +++ b/contrib/rosetta/rosetta-cli/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17-alpine as build +FROM golang:1.18-alpine as build RUN apk add git gcc libc-dev --no-cache @@ -15,4 +15,4 @@ RUN apk add gcc libc-dev python3 --no-cache ENV PATH=$PATH:/bin -COPY --from=build /rosetta/rosetta-cli /bin/rosetta-cli \ No newline at end of file +COPY --from=build /rosetta/rosetta-cli /bin/rosetta-cli diff --git a/core/Makefile b/core/Makefile new file mode 100644 index 000000000000..b8205e21f424 --- /dev/null +++ b/core/Makefile @@ -0,0 +1,2 @@ +codegen: + (cd internal; buf generate) \ No newline at end of file diff --git a/core/README.md b/core/README.md new file mode 100644 index 000000000000..647894dce659 --- /dev/null +++ b/core/README.md @@ -0,0 +1,11 @@ +# Cosmos SDK Core + +The [cosmossdk.io/core](https://pkg.go.dev/cosmossdk.io/core) go module defines +"core" functionality for the Cosmos SDK. + +Currently functionality for registering modules using the [appmodule](https://pkg.go.dev/cosmossdk.io/core/appmodule) +package and composing apps using the [appconfig](https://pkg.go.dev/cosmossdk.io/core/appconfig) +package is provided. + +In the future core functionality for building Cosmos SDK app modules will be +provided in this go module. \ No newline at end of file diff --git a/core/appconfig/config.go b/core/appconfig/config.go new file mode 100644 index 000000000000..f0894cc15cd3 --- /dev/null +++ b/core/appconfig/config.go @@ -0,0 +1,111 @@ +package appconfig + +import ( + "fmt" + "reflect" + "strings" + + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/reflect/protoregistry" + "google.golang.org/protobuf/types/known/anypb" + "sigs.k8s.io/yaml" + + "github.com/cosmos/cosmos-sdk/container" + + appv1alpha1 "github.com/cosmos/cosmos-sdk/api/cosmos/app/v1alpha1" + + "cosmossdk.io/core/internal" +) + +// LoadJSON loads an app config in JSON format. +func LoadJSON(bz []byte) container.Option { + config := &appv1alpha1.Config{} + err := protojson.Unmarshal(bz, config) + if err != nil { + return container.Error(err) + } + + return Compose(config) +} + +// LoadYAML loads an app config in YAML format. +func LoadYAML(bz []byte) container.Option { + j, err := yaml.YAMLToJSON(bz) + if err != nil { + return container.Error(err) + } + + return LoadJSON(j) +} + +// Compose composes a v1alpha1 app config into a container option by resolving +// the required modules and composing their options. +func Compose(appConfig *appv1alpha1.Config) container.Option { + opts := []container.Option{ + container.Supply(appConfig), + } + + for _, module := range appConfig.Modules { + if module.Name == "" { + return container.Error(fmt.Errorf("module is missing name")) + } + + if module.Config == nil { + return container.Error(fmt.Errorf("module %q is missing a config object", module.Name)) + } + + msgType, err := protoregistry.GlobalTypes.FindMessageByURL(module.Config.TypeUrl) + if err != nil { + return container.Error(err) + } + + modules, err := internal.ModulesByProtoMessageName() + if err != nil { + return container.Error(err) + } + + init, ok := modules[msgType.Descriptor().FullName()] + if !ok { + modDesc := proto.GetExtension(msgType.Descriptor().Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor) + if modDesc == nil { + return container.Error(fmt.Errorf("no module registered for type URL %s and that protobuf type does not have the option %s\n\n%s", + module.Config.TypeUrl, appv1alpha1.E_Module.TypeDescriptor().FullName(), dumpRegisteredModules(modules))) + } + + return container.Error(fmt.Errorf("no module registered for type URL %s, did you forget to import %s\n\n%s", + module.Config.TypeUrl, modDesc.GoImport, dumpRegisteredModules(modules))) + } + + config := init.ConfigProtoMessage.ProtoReflect().Type().New().Interface() + err = anypb.UnmarshalTo(module.Config, config, proto.UnmarshalOptions{}) + if err != nil { + + return container.Error(err) + } + + opts = append(opts, container.Provide(container.ProviderDescriptor{ + Inputs: nil, + Outputs: []container.ProviderOutput{{Type: init.ConfigGoType}}, + Fn: func(values []reflect.Value) ([]reflect.Value, error) { + return []reflect.Value{reflect.ValueOf(config)}, nil + }, + Location: container.LocationFromCaller(0), + })) + + for _, provider := range init.Providers { + opts = append(opts, container.ProvideInModule(module.Name, provider)) + } + } + + return container.Options(opts...) +} + +func dumpRegisteredModules(modules map[protoreflect.FullName]*internal.ModuleInitializer) string { + var mods []string + for name := range modules { + mods = append(mods, " "+string(name)) + } + return fmt.Sprintf("registered modules are:\n%s", strings.Join(mods, "\n")) +} diff --git a/core/appconfig/config_test.go b/core/appconfig/config_test.go new file mode 100644 index 000000000000..0f6b579cd88f --- /dev/null +++ b/core/appconfig/config_test.go @@ -0,0 +1,104 @@ +package appconfig_test + +import ( + "bytes" + "reflect" + "testing" + + "gotest.tools/v3/assert" + + "github.com/cosmos/cosmos-sdk/container" + + "cosmossdk.io/core/appconfig" + "cosmossdk.io/core/appmodule" + "cosmossdk.io/core/internal" + "cosmossdk.io/core/internal/testpb" + _ "cosmossdk.io/core/internal/testpb" +) + +func expectContainerErrorContains(t *testing.T, option container.Option, contains string) { + t.Helper() + err := container.Build(option) + assert.ErrorContains(t, err, contains) +} + +func TestCompose(t *testing.T) { + opt := appconfig.LoadJSON([]byte(`{"modules":[{}]}`)) + expectContainerErrorContains(t, opt, "module is missing name") + + opt = appconfig.LoadJSON([]byte(`{"modules":[{"name": "a"}]}`)) + expectContainerErrorContains(t, opt, `module "a" is missing a config object`) + + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": testpb.ModuleFoo +`)) + expectContainerErrorContains(t, opt, `unable to resolve`) + + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": cosmos.app.v1alpha1.Config # this is not actually a module config type! +`)) + expectContainerErrorContains(t, opt, "does not have the option cosmos.app.v1alpha1.module") + expectContainerErrorContains(t, opt, "registered modules are") + expectContainerErrorContains(t, opt, "testpb.TestModuleA") + + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": testpb.TestUnregisteredModule +`)) + expectContainerErrorContains(t, opt, "did you forget to import cosmossdk.io/core/internal/testpb") + expectContainerErrorContains(t, opt, "registered modules are") + expectContainerErrorContains(t, opt, "testpb.TestModuleA") + + var app testpb.App + opt = appconfig.LoadYAML([]byte(` +modules: +- name: runtime + config: + "@type": testpb.TestRuntimeModule +- name: a + config: + "@type": testpb.TestModuleA +- name: b + config: + "@type": testpb.TestModuleB +`)) + assert.NilError(t, container.Build(opt, &app)) + buf := &bytes.Buffer{} + app(buf) + const expected = `got store key a +got store key b +running module handler a +result: hello +running module handler b +result: goodbye +` + assert.Equal(t, expected, buf.String()) + + // module registration failures: + appmodule.Register(&testpb.TestNoModuleOptionModule{}) + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": testpb.TestNoGoImportModule +`)) + expectContainerErrorContains(t, opt, "module should have the option cosmos.app.v1alpha1.module") + + internal.ModuleRegistry = map[reflect.Type]*internal.ModuleInitializer{} // reset module registry + appmodule.Register(&testpb.TestNoGoImportModule{}) + opt = appconfig.LoadYAML([]byte(` +modules: +- name: a + config: + "@type": testpb.TestNoGoImportModule +`)) + expectContainerErrorContains(t, opt, "module should have ModuleDescriptor.go_import specified") +} diff --git a/core/appconfig/doc.go b/core/appconfig/doc.go new file mode 100644 index 000000000000..a2bf09cfb1a4 --- /dev/null +++ b/core/appconfig/doc.go @@ -0,0 +1,3 @@ +// Package appconfig defines functionality for loading declarative Cosmos SDK +// app configurations. +package appconfig diff --git a/core/appmodule/doc.go b/core/appmodule/doc.go new file mode 100644 index 000000000000..0ea54956c286 --- /dev/null +++ b/core/appmodule/doc.go @@ -0,0 +1,5 @@ +// Package appmodule defines the functionality for registering Cosmos SDK app +// modules that are assembled using the github.com/cosmos/cosmos-sdk/container +// dependency injection system and the declarative app configuration format +// handled by the appconfig package. +package appmodule diff --git a/core/appmodule/option.go b/core/appmodule/option.go new file mode 100644 index 000000000000..ad87098da3d6 --- /dev/null +++ b/core/appmodule/option.go @@ -0,0 +1,35 @@ +package appmodule + +import ( + "github.com/cosmos/cosmos-sdk/container" + + "cosmossdk.io/core/internal" +) + +// Option is a functional option for implementing modules. +type Option interface { + apply(*internal.ModuleInitializer) error +} + +type funcOption func(initializer *internal.ModuleInitializer) error + +func (f funcOption) apply(initializer *internal.ModuleInitializer) error { + return f(initializer) +} + +// Provide registers providers with the dependency injection system that will be +// run within the module scope. See github.com/cosmos/cosmos-sdk/container for +// documentation on the dependency injection system. +func Provide(providers ...interface{}) Option { + return funcOption(func(initializer *internal.ModuleInitializer) error { + for _, provider := range providers { + desc, err := container.ExtractProviderDescriptor(provider) + if err != nil { + return err + } + + initializer.Providers = append(initializer.Providers, desc) + } + return nil + }) +} diff --git a/core/appmodule/register.go b/core/appmodule/register.go new file mode 100644 index 000000000000..56004dbb863c --- /dev/null +++ b/core/appmodule/register.go @@ -0,0 +1,34 @@ +package appmodule + +import ( + "reflect" + + "google.golang.org/protobuf/proto" + + "cosmossdk.io/core/internal" +) + +// Register registers a module with the global module registry. The provided +// protobuf message is used only to uniquely identify the protobuf module config +// type. The instance of the protobuf message used in the actual configuration +// will be injected into the container and can be requested by a provider +// function. All module initialization should be handled by the provided options. +// +// Protobuf message types used for module configuration should define the +// cosmos.app.v1alpha.module option and must explicitly specify go_package +// to make debugging easier for users. +func Register(msg proto.Message, options ...Option) { + ty := reflect.TypeOf(msg) + init := &internal.ModuleInitializer{ + ConfigProtoMessage: msg, + ConfigGoType: ty, + } + internal.ModuleRegistry[ty] = init + + for _, option := range options { + init.Error = option.apply(init) + if init.Error != nil { + return + } + } +} diff --git a/core/go.mod b/core/go.mod new file mode 100644 index 000000000000..02cecf9655ee --- /dev/null +++ b/core/go.mod @@ -0,0 +1,32 @@ +module cosmossdk.io/core + +go 1.18 + +require ( + github.com/cosmos/cosmos-proto v1.0.0-alpha7 + github.com/cosmos/cosmos-sdk/api v0.1.0 + github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3 + google.golang.org/protobuf v1.28.0 + gotest.tools/v3 v3.2.0 + sigs.k8s.io/yaml v1.3.0 +) + +require ( + github.com/fogleman/gg v1.3.0 // indirect + github.com/goccy/go-graphviz v0.0.9 // indirect + github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.6 // indirect + github.com/kr/pretty v0.1.0 // indirect + github.com/pkg/errors v0.9.1 // indirect + golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect + golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect + golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/text v0.3.5 // indirect + google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect + google.golang.org/grpc v1.46.0 // indirect + gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect +) + +replace github.com/cosmos/cosmos-sdk/api => ../api diff --git a/core/go.sum b/core/go.sum new file mode 100644 index 000000000000..e5c7bcaceeba --- /dev/null +++ b/core/go.sum @@ -0,0 +1,190 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/corona10/goimagehash v1.0.2 h1:pUfB0LnsJASMPGEZLj7tGY251vF+qLGqOgEP4rUs6kA= +github.com/corona10/goimagehash v1.0.2/go.mod h1:/l9umBhvcHQXVtQO1V6Gp1yD20STawkhRnnX0D1bvVI= +github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= +github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= +github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3 h1:CC8p43RhsrtZdPOkT/Q5q8QkEGKCq3BbTr/wG/3vJ70= +github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3/go.mod h1:fd4VKEYJiPjjElIRm7xsjUFMh2ljTtooK1H/DJa0uPU= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8= +github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/goccy/go-graphviz v0.0.9 h1:s/FMMJ1Joj6La3S5ApO3Jk2cwM4LpXECC2muFx3IPQQ= +github.com/goccy/go-graphviz v0.0.9/go.mod h1:wXVsXxmyMQU6TN3zGRttjNn3h+iCAS7xQFC6TlNvLhk= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 h1:BvoENQQU+fZ9uukda/RzCAL/191HHwJA5b13R6diVlY= +github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/image v0.0.0-20200119044424-58c23975cae1 h1:5h3ngYt7+vXCDZCup/HkCQgW5XwmSvR/nA2JmJ0RErg= +golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +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= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= +golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw= +google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +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= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I= +gotest.tools/v3 v3.2.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/core/internal/buf.gen.yaml b/core/internal/buf.gen.yaml new file mode 100644 index 000000000000..f4e31b03e8ae --- /dev/null +++ b/core/internal/buf.gen.yaml @@ -0,0 +1,11 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: cosmossdk.io/core/internal + override: + buf.build/cosmos/cosmos-sdk: cosmossdk.io/api +plugins: + - name: go-pulsar + out: . + opt: paths=source_relative diff --git a/core/internal/buf.yaml b/core/internal/buf.yaml new file mode 100644 index 000000000000..ac1df238ebec --- /dev/null +++ b/core/internal/buf.yaml @@ -0,0 +1,9 @@ +version: v1 +lint: + use: + - DEFAULT + except: + - PACKAGE_VERSION_SUFFIX +breaking: + ignore: + - testpb diff --git a/core/internal/registry.go b/core/internal/registry.go new file mode 100644 index 000000000000..d56a6ed726ba --- /dev/null +++ b/core/internal/registry.go @@ -0,0 +1,59 @@ +package internal + +import ( + "fmt" + "reflect" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + + "github.com/cosmos/cosmos-sdk/container" + + appv1alpha1 "github.com/cosmos/cosmos-sdk/api/cosmos/app/v1alpha1" +) + +// ModuleRegistry is the registry of module initializers indexed by their golang +// type to avoid any issues with protobuf descriptor initialization. +var ModuleRegistry = map[reflect.Type]*ModuleInitializer{} + +// ModuleInitializer describes how to initialize a module. +type ModuleInitializer struct { + ConfigGoType reflect.Type + ConfigProtoMessage proto.Message + Error error + Providers []container.ProviderDescriptor +} + +// ModulesByProtoMessageName should be used to retrieve modules by their protobuf name. +// This is done lazily after module registration to deal with non-deterministic issues +// that can occur with respect to protobuf descriptor initialization. +func ModulesByProtoMessageName() (map[protoreflect.FullName]*ModuleInitializer, error) { + res := map[protoreflect.FullName]*ModuleInitializer{} + + for _, initializer := range ModuleRegistry { + descriptor := initializer.ConfigProtoMessage.ProtoReflect().Descriptor() + fullName := descriptor.FullName() + if _, ok := res[fullName]; ok { + return nil, fmt.Errorf("duplicate module registratio for %s", fullName) + } + + modDesc := proto.GetExtension(descriptor.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor) + if modDesc == nil { + return nil, fmt.Errorf( + "protobuf type %s registered as a module should have the option %s", + fullName, + appv1alpha1.E_Module.TypeDescriptor().FullName()) + } + + if modDesc.GoImport == "" { + return nil, fmt.Errorf( + "protobuf type %s registered as a module should have ModuleDescriptor.go_import specified", + fullName, + ) + } + + res[fullName] = initializer + } + + return res, nil +} diff --git a/core/internal/testpb/modules.go b/core/internal/testpb/modules.go new file mode 100644 index 000000000000..e87a2aab03aa --- /dev/null +++ b/core/internal/testpb/modules.go @@ -0,0 +1,99 @@ +package testpb + +import ( + "fmt" + "io" + "sort" + + "github.com/cosmos/cosmos-sdk/container" + + "cosmossdk.io/core/appmodule" +) + +func init() { + appmodule.Register(&TestRuntimeModule{}, + appmodule.Provide(provideRuntimeState, provideStoreKey, provideApp), + ) + + appmodule.Register(&TestModuleA{}, + appmodule.Provide(provideModuleA), + ) + + appmodule.Register(&TestModuleB{}, + appmodule.Provide(provideModuleB), + ) +} + +func provideRuntimeState() *runtimeState { + return &runtimeState{} +} + +func provideStoreKey(key container.ModuleKey, state *runtimeState) StoreKey { + sk := StoreKey{name: key.Name()} + state.storeKeys = append(state.storeKeys, sk) + return sk +} + +func provideApp(state *runtimeState, handlers map[string]Handler) App { + return func(w io.Writer) { + for _, key := range state.storeKeys { + _, _ = fmt.Fprintf(w, "got store key %s\n", key.name) + } + + var modNames []string + for modName := range handlers { + modNames = append(modNames, modName) + } + + sort.Strings(modNames) + for _, name := range modNames { + _, _ = fmt.Fprintf(w, "running module handler %s\n", name) + _, _ = fmt.Fprintf(w, "result: %s\n", handlers[name].DoSomething()) + } + } +} + +type App func(writer io.Writer) + +type runtimeState struct { + storeKeys []StoreKey +} + +type StoreKey struct{ name string } + +type Handler struct { + DoSomething func() string +} + +func (h Handler) IsOnePerModuleType() {} + +func provideModuleA(key StoreKey) (KeeperA, Handler) { + return keeperA{key: key}, Handler{DoSomething: func() string { + return "hello" + }} +} + +type keeperA struct { + key StoreKey +} + +type KeeperA interface { + Foo() +} + +func (k keeperA) Foo() {} + +func provideModuleB(key StoreKey, a KeeperA) (KeeperB, Handler) { + return keeperB{key: key, a: a}, Handler{ + DoSomething: func() string { + return "goodbye" + }, + } +} + +type keeperB struct { + key StoreKey + a KeeperA +} + +type KeeperB interface{} diff --git a/core/internal/testpb/test.proto b/core/internal/testpb/test.proto new file mode 100644 index 000000000000..00aa0bd6c769 --- /dev/null +++ b/core/internal/testpb/test.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; + +package testpb; + +import "cosmos/app/v1alpha1/module.proto"; + +message TestRuntimeModule { + option (cosmos.app.v1alpha1.module) = { + go_import: "cosmossdk.io/core/internal/testpb" + }; +} + +message TestModuleA { + option (cosmos.app.v1alpha1.module) = { + go_import: "cosmossdk.io/core/internal/testpb" + }; +} + +message TestModuleB { + option (cosmos.app.v1alpha1.module) = { + go_import: "cosmossdk.io/core/internal/testpb" + }; +} + +message TestUnregisteredModule { + option (cosmos.app.v1alpha1.module) = { + go_import: "cosmossdk.io/core/internal/testpb" + }; +} + +message TestNoModuleOptionModule {} + +message TestNoGoImportModule { + option (cosmos.app.v1alpha1.module) = {}; +} diff --git a/core/internal/testpb/test.pulsar.go b/core/internal/testpb/test.pulsar.go new file mode 100644 index 000000000000..7ca6f2ed7530 --- /dev/null +++ b/core/internal/testpb/test.pulsar.go @@ -0,0 +1,2483 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package testpb + +import ( + fmt "fmt" + runtime "github.com/cosmos/cosmos-proto/runtime" + _ "github.com/cosmos/cosmos-sdk/api/cosmos/app/v1alpha1" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_TestRuntimeModule protoreflect.MessageDescriptor +) + +func init() { + file_testpb_test_proto_init() + md_TestRuntimeModule = File_testpb_test_proto.Messages().ByName("TestRuntimeModule") +} + +var _ protoreflect.Message = (*fastReflection_TestRuntimeModule)(nil) + +type fastReflection_TestRuntimeModule TestRuntimeModule + +func (x *TestRuntimeModule) ProtoReflect() protoreflect.Message { + return (*fastReflection_TestRuntimeModule)(x) +} + +func (x *TestRuntimeModule) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_test_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_TestRuntimeModule_messageType fastReflection_TestRuntimeModule_messageType +var _ protoreflect.MessageType = fastReflection_TestRuntimeModule_messageType{} + +type fastReflection_TestRuntimeModule_messageType struct{} + +func (x fastReflection_TestRuntimeModule_messageType) Zero() protoreflect.Message { + return (*fastReflection_TestRuntimeModule)(nil) +} +func (x fastReflection_TestRuntimeModule_messageType) New() protoreflect.Message { + return new(fastReflection_TestRuntimeModule) +} +func (x fastReflection_TestRuntimeModule_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TestRuntimeModule +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TestRuntimeModule) Descriptor() protoreflect.MessageDescriptor { + return md_TestRuntimeModule +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_TestRuntimeModule) Type() protoreflect.MessageType { + return _fastReflection_TestRuntimeModule_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TestRuntimeModule) New() protoreflect.Message { + return new(fastReflection_TestRuntimeModule) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TestRuntimeModule) Interface() protoreflect.ProtoMessage { + return (*TestRuntimeModule)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_TestRuntimeModule) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_TestRuntimeModule) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestRuntimeModule")) + } + panic(fmt.Errorf("message testpb.TestRuntimeModule does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestRuntimeModule) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestRuntimeModule")) + } + panic(fmt.Errorf("message testpb.TestRuntimeModule does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_TestRuntimeModule) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestRuntimeModule")) + } + panic(fmt.Errorf("message testpb.TestRuntimeModule does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestRuntimeModule) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestRuntimeModule")) + } + panic(fmt.Errorf("message testpb.TestRuntimeModule does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestRuntimeModule) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestRuntimeModule")) + } + panic(fmt.Errorf("message testpb.TestRuntimeModule does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_TestRuntimeModule) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestRuntimeModule")) + } + panic(fmt.Errorf("message testpb.TestRuntimeModule does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_TestRuntimeModule) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.TestRuntimeModule", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_TestRuntimeModule) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestRuntimeModule) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_TestRuntimeModule) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_TestRuntimeModule) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TestRuntimeModule) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*TestRuntimeModule) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*TestRuntimeModule) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestRuntimeModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestRuntimeModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_TestModuleA protoreflect.MessageDescriptor +) + +func init() { + file_testpb_test_proto_init() + md_TestModuleA = File_testpb_test_proto.Messages().ByName("TestModuleA") +} + +var _ protoreflect.Message = (*fastReflection_TestModuleA)(nil) + +type fastReflection_TestModuleA TestModuleA + +func (x *TestModuleA) ProtoReflect() protoreflect.Message { + return (*fastReflection_TestModuleA)(x) +} + +func (x *TestModuleA) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_test_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_TestModuleA_messageType fastReflection_TestModuleA_messageType +var _ protoreflect.MessageType = fastReflection_TestModuleA_messageType{} + +type fastReflection_TestModuleA_messageType struct{} + +func (x fastReflection_TestModuleA_messageType) Zero() protoreflect.Message { + return (*fastReflection_TestModuleA)(nil) +} +func (x fastReflection_TestModuleA_messageType) New() protoreflect.Message { + return new(fastReflection_TestModuleA) +} +func (x fastReflection_TestModuleA_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TestModuleA +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TestModuleA) Descriptor() protoreflect.MessageDescriptor { + return md_TestModuleA +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_TestModuleA) Type() protoreflect.MessageType { + return _fastReflection_TestModuleA_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TestModuleA) New() protoreflect.Message { + return new(fastReflection_TestModuleA) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TestModuleA) Interface() protoreflect.ProtoMessage { + return (*TestModuleA)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_TestModuleA) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_TestModuleA) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleA")) + } + panic(fmt.Errorf("message testpb.TestModuleA does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestModuleA) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleA")) + } + panic(fmt.Errorf("message testpb.TestModuleA does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_TestModuleA) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleA")) + } + panic(fmt.Errorf("message testpb.TestModuleA does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestModuleA) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleA")) + } + panic(fmt.Errorf("message testpb.TestModuleA does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestModuleA) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleA")) + } + panic(fmt.Errorf("message testpb.TestModuleA does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_TestModuleA) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleA")) + } + panic(fmt.Errorf("message testpb.TestModuleA does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_TestModuleA) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.TestModuleA", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_TestModuleA) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestModuleA) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_TestModuleA) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_TestModuleA) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TestModuleA) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*TestModuleA) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*TestModuleA) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestModuleA: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestModuleA: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_TestModuleB protoreflect.MessageDescriptor +) + +func init() { + file_testpb_test_proto_init() + md_TestModuleB = File_testpb_test_proto.Messages().ByName("TestModuleB") +} + +var _ protoreflect.Message = (*fastReflection_TestModuleB)(nil) + +type fastReflection_TestModuleB TestModuleB + +func (x *TestModuleB) ProtoReflect() protoreflect.Message { + return (*fastReflection_TestModuleB)(x) +} + +func (x *TestModuleB) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_test_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_TestModuleB_messageType fastReflection_TestModuleB_messageType +var _ protoreflect.MessageType = fastReflection_TestModuleB_messageType{} + +type fastReflection_TestModuleB_messageType struct{} + +func (x fastReflection_TestModuleB_messageType) Zero() protoreflect.Message { + return (*fastReflection_TestModuleB)(nil) +} +func (x fastReflection_TestModuleB_messageType) New() protoreflect.Message { + return new(fastReflection_TestModuleB) +} +func (x fastReflection_TestModuleB_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TestModuleB +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TestModuleB) Descriptor() protoreflect.MessageDescriptor { + return md_TestModuleB +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_TestModuleB) Type() protoreflect.MessageType { + return _fastReflection_TestModuleB_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TestModuleB) New() protoreflect.Message { + return new(fastReflection_TestModuleB) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TestModuleB) Interface() protoreflect.ProtoMessage { + return (*TestModuleB)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_TestModuleB) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_TestModuleB) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleB")) + } + panic(fmt.Errorf("message testpb.TestModuleB does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestModuleB) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleB")) + } + panic(fmt.Errorf("message testpb.TestModuleB does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_TestModuleB) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleB")) + } + panic(fmt.Errorf("message testpb.TestModuleB does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestModuleB) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleB")) + } + panic(fmt.Errorf("message testpb.TestModuleB does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestModuleB) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleB")) + } + panic(fmt.Errorf("message testpb.TestModuleB does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_TestModuleB) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestModuleB")) + } + panic(fmt.Errorf("message testpb.TestModuleB does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_TestModuleB) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.TestModuleB", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_TestModuleB) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestModuleB) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_TestModuleB) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_TestModuleB) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TestModuleB) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*TestModuleB) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*TestModuleB) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestModuleB: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestModuleB: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_TestUnregisteredModule protoreflect.MessageDescriptor +) + +func init() { + file_testpb_test_proto_init() + md_TestUnregisteredModule = File_testpb_test_proto.Messages().ByName("TestUnregisteredModule") +} + +var _ protoreflect.Message = (*fastReflection_TestUnregisteredModule)(nil) + +type fastReflection_TestUnregisteredModule TestUnregisteredModule + +func (x *TestUnregisteredModule) ProtoReflect() protoreflect.Message { + return (*fastReflection_TestUnregisteredModule)(x) +} + +func (x *TestUnregisteredModule) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_test_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_TestUnregisteredModule_messageType fastReflection_TestUnregisteredModule_messageType +var _ protoreflect.MessageType = fastReflection_TestUnregisteredModule_messageType{} + +type fastReflection_TestUnregisteredModule_messageType struct{} + +func (x fastReflection_TestUnregisteredModule_messageType) Zero() protoreflect.Message { + return (*fastReflection_TestUnregisteredModule)(nil) +} +func (x fastReflection_TestUnregisteredModule_messageType) New() protoreflect.Message { + return new(fastReflection_TestUnregisteredModule) +} +func (x fastReflection_TestUnregisteredModule_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TestUnregisteredModule +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TestUnregisteredModule) Descriptor() protoreflect.MessageDescriptor { + return md_TestUnregisteredModule +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_TestUnregisteredModule) Type() protoreflect.MessageType { + return _fastReflection_TestUnregisteredModule_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TestUnregisteredModule) New() protoreflect.Message { + return new(fastReflection_TestUnregisteredModule) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TestUnregisteredModule) Interface() protoreflect.ProtoMessage { + return (*TestUnregisteredModule)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_TestUnregisteredModule) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_TestUnregisteredModule) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestUnregisteredModule")) + } + panic(fmt.Errorf("message testpb.TestUnregisteredModule does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestUnregisteredModule) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestUnregisteredModule")) + } + panic(fmt.Errorf("message testpb.TestUnregisteredModule does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_TestUnregisteredModule) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestUnregisteredModule")) + } + panic(fmt.Errorf("message testpb.TestUnregisteredModule does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestUnregisteredModule) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestUnregisteredModule")) + } + panic(fmt.Errorf("message testpb.TestUnregisteredModule does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestUnregisteredModule) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestUnregisteredModule")) + } + panic(fmt.Errorf("message testpb.TestUnregisteredModule does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_TestUnregisteredModule) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestUnregisteredModule")) + } + panic(fmt.Errorf("message testpb.TestUnregisteredModule does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_TestUnregisteredModule) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.TestUnregisteredModule", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_TestUnregisteredModule) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestUnregisteredModule) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_TestUnregisteredModule) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_TestUnregisteredModule) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TestUnregisteredModule) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*TestUnregisteredModule) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*TestUnregisteredModule) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestUnregisteredModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestUnregisteredModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_TestNoModuleOptionModule protoreflect.MessageDescriptor +) + +func init() { + file_testpb_test_proto_init() + md_TestNoModuleOptionModule = File_testpb_test_proto.Messages().ByName("TestNoModuleOptionModule") +} + +var _ protoreflect.Message = (*fastReflection_TestNoModuleOptionModule)(nil) + +type fastReflection_TestNoModuleOptionModule TestNoModuleOptionModule + +func (x *TestNoModuleOptionModule) ProtoReflect() protoreflect.Message { + return (*fastReflection_TestNoModuleOptionModule)(x) +} + +func (x *TestNoModuleOptionModule) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_test_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_TestNoModuleOptionModule_messageType fastReflection_TestNoModuleOptionModule_messageType +var _ protoreflect.MessageType = fastReflection_TestNoModuleOptionModule_messageType{} + +type fastReflection_TestNoModuleOptionModule_messageType struct{} + +func (x fastReflection_TestNoModuleOptionModule_messageType) Zero() protoreflect.Message { + return (*fastReflection_TestNoModuleOptionModule)(nil) +} +func (x fastReflection_TestNoModuleOptionModule_messageType) New() protoreflect.Message { + return new(fastReflection_TestNoModuleOptionModule) +} +func (x fastReflection_TestNoModuleOptionModule_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TestNoModuleOptionModule +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TestNoModuleOptionModule) Descriptor() protoreflect.MessageDescriptor { + return md_TestNoModuleOptionModule +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_TestNoModuleOptionModule) Type() protoreflect.MessageType { + return _fastReflection_TestNoModuleOptionModule_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TestNoModuleOptionModule) New() protoreflect.Message { + return new(fastReflection_TestNoModuleOptionModule) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TestNoModuleOptionModule) Interface() protoreflect.ProtoMessage { + return (*TestNoModuleOptionModule)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_TestNoModuleOptionModule) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_TestNoModuleOptionModule) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoModuleOptionModule")) + } + panic(fmt.Errorf("message testpb.TestNoModuleOptionModule does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestNoModuleOptionModule) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoModuleOptionModule")) + } + panic(fmt.Errorf("message testpb.TestNoModuleOptionModule does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_TestNoModuleOptionModule) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoModuleOptionModule")) + } + panic(fmt.Errorf("message testpb.TestNoModuleOptionModule does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestNoModuleOptionModule) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoModuleOptionModule")) + } + panic(fmt.Errorf("message testpb.TestNoModuleOptionModule does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestNoModuleOptionModule) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoModuleOptionModule")) + } + panic(fmt.Errorf("message testpb.TestNoModuleOptionModule does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_TestNoModuleOptionModule) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoModuleOptionModule")) + } + panic(fmt.Errorf("message testpb.TestNoModuleOptionModule does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_TestNoModuleOptionModule) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.TestNoModuleOptionModule", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_TestNoModuleOptionModule) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestNoModuleOptionModule) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_TestNoModuleOptionModule) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_TestNoModuleOptionModule) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TestNoModuleOptionModule) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*TestNoModuleOptionModule) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*TestNoModuleOptionModule) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestNoModuleOptionModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestNoModuleOptionModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_TestNoGoImportModule protoreflect.MessageDescriptor +) + +func init() { + file_testpb_test_proto_init() + md_TestNoGoImportModule = File_testpb_test_proto.Messages().ByName("TestNoGoImportModule") +} + +var _ protoreflect.Message = (*fastReflection_TestNoGoImportModule)(nil) + +type fastReflection_TestNoGoImportModule TestNoGoImportModule + +func (x *TestNoGoImportModule) ProtoReflect() protoreflect.Message { + return (*fastReflection_TestNoGoImportModule)(x) +} + +func (x *TestNoGoImportModule) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_test_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_TestNoGoImportModule_messageType fastReflection_TestNoGoImportModule_messageType +var _ protoreflect.MessageType = fastReflection_TestNoGoImportModule_messageType{} + +type fastReflection_TestNoGoImportModule_messageType struct{} + +func (x fastReflection_TestNoGoImportModule_messageType) Zero() protoreflect.Message { + return (*fastReflection_TestNoGoImportModule)(nil) +} +func (x fastReflection_TestNoGoImportModule_messageType) New() protoreflect.Message { + return new(fastReflection_TestNoGoImportModule) +} +func (x fastReflection_TestNoGoImportModule_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TestNoGoImportModule +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TestNoGoImportModule) Descriptor() protoreflect.MessageDescriptor { + return md_TestNoGoImportModule +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_TestNoGoImportModule) Type() protoreflect.MessageType { + return _fastReflection_TestNoGoImportModule_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TestNoGoImportModule) New() protoreflect.Message { + return new(fastReflection_TestNoGoImportModule) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TestNoGoImportModule) Interface() protoreflect.ProtoMessage { + return (*TestNoGoImportModule)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_TestNoGoImportModule) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_TestNoGoImportModule) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoGoImportModule")) + } + panic(fmt.Errorf("message testpb.TestNoGoImportModule does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestNoGoImportModule) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoGoImportModule")) + } + panic(fmt.Errorf("message testpb.TestNoGoImportModule does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_TestNoGoImportModule) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoGoImportModule")) + } + panic(fmt.Errorf("message testpb.TestNoGoImportModule does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestNoGoImportModule) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoGoImportModule")) + } + panic(fmt.Errorf("message testpb.TestNoGoImportModule does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestNoGoImportModule) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoGoImportModule")) + } + panic(fmt.Errorf("message testpb.TestNoGoImportModule does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_TestNoGoImportModule) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.TestNoGoImportModule")) + } + panic(fmt.Errorf("message testpb.TestNoGoImportModule does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_TestNoGoImportModule) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.TestNoGoImportModule", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_TestNoGoImportModule) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TestNoGoImportModule) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_TestNoGoImportModule) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_TestNoGoImportModule) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TestNoGoImportModule) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*TestNoGoImportModule) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*TestNoGoImportModule) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestNoGoImportModule: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TestNoGoImportModule: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: testpb/test.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type TestRuntimeModule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TestRuntimeModule) Reset() { + *x = TestRuntimeModule{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestRuntimeModule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestRuntimeModule) ProtoMessage() {} + +// Deprecated: Use TestRuntimeModule.ProtoReflect.Descriptor instead. +func (*TestRuntimeModule) Descriptor() ([]byte, []int) { + return file_testpb_test_proto_rawDescGZIP(), []int{0} +} + +type TestModuleA struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TestModuleA) Reset() { + *x = TestModuleA{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_test_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestModuleA) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestModuleA) ProtoMessage() {} + +// Deprecated: Use TestModuleA.ProtoReflect.Descriptor instead. +func (*TestModuleA) Descriptor() ([]byte, []int) { + return file_testpb_test_proto_rawDescGZIP(), []int{1} +} + +type TestModuleB struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TestModuleB) Reset() { + *x = TestModuleB{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_test_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestModuleB) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestModuleB) ProtoMessage() {} + +// Deprecated: Use TestModuleB.ProtoReflect.Descriptor instead. +func (*TestModuleB) Descriptor() ([]byte, []int) { + return file_testpb_test_proto_rawDescGZIP(), []int{2} +} + +type TestUnregisteredModule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TestUnregisteredModule) Reset() { + *x = TestUnregisteredModule{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_test_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestUnregisteredModule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestUnregisteredModule) ProtoMessage() {} + +// Deprecated: Use TestUnregisteredModule.ProtoReflect.Descriptor instead. +func (*TestUnregisteredModule) Descriptor() ([]byte, []int) { + return file_testpb_test_proto_rawDescGZIP(), []int{3} +} + +type TestNoModuleOptionModule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TestNoModuleOptionModule) Reset() { + *x = TestNoModuleOptionModule{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_test_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestNoModuleOptionModule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestNoModuleOptionModule) ProtoMessage() {} + +// Deprecated: Use TestNoModuleOptionModule.ProtoReflect.Descriptor instead. +func (*TestNoModuleOptionModule) Descriptor() ([]byte, []int) { + return file_testpb_test_proto_rawDescGZIP(), []int{4} +} + +type TestNoGoImportModule struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *TestNoGoImportModule) Reset() { + *x = TestNoGoImportModule{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_test_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestNoGoImportModule) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestNoGoImportModule) ProtoMessage() {} + +// Deprecated: Use TestNoGoImportModule.ProtoReflect.Descriptor instead. +func (*TestNoGoImportModule) Descriptor() ([]byte, []int) { + return file_testpb_test_proto_rawDescGZIP(), []int{5} +} + +var File_testpb_test_proto protoreflect.FileDescriptor + +var file_testpb_test_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x1a, 0x20, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, + 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x3e, 0x0a, + 0x11, 0x54, 0x65, 0x73, 0x74, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x3a, 0x29, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x23, 0x0a, 0x21, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x22, 0x38, 0x0a, + 0x0b, 0x54, 0x65, 0x73, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x41, 0x3a, 0x29, 0xba, 0xc0, + 0x96, 0xda, 0x01, 0x23, 0x0a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, + 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x22, 0x38, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x4d, + 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x42, 0x3a, 0x29, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x23, 0x0a, 0x21, + 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x72, + 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, + 0x62, 0x22, 0x43, 0x0a, 0x16, 0x54, 0x65, 0x73, 0x74, 0x55, 0x6e, 0x72, 0x65, 0x67, 0x69, 0x73, + 0x74, 0x65, 0x72, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x29, 0xba, 0xc0, 0x96, + 0xda, 0x01, 0x23, 0x0a, 0x21, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, + 0x6f, 0x2f, 0x63, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, + 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0x22, 0x1a, 0x0a, 0x18, 0x54, 0x65, 0x73, 0x74, 0x4e, 0x6f, + 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x6f, 0x64, 0x75, + 0x6c, 0x65, 0x22, 0x1e, 0x0a, 0x14, 0x54, 0x65, 0x73, 0x74, 0x4e, 0x6f, 0x47, 0x6f, 0x49, 0x6d, + 0x70, 0x6f, 0x72, 0x74, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x06, 0xba, 0xc0, 0x96, 0xda, + 0x01, 0x00, 0x42, 0x72, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, + 0x42, 0x09, 0x54, 0x65, 0x73, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x21, 0x63, + 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x72, 0x65, + 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, + 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xca, + 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xe2, 0x02, 0x12, 0x54, 0x65, 0x73, 0x74, 0x70, + 0x62, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x06, + 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_testpb_test_proto_rawDescOnce sync.Once + file_testpb_test_proto_rawDescData = file_testpb_test_proto_rawDesc +) + +func file_testpb_test_proto_rawDescGZIP() []byte { + file_testpb_test_proto_rawDescOnce.Do(func() { + file_testpb_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_testpb_test_proto_rawDescData) + }) + return file_testpb_test_proto_rawDescData +} + +var file_testpb_test_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_testpb_test_proto_goTypes = []interface{}{ + (*TestRuntimeModule)(nil), // 0: testpb.TestRuntimeModule + (*TestModuleA)(nil), // 1: testpb.TestModuleA + (*TestModuleB)(nil), // 2: testpb.TestModuleB + (*TestUnregisteredModule)(nil), // 3: testpb.TestUnregisteredModule + (*TestNoModuleOptionModule)(nil), // 4: testpb.TestNoModuleOptionModule + (*TestNoGoImportModule)(nil), // 5: testpb.TestNoGoImportModule +} +var file_testpb_test_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_testpb_test_proto_init() } +func file_testpb_test_proto_init() { + if File_testpb_test_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_testpb_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestRuntimeModule); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testpb_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestModuleA); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testpb_test_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestModuleB); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testpb_test_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestUnregisteredModule); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testpb_test_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestNoModuleOptionModule); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testpb_test_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestNoGoImportModule); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_testpb_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 6, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_testpb_test_proto_goTypes, + DependencyIndexes: file_testpb_test_proto_depIdxs, + MessageInfos: file_testpb_test_proto_msgTypes, + }.Build() + File_testpb_test_proto = out.File + file_testpb_test_proto_rawDesc = nil + file_testpb_test_proto_goTypes = nil + file_testpb_test_proto_depIdxs = nil +} diff --git a/cosmovisor/CHANGELOG.md b/cosmovisor/CHANGELOG.md index 5eb4e921ba5b..60be65797106 100644 --- a/cosmovisor/CHANGELOG.md +++ b/cosmovisor/CHANGELOG.md @@ -37,6 +37,11 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Features + +* [\#11823](https://github.com/cosmos/cosmos-sdk/pull/11823) Refactor `cosmovisor` CLI to use `cobra`. +* [\#11731](https://github.com/cosmos/cosmos-sdk/pull/11731) `cosmovisor version -o json` returns the cosmovisor version and the result of `simd --output json --long` in one JSON object. + ## v1.1.0 2022-10-02 ### Features diff --git a/cosmovisor/README.md b/cosmovisor/README.md index bf5d00933b9d..29dc3d000b6b 100644 --- a/cosmovisor/README.md +++ b/cosmovisor/README.md @@ -37,7 +37,7 @@ To install a previous version, you can specify the version. IMPORTANT: Chains th go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v0.1.0 ``` -You can run `cosmovisor --version` to check the Cosmovisor version (works only with Cosmovisor >=1.0.0). +You can run `cosmovisor version` to check the Cosmovisor version (works only with Cosmovisor >1.1.0). You can also install from source by pulling the cosmos-sdk repository and switching to the correct version and building as follows: @@ -62,7 +62,7 @@ The first argument passed to `cosmovisor` is the action for `cosmovisor` to take * `help`, `--help`, or `-h` - Output `cosmovisor` help information and check your `cosmovisor` configuration. * `run` - Run the configured binary using the rest of the provided arguments. -* `version`, or `--version` - Output the `cosmovisor` version and also run the binary with the `version` argument. +* `version` - Output the `cosmovisor` version and also run the binary with the `version` argument. All arguments passed to `cosmovisor run` will be passed to the application binary (as a subprocess). `cosmovisor` will return `/dev/stdout` and `/dev/stderr` of the subprocess as its own. For this reason, `cosmovisor run` cannot accept any command-line arguments other than those available to the application binary. @@ -209,7 +209,6 @@ You can also use `sha512sum` if you would prefer to use longer hashes, or `md5su The following instructions provide a demonstration of `cosmovisor` using the simulation application (`simapp`) shipped with the Cosmos SDK's source code. The following commands are to be run from within the `cosmos-sdk` repository. - ### Chain Setup Let's create a new chain using the `v0.44` version of simapp (the Cosmos SDK demo app): @@ -234,7 +233,7 @@ Set up app config: ``` Initialize the node and overwrite any previous genesis file (never do this in a production environment): - + ```sh @@ -289,17 +288,15 @@ cp ./build/simd $DAEMON_HOME/cosmovisor/genesis/bin Now you can run cosmovisor with simapp v0.44: - ```sh cosmovisor run start ``` - #### Update App Update app to the latest version (e.g. v0.45). -Next, we can add a migration - which is defined using `x/upgrade` [upgrade plan](https://github.com/cosmos/cosmos-sdk/blob/master/docs/core/upgrade.md) (you may refer to a past version if you are using an older Cosmos SDK release). In a migration we can do any deterministic state change. +Next, we can add a migration - which is defined using `x/upgrade` [upgrade plan](https://github.com/cosmos/cosmos-sdk/blob/main/docs/core/upgrade.md) (you may refer to a past version if you are using an older Cosmos SDK release). In a migration we can do any deterministic state change. Build the new version `simd` binary: @@ -314,7 +311,6 @@ mkdir -p $DAEMON_HOME/cosmovisor/upgrades/test1/bin cp ./build/simd $DAEMON_HOME/cosmovisor/upgrades/test1/bin ``` - Open a new terminal window and submit an upgrade proposal along with a deposit and a vote (these commands must be run within 20 seconds of each other): ```sh diff --git a/cosmovisor/RELEASE_NOTES.md b/cosmovisor/RELEASE_NOTES.md index 95e1ddf9538f..ecec04998123 100644 --- a/cosmovisor/RELEASE_NOTES.md +++ b/cosmovisor/RELEASE_NOTES.md @@ -17,7 +17,7 @@ The existing way of starting an app with Cosmovisor has been deprecated (`cosmov ### New Features -We added a new configuration option: `DAEMON_BACKUP_DIR` (as env variable). When set, Cosmovisor will create backup the app data backup in that directory (instead of using the app home directory) before running the update. See the [README](https://github.com/cosmos/cosmos-sdk/blob/master/cosmovisor/README.md#command-line-arguments-and-environment-variables) file for more details. +We added a new configuration option: `DAEMON_BACKUP_DIR` (as env variable). When set, Cosmovisor will create backup the app data backup in that directory (instead of using the app home directory) before running the update. See the [README](https://github.com/cosmos/cosmos-sdk/blob/main/cosmovisor/README.md#command-line-arguments-and-environment-variables) file for more details. ### Bug Fixes diff --git a/cosmovisor/args.go b/cosmovisor/args.go index f3643cdbdbf6..c9a0d36a9279 100644 --- a/cosmovisor/args.go +++ b/cosmovisor/args.go @@ -11,11 +11,10 @@ import ( "strings" "time" - "github.com/rs/zerolog" - cverrors "github.com/cosmos/cosmos-sdk/cosmovisor/errors" upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/rs/zerolog" ) // environment variable names @@ -184,11 +183,11 @@ func GetConfigFromEnv() (*Config, error) { } // LogConfigOrError logs either the config details or the error. -func LogConfigOrError(logger zerolog.Logger, cfg *Config, err error) { +func LogConfigOrError(logger *zerolog.Logger, cfg *Config, err error) { if cfg == nil && err == nil { return } - logger.Info().Msg("Configuration:") + logger.Info().Msg("configuration:") switch { case err != nil: cverrors.LogErrors(logger, "configuration errors found", err) @@ -227,9 +226,9 @@ func (cfg *Config) validate() []error { // if UnsafeSkipBackup is false, check if the DataBackupPath valid switch { case cfg.DataBackupPath == "": - errs = append(errs, errors.New(EnvDataBackupPath + " must not be empty")) + errs = append(errs, fmt.Errorf("%s must not be empty", EnvDataBackupPath)) case !filepath.IsAbs(cfg.DataBackupPath): - errs = append(errs, errors.New(cfg.DataBackupPath + " must be an absolute path")) + errs = append(errs, fmt.Errorf("%s must be an absolute path", cfg.DataBackupPath)) default: switch info, err := os.Stat(cfg.DataBackupPath); { case err != nil: @@ -281,9 +280,9 @@ func (cfg *Config) SetCurrentUpgrade(u upgradetypes.Plan) error { return f.Close() } -func (cfg *Config) UpgradeInfo() upgradetypes.Plan { +func (cfg *Config) UpgradeInfo() (upgradetypes.Plan, error) { if cfg.currentUpgrade.Name != "" { - return cfg.currentUpgrade + return cfg.currentUpgrade, nil } filename := filepath.Join(cfg.Root(), currentLink, upgradekeeper.UpgradeInfoFileName) @@ -300,12 +299,11 @@ func (cfg *Config) UpgradeInfo() upgradetypes.Plan { goto returnError } cfg.currentUpgrade = u - return cfg.currentUpgrade + return cfg.currentUpgrade, nil returnError: - Logger.Error().Err(err).Str("filename", filename).Msg("failed to read") cfg.currentUpgrade.Name = "_" - return cfg.currentUpgrade + return cfg.currentUpgrade, fmt.Errorf("failed to read %q: %w", filename, err) } // checks and validates env option diff --git a/cosmovisor/args_test.go b/cosmovisor/args_test.go index 67226df6dc7b..136440a63251 100644 --- a/cosmovisor/args_test.go +++ b/cosmovisor/args_test.go @@ -570,9 +570,10 @@ func (s *argsTestSuite) TestLogConfigOrError() { } errMulti := errors.FlattenErrors(errs...) - makeTestLogger := func(testName string, out io.Writer) zerolog.Logger { + makeTestLogger := func(testName string, out io.Writer) *zerolog.Logger { output := zerolog.ConsoleWriter{Out: out, TimeFormat: time.Kitchen, NoColor: true} - return zerolog.New(output).With().Str("test", testName).Timestamp().Logger() + logger := zerolog.New(output).With().Str("test", testName).Timestamp().Logger() + return &logger } tests := []struct { diff --git a/cosmovisor/cmd/cosmovisor/cmd/help.go b/cosmovisor/cmd/cosmovisor/cmd/help.go deleted file mode 100644 index e25df4ee3671..000000000000 --- a/cosmovisor/cmd/cosmovisor/cmd/help.go +++ /dev/null @@ -1,47 +0,0 @@ -package cmd - -import ( - "fmt" - - "github.com/cosmos/cosmos-sdk/cosmovisor" -) - -// HelpArgs are the strings that indicate a cosmovisor help command. -var HelpArgs = []string{"help", "--help", "-h"} - -// ShouldGiveHelp checks the env and provided args to see if help is needed or being requested. -// Help is needed if either cosmovisor.EnvName and/or cosmovisor.EnvHome env vars aren't set. -// Help is requested if the first arg is "help", "--help", or "-h". -func ShouldGiveHelp(arg string) bool { - return isOneOf(arg, HelpArgs) -} - -// DoHelp outputs help text -func DoHelp() { - // Not using the logger for this output because the header and footer look weird for help text. - fmt.Println(GetHelpText()) -} - -// GetHelpText creates the help text multi-line string. -func GetHelpText() string { - return fmt.Sprintf(`Cosmosvisor - A process manager for Cosmos SDK application binaries. - -Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required %s env variable). -It starts the App by passing all provided arguments and monitors the %s/data/upgrade-info.json -file to perform an update. The upgrade-info.json file is created by the App x/upgrade module -when the blockchain height reaches an approved upgrade proposal. The file includes data from -the proposal. Cosmovisor interprets that data to perform an update: switch a current binary -and restart the App. - -Configuration of Cosmovisor is done through environment variables, which are -documented in: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md - -To get help for the configured binary: - cosmovisor run help - -Available Commands: - help This help message - run Runs app passing all subsequent parameters - version Prints version of cosmovisor and the associated app. -`, cosmovisor.EnvName, cosmovisor.EnvHome) -} diff --git a/cosmovisor/cmd/cosmovisor/cmd/root.go b/cosmovisor/cmd/cosmovisor/cmd/root.go deleted file mode 100644 index 2b1921ca5657..000000000000 --- a/cosmovisor/cmd/cosmovisor/cmd/root.go +++ /dev/null @@ -1,40 +0,0 @@ -package cmd - -import ( - "strings" - - "github.com/cosmos/cosmos-sdk/cosmovisor" -) - -// RunCosmovisorCommand executes the desired cosmovisor command. -func RunCosmovisorCommand(args []string) error { - arg0 := "" - if len(args) > 0 { - arg0 = strings.TrimSpace(args[0]) - } - switch { - case IsVersionCommand(arg0): - return PrintVersion() - case ShouldGiveHelp(arg0): - DoHelp() - return nil - case IsRunCommand(arg0): - return Run(args[1:]) - } - warnRun := func() { - cosmovisor.Logger.Warn().Msg("Use of cosmovisor without the 'run' command is deprecated. Use: cosmovisor run [args]") - } - warnRun() - defer warnRun() - return Run(args) -} - -// isOneOf returns true if the given arg equals one of the provided options (ignoring case). -func isOneOf(arg string, options []string) bool { - for _, opt := range options { - if strings.EqualFold(arg, opt) { - return true - } - } - return false -} diff --git a/cosmovisor/cmd/cosmovisor/cmd/run.go b/cosmovisor/cmd/cosmovisor/cmd/run.go deleted file mode 100644 index 8912e1a9775f..000000000000 --- a/cosmovisor/cmd/cosmovisor/cmd/run.go +++ /dev/null @@ -1,39 +0,0 @@ -package cmd - -import ( - "os" - - "github.com/cosmos/cosmos-sdk/cosmovisor" -) - -// RunArgs are the strings that indicate a cosmovisor run command. -var RunArgs = []string{"run"} - -// IsRunCommand checks if the given args indicate that a run is desired. -func IsRunCommand(arg string) bool { - return isOneOf(arg, RunArgs) -} - -// Run runs the configured program with the given args and monitors it for upgrades. -func Run(args []string) error { - cfg, err := cosmovisor.GetConfigFromEnv() - if err != nil { - return err - } - launcher, err := cosmovisor.NewLauncher(cfg) - if err != nil { - return err - } - - doUpgrade, err := launcher.Run(args, os.Stdout, os.Stderr) - // if RestartAfterUpgrade, we launch after a successful upgrade (only condition LaunchProcess returns nil) - for cfg.RestartAfterUpgrade && err == nil && doUpgrade { - cosmovisor.Logger.Info().Str("app", cfg.Name).Msg("upgrade detected, relaunching") - doUpgrade, err = launcher.Run(args, os.Stdout, os.Stderr) - } - if doUpgrade && err == nil { - cosmovisor.Logger.Info().Msg("upgrade detected, DAEMON_RESTART_AFTER_UPGRADE is off. Verify new upgrade and start cosmovisor again.") - } - - return err -} diff --git a/cosmovisor/cmd/cosmovisor/cmd/run_test.go b/cosmovisor/cmd/cosmovisor/cmd/run_test.go deleted file mode 100644 index b54b38fd8fcd..000000000000 --- a/cosmovisor/cmd/cosmovisor/cmd/run_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package cmd - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestIsRunCommand(t *testing.T) { - cases := []struct { - name string - arg string - expected bool - }{ - { - name: "empty string", - arg: "", - expected: false, - }, - { - name: "random", - arg: "random", - expected: false, - }, - { - name: "run", - arg: "run", - expected: true, - }, - { - name: "run weird casing", - arg: "RUn", - expected: true, - }, - { - name: "--run", - arg: "--run", - expected: false, - }, - { - name: "help", - arg: "help", - expected: false, - }, - { - name: "-h", - arg: "-h", - expected: false, - }, - { - name: "--help", - arg: "--help", - expected: false, - }, - { - name: "version", - arg: "version", - expected: false, - }, - { - name: "--version", - arg: "--version", - expected: false, - }, - } - - for _, tc := range cases { - t.Run(fmt.Sprintf("%s - %t", tc.name, tc.expected), func(t *testing.T) { - actual := IsRunCommand(tc.arg) - require.Equal(t, tc.expected, actual) - }) - } -} - -// TODO: Write tests for func Run(args []string) error diff --git a/cosmovisor/cmd/cosmovisor/cmd/version.go b/cosmovisor/cmd/cosmovisor/cmd/version.go deleted file mode 100644 index 8f7e68f940fa..000000000000 --- a/cosmovisor/cmd/cosmovisor/cmd/version.go +++ /dev/null @@ -1,36 +0,0 @@ -package cmd - -import ( - "fmt" - "os" - "time" - - cverrors "github.com/cosmos/cosmos-sdk/cosmovisor/errors" - "github.com/rs/zerolog" -) - -// Version represents Cosmovisor version value. Overwritten during build -var Version = "1.1.0" - -// VersionArgs is the strings that indicate a cosmovisor version command. -var VersionArgs = []string{"version", "--version"} - -// IsVersionCommand checks if the given args indicate that the version is being requested. -func IsVersionCommand(arg string) bool { - return isOneOf(arg, VersionArgs) -} - -// PrintVersion prints the cosmovisor version. -func PrintVersion() error { - fmt.Println("Cosmovisor Version: ", Version) - - if err := Run([]string{"version"}); err != nil { - // Check the config and output details or any errors. - // Not using the cosmovisor.Logger in order to ignore any level it might have set, - // and also to not have any of the extra parameters in the output. - output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.Kitchen} - logger := zerolog.New(output).With().Timestamp().Logger() - cverrors.LogErrors(logger, "Can't run APP version", err) - } - return nil -} diff --git a/cosmovisor/cmd/cosmovisor/cmd/version_test.go b/cosmovisor/cmd/cosmovisor/cmd/version_test.go deleted file mode 100644 index 6c842494e85f..000000000000 --- a/cosmovisor/cmd/cosmovisor/cmd/version_test.go +++ /dev/null @@ -1,85 +0,0 @@ -package cmd - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/require" -) - -func TestIsVersionCommand(t *testing.T) { - cases := []struct { - name string - arg string - expected bool - }{ - { - name: "empty string", - arg: "", - expected: false, - }, - { - name: "random", - arg: "random", - expected: false, - }, - { - name: "version", - arg: "version", - expected: true, - }, - { - name: "--version", - arg: "--version", - expected: true, - }, - { - name: "version weird casing", - arg: "veRSiOn", - expected: true, - }, - { - // -v should be reserved for verbose, and should not be used for --version. - name: "-v", - arg: "-v", - expected: false, - }, - { - name: "typo", - arg: "vrsion", - expected: false, - }, - { - name: "non version command", - arg: "start", - expected: false, - }, - { - name: "help", - arg: "help", - expected: false, - }, - { - name: "-h", - arg: "-h", - expected: false, - }, - { - name: "--help", - arg: "--help", - expected: false, - }, - { - name: "run", - arg: "run", - expected: false, - }, - } - - for _, tc := range cases { - t.Run(fmt.Sprintf("%s - %t", tc.name, tc.expected), func(t *testing.T) { - actual := IsVersionCommand(tc.arg) - require.Equal(t, tc.expected, actual) - }) - } -} diff --git a/cosmovisor/cmd/cosmovisor/help.go b/cosmovisor/cmd/cosmovisor/help.go new file mode 100644 index 000000000000..25f2ca6c17b4 --- /dev/null +++ b/cosmovisor/cmd/cosmovisor/help.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/cosmovisor" +) + +// GetHelpText creates the help text multi-line string. +func GetHelpText() string { + return fmt.Sprintf(`Cosmosvisor - A process manager for Cosmos SDK application binaries. + +Cosmovisor is a wrapper for a Cosmos SDK based App (set using the required %s env variable). +It starts the App by passing all provided arguments and monitors the %s/data/upgrade-info.json +file to perform an update. The upgrade-info.json file is created by the App x/upgrade module +when the blockchain height reaches an approved upgrade proposal. The file includes data from +the proposal. Cosmovisor interprets that data to perform an update: switch a current binary +and restart the App. + +Configuration of Cosmovisor is done through environment variables, which are +documented in: https://github.com/cosmos/cosmos-sdk/tree/main/cosmovisor/README.md`, + cosmovisor.EnvName, cosmovisor.EnvHome, + ) +} diff --git a/cosmovisor/cmd/cosmovisor/cmd/help_test.go b/cosmovisor/cmd/cosmovisor/help_test.go similarity index 66% rename from cosmovisor/cmd/cosmovisor/cmd/help_test.go rename to cosmovisor/cmd/cosmovisor/help_test.go index ebcc252d5701..102dd798ab91 100644 --- a/cosmovisor/cmd/cosmovisor/cmd/help_test.go +++ b/cosmovisor/cmd/cosmovisor/help_test.go @@ -1,11 +1,10 @@ -package cmd +package main import ( "fmt" "os" "testing" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -88,77 +87,11 @@ func (s *HelpTestSuite) setEnv(t *testing.T, env *cosmovisorHelpEnv) { } } -func (s HelpTestSuite) TestShouldGiveHelpArg() { - initialEnv := s.clearEnv() - defer s.setEnv(nil, initialEnv) - - s.setEnv(s.T(), &cosmovisorHelpEnv{"/testhome", "testname"}) - - tests := []struct { - name string - arg string - expected bool - }{ - { - name: "empty string", - arg: "", - expected: false, - }, - { - name: "random", - arg: "random", - expected: false, - }, - { - name: "help", - arg: "help", - expected: true, - }, - { - name: "-h", - arg: "-h", - expected: true, - }, - { - name: "--help", - arg: "--help", - expected: true, - }, - { - name: "help weird casing", - arg: "hELP", - expected: true, - }, - { - name: "version", - arg: "version", - expected: false, - }, - { - name: "--version", - arg: "--version", - expected: false, - }, - { - name: "run", - arg: "run", - expected: false, - }, - } - - for _, tc := range tests { - s.T().Run(fmt.Sprintf("%s - %t", tc.name, tc.expected), func(t *testing.T) { - actual := ShouldGiveHelp(tc.arg) - assert.Equal(t, tc.expected, actual) - }) - } -} - func (s *HelpTestSuite) TestGetHelpText() { expectedPieces := []string{ "Cosmosvisor", cosmovisor.EnvName, cosmovisor.EnvHome, - "https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor/README.md", + "https://github.com/cosmos/cosmos-sdk/tree/main/cosmovisor/README.md", } actual := GetHelpText() diff --git a/cosmovisor/cmd/cosmovisor/main.go b/cosmovisor/cmd/cosmovisor/main.go index 8cd8623c7e7e..628b7da4f7f5 100644 --- a/cosmovisor/cmd/cosmovisor/main.go +++ b/cosmovisor/cmd/cosmovisor/main.go @@ -1,17 +1,19 @@ package main import ( + "context" "os" "github.com/cosmos/cosmos-sdk/cosmovisor" - "github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor/cmd" cverrors "github.com/cosmos/cosmos-sdk/cosmovisor/errors" ) func main() { - cosmovisor.SetupLogging() - if err := cmd.RunCosmovisorCommand(os.Args[1:]); err != nil { - cverrors.LogErrors(cosmovisor.Logger, "", err) + logger := cosmovisor.NewLogger() + ctx := context.WithValue(context.Background(), cosmovisor.LoggerKey, logger) + + if err := rootCmd.ExecuteContext(ctx); err != nil { + cverrors.LogErrors(logger, "", err) os.Exit(1) } } diff --git a/cosmovisor/cmd/cosmovisor/root.go b/cosmovisor/cmd/cosmovisor/root.go new file mode 100644 index 000000000000..69f6cfe075ed --- /dev/null +++ b/cosmovisor/cmd/cosmovisor/root.go @@ -0,0 +1,11 @@ +package main + +import ( + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "cosmovisor", + Short: "A process manager for Cosmos SDK application binaries.", + Long: GetHelpText(), +} diff --git a/cosmovisor/cmd/cosmovisor/run.go b/cosmovisor/cmd/cosmovisor/run.go new file mode 100644 index 000000000000..f0917a3fc949 --- /dev/null +++ b/cosmovisor/cmd/cosmovisor/run.go @@ -0,0 +1,53 @@ +package main + +import ( + "github.com/cosmos/cosmos-sdk/cosmovisor" + "github.com/rs/zerolog" + "github.com/spf13/cobra" +) + +func init() { + rootCmd.AddCommand(runCmd) +} + +var runCmd = &cobra.Command{ + Use: "run", + Short: "Run an APP command.", + SilenceUsage: true, + DisableFlagParsing: true, + RunE: func(cmd *cobra.Command, args []string) error { + logger := cmd.Context().Value(cosmovisor.LoggerKey).(*zerolog.Logger) + + return Run(logger, args) + }, +} + +// Run runs the configured program with the given args and monitors it for upgrades. +func Run(logger *zerolog.Logger, args []string, options ...RunOption) error { + cfg, err := cosmovisor.GetConfigFromEnv() + if err != nil { + return err + } + + runCfg := DefaultRunConfig + for _, opt := range options { + opt(&runCfg) + } + + launcher, err := cosmovisor.NewLauncher(logger, cfg) + if err != nil { + return err + } + + doUpgrade, err := launcher.Run(args, runCfg.StdOut, runCfg.StdErr) + // if RestartAfterUpgrade, we launch after a successful upgrade (only condition LaunchProcess returns nil) + for cfg.RestartAfterUpgrade && err == nil && doUpgrade { + logger.Info().Str("app", cfg.Name).Msg("upgrade detected, relaunching") + doUpgrade, err = launcher.Run(args, runCfg.StdOut, runCfg.StdErr) + } + if doUpgrade && err == nil { + logger.Info().Msg("upgrade detected, DAEMON_RESTART_AFTER_UPGRADE is off. Verify new upgrade and start cosmovisor again.") + } + + return err +} diff --git a/cosmovisor/cmd/cosmovisor/run_config.go b/cosmovisor/cmd/cosmovisor/run_config.go new file mode 100644 index 000000000000..5a77e30b4186 --- /dev/null +++ b/cosmovisor/cmd/cosmovisor/run_config.go @@ -0,0 +1,34 @@ +package main + +import ( + "io" + "os" +) + +// DefaultRunConfig defintes a default RunConfig that writes to os.Stdout and os.Stderr +var DefaultRunConfig = RunConfig{ + StdOut: os.Stdout, + StdErr: os.Stderr, +} + +// RunConfig defines the configuration for running a command +type RunConfig struct { + StdOut io.Writer + StdErr io.Writer +} + +type RunOption func(*RunConfig) + +// StdOutRunOption sets the StdOut writer for the Run command +func StdOutRunOption(w io.Writer) RunOption { + return func(cfg *RunConfig) { + cfg.StdOut = w + } +} + +// SdErrRunOption sets the StdErr writer for the Run command +func StdErrRunOption(w io.Writer) RunOption { + return func(cfg *RunConfig) { + cfg.StdErr = w + } +} diff --git a/cosmovisor/cmd/cosmovisor/run_test.go b/cosmovisor/cmd/cosmovisor/run_test.go new file mode 100644 index 000000000000..7c585d9b6461 --- /dev/null +++ b/cosmovisor/cmd/cosmovisor/run_test.go @@ -0,0 +1,4 @@ +package main + +// TODO: Write tests for func Run(args []string) error +// https://github.com/cosmos/cosmos-sdk/issues/11852 diff --git a/cosmovisor/cmd/cosmovisor/version.go b/cosmovisor/cmd/cosmovisor/version.go new file mode 100644 index 000000000000..de5005a721f4 --- /dev/null +++ b/cosmovisor/cmd/cosmovisor/version.go @@ -0,0 +1,81 @@ +package main + +import ( + "encoding/json" + "fmt" + "strings" + + "github.com/cosmos/cosmos-sdk/cosmovisor" + "github.com/rs/zerolog" + "github.com/spf13/cobra" + tmcli "github.com/tendermint/tendermint/libs/cli" +) + +func init() { + versionCmd.Flags().StringP(OutputFlag, "o", "text", "Output format (text|json)") + rootCmd.AddCommand(versionCmd) +} + +var ( + // Version represents Cosmovisor version value. Overwritten during build + Version = "1.1.0" + // OutputFlag defines the output format flag + OutputFlag = tmcli.OutputFlag +) + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Prints the version of Cosmovisor.", + SilenceUsage: true, + RunE: func(cmd *cobra.Command, args []string) error { + logger := cmd.Context().Value(cosmovisor.LoggerKey).(*zerolog.Logger) + + if val, err := cmd.Flags().GetString(OutputFlag); val == "json" && err == nil { + return printVersionJSON(logger, args) + } + + return printVersion(logger, args) + }, +} + +func printVersion(logger *zerolog.Logger, args []string) error { + fmt.Println("cosmovisor version: ", Version) + + if err := Run(logger, append([]string{"version"}, args...)); err != nil { + return fmt.Errorf("failed to run version command: %w", err) + } + + return nil +} + +func printVersionJSON(logger *zerolog.Logger, args []string) error { + buf := new(strings.Builder) + + // disable logger + l := logger.Level(zerolog.Disabled) + logger = &l + + if err := Run( + logger, + []string{"version", "--long", "--output", "json"}, + StdOutRunOption(buf), + ); err != nil { + return fmt.Errorf("failed to run version command: %w", err) + } + + out, err := json.Marshal(struct { + Version string `json:"cosmovisor_version"` + AppVersion json.RawMessage `json:"app_version"` + }{ + Version: Version, + AppVersion: json.RawMessage(buf.String()), + }) + if err != nil { + l := logger.Level(zerolog.TraceLevel) + logger = &l + return fmt.Errorf("can't print version output, expected valid json from APP, got: %s - %w", buf.String(), err) + } + + fmt.Println(string(out)) + return nil +} diff --git a/cosmovisor/cmd/cosmovisor/version_test.go b/cosmovisor/cmd/cosmovisor/version_test.go new file mode 100644 index 000000000000..f9dfa1401443 --- /dev/null +++ b/cosmovisor/cmd/cosmovisor/version_test.go @@ -0,0 +1,21 @@ +package main + +import ( + "context" + "testing" + + "github.com/cosmos/cosmos-sdk/cosmovisor" + "github.com/cosmos/cosmos-sdk/testutil" + "github.com/stretchr/testify/require" +) + +func TestVersionCommand_Error(t *testing.T) { + logger := cosmovisor.NewLogger() + + rootCmd.SetArgs([]string{"version"}) + _, out := testutil.ApplyMockIO(rootCmd) + ctx := context.WithValue(context.Background(), cosmovisor.LoggerKey, logger) + + require.Error(t, rootCmd.ExecuteContext(ctx)) + require.Contains(t, out.String(), "DAEMON_NAME is not set") +} diff --git a/cosmovisor/errors/multi.go b/cosmovisor/errors/multi.go index bb7885a9bb9f..a78a61a4e8f4 100644 --- a/cosmovisor/errors/multi.go +++ b/cosmovisor/errors/multi.go @@ -70,7 +70,7 @@ func (e MultiError) String() string { return e.Error() } -func LogErrors(logger zerolog.Logger, msg string, err error) { +func LogErrors(logger *zerolog.Logger, msg string, err error) { switch err := err.(type) { case *MultiError: if msg != "" { @@ -82,5 +82,4 @@ func LogErrors(logger zerolog.Logger, msg string, err error) { default: logger.Error().Err(err).Msg(msg) } - } diff --git a/cosmovisor/go.mod b/cosmovisor/go.mod index 406d5866f2e5..0c733c5e63a2 100644 --- a/cosmovisor/go.mod +++ b/cosmovisor/go.mod @@ -1,26 +1,24 @@ module github.com/cosmos/cosmos-sdk/cosmovisor -go 1.17 +go 1.18 require ( - github.com/cosmos/cosmos-sdk v0.45.2 - github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-getter v1.5.11 + github.com/cosmos/cosmos-sdk v0.46.0-beta2 + github.com/hashicorp/go-getter v1.6.1 github.com/otiai10/copy v1.7.0 github.com/rs/zerolog v1.26.1 + github.com/spf13/cobra v1.4.0 github.com/stretchr/testify v1.7.1 - google.golang.org/api v0.63.0 // indirect - google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + github.com/tendermint/tendermint v0.35.4 ) require ( - cloud.google.com/go v0.99.0 // indirect - cloud.google.com/go/storage v1.10.0 // indirect - filippo.io/edwards25519 v1.0.0-beta.2 // indirect + cloud.google.com/go v0.100.2 // indirect + cloud.google.com/go/compute v1.5.0 // indirect + cloud.google.com/go/iam v0.3.0 // indirect + cloud.google.com/go/storage v1.14.0 // indirect + filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/keyring v1.1.6 // indirect - github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect - github.com/DataDog/zstd v1.4.5 // indirect github.com/armon/go-metrics v0.3.10 // indirect github.com/aws/aws-sdk-go v1.40.45 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -29,100 +27,99 @@ require ( github.com/btcsuite/btcd v0.22.0-beta // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/confio/ics23/go v0.6.6 // indirect + github.com/confio/ics23/go v0.7.0 // indirect github.com/cosmos/btcutil v1.0.4 // indirect + github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect + github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.3 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/iavl v0.17.3 // indirect + github.com/cosmos/iavl v0.18.0 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect github.com/danieljoos/wincred v1.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dgraph-io/badger/v2 v2.2007.2 // indirect - github.com/dgraph-io/ristretto v0.0.3 // indirect + github.com/dgraph-io/badger/v2 v2.2007.4 // indirect + github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect - github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect - github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // 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/gogo/protobuf v1.3.3 // indirect + github.com/golang/glog v1.0.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.2 // indirect - github.com/golang/snappy v0.0.3 // indirect - github.com/google/btree v1.0.0 // indirect - github.com/googleapis/gax-go/v2 v2.1.1 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/google/btree v1.0.1 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/googleapis/gax-go/v2 v2.3.0 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.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-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-version v1.2.0 // indirect - github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/hashicorp/go-version v1.4.0 // indirect + github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect + github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jmespath/go-jmespath v0.4.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/libp2p/go-buffer-pool v0.0.2 // indirect - github.com/magiconair/properties v1.8.5 // indirect + github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-isatty v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.0.0 // indirect github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/oasisprotocol/curve25519-voi v0.0.0-20210609091139-0a56a4bca00b // indirect github.com/pelletier/go-toml v1.9.4 // indirect + github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_golang v1.12.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/common v0.33.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect - github.com/regen-network/cosmos-proto v0.3.1 // 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/afero v1.8.2 // indirect github.com/spf13/cast v1.4.1 // indirect - github.com/spf13/cobra v1.3.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.10.1 // indirect + github.com/spf13/viper v1.11.0 // indirect github.com/subosito/gotenv v1.2.0 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect + github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect github.com/tendermint/btcd v0.1.1 // indirect github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect github.com/tendermint/go-amino v0.16.0 // indirect - github.com/tendermint/tendermint v0.34.16 // indirect github.com/tendermint/tm-db v0.6.6 // indirect github.com/ulikunitz/xz v0.5.8 // indirect - github.com/zondax/hid v0.9.0 // indirect + github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 // indirect go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.23.0 // indirect - golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e // indirect - golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b // indirect - golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect - golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect + golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect + golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect + golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect + golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e // indirect + golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect + google.golang.org/api v0.74.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/grpc v1.44.0 // indirect - google.golang.org/protobuf v1.27.1 // indirect - gopkg.in/ini.v1 v1.66.2 // indirect + google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac // indirect + google.golang.org/grpc v1.45.0 // indirect + google.golang.org/protobuf v1.28.0 // indirect + gopkg.in/ini.v1 v1.66.4 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + sigs.k8s.io/yaml v1.3.0 // indirect ) replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 diff --git a/cosmovisor/go.sum b/cosmovisor/go.sum index 4e50c55a6f2e..d33a496ba55b 100644 --- a/cosmovisor/go.sum +++ b/cosmovisor/go.sum @@ -1,9 +1,12 @@ +4d63.com/gochecknoglobals v0.1.0/go.mod h1:wfdC5ZjKSPr7CybKEcgJhUOgeAQW1+7WcyK8OvUilfo= bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM= +bitbucket.org/creachadair/shell v0.0.6/go.mod h1:8Qqi/cYk7vPnsOePHroKXDJYmb5x7ENhtiFtfZq8K+M= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 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= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= @@ -12,10 +15,12 @@ cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6 cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.60.0/go.mod h1:yw2G51M9IfRboUH61Us8GqCeF1PzPblB823Mn2q2eAU= cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= 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= @@ -27,79 +32,77 @@ cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+Y 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.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= -cloud.google.com/go v0.99.0 h1:y/cM2iqGgGi5D5DQZl6D9STN/3dR/Vx5Mp8s752oJTY= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +cloud.google.com/go v0.100.2 h1:t9Iw5QH5v4XtlEQaCtUY7x6sCABps8sW0acw7e2WQ6Y= +cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= 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= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= +cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= +cloud.google.com/go/compute v1.5.0 h1:b1zWmYuuHz7gO9kDcM/EpHGr06UgsYNRpNJzI2kFiLM= +cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= 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.0/go.mod h1:afJwI0vaXwAG54kI7A//lP/lSPDkQORQuMkv56TxEPU= cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= +cloud.google.com/go/iam v0.3.0 h1:exkAomrVUuzx9kWFI1wm3KI0uoDeUFPB4kKGzx6x+Gc= +cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= 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= cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/pubsub v1.5.0/go.mod h1:ZEwJccE3z93Z2HWvstpri00jOg7oO4UZDtKhwDwqF0w= +cloud.google.com/go/spanner v1.7.0/go.mod h1:sd3K2gZ9Fd0vMPLXzeCrF6fq4i63Q7aTLW/lBIfBkIk= cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0 h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0 h1:6RRlFMv1omScs6iq2hfE3IvgE+l6RfJPampq8UZc5TU= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= +contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI= -filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= +filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= +filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= github.com/99designs/keyring v1.1.6 h1:kVDC2uCgVwecxCk+9zoCt2uEL6dt+dfVzMvGgnVcIuM= github.com/99designs/keyring v1.1.6/go.mod h1:16e0ds7LGQQcT59QqkTg72Hh5ShM51Byv5PEmW6uoRU= -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-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/Antonboom/errname v0.1.5/go.mod h1:DugbBstvPFQbv/5uLcRRzfrNqKE9tVdVCqWCLp6Cifo= +github.com/Antonboom/nilnil v0.1.0/go.mod h1:PhHLvRPSghY5Y7mX4TW+BHZQYo1A8flE5H20D3IPZBo= +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/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -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.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +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/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= 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/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= +github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= 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= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/OpenPeeDeeP/depguard v1.1.0/go.mod h1:JtAMzWkmFEzDPyAd+W0NHl1lvpQKTvT9jnRVsohBKpc= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -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/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/go.mod h1:L5Z7tw+7lRK1Fnpi/LT/ooCP1elkXn0krMWBQHUhEDE= -github.com/adlio/schema v1.2.3/go.mod h1:nD7ZWmMMbwU12Pqwg+qL0rTvHBrBXfNz+5UQxTfy38M= +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= @@ -108,11 +111,12 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= +github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= +github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= +github.com/andybalholm/brotli v1.0.3/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= +github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ= 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= @@ -121,14 +125,14 @@ github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8 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/ashanbrown/forbidigo v1.3.0/go.mod h1:vVW7PEdqEFqapJe95xHkTfB1+XvZXBFg8t0sG2FIxmI= +github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= -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.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.36.30/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.40.45 h1:QN1nsY27ssD/JmW4s83qmSb+uL6DG4GmCDzjmJB4xUI= github.com/aws/aws-sdk-go v1.40.45/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= -github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= @@ -142,19 +146,18 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= +github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= +github.com/blizzy78/varnamelen v0.6.1/go.mod h1:zy2Eic4qWqjrxa60jG34cfL0VXcSwzUrIx68eJPb4Q8= +github.com/bombsimon/wsl/v3 v3.3.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= +github.com/breml/bidichk v0.2.2/go.mod h1:zbfeitpevDUGI7V91Uzzuwrn4Vls8MoBMrwtt78jmso= +github.com/breml/errchkjson v0.2.3/go.mod h1:jZEATw/jF69cL1iy7//Yih8yp/mXp2CBoBr9GJwCAsY= 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= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= -github.com/btcsuite/btcutil v1.0.2/go.mod h1:j9HUFwoQRsZL3V4n+qG+CUnEGHOarIxfC3Le2Yhbcts= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg= @@ -164,18 +167,21 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= 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/butuzov/ireturn v0.1.1/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc= 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 h1:G2HAfAmvm/GcKan2oOQpBXOd2tT2G57ZnZGWa1PxPBQ= 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/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/charithe/durationcheck v0.0.9/go.mod h1:SSbRIBVfMjCi/kEB6K65XEA83D6prSM8ap1UCpNKtgg= +github.com/chavacava/garif v0.0.0-20210405164556-e8a0a408d6af/go.mod h1:Qjyv4H3//PWVzTeCezG2b9IRn6myJxJSr4TD/xo6ojU= github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= @@ -185,9 +191,7 @@ github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJ github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= -github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/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-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -198,35 +202,38 @@ github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= -github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coinbase/rosetta-sdk-go v0.7.0 h1:lmTO/JEpCvZgpbkOITL95rA80CPKb5CtMzLaqF2mCNg= -github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq3yftRmpsy29coWE= -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/coinbase/rosetta-sdk-go v0.7.6 h1:y3/Lxu9ojIsUKnhNc5UaZF/i0byfuNDWXLYMSKG+IBs= +github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8= +github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= -github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= 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= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= -github.com/cosmos/cosmos-sdk v0.45.2 h1:kQENBJEWcdNXmct4Rfc6H5ejCjzFqCjx4uOU0kooEak= -github.com/cosmos/cosmos-sdk v0.45.2/go.mod h1:DhSVBqJkhjB694w99FudptzPhU0XHd/qcyiNCLOjkds= -github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= +github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= +github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= +github.com/cosmos/cosmos-sdk v0.46.0-beta2 h1:emigIPQ6lW2fIeV77yNpb9TR4Ij/tqeWaUJQ2up06Q0= +github.com/cosmos/cosmos-sdk v0.46.0-beta2/go.mod h1:++o5Yd16NY5aWrJUFgbNjBQCJ4bOVZbUxKcfEfkS7bI= +github.com/cosmos/cosmos-sdk/api v0.1.0 h1:xfSKM0e9p+EJTMQnf5PbWE6VT8ruxTABIJ64Rd064dE= +github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 h1:6YvzjQtc+cDwCe9XwYPPa8zFCxNG79N7vmCjpK+vGOg= +github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.3 h1:Ep7FHNViVwwGnwLFEPewZYsyN2CJNVMmMvFmtNQtbnw= +github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.3/go.mod h1:HFea93YKmoMJ/mNKtkSeJZDtyJ4inxBsUK928KONcqo= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= -github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= -github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w= +github.com/cosmos/iavl v0.18.0 h1:02ur4vnalMR2GuWCFNkuseUcl/BCVmg9tOeHOGiZOkE= +github.com/cosmos/iavl v0.18.0/go.mod h1:L0VZHfq0tqMNJvXlslGExaaiZM7eSm+90Vh9QUbp6j4= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= @@ -235,46 +242,48 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc 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/creachadair/atomicfile v0.2.4/go.mod h1:BRq8Une6ckFneYXZQ+kO7p1ZZP3I2fzVzf28JxrIkBc= +github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6VqkYlkM= +github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk= +github.com/creachadair/tomledit v0.0.16/go.mod h1:gvtfnSZLa+YNQD28vaPq0Nk12bRxEhmUdBzAWn+EGF4= 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= +github.com/daixiang0/gci v0.3.3/go.mod h1:1Xr2bxnQbDxCqqulUOv8qpGqkgRw9RSCGGjEC2LjF8o= github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= +github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/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/denis-tingaikin/go-header v0.4.3/go.mod h1:0wOCWuN71D5qIgE2nz9KrKmuYBAC2Mra5RassOIQ2/c= +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= github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= +github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= +github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgraph-io/ristretto v0.0.3 h1:jh22xisGBjrEVnRZ1DVTpBVQm0Xndu8sMl0CWDzSIBI= -github.com/dgraph-io/ristretto v0.0.3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= +github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b h1:HBah4D48ypg3J7Np4N+HY/ZR76fx3HEUGxDU6Uk39oQ= github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= -github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/edsrzf/mmap-go 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.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= @@ -284,80 +293,82 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= +github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 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/esimonov/ifshort v1.0.4/go.mod h1:Pe8zjlRrJ80+q2CxHLfEOfTwxCZ4O+MuhcHcfgNWTk0= +github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= -github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= -github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/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/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= 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/frankban/quicktest v1.14.2/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 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/fullstorydev/grpcurl v1.6.0/go.mod h1:ZQ+ayqbKMJNhzLmbpCiurTVlaK2M/3nqZCxaQ2Ze/sM= +github.com/fzipp/gocyclo v0.4.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/go-critic/go-critic v0.6.2/go.mod h1:td1s27kfmLpe5G/DPjlnFI7o1UCzePptwU7Az0V5iCM= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -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/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/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= -github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= -github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= -github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-redis/redis v6.15.8+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= 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-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= +github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ= +github.com/go-toolsmith/astequal v1.0.0/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY= +github.com/go-toolsmith/astequal v1.0.1/go.mod h1:4oGA3EZXTVItV/ipGiOx7NWkY5veFfcsOJVS2YxltLw= +github.com/go-toolsmith/astfmt v1.0.0/go.mod h1:cnWmsOAuq4jJY6Ct5YWlVLmcmLMn1JUPuQIHCY7CJDw= +github.com/go-toolsmith/astp v1.0.0/go.mod h1:RSyrtpVlfTFGDYRbrjyWP1pYu//tSFcvdYrA8meBmLI= +github.com/go-toolsmith/pkgload v1.0.2-0.20220101231613-e814995d17c5/go.mod h1:3NAwwmD4uY/yggRxoEjk/S00MIV3A+H7rrE3i87eYxM= +github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8= +github.com/go-toolsmith/typep v1.0.2/go.mod h1:JSQCQMUPdRlMZFswiq3TGpNp1GMktqkR2Ns5AIQkATU= +github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= 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/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= -github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= -github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= +github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= -github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= -github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= +github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= +github.com/golang-sql/sqlexp v0.0.0-20170517235910-f1bb20e5a188/go.mod h1:vXjM/+wXQnTPR4KqTKDgJukSZ6amVRtWMPEjE6sQoK8= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -375,6 +386,7 @@ github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71 github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -396,12 +408,25 @@ 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/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/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4= +github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= +github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613/go.mod h1:SyvUF2NxV+sN8upjjeVYr5W7tyxaT1JVtvhKhOn2ii8= +github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU= +github.com/golangci/golangci-lint v1.45.2/go.mod h1:f20dpzMmUTRp+oYnX0OGjV1Au3Jm2JeI9yLqHq1/xsI= +github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg= +github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca/go.mod h1:tvlJhZqDe4LMs4ZHD0oMUlt9G2LWuDGoisJTBzLMV9o= +github.com/golangci/misspell v0.3.5/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPPChZ7PhiVA= +github.com/golangci/revgrep v0.0.0-20210930125155-c22e5001d4f2/go.mod h1:LK+zW4MpyytAWQRz0M4xnzEk50lSvqDQKfx304apFkY= +github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ= 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= +github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= +github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= +github.com/google/certificate-transparency-go v1.1.1/go.mod h1:FDKqPvSXawb2ecErVRrD+nfy23RCzyl7eqVCEmlT1Zs= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -413,12 +438,12 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= +github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= -github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -433,85 +458,99 @@ github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200507031123-427632fa3b1c/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/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-20210407192527-94a9f03dee38/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/trillian v1.3.11/go.mod h1:0tPraVHrSDkA3BO6vKX67zgLXs6SsOAbHEivX+9mPgw= +github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 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/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/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/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= +github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= +github.com/googleapis/gax-go/v2 v2.3.0 h1:nRJtk3y8Fm770D42QV6T90ZnvFZyk7agSo3Q+Z9p3WI= +github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= 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/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0= +github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= -github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= -github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.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/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= +github.com/gostaticanalysis/analysisutil v0.0.3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= +github.com/gostaticanalysis/analysisutil v0.1.0/go.mod h1:dMhHRU9KTiDcuLGdy87/2gTR8WruwYZrKdRq9m1O6uw= +github.com/gostaticanalysis/analysisutil v0.4.1/go.mod h1:18U/DLpRgIUd459wGxVHE0fRgmo1UgHDcbw7F5idXu0= +github.com/gostaticanalysis/analysisutil v0.7.1/go.mod h1:v21E3hY37WKMGSnbsw2S/ojApNWb6C1//mXO48CXbVc= +github.com/gostaticanalysis/comment v1.3.0/go.mod h1:xMicKDx7XRXYdVwY9f9wQpDJVnqWxw9wCauCMKp+IBI= +github.com/gostaticanalysis/comment v1.4.1/go.mod h1:ih6ZxzTHLdadaiSnF5WY3dxUoXfXAlTaRzuaNDlSado= +github.com/gostaticanalysis/comment v1.4.2/go.mod h1:KLUTGDv6HOCotCH8h2erHKmpci2ZoR8VPu34YA2uzdM= +github.com/gostaticanalysis/forcetypeassert v0.1.0/go.mod h1:qZEedyP/sY1lTGV1uJ3VhWZ2mqag3IkWsDHVbplHXak= +github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW0HU0GPE3+5PWN4A= +github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M= +github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Repi5x3CuviD3dgAZaBU= github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= -github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= +github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8ZofjG1Y75iExal34USq5p+wiN1tpie8IrU= github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0= -github.com/gtank/merlin v0.1.1-0.20191105220539-8318aed1a79f/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= -github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= -github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= -github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.5.11 h1:wioTuNmaBU3IE9vdFtFMcmZWj0QzLc6DYaP6sNe5onY= -github.com/hashicorp/go-getter v1.5.11/go.mod h1:9i48BP6wpWweI/0/+FBjqLrp9S8XtwUGjiu0QkWHEaY= +github.com/hashicorp/go-getter v1.6.1 h1:NASsgP4q6tL94WH6nJxKWj8As2H/2kop/bB1d8JMyRY= +github.com/hashicorp/go-getter v1.6.1/go.mod h1:IZCrswsZPeWv9IkVnLElzRU/gz/QPi6pZHn4tv6vbwA= 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-hclog v1.2.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-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= @@ -521,48 +560,46 @@ github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/b github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= -github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4= +github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= +github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= 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/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= +github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU= +github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= 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/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= +github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= github.com/hudl/fargo v1.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= -github.com/improbable-eng/grpc-web v0.14.1/go.mod h1:zEjGHa8DAlkoOXmswrNvhUGEYQA9UI7DhrGeHR1DMGU= +github.com/imdario/mergo v0.3.4/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/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= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jhump/protoreflect v1.9.0/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= +github.com/jgautheron/goconst v1.5.1/go.mod h1:aAosetZ5zaeC/2EfMeRswtxUFBpe2Hr7HzkgX4fanO4= +github.com/jhump/protoreflect v1.6.1/go.mod h1:RZQ/lnuN+zqeRVpQigTwO6o0AJUkxbnSnpuG7toUTG4= +github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c= +github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -571,12 +608,14 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw 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/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jonboulle/clockwork v0.2.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/josharian/txtarfs v0.0.0-20210218200122-0702f000015a/go.mod h1:izVPOvVRsHiKkeGCT6tYBNWyDVuzj9wAaBb5R9qamfw= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -584,61 +623,71 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm 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/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/juju/ratelimit v1.0.1/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk= 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/julz/importas v0.1.0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= 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/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= 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= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= 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.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.13.5/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= 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.2/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= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kulti/thelper v0.5.1/go.mod h1:vMu2Cizjy/grP+jmsvOFDx1kYP6+PD1lqg4Yu5exl2U= +github.com/kunwardeep/paralleltest v1.0.3/go.mod h1:vLydzomDFpk7yu5UX02RmP0H8QfRPOV/oFhWN85Mjb4= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -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.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= +github.com/kyoh86/exportloopref v0.1.8/go.mod h1:1tUcJeiioIs7VWe5gcOObrux3lb66+sBqGZrRkMwPgg= +github.com/ldez/gomoddirectives v0.2.2/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdBr6g8G04uz6d0= +github.com/ldez/tagliatelle v0.3.1/go.mod h1:8s6WJQwEYHbKZDsp/LjArytKOG8qaMrKQQ3mFukHs88= +github.com/leonklingele/grouper v1.1.0/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY= +github.com/letsencrypt/pkcs11key/v4 v4.0.0/go.mod h1:EFUvBDay26dErnNb70Nd0/VW3tJiIbETBPTl9ATXQag= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.5 h1:J+gdV2cUmX7ZqL2B0lFcW0m+egaHC2V3lpO8nWxyYiQ= +github.com/lib/pq v1.10.5/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/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= -github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= +github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/maratori/testpackage v1.0.1/go.mod h1:ddKdw+XG0Phzhx8BFDTKgpWP4i7MpApTE5fXSKAqwDU= +github.com/matoous/godox v0.0.0-20210227103229-6504466cf951/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s= +github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= 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= @@ -646,253 +695,268 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky 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-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= 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/mbilski/exhaustivestruct v1.2.0/go.mod h1:OeTBVxQWoEmB2J2JCHmXWPJ0aksxSUOUy+nvtVEfzXc= +github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg= +github.com/mgechev/revive v1.1.4/go.mod h1:ZZq2bmyssGh8MSPz3VVziqRNIMYTJXzP8MUKG90vZ9A= 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.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= 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/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= +github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-ps v1.0.0/go.mod h1:J4lOc8z8yJs6vUwklHw2XEIiT4z4C40KtWVN3nvg8Pg= github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.3.3/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/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 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/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 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/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/moricho/tparallel v0.2.1/go.mod h1:fXEIZxG2vdfl0ZF8b42f5a78EhjjD5mX8qUplsoSU4k= +github.com/mozilla/scribe v0.0.0-20180711195314-fb71baf557c1/go.mod h1:FIczTrinKo8VaLxe6PWTPEXRXDIHz2QAwiaBaP5/4a8= +github.com/mozilla/tls-observatory v0.0.0-20210609171429-7bc42856d2e5/go.mod h1:FUqVoUPHSEdDR0MnFM3Dh8AU0pZHLXUD127SAJGER/s= +github.com/mroth/weightedrand v0.4.1/go.mod h1:3p2SIcC8al1YMzGhAIoXD+r9olo/g/cdJgAD905gyNE= 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= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76/go.mod h1:x5OoJHDHqxHS801UIuhqGl6QdSAEJvtausosHSdazIo= -github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= -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/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= +github.com/mwitkow/go-proto-validators v0.2.0/go.mod h1:ZfA1hW+UH/2ZHOWvQ3HnQaU0DtnpXu850MZiy+YUgcc= +github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE= github.com/nats-io/jwt 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/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= +github.com/nishanths/exhaustive v0.7.11/go.mod h1:gX+MP7DWMKJmNa1HfMozK+u04hQd3na9i0hyqf3/dOI= +github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= +github.com/nishanths/predeclared v0.2.1/go.mod h1:HvkGJcA3naj4lOwnFXFDkFxVtSqQMB9sbB1usJ+xjQE= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= -github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= +github.com/oasisprotocol/curve25519-voi v0.0.0-20210609091139-0a56a4bca00b h1:MKwruh+HeCSKWphkxuzvRzU4QzDkg7yiPkDVV0cDFgI= +github.com/oasisprotocol/curve25519-voi v0.0.0-20210609091139-0a56a4bca00b/go.mod h1:TLJifjWF6eotcfzDjKZsDqWJ+73Uvj/N85MvVyrvynM= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= github.com/opencontainers/runc v1.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/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= -github.com/otiai10/copy v1.6.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= +github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= +github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI= github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pborman/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.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/pelletier/go-toml/v2 v2.0.0-beta.8 h1:dy81yyLYJDwMTifq24Oi/IslOslRrDSb3jwDggjz3Z0= +github.com/pelletier/go-toml/v2 v2.0.0-beta.8/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= 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/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= 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/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d/go.mod h1:3OzsM7FXDQlpCiw2j81fOmAwQLnZnLGXVKUzeKQXIAw= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= +github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 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/polyfloyd/go-errorlint v0.0.0-20211125173453-6d6d39c5bb8b/go.mod h1:wi9BfjxjF/bwiZ701TzmfKu6UKC357IOAtNr0Td0Lvw= 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/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_golang v1.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= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= -github.com/prometheus/common v0.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.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/common v0.33.0 h1:rHgav/0a6+uYgGdNt3jwz8FNSesO/Hsang3O0T9A5SE= +github.com/prometheus/common v0.33.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/tsdb v0.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/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= +github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= +github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30= +github.com/quasilyte/go-ruleguard v0.3.15/go.mod h1:NhuWhnlVEM1gT1A4VJHYfy9MuYSxxwHgxWoPsn9llB4= +github.com/quasilyte/go-ruleguard/dsl v0.3.0/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/quasilyte/go-ruleguard/dsl v0.3.12-0.20220101150716-969a394a9451/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/quasilyte/go-ruleguard/dsl v0.3.12/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/quasilyte/go-ruleguard/dsl v0.3.17/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/quasilyte/go-ruleguard/rules v0.0.0-20201231183845-9e62ed36efe1/go.mod h1:7JTjp89EGyU1d6XfBiXihJNG37wB2VRkd125Q1u7Plc= +github.com/quasilyte/go-ruleguard/rules v0.0.0-20211022131956-028d6511ab71/go.mod h1:4cgAphtvu7Ftv7vOT2ZOYhC6CvBxZixcasr8qIOTA50= +github.com/quasilyte/gogrep v0.0.0-20220103110004-ffaa07af02e3/go.mod h1:wSEyW6O61xRV6zb6My3HxrQ5/8ke7NE2OayqCHa3xRM= +github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= -github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 h1:MkV+77GLUNo5oJ0jf870itWm3D0Sjh7+Za9gazKc5LQ= github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzywPxOvwMdxcg= -github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= -github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= 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/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o= 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/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.23.0/go.mod h1:6c7hFfxPOy7TacJc4Fcdi24/J0NKYGzjG8FWRI916Qo= github.com/rs/zerolog v1.26.1 h1:/ihwxqH+4z8UxyI70wM1z9yCvkWcfz/a3mj48k/Zngc= github.com/rs/zerolog v1.26.1/go.mod h1:/wSSJWX7lVrsOwlbyTRSOJvqRlc+WjWlfes+CiJ+tmc= 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/ryancurrah/gomodguard v1.2.3/go.mod h1:rYbA/4Tg5c54mV1sv4sQTP5WOPBcoLtnBZ7/TEhXAbg= +github.com/ryanrolds/sqlclosecheck v0.3.0/go.mod h1:1gREqxyTGR3lVtpngyFo3hZAgk0KCtEdgEkHwDbigdA= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sagikazarmark/crypt v0.1.0/go.mod h1:B/mN0msZuINBtQ1zZLEQcegFJJf9vnYIR88KRMEuODE= github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= 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/sagikazarmark/crypt v0.5.0/go.mod h1:l+nzl7KWh51rpzp2h7t4MZWyiEWdhNpOAnclKvg+mdA= +github.com/sanposhiho/wastedassign/v2 v2.0.6/go.mod h1:KyZ0MWTwxxBmfwn33zh3k1dmsbF2ud9pAAGfoLfjhtI= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= -github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= -github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/securego/gosec/v2 v2.10.0/go.mod h1:PVq8Ewh/nCN8l/kKC6zrGXSr7m2NmEK6ITIAWMtIaA0= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= +github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY= +github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= +github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sivchari/containedctx v1.0.2/go.mod h1:PwZOeqm4/DLoJOqMSIJs3aKqXRX4YO+uXww087KZ7Bw= +github.com/sivchari/tenv v1.4.7/go.mod h1:5nF+bITvkebQVanjU6IuMbvIot/7ReNsUV7I5NbprB0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 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= +github.com/sonatard/noctx v0.0.1/go.mod h1:9D2D/EoULe8Yy2joDHJj7bv3sZoq9AaSb8B4lqBjiZI= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= +github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= 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/afero v1.8.0/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= +github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= +github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= github.com/spf13/cast v1.3.0/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.3.0 h1:R7cSvGu+Vv+qX0gW5R/85dx2kmmJT5z5NM8ifdYjdn0= github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= +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= @@ -902,23 +966,21 @@ 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.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4= github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= -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/spf13/viper v1.11.0 h1:7OX/1FS6n7jHD1zGrZTM7WtY13ZELRyosK4k93oPr44= +github.com/spf13/viper v1.11.0/go.mod h1:djo0X/bA5+tYVoCn+C7cAYJGcVn/qYLFTG8gdUsX7Zk= +github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= 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= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -929,9 +991,12 @@ github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMT 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/sylvia7788/contextcheck v1.0.4/go.mod h1:vuPKJMQ7MQ91ZTqfdyreNKwZjyUg6KO+IebVyQDedZQ= github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= +github.com/tdakkota/asciicheck v0.1.1/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= @@ -940,63 +1005,80 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0= -github.com/tendermint/tendermint v0.34.16 h1:J2h7SwKWEv/cPuby2gjFhY00L2nLCoJOVFZvDbVeA8Q= -github.com/tendermint/tendermint v0.34.16/go.mod h1:n0G22GynfeXTYbrn2IeLeB+oqsAe6R6jl4vZxZ1Y8F4= -github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw= +github.com/tendermint/tendermint v0.35.4 h1:ZL9Q+rXBwTEYbONBXy0mWkyG08uvdgQNSuYmoBR1sfE= +github.com/tendermint/tendermint v0.35.4/go.mod h1:+9zS92hqCl6mL7XLK3dg71nzoBLJlkl/aNLx4NXKNP8= 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/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= +github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= +github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8= +github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= +github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= +github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= 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/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tomarrell/wrapcheck/v2 v2.5.0/go.mod h1:68bQ/eJg55BROaRTbMjC7vuhL2OgfoG8bLp9ZyoBfyY= +github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4= +github.com/tommy-muehle/go-mnd/v2 v2.5.0/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= 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/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= +github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= +github.com/ultraware/whitespace v0.0.5/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/uudashr/gocognit v1.0.5/go.mod h1:wgYz0mitoKOTysqxTDMOUXg+Jb5SvtihkfmugIZYpEA= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.30.0/go.mod h1:2rsYD01CKFrjjsvFxx75KlEUNpWNBY9JWD3K/7o2Cus= +github.com/valyala/quicktemplate v1.7.0/go.mod h1:sqKJnoaOF88V07vkO+9FL8fb9uZg/VPSJnLYn+LmLk8= +github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +github.com/vektra/mockery/v2 v2.10.6/go.mod h1:8vf4KDDUptfkyypzdHLuE7OE2xA7Gdt60WgIS8PgD+U= +github.com/viki-org/dnscache v0.0.0-20130720023526-c70c1f23c5d8/go.mod h1:dniwbG03GafCjFohMDmz6Zc6oCuiqgH6tGNyXTkHzXE= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= -github.com/vmihailenco/msgpack/v5 v5.1.4/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI= -github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE= +github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= +github.com/yeya24/promlinter v0.1.1-0.20210918184747-d757024714a1/go.mod h1:rs5vtZzeBHqqMwXqFScncpCF6u06lezhZepno9AB1Oc= +github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= +github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 h1:O9XLFXGkVswDFmH9LaYpqu+r/AAFWqr0DL6V00KEVFg= +github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= +gitlab.com/bosi/decorder v0.2.1/go.mod h1:6C/nhLSbF6qZbYD8bRmISBwc6vcWdNsiIBkRvjJFrH0= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= -go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= +go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c/go.mod h1:xCI7ZzBfRuGgBXyXO6yfWfDmlWd35khcWpUa4L0xI/k= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/api/v3 v3.5.2/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= 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/pkg/v3 v3.5.2/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/v2 v2.305.2/go.mod h1:2D7ZejHVMIfog1221iLSYlQRzrtECw3kz4I4VAQm3qI= 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.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -1014,6 +1096,7 @@ 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.4.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= @@ -1022,39 +1105,43 @@ 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-20180501155221-613d6eafa307/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= golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 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-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= 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/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e h1:1SzTfNOXwIS2oWiMF+6qu0OUDKb0dauo6MoDUQyu+yU= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA= +golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 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= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= @@ -1080,29 +1167,26 @@ golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mobile v0.0.0-20200801112145-973feb4309de/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/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/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= 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-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -1116,6 +1200,7 @@ golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1133,7 +1218,6 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -1146,14 +1230,21 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b 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-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +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-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b h1:MWaHNqZy3KTpuTMAGvv+Kw+ylsEpmyJZizz1dqxnu28= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220412020605-290c469a71a5 h1:bRb386wvrE+oBNdF1d/Xh9mQrfQ4ecYhW5qJ5GvTGT4= +golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= 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= @@ -1170,18 +1261,23 @@ golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ 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 h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= 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= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1190,7 +1286,6 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1208,6 +1303,7 @@ 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-20190916202348-b4ddaad3f8a3/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= @@ -1218,7 +1314,6 @@ golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7w 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= @@ -1241,19 +1336,19 @@ golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -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= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-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-20210225134936-a50acf3fe073/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= @@ -1261,6 +1356,7 @@ golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1271,21 +1367,34 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/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-20210915083310-ed5796bab164/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-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/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-20211213223007-03aa0b5f6827/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220111092808-5a964db01320/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e h1:w36l2Uw3dRan1K3TyXriXvY+6T56GNmlKGcqiQUJDfM= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/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= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1303,14 +1412,17 @@ golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190307163923-6a08e3108db3/go.mod h1:25r3+/G6/xytQM8iWZKq3Hn0kr0rgFKPUNVEL/dr3z4= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190321232350-e250d351ecad/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -1320,21 +1432,24 @@ golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgw 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-20190910044552-dd2b5c81c578/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-20190916130336-e45ffcd953cc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/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= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117220505-0cba7a3a9ee9/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1344,46 +1459,73 @@ golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200324003944-a576cf524670/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200414032229-332987a829c3/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200422022333-3d57cf2e726e/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200622203043-20e05c1c8ffa/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200624225443-88f3c62a19ff/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200625211823-6506e20df31f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200630154851-b2d8b0336632/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200706234117-b22de6825cf7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200724022722-7017fd6b1305/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200812195022-5ae4c3c160a0/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200820010801-b793a1359eac/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200831203904-5a2aa26beb65/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201001104356-43ebab892c4c/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201002184944-ecd9fd270d5d/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201023174141-c8cfbd0f21e6/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201028025901-8cd080b735b3/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201114224030-61ea331ec02b/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= golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201230224404-63754364767c/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1-0.20210205202024-ef80cdb6ec6d/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= +golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= 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/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.9-0.20211228192929-ee1ca4ffc4da/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= 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= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/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= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.10.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= @@ -1412,27 +1554,33 @@ google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdr 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.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= -google.golang.org/api v0.63.0 h1:n2bqqK895ygnBpdPDYetfy23K7fJ22wsrZKCyfuRkkA= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= +google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= +google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= +google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= +google.golang.org/api v0.74.0 h1:ExR2D+5TYIrMphWgs5JCgwRhEDlPDXXrLwHHMgPHTXE= +google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= @@ -1454,17 +1602,19 @@ google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200626011028-ee7919e894b5/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200707001353-8e8330bf89df/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 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= @@ -1493,28 +1643,34 @@ google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/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.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= +google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac h1:qSNTkEN+L2mvWcLgJOR+8bdHX9rN/IdU3A1Ghpfb1Rg= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.22.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.0/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= @@ -1530,8 +1686,9 @@ google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9K google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.44.0 h1:weqSxi/TMs1SqFRMHCtBgXRs8k3X39QIDEZ0pRcttUg= google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= 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= @@ -1543,11 +1700,11 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -1557,18 +1714,18 @@ gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLF 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= gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= +gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= 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/ini.v1 v1.66.3/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4= +gopkg.in/ini.v1 v1.66.4/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -1576,6 +1733,7 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.6/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= @@ -1584,7 +1742,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C 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/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1592,12 +1749,18 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.2.2/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY= +mvdan.cc/gofumpt v0.3.0/go.mod h1:0+VyGZWleeIj5oostkOex+nDBA0eyavuDnDusAJ8ylo= +mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= +mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= +mvdan.cc/unparam v0.0.0-20211214103731-d0ef000c54e5/go.mod h1:b8RRCBm0eeiWR8cfN88xeq2G5SG3VKGO+5UPWi5FSOY= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= -nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= 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= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/cosmovisor/logger.go b/cosmovisor/logger.go index cc7b58720de6..bcec3a02544c 100644 --- a/cosmovisor/logger.go +++ b/cosmovisor/logger.go @@ -7,9 +7,10 @@ import ( "github.com/rs/zerolog" ) -var Logger zerolog.Logger +var LoggerKey struct{} -func SetupLogging() { +func NewLogger() *zerolog.Logger { output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.Kitchen} - Logger = zerolog.New(output).With().Str("module", "cosmovisor").Timestamp().Logger() + logger := zerolog.New(output).With().Str("module", "cosmovisor").Timestamp().Logger() + return &logger } diff --git a/cosmovisor/process.go b/cosmovisor/process.go index 0f57940553ba..17b9b67eaf04 100644 --- a/cosmovisor/process.go +++ b/cosmovisor/process.go @@ -14,18 +14,24 @@ import ( "time" "github.com/otiai10/copy" + "github.com/rs/zerolog" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ) type Launcher struct { - cfg *Config - fw *fileWatcher + logger *zerolog.Logger + cfg *Config + fw *fileWatcher } -func NewLauncher(cfg *Config) (Launcher, error) { - fw, err := newUpgradeFileWatcher(cfg.UpgradeInfoFilePath(), cfg.PollInterval) - return Launcher{cfg, fw}, err +func NewLauncher(logger *zerolog.Logger, cfg *Config) (Launcher, error) { + fw, err := newUpgradeFileWatcher(logger, cfg.UpgradeInfoFilePath(), cfg.PollInterval) + if err != nil { + return Launcher{}, err + } + + return Launcher{logger: logger, cfg: cfg, fw: fw}, nil } // Run launches the app in a subprocess and returns when the subprocess (app) @@ -40,7 +46,8 @@ func (l Launcher) Run(args []string, stdout, stderr io.Writer) (bool, error) { if err := EnsureBinary(bin); err != nil { return false, fmt.Errorf("current binary is invalid: %w", err) } - Logger.Info().Str("path", bin).Strs("args", args).Msg("running app") + + l.logger.Info().Str("path", bin).Strs("args", args).Msg("running app") cmd := exec.Command(bin, args...) cmd.Stdout = stdout cmd.Stderr = stderr @@ -53,7 +60,7 @@ func (l Launcher) Run(args []string, stdout, stderr io.Writer) (bool, error) { go func() { sig := <-sigs if err := cmd.Process.Signal(sig); err != nil { - Logger.Fatal().Err(err).Str("bin", bin).Msg("terminated") + l.logger.Fatal().Err(err).Str("bin", bin).Msg("terminated") } }() @@ -63,16 +70,16 @@ func (l Launcher) Run(args []string, stdout, stderr io.Writer) (bool, error) { } if !IsSkipUpgradeHeight(args, l.fw.currentInfo) { - if err := doBackup(l.cfg); err != nil { + if err := l.doBackup(); err != nil { return false, err } - if err = doPreUpgrade(l.cfg); err != nil { + if err = l.doPreUpgrade(); err != nil { return false, err } } - return true, DoUpgrade(l.cfg, l.fw.currentInfo) + return true, DoUpgrade(l.logger, l.cfg, l.fw.currentInfo) } // WaitForUpgradeOrExit checks upgrade plan file created by the app. @@ -83,8 +90,12 @@ func (l Launcher) Run(args []string, stdout, stderr io.Writer) (bool, error) { // It returns (false, nil) if the process exited normally without triggering an upgrade. This is very unlikely // to happened with "start" but may happened with short-lived commands like `gaiad export ...` func (l Launcher) WaitForUpgradeOrExit(cmd *exec.Cmd) (bool, error) { - currentUpgrade := l.cfg.UpgradeInfo() - var cmdDone = make(chan error) + currentUpgrade, err := l.cfg.UpgradeInfo() + if err != nil { + l.logger.Error().Err(err) + } + + cmdDone := make(chan error) go func() { cmdDone <- cmd.Wait() }() @@ -92,7 +103,7 @@ func (l Launcher) WaitForUpgradeOrExit(cmd *exec.Cmd) (bool, error) { select { case <-l.fw.MonitorUpdate(currentUpgrade): // upgrade - kill the process and restart - Logger.Info().Msg("Daemon shutting down in an attempt to restart") + l.logger.Info().Msg("daemon shutting down in an attempt to restart") _ = cmd.Process.Kill() case err := <-cmdDone: l.fw.Stop() @@ -109,12 +120,12 @@ func (l Launcher) WaitForUpgradeOrExit(cmd *exec.Cmd) (bool, error) { return true, nil } -func doBackup(cfg *Config) error { +func (l Launcher) doBackup() error { // take backup if `UNSAFE_SKIP_BACKUP` is not set. - if !cfg.UnsafeSkipBackup { + if !l.cfg.UnsafeSkipBackup { // check if upgrade-info.json is not empty. var uInfo upgradetypes.Plan - upgradeInfoFile, err := os.ReadFile(filepath.Join(cfg.Home, "data", "upgrade-info.json")) + upgradeInfoFile, err := os.ReadFile(filepath.Join(l.cfg.Home, "data", "upgrade-info.json")) if err != nil { return fmt.Errorf("error while reading upgrade-info.json: %w", err) } @@ -131,12 +142,12 @@ func doBackup(cfg *Config) error { // a destination directory, Format YYYY-MM-DD st := time.Now() stStr := fmt.Sprintf("%d-%d-%d", st.Year(), st.Month(), st.Day()) - dst := filepath.Join(cfg.DataBackupPath, fmt.Sprintf("data"+"-backup-%s", stStr)) + dst := filepath.Join(l.cfg.DataBackupPath, fmt.Sprintf("data"+"-backup-%s", stStr)) - Logger.Info().Time("backup start time", st).Msg("starting to take backup of data directory") + l.logger.Info().Time("backup start time", st).Msg("starting to take backup of data directory") // copy the $DAEMON_HOME/data to a backup dir - err = copy.Copy(filepath.Join(cfg.Home, "data"), dst) + err = copy.Copy(filepath.Join(l.cfg.Home, "data"), dst) if err != nil { return fmt.Errorf("error while taking data backup: %w", err) @@ -144,7 +155,7 @@ func doBackup(cfg *Config) error { // backup is done, lets check endtime to calculate total time taken for backup process et := time.Now() - Logger.Info().Str("backup saved at", dst).Time("backup completion time", et).TimeDiff("time taken to complete backup", et, st).Msg("backup completed") + l.logger.Info().Str("backup saved at", dst).Time("backup completion time", et).TimeDiff("time taken to complete backup", et, st).Msg("backup completed") } return nil @@ -152,38 +163,39 @@ func doBackup(cfg *Config) error { // doPreUpgrade runs the pre-upgrade command defined by the application and handles respective error codes // cfg contains the cosmovisor config from env var -func doPreUpgrade(cfg *Config) error { +func (l *Launcher) doPreUpgrade() error { counter := 0 for { - if counter > cfg.PreupgradeMaxRetries { - return fmt.Errorf("pre-upgrade command failed. reached max attempt of retries - %d", cfg.PreupgradeMaxRetries) + if counter > l.cfg.PreupgradeMaxRetries { + return fmt.Errorf("pre-upgrade command failed. reached max attempt of retries - %d", l.cfg.PreupgradeMaxRetries) } - err := executePreUpgradeCmd(cfg) + err := l.executePreUpgradeCmd() counter += 1 if err != nil { if err.(*exec.ExitError).ProcessState.ExitCode() == 1 { - Logger.Info().Msg("pre-upgrade command does not exist. continuing the upgrade.") + l.logger.Info().Msg("pre-upgrade command does not exist. continuing the upgrade.") return nil } if err.(*exec.ExitError).ProcessState.ExitCode() == 30 { return fmt.Errorf("pre-upgrade command failed : %w", err) } if err.(*exec.ExitError).ProcessState.ExitCode() == 31 { - Logger.Error().Err(err).Int("attempt", counter).Msg("pre-upgrade command failed. retrying") + l.logger.Error().Err(err).Int("attempt", counter).Msg("pre-upgrade command failed. retrying") continue } } - fmt.Println("pre-upgrade successful. continuing the upgrade.") + + l.logger.Info().Msg("pre-upgrade successful. continuing the upgrade.") return nil } } // executePreUpgradeCmd runs the pre-upgrade command defined by the application // cfg contains the cosmosvisor config from the env vars -func executePreUpgradeCmd(cfg *Config) error { - bin, err := cfg.CurrentBin() +func (l *Launcher) executePreUpgradeCmd() error { + bin, err := l.cfg.CurrentBin() if err != nil { return err } @@ -200,7 +212,6 @@ func IsSkipUpgradeHeight(args []string, upgradeInfo upgradetypes.Plan) bool { if h == int(upgradeInfo.Height) { return true } - } return false } diff --git a/cosmovisor/process_test.go b/cosmovisor/process_test.go index b0c5ceb88a35..623634277bb6 100644 --- a/cosmovisor/process_test.go +++ b/cosmovisor/process_test.go @@ -1,3 +1,4 @@ +//go:build linux // +build linux package cosmovisor_test @@ -28,17 +29,19 @@ func (s *processTestSuite) TestLaunchProcess() { require := s.Require() home := copyTestData(s.T(), "validate") cfg := &cosmovisor.Config{Home: home, Name: "dummyd", PollInterval: 20, UnsafeSkipBackup: true} + logger := cosmovisor.NewLogger() // should run the genesis binary and produce expected output - var stdout, stderr = NewBuffer(), NewBuffer() + stdout, stderr := NewBuffer(), NewBuffer() currentBin, err := cfg.CurrentBin() require.NoError(err) require.Equal(cfg.GenesisBin(), currentBin) - launcher, err := cosmovisor.NewLauncher(cfg) + launcher, err := cosmovisor.NewLauncher(logger, cfg) require.NoError(err) upgradeFile := cfg.UpgradeInfoFilePath() + args := []string{"foo", "bar", "1234", upgradeFile} doUpgrade, err := launcher.Run(args, stdout, stderr) require.NoError(err) @@ -77,6 +80,7 @@ func (s *processTestSuite) TestLaunchProcessWithDownloads() { require := s.Require() home := copyTestData(s.T(), "download") cfg := &cosmovisor.Config{Home: home, Name: "autod", AllowDownloadBinaries: true, PollInterval: 100, UnsafeSkipBackup: true} + logger := cosmovisor.NewLogger() upgradeFilename := cfg.UpgradeInfoFilePath() // should run the genesis binary and produce expected output @@ -84,10 +88,10 @@ func (s *processTestSuite) TestLaunchProcessWithDownloads() { require.NoError(err) require.Equal(cfg.GenesisBin(), currentBin) - launcher, err := cosmovisor.NewLauncher(cfg) + launcher, err := cosmovisor.NewLauncher(logger, cfg) require.NoError(err) - var stdout, stderr = NewBuffer(), NewBuffer() + stdout, stderr := NewBuffer(), NewBuffer() args := []string{"some", "args", upgradeFilename} doUpgrade, err := launcher.Run(args, stdout, stderr) diff --git a/cosmovisor/scanner.go b/cosmovisor/scanner.go index 4dbcb13d7f8d..7ed696f48150 100644 --- a/cosmovisor/scanner.go +++ b/cosmovisor/scanner.go @@ -6,12 +6,16 @@ import ( "fmt" "os" "path/filepath" + "strings" "time" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/rs/zerolog" ) type fileWatcher struct { + logger *zerolog.Logger + // full path to a watched file filename string interval time.Duration @@ -25,22 +29,34 @@ type fileWatcher struct { initialized bool } -func newUpgradeFileWatcher(filename string, interval time.Duration) (*fileWatcher, error) { +func newUpgradeFileWatcher(logger *zerolog.Logger, filename string, interval time.Duration) (*fileWatcher, error) { if filename == "" { return nil, errors.New("filename undefined") } + filenameAbs, err := filepath.Abs(filename) if err != nil { return nil, - fmt.Errorf("wrong path, %s must be a valid file path, [%w]", filename, err) + fmt.Errorf("invalid path; %s must be a valid file path: %w", filename, err) } + dirname := filepath.Dir(filename) info, err := os.Stat(dirname) if err != nil || !info.IsDir() { - return nil, fmt.Errorf("wrong path, %s must be an existing directory, [%w]", dirname, err) + return nil, fmt.Errorf("invalid path; %s must be an existing directory: %w", dirname, err) } - return &fileWatcher{filenameAbs, interval, upgradetypes.Plan{}, time.Time{}, make(chan bool), time.NewTicker(interval), false, false}, nil + return &fileWatcher{ + logger: logger, + filename: filenameAbs, + interval: interval, + currentInfo: upgradetypes.Plan{}, + lastModTime: time.Time{}, + cancel: make(chan bool), + ticker: time.NewTicker(interval), + needsUpdate: false, + initialized: false, + }, nil } func (fw *fileWatcher) Stop() { @@ -64,11 +80,13 @@ func (fw *fileWatcher) MonitorUpdate(currentUpgrade upgradetypes.Plan) <-chan st done <- struct{}{} return } + case <-fw.cancel: return } } }() + return done } @@ -79,25 +97,33 @@ func (fw *fileWatcher) CheckUpdate(currentUpgrade upgradetypes.Plan) bool { if fw.needsUpdate { return true } + stat, err := os.Stat(fw.filename) - if err != nil { // file doesn't exists + if err != nil { + // file doesn't exists return false } + if !stat.ModTime().After(fw.lastModTime) { return false } + info, err := parseUpgradeInfoFile(fw.filename) if err != nil { - Logger.Fatal().Err(err).Msg("Can't parse upgrade info file") + fw.logger.Fatal().Err(err).Msg("failed to parse upgrade info file") return false } - if !fw.initialized { // daemon has restarted + + if !fw.initialized { + // daemon has restarted fw.initialized = true fw.currentInfo = info fw.lastModTime = stat.ModTime() - // heuristic: deamon has restarted, so we don't know if we successfully downloaded the upgrade or not. - // so we try to compare the running upgrade name (read from the cosmovisor file) with the upgrade info - if currentUpgrade.Name != fw.currentInfo.Name { + + // Heuristic: Deamon has restarted, so we don't know if we successfully + // downloaded the upgrade or not. So we try to compare the running upgrade + // name (read from the cosmovisor file) with the upgrade info. + if !strings.EqualFold(currentUpgrade.Name, fw.currentInfo.Name) { fw.needsUpdate = true return true } @@ -109,24 +135,32 @@ func (fw *fileWatcher) CheckUpdate(currentUpgrade upgradetypes.Plan) bool { fw.needsUpdate = true return true } + return false } func parseUpgradeInfoFile(filename string) (upgradetypes.Plan, error) { var ui upgradetypes.Plan + f, err := os.Open(filename) if err != nil { - return ui, err + return upgradetypes.Plan{}, err } defer f.Close() + d := json.NewDecoder(f) - err = d.Decode(&ui) - if err != nil { - return ui, err + if err := d.Decode(&ui); err != nil { + return upgradetypes.Plan{}, err } + // required values must be set - if ui.Height == 0 || ui.Name == "" { - return upgradetypes.Plan{}, fmt.Errorf("invalid upgrade-info.json content. Name and Hight must be not empty. Got: %v", ui) + if ui.Height <= 0 || ui.Name == "" { + return upgradetypes.Plan{}, fmt.Errorf("invalid upgrade-info.json content; name and height must be not empty; got: %v", ui) } + + // Normalize name to prevent operator error in upgrade name case sensitivity + // errors. + ui.Name = strings.ToLower(ui.Name) + return ui, err } diff --git a/cosmovisor/testdata/download/cosmovisor/genesis/bin/autod b/cosmovisor/testdata/download/cosmovisor/genesis/bin/autod index 8eb6d32fe565..89cb77365a14 100755 --- a/cosmovisor/testdata/download/cosmovisor/genesis/bin/autod +++ b/cosmovisor/testdata/download/cosmovisor/genesis/bin/autod @@ -6,7 +6,7 @@ echo 'ERROR: UPGRADE "chain2" NEEDED at height: 49: zip_binary' # create upgrade info # this info contains directly information about binaries (in chain2->chain3 update we test with info containing a link to the file with an address for the new chain binary) -echo '{"name":"chain2","height":49,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/cosmos/cosmos-sdk/raw/master/cosmovisor/testdata/repo/chain2-zip_bin/autod.zip?checksum=sha256:e2e178953d176196dcf736afa821121b259697ab4df90582044c313bcae48f13\"}}"}' > $3 +echo '{"name":"chain2","height":49,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/cosmos/cosmos-sdk/raw/main/cosmovisor/testdata/repo/chain2-zip_bin/autod.zip?checksum=sha256:b30cf0b1a3e46ac9587cc4d7b102eb796e39e3e0dfa3f8ca6e163fc1b1e913ca\"}}"}' >$3 sleep 0.1 echo Never should be printed!!! diff --git a/cosmovisor/testdata/repo/chain2-zip_bin/autod b/cosmovisor/testdata/repo/chain2-zip_bin/autod index 40cbf0fcb405..5bc99c552123 100755 --- a/cosmovisor/testdata/repo/chain2-zip_bin/autod +++ b/cosmovisor/testdata/repo/chain2-zip_bin/autod @@ -6,8 +6,8 @@ echo Args: $@ echo 'ERROR: UPGRADE "chain3" NEEDED at height: 936: ref_to_chain3-zip_dir.json module=main' # this update info doesn't contain binaries, instead it is a reference for further download instructions. -# echo '{"name":"chain3","height":936,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/cosmos/cosmos-sdk/raw/master/cosmovisor/testdata/repo/ref_to_chain3-zip_dir.json\"}}"}' > $3 -echo '{"name":"chain3","height":936,"info":"https://github.com/cosmos/cosmos-sdk/raw/master/cosmovisor/testdata/repo/ref_to_chain3-zip_dir.json"}' > $3 +# echo '{"name":"chain3","height":936,"info":"{\"binaries\":{\"linux/amd64\":\"https://github.com/cosmos/cosmos-sdk/raw/main/cosmovisor/testdata/repo/ref_to_chain3-zip_dir.json\"}}"}' > $3 +echo '{"name":"chain3","height":936,"info":"https://github.com/cosmos/cosmos-sdk/raw/main/cosmovisor/testdata/repo/ref_to_chain3-zip_dir.json"}' >$3 sleep 1 echo 'Do not print' diff --git a/cosmovisor/testdata/repo/chain2-zip_bin/autod.zip b/cosmovisor/testdata/repo/chain2-zip_bin/autod.zip index a61e2e37918c..68d33a538c5b 100644 Binary files a/cosmovisor/testdata/repo/chain2-zip_bin/autod.zip and b/cosmovisor/testdata/repo/chain2-zip_bin/autod.zip differ diff --git a/cosmovisor/testdata/repo/ref_to_chain3-zip_dir.json b/cosmovisor/testdata/repo/ref_to_chain3-zip_dir.json index 78128c58f422..7baa216b9633 100644 --- a/cosmovisor/testdata/repo/ref_to_chain3-zip_dir.json +++ b/cosmovisor/testdata/repo/ref_to_chain3-zip_dir.json @@ -1,5 +1,5 @@ { - "binaries": { - "linux/amd64": "https://github.com/cosmos/cosmos-sdk/raw/master/cosmovisor/testdata/repo/chain3-zip_dir/autod.zip?checksum=sha256:8951f52a0aea8617de0ae459a20daf704c29d259c425e60d520e363df0f166b4" - } + "binaries": { + "linux/amd64": "https://github.com/cosmos/cosmos-sdk/raw/main/cosmovisor/testdata/repo/chain3-zip_dir/autod.zip?checksum=sha256:8951f52a0aea8617de0ae459a20daf704c29d259c425e60d520e363df0f166b4" + } } diff --git a/cosmovisor/upgrade.go b/cosmovisor/upgrade.go index a91b40cea8d8..9667ffb5ede4 100644 --- a/cosmovisor/upgrade.go +++ b/cosmovisor/upgrade.go @@ -10,16 +10,16 @@ import ( "runtime" "strings" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/hashicorp/go-getter" "github.com/otiai10/copy" - - upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/rs/zerolog" ) // DoUpgrade will be called after the log message has been parsed and the process has terminated. // We can now make any changes to the underlying directory without interference and leave it // in a state, so we can make a proper restart -func DoUpgrade(cfg *Config, info upgradetypes.Plan) error { +func DoUpgrade(logger *zerolog.Logger, cfg *Config, info upgradetypes.Plan) error { // Simplest case is to switch the link err := EnsureBinary(cfg.UpgradeBin(info.Name)) if err == nil { @@ -37,11 +37,11 @@ func DoUpgrade(cfg *Config, info upgradetypes.Plan) error { } // If not there, then we try to download it... maybe - Logger.Info().Msg("No upgrade binary found, beginning to download it") + logger.Info().Msg("no upgrade binary found, beginning to download it") if err := DownloadBinary(cfg, info); err != nil { return fmt.Errorf("cannot download binary. %w", err) } - Logger.Info().Msg("Downloading binary complete") + logger.Info().Msg("downloading binary complete") // and then set the binary again if err := EnsureBinary(cfg.UpgradeBin(info.Name)); err != nil { @@ -91,11 +91,11 @@ func MarkExecutable(path string) error { return fmt.Errorf("stating binary: %w", err) } // end early if world exec already set - if info.Mode()&0001 == 1 { + if info.Mode()&0o001 == 1 { return nil } // now try to set all exec bits - newMode := info.Mode().Perm() | 0111 + newMode := info.Mode().Perm() | 0o111 return os.Chmod(path, newMode) } @@ -162,7 +162,7 @@ func EnsureBinary(path string) error { } // this checks if the world-executable bit is set (we cannot check owner easily) - exec := info.Mode().Perm() & 0001 + exec := info.Mode().Perm() & 0o001 if exec == 0 { return fmt.Errorf("%s is not world executable", info.Name()) } diff --git a/cosmovisor/upgrade_test.go b/cosmovisor/upgrade_test.go index 9002ff4066bb..44a611222d11 100644 --- a/cosmovisor/upgrade_test.go +++ b/cosmovisor/upgrade_test.go @@ -95,6 +95,7 @@ func (s *upgradeTestSuite) assertCurrentLink(cfg cosmovisor.Config, target strin func (s *upgradeTestSuite) TestDoUpgradeNoDownloadUrl() { home := copyTestData(s.T(), "validate") cfg := &cosmovisor.Config{Home: home, Name: "dummyd", AllowDownloadBinaries: true} + logger := cosmovisor.NewLogger() currentBin, err := cfg.CurrentBin() s.Require().NoError(err) @@ -104,7 +105,7 @@ func (s *upgradeTestSuite) TestDoUpgradeNoDownloadUrl() { // do upgrade ignores bad files for _, name := range []string{"missing", "nobin", "noexec"} { info := upgradetypes.Plan{Name: name} - err = cosmovisor.DoUpgrade(cfg, info) + err = cosmovisor.DoUpgrade(logger, cfg, info) s.Require().Error(err, name) currentBin, err := cfg.CurrentBin() s.Require().NoError(err) @@ -115,7 +116,7 @@ func (s *upgradeTestSuite) TestDoUpgradeNoDownloadUrl() { for _, upgrade := range []string{"chain2", "chain3"} { // now set it to a valid upgrade and make sure CurrentBin is now set properly info := upgradetypes.Plan{Name: upgrade} - err = cosmovisor.DoUpgrade(cfg, info) + err = cosmovisor.DoUpgrade(logger, cfg, info) s.Require().NoError(err) // we should see current point to the new upgrade dir upgradeBin := cfg.UpgradeBin(upgrade) @@ -154,7 +155,7 @@ func (s *upgradeTestSuite) TestGetDownloadURL() { }, "follow reference": { info: ref, - url: "https://github.com/cosmos/cosmos-sdk/raw/master/cosmovisor/testdata/repo/chain3-zip_dir/autod.zip?checksum=sha256:8951f52a0aea8617de0ae459a20daf704c29d259c425e60d520e363df0f166b4", + url: "https://github.com/cosmos/cosmos-sdk/raw/main/cosmovisor/testdata/repo/chain3-zip_dir/autod.zip?checksum=sha256:8951f52a0aea8617de0ae459a20daf704c29d259c425e60d520e363df0f166b4", }, "malformated reference target": { info: badref, diff --git a/crypto/armor.go b/crypto/armor.go index 2a45e67ce586..1da3e9703326 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -148,7 +148,6 @@ func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase string, algo st func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) { saltBytes = crypto.CRandBytes(16) key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter) - if err != nil { panic(sdkerrors.Wrap(err, "error generating bcrypt key from passphrase")) } diff --git a/crypto/hd/algo.go b/crypto/hd/algo.go index 5f9965a24531..0feb4ff49b47 100644 --- a/crypto/hd/algo.go +++ b/crypto/hd/algo.go @@ -22,21 +22,20 @@ const ( Sr25519Type = PubKeyType("sr25519") ) -var ( - // Secp256k1 uses the Bitcoin secp256k1 ECDSA parameters. - Secp256k1 = secp256k1Algo{} -) +// Secp256k1 uses the Bitcoin secp256k1 ECDSA parameters. +var Secp256k1 = secp256k1Algo{} -type DeriveFn func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) -type GenerateFn func(bz []byte) types.PrivKey +type ( + DeriveFn func(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) + GenerateFn func(bz []byte) types.PrivKey +) type WalletGenerator interface { Derive(mnemonic string, bip39Passphrase, hdPath string) ([]byte, error) Generate(bz []byte) types.PrivKey } -type secp256k1Algo struct { -} +type secp256k1Algo struct{} func (s secp256k1Algo) Name() PubKeyType { return Secp256k1Type @@ -63,7 +62,7 @@ func (s secp256k1Algo) Derive() DeriveFn { // Generate generates a secp256k1 private key from the given bytes. func (s secp256k1Algo) Generate() GenerateFn { return func(bz []byte) types.PrivKey { - var bzArr = make([]byte, secp256k1.PrivKeySize) + bzArr := make([]byte, secp256k1.PrivKeySize) copy(bzArr, bz) return &secp256k1.PrivKey{Key: bzArr} diff --git a/crypto/hd/fundraiser_test.go b/crypto/hd/fundraiser_test.go index 9cd3b15dfd50..674ab95c71c8 100644 --- a/crypto/hd/fundraiser_test.go +++ b/crypto/hd/fundraiser_test.go @@ -7,10 +7,8 @@ import ( "os" "testing" - "github.com/stretchr/testify/require" - "github.com/cosmos/go-bip39" - + "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/crypto/hd" diff --git a/crypto/hd/hdpath_test.go b/crypto/hd/hdpath_test.go index 42abd023870a..6ea418b92db3 100644 --- a/crypto/hd/hdpath_test.go +++ b/crypto/hd/hdpath_test.go @@ -5,11 +5,11 @@ import ( "fmt" "testing" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/go-bip39" "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/types" ) var defaultBIP39Passphrase = "" @@ -89,7 +89,6 @@ func TestParamsFromPath(t *testing.T) { require.Nil(t, params, errStr) require.Error(t, err, errStr) } - } func TestCreateHDPath(t *testing.T) { @@ -300,7 +299,7 @@ func TestDerivePrivateKeyForPathDoNotCrash(t *testing.T) { for _, path := range paths { path := path t.Run(path, func(t *testing.T) { - hd.DerivePrivateKeyForPath([32]byte{}, [32]byte{}, path) + _, _ = hd.DerivePrivateKeyForPath([32]byte{}, [32]byte{}, path) }) } } diff --git a/crypto/keyring/doc.go b/crypto/keyring/doc.go index 04a8b98cdfba..b642680c0662 100644 --- a/crypto/keyring/doc.go +++ b/crypto/keyring/doc.go @@ -1,17 +1,11 @@ // Package keys provides common key management API. // // -// The Keybase interface +// The Keyring interface // -// The Keybase interface defines the methods that a type needs to implement to be used +// The Keyring interface defines the methods that a type needs to implement to be used // as key storage backend. This package provides few implementations out-of-the-box. // -// NewLegacy -// -// The NewLegacy constructor returns an on-disk implementation backed by LevelDB storage that has been -// the default implementation used by the SDK until v0.38.0. Due to security concerns, it is -// recommended to drop it in favor of the NewKeyring constructor as it will be removed in future releases. -// // NewInMemory // // The NewInMemory constructor returns an implementation backed by an in-memory, goroutine-safe diff --git a/crypto/keyring/keyring.go b/crypto/keyring/keyring.go index 7cd3bd310730..303b0ed07fce 100644 --- a/crypto/keyring/keyring.go +++ b/crypto/keyring/keyring.go @@ -100,13 +100,6 @@ type Keyring interface { Migrator } -// UnsafeKeyring exposes unsafe operations such as unsafe unarmored export in -// addition to those that are made available by the Keyring interface. -type UnsafeKeyring interface { - Keyring - UnsafeExporter -} - // Signer is implemented by key stores that want to provide signing capabilities. type Signer interface { // Sign sign byte messages with a user key. @@ -125,9 +118,9 @@ type Importer interface { ImportPubKey(uid string, armor string) error } -// Migrator is implemented by key stores and enables migration of keys from amino to proto +// Migrator is implemented by key stores and enables migration of keys from amino to proto type Migrator interface { - MigrateAll() (bool, error) + MigrateAll() error } // Exporter is implemented by key stores that support export of public and private keys. @@ -142,13 +135,6 @@ type Exporter interface { ExportPrivKeyArmorByAddress(address sdk.Address, encryptPassphrase string) (armor string, err error) } -// UnsafeExporter is implemented by key stores that support unsafe export -// of private keys' material. -type UnsafeExporter interface { - // UnsafeExportPrivKeyHex returns a private key in unarmored hex format - UnsafeExportPrivKeyHex(uid string) (string, error) -} - // Option overrides keyring configuration options. type Option func(options *Options) @@ -500,7 +486,7 @@ func wrapKeyNotFound(err error, msg string) error { } func (ks keystore) List() ([]*Record, error) { - if _, err := ks.MigrateAll(); err != nil { + if err := ks.MigrateAll(); err != nil { return nil, err } @@ -512,7 +498,7 @@ func (ks keystore) List() ([]*Record, error) { var res []*Record //nolint:prealloc sort.Strings(keys) for _, key := range keys { - if strings.Contains(key, addressSuffix) { + if strings.HasSuffix(key, addressSuffix) { continue } @@ -597,7 +583,7 @@ func (ks keystore) isSupportedSigningAlgo(algo SignatureAlgo) bool { } func (ks keystore) Key(uid string) (*Record, error) { - k, _, err := ks.migrate(uid) + k, err := ks.migrate(uid) if err != nil { return nil, err } @@ -778,7 +764,11 @@ func (ks keystore) writeLocalKey(name string, privKey types.PrivKey) (*Record, e return k, ks.writeRecord(k) } -// writeRecord persists a keyring item in keystore if it does not exist there +// writeRecord persists a keyring item in keystore if it does not exist there. +// For each key record, we actually write 2 items: +// - one with key `.info`, with Data = the serialized protobuf key +// - another with key `.address`, with Data = the uid (i.e. the key name) +// This is to be able to query keys both by name and by address. func (ks keystore) writeRecord(k *Record) error { addr, err := k.GetAddress() if err != nil { @@ -797,7 +787,7 @@ func (ks keystore) writeRecord(k *Record) error { serializedRecord, err := ks.cdc.Marshal(k) if err != nil { - return fmt.Errorf("unable to serialize record, err - %s", err) + return fmt.Errorf("unable to serialize record; %+w", err) } item := keyring.Item{ @@ -871,83 +861,96 @@ func (ks keystore) writeMultisigKey(name string, pk types.PubKey) (*Record, erro return k, ks.writeRecord(k) } -func (ks keystore) MigrateAll() (bool, error) { +func (ks keystore) MigrateAll() error { keys, err := ks.db.Keys() if err != nil { - return false, err + return err } if len(keys) == 0 { - return false, nil + return nil } - var migrated bool for _, key := range keys { - if strings.Contains(key, addressSuffix) { + // The keyring items with `.address` suffix only holds as Data the + // key name uid, so there's nothing to migrate. + if strings.HasSuffix(key, addressSuffix) { continue } - _, migrated2, err := ks.migrate(key) + _, err := ks.migrate(key) if err != nil { - fmt.Printf("migrate err: %q", err) + fmt.Printf("migrate err for key %s: %q\n", key, err) continue } - - if migrated2 { - migrated = true - } } - return migrated, nil + return nil } // migrate converts keyring.Item from amino to proto serialization format. -func (ks keystore) migrate(key string) (*Record, bool, error) { - if !(strings.HasSuffix(key, infoSuffix)) && !(strings.HasPrefix(key, sdk.Bech32PrefixAccAddr)) { +// the `key` argument can be a key uid (e.g. "alice") or with the '.info' +// suffix (e.g. "alice.info"). +// +// It operates as follows: +// 1. retrieve any key +// 2. try to decode it using protobuf +// 3. if ok, then return the key, do nothing else +// 4. if it fails, then try to decode it using amino +// 5. convert from the amino struct to the protobuf struct +// 6. write the proto-encoded key back to the keyring +func (ks keystore) migrate(key string) (*Record, error) { + if !strings.HasSuffix(key, infoSuffix) { key = infoKey(key) } + + // 1. get the key. item, err := ks.db.Get(key) if err != nil { - return nil, false, wrapKeyNotFound(err, key) + return nil, wrapKeyNotFound(err, key) } if len(item.Data) == 0 { - return nil, false, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, key) + return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, key) } - // 2.try to deserialize using proto, if good then continue, otherwise try to deserialize using amino + // 2. Try to deserialize using proto k, err := ks.protoUnmarshalRecord(item.Data) + // 3. If ok then return the key if err == nil { - return k, false, nil + return k, nil } - LegacyInfo, err := unMarshalLegacyInfo(item.Data) + // 4. Try to decode with amino + legacyInfo, err := unMarshalLegacyInfo(item.Data) if err != nil { - return nil, false, fmt.Errorf("unable to unmarshal item.Data, err: %w", err) + return nil, fmt.Errorf("unable to unmarshal item.Data, err: %w", err) } - // 4.serialize info using proto - k, err = ks.convertFromLegacyInfo(LegacyInfo) + // 5. Convert and serialize info using proto + k, err = ks.convertFromLegacyInfo(legacyInfo) if err != nil { - return nil, false, fmt.Errorf("convertFromLegacyInfo, err: %w", err) + return nil, fmt.Errorf("convertFromLegacyInfo, err: %w", err) } serializedRecord, err := ks.cdc.Marshal(k) if err != nil { - return nil, false, fmt.Errorf("unable to serialize record, err: %w", err) + return nil, fmt.Errorf("unable to serialize record, err: %w", err) } item = keyring.Item{ - Key: key, - Data: serializedRecord, - Description: "SDK kerying version", + Key: key, + Data: serializedRecord, } - // 5.overwrite the keyring entry with + + // 6. Overwrite the keyring entry with the new proto-encoded key. if err := ks.SetItem(item); err != nil { - return nil, false, fmt.Errorf("unable to set keyring.Item, err: %w", err) + return nil, fmt.Errorf("unable to set keyring.Item, err: %w", err) } - return k, true, nil + fmt.Printf("Successfully migrated key %s.\n", key) + + return k, nil } func (ks keystore) protoUnmarshalRecord(bz []byte) (*Record, error) { @@ -996,29 +999,6 @@ func (ks keystore) convertFromLegacyInfo(info LegacyInfo) (*Record, error) { } } -type unsafeKeystore struct { - keystore -} - -// NewUnsafe returns a new keyring that provides support for unsafe operations. -func NewUnsafe(kr Keyring) UnsafeKeyring { - // The type assertion is against the only keystore - // implementation that is currently provided. - ks := kr.(keystore) - - return unsafeKeystore{ks} -} - -// UnsafeExportPrivKeyHex exports private keys in unarmored hexadecimal format. -func (ks unsafeKeystore) UnsafeExportPrivKeyHex(uid string) (privkey string, err error) { - priv, err := ks.ExportPrivateKeyObject(uid) - if err != nil { - return "", err - } - - return hex.EncodeToString(priv.Bytes()), nil -} - func addrHexKeyAsString(address sdk.Address) string { return fmt.Sprintf("%s.%s", hex.EncodeToString(address.Bytes()), addressSuffix) } diff --git a/crypto/keyring/keyring_ledger_test.go b/crypto/keyring/keyring_ledger_test.go index b57351ba947a..6845b6088212 100644 --- a/crypto/keyring/keyring_ledger_test.go +++ b/crypto/keyring/keyring_ledger_test.go @@ -19,7 +19,6 @@ func TestInMemoryCreateLedger(t *testing.T) { kb := NewInMemory(cdc) k, err := kb.SaveLedgerKey("some_account", hd.Secp256k1, "cosmos", 118, 3, 1) - if err != nil { require.Error(t, err) require.Equal(t, "ledger nano S: support for ledger devices is not available in this executable", err.Error()) diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index ad3e109b74d0..a0a006b4f112 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -1077,19 +1077,19 @@ func TestNonConsistentKeyring_SavePubKey(t *testing.T) { priv := ed25519.GenPrivKey() pub := priv.PubKey() - k, err := kr.SaveOfflineKey(key, pub) - require.Nil(t, err) + _, err = kr.SaveOfflineKey(key, pub) + require.NoError(t, err) // broken keyring state test unsafeKr, ok := kr.(keystore) require.True(t, ok) // we lost public key for some reason, but still have an address record - unsafeKr.db.Remove(infoKey(key)) + require.NoError(t, unsafeKr.db.Remove(infoKey(key))) list, err = kr.List() require.NoError(t, err) require.Equal(t, 0, len(list)) - k, err = kr.SaveOfflineKey(key, pub) + k, err := kr.SaveOfflineKey(key, pub) require.Nil(t, err) pubKey, err := k.GetPubKey() require.NoError(t, err) @@ -1287,17 +1287,13 @@ func TestAltKeyring_UnsafeExportPrivKeyHex(t *testing.T) { _, _, err = kr.NewMnemonic(uid, English, sdk.FullFundraiserPath, DefaultBIP39Passphrase, hd.Secp256k1) require.NoError(t, err) - unsafeKeyring := NewUnsafe(kr) - privKey, err := unsafeKeyring.UnsafeExportPrivKeyHex(uid) - - require.NoError(t, err) - require.Equal(t, 64, len(privKey)) + privKey, err := kr.(keystore).ExportPrivateKeyObject(uid) - _, err = hex.DecodeString(privKey) require.NoError(t, err) + require.Equal(t, 64, len(hex.EncodeToString(privKey.Bytes()))) // test error on non existing key - _, err = unsafeKeyring.UnsafeExportPrivKeyHex("non-existing") + _, err = kr.(keystore).ExportPrivateKeyObject("non-existing") require.Error(t, err) } diff --git a/crypto/keyring/legacy_info.go b/crypto/keyring/legacy_info.go index 8b05b6a0312c..8de45feb1be2 100644 --- a/crypto/keyring/legacy_info.go +++ b/crypto/keyring/legacy_info.go @@ -255,7 +255,6 @@ func unMarshalLegacyInfo(bz []byte) (info LegacyInfo, err error) { // privKeyFromLegacyInfo exports a private key from LegacyInfo func privKeyFromLegacyInfo(info LegacyInfo) (cryptotypes.PrivKey, error) { - switch linfo := info.(type) { case legacyLocalInfo: if linfo.PrivKeyArmor == "" { diff --git a/crypto/keyring/migration_test.go b/crypto/keyring/migration_test.go index cfe55bd657a9..2435671e4e47 100644 --- a/crypto/keyring/migration_test.go +++ b/crypto/keyring/migration_test.go @@ -16,7 +16,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -const n1 = "cosmos" +const n1 = "cosmos.info" type MigrationTestSuite struct { suite.Suite @@ -57,8 +57,7 @@ func (s *MigrationTestSuite) TestMigrateLegacyLocalKey() { s.Require().NoError(s.ks.SetItem(item)) - _, migrated, err := s.ks.migrate(n1) - s.Require().True(migrated) + _, err := s.ks.migrate(n1) s.Require().NoError(err) } @@ -76,8 +75,7 @@ func (s *MigrationTestSuite) TestMigrateLegacyLedgerKey() { s.Require().NoError(s.ks.SetItem(item)) - _, migrated, err := s.ks.migrate(n1) - s.Require().True(migrated) + _, err := s.ks.migrate(n1) s.Require().NoError(err) } @@ -93,8 +91,7 @@ func (s *MigrationTestSuite) TestMigrateLegacyOfflineKey() { s.Require().NoError(s.ks.SetItem(item)) - _, migrated, err := s.ks.migrate(n1) - s.Require().True(migrated) + _, err := s.ks.migrate(n1) s.Require().NoError(err) } @@ -117,8 +114,7 @@ func (s *MigrationTestSuite) TestMigrateLegacyMultiKey() { s.Require().NoError(s.ks.SetItem(item)) - _, migrated, err := s.ks.migrate(n1) - s.Require().True(migrated) + _, err = s.ks.migrate(n1) s.Require().NoError(err) } @@ -137,7 +133,7 @@ func (s *MigrationTestSuite) TestMigrateLocalRecord() { s.Require().NoError(s.ks.SetItem(item)) - k2, migrated, err := s.ks.migrate(n1) + k2, err := s.ks.migrate(n1) s.Require().Equal(k2.Name, k1.Name) pub, err := k2.GetPubKey() @@ -148,7 +144,6 @@ func (s *MigrationTestSuite) TestMigrateLocalRecord() { s.Require().NoError(err) s.Require().Equal(priv, s.priv) - s.Require().False(migrated) s.Require().NoError(err) } @@ -162,8 +157,7 @@ func (s *MigrationTestSuite) TestMigrateOneRandomItemError() { s.Require().NoError(s.ks.SetItem(errItem)) - _, migrated, err := s.ks.migrate(n1) - s.Require().False(migrated) + _, err := s.ks.migrate(n1) s.Require().Error(err) } @@ -197,14 +191,12 @@ func (s *MigrationTestSuite) TestMigrateAllLegacyMultiOffline() { s.Require().NoError(s.ks.SetItem(item)) - migrated, err := s.kb.MigrateAll() - s.Require().True(migrated) + err = s.kb.MigrateAll() s.Require().NoError(err) } func (s *MigrationTestSuite) TestMigrateAllNoItem() { - migrated, err := s.kb.MigrateAll() - s.Require().False(migrated) + err := s.kb.MigrateAll() s.Require().NoError(err) } @@ -221,9 +213,8 @@ func (s *MigrationTestSuite) TestMigrateErrUnknownItemKey() { s.Require().NoError(s.ks.SetItem(item)) incorrectItemKey := n1 + "1" - _, migrated, err := s.ks.migrate(incorrectItemKey) - s.Require().False(migrated) - s.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, incorrectItemKey).Error()) + _, err := s.ks.migrate(incorrectItemKey) + s.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, infoKey(incorrectItemKey)).Error()) } func (s *MigrationTestSuite) TestMigrateErrEmptyItemData() { @@ -235,10 +226,10 @@ func (s *MigrationTestSuite) TestMigrateErrEmptyItemData() { s.Require().NoError(s.ks.SetItem(item)) - _, migrated, err := s.ks.migrate(n1) - s.Require().False(migrated) + _, err := s.ks.migrate(n1) s.Require().EqualError(err, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, n1).Error()) } + func TestMigrationTestSuite(t *testing.T) { suite.Run(t, new(MigrationTestSuite)) } diff --git a/crypto/keyring/record.go b/crypto/keyring/record.go index acc84f6490b1..1b1885648e5e 100644 --- a/crypto/keyring/record.go +++ b/crypto/keyring/record.go @@ -28,7 +28,7 @@ func NewLocalRecord(name string, priv cryptotypes.PrivKey, pk cryptotypes.PubKey return nil, err } - recordLocal := &Record_Local{any, priv.Type()} + recordLocal := &Record_Local{any} recordLocalItem := &Record_Local_{recordLocal} return newRecord(name, pk, recordLocalItem) diff --git a/crypto/keyring/record.pb.go b/crypto/keyring/record.pb.go index c94e1ce0faa8..5e8df719a5c6 100644 --- a/crypto/keyring/record.pb.go +++ b/crypto/keyring/record.pb.go @@ -146,8 +146,7 @@ func (*Record) XXX_OneofWrappers() []interface{} { // Item is a keyring item stored in a keyring backend. // Local item type Record_Local struct { - PrivKey *types.Any `protobuf:"bytes,1,opt,name=priv_key,json=privKey,proto3" json:"priv_key,omitempty"` - PrivKeyType string `protobuf:"bytes,2,opt,name=priv_key_type,json=privKeyType,proto3" json:"priv_key_type,omitempty"` + PrivKey *types.Any `protobuf:"bytes,1,opt,name=priv_key,json=privKey,proto3" json:"priv_key,omitempty"` } func (m *Record_Local) Reset() { *m = Record_Local{} } @@ -308,34 +307,33 @@ func init() { } var fileDescriptor_36d640103edea005 = []byte{ - // 424 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x4d, 0x8b, 0xd4, 0x30, - 0x18, 0xc7, 0x5b, 0xed, 0xb4, 0x4e, 0x16, 0x2f, 0x61, 0x0f, 0xb5, 0x48, 0x19, 0x16, 0xd4, 0x01, - 0xd9, 0x84, 0xd5, 0x39, 0x2f, 0xec, 0xe0, 0x61, 0x16, 0x15, 0x97, 0xe0, 0x49, 0x84, 0xa5, 0x2f, - 0x99, 0xb6, 0x4c, 0xdb, 0x84, 0x4c, 0x3b, 0x90, 0x2f, 0x21, 0x7e, 0xac, 0x3d, 0xee, 0xd1, 0xa3, - 0xce, 0x7c, 0x11, 0xc9, 0x93, 0xf6, 0xe0, 0x82, 0x8e, 0xa7, 0xa6, 0xe4, 0xf7, 0xfc, 0x5f, 0x1e, - 0x82, 0x5e, 0x64, 0x62, 0xdb, 0x88, 0x2d, 0xcd, 0x94, 0x96, 0x9d, 0xa0, 0x1b, 0xae, 0x55, 0xd5, - 0x16, 0x74, 0x77, 0x41, 0x15, 0xcf, 0x84, 0xca, 0x89, 0x54, 0xa2, 0x13, 0x38, 0xb4, 0x18, 0xb1, - 0x18, 0x19, 0x30, 0xb2, 0xbb, 0x88, 0x4e, 0x0b, 0x51, 0x08, 0x80, 0xa8, 0x39, 0x59, 0x3e, 0x7a, - 0x56, 0x08, 0x51, 0xd4, 0x9c, 0xc2, 0x5f, 0xda, 0xaf, 0x69, 0xd2, 0xea, 0xe1, 0xea, 0xf9, 0x9f, - 0x8e, 0x65, 0x6e, 0xcc, 0xca, 0xc1, 0xe8, 0xec, 0x9b, 0x87, 0x7c, 0x06, 0xce, 0x18, 0x23, 0xaf, - 0x4d, 0x1a, 0x1e, 0xba, 0x33, 0x77, 0x3e, 0x65, 0x70, 0xc6, 0xe7, 0x28, 0x90, 0x7d, 0x7a, 0xbb, - 0xe1, 0x3a, 0x7c, 0x34, 0x73, 0xe7, 0x27, 0x6f, 0x4e, 0x89, 0x75, 0x22, 0xa3, 0x13, 0xb9, 0x6a, - 0x35, 0xf3, 0x65, 0x9f, 0xbe, 0xe7, 0x1a, 0x5f, 0xa2, 0x49, 0x2d, 0xb2, 0xa4, 0x0e, 0x1f, 0x03, - 0xfc, 0x92, 0xfc, 0xad, 0x06, 0xb1, 0x9e, 0xe4, 0x83, 0xa1, 0x57, 0x0e, 0xb3, 0x63, 0xf8, 0x0a, - 0xf9, 0x35, 0xcf, 0x0b, 0xae, 0x42, 0x0f, 0x04, 0x5e, 0x1d, 0x17, 0x00, 0x7c, 0xe5, 0xb0, 0x61, - 0xd0, 0x44, 0x68, 0xfa, 0xba, 0xab, 0xc2, 0xc9, 0x7f, 0x46, 0xf8, 0x68, 0x68, 0x13, 0x01, 0xc6, - 0xf0, 0x3b, 0x14, 0x88, 0xf5, 0xba, 0xae, 0x5a, 0x1e, 0xfa, 0xa0, 0x30, 0x3f, 0xaa, 0xf0, 0xc9, - 0xf2, 0x2b, 0x87, 0x8d, 0xa3, 0xd1, 0x57, 0x34, 0x81, 0x6a, 0x98, 0xa2, 0x27, 0x52, 0x55, 0x3b, - 0xd8, 0xa0, 0xfb, 0x8f, 0x0d, 0x06, 0x86, 0x32, 0x2b, 0x3c, 0x43, 0x4f, 0xc7, 0x81, 0xdb, 0x4e, - 0x4b, 0x0e, 0x7b, 0x9f, 0xb2, 0x93, 0xe1, 0xfe, 0xb3, 0x96, 0x3c, 0xba, 0x44, 0xbe, 0xed, 0x8d, - 0x17, 0xc8, 0x93, 0x49, 0x57, 0x0e, 0xd2, 0xb3, 0x07, 0x51, 0xcb, 0xdc, 0xa4, 0x5c, 0x5e, 0xdf, - 0x2c, 0x16, 0x37, 0x89, 0x4a, 0x9a, 0x2d, 0x03, 0x3a, 0x0a, 0xd0, 0x04, 0x5a, 0x47, 0x53, 0x14, - 0x0c, 0xe1, 0x97, 0x3e, 0xf2, 0xaa, 0x8e, 0x37, 0xcb, 0xeb, 0xbb, 0x5f, 0xb1, 0x73, 0xb7, 0x8f, - 0xdd, 0xfb, 0x7d, 0xec, 0xfe, 0xdc, 0xc7, 0xee, 0xf7, 0x43, 0xec, 0xdc, 0x1f, 0x62, 0xe7, 0xc7, - 0x21, 0x76, 0xbe, 0xbc, 0x2e, 0xaa, 0xae, 0xec, 0x53, 0x92, 0x89, 0x86, 0x8e, 0xef, 0x0a, 0x3e, - 0xe7, 0xdb, 0x7c, 0xf3, 0xe0, 0x51, 0xa7, 0x3e, 0x34, 0x7c, 0xfb, 0x3b, 0x00, 0x00, 0xff, 0xff, - 0xe8, 0x29, 0x24, 0x50, 0xf4, 0x02, 0x00, 0x00, + // 408 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x3d, 0x6b, 0xdb, 0x40, + 0x1c, 0xc6, 0xa5, 0x5a, 0x2f, 0xf5, 0x75, 0x3b, 0x3c, 0xa8, 0xa2, 0x08, 0x53, 0x68, 0x6b, 0x28, + 0xbe, 0xc3, 0xad, 0x87, 0x4e, 0x06, 0x9b, 0x0e, 0x36, 0x4e, 0x88, 0xd1, 0x98, 0x25, 0xe8, 0xe5, + 0x2c, 0x09, 0x4b, 0x3a, 0x71, 0x92, 0x0c, 0xfa, 0x16, 0xf9, 0x58, 0x1e, 0x3d, 0x66, 0x4c, 0xec, + 0x2d, 0x9f, 0x22, 0xdc, 0x9d, 0x3c, 0xc4, 0x90, 0x38, 0x93, 0x4e, 0xdc, 0xef, 0xf9, 0x3f, 0xcf, + 0x73, 0xfc, 0xc1, 0x8f, 0x80, 0x96, 0x19, 0x2d, 0x71, 0xc0, 0x9a, 0xa2, 0xa2, 0x78, 0x43, 0x1a, + 0x96, 0xe4, 0x11, 0xde, 0x8e, 0x30, 0x23, 0x01, 0x65, 0x21, 0x2a, 0x18, 0xad, 0x28, 0xb4, 0x24, + 0x86, 0x24, 0x86, 0x5a, 0x0c, 0x6d, 0x47, 0x76, 0x2f, 0xa2, 0x11, 0x15, 0x10, 0xe6, 0x27, 0xc9, + 0xdb, 0x5f, 0x23, 0x4a, 0xa3, 0x94, 0x60, 0xf1, 0xe7, 0xd7, 0x6b, 0xec, 0xe5, 0x4d, 0x7b, 0xf5, + 0xed, 0xb5, 0x63, 0x1c, 0x72, 0xb3, 0xb8, 0x35, 0xfa, 0xfe, 0xdc, 0x01, 0x86, 0x2b, 0x9c, 0x21, + 0x04, 0x5a, 0xee, 0x65, 0xc4, 0x52, 0xfb, 0xea, 0xa0, 0xeb, 0x8a, 0x33, 0x1c, 0x02, 0xb3, 0xa8, + 0xfd, 0xbb, 0x0d, 0x69, 0xac, 0x4f, 0x7d, 0x75, 0xf0, 0xe5, 0x4f, 0x0f, 0x49, 0x27, 0x74, 0x72, + 0x42, 0xd3, 0xbc, 0x71, 0x8d, 0xa2, 0xf6, 0x97, 0xa4, 0x81, 0x13, 0xa0, 0xa7, 0x34, 0xf0, 0x52, + 0xab, 0x23, 0xe0, 0x9f, 0xe8, 0xad, 0x1a, 0x48, 0x7a, 0xa2, 0x2b, 0x4e, 0xcf, 0x15, 0x57, 0xca, + 0xe0, 0x14, 0x18, 0x29, 0x09, 0x23, 0xc2, 0x2c, 0x4d, 0x0c, 0xf8, 0x75, 0x79, 0x80, 0xc0, 0xe7, + 0x8a, 0xdb, 0x0a, 0x79, 0x84, 0xac, 0x4e, 0xab, 0xc4, 0xd2, 0x3f, 0x18, 0xe1, 0x9a, 0xd3, 0x3c, + 0x82, 0x90, 0xc1, 0xff, 0xc0, 0xa4, 0xeb, 0x75, 0x9a, 0xe4, 0xc4, 0x32, 0xc4, 0x84, 0xc1, 0xc5, + 0x09, 0x37, 0x92, 0x9f, 0x2b, 0xee, 0x49, 0x6a, 0xff, 0x03, 0xba, 0xa8, 0x06, 0x31, 0xf8, 0x5c, + 0xb0, 0x64, 0x2b, 0x5e, 0x50, 0x7d, 0xe7, 0x05, 0x4d, 0x4e, 0x2d, 0x49, 0x63, 0x4f, 0x80, 0x21, + 0x3b, 0xc1, 0x31, 0xd0, 0x0a, 0xaf, 0x8a, 0x5b, 0x59, 0xff, 0x2c, 0x46, 0x1c, 0xf2, 0x04, 0xb3, + 0xc5, 0x6a, 0x3c, 0x5e, 0x79, 0xcc, 0xcb, 0x4a, 0x57, 0xd0, 0xb6, 0x09, 0x74, 0xd1, 0xc8, 0xee, + 0x02, 0xb3, 0x0d, 0x36, 0x33, 0x80, 0x96, 0x54, 0x24, 0x9b, 0x2d, 0x76, 0x4f, 0x8e, 0xb2, 0x3b, + 0x38, 0xea, 0xfe, 0xe0, 0xa8, 0x8f, 0x07, 0x47, 0xbd, 0x3f, 0x3a, 0xca, 0xfe, 0xe8, 0x28, 0x0f, + 0x47, 0x47, 0xb9, 0xfd, 0x1d, 0x25, 0x55, 0x5c, 0xfb, 0x28, 0xa0, 0x19, 0x3e, 0xed, 0x8c, 0xf8, + 0x0c, 0xcb, 0x70, 0x73, 0xb6, 0xb0, 0xbe, 0x21, 0xd2, 0xff, 0x7d, 0x09, 0x00, 0x00, 0xff, 0xff, + 0x64, 0x83, 0x0c, 0x89, 0xd0, 0x02, 0x00, 0x00, } func (m *Record) Marshal() (dAtA []byte, err error) { @@ -493,13 +491,6 @@ func (m *Record_Local) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.PrivKeyType) > 0 { - i -= len(m.PrivKeyType) - copy(dAtA[i:], m.PrivKeyType) - i = encodeVarintRecord(dAtA, i, uint64(len(m.PrivKeyType))) - i-- - dAtA[i] = 0x12 - } if m.PrivKey != nil { { size, err := m.PrivKey.MarshalToSizedBuffer(dAtA[:i]) @@ -685,10 +676,6 @@ func (m *Record_Local) Size() (n int) { l = m.PrivKey.Size() n += 1 + l + sovRecord(uint64(l)) } - l = len(m.PrivKeyType) - if l > 0 { - n += 1 + l + sovRecord(uint64(l)) - } return n } @@ -1052,38 +1039,6 @@ func (m *Record_Local) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrivKeyType", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowRecord - } - 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 ErrInvalidLengthRecord - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthRecord - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PrivKeyType = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipRecord(dAtA[iNdEx:]) diff --git a/crypto/keyring/record_test.go b/crypto/keyring/record_test.go index 6c17379b4653..2ec0401d87ff 100644 --- a/crypto/keyring/record_test.go +++ b/crypto/keyring/record_test.go @@ -78,7 +78,6 @@ func (s *RecordTestSuite) TestLocalRecordMarshaling() { anyPrivKey, err := codectypes.NewAnyWithValue(s.priv) s.Require().NoError(err) s.Require().Equal(localRecord2.PrivKey, anyPrivKey) - s.Require().Equal(localRecord2.PrivKeyType, s.priv.Type()) } func (s *RecordTestSuite) TestLedgerRecordMarshaling() { diff --git a/crypto/keyring/signing_algorithms_test.go b/crypto/keyring/signing_algorithms_test.go index e99492f12a17..131ade58b4e2 100644 --- a/crypto/keyring/signing_algorithms_test.go +++ b/crypto/keyring/signing_algorithms_test.go @@ -59,8 +59,7 @@ func TestAltSigningAlgoList_String(t *testing.T) { require.Equal(t, fmt.Sprintf("%s,notSupported", hd.Secp256k1Type), list.String()) } -type notSupportedAlgo struct { -} +type notSupportedAlgo struct{} func (n notSupportedAlgo) Name() hd.PubKeyType { return "notSupported" diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go index 4ade041c4137..05d5d7466e13 100644 --- a/crypto/keys/ed25519/ed25519.go +++ b/crypto/keys/ed25519/ed25519.go @@ -34,8 +34,10 @@ const ( keyType = "ed25519" ) -var _ cryptotypes.PrivKey = &PrivKey{} -var _ codec.AminoMarshaler = &PrivKey{} +var ( + _ cryptotypes.PrivKey = &PrivKey{} + _ codec.AminoMarshaler = &PrivKey{} +) // Bytes returns the privkey byte format. func (privKey *PrivKey) Bytes() []byte { @@ -150,8 +152,10 @@ func GenPrivKeyFromSecret(secret []byte) *PrivKey { //------------------------------------- -var _ cryptotypes.PubKey = &PubKey{} -var _ codec.AminoMarshaler = &PubKey{} +var ( + _ cryptotypes.PubKey = &PubKey{} + _ codec.AminoMarshaler = &PubKey{} +) // Address is the SHA256-20 of the raw pubkey bytes. // It doesn't implement ADR-28 addresses and it must not be used diff --git a/crypto/keys/internal/benchmarking/bench.go b/crypto/keys/internal/benchmarking/bench.go index aab5d5f30382..dc99a082fdfa 100644 --- a/crypto/keys/internal/benchmarking/bench.go +++ b/crypto/keys/internal/benchmarking/bench.go @@ -30,7 +30,6 @@ func BenchmarkSigning(b *testing.B, priv types.PrivKey) { b.ResetTimer() for i := 0; i < b.N; i++ { _, err := priv.Sign(message) - if err != nil { b.FailNow() } diff --git a/crypto/keys/internal/ecdsa/privkey.go b/crypto/keys/internal/ecdsa/privkey.go index 690c07670d64..2aeedb1c4ddc 100644 --- a/crypto/keys/internal/ecdsa/privkey.go +++ b/crypto/keys/internal/ecdsa/privkey.go @@ -29,7 +29,6 @@ func IsSNormalized(sigS *big.Int) bool { // NormalizeS will invert the s value if not already in the lower half // of curve order value func NormalizeS(sigS *big.Int) *big.Int { - if IsSNormalized(sigS) { return sigS } @@ -41,7 +40,6 @@ func NormalizeS(sigS *big.Int) *big.Int { // R, S are padded to 32 bytes respectively. // code roughly copied from secp256k1_nocgo.go func signatureRaw(r *big.Int, s *big.Int) []byte { - rBytes := r.Bytes() sBytes := s.Bytes() sigBytes := make([]byte, 64) @@ -90,10 +88,8 @@ func (sk *PrivKey) Bytes() []byte { // It then raw encodes the signature as two fixed width 32-byte values // concatenated, reusing the code copied from secp256k1_nocgo.go func (sk *PrivKey) Sign(msg []byte) ([]byte, error) { - digest := sha256.Sum256(msg) r, s, err := ecdsa.Sign(rand.Reader, &sk.PrivateKey, digest[:]) - if err != nil { return nil, err } diff --git a/crypto/keys/internal/ecdsa/privkey_internal_test.go b/crypto/keys/internal/ecdsa/privkey_internal_test.go index 1eae718f698f..660a62aa2ba8 100644 --- a/crypto/keys/internal/ecdsa/privkey_internal_test.go +++ b/crypto/keys/internal/ecdsa/privkey_internal_test.go @@ -4,11 +4,11 @@ import ( "crypto/ecdsa" "crypto/elliptic" "crypto/sha256" - "github.com/tendermint/tendermint/crypto" "math/big" "testing" "github.com/stretchr/testify/suite" + "github.com/tendermint/tendermint/crypto" ) func TestSKSuite(t *testing.T) { @@ -38,11 +38,12 @@ func (suite *SKSuite) TestMarshal() { require := suite.Require() const size = 32 - var buffer = make([]byte, size) - suite.sk.MarshalTo(buffer) + buffer := make([]byte, size) + _, err := suite.sk.MarshalTo(buffer) + require.NoError(err) - var sk = new(PrivKey) - err := sk.Unmarshal(buffer, secp256r1, size) + sk := new(PrivKey) + err = sk.Unmarshal(buffer, secp256r1, size) require.NoError(err) require.True(sk.Equal(&suite.sk.PrivateKey)) } @@ -80,7 +81,7 @@ func (suite *SKSuite) TestSign() { // leave r untouched! high_s := new(big.Int).Mod(new(big.Int).Neg(low_s), elliptic.P256().Params().N) - require.False(suite.pk.VerifySignature(msg, signatureRaw(r,high_s))) + require.False(suite.pk.VerifySignature(msg, signatureRaw(r, high_s))) // Valid signature using low_s, but too long sigCpy = make([]byte, len(sig)+2) diff --git a/crypto/keys/internal/ecdsa/pubkey.go b/crypto/keys/internal/ecdsa/pubkey.go index 75fbd8b8826d..69b4a7f58504 100644 --- a/crypto/keys/internal/ecdsa/pubkey.go +++ b/crypto/keys/internal/ecdsa/pubkey.go @@ -60,7 +60,6 @@ func (pk *PubKey) Bytes() []byte { // lower half of the curve order // 7/21/21 - expects raw encoded signature (fixed-width 64-bytes, R || S) func (pk *PubKey) VerifySignature(msg []byte, sig []byte) bool { - // check length for raw signature // which is two 32-byte padded big.Ints // concatenated diff --git a/crypto/keys/internal/ecdsa/pubkey_internal_test.go b/crypto/keys/internal/ecdsa/pubkey_internal_test.go index 88dc95a3bbd5..5434c8504c83 100644 --- a/crypto/keys/internal/ecdsa/pubkey_internal_test.go +++ b/crypto/keys/internal/ecdsa/pubkey_internal_test.go @@ -59,12 +59,12 @@ func (suite *PKSuite) TestMarshal() { require := suite.Require() const size = 33 // secp256r1 size - var buffer = make([]byte, size) + buffer := make([]byte, size) n, err := suite.pk.MarshalTo(buffer) require.NoError(err) require.Equal(size, n) - var pk = new(PubKey) + pk := new(PubKey) err = pk.Unmarshal(buffer, secp256r1, size) require.NoError(err) require.True(pk.PublicKey.Equal(&suite.pk.PublicKey)) diff --git a/crypto/keys/multisig/multisig.go b/crypto/keys/multisig/multisig.go index e39c508be6f8..eb381bf5987a 100644 --- a/crypto/keys/multisig/multisig.go +++ b/crypto/keys/multisig/multisig.go @@ -11,8 +11,10 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx/signing" ) -var _ multisigtypes.PubKey = &LegacyAminoPubKey{} -var _ types.UnpackInterfacesMessage = &LegacyAminoPubKey{} +var ( + _ multisigtypes.PubKey = &LegacyAminoPubKey{} + _ types.UnpackInterfacesMessage = &LegacyAminoPubKey{} +) // NewLegacyAminoPubKey returns a new LegacyAminoPubKey. // Multisig can be constructed with multiple same keys - it will increase the power of diff --git a/crypto/keys/multisig/multisig_test.go b/crypto/keys/multisig/multisig_test.go index 1fc16893eb90..ae3023da828b 100644 --- a/crypto/keys/multisig/multisig_test.go +++ b/crypto/keys/multisig/multisig_test.go @@ -110,7 +110,8 @@ func TestVerifyMultisignature(t *testing.T) { pk = genPk }, true, - }, { + }, + { "wrong size for sig bit array", func(require *require.Assertions) { pubKeys := generatePubKeys(3) @@ -165,7 +166,8 @@ func TestVerifyMultisignature(t *testing.T) { ) }, true, - }, { + }, + { "duplicate signatures", func(require *require.Assertions) { pubKeys, sigs := generatePubKeysAndSignatures(5, msg) @@ -173,12 +175,13 @@ func TestVerifyMultisignature(t *testing.T) { sig = multisig.NewMultisig(5) require.Error(pk.VerifyMultisignature(signBytesFn, sig)) - multisig.AddSignatureFromPubKey(sig, sigs[0], pubKeys[0], pubKeys) + require.NoError(multisig.AddSignatureFromPubKey(sig, sigs[0], pubKeys[0], pubKeys)) // Add second signature manually sig.Signatures = append(sig.Signatures, sigs[0]) }, false, - }, { + }, + { "duplicated key", func(require *require.Assertions) { // here we test an edge case where we create a multi sig with two same @@ -191,7 +194,8 @@ func TestVerifyMultisignature(t *testing.T) { multisig.AddSignature(sig, sigs[0], 1) }, true, - }, { + }, + { "same key used twice", func(require *require.Assertions) { pubkeys, sigs := generatePubKeysAndSignatures(3, msg) @@ -201,15 +205,16 @@ func TestVerifyMultisignature(t *testing.T) { multisig.AddSignature(sig, sigs[0], 1) }, false, - }, { + }, + { "unable to verify signature", func(require *require.Assertions) { pubKeys := generatePubKeys(2) _, sigs := generatePubKeysAndSignatures(2, msg) pk = kmultisig.NewLegacyAminoPubKey(2, pubKeys) sig = multisig.NewMultisig(2) - multisig.AddSignatureFromPubKey(sig, sigs[0], pubKeys[0], pubKeys) - multisig.AddSignatureFromPubKey(sig, sigs[1], pubKeys[1], pubKeys) + require.NoError(multisig.AddSignatureFromPubKey(sig, sigs[0], pubKeys[0], pubKeys)) + require.NoError(multisig.AddSignatureFromPubKey(sig, sigs[1], pubKeys[1], pubKeys)) }, false, }, diff --git a/crypto/keys/secp256k1/internal/secp256k1/curve.go b/crypto/keys/secp256k1/internal/secp256k1/curve.go index fa1b199a3484..b5c80b23ad62 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/curve.go +++ b/crypto/keys/secp256k1/internal/secp256k1/curve.go @@ -93,19 +93,19 @@ func (BitCurve *BitCurve) Params() *elliptic.CurveParams { // IsOnCurve returns true if the given (x,y) lies on the BitCurve. func (BitCurve *BitCurve) IsOnCurve(x, y *big.Int) bool { // y² = x³ + b - y2 := new(big.Int).Mul(y, y) //y² - y2.Mod(y2, BitCurve.P) //y²%P + y2 := new(big.Int).Mul(y, y) // y² + y2.Mod(y2, BitCurve.P) // y²%P - x3 := new(big.Int).Mul(x, x) //x² - x3.Mul(x3, x) //x³ + x3 := new(big.Int).Mul(x, x) // x² + x3.Mul(x3, x) // x³ - x3.Add(x3, BitCurve.B) //x³+B + x3.Add(x3, BitCurve.B) // x³+B x3.Mod(x3, BitCurve.P) //(x³+B)%P return x3.Cmp(y2) == 0 } -//TODO: double check if the function is okay +// TODO: double check if the function is okay // 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) { @@ -217,30 +217,30 @@ func (BitCurve *BitCurve) Double(x1, y1 *big.Int) (*big.Int, *big.Int) { func (BitCurve *BitCurve) doubleJacobian(x, y, z *big.Int) (*big.Int, *big.Int, *big.Int) { // See http://hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#doubling-dbl-2009-l - a := new(big.Int).Mul(x, x) //X1² - b := new(big.Int).Mul(y, y) //Y1² - c := new(big.Int).Mul(b, b) //B² + a := new(big.Int).Mul(x, x) // X1² + b := new(big.Int).Mul(y, y) // Y1² + c := new(big.Int).Mul(b, b) // B² - d := new(big.Int).Add(x, b) //X1+B + d := new(big.Int).Add(x, b) // X1+B d.Mul(d, d) //(X1+B)² d.Sub(d, a) //(X1+B)²-A d.Sub(d, c) //(X1+B)²-A-C - d.Mul(d, big.NewInt(2)) //2*((X1+B)²-A-C) + d.Mul(d, big.NewInt(2)) // 2*((X1+B)²-A-C) - e := new(big.Int).Mul(big.NewInt(3), a) //3*A - f := new(big.Int).Mul(e, e) //E² + e := new(big.Int).Mul(big.NewInt(3), a) // 3*A + f := new(big.Int).Mul(e, e) // E² - x3 := new(big.Int).Mul(big.NewInt(2), d) //2*D - x3.Sub(f, x3) //F-2*D + x3 := new(big.Int).Mul(big.NewInt(2), d) // 2*D + x3.Sub(f, x3) // F-2*D x3.Mod(x3, BitCurve.P) - y3 := new(big.Int).Sub(d, x3) //D-X3 - y3.Mul(e, y3) //E*(D-X3) - y3.Sub(y3, new(big.Int).Mul(big.NewInt(8), c)) //E*(D-X3)-8*C + y3 := new(big.Int).Sub(d, x3) // D-X3 + y3.Mul(e, y3) // E*(D-X3) + y3.Sub(y3, new(big.Int).Mul(big.NewInt(8), c)) // E*(D-X3)-8*C y3.Mod(y3, BitCurve.P) - z3 := new(big.Int).Mul(y, z) //Y1*Z1 - z3.Mul(big.NewInt(2), z3) //3*Y1*Z1 + z3 := new(big.Int).Mul(y, z) // Y1*Z1 + z3.Mul(big.NewInt(2), z3) // 3*Y1*Z1 z3.Mod(z3, BitCurve.P) return x3, y3, z3 diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/dummy.go index fda594be9914..2c946210c54d 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/dummy.go +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/contrib/dummy.go @@ -1,3 +1,4 @@ +//go:build dummy // +build dummy // Package c contains only a C file. diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/dummy.go index 379b16992f47..04bbe3d76ecc 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/dummy.go +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/dummy.go @@ -1,3 +1,4 @@ +//go:build dummy // +build dummy // Package c contains only a C file. diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include/dummy.go index 5af540c73c4a..64c71b8451d8 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include/dummy.go +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/include/dummy.go @@ -1,3 +1,4 @@ +//go:build dummy // +build dummy // Package c contains only a C file. diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/dummy.go index 65868f38a8ea..2df270adc35e 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/dummy.go +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/dummy.go @@ -1,3 +1,4 @@ +//go:build dummy // +build dummy // Package c contains only a C file. diff --git a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/dummy.go b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/dummy.go index 3c7a696439f0..99c538db51b0 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/dummy.go +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/dummy.go @@ -1,3 +1,4 @@ +//go:build dummy // +build dummy // Package c contains only a C file. 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 index b6fc38327ec8..48c2e0aa5453 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/ecdh/dummy.go +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/ecdh/dummy.go @@ -1,3 +1,4 @@ +//go:build dummy // +build dummy // Package c contains only a C file. 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 index b9491f0cb9f4..8efbd7abe71b 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/recovery/dummy.go +++ b/crypto/keys/secp256k1/internal/secp256k1/libsecp256k1/src/modules/recovery/dummy.go @@ -1,3 +1,4 @@ +//go:build dummy // +build dummy // Package c contains only a C file. diff --git a/crypto/keys/secp256k1/internal/secp256k1/secp256_test.go b/crypto/keys/secp256k1/internal/secp256k1/secp256_test.go index ef2a3a3790b4..dbf61b37879f 100644 --- a/crypto/keys/secp256k1/internal/secp256k1/secp256_test.go +++ b/crypto/keys/secp256k1/internal/secp256k1/secp256_test.go @@ -48,7 +48,7 @@ func randSig() []byte { // 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]) + b := int(sig[32]) if b < 0 { t.Errorf("highest bit is negative: %d", b) } diff --git a/crypto/keys/secp256k1/secp256k1.go b/crypto/keys/secp256k1/secp256k1.go index 231a895a6103..51034275cd94 100644 --- a/crypto/keys/secp256k1/secp256k1.go +++ b/crypto/keys/secp256k1/secp256k1.go @@ -17,8 +17,10 @@ import ( "github.com/cosmos/cosmos-sdk/types/errors" ) -var _ cryptotypes.PrivKey = &PrivKey{} -var _ codec.AminoMarshaler = &PrivKey{} +var ( + _ cryptotypes.PrivKey = &PrivKey{} + _ codec.AminoMarshaler = &PrivKey{} +) const ( PrivKeySize = 32 @@ -138,8 +140,10 @@ func GenPrivKeyFromSecret(secret []byte) *PrivKey { //------------------------------------- -var _ cryptotypes.PubKey = &PubKey{} -var _ codec.AminoMarshaler = &PubKey{} +var ( + _ cryptotypes.PubKey = &PubKey{} + _ codec.AminoMarshaler = &PubKey{} +) // PubKeySize is comprised of 32 bytes for one field element // (the x-coordinate), plus one byte for the parity of the y-coordinate. diff --git a/crypto/keys/secp256k1/secp256k1_internal_test.go b/crypto/keys/secp256k1/secp256k1_internal_test.go index a2c8e73bcbe7..7cbe5949f70c 100644 --- a/crypto/keys/secp256k1/secp256k1_internal_test.go +++ b/crypto/keys/secp256k1/secp256k1_internal_test.go @@ -10,7 +10,6 @@ import ( ) func Test_genPrivKey(t *testing.T) { - empty := make([]byte, 32) oneB := big.NewInt(1).Bytes() onePadded := make([]byte, 32) diff --git a/crypto/keys/secp256k1/secp256k1_test.go b/crypto/keys/secp256k1/secp256k1_test.go index 79d2faf5158e..63f5579459f1 100644 --- a/crypto/keys/secp256k1/secp256k1_test.go +++ b/crypto/keys/secp256k1/secp256k1_test.go @@ -41,7 +41,7 @@ func TestPubKeySecp256k1Address(t *testing.T) { addrBbz, _, _ := base58.CheckDecode(d.addr) addrB := crypto.Address(addrBbz) - var priv = secp256k1.PrivKey{Key: privB} + priv := secp256k1.PrivKey{Key: privB} pubKey := priv.PubKey() pubT, _ := pubKey.(*secp256k1.PubKey) diff --git a/crypto/keys/secp256r1/pubkey_internal_test.go b/crypto/keys/secp256r1/pubkey_internal_test.go index 3df25ebedf0e..7c77665cf1b7 100644 --- a/crypto/keys/secp256r1/pubkey_internal_test.go +++ b/crypto/keys/secp256r1/pubkey_internal_test.go @@ -111,8 +111,7 @@ func (suite *PKSuite) TestMarshalProto() { require.NoError(cdc.UnmarshalInterface(bz, &pkI)) require.True(pkI.Equals(suite.pk)) - cdc.UnmarshalInterface(bz, nil) - require.Error(err, "nil should fail") + require.Error(cdc.UnmarshalInterface(bz, nil), "nil should fail") } func (suite *PKSuite) TestSize() { diff --git a/crypto/ledger/encode_test.go b/crypto/ledger/encode_test.go index 447891fde768..7a60c3d147f5 100644 --- a/crypto/ledger/encode_test.go +++ b/crypto/ledger/encode_test.go @@ -30,7 +30,7 @@ func checkAminoJSON(t *testing.T, src interface{}, dst interface{}, isNil bool) // nolint: govet func ExamplePrintRegisteredTypes() { - cdc.PrintTypes(os.Stdout) + _ = cdc.PrintTypes(os.Stdout) // | Type | Name | Prefix | Length | Notes | // | ---- | ---- | ------ | ----- | ------ | // | PrivKeyLedgerSecp256k1 | tendermint/PrivKeyLedgerSecp256k1 | 0x10CAB393 | variable | | @@ -44,7 +44,6 @@ func ExamplePrintRegisteredTypes() { } func TestNilEncodings(t *testing.T) { - // Check nil Signature. var a, b []byte checkAminoJSON(t, &a, &b, true) @@ -59,5 +58,4 @@ func TestNilEncodings(t *testing.T) { var e, f cryptotypes.PrivKey checkAminoJSON(t, &e, &f, true) require.EqualValues(t, e, f) - } diff --git a/crypto/ledger/ledger_mock.go b/crypto/ledger/ledger_mock.go index 868815982e1f..740a773d12ce 100644 --- a/crypto/ledger/ledger_mock.go +++ b/crypto/ledger/ledger_mock.go @@ -28,8 +28,7 @@ func init() { } } -type LedgerSECP256K1Mock struct { -} +type LedgerSECP256K1Mock struct{} func (mock LedgerSECP256K1Mock) Close() error { return nil diff --git a/crypto/ledger/ledger_real.go b/crypto/ledger/ledger_real.go index 07f8a8e3ed6a..48c87aff7683 100644 --- a/crypto/ledger/ledger_real.go +++ b/crypto/ledger/ledger_real.go @@ -1,3 +1,4 @@ +//go:build cgo && ledger && !test_ledger_mock // +build cgo,ledger,!test_ledger_mock package ledger diff --git a/crypto/ledger/ledger_secp256k1.go b/crypto/ledger/ledger_secp256k1.go index db09ba2e8d3a..dffded571ab5 100644 --- a/crypto/ledger/ledger_secp256k1.go +++ b/crypto/ledger/ledger_secp256k1.go @@ -14,11 +14,9 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/types" ) -var ( - // discoverLedger defines a function to be invoked at runtime for discovering - // a connected Ledger device. - discoverLedger discoverLedgerFn -) +// discoverLedger defines a function to be invoked at runtime for discovering +// a connected Ledger device. +var discoverLedger discoverLedgerFn type ( // discoverLedgerFn defines a Ledger discovery function that returns a @@ -102,8 +100,7 @@ func (pkl PrivKeyLedgerSecp256k1) Sign(message []byte) ([]byte, error) { } // ShowAddress triggers a ledger device to show the corresponding address. -func ShowAddress(path hd.BIP44Params, expectedPubKey types.PubKey, - accountAddressPrefix string) error { +func ShowAddress(path hd.BIP44Params, expectedPubKey types.PubKey, accountAddressPrefix string) error { device, err := getDevice() if err != nil { return err diff --git a/crypto/types/compact_bit_array_test.go b/crypto/types/compact_bit_array_test.go index 1a76d4531352..143f3a07891c 100644 --- a/crypto/types/compact_bit_array_test.go +++ b/crypto/types/compact_bit_array_test.go @@ -67,7 +67,6 @@ func TestBitArrayEqual(t *testing.T) { } func TestJSONMarshalUnmarshal(t *testing.T) { - bA1 := NewCompactBitArray(0) bA2 := NewCompactBitArray(1) @@ -218,7 +217,6 @@ func TestCompactBitArrayNumOfTrueBitsBefore(t *testing.T) { require.NoError(t, err) for i := 0; i < len(tc.bAIndex); i++ { - require.Equal(t, tc.trueValueIndex[i], bA.NumTrueBitsBefore(tc.bAIndex[i]), "tc %d, i %d", tcIndex, i) } }) diff --git a/crypto/xsalsa20symmetric/symmetric.go b/crypto/xsalsa20symmetric/symmetric.go index cf24daea35ce..e205985e33fa 100644 --- a/crypto/xsalsa20symmetric/symmetric.go +++ b/crypto/xsalsa20symmetric/symmetric.go @@ -10,8 +10,10 @@ import ( // TODO, make this into a struct that implements crypto.Symmetric. -const nonceLen = 24 -const secretLen = 32 +const ( + nonceLen = 24 + secretLen = 32 +) // secret must be 32 bytes long. Use something like Sha256(Bcrypt(passphrase)) // The ciphertext is (secretbox.Overhead + 24) bytes longer than the plaintext. diff --git a/crypto/xsalsa20symmetric/symmetric_test.go b/crypto/xsalsa20symmetric/symmetric_test.go index b35633b96cb3..0a7431671877 100644 --- a/crypto/xsalsa20symmetric/symmetric_test.go +++ b/crypto/xsalsa20symmetric/symmetric_test.go @@ -11,7 +11,6 @@ import ( ) func TestSimple(t *testing.T) { - plaintext := []byte("sometext") secret := []byte("somesecretoflengththirtytwo===32") ciphertext := EncryptSymmetric(plaintext, secret) @@ -22,7 +21,6 @@ func TestSimple(t *testing.T) { } func TestSimpleWithKDF(t *testing.T) { - plaintext := []byte("sometext") secretPass := []byte("somesecret") secret, err := bcrypt.GenerateFromPassword(secretPass, 12) diff --git a/db/badgerdb/db.go b/db/badgerdb/db.go index 89b10242ae1f..d89ede35705c 100644 --- a/db/badgerdb/db.go +++ b/db/badgerdb/db.go @@ -19,9 +19,7 @@ import ( "github.com/dgraph-io/ristretto/z" ) -var ( - versionsFilename = "versions.csv" -) +var versionsFilename = "versions.csv" var ( _ db.DBConnection = (*BadgerDB)(nil) @@ -83,7 +81,7 @@ func init() { func NewDB(dir string) (*BadgerDB, error) { // Since Badger doesn't support database names, we join both to obtain // the final directory to use for the database. - if err := os.MkdirAll(dir, 0755); err != nil { + if err := os.MkdirAll(dir, 0o755); err != nil { return nil, err } opts := badger.DefaultOptions(dir) @@ -111,7 +109,7 @@ func NewDBWithOptions(opts badger.Options) (*BadgerDB, error) { // Load metadata CSV file containing valid versions func readVersionsFile(path string) (*versionManager, error) { - file, err := os.OpenFile(path, os.O_RDONLY|os.O_CREATE, 0644) + file, err := os.OpenFile(path, os.O_RDONLY|os.O_CREATE, 0o644) if err != nil { return nil, err } @@ -155,7 +153,7 @@ func readVersionsFile(path string) (*versionManager, error) { // Write version metadata to CSV file func writeVersionsFile(vm *versionManager, path string) error { rows := [][]string{ - []string{"0", strconv.FormatUint(vm.lastTs, 10)}, + {"0", strconv.FormatUint(vm.lastTs, 10)}, } for it := vm.Iterator(); it.Next(); { version := it.Value() diff --git a/db/go.mod b/db/go.mod index 973d6074249e..6172bd01b1f4 100644 --- a/db/go.mod +++ b/db/go.mod @@ -1,4 +1,4 @@ -go 1.17 +go 1.18 module github.com/cosmos/cosmos-sdk/db diff --git a/db/go.sum b/db/go.sum index c7e75ea4532d..2dec902cadcf 100644 --- a/db/go.sum +++ b/db/go.sum @@ -33,11 +33,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= -github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= -github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= -github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -115,7 +112,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -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/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= @@ -159,15 +155,11 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 h1:7NCfEGl0sfUojmX78nK9pBJuUlSZWEJA/TwASvfiPLo= golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= diff --git a/db/internal/util.go b/db/internal/util.go index b33f8ac67733..ea7425319ce3 100644 --- a/db/internal/util.go +++ b/db/internal/util.go @@ -2,6 +2,7 @@ package util import ( "fmt" + dbm "github.com/cosmos/cosmos-sdk/db" ) diff --git a/db/prefix/prefix.go b/db/prefix/prefix.go index c6ed87cba84f..3ddf1b41b4d0 100644 --- a/db/prefix/prefix.go +++ b/db/prefix/prefix.go @@ -24,9 +24,11 @@ type prefixW struct { prefix []byte } -var _ db.DBReader = (*prefixR)(nil) -var _ db.DBReadWriter = (*prefixRW)(nil) -var _ db.DBWriter = (*prefixW)(nil) +var ( + _ db.DBReader = (*prefixR)(nil) + _ db.DBReadWriter = (*prefixRW)(nil) + _ db.DBWriter = (*prefixW)(nil) +) // NewPrefixReader returns a DBReader that only has access to the subset of DB keys // that contain the given prefix. diff --git a/db/rocksdb/db.go b/db/rocksdb/db.go index 592ad8c0983e..1bf025461598 100644 --- a/db/rocksdb/db.go +++ b/db/rocksdb/db.go @@ -69,7 +69,7 @@ type dbOptions struct { } func init() { - creator := func(name string, dir string) (DBConnection, error) { + creator := func(name string, dir string) (db.DBConnection, error) { dir = filepath.Join(dir, name) return NewDB(dir) } @@ -79,7 +79,7 @@ func init() { // NewDB creates a new RocksDB key-value database with inside the given directory. // If dir does not exist, it will be created. func NewDB(dir string) (*dbManager, error) { - if err := os.MkdirAll(dir, 0755); err != nil { + if err := os.MkdirAll(dir, 0o755); err != nil { return nil, err } @@ -108,7 +108,7 @@ func NewDB(dir string) (*dbManager, error) { cpCache: checkpointCache{cache: map[uint64]*cpCacheEntry{}}, } - err := os.MkdirAll(mgr.checkpointsDir(), 0755) + err := os.MkdirAll(mgr.checkpointsDir(), 0o755) if err != nil { return nil, err } diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index 8b8f68687393..b2bfc1d0602c 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -38,21 +38,17 @@ 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": "master", - "key": "master" + "label": "v0.45", + "key": "v0.45" + }, + { + "label": "main", + "key": "main" } ], topbar: { @@ -189,7 +185,7 @@ module.exports = { { title: "Contributing to the docs", url: - "https://github.com/cosmos/cosmos-sdk/blob/master/docs/DOCS_README.md" + "https://github.com/cosmos/cosmos-sdk/blob/main/docs/DOCS_README.md" }, { title: "Source code on GitHub", diff --git a/docs/.vuepress/enhanceApp.js b/docs/.vuepress/enhanceApp.js index 36cee6366fc8..1bed0f795900 100644 --- a/docs/.vuepress/enhanceApp.js +++ b/docs/.vuepress/enhanceApp.js @@ -1,8 +1,8 @@ export default ({ router }) => { router.addRoutes([ - { path: '/master/spec/*', redirect: '/master/modules/' }, - { path: '/master/spec/governance/', redirect: '/master/modules/gov/' }, - { path: '/v0.41/', redirect: '/v0.42/' }, - { path: '/v0.43/', redirect: '/v0.44/' }, - ]) -} + { path: "/main/spec/*", redirect: "/modules/" }, + { path: "/main/spec/governance/", redirect: "/modules/gov/" }, + { path: "/v0.43/", redirect: "/v0.44/" }, // TODO to fix: https://github.com/cosmos/cosmos-sdk/issues/11798 + { path: "/master/", redirect: "/" }, + ]); +}; diff --git a/docs/DOCS_README.md b/docs/DOCS_README.md index 9ec1fd81c1e5..6439571f7820 100644 --- a/docs/DOCS_README.md +++ b/docs/DOCS_README.md @@ -1,6 +1,6 @@ # Updating the docs -If you want to open a PR in Cosmos SDK to update the documentation, please follow the guidelines in [`CONTRIBUTING.md`](https://github.com/cosmos/cosmos-sdk/tree/master/CONTRIBUTING.md#updating-documentation). +If you want to open a PR in Cosmos SDK to update the documentation, please follow the guidelines in [`CONTRIBUTING.md`](https://github.com/cosmos/cosmos-sdk/tree/main/CONTRIBUTING.md#updating-documentation). ## Internationalization @@ -13,8 +13,8 @@ If you want to open a PR in Cosmos SDK to update the documentation, please follo * `docs/intro/` * `docs/migrations/` * `docs/run-node/` -* Each `docs//` folder must also have a `README.md` that includes a translated version of both the layout and content within the root-level [`README.md`](https://github.com/cosmos/cosmos-sdk/tree/master/docs/README.md). The layout defined in the `README.md` is used to build the homepage. -* Always translate content living on `master` unless you are revising documentation for a specific release. Translated documentation like the root-level documentation is semantically versioned. +* Each `docs//` folder must also have a `README.md` that includes a translated version of both the layout and content within the root-level [`README.md`](https://github.com/cosmos/cosmos-sdk/tree/main/docs/README.md). The layout defined in the `README.md` is used to build the homepage. +* Always translate content living on `main` unless you are revising documentation for a specific release. Translated documentation like the root-level documentation is semantically versioned. * For additional configuration options, please see [VuePress Internationalization](https://vuepress.vuejs.org/guide/i18n.html). ## Docs Build Workflow @@ -23,7 +23,7 @@ The documentation for Cosmos SDK is hosted at https://docs.cosmos.network/ and b ### How It Works -There is a CircleCI job listening for changes in the `/docs` directory for the `master` branch and each supported version tag (`v0.39` and `v0.42`). Any updates to files in the `/docs` directory will automatically trigger a website deployment. Under the hood, the private website repository has a `make build-docs` target consumed by a CircleCI job within that repository. +There is a CircleCI job listening for changes in the `/docs` directory for the `main` branch and each supported version tag (`v0.39` and `v0.42`). Any updates to files in the `/docs` directory will automatically trigger a website deployment. Under the hood, the private website repository has a `make build-docs` target consumed by a CircleCI job within that repository. ## README @@ -92,7 +92,7 @@ To build documentation as a static website run `npm run build`. You will find th First, run `make tools` from the root of repo, to install the swagger-ui tool. -Then, edit the `swagger.yaml` manually; it is found [here](https://github.com/cosmos/cosmos-sdk/blob/master/client/lcd/swagger-ui/swagger.yaml) +Then, edit the `swagger.yaml` manually; it is found [here](https://github.com/cosmos/cosmos-sdk/blob/main/client/lcd/swagger-ui/swagger.yaml) Finally, run `make update_gaia_lite_docs` from the root of the repo. diff --git a/docs/README.md b/docs/README.md index 2e9e03f2cbba..35ee1daf20c0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -48,7 +48,7 @@ aside: false ## Get Started * **[Cosmos SDK Intro](./intro/overview.md)**: High-level overview of the Cosmos SDK. -* **[Starport](https://docs.starport.network/)**: A developer-friendly interface to the Cosmos SDK to scaffold, launch, and maintain any crypto application on a sovereign and secured blockchain. +* **[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 Docs @@ -56,7 +56,7 @@ aside: false * **[Basics](./basics/)**: Basic concepts of the Cosmos SDK, including the standard anatomy of an application, the transaction lifecycle, and accounts management. * **[Core](./core/)**: Core concepts of the Cosmos SDK, including `baseapp`, the `store`, or the `server`. * **[Building Modules](./building-modules/)**: Important concepts for module developers like `message`, `keeper`, and `querier`. -* **[IBC](./ibc/)**: IBC protocol integration and concepts. +* **[IBC](https://ibc.cosmos.network/)**: IBC protocol integration and concepts. * **[Running a Node, API, CLI](./run-node/)**: How to run a node and interact with the node using the CLI and the API. * **[Migrations](./migrations/)**: Migration guides for updating to newer versions of Cosmos SDK. @@ -70,7 +70,7 @@ aside: false ## Cosmos Hub -The Cosmos Hub (`gaia`) docs have moved to [github.com/cosmos/gaia](https://github.com/cosmos/gaia/tree/master/docs). +The Cosmos Hub (`gaia`) docs have moved to [github.com/cosmos/gaia](https://github.com/cosmos/gaia/tree/main/docs). ## Languages @@ -78,4 +78,4 @@ The Cosmos SDK is written in [Golang](https://golang.org/), though the framework ## Contribute -See the [DOCS_README.md](https://github.com/cosmos/cosmos-sdk/blob/master/docs/DOCS_README.md) for details of the build process and considerations when making changes. +See the [DOCS_README.md](https://github.com/cosmos/cosmos-sdk/blob/main/docs/DOCS_README.md) for details of the build process and considerations when making changes. diff --git a/docs/architecture/PROCESS.md b/docs/architecture/PROCESS.md index 528301a67b39..c5140bbe41f3 100644 --- a/docs/architecture/PROCESS.md +++ b/docs/architecture/PROCESS.md @@ -14,7 +14,7 @@ ADR creation is an **iterative** process. Instead of trying to solve all decisio 2. Once the motivation is validated, a GitHub Pull Request (PR) is created with a new document based on the `adr-template.md`. -3. An ADR doesn't have to arrive to `master` with an _accepted_ status in a single PR. If the motivation is clear and the solution is sound, we SHOULD be able to merge it and keep a _proposed_ status. It's preferable to have an iterative approach rather than long, not merged Pull Requests. +3. An ADR doesn't have to arrive to `main` with an _accepted_ status in a single PR. If the motivation is clear and the solution is sound, we SHOULD be able to merge it and keep a _proposed_ status. It's preferable to have an iterative approach rather than long, not merged Pull Requests. 4. If a _proposed_ ADR is merged, then it should clearly document outstanding issues either in ADR document notes or in a GitHub Issue. diff --git a/docs/architecture/README.md b/docs/architecture/README.md index 18ed71c2df6a..4257d1e87ba8 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -56,6 +56,7 @@ When writing ADRs, follow the same best practices for writing RFCs. When writing * [ADR 029: Fee Grant Module](./adr-029-fee-grant-module.md) * [ADR 030: Message Authorization Module](./adr-030-authz-module.md) * [ADR 031: Protobuf Msg Services](./adr-031-msg-service.md) +* [ADR 055: ORM](./adr-055-orm.md) ### Proposed @@ -83,3 +84,4 @@ When writing ADRs, follow the same best practices for writing RFCs. When writing - [ADR 044: Guidelines for Updating Protobuf Definitions](./adr-044-protobuf-updates-guidelines.md) - [ADR 047: Extend Upgrade Plan](./adr-047-extend-upgrade-plan.md) +- [ADR 053: Go Module Refactoring](./adr-053-go-module-refactoring.md) diff --git a/docs/architecture/adr-018-extendable-voting-period.md b/docs/architecture/adr-018-extendable-voting-period.md index 2c6a30e80da9..ee238fc35ae8 100644 --- a/docs/architecture/adr-018-extendable-voting-period.md +++ b/docs/architecture/adr-018-extendable-voting-period.md @@ -18,7 +18,7 @@ Thus, we propose the following mechanism: ### Params -* The current gov param `VotingPeriod` is to be replaced by a `MinVotingPeriod` param. This is the the default voting period that all governance proposal voting periods start with. +* The current gov param `VotingPeriod` is to be replaced by a `MinVotingPeriod` param. This is the default voting period that all governance proposal voting periods start with. * There is a new gov param called `MaxVotingPeriodExtension`. ### Mechanism diff --git a/docs/architecture/adr-020-protobuf-transaction-encoding.md b/docs/architecture/adr-020-protobuf-transaction-encoding.md index 32ee3a64a6ab..71bd1f9fd0de 100644 --- a/docs/architecture/adr-020-protobuf-transaction-encoding.md +++ b/docs/architecture/adr-020-protobuf-transaction-encoding.md @@ -222,7 +222,7 @@ Signature verifiers do: * Pull account number and sequence from the state. * Obtain the public key either from state or `AuthInfo`'s `signer_infos`. * Create a `SignDoc` and serialize it using [ADR 027](./adr-027-deterministic-protobuf-serialization.md). - * Verify the signature at the the same list position against the serialized `SignDoc`. + * Verify the signature at the same list position against the serialized `SignDoc`. #### `SIGN_MODE_LEGACY_AMINO` diff --git a/docs/architecture/adr-030-authz-module.md b/docs/architecture/adr-030-authz-module.md index b9c0720e10f0..1390d0f6b4c5 100644 --- a/docs/architecture/adr-030-authz-module.md +++ b/docs/architecture/adr-030-authz-module.md @@ -6,6 +6,7 @@ * 2020-10-12: Updated Draft * 2020-11-13: Accepted * 2020-05-06: proto API updates, use `sdk.Msg` instead of `sdk.ServiceMsg` (the latter concept was removed from Cosmos SDK) +* 2022-04-20: Updated the `SendAuthorization` proto docs to clarify the `SpendLimit` is a required field. (Generic authorization can be used with bank msg type url to create limit less bank authorization) ## Status @@ -87,8 +88,8 @@ a `SpendLimit` and updates it down to zero: ```go type SendAuthorization struct { // SpendLimit specifies the maximum amount of tokens that can be spent - // by this authorization and will be updated as tokens are spent. If it is - // empty, there is no spend limit and any amount of coins can be spent. + // by this authorization and will be updated as tokens are spent. This field is required. (Generic authorization + // can be used with bank msg type url to create limit less bank authorization). SpendLimit sdk.Coins } diff --git a/docs/architecture/adr-037-gov-split-vote.md b/docs/architecture/adr-037-gov-split-vote.md index c09041a84e17..a2f457c33789 100644 --- a/docs/architecture/adr-037-gov-split-vote.md +++ b/docs/architecture/adr-037-gov-split-vote.md @@ -10,7 +10,7 @@ Accepted ## Abstract -This ADR defines a modification to the the governance module that would allow a staker to split their votes into several voting options. For example, it could use 70% of its voting power to vote Yes and 30% of its voting power to vote No. +This ADR defines a modification to the governance module that would allow a staker to split their votes into several voting options. For example, it could use 70% of its voting power to vote Yes and 30% of its voting power to vote No. ## Context diff --git a/docs/architecture/adr-044-protobuf-updates-guidelines.md b/docs/architecture/adr-044-protobuf-updates-guidelines.md index 833a5648cc64..6c0b33bc806f 100644 --- a/docs/architecture/adr-044-protobuf-updates-guidelines.md +++ b/docs/architecture/adr-044-protobuf-updates-guidelines.md @@ -15,7 +15,7 @@ This ADR provides guidelines and recommended practices when updating Protobuf de ## Context -The Cosmos SDK maintains a set of [Protobuf definitions](https://github.com/cosmos/cosmos-sdk/tree/master/proto/cosmos). It is important to correctly design Protobuf definitions to avoid any breaking changes within the same version. The reasons are to not break tooling (including indexers and explorers), wallets and other third-party integrations. +The Cosmos SDK maintains a set of [Protobuf definitions](https://github.com/cosmos/cosmos-sdk/tree/main/proto/cosmos). It is important to correctly design Protobuf definitions to avoid any breaking changes within the same version. The reasons are to not break tooling (including indexers and explorers), wallets and other third-party integrations. When making changes to these Protobuf definitions, the Cosmos SDK currently only follows [Buf's](https://docs.buf.build/) recommendations. We noticed however that Buf's recommendations might still result in breaking changes in the SDK in some cases. For example: diff --git a/docs/architecture/adr-045-check-delivertx-middlewares.md b/docs/architecture/adr-045-check-delivertx-middlewares.md index bb108d401ea4..60172977c980 100644 --- a/docs/architecture/adr-045-check-delivertx-middlewares.md +++ b/docs/architecture/adr-045-check-delivertx-middlewares.md @@ -4,10 +4,11 @@ * 20.08.2021: Initial draft. * 07.12.2021: Update `tx.Handler` interface ([\#10693](https://github.com/cosmos/cosmos-sdk/pull/10693)). +* 17.05.2022: ADR is abandoned, as middlewares are deemed too hard to reason about. ## Status -ACCEPTED +ABANDONED. Replacement is being discussed in [#11955](https://github.com/cosmos/cosmos-sdk/issues/11955). ## Abstract @@ -220,7 +221,7 @@ While the app developer can define and compose the middlewares of their choice, | Middleware | Description | | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | RunMsgsTxHandler | This is the base `tx.Handler`. It replaces the old baseapp's `runMsgs`, and executes a transaction's `Msg`s. | -| TxDecoderMiddleware | This middleware takes in transaction raw bytes, and decodes them into a `sdk.Tx`. It replaces the `baseapp.txDecoder` field, so that BaseApp stays as thin as possible. Since most middlewares read the contents of the `sdk.Tx`, the TxDecoderMiddleware should be run first in the middelware stack. | +| TxDecoderMiddleware | This middleware takes in transaction raw bytes, and decodes them into a `sdk.Tx`. It replaces the `baseapp.txDecoder` field, so that BaseApp stays as thin as possible. Since most middlewares read the contents of the `sdk.Tx`, the TxDecoderMiddleware should be run first in the middleware stack. | | {Antehandlers} | Each antehandler is converted to its own middleware. These middlewares perform signature verification, fee deductions and other validations on the incoming transaction. | | IndexEventsTxMiddleware | This is a simple middleware that chooses which events to index in Tendermint. Replaces `baseapp.indexEvents` (which unfortunately still exists in baseapp too, because it's used to index Begin/EndBlock events) | | RecoveryTxMiddleware | This index recovers from panics. It replaces baseapp.runTx's panic recovery described in [ADR-022](./adr-022-custom-panic-handling.md). | diff --git a/docs/architecture/adr-048-consensus-fees.md b/docs/architecture/adr-048-consensus-fees.md new file mode 100644 index 000000000000..4ce4c81375d9 --- /dev/null +++ b/docs/architecture/adr-048-consensus-fees.md @@ -0,0 +1,203 @@ +# ADR 048: Multi Tire Gas Price System + +## Changelog + +- Dec 1, 2021: Initial Draft + +## Status + +Rejected + +## Abstract + +This ADR describes a flexible mechanism to maintain a consensus level gas prices, in which one can choose a multi-tier gas price system or EIP-1559 like one through configuration. + +## Context + +Currently, each validator configures it's own `minimal-gas-prices` in `app.yaml`. But setting a proper minimal gas price is critical to protect network from dos attack, and it's hard for all the validators to pick a sensible value, so we propose to maintain a gas price in consensus level. + +Since tendermint 0.35 has supported mempool prioritization, we can take advantage of that to implement more sophisticated gas fee system. + +## Multi-Tier Price System + +We propose a multi-tier price system on consensus to provide maximum flexibility: + +- Tier 1: a constant gas price, which could only be modified occasionally through governance proposal. +- Tier 2: a dynamic gas price which is adjusted according to previous block load. +- Tier 3: a dynamic gas price which is adjusted according to previous block load at a higher speed. + +The gas price of higher tier should bigger than the lower tier. + +The transaction fees are charged with the exact gas price calculated on consensus. + +The parameter schema is like this: + +```protobuf +message TierParams { + uint32 priority = 1 // priority in tendermint mempool + Coin initial_gas_price = 2 // + uint32 parent_gas_target = 3 // the target saturation of block + uint32 change_denominator = 4 // decides the change speed + Coin min_gas_price = 5 // optional lower bound of the price adjustment + Coin max_gas_price = 6 // optional upper bound of the price adjustment +} + +message Params { + repeated TierParams tiers = 1; +} +``` + +### Extension Options + +We need to allow user to specify the tier of service for the transaction, to support it in an extensible way, we add an extension option in `AuthInfo`: + +```protobuf +message ExtensionOptionsTieredTx { + uint32 fee_tier = 1 +} +``` + +The value of `fee_tier` is just the index to the `tiers` parameter list. + +We also change the semantic of existing `fee` field of `Tx`, instead of charging user the exact `fee` amount, we treat it as a fee cap, while the actual amount of fee charged is decided dynamically. If the `fee` is smaller than dynamic one, the transaction won't be included in current block and ideally should stay in the mempool until the consensus gas price drop. The mempool can eventually prune old transactions. + +### Tx Prioritization + +Transactions are prioritized based on the tier, the higher the tier, the higher the priority. + +Within the same tier, follow the default Tendermint order (currently FIFO). Be aware of that the mempool tx ordering logic is not part of consensus and can be modified by malicious validator. + +This mechanism can be easily composed with prioritization mechanisms: +* we can add extra tiers out of a user control: + * Example 1: user can set tier 0, 10 or 20, but the protocol will create tiers 0, 1, 2 ... 29. For example IBC transactions will go to tier `user_tier + 5`: if user selected tier 1, then the transaction will go to tier 15. + * Example 2: we can reserve tier 4, 5, ... only for special transaction types. For example, tier 5 is reserved for evidence tx. So if submits a bank.Send transaction and set tier 5, it will be delegated to tier 3 (the max tier level available for any transaction). + * Example 3: we can enforce that all transactions of a sepecific type will go to specific tier. For example, tier 100 will be reserved for evidence transactions and all evidence transactions will always go to that tier. + +### `min-gas-prices` + +Deprecate the current per-validator `min-gas-prices` configuration, since it would confusing for it to work together with the consensus gas price. + +### Adjust For Block Load + +For tier 2 and tier 3 transactions, the gas price is adjusted according to previous block load, the logic could be similar to EIP-1559: + +```python +def adjust_gas_price(gas_price, parent_gas_used, tier): + if parent_gas_used == tier.parent_gas_target: + return gas_price + elif parent_gas_used > tier.parent_gas_target: + gas_used_delta = parent_gas_used - tier.parent_gas_target + gas_price_delta = max(gas_price * gas_used_delta // tier.parent_gas_target // tier.change_speed, 1) + return gas_price + gas_price_delta + else: + gas_used_delta = parent_gas_target - parent_gas_used + gas_price_delta = gas_price * gas_used_delta // parent_gas_target // tier.change_speed + return gas_price - gas_price_delta +``` + +### Block Segment Reservation + +Ideally we should reserve block segments for each tier, so the lower tiered transactions won't be completely squeezed out by higher tier transactions, which will force user to use higher tier, and the system degraded to a single tier. + +We need help from tendermint to implement this. + +## Implementation + +We can make each tier's gas price strategy fully configurable in protocol parameters, while providing a sensible default one. + +Pseudocode in python-like syntax: + +```python +interface TieredTx: + def tier(self) -> int: + pass + +def tx_tier(tx): + if isinstance(tx, TieredTx): + return tx.tier() + else: + # default tier for custom transactions + return 0 + # NOTE: we can add more rules here per "Tx Prioritization" section + +class TierParams: + 'gas price strategy parameters of one tier' + priority: int # priority in tendermint mempool + initial_gas_price: Coin + parent_gas_target: int + change_speed: Decimal # 0 means don't adjust for block load. + +class Params: + 'protocol parameters' + tiers: List[TierParams] + +class State: + 'consensus state' + # total gas used in last block, None when it's the first block + parent_gas_used: Optional[int] + # gas prices of last block for all tiers + gas_prices: List[Coin] + +def begin_block(): + 'Adjust gas prices' + for i, tier in enumerate(Params.tiers): + if State.parent_gas_used is None: + # initialized gas price for the first block + State.gas_prices[i] = tier.initial_gas_price + else: + # adjust gas price according to gas used in previous block + State.gas_prices[i] = adjust_gas_price(State.gas_prices[i], State.parent_gas_used, tier) + +def mempoolFeeTxHandler_checkTx(ctx, tx): + # the minimal-gas-price configured by validator, zero in deliver_tx context + validator_price = ctx.MinGasPrice() + consensus_price = State.gas_prices[tx_tier(tx)] + min_price = max(validator_price, consensus_price) + + # zero means infinity for gas price cap + if tx.gas_price() > 0 and tx.gas_price() < min_price: + return 'insufficient fees' + return next_CheckTx(ctx, tx) + +def txPriorityHandler_checkTx(ctx, tx): + res, err := next_CheckTx(ctx, tx) + # pass priority to tendermint + res.Priority = Params.tiers[tx_tier(tx)].priority + return res, err + +def end_block(): + 'Update block gas used' + State.parent_gas_used = block_gas_meter.consumed() +``` + +### Dos attack protection + +To fully saturate the blocks and prevent other transactions from executing, attacker need to use transactions of highest tier, the cost would be significantly higher than the default tier. + +If attacker spam with lower tier transactions, user can mitigate by sending higher tier transactions. + +## Consequences + +### Backwards Compatibility + +- New protocol parameters. +- New consensus states. +- New/changed fields in transaction body. + +### Positive + +- The default tier keeps the same predictable gas price experience for client. +- The higher tier's gas price can adapt to block load. +- No priority conflict with custom priority based on transaction types, since this proposal only occupy three priority levels. +- Possibility to compose different priority rules with tiers + +### Negative + +- Wallets & tools need to update to support the new `tier` parameter, and semantic of `fee` field is changed. + +### Neutral + +## References + +- https://eips.ethereum.org/EIPS/eip-1559 +- https://iohk.io/en/blog/posts/2021/11/26/network-traffic-and-tiered-pricing/ diff --git a/docs/architecture/adr-053-go-module-refactoring.md b/docs/architecture/adr-053-go-module-refactoring.md new file mode 100644 index 000000000000..9093ae9d9013 --- /dev/null +++ b/docs/architecture/adr-053-go-module-refactoring.md @@ -0,0 +1,109 @@ +# ADR 053: Go Module Refactoring + +## Changelog + +* 2022-04-27: First Draft + +## Status + +PROPOSED + +## Abstract + +The current SDK is built as a single monolithic go module. This ADR describes +how we refactor the SDK into smaller independently versioned go modules +for ease of maintenance. + +## Context + +Go modules impose certain requirements on software projects with respect to +stable version numbers (anything above 0.x) in that [any API breaking changes +necessitate a major version](https://go.dev/doc/modules/release-workflow#breaking) +increase which technically creates a new go module +(with a v2, v3, etc. suffix). + +[Keeping modules API compatible](https://go.dev/blog/module-compatibility) in +this way requires a fair amount of fair thought and discipline. + +The Cosmos SDK is a fairly large project which originated before go modules +came into existence and has always been under a v0.x release even though +it has been used in production for years now, not because it isn't production +quality software, but rather because the API compatibility guarantees required +by go modules are fairly complex to adhere to with such a large project. +Up to now, it has generally been deemed more important to be able to break the +API if needed rather than require all users update all package import paths +to accommodate breaking changes causing v2, v3, etc. releases. This is in +addition to the other complexities related to protobuf generated code that will +be addressed in a separate ADR. + +Nevertheless, the desire for semantic versioning has been [strong in the +community](https://github.com/cosmos/cosmos-sdk/discussions/10162) and the +single go module release process has made it very hard to +release small changes to isolated features in a timely manner. Release cycles +often exceed six months which means small improvements done in a day or +two get bottle-necked by everything else in the monolithic release cycle. + +## Decision + +To improve the current situation, the SDK is being refactored into multiple +go modules within the current repository. There has been a [fair amount of +debate](https://github.com/cosmos/cosmos-sdk/discussions/10582#discussioncomment-1813377) +as to how to do this, with some developers arguing for larger vs smaller +module scopes. There are pros and cons to both approaches (which will be +discussed below in the [Consequences](#consequences) section), but the +approach being adopted is the following: +* a go module should generally be scoped to a specific coherent set of +functionality (such as math, errors, store, etc.) +* when code is removed from the core SDK and moved to a new module path, every +effort should be made to avoid API breaking changes in the existing code using +aliases and wrapper types (as done in https://github.com/cosmos/cosmos-sdk/pull/10779 +and https://github.com/cosmos/cosmos-sdk/pull/11788) +* new go modules should be moved to a standalone domain (`cosmossdk.io`) before +being tagged as `v1.0.0` to accommodate the possibility that they may be +better served by a standalone repository in the future +* all go modules should follow the guidelines in https://go.dev/blog/module-compatibility +before `v1.0.0` is tagged and should make use of `internal` packages to limit +the exposed API surface +* the new go module's API may deviate from the existing code where there are +clear improvements to be made or to remove legacy dependencies (for instance on +amino or gogo proto), as long the old package attempts +to avoid API breakage with aliases and wrappers +* care should be taken when simply trying to turn an existing package into a +new go module: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository. +In general, it seems safer to just create a new module path (appending v2, v3, etc. +if necessary), rather than trying to make an old package a new module. + +## Consequences + +### Backwards Compatibility + +If the above guidelines are followed to use aliases or wrapper types pointing +in existing APIs that point back to the new go modules, there should be no or +very limited breaking changes to existing APIs. + +### Positive + +* standalone pieces of software will reach `v1.0.0` sooner +* new features to specific functionality will be released sooner + +### Negative + +* there will be more go module versions to update in the SDK itself and +per-project, although most of these will hopefully be indirect + +### Neutral + +## Further Discussions + +Further discussions are occurring in primarily in +https://github.com/cosmos/cosmos-sdk/discussions/10582 and within +the Cosmos SDK Framework Working Group. + +## References + +* https://go.dev/doc/modules/release-workflow +* https://go.dev/blog/module-compatibility +* https://github.com/cosmos/cosmos-sdk/discussions/10162 +* https://github.com/cosmos/cosmos-sdk/discussions/10582 +* https://github.com/cosmos/cosmos-sdk/pull/10779 +* https://github.com/cosmos/cosmos-sdk/pull/11788 \ No newline at end of file diff --git a/docs/architecture/adr-055-orm.md b/docs/architecture/adr-055-orm.md new file mode 100644 index 000000000000..71a7595260e1 --- /dev/null +++ b/docs/architecture/adr-055-orm.md @@ -0,0 +1,111 @@ +# ADR 055: ORM + +## Changelog + +* 2022-04-27: First draft + +## Status + +ACCEPTED Implemented + +## Abstract + +In order to make it easier for developers to build Cosmos SDK modules and for clients to query, index and verify proofs +against state data, we have implemented an ORM (object-relational mapping) layer for the Cosmos SDK. + +## Context + +Historically modules in the Cosmos SDK have always used the key-value store directly and created various handwritten +functions for managing key format as well as constructing secondary indexes. This consumes a significant amount of +time when building a module and is error-prone. Because key formats are non-standard, sometimes poorly documented, +and subject to change, it is hard for clients to generically index, query and verify merkle proofs against state data. + +The known first instance of an "ORM" in the Cosmos ecosystem was in [weave](https://github.com/iov-one/weave/tree/master/orm). +A later version was built for [regen-ledger](https://github.com/regen-network/regen-ledger/tree/157181f955823149e1825263a317ad8e16096da4/orm) for +use in the group module and later [ported to the SDK](https://github.com/cosmos/cosmos-sdk/tree/35d3312c3be306591fcba39892223f1244c8d108/x/group/internal/orm) +just for that purpose. + +While these earlier designs made it significantly easier to write state machines, they still required a lot of manual +configuration, didn't expose state format directly to clients, and were limited in their support of different types +of index keys, composite keys, and range queries. + +Discussions about the design continued in https://github.com/cosmos/cosmos-sdk/discussions/9156 and more +sophisticated proofs of concept were created in https://github.com/allinbits/cosmos-sdk-poc/tree/master/runtime/orm +and https://github.com/cosmos/cosmos-sdk/pull/10454. + +## Decision + +These prior efforts culminated in the creation of the Cosmos SDK `orm` go module which uses protobuf annotations +for specifying ORM table definitions. This ORM is based on the new `google.golang.org/protobuf/reflect/protoreflect` +API and supports: +* sorted indexes for all simple protobuf types (except `bytes`, `enum`, `float`, `double`) as well as `Timestamp` and `Duration` +* unsorted `bytes` and `enum` indexes +* composite primary and secondary keys +* unique indexes +* auto-incrementing `uint64` primary keys +* complex prefix and range queries +* paginated queries +* complete logical decoding of KV-store data + +Almost all the information needed to decode state directly is specified in .proto files. Each table definition specifies +an ID which is unique per .proto file and each index within a table is unique within that table. Clients then only need +to know the name of a module and the prefix ORM data for a specific .proto file within that module in order to decode +state data directly. This additional information will be exposed directly through app configs which will be explained +in a future ADR related to app wiring. + +The ORM makes optimizations around storage space by not repeating values in the primary key in the key value +when storing primary key records. For example, if the object `{"a":0,"b":1}` has the primary key `a`, it will +be stored in the key value store as `Key: '0', Value: {"b":1}` (with more efficient protobuf binary encoding). +Also, the generated code from https://github.com/cosmos/cosmos-proto does optimizations around the +`google.golang.org/protobuf/reflect/protoreflect` API to improve performance. + +A code generator is included with the ORM which creates type safe wrappers around the ORM's dynamic `Table` +implementation and is the recommended way for modules to use the ORM. + +The ORM tests provide a simplified bank module demonstration which illustrates: +- [ORM proto options](https://github.com/cosmos/cosmos-sdk/blob/0d846ae2f0424b2eb640f6679a703b52d407813d/orm/internal/testpb/bank.proto) +- [Generated Code](https://github.com/cosmos/cosmos-sdk/blob/0d846ae2f0424b2eb640f6679a703b52d407813d/orm/internal/testpb/bank.cosmos_orm.go) +- [Example Usage in a Module Keeper](https://github.com/cosmos/cosmos-sdk/blob/0d846ae2f0424b2eb640f6679a703b52d407813d/orm/model/ormdb/module_test.go) + +## Consequences + +### Backwards Compatibility + +State machine code that adopts the ORM will need migrations as the state layout is generally backwards incompatible. +These state machines will also need to migrate to https://github.com/cosmos/cosmos-proto at least for state data. + +### Positive + +* easier to build modules +* easier to add secondary indexes to state +* possible to write a generic indexer for ORM state +* easier to write clients that do state proofs +* possible to automatically write query layers rather than needing to manually implement gRPC queries + +### Negative + +* worse performance than handwritten keys (for now). See [Further Discussions](#further-discussions) +for potential improvements + +### Neutral + +## Further Discussions + +Further discussions will happen within the Cosmos SDK Framework Working Group. Current planned and ongoing work includes: +* automatically generate client-facing query layer +* client-side query libraries that transparently verify light client proofs +* index ORM data to SQL databases +* improve performance by: + * optimizing existing reflection based code to avoid unnecessary gets when doing deletes & updates of simple tables + * more sophisticated code generation such as making fast path reflection even faster (avoiding `switch` statements), + or even fully generating code that equals handwritten performance + + +## References + +* https://github.com/iov-one/weave/tree/master/orm). +* https://github.com/regen-network/regen-ledger/tree/157181f955823149e1825263a317ad8e16096da4/orm +* https://github.com/cosmos/cosmos-sdk/tree/35d3312c3be306591fcba39892223f1244c8d108/x/group/internal/orm +* https://github.com/cosmos/cosmos-sdk/discussions/9156 +* https://github.com/allinbits/cosmos-sdk-poc/tree/master/runtime/orm +* https://github.com/cosmos/cosmos-sdk/pull/10454 \ No newline at end of file diff --git a/docs/basics/accounts.md b/docs/basics/accounts.md index 05e9ff268141..2ee844c83203 100644 --- a/docs/basics/accounts.md +++ b/docs/basics/accounts.md @@ -131,16 +131,16 @@ For user interactions, `PubKey` is formatted using Protobufs JSON ([ProtoMarshal A `Keyring` is an object that stores and manages accounts. In the Cosmos SDK, a `Keyring` implementation follows the `Keyring` interface: -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.42.1/crypto/keyring/keyring.go#L51-L89 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/crypto/keyring/keyring.go#L54-L101 The default implementation of `Keyring` comes from the third-party [`99designs/keyring`](https://github.com/99designs/keyring) library. A few notes on the `Keyring` methods: -* `Sign(uid string, payload []byte) ([]byte, sdkcrypto.PubKey, error)` strictly deals with the signature of the `payload` bytes. You must prepare and encode the transaction into a canonical `[]byte` form. Because protobuf is not deterministic, it has been decided in [ADR-020](../architecture/adr-020-protobuf-transaction-encoding.md) that the canonical `payload` to sign is the `SignDoc` struct, deterministically encoded using [ADR-027](../architecture/adr-027-deterministic-protobuf-serialization.md). Note that signature verification is not implemented in the Cosmos SDK by default, it is deferred to the [`anteHandler`](../core/baseapp.md#antehandler). - +++ https://github.com/cosmos/cosmos-sdk/blob/v0.42.1/proto/cosmos/tx/v1beta1/tx.proto#L47-L64 +* `Sign(uid string, msg []byte) ([]byte, types.PubKey, error)` strictly deals with the signature of the `msg` bytes. You must prepare and encode the transaction into a canonical `[]byte` form. Because protobuf is not deterministic, it has been decided in [ADR-020](../architecture/adr-020-protobuf-transaction-encoding.md) that the canonical `payload` to sign is the `SignDoc` struct, deterministically encoded using [ADR-027](../architecture/adr-027-deterministic-protobuf-serialization.md). Note that signature verification is not implemented in the Cosmos SDK by default, it is deferred to the [`SigVerificationMiddleware middleware`](../core/baseapp.md#middleware). + +++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/tx/v1beta1/tx.proto#L49-L64 -* `NewAccount(uid, mnemonic, bip39Passwd, hdPath string, algo SignatureAlgo) (Info, error)` creates a new account based on the [`bip44 path`](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) and persists it on disk. The `PrivKey` is **never stored unencrypted**, instead it is [encrypted with a passphrase](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/crypto/armor.go) before being persisted. In the context of this method, the key type and sequence number refer to the segment of the BIP44 derivation path (for example, `0`, `1`, `2`, ...) that is used to derive a private and a public key from the mnemonic. Using the same mnemonic and derivation path, the same `PrivKey`, `PubKey` and `Address` is generated. The following keys are supported by the keyring: +* `NewAccount(uid, mnemonic, bip39Passphrase, hdPath string, algo SignatureAlgo) (*Record, error)` creates a new account based on the [`bip44 path`](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki) and persists it on disk. The `PrivKey` is **never stored unencrypted**, instead it is [encrypted with a passphrase](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/crypto/armor.go) before being persisted. In the context of this method, the key type and sequence number refer to the segment of the BIP44 derivation path (for example, `0`, `1`, `2`, ...) that is used to derive a private and a public key from the mnemonic. Using the same mnemonic and derivation path, the same `PrivKey`, `PubKey` and `Address` is generated. The following keys are supported by the keyring: * `secp256k1` * `ed25519` diff --git a/docs/basics/app-anatomy.md b/docs/basics/app-anatomy.md index 312b3d72eb32..ab7dfc55c68e 100644 --- a/docs/basics/app-anatomy.md +++ b/docs/basics/app-anatomy.md @@ -44,7 +44,7 @@ In general, the core of the state-machine is defined in a file called `app.go`. The first thing defined in `app.go` is the `type` of the application. It is generally comprised of the following parts: -* **A reference to [`baseapp`](../core/baseapp.md).** The custom application defined in `app.go` is an extension of `baseapp`. When a transaction is relayed by Tendermint to the application, `app` uses `baseapp`'s methods to route them to the appropriate module. `baseapp` implements most of the core logic for the application, including all the [ABCI methods](https://tendermint.com/docs/spec/abci/abci.html#overview) and the [routing logic](../core/baseapp.md#routing). +* **A reference to [`baseapp`](../core/baseapp.md).** The custom application defined in `app.go` is an extension of `baseapp`. When a transaction is relayed by Tendermint to the application, `app` uses `baseapp`'s methods to route them to the appropriate module. `baseapp` implements most of the core logic for the application, including all the [ABCI methods](https://docs.tendermint.com/master/spec/abci/abci.html) and the [routing logic](../core/baseapp.md#routing). * **A list of store keys**. The [store](../core/store.md), which contains the entire state, is implemented as a [`multistore`](../core/store.md#multistore) (i.e. a store of stores) in the Cosmos SDK. Each module uses one or multiple stores in the multistore to persist their part of the state. These stores can be accessed with specific keys that are declared in the `app` type. These keys, along with the `keepers`, are at the heart of the [object-capabilities model](../core/ocap.md) of the Cosmos SDK. * **A list of module's `keeper`s.** Each module defines an abstraction called [`keeper`](../building-modules/keeper.md), which handles reads and writes for this module's store(s). The `keeper`'s methods of one module can be called from other modules (if authorized), which is why they are declared in the application's type and exported as interfaces to other modules so that the latter can only access the authorized functions. * **A reference to an [`appCodec`](../core/encoding.md).** The application's `appCodec` is used to serialize and deserialize data structures in order to store them, as stores can only persist `[]bytes`. The default codec is [Protocol Buffers](../core/encoding.md). @@ -53,13 +53,13 @@ The first thing defined in `app.go` is the `type` of the application. It is gene See an example of application type definition from `simapp`, the Cosmos SDK's own app used for demo and testing purposes: -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/simapp/app.go#L145-L187 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/simapp/app.go#L151-L195 ### Constructor Function This function constructs a new application of the type defined in the section above. It must fulfill the `AppCreator` signature in order to be used in the [`start` command](../core/node.md#start-command) of the application's daemon command. -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/server/types/app.go#L48-L50 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/server/types/app.go#L57-L59 Here are the main actions performed by this function: @@ -73,7 +73,7 @@ Here are the main actions performed by this function: * Set the remainder of application's parameters: * [`InitChainer`](#initchainer): used to initialize the application when it is first started. * [`BeginBlocker`, `EndBlocker`](#beginblocker-and-endlbocker): called at the beginning and the end of every block). - * [`anteHandler`](../core/baseapp.md#antehandler): used to handle fees and signature verification. + * [`TxHandler`](../core/baseapp.md#middleware): to setup middlewares, f.e. used to handle fees and signature verification. * Mount the stores. * Return the application. @@ -81,7 +81,7 @@ Note that this function only creates an instance of the app, while the actual st See an example of application constructor from `simapp`: -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/simapp/app.go#L198-L441 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/simapp/app.go#L207-L456 ### InitChainer @@ -143,10 +143,10 @@ Each module defines two [Protobuf services](https://developers.google.com/protoc Each Protobuf `Msg` service method is 1:1 related to a Protobuf request type, which must implement `sdk.Msg` interface. Note that `sdk.Msg`s are bundled in [transactions](../core/transactions.md), and each transaction contains one or multiple messages. -When a valid block of transactions is received by the full-node, Tendermint relays each one to the application via [`DeliverTx`](https://tendermint.com/docs/app-dev/abci-spec.html#delivertx). Then, the application handles the transaction: +When a valid block of transactions is received by the full-node, Tendermint relays each one to the application via [`DeliverTx`](https://docs.tendermint.com/master/spec/abci/apps.html#delivertx). Then, the application handles the transaction: -1. Upon receiving the transaction, the application first unmarshalls it from `[]bytes`. -2. Then, it verifies a few things about the transaction like [fee payment and signatures](#gas-fees.md#antehandler) before extracting the `Msg`(s) contained in the transaction. +1. Upon receiving the transaction, the application first unmarshalls it from `[]byte`. +2. Then, it verifies a few things about the transaction like [fee payment and signatures](./gas-fees.md#middleware) before extracting the `Msg`(s) contained in the transaction. 3. `sdk.Msg`s are encoded using Protobuf [`Any`s](#register-codec). By analyzing each `Any`'s `type_url`, baseapp's `msgServiceRouter` routes the `sdk.Msg` to the corresponding module's `Msg` service. 4. If the message is successfully processed, the state is updated. @@ -197,7 +197,7 @@ Generally, the [commands related to a module](../building-modules/module-interfa #### gRPC -[gRPC](https://grpc.io) is a modern open source high performance RPC framework that has support in multiple languages. It is the recommended way for external clients (such as wallets, browsers and other backend services) to interact with a node. +[gRPC](https://grpc.io) is a modern open-source high performance RPC framework that has support in multiple languages. It is the recommended way for external clients (such as wallets, browsers and other backend services) to interact with a node. Each module can expose gRPC endpoints, called [service methods](https://grpc.io/docs/what-is-grpc/core-concepts/#service-definition) and are defined in the [module's Protobuf `query.proto` file](#grpc-query-services). A service method is defined by its name, input arguments and output response. The module then needs to: diff --git a/docs/basics/gas-fees.md b/docs/basics/gas-fees.md index 81df8096e728..10205cf92996 100644 --- a/docs/basics/gas-fees.md +++ b/docs/basics/gas-fees.md @@ -15,7 +15,7 @@ This document describes the default strategies to handle gas and fees within a C In the Cosmos SDK, `gas` is a special unit that is used to track the consumption of resources during execution. `gas` is typically consumed whenever read and writes are made to the store, but it can also be consumed if expensive computation needs to be done. It serves two main purposes: * Make sure blocks are not consuming too many resources and will be finalized. This is implemented by default in the Cosmos SDK via the [block gas meter](#block-gas-meter). -* Prevent spam and abuse from end-user. To this end, `gas` consumed during [`message`](../building-modules/messages-and-queries.md#messages) execution is typically priced, resulting in a `fee` (`fees = gas * gas-prices`). `fees` generally have to be paid by the sender of the `message`. Note that the Cosmos SDK does not enforce `gas` pricing by default, as there may be other ways to prevent spam (e.g. bandwidth schemes). Still, most applications will implement `fee` mechanisms to prevent spam. This is done via the [`AnteHandler`](#antehandler). +* Prevent spam and abuse from end-user. To this end, `gas` consumed during [`message`](../building-modules/messages-and-queries.md#messages) execution is typically priced, resulting in a `fee` (`fees = gas * gas-prices`). `fees` generally have to be paid by the sender of the `message`. Note that the Cosmos SDK does not enforce `gas` pricing by default, as there may be other ways to prevent spam (e.g. bandwidth schemes). Still, most applications will implement `fee` mechanisms to prevent spam. This is done via the [`GasTxMiddleware` middleware](#middleware). ## Gas Meter @@ -42,13 +42,13 @@ By default, the Cosmos SDK makes use of two different gas meters, the [main gas ### Main Gas Meter -`ctx.GasMeter()` is the main gas meter of the application. The main gas meter is initialized in `BeginBlock` via `setDeliverState`, and then tracks gas consumption during execution sequences that lead to state-transitions, i.e. those originally triggered by [`BeginBlock`](../core/baseapp.md#beginblock), [`DeliverTx`](../core/baseapp.md#delivertx) and [`EndBlock`](../core/baseapp.md#endblock). At the beginning of each `DeliverTx`, the main gas meter **must be set to 0** in the [`AnteHandler`](#antehandler), so that it can track gas consumption per-transaction. +`ctx.GasMeter()` is the main gas meter of the application. The main gas meter is initialized in `BeginBlock` via `setDeliverState`, and then tracks gas consumption during execution sequences that lead to state-transitions, i.e. those originally triggered by [`BeginBlock`](../core/baseapp.md#beginblock), [`DeliverTx`](../core/baseapp.md#delivertx) and [`EndBlock`](../core/baseapp.md#endblock). At the beginning of each `DeliverTx`, the main gas meter **must be set to 0** in the [`GasTxMiddleware` middleware](#middleware), so that it can track gas consumption per-transaction. Gas consumption can be done manually, generally by the module developer in the [`BeginBlocker`, `EndBlocker`](../building-modules/beginblock-endblock.md) or [`Msg` service](../building-modules/msg-services.md), but most of the time it is done automatically whenever there is a read or write to the store. This automatic gas consumption logic is implemented in a special store called [`GasKv`](../core/store.md#gaskv-store). ### Block Gas Meter -`ctx.BlockGasMeter()` is the gas meter used to track gas consumption per block and make sure it does not go above a certain limit. A new instance of the `BlockGasMeter` is created each time [`BeginBlock`](../core/baseapp.md#beginblock) is called. The `BlockGasMeter` is finite, and the limit of gas per block is defined in the application's consensus parameters. By default Cosmos SDK applications use the default consensus parameters provided by Tendermint: +`ctx.BlockGasMeter()` is the gas meter used to track gas consumption per block and make sure it does not go above a certain limit. A new instance of the `BlockGasMeter` is created each time [`BeginBlock`](../core/baseapp.md#beginblock) is called. The `BlockGasMeter` is finite, and the limit of gas per block is defined in the application's consensus parameters. By default, Cosmos SDK applications use the default consensus parameters provided by Tendermint: +++ https://github.com/tendermint/tendermint/blob/v0.34.0-rc6/types/params.go#L34-L41 @@ -61,28 +61,22 @@ ctx.BlockGasMeter().ConsumeGas( ) ``` -## AnteHandler +## Middleware -The `AnteHandler` is run for every transaction during `CheckTx` and `DeliverTx`, before a Protobuf `Msg` service method for each `sdk.Msg` in the transaction. `AnteHandler`s have the following signature: +The `GasTxMiddleware` is run for every transaction during `CheckTx` and `DeliverTx`, before a Protobuf `Msg` service method for each `sdk.Msg` in the transaction. -```go -// AnteHandler authenticates transactions, before their internal messages are handled. -// If newCtx.IsZero(), ctx is used instead. -type AnteHandler func(ctx Context, tx Tx, simulate bool) (newCtx Context, result Result, abort bool) -``` - -The `anteHandler` is not implemented in the core Cosmos SDK but in a module. This gives the possibility to developers to choose which version of `AnteHandler` fits their application's needs. That said, most applications today use the default implementation defined in the [`auth` module](https://github.com/cosmos/cosmos-sdk/tree/master/x/auth). Here is what the `anteHandler` is intended to do in a normal Cosmos SDK application: +The `GasTxMiddleware` is not implemented in the core Cosmos SDK but in a module. That said, most applications today use the default implementation defined in the [`auth` module](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth/middleware). Here is what the `middleware` is intended to do in a normal Cosmos SDK application: -* Verify that the transaction are of the correct type. Transaction types are defined in the module that implements the `anteHandler`, and they follow the transaction interface: - +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/types/tx_msg.go#L49-L57 +* Verify that the transactions are of the correct type. Transaction types are defined in the module that implements the `middleware`, and they follow the transaction interface: + +++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/types/tx_msg.go#L38-L46 This enables developers to play with various types for the transaction of their application. In the default `auth` module, the default transaction type is `Tx`: - +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/proto/cosmos/tx/v1beta1/tx.proto#L12-L25 -* Verify signatures for each [`message`](../building-modules/messages-and-queries.md#messages) contained in the transaction. Each `message` should be signed by one or multiple sender(s), and these signatures must be verified in the `anteHandler`. -* During `CheckTx`, verify that the gas prices provided with the transaction is greater than the local `min-gas-prices` (as a reminder, gas-prices can be deducted from the following equation: `fees = gas * gas-prices`). `min-gas-prices` is a parameter local to each full-node and used during `CheckTx` to discard transactions that do not provide a minimum amount of fees. This ensure that the mempool cannot be spammed with garbage transactions. + +++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/tx/v1beta1/tx.proto#L13-L26 +* Verify signatures for each [`message`](../building-modules/messages-and-queries.md#messages) contained in the transaction. Each `message` should be signed by one or multiple sender(s), and these signatures must be verified by a `middleware`. +* During `CheckTx`, verify that the gas prices provided with the transaction is greater than the local `min-gas-prices` (as a reminder, gas-prices can be deducted from the following equation: `fees = gas * gas-prices`). `min-gas-prices` is a parameter local to each full-node and used during `CheckTx` to discard transactions that do not provide a minimum amount of fees. This ensures that the mempool cannot be spammed with garbage transactions. * Verify that the sender of the transaction has enough funds to cover for the `fees`. When the end-user generates a transaction, they must indicate 2 of the 3 following parameters (the third one being implicit): `fees`, `gas` and `gas-prices`. This signals how much they are willing to pay for nodes to execute their transaction. The provided `gas` value is stored in a parameter called `GasWanted` for later use. -* Set `newCtx.GasMeter` to 0, with a limit of `GasWanted`. **This step is extremely important**, as it not only makes sure the transaction cannot consume infinite gas, but also that `ctx.GasMeter` is reset in-between each `DeliverTx` (`ctx` is set to `newCtx` after `anteHandler` is run, and the `anteHandler` is run each time `DeliverTx` is called). +* Set `newCtx.GasMeter` to 0, with a limit of `GasWanted`. **This step is crucial**, as it not only makes sure the transaction cannot consume infinite gas, but also that `ctx.GasMeter` is reset in-between each `DeliverTx` (`ctx.GasMeter` is set by the middleware each time `DeliverTx` is called). -As explained above, the `anteHandler` returns a maximum limit of `gas` the transaction can consume during execution called `GasWanted`. The actual amount consumed in the end is denominated `GasUsed`, and we must therefore have `GasUsed =< GasWanted`. Both `GasWanted` and `GasUsed` are relayed to the underlying consensus engine when [`DeliverTx`](../core/baseapp.md#delivertx) returns. +As explained above, the middleware returns a maximum limit of `gas` the transaction can consume during execution called `GasWanted`. The actual amount consumed in the end is denominated `GasUsed`, and we must therefore have `GasUsed =< GasWanted`. Both `GasWanted` and `GasUsed` are relayed to the underlying consensus engine when [`DeliverTx`](../core/baseapp.md#delivertx) returns. ## Next {hide} diff --git a/docs/basics/query-lifecycle.md b/docs/basics/query-lifecycle.md index 7d85127d3827..1e0221caa7b5 100644 --- a/docs/basics/query-lifecycle.md +++ b/docs/basics/query-lifecycle.md @@ -123,11 +123,11 @@ Here is what the code looks like: With a call to `ABCIQueryWithOptions()`, `MyQuery` is received by a [full-node](../core/encoding.md) which will then process the request. Note that, while the RPC is made to the consensus engine (e.g. Tendermint Core) of a full-node, queries are not part of consensus and will not be broadcasted to the rest of the network, as they do not require anything the network needs to agree upon. -Read more about ABCI Clients and Tendermint RPC in the Tendermint documentation [here](https://tendermint.com/rpc). +Read more about ABCI Clients and Tendermint RPC in the Tendermint documentation [here](https://docs.tendermint.com/master/rpc/). ## Application Query Handling -When a query is received by the full-node after it has been relayed from the underlying consensus engine, it is now being handled within an environment that understands application-specific types and has a copy of the state. [`baseapp`](../core/baseapp.md) implements the ABCI [`Query()`](../core/baseapp.md#query) function and handles gRPC queries. The query route is parsed, and it it matches the fully-qualified service method name of an existing service method (most likely in one of the modules), then `baseapp` will relay the request to the relevant module. +When a query is received by the full-node after it has been relayed from the underlying consensus engine, it is now being handled within an environment that understands application-specific types and has a copy of the state. [`baseapp`](../core/baseapp.md) implements the ABCI [`Query()`](../core/baseapp.md#query) function and handles gRPC queries. The query route is parsed, and it matches the fully-qualified service method name of an existing service method (most likely in one of the modules), then `baseapp` will relay the request to the relevant module. Apart from gRPC routes, `baseapp` also handles four different types of queries: `app`, `store`, `p2p`, and `custom`. The first three types (`app`, `store`, `p2p`) are purely application-level and thus directly handled by `baseapp` or the stores, but the `custom` query type requires `baseapp` to route the query to a module's [legacy queriers](../building-modules/query-services.md#legacy-queriers). To learn more about these queries, please refer to [this guide](../core/grpc_rest.md#tendermint-rpc). @@ -137,7 +137,7 @@ Once a result is received from the querier, `baseapp` begins the process of retu ## Response -Since `Query()` is an ABCI function, `baseapp` returns the response as an [`abci.ResponseQuery`](https://tendermint.com/docs/spec/abci/abci.html#messages) type. The `client.Context` `Query()` routine receives the response and. +Since `Query()` is an ABCI function, `baseapp` returns the response as an [`abci.ResponseQuery`](https://docs.tendermint.com/master/spec/abci/abci.html#query-2) type. The `client.Context` `Query()` routine receives the response and. ### CLI Response diff --git a/docs/basics/tx-lifecycle.md b/docs/basics/tx-lifecycle.md index 8209e2c518a5..024a26b97dd2 100644 --- a/docs/basics/tx-lifecycle.md +++ b/docs/basics/tx-lifecycle.md @@ -30,7 +30,7 @@ Additionally, there are several [flags](../core/cli.md) users can use to indicat * `--gas` refers to how much [gas](./gas-fees.md), which represents computational resources, `Tx` consumes. Gas is dependent on the transaction and is not precisely calculated until execution, but can be estimated by providing `auto` as the value for `--gas`. * `--gas-adjustment` (optional) can be used to scale `gas` up in order to avoid underestimating. For example, users can specify their gas adjustment as 1.5 to use 1.5 times the estimated gas. -* `--gas-prices` specifies how much the user is willing pay per unit of gas, which can be one or multiple denominations of tokens. For example, `--gas-prices=0.025uatom, 0.025upho` means the user is willing to pay 0.025uatom AND 0.025upho per unit of gas. +* `--gas-prices` specifies how much the user is willing to pay per unit of gas, which can be one or multiple denominations of tokens. For example, `--gas-prices=0.025uatom, 0.025upho` means the user is willing to pay 0.025uatom AND 0.025upho per unit of gas. * `--fees` specifies how much in fees the user is willing to pay in total. * `--timeout-height` specifies a block timeout height to prevent the tx from being committed past a certain height. @@ -40,7 +40,7 @@ Later, validators decide whether or not to include the transaction in their bloc #### CLI Example -Users of application `app` can enter the following command into their CLI to generate a transaction to send 1000uatom from a `senderAddress` to a `recipientAddress`. It specifies how much gas they are willing to pay: an automatic estimate scaled up by 1.5 times, with a gas price of 0.025uatom per unit gas. +Users of the application `app` can enter the following command into their CLI to generate a transaction to send 1000uatom from a `senderAddress` to a `recipientAddress`. It specifies how much gas they are willing to pay: an automatic estimate scaled up by 1.5 times, with a gas price of 0.025uatom per unit gas. ```bash appd tx send 1000uatom --from --gas auto --gas-adjustment 1.5 --gas-prices 0.025uatom @@ -48,13 +48,13 @@ appd tx send 1000uatom --from --gas auto --ga #### Other Transaction Creation Methods -The command-line is an easy way to interact with an application, but `Tx` can also be created using a [gRPC or REST interface](../core/grpc_rest.md) or some other entrypoint defined by the application developer. From the user's perspective, the interaction depends on the web interface or wallet they are using (e.g. creating `Tx` using [Lunie.io](https://lunie.io/#/) and signing it with a Ledger Nano S). +The command-line is an easy way to interact with an application, but `Tx` can also be created using a [gRPC or REST interface](../core/grpc_rest.md) or some other entry point defined by the application developer. From the user's perspective, the interaction depends on the web interface or wallet they are using (e.g. creating `Tx` using [Lunie.io](https://lunie.io/#/) and signing it with a Ledger Nano S). ## Addition to Mempool -Each full-node (running Tendermint) that receives a `Tx` sends an [ABCI message](https://tendermint.com/docs/spec/abci/abci.html#messages), +Each full-node (running Tendermint) that receives a `Tx` sends an [ABCI message](https://docs.tendermint.com/master/spec/abci/abci.html#messages), `CheckTx`, to the application layer to check for validity, and receives an `abci.ResponseCheckTx`. If the `Tx` passes the checks, it is held in the nodes' -[**Mempool**](https://tendermint.com/docs/tendermint-core/mempool.html#mempool), an in-memory pool of transactions unique to each node) pending inclusion in a block - honest nodes will discard `Tx` if it is found to be invalid. Prior to consensus, nodes continuously check incoming transactions and gossip them to their peers. +[**Mempool**](https://docs.tendermint.com/master/tendermint-core/mempool/), an in-memory pool of transactions unique to each node, pending inclusion in a block - honest nodes will discard `Tx` if it is found to be invalid. Prior to consensus, nodes continuously check incoming transactions and gossip them to their peers. ### Types of Checks @@ -66,9 +66,9 @@ them - and are thus less computationally expensive. Stateless checks include mak are not empty, enforcing nonnegative numbers, and other logic specified in the definitions. **_Stateful_** checks validate transactions and messages based on a committed state. Examples -include checking that the relevant values exist and are able to be transacted with, the address +include checking that the relevant values exist and can be transacted with, the address has sufficient funds, and the sender is authorized or has the correct ownership to transact. -At any given moment, full-nodes typically have [multiple versions](../core/baseapp.md#volatile-states) +At any given moment, full-nodes typically have [multiple versions](../core/baseapp.md#state-updates) of the application's internal state for different purposes. For example, nodes will execute state changes while in the process of verifying transactions, but still need a copy of the last committed state in order to answer queries - they should not respond using state with uncommitted changes. @@ -79,7 +79,7 @@ through several steps, beginning with decoding `Tx`. ### Decoding -When `Tx` is received by the application from the underlying consensus engine (e.g. Tendermint), it is still in its [encoded](../core/encoding.md) `[]byte` form and needs to be unmarshaled in order to be processed. Then, the [`runTx`](../core/baseapp.md#runtx-and-runmsgs) function is called to run in `runTxModeCheck` mode, meaning the function will run all checks but exit before executing messages and writing state changes. +When `Tx` is received by the application from the underlying consensus engine (e.g. Tendermint), it is still in its [encoded](../core/encoding.md) `[]byte` form and needs to be unmarshaled in order to be processed. Then, the transaction is passed to the middlewares defined in `tx.Handler`. The middlewares will perform additional checks defined in their own `CheckTx`, meaning that they will run all checks but exit before executing messages and writing state changes. ### ValidateBasic @@ -89,20 +89,20 @@ To discard obviously invalid messages, the `BaseApp` type calls the `ValidateBas #### Guideline -Gas is not charged when `ValidateBasic` is executed so we recommend only performing all necessary stateless checks to enable middleware operations (for example, parsing the required signer accounts to validate a signature by a middleware) and stateless sanity checks not impacting performance of the CheckTx phase. +Gas is not charged when `ValidateBasic` is executed, so we recommend only performing all necessary stateless checks to enable middleware operations (for example, parsing the required signer accounts to validate a signature by a middleware) and stateless sanity checks not impacting performance of the CheckTx phase. Other validation operations must be performed when [handling a message](../building-modules/msg-services#Validation) in a module Msg Server. Example, if the message is to send coins from one address to another, `ValidateBasic` likely checks for non-empty addresses and a non-negative coin amount, but does not require knowledge of state such as the account balance of an address. See also [Msg Service Validation](../building-modules/msg-services.md#Validation). -### AnteHandler +### Middlewares -After the ValidateBasic checks, the `AnteHandler`s are run. Technically, they are optional, but in practice, they are very often present to perform signature verification, gas calculation, fee deduction and other core operations related to blockchain transactions. +Middlewares implements the `TxHandler` interface and are defined by `tx.Handler` in `BaseApp`. This architecture allows running the middlewares logic in the `CheckTx` and `DeliverTx` phases. Technically, they are optional, but in practice, they are very often present to perform signature verification, gas calculation, fee deduction and other core operations related to blockchain transactions. -A copy of the cached context is provided to the `AnteHandler`, which performs limited checks specified for the transaction type. Using a copy allows the AnteHandler to do stateful checks for `Tx` without modifying the last committed state, and revert back to the original if the execution fails. +A copy of the cached context is provided to the middleware, which performs limited checks specified for the transaction type. Using a copy allows the Middleware to do stateful checks for `Tx` without modifying the last committed state, and revert back to the original if the execution fails. -For example, the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/master/x/auth/spec) module `AnteHandler` checks and increments sequence numbers, checks signatures and account numbers, and deducts fees from the first signer of the transaction - all state changes are made using the `checkState`. +For example, the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth/spec) middlewares can check and increment sequence numbers, check signatures and account numbers, and deduct fees from the first signer of the transaction - all state changes are made using the `checkState`. ### Gas @@ -117,7 +117,7 @@ nodes and add it to the Mempool so that the `Tx` becomes a candidate to be inclu The **mempool** serves the purpose of keeping track of transactions seen by all full-nodes. Full-nodes keep a **mempool cache** of the last `mempool.cache_size` transactions they have seen, as a first line of defense to prevent replay attacks. Ideally, `mempool.cache_size` is large enough to encompass all -of the transactions in the full mempool. If the the mempool cache is too small to keep track of all +of the transactions in the full mempool. If the mempool cache is too small to keep track of all the transactions, `CheckTx` is responsible for identifying and rejecting replayed transactions. Currently existing preventative measures include fees and a `sequence` (nonce) counter to distinguish @@ -137,7 +137,7 @@ Consensus, the process through which validator nodes come to agreement on which accept, happens in **rounds**. Each round begins with a proposer creating a block of the most recent transactions and ends with **validators**, special full-nodes with voting power responsible for consensus, agreeing to accept the block or go with a `nil` block instead. Validator nodes -execute the consensus algorithm, such as [Tendermint BFT](https://tendermint.com/docs/spec/consensus/consensus.html#terms), +execute the consensus algorithm, such as [Tendermint BFT](https://docs.tendermint.com/master/spec/consensus/consensus.html#terms), confirming the transactions using ABCI requests to the application, in order to come to this agreement. The first step of consensus is the **block proposal**. One proposer amongst the validators is chosen @@ -201,19 +201,19 @@ Instead of using their `checkState`, full-nodes use `deliverState`: * **Decoding:** Since `DeliverTx` is an ABCI call, `Tx` is received in the encoded `[]byte` form. Nodes first unmarshal the transaction, using the [`TxConfig`](./app-anatomy#register-codec) defined in the app, then call `runTx` in `runTxModeDeliver`, which is very similar to `CheckTx` but also executes and writes state changes. -* **Checks:** Full-nodes call `validateBasicMsgs` and the `AnteHandler` again. This second check +* **Checks:** Full-nodes call `validateBasicMsgs` and the `DeliverTx` from the middleware again. This second check happens because they may not have seen the same transactions during the addition to Mempool stage\ and a malicious proposer may have included invalid ones. One difference here is that the - `AnteHandler` will not compare `gas-prices` to the node's `min-gas-prices` since that value is local + middleware will not compare `gas-prices` to the node's `min-gas-prices` since that value is local to each node - differing values across nodes would yield nondeterministic results. -* **`MsgServiceRouter`:** While `CheckTx` would have exited, `DeliverTx` continues to run - [`runMsgs`](../core/baseapp.md#runtx-and-runmsgs) to fully execute each `Msg` within the transaction. +* **`RunMsgsTxHandler`:** While `CheckTx` would have exited, `DeliverTx` continues to run + [`RunMsgsTxHandler`](../core/baseapp.md#middlewares) to fully execute each `Msg` within the transaction. Since the transaction may have messages from different modules, `BaseApp` needs to know which module - to find the appropriate handler. This is achieved using `BaseApp`'s `MsgServiceRouter` so that it can be processed by the module's Protobuf [`Msg` service](../building-modules/msg-services.md). + to find the appropriate handler. This is achieved using `RunMsgsTxHandler`'s `MsgServiceRouter` so that it can be processed by the module's Protobuf [`Msg` service](../building-modules/msg-services.md). For `LegacyMsg` routing, the `Route` function is called via the [module manager](../building-modules/module-manager.md) to retrieve the route name and find the legacy [`Handler`](../building-modules/msg-services.md#handler-type) within the module. -* **`Msg` service:** a Protobuf `Msg` service, a step up from `AnteHandler`, is responsible for executing each +* **`Msg` service:** a Protobuf `Msg` service is responsible for executing each message in the `Tx` and causes state transitions to persist in `deliverTxState`. * **Gas:** While a `Tx` is being delivered, a `GasMeter` is used to keep track of how much diff --git a/docs/building-modules/README.md b/docs/building-modules/README.md index 411c3e8d38d8..8dd53c945954 100644 --- a/docs/building-modules/README.md +++ b/docs/building-modules/README.md @@ -1,7 +1,7 @@ # Building Modules diff --git a/docs/building-modules/beginblock-endblock.md b/docs/building-modules/beginblock-endblock.md index 2aab17db62f3..2eff43ba0ee1 100644 --- a/docs/building-modules/beginblock-endblock.md +++ b/docs/building-modules/beginblock-endblock.md @@ -22,7 +22,7 @@ The actual implementation of `BeginBlocker` and `EndBlocker` in `abci.go` are ve * If needed, they use the `keeper` and `ctx` to trigger state-transitions. * If needed, they can emit [`events`](../core/events.md) via the `ctx`'s `EventManager`. -A specificity of the `EndBlocker` is that it can return validator updates to the underlying consensus engine in the form of an [`[]abci.ValidatorUpdates`](https://tendermint.com/docs/app-dev/abci-spec.html#validatorupdate). This is the preferred way to implement custom validator changes. +A specificity of the `EndBlocker` is that it can return validator updates to the underlying consensus engine in the form of an [`[]abci.ValidatorUpdates`](https://docs.tendermint.com/master/spec/abci/abci.html#validatorupdate). This is the preferred way to implement custom validator changes. It is possible for developers to define the order of execution between the `BeginBlocker`/`EndBlocker` functions of each of their application's modules via the module's manager `SetOrderBeginBlocker`/`SetOrderEndBlocker` methods. For more on the module manager, click [here](./module-manager.md#manager). diff --git a/docs/building-modules/keeper.md b/docs/building-modules/keeper.md index 515dc35318fc..d00bf76b5d63 100644 --- a/docs/building-modules/keeper.md +++ b/docs/building-modules/keeper.md @@ -12,9 +12,9 @@ order: 7 ## Motivation -The Cosmos SDK is a framework that makes it easy for developers to build complex decentralised applications from scratch, mainly by composing modules together. As the ecosystem of open source modules for the Cosmos SDK expands, it will become increasingly likely that some of these modules contain vulnerabilities, as a result of the negligence or malice of their developer. +The Cosmos SDK is a framework that makes it easy for developers to build complex decentralized applications from scratch, mainly by composing modules together. As the ecosystem of open-source modules for the Cosmos SDK expands, it will become increasingly likely that some of these modules contain vulnerabilities, as a result of the negligence or malice of their developer. -The Cosmos SDK adopts an [object-capabilities-based approach](../core/ocap.md) to help developers better protect their application from unwanted inter-module interactions, and `keeper`s are at the core of this approach. A `keeper` can be thought of quite literally as the gatekeeper of a module's store(s). Each store (typically an [`IAVL` Store](../core/store.md#iavl-store)) defined within a module comes with a `storeKey`, which grants unlimited access to it. The module's `keeper` holds this `storeKey` (which should otherwise remain unexposed), and defines [methods](#implementing-methods) for reading and writing to the store(s). +The Cosmos SDK adopts an [object-capabilities-based approach](../core/ocap.md) to help developers better protect their application from unwanted inter-module interactions, and `keeper`s are at the core of this approach. A `keeper` can be considered quite literally to be the gatekeeper of a module's store(s). Each store (typically an [`IAVL` Store](../core/store.md#iavl-store)) defined within a module comes with a `storeKey`, which grants unlimited access to it. The module's `keeper` holds this `storeKey` (which should otherwise remain unexposed), and defines [methods](#implementing-methods) for reading and writing to the store(s). The core idea behind the object-capabilities approach is to only reveal what is necessary to get the work done. In practice, this means that instead of handling permissions of modules through access-control lists, module `keeper`s are passed a reference to the specific instance of the other modules' `keeper`s that they need to access (this is done in the [application's constructor function](../basics/app-anatomy.md#constructor-function)). As a consequence, a module can only interact with the subset of state defined in another module via the methods exposed by the instance of the other module's `keeper`. This is a great way for developers to control the interactions that their own module can have with modules developed by external developers. @@ -56,7 +56,7 @@ func (k Keeper) Get(ctx sdk.Context, key string) returnType and the method will go through the following steps: -1. Retrieve the appropriate store from the `ctx` using the `storeKey`. This is done through the `KVStore(storeKey sdk.StoreKey)` method of the `ctx`. Then it's prefered to use the `prefix.Store` to access only the desired limited subset of the store for convenience and safety. +1. Retrieve the appropriate store from the `ctx` using the `storeKey`. This is done through the `KVStore(storeKey sdk.StoreKey)` method of the `ctx`. Then it's preferred to use the `prefix.Store` to access only the desired limited subset of the store for convenience and safety. 2. If it exists, get the `[]byte` value stored at location `[]byte(key)` using the `Get(key []byte)` method of the store. 3. Unmarshall the retrieved value from `[]byte` to `returnType` using the codec `cdc`. Return the value. diff --git a/docs/building-modules/messages-and-queries.md b/docs/building-modules/messages-and-queries.md index 103d17e941e6..11e92fe30738 100644 --- a/docs/building-modules/messages-and-queries.md +++ b/docs/building-modules/messages-and-queries.md @@ -54,7 +54,7 @@ A `LegacyMsg` is typically accompanied by a standard constructor function, that It extends `proto.Message` and contains the following methods: * `Route() string`: Name of the route for this message. Typically all `message`s in a module have the same route, which is most often the module's name. -* `Type() string`: Type of the message, used primarly in [events](../core/events.md). This should return a message-specific `string`, typically the denomination of the message itself. +* `Type() string`: Type of the message, used primarily in [events](../core/events.md). This should return a message-specific `string`, typically the denomination of the message itself. * [`ValidateBasic() error`](../basics/tx-lifecycle.md#ValidateBasic). * `GetSignBytes() []byte`: Return the canonical byte representation of the message. Used to generate a signature. * `GetSigners() []AccAddress`: Return the list of signers. The Cosmos SDK will make sure that each `message` contained in a transaction is signed by all the signers listed in the list returned by this method. @@ -69,7 +69,7 @@ A `query` is a request for information made by end-users of applications through ### gRPC Queries -Starting from v0.40, the prefered way to define queries is by using [Protobuf services](https://developers.google.com/protocol-buffers/docs/proto#services). A `Query` service should be created per module in `query.proto`. This service lists endpoints starting with `rpc`. +Starting from v0.40, the preferred way to define queries is by using [Protobuf services](https://developers.google.com/protocol-buffers/docs/proto#services). A `Query` service should be created per module in `query.proto`. This service lists endpoints starting with `rpc`. Here's an example of such a `Query` service definition: @@ -81,7 +81,7 @@ A `RegisterQueryServer` method is also generated and should be used to register ### Legacy Queries -Before the introduction of Protobuf and gRPC in the Cosmos SDK, there was usually no specific `query` object defined by module developers, contrary to `message`s. Instead, the Cosmos SDK took the simpler approach of using a simple `path` to define each `query`. The `path` contains the `query` type and all the arguments needed in order to process it. For most module queries, the `path` should look like the following: +Before the introduction of Protobuf and gRPC in the Cosmos SDK, there was usually no specific `query` object defined by module developers, contrary to `message`s. Instead, the Cosmos SDK took the simpler approach of using a simple `path` to define each `query`. The `path` contains the `query` type and all the arguments needed to process it. For most module queries, the `path` should look like the following: ```text queryCategory/queryRoute/queryType/arg1/arg2/... diff --git a/docs/building-modules/module-manager.md b/docs/building-modules/module-manager.md index 1facca88deb4..b3e4094e711a 100644 --- a/docs/building-modules/module-manager.md +++ b/docs/building-modules/module-manager.md @@ -38,7 +38,6 @@ Let us go through the methods: * `RegisterInterfaces(codectypes.InterfaceRegistry)`: Registers a module's interface types and their concrete implementations as `proto.Message`. * `DefaultGenesis(codec.JSONCodec)`: Returns a default [`GenesisState`](./genesis.md#genesisstate) for the module, marshalled to `json.RawMessage`. The default `GenesisState` need to be defined by the module developer and is primarily used for testing. * `ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage)`: Used to validate the `GenesisState` defined by a module, given in its `json.RawMessage` form. It will usually unmarshall the `json` before running a custom [`ValidateGenesis`](./genesis.md#validategenesis) function defined by the module developer. -* `RegisterRESTRoutes(client.Context, *mux.Router)`: Registers the REST routes for the module. These routes will be used to map REST request to the module in order to process them. See [gRPC and REST](../core/grpc_rest.md) for more. * `RegisterGRPCGatewayRoutes(client.Context, *runtime.ServeMux)`: Registers gRPC routes for the module. * `GetTxCmd()`: Returns the root [`Tx` command](./module-interfaces.md#tx) for the module. The subcommands of this root command are used by end-users to generate new transactions containing [`message`s](./messages-and-queries.md#queries) defined in the module. * `GetQueryCmd()`: Return the root [`query` command](./module-interfaces.md#query) for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module. @@ -110,12 +109,11 @@ The `BasicManager` is a structure that lists all the `AppModuleBasic` of an appl It implements the following methods: -* `NewBasicManager(modules ...AppModuleBasic)`: Constructor function. It takes a list of the application's `AppModuleBasic` and builds a new `BasicManager`. This function is generally called in the `init()` function of [`app.go`](../basics/app-anatomy.md#core-application-file) to quickly initialize the independent elements of the application's modules (click [here](https://github.com/cosmos/gaia/blob/master/app/app.go#L59-L74) to see an example). +* `NewBasicManager(modules ...AppModuleBasic)`: Constructor function. It takes a list of the application's `AppModuleBasic` and builds a new `BasicManager`. This function is generally called in the `init()` function of [`app.go`](../basics/app-anatomy.md#core-application-file) to quickly initialize the independent elements of the application's modules (click [here](https://github.com/cosmos/gaia/blob/main/app/app.go#L59-L74) to see an example). * `RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)`: Registers the [`codec.LegacyAmino`s](../core/encoding.md#amino) of each of the application's `AppModuleBasic`. This function is usually called early on in the [application's construction](../basics/app-anatomy.md#constructor). * `RegisterInterfaces(registry codectypes.InterfaceRegistry)`: Registers interface types and implementations of each of the application's `AppModuleBasic`. * `DefaultGenesis(cdc codec.JSONCodec)`: Provides default genesis information for modules in the application by calling the [`DefaultGenesis(cdc codec.JSONCodec)`](./genesis.md#defaultgenesis) function of each module. It is used to construct a default genesis file for the application. * `ValidateGenesis(cdc codec.JSONCodec, txEncCfg client.TxEncodingConfig, genesis map[string]json.RawMessage)`: Validates the genesis information modules by calling the [`ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage)`](./genesis.md#validategenesis) function of each module. -* `RegisterRESTRoutes(ctx client.Context, rtr *mux.Router)`: Registers REST routes for modules by calling the [`RegisterRESTRoutes`](./module-interfaces.md#register-routes) function of each module. This function is usually called function from the `main.go` function of the [application's command-line interface](../core/cli.md). * `RegisterGRPCGatewayRoutes(clientCtx client.Context, rtr *runtime.ServeMux)`: Registers gRPC routes for modules. * `AddTxCommands(rootTxCmd *cobra.Command)`: Adds modules' transaction commands to the application's [`rootTxCommand`](../core/cli.md#transaction-commands). This function is usually called function from the `main.go` function of the [application's command-line interface](../core/cli.md). * `AddQueryCommands(rootQueryCmd *cobra.Command)`: Adds modules' query commands to the application's [`rootQueryCommand`](../core/cli.md#query-commands). This function is usually called function from the `main.go` function of the [application's command-line interface](../core/cli.md). diff --git a/docs/building-modules/msg-services.md b/docs/building-modules/msg-services.md index cb52425ff8fc..82f4e44e6783 100644 --- a/docs/building-modules/msg-services.md +++ b/docs/building-modules/msg-services.md @@ -23,11 +23,11 @@ Protobuf generates a `MsgServer` interface based on a definition of `Msg` servic When possible, the existing module's [`Keeper`](keeper.md) should implement `MsgServer`, otherwise a `msgServer` struct that embeds the `Keeper` can be created, typically in `./keeper/msg_server.go`: -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc1/x/bank/keeper/msg_server.go#L14-L16 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/x/bank/keeper/msg_server.go#L14:L16 `msgServer` methods can retrieve the `sdk.Context` from the `context.Context` parameter method using the `sdk.UnwrapSDKContext`: -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc1/x/bank/keeper/msg_server.go#L27-L28 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/x/bank/keeper/msg_server.go#L27-L28 `sdk.Msg` processing usually follows these 3 steps: diff --git a/docs/building-modules/query-services.md b/docs/building-modules/query-services.md index bb994f08e435..beae1013ca02 100644 --- a/docs/building-modules/query-services.md +++ b/docs/building-modules/query-services.md @@ -68,7 +68,7 @@ func NewQuerier(keeper Keeper) sdk.Querier { This simple switch returns a `querier` function specific to the type of the received `query`. At this point of the [query lifecycle](../basics/query-lifecycle.md), the first element of the `path` (`path[0]`) contains the type of the query. The following elements are either empty or contain arguments needed to process the query. -The `querier` functions themselves are pretty straighforward. They generally fetch a value or values from the state using the [`keeper`](./keeper.md). Then, they marshall the value(s) using the [`codec`](../core/encoding.md) and return the `[]byte` obtained as result. +The `querier` functions themselves are pretty straightforward. They generally fetch a value or values from the state using the [`keeper`](./keeper.md). Then, they marshall the value(s) using the [`codec`](../core/encoding.md) and return the `[]byte` obtained as result. For a deeper look at `querier`s, see this [example implementation of a `querier` function](https://github.com/cosmos/cosmos-sdk/blob/7f59723d889b69ca19966167f0b3a7fec7a39e53/x/gov/keeper/querier.go) from the bank module. diff --git a/docs/building-modules/simulator.md b/docs/building-modules/simulator.md index ab5801160dbb..c9db04a710af 100644 --- a/docs/building-modules/simulator.md +++ b/docs/building-modules/simulator.md @@ -68,7 +68,7 @@ As you can see, the weights are predefined in this case. Options exist to overri Here is how one can override the above package `simappparams`. -+++ https://github.com/cosmos/gaia/blob/master/sims.mk#L9-L22 ++++ https://github.com/cosmos/gaia/blob/main/sims.mk#L9-L22 For the last test a tool called runsim is used, this is used to parallelize go test instances, provide info to Github and slack integrations to provide information to your team on how the simulations are running. diff --git a/docs/core/README.md b/docs/core/README.md index a6853b41802a..ef83bfbbc0fb 100644 --- a/docs/core/README.md +++ b/docs/core/README.md @@ -11,15 +11,15 @@ This repository contains reference documentation on the core concepts of the Cos 1. [`BaseApp`](./baseapp.md) 2. [Transaction](./transactions.md) 3. [Context](./context.md) -4. [Node Client](./node.md) -5. [Store](./store.md) -6. [Encoding](./encoding.md) -7. [gRPC, REST and Tendermint Endpoints](./grpc_rest.md) -8. [Command-Line Interface](./cli.md) -9. [Events](./events.md) -10. [Telemetry](./telemetry.md) -11. [Object-Capabilities](./ocap.md) -12. [RunTx recovery middleware](./runtx_middleware.md) +4. [CheckTx and DeliverTx middlewares](./middleware.md) +5. [Node Client](./node.md) +6. [Store](./store.md) +7. [Encoding](./encoding.md) +8. [gRPC, REST and Tendermint Endpoints](./grpc_rest.md) +9. [Command-Line Interface](./cli.md) +10. [Events](./events.md) +11. [Telemetry](./telemetry.md) +12. [Object-Capabilities](./ocap.md) 13. [Simulation](./simulation.md) 14. [Protobuf documentation](./proto-docs.md) 15. [In-Place Store Migrations](./upgrade.md) diff --git a/docs/core/baseapp.md b/docs/core/baseapp.md index 7d2850b71f99..6b1c47c37dce 100644 --- a/docs/core/baseapp.md +++ b/docs/core/baseapp.md @@ -15,9 +15,9 @@ This document describes `BaseApp`, the abstraction that implements the core func `BaseApp` is a base type that implements the core of a Cosmos SDK application, namely: -* The [Application Blockchain Interface](#abci), for the state-machine to communicate with the underlying consensus engine (e.g. Tendermint). +* The [Application Blockchain Interface](#main-abci-messages), for the state-machine to communicate with the underlying consensus engine (e.g. Tendermint). * [Service Routers](#service-routers), to route messages and queries to the appropriate module. -* Different [states](#states), as the state-machine can have different volatile states updated based on the ABCI message received. +* Different [states](#state-updates), as the state-machine can have different volatile states updated based on the ABCI message received. The goal of `BaseApp` is to provide the fundamental layer of a Cosmos SDK application that developers can easily extend to build their own custom application. Usually, @@ -45,7 +45,7 @@ management logic. The `BaseApp` type holds many important parameters for any Cosmos SDK based application. -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/baseapp/baseapp.go#L46-L131 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/baseapp/baseapp.go#L44-L131 Let us go through the most important components. @@ -60,31 +60,27 @@ First, the important parameters that are initialized during the bootstrapping of The `CommitMultiStore` is a multi-store, meaning a store of stores. Each module of the application uses one or multiple `KVStores` in the multi-store to persist their subset of the state. * Database: The `db` is used by the `CommitMultiStore` to handle data persistence. -* [`Msg` Service Router](#msg-service-router): The `msgServiceRouter` facilitates the routing of `sdk.Msg` requests to the appropriate - module `Msg` service for processing. Here a `sdk.Msg` refers to the transaction component that needs to be - processed by a service in order to update the application state, and not to ABCI message which implements - the interface between the application and the underlying consensus engine. * [gRPC Query Router](#grpc-query-router): The `grpcQueryRouter` facilitates the routing of gRPC queries to the appropriate module for it to be processed. These queries are not ABCI messages themselves, but they are relayed to the relevant module's gRPC `Query` service. * [`TxDecoder`](https://godoc.org/github.com/cosmos/cosmos-sdk/types#TxDecoder): It is used to decode raw transaction bytes relayed by the underlying Tendermint engine. * [`ParamStore`](#paramstore): The parameter store used to get and set application consensus parameters. -* [`AnteHandler`](#antehandler): This handler is used to handle signature verification, fee payment, - and other pre-message execution checks when a transaction is received. It's executed during +* [`TxHandler`](#middlewares): This handler is used to set middlewares. Middlewares can, for instace, handle signature verification, + fee payment, and other pre-message execution checks when a transaction is received. It's executed during [`CheckTx/RecheckTx`](#checktx) and [`DeliverTx`](#delivertx). * [`InitChainer`](../basics/app-anatomy.md#initchainer), [`BeginBlocker` and `EndBlocker`](../basics/app-anatomy.md#beginblocker-and-endblocker): These are the functions executed when the application receives the `InitChain`, `BeginBlock` and `EndBlock` ABCI messages from the underlying Tendermint engine. -Then, parameters used to define [volatile states](#volatile-states) (i.e. cached states): +Then, parameters used to define [volatile states](#state-updates) (i.e. cached states): * `checkState`: This state is updated during [`CheckTx`](#checktx), and reset on [`Commit`](#commit). * `deliverState`: This state is updated during [`DeliverTx`](#delivertx), and set to `nil` on [`Commit`](#commit) and gets re-initialized on BeginBlock. -Finally, a few more important parameterd: +Finally, a few more important parameters: * `voteInfos`: This parameter carries the list of validators whose precommit is missing, either because they did not vote or because the proposer did not include their vote. This information is @@ -92,8 +88,8 @@ Finally, a few more important parameterd: punishing absent validators. * `minGasPrices`: This parameter defines the minimum gas prices accepted by the node. This is a **local** parameter, meaning each full-node can set a different `minGasPrices`. It is used in the - `AnteHandler` during [`CheckTx`](#checktx), mainly as a spam protection mechanism. The transaction - enters the [mempool](https://tendermint.com/docs/tendermint-core/mempool.html#transaction-ordering) + `TxHandler` during [`CheckTx`](#checktx), mainly as a spam protection mechanism. The transaction + enters the [mempool](https://docs.tendermint.com/master/tendermint-core/mempool/) only if the gas prices of the transaction are greater than one of the minimum gas price in `minGasPrices` (e.g. if `minGasPrices == 1uatom,1photon`, the `gas-price` of the transaction must be greater than `1uatom` OR `1photon`). @@ -142,9 +138,8 @@ To avoid unnecessary roundtrip to the main state, all reads to the branched stor ### CheckTx State Updates During `CheckTx`, the `checkState`, which is based off of the last committed state from the root -store, is used for any reads and writes. Here we only execute the `AnteHandler` and verify a service router -exists for every message in the transaction. Note, when we execute the `AnteHandler`, we branch -the already branched `checkState`. This has the side effect that if the `AnteHandler` fails, +store, is used for any reads and writes. Here we only execute the wired middlewares `CheckTx` and verify a service router +exists for every message in the transaction. Note, that if a middleware's `CheckTx` fails, the state transitions won't be reflected in the `checkState` -- i.e. `checkState` is only updated on success. @@ -164,7 +159,7 @@ The state flow for `DeliverTx` is nearly identical to `CheckTx` except state tra the `deliverState` and messages in a transaction are executed. Similarly to `CheckTx`, state transitions occur on a doubly branched state -- `deliverState`. Successful message execution results in writes being committed to `deliverState`. Note, if message execution fails, state transitions from -the AnteHandler are persisted. +the middlewares are persisted. ![DeliverTx](./baseapp_state-deliver_tx.png) @@ -187,25 +182,17 @@ on-chain governance. ## Service Routers -When messages and queries are received by the application, they must be routed to the appropriate module in order to be processed. Routing is done via `BaseApp`, which holds a `msgServiceRouter` for messages, and a `grpcQueryRouter` for queries. - -### `Msg` Service Router - -[`sdk.Msg`s](#../building-modules/messages-and-queries.md#messages) need to be routed after they are extracted from transactions, which are sent from the underlying Tendermint engine via the [`CheckTx`](#checktx) and [`DeliverTx`](#delivertx) ABCI messages. To do so, `BaseApp` holds a `msgServiceRouter` which maps fully-qualified service methods (`string`, defined in each module's Protobuf `Msg` service) to the appropriate module's `MsgServer` implementation. - -The [default `msgServiceRouter` included in `BaseApp`](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/baseapp/msg_service_router.go) is stateless. However, some applications may want to make use of more stateful routing mechanisms such as allowing governance to disable certain routes or point them to new modules for upgrade purposes. For this reason, the `sdk.Context` is also passed into each [route handler inside `msgServiceRouter`](https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/baseapp/msg_service_router.go#L31-L32). For a stateless router that doesn't want to make use of this, you can just ignore the `ctx`. - -The application's `msgServiceRouter` is initialized with all the routes using the application's [module manager](../building-modules/module-manager.md#manager) (via the `RegisterServices` method), which itself is initialized with all the application's modules in the application's [constructor](../basics/app-anatomy.md#app-constructor). +When messages and queries are received by the application, they must be routed to the appropriate module in order to be processed. Routing is done via `BaseApp`, with `queryRouter` for queries and `grpcQueryRouter` for gRPC queries. ### gRPC Query Router -Similar to `sdk.Msg`s, [`queries`](../building-modules/messages-and-queries.md#queries) need to be routed to the appropriate module's [`Query` service](../building-modules/query-services.md). To do so, `BaseApp` holds a `grpcQueryRouter`, which maps modules' fully-qualified service methods (`string`, defined in their Protobuf `Query` gRPC) to their `QueryServer` implementation. The `grpcQueryRouter` is called during the initial stages of query processing, which can be either by directly sending a gRPC query to the gRPC endpoint, or via the [`Query` ABCI message](#query) on the Tendermint RPC endpoint. +[`Queries`](../building-modules/messages-and-queries.md#queries) need to be routed to the appropriate module's [`Query` service](../building-modules/query-services.md). To do so, `BaseApp` holds a `grpcQueryRouter`, which maps modules' fully-qualified service methods (`string`, defined in their Protobuf `Query` gRPC) to their `QueryServer` implementation. The `grpcQueryRouter` is called during the initial stages of query processing, which can be either by directly sending a gRPC query to the gRPC endpoint, or via the [`Query` ABCI message](#query) on the Tendermint RPC endpoint. -Just like the `msgServiceRouter`, the `grpcQueryRouter` is initialized with all the query routes using the application's [module manager](../building-modules/module-manager.md) (via the `RegisterServices` method), which itself is initialized with all the application's modules in the application's [constructor](../basics/app-anatomy.md#app-constructor). +The `grpcQueryRouter` is initialized with all the query routes using the application's [module manager](../building-modules/module-manager.md) (via the `RegisterServices` method), which itself is initialized with all the application's modules in the application's [constructor](../basics/app-anatomy.md#app-constructor). ## Main ABCI Messages -The [Application-Blockchain Interface](https://tendermint.com/docs/spec/abci/) (ABCI) is a generic interface that connects a state-machine with a consensus engine to form a functional full-node. It can be wrapped in any language, and needs to be implemented by each application-specific blockchain built on top of an ABCI-compatible consensus engine like Tendermint. +The [Application-Blockchain Interface](https://docs.tendermint.com/master/spec/abci/) (ABCI) is a generic interface that connects a state-machine with a consensus engine to form a functional full-node. It can be wrapped in any language, and needs to be implemented by each application-specific blockchain built on top of an ABCI-compatible consensus engine like Tendermint. The consensus engine handles two main tasks: @@ -236,25 +223,24 @@ to do the following checks: 3. Perform non-module related _stateful_ checks on the [account](../basics/accounts.md). This step is mainly about checking that the `sdk.Msg` signatures are valid, that enough fees are provided and that the sending account has enough funds to pay for said fees. Note that no precise [`gas`](../basics/gas-fees.md) counting occurs here, - as `sdk.Msg`s are not processed. Usually, the [`AnteHandler`](../basics/gas-fees.md#antehandler) will check that the `gas` provided + as `sdk.Msg`s are not processed. Usually, the [`middleware`](../basics/gas-fees.md#middleware) will check that the `gas` provided with the transaction is superior to a minimum reference gas amount based on the raw transaction size, in order to avoid spam with transactions that provide 0 gas. `CheckTx` does **not** process `sdk.Msg`s - they only need to be processed when the canonical state need to be updated, which happens during `DeliverTx`. -Steps 2. and 3. are performed by the [`AnteHandler`](../basics/gas-fees.md#antehandler) in the [`RunTx()`](#runtx-antehandler-and-runmsgs) -function, which `CheckTx()` calls with the `runTxModeCheck` mode. During each step of `CheckTx()`, a -special [volatile state](#volatile-states) called `checkState` is updated. This state is used to keep -track of the temporary changes triggered by the `CheckTx()` calls of each transaction without modifying -the [main canonical state](#main-state) . For example, when a transaction goes through `CheckTx()`, the -transaction's fees are deducted from the sender's account in `checkState`. If a second transaction is +Steps 2. and 3. are performed by the [`middlewares`](../basics/gas-fees.md#middleware)' `CheckTx()`. +During each step of `CheckTx()`, a special [volatile state](#state-updates) called `checkState` is updated. +This state is used to keep track of the temporary changes triggered by the `CheckTx()` calls of each transaction +without modifying the [main canonical state](#main-state) . For example, when a transaction goes through `CheckTx()`, +the transaction's fees are deducted from the sender's account in `checkState`. If a second transaction is received from the same account before the first is processed, and the account has consumed all its funds in `checkState` during the first transaction, the second transaction will fail `CheckTx`() and be rejected. In any case, the sender's account will not actually pay the fees until the transaction is actually included in a block, because `checkState` never gets committed to the main state. The `checkState` is reset to the latest state of the main state each time a blocks gets [committed](#commit). -`CheckTx` returns a response to the underlying consensus engine of type [`abci.ResponseCheckTx`](https://tendermint.com/docs/spec/abci/abci.html#messages). +`CheckTx` returns a response to the underlying consensus engine of type [`abci.ResponseCheckTx`](https://docs.tendermint.com/master/spec/abci/abci.html#checktx-2). The response contains: * `Code (uint32)`: Response Code. `0` if successful. @@ -280,20 +266,20 @@ This allows certain checks like signature verification can be skipped during `Ch When the underlying consensus engine receives a block proposal, each transaction in the block needs to be processed by the application. To that end, the underlying consensus engine sends a `DeliverTx` message to the application for each transaction in a sequential order. -Before the first transaction of a given block is processed, a [volatile state](#volatile-states) called `deliverState` is intialized during [`BeginBlock`](#beginblock). This state is updated each time a transaction is processed via `DeliverTx`, and committed to the [main state](#main-state) when the block is [committed](#commit), after what is is set to `nil`. +Before the first transaction of a given block is processed, a [volatile state](#state-updates) called `deliverState` is initialized during [`BeginBlock`](#beginblock). This state is updated each time a transaction is processed via `DeliverTx`, and committed to the [main state](#main-state) when the block is [committed](#commit), after what it is set to `nil`. `DeliverTx` performs the **exact same steps as `CheckTx`**, with a little caveat at step 3 and the addition of a fifth step: -1. The `AnteHandler` does **not** check that the transaction's `gas-prices` is sufficient. That is because the `min-gas-prices` value `gas-prices` is checked against is local to the node, and therefore what is enough for one full-node might not be for another. This means that the proposer can potentially include transactions for free, although they are not incentivised to do so, as they earn a bonus on the total fee of the block they propose. +1. The `GasTxMiddleware` does **not** check that the transaction's `gas-prices` is sufficient. That is because the `min-gas-prices` value `gas-prices` is checked against is local to the node, and therefore what is enough for one full-node might not be for another. This means that the proposer can potentially include transactions for free, although they are not incentivised to do so, as they earn a bonus on the total fee of the block they propose. 2. For each `sdk.Msg` in the transaction, route to the appropriate module's Protobuf [`Msg` service](../building-modules/msg-services.md). Additional _stateful_ checks are performed, and the branched multistore held in `deliverState`'s `context` is updated by the module's `keeper`. If the `Msg` service returns successfully, the branched multistore held in `context` is written to `deliverState` `CacheMultiStore`. During the additional fifth step outlined in (2), each read/write to the store increases the value of `GasConsumed`. You can find the default cost of each operation: -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/store/types/gas.go#L164-L175 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/store/types/gas.go#L230-L241 At any point, if `GasConsumed > GasWanted`, the function returns with `Code != 0` and `DeliverTx` fails. -`DeliverTx` returns a response to the underlying consensus engine of type [`abci.ResponseDeliverTx`](https://tendermint.com/docs/spec/abci/abci.html#delivertx). The response contains: +`DeliverTx` returns a response to the underlying consensus engine of type [`abci.ResponseDeliverTx`](https://docs.tendermint.com/master/spec/abci/abci.html#delivertx-2). The response contains: * `Code (uint32)`: Response Code. `0` if successful. * `Data ([]byte)`: Result bytes, if any. @@ -304,90 +290,77 @@ At any point, if `GasConsumed > GasWanted`, the function returns with `Code != 0 * `Events ([]cmn.KVPair)`: Key-Value tags for filtering and indexing transactions (eg. by account). See [`event`s](./events.md) for more. * `Codespace (string)`: Namespace for the Code. -## RunTx, AnteHandler and RunMsgs - -### RunTx - -`RunTx` is called from `CheckTx`/`DeliverTx` to handle the transaction, with `runTxModeCheck` or `runTxModeDeliver` as parameter to differentiate between the two modes of execution. Note that when `RunTx` receives a transaction, it has already been decoded. - -The first thing `RunTx` does upon being called is to retrieve the `context`'s `CacheMultiStore` by calling the `getContextForTx()` function with the appropriate mode (either `runTxModeCheck` or `runTxModeDeliver`). This `CacheMultiStore` is a branch of the main store, with cache functionality (for query requests), instantiated during `BeginBlock` for `DeliverTx` and during the `Commit` of the previous block for `CheckTx`. After that, two `defer func()` are called for [`gas`](../basics/gas-fees.md) management. They are executed when `runTx` returns and make sure `gas` is actually consumed, and will throw errors, if any. - -After that, `RunTx()` calls `ValidateBasic()` on each `sdk.Msg`in the `Tx`, which runs preliminary _stateless_ validity checks. If any `sdk.Msg` fails to pass `ValidateBasic()`, `RunTx()` returns with an error. +## Middlewares -Then, the [`anteHandler`](#antehandler) of the application is run (if it exists). In preparation of this step, both the `checkState`/`deliverState`'s `context` and `context`'s `CacheMultiStore` are branched using the `cacheTxContext()` function. +Middlewares implement the `tx.Handler` interface. They are called within BaseApp `CheckTx` and `DeliverTx`, allowing to run custom logic before or after the transaction is processed. They are primarily used to authenticate the transaction before the transaction's internal messages are processed, but also to perform additional checks on the transaction itself. -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/baseapp/baseapp.go#L623-L630 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/types/tx/middleware.go#L62:L68 -This allows `RunTx` not to commit the changes made to the state during the execution of `anteHandler` if it ends up failing. It also prevents the module implementing the `anteHandler` from writing to state, which is an important part of the [object-capabilities](./ocap.md) of the Cosmos SDK. - -Finally, the [`RunMsgs()`](#runmsgs) function is called to process the `sdk.Msg`s in the `Tx`. In preparation of this step, just like with the `anteHandler`, both the `checkState`/`deliverState`'s `context` and `context`'s `CacheMultiStore` are branched using the `cacheTxContext()` function. - -### AnteHandler - -The `AnteHandler` is a special handler that implements the `AnteHandler` interface and is used to authenticate the transaction before the transaction's internal messages are processed. - -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/types/handler.go#L6-L8 - -The `AnteHandler` is theoretically optional, but still a very important component of public blockchain networks. It serves 3 primary purposes: +Middlewares are theoretically optional, but still a very important component of public blockchain networks. They have 3 primary purposes: * Be a primary line of defense against spam and second line of defense (the first one being the mempool) against transaction replay with fees deduction and [`sequence`](./transactions.md#transaction-generation) checking. * Perform preliminary _stateful_ validity checks like ensuring signatures are valid or that the sender has enough funds to pay for fees. * Play a role in the incentivisation of stakeholders via the collection of transaction fees. -`BaseApp` holds an `anteHandler` as parameter that is initialized in the [application's constructor](../basics/app-anatomy.md#application-constructor). The most widely used `anteHandler` is the [`auth` module](https://github.com/cosmos/cosmos-sdk/blob/v0.42.1/x/auth/ante/ante.go). +`BaseApp` holds a `txHandler` as parameter that is initialized in the [application's constructor](../basics/app-anatomy.md#application-constructor). The most widely used `middlewares` are the [`auth` module middlewares](https://github.com/cosmos/cosmos-sdk/blob/main/x/auth/middleware). + +`NewDefaultTxHandler` groups a number a `middlewares` that are commonly used: + ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/x/auth/middleware/middleware.go#L89:L130 -Click [here](../basics/gas-fees.md#antehandler) for more on the `anteHandler`. +Click [here](../basics/gas-fees.md#middleware) for more on these `middlewares`. -### RunMsgs +### RunMsgsTxHandler -`RunMsgs` is called from `RunTx` with `runTxModeCheck` as parameter to check the existence of a route for each message the transaction, and with `runTxModeDeliver` to actually process the `sdk.Msg`s. +`RunMsgsTxHandler` is a middleware that runs the `sdk.Msg`s in the transaction. +When being called from `DeliverTx` or `SimulateTx`, it retrieves the `sdk.Msg`'s fully-qualified type name, by checking the `type_url` of the Protobuf `Any` representing the `sdk.Msg`. Then, using its [`msgServiceRouter`](#msg-service-router), it checks for the existence of `Msg` service method related to that `type_url`. At this point the [`Msg` service](../building-modules/msg-services.md) RPC is executed, before returning. -First, it retrieves the `sdk.Msg`'s fully-qualified type name, by checking the `type_url` of the Protobuf `Any` representing the `sdk.Msg`. Then, using the application's [`msgServiceRouter`](#msg-service-router), it checks for the existence of `Msg` service method related to that `type_url`. At this point, if `mode == runTxModeCheck`, `RunMsgs` returns. Otherwise, if `mode == runTxModeDeliver`, the [`Msg` service](../building-modules/msg-services.md) RPC is executed, before `RunMsgs` returns. +Note: When its `CheckTx` method is called, the `RunMsgsTxHandler` does not do anything as messages are not run during `CheckTx`. ## Other ABCI Messages ### InitChain -The [`InitChain` ABCI message](https://tendermint.com/docs/app-dev/abci-spec.html#initchain) is sent from the underlying Tendermint engine when the chain is first started. It is mainly used to **initialize** parameters and state like: +The [`InitChain` ABCI message](https://docs.tendermint.com/master/spec/abci/abci.html#initchain) is sent from the underlying Tendermint engine when the chain is first started. It is mainly used to **initialize** parameters and state like: -* [Consensus Parameters](https://tendermint.com/docs/spec/abci/apps.html#consensus-parameters) via `setConsensusParams`. -* [`checkState` and `deliverState`](#volatile-states) via `setCheckState` and `setDeliverState`. +* [Consensus Parameters](https://docs.tendermint.com/master/spec/abci/apps.html#consensus-parameters) via `setConsensusParams`. +* [`checkState` and `deliverState`](#state-updates) via `setCheckState` and `setDeliverState`. * The [block gas meter](../basics/gas-fees.md#block-gas-meter), with infinite gas to process genesis transactions. Finally, the `InitChain(req abci.RequestInitChain)` method of `BaseApp` calls the [`initChainer()`](../basics/app-anatomy.md#initchainer) of the application in order to initialize the main state of the application from the `genesis file` and, if defined, call the [`InitGenesis`](../building-modules/genesis.md#initgenesis) function of each of the application's modules. ### BeginBlock -The [`BeginBlock` ABCI message](#https://tendermint.com/docs/app-dev/abci-spec.html#beginblock) is sent from the underlying Tendermint engine when a block proposal created by the correct proposer is received, before [`DeliverTx`](#delivertx) is run for each transaction in the block. It allows developers to have logic be executed at the beginning of each block. In the Cosmos SDK, the `BeginBlock(req abci.RequestBeginBlock)` method does the following: +The [`BeginBlock` ABCI message](https://docs.tendermint.com/master/spec/abci/abci.html#beginblock) is sent from the underlying Tendermint engine when a block proposal created by the correct proposer is received, before [`DeliverTx`](#delivertx) is run for each transaction in the block. It allows developers to have logic be executed at the beginning of each block. In the Cosmos SDK, the `BeginBlock(req abci.RequestBeginBlock)` method does the following: -* Initialize [`deliverState`](#volatile-states) with the latest header using the `req abci.RequestBeginBlock` passed as parameter via the `setDeliverState` function. +* Initialize [`deliverState`](#state-updates) with the latest header using the `req abci.RequestBeginBlock` passed as parameter via the `setDeliverState` function. +++ https://github.com/cosmos/cosmos-sdk/blob/7d7821b9af132b0f6131640195326aa02b6751db/baseapp/baseapp.go#L387-L397 This function also resets the [main gas meter](../basics/gas-fees.md#main-gas-meter). * Initialize the [block gas meter](../basics/gas-fees.md#block-gas-meter) with the `maxGas` limit. The `gas` consumed within the block cannot go above `maxGas`. This parameter is defined in the application's consensus parameters. * Run the application's [`beginBlocker()`](../basics/app-anatomy.md#beginblocker-and-endblock), which mainly runs the [`BeginBlocker()`](../building-modules/beginblock-endblock.md#beginblock) method of each of the application's modules. -* Set the [`VoteInfos`](https://tendermint.com/docs/app-dev/abci-spec.html#voteinfo) of the application, i.e. the list of validators whose _precommit_ for the previous block was included by the proposer of the current block. This information is carried into the [`Context`](./context.md) so that it can be used during `DeliverTx` and `EndBlock`. +* Set the [`VoteInfos`](https://docs.tendermint.com/master/spec/abci/abci.html#voteinfo) of the application, i.e. the list of validators whose _precommit_ for the previous block was included by the proposer of the current block. This information is carried into the [`Context`](./context.md) so that it can be used during `DeliverTx` and `EndBlock`. ### EndBlock -The [`EndBlock` ABCI message](#https://tendermint.com/docs/app-dev/abci-spec.html#endblock) is sent from the underlying Tendermint engine after [`DeliverTx`](#delivertx) as been run for each transaction in the block. It allows developers to have logic be executed at the end of each block. In the Cosmos SDK, the bulk `EndBlock(req abci.RequestEndBlock)` method is to run the application's [`EndBlocker()`](../basics/app-anatomy.md#beginblocker-and-endblock), which mainly runs the [`EndBlocker()`](../building-modules/beginblock-endblock.md#beginblock) method of each of the application's modules. +The [`EndBlock` ABCI message](https://docs.tendermint.com/master/spec/abci/abci.html#endblock) is sent from the underlying Tendermint engine after [`DeliverTx`](#delivertx) as been run for each transaction in the block. It allows developers to have logic be executed at the end of each block. In the Cosmos SDK, the bulk `EndBlock(req abci.RequestEndBlock)` method is to run the application's [`EndBlocker()`](../basics/app-anatomy.md#beginblocker-and-endblock), which mainly runs the [`EndBlocker()`](../building-modules/beginblock-endblock.md#beginblock) method of each of the application's modules. ### Commit -The [`Commit` ABCI message](https://tendermint.com/docs/app-dev/abci-spec.html#commit) is sent from the underlying Tendermint engine after the full-node has received _precommits_ from 2/3+ of validators (weighted by voting power). On the `BaseApp` end, the `Commit(res abci.ResponseCommit)` function is implemented to commit all the valid state transitions that occured during `BeginBlock`, `DeliverTx` and `EndBlock` and to reset state for the next block. +The [`Commit` ABCI message](https://docs.tendermint.com/master/spec/abci/abci.html#commit) is sent from the underlying Tendermint engine after the full-node has received _precommits_ from 2/3+ of validators (weighted by voting power). On the `BaseApp` end, the `Commit(res abci.ResponseCommit)` function is implemented to commit all the valid state transitions that occurred during `BeginBlock`, `DeliverTx` and `EndBlock` and to reset state for the next block. -To commit state-transitions, the `Commit` function calls the `Write()` function on `deliverState.ms`, where `deliverState.ms` is a branched multistore of the main store `app.cms`. Then, the `Commit` function sets `checkState` to the latest header (obtbained from `deliverState.ctx.BlockHeader`) and `deliverState` to `nil`. +To commit state-transitions, the `Commit` function calls the `Write()` function on `deliverState.ms`, where `deliverState.ms` is a branched multistore of the main store `app.cms`. Then, the `Commit` function sets `checkState` to the latest header (obtained from `deliverState.ctx.BlockHeader`) and `deliverState` to `nil`. Finally, `Commit` returns the hash of the commitment of `app.cms` back to the underlying consensus engine. This hash is used as a reference in the header of the next block. ### Info -The [`Info` ABCI message](https://tendermint.com/docs/app-dev/abci-spec.html#info) is a simple query from the underlying consensus engine, notably used to sync the latter with the application during a handshake that happens on startup. When called, the `Info(res abci.ResponseInfo)` function from `BaseApp` will return the application's name, version and the hash of the last commit of `app.cms`. +The [`Info` ABCI message](https://docs.tendermint.com/master/spec/abci/abci.html#info) is a simple query from the underlying consensus engine, notably used to sync the latter with the application during a handshake that happens on startup. When called, the `Info(res abci.ResponseInfo)` function from `BaseApp` will return the application's name, version and the hash of the last commit of `app.cms`. ### Query -The [`Query` ABCI message](https://tendermint.com/docs/app-dev/abci-spec.html#query) is used to serve queries received from the underlying consensus engine, including queries received via RPC like Tendermint RPC. It used to be the main entrypoint to build interfaces with the application, but with the introduction of [gRPC queries](../building-modules/query-services.md) in Cosmos SDK v0.40, its usage is more limited. The application must respect a few rules when implementing the `Query` method, which are outlined [here](https://tendermint.com/docs/app-dev/abci-spec.html#query). +The [`Query` ABCI message](https://docs.tendermint.com/master/spec/abci/abci.html#query-2) is used to serve queries received from the underlying consensus engine, including queries received via RPC like Tendermint RPC. It used to be the main entrypoint to build interfaces with the application, but with the introduction of [gRPC queries](../building-modules/query-services.md) in Cosmos SDK v0.40, its usage is more limited. The application must respect a few rules when implementing the `Query` method, which are outlined [here](https://docs.tendermint.com/master/spec/abci/apps.html#query). -Each Tendermint `query` comes with a `path`, which is a `string` which denotes what to query. If the `path` matches a gRPC fully-qualified service method, then `BaseApp` will defer the query to the `grpcQueryRouter` and let it handle it like explained [above](#grpc-query-router). Otherwise, the `path` represents a query that is not (yet) handled by the gRPC router. `BaseApp` splits the `path` string with the `/` delimiter. By convention, the first element of the splitted string (`splitted[0]`) contains the category of `query` (`app`, `p2p`, `store` or `custom` ). The `BaseApp` implementation of the `Query(req abci.RequestQuery)` method is a simple dispatcher serving these 4 main categories of queries: +Each Tendermint `query` comes with a `path`, which is a `string` which denotes what to query. If the `path` matches a gRPC fully-qualified service method, then `BaseApp` will defer the query to the `grpcQueryRouter` and let it handle it like explained [above](#grpc-query-router). Otherwise, the `path` represents a query that is not (yet) handled by the gRPC router. `BaseApp` splits the `path` string with the `/` delimiter. By convention, the first element of the split string (`split[0]`) contains the category of `query` (`app`, `p2p`, `store` or `custom` ). The `BaseApp` implementation of the `Query(req abci.RequestQuery)` method is a simple dispatcher serving these 4 main categories of queries: * Application-related queries like querying the application's version, which are served via the `handleQueryApp` method. * Direct queries to the multistore, which are served by the `handlerQueryStore` method. These direct queries are different from custom queries which go through `app.queryRouter`, and are mainly used by third-party service provider like block explorers. diff --git a/docs/core/cli.md b/docs/core/cli.md index 1d9f5945f48b..2caca1103d37 100644 --- a/docs/core/cli.md +++ b/docs/core/cli.md @@ -4,7 +4,7 @@ order: 9 # Command-Line Interface -This document describes how commmand-line interface (CLI) works on a high-level, for an [**application**](../basics/app-anatomy.md). A separate document for implementing a CLI for a Cosmos SDK [**module**](../building-modules/intro.md) can be found [here](../building-modules/module-interfaces.md#cli). {synopsis} +This document describes how command-line interface (CLI) works on a high-level, for an [**application**](../basics/app-anatomy.md). A separate document for implementing a CLI for a Cosmos SDK [**module**](../building-modules/intro.md) can be found [here](../building-modules/module-interfaces.md#cli). {synopsis} ## Command-Line Interface @@ -120,13 +120,13 @@ Flags are added to commands directly (generally in the [module's CLI file](../bu ## Environment variables -Each flag is bound to it's respecteve named environment variable. Then name of the environment variable consist of two parts - capital case `basename` followed by flag name of the flag. `-` must be substituted with `_`. For example flag `--home` for application with basename `GAIA` is bound to `GAIA_HOME`. It allows to reduce amount of flags typed for routine operations. For example instead of: +Each flag is bound to it's respecteve named environment variable. Then name of the environment variable consist of two parts - capital case `basename` followed by flag name of the flag. `-` must be substituted with `_`. For example flag `--home` for application with basename `GAIA` is bound to `GAIA_HOME`. It allows reducing the amount of flags typed for routine operations. For example instead of: ```sh gaia --home=./ --node= --chain-id="testchain-1" --keyring-backend=test tx ... --from= ``` -this will be more convinient: +this will be more convenient: ```sh # define env variables in .env, .envrc etc diff --git a/docs/core/context.md b/docs/core/context.md index 3a0efa4353de..a1e912797b8c 100644 --- a/docs/core/context.md +++ b/docs/core/context.md @@ -4,7 +4,7 @@ order: 3 # Context -The `context` is a data structure intended to be passed from function to function that carries information about the current state of the application. It provides an access to a branched storage (a safe branch of the entire state) as well as useful objects and information like `gasMeter`, `block height`, `consensus parameters` and more. {synopsis} +The `context` is a data structure intended to be passed from function to function that carries information about the current state of the application. It provides access to a branched storage (a safe branch of the entire state) as well as useful objects and information like `gasMeter`, `block height`, `consensus parameters` and more. {synopsis} ## Pre-requisites Readings @@ -19,15 +19,15 @@ The Cosmos SDK `Context` is a custom data structure that contains Go's stdlib [` * **Context:** The base type is a Go [Context](https://golang.org/pkg/context), which is explained further in the [Go Context Package](#go-context-package) section below. * **Multistore:** Every application's `BaseApp` contains a [`CommitMultiStore`](./store.md#multistore) which is provided when a `Context` is created. Calling the `KVStore()` and `TransientStore()` methods allows modules to fetch their respective [`KVStore`](./store.md#base-layer-kvstores) using their unique `StoreKey`. -* **ABCI Header:** The [header](https://tendermint.com/docs/spec/abci/abci.html#header) is an ABCI type. It carries important information about the state of the blockchain, such as block height and proposer of the current block. +* **Header:** The [header](https://docs.tendermint.com/master/spec/core/data_structures.html#header) is a Blockchain type. It carries important information about the state of the blockchain, such as block height and proposer of the current block. * **Chain ID:** The unique identification number of the blockchain a block pertains to. -* **Transaction Bytes:** The `[]byte` representation of a transaction being processed using the context. Every transaction is processed by various parts of the Cosmos SDK and consensus engine (e.g. Tendermint) throughout its [lifecycle](../basics/tx-lifecycle.md), some of which to not have any understanding of transaction types. Thus, transactions are marshaled into the generic `[]byte` type using some kind of [encoding format](./encoding.md) such as [Amino](./encoding.md). -* **Logger:** A `logger` from the Tendermint libraries. Learn more about logs [here](https://tendermint.com/docs/tendermint-core/how-to-read-logs.html#how-to-read-logs). Modules call this method to create their own unique module-specific logger. -* **VoteInfo:** A list of the ABCI type [`VoteInfo`](https://tendermint.com/docs/spec/abci/abci.html#voteinfo), which includes the name of a validator and a boolean indicating whether they have signed the block. +* **Transaction Bytes:** The `[]byte` representation of a transaction being processed using the context. Every transaction is processed by various parts of the Cosmos SDK and consensus engine (e.g. Tendermint) throughout its [lifecycle](../basics/tx-lifecycle.md), some of which do not have any understanding of transaction types. Thus, transactions are marshaled into the generic `[]byte` type using some kind of [encoding format](./encoding.md) such as [Amino](./encoding.md). +* **Logger:** A `logger` from the Tendermint libraries. Learn more about logs [here](https://docs.tendermint.com/master/nodes/logging.html). Modules call this method to create their own unique module-specific logger. +* **VoteInfo:** A list of the ABCI type [`VoteInfo`](https://docs.tendermint.com/master/spec/abci/abci.html#voteinfo), which includes the name of a validator and a boolean indicating whether they have signed the block. * **Gas Meters:** Specifically, a [`gasMeter`](../basics/gas-fees.md#main-gas-meter) for the transaction currently being processed using the context and a [`blockGasMeter`](../basics/gas-fees.md#block-gas-meter) for the entire block it belongs to. Users specify how much in fees they wish to pay for the execution of their transaction; these gas meters keep track of how much [gas](../basics/gas-fees.md) has been used in the transaction or block so far. If the gas meter runs out, execution halts. * **CheckTx Mode:** A boolean value indicating whether a transaction should be processed in `CheckTx` or `DeliverTx` mode. * **Min Gas Price:** The minimum [gas](../basics/gas-fees.md) price a node is willing to take in order to include a transaction in its block. This price is a local value configured by each node individually, and should therefore **not be used in any functions used in sequences leading to state-transitions**. -* **Consensus Params:** The ABCI type [Consensus Parameters](https://tendermint.com/docs/spec/abci/apps.html#consensus-parameters), which specify certain limits for the blockchain, such as maximum gas for a block. +* **Consensus Params:** The ABCI type [Consensus Parameters](https://docs.tendermint.com/master/spec/abci/apps.html#consensus-parameters), which specify certain limits for the blockchain, such as maximum gas for a block. * **Event Manager:** The event manager allows any caller with access to a `Context` to emit [`Events`](./events.md). Modules may define module specific `Events` by defining various `Types` and `Attributes` or use the common definitions found in `types/`. Clients can subscribe or query for these `Events`. These `Events` are collected throughout `DeliverTx`, `BeginBlock`, and `EndBlock` and are returned to Tendermint for indexing. For example: @@ -72,32 +72,9 @@ goes wrong. The pattern of usage for a Context is as follows: needs to be done - the branch `ctx` is simply discarded. If successful, the changes made to the `CacheMultiStore` can be committed to the original `ctx.ms` via `Write()`. -For example, here is a snippet from the [`runTx`](./baseapp.md#runtx-and-runmsgs) function in -[`baseapp`](./baseapp.md): +For example, here is a snippet from the [`CustomTxHandlerMiddleware`](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/baseapp/custom_txhandler_test.go#L23) used in tests: -```go -runMsgCtx, msCache := app.cacheTxContext(ctx, txBytes) -result = app.runMsgs(runMsgCtx, msgs, mode) -result.GasWanted = gasWanted - -if mode != runTxModeDeliver { - return result -} - -if result.IsOK() { - msCache.Write() -} -``` - -Here is the process: - -1. Prior to calling `runMsgs` on the message(s) in the transaction, it uses `app.cacheTxContext()` - to branch and cache the context and multistore. -2. `runMsgCtx` - the context with branched store, is used in `runMsgs` to return a result. -3. If the process is running in [`checkTxMode`](./baseapp.md#checktx), there is no need to write the - changes - the result is returned immediately. -4. If the process is running in [`deliverTxMode`](./baseapp.md#delivertx) and the result indicates - a successful run over all the messages, the branched multistore is written back to the original. ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/baseapp/custom_txhandler_test.go#L62:L97 ## Next {hide} diff --git a/docs/core/encoding.md b/docs/core/encoding.md index 9e71968c26cd..dea5ce105b65 100644 --- a/docs/core/encoding.md +++ b/docs/core/encoding.md @@ -30,8 +30,8 @@ tree. For store encoding, protobuf definitions can exist for any type and will typically have an Amino-based "intermediary" type. Specifically, the protobuf-based type definition is used for serialization and persistence, whereas the Amino-based type -is used for business logic in the state-machine where they may converted back-n-forth. -Note, the Amino-based types may slowly be phased-out in the future so developers +is used for business logic in the state-machine where they may convert back-n-forth. +Note, the Amino-based types may slowly be phased-out in the future, so developers should take note to use the protobuf message definitions where possible. In the `codec` package, there exists two core interfaces, `Marshaler` and `ProtoMarshaler`, @@ -43,7 +43,7 @@ In addition, there exists two implementations of `Marshaler`. The first being second being `ProtoCodec`, where both binary and JSON serialization is handled via Protobuf. -This means that modules may use Amino or Protobuf encoding but the types must +This means that modules may use Amino or Protobuf encoding, but the types must implement `ProtoMarshaler`. If modules wish to avoid implementing this interface for their types, they may use an Amino codec directly. @@ -73,12 +73,12 @@ Since the `MsgExec` message type can contain different messages instances, it is add the following code inside the `init` method of their module's `codec.go` file: ```go -import "github.com/cosmos/cosmos-sdk/codec/legacy" +import authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" init() { - // Register all Amino interfaces and concrete types on the global Amino codec so that this can later be - // used to properly serialize x/authz MsgExec instances - RegisterLegacyAminoCodec(legacy.Cdc) + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } ``` @@ -247,7 +247,7 @@ may simply migrate any existing types that are encoded and persisted via their concrete Amino codec to Protobuf (see 1. for further guidelines) and accept a `Marshaler` as the codec which is implemented via the `ProtoCodec` without any further customization. -However, if a module type composes an interface, it must wrap it in the `skd.Any` (from `/types` package) type. To do that, a module-level .proto file must use [`google.protobuf.Any`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto) for respective message type interface types. +However, if a module type composes an interface, it must wrap it in the `sdk.Any` (from `/types` package) type. To do that, a module-level .proto file must use [`google.protobuf.Any`](https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto) for respective message type interface types. For example, in the `x/evidence` module defines an `Evidence` interface, which is used by the `MsgSubmitEvidence`. The structure definition must use `sdk.Any` to wrap the evidence file. In the proto file we define it as follows: diff --git a/docs/core/grpc_rest.md b/docs/core/grpc_rest.md index 5052f64cfa33..527757534620 100644 --- a/docs/core/grpc_rest.md +++ b/docs/core/grpc_rest.md @@ -32,7 +32,7 @@ replace google.golang.org/grpc => google.golang.org/grpc v1.33.2 Please see [issue #8392](https://github.com/cosmos/cosmos-sdk/issues/8392) for more info. ::: -Cosmos SDK v0.40 introduced Protobuf as the main [encoding](./encoding) library, and this brings a wide range of Protobuf-based tools that can be plugged into the Cosmos SDK. One such tool is [gRPC](https://grpc.io), a modern open source high performance RPC framework that has decent client support in several languages. +Cosmos SDK v0.40 introduced Protobuf as the main [encoding](./encoding) library, and this brings a wide range of Protobuf-based tools that can be plugged into the Cosmos SDK. One such tool is [gRPC](https://grpc.io), a modern open-source high performance RPC framework that has decent client support in several languages. Each module exposes a [Protobuf `Query` service](../building-modules/messages-and-queries.md#queries) that defines state queries. The `Query` services and a transaction service used to broadcast transactions are hooked up to the gRPC server via the following function inside the application: @@ -51,7 +51,7 @@ The `grpc.Server` is a concrete gRPC server, which spawns and serves all gRPC qu Once the gRPC server is started, you can send requests to it using a gRPC client. Some examples are given in our [Interact with the Node](../run-node/interact-node.md#using-grpc) tutorial. -An overview of all available gRPC endpoints shipped with the Cosmos SDK is [Protobuf documention](https://buf.build/cosmos/cosmos-sdk). +An overview of all available gRPC endpoints shipped with the Cosmos SDK is [Protobuf documentation](https://buf.build/cosmos/cosmos-sdk). ## REST Server diff --git a/docs/core/middleware.md b/docs/core/middleware.md index 5cbdb18213ca..f7ea5dd8df10 100644 --- a/docs/core/middleware.md +++ b/docs/core/middleware.md @@ -1,5 +1,5 @@ # Middlewares @@ -10,11 +10,11 @@ order: 3 ## Pre-requisite Readings * [Anatomy of a Cosmos SDK Application](../basics/app-anatomy.md) {prereq} -* [Transactons](transactions.md) {prereq} +* [Transactions](transactions.md) {prereq} ## Middlewares -The SDK Baseapp's implementation of ABCI CheckTx, DeliverTx, and Baseapp's own Simulate methods use a middleware-based design. Middlewares can add logic to be executed before or after a transaction handler execution. Middlewares are like an `antehandler` with the added feature of being able to add post-transaction handler execution. Middlewares allow us to solve use cases like transaction Tips and refund unused gas (issue [#2150](https://github.com/cosmos/cosmos-sdk/issues/2150)). +The SDK Baseapp's implementation of ABCI CheckTx, DeliverTx, and Baseapp's own Simulate methods use a middleware-based design. Middlewares can add logic to be executed before or after a transaction handler execution. Middlewares are like the previous notion of `antehandler` with the added feature of being able to add post-transaction handler execution. Middlewares allow us to solve use cases like transaction Tips and refund unused gas (issue [#2150](https://github.com/cosmos/cosmos-sdk/issues/2150)). ### Type Definition @@ -107,7 +107,7 @@ While BaseApp holds a reference to a `tx.Handler`, this `tx.Handler` itself is d Then, the app developer can compose multiple middlewares on top of the base `tx.Handler`. Each middleware can run pre-and-post-processing logic around its next middleware, as described in the section above. Conceptually, as an example, given the middlewares `A`, `B`, and `C` and the base `tx.Handler` `H` the stack looks like: -![Composing](baseapp_transaction-middleware.png) +![Composing](./baseapp_transaction-middleware.png) ```text A.pre @@ -143,11 +143,11 @@ While the app developer can define and compose the middlewares of their choice, | Middleware | Description | | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | RunMsgsTxHandler | This is the base `tx.Handler`. It replaces the old baseapp's `runMsgs`, and executes a transaction's `Msg`s. | -| TxDecoderMiddleware | This middleware takes in transaction raw bytes, and decodes them into a `sdk.Tx`. It replaces the `baseapp.txDecoder` field, so that BaseApp stays as thin as possible. Since most middlewares read the contents of the `sdk.Tx`, the TxDecoderMiddleware should be run first in the middelware stack. | +| TxDecoderMiddleware | This middleware takes in transaction raw bytes, and decodes them into a `sdk.Tx`. It replaces the `baseapp.txDecoder` field, so that BaseApp stays as thin as possible. Since most middlewares read the contents of the `sdk.Tx`, the TxDecoderMiddleware should be run first in the middleware stack. | | {Antehandlers} | Each antehandler is converted to its own middleware. These middlewares perform signature verification, fee deductions and other validations on the incoming transaction. | | IndexEventsTxMiddleware | This is a simple middleware that chooses which events to index in Tendermint. Replaces `baseapp.indexEvents` (which unfortunately still exists in baseapp too, because it's used to index Begin/EndBlock events) | | RecoveryTxMiddleware | This index recovers from panics. It replaces baseapp.runTx's panic recovery described in [ADR-022](./adr-022-custom-panic-handling.md). | -| GasTxMiddleware | This replaces the [`Setup`](https://github.com/cosmos/cosmos-sdk/blob/v0.43.0/x/auth/ante/setup.go) Antehandler. It sets a GasMeter on sdk.Context. Note that before, GasMeter was set on sdk.Context inside the antehandlers, and there was some mess around the fact that antehandlers had their own panic recovery system so that the GasMeter could be read by baseapp's recovery system. Now, this mess is all removed: one middleware sets GasMeter, another one handles recovery. | +| GasTxMiddleware | This replaces the [`Setup`](https://github.com/cosmos/cosmos-sdk/blob/v0.45.3/x/auth/ante/setup.go) Antehandler. It sets a GasMeter on sdk.Context. Note that before, GasMeter was set on sdk.Context inside the antehandlers, and there was some mess around the fact that antehandlers had their own panic recovery system so that the GasMeter could be read by baseapp's recovery system. Now, this mess is all removed: one middleware sets GasMeter, another one handles recovery. | | TipMiddleware | This pays for transaction fees using another denom than the native fee denom of the chain. [`docs`](tips.md) | | SigGasConsumeMiddleware | SigGasConsumeMiddleware consumes parameter-defined amount of gas for each signature. | | SigVerificationMiddleware | verifies all signatures for a tx and return an error if any are invalid | diff --git a/docs/core/node.md b/docs/core/node.md index a4693643ecf2..67497e9f58d7 100644 --- a/docs/core/node.md +++ b/docs/core/node.md @@ -55,13 +55,13 @@ In practice, the [constructor of the application](../basics/app-anatomy.md#const +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/simapp/simd/cmd/root.go#L170-L215 -Then, the instance of `app` is used to instanciate a new Tendermint node: +Then, the instance of `app` is used to instantiate a new Tendermint node: +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/server/start.go#L235-L244 The Tendermint node can be created with `app` because the latter satisfies the [`abci.Application` interface](https://github.com/tendermint/tendermint/blob/v0.34.0/abci/types/application.go#L7-L32) (given that `app` extends [`baseapp`](./baseapp.md)). As part of the `NewNode` method, Tendermint makes sure that the height of the application (i.e. number of blocks since genesis) is equal to the height of the Tendermint node. The difference between these two heights should always be negative or null. If it is strictly negative, `NewNode` will replay blocks until the height of the application reaches the height of the Tendermint node. Finally, if the height of the application is `0`, the Tendermint node will call [`InitChain`](./baseapp.md#initchain) on the application to initialize the state from the genesis file. -Once the Tendermint node is instanciated and in sync with the application, the node can be started: +Once the Tendermint node is instantiated and in sync with the application, the node can be started: +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/server/start.go#L250-L252 diff --git a/docs/core/proto-docs.md b/docs/core/proto-docs.md index ba2a6f37c61d..8ea66828cf93 100644 --- a/docs/core/proto-docs.md +++ b/docs/core/proto-docs.md @@ -1,7 +1,7 @@ # Protobuf Documentation -This file has been replaced by [Cosmos-SDK Buf Proto-docs](https://buf.build/cosmos/cosmos-sdk/docs/main) +See [Cosmos-SDK Buf Proto-docs](https://buf.build/cosmos/cosmos-sdk/docs/main) diff --git a/docs/core/runtx_middleware.md b/docs/core/runtx_middleware.md deleted file mode 100644 index 32f7bb1ce882..000000000000 --- a/docs/core/runtx_middleware.md +++ /dev/null @@ -1,73 +0,0 @@ - - -# RunTx recovery middleware - -`BaseApp.runTx()` function handles Golang panics that might occur during transactions execution, for example, keeper has faced an invalid state and paniced. -Depending on the panic type different handler is used, for instance the default one prints an error log message. -Recovery middleware is used to add custom panic recovery for Cosmos SDK application developers. - -More context could be found in the corresponding [ADR-022](../architecture/adr-022-custom-panic-handling.md). - -Implementation could be found in the [recovery.go](https://github.com/cosmos/cosmos-sdk/tree/v0.46.0-alpha2/x/auth/middleware/recovery.go) file. - -## Interface - -```go -type RecoveryHandtree/v0.46.0-alpha2 -``` - -`recoveryObj` is a return value for `recover()` function from the `buildin` Golang package. - -**Contract:** - -* RecoveryHandler returns `nil` if `recoveryObj` wasn't handled and should be passed to the next recovery middleware; -* RecoveryHandler returns a non-nil `error` if `recoveryObj` was handled; - -## Custom RecoveryHandler register - -`BaseApp.AddRunTxRecoveryHandler(handlers ...RecoveryHandler)` - -BaseApp method adds recovery middleware to the default recovery chain. - -## Example - -Lets assume we want to emit the "Consensus failure" chain state if some particular error occurred. - -We have a module keeper that panics: - -```go -func (k FooKeeper) Do(obj interface{}) { - if obj == nil { - // that shouldn't happen, we need to crash the app - err := sdkErrors.Wrap(fooTypes.InternalError, "obj is nil") - panic(err) - } -} -``` - -By default that panic would be recovered and an error message will be printed to log. To override that behaviour we should register a custom RecoveryHandler: - -```go -// Cosmos SDK application constructor -customHandler := func(recoveryObj interface{}) error { - err, ok := recoveryObj.(error) - if !ok { - return nil - } - - if fooTypes.InternalError.Is(err) { - panic(fmt.Errorf("FooKeeper did panic with error: %w", err)) - } - - return nil -} - -baseApp := baseapp.NewBaseApp(...) -baseApp.AddRunTxRecoveryHandler(customHandler) -``` - -## Next {hide} - -Learn about the [IBC](./../ibc/README.md) protocol {hide} diff --git a/docs/core/simulation.md b/docs/core/simulation.md index 68503d8af5f2..5f13e820d7fd 100644 --- a/docs/core/simulation.md +++ b/docs/core/simulation.md @@ -1,5 +1,5 @@ # Cosmos Blockchain Simulator @@ -76,7 +76,7 @@ check the Cosmos SDK [Makefile](https://github.com/cosmos/cosmos-sdk/blob/v0.40. Here are some suggestions when encountering a simulation failure: -* Export the app state at the height were the failure was found. You can do this +* Export the app state at the height where the failure was found. You can do this by passing the `-ExportStatePath` flag to the simulator. * Use `-Verbose` logs. They could give you a better hint on all the operations involved. @@ -84,7 +84,7 @@ Here are some suggestions when encountering a simulation failure: frequently. * Print all the failed invariants at once with `-PrintAllInvariants`. * Try using another `-Seed`. If it can reproduce the same error and if it fails - sooner you will spend less time running the simulations. + sooner, you will spend less time running the simulations. * Reduce the `-NumBlocks` . How's the app state at the height previous to the failure? * Run invariants on every operation with `-SimulateEveryOperation`. _Note_: this diff --git a/docs/core/tips.md b/docs/core/tips.md index 3765cc9f4452..a76c3564b758 100644 --- a/docs/core/tips.md +++ b/docs/core/tips.md @@ -1,5 +1,5 @@ # Transaction Tips @@ -14,13 +14,13 @@ Transaction tips is a new solution for cross-chain transaction fees payment, whe Assuming we have two chains, A and B, we define the following terms: -- **the tipper**: this is the initiator of the transaction, who wants to execute a `Msg` on chain A, but doesn't have any native chain A tokens, only chain B tokens. In our example above, the tipper is the Osmosis (chain B) user wanting to vote on a Cosmos Hub (chain A) proposal. -- **the fee payer**: this is the party that will relay and broadcast the final transaction on chain A, and has chain A tokens. The tipper doesn't need to trust the feepayer. -- **the target chain**: the chain where the `Msg` is executed, chain A in this case. +* **the tipper**: this is the initiator of the transaction, who wants to execute a `Msg` on chain A, but doesn't have any native chain A tokens, only chain B tokens. In our example above, the tipper is the Osmosis (chain B) user wanting to vote on a Cosmos Hub (chain A) proposal. +* **the fee payer**: this is the party that will relay and broadcast the final transaction on chain A, and has chain A tokens. The tipper doesn't need to trust the feepayer. +* **the target chain**: the chain where the `Msg` is executed, chain A in this case. ## Transaction Tips Flow -The transaction tips flow happens in multipe steps. +The transaction tips flow happens in multiple steps. 1. The tipper sends via IBC some chain B tokens to chain A. These tokens will cover for fees on the target chain A. This means that chain A's bank module holds some IBC tokens under the tipper's address. @@ -42,12 +42,12 @@ Notice that this document doesn't sign over the final chain A fees. Instead, it 4. From the signed `AuxSignerData` document, the fee payer constructs a transaction, using the following algorithm: -- use as `TxBody` the exact `AuxSignerData.SignDocDirectAux.body_bytes`, to not alter the original intent of the tipper, -- create an `AuthInfo` with: - - `AuthInfo.Tip` copied from `AuxSignerData.SignDocDirectAux.Tip`, - - `AuthInfo.Fee` chosen by the fee payer, which should cover for the transaction gas, but also be small enough so that the tip/fee exchange rate is economically interesting for the fee payer, - - `AuthInfo.SignerInfos` has two signers: the first signer is the tipper, using the public key, sequence and sign mode specified in `AuxSignerData`; and the second signer is the fee payer, using their favorite sign mode, -- a `Signatures` array with two items: the tipper's signature from `AuxSignerData.Sig`, and the final fee payer's signature. +* use as `TxBody` the exact `AuxSignerData.SignDocDirectAux.body_bytes`, to not alter the original intent of the tipper, +* create an `AuthInfo` with: + * `AuthInfo.Tip` copied from `AuxSignerData.SignDocDirectAux.Tip`, + * `AuthInfo.Fee` chosen by the fee payer, which should cover for the transaction gas, but also be small enough so that the tip/fee exchange rate is economically interesting for the fee payer, + * `AuthInfo.SignerInfos` has two signers: the first signer is the tipper, using the public key, sequence and sign mode specified in `AuxSignerData`; and the second signer is the fee payer, using their favorite sign mode, +* a `Signatures` array with two items: the tipper's signature from `AuxSignerData.Sig`, and the final fee payer's signature. 5. Broadcast the final transaction signed by the two parties to the target chain. Once included, the Cosmos SDK will trigger a transfer of the `Tip` specified in the transaction from the tipper address to the fee payer address. @@ -63,10 +63,10 @@ In the future, we imagine a market where fee payers will compete to include tran As we mentioned in the flow above, the tipper signs over the `SignDocDirectAux`, and the fee payer signs over the whole final transaction. As such, both parties might use different sign modes. -- The tipper MUST use `SIGN_MODE_DIRECT_AUX` or `SIGN_MODE_LEGACY_AMINO_JSON`. That is because the tipper needs to sign over the body, the tip, but not the other signers' information and not over the fee (which is unknown to the tipper). -- The fee payer MUST use `SIGN_MODE_DIRECT` or `SIGN_MODE_LEGACY_AMINO_JSON`. The fee payer signs over the whole transaction. +* The tipper MUST use `SIGN_MODE_DIRECT_AUX` or `SIGN_MODE_LEGACY_AMINO_JSON`. That is because the tipper needs to sign over the body, the tip, but not the other signers' information and not over the fee (which is unknown to the tipper). +* The fee payer MUST use `SIGN_MODE_DIRECT` or `SIGN_MODE_LEGACY_AMINO_JSON`. The fee payer signs over the whole transaction. -For example, if the fee payers signs the whole transaction with `SIGN_MODE_DIRECT_AUX`, it will be rejected by the node, as that would introduce malleability issues (`SIGN_MODE_DIRECT_AUX` doesn't sign over fees). +For example, if the fee payer signs the whole transaction with `SIGN_MODE_DIRECT_AUX`, it will be rejected by the node, as that would introduce malleability issues (`SIGN_MODE_DIRECT_AUX` doesn't sign over fees). In both cases, using `SIGN_MODE_LEGACY_AMINO_JSON` is recommended only if hardware wallet signing is needed. @@ -98,7 +98,7 @@ If you are using the Cosmos SDK's default middleware stack `NewDefaultTxHandler( The Cosmos SDK also provides some CLI tooling for the transaction tips flow, both for the tipper and for the feepayer. -For the tipper, the CLI `tx` subcommand has two new flags: `--aux` and `--tip`. The `--aux` flag is used to denote that we are creating a `AuxSignerData` instead of a , and the `--tip` is used to populate its `Tip` field. +For the tipper, the CLI `tx` subcommand has two new flags: `--aux` and `--tip`. The `--aux` flag is used to denote that we are creating an `AuxSignerData` instead of a `Tx`, and the `--tip` is used to populate its `Tip` field. ```bash $ simd tx gov vote 16 yes --from --aux --tip 50ibcdenom @@ -110,7 +110,7 @@ $ simd tx gov vote 16 yes --from --aux --tip 50ibcdenom It is useful to pipe the JSON output to a file, `> aux_signed_tx.json` -For the fee payer, the Cosmos SDK added a `tx aux-to-fee` subcommand to include a `AuxSignerData` into a transaction, add fees to it, and broadcast it. +For the fee payer, the Cosmos SDK added a `tx aux-to-fee` subcommand to include an `AuxSignerData` into a transaction, add fees to it, and broadcast it. ```bash $ simd tx aux-to-fee aux_signed_tx.json --from --fees 30atom diff --git a/docs/core/transactions.md b/docs/core/transactions.md index ca146e81d706..b8b7ec774107 100644 --- a/docs/core/transactions.md +++ b/docs/core/transactions.md @@ -20,12 +20,12 @@ When users want to interact with an application and make state changes (e.g. sen Transaction objects are Cosmos SDK types that implement the `Tx` interface -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/types/tx_msg.go#L49-L57 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/types/tx_msg.go#L38-L46 It contains the following methods: * **GetMsgs:** unwraps the transaction and returns a list of contained `sdk.Msg`s - one transaction may have one or multiple messages, which are defined by module developers. -* **ValidateBasic:** lightweight, [_stateless_](../basics/tx-lifecycle.md#types-of-checks) checks used by ABCI messages [`CheckTx`](./baseapp.md#checktx) and [`DeliverTx`](./baseapp.md#delivertx) to make sure transactions are not invalid. For example, the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/master/x/auth) module's `StdTx` `ValidateBasic` function checks that its transactions are signed by the correct number of signers and that the fees do not exceed what the user's maximum. Note that this function is to be distinct from `sdk.Msg` [`ValidateBasic`](../basics/tx-lifecycle.md#ValidateBasic) methods, which perform basic validity checks on messages only. When [`runTx`](./baseapp.md#runtx) is checking a transaction created from the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/master/x/auth/spec) module, it first runs `ValidateBasic` on each message, then runs the `auth` module AnteHandler which calls `ValidateBasic` for the transaction itself. +* **ValidateBasic:** lightweight, [_stateless_](../basics/tx-lifecycle.md#types-of-checks) checks used by ABCI messages [`CheckTx`](./baseapp.md#checktx) and [`DeliverTx`](./baseapp.md#delivertx) to make sure transactions are not invalid. For example, the [`auth`](https://github.com/cosmos/cosmos-sdk/tree/main/x/auth) module's `ValidateBasic` function checks that its transactions are signed by the correct number of signers and that the fees do not exceed what the user's maximum. Note that this function is to be distinct from `sdk.Msg` [`ValidateBasic`](../basics/tx-lifecycle.md#ValidateBasic) methods, which perform basic validity checks on messages only. When using [`ValidateBasicMiddleware`](https://github.com/cosmos/cosmos-sdk/blob/main/x/auth/spec/03_middlewares.md), `ValidateBasic` is called on each message, and then the middleware calls `ValidateBasic` for the transaction itself. As a developer, you should rarely manipulate `Tx` directly, as `Tx` is really an intermediate type used for transaction generation. Instead, developers should prefer the `TxBuilder` interface, which you can learn more about [below](#transaction-generation). @@ -47,19 +47,35 @@ Once signed by all signers, the `body_bytes`, `auth_info_bytes` and `signatures` #### `SIGN_MODE_LEGACY_AMINO_JSON` -The legacy implemention of the `Tx` interface is the `StdTx` struct from `x/auth`: +The legacy implementation of the `Tx` interface is the `StdTx` struct from `x/auth`: +++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/x/auth/legacy/legacytx/stdtx.go#L120-L130 The document signed by all signers is `StdSignDoc`: -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.40.0-rc3/x/auth/legacy/legacytx/stdsign.go#L20-L33 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/x/auth/migrations/legacytx/stdsign.go#L38-L52 which is encoded into bytes using Amino JSON. Once all signatures are gathered into `StdTx`, `StdTx` is serialized using Amino JSON, and these bytes are broadcasted over the network. #### Other Sign Modes -Other sign modes, most notably `SIGN_MODE_TEXTUAL`, are being discussed. If you wish to learn more about them, please refer to [ADR-020](../architecture/adr-020-protobuf-transaction-encoding.md). +The Cosmos SDK also provides a couple of other sign modes for particular use cases. + +#### `SIGN_MODE_DIRECT_AUX` + +`SIGN_MODE_DIRECT_AUX` is a sign mode released in the Cosmos SDK v0.46 which targets transactions with multiple signers. Whereas `SIGN_MODE_DIRECT` expects each signer to sign over both `TxBody` and `AuthInfo` (which includes all other signers' signer infos, i.e. their account sequence, public key and mode info), `SIGN_MODE_DIRECT_AUX` allows N-1 signers to only sign over `TxBody` and _their own_ signer info. Morever, each auxiliary signer (i.e. a signer using `SIGN_MODE_DIRECT_AUX`) doesn't +need to sign over the fees: + ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/tx/v1beta1/tx.proto#L67-L93 + +The use case is a multi-signer transaction, where one of the signers is appointed to gather all signatures, broadcast the signature and pay for fees, and the others only care about the transaction body. This generally allows for a better multi-signing UX. If Alice, Bob and Charlie are part of a 3-signer transaction, then Alice and Bob can both use `SIGN_MODE_DIRECT_AUX` to sign over the `TxBody` and their own signer info (no need an additional step to gather other signers' ones, like in `SIGN_MODE_DIRECT`), without specifying a fee in their SignDoc. Charlie can then gather both signatures from Alice and Bob, and +create the final transaction by appending a fee. Note that the fee payer of the transaction (in our case Charlie) must sign over the fees, so must use `SIGN_MODE_DIRECT` or `SIGN_MODE_LEGACY_AMINO_JSON`. + +A concrete use case is implemented in [transaction tips](./tips.md): the tipper may use `SIGN_MODE_DIRECT_AUX` to specify a tip in the transaction, without signing over the actual transaction fees. Then, the fee payer appends fees inside the tipper's desired `TxBody`, and as an exchange for paying the fees and broadcasting the transaction, receives the tipper's transaction tips as payment. + +#### `SIGN_MODE_TEXTUAL` + +`SIGN_MODE_TEXTUAL` is a new sign mode for delivering a better signing experience on hardware wallets, it is currently still under implementation. If you wish to learn more, please refer to [ADR-050](https://github.com/cosmos/cosmos-sdk/pull/10701). ## Transaction Process @@ -74,12 +90,12 @@ The next paragraphs will describe each of these components, in this order. ### Messages ::: tip -Module `sdk.Msg`s are not to be confused with [ABCI Messages](https://tendermint.com/docs/spec/abci/abci.html#messages) which define interactions between the Tendermint and application layers. +Module `sdk.Msg`s are not to be confused with [ABCI Messages](https://docs.tendermint.com/master/spec/abci/abci.html#messages) which define interactions between the Tendermint and application layers. ::: **Messages** (or `sdk.Msg`s) are module-specific objects that trigger state transitions within the scope of the module they belong to. Module developers define the messages for their module by adding methods to the Protobuf [`Msg` service](../building-modules/msg-services.md), and also implement the corresponding `MsgServer`. -Each `sdk.Msg`s is related to exactly one Protobuf [`Msg` service](../building-modules/msg-services.md) RPC, defined inside each module's `tx.proto` file. An SKD app router automatically maps every `sdk.Msg` to a corresponding RPC. Protobuf generates a `MsgServer` interface for each module `Msg` service, and the module developer needs to implement this interface. +Each `sdk.Msg`s is related to exactly one Protobuf [`Msg` service](../building-modules/msg-services.md) RPC, defined inside each module's `tx.proto` file. A SDK app router automatically maps every `sdk.Msg` to a corresponding RPC. Protobuf generates a `MsgServer` interface for each module `Msg` service, and the module developer needs to implement this interface. This design puts more responsibility on module developers, allowing application developers to reuse common functionalities without having to implement state transition logic repetitively. To learn more about Protobuf `Msg` services and how to implement `MsgServer`, click [here](../building-modules/msg-services.md). @@ -126,7 +142,7 @@ Once the transaction bytes are generated, there are currently three ways of broa #### CLI -Application developers create entrypoints to the application by creating a [command-line interface](../core/cli.md), [gRPC and/or REST interface](../core/grpc_rest.md), typically found in the application's `./cmd` folder. These interfaces allow users to interact with the application through command-line. +Application developers create entry points to the application by creating a [command-line interface](../core/cli.md), [gRPC and/or REST interface](../core/grpc_rest.md), typically found in the application's `./cmd` folder. These interfaces allow users to interact with the application through command-line. For the [command-line interface](../building-modules/module-interfaces.md#cli), module developers create subcommands to add as children to the application top-level transaction command `TxCmd`. CLI commands actually bundle all the steps of transaction processing into one simple command: creating messages, generating transactions and broadcasting. For concrete examples, see the [Interacting with a Node](../run-node/interact-node.md) section. An example transaction made using CLI looks like: diff --git a/docs/core/upgrade.md b/docs/core/upgrade.md index b1fb6859c232..315ce783aca9 100644 --- a/docs/core/upgrade.md +++ b/docs/core/upgrade.md @@ -5,7 +5,7 @@ order: 15 # In-Place Store Migrations ::: warning -Read and understand all of the in-place store migration documentation before you run a migration on a live chain. +Read and understand all the in-place store migration documentation before you run a migration on a live chain. ::: Upgrade your app modules smoothly with custom in-place store migration logic. {synopsis} @@ -67,7 +67,7 @@ To learn more about configuring migration scripts for your modules, see the [Mod By default, all migrations are run in module name alphabetical ascending order, except `x/auth` which is run last. The reason is state dependencies between x/auth and other modules (you can read more in [issue #10606](https://github.com/cosmos/cosmos-sdk/issues/10606)). -If you want to change the order of migration then you should call `app.mm.SetOrderMigrations(module1, module2, ...)` in your app.go file. The function will panic if you forget to include a module in the argument list. +If you want to change the order of migration, then you should call `app.mm.SetOrderMigrations(module1, module2, ...)` in your app.go file. The function will panic if you forget to include a module in the argument list. ## Adding New Modules During Upgrades @@ -155,6 +155,6 @@ app.UpgradeKeeper.SetUpgradeHandler("my-plan", func(ctx sdk.Context, plan upgrad You can sync a full node to an existing blockchain which has been upgraded using Cosmovisor -In order to successfully sync, you must start with the initial binary that the blockchain started with at genesis. If all Software Upgrade Plans contain binary instruction then you can run Cosmovisor with auto download option to automatically handle downloading and switching to the binaries associated with each sequential upgrade. Otherwise you need to manually provide all binaries to Cosmovisor. +To successfully sync, you must start with the initial binary that the blockchain started with at genesis. If all Software Upgrade Plans contain binary instruction, then you can run Cosmovisor with auto-download option to automatically handle downloading and switching to the binaries associated with each sequential upgrade. Otherwise, you need to manually provide all binaries to Cosmovisor. To learn more about Cosmovisor, see the [Cosmovisor Quick Start](../run-node/cosmovisor.md). diff --git a/docs/ibc/README.md b/docs/ibc/README.md index 8be696391299..872e5c0dcfcc 100644 --- a/docs/ibc/README.md +++ b/docs/ibc/README.md @@ -1,20 +1,9 @@ # IBC -This repository contains reference documentation for the IBC protocol integration and concepts: - -1. [Overview](./overview.md) -2. [Integration](./integration.md) -3. [Customization](./custom.md) -4. [Relayer](./relayer.md) -5. [Governance Proposals](./proposals.md) - -**NOTE**: The IBC module has been moved to its [own repository](https://github.com/cosmos/ibc-go). - -After reading about IBC, head on to the [Building Modules -documentation](../building-modules/README.md) to learn more about the process of building modules. +See the official [`ibc-go` documentation](https://ibc.cosmos.network). diff --git a/docs/ibc/custom.md b/docs/ibc/custom.md deleted file mode 100644 index 1a5e0e306d2a..000000000000 --- a/docs/ibc/custom.md +++ /dev/null @@ -1,468 +0,0 @@ - - -# Customization - -Learn how to configure your application to use IBC and send data packets to other chains. {synopsis} - -This document serves as a guide for developers who want to write their own Inter-blockchain -Communication Protocol (IBC) applications for custom [use-cases](https://github.com/cosmos/ics/blob/master/ibc/4_IBC_USECASES.md). - -Due to the modular design of the IBC protocol, IBC -application developers do not need to concern themselves with the low-level details of clients, -connections, and proof verification. Nevertheless a brief explanation of the lower levels of the -stack is given so that application developers may have a high-level understanding of the IBC -protocol. Then the document goes into detail on the abstraction layer most relevant for application -developers (channels and ports), and describes how to define your own custom packets, and -`IBCModule` callbacks. - -To have your module interact over IBC you must: bind to a port(s), define your own packet data and acknolwedgement structs as well as how to encode/decode them, and implement the -`IBCModule` interface. Below is a more detailed explanation of how to write an IBC application -module correctly. - -## Pre-requisites Readings - -* [IBC Overview](./overview.md)) {prereq} -* [IBC default integration](./integration.md) {prereq} - -## Create a custom IBC application module - -### Implement `IBCModule` Interface and callbacks - -The Cosmos SDK expects all IBC modules to implement the [`IBCModule` -interface](https://github.com/cosmos/ibc-go/tree/main/modules/core/05-port/types/module.go). This -interface contains all of the callbacks IBC expects modules to implement. This section will describe -the callbacks that are called during channel handshake execution. - -Here are the channel handshake callbacks that modules are expected to implement: - -```go -// Called by IBC Handler on MsgOpenInit -func (k Keeper) OnChanOpenInit(ctx sdk.Context, - order channeltypes.Order, - connectionHops []string, - portID string, - channelID string, - channelCap *capabilitytypes.Capability, - counterparty channeltypes.Counterparty, - version string, -) error { - // OpenInit must claim the channelCapability that IBC passes into the callback - if err := k.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { - return err - } - - // ... do custom initialization logic - - // Use above arguments to determine if we want to abort handshake - // Examples: Abort if order == UNORDERED, - // Abort if version is unsupported - err := checkArguments(args) - return err -} - -// Called by IBC Handler on MsgOpenTry -OnChanOpenTry( - ctx sdk.Context, - order channeltypes.Order, - connectionHops []string, - portID, - channelID string, - channelCap *capabilitytypes.Capability, - counterparty channeltypes.Counterparty, - version, - counterpartyVersion string, -) error { - // Module may have already claimed capability in OnChanOpenInit in the case of crossing hellos - // (ie chainA and chainB both call ChanOpenInit before one of them calls ChanOpenTry) - // If the module can already authenticate the capability then the module already owns it so we don't need to claim - // Otherwise, module does not have channel capability and we must claim it from IBC - if !k.AuthenticateCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)) { - // Only claim channel capability passed back by IBC module if we do not already own it - if err := k.scopedKeeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil { - return err - } - } - - // ... do custom initialization logic - - // Use above arguments to determine if we want to abort handshake - err := checkArguments(args) - return err -} - -// Called by IBC Handler on MsgOpenAck -OnChanOpenAck( - ctx sdk.Context, - portID, - channelID string, - counterpartyVersion string, -) error { - // ... do custom initialization logic - - // Use above arguments to determine if we want to abort handshake - err := checkArguments(args) - return err -} - -// Called by IBC Handler on MsgOpenConfirm -OnChanOpenConfirm( - ctx sdk.Context, - portID, - channelID string, -) error { - // ... do custom initialization logic - - // Use above arguments to determine if we want to abort handshake - err := checkArguments(args) - return err -} -``` - -The channel closing handshake will also invoke module callbacks that can return errors to abort the -closing handshake. Closing a channel is a 2-step handshake, the initiating chain calls -`ChanCloseInit` and the finalizing chain calls `ChanCloseConfirm`. - -```go -// Called by IBC Handler on MsgCloseInit -OnChanCloseInit( - ctx sdk.Context, - portID, - channelID string, -) error { - // ... do custom finalization logic - - // Use above arguments to determine if we want to abort handshake - err := checkArguments(args) - return err -} - -// Called by IBC Handler on MsgCloseConfirm -OnChanCloseConfirm( - ctx sdk.Context, - portID, - channelID string, -) error { - // ... do custom finalization logic - - // Use above arguments to determine if we want to abort handshake - err := checkArguments(args) - return err -} -``` - -#### Channel Handshake Version Negotiation - -Application modules are expected to verify versioning used during the channel handshake procedure. - -* `ChanOpenInit` callback should verify that the `MsgChanOpenInit.Version` is valid -* `ChanOpenTry` callback should verify that the `MsgChanOpenTry.Version` is valid and that `MsgChanOpenTry.CounterpartyVersion` is valid. -* `ChanOpenAck` callback should verify that the `MsgChanOpenAck.CounterpartyVersion` is valid and supported. - -Versions must be strings but can implement any versioning structure. If your application plans to -have linear releases then semantic versioning is recommended. If your application plans to release -various features in between major releases then it is advised to use the same versioning scheme -as IBC. This versioning scheme specifies a version identifier and compatible feature set with -that identifier. Valid version selection includes selecting a compatible version identifier with -a subset of features supported by your application for that version. The struct is used for this -scheme can be found in `03-connection/types`. - -Since the version type is a string, applications have the ability to do simple version verification -via string matching or they can use the already impelemented versioning system and pass the proto -encoded version into each handhshake call as necessary. - -ICS20 currently implements basic string matching with a single supported version. - -### Bind Ports - -Currently, ports must be bound on app initialization. A module may bind to ports in `InitGenesis` -like so: - -```go -func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, state types.GenesisState) { - // ... other initialization logic - - // Only try to bind to port if it is not already bound, since we may already own - // port capability from capability InitGenesis - if !isBound(ctx, state.PortID) { - // module binds to desired ports on InitChain - // and claims returned capabilities - cap1 := keeper.IBCPortKeeper.BindPort(ctx, port1) - cap2 := keeper.IBCPortKeeper.BindPort(ctx, port2) - cap3 := keeper.IBCPortKeeper.BindPort(ctx, port3) - - // NOTE: The module's scoped capability keeper must be private - keeper.scopedKeeper.ClaimCapability(cap1) - keeper.scopedKeeper.ClaimCapability(cap2) - keeper.scopedKeeper.ClaimCapability(cap3) - } - - // ... more initialization logic -} -``` - -### Custom Packets - -Modules connected by a channel must agree on what application data they are sending over the -channel, as well as how they will encode/decode it. This process is not specified by IBC as it is up -to each application module to determine how to implement this agreement. However, for most -applications this will happen as a version negotiation during the channel handshake. While more -complex version negotiation is possible to implement inside the channel opening handshake, a very -simple version negotation is implemented in the [ibc-transfer module](https://github.com/cosmos/ibc-go/tree/main/modules/apps/transfer/module.go). - -Thus, a module must define its a custom packet data structure, along with a well-defined way to -encode and decode it to and from `[]byte`. - -```go -// Custom packet data defined in application module -type CustomPacketData struct { - // Custom fields ... -} - -EncodePacketData(packetData CustomPacketData) []byte { - // encode packetData to bytes -} - -DecodePacketData(encoded []byte) (CustomPacketData) { - // decode from bytes to packet data -} -``` - -Then a module must encode its packet data before sending it through IBC. - -```go -// Sending custom application packet data -data := EncodePacketData(customPacketData) -packet.Data = data -IBCChannelKeeper.SendPacket(ctx, packet) -``` - -A module receiving a packet must decode the `PacketData` into a structure it expects so that it can -act on it. - -```go -// Receiving custom application packet data (in OnRecvPacket) -packetData := DecodePacketData(packet.Data) -// handle received custom packet data -``` - -#### Packet Flow Handling - -Just as IBC expected modules to implement callbacks for channel handshakes, IBC also expects modules -to implement callbacks for handling the packet flow through a channel. - -Once a module A and module B are connected to each other, relayers can start relaying packets and -acknowledgements back and forth on the channel. - -![IBC packet flow diagram](https://media.githubusercontent.com/media/cosmos/ics/master/spec/ics-004-channel-and-packet-semantics/packet-state-machine.png) - -Briefly, a successful packet flow works as follows: - -1. module A sends a packet through the IBC module -2. the packet is received by module B -3. if module B writes an acknowledgement of the packet then module A will process the - acknowledgement -4. if the packet is not successfully received before the timeout, then module A processes the - packet's timeout. - -##### Sending Packets - -Modules do not send packets through callbacks, since the modules initiate the action of sending -packets to the IBC module, as opposed to other parts of the packet flow where msgs sent to the IBC -module must trigger execution on the port-bound module through the use of callbacks. Thus, to send a -packet a module simply needs to call `SendPacket` on the `IBCChannelKeeper`. - -```go -// retrieve the dynamic capability for this channel -channelCap := scopedKeeper.GetCapability(ctx, channelCapName) -// Sending custom application packet data -data := EncodePacketData(customPacketData) -packet.Data = data -// Send packet to IBC, authenticating with channelCap -IBCChannelKeeper.SendPacket(ctx, channelCap, packet) -``` - -::: warning -In order to prevent modules from sending packets on channels they do not own, IBC expects -modules to pass in the correct channel capability for the packet's source channel. -::: - -##### Receiving Packets - -To handle receiving packets, the module must implement the `OnRecvPacket` callback. This gets -invoked by the IBC module after the packet has been proved valid and correctly processed by the IBC -keepers. Thus, the `OnRecvPacket` callback only needs to worry about making the appropriate state -changes given the packet data without worrying about whether the packet is valid or not. - -Modules may return an acknowledgement as a byte string and return it to the IBC handler. -The IBC handler will then commit this acknowledgement of the packet so that a relayer may relay the -acknowledgement back to the sender module. - -```go -OnRecvPacket( - ctx sdk.Context, - packet channeltypes.Packet, -) (res *sdk.Result, ack []byte, abort error) { - // Decode the packet data - packetData := DecodePacketData(packet.Data) - - // do application state changes based on packet data - // and return result, acknowledgement and abortErr - // Note: abortErr is only not nil if we need to abort the entire receive packet, and allow a replay of the receive. - // If the application state change failed but we do not want to replay the packet, - // simply encode this failure with relevant information in ack and return nil error - res, ack, abortErr := processPacket(ctx, packet, packetData) - - // if we need to abort the entire receive packet, return error - if abortErr != nil { - return nil, nil, abortErr - } - - // Encode the ack since IBC expects acknowledgement bytes - ackBytes := EncodeAcknowledgement(ack) - - return res, ackBytes, nil -} -``` - -::: warning -`OnRecvPacket` should **only** return an error if we want the entire receive packet execution -(including the IBC handling) to be reverted. This will allow the packet to be replayed in the case -that some mistake in the relaying caused the packet processing to fail. - -If some application-level error happened while processing the packet data, in most cases, we will -not want the packet processing to revert. Instead, we may want to encode this failure into the -acknowledgement and finish processing the packet. This will ensure the packet cannot be replayed, -and will also allow the sender module to potentially remediate the situation upon receiving the -acknowledgement. An example of this technique is in the `ibc-transfer` module's -[`OnRecvPacket`](https://github.com/cosmos/ibc-go/tree/main/modules/apps/transfer/module.go). -::: - -### Acknowledgements - -Modules may commit an acknowledgement upon receiving and processing a packet in the case of synchronous packet processing. -In the case where a packet is processed at some later point after the packet has been received (asynchronous execution), the acknowledgement -will be written once the packet has been processed by the application which may be well after the packet receipt. - -NOTE: Most blockchain modules will want to use the synchronous execution model in which the module processes and writes the acknowledgement -for a packet as soon as it has been received from the IBC module. - -This acknowledgement can then be relayed back to the original sender chain, which can take action -depending on the contents of the acknowledgement. - -Just as packet data was opaque to IBC, acknowledgements are similarly opaque. Modules must pass and -receive acknowledegments with the IBC modules as byte strings. - -Thus, modules must agree on how to encode/decode acknowledgements. The process of creating an -acknowledgement struct along with encoding and decoding it, is very similar to the packet data -example above. [ICS 04](https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope) -specifies a recommended format for acknowledgements. This acknowledgement type can be imported from -[channel types](https://github.com/cosmos/ibc-go/tree/main/modules/core/04-channel/types). - -While modules may choose arbitrary acknowledgement structs, a default acknowledgement types is provided by IBC [here](https://github.com/cosmos/ibc-go/blob/main/proto/ibc/core/channel/v1/channel.proto): - -```proto -// Acknowledgement is the recommended acknowledgement format to be used by -// app-specific protocols. -// NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental -// conflicts with other protobuf message formats used for acknowledgements. -// The first byte of any message with this format will be the non-ASCII values -// `0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: -// https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#acknowledgement-envelope -message Acknowledgement { - // response contains either a result or an error and must be non-empty - oneof response { - bytes result = 21; - string error = 22; - } -} -``` - -#### Acknowledging Packets - -After a module writes an acknowledgement, a relayer can relay back the acknowledgement to the sender module. The sender module can -then process the acknowledgement using the `OnAcknowledgementPacket` callback. The contents of the -acknowledgement is entirely upto the modules on the channel (just like the packet data); however, it -may often contain information on whether the packet was successfully processed along -with some additional data that could be useful for remediation if the packet processing failed. - -Since the modules are responsible for agreeing on an encoding/decoding standard for packet data and -acknowledgements, IBC will pass in the acknowledgements as `[]byte` to this callback. The callback -is responsible for decoding the acknowledgement and processing it. - -```go -OnAcknowledgementPacket( - ctx sdk.Context, - packet channeltypes.Packet, - acknowledgement []byte, -) (*sdk.Result, error) { - // Decode acknowledgement - ack := DecodeAcknowledgement(acknowledgement) - - // process ack - res, err := processAck(ack) - return res, err -} -``` - -#### Timeout Packets - -If the timeout for a packet is reached before the packet is successfully received or the -counterparty channel end is closed before the packet is successfully received, then the receiving -chain can no longer process it. Thus, the sending chain must process the timeout using -`OnTimeoutPacket` to handle this situation. Again the IBC module will verify that the timeout is -indeed valid, so our module only needs to implement the state machine logic for what to do once a -timeout is reached and the packet can no longer be received. - -```go -OnTimeoutPacket( - ctx sdk.Context, - packet channeltypes.Packet, -) (*sdk.Result, error) { - // do custom timeout logic -} -``` - -### Routing - -As mentioned above, modules must implement the IBC module interface (which contains both channel -handshake callbacks and packet handling callbacks). The concrete implementation of this interface -must be registered with the module name as a route on the IBC `Router`. - -```go -// app.go -func NewApp(...args) *App { -// ... - -// Create static IBC router, add module routes, then set and seal it -ibcRouter := port.NewRouter() - -ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule) -// Note: moduleCallbacks must implement IBCModule interface -ibcRouter.AddRoute(moduleName, moduleCallbacks) - -// Setting Router will finalize all routes by sealing router -// No more routes can be added -app.IBCKeeper.SetRouter(ibcRouter) -``` - -## Working Example - -For a real working example of an IBC application, you can look through the `ibc-transfer` module -which implements everything discussed above. - -Here are the useful parts of the module to look at: - -[Binding to transfer -port](https://github.com/cosmos/ibc-go/blob/main/modules/apps/transfer/types/genesis.go) - -[Sending transfer -packets](https://github.com/cosmos/ibc-go/blob/main/modules/apps/transfer/keeper/relay.go) - -[Implementing IBC -callbacks](https://github.com/cosmos/ibc-go/blob/main/modules/apps/transfer/module.go) - -## Next {hide} - -Learn about [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/intro.md) {hide} diff --git a/docs/ibc/integration.md b/docs/ibc/integration.md deleted file mode 100644 index f35da72fc23e..000000000000 --- a/docs/ibc/integration.md +++ /dev/null @@ -1,252 +0,0 @@ - - -# Integration - -Learn how to integrate IBC to your application and send data packets to other chains. {synopsis} - -This document outlines the required steps to integrate and configure the [IBC -module](https://github.com/cosmos/ibc-go/tree/main/modules/core) to your Cosmos SDK application and -send fungible token transfers to other chains. - -## Integrating the IBC module - -Integrating the IBC module to your Cosmos SDK-based application is straighforward. The general changes can be summarized in the following steps: - -* Add required modules to the `module.BasicManager` -* Define additional `Keeper` fields for the new modules on the `App` type -* Add the module's `StoreKeys` and initialize their `Keepers` -* Set up corresponding routers and routes for the `ibc` and `evidence` modules -* Add the modules to the module `Manager` -* Add modules to `Begin/EndBlockers` and `InitGenesis` -* Update the module `SimulationManager` to enable simulations - -### Module `BasicManager` and `ModuleAccount` permissions - -The first step is to add the following modules to the `BasicManager`: `x/capability`, `x/ibc`, -`x/evidence` and `x/ibc-transfer`. After that, we need to grant `Minter` and `Burner` permissions to -the `ibc-transfer` `ModuleAccount` to mint and burn relayed tokens. - -```go -// app.go -var ( - - ModuleBasics = module.NewBasicManager( - // ... - capability.AppModuleBasic{}, - ibc.AppModuleBasic{}, - evidence.AppModuleBasic{}, - transfer.AppModuleBasic{}, // i.e ibc-transfer module - ) - - // module account permissions - maccPerms = map[string][]string{ - // other module accounts permissions - // ... - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, -) -``` - -### Application fields - -Then, we need to register the `Keepers` as follows: - -```go -// app.go -type App struct { - // baseapp, keys and subspaces definitions - - // other keepers - // ... - IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly - EvidenceKeeper evidencekeeper.Keeper // required to set up the client misbehaviour route - TransferKeeper ibctransferkeeper.Keeper // for cross-chain fungible token transfers - - // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - - /// ... - /// module and simulation manager definitions -} -``` - -### Configure the `Keepers` - -During initialization, besides initializing the IBC `Keepers` (for the `x/ibc`, and -`x/ibc-transfer` modules), we need to grant specific capabilities through the capability module -`ScopedKeepers` so that we can authenticate the object-capability permissions for each of the IBC -channels. - -```go -func NewApp(...args) *App { - // define codecs and baseapp - - // add capability keeper and ScopeToModule for ibc module - app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) - - // grant capabilities for the ibc and ibc-transfer modules - scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) - scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) - - // ... other modules keepers - - // Create IBC Keeper - app.IBCKeeper = ibckeeper.NewKeeper( - appCodec, keys[ibchost.StoreKey], app.StakingKeeper, scopedIBCKeeper, - ) - - // Create Transfer Keepers - app.TransferKeeper = ibctransferkeeper.NewKeeper( - appCodec, keys[ibctransfertypes.StoreKey], - app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper, - app.AccountKeeper, app.BankKeeper, scopedTransferKeeper, - ) - transferModule := transfer.NewAppModule(app.TransferKeeper) - - // Create evidence Keeper for to register the IBC light client misbehaviour evidence route - evidenceKeeper := evidencekeeper.NewKeeper( - appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper, - ) - - // .. continues -} -``` - -### Register `Routers` - -IBC needs to know which module is bound to which port so that it can route packets to the -appropriate module and call the appropriate callbacks. The port to module name mapping is handled by -IBC's port `Keeper`. However, the mapping from module name to the relevant callbacks is accomplished -by the port -[`Router`](https://github.com/cosmos/ibc-go/blob/main/modules/core/05-port/types/router.go) on the -IBC module. - -Adding the module routes allows the IBC handler to call the appropriate callback when processing a -channel handshake or a packet. - -The second `Router` that is required is the evidence module router. This router handles genenal -evidence submission and routes the business logic to each registered evidence handler. In the case -of IBC, it is required to submit evidence for [light client -misbehaviour](https://github.com/cosmos/ics/tree/master/spec/ics-002-client-semantics#misbehaviour) -in order to freeze a client and prevent further data packets from being sent/received. - -Currently, a `Router` is static so it must be initialized and set correctly on app initialization. -Once the `Router` has been set, no new routes can be added. - -```go -// app.go -func NewApp(...args) *App { - // .. continuation from above - - // Create static IBC router, add ibc-tranfer module route, then set and seal it - ibcRouter := port.NewRouter() - ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule) - // Setting Router will finalize all routes by sealing router - // No more routes can be added - app.IBCKeeper.SetRouter(ibcRouter) - - // create static Evidence routers - - evidenceRouter := evidencetypes.NewRouter(). - // add IBC ClientMisbehaviour evidence handler - AddRoute(ibcclient.RouterKey, ibcclient.HandlerClientMisbehaviour(app.IBCKeeper.ClientKeeper)) - - // Setting Router will finalize all routes by sealing router - // No more routes can be added - evidenceKeeper.SetRouter(evidenceRouter) - - // set the evidence keeper from the section above - app.EvidenceKeeper = *evidenceKeeper - - // .. continues -``` - -### Module Managers - -In order to use IBC, we need to add the new modules to the module `Manager` and to the `SimulationManager` in case your application supports [simulations](./../building-modules/simulator.md). - -```go -// app.go -func NewApp(...args) *App { - // .. continuation from above - - app.mm = module.NewManager( - // other modules - // ... - capability.NewAppModule(appCodec, *app.CapabilityKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - ibc.NewAppModule(app.IBCKeeper), - transferModule, - ) - - // ... - - app.sm = module.NewSimulationManager( - // other modules - // ... - capability.NewAppModule(appCodec, *app.CapabilityKeeper), - evidence.NewAppModule(app.EvidenceKeeper), - ibc.NewAppModule(app.IBCKeeper), - transferModule, - ) - - // .. continues -``` - -### Application ABCI Ordering - -One addition from IBC is the concept of `HistoricalEntries` which are stored on the staking module. -Each entry contains the historical information for the `Header` and `ValidatorSet` of this chain which is stored -at each height during the `BeginBlock` call. The historical info is required to introspect the -past historical info at any given height in order to verify the light client `ConsensusState` during the -connection handhake. - -The IBC module also has -[`BeginBlock`](https://github.com/cosmos/ibc-go/blob/main/modules/core/02-client/abci.go) logic as -well. This is optional as it is only required if your application uses the [localhost -client](https://github.com/cosmos/ibc/tree/master/spec/client/ics-009-loopback-client) to connect two -different modules from the same chain. - -::: tip -Only register the ibc module to the `SetOrderBeginBlockers` if your application will use the -localhost (_aka_ loopback) client. -::: - -```go -// app.go -func NewApp(...args) *App { - // .. continuation from above - - // add evidence, staking and ibc modules to BeginBlockers - app.mm.SetOrderBeginBlockers( - // other modules ... - evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName, - ) - - // ... - - // NOTE: Capability module must occur first so that it can initialize any capabilities - // so that other modules that want to create or claim capabilities afterwards in InitChain - // can do so safely. - app.mm.SetOrderInitGenesis( - capabilitytypes.ModuleName, - // other modules ... - ibchost.ModuleName, evidencetypes.ModuleName, ibctransfertypes.ModuleName, - ) - - // .. continues -``` - -::: warning -**IMPORTANT**: The capability module **must** be declared first in `SetOrderInitGenesis` -::: - -That's it! You have now wired up the IBC module and are now able to send fungible tokens across -different chains. If you want to have a broader view of the changes take a look into the Cosmos SDK's -[`SimApp`](https://github.com/cosmos/ibc-go/blob/main/testing/simapp/app.go). - -## Next {hide} - -Learn about how to create [custom IBC modules](./custom.md) for your application {hide} diff --git a/docs/ibc/overview.md b/docs/ibc/overview.md deleted file mode 100644 index 1fb9ee43fabf..000000000000 --- a/docs/ibc/overview.md +++ /dev/null @@ -1,155 +0,0 @@ - - -# IBC Overview - -Learn what IBC is, its components, and use cases. {synopsis} - -## What is the Inter-Blockchain Communication Protocol (IBC) - -The Inter-Blockchain Communication protocol (IBC) allows blockchains to talk to each other. The backbone of the Cosmos ecosystem, IBC handles transport across different sovereign blockchains. This end-to-end, connection-oriented, stateful protocol provides reliable, ordered, and authenticated communication between heterogeneous blockchains. - -This IBC implementation in Golang is built as a Cosmos SDK module. This document is a guide for developers who want to write their own IBC apps for custom use cases. - -The modular design of the IBC protocol means that IBC app developers do not require in-depth knowledge of the low-level details of clients, connections, and proof verification. This brief explanation of the lower levels of the stack is provided so that app developers can gain a high-level understanding of the IBC protocol. - -The abstraction layer details on channels and ports are relevant for app developers. You can define your own custom packets and IBCModule callbacks. - -The following requirements must be met for a module to interact over IBC: - -* Bind to one or more ports - -* Define the packet data - -* Define optional acknowledgement structures and methods to encode and decode them - -* Implement the IBCModule interface - -## Components Overview - -This section describes the IBC components and links to the repos. - -### [Clients](https://github.com/cosmos/ibc-go/blob/main/modules/core/02-client) - -IBC clients are light clients that are identified by a unique client id. IBC clients track the consensus states of other blockchains and the proof specs of those blockchains that are required to properly verify proofs against the client's consensus state. A client can be associated with any number of connections to multiple chains. The supported IBC clients are: - -* [Solo Machine light client](https://github.com/cosmos/ibc-go/blob/main/modules/light-clients/06-solomachine): devices such as phones, browsers, or laptops. -* [Tendermint light client](https://github.com/cosmos/ibc-go/blob/main/modules/light-clients/07-tendermint): The default for Cosmos SDK-based chains. -* [Localhost (loopback) client](https://github.com/cosmos/ibc-go/blob/main/modules/light-clients/09-localhost): Useful for testing, simulation, and relaying packets to modules on the same application. - -### [Connections](https://github.com/cosmos/ibc-go/blob/main/modules/core/03-connection) - -Connections encapsulate two `ConnectionEnd` objects on two separate blockchains. Each `ConnectionEnd` is associated with a client of the other blockchain (the counterparty blockchain). The connection handshake is responsible for verifying that the light clients on each chain are correct for their respective counterparties. Connections, once established, are responsible for facilitating all cross-chain verification of IBC state. A connection can be associated with any number of channels. - -### [Proofs](https://github.com/cosmos/ibc-go/blob/main/modules/core/23-commitment) and [Paths](https://github.com/cosmos/ibc-go/blob/main/modules/core/24-host) - -In IBC, blockchains do not directly pass messages to each other over the network. - -* To communicate, a blockchain commits some state to a precisely defined path reserved for a specific message type and a specific counterparty. For example, a blockchain that stores a specific connectionEnd as part of a handshake or a packet intended to be relayed to a module on the counterparty chain. - -* A relayer process monitors for updates to these paths and relays messages by submitting the data stored under the path along with a proof of that data to the counterparty chain. - -* The paths that all IBC implementations must support for committing IBC messages are defined in [ICS-24 host requirements](https://github.com/cosmos/ics/tree/master/spec/core/ics-024-host-requirements). - -* The proof format that all implementations must produce and verify is defined in [ICS-23 implementation](https://github.com/confio/ics23). - -### [Capabilities](./ocap.md) - -IBC is intended to work in execution environments where modules do not necessarily trust each other. IBC must authenticate module actions on ports and channels so that only modules with the appropriate permissions can use the channels. This security is accomplished using [dynamic capabilities](../architecture/adr-003-dynamic-capability-store.md). Upon binding to a port or creating a channel for a module, IBC returns a dynamic capability that the module must claim to use that port or channel. This binding strategy prevents other modules from using that port or channel since those modules do not own the appropriate capability. - -While this explanation is useful background information, IBC modules do not need to interact at all with these lower-level abstractions. The relevant abstraction layer for IBC application developers is that of channels and ports. - -Write your IBC applications as self-contained **modules**. A module on one blockchain can communicate with other modules on other blockchains by sending, receiving, and acknowledging packets through channels that are uniquely identified by the `(channelID, portID)` tuple. - -A useful analogy is to consider IBC modules as internet apps on a computer. A channel can then be conceptualized as an IP connection, with the IBC portID is like an IP port, and the IBC channelID is like an IP address. A single instance of an IBC module can communicate on the same port with any number of other modules and IBC correctly routes all packets to the relevant module using the `(channelID, portID)` tuple. An IBC module can also communicate with another IBC module over multiple ports by sending each `(portID<->portID)` packet stream on a different unique channel. - -### [Ports](https://github.com/cosmos/ibc-go/blob/main/modules/core/05-port) - -An IBC module can bind to any number of ports. Each port must be identified by a unique `portID`. Since IBC is designed to be secure with mutually-distrusted modules that operate on the same ledger, binding a port returns the dynamic object capability. To take action on a particular port, for example, to open a channel with its portID, a module must provide the dynamic object capability to the IBC handler. This requirement prevents a malicious module from opening channels with ports it does not own. - -IBC modules are responsible for claiming the capability that is returned on `BindPort`. - -### [Channels](https://github.com/cosmos/ibc-go/blob/main/modules/core/04-channel) - -An IBC channel can be established between two IBC ports. A port is exclusively owned by a single module. IBC packets are sent over channels. Just as IP packets contain the destination IP address, IP port, the source IP address, and source IP port, IBC packets contain the destination portID, channelID, the source portID, and channelID. The IBC packets enable IBC to correctly route the packets to the destination module, while also allowing modules receiving packets to know the sender module. - -* A channel can be `ORDERED` so that packets from a sending module must be processed by the receiving module in the order they were sent. - -* Recommended, a channel may be `UNORDERED` so that packets from a sending module are processed in the order they arrive, which may not be the order the packets were sent. - -Modules may choose which channels they wish to communicate over with. IBC expects modules to implement callbacks that are called during the channel handshake. These callbacks may do custom channel initialization logic. If an error is returned, the channel handshake fails. By returning errors on callbacks, modules can programmatically reject and accept channels. - -The channel handshake is a 4-step handshake. Briefly, if a given chain A wants to open a channel with chain B using an already established connection: - -1. Chain A sends a `ChanOpenInit` message to signal a channel initialization attempt with chain B. -2. Chain B sends a `ChanOpenTry` message to try opening the channel on chain A. -3. Chain A sends a `ChanOpenAck` message to mark its channel end status as open. -4. Chain B sends a `ChanOpenConfirm` message to mark its channel end status as open. - -If all of these actions happen successfully, the channel is open on both sides. At each step in the handshake, the module associated with the `ChannelEnd` executes its callback for that step of the handshake. So on `ChanOpenInit`, the module on chain A has its callback `OnChanOpenInit` executed. - -Just as ports came with dynamic capabilities, channel initialization returns a dynamic capability that the module **must** claim so that they can pass in a capability to authenticate channel actions like sending packets. The channel capability is passed into the callback on the first parts of the handshake: `OnChanOpenInit` on the initializing chain or `OnChanOpenTry` on the other chain. - -### [Packets](https://github.com/cosmos/ibc-go/blob/main/modules/core/04-channel) - -Modules communicate with each other by sending packets over IBC channels. All IBC packets contain: - -* Destination `portID` - -* Destination `channelID` - -* Source `portID` - -* Source `channelID` - - These port and channels allow the modules to know the sender module of a given packet. - -* A sequence to optionally enforce ordering - -* `TimeoutTimestamp` and `TimeoutHeight` - - When non-zero, these timeout values determine the deadline before which the receiving module must process a packet. - - If the timeout passes without the packet being successfully received, the sending module can timeout the packet and take appropriate actions. - -Modules send custom application data to each other inside the `Data []byte` field of the IBC packet. Packet data is completely opaque to IBC handlers. The sender module must encode their application-specific packet information into the `Data` field of packets. The receiver module must decode that `Data` back to the original application data. - -### [Receipts and Timeouts](https://github.com/cosmos/ibc-go/blob/main/modules/core/04-channel) - -Since IBC works over a distributed network and relies on potentially faulty relayers to relay messages between ledgers, IBC must handle the case where a packet does not get sent to its destination in a timely manner or at all. Packets must specify a timeout height or timeout timestamp after which a packet can no longer be successfully received on the destination chain. - -If the timeout is reached, then a proof-of-packet timeout can be submitted to the original chain which can then perform application-specific logic to timeout the packet, perhaps by rolling back the packet send changes (refunding senders any locked funds, and so on). - -In ORDERED channels, a timeout of a single packet in the channel closes the channel. If packet sequence `n` times out, then no packet at sequence `k > n` can be successfully received without violating the contract of ORDERED channels that packets are processed in the order that they are sent. Since ORDERED channels enforce this invariant, a proof that sequence `n` hasn't been received on the destination chain by packet `n`'s specified timeout is sufficient to timeout packet `n` and close the channel. - -In the UNORDERED case, packets can be received in any order. IBC writes a packet receipt for each sequence it has received in the UNORDERED channel. This receipt contains no information and is simply a marker intended to signify that the UNORDERED channel has received a packet at the specified sequence. To timeout a packet on an UNORDERED channel, proof that a packet receipt does not exist is required for the packet's sequence by the specified timeout. Of course, timing out a packet on an UNORDERED channel triggers the application specific timeout logic for that packet, and does not close the channel. - -For this reason, most modules that use UNORDERED channels are recommended as they require less liveness guarantees to function effectively for users of that channel. - -### [Acknowledgements](https://github.com/cosmos/ibc-go/blob/main/modules/core/04-channel) - -Modules also write application-specific acknowledgements when processing a packet. Acknowledgements can be done: - -* Synchronously on `OnRecvPacket` if the module processes packets as soon as they are received from IBC module. - -* Asynchronously if module processes packets at some later point after receiving the packet. - -This acknowledgement data is opaque to IBC much like the packet `Data` and is treated by IBC as a simple byte string `[]byte`. The receiver modules must encode their acknowledgement so that the sender module can decode it correctly. How the acknowledgement is encoded should be decided through version negotiation during the channel handshake. - -The acknowledgement can encode whether the packet processing succeeded or failed, along with additional information that allows the sender module to take appropriate action. - -After the acknowledgement has been written by the receiving chain, a relayer relays the acknowledgement back to the original sender module which then executes application-specific acknowledgment logic using the contents of the acknowledgement. This acknowledgement can involve rolling back packet-send changes in the case of a failed acknowledgement (refunding senders). - -After an acknowledgement is received successfully on the original sender the chain, the IBC module deletes the corresponding packet commitment as it is no longer needed. - -## Further Readings and Specs - -To learn more about IBC, check out the following specifications: - -* [IBC specs](https://github.com/cosmos/ibc/tree/master/spec) -* [IBC protocol on the Cosmos SDK](https://github.com/cosmos/ibc-go/tree/main/docs) - -## Next {hide} - -Learn about how to [integrate](./integration.md) IBC to your application {hide} diff --git a/docs/ibc/proposals.md b/docs/ibc/proposals.md deleted file mode 100644 index d82609262e42..000000000000 --- a/docs/ibc/proposals.md +++ /dev/null @@ -1,42 +0,0 @@ - - -# Governance Proposals - -In uncommon situations, a highly valued client may become frozen due to uncontrollable -circumstances. A highly valued client might have hundreds of channels being actively used. -Some of those channels might have a significant amount of locked tokens used for ICS 20. - -If the one third of the validator set of the chain the client represents decides to collude, -they can sign off on two valid but conflicting headers each signed by the other one third -of the honest validator set. The light client can now be updated with two valid, but conflicting -headers at the same height. The light client cannot know which header is trustworthy and therefore -evidence of such misbehaviour is likely to be submitted resulting in a frozen light client. - -Frozen light clients cannot be updated under any circumstance except via a governance proposal. -Since a quorum of validators can sign arbitrary state roots which may not be valid executions -of the state machine, a governance proposal has been added to ease the complexity of unfreezing -or updating clients which have become "stuck". Without this mechanism, validator sets would need -to construct a state root to unfreeze the client. Unfreezing clients, re-enables all of the channels -built upon that client. This may result in recovery of otherwise lost funds. - -Tendermint light clients may become expired if the trusting period has passed since their -last update. This may occur if relayers stop submitting headers to update the clients. - -An unplanned upgrade by the counterparty chain may also result in expired clients. If the counterparty -chain undergoes an unplanned upgrade, there may be no commitment to that upgrade signed by the validator -set before the chain-id changes. In this situation, the validator set of the last valid update for the -light client is never expected to produce another valid header since the chain-id has changed, which will -ultimately lead the on-chain light client to become expired. - -In the case that a highly valued light client is frozen, expired, or rendered non-updateable, a -governance proposal may be submitted to update this client, known as the subject client. The -proposal includes the client identifier for the subject, the client identifier for a substitute -client, and an initial height to reference the substitute client from. Light client implementations -may implement custom updating logic, but in most cases, the subject will be updated with information -from the substitute client, if the proposal passes. The substitute client is used as a "stand in" -while the subject is on trial. It is best practice to create a substitute client *after* the subject -has become frozen to avoid the substitute from also becoming frozen. An active substitute client -allows headers to be submitted during the voting period to prevent accidental expiry once the proposal -passes. diff --git a/docs/ibc/relayer.md b/docs/ibc/relayer.md deleted file mode 100644 index b25f95df3bfa..000000000000 --- a/docs/ibc/relayer.md +++ /dev/null @@ -1,47 +0,0 @@ - - -# Relayer - -## Prerequisites Readings - -* [IBC Overview](./overview.md) {prereq} -* [Events](https://github.com/cosmos/cosmos-sdk/blob/master/docs/core/events.md) {prereq} - -## Events - -Events are emitted for every transaction processed by the base application to indicate the execution -of some logic clients may want to be aware of. This is extremely useful when relaying IBC packets. -Any message that uses IBC will emit events for the corresponding TAO logic executed as defined in -the [IBC events spec](https://github.com/cosmos/ibc-go/blob/main/modules/core/spec/06_events.md). - -In the Cosmos SDK, it can be assumed that for every message there is an event emitted with the type `message`, -attribute key `action`, and an attribute value representing the type of message sent -(`channel_open_init` would be the attribute value for `MsgChannelOpenInit`). If a relayer queries -for transaction events, it can split message events using this event Type/Attribute Key pair. - -The Event Type `message` with the Attribute Key `module` may be emitted multiple times for a single -message due to application callbacks. It can be assumed that any TAO logic executed will result in -a module event emission with the attribute value `ibc_` (02-client emits `ibc_client`). - -### Subscribing with Tendermint - -Calling the Tendermint RPC method `Subscribe` via [Tendermint's Websocket](https://docs.tendermint.com/master/rpc/) will return events using -Tendermint's internal representation of them. Instead of receiving back a list of events as they -were emitted, Tendermint will return the type `map[string][]string` which maps a string in the -form `.` to `attribute_value`. This causes extraction of the event -ordering to be non-trivial, but still possible. - -A relayer should use the `message.action` key to extract the number of messages in the transaction -and the type of IBC transactions sent. For every IBC transaction within the string array for -`message.action`, the necessary information should be extracted from the other event fields. If -`send_packet` appears at index 2 in the value for `message.action`, a relayer will need to use the -value at index 2 of the key `send_packet.packet_sequence`. This process should be repeated for each -piece of information needed to relay a packet. - -## Example Implementations - -* [Golang Relayer](https://github.com/iqlusioninc/relayer) -* [Hermes](https://github.com/informalsystems/ibc-rs/tree/master/relayer) -* [Typescript Relayer](https://github.com/confio/ts-relayer) diff --git a/docs/ibc/upgrades/README.md b/docs/ibc/upgrades/README.md deleted file mode 100644 index 3e482488e525..000000000000 --- a/docs/ibc/upgrades/README.md +++ /dev/null @@ -1,14 +0,0 @@ - - -# Upgrading IBC Chains Overview - -This directory contains information on how to upgrade an IBC chain without breaking counterparty clients and connections. - -IBC-connnected chains must be able to upgrade without breaking connections to other chains. Otherwise there would be a massive disincentive towards upgrading and disrupting high-value IBC connections, thus preventing chains in the IBC ecosystem from evolving and improving. Many chain upgrades may be irrelevant to IBC, however some upgrades could potentially break counterparty clients if not handled correctly. Thus, any IBC chain that wishes to perform a IBC-client-breaking upgrade must perform an IBC upgrade in order to allow counterparty clients to securely upgrade to the new light client. - -1. The [quick-guide](./quick-guide.md) describes how IBC-connected chains can perform client-breaking upgrades and how relayers can securely upgrade counterparty clients using the Cosmos SDK. -2. The [developer-guide](./developer-guide.md) is a guide for developers intending to develop IBC client implementations with upgrade functionality. diff --git a/docs/ibc/upgrades/developer-guide.md b/docs/ibc/upgrades/developer-guide.md deleted file mode 100644 index d41b3346d4f7..000000000000 --- a/docs/ibc/upgrades/developer-guide.md +++ /dev/null @@ -1,50 +0,0 @@ - - -# IBC Client Developer Guide to Upgrades - -Learn how to implement upgrade functionality for your custom IBC client. {synopsis} - -As mentioned in the [README](./README.md), it is vital that high-value IBC clients can upgrade along with their underlying chains to avoid disruption to the IBC ecosystem. Thus, IBC client developers will want to implement upgrade functionality to enable clients to maintain connections and channels even across chain upgrades. - -The IBC protocol allows client implementations to provide a path to upgrading clients given the upgraded client state, upgraded consensus state and proofs for each. - -```go -// Upgrade functions -// NOTE: proof heights are not included as upgrade to a new revision is expected to pass only on the last -// height committed by the current revision. Clients are responsible for ensuring that the planned last -// height of the current revision is somehow encoded in the proof verification process. -// This is to ensure that no premature upgrades occur, since upgrade plans committed to by the counterparty -// may be cancelled or modified before the last planned height. -VerifyUpgradeAndUpdateState( - ctx sdk.Context, - cdc codec.BinaryCodec, - store sdk.KVStore, - newClient ClientState, - newConsState ConsensusState, - proofUpgradeClient, - proofUpgradeConsState []byte, -) (upgradedClient ClientState, upgradedConsensus ConsensusState, err error) -``` - -Note that the clients should have prior knowledge of the merkle path that the upgraded client and upgraded consensus states will use. The height at which the upgrade has occurred should also be encoded in the proof. The Tendermint client implementation accomplishes this by including an `UpgradePath` in the ClientState itself, which is used along with the upgrade height to construct the merkle path under which the client state and consensus state are committed. - -Developers must ensure that the `UpgradeClientMsg` does not pass until the last height of the old chain has been committed, and after the chain upgrades, the `UpgradeClientMsg` should pass once and only once on all counterparty clients. - -Developers must ensure that the new client adopts all of the new Client parameters that must be uniform across every valid light client of a chain (chain-chosen parameters), while maintaining the Client parameters that are customizable by each individual client (client-chosen parameters) from the previous version of the client. - -Upgrades must adhere to the IBC Security Model. IBC does not rely on the assumption of honest relayers for correctness. Thus users should not have to rely on relayers to maintain client correctness and security (though honest relayers must exist to maintain relayer liveness). While relayers may choose any set of client parameters while creating a new `ClientState`, this still holds under the security model since users can always choose a relayer-created client that suits their security and correctness needs or create a Client with their desired parameters if no such client exists. - -However, when upgrading an existing client, one must keep in mind that there are already many users who depend on this client's particular parameters. We cannot give the upgrading relayer free choice over these parameters once they have already been chosen. This would violate the security model since users who rely on the client would have to rely on the upgrading relayer to maintain the same level of security. Thus, developers must make sure that their upgrade mechanism allows clients to upgrade the chain-specified parameters whenever a chain upgrade changes these parameters (examples in the Tendermint client include `UnbondingPeriod`, `ChainID`, `UpgradePath`, etc.), while ensuring that the relayer submitting the `UpgradeClientMsg` cannot alter the client-chosen parameters that the users are relying upon (examples in Tendermint client include `TrustingPeriod`, `TrustLevel`, `MaxClockDrift`, etc). - -Developers should maintain the distinction between Client parameters that are uniform across every valid light client of a chain (chain-chosen parameters), and Client parameters that are customizable by each individual client (client-chosen parameters); since this distinction is necessary to implement the `ZeroCustomFields` method in the `ClientState` interface: - -```go -// Utility function that zeroes out any client customizable fields in client state -// Ledger enforced fields are maintained while all custom fields are zero values -// Used to verify upgrades -ZeroCustomFields() ClientState -``` - -Counterparty clients can upgrade securely by using all of the chain-chosen parameters from the chain-committed `UpgradedClient` and preserving all of the old client-chosen parameters. This enables chains to securely upgrade without relying on an honest relayer, however it can in some cases lead to an invalid final `ClientState` if the new chain-chosen parameters clash with the old client-chosen parameter. This can happen in the Tendermint client case if the upgrading chain lowers the `UnbondingPeriod` (chain-chosen) to a duration below that of a counterparty client's `TrustingPeriod` (client-chosen). Such cases should be clearly documented by developers, so that chains know which upgrades should be avoided to prevent this problem. The final upgraded client should also be validated in `VerifyUpgradeAndUpdateState` before returning to ensure that the client does not upgrade to an invalid `ClientState`. diff --git a/docs/ibc/upgrades/quick-guide.md b/docs/ibc/upgrades/quick-guide.md deleted file mode 100644 index 7a479a58bc18..000000000000 --- a/docs/ibc/upgrades/quick-guide.md +++ /dev/null @@ -1,54 +0,0 @@ - - -# How to Upgrade IBC Chains and their Clients - -Learn how to upgrade your chain and counterparty clients. {synopsis} - -The information in this doc for upgrading chains is relevant to Cosmos SDK chains. However, the guide for counterparty clients is relevant to any Tendermint client that enables upgrades. - -## IBC Client Breaking Upgrades - -IBC-connected chains must perform an IBC upgrade if their upgrade will break counterparty IBC clients. The current IBC protocol supports upgrading tendermint chains for a specific subset of IBC-client-breaking upgrades. Here is the exhaustive list of IBC client-breaking upgrades and whether the IBC protocol currently supports such upgrades. - -IBC currently does **NOT** support unplanned upgrades. All of the following upgrades must be planned and committed to in advance by the upgrading chain, in order for counterparty clients to maintain their connections securely. - -Note: Since upgrades are only implemented for Tendermint clients, this doc only discusses upgrades on Tendermint chains that would break counterparty IBC Tendermint Clients. - -1. Changing the Chain-ID: **Supported** -2. Changing the UnbondingPeriod: **Partially Supported**, chains may increase the unbonding period with no issues. However, decreasing the unbonding period may irreversibly break some counterparty clients. Thus, it is **not recommended** that chains reduce the unbonding period. -3. Changing the height (resetting to 0): **Supported**, so long as chains remember to increment the revision number in their chain-id. -4. Changing the ProofSpecs: **Supported**, this should be changed if the proof structure needed to verify IBC proofs is changed across the upgrade. Ex: Switching from an IAVL store, to a SimpleTree Store -5. Changing the UpgradePath: **Supported**, this might involve changing the key under which upgraded clients and consensus states are stored in the upgrade store, or even migrating the upgrade store itself. -6. Migrating the IBC store: **Unsupported**, as the IBC store location is negotiated by the connection. -7. Upgrading to a backwards compatible version of IBC: Supported -8. Upgrading to a non-backwards compatible version of IBC: **Unsupported**, as IBC version is negotiated on connection handshake. -9. Changing the Tendermint LightClient algorithm: **Partially Supported**. Changes to the light client algorithm that do not change the ClientState or ConsensusState struct may be supported, provided that the counterparty is also upgraded to support the new light client algorithm. Changes that require updating the ClientState and ConsensusState structs themselves are theoretically possible by providing a path to translate an older ClientState struct into the new ClientState struct; however this is not currently implemented. - -## Step-by-Step Upgrade Process for Cosmos SDK chains - -If the IBC-connected chain is conducting an upgrade that will break counterparty clients, it must ensure that the upgrade is first supported by IBC using the list above and then execute the upgrade process described below in order to prevent counterparty clients from breaking. - -1. Create an `UpgradeProposal` with an IBC ClientState in the `UpgradedClientState` field and a `UpgradePlan` in the `Plan` field. Note that the proposal `Plan` must specify an upgrade height **only** (no upgrade time), and the `ClientState` should only include the fields common to all valid clients and zero out any client-customizable fields (such as TrustingPeriod). -2. Vote on and pass the `UpgradeProposal` - -Upon the `UpgradeProposal` passing, the upgrade module will commit the UpgradedClient under the key: `upgrade/UpgradedIBCState/{upgradeHeight}/upgradedClient`. On the block right before the upgrade height, the upgrade module will also commit an initial consensus state for the next chain under the key: `upgrade/UpgradedIBCState/{upgradeHeight}/upgradedConsState`. - -Once the chain reaches the upgrade height and halts, a relayer can upgrade the counterparty clients to the last block of the old chain. They can then submit the proofs of the `UpgradedClient` and `UpgradedConsensusState` against this last block and upgrade the counterparty client. - -## Step-by-Step Upgrade Process for Relayers Upgrading Counterparty Clients - -Once the upgrading chain has committed to upgrading, relayers must wait till the chain halts at the upgrade height before upgrading counterparty clients. This is because chains may reschedule or cancel upgrade plans before they occur. Thus, relayers must wait till the chain reaches the upgrade height and halts before they can be sure the upgrade will take place. - -Thus, the upgrade process for relayers trying to upgrade the counterparty clients is as follows: - -1. Wait for the upgrading chain to reach the upgrade height and halt -2. Query a full node for the proofs of `UpgradedClient` and `UpgradedConsensusState` at the last height of the old chain. -3. Update the counterparty client to the last height of the old chain using the `UpdateClient` msg. -4. Submit an `UpgradeClient` msg to the counterparty chain with the `UpgradedClient`, `UpgradedConsensusState` and their respective proofs. -5. Submit an `UpdateClient` msg to the counterparty chain with a header from the new upgraded chain. - -The Tendermint client on the counterparty chain will verify that the upgrading chain did indeed commit to the upgraded client and upgraded consensus state at the upgrade height (since the upgrade height is included in the key). If the proofs are verified against the upgrade height, then the client will upgrade to the new client while retaining all of its client-customized fields. Thus, it will retain its old TrustingPeriod, TrustLevel, MaxClockDrift, etc; while adopting the new chain-specified fields such as UnbondingPeriod, ChainId, UpgradePath, etc. Note, this can lead to an invalid client since the old client-chosen fields may no longer be valid given the new chain-chosen fields. Upgrading chains should try to avoid these situations by not altering parameters that can break old clients. For an example, see the UnbondingPeriod example in the supported upgrades section. - -The upgraded consensus state will serve purely as a basis of trust for future `UpdateClientMsgs` and will not contain a consensus root to perform proof verification against. Thus, relayers must submit an `UpdateClientMsg` with a header from the new chain so that the connection can be used for proof verification again. diff --git a/docs/intro/overview.md b/docs/intro/overview.md index 792c269f395c..859f0acce9f7 100644 --- a/docs/intro/overview.md +++ b/docs/intro/overview.md @@ -8,11 +8,11 @@ order: 1 The [Cosmos SDK](https://github.com/cosmos/cosmos-sdk) is an open-source framework for building multi-asset public Proof-of-Stake (PoS) blockchains, like the Cosmos Hub, as well as permissioned Proof-of-Authority (PoA) blockchains. Blockchains built with the Cosmos SDK are generally referred to as **application-specific blockchains**. -The goal of the Cosmos SDK is to allow developers to easily create custom blockchains from scratch that can natively interoperate with other blockchains. We envision the Cosmos SDK as the npm-like framework to build secure blockchain applications on top of [Tendermint](https://github.com/tendermint/tendermint). SDK-based blockchains are built out of composable [modules](../building-modules/intro.md), most of which are open source and readily available for any developers to use. Anyone can create a module for the Cosmos SDK, and integrating already-built modules is as simple as importing them into your blockchain application. What's more, the Cosmos SDK is a capabilities-based system that allows developers to better reason about the security of interactions between modules. For a deeper look at capabilities, jump to [Object-Capability Model](../core/ocap.md). +The goal of the Cosmos SDK is to allow developers to easily create custom blockchains from scratch that can natively interoperate with other blockchains. We envision the Cosmos SDK as the npm-like framework to build secure blockchain applications on top of [Tendermint](https://github.com/tendermint/tendermint). SDK-based blockchains are built out of composable [modules](../building-modules/intro.md), most of which are open-source and readily available for any developers to use. Anyone can create a module for the Cosmos SDK, and integrating already-built modules is as simple as importing them into your blockchain application. What's more, the Cosmos SDK is a capabilities-based system that allows developers to better reason about the security of interactions between modules. For a deeper look at capabilities, jump to [Object-Capability Model](../core/ocap.md). ## What are Application-Specific Blockchains -One development paradigm in the blockchain world today is that of virtual-machine blockchains like Ethereum, where development generally revolves around building decentralised applications on top of an existing blockchain as a set of smart contracts. While smart contracts can be very good for some use cases like single-use applications (e.g. ICOs), they often fall short for building complex decentralised platforms. More generally, smart contracts can be limiting in terms of flexibility, sovereignty and performance. +One development paradigm in the blockchain world today is that of virtual-machine blockchains like Ethereum, where development generally revolves around building decentralized applications on top of an existing blockchain as a set of smart contracts. While smart contracts can be very good for some use cases like single-use applications (e.g. ICOs), they often fall short for building complex decentralized platforms. More generally, smart contracts can be limiting in terms of flexibility, sovereignty and performance. Application-specific blockchains offer a radically different development paradigm than virtual-machine blockchains. An application-specific blockchain is a blockchain customized to operate a single application: developers have all the freedom to make the design decisions required for the application to run optimally. They can also provide better sovereignty, security and performance. @@ -20,10 +20,10 @@ Learn more about [application-specific blockchains](./why-app-specific.md). ## Why the Cosmos SDK -The Cosmos SDK is the most advanced framework for building custom application-specific blockchains today. Here are a few reasons why you might want to consider building your decentralised application with the Cosmos SDK: +The Cosmos SDK is the most advanced framework for building custom application-specific blockchains today. Here are a few reasons why you might want to consider building your decentralized application with the Cosmos SDK: * The default consensus engine available within the Cosmos SDK is [Tendermint Core](https://github.com/tendermint/tendermint). Tendermint is the most (and only) mature BFT consensus engine in existence. It is widely used across the industry and is considered the gold standard consensus engine for building Proof-of-Stake systems. -* The Cosmos SDK is open source and designed to make it easy to build blockchains out of composable [modules](../../x/). As the ecosystem of open source Cosmos SDK modules grows, it will become increasingly easier to build complex decentralised platforms with it. +* The Cosmos SDK is open-source and designed to make it easy to build blockchains out of composable [modules](../../x/). As the ecosystem of open-source Cosmos SDK modules grows, it will become increasingly easier to build complex decentralized platforms with it. * The Cosmos SDK is inspired by capabilities-based security, and informed by years of wrestling with blockchain state-machines. This makes the Cosmos SDK a very secure environment to build blockchains. * Most importantly, the Cosmos SDK has already been used to build many application-specific blockchains that are already in production. Among others, we can cite [Cosmos Hub](https://hub.cosmos.network), [IRIS Hub](https://irisnet.org), [Binance Chain](https://docs.binance.org/), [Terra](https://terra.money/) or [Kava](https://www.kava.io/). [Many more](https://cosmos.network/ecosystem) are building on the Cosmos SDK. diff --git a/docs/intro/sdk-app-architecture.md b/docs/intro/sdk-app-architecture.md index 31e82aff25d4..2a6b52b2d9ec 100644 --- a/docs/intro/sdk-app-architecture.md +++ b/docs/intro/sdk-app-architecture.md @@ -36,7 +36,7 @@ The Cosmos SDK gives developers maximum flexibility to define the state of their ## Tendermint -Thanks to the Cosmos SDK, developers just have to define the state machine, and [*Tendermint*](https://tendermint.com/docs/introduction/what-is-tendermint.html) will handle replication over the network for them. +Thanks to the Cosmos SDK, developers just have to define the state machine, and [*Tendermint*](https://docs.tendermint.com/master/introduction/what-is-tendermint.html) will handle replication over the network for them. ```text ^ +-------------------------------+ ^ @@ -84,11 +84,11 @@ Note that **Tendermint only handles transaction bytes**. It has no knowledge of Here are the most important messages of the ABCI: -* `CheckTx`: When a transaction is received by Tendermint Core, it is passed to the application to check if a few basic requirements are met. `CheckTx` is used to protect the mempool of full-nodes against spam transactions. A special handler called the [`AnteHandler`](../basics/gas-fees.md#antehandler) is used to execute a series of validation steps such as checking for sufficient fees and validating the signatures. If the checks are valid, the transaction is added to the [mempool](https://docs.tendermint.com/v0.34/tendermint-core/mempool.html#mempool) and relayed to peer nodes. Note that transactions are not processed (i.e. no modification of the state occurs) with `CheckTx` since they have not been included in a block yet. -* `DeliverTx`: When a [valid block](https://docs.tendermint.com/v0.34/spec/blockchain/blockchain.html#validation) is received by Tendermint Core, each transaction in the block is passed to the application via `DeliverTx` in order to be processed. It is during this stage that the state transitions occur. The `AnteHandler` executes again along with the actual [`Msg` service](../building-modules/msg-services.md) RPC for each message in the transaction. -* `BeginBlock`/`EndBlock`: These messages are executed at the beginning and the end of each block, whether the block contains transaction or not. It is useful to trigger automatic execution of logic. Proceed with caution though, as computationally expensive loops could slow down your blockchain, or even freeze it if the loop is infinite. +* `CheckTx`: When a transaction is received by Tendermint Core, it is passed to the application to check if a few basic requirements are met. `CheckTx` is used to protect the mempool of full-nodes against spam transactions. The [middlewares](../basics/gas-fees.md#middleware) `CheckTx` are used to execute a series of validation steps such as checking for sufficient fees and validating the signatures. If the checks are valid, the transaction is added to the [mempool](https://docs.tendermint.com/v0.34/tendermint-core/mempool.html#mempool) and relayed to peer nodes. Note that transactions are not processed (i.e. no modification of the state occurs) with `CheckTx` since they have not been included in a block yet. +* `DeliverTx`: When a [valid block](https://docs.tendermint.com/v0.34/spec/blockchain/blockchain.html#validation) is received by Tendermint Core, each transaction in the block is passed to the application via `DeliverTx` in order to be processed. It is during this stage that the state transitions occur. The `middleware` executes its defined `DeliverTx`, along with the actual [`Msg` service](../building-modules/msg-services.md) RPC for each message in the transaction. +* `BeginBlock`/`EndBlock`: These messages are executed at the beginning and the end of each block, whether the block contains transactions or not. It is useful to trigger automatic execution of logic. Proceed with caution though, as computationally expensive loops could slow down your blockchain, or even freeze it if the loop is infinite. -Find a more detailed view of the ABCI methods from the [Tendermint docs](https://docs.tendermint.com/v0.34/spec/abci/abci.html#overview). +Find a more detailed view of the ABCI methods from the [Tendermint docs](https://docs.tendermint.com/v0.35/introduction/what-is-tendermint.html#abci-overview). Any application built on Tendermint needs to implement the ABCI interface in order to communicate with the underlying local Tendermint engine. Fortunately, you do not have to implement the ABCI interface. The Cosmos SDK provides a boilerplate implementation of it in the form of [baseapp](./sdk-design.md#baseapp). diff --git a/docs/intro/why-app-specific.md b/docs/intro/why-app-specific.md index 8efb70cb7f3d..e456edd1d070 100644 --- a/docs/intro/why-app-specific.md +++ b/docs/intro/why-app-specific.md @@ -8,7 +8,7 @@ This document explains what application-specific blockchains are, and why develo ## What are application-specific blockchains -Application-specific blockchains are blockchains customized to operate a single application. Instead of building a decentralised application on top of an underlying blockchain like Ethereum, developers build their own blockchain from the ground up. This means building a full-node client, a light-client, and all the necessary interfaces (CLI, REST, ...) to interact with the nodes. +Application-specific blockchains are blockchains customized to operate a single application. Instead of building a decentralized application on top of an underlying blockchain like Ethereum, developers build their own blockchain from the ground up. This means building a full-node client, a light-client, and all the necessary interfaces (CLI, REST, ...) to interact with the nodes. ```text ^ +-------------------------------+ ^ @@ -28,13 +28,13 @@ Blockchain node | | Consensus | | ## What are the shortcomings of Smart Contracts -Virtual-machine blockchains like Ethereum addressed the demand for more programmability back in 2014. At the time, the options available for building decentralised applications were quite limited. Most developers would build on top of the complex and limited Bitcoin scripting language, or fork the Bitcoin codebase which was hard to work with and customize. +Virtual-machine blockchains like Ethereum addressed the demand for more programmability back in 2014. At the time, the options available for building decentralized applications were quite limited. Most developers would build on top of the complex and limited Bitcoin scripting language, or fork the Bitcoin codebase which was hard to work with and customize. -Virtual-machine blockchains came in with a new value proposition. Their state-machine incorporates a virtual-machine that is able to interpret turing-complete programs called Smart Contracts. These Smart Contracts are very good for use cases like one-time events (e.g. ICOs), but they can fall short for building complex decentralised platforms. Here is why: +Virtual-machine blockchains came in with a new value proposition. Their state-machine incorporates a virtual-machine that is able to interpret turing-complete programs called Smart Contracts. These Smart Contracts are very good for use cases like one-time events (e.g. ICOs), but they can fall short for building complex decentralized platforms. Here is why: * Smart Contracts are generally developed with specific programming languages that can be interpreted by the underlying virtual-machine. These programming languages are often immature and inherently limited by the constraints of the virtual-machine itself. For example, the Ethereum Virtual Machine does not allow developers to implement automatic execution of code. Developers are also limited to the account-based system of the EVM, and they can only choose from a limited set of functions for their cryptographic operations. These are examples, but they hint at the lack of **flexibility** that a smart contract environment often entails. -* Smart Contracts are all run by the same virtual machine. This means that they compete for resources, which can severely restrain **performance**. And even if the state-machine were to be split in multiple subsets (e.g. via sharding), Smart Contracts would still need to be interpeted by a virtual machine, which would limit performance compared to a native application implemented at state-machine level (our benchmarks show an improvement on the order of 10x in performance when the virtual-machine is removed). -* Another issue with the fact that Smart Contracts share the same underlying environment is the resulting limitation in **sovereignty**. A decentralised application is an ecosystem that involves multiple players. If the application is built on a general-purpose virtual-machine blockchain, stakeholders have very limited sovereignty over their application, and are ultimately superseded by the governance of the underlying blockchain. If there is a bug in the application, very little can be done about it. +* Smart Contracts are all run by the same virtual machine. This means that they compete for resources, which can severely restrain **performance**. And even if the state-machine were to be split in multiple subsets (e.g. via sharding), Smart Contracts would still need to be interpreted by a virtual machine, which would limit performance compared to a native application implemented at state-machine level (our benchmarks show an improvement on the order of 10x in performance when the virtual-machine is removed). +* Another issue with the fact that Smart Contracts share the same underlying environment is the resulting limitation in **sovereignty**. A decentralized application is an ecosystem that involves multiple players. If the application is built on a general-purpose virtual-machine blockchain, stakeholders have very limited sovereignty over their application, and are ultimately superseded by the governance of the underlying blockchain. If there is a bug in the application, very little can be done about it. Application-Specific Blockchains are designed to address these shortcomings. @@ -56,7 +56,7 @@ The list above contains a few examples that show how much flexibility applicatio ### Performance -Decentralised applications built with Smart Contracts are inherently capped in performance by the underlying environment. For a decentralised application to optimise performance, it needs to be built as an application-specific blockchain. Next are some of the benefits an application-specific blockchain brings in terms of performance: +decentralized applications built with Smart Contracts are inherently capped in performance by the underlying environment. For a decentralized application to optimise performance, it needs to be built as an application-specific blockchain. Next are some of the benefits an application-specific blockchain brings in terms of performance: * Developers of application-specific blockchains can choose to operate with a novel consensus engine such as Tendermint BFT. Compared to Proof-of-Work (used by most virtual-machine blockchains today), it offers significant gains in throughput. * An application-specific blockchain only operates a single application, so that the application does not compete with others for computation and storage. This is the opposite of most non-sharded virtual-machine blockchains today, where smart contracts all compete for computation and storage. @@ -72,7 +72,7 @@ Security is hard to quantify, and greatly varies from platform to platform. That ### Sovereignty -One of the major benefits of application-specific blockchains is sovereignty. A decentralised application is an ecosystem that involves many actors: users, developers, third-party services, and more. When developers build on virtual-machine blockchain where many decentralised applications coexist, the community of the application is different than the community of the underlying blockchain, and the latter supersedes the former in the governance process. If there is a bug or if a new feature is needed, stakeholders of the application have very little leeway to upgrade the code. If the community of the underlying blockchain refuses to act, nothing can happen. +One of the major benefits of application-specific blockchains is sovereignty. A decentralized application is an ecosystem that involves many actors: users, developers, third-party services, and more. When developers build on virtual-machine blockchain where many decentralized applications coexist, the community of the application is different than the community of the underlying blockchain, and the latter supersedes the former in the governance process. If there is a bug or if a new feature is needed, stakeholders of the application have very little leeway to upgrade the code. If the community of the underlying blockchain refuses to act, nothing can happen. The fundamental issue here is that the governance of the application and the governance of the network are not aligned. This issue is solved by application-specific blockchains. Because application-specific blockchains specialize to operate a single application, stakeholders of the application have full control over the entire chain. This ensures that the community will not be stuck if a bug is discovered, and that it has the freedom to choose how it is going to evolve. diff --git a/docs/package-lock.json b/docs/package-lock.json index a1227c824858..6197f8c9c3b2 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -2079,9 +2079,9 @@ } }, "node_modules/async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "dependencies": { "lodash": "^4.17.14" } @@ -14551,9 +14551,9 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=" }, "async": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz", - "integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==", + "version": "2.6.4", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz", + "integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==", "requires": { "lodash": "^4.17.14" } diff --git a/docs/run-node/interact-node.md b/docs/run-node/interact-node.md index 270326ad03ad..13cfb86d5369 100644 --- a/docs/run-node/interact-node.md +++ b/docs/run-node/interact-node.md @@ -109,16 +109,28 @@ Assuming the state at that block has not yet been pruned by the node, this query The following snippet shows how to query the state using gRPC inside a Go program. The idea is to create a gRPC connection, and use the Protobuf-generated client code to query the gRPC server. +#### Install cosmos sdk + +Add below line to `go.mod` to replace protobuf, read more [#8469](https://github.com/cosmos/cosmos-sdk/issues/8469) + +``` +replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 +``` + +```bash +$ go get github.com/cosmos/cosmos-sdk@main +``` + ```go import ( "context" "fmt" - "google.golang.org/grpc" + "google.golang.org/grpc" - "github.com/cosmos/cosmo-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) func queryState() error { @@ -128,20 +140,23 @@ func queryState() error { } // Create a connection to the gRPC server. - grpcConn := grpc.Dial( + grpcConn, err := grpc.Dial( "127.0.0.1:9090", // your gRPC server address. grpc.WithInsecure(), // The Cosmos SDK doesn't support any transport security mechanism. // This instantiates a general gRPC codec which handles proto bytes. We pass in a nil interface registry // if the request/response types contain interface instead of 'nil' you should pass the application specific codec. grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(nil).GRPCCodec())), ) + if err != nil { + return err + } defer grpcConn.Close() // This creates a gRPC client to query the x/bank service. bankClient := banktypes.NewQueryClient(grpcConn) bankRes, err := bankClient.Balance( context.Background(), - &banktypes.QueryBalanceRequest{Address: myAddress, Denom: "atom"}, + &banktypes.QueryBalanceRequest{Address: myAddress.String(), Denom: "atom"}, ) if err != nil { return err @@ -167,8 +182,10 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/metadata" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" - "github.com/cosmos/cosmos-sdk/types/tx" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) func queryState() error { @@ -177,13 +194,13 @@ func queryState() error { var header metadata.MD bankRes, err = bankClient.Balance( metadata.AppendToOutgoingContext(context.Background(), grpctypes.GRPCBlockHeightHeader, "12"), // Add metadata to request - &banktypes.QueryBalanceRequest{Address: myAddress, Denom: denom}, + &banktypes.QueryBalanceRequest{Address: myAddress.String(), Denom: "atom"}, grpc.Header(&header), // Retrieve header from response ) if err != nil { return err } - blockHeight = header.Get(grpctypes.GRPCBlockHeightHeader) + blockHeight := header.Get(grpctypes.GRPCBlockHeightHeader) fmt.Println(blockHeight) // Prints the block height (12) diff --git a/docs/run-node/keyring.md b/docs/run-node/keyring.md index db971d5a1794..5197c382b71c 100644 --- a/docs/run-node/keyring.md +++ b/docs/run-node/keyring.md @@ -129,7 +129,7 @@ MY_VALIDATOR_ADDRESS=$(simd keys show my_validator -a --keyring-backend test) This command generates a new 24-word mnemonic phrase, persists it to the relevant backend, and outputs information about the keypair. If this keypair will be used to hold value-bearing tokens, be sure to write down the mnemonic phrase somewhere safe! -By default, the keyring generates a `secp256k1` keypair. The keyring also supports `ed25519` keys, which may be created by passing the `--algo ed25519` flag. A keyring can of course hold both types of keys simultaneously, and the Cosmos SDK's `x/auth` module (in particular its [AnteHandlers](../core/baseapp.md#antehandler)) supports natively these two public key algorithms. +By default, the keyring generates a `secp256k1` keypair. The keyring also supports `ed25519` keys, which may be created by passing the `--algo ed25519` flag. A keyring can of course hold both types of keys simultaneously, and the Cosmos SDK's `x/auth` module (in particular its [middlewares](../core/baseapp.md#middleware)) supports natively these two public key algorithms. ## Next {hide} diff --git a/docs/versions b/docs/versions index aec06db250e3..23488cf36132 100644 --- a/docs/versions +++ b/docs/versions @@ -1,4 +1,4 @@ -master master -launchpad/backports v0.39 -release/v0.42.x v0.42 release/v0.44.x v0.44 +release/v0.45.x v0.45 +main master +main main diff --git a/errors/CHANGELOG.md b/errors/CHANGELOG.md index dfe84a504ec9..7b1889d7334e 100644 --- a/errors/CHANGELOG.md +++ b/errors/CHANGELOG.md @@ -15,10 +15,7 @@ Change log entries are to be added to the Unreleased section under the appropriate stanza (see below). Each entry should ideally include a tag and the Github issue reference in the following format: -* () \# message - -The issue numbers will later be link-ified during the release process so you do -not have to worry about including a link manually, but you can if you wish. +* () [#] Changelog message. Types of changes (Stanzas): @@ -26,14 +23,18 @@ Types of changes (Stanzas): "Improvements" for changes in existing functionality. "Deprecated" for soon-to-be removed features. "Bug Fixes" for any bug fixes. -"Client Breaking" for breaking Protobuf, gRPC and REST routes used by end-users. -"CLI Breaking" for breaking CLI commands. "API Breaking" for breaking exported APIs used by developers building on SDK. Ref: https://keepachangelog.com/en/1.0.0/ --> # Changelog +## [Unreleased] + +### Improvements + +* [\#11762](https://github.com/cosmos/cosmos-sdk/pull/11762) Improve error messages + ## v1.0.0 ### Features @@ -42,4 +43,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) Add `RegisterWithGRPCCode` function to associate a gRPC error code with errors. ### API Breaking + * [\#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) `New` now is an alias for `Register` and should only be used in initialization code. + +### Bug Fixes + +* [\#11714](https://github.com/cosmos/cosmos-sdk/pull/11714) Add wrapped error messages in `GRPCStatus()` diff --git a/errors/abci.go b/errors/abci.go index afd535e198c6..603f3b36ff1c 100644 --- a/errors/abci.go +++ b/errors/abci.go @@ -42,9 +42,8 @@ func debugErrEncoder(err error) string { return fmt.Sprintf("%+v", err) } -// The defaultErrEncoder applies Redact on the error before encoding it with its internal error message. func defaultErrEncoder(err error) string { - return Redact(err).Error() + return err.Error() } type coder interface { @@ -111,19 +110,3 @@ func errIsNil(err error) bool { } return false } - -var errPanicWithMsg = Wrapf(ErrPanic, "panic message redacted to hide potentially sensitive system info") - -// Redact replaces an error that is not initialized as an ABCI Error with a -// generic internal error instance. If the error is an ABCI Error, that error is -// simply returned. -func Redact(err error) error { - if ErrPanic.Is(err) { - return errPanicWithMsg - } - if abciCode(err) == internalABCICode { - return errInternal - } - - return err -} diff --git a/errors/abci_test.go b/errors/abci_test.go index b9370bd7d601..0982709bf7e6 100644 --- a/errors/abci_test.go +++ b/errors/abci_test.go @@ -57,13 +57,6 @@ func (s *abciTestSuite) TestABCInfo() { wantCode: 0, wantSpace: "", }, - "stdlib is generic message": { - err: io.EOF, - debug: false, - wantLog: "internal", - wantCode: 1, - wantSpace: UndefinedCodespace, - }, "stdlib returns error message in debug mode": { err: io.EOF, debug: true, @@ -71,13 +64,6 @@ func (s *abciTestSuite) TestABCInfo() { wantCode: 1, wantSpace: UndefinedCodespace, }, - "wrapped stdlib is only a generic message": { - err: Wrap(io.EOF, "cannot read file"), - debug: false, - wantLog: "internal", - wantCode: 1, - wantSpace: UndefinedCodespace, - }, // This is hard to test because of attached stacktrace. This // case is tested in an another test. //"wrapped stdlib is a full message in debug mode": { @@ -103,10 +89,12 @@ func (s *abciTestSuite) TestABCInfo() { } for testName, tc := range cases { - space, code, log := ABCIInfo(tc.err, tc.debug) - s.Require().Equal(tc.wantSpace, space, testName) - s.Require().Equal(tc.wantCode, code, testName) - s.Require().Equal(tc.wantLog, log, testName) + s.T().Run(testName, func(t *testing.T) { + space, code, log := ABCIInfo(tc.err, tc.debug) + s.Require().Equal(tc.wantSpace, space, testName) + s.Require().Equal(tc.wantCode, code, testName) + s.Require().Equal(tc.wantLog, log, testName) + }) } } @@ -135,25 +123,20 @@ func (s *abciTestSuite) TestABCIInfoStacktrace() { wantStacktrace: true, wantErrMsg: "wrapped: stdlib", }, - "wrapped stdlib error in non-debug mode does not have stacktrace": { - err: Wrap(fmt.Errorf("stdlib"), "wrapped"), - debug: false, - wantStacktrace: false, - wantErrMsg: "internal", - }, } - const thisTestSrc = "github.com/cosmos/cosmos-sdk/errors.(*abciTestSuite).TestABCIInfoStacktrace" + const thisTestSrc = "cosmossdk.io/errors.(*abciTestSuite).TestABCIInfoStacktrace" for testName, tc := range cases { - _, _, log := ABCIInfo(tc.err, tc.debug) - if !tc.wantStacktrace { - s.Require().Equal(tc.wantErrMsg, log, testName) - continue - } - - s.Require().True(strings.Contains(log, thisTestSrc), testName) - s.Require().True(strings.Contains(log, tc.wantErrMsg), testName) + s.T().Run(testName, func(t *testing.T) { + _, _, log := ABCIInfo(tc.err, tc.debug) + if !tc.wantStacktrace { + s.Require().Equal(tc.wantErrMsg, log, testName) + } else { + s.Require().True(strings.Contains(log, thisTestSrc), testName) + s.Require().True(strings.Contains(log, tc.wantErrMsg), testName) + } + }) } } @@ -163,46 +146,6 @@ func (s *abciTestSuite) TestABCIInfoHidesStacktrace() { s.Require().Equal("wrapped: unauthorized", log) } -func (s *abciTestSuite) TestRedact() { - cases := map[string]struct { - err error - untouched bool // if true we expect the same error after redact - changed error // if untouched == false, expect this error - }{ - "panic looses message": { - err: Wrap(ErrPanic, "some secret stack trace"), - changed: errPanicWithMsg, - }, - "sdk errors untouched": { - err: Wrap(ErrUnauthorized, "cannot drop db"), - untouched: true, - }, - "pass though custom errors with ABCI code": { - err: customErr{}, - untouched: true, - }, - "redact stdlib error": { - err: fmt.Errorf("stdlib error"), - changed: errInternal, - }, - } - - for name, tc := range cases { - spec := tc - redacted := Redact(spec.err) - if spec.untouched { - s.Require().Equal(spec.err, redacted, name) - continue - } - - // see if we got the expected redact - s.Require().Equal(spec.changed, redacted, name) - // make sure the ABCI code did not change - s.Require().Equal(abciCode(spec.err), abciCode(redacted), name) - - } -} - func (s *abciTestSuite) TestABCIInfoSerializeErr() { var ( // Create errors with stacktrace for equal comparison. @@ -231,10 +174,6 @@ func (s *abciTestSuite) TestABCIInfoSerializeErr() { debug: true, exp: fmt.Sprintf("%+v", myErrDecode), }, - "redact in default encoder": { - src: myPanic, - exp: "panic message redacted to hide potentially sensitive system info: panic", - }, "do not redact in debug encoder": { src: myPanic, debug: true, diff --git a/errors/errors.go b/errors/errors.go index 0dedd4268874..854089a40ff0 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -251,7 +251,8 @@ func (e *wrappedError) GRPCStatus() *grpcstatus.Status { if hasStatus, ok := w.(interface { GRPCStatus() *grpcstatus.Status }); ok { - return hasStatus.GRPCStatus() + status := hasStatus.GRPCStatus() + return grpcstatus.New(status.Code(), fmt.Sprintf("%s: %s", status.Message(), e.msg)) } x, ok := w.(causer) diff --git a/errors/errors_test.go b/errors/errors_test.go index acc00fb12977..1dda2344e664 100644 --- a/errors/errors_test.go +++ b/errors/errors_test.go @@ -5,12 +5,10 @@ import ( "fmt" "testing" - grpcstatus "google.golang.org/grpc/status" - - "google.golang.org/grpc/codes" - "github.com/pkg/errors" "github.com/stretchr/testify/suite" + "google.golang.org/grpc/codes" + grpcstatus "google.golang.org/grpc/status" ) type errorsTestSuite struct { @@ -117,8 +115,8 @@ func (s *errorsTestSuite) TestIsOf() { require := s.Require() var errNil *Error - var err = ErrInvalidAddress - var errW = Wrap(ErrLogic, "more info") + err := ErrInvalidAddress + errW := Wrap(ErrLogic, "more info") require.False(IsOf(errNil), "nil error should always have no causer") require.False(IsOf(errNil, err), "nil error should always have no causer") @@ -130,12 +128,11 @@ func (s *errorsTestSuite) TestIsOf() { require.True(IsOf(errW, ErrLogic)) require.True(IsOf(errW, err, ErrLogic)) require.True(IsOf(errW, nil, errW), "error should much itself") - var err2 = errors.New("other error") + err2 := errors.New("other error") require.True(IsOf(err2, nil, err2), "error should much itself") } -type customError struct { -} +type customError struct{} func (customError) Error() string { return "custom error" @@ -172,35 +169,35 @@ func (s *errorsTestSuite) TestWrappedIs() { } func (s *errorsTestSuite) TestWrappedIsMultiple() { - var errTest = errors.New("test error") - var errTest2 = errors.New("test error 2") + errTest := errors.New("test error") + errTest2 := errors.New("test error 2") err := Wrap(errTest2, Wrap(errTest, "some random description").Error()) s.Require().True(stdlib.Is(err, errTest2)) } func (s *errorsTestSuite) TestWrappedIsFail() { - var errTest = errors.New("test error") - var errTest2 = errors.New("test error 2") + errTest := errors.New("test error") + errTest2 := errors.New("test error 2") err := Wrap(errTest2, Wrap(errTest, "some random description").Error()) s.Require().False(stdlib.Is(err, errTest)) } func (s *errorsTestSuite) TestWrappedUnwrap() { - var errTest = errors.New("test error") + errTest := errors.New("test error") err := Wrap(errTest, "some random description") s.Require().Equal(errTest, stdlib.Unwrap(err)) } func (s *errorsTestSuite) TestWrappedUnwrapMultiple() { - var errTest = errors.New("test error") - var errTest2 = errors.New("test error 2") + errTest := errors.New("test error") + errTest2 := errors.New("test error 2") err := Wrap(errTest2, Wrap(errTest, "some random description").Error()) s.Require().Equal(errTest2, stdlib.Unwrap(err)) } func (s *errorsTestSuite) TestWrappedUnwrapFail() { - var errTest = errors.New("test error") - var errTest2 = errors.New("test error 2") + errTest := errors.New("test error") + errTest2 := errors.New("test error 2") err := Wrap(errTest2, Wrap(errTest, "some random description").Error()) s.Require().NotEqual(errTest, stdlib.Unwrap(err)) } @@ -221,6 +218,10 @@ func (s *errorsTestSuite) TestGRPCStatus() { // test wrapping s.Require().Equal(codes.Unimplemented, grpcstatus.Code(ErrNotSupported.Wrap("test"))) s.Require().Equal(codes.FailedPrecondition, grpcstatus.Code(ErrConflict.Wrapf("test %s", "foo"))) + + status, ok = grpcstatus.FromError(ErrNotFound.Wrap("test")) + s.Require().True(ok) + s.Require().Equal("codespace testtesttest code 38: not found: test", status.Message()) } func ExampleWrap() { diff --git a/errors/go.mod b/errors/go.mod index 879d815326f8..c798fa867709 100644 --- a/errors/go.mod +++ b/errors/go.mod @@ -1,18 +1,18 @@ -module github.com/cosmos/cosmos-sdk/errors +module cosmossdk.io/errors -go 1.17 +go 1.18 require ( github.com/pkg/errors v0.9.1 github.com/stretchr/testify v1.7.0 - google.golang.org/grpc v1.44.0 + google.golang.org/grpc v1.45.0 ) require ( github.com/davecgh/go-spew v1.1.0 // indirect - github.com/golang/protobuf v1.4.3 // indirect + github.com/golang/protobuf v1.5.2 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect - google.golang.org/protobuf v1.25.0 // indirect + google.golang.org/protobuf v1.26.0 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) diff --git a/errors/go.sum b/errors/go.sum index ff1485214faf..cff25191d667 100644 --- a/errors/go.sum +++ b/errors/go.sum @@ -32,14 +32,17 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -100,8 +103,8 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.44.0 h1:weqSxi/TMs1SqFRMHCtBgXRs8k3X39QIDEZ0pRcttUg= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= 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= @@ -110,8 +113,10 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/errors/stacktrace.go b/errors/stacktrace.go index b01a3e80911e..dc60870763a5 100644 --- a/errors/stacktrace.go +++ b/errors/stacktrace.go @@ -48,9 +48,9 @@ func trimInternal(st errors.StackTrace) errors.StackTrace { // manual error creation, or runtime for caught panics for matchesFunc(st[0], // where we create errors - "github.com/cosmos/cosmos-sdk/errors.Wrap", - "github.com/cosmos/cosmos-sdk/errors.Wrapf", - "github.com/cosmos/cosmos-sdk/errors.WithType", + "cosmossdk.io/errors.Wrap", + "cosmossdk.io/errors.Wrapf", + "cosmossdk.io/errors.WithType", // runtime are added on panics "runtime.", // _test is defined in coverage tests, causing failure diff --git a/errors/stacktrace_test.go b/errors/stacktrace_test.go index af91cb5951ee..c0a8d6141c25 100644 --- a/errors/stacktrace_test.go +++ b/errors/stacktrace_test.go @@ -32,8 +32,8 @@ func (s *errorsTestSuite) TestStackTrace() { // Wrapping code is unwanted in the errors stack trace. unwantedSrc := []string{ - "github.com/cosmos/cosmos-sdk/errors.Wrap\n", - "github.com/cosmos/cosmos-sdk/errors.Wrapf\n", + "cosmossdk.io/errors.Wrap\n", + "cosmossdk.io/errors.Wrapf\n", "runtime.goexit\n", } const thisTestSrc = "errors/stacktrace_test.go" diff --git a/go.mod b/go.mod index 5ae6d9659e7f..b1a3d22c9673 100644 --- a/go.mod +++ b/go.mod @@ -1,33 +1,35 @@ -go 1.17 +go 1.18 module github.com/cosmos/cosmos-sdk require ( + cosmossdk.io/api v0.1.0-alpha8 + cosmossdk.io/errors v1.0.0-beta.6 + cosmossdk.io/math v1.0.0-beta.2 github.com/99designs/keyring v1.1.6 - github.com/armon/go-metrics v0.3.10 + github.com/armon/go-metrics v0.3.11 github.com/bgentry/speakeasy v0.1.0 - github.com/btcsuite/btcd v0.22.0-beta + github.com/btcsuite/btcd v0.22.1 github.com/cockroachdb/apd/v2 v2.0.2 - github.com/coinbase/rosetta-sdk-go v0.7.7 + github.com/coinbase/rosetta-sdk-go v0.7.9 github.com/confio/ics23/go v0.7.0 github.com/cosmos/btcutil v1.0.4 github.com/cosmos/cosmos-proto v1.0.0-alpha7 - github.com/cosmos/cosmos-sdk/api v0.1.0 github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 - github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.3 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl v0.18.0 github.com/cosmos/ledger-cosmos-go v0.11.1 github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/gogo/gateway v1.1.0 - github.com/gogo/protobuf v1.3.3 + github.com/gogo/protobuf v1.3.2 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.2 + github.com/google/uuid v1.3.0 github.com/gorilla/handlers v1.5.1 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/hashicorp/go-getter v1.5.11 + github.com/hashicorp/go-getter v1.6.1 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 github.com/improbable-eng/grpc-web v0.15.0 @@ -36,31 +38,33 @@ require ( github.com/magiconair/properties v1.8.6 github.com/mattn/go-isatty v0.0.14 github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.12.1 - github.com/prometheus/common v0.33.0 + github.com/prometheus/client_golang v1.12.2 + github.com/prometheus/common v0.34.0 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 github.com/rs/zerolog v1.26.1 - github.com/spf13/cast v1.4.1 + github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.4.0 github.com/spf13/pflag v1.0.5 - github.com/spf13/viper v1.10.1 + github.com/spf13/viper v1.11.0 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.35.2 + github.com/tendermint/tendermint v0.35.4 github.com/tendermint/tm-db v0.6.6 - golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce - google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf - google.golang.org/grpc v1.45.0 + golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 + google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac + google.golang.org/grpc v1.46.2 google.golang.org/protobuf v1.28.0 pgregory.net/rapid v0.4.7 sigs.k8s.io/yaml v1.3.0 ) require ( - cloud.google.com/go v0.99.0 // indirect + cloud.google.com/go v0.100.2 // indirect + cloud.google.com/go/compute v1.5.0 // indirect + cloud.google.com/go/iam v0.3.0 // indirect cloud.google.com/go/storage v1.14.0 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect @@ -71,6 +75,7 @@ require ( 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/creachadair/taskgroup v0.3.2 // indirect github.com/danieljoos/wincred v1.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect @@ -91,22 +96,21 @@ require ( github.com/google/btree v1.0.1 // indirect github.com/google/flatbuffers v2.0.0+incompatible // indirect github.com/google/orderedcode v0.0.1 // indirect - github.com/google/uuid v1.3.0 // indirect - github.com/googleapis/gax-go/v2 v2.1.1 // indirect + github.com/googleapis/gax-go/v2 v2.3.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-safetemp v1.0.0 // indirect - github.com/hashicorp/go-version v1.2.1 // indirect + github.com/hashicorp/go-version v1.4.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jmespath/go-jmespath v0.4.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/lib/pq v1.10.5 // indirect github.com/libp2p/go-buffer-pool v0.0.2 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/minio/highwayhash v1.0.2 // indirect @@ -116,6 +120,7 @@ require ( github.com/mtibben/percent v0.2.1 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20210609091139-0a56a4bca00b // indirect github.com/pelletier/go-toml v1.9.4 // indirect + github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // 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 @@ -123,7 +128,7 @@ require ( 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.8.0 // indirect + github.com/spf13/afero v1.8.2 // 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.20210819022825-2ae1ddf74ef7 // indirect @@ -132,29 +137,29 @@ require ( github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 // indirect go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.23.0 // indirect - golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect - golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect + golang.org/x/net v0.0.0-20220412020605-290c469a71a5 // indirect + golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect + golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e // indirect golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect golang.org/x/text v0.3.7 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - google.golang.org/api v0.63.0 // indirect + golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect + google.golang.org/api v0.74.0 // indirect google.golang.org/appengine v1.6.7 // indirect - gopkg.in/ini.v1 v1.66.3 // indirect + gopkg.in/ini.v1 v1.66.4 // indirect gopkg.in/yaml.v2 v2.4.0 // 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 + github.com/cosmos/cosmos-sdk/db => ./db -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 -replace github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0 - -replace github.com/cosmos/cosmos-sdk/db => ./db + // 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 +) retract v0.43.0 diff --git a/go.sum b/go.sum index 5a04f7c3ba36..1410f7bc6534 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,9 @@ cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+Y 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.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= -cloud.google.com/go v0.99.0 h1:y/cM2iqGgGi5D5DQZl6D9STN/3dR/Vx5Mp8s752oJTY= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +cloud.google.com/go v0.100.2 h1:t9Iw5QH5v4XtlEQaCtUY7x6sCABps8sW0acw7e2WQ6Y= +cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= 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= @@ -43,10 +44,16 @@ cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUM cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/bigtable v1.2.0/go.mod h1:JcVAOl45lrTmQfLj7T6TxyMzIN/3FGGcFm+2xVAli2o= +cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= +cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= +cloud.google.com/go/compute v1.5.0 h1:b1zWmYuuHz7gO9kDcM/EpHGr06UgsYNRpNJzI2kFiLM= +cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= 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.6.0/go.mod h1:afJwI0vaXwAG54kI7A//lP/lSPDkQORQuMkv56TxEPU= cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= +cloud.google.com/go/iam v0.3.0 h1:exkAomrVUuzx9kWFI1wm3KI0uoDeUFPB4kKGzx6x+Gc= +cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= 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= @@ -62,6 +69,12 @@ cloud.google.com/go/storage v1.14.0 h1:6RRlFMv1omScs6iq2hfE3IvgE+l6RfJPampq8UZc5 cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= +cosmossdk.io/api v0.1.0-alpha8 h1:Hr+8bLI4UphF+aMiDIVklrdzRm99dFaNq2inBKGDzNU= +cosmossdk.io/api v0.1.0-alpha8/go.mod h1:gIs3NW5OSNK5wKqxF8JHnGTL82QMsXpwGeKmu2i5xFA= +cosmossdk.io/errors v1.0.0-beta.6 h1:aIn9ZemUfjdgVHNuAgEcKklbOa+ygv6u9gbWOGvzIoU= +cosmossdk.io/errors v1.0.0-beta.6/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= +cosmossdk.io/math v1.0.0-beta.2 h1:17hSVc9ne1c31IaLDfjRojtN+y4Rd2N8H/6Fht2sBzw= +cosmossdk.io/math v1.0.0-beta.2/go.mod h1:u/MXvf8wbUbCsAEyQSSYXXMsczAsFX48e2D6JI86T4o= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= @@ -69,23 +82,17 @@ git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFN git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA= github.com/Antonboom/errname v0.1.5/go.mod h1:DugbBstvPFQbv/5uLcRRzfrNqKE9tVdVCqWCLp6Cifo= github.com/Antonboom/nilnil v0.1.0/go.mod h1:PhHLvRPSghY5Y7mX4TW+BHZQYo1A8flE5H20D3IPZBo= -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-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= +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/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= +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-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -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.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +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/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= @@ -117,8 +124,8 @@ github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/ 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.2.3 h1:GfKThfEsjS9cCz7gaF8zdXv4cpTdUqdljkKGDTbJjys= -github.com/adlio/schema v1.2.3/go.mod h1:nD7ZWmMMbwU12Pqwg+qL0rTvHBrBXfNz+5UQxTfy38M= +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= @@ -142,13 +149,14 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hC 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/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-metrics v0.3.11 h1:/q4zqTAH+/mtFjimfc0SC7yuuxZshlS4TaCeBm+7sZ0= +github.com/armon/go-metrics v0.3.11/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/ashanbrown/forbidigo v1.3.0/go.mod h1:vVW7PEdqEFqapJe95xHkTfB1+XvZXBFg8t0sG2FIxmI= -github.com/ashanbrown/makezero v1.1.0/go.mod h1:oG9Dnez7/ESBqc4EdrdNlryeo7d0KcW1ftXHm7nU/UU= +github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= @@ -181,7 +189,7 @@ 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/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= -github.com/blizzy78/varnamelen v0.6.0/go.mod h1:zy2Eic4qWqjrxa60jG34cfL0VXcSwzUrIx68eJPb4Q8= +github.com/blizzy78/varnamelen v0.6.1/go.mod h1:zy2Eic4qWqjrxa60jG34cfL0VXcSwzUrIx68eJPb4Q8= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/bombsimon/wsl/v3 v3.3.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= @@ -191,8 +199,13 @@ github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BR github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs= -github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= +github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= +github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= +github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= @@ -253,8 +266,8 @@ github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOG 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/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= -github.com/coinbase/rosetta-sdk-go v0.7.7 h1:1b4YhFs4hE7sjRlsJ16VBow1cq0NfmKY2v9tT1PKx7I= -github.com/coinbase/rosetta-sdk-go v0.7.7/go.mod h1:lt2lJX/HQ2stryuKkukCWMcX3T5fBU62UrdhuwsnVYg= +github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= +github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8= github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= @@ -279,13 +292,8 @@ github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= -github.com/cosmos/cosmos-sdk/api v0.1.0 h1:xfSKM0e9p+EJTMQnf5PbWE6VT8ruxTABIJ64Rd064dE= -github.com/cosmos/cosmos-sdk/api v0.1.0/go.mod h1:CupqQBskAOiTXO1XDZ/wrtWzN/wTxUvbQmOqdUhR8wI= -github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.3 h1:Ep7FHNViVwwGnwLFEPewZYsyN2CJNVMmMvFmtNQtbnw= -github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.3/go.mod h1:HFea93YKmoMJ/mNKtkSeJZDtyJ4inxBsUK928KONcqo= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= -github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.18.0 h1:02ur4vnalMR2GuWCFNkuseUcl/BCVmg9tOeHOGiZOkE= github.com/cosmos/iavl v0.18.0/go.mod h1:L0VZHfq0tqMNJvXlslGExaaiZM7eSm+90Vh9QUbp6j4= github.com/cosmos/keyring v1.1.7-0.20210622111912-ef00f8ac3d76 h1:DdzS1m6o/pCqeZ8VOAit/gyATedRgjvkVI+UCrLpyuU= @@ -298,11 +306,15 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc 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/creachadair/atomicfile v0.2.4/go.mod h1:BRq8Une6ckFneYXZQ+kO7p1ZZP3I2fzVzf28JxrIkBc= +github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6VqkYlkM= +github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk= +github.com/creachadair/tomledit v0.0.16/go.mod h1:gvtfnSZLa+YNQD28vaPq0Nk12bRxEhmUdBzAWn+EGF4= 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/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= -github.com/daixiang0/gci v0.3.1-0.20220208004058-76d765e3ab48/go.mod h1:jaASoJmv/ykO9dAAPy31iJnreV19248qKDdVWf3QgC4= +github.com/daixiang0/gci v0.3.3/go.mod h1:1Xr2bxnQbDxCqqulUOv8qpGqkgRw9RSCGGjEC2LjF8o= github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= @@ -312,10 +324,13 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs 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 v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M= github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= -github.com/denis-tingajkin/go-header v0.4.2/go.mod h1:eLRHAVXzE5atsKAnNRDB90WHCFFnBUn4RN0nRcs1LJA= +github.com/denis-tingaikin/go-header v0.4.3/go.mod h1:0wOCWuN71D5qIgE2nz9KrKmuYBAC2Mra5RassOIQ2/c= +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/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= @@ -334,6 +349,8 @@ 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.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +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= @@ -361,11 +378,12 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 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/esimonov/ifshort v1.0.4/go.mod h1:Pe8zjlRrJ80+q2CxHLfEOfTwxCZ4O+MuhcHcfgNWTk0= -github.com/ethereum/go-ethereum v1.10.16/go.mod h1:Anj6cxczl+AHy63o4X9O8yWNHuN5wMpfb8MAnHkWn7Y= +github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= @@ -391,7 +409,8 @@ github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVB 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/frankban/quicktest v1.14.0/go.mod h1:NeW+ay9A/U67EYXNFA1nPE8e/tnQv/09mUdL/ijj8og= +github.com/frankban/quicktest v1.14.2/go.mod h1:mgiwOwqx65TmIk1wJ6Q7wvnVMocbUorkibMOrVTHZps= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= @@ -470,6 +489,9 @@ github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= +github.com/golang-jwt/jwt/v4 v4.3.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/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -521,7 +543,7 @@ github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8ju github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= github.com/golangci/go-misc v0.0.0-20180628070357-927a3d87b613/go.mod h1:SyvUF2NxV+sN8upjjeVYr5W7tyxaT1JVtvhKhOn2ii8= github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU= -github.com/golangci/golangci-lint v1.44.2/go.mod h1:KjBgkLvsTWDkhfu12iCrv0gwL1kON5KNhbyjQ6qN7Jo= +github.com/golangci/golangci-lint v1.45.2/go.mod h1:f20dpzMmUTRp+oYnX0OGjV1Au3Jm2JeI9yLqHq1/xsI= github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y= github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg= github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca/go.mod h1:tvlJhZqDe4LMs4ZHD0oMUlt9G2LWuDGoisJTBzLMV9o= @@ -587,14 +609,16 @@ github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4Mgqvf 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/google/uuid v1.1.5/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/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/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1 h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= +github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= +github.com/googleapis/gax-go/v2 v2.3.0 h1:nRJtk3y8Fm770D42QV6T90ZnvFZyk7agSo3Q+Z9p3WI= +github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -657,11 +681,12 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-getter v1.5.11 h1:wioTuNmaBU3IE9vdFtFMcmZWj0QzLc6DYaP6sNe5onY= -github.com/hashicorp/go-getter v1.5.11/go.mod h1:9i48BP6wpWweI/0/+FBjqLrp9S8XtwUGjiu0QkWHEaY= +github.com/hashicorp/go-getter v1.6.1 h1:NASsgP4q6tL94WH6nJxKWj8As2H/2kop/bB1d8JMyRY= +github.com/hashicorp/go-getter v1.6.1/go.mod h1:IZCrswsZPeWv9IkVnLElzRU/gz/QPi6pZHn4tv6vbwA= 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-hclog v1.2.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= @@ -681,8 +706,9 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1 github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.4.0 h1:aAQzgqIrRKRa7w75CKpbBxYsmUoPjzVm1W59ca1L0J4= +github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -701,6 +727,7 @@ github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOn github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= +github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE= github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= @@ -711,7 +738,7 @@ github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbc github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= -github.com/huin/goupnp v1.0.2/go.mod h1:0dxJBVBHqTMjIUMkESDTNgOOx/Mw5wYIfyFmdzSamkM= +github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= 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= @@ -833,8 +860,9 @@ github.com/letsencrypt/pkcs11key/v4 v4.0.0/go.mod h1:EFUvBDay26dErnNb70Nd0/VW3tJ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.5 h1:J+gdV2cUmX7ZqL2B0lFcW0m+egaHC2V3lpO8nWxyYiQ= +github.com/lib/pq v1.10.5/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= @@ -862,8 +890,6 @@ github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope 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.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= @@ -926,6 +952,7 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN 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/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/moricho/tparallel v0.2.1/go.mod h1:fXEIZxG2vdfl0ZF8b42f5a78EhjjD5mX8qUplsoSU4k= github.com/mozilla/scribe v0.0.0-20180711195314-fb71baf557c1/go.mod h1:FIczTrinKo8VaLxe6PWTPEXRXDIHz2QAwiaBaP5/4a8= @@ -984,13 +1011,15 @@ github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvw github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= -github.com/onsi/gomega v1.17.0 h1:9Luw4uT5HTjHTN8+aNcSThgH1vdXnmdJ8xIfZ4wyTRE= github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -1027,6 +1056,8 @@ github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtP github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 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/pelletier/go-toml/v2 v2.0.0-beta.8 h1:dy81yyLYJDwMTifq24Oi/IslOslRrDSb3jwDggjz3Z0= +github.com/pelletier/go-toml/v2 v2.0.0-beta.8/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM= github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= @@ -1039,6 +1070,7 @@ github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG 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/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1063,8 +1095,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.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_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= +github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -1084,8 +1117,8 @@ github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16 github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.33.0 h1:rHgav/0a6+uYgGdNt3jwz8FNSesO/Hsang3O0T9A5SE= -github.com/prometheus/common v0.33.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= +github.com/prometheus/common v0.34.0 h1:RBmGO9d/FVjqHT0yUGQwBJhkwKV+wPCn7KGpvfab0uE= +github.com/prometheus/common v0.34.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= 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= @@ -1141,13 +1174,14 @@ github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb github.com/sagikazarmark/crypt v0.1.0/go.mod h1:B/mN0msZuINBtQ1zZLEQcegFJJf9vnYIR88KRMEuODE= github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= github.com/sagikazarmark/crypt v0.4.0/go.mod h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM= +github.com/sagikazarmark/crypt v0.5.0/go.mod h1:l+nzl7KWh51rpzp2h7t4MZWyiEWdhNpOAnclKvg+mdA= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sanposhiho/wastedassign/v2 v2.0.6/go.mod h1:KyZ0MWTwxxBmfwn33zh3k1dmsbF2ud9pAAGfoLfjhtI= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= -github.com/securego/gosec/v2 v2.9.6/go.mod h1:EESY9Ywxo/Zc5NyF/qIj6Cop+4PSWM0F0OfGD7FdIXc= +github.com/securego/gosec/v2 v2.10.0/go.mod h1:PVq8Ewh/nCN8l/kKC6zrGXSr7m2NmEK6ITIAWMtIaA0= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= @@ -1155,7 +1189,7 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= -github.com/shirou/gopsutil/v3 v3.22.1/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY= +github.com/shirou/gopsutil/v3 v3.22.2/go.mod h1:WapW1AOOPlHyXr+yOyw3uYx36enocrtSoSBy0L5vUHY= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= @@ -1165,7 +1199,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/sivchari/containedctx v1.0.1/go.mod h1:PwZOeqm4/DLoJOqMSIJs3aKqXRX4YO+uXww087KZ7Bw= +github.com/sivchari/containedctx v1.0.2/go.mod h1:PwZOeqm4/DLoJOqMSIJs3aKqXRX4YO+uXww087KZ7Bw= github.com/sivchari/tenv v1.4.7/go.mod h1:5nF+bITvkebQVanjU6IuMbvIot/7ReNsUV7I5NbprB0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= @@ -1180,11 +1214,13 @@ github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2 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/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/afero v1.8.0 h1:5MmtuhAgYeU6qpa7w7bP0dv6MBYuup0vekhSpSkoq60= github.com/spf13/afero v1.8.0/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= +github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= +github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= github.com/spf13/cast v1.3.0/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/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= @@ -1202,8 +1238,9 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= github.com/spf13/viper v1.9.0/go.mod h1:+i6ajR7OX2XaiBkrcZJFK21htRk7eDeLg7+O6bhUPP4= github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= -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/spf13/viper v1.11.0 h1:7OX/1FS6n7jHD1zGrZTM7WtY13ZELRyosK4k93oPr44= +github.com/spf13/viper v1.11.0/go.mod h1:djo0X/bA5+tYVoCn+C7cAYJGcVn/qYLFTG8gdUsX7Zk= github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= @@ -1242,8 +1279,8 @@ github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RM github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.35.2 h1:AhPjef5hptLQP5i8vs+8zMCu9mczX5fvBd2F575QXVk= -github.com/tendermint/tendermint v0.35.2/go.mod h1:0sVA1nOm5KKaxHar3aIzmMGKH9F/nBMn7T5ruQGZuHg= +github.com/tendermint/tendermint v0.35.4 h1:ZL9Q+rXBwTEYbONBXy0mWkyG08uvdgQNSuYmoBR1sfE= +github.com/tendermint/tendermint v0.35.4/go.mod h1:+9zS92hqCl6mL7XLK3dg71nzoBLJlkl/aNLx4NXKNP8= 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/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= @@ -1264,7 +1301,7 @@ github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcy 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/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tomarrell/wrapcheck/v2 v2.4.0/go.mod h1:68bQ/eJg55BROaRTbMjC7vuhL2OgfoG8bLp9ZyoBfyY= +github.com/tomarrell/wrapcheck/v2 v2.5.0/go.mod h1:68bQ/eJg55BROaRTbMjC7vuhL2OgfoG8bLp9ZyoBfyY= github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4= github.com/tommy-muehle/go-mnd/v2 v2.5.0/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= @@ -1292,7 +1329,7 @@ github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPU github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/quicktemplate v1.7.0/go.mod h1:sqKJnoaOF88V07vkO+9FL8fb9uZg/VPSJnLYn+LmLk8= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= -github.com/vektra/mockery/v2 v2.10.0/go.mod h1:m/WO2UzWzqgVX3nvqpRQq70I4Z7jbSCRhdmkgtp+Ab4= +github.com/vektra/mockery/v2 v2.10.6/go.mod h1:8vf4KDDUptfkyypzdHLuE7OE2xA7Gdt60WgIS8PgD+U= github.com/viki-org/dnscache v0.0.0-20130720023526-c70c1f23c5d8/go.mod h1:dniwbG03GafCjFohMDmz6Zc6oCuiqgH6tGNyXTkHzXE= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= @@ -1330,10 +1367,13 @@ go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mI go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c/go.mod h1:xCI7ZzBfRuGgBXyXO6yfWfDmlWd35khcWpUa4L0xI/k= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/api/v3 v3.5.2/go.mod h1:5GB2vv4A4AOn3yk7MftYGHkUfGtDHnEraIjym4dYz5A= 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/pkg/v3 v3.5.2/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/v2 v2.305.2/go.mod h1:2D7ZejHVMIfog1221iLSYlQRzrtECw3kz4I4VAQm3qI= go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= @@ -1384,6 +1424,7 @@ golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-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-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= @@ -1393,10 +1434,13 @@ golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/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/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= -golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce h1:Roh6XWxHFKrPgC/EQhVubSAGQ6Ozk6IdxHSzt1mR0EI= golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 h1:kUhD7nTDoI3fVd9G4ORWrbV5NY0liEs/Jg2pv5f+bBA= +golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= 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= @@ -1439,6 +1483,7 @@ 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/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= 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-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1480,6 +1525,7 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= @@ -1495,6 +1541,7 @@ golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +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-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -1503,8 +1550,10 @@ golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220412020605-290c469a71a5 h1:bRb386wvrE+oBNdF1d/Xh9mQrfQ4ecYhW5qJ5GvTGT4= +golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= 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= @@ -1522,8 +1571,10 @@ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ 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/oauth2 v0.0.0-20220223155221-ee480838109b h1:clP8eMhB30EHdc0bd2Twtq6kgU7yl5ub2cQLSdrv1Dg= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= 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= @@ -1643,15 +1694,20 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02/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-20211213223007-03aa0b5f6827/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220111092808-5a964db01320/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/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e h1:w36l2Uw3dRan1K3TyXriXvY+6T56GNmlKGcqiQUJDfM= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/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/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= @@ -1776,11 +1832,13 @@ golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.9-0.20211228192929-ee1ca4ffc4da/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= 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= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/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.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= @@ -1822,8 +1880,12 @@ google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdr 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.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= -google.golang.org/api v0.63.0 h1:n2bqqK895ygnBpdPDYetfy23K7fJ22wsrZKCyfuRkkA= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= +google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= +google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= +google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= +google.golang.org/api v0.74.0 h1:ExR2D+5TYIrMphWgs5JCgwRhEDlPDXXrLwHHMgPHTXE= +google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1912,9 +1974,16 @@ google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ6 google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/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/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf h1:SVYXkUz2yZS9FWb2Gm8ivSlbNQzL2Z/NpPKE3RG2jWk= +google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac h1:qSNTkEN+L2mvWcLgJOR+8bdHX9rN/IdU3A1Ghpfb1Rg= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1954,8 +2023,9 @@ google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9K google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= 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= @@ -1988,8 +2058,9 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.66.3 h1:jRskFVxYaMGAMUbN0UZ7niA9gzL9B49DOqE78vg0k3w= gopkg.in/ini.v1 v1.66.3/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.66.4 h1:SsAcf+mM7mRZo2nJNGt8mZCjG8ZRaNGMURJw7BsIST4= +gopkg.in/ini.v1 v1.66.4/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= @@ -2022,7 +2093,7 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= honnef.co/go/tools v0.2.2/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY= -mvdan.cc/gofumpt v0.2.1/go.mod h1:a/rvZPhsNaedOJBzqRD9omnwVwHZsBdJirXHa9Gh9Ig= +mvdan.cc/gofumpt v0.3.0/go.mod h1:0+VyGZWleeIj5oostkOex+nDBA0eyavuDnDusAJ8ylo= mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= mvdan.cc/unparam v0.0.0-20211214103731-d0ef000c54e5/go.mod h1:b8RRCBm0eeiWR8cfN88xeq2G5SG3VKGO+5UPWi5FSOY= diff --git a/internal/db/tmdb_adapter.go b/internal/db/tmdb_adapter.go index a36f5d023188..c7eb775efb79 100644 --- a/internal/db/tmdb_adapter.go +++ b/internal/db/tmdb_adapter.go @@ -15,7 +15,7 @@ import ( // compatibility with existing code that expects the old interface. type TmdbAdapter struct { dbm.DBReadWriter - db dbm.DBConnection + Connection dbm.DBConnection } type tmdbBatchAdapter struct { *TmdbAdapter @@ -29,7 +29,7 @@ var ( // ConnectionAsTmdb returns a tmdb.DB which wraps a DBConnection. func ConnectionAsTmdb(db dbm.DBConnection) *TmdbAdapter { return &TmdbAdapter{db.ReadWriter(), db} } -func (d *TmdbAdapter) Close() error { d.CloseTx(); return d.db.Close() } +func (d *TmdbAdapter) Close() error { d.CloseTx(); return d.Connection.Close() } func (d *TmdbAdapter) CloseTx() error { return d.DBReadWriter.Discard() } func (d *TmdbAdapter) sync() error { @@ -37,7 +37,7 @@ func (d *TmdbAdapter) sync() error { if err != nil { return err } - d.DBReadWriter = d.db.ReadWriter() + d.DBReadWriter = d.Connection.ReadWriter() return nil } func (d *TmdbAdapter) DeleteSync(k []byte) error { @@ -60,11 +60,11 @@ func (d *TmdbAdapter) Commit() (uint64, error) { if err != nil { return 0, err } - v, err := d.db.SaveNextVersion() + v, err := d.Connection.SaveNextVersion() if err != nil { return 0, err } - d.DBReadWriter = d.db.ReadWriter() + d.DBReadWriter = d.Connection.ReadWriter() return v, err } diff --git a/math/CHANGELOG.md b/math/CHANGELOG.md new file mode 100644 index 000000000000..16de809f2717 --- /dev/null +++ b/math/CHANGELOG.md @@ -0,0 +1,32 @@ + + +# Changelog + +## [Unreleased] diff --git a/math/doc.go b/math/doc.go new file mode 100644 index 000000000000..17664a9531e0 --- /dev/null +++ b/math/doc.go @@ -0,0 +1,6 @@ +/* +Package math implements custom Cosmos SDK math types used for arithmetic +operations. Signed and unsigned integer types utilize Golang's standard library +big integers types, having a maximum bit length of 256 bits. +*/ +package math diff --git a/math/go.mod b/math/go.mod new file mode 100644 index 000000000000..ac1dfad9d0b3 --- /dev/null +++ b/math/go.mod @@ -0,0 +1,11 @@ +module cosmossdk.io/math + +go 1.18 + +require github.com/stretchr/testify v1.7.0 + +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect +) diff --git a/math/go.sum b/math/go.sum new file mode 100644 index 000000000000..acb88a48f684 --- /dev/null +++ b/math/go.sum @@ -0,0 +1,11 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/types/int.go b/math/int.go similarity index 93% rename from types/int.go rename to math/int.go index 04b808fbc69d..159e2d7d224c 100644 --- a/types/int.go +++ b/math/int.go @@ -1,15 +1,15 @@ -package types +package math import ( "encoding" "encoding/json" "fmt" - "testing" - "math/big" + "testing" ) -const maxBitLen = 256 +// MaxBitLen defines the maximum bit length supported bit Int and Uint types. +const MaxBitLen = 256 func newIntegerFromString(s string) (*big.Int, bool) { return new(big.Int).SetString(s, 0) @@ -60,14 +60,14 @@ func unmarshalText(i *big.Int, text string) error { return err } - if i.BitLen() > maxBitLen { + if i.BitLen() > MaxBitLen { return fmt.Errorf("integer out of range: %s", text) } return nil } -var _ CustomProtobufType = (*Int)(nil) +var _ customProtobufType = (*Int)(nil) // Int wraps big.Int with a 257 bit range bound // Checks overflow, underflow and division by zero @@ -108,7 +108,7 @@ func NewIntFromBigInt(i *big.Int) Int { return Int{} } - if i.BitLen() > maxBitLen { + if i.BitLen() > MaxBitLen { panic("NewIntFromBigInt() out of bound") } return Int{i} @@ -121,7 +121,7 @@ func NewIntFromString(s string) (res Int, ok bool) { return } // Check overflow - if i.BitLen() > maxBitLen { + if i.BitLen() > MaxBitLen { ok = false return } @@ -139,7 +139,7 @@ func NewIntWithDecimal(n int64, dec int) Int { i.Mul(big.NewInt(n), exp) // Check overflow - if i.BitLen() > maxBitLen { + if i.BitLen() > MaxBitLen { panic("NewIntWithDecimal() out of bound") } return Int{i} @@ -151,11 +151,6 @@ func ZeroInt() Int { return Int{big.NewInt(0)} } // OneInt returns Int value with one func OneInt() Int { return Int{big.NewInt(1)} } -// ToDec converts Int to Dec -func (i Int) ToDec() Dec { - return NewDecFromInt(i) -} - // Int64 converts Int to int64 // Panics if the value is out of range func (i Int) Int64() int64 { @@ -234,7 +229,7 @@ func (i Int) LTE(i2 Int) bool { func (i Int) Add(i2 Int) (res Int) { res = Int{add(i.i, i2.i)} // Check overflow - if res.i.BitLen() > maxBitLen { + if res.i.BitLen() > MaxBitLen { panic("Int overflow") } return @@ -249,7 +244,7 @@ func (i Int) AddRaw(i2 int64) Int { func (i Int) Sub(i2 Int) (res Int) { res = Int{sub(i.i, i2.i)} // Check overflow - if res.i.BitLen() > maxBitLen { + if res.i.BitLen() > MaxBitLen { panic("Int overflow") } return @@ -263,12 +258,12 @@ func (i Int) SubRaw(i2 int64) Int { // Mul multiples two Ints func (i Int) Mul(i2 Int) (res Int) { // Check overflow - if i.i.BitLen()+i2.i.BitLen()-1 > maxBitLen { + if i.i.BitLen()+i2.i.BitLen()-1 > MaxBitLen { panic("Int overflow") } res = Int{mul(i.i, i2.i)} // Check overflow if sign of both are same - if res.i.BitLen() > maxBitLen { + if res.i.BitLen() > MaxBitLen { panic("Int overflow") } return @@ -388,8 +383,8 @@ func (i *Int) MarshalTo(data []byte) (n int, err error) { i.i = new(big.Int) } if i.i.BitLen() == 0 { // The value 0 - copy(data, []byte{0x30}) - return 1, nil + n = copy(data, []byte{0x30}) + return n, nil } bz, err := i.Marshal() @@ -397,8 +392,8 @@ func (i *Int) MarshalTo(data []byte) (n int, err error) { return 0, err } - copy(data, bz) - return len(bz), nil + n = copy(data, bz) + return n, nil } // Unmarshal implements the gogo proto custom type interface. @@ -416,8 +411,8 @@ func (i *Int) Unmarshal(data []byte) error { return err } - if i.i.BitLen() > maxBitLen { - return fmt.Errorf("integer out of range; got: %d, max: %d", i.i.BitLen(), maxBitLen) + if i.i.BitLen() > MaxBitLen { + return fmt.Errorf("integer out of range; got: %d, max: %d", i.i.BitLen(), MaxBitLen) } return nil @@ -437,7 +432,3 @@ func (i *Int) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) } func IntEq(t *testing.T, exp, got Int) (*testing.T, bool, string, string, string) { return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() } - -func (ip IntProto) String() string { - return ip.Int.String() -} diff --git a/types/int_internal_test.go b/math/int_internal_test.go similarity index 99% rename from types/int_internal_test.go rename to math/int_internal_test.go index 77d357bbf750..d2cb90240852 100644 --- a/types/int_internal_test.go +++ b/math/int_internal_test.go @@ -1,4 +1,4 @@ -package types +package math import ( "math/big" diff --git a/types/int_test.go b/math/int_test.go similarity index 69% rename from types/int_test.go rename to math/int_test.go index a6ec8c6d48bd..c39fce0ee51c 100644 --- a/types/int_test.go +++ b/math/int_test.go @@ -1,4 +1,4 @@ -package types_test +package math_test import ( "fmt" @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/suite" - sdk "github.com/cosmos/cosmos-sdk/types" + "cosmossdk.io/math" ) type intTestSuite struct { @@ -27,30 +27,30 @@ func (s *intTestSuite) SetupSuite() { func (s *intTestSuite) TestFromInt64() { for n := 0; n < 20; n++ { r := rand.Int63() - s.Require().Equal(r, sdk.NewInt(r).Int64()) + s.Require().Equal(r, math.NewInt(r).Int64()) } } func (s *intTestSuite) TestFromUint64() { for n := 0; n < 20; n++ { r := rand.Uint64() - s.Require().True(sdk.NewIntFromUint64(r).IsUint64()) - s.Require().Equal(r, sdk.NewIntFromUint64(r).Uint64()) + s.Require().True(math.NewIntFromUint64(r).IsUint64()) + s.Require().Equal(r, math.NewIntFromUint64(r).Uint64()) } } func (s *intTestSuite) TestIntPanic() { // Max Int = 2^256-1 = 1.1579209e+77 // Min Int = -(2^256-1) = -1.1579209e+77 - s.Require().NotPanics(func() { sdk.NewIntWithDecimal(4, 76) }) - i1 := sdk.NewIntWithDecimal(4, 76) - s.Require().NotPanics(func() { sdk.NewIntWithDecimal(5, 76) }) - i2 := sdk.NewIntWithDecimal(5, 76) - s.Require().NotPanics(func() { sdk.NewIntWithDecimal(6, 76) }) - i3 := sdk.NewIntWithDecimal(6, 76) + s.Require().NotPanics(func() { math.NewIntWithDecimal(4, 76) }) + i1 := math.NewIntWithDecimal(4, 76) + s.Require().NotPanics(func() { math.NewIntWithDecimal(5, 76) }) + i2 := math.NewIntWithDecimal(5, 76) + s.Require().NotPanics(func() { math.NewIntWithDecimal(6, 76) }) + i3 := math.NewIntWithDecimal(6, 76) - s.Require().Panics(func() { sdk.NewIntWithDecimal(2, 77) }) - s.Require().Panics(func() { sdk.NewIntWithDecimal(9, 80) }) + s.Require().Panics(func() { math.NewIntWithDecimal(2, 77) }) + s.Require().Panics(func() { math.NewIntWithDecimal(9, 80) }) // Overflow check s.Require().NotPanics(func() { i1.Add(i1) }) @@ -84,20 +84,20 @@ func (s *intTestSuite) TestIntPanic() { s.Require().Panics(func() { i3.Mul(i3.Neg()) }) // Bound check - intmax := sdk.NewIntFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1))) + intmax := math.NewIntFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1))) intmin := intmax.Neg() - s.Require().NotPanics(func() { intmax.Add(sdk.ZeroInt()) }) - s.Require().NotPanics(func() { intmin.Sub(sdk.ZeroInt()) }) - s.Require().Panics(func() { intmax.Add(sdk.OneInt()) }) - s.Require().Panics(func() { intmin.Sub(sdk.OneInt()) }) + s.Require().NotPanics(func() { intmax.Add(math.ZeroInt()) }) + s.Require().NotPanics(func() { intmin.Sub(math.ZeroInt()) }) + s.Require().Panics(func() { intmax.Add(math.OneInt()) }) + s.Require().Panics(func() { intmin.Sub(math.OneInt()) }) - s.Require().NotPanics(func() { sdk.NewIntFromBigInt(nil) }) - s.Require().True(sdk.NewIntFromBigInt(nil).IsNil()) + s.Require().NotPanics(func() { math.NewIntFromBigInt(nil) }) + s.Require().True(math.NewIntFromBigInt(nil).IsNil()) // Division-by-zero check - s.Require().Panics(func() { i1.Quo(sdk.NewInt(0)) }) + s.Require().Panics(func() { i1.Quo(math.NewInt(0)) }) - s.Require().NotPanics(func() { sdk.Int{}.BigInt() }) + s.Require().NotPanics(func() { math.Int{}.BigInt() }) } // Tests below uses randomness @@ -107,17 +107,17 @@ func (s *intTestSuite) TestIntPanic() { func (s *intTestSuite) TestIdentInt() { for d := 0; d < 1000; d++ { n := rand.Int63() - i := sdk.NewInt(n) + i := math.NewInt(n) - ifromstr, ok := sdk.NewIntFromString(strconv.FormatInt(n, 10)) + ifromstr, ok := math.NewIntFromString(strconv.FormatInt(n, 10)) s.Require().True(ok) cases := []int64{ i.Int64(), i.BigInt().Int64(), ifromstr.Int64(), - sdk.NewIntFromBigInt(big.NewInt(n)).Int64(), - sdk.NewIntWithDecimal(n, 0).Int64(), + math.NewIntFromBigInt(big.NewInt(n)).Int64(), + math.NewIntWithDecimal(n, 0).Int64(), } for tcnum, tc := range cases { @@ -143,12 +143,12 @@ func maxint(i1, i2 int64) int64 { func (s *intTestSuite) TestArithInt() { for d := 0; d < 1000; d++ { n1 := int64(rand.Int31()) - i1 := sdk.NewInt(n1) + i1 := math.NewInt(n1) n2 := int64(rand.Int31()) - i2 := sdk.NewInt(n2) + i2 := math.NewInt(n2) cases := []struct { - ires sdk.Int + ires math.Int nres int64 }{ {i1.Add(i2), n1 + n2}, @@ -159,8 +159,8 @@ func (s *intTestSuite) TestArithInt() { {i1.SubRaw(n2), n1 - n2}, {i1.MulRaw(n2), n1 * n2}, {i1.QuoRaw(n2), n1 / n2}, - {sdk.MinInt(i1, i2), minint(n1, n2)}, - {sdk.MaxInt(i1, i2), maxint(n1, n2)}, + {math.MinInt(i1, i2), minint(n1, n2)}, + {math.MaxInt(i1, i2), maxint(n1, n2)}, {i1.Neg(), -n1}, {i1.Abs(), n1}, {i1.Neg().Abs(), n1}, @@ -170,15 +170,14 @@ func (s *intTestSuite) TestArithInt() { s.Require().Equal(tc.nres, tc.ires.Int64(), "Int arithmetic operation does not match with int64 operation. tc #%d", tcnum) } } - } func (s *intTestSuite) TestCompInt() { for d := 0; d < 1000; d++ { n1 := int64(rand.Int31()) - i1 := sdk.NewInt(n1) + i1 := math.NewInt(n1) n2 := int64(rand.Int31()) - i2 := sdk.NewInt(n2) + i2 := math.NewInt(n2) cases := []struct { ires bool @@ -196,93 +195,93 @@ func (s *intTestSuite) TestCompInt() { } } -func randint() sdk.Int { - return sdk.NewInt(rand.Int63()) +func randint() math.Int { + return math.NewInt(rand.Int63()) } func (s *intTestSuite) TestImmutabilityAllInt() { - ops := []func(*sdk.Int){ - func(i *sdk.Int) { _ = i.Add(randint()) }, - func(i *sdk.Int) { _ = i.Sub(randint()) }, - func(i *sdk.Int) { _ = i.Mul(randint()) }, - func(i *sdk.Int) { _ = i.Quo(randint()) }, - func(i *sdk.Int) { _ = i.AddRaw(rand.Int63()) }, - func(i *sdk.Int) { _ = i.SubRaw(rand.Int63()) }, - func(i *sdk.Int) { _ = i.MulRaw(rand.Int63()) }, - func(i *sdk.Int) { _ = i.QuoRaw(rand.Int63()) }, - func(i *sdk.Int) { _ = i.Neg() }, - func(i *sdk.Int) { _ = i.Abs() }, - func(i *sdk.Int) { _ = i.IsZero() }, - func(i *sdk.Int) { _ = i.Sign() }, - func(i *sdk.Int) { _ = i.Equal(randint()) }, - func(i *sdk.Int) { _ = i.GT(randint()) }, - func(i *sdk.Int) { _ = i.LT(randint()) }, - func(i *sdk.Int) { _ = i.String() }, + ops := []func(*math.Int){ + func(i *math.Int) { _ = i.Add(randint()) }, + func(i *math.Int) { _ = i.Sub(randint()) }, + func(i *math.Int) { _ = i.Mul(randint()) }, + func(i *math.Int) { _ = i.Quo(randint()) }, + func(i *math.Int) { _ = i.AddRaw(rand.Int63()) }, + func(i *math.Int) { _ = i.SubRaw(rand.Int63()) }, + func(i *math.Int) { _ = i.MulRaw(rand.Int63()) }, + func(i *math.Int) { _ = i.QuoRaw(rand.Int63()) }, + func(i *math.Int) { _ = i.Neg() }, + func(i *math.Int) { _ = i.Abs() }, + func(i *math.Int) { _ = i.IsZero() }, + func(i *math.Int) { _ = i.Sign() }, + func(i *math.Int) { _ = i.Equal(randint()) }, + func(i *math.Int) { _ = i.GT(randint()) }, + func(i *math.Int) { _ = i.LT(randint()) }, + func(i *math.Int) { _ = i.String() }, } for i := 0; i < 1000; i++ { n := rand.Int63() - ni := sdk.NewInt(n) + ni := math.NewInt(n) for opnum, op := range ops { op(&ni) s.Require().Equal(n, ni.Int64(), "Int is modified by operation. tc #%d", opnum) - s.Require().Equal(sdk.NewInt(n), ni, "Int is modified by operation. tc #%d", opnum) + s.Require().Equal(math.NewInt(n), ni, "Int is modified by operation. tc #%d", opnum) } } } func (s *intTestSuite) TestEncodingTableInt() { - var i sdk.Int + var i math.Int cases := []struct { - i sdk.Int + i math.Int jsonBz []byte rawBz []byte }{ { - sdk.NewInt(0), + math.NewInt(0), []byte("\"0\""), []byte{0x30}, }, { - sdk.NewInt(100), + math.NewInt(100), []byte("\"100\""), []byte{0x31, 0x30, 0x30}, }, { - sdk.NewInt(-100), + math.NewInt(-100), []byte("\"-100\""), []byte{0x2d, 0x31, 0x30, 0x30}, }, { - sdk.NewInt(51842), + math.NewInt(51842), []byte("\"51842\""), []byte{0x35, 0x31, 0x38, 0x34, 0x32}, }, { - sdk.NewInt(-51842), + math.NewInt(-51842), []byte("\"-51842\""), []byte{0x2d, 0x35, 0x31, 0x38, 0x34, 0x32}, }, { - sdk.NewInt(19513368), + math.NewInt(19513368), []byte("\"19513368\""), []byte{0x31, 0x39, 0x35, 0x31, 0x33, 0x33, 0x36, 0x38}, }, { - sdk.NewInt(-19513368), + math.NewInt(-19513368), []byte("\"-19513368\""), []byte{0x2d, 0x31, 0x39, 0x35, 0x31, 0x33, 0x33, 0x36, 0x38}, }, { - sdk.NewInt(999999999999), + math.NewInt(999999999999), []byte("\"999999999999\""), []byte{0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, }, { - sdk.NewInt(-999999999999), + math.NewInt(-999999999999), []byte("\"-999999999999\""), []byte{0x2d, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, }, @@ -308,35 +307,35 @@ func (s *intTestSuite) TestEncodingTableInt() { } func (s *intTestSuite) TestEncodingTableUint() { - var i sdk.Uint + var i math.Uint cases := []struct { - i sdk.Uint + i math.Uint jsonBz []byte rawBz []byte }{ { - sdk.NewUint(0), + math.NewUint(0), []byte("\"0\""), []byte{0x30}, }, { - sdk.NewUint(100), + math.NewUint(100), []byte("\"100\""), []byte{0x31, 0x30, 0x30}, }, { - sdk.NewUint(51842), + math.NewUint(51842), []byte("\"51842\""), []byte{0x35, 0x31, 0x38, 0x34, 0x32}, }, { - sdk.NewUint(19513368), + math.NewUint(19513368), []byte("\"19513368\""), []byte{0x31, 0x39, 0x35, 0x31, 0x33, 0x33, 0x36, 0x38}, }, { - sdk.NewUint(999999999999), + math.NewUint(999999999999), []byte("\"999999999999\""), []byte{0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, }, @@ -377,24 +376,24 @@ func (s *intTestSuite) TestIntMod() { for _, tt := range tests { if tt.wantPanic { - s.Require().Panics(func() { sdk.NewInt(tt.x).Mod(sdk.NewInt(tt.y)) }) - s.Require().Panics(func() { sdk.NewInt(tt.x).ModRaw(tt.y) }) + s.Require().Panics(func() { math.NewInt(tt.x).Mod(math.NewInt(tt.y)) }) + s.Require().Panics(func() { math.NewInt(tt.x).ModRaw(tt.y) }) return } - s.Require().True(sdk.NewInt(tt.x).Mod(sdk.NewInt(tt.y)).Equal(sdk.NewInt(tt.ret))) - s.Require().True(sdk.NewInt(tt.x).ModRaw(tt.y).Equal(sdk.NewInt(tt.ret))) + s.Require().True(math.NewInt(tt.x).Mod(math.NewInt(tt.y)).Equal(math.NewInt(tt.ret))) + s.Require().True(math.NewInt(tt.x).ModRaw(tt.y).Equal(math.NewInt(tt.ret))) } } func (s *intTestSuite) TestIntEq() { - _, resp, _, _, _ := sdk.IntEq(s.T(), sdk.ZeroInt(), sdk.ZeroInt()) + _, resp, _, _, _ := math.IntEq(s.T(), math.ZeroInt(), math.ZeroInt()) s.Require().True(resp) - _, resp, _, _, _ = sdk.IntEq(s.T(), sdk.OneInt(), sdk.ZeroInt()) + _, resp, _, _, _ = math.IntEq(s.T(), math.OneInt(), math.ZeroInt()) s.Require().False(resp) } func TestRoundTripMarshalToInt(t *testing.T) { - var values = []int64{ + values := []int64{ 0, 1, 1 << 10, @@ -410,12 +409,12 @@ func TestRoundTripMarshalToInt(t *testing.T) { t.Parallel() var scratch [20]byte - iv := sdk.NewInt(value) + iv := math.NewInt(value) n, err := iv.MarshalTo(scratch[:]) if err != nil { t.Fatal(err) } - rt := new(sdk.Int) + rt := new(math.Int) if err := rt.Unmarshal(scratch[:n]); err != nil { t.Fatal(err) } diff --git a/math/proto.go b/math/proto.go new file mode 100644 index 000000000000..86e78bafa90d --- /dev/null +++ b/math/proto.go @@ -0,0 +1,15 @@ +package math + +// customProtobufType defines the interface custom gogo proto types must implement +// in order to be used as a "customtype" extension. +// +// ref: https://github.com/gogo/protobuf/blob/master/custom_types.md +type customProtobufType interface { + Marshal() ([]byte, error) + MarshalTo(data []byte) (n int, err error) + Unmarshal(data []byte) error + Size() int + + MarshalJSON() ([]byte, error) + UnmarshalJSON(data []byte) error +} diff --git a/types/uint.go b/math/uint.go similarity index 94% rename from types/uint.go rename to math/uint.go index dbdd17bd58a9..8ce6105e9fb0 100644 --- a/types/uint.go +++ b/math/uint.go @@ -1,4 +1,4 @@ -package types +package math import ( "errors" @@ -49,7 +49,7 @@ func ZeroUint() Uint { return Uint{big.NewInt(0)} } // OneUint returns Uint value with one. func OneUint() Uint { return Uint{big.NewInt(1)} } -var _ CustomProtobufType = (*Uint)(nil) +var _ customProtobufType = (*Uint)(nil) // Uint64 converts Uint to uint64 // Panics if the value is out of range @@ -162,8 +162,8 @@ func (u *Uint) MarshalTo(data []byte) (n int, err error) { u.i = new(big.Int) } if u.i.BitLen() == 0 { // The value 0 - copy(data, []byte{0x30}) - return 1, nil + n = copy(data, []byte{0x30}) + return n, nil } bz, err := u.Marshal() @@ -171,8 +171,8 @@ func (u *Uint) MarshalTo(data []byte) (n int, err error) { return 0, err } - copy(data, bz) - return len(bz), nil + n = copy(data, bz) + return n, nil } // Unmarshal implements the gogo proto custom type interface. @@ -190,11 +190,8 @@ func (u *Uint) Unmarshal(data []byte) error { return err } - if u.i.BitLen() > maxBitLen { - return fmt.Errorf("integer out of range; got: %d, max: %d", u.i.BitLen(), maxBitLen) - } - - return nil + // Finally check for overflow. + return UintOverflow(u.i) } // Size implements the gogo proto custom type interface. @@ -213,8 +210,9 @@ func UintOverflow(i *big.Int) error { if i.Sign() < 0 { return errors.New("non-positive integer") } - if i.BitLen() > 256 { - return fmt.Errorf("bit length %d greater than 256", i.BitLen()) + + if g, w := i.BitLen(), MaxBitLen; g > w { + return fmt.Errorf("integer out of range; got: %d, max: %d", g, w) } return nil } diff --git a/types/uint_internal_test.go b/math/uint_internal_test.go similarity index 98% rename from types/uint_internal_test.go rename to math/uint_internal_test.go index a39869cac759..a3f1fb4f5e1b 100644 --- a/types/uint_internal_test.go +++ b/math/uint_internal_test.go @@ -1,4 +1,4 @@ -package types +package math import ( "math/big" @@ -51,5 +51,4 @@ func (s *uintInternalTestSuite) TestUintSize() { s.Require().Equal(2, x.Size()) x = NewUint(100) s.Require().Equal(3, x.Size()) - } diff --git a/math/uint_test.go b/math/uint_test.go new file mode 100644 index 000000000000..3077e5094181 --- /dev/null +++ b/math/uint_test.go @@ -0,0 +1,363 @@ +package math_test + +import ( + "fmt" + "math" + "math/big" + "math/rand" + "strings" + "testing" + + sdkmath "cosmossdk.io/math" + "github.com/stretchr/testify/suite" +) + +type uintTestSuite struct { + suite.Suite +} + +func TestUnitTestSuite(t *testing.T) { + suite.Run(t, new(uintTestSuite)) +} + +func (s *uintTestSuite) SetupSuite() { + s.T().Parallel() +} + +func (s *uintTestSuite) TestUintPanics() { + // Max Uint = 1.15e+77 + // Min Uint = 0 + u1 := sdkmath.NewUint(0) + u2 := sdkmath.OneUint() + + s.Require().Equal(uint64(0), u1.Uint64()) + s.Require().Equal(uint64(1), u2.Uint64()) + + s.Require().Panics(func() { sdkmath.NewUintFromBigInt(big.NewInt(-5)) }) + s.Require().Panics(func() { sdkmath.NewUintFromString("-1") }) + s.Require().NotPanics(func() { + s.Require().True(sdkmath.NewUintFromString("0").Equal(sdkmath.ZeroUint())) + s.Require().True(sdkmath.NewUintFromString("5").Equal(sdkmath.NewUint(5))) + }) + + // Overflow check + s.Require().True(u1.Add(u1).Equal(sdkmath.ZeroUint())) + s.Require().True(u1.Add(sdkmath.OneUint()).Equal(sdkmath.OneUint())) + s.Require().Equal(uint64(0), u1.Uint64()) + s.Require().Equal(uint64(1), sdkmath.OneUint().Uint64()) + s.Require().Panics(func() { u1.SubUint64(2) }) + s.Require().True(u1.SubUint64(0).Equal(sdkmath.ZeroUint())) + s.Require().True(u2.Add(sdkmath.OneUint()).Sub(sdkmath.OneUint()).Equal(sdkmath.OneUint())) // i2 == 1 + s.Require().True(u2.Add(sdkmath.OneUint()).Mul(sdkmath.NewUint(5)).Equal(sdkmath.NewUint(10))) // i2 == 10 + s.Require().True(sdkmath.NewUint(7).Quo(sdkmath.NewUint(2)).Equal(sdkmath.NewUint(3))) + s.Require().True(sdkmath.NewUint(0).Quo(sdkmath.NewUint(2)).Equal(sdkmath.ZeroUint())) + s.Require().True(sdkmath.NewUint(5).MulUint64(4).Equal(sdkmath.NewUint(20))) + s.Require().True(sdkmath.NewUint(5).MulUint64(0).Equal(sdkmath.ZeroUint())) + + uintmax := sdkmath.NewUintFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1))) + uintmin := sdkmath.ZeroUint() + + // divs by zero + s.Require().Panics(func() { sdkmath.OneUint().Mul(sdkmath.ZeroUint().SubUint64(uint64(1))) }) + s.Require().Panics(func() { sdkmath.OneUint().QuoUint64(0) }) + s.Require().Panics(func() { sdkmath.OneUint().Quo(sdkmath.ZeroUint()) }) + s.Require().Panics(func() { sdkmath.ZeroUint().QuoUint64(0) }) + s.Require().Panics(func() { sdkmath.OneUint().Quo(sdkmath.ZeroUint().Sub(sdkmath.OneUint())) }) + s.Require().Panics(func() { uintmax.Add(sdkmath.OneUint()) }) + s.Require().Panics(func() { uintmax.Incr() }) + s.Require().Panics(func() { uintmin.Sub(sdkmath.OneUint()) }) + s.Require().Panics(func() { uintmin.Decr() }) + + s.Require().Equal(uint64(0), sdkmath.MinUint(sdkmath.ZeroUint(), sdkmath.OneUint()).Uint64()) + s.Require().Equal(uint64(1), sdkmath.MaxUint(sdkmath.ZeroUint(), sdkmath.OneUint()).Uint64()) + + // comparison ops + s.Require().True( + sdkmath.OneUint().GT(sdkmath.ZeroUint()), + ) + s.Require().False( + sdkmath.OneUint().LT(sdkmath.ZeroUint()), + ) + s.Require().True( + sdkmath.OneUint().GTE(sdkmath.ZeroUint()), + ) + s.Require().False( + sdkmath.OneUint().LTE(sdkmath.ZeroUint()), + ) + + s.Require().False(sdkmath.ZeroUint().GT(sdkmath.OneUint())) + s.Require().True(sdkmath.ZeroUint().LT(sdkmath.OneUint())) + s.Require().False(sdkmath.ZeroUint().GTE(sdkmath.OneUint())) + s.Require().True(sdkmath.ZeroUint().LTE(sdkmath.OneUint())) +} + +func (s *uintTestSuite) TestArithUint() { + for d := 0; d < 1000; d++ { + n1 := uint64(rand.Uint32()) + u1 := sdkmath.NewUint(n1) + n2 := uint64(rand.Uint32()) + u2 := sdkmath.NewUint(n2) + + cases := []struct { + ures sdkmath.Uint + nres uint64 + }{ + {u1.Add(u2), n1 + n2}, + {u1.Mul(u2), n1 * n2}, + {u1.Quo(u2), n1 / n2}, + {u1.AddUint64(n2), n1 + n2}, + {u1.MulUint64(n2), n1 * n2}, + {u1.QuoUint64(n2), n1 / n2}, + {sdkmath.MinUint(u1, u2), minuint(n1, n2)}, + {sdkmath.MaxUint(u1, u2), maxuint(n1, n2)}, + {u1.Incr(), n1 + 1}, + } + + for tcnum, tc := range cases { + s.Require().Equal(tc.nres, tc.ures.Uint64(), "Uint arithmetic operation does not match with uint64 operation. tc #%d", tcnum) + } + + if n2 > n1 { + n1, n2 = n2, n1 + u1, u2 = sdkmath.NewUint(n1), sdkmath.NewUint(n2) + } + + subs := []struct { + ures sdkmath.Uint + nres uint64 + }{ + {u1.Sub(u2), n1 - n2}, + {u1.SubUint64(n2), n1 - n2}, + {u1.Decr(), n1 - 1}, + } + + for tcnum, tc := range subs { + s.Require().Equal(tc.nres, tc.ures.Uint64(), "Uint subtraction does not match with uint64 operation. tc #%d", tcnum) + } + } +} + +func (s *uintTestSuite) TestCompUint() { + for d := 0; d < 10000; d++ { + n1 := rand.Uint64() + i1 := sdkmath.NewUint(n1) + n2 := rand.Uint64() + i2 := sdkmath.NewUint(n2) + + cases := []struct { + ires bool + nres bool + }{ + {i1.Equal(i2), n1 == n2}, + {i1.GT(i2), n1 > n2}, + {i1.LT(i2), n1 < n2}, + {i1.GTE(i2), !i1.LT(i2)}, + {!i1.GTE(i2), i1.LT(i2)}, + {i1.LTE(i2), n1 <= n2}, + {i2.LTE(i1), n2 <= n1}, + } + + for tcnum, tc := range cases { + s.Require().Equal(tc.nres, tc.ires, "Uint comparison operation does not match with uint64 operation. tc #%d", tcnum) + } + } +} + +func (s *uintTestSuite) TestImmutabilityAllUint() { + ops := []func(*sdkmath.Uint){ + func(i *sdkmath.Uint) { _ = i.Add(sdkmath.NewUint(rand.Uint64())) }, + func(i *sdkmath.Uint) { _ = i.Sub(sdkmath.NewUint(rand.Uint64() % i.Uint64())) }, + func(i *sdkmath.Uint) { _ = i.Mul(randuint()) }, + func(i *sdkmath.Uint) { _ = i.Quo(randuint()) }, + func(i *sdkmath.Uint) { _ = i.AddUint64(rand.Uint64()) }, + func(i *sdkmath.Uint) { _ = i.SubUint64(rand.Uint64() % i.Uint64()) }, + func(i *sdkmath.Uint) { _ = i.MulUint64(rand.Uint64()) }, + func(i *sdkmath.Uint) { _ = i.QuoUint64(rand.Uint64()) }, + func(i *sdkmath.Uint) { _ = i.IsZero() }, + func(i *sdkmath.Uint) { _ = i.Equal(randuint()) }, + func(i *sdkmath.Uint) { _ = i.GT(randuint()) }, + func(i *sdkmath.Uint) { _ = i.GTE(randuint()) }, + func(i *sdkmath.Uint) { _ = i.LT(randuint()) }, + func(i *sdkmath.Uint) { _ = i.LTE(randuint()) }, + func(i *sdkmath.Uint) { _ = i.String() }, + func(i *sdkmath.Uint) { _ = i.Incr() }, + func(i *sdkmath.Uint) { + if i.IsZero() { + return + } + + _ = i.Decr() + }, + } + + for i := 0; i < 1000; i++ { + n := rand.Uint64() + ni := sdkmath.NewUint(n) + + for opnum, op := range ops { + op(&ni) + + s.Require().Equal(n, ni.Uint64(), "Uint is modified by operation. #%d", opnum) + s.Require().Equal(sdkmath.NewUint(n), ni, "Uint is modified by operation. #%d", opnum) + } + } +} + +func (s *uintTestSuite) TestSafeSub() { + testCases := []struct { + x, y sdkmath.Uint + expected uint64 + panic bool + }{ + {sdkmath.NewUint(0), sdkmath.NewUint(0), 0, false}, + {sdkmath.NewUint(10), sdkmath.NewUint(5), 5, false}, + {sdkmath.NewUint(5), sdkmath.NewUint(10), 5, true}, + {sdkmath.NewUint(math.MaxUint64), sdkmath.NewUint(0), math.MaxUint64, false}, + } + + for i, tc := range testCases { + tc := tc + if tc.panic { + s.Require().Panics(func() { tc.x.Sub(tc.y) }) + continue + } + s.Require().Equal( + tc.expected, tc.x.Sub(tc.y).Uint64(), + "invalid subtraction result; x: %s, y: %s, tc: #%d", tc.x, tc.y, i, + ) + } +} + +func (s *uintTestSuite) TestParseUint() { + type args struct { + s string + } + tests := []struct { + name string + args args + want sdkmath.Uint + wantErr bool + }{ + {"malformed", args{"malformed"}, sdkmath.Uint{}, true}, + {"empty", args{""}, sdkmath.Uint{}, true}, + {"positive", args{"50"}, sdkmath.NewUint(uint64(50)), false}, + {"negative", args{"-1"}, sdkmath.Uint{}, true}, + {"zero", args{"0"}, sdkmath.ZeroUint(), false}, + } + for _, tt := range tests { + got, err := sdkmath.ParseUint(tt.args.s) + if tt.wantErr { + s.Require().Error(err) + continue + } + s.Require().NoError(err) + s.Require().True(got.Equal(tt.want)) + } +} + +func randuint() sdkmath.Uint { + return sdkmath.NewUint(rand.Uint64()) +} + +func (s *uintTestSuite) TestRelativePow() { + tests := []struct { + args []sdkmath.Uint + want sdkmath.Uint + }{ + {[]sdkmath.Uint{sdkmath.ZeroUint(), sdkmath.ZeroUint(), sdkmath.OneUint()}, sdkmath.OneUint()}, + {[]sdkmath.Uint{sdkmath.ZeroUint(), sdkmath.ZeroUint(), sdkmath.NewUint(10)}, sdkmath.NewUint(10)}, + {[]sdkmath.Uint{sdkmath.ZeroUint(), sdkmath.OneUint(), sdkmath.NewUint(10)}, sdkmath.ZeroUint()}, + {[]sdkmath.Uint{sdkmath.NewUint(10), sdkmath.NewUint(2), sdkmath.OneUint()}, sdkmath.NewUint(100)}, + {[]sdkmath.Uint{sdkmath.NewUint(210), sdkmath.NewUint(2), sdkmath.NewUint(100)}, sdkmath.NewUint(441)}, + {[]sdkmath.Uint{sdkmath.NewUint(2100), sdkmath.NewUint(2), sdkmath.NewUint(1000)}, sdkmath.NewUint(4410)}, + {[]sdkmath.Uint{sdkmath.NewUint(1000000001547125958), sdkmath.NewUint(600), sdkmath.NewUint(1000000000000000000)}, sdkmath.NewUint(1000000928276004850)}, + } + for i, tc := range tests { + res := sdkmath.RelativePow(tc.args[0], tc.args[1], tc.args[2]) + s.Require().Equal(tc.want, res, "unexpected result for test case %d, input: %v, got: %v", i, tc.args, res) + } +} + +func minuint(i1, i2 uint64) uint64 { + if i1 < i2 { + return i1 + } + return i2 +} + +func maxuint(i1, i2 uint64) uint64 { + if i1 > i2 { + return i1 + } + return i2 +} + +func TestRoundTripMarshalToUint(t *testing.T) { + values := []uint64{ + 0, + 1, + 1 << 10, + 1<<10 - 3, + 1<<63 - 1, + 1<<32 - 7, + 1<<22 - 8, + math.MaxUint64, + } + + for _, value := range values { + value := value + t.Run(fmt.Sprintf("%d", value), func(t *testing.T) { + t.Parallel() + + var scratch [20]byte + uv := sdkmath.NewUint(value) + n, err := uv.MarshalTo(scratch[:]) + if err != nil { + t.Fatal(err) + } + rt := new(sdkmath.Uint) + if err := rt.Unmarshal(scratch[:n]); err != nil { + t.Fatal(err) + } + if !rt.Equal(uv) { + t.Fatalf("roundtrip=%q != original=%q", rt, uv) + } + }) + } +} + +func TestWeakUnmarshalNegativeSign(t *testing.T) { + neg10, _ := new(big.Int).SetString("-10", 0) + blob, err := neg10.MarshalText() + if err != nil { + t.Fatal(err) + } + + ui := new(sdkmath.Uint) + err = ui.Unmarshal(blob) + if err == nil { + t.Fatal("Failed to catch the negative value") + } + if errStr := err.Error(); !strings.Contains(errStr, "non-positive") { + t.Fatalf("negative value not reported, got instead %q", errStr) + } +} + +func TestWeakUnmarshalOverflow(t *testing.T) { + exp := new(big.Int).SetUint64(256) + pos10, _ := new(big.Int).SetString("10", 0) + exp10Pow256 := new(big.Int).Exp(pos10, exp, nil) + blob, err := exp10Pow256.MarshalText() + if err != nil { + t.Fatal(err) + } + + ui := new(sdkmath.Uint) + err = ui.Unmarshal(blob) + if err == nil { + t.Fatal("Failed to catch the overflowed value") + } + if errStr := err.Error(); !strings.Contains(errStr, "out of range") { + t.Fatalf("out of range value not reported, got instead %q", errStr) + } +} diff --git a/orm/encoding/ormfield/codec.go b/orm/encoding/ormfield/codec.go index dee0529e222f..14a1d4804c71 100644 --- a/orm/encoding/ormfield/codec.go +++ b/orm/encoding/ormfield/codec.go @@ -13,7 +13,6 @@ import ( // Codec defines an interface for decoding and encoding values in ORM index keys. type Codec interface { - // Decode decodes a value in a key. Decode(r Reader) (protoreflect.Value, error) diff --git a/orm/encoding/ormfield/int32.go b/orm/encoding/ormfield/int32.go index 97eb93070da8..a3482ba862a6 100644 --- a/orm/encoding/ormfield/int32.go +++ b/orm/encoding/ormfield/int32.go @@ -14,8 +14,10 @@ type Int32Codec struct{} var int32Codec = Int32Codec{} -const int32Max = 2147483647 -const int32Offset = int32Max + 1 +const ( + int32Max = 2147483647 + int32Offset = int32Max + 1 +) func (i Int32Codec) Decode(r Reader) (protoreflect.Value, error) { var x uint32 diff --git a/orm/encoding/ormfield/string.go b/orm/encoding/ormfield/string.go index 90c368f81ffb..3a9955e83e5d 100644 --- a/orm/encoding/ormfield/string.go +++ b/orm/encoding/ormfield/string.go @@ -16,7 +16,7 @@ func (s StringCodec) FixedBufferSize() int { } func (s StringCodec) ComputeBufferSize(value protoreflect.Value) (int, error) { - return len(value.Interface().(string)), nil + return len(value.String()), nil } func (s StringCodec) IsOrdered() bool { @@ -24,7 +24,7 @@ func (s StringCodec) IsOrdered() bool { } func (s StringCodec) Compare(v1, v2 protoreflect.Value) int { - return strings.Compare(v1.Interface().(string), v2.Interface().(string)) + return strings.Compare(v1.String(), v2.String()) } func (s StringCodec) Decode(r Reader) (protoreflect.Value, error) { @@ -33,7 +33,7 @@ func (s StringCodec) Decode(r Reader) (protoreflect.Value, error) { } func (s StringCodec) Encode(value protoreflect.Value, w io.Writer) error { - _, err := w.Write([]byte(value.Interface().(string))) + _, err := w.Write([]byte(value.String())) return err } @@ -46,7 +46,7 @@ func (s NonTerminalStringCodec) FixedBufferSize() int { } func (s NonTerminalStringCodec) ComputeBufferSize(value protoreflect.Value) (int, error) { - return len(value.Interface().(string)) + 1, nil + return len(value.String()) + 1, nil } func (s NonTerminalStringCodec) IsOrdered() bool { @@ -54,7 +54,7 @@ func (s NonTerminalStringCodec) IsOrdered() bool { } func (s NonTerminalStringCodec) Compare(v1, v2 protoreflect.Value) int { - return strings.Compare(v1.Interface().(string), v2.Interface().(string)) + return strings.Compare(v1.String(), v2.String()) } func (s NonTerminalStringCodec) Decode(r Reader) (protoreflect.Value, error) { @@ -69,7 +69,7 @@ func (s NonTerminalStringCodec) Decode(r Reader) (protoreflect.Value, error) { } func (s NonTerminalStringCodec) Encode(value protoreflect.Value, w io.Writer) error { - str := value.Interface().(string) + str := value.String() bz := []byte(str) for _, b := range bz { if b == 0 { diff --git a/orm/encoding/ormkv/codec.go b/orm/encoding/ormkv/codec.go index afaa4b044020..1f93b9e54220 100644 --- a/orm/encoding/ormkv/codec.go +++ b/orm/encoding/ormkv/codec.go @@ -6,7 +6,6 @@ import "google.golang.org/protobuf/reflect/protoreflect" // kv-store backing an ORM instance. EntryCodec's enable full logical decoding // of ORM data. type EntryCodec interface { - // DecodeEntry decodes a kv-pair into an Entry. DecodeEntry(k, v []byte) (Entry, error) diff --git a/orm/encoding/ormkv/entry.go b/orm/encoding/ormkv/entry.go index 869eb9fbef38..2098afbac6a9 100644 --- a/orm/encoding/ormkv/entry.go +++ b/orm/encoding/ormkv/entry.go @@ -26,7 +26,6 @@ type Entry interface { // PrimaryKeyEntry represents a logically decoded primary-key entry. type PrimaryKeyEntry struct { - // TableName is the table this entry represents. TableName protoreflect.FullName @@ -71,7 +70,6 @@ func (p *PrimaryKeyEntry) doNotImplement() {} // IndexKeyEntry represents a logically decoded index entry. type IndexKeyEntry struct { - // TableName is the table this entry represents. TableName protoreflect.FullName @@ -111,14 +109,12 @@ func (i *IndexKeyEntry) String() string { if i.IsUnique { return fmt.Sprintf("UNIQ %s", i.string()) } else { - return fmt.Sprintf("IDX %s", i.string()) } } // SeqEntry represents a sequence for tables with auto-incrementing primary keys. type SeqEntry struct { - // TableName is the table this entry represents. TableName protoreflect.FullName diff --git a/orm/encoding/ormkv/index_key.go b/orm/encoding/ormkv/index_key.go index 335a5f820a92..55284f220636 100644 --- a/orm/encoding/ormkv/index_key.go +++ b/orm/encoding/ormkv/index_key.go @@ -62,7 +62,6 @@ func NewIndexKeyCodec(prefix []byte, messageType protoreflect.MessageType, index } func (cdc IndexKeyCodec) DecodeIndexKey(k, _ []byte) (indexFields, primaryKey []protoreflect.Value, err error) { - values, err := cdc.DecodeKey(bytes.NewReader(k)) // got prefix key if err == io.EOF { diff --git a/orm/encoding/ormkv/key_codec.go b/orm/encoding/ormkv/key_codec.go index 9b3605b5ff9b..00ef51ea28e7 100644 --- a/orm/encoding/ormkv/key_codec.go +++ b/orm/encoding/ormkv/key_codec.go @@ -82,7 +82,7 @@ func (cdc *KeyCodec) EncodeKey(values []protoreflect.Value) ([]byte, error) { return nil, err } - w := bytes.NewBuffer(make([]byte, 0, sz)) + w := bytes.NewBuffer(make([]byte, 0, sz+len(cdc.prefix))) if _, err = w.Write(cdc.prefix); err != nil { return nil, err } diff --git a/orm/encoding/ormkv/primary_key.go b/orm/encoding/ormkv/primary_key.go index 268cb1dc7f28..ff4509cb562e 100644 --- a/orm/encoding/ormkv/primary_key.go +++ b/orm/encoding/ormkv/primary_key.go @@ -51,7 +51,6 @@ func (p PrimaryKeyCodec) DecodeIndexKey(k, _ []byte) (indexFields, primaryKey [] primaryKey = indexFields } return indexFields, primaryKey, nil - } func (p PrimaryKeyCodec) DecodeEntry(k, v []byte) (Entry, error) { diff --git a/orm/go.mod b/orm/go.mod index 7e32039e8cb6..c619d400c0bb 100644 --- a/orm/go.mod +++ b/orm/go.mod @@ -1,20 +1,20 @@ module github.com/cosmos/cosmos-sdk/orm -go 1.17 +go 1.18 require ( + cosmossdk.io/errors v1.0.0-beta.6 github.com/cosmos/cosmos-proto v1.0.0-alpha7 github.com/cosmos/cosmos-sdk/api v0.1.0 - github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.4 github.com/golang/mock v1.6.0 - github.com/google/go-cmp v0.5.7 + github.com/google/go-cmp v0.5.8 github.com/iancoleman/strcase v0.2.0 - github.com/regen-network/gocuke v0.6.1 + github.com/regen-network/gocuke v0.6.2 github.com/stretchr/testify v1.7.1 github.com/tendermint/tm-db v0.6.7 - google.golang.org/grpc v1.45.0 + google.golang.org/grpc v1.46.2 google.golang.org/protobuf v1.28.0 - gotest.tools/v3 v3.1.0 + gotest.tools/v3 v3.2.0 pgregory.net/rapid v0.4.7 ) @@ -24,14 +24,14 @@ require ( github.com/cespare/xxhash v1.1.0 // indirect github.com/cockroachdb/apd/v3 v3.1.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect - github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect - github.com/cucumber/messages-go/v16 v16.0.1 // indirect + github.com/cucumber/common/gherkin/go/v22 v22.0.0 // indirect + github.com/cucumber/common/messages/go/v17 v17.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgraph-io/badger/v2 v2.2007.2 // indirect github.com/dgraph-io/ristretto v0.0.3 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect - github.com/gofrs/uuid v4.0.0+incompatible // indirect + github.com/gofrs/uuid v4.2.0+incompatible // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3 // indirect @@ -44,7 +44,6 @@ require ( golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect golang.org/x/sys v0.0.0-20210903071746-97244b99971b // indirect golang.org/x/text v0.3.6 // indirect - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect diff --git a/orm/go.sum b/orm/go.sum index bd18bce305b2..0b4e8cb3e2c1 100644 --- a/orm/go.sum +++ b/orm/go.sum @@ -1,5 +1,7 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cosmossdk.io/errors v1.0.0-beta.6 h1:aIn9ZemUfjdgVHNuAgEcKklbOa+ygv6u9gbWOGvzIoU= +cosmossdk.io/errors v1.0.0-beta.6/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= @@ -20,9 +22,9 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w= github.com/cockroachdb/apd/v3 v3.1.0/go.mod h1:6qgPBMXjATAdD/VefbRP9NoSLKjbB4LCoA7gN4LpHs4= @@ -33,16 +35,13 @@ github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hk github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= github.com/cosmos/cosmos-sdk/api v0.1.0 h1:xfSKM0e9p+EJTMQnf5PbWE6VT8ruxTABIJ64Rd064dE= github.com/cosmos/cosmos-sdk/api v0.1.0/go.mod h1:CupqQBskAOiTXO1XDZ/wrtWzN/wTxUvbQmOqdUhR8wI= -github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.4 h1:Kjv3QD2Y3C7TvxDh1+Yg9cXefwFbTOUypUtB1tMJRco= -github.com/cosmos/cosmos-sdk/errors v1.0.0-beta.4/go.mod h1:HFea93YKmoMJ/mNKtkSeJZDtyJ4inxBsUK928KONcqo= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/cucumber/gherkin-go/v19 v19.0.3 h1:mMSKu1077ffLbTJULUfM5HPokgeBcIGboyeNUof1MdE= -github.com/cucumber/gherkin-go/v19 v19.0.3/go.mod h1:jY/NP6jUtRSArQQJ5h1FXOUgk5fZK24qtE7vKi776Vw= -github.com/cucumber/messages-go/v16 v16.0.0/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g= -github.com/cucumber/messages-go/v16 v16.0.1 h1:fvkpwsLgnIm0qugftrw2YwNlio+ABe2Iu94Ap8GMYIY= -github.com/cucumber/messages-go/v16 v16.0.1/go.mod h1:EJcyR5Mm5ZuDsKJnT2N9KRnBK30BGjtYotDKpwQ0v6g= +github.com/cucumber/common/gherkin/go/v22 v22.0.0 h1:4K8NqptbvdOrjL9DEea6HFjSpbdT9+Q5kgLpmmsHYl0= +github.com/cucumber/common/gherkin/go/v22 v22.0.0/go.mod h1:3mJT10B2GGn3MvVPd3FwR7m2u4tLhSRhWUqJU4KN4Fg= +github.com/cucumber/common/messages/go/v17 v17.1.1 h1:RNqopvIFyLWnKv0LfATh34SWBhXeoFTJnSrgm9cT/Ts= +github.com/cucumber/common/messages/go/v17 v17.1.1/go.mod h1:bpGxb57tDE385Rb2EohgUadLkAbhoC4IyCFi89u/JQI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -60,21 +59,19 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= -github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= -github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= -github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= 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/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0= +github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -108,8 +105,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= @@ -127,7 +124,6 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= -github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -148,8 +144,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/regen-network/gocuke v0.6.1 h1:SEsXbZDg7/DXpy/hPsLbVvfdObpK13PsJ8Pq3ko+S4s= -github.com/regen-network/gocuke v0.6.1/go.mod h1:+i/R+pDBMLx1M7rL3fV7FC18gzyVTdGu3rNLUSOzHIo= +github.com/regen-network/gocuke v0.6.2 h1:pHviZ0kKAq2U2hN2q3smKNxct6hS0mGByFMHGnWA97M= +github.com/regen-network/gocuke v0.6.2/go.mod h1:zYaqIHZobHyd0xOrHGPQjbhGJsuZ1oElx150u2o1xuk= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= @@ -233,7 +229,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210903071746-97244b99971b h1:3Dq0eVHn0uaQJmPO+/aYPI/fRMqdrVDbu7MQcku54gg= golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -265,7 +260,6 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf h1:SVYXkUz2yZS9FWb2Gm8ivSlbNQzL2Z/NpPKE3RG2jWk= google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -274,10 +268,9 @@ google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0 h1:NEpgUqV3Z+ZjkqMsxMg11IaDrXY4RY6CQukSGK0uI1M= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= 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= @@ -306,8 +299,8 @@ gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools/v3 v3.1.0 h1:rVV8Tcg/8jHUkPUorwjaMTtemIMVXfIPKiOqnhEhakk= -gotest.tools/v3 v3.1.0/go.mod h1:fHy7eyTmJFO5bQbUsEGQ1v4m2J3Jz9eWL54TP2/ZuYQ= +gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I= +gotest.tools/v3 v3.2.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= pgregory.net/rapid v0.4.7 h1:MTNRktPuv5FNqOO151TM9mDTa+XHcX6ypYeISDVD14g= diff --git a/orm/internal/buf.gen.yaml b/orm/internal/buf.gen.yaml index bd2a91632353..7acae39d5714 100644 --- a/orm/internal/buf.gen.yaml +++ b/orm/internal/buf.gen.yaml @@ -4,7 +4,7 @@ managed: go_package_prefix: default: github.com/cosmos/cosmos-sdk/orm/internal override: - buf.build/cosmos/cosmos-sdk: github.com/cosmos/cosmos-sdk/api + buf.build/cosmos/cosmos-sdk: cosmossdk.io/api plugins: - name: go-pulsar out: . diff --git a/orm/internal/codegen/file.go b/orm/internal/codegen/file.go index 6adf8df61d5d..c19b81ac9edb 100644 --- a/orm/internal/codegen/file.go +++ b/orm/internal/codegen/file.go @@ -153,7 +153,6 @@ func (f fileGen) genStoreConstructor(stores []*protogen.Message) { } f.P("}, nil") f.P("}") - } func (f fileGen) fieldsToCamelCase(fields string) string { diff --git a/orm/internal/codegen/index.go b/orm/internal/codegen/index.go index 61c1281e35ae..9b889d431e46 100644 --- a/orm/internal/codegen/index.go +++ b/orm/internal/codegen/index.go @@ -9,7 +9,6 @@ import ( ) func (t tableGen) genIndexKeys() { - // interface that all keys must adhere to t.P("type ", t.indexKeyInterfaceName(), " interface {") t.P("id() uint32") @@ -112,7 +111,6 @@ func (t tableGen) genIndex(fields string, id uint32, isPrimaryKey bool) { for i := 1; i < len(fieldsSlc)+1; i++ { t.genWithMethods(idxKeyName, fieldsSlc[:i]) } - } func (t tableGen) genIndexInterfaceMethods(id uint32, indexStructName string) { diff --git a/orm/internal/codegen/table.go b/orm/internal/codegen/table.go index ae50ce702be5..ed03ac5eb55a 100644 --- a/orm/internal/codegen/table.go +++ b/orm/internal/codegen/table.go @@ -61,7 +61,7 @@ func (t tableGen) getTableInterface() { t.P("type ", t.messageTableInterfaceName(t.msg), " interface {") t.P("Insert(ctx ", contextPkg.Ident("Context"), ", ", t.param(t.msg.GoIdent.GoName), " *", t.QualifiedGoIdent(t.msg.GoIdent), ") error") if t.table.PrimaryKey.AutoIncrement { - t.P("InsertReturningID(ctx ", contextPkg.Ident("Context"), ", ", t.param(t.msg.GoIdent.GoName), " *", t.QualifiedGoIdent(t.msg.GoIdent), ") (uint64, error)") + t.P("InsertReturning", t.fieldsToCamelCase(t.table.PrimaryKey.Fields), "(ctx ", contextPkg.Ident("Context"), ", ", t.param(t.msg.GoIdent.GoName), " *", t.QualifiedGoIdent(t.msg.GoIdent), ") (uint64, error)") } t.P("Update(ctx ", contextPkg.Ident("Context"), ", ", t.param(t.msg.GoIdent.GoName), " *", t.QualifiedGoIdent(t.msg.GoIdent), ") error") t.P("Save(ctx ", contextPkg.Ident("Context"), ", ", t.param(t.msg.GoIdent.GoName), " *", t.QualifiedGoIdent(t.msg.GoIdent), ") error") @@ -180,8 +180,8 @@ func (t tableGen) genTableImpl() { } if t.table.PrimaryKey.AutoIncrement { - t.P(receiver, "InsertReturningID(ctx ", contextPkg.Ident("Context"), ", ", varName, " *", varTypeName, ") (uint64, error) {") - t.P("return ", receiverVar, ".table.InsertReturningID(ctx, ", varName, ")") + t.P(receiver, "InsertReturning", t.fieldsToCamelCase(t.table.PrimaryKey.Fields), "(ctx ", contextPkg.Ident("Context"), ", ", varName, " *", varTypeName, ") (uint64, error) {") + t.P("return ", receiverVar, ".table.InsertReturningPKey(ctx, ", varName, ")") t.P("}") t.P() } diff --git a/orm/internal/testkv/debug.go b/orm/internal/testkv/debug.go index 8cdc032f5a67..5e2382246d46 100644 --- a/orm/internal/testkv/debug.go +++ b/orm/internal/testkv/debug.go @@ -14,7 +14,6 @@ import ( // Debugger is an interface that handles debug info from the debug store wrapper. type Debugger interface { - // Log logs a single log message. Log(string) diff --git a/orm/internal/testkv/leveldb.go b/orm/internal/testkv/leveldb.go new file mode 100644 index 000000000000..e7fb201e0a4e --- /dev/null +++ b/orm/internal/testkv/leveldb.go @@ -0,0 +1,18 @@ +package testkv + +import ( + "testing" + + dbm "github.com/tendermint/tm-db" + "gotest.tools/v3/assert" + + "github.com/cosmos/cosmos-sdk/orm/model/ormtable" +) + +func NewGoLevelDBBackend(t testing.TB) ormtable.Backend { + db, err := dbm.NewGoLevelDB("test", t.TempDir()) + assert.NilError(t, err) + return ormtable.NewBackend(ormtable.BackendOptions{ + CommitmentStore: db, + }) +} diff --git a/orm/internal/testpb/test_schema.cosmos_orm.go b/orm/internal/testpb/test_schema.cosmos_orm.go index 5f62658a0778..a5cf2a6fbd11 100644 --- a/orm/internal/testpb/test_schema.cosmos_orm.go +++ b/orm/internal/testpb/test_schema.cosmos_orm.go @@ -215,7 +215,7 @@ func NewExampleTableTable(db ormtable.Schema) (ExampleTableTable, error) { type ExampleAutoIncrementTableTable interface { Insert(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error - InsertReturningID(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) (uint64, error) + InsertReturningId(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) (uint64, error) Update(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error Save(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error Delete(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error @@ -298,8 +298,8 @@ func (this exampleAutoIncrementTableTable) Delete(ctx context.Context, exampleAu return this.table.Delete(ctx, exampleAutoIncrementTable) } -func (this exampleAutoIncrementTableTable) InsertReturningID(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) (uint64, error) { - return this.table.InsertReturningID(ctx, exampleAutoIncrementTable) +func (this exampleAutoIncrementTableTable) InsertReturningId(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) (uint64, error) { + return this.table.InsertReturningPKey(ctx, exampleAutoIncrementTable) } func (this exampleAutoIncrementTableTable) Has(ctx context.Context, id uint64) (found bool, err error) { @@ -400,7 +400,7 @@ func NewExampleSingletonTable(db ormtable.Schema) (ExampleSingletonTable, error) type ExampleTimestampTable interface { Insert(ctx context.Context, exampleTimestamp *ExampleTimestamp) error - InsertReturningID(ctx context.Context, exampleTimestamp *ExampleTimestamp) (uint64, error) + InsertReturningId(ctx context.Context, exampleTimestamp *ExampleTimestamp) (uint64, error) Update(ctx context.Context, exampleTimestamp *ExampleTimestamp) error Save(ctx context.Context, exampleTimestamp *ExampleTimestamp) error Delete(ctx context.Context, exampleTimestamp *ExampleTimestamp) error @@ -480,8 +480,8 @@ func (this exampleTimestampTable) Delete(ctx context.Context, exampleTimestamp * return this.table.Delete(ctx, exampleTimestamp) } -func (this exampleTimestampTable) InsertReturningID(ctx context.Context, exampleTimestamp *ExampleTimestamp) (uint64, error) { - return this.table.InsertReturningID(ctx, exampleTimestamp) +func (this exampleTimestampTable) InsertReturningId(ctx context.Context, exampleTimestamp *ExampleTimestamp) (uint64, error) { + return this.table.InsertReturningPKey(ctx, exampleTimestamp) } func (this exampleTimestampTable) Has(ctx context.Context, id uint64) (found bool, err error) { @@ -680,12 +680,132 @@ func NewSimpleExampleTable(db ormtable.Schema) (SimpleExampleTable, error) { return simpleExampleTable{table}, nil } +type ExampleAutoIncFieldNameTable interface { + Insert(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) error + InsertReturningFoo(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) (uint64, error) + Update(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) error + Save(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) error + Delete(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) error + Has(ctx context.Context, foo uint64) (found bool, err error) + // Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found. + Get(ctx context.Context, foo uint64) (*ExampleAutoIncFieldName, error) + List(ctx context.Context, prefixKey ExampleAutoIncFieldNameIndexKey, opts ...ormlist.Option) (ExampleAutoIncFieldNameIterator, error) + ListRange(ctx context.Context, from, to ExampleAutoIncFieldNameIndexKey, opts ...ormlist.Option) (ExampleAutoIncFieldNameIterator, error) + DeleteBy(ctx context.Context, prefixKey ExampleAutoIncFieldNameIndexKey) error + DeleteRange(ctx context.Context, from, to ExampleAutoIncFieldNameIndexKey) error + + doNotImplement() +} + +type ExampleAutoIncFieldNameIterator struct { + ormtable.Iterator +} + +func (i ExampleAutoIncFieldNameIterator) Value() (*ExampleAutoIncFieldName, error) { + var exampleAutoIncFieldName ExampleAutoIncFieldName + err := i.UnmarshalMessage(&exampleAutoIncFieldName) + return &exampleAutoIncFieldName, err +} + +type ExampleAutoIncFieldNameIndexKey interface { + id() uint32 + values() []interface{} + exampleAutoIncFieldNameIndexKey() +} + +// primary key starting index.. +type ExampleAutoIncFieldNamePrimaryKey = ExampleAutoIncFieldNameFooIndexKey + +type ExampleAutoIncFieldNameFooIndexKey struct { + vs []interface{} +} + +func (x ExampleAutoIncFieldNameFooIndexKey) id() uint32 { return 0 } +func (x ExampleAutoIncFieldNameFooIndexKey) values() []interface{} { return x.vs } +func (x ExampleAutoIncFieldNameFooIndexKey) exampleAutoIncFieldNameIndexKey() {} + +func (this ExampleAutoIncFieldNameFooIndexKey) WithFoo(foo uint64) ExampleAutoIncFieldNameFooIndexKey { + this.vs = []interface{}{foo} + return this +} + +type exampleAutoIncFieldNameTable struct { + table ormtable.AutoIncrementTable +} + +func (this exampleAutoIncFieldNameTable) Insert(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) error { + return this.table.Insert(ctx, exampleAutoIncFieldName) +} + +func (this exampleAutoIncFieldNameTable) Update(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) error { + return this.table.Update(ctx, exampleAutoIncFieldName) +} + +func (this exampleAutoIncFieldNameTable) Save(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) error { + return this.table.Save(ctx, exampleAutoIncFieldName) +} + +func (this exampleAutoIncFieldNameTable) Delete(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) error { + return this.table.Delete(ctx, exampleAutoIncFieldName) +} + +func (this exampleAutoIncFieldNameTable) InsertReturningFoo(ctx context.Context, exampleAutoIncFieldName *ExampleAutoIncFieldName) (uint64, error) { + return this.table.InsertReturningPKey(ctx, exampleAutoIncFieldName) +} + +func (this exampleAutoIncFieldNameTable) Has(ctx context.Context, foo uint64) (found bool, err error) { + return this.table.PrimaryKey().Has(ctx, foo) +} + +func (this exampleAutoIncFieldNameTable) Get(ctx context.Context, foo uint64) (*ExampleAutoIncFieldName, error) { + var exampleAutoIncFieldName ExampleAutoIncFieldName + found, err := this.table.PrimaryKey().Get(ctx, &exampleAutoIncFieldName, foo) + if err != nil { + return nil, err + } + if !found { + return nil, ormerrors.NotFound + } + return &exampleAutoIncFieldName, nil +} + +func (this exampleAutoIncFieldNameTable) List(ctx context.Context, prefixKey ExampleAutoIncFieldNameIndexKey, opts ...ormlist.Option) (ExampleAutoIncFieldNameIterator, error) { + it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...) + return ExampleAutoIncFieldNameIterator{it}, err +} + +func (this exampleAutoIncFieldNameTable) ListRange(ctx context.Context, from, to ExampleAutoIncFieldNameIndexKey, opts ...ormlist.Option) (ExampleAutoIncFieldNameIterator, error) { + it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...) + return ExampleAutoIncFieldNameIterator{it}, err +} + +func (this exampleAutoIncFieldNameTable) DeleteBy(ctx context.Context, prefixKey ExampleAutoIncFieldNameIndexKey) error { + return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...) +} + +func (this exampleAutoIncFieldNameTable) DeleteRange(ctx context.Context, from, to ExampleAutoIncFieldNameIndexKey) error { + return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values()) +} + +func (this exampleAutoIncFieldNameTable) doNotImplement() {} + +var _ ExampleAutoIncFieldNameTable = exampleAutoIncFieldNameTable{} + +func NewExampleAutoIncFieldNameTable(db ormtable.Schema) (ExampleAutoIncFieldNameTable, error) { + table := db.GetTable(&ExampleAutoIncFieldName{}) + if table == nil { + return nil, ormerrors.TableNotFound.Wrap(string((&ExampleAutoIncFieldName{}).ProtoReflect().Descriptor().FullName())) + } + return exampleAutoIncFieldNameTable{table.(ormtable.AutoIncrementTable)}, nil +} + type TestSchemaStore interface { ExampleTableTable() ExampleTableTable ExampleAutoIncrementTableTable() ExampleAutoIncrementTableTable ExampleSingletonTable() ExampleSingletonTable ExampleTimestampTable() ExampleTimestampTable SimpleExampleTable() SimpleExampleTable + ExampleAutoIncFieldNameTable() ExampleAutoIncFieldNameTable doNotImplement() } @@ -696,6 +816,7 @@ type testSchemaStore struct { exampleSingleton ExampleSingletonTable exampleTimestamp ExampleTimestampTable simpleExample SimpleExampleTable + exampleAutoIncFieldName ExampleAutoIncFieldNameTable } func (x testSchemaStore) ExampleTableTable() ExampleTableTable { @@ -718,6 +839,10 @@ func (x testSchemaStore) SimpleExampleTable() SimpleExampleTable { return x.simpleExample } +func (x testSchemaStore) ExampleAutoIncFieldNameTable() ExampleAutoIncFieldNameTable { + return x.exampleAutoIncFieldName +} + func (testSchemaStore) doNotImplement() {} var _ TestSchemaStore = testSchemaStore{} @@ -748,11 +873,17 @@ func NewTestSchemaStore(db ormtable.Schema) (TestSchemaStore, error) { return nil, err } + exampleAutoIncFieldNameTable, err := NewExampleAutoIncFieldNameTable(db) + if err != nil { + return nil, err + } + return testSchemaStore{ exampleTableTable, exampleAutoIncrementTableTable, exampleSingletonTable, exampleTimestampTable, simpleExampleTable, + exampleAutoIncFieldNameTable, }, nil } diff --git a/orm/internal/testpb/test_schema.proto b/orm/internal/testpb/test_schema.proto index 0fe4167c625d..ca2137531cf8 100644 --- a/orm/internal/testpb/test_schema.proto +++ b/orm/internal/testpb/test_schema.proto @@ -115,4 +115,14 @@ message SimpleExample { string name = 1; string unique = 2; string not_unique = 3; +} + +// ExampleAutoIncFieldName is a table for testing InsertReturning. +message ExampleAutoIncFieldName { + option (cosmos.orm.v1.table) = { + id: 6 + primary_key: {fields: "foo" auto_increment: true} + }; + uint64 foo = 1; + uint64 bar = 2; } \ No newline at end of file diff --git a/orm/internal/testpb/test_schema.pulsar.go b/orm/internal/testpb/test_schema.pulsar.go index d69e8bb1b450..25719593c075 100644 --- a/orm/internal/testpb/test_schema.pulsar.go +++ b/orm/internal/testpb/test_schema.pulsar.go @@ -1872,7 +1872,7 @@ func (x *ExampleTable_ExampleMessage) ProtoReflect() protoreflect.Message { } func (x *ExampleTable_ExampleMessage) slowProtoReflect() protoreflect.Message { - mi := &file_testpb_test_schema_proto_msgTypes[6] + mi := &file_testpb_test_schema_proto_msgTypes[7] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -4397,6 +4397,458 @@ func (x *fastReflection_SimpleExample) ProtoMethods() *protoiface.Methods { } } +var ( + md_ExampleAutoIncFieldName protoreflect.MessageDescriptor + fd_ExampleAutoIncFieldName_foo protoreflect.FieldDescriptor + fd_ExampleAutoIncFieldName_bar protoreflect.FieldDescriptor +) + +func init() { + file_testpb_test_schema_proto_init() + md_ExampleAutoIncFieldName = File_testpb_test_schema_proto.Messages().ByName("ExampleAutoIncFieldName") + fd_ExampleAutoIncFieldName_foo = md_ExampleAutoIncFieldName.Fields().ByName("foo") + fd_ExampleAutoIncFieldName_bar = md_ExampleAutoIncFieldName.Fields().ByName("bar") +} + +var _ protoreflect.Message = (*fastReflection_ExampleAutoIncFieldName)(nil) + +type fastReflection_ExampleAutoIncFieldName ExampleAutoIncFieldName + +func (x *ExampleAutoIncFieldName) ProtoReflect() protoreflect.Message { + return (*fastReflection_ExampleAutoIncFieldName)(x) +} + +func (x *ExampleAutoIncFieldName) slowProtoReflect() protoreflect.Message { + mi := &file_testpb_test_schema_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_ExampleAutoIncFieldName_messageType fastReflection_ExampleAutoIncFieldName_messageType +var _ protoreflect.MessageType = fastReflection_ExampleAutoIncFieldName_messageType{} + +type fastReflection_ExampleAutoIncFieldName_messageType struct{} + +func (x fastReflection_ExampleAutoIncFieldName_messageType) Zero() protoreflect.Message { + return (*fastReflection_ExampleAutoIncFieldName)(nil) +} +func (x fastReflection_ExampleAutoIncFieldName_messageType) New() protoreflect.Message { + return new(fastReflection_ExampleAutoIncFieldName) +} +func (x fastReflection_ExampleAutoIncFieldName_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_ExampleAutoIncFieldName +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_ExampleAutoIncFieldName) Descriptor() protoreflect.MessageDescriptor { + return md_ExampleAutoIncFieldName +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_ExampleAutoIncFieldName) Type() protoreflect.MessageType { + return _fastReflection_ExampleAutoIncFieldName_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_ExampleAutoIncFieldName) New() protoreflect.Message { + return new(fastReflection_ExampleAutoIncFieldName) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_ExampleAutoIncFieldName) Interface() protoreflect.ProtoMessage { + return (*ExampleAutoIncFieldName)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_ExampleAutoIncFieldName) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Foo != uint64(0) { + value := protoreflect.ValueOfUint64(x.Foo) + if !f(fd_ExampleAutoIncFieldName_foo, value) { + return + } + } + if x.Bar != uint64(0) { + value := protoreflect.ValueOfUint64(x.Bar) + if !f(fd_ExampleAutoIncFieldName_bar, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_ExampleAutoIncFieldName) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "testpb.ExampleAutoIncFieldName.foo": + return x.Foo != uint64(0) + case "testpb.ExampleAutoIncFieldName.bar": + return x.Bar != uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.ExampleAutoIncFieldName")) + } + panic(fmt.Errorf("message testpb.ExampleAutoIncFieldName does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ExampleAutoIncFieldName) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "testpb.ExampleAutoIncFieldName.foo": + x.Foo = uint64(0) + case "testpb.ExampleAutoIncFieldName.bar": + x.Bar = uint64(0) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.ExampleAutoIncFieldName")) + } + panic(fmt.Errorf("message testpb.ExampleAutoIncFieldName does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_ExampleAutoIncFieldName) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "testpb.ExampleAutoIncFieldName.foo": + value := x.Foo + return protoreflect.ValueOfUint64(value) + case "testpb.ExampleAutoIncFieldName.bar": + value := x.Bar + return protoreflect.ValueOfUint64(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.ExampleAutoIncFieldName")) + } + panic(fmt.Errorf("message testpb.ExampleAutoIncFieldName does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ExampleAutoIncFieldName) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "testpb.ExampleAutoIncFieldName.foo": + x.Foo = value.Uint() + case "testpb.ExampleAutoIncFieldName.bar": + x.Bar = value.Uint() + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.ExampleAutoIncFieldName")) + } + panic(fmt.Errorf("message testpb.ExampleAutoIncFieldName does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ExampleAutoIncFieldName) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "testpb.ExampleAutoIncFieldName.foo": + panic(fmt.Errorf("field foo of message testpb.ExampleAutoIncFieldName is not mutable")) + case "testpb.ExampleAutoIncFieldName.bar": + panic(fmt.Errorf("field bar of message testpb.ExampleAutoIncFieldName is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.ExampleAutoIncFieldName")) + } + panic(fmt.Errorf("message testpb.ExampleAutoIncFieldName does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_ExampleAutoIncFieldName) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "testpb.ExampleAutoIncFieldName.foo": + return protoreflect.ValueOfUint64(uint64(0)) + case "testpb.ExampleAutoIncFieldName.bar": + return protoreflect.ValueOfUint64(uint64(0)) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: testpb.ExampleAutoIncFieldName")) + } + panic(fmt.Errorf("message testpb.ExampleAutoIncFieldName does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_ExampleAutoIncFieldName) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in testpb.ExampleAutoIncFieldName", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_ExampleAutoIncFieldName) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_ExampleAutoIncFieldName) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_ExampleAutoIncFieldName) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_ExampleAutoIncFieldName) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*ExampleAutoIncFieldName) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + if x.Foo != 0 { + n += 1 + runtime.Sov(uint64(x.Foo)) + } + if x.Bar != 0 { + n += 1 + runtime.Sov(uint64(x.Bar)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*ExampleAutoIncFieldName) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.Bar != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Bar)) + i-- + dAtA[i] = 0x10 + } + if x.Foo != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Foo)) + i-- + dAtA[i] = 0x8 + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*ExampleAutoIncFieldName) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ExampleAutoIncFieldName: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: ExampleAutoIncFieldName: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Foo", wireType) + } + x.Foo = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Foo |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Bar", wireType) + } + x.Bar = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Bar |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.0 @@ -4869,6 +5321,50 @@ func (x *SimpleExample) GetNotUnique() string { return "" } +// ExampleAutoIncFieldName is a table for testing InsertReturning. +type ExampleAutoIncFieldName struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Foo uint64 `protobuf:"varint,1,opt,name=foo,proto3" json:"foo,omitempty"` + Bar uint64 `protobuf:"varint,2,opt,name=bar,proto3" json:"bar,omitempty"` +} + +func (x *ExampleAutoIncFieldName) Reset() { + *x = ExampleAutoIncFieldName{} + if protoimpl.UnsafeEnabled { + mi := &file_testpb_test_schema_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ExampleAutoIncFieldName) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExampleAutoIncFieldName) ProtoMessage() {} + +// Deprecated: Use ExampleAutoIncFieldName.ProtoReflect.Descriptor instead. +func (*ExampleAutoIncFieldName) Descriptor() ([]byte, []int) { + return file_testpb_test_schema_proto_rawDescGZIP(), []int{5} +} + +func (x *ExampleAutoIncFieldName) GetFoo() uint64 { + if x != nil { + return x.Foo + } + return 0 +} + +func (x *ExampleAutoIncFieldName) GetBar() uint64 { + if x != nil { + return x.Bar + } + return 0 +} + type ExampleTable_ExampleMessage struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -4881,7 +5377,7 @@ type ExampleTable_ExampleMessage struct { func (x *ExampleTable_ExampleMessage) Reset() { *x = ExampleTable_ExampleMessage{} if protoimpl.UnsafeEnabled { - mi := &file_testpb_test_schema_proto_msgTypes[6] + mi := &file_testpb_test_schema_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -4992,23 +5488,28 @@ var file_testpb_test_schema_proto_rawDesc = []byte{ 0x0a, 0x6e, 0x6f, 0x74, 0x5f, 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x6f, 0x74, 0x55, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x3a, 0x1e, 0xf2, 0x9e, 0xd3, 0x8e, 0x03, 0x18, 0x0a, 0x06, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0c, 0x0a, 0x06, - 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x10, 0x01, 0x18, 0x01, 0x18, 0x05, 0x2a, 0x64, 0x0a, 0x04, - 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x55, 0x4e, 0x53, - 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, - 0x55, 0x4d, 0x5f, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, 0x55, 0x4d, - 0x5f, 0x54, 0x57, 0x4f, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x46, - 0x49, 0x56, 0x45, 0x10, 0x05, 0x12, 0x1b, 0x0a, 0x0e, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x4e, 0x45, - 0x47, 0x5f, 0x54, 0x48, 0x52, 0x45, 0x45, 0x10, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0x01, 0x42, 0x87, 0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x70, - 0x62, 0x42, 0x0f, 0x54, 0x65, 0x73, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, 0x72, 0x6f, - 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2d, 0x73, - 0x64, 0x6b, 0x2f, 0x6f, 0x72, 0x6d, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, - 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x54, - 0x65, 0x73, 0x74, 0x70, 0x62, 0xca, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xe2, 0x02, - 0x12, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0xea, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x75, 0x6e, 0x69, 0x71, 0x75, 0x65, 0x10, 0x01, 0x18, 0x01, 0x18, 0x05, 0x22, 0x50, 0x0a, 0x17, + 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x41, 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x46, 0x69, + 0x65, 0x6c, 0x64, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x12, 0x10, 0x0a, 0x03, 0x62, 0x61, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x62, 0x61, 0x72, 0x3a, 0x11, 0xf2, 0x9e, 0xd3, + 0x8e, 0x03, 0x0b, 0x0a, 0x07, 0x0a, 0x03, 0x66, 0x6f, 0x6f, 0x10, 0x01, 0x18, 0x06, 0x2a, 0x64, + 0x0a, 0x04, 0x45, 0x6e, 0x75, 0x6d, 0x12, 0x14, 0x0a, 0x10, 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x55, + 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, + 0x45, 0x4e, 0x55, 0x4d, 0x5f, 0x4f, 0x4e, 0x45, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x45, 0x4e, + 0x55, 0x4d, 0x5f, 0x54, 0x57, 0x4f, 0x10, 0x02, 0x12, 0x0d, 0x0a, 0x09, 0x45, 0x4e, 0x55, 0x4d, + 0x5f, 0x46, 0x49, 0x56, 0x45, 0x10, 0x05, 0x12, 0x1b, 0x0a, 0x0e, 0x45, 0x4e, 0x55, 0x4d, 0x5f, + 0x4e, 0x45, 0x47, 0x5f, 0x54, 0x48, 0x52, 0x45, 0x45, 0x10, 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0x01, 0x42, 0x87, 0x01, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x74, 0x65, 0x73, + 0x74, 0x70, 0x62, 0x42, 0x0f, 0x54, 0x65, 0x73, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x50, + 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x6f, 0x72, 0x6d, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x70, 0x62, 0xa2, 0x02, 0x03, 0x54, 0x58, 0x58, 0xaa, 0x02, + 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0xca, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, + 0xe2, 0x02, 0x12, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, + 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x06, 0x54, 0x65, 0x73, 0x74, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -5024,7 +5525,7 @@ func file_testpb_test_schema_proto_rawDescGZIP() []byte { } var file_testpb_test_schema_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_testpb_test_schema_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_testpb_test_schema_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_testpb_test_schema_proto_goTypes = []interface{}{ (Enum)(0), // 0: testpb.Enum (*ExampleTable)(nil), // 1: testpb.ExampleTable @@ -5032,23 +5533,24 @@ var file_testpb_test_schema_proto_goTypes = []interface{}{ (*ExampleSingleton)(nil), // 3: testpb.ExampleSingleton (*ExampleTimestamp)(nil), // 4: testpb.ExampleTimestamp (*SimpleExample)(nil), // 5: testpb.SimpleExample - nil, // 6: testpb.ExampleTable.MapEntry - (*ExampleTable_ExampleMessage)(nil), // 7: testpb.ExampleTable.ExampleMessage - (*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp - (*durationpb.Duration)(nil), // 9: google.protobuf.Duration + (*ExampleAutoIncFieldName)(nil), // 6: testpb.ExampleAutoIncFieldName + nil, // 7: testpb.ExampleTable.MapEntry + (*ExampleTable_ExampleMessage)(nil), // 8: testpb.ExampleTable.ExampleMessage + (*timestamppb.Timestamp)(nil), // 9: google.protobuf.Timestamp + (*durationpb.Duration)(nil), // 10: google.protobuf.Duration } var file_testpb_test_schema_proto_depIdxs = []int32{ - 8, // 0: testpb.ExampleTable.ts:type_name -> google.protobuf.Timestamp - 9, // 1: testpb.ExampleTable.dur:type_name -> google.protobuf.Duration - 0, // 2: testpb.ExampleTable.e:type_name -> testpb.Enum - 6, // 3: testpb.ExampleTable.map:type_name -> testpb.ExampleTable.MapEntry - 7, // 4: testpb.ExampleTable.msg:type_name -> testpb.ExampleTable.ExampleMessage - 8, // 5: testpb.ExampleTimestamp.ts:type_name -> google.protobuf.Timestamp - 6, // [6:6] is the sub-list for method output_type - 6, // [6:6] is the sub-list for method input_type - 6, // [6:6] is the sub-list for extension type_name - 6, // [6:6] is the sub-list for extension extendee - 0, // [0:6] is the sub-list for field type_name + 9, // 0: testpb.ExampleTable.ts:type_name -> google.protobuf.Timestamp + 10, // 1: testpb.ExampleTable.dur:type_name -> google.protobuf.Duration + 0, // 2: testpb.ExampleTable.e:type_name -> testpb.Enum + 7, // 3: testpb.ExampleTable.map:type_name -> testpb.ExampleTable.MapEntry + 8, // 4: testpb.ExampleTable.msg:type_name -> testpb.ExampleTable.ExampleMessage + 9, // 5: testpb.ExampleTimestamp.ts:type_name -> google.protobuf.Timestamp + 6, // [6:6] is the sub-list for method output_type + 6, // [6:6] is the sub-list for method input_type + 6, // [6:6] is the sub-list for extension type_name + 6, // [6:6] is the sub-list for extension extendee + 0, // [0:6] is the sub-list for field type_name } func init() { file_testpb_test_schema_proto_init() } @@ -5117,7 +5619,19 @@ func file_testpb_test_schema_proto_init() { return nil } } - file_testpb_test_schema_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_testpb_test_schema_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ExampleAutoIncFieldName); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_testpb_test_schema_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*ExampleTable_ExampleMessage); i { case 0: return &v.state @@ -5139,7 +5653,7 @@ func file_testpb_test_schema_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_testpb_test_schema_proto_rawDesc, NumEnums: 1, - NumMessages: 7, + NumMessages: 8, NumExtensions: 0, NumServices: 0, }, diff --git a/orm/model/ormdb/json.go b/orm/model/ormdb/json.go index c8c78252ea1a..3a64ae52fbe6 100644 --- a/orm/model/ormdb/json.go +++ b/orm/model/ormdb/json.go @@ -11,7 +11,7 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" - "github.com/cosmos/cosmos-sdk/errors" + "cosmossdk.io/errors" ) func (m moduleDB) DefaultJSON(target ormjson.WriteTarget) error { diff --git a/orm/model/ormdb/module.go b/orm/model/ormdb/module.go index dfdc63f72047..4c6e1a0a34c5 100644 --- a/orm/model/ormdb/module.go +++ b/orm/model/ormdb/module.go @@ -51,7 +51,6 @@ type moduleDB struct { // ModuleDBOptions are options for constructing a ModuleDB. type ModuleDBOptions struct { - // TypeResolver is an optional type resolver to be used when unmarshaling // protobuf messages. If it is nil, protoregistry.GlobalTypes will be used. TypeResolver ormtable.TypeResolver diff --git a/orm/model/ormdb/module_test.go b/orm/model/ormdb/module_test.go index d7150455111d..5bb7a68420e5 100644 --- a/orm/model/ormdb/module_test.go +++ b/orm/model/ormdb/module_test.go @@ -355,13 +355,14 @@ func TestGetBackendResolver(t *testing.T) { }) assert.ErrorContains(t, err, "unsupported") - _, err = ormdb.NewModuleDB(&ormv1alpha1.ModuleSchemaDescriptor{SchemaFile: []*ormv1alpha1.ModuleSchemaDescriptor_FileEntry{ - { - Id: 1, - ProtoFileName: testpb.File_testpb_bank_proto.Path(), - StorageType: ormv1alpha1.StorageType_STORAGE_TYPE_MEMORY, + _, err = ormdb.NewModuleDB(&ormv1alpha1.ModuleSchemaDescriptor{ + SchemaFile: []*ormv1alpha1.ModuleSchemaDescriptor_FileEntry{ + { + Id: 1, + ProtoFileName: testpb.File_testpb_bank_proto.Path(), + StorageType: ormv1alpha1.StorageType_STORAGE_TYPE_MEMORY, + }, }, - }, }, ormdb.ModuleDBOptions{ GetBackendResolver: getResolver, }) diff --git a/orm/model/ormtable/auto_increment.go b/orm/model/ormtable/auto_increment.go index 40f625b73fac..2a0eed6f94b6 100644 --- a/orm/model/ormtable/auto_increment.go +++ b/orm/model/ormtable/auto_increment.go @@ -22,7 +22,7 @@ type autoIncrementTable struct { seqCodec *ormkv.SeqCodec } -func (t autoIncrementTable) InsertReturningID(ctx context.Context, message proto.Message) (newId uint64, err error) { +func (t autoIncrementTable) InsertReturningPKey(ctx context.Context, message proto.Message) (newPK uint64, err error) { backend, err := t.getWriteBackend(ctx) if err != nil { return 0, err @@ -61,7 +61,7 @@ func (t autoIncrementTable) Update(ctx context.Context, message proto.Message) e return err } -func (t *autoIncrementTable) save(ctx context.Context, backend Backend, message proto.Message, mode saveMode) (newId uint64, err error) { +func (t *autoIncrementTable) save(ctx context.Context, backend Backend, message proto.Message, mode saveMode) (newPK uint64, err error) { messageRef := message.ProtoReflect() val := messageRef.Get(t.autoIncField).Uint() writer := newBatchIndexCommitmentWriter(backend) @@ -73,12 +73,12 @@ func (t *autoIncrementTable) save(ctx context.Context, backend Backend, message } mode = saveModeInsert - newId, err = t.nextSeqValue(writer.IndexStore()) + newPK, err = t.nextSeqValue(writer.IndexStore()) if err != nil { return 0, err } - messageRef.Set(t.autoIncField, protoreflect.ValueOfUint64(newId)) + messageRef.Set(t.autoIncField, protoreflect.ValueOfUint64(newPK)) } else { if mode == saveModeInsert { return 0, ormerrors.AutoIncrementKeyAlreadySet @@ -87,7 +87,7 @@ func (t *autoIncrementTable) save(ctx context.Context, backend Backend, message mode = saveModeUpdate } - return newId, t.tableImpl.doSave(ctx, writer, message, mode) + return newPK, t.tableImpl.doSave(ctx, writer, message, mode) } func (t *autoIncrementTable) curSeqValue(kv kv.ReadonlyStore) (uint64, error) { @@ -121,11 +121,12 @@ func (t autoIncrementTable) EncodeEntry(entry ormkv.Entry) (k, v []byte, err err } func (t autoIncrementTable) ValidateJSON(reader io.Reader) error { - return t.decodeAutoIncJson(nil, reader, func(message proto.Message, maxID uint64) error { + return t.decodeAutoIncJson(nil, reader, func(message proto.Message, maxSeq uint64) error { messageRef := message.ProtoReflect() - id := messageRef.Get(t.autoIncField).Uint() - if id > maxID { - return fmt.Errorf("invalid ID %d, expected a value <= %d, the highest sequence number", id, maxID) + pkey := messageRef.Get(t.autoIncField).Uint() + if pkey > maxSeq { + return fmt.Errorf("invalid auto increment primary key %d, expected a value <= %d, the highest "+ + "sequence number", pkey, maxSeq) } if t.customJSONValidator != nil { @@ -142,22 +143,23 @@ func (t autoIncrementTable) ImportJSON(ctx context.Context, reader io.Reader) er return err } - return t.decodeAutoIncJson(backend, reader, func(message proto.Message, maxID uint64) error { + return t.decodeAutoIncJson(backend, reader, func(message proto.Message, maxSeq uint64) error { messageRef := message.ProtoReflect() - id := messageRef.Get(t.autoIncField).Uint() - if id == 0 { - // we don't have an ID in the JSON, so we call Save to insert and + pkey := messageRef.Get(t.autoIncField).Uint() + if pkey == 0 { + // we don't have a primary key in the JSON, so we call Save to insert and // generate one _, err = t.save(ctx, backend, message, saveModeInsert) return err } else { - if id > maxID { - return fmt.Errorf("invalid ID %d, expected a value <= %d, the highest sequence number", id, maxID) + if pkey > maxSeq { + return fmt.Errorf("invalid auto increment primary key %d, expected a value <= %d, the highest "+ + "sequence number", pkey, maxSeq) } - // we do have an ID and calling Save will fail because it expects - // either no ID or SAVE_MODE_UPDATE. So instead we drop one level + // we do have a primary key and calling Save will fail because it expects + // either no primary key or SAVE_MODE_UPDATE. So instead we drop one level // down and insert using tableImpl which doesn't know about - // auto-incrementing IDs + // auto-incrementing primary keys. return t.tableImpl.save(ctx, backend, message, saveModeInsert) } }) diff --git a/orm/model/ormtable/auto_increment_test.go b/orm/model/ormtable/auto_increment_test.go index 4f1556f4f1a3..c3180000dc5a 100644 --- a/orm/model/ormtable/auto_increment_test.go +++ b/orm/model/ormtable/auto_increment_test.go @@ -54,7 +54,7 @@ func runAutoIncrementScenario(t *testing.T, table ormtable.AutoIncrementTable, c assert.Equal(t, uint64(1), ex1.Id) ex2 := &testpb.ExampleAutoIncrementTable{X: "bar", Y: 10} - newId, err := table.InsertReturningID(ctx, ex2) + newId, err := table.InsertReturningPKey(ctx, ex2) assert.NilError(t, err) assert.Equal(t, uint64(2), ex2.Id) assert.Equal(t, newId, ex2.Id) @@ -89,9 +89,9 @@ func TestBadJSON(t *testing.T) { store := ormtable.WrapContextDefault(testkv.NewSplitMemBackend()) f, err := os.Open("testdata/bad_auto_inc.json") assert.NilError(t, err) - assert.ErrorContains(t, table.ImportJSON(store, f), "invalid ID") + assert.ErrorContains(t, table.ImportJSON(store, f), "invalid auto increment primary key") f, err = os.Open("testdata/bad_auto_inc2.json") assert.NilError(t, err) - assert.ErrorContains(t, table.ImportJSON(store, f), "invalid ID") + assert.ErrorContains(t, table.ImportJSON(store, f), "invalid auto increment primary key") } diff --git a/orm/model/ormtable/backend.go b/orm/model/ormtable/backend.go index 8013309d0fab..66ff949ad5c0 100644 --- a/orm/model/ormtable/backend.go +++ b/orm/model/ormtable/backend.go @@ -50,7 +50,6 @@ type Backend interface { // If the index store is not defined, the commitment store will be // used for all operations. type ReadBackendOptions struct { - // CommitmentStoreReader is a reader for the commitment store. CommitmentStoreReader kv.ReadonlyStore @@ -135,7 +134,6 @@ func (c backend) IndexStore() kv.Store { // If the index store is not defined, the commitment store will be // used for all operations. type BackendOptions struct { - // CommitmentStore is the commitment store. CommitmentStore kv.Store diff --git a/orm/model/ormtable/batch.go b/orm/model/ormtable/batch.go index c34dbf44464a..7983bee77269 100644 --- a/orm/model/ormtable/batch.go +++ b/orm/model/ormtable/batch.go @@ -75,7 +75,6 @@ func flushBuf(store kv.Store, writes []*batchWriterEntry) error { return err } } - } return nil } diff --git a/orm/model/ormtable/bench_test.go b/orm/model/ormtable/bench_test.go new file mode 100644 index 000000000000..6194b3cfed46 --- /dev/null +++ b/orm/model/ormtable/bench_test.go @@ -0,0 +1,315 @@ +package ormtable_test + +import ( + "context" + "fmt" + "testing" + + "google.golang.org/protobuf/proto" + + "github.com/cosmos/cosmos-sdk/orm/internal/testkv" + "github.com/cosmos/cosmos-sdk/orm/testing/ormtest" + + dbm "github.com/tendermint/tm-db" + "gotest.tools/v3/assert" + + "github.com/cosmos/cosmos-sdk/orm/internal/testpb" + "github.com/cosmos/cosmos-sdk/orm/model/ormtable" + "github.com/cosmos/cosmos-sdk/orm/types/kv" +) + +func initBalanceTable(t testing.TB) testpb.BalanceTable { + table, err := ormtable.Build(ormtable.Options{ + MessageType: (&testpb.Balance{}).ProtoReflect().Type(), + }) + assert.NilError(t, err) + + balanceTable, err := testpb.NewBalanceTable(table) + assert.NilError(t, err) + + return balanceTable +} + +func BenchmarkMemory(b *testing.B) { + bench(b, func(tb testing.TB) ormtable.Backend { + return ormtest.NewMemoryBackend() + }) +} + +func BenchmarkLevelDB(b *testing.B) { + bench(b, testkv.NewGoLevelDBBackend) +} + +func bench(b *testing.B, newBackend func(testing.TB) ormtable.Backend) { + b.Run("insert", func(b *testing.B) { + b.StopTimer() + ctx := ormtable.WrapContextDefault(newBackend(b)) + b.StartTimer() + benchInsert(b, ctx) + }) + b.Run("update", func(b *testing.B) { + b.StopTimer() + ctx := ormtable.WrapContextDefault(newBackend(b)) + benchInsert(b, ctx) + b.StartTimer() + benchUpdate(b, ctx) + }) + b.Run("get", func(b *testing.B) { + b.StopTimer() + ctx := ormtable.WrapContextDefault(newBackend(b)) + benchInsert(b, ctx) + b.StartTimer() + benchGet(b, ctx) + }) + b.Run("delete", func(b *testing.B) { + b.StopTimer() + ctx := ormtable.WrapContextDefault(newBackend(b)) + benchInsert(b, ctx) + b.StartTimer() + benchDelete(b, ctx) + }) +} + +func benchInsert(b *testing.B, ctx context.Context) { + balanceTable := initBalanceTable(b) + for i := 0; i < b.N; i++ { + assert.NilError(b, balanceTable.Insert(ctx, &testpb.Balance{ + Address: fmt.Sprintf("acct%d", i), + Denom: "bar", + Amount: 10, + })) + } +} + +func benchUpdate(b *testing.B, ctx context.Context) { + balanceTable := initBalanceTable(b) + for i := 0; i < b.N; i++ { + assert.NilError(b, balanceTable.Update(ctx, &testpb.Balance{ + Address: fmt.Sprintf("acct%d", i), + Denom: "bar", + Amount: 11, + })) + } +} + +func benchGet(b *testing.B, ctx context.Context) { + balanceTable := initBalanceTable(b) + for i := 0; i < b.N; i++ { + balance, err := balanceTable.Get(ctx, fmt.Sprintf("acct%d", i), "bar") + assert.NilError(b, err) + assert.Equal(b, uint64(10), balance.Amount) + } +} + +func benchDelete(b *testing.B, ctx context.Context) { + balanceTable := initBalanceTable(b) + for i := 0; i < b.N; i++ { + assert.NilError(b, balanceTable.Delete(ctx, &testpb.Balance{ + Address: fmt.Sprintf("acct%d", i), + Denom: "bar", + })) + } +} + +// +// Manually written versions of insert, update, delete and get for testpb.Balance +// + +const ( + addressDenomPrefix byte = iota + denomAddressPrefix +) + +func insertBalance(store kv.Store, balance *testpb.Balance) error { + denom := balance.Denom + balance.Denom = "" + addr := balance.Address + balance.Address = "" + + addressDenomKey := []byte{addressDenomPrefix} + addressDenomKey = append(addressDenomKey, []byte(addr)...) + addressDenomKey = append(addressDenomKey, 0x0) + addressDenomKey = append(addressDenomKey, []byte(denom)...) + has, err := store.Has(addressDenomKey) + if err != nil { + return err + } + + if has { + return fmt.Errorf("already exists") + } + + bz, err := proto.Marshal(balance) + if err != nil { + return err + } + balance.Denom = denom + balance.Address = addr + + err = store.Set(addressDenomKey, bz) + if err != nil { + return err + } + + // set denom address index + denomAddressKey := []byte{denomAddressPrefix} + denomAddressKey = append(denomAddressKey, []byte(balance.Denom)...) + denomAddressKey = append(denomAddressKey, 0x0) + denomAddressKey = append(denomAddressKey, []byte(balance.Address)...) + err = store.Set(denomAddressKey, []byte{}) + if err != nil { + return err + } + + return nil +} + +func updateBalance(store kv.Store, balance *testpb.Balance) error { + denom := balance.Denom + balance.Denom = "" + addr := balance.Address + balance.Address = "" + bz, err := proto.Marshal(balance) + if err != nil { + return err + } + balance.Denom = denom + balance.Address = addr + + addressDenomKey := []byte{addressDenomPrefix} + addressDenomKey = append(addressDenomKey, []byte(addr)...) + addressDenomKey = append(addressDenomKey, 0x0) + addressDenomKey = append(addressDenomKey, []byte(denom)...) + + return store.Set(addressDenomKey, bz) +} + +func deleteBalance(store kv.Store, balance *testpb.Balance) error { + denom := balance.Denom + addr := balance.Address + + addressDenomKey := []byte{addressDenomPrefix} + addressDenomKey = append(addressDenomKey, []byte(addr)...) + addressDenomKey = append(addressDenomKey, 0x0) + addressDenomKey = append(addressDenomKey, []byte(denom)...) + err := store.Delete(addressDenomKey) + if err != nil { + return err + } + + denomAddressKey := []byte{denomAddressPrefix} + denomAddressKey = append(denomAddressKey, []byte(balance.Denom)...) + denomAddressKey = append(denomAddressKey, 0x0) + denomAddressKey = append(denomAddressKey, []byte(balance.Address)...) + return store.Delete(denomAddressKey) +} + +func getBalance(store kv.Store, address, denom string) (*testpb.Balance, error) { + addressDenomKey := []byte{addressDenomPrefix} + addressDenomKey = append(addressDenomKey, []byte(address)...) + addressDenomKey = append(addressDenomKey, 0x0) + addressDenomKey = append(addressDenomKey, []byte(denom)...) + + bz, err := store.Get(addressDenomKey) + if err != nil { + return nil, err + } + + if bz == nil { + return nil, fmt.Errorf("not found") + } + + balance := testpb.Balance{} + err = proto.Unmarshal(bz, &balance) + if err != nil { + return nil, err + } + + balance.Address = address + balance.Denom = denom + + return &balance, nil +} + +func BenchmarkManualInsertMemory(b *testing.B) { + benchManual(b, func() (dbm.DB, error) { + return dbm.NewMemDB(), nil + }) +} + +func BenchmarkManualInsertLevelDB(b *testing.B) { + benchManual(b, func() (dbm.DB, error) { + return dbm.NewGoLevelDB("test", b.TempDir()) + }) +} + +func benchManual(b *testing.B, newStore func() (dbm.DB, error)) { + b.Run("insert", func(b *testing.B) { + b.StopTimer() + store, err := newStore() + assert.NilError(b, err) + b.StartTimer() + benchManualInsert(b, store) + }) + b.Run("update", func(b *testing.B) { + b.StopTimer() + store, err := newStore() + assert.NilError(b, err) + benchManualInsert(b, store) + b.StartTimer() + benchManualUpdate(b, store) + }) + b.Run("get", func(b *testing.B) { + b.StopTimer() + store, err := newStore() + assert.NilError(b, err) + benchManualInsert(b, store) + b.StartTimer() + benchManualGet(b, store) + }) + b.Run("delete", func(b *testing.B) { + b.StopTimer() + store, err := newStore() + assert.NilError(b, err) + benchManualInsert(b, store) + b.StartTimer() + benchManualDelete(b, store) + }) +} + +func benchManualInsert(b *testing.B, store kv.Store) { + for i := 0; i < b.N; i++ { + assert.NilError(b, insertBalance(store, &testpb.Balance{ + Address: fmt.Sprintf("acct%d", i), + Denom: "bar", + Amount: 10, + })) + } +} + +func benchManualUpdate(b *testing.B, store kv.Store) { + for i := 0; i < b.N; i++ { + assert.NilError(b, updateBalance(store, &testpb.Balance{ + Address: fmt.Sprintf("acct%d", i), + Denom: "bar", + Amount: 11, + })) + } +} + +func benchManualDelete(b *testing.B, store kv.Store) { + for i := 0; i < b.N; i++ { + assert.NilError(b, deleteBalance(store, &testpb.Balance{ + Address: fmt.Sprintf("acct%d", i), + Denom: "bar", + })) + } +} + +func benchManualGet(b *testing.B, store kv.Store) { + for i := 0; i < b.N; i++ { + balance, err := getBalance(store, fmt.Sprintf("acct%d", i), "bar") + assert.NilError(b, err) + assert.Equal(b, uint64(10), balance.Amount) + } +} diff --git a/orm/model/ormtable/hooks.go b/orm/model/ormtable/hooks.go index 288bfd2b43db..c5a76a6af8fa 100644 --- a/orm/model/ormtable/hooks.go +++ b/orm/model/ormtable/hooks.go @@ -9,7 +9,6 @@ import ( // ValidateHooks defines an interface for a table hooks which can intercept // insert, update and delete operations and possibly return an error. type ValidateHooks interface { - // ValidateInsert is called before the message is inserted. // If error is not nil the insertion will fail. ValidateInsert(context.Context, proto.Message) error @@ -30,7 +29,6 @@ type ValidateHooks interface { // may be called but the enclosing transaction may still fail. The context // is provided in each method to help coordinate this. type WriteHooks interface { - // OnInsert is called after an message is inserted into the store. OnInsert(context.Context, proto.Message) diff --git a/orm/model/ormtable/index.go b/orm/model/ormtable/index.go index eb4974d6c13e..903c19348505 100644 --- a/orm/model/ormtable/index.go +++ b/orm/model/ormtable/index.go @@ -16,7 +16,6 @@ import ( // are stateless, with all state existing only in the store passed // to index methods. type Index interface { - // List does iteration over the index with the provided prefix key and options. // Prefix key values must correspond in type to the index's fields and the // number of values provided cannot exceed the number of fields in the index, diff --git a/orm/model/ormtable/index_impl.go b/orm/model/ormtable/index_impl.go index a566b93964a7..7289efc40af4 100644 --- a/orm/model/ormtable/index_impl.go +++ b/orm/model/ormtable/index_impl.go @@ -61,8 +61,10 @@ func (i indexKeyIndex) ListRange(ctx context.Context, from, to []interface{}, op return rangeIterator(backend.IndexStoreReader(), backend, i, i.KeyCodec, from, to, options) } -var _ indexer = &indexKeyIndex{} -var _ Index = &indexKeyIndex{} +var ( + _ indexer = &indexKeyIndex{} + _ Index = &indexKeyIndex{} +) func (i indexKeyIndex) doNotImplement() {} diff --git a/orm/model/ormtable/iterator.go b/orm/model/ormtable/iterator.go index 3aa62d314acf..baf662febd65 100644 --- a/orm/model/ormtable/iterator.go +++ b/orm/model/ormtable/iterator.go @@ -18,7 +18,6 @@ import ( // Instead you should do reads and writes separately, or use a helper // function like DeleteBy which does this efficiently. type Iterator interface { - // Next advances the iterator and returns true if a valid entry is found. // Next must be called before starting iteration. Next() bool diff --git a/orm/model/ormtable/paginate.go b/orm/model/ormtable/paginate.go index 56f30cf8fb04..7c38405c1443 100644 --- a/orm/model/ormtable/paginate.go +++ b/orm/model/ormtable/paginate.go @@ -76,7 +76,6 @@ func (it *paginationIterator) Next() bool { // so the index == total entries. it.pageRes.Total = uint64(it.i) } - } return false } diff --git a/orm/model/ormtable/save_test.go b/orm/model/ormtable/save_test.go index dc3a24edd0ca..564a8edb2f1d 100644 --- a/orm/model/ormtable/save_test.go +++ b/orm/model/ormtable/save_test.go @@ -3,11 +3,12 @@ package ormtable_test import ( "context" "fmt" + "testing" + "github.com/cosmos/cosmos-sdk/orm/model/ormtable" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/encoding/protojson" - "testing" "github.com/regen-network/gocuke" "gotest.tools/v3/assert" diff --git a/orm/model/ormtable/table.go b/orm/model/ormtable/table.go index 7594fcadbbf6..b66520ac8e61 100644 --- a/orm/model/ormtable/table.go +++ b/orm/model/ormtable/table.go @@ -153,7 +153,7 @@ type Schema interface { type AutoIncrementTable interface { Table - // InsertReturningID inserts the provided entry in the store and returns the newly - // generated ID for the message or an error. - InsertReturningID(ctx context.Context, message proto.Message) (newId uint64, err error) + // InsertReturningPKey inserts the provided entry in the store and returns the newly + // generated primary key for the message or an error. + InsertReturningPKey(ctx context.Context, message proto.Message) (newPK uint64, err error) } diff --git a/orm/model/ormtable/table_impl.go b/orm/model/ormtable/table_impl.go index b598161b6cf6..b0d77ccf7c69 100644 --- a/orm/model/ormtable/table_impl.go +++ b/orm/model/ormtable/table_impl.go @@ -414,8 +414,10 @@ func (t tableImpl) Get(ctx context.Context, message proto.Message) (found bool, return t.primaryKeyIndex.get(backend, message, keyValues) } -var _ Table = &tableImpl{} -var _ Schema = &tableImpl{} +var ( + _ Table = &tableImpl{} + _ Schema = &tableImpl{} +) type saveMode int diff --git a/orm/model/ormtable/table_test.go b/orm/model/ormtable/table_test.go index 06df3f3cb48b..d3f0f5925b4b 100644 --- a/orm/model/ormtable/table_test.go +++ b/orm/model/ormtable/table_test.go @@ -22,8 +22,9 @@ import ( "github.com/cosmos/cosmos-sdk/orm/types/kv" + sdkerrors "cosmossdk.io/errors" queryv1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/base/query/v1beta1" - sdkerrors "github.com/cosmos/cosmos-sdk/errors" + "github.com/cosmos/cosmos-sdk/orm/encoding/ormkv" "github.com/cosmos/cosmos-sdk/orm/internal/testkv" "github.com/cosmos/cosmos-sdk/orm/internal/testpb" @@ -97,7 +98,6 @@ func TestPaginationLimitCountTotal(t *testing.T) { pr := it.PageResponse() assert.Check(t, pr != nil) assert.Equal(t, uint64(3), pr.Total) - } func TestImportedMessageIterator(t *testing.T) { @@ -186,7 +186,7 @@ func runTestScenario(t *testing.T, table ormtable.Table, backend ormtable.Backen assert.Assert(t, it.Next()) msg, err := it.GetMessage() assert.NilError(t, err) - //t.Logf("data[%d] %v == %v", i, data[i], msg) + // t.Logf("data[%d] %v == %v", i, data[i], msg) assert.DeepEqual(t, data[i], msg, protocmp.Transform()) } // make sure the iterator is done @@ -497,7 +497,6 @@ func runTestScenario(t *testing.T, table ormtable.Table, backend ormtable.Backen it, err = store.List(ctx, testpb.ExampleTablePrimaryKey{}) assert.NilError(t, err) assertIteratorItems(it, 2, 6, 10) - } func TestRandomTableData(t *testing.T) { @@ -603,7 +602,6 @@ func testIndex(t *testing.T, model *IndexModel) { assert.DeepEqual(t, model.data[i], data2[i], protocmp.Transform()) } } - } func reverseData(data []proto.Message) []proto.Message { @@ -790,3 +788,18 @@ func TestReadonly(t *testing.T) { ctx := ormtable.WrapContextDefault(readBackend) assert.ErrorIs(t, ormerrors.ReadOnly, table.Insert(ctx, &testpb.ExampleTable{})) } + +func TestInsertReturningFieldName(t *testing.T) { + table, err := ormtable.Build(ormtable.Options{ + MessageType: (&testpb.ExampleAutoIncFieldName{}).ProtoReflect().Type(), + }) + backend := testkv.NewSplitMemBackend() + ctx := ormtable.WrapContextDefault(backend) + store, err := testpb.NewExampleAutoIncFieldNameTable(table) + assert.NilError(t, err) + foo, err := store.InsertReturningFoo(ctx, &testpb.ExampleAutoIncFieldName{ + Bar: 45, + }) + assert.NilError(t, err) + assert.Equal(t, uint64(1), foo) +} diff --git a/orm/model/ormtable/unique.go b/orm/model/ormtable/unique.go index 63386942ae09..912b9db16fd8 100644 --- a/orm/model/ormtable/unique.go +++ b/orm/model/ormtable/unique.go @@ -190,8 +190,10 @@ func (u uniqueKeyIndex) Fields() string { return u.fields.String() } -var _ indexer = &uniqueKeyIndex{} -var _ UniqueIndex = &uniqueKeyIndex{} +var ( + _ indexer = &uniqueKeyIndex{} + _ UniqueIndex = &uniqueKeyIndex{} +) // isNonTrivialUniqueKey checks if unique key fields are non-trivial, meaning that they // don't contain the full primary key. If they contain the full primary key, then diff --git a/orm/types/ormerrors/errors.go b/orm/types/ormerrors/errors.go index 7f660927ad5e..d62d1f0ba2b1 100644 --- a/orm/types/ormerrors/errors.go +++ b/orm/types/ormerrors/errors.go @@ -1,7 +1,7 @@ package ormerrors import ( - "github.com/cosmos/cosmos-sdk/errors" + "cosmossdk.io/errors" "google.golang.org/grpc/codes" ) diff --git a/proto/buf.gen.pulsar.yaml b/proto/buf.gen.pulsar.yaml index c1085e526134..fada5e7dd3b0 100644 --- a/proto/buf.gen.pulsar.yaml +++ b/proto/buf.gen.pulsar.yaml @@ -2,7 +2,7 @@ version: v1 managed: enabled: true go_package_prefix: - default: github.com/cosmos/cosmos-sdk/api + default: cosmossdk.io/api except: - buf.build/googleapis/googleapis - buf.build/cosmos/gogo-proto diff --git a/proto/cosmos/app/v1alpha1/module.proto b/proto/cosmos/app/v1alpha1/module.proto index 599078d7ee05..990857172ec5 100644 --- a/proto/cosmos/app/v1alpha1/module.proto +++ b/proto/cosmos/app/v1alpha1/module.proto @@ -18,10 +18,8 @@ extend google.protobuf.MessageOptions { // ModuleDescriptor describes an app module. message ModuleDescriptor { // go_import names the package that should be imported by an app to load the - // module in the runtime module registry. Either go_import must be defined here - // or the go_package option must be defined at the file level to indicate - // to users where to location the module implementation. go_import takes - // precedence over go_package when both are defined. + // module in the runtime module registry. It is required to make debugging + // of configuration errors easier for users. string go_import = 1; // use_package refers to a protobuf package that this module @@ -53,8 +51,8 @@ message PackageReference { // present in a previous version. // // A package should indicate its revision with a source code comment - // above the package declaration in one of its fields containing the - // test "Revision N" where N is an integer revision. All packages start + // above the package declaration in one of its files containing the + // text "Revision N" where N is an integer revision. All packages start // at revision 0 the first time they are released in a module. // // When a new version of a module is released and items are added to existing diff --git a/proto/cosmos/auth/v1beta1/query.proto b/proto/cosmos/auth/v1beta1/query.proto index 7798da00233a..894429bdaaf0 100644 --- a/proto/cosmos/auth/v1beta1/query.proto +++ b/proto/cosmos/auth/v1beta1/query.proto @@ -30,21 +30,29 @@ service Query { } // ModuleAccounts returns all the existing module accounts. + // + // Since: cosmos-sdk 0.46 rpc ModuleAccounts(QueryModuleAccountsRequest) returns (QueryModuleAccountsResponse) { option (google.api.http).get = "/cosmos/auth/v1beta1/module_accounts"; } - // Bech32 queries bech32Prefix + // Bech32Prefix queries bech32Prefix + // + // Since: cosmos-sdk 0.46 rpc Bech32Prefix(Bech32PrefixRequest) returns (Bech32PrefixResponse) { option (google.api.http).get = "/cosmos/auth/v1beta1/bech32"; } // AddressBytesToString converts Account Address bytes to string + // + // Since: cosmos-sdk 0.46 rpc AddressBytesToString(AddressBytesToStringRequest) returns (AddressBytesToStringResponse) { option (google.api.http).get = "/cosmos/auth/v1beta1/bech32/{address_bytes}"; } // AddressStringToBytes converts Address string to bytes + // + // Since: cosmos-sdk 0.46 rpc AddressStringToBytes(AddressStringToBytesRequest) returns (AddressStringToBytesResponse) { option (google.api.http).get = "/cosmos/auth/v1beta1/bech32/{address_string}"; } @@ -79,6 +87,8 @@ message QueryAccountRequest { } // QueryModuleAccountsRequest is the request type for the Query/ModuleAccounts RPC method. +// +// Since: cosmos-sdk 0.46 message QueryModuleAccountsRequest {} // QueryParamsResponse is the response type for the Query/Params RPC method. @@ -97,34 +107,48 @@ message QueryAccountResponse { message QueryParamsRequest {} // QueryModuleAccountsResponse is the response type for the Query/ModuleAccounts RPC method. +// +// Since: cosmos-sdk 0.46 message QueryModuleAccountsResponse { repeated google.protobuf.Any accounts = 1 [(cosmos_proto.accepts_interface) = "ModuleAccountI"]; } -// Bech32PrefixRequest is the request type for Bech32Prefix rpc method +// Bech32PrefixRequest is the request type for Bech32Prefix rpc method. +// +// Since: cosmos-sdk 0.46 message Bech32PrefixRequest {} -// Bech32PrefixResponse is the response type for Bech32Prefix rpc method +// Bech32PrefixResponse is the response type for Bech32Prefix rpc method. +// +// Since: cosmos-sdk 0.46 message Bech32PrefixResponse { string bech32_prefix = 1; } -// AddressBytesToStringRequest is the request type for AddressString rpc method +// AddressBytesToStringRequest is the request type for AddressString rpc method. +// +// Since: cosmos-sdk 0.46 message AddressBytesToStringRequest { bytes address_bytes = 1; } -// AddressBytesToStringResponse is the response type for AddressString rpc method +// AddressBytesToStringResponse is the response type for AddressString rpc method. +// +// Since: cosmos-sdk 0.46 message AddressBytesToStringResponse { string address_string = 1; } -// AddressStringToBytesRequest is the request type for AccountBytes rpc method +// AddressStringToBytesRequest is the request type for AccountBytes rpc method. +// +// Since: cosmos-sdk 0.46 message AddressStringToBytesRequest { string address_string = 1; } -// AddressStringToBytesResponse is the response type for AddressBytes rpc method +// AddressStringToBytesResponse is the response type for AddressBytes rpc method. +// +// Since: cosmos-sdk 0.46 message AddressStringToBytesResponse { bytes address_bytes = 1; } diff --git a/proto/cosmos/bank/v1beta1/query.proto b/proto/cosmos/bank/v1beta1/query.proto index 0d81a20d988a..635471c4b9dd 100644 --- a/proto/cosmos/bank/v1beta1/query.proto +++ b/proto/cosmos/bank/v1beta1/query.proto @@ -24,6 +24,8 @@ service Query { // SpendableBalances queries the spenable balance of all coins for a single // account. + // + // Since: cosmos-sdk 0.46 rpc SpendableBalances(QuerySpendableBalancesRequest) returns (QuerySpendableBalancesResponse) { option (google.api.http).get = "/cosmos/bank/v1beta1/spendable_balances/{address}"; } @@ -56,6 +58,8 @@ service Query { // DenomOwners queries for all account addresses that own a particular token // denomination. + // + // Since: cosmos-sdk 0.46 rpc DenomOwners(QueryDenomOwnersRequest) returns (QueryDenomOwnersResponse) { option (google.api.http).get = "/cosmos/bank/v1beta1/denom_owners/{denom}"; } @@ -104,6 +108,8 @@ message QueryAllBalancesResponse { // QuerySpendableBalancesRequest defines the gRPC request structure for querying // an account's spendable balances. +// +// Since: cosmos-sdk 0.46 message QuerySpendableBalancesRequest { option (gogoproto.equal) = false; option (gogoproto.goproto_getters) = false; @@ -117,6 +123,8 @@ message QuerySpendableBalancesRequest { // QuerySpendableBalancesResponse defines the gRPC response structure for querying // an account's spendable balances. +// +// Since: cosmos-sdk 0.46 message QuerySpendableBalancesResponse { // balances is the spendable balances of all the coins. repeated cosmos.base.v1beta1.Coin balances = 1 @@ -214,16 +222,19 @@ message QueryDenomOwnersRequest { // DenomOwner defines structure representing an account that owns or holds a // particular denominated token. It contains the account address and account // balance of the denominated token. +// +// Since: cosmos-sdk 0.46 message DenomOwner { // address defines the address that owns a particular denomination. string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - ; // balance is the balance of the denominated coin for an account. cosmos.base.v1beta1.Coin balance = 2 [(gogoproto.nullable) = false]; } // QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query. +// +// Since: cosmos-sdk 0.46 message QueryDenomOwnersResponse { repeated DenomOwner denom_owners = 1; diff --git a/proto/cosmos/base/abci/v1beta1/abci.proto b/proto/cosmos/base/abci/v1beta1/abci.proto index 09a2fcc4789d..ddaa63561774 100644 --- a/proto/cosmos/base/abci/v1beta1/abci.proto +++ b/proto/cosmos/base/abci/v1beta1/abci.proto @@ -41,7 +41,7 @@ message TxResponse { string timestamp = 12; // Events defines all the events emitted by processing a transaction. Note, // these events include those emitted by processing all the messages and those - // emitted from the ante handler. Whereas Logs contains the events, with + // emitted from the ante. Whereas Logs contains the events, with // additional metadata, emitted only by processing the messages. // // Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 diff --git a/proto/cosmos/base/snapshots/v1beta1/snapshot.proto b/proto/cosmos/base/snapshots/v1beta1/snapshot.proto index a89e0b4c361c..022f8e067263 100644 --- a/proto/cosmos/base/snapshots/v1beta1/snapshot.proto +++ b/proto/cosmos/base/snapshots/v1beta1/snapshot.proto @@ -20,6 +20,8 @@ message Metadata { } // SnapshotItem is an item contained in a rootmulti.Store snapshot. +// +// Since: cosmos-sdk 0.46 message SnapshotItem { // item is the specific type of snapshot item. oneof item { @@ -33,11 +35,15 @@ message SnapshotItem { } // SnapshotStoreItem contains metadata about a snapshotted store. +// +// Since: cosmos-sdk 0.46 message SnapshotStoreItem { string name = 1; } // SnapshotIAVLItem is an exported IAVL node. +// +// Since: cosmos-sdk 0.46 message SnapshotIAVLItem { bytes key = 1; bytes value = 2; @@ -48,23 +54,31 @@ message SnapshotIAVLItem { } // SnapshotExtensionMeta contains metadata about an external snapshotter. +// +// Since: cosmos-sdk 0.46 message SnapshotExtensionMeta { string name = 1; uint32 format = 2; } // SnapshotExtensionPayload contains payloads of an external snapshotter. +// +// Since: cosmos-sdk 0.46 message SnapshotExtensionPayload { bytes payload = 1; } // SnapshotKVItem is an exported Key/Value Pair +// +// Since: cosmos-sdk 0.46 message SnapshotKVItem { bytes key = 1; bytes value = 2; } // SnapshotSchema is an exported schema of smt store +// +// Since: cosmos-sdk 0.46 message SnapshotSchema{ repeated bytes keys = 1; } diff --git a/proto/cosmos/base/tendermint/v1beta1/query.proto b/proto/cosmos/base/tendermint/v1beta1/query.proto index 96a46e53cb67..b6ddb1a5e737 100644 --- a/proto/cosmos/base/tendermint/v1beta1/query.proto +++ b/proto/cosmos/base/tendermint/v1beta1/query.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package cosmos.base.tendermint.v1beta1; +import "gogoproto/gogo.proto"; import "google/protobuf/any.proto"; import "google/api/annotations.proto"; import "tendermint/p2p/types.proto"; @@ -17,14 +18,17 @@ service Service { rpc GetNodeInfo(GetNodeInfoRequest) returns (GetNodeInfoResponse) { option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/node_info"; } + // GetSyncing queries node syncing. rpc GetSyncing(GetSyncingRequest) returns (GetSyncingResponse) { option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/syncing"; } + // GetLatestBlock returns the latest block. rpc GetLatestBlock(GetLatestBlockRequest) returns (GetLatestBlockResponse) { option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/latest"; } + // GetBlockByHeight queries block for given height. rpc GetBlockByHeight(GetBlockByHeightRequest) returns (GetBlockByHeightResponse) { option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/blocks/{height}"; @@ -34,10 +38,20 @@ service Service { rpc GetLatestValidatorSet(GetLatestValidatorSetRequest) returns (GetLatestValidatorSetResponse) { option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/latest"; } + // GetValidatorSetByHeight queries validator-set at a given height. rpc GetValidatorSetByHeight(GetValidatorSetByHeightRequest) returns (GetValidatorSetByHeightResponse) { option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/validatorsets/{height}"; } + + // ABCIQuery defines a query handler that supports ABCI queries directly to the + // application, bypassing Tendermint completely. The ABCI query must contain + // a valid and supported path, including app, custom, p2p, and store. + // + // Since: cosmos-sdk 0.46 + rpc ABCIQuery(ABCIQueryRequest) returns (ABCIQueryResponse) { + option (google.api.http).get = "/cosmos/base/tendermint/v1beta1/abci_query"; + } } // GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. @@ -136,3 +150,47 @@ message Module { // checksum string sum = 3; } + +// ABCIQueryRequest defines the request structure for the ABCIQuery gRPC query. +message ABCIQueryRequest { + bytes data = 1; + string path = 2; + int64 height = 3; + bool prove = 4; +} + +// ABCIQueryResponse defines the response structure for the ABCIQuery gRPC query. +// +// Note: This type is a duplicate of the ResponseQuery proto type defined in +// Tendermint. +message ABCIQueryResponse { + uint32 code = 1; + // DEPRECATED: use "value" instead + reserved 2; + string log = 3; // nondeterministic + string info = 4; // nondeterministic + int64 index = 5; + bytes key = 6; + bytes value = 7; + ProofOps proof_ops = 8; + int64 height = 9; + string codespace = 10; +} + +// ProofOp defines an operation used for calculating Merkle root. The data could +// be arbitrary format, providing nessecary data for example neighbouring node +// hash. +// +// Note: This type is a duplicate of the ProofOp proto type defined in Tendermint. +message ProofOp { + string type = 1; + bytes key = 2; + bytes data = 3; +} + +// ProofOps is Merkle proof defined by the list of ProofOps. +// +// Note: This type is a duplicate of the ProofOps proto type defined in Tendermint. +message ProofOps { + repeated ProofOp ops = 1 [(gogoproto.nullable) = false]; +} diff --git a/proto/cosmos/crypto/hd/v1/hd.proto b/proto/cosmos/crypto/hd/v1/hd.proto index e4a95afcba9f..bb079ce66501 100644 --- a/proto/cosmos/crypto/hd/v1/hd.proto +++ b/proto/cosmos/crypto/hd/v1/hd.proto @@ -1,3 +1,4 @@ +// Since: cosmos-sdk 0.46 syntax = "proto3"; package cosmos.crypto.hd.v1; diff --git a/proto/cosmos/crypto/keyring/v1/record.proto b/proto/cosmos/crypto/keyring/v1/record.proto index 9b2d3c96439f..ca70aa984af6 100644 --- a/proto/cosmos/crypto/keyring/v1/record.proto +++ b/proto/cosmos/crypto/keyring/v1/record.proto @@ -1,3 +1,4 @@ +// Since: cosmos-sdk 0.46 syntax = "proto3"; package cosmos.crypto.keyring.v1; @@ -17,13 +18,13 @@ message Record { // Record contains one of the following items oneof item { - // local stores the public information about a locally stored key + // local stores the private key locally. Local local = 3; - // ledger stores the public information about a Ledger key + // ledger stores the information about a Ledger key. Ledger ledger = 4; - // Multi does not store any information. + // Multi does not store any other information. Multi multi = 5; - // Offline does not store any information. + // Offline does not store any other information. Offline offline = 6; } @@ -31,7 +32,6 @@ message Record { // Local item message Local { google.protobuf.Any priv_key = 1; - string priv_key_type = 2; } // Ledger item diff --git a/proto/cosmos/feegrant/v1beta1/query.proto b/proto/cosmos/feegrant/v1beta1/query.proto index 59c992c911d6..baef77701623 100644 --- a/proto/cosmos/feegrant/v1beta1/query.proto +++ b/proto/cosmos/feegrant/v1beta1/query.proto @@ -23,7 +23,8 @@ service Query { } // AllowancesByGranter returns all the grants given by an address - // Since v0.46 + // + // Since: cosmos-sdk 0.46 rpc AllowancesByGranter(QueryAllowancesByGranterRequest) returns (QueryAllowancesByGranterResponse) { option (google.api.http).get = "/cosmos/feegrant/v1beta1/issued/{granter}"; } @@ -62,6 +63,8 @@ message QueryAllowancesResponse { } // QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. +// +// Since: cosmos-sdk 0.46 message QueryAllowancesByGranterRequest { string granter = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; @@ -70,6 +73,8 @@ message QueryAllowancesByGranterRequest { } // QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. +// +// Since: cosmos-sdk 0.46 message QueryAllowancesByGranterResponse { // allowances that have been issued by the granter. repeated cosmos.feegrant.v1beta1.Grant allowances = 1; diff --git a/proto/cosmos/group/v1/events.proto b/proto/cosmos/group/v1/events.proto index e8b457c89a9d..c2cfe8728f72 100644 --- a/proto/cosmos/group/v1/events.proto +++ b/proto/cosmos/group/v1/events.proto @@ -65,6 +65,9 @@ message EventExec { // result is the proposal execution result. ProposalExecutorResult result = 2; + + // logs contains error logs in case the execution result is FAILURE. + string logs = 3; } // EventLeaveGroup is an event emitted when group member leaves the group. diff --git a/proto/cosmos/group/v1/tx.proto b/proto/cosmos/group/v1/tx.proto index 4a3deae50202..1983d31ba864 100644 --- a/proto/cosmos/group/v1/tx.proto +++ b/proto/cosmos/group/v1/tx.proto @@ -46,7 +46,7 @@ service Msg { // SubmitProposal submits a new proposal. rpc SubmitProposal(MsgSubmitProposal) returns (MsgSubmitProposalResponse); - // WithdrawProposal aborts a proposal. + // WithdrawProposal withdraws a proposal. rpc WithdrawProposal(MsgWithdrawProposal) returns (MsgWithdrawProposalResponse); // Vote allows a voter to vote on a proposal. @@ -71,7 +71,7 @@ message MsgCreateGroup { string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // members defines the group members. - repeated Member members = 2 [(gogoproto.nullable) = false]; + repeated MemberRequest members = 2 [(gogoproto.nullable) = false]; // metadata is any arbitrary metadata to attached to the group. string metadata = 3; @@ -96,7 +96,7 @@ message MsgUpdateGroupMembers { // member_updates is the list of members to update, // set weight to 0 to remove a member. - repeated Member member_updates = 3 [(gogoproto.nullable) = false]; + repeated MemberRequest member_updates = 3 [(gogoproto.nullable) = false]; } // MsgUpdateGroupMembersResponse is the Msg/UpdateGroupMembers response type. @@ -156,7 +156,7 @@ message MsgCreateGroupPolicy { string metadata = 3; // decision_policy specifies the group policy's decision policy. - google.protobuf.Any decision_policy = 4 [(cosmos_proto.accepts_interface) = "DecisionPolicy"]; + google.protobuf.Any decision_policy = 4 [(cosmos_proto.accepts_interface) = "cosmos.group.v1.DecisionPolicy"]; } // MsgCreateGroupPolicyResponse is the Msg/CreateGroupPolicy response type. @@ -189,7 +189,7 @@ message MsgCreateGroupWithPolicy { string admin = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // members defines the group members. - repeated Member members = 2 [(gogoproto.nullable) = false]; + repeated MemberRequest members = 2 [(gogoproto.nullable) = false]; // group_metadata is any arbitrary metadata attached to the group. string group_metadata = 3; @@ -202,7 +202,7 @@ message MsgCreateGroupWithPolicy { bool group_policy_as_admin = 5; // decision_policy specifies the group policy's decision policy. - google.protobuf.Any decision_policy = 6 [(cosmos_proto.accepts_interface) = "DecisionPolicy"]; + google.protobuf.Any decision_policy = 6 [(cosmos_proto.accepts_interface) = "cosmos.group.v1.DecisionPolicy"]; } // MsgCreateGroupWithPolicyResponse is the Msg/CreateGroupWithPolicy response type. @@ -231,7 +231,7 @@ message MsgUpdateGroupPolicyDecisionPolicy { string group_policy_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // decision_policy is the updated group policy's decision policy. - google.protobuf.Any decision_policy = 3 [(cosmos_proto.accepts_interface) = "DecisionPolicy"]; + google.protobuf.Any decision_policy = 3 [(cosmos_proto.accepts_interface) = "cosmos.group.v1.DecisionPolicy"]; } // MsgUpdateGroupPolicyDecisionPolicyResponse is the Msg/UpdateGroupPolicyDecisionPolicy response type. @@ -353,7 +353,10 @@ message MsgExec { } // MsgExecResponse is the Msg/Exec request type. -message MsgExecResponse {} +message MsgExecResponse { + // result is the final result of the proposal execution. + ProposalExecutorResult result = 2; +} // MsgLeaveGroup is the Msg/LeaveGroup request type. message MsgLeaveGroup { diff --git a/proto/cosmos/group/v1/types.proto b/proto/cosmos/group/v1/types.proto index ec6cd744d8c9..63e20c8f6ff2 100644 --- a/proto/cosmos/group/v1/types.proto +++ b/proto/cosmos/group/v1/types.proto @@ -12,7 +12,7 @@ import "cosmos_proto/cosmos.proto"; import "google/protobuf/any.proto"; // Member represents a group member with an account address, -// non-zero weight and metadata. +// non-zero weight, metadata and added_at timestamp. message Member { // address is the member's account address. @@ -28,11 +28,20 @@ message Member { google.protobuf.Timestamp added_at = 4 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; } -// Members defines a repeated slice of Member objects. -message Members { - // members is the list of members. - repeated Member members = 1 [(gogoproto.nullable) = false]; +// MemberRequest represents a group member to be used in Msg server requests. +// Contrary to `Member`, it doesn't have any `added_at` field +// since this field cannot be set as part of requests. +message MemberRequest { + + // address is the member's account address. + string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // weight is the member's voting weight that should be greater than 0. + string weight = 2; + + // metadata is any arbitrary metadata attached to the member. + string metadata = 3; } // ThresholdDecisionPolicy is a decision policy where a proposal passes when it @@ -167,7 +176,7 @@ message GroupPolicyInfo { uint64 version = 5; // decision_policy specifies the group policy's decision policy. - google.protobuf.Any decision_policy = 6 [(cosmos_proto.accepts_interface) = "DecisionPolicy"]; + google.protobuf.Any decision_policy = 6 [(cosmos_proto.accepts_interface) = "cosmos.group.v1.DecisionPolicy"]; // created_at is a timestamp specifying when a group policy was created. google.protobuf.Timestamp created_at = 7 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; @@ -221,7 +230,7 @@ message Proposal { // accordingly updated. google.protobuf.Timestamp voting_period_end = 10 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true]; - // executor_result is the final result based on the votes and election rule. Initial value is NotRun. + // executor_result is the final result of the proposal execution. Initial value is NotRun. ProposalExecutorResult executor_result = 11; // messages is a list of `sdk.Msg`s that will be executed if the proposal passes. diff --git a/proto/cosmos/orm/v1/orm.proto b/proto/cosmos/orm/v1/orm.proto index abfbbd4f5cea..389babd19665 100644 --- a/proto/cosmos/orm/v1/orm.proto +++ b/proto/cosmos/orm/v1/orm.proto @@ -79,7 +79,7 @@ message SecondaryIndexDescriptor { // Index keys are prefixed by the varint encoded table id and the varint // encoded index id plus any additional prefix specified by the schema. // - // In addition the the field segments, non-unique index keys are suffixed with + // In addition the field segments, non-unique index keys are suffixed with // any additional primary key fields not present in the index fields so that the // primary key can be reconstructed. Unique indexes instead of being suffixed // store the remaining primary key fields in the value.. diff --git a/proto/cosmos/params/v1beta1/query.proto b/proto/cosmos/params/v1beta1/query.proto index 3b1c9a760092..97d0a71d7f5e 100644 --- a/proto/cosmos/params/v1beta1/query.proto +++ b/proto/cosmos/params/v1beta1/query.proto @@ -16,6 +16,8 @@ service Query { } // Subspaces queries for all registered subspaces and all keys for a subspace. + // + // Since: cosmos-sdk 0.46 rpc Subspaces(QuerySubspacesRequest) returns (QuerySubspacesResponse) { option (google.api.http).get = "/cosmos/params/v1beta1/subspaces"; } @@ -38,16 +40,22 @@ message QueryParamsResponse { // QuerySubspacesRequest defines a request type for querying for all registered // subspaces and all keys for a subspace. +// +// Since: cosmos-sdk 0.46 message QuerySubspacesRequest {} // QuerySubspacesResponse defines the response types for querying for all // registered subspaces and all keys for a subspace. +// +// Since: cosmos-sdk 0.46 message QuerySubspacesResponse { repeated Subspace subspaces = 1; } // Subspace defines a parameter subspace name and all the keys that exist for // the subspace. +// +// Since: cosmos-sdk 0.46 message Subspace { string subspace = 1; repeated string keys = 2; diff --git a/proto/cosmos/staking/v1beta1/query.proto b/proto/cosmos/staking/v1beta1/query.proto index 02469232ba06..2cbb750b0bde 100644 --- a/proto/cosmos/staking/v1beta1/query.proto +++ b/proto/cosmos/staking/v1beta1/query.proto @@ -119,7 +119,7 @@ message QueryValidatorRequest { // QueryValidatorResponse is response type for the Query/Validator RPC method message QueryValidatorResponse { - // validator defines the the validator info. + // validator defines the validator info. Validator validator = 1 [(gogoproto.nullable) = false]; } @@ -289,7 +289,7 @@ message QueryDelegatorValidatorsRequest { // QueryDelegatorValidatorsResponse is response type for the // Query/DelegatorValidators RPC method. message QueryDelegatorValidatorsResponse { - // validators defines the the validators' info of a delegator. + // validators defines the validators' info of a delegator. repeated Validator validators = 1 [(gogoproto.nullable) = false]; // pagination defines the pagination in the response. @@ -312,7 +312,7 @@ message QueryDelegatorValidatorRequest { // QueryDelegatorValidatorResponse response type for the // Query/DelegatorValidator RPC method. message QueryDelegatorValidatorResponse { - // validator defines the the validator info. + // validator defines the validator info. Validator validator = 1 [(gogoproto.nullable) = false]; } diff --git a/proto/cosmos/staking/v1beta1/staking.proto b/proto/cosmos/staking/v1beta1/staking.proto index dcf2645fa247..6dc965feab47 100644 --- a/proto/cosmos/staking/v1beta1/staking.proto +++ b/proto/cosmos/staking/v1beta1/staking.proto @@ -117,6 +117,8 @@ message Validator { // commission defines the commission parameters. Commission commission = 10 [(gogoproto.nullable) = false]; // min_self_delegation is the validator's self declared minimum self delegation. + // + // Since: cosmos-sdk 0.46 string min_self_delegation = 11 [ (cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", diff --git a/proto/cosmos/staking/v1beta1/tx.proto b/proto/cosmos/staking/v1beta1/tx.proto index b7dac39861d8..ca8f76df19dc 100644 --- a/proto/cosmos/staking/v1beta1/tx.proto +++ b/proto/cosmos/staking/v1beta1/tx.proto @@ -35,6 +35,8 @@ service Msg { // CancelUnbondingDelegation defines a method for performing canceling the unbonding delegation // and delegate back to previous validator. + // + // Since: cosmos-sdk 0.46 rpc CancelUnbondingDelegation(MsgCancelUnbondingDelegation) returns (MsgCancelUnbondingDelegationResponse); } @@ -142,6 +144,8 @@ message MsgUndelegateResponse { } // MsgCancelUnbondingDelegation defines the SDK message for performing a cancel unbonding delegation for delegator +// +// Since: cosmos-sdk 0.46 message MsgCancelUnbondingDelegation{ option (cosmos.msg.v1.signer) = "delegator_address"; option (gogoproto.equal) = false; @@ -156,4 +160,6 @@ message MsgCancelUnbondingDelegation{ } // MsgCancelUnbondingDelegationResponse +// +// Since: cosmos-sdk 0.46 message MsgCancelUnbondingDelegationResponse{} diff --git a/proto/cosmos/tx/v1beta1/tx.proto b/proto/cosmos/tx/v1beta1/tx.proto index ac7b690f4661..b015604e3177 100644 --- a/proto/cosmos/tx/v1beta1/tx.proto +++ b/proto/cosmos/tx/v1beta1/tx.proto @@ -238,11 +238,11 @@ message AuxSignerData { // AuxSignerData across different chains, the bech32 prefix of the target // chain (where the final transaction is broadcasted) should be used. string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; - // sign_doc is the SIGN_MOD_DIRECT_AUX sign doc that the auxiliary signer + // sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the auxiliary signer // signs. Note: we use the same sign doc even if we're signing with // LEGACY_AMINO_JSON. SignDocDirectAux sign_doc = 2; - // mode is the signing mode of the single signer + // mode is the signing mode of the single signer. cosmos.tx.signing.v1beta1.SignMode mode = 3; // sig is the signature of the sign doc. bytes sig = 4; diff --git a/proto/cosmos/upgrade/v1beta1/query.proto b/proto/cosmos/upgrade/v1beta1/query.proto index e8c4baa0d66b..870cf9ee6bbc 100644 --- a/proto/cosmos/upgrade/v1beta1/query.proto +++ b/proto/cosmos/upgrade/v1beta1/query.proto @@ -37,6 +37,8 @@ service Query { } // Returns the account with authority to conduct upgrades + // + // Since: cosmos-sdk 0.46 rpc Authority(QueryAuthorityRequest) returns (QueryAuthorityResponse) { option (google.api.http).get = "/cosmos/upgrade/v1beta1/authority"; } diff --git a/proto/cosmos/upgrade/v1beta1/tx.proto b/proto/cosmos/upgrade/v1beta1/tx.proto index 9b04bf44bebc..7a2931da2148 100644 --- a/proto/cosmos/upgrade/v1beta1/tx.proto +++ b/proto/cosmos/upgrade/v1beta1/tx.proto @@ -1,3 +1,4 @@ +// Since: cosmos-sdk 0.46 syntax = "proto3"; package cosmos.upgrade.v1beta1; @@ -52,4 +53,4 @@ message MsgCancelUpgrade { // MsgCancelUpgradeResponse is the Msg/CancelUpgrade response type. // // Since: cosmos-sdk 0.46 -message MsgCancelUpgradeResponse {} \ No newline at end of file +message MsgCancelUpgradeResponse {} diff --git a/proto/cosmos/vesting/v1beta1/tx.proto b/proto/cosmos/vesting/v1beta1/tx.proto index 211bad09e0ad..27511ba80cbd 100644 --- a/proto/cosmos/vesting/v1beta1/tx.proto +++ b/proto/cosmos/vesting/v1beta1/tx.proto @@ -17,9 +17,13 @@ service Msg { rpc CreateVestingAccount(MsgCreateVestingAccount) returns (MsgCreateVestingAccountResponse); // CreatePermanentLockedAccount defines a method that enables creating a permanent // locked account. + // + // Since: cosmos-sdk 0.46 rpc CreatePermanentLockedAccount(MsgCreatePermanentLockedAccount) returns (MsgCreatePermanentLockedAccountResponse); // CreatePeriodicVestingAccount defines a method that enables creating a // periodic vesting account. + // + // Since: cosmos-sdk 0.46 rpc CreatePeriodicVestingAccount(MsgCreatePeriodicVestingAccount) returns (MsgCreatePeriodicVestingAccountResponse); } @@ -44,6 +48,8 @@ message MsgCreateVestingAccountResponse {} // MsgCreatePermanentLockedAccount defines a message that enables creating a permanent // locked account. +// +// Since: cosmos-sdk 0.46 message MsgCreatePermanentLockedAccount { option (gogoproto.equal) = true; @@ -54,10 +60,14 @@ message MsgCreatePermanentLockedAccount { } // MsgCreatePermanentLockedAccountResponse defines the Msg/CreatePermanentLockedAccount response type. +// +// Since: cosmos-sdk 0.46 message MsgCreatePermanentLockedAccountResponse {} // MsgCreateVestingAccount defines a message that enables creating a vesting // account. +// +// Since: cosmos-sdk 0.46 message MsgCreatePeriodicVestingAccount { option (cosmos.msg.v1.signer) = "from_address"; @@ -71,4 +81,6 @@ message MsgCreatePeriodicVestingAccount { // MsgCreateVestingAccountResponse defines the Msg/CreatePeriodicVestingAccount // response type. +// +// Since: cosmos-sdk 0.46 message MsgCreatePeriodicVestingAccountResponse {} diff --git a/pruning/README.md b/pruning/README.md new file mode 100644 index 000000000000..f7afae8e6ac3 --- /dev/null +++ b/pruning/README.md @@ -0,0 +1,29 @@ +# Pruning + +## Overview + +Pruning is the mechanism for deleting old application heights from the disk. Depending on the use case, +nodes may require different pruning strategies. For example, archive nodes must keep all +the states and prune nothing. On the other hand, a regular validator node may want to only keep 100 latest heights for performance reasons. + +## Strategies + +The strategies are configured in `app.toml`, with the format `pruning = ""` where the options are: + +- `default`: only the last 362,880 states(approximately 3.5 weeks worth of state) are kept; pruning at 10 block intervals +- `nothing`: all historic states will be saved, nothing will be deleted (i.e. archiving node) +- `everything`: 2 latest states will be kept; pruning at 10 block intervals. +- `custom`: allow pruning options to be manually specified through 'pruning-keep-recent', and 'pruning-interval' + +If no strategy is given to the BaseApp, `nothing` is selected. However, we perform validation on the CLI layer to require these to be always set in the config file. + +## Custom Pruning + +These are applied if and only if the pruning strategy is custom: +- `pruning-keep-recent`: N means to keep all of the last N states +- `pruning-interval`: N means to delete old states from disk every Nth block. + +## Relationship to State Sync Snapshots + +Snapshot settings are optional. However, if set, they have an effect on how pruning is done by +persisting the heights that are multiples of `state-sync.snapshot-interval` until after the snapshot is complete. See the "Relationship to Pruning" section in `snapshots/README.md` for more details. diff --git a/pruning/export_test.go b/pruning/export_test.go new file mode 100644 index 000000000000..8c38778bf93d --- /dev/null +++ b/pruning/export_test.go @@ -0,0 +1,11 @@ +package pruning + +var ( + PruneHeightsKey = pruneHeightsKey + PruneSnapshotHeightsKey = pruneSnapshotHeightsKey + + Int64SliceToBytes = int64SliceToBytes + ListToBytes = listToBytes + LoadPruningHeights = loadPruningHeights + LoadPruningSnapshotHeights = loadPruningSnapshotHeights +) diff --git a/pruning/manager.go b/pruning/manager.go new file mode 100644 index 000000000000..8e7c61cc9ef6 --- /dev/null +++ b/pruning/manager.go @@ -0,0 +1,282 @@ +package pruning + +import ( + "container/list" + "encoding/binary" + "fmt" + "sync" + + "github.com/tendermint/tendermint/libs/log" + dbm "github.com/tendermint/tm-db" + + "github.com/cosmos/cosmos-sdk/pruning/types" +) + +// Manager is an abstraction to handle the logic needed for +// determinging when to prune old heights of the store +// based on the strategy described by the pruning options. +type Manager struct { + db dbm.DB + logger log.Logger + opts types.PruningOptions + snapshotInterval uint64 + // Although pruneHeights happen in the same goroutine with the normal execution, + // we sync access to them to avoid soundness issues in the future if concurrency pattern changes. + pruneHeightsMx sync.Mutex + pruneHeights []int64 + // Snapshots are taken in a separate goroutine from the regular execution + // and can be delivered asynchrounously via HandleHeightSnapshot. + // Therefore, we sync access to pruneSnapshotHeights with this mutex. + pruneSnapshotHeightsMx sync.Mutex + // These are the heights that are multiples of snapshotInterval and kept for state sync snapshots. + // The heights are added to this list to be pruned when a snapshot is complete. + pruneSnapshotHeights *list.List +} + +// NegativeHeightsError is returned when a negative height is provided to the manager. +type NegativeHeightsError struct { + Height int64 +} + +var _ error = &NegativeHeightsError{} + +func (e *NegativeHeightsError) Error() string { + return fmt.Sprintf("failed to get pruned heights: %d", e.Height) +} + +var ( + pruneHeightsKey = []byte("s/pruneheights") + pruneSnapshotHeightsKey = []byte("s/prunesnapshotheights") +) + +// NewManager returns a new Manager with the given db and logger. +// The retuned manager uses a pruning strategy of "nothing" which +// keeps all heights. Users of the Manager may change the strategy +// by calling SetOptions. +func NewManager(db dbm.DB, logger log.Logger) *Manager { + return &Manager{ + db: db, + logger: logger, + opts: types.NewPruningOptions(types.PruningNothing), + pruneHeights: []int64{}, + pruneSnapshotHeights: list.New(), + } +} + +// SetOptions sets the pruning strategy on the manager. +func (m *Manager) SetOptions(opts types.PruningOptions) { + m.opts = opts +} + +// GetOptions fetches the pruning strategy from the manager. +func (m *Manager) GetOptions() types.PruningOptions { + return m.opts +} + +// GetFlushAndResetPruningHeights returns all heights to be pruned during the next call to Prune(). +// It also flushes and resets the pruning heights. +func (m *Manager) GetFlushAndResetPruningHeights() ([]int64, error) { + if m.opts.GetPruningStrategy() == types.PruningNothing { + return []int64{}, nil + } + m.pruneHeightsMx.Lock() + defer m.pruneHeightsMx.Unlock() + + // flush the updates to disk so that it is not lost if crash happens. + if err := m.db.SetSync(pruneHeightsKey, int64SliceToBytes(m.pruneHeights)); err != nil { + return nil, err + } + + // Return a copy to prevent data races. + pruningHeights := make([]int64, len(m.pruneHeights)) + copy(pruningHeights, m.pruneHeights) + m.pruneHeights = m.pruneHeights[:0] + + return pruningHeights, nil +} + +// HandleHeight determines if previousHeight height needs to be kept for pruning at the right interval prescribed by +// the pruning strategy. Returns previousHeight, if it was kept to be pruned at the next call to Prune(), 0 otherwise. +// previousHeight must be greater than 0 for the handling to take effect since valid heights start at 1 and 0 represents +// the latest height. The latest height cannot be pruned. As a result, if previousHeight is less than or equal to 0, 0 is returned. +func (m *Manager) HandleHeight(previousHeight int64) int64 { + if m.opts.GetPruningStrategy() == types.PruningNothing || previousHeight <= 0 { + return 0 + } + + defer func() { + m.pruneHeightsMx.Lock() + defer m.pruneHeightsMx.Unlock() + + m.pruneSnapshotHeightsMx.Lock() + defer m.pruneSnapshotHeightsMx.Unlock() + + // move persisted snapshot heights to pruneHeights which + // represent the heights to be pruned at the next pruning interval. + var next *list.Element + for e := m.pruneSnapshotHeights.Front(); e != nil; e = next { + snHeight := e.Value.(int64) + if snHeight < previousHeight-int64(m.opts.KeepRecent) { + m.pruneHeights = append(m.pruneHeights, snHeight) + + // We must get next before removing to be able to continue iterating. + next = e.Next() + m.pruneSnapshotHeights.Remove(e) + } else { + next = e.Next() + } + } + + // flush the updates to disk so that they are not lost if crash happens. + if err := m.db.SetSync(pruneHeightsKey, int64SliceToBytes(m.pruneHeights)); err != nil { + panic(err) + } + }() + + if int64(m.opts.KeepRecent) < previousHeight { + pruneHeight := previousHeight - int64(m.opts.KeepRecent) + // We consider this height to be pruned iff: + // + // - snapshotInterval is zero as that means that all heights should be pruned. + // - snapshotInterval % (height - KeepRecent) != 0 as that means the height is not + // a 'snapshot' height. + if m.snapshotInterval == 0 || pruneHeight%int64(m.snapshotInterval) != 0 { + m.pruneHeightsMx.Lock() + defer m.pruneHeightsMx.Unlock() + + m.pruneHeights = append(m.pruneHeights, pruneHeight) + return pruneHeight + } + } + return 0 +} + +// HandleHeightSnapshot persists the snapshot height to be pruned at the next appropriate +// height defined by the pruning strategy. Flushes the update to disk and panics if the flush fails +// The input height must be greater than 0 and pruning strategy any but pruning nothing. +// If one of these conditions is not met, this function does nothing. +func (m *Manager) HandleHeightSnapshot(height int64) { + if m.opts.GetPruningStrategy() == types.PruningNothing || height <= 0 { + return + } + + m.pruneSnapshotHeightsMx.Lock() + defer m.pruneSnapshotHeightsMx.Unlock() + + m.logger.Debug("HandleHeightSnapshot", "height", height) + m.pruneSnapshotHeights.PushBack(height) + + // flush the updates to disk so that they are not lost if crash happens. + if err := m.db.SetSync(pruneSnapshotHeightsKey, listToBytes(m.pruneSnapshotHeights)); err != nil { + panic(err) + } +} + +// SetSnapshotInterval sets the interval at which the snapshots are taken. +func (m *Manager) SetSnapshotInterval(snapshotInterval uint64) { + m.snapshotInterval = snapshotInterval +} + +// ShouldPruneAtHeight return true if the given height should be pruned, false otherwise +func (m *Manager) ShouldPruneAtHeight(height int64) bool { + return m.opts.Interval > 0 && m.opts.GetPruningStrategy() != types.PruningNothing && height%int64(m.opts.Interval) == 0 +} + +// LoadPruningHeights loads the pruning heights from the database as a crash recovery. +func (m *Manager) LoadPruningHeights(db dbm.DB) error { + if m.opts.GetPruningStrategy() == types.PruningNothing { + return nil + } + loadedPruneHeights, err := loadPruningHeights(db) + if err != nil { + return err + } + + if len(loadedPruneHeights) > 0 { + m.pruneHeightsMx.Lock() + defer m.pruneHeightsMx.Unlock() + m.pruneHeights = loadedPruneHeights + } + + loadedPruneSnapshotHeights, err := loadPruningSnapshotHeights(db) + if err != nil { + return err + } + + if loadedPruneSnapshotHeights.Len() > 0 { + m.pruneSnapshotHeightsMx.Lock() + defer m.pruneSnapshotHeightsMx.Unlock() + m.pruneSnapshotHeights = loadedPruneSnapshotHeights + } + + return nil +} + +func loadPruningHeights(db dbm.DB) ([]int64, error) { + bz, err := db.Get(pruneHeightsKey) + if err != nil { + return nil, fmt.Errorf("failed to get pruned heights: %w", err) + } + if len(bz) == 0 { + return []int64{}, nil + } + + prunedHeights := make([]int64, len(bz)/8) + i, offset := 0, 0 + for offset < len(bz) { + h := int64(binary.BigEndian.Uint64(bz[offset : offset+8])) + if h < 0 { + return []int64{}, &NegativeHeightsError{Height: h} + } + + prunedHeights[i] = h + i++ + offset += 8 + } + + return prunedHeights, nil +} + +func loadPruningSnapshotHeights(db dbm.DB) (*list.List, error) { + bz, err := db.Get(pruneSnapshotHeightsKey) + if err != nil { + return nil, fmt.Errorf("failed to get post-snapshot pruned heights: %w", err) + } + pruneSnapshotHeights := list.New() + if len(bz) == 0 { + return pruneSnapshotHeights, nil + } + + i, offset := 0, 0 + for offset < len(bz) { + h := int64(binary.BigEndian.Uint64(bz[offset : offset+8])) + if h < 0 { + return nil, &NegativeHeightsError{Height: h} + } + pruneSnapshotHeights.PushBack(h) + i++ + offset += 8 + } + + return pruneSnapshotHeights, nil +} + +func int64SliceToBytes(slice []int64) []byte { + bz := make([]byte, 0, len(slice)*8) + for _, ph := range slice { + buf := make([]byte, 8) + binary.BigEndian.PutUint64(buf, uint64(ph)) + bz = append(bz, buf...) + } + return bz +} + +func listToBytes(list *list.List) []byte { + bz := make([]byte, 0, list.Len()*8) + for e := list.Front(); e != nil; e = e.Next() { + buf := make([]byte, 8) + binary.BigEndian.PutUint64(buf, uint64(e.Value.(int64))) + bz = append(bz, buf...) + } + return bz +} diff --git a/pruning/manager_test.go b/pruning/manager_test.go new file mode 100644 index 000000000000..85d38e8c8af7 --- /dev/null +++ b/pruning/manager_test.go @@ -0,0 +1,532 @@ +package pruning_test + +import ( + "container/list" + "errors" + "fmt" + "testing" + + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + db "github.com/tendermint/tm-db" + + "github.com/cosmos/cosmos-sdk/pruning" + "github.com/cosmos/cosmos-sdk/pruning/mock" + "github.com/cosmos/cosmos-sdk/pruning/types" +) + +const dbErr = "db error" + +func TestNewManager(t *testing.T) { + manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) + + require.NotNil(t, manager) + heights, err := manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.NotNil(t, heights) + require.Equal(t, types.PruningNothing, manager.GetOptions().GetPruningStrategy()) +} + +func TestStrategies(t *testing.T) { + testcases := map[string]struct { + strategy types.PruningOptions + snapshotInterval uint64 + strategyToAssert types.PruningStrategy + isValid bool + }{ + "prune nothing - no snapshot": { + strategy: types.NewPruningOptions(types.PruningNothing), + strategyToAssert: types.PruningNothing, + }, + "prune nothing - snapshot": { + strategy: types.NewPruningOptions(types.PruningNothing), + strategyToAssert: types.PruningNothing, + snapshotInterval: 100, + }, + "prune default - no snapshot": { + strategy: types.NewPruningOptions(types.PruningDefault), + strategyToAssert: types.PruningDefault, + }, + "prune default - snapshot": { + strategy: types.NewPruningOptions(types.PruningDefault), + strategyToAssert: types.PruningDefault, + snapshotInterval: 100, + }, + "prune everything - no snapshot": { + strategy: types.NewPruningOptions(types.PruningEverything), + strategyToAssert: types.PruningEverything, + }, + "prune everything - snapshot": { + strategy: types.NewPruningOptions(types.PruningEverything), + strategyToAssert: types.PruningEverything, + snapshotInterval: 100, + }, + "custom 100-10-15": { + strategy: types.NewCustomPruningOptions(100, 15), + snapshotInterval: 10, + strategyToAssert: types.PruningCustom, + }, + "custom 10-10-15": { + strategy: types.NewCustomPruningOptions(10, 15), + snapshotInterval: 10, + strategyToAssert: types.PruningCustom, + }, + "custom 100-0-15": { + strategy: types.NewCustomPruningOptions(100, 15), + snapshotInterval: 0, + strategyToAssert: types.PruningCustom, + }, + } + + manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) + + require.NotNil(t, manager) + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + curStrategy := tc.strategy + manager.SetSnapshotInterval(tc.snapshotInterval) + + pruneStrategy := curStrategy.GetPruningStrategy() + require.Equal(t, tc.strategyToAssert, pruneStrategy) + + // Validate strategy parameters + switch pruneStrategy { + case types.PruningDefault: + require.Equal(t, uint64(362880), curStrategy.KeepRecent) + require.Equal(t, uint64(10), curStrategy.Interval) + case types.PruningNothing: + require.Equal(t, uint64(0), curStrategy.KeepRecent) + require.Equal(t, uint64(0), curStrategy.Interval) + case types.PruningEverything: + require.Equal(t, uint64(2), curStrategy.KeepRecent) + require.Equal(t, uint64(10), curStrategy.Interval) + default: + // + } + + manager.SetOptions(curStrategy) + require.Equal(t, tc.strategy, manager.GetOptions()) + + curKeepRecent := curStrategy.KeepRecent + curInterval := curStrategy.Interval + + for curHeight := int64(0); curHeight < 110000; curHeight++ { + handleHeightActual := manager.HandleHeight(curHeight) + shouldPruneAtHeightActual := manager.ShouldPruneAtHeight(curHeight) + + curPruningHeihts, err := manager.GetFlushAndResetPruningHeights() + require.Nil(t, err) + + curHeightStr := fmt.Sprintf("height: %d", curHeight) + + switch curStrategy.GetPruningStrategy() { + case types.PruningNothing: + require.Equal(t, int64(0), handleHeightActual, curHeightStr) + require.False(t, shouldPruneAtHeightActual, curHeightStr) + + heights, err := manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, 0, len(heights)) + default: + if curHeight > int64(curKeepRecent) && (tc.snapshotInterval != 0 && (curHeight-int64(curKeepRecent))%int64(tc.snapshotInterval) != 0 || tc.snapshotInterval == 0) { + expectedHeight := curHeight - int64(curKeepRecent) + require.Equal(t, curHeight-int64(curKeepRecent), handleHeightActual, curHeightStr) + + require.Contains(t, curPruningHeihts, expectedHeight, curHeightStr) + } else { + require.Equal(t, int64(0), handleHeightActual, curHeightStr) + + heights, err := manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, 0, len(heights)) + } + require.Equal(t, curHeight%int64(curInterval) == 0, shouldPruneAtHeightActual, curHeightStr) + } + heights, err := manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, 0, len(heights)) + } + }) + } +} + +func TestHandleHeight_Inputs(t *testing.T) { + var keepRecent int64 = int64(types.NewPruningOptions(types.PruningEverything).KeepRecent) + + testcases := map[string]struct { + height int64 + expectedResult int64 + strategy types.PruningStrategy + expectedHeights []int64 + }{ + "previousHeight is negative - prune everything - invalid previousHeight": { + -1, + 0, + types.PruningEverything, + []int64{}, + }, + "previousHeight is zero - prune everything - invalid previousHeight": { + 0, + 0, + types.PruningEverything, + []int64{}, + }, + "previousHeight is positive but within keep recent- prune everything - not kept": { + keepRecent, + 0, + types.PruningEverything, + []int64{}, + }, + "previousHeight is positive and greater than keep recent - kept": { + keepRecent + 1, + keepRecent + 1 - keepRecent, + types.PruningEverything, + []int64{keepRecent + 1 - keepRecent}, + }, + "pruning nothing, previousHeight is positive and greater than keep recent - not kept": { + keepRecent + 1, + 0, + types.PruningNothing, + []int64{}, + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) + require.NotNil(t, manager) + manager.SetOptions(types.NewPruningOptions(tc.strategy)) + + handleHeightActual := manager.HandleHeight(tc.height) + require.Equal(t, tc.expectedResult, handleHeightActual) + + actualHeights, err := manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, len(tc.expectedHeights), len(actualHeights)) + require.Equal(t, tc.expectedHeights, actualHeights) + }) + } +} + +func TestHandleHeight_FlushLoadFromDisk(t *testing.T) { + testcases := map[string]struct { + previousHeight int64 + keepRecent uint64 + snapshotInterval uint64 + movedSnapshotHeights []int64 + expectedHandleHeightResult int64 + expectedLoadPruningHeightsResult error + expectedLoadedHeights []int64 + }{ + "simple flush occurs": { + previousHeight: 11, + keepRecent: 10, + snapshotInterval: 0, + movedSnapshotHeights: []int64{}, + expectedHandleHeightResult: 11 - 10, + expectedLoadPruningHeightsResult: nil, + expectedLoadedHeights: []int64{11 - 10}, + }, + "previous height <= keep recent - no update and no flush": { + previousHeight: 9, + keepRecent: 10, + snapshotInterval: 0, + movedSnapshotHeights: []int64{}, + expectedHandleHeightResult: 0, + expectedLoadPruningHeightsResult: nil, + expectedLoadedHeights: []int64{}, + }, + "previous height alligns with snapshot interval - no update and no flush": { + previousHeight: 12, + keepRecent: 10, + snapshotInterval: 2, + movedSnapshotHeights: []int64{}, + expectedHandleHeightResult: 0, + expectedLoadPruningHeightsResult: nil, + expectedLoadedHeights: []int64{}, + }, + "previous height does not align with snapshot interval - flush": { + previousHeight: 12, + keepRecent: 10, + snapshotInterval: 3, + movedSnapshotHeights: []int64{}, + expectedHandleHeightResult: 2, + expectedLoadPruningHeightsResult: nil, + expectedLoadedHeights: []int64{2}, + }, + "moved snapshot heights - flushed": { + previousHeight: 32, + keepRecent: 10, + snapshotInterval: 5, + movedSnapshotHeights: []int64{15, 20, 25}, + expectedHandleHeightResult: 22, + expectedLoadPruningHeightsResult: nil, + expectedLoadedHeights: []int64{15, 20, 22}, + }, + "previous height alligns with snapshot interval - no update but flush snapshot heights": { + previousHeight: 30, + keepRecent: 10, + snapshotInterval: 5, + movedSnapshotHeights: []int64{15, 20, 25}, + expectedHandleHeightResult: 0, + expectedLoadPruningHeightsResult: nil, + expectedLoadedHeights: []int64{15}, + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + // Setup + db := db.NewMemDB() + manager := pruning.NewManager(db, log.NewNopLogger()) + require.NotNil(t, manager) + + manager.SetSnapshotInterval(tc.snapshotInterval) + manager.SetOptions(types.NewCustomPruningOptions(uint64(tc.keepRecent), uint64(10))) + + for _, snapshotHeight := range tc.movedSnapshotHeights { + manager.HandleHeightSnapshot(snapshotHeight) + } + + // Test HandleHeight and flush + handleHeightActual := manager.HandleHeight(tc.previousHeight) + require.Equal(t, tc.expectedHandleHeightResult, handleHeightActual) + + loadedPruneHeights, err := pruning.LoadPruningHeights(db) + require.NoError(t, err) + require.Equal(t, len(loadedPruneHeights), len(loadedPruneHeights)) + + // Test load back + err = manager.LoadPruningHeights(db) + require.NoError(t, err) + + heights, err := manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, len(tc.expectedLoadedHeights), len(heights)) + require.ElementsMatch(t, tc.expectedLoadedHeights, heights) + }) + } +} + +func TestHandleHeight_DbErr_Panic(t *testing.T) { + ctrl := gomock.NewController(t) + + // Setup + dbMock := mock.NewMockDB(ctrl) + + dbMock.EXPECT().SetSync(gomock.Any(), gomock.Any()).Return(errors.New(dbErr)).Times(1) + + manager := pruning.NewManager(dbMock, log.NewNopLogger()) + manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) + require.NotNil(t, manager) + + defer func() { + if r := recover(); r == nil { + t.Fail() + } + }() + + manager.HandleHeight(10) +} + +func TestHandleHeightSnapshot_FlushLoadFromDisk(t *testing.T) { + loadedHeightsMirror := []int64{} + + // Setup + db := db.NewMemDB() + manager := pruning.NewManager(db, log.NewNopLogger()) + require.NotNil(t, manager) + + manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) + + for snapshotHeight := int64(-1); snapshotHeight < 100; snapshotHeight++ { + // Test flush + manager.HandleHeightSnapshot(snapshotHeight) + + // Post test + if snapshotHeight > 0 { + loadedHeightsMirror = append(loadedHeightsMirror, snapshotHeight) + } + + loadedSnapshotHeights, err := pruning.LoadPruningSnapshotHeights(db) + require.NoError(t, err) + require.Equal(t, len(loadedHeightsMirror), loadedSnapshotHeights.Len()) + + // Test load back + err = manager.LoadPruningHeights(db) + require.NoError(t, err) + + loadedSnapshotHeights, err = pruning.LoadPruningSnapshotHeights(db) + require.NoError(t, err) + require.Equal(t, len(loadedHeightsMirror), loadedSnapshotHeights.Len()) + } +} + +func TestHandleHeightSnapshot_DbErr_Panic(t *testing.T) { + ctrl := gomock.NewController(t) + + // Setup + dbMock := mock.NewMockDB(ctrl) + + dbMock.EXPECT().SetSync(gomock.Any(), gomock.Any()).Return(errors.New(dbErr)).Times(1) + + manager := pruning.NewManager(dbMock, log.NewNopLogger()) + manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) + require.NotNil(t, manager) + + defer func() { + if r := recover(); r == nil { + t.Fail() + } + }() + + manager.HandleHeightSnapshot(10) +} + +func TestFlushLoad(t *testing.T) { + db := db.NewMemDB() + manager := pruning.NewManager(db, log.NewNopLogger()) + require.NotNil(t, manager) + + curStrategy := types.NewCustomPruningOptions(100, 15) + + snapshotInterval := uint64(10) + manager.SetSnapshotInterval(snapshotInterval) + + manager.SetOptions(curStrategy) + require.Equal(t, curStrategy, manager.GetOptions()) + + keepRecent := curStrategy.KeepRecent + + heightsToPruneMirror := make([]int64, 0) + + for curHeight := int64(0); curHeight < 1000; curHeight++ { + handleHeightActual := manager.HandleHeight(curHeight) + + curHeightStr := fmt.Sprintf("height: %d", curHeight) + + if curHeight > int64(keepRecent) && (snapshotInterval != 0 && (curHeight-int64(keepRecent))%int64(snapshotInterval) != 0 || snapshotInterval == 0) { + expectedHandleHeight := curHeight - int64(keepRecent) + require.Equal(t, expectedHandleHeight, handleHeightActual, curHeightStr) + heightsToPruneMirror = append(heightsToPruneMirror, expectedHandleHeight) + } else { + require.Equal(t, int64(0), handleHeightActual, curHeightStr) + } + + if manager.ShouldPruneAtHeight(curHeight) && curHeight > int64(keepRecent) { + actualHeights, err := manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, len(heightsToPruneMirror), len(actualHeights)) + require.Equal(t, heightsToPruneMirror, actualHeights) + + err = manager.LoadPruningHeights(db) + require.NoError(t, err) + + actualHeights, err = manager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, len(heightsToPruneMirror), len(actualHeights)) + require.Equal(t, heightsToPruneMirror, actualHeights) + + heightsToPruneMirror = make([]int64, 0) + } + } +} + +func TestLoadPruningHeights(t *testing.T) { + var ( + manager = pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) + err error + ) + require.NotNil(t, manager) + + // must not be PruningNothing + manager.SetOptions(types.NewPruningOptions(types.PruningDefault)) + + testcases := map[string]struct { + flushedPruningHeights []int64 + getFlushedPruningSnapshotHeights func() *list.List + expectedResult error + }{ + "negative pruningHeight - error": { + flushedPruningHeights: []int64{10, 0, -1}, + expectedResult: &pruning.NegativeHeightsError{Height: -1}, + }, + "negative snapshotPruningHeight - error": { + getFlushedPruningSnapshotHeights: func() *list.List { + l := list.New() + l.PushBack(int64(5)) + l.PushBack(int64(-2)) + l.PushBack(int64(3)) + return l + }, + expectedResult: &pruning.NegativeHeightsError{Height: -2}, + }, + "both have negative - pruningHeight error": { + flushedPruningHeights: []int64{10, 0, -1}, + getFlushedPruningSnapshotHeights: func() *list.List { + l := list.New() + l.PushBack(int64(5)) + l.PushBack(int64(-2)) + l.PushBack(int64(3)) + return l + }, + expectedResult: &pruning.NegativeHeightsError{Height: -1}, + }, + "both non-negative - success": { + flushedPruningHeights: []int64{10, 0, 3}, + getFlushedPruningSnapshotHeights: func() *list.List { + l := list.New() + l.PushBack(int64(5)) + l.PushBack(int64(0)) + l.PushBack(int64(3)) + return l + }, + }, + } + + for name, tc := range testcases { + t.Run(name, func(t *testing.T) { + db := db.NewMemDB() + if tc.flushedPruningHeights != nil { + err = db.Set(pruning.PruneHeightsKey, pruning.Int64SliceToBytes(tc.flushedPruningHeights)) + require.NoError(t, err) + } + + if tc.getFlushedPruningSnapshotHeights != nil { + err = db.Set(pruning.PruneSnapshotHeightsKey, pruning.ListToBytes(tc.getFlushedPruningSnapshotHeights())) + require.NoError(t, err) + } + + err = manager.LoadPruningHeights(db) + require.Equal(t, tc.expectedResult, err) + }) + } +} + +func TestLoadPruningHeights_PruneNothing(t *testing.T) { + manager := pruning.NewManager(db.NewMemDB(), log.NewNopLogger()) + require.NotNil(t, manager) + + manager.SetOptions(types.NewPruningOptions(types.PruningNothing)) + + require.Nil(t, manager.LoadPruningHeights(db.NewMemDB())) +} + +func TestGetFlushAndResetPruningHeights_DbErr_Panic(t *testing.T) { + ctrl := gomock.NewController(t) + + // Setup + dbMock := mock.NewMockDB(ctrl) + + dbMock.EXPECT().SetSync(gomock.Any(), gomock.Any()).Return(errors.New(dbErr)).Times(1) + + manager := pruning.NewManager(dbMock, log.NewNopLogger()) + manager.SetOptions(types.NewPruningOptions(types.PruningEverything)) + require.NotNil(t, manager) + + heights, err := manager.GetFlushAndResetPruningHeights() + require.Error(t, err) + require.Nil(t, heights) +} diff --git a/pruning/mock/db_mock.go b/pruning/mock/db_mock.go new file mode 100644 index 000000000000..fb6ee740b972 --- /dev/null +++ b/pruning/mock/db_mock.go @@ -0,0 +1,420 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: /home/roman/projects/cosmos-sdk/vendor/github.com/tendermint/tm-db/types.go + +// Package mock_db is a generated GoMock package. +package mock + +import ( + reflect "reflect" + + gomock "github.com/golang/mock/gomock" + db "github.com/tendermint/tm-db" +) + +// MockDB is a mock of DB interface. +type MockDB struct { + ctrl *gomock.Controller + recorder *MockDBMockRecorder +} + +// MockDBMockRecorder is the mock recorder for MockDB. +type MockDBMockRecorder struct { + mock *MockDB +} + +// NewMockDB creates a new mock instance. +func NewMockDB(ctrl *gomock.Controller) *MockDB { + mock := &MockDB{ctrl: ctrl} + mock.recorder = &MockDBMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockDB) EXPECT() *MockDBMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockDB) Close() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockDBMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockDB)(nil).Close)) +} + +// Delete mocks base method. +func (m *MockDB) Delete(arg0 []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockDBMockRecorder) Delete(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockDB)(nil).Delete), arg0) +} + +// DeleteSync mocks base method. +func (m *MockDB) DeleteSync(arg0 []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteSync", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteSync indicates an expected call of DeleteSync. +func (mr *MockDBMockRecorder) DeleteSync(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteSync", reflect.TypeOf((*MockDB)(nil).DeleteSync), arg0) +} + +// Get mocks base method. +func (m *MockDB) Get(arg0 []byte) ([]byte, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Get", arg0) + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Get indicates an expected call of Get. +func (mr *MockDBMockRecorder) Get(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockDB)(nil).Get), arg0) +} + +// Has mocks base method. +func (m *MockDB) Has(key []byte) (bool, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Has", key) + ret0, _ := ret[0].(bool) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Has indicates an expected call of Has. +func (mr *MockDBMockRecorder) Has(key interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Has", reflect.TypeOf((*MockDB)(nil).Has), key) +} + +// Iterator mocks base method. +func (m *MockDB) Iterator(start, end []byte) (db.Iterator, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Iterator", start, end) + ret0, _ := ret[0].(db.Iterator) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// Iterator indicates an expected call of Iterator. +func (mr *MockDBMockRecorder) Iterator(start, end interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Iterator", reflect.TypeOf((*MockDB)(nil).Iterator), start, end) +} + +// NewBatch mocks base method. +func (m *MockDB) NewBatch() db.Batch { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "NewBatch") + ret0, _ := ret[0].(db.Batch) + return ret0 +} + +// NewBatch indicates an expected call of NewBatch. +func (mr *MockDBMockRecorder) NewBatch() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NewBatch", reflect.TypeOf((*MockDB)(nil).NewBatch)) +} + +// Print mocks base method. +func (m *MockDB) Print() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Print") + ret0, _ := ret[0].(error) + return ret0 +} + +// Print indicates an expected call of Print. +func (mr *MockDBMockRecorder) Print() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Print", reflect.TypeOf((*MockDB)(nil).Print)) +} + +// ReverseIterator mocks base method. +func (m *MockDB) ReverseIterator(start, end []byte) (db.Iterator, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ReverseIterator", start, end) + ret0, _ := ret[0].(db.Iterator) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// ReverseIterator indicates an expected call of ReverseIterator. +func (mr *MockDBMockRecorder) ReverseIterator(start, end interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReverseIterator", reflect.TypeOf((*MockDB)(nil).ReverseIterator), start, end) +} + +// Set mocks base method. +func (m *MockDB) Set(arg0, arg1 []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Set", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// Set indicates an expected call of Set. +func (mr *MockDBMockRecorder) Set(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockDB)(nil).Set), arg0, arg1) +} + +// SetSync mocks base method. +func (m *MockDB) SetSync(arg0, arg1 []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetSync", arg0, arg1) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetSync indicates an expected call of SetSync. +func (mr *MockDBMockRecorder) SetSync(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetSync", reflect.TypeOf((*MockDB)(nil).SetSync), arg0, arg1) +} + +// Stats mocks base method. +func (m *MockDB) Stats() map[string]string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Stats") + ret0, _ := ret[0].(map[string]string) + return ret0 +} + +// Stats indicates an expected call of Stats. +func (mr *MockDBMockRecorder) Stats() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Stats", reflect.TypeOf((*MockDB)(nil).Stats)) +} + +// MockBatch is a mock of Batch interface. +type MockBatch struct { + ctrl *gomock.Controller + recorder *MockBatchMockRecorder +} + +// MockBatchMockRecorder is the mock recorder for MockBatch. +type MockBatchMockRecorder struct { + mock *MockBatch +} + +// NewMockBatch creates a new mock instance. +func NewMockBatch(ctrl *gomock.Controller) *MockBatch { + mock := &MockBatch{ctrl: ctrl} + mock.recorder = &MockBatchMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockBatch) EXPECT() *MockBatchMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockBatch) Close() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockBatchMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockBatch)(nil).Close)) +} + +// Delete mocks base method. +func (m *MockBatch) Delete(key []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Delete", key) + ret0, _ := ret[0].(error) + return ret0 +} + +// Delete indicates an expected call of Delete. +func (mr *MockBatchMockRecorder) Delete(key interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockBatch)(nil).Delete), key) +} + +// Set mocks base method. +func (m *MockBatch) Set(key, value []byte) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Set", key, value) + ret0, _ := ret[0].(error) + return ret0 +} + +// Set indicates an expected call of Set. +func (mr *MockBatchMockRecorder) Set(key, value interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockBatch)(nil).Set), key, value) +} + +// Write mocks base method. +func (m *MockBatch) Write() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Write") + ret0, _ := ret[0].(error) + return ret0 +} + +// Write indicates an expected call of Write. +func (mr *MockBatchMockRecorder) Write() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Write", reflect.TypeOf((*MockBatch)(nil).Write)) +} + +// WriteSync mocks base method. +func (m *MockBatch) WriteSync() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "WriteSync") + ret0, _ := ret[0].(error) + return ret0 +} + +// WriteSync indicates an expected call of WriteSync. +func (mr *MockBatchMockRecorder) WriteSync() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "WriteSync", reflect.TypeOf((*MockBatch)(nil).WriteSync)) +} + +// MockIterator is a mock of Iterator interface. +type MockIterator struct { + ctrl *gomock.Controller + recorder *MockIteratorMockRecorder +} + +// MockIteratorMockRecorder is the mock recorder for MockIterator. +type MockIteratorMockRecorder struct { + mock *MockIterator +} + +// NewMockIterator creates a new mock instance. +func NewMockIterator(ctrl *gomock.Controller) *MockIterator { + mock := &MockIterator{ctrl: ctrl} + mock.recorder = &MockIteratorMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockIterator) EXPECT() *MockIteratorMockRecorder { + return m.recorder +} + +// Close mocks base method. +func (m *MockIterator) Close() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Close") + ret0, _ := ret[0].(error) + return ret0 +} + +// Close indicates an expected call of Close. +func (mr *MockIteratorMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockIterator)(nil).Close)) +} + +// Domain mocks base method. +func (m *MockIterator) Domain() ([]byte, []byte) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Domain") + ret0, _ := ret[0].([]byte) + ret1, _ := ret[1].([]byte) + return ret0, ret1 +} + +// Domain indicates an expected call of Domain. +func (mr *MockIteratorMockRecorder) Domain() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Domain", reflect.TypeOf((*MockIterator)(nil).Domain)) +} + +// Error mocks base method. +func (m *MockIterator) Error() error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Error") + ret0, _ := ret[0].(error) + return ret0 +} + +// Error indicates an expected call of Error. +func (mr *MockIteratorMockRecorder) Error() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Error", reflect.TypeOf((*MockIterator)(nil).Error)) +} + +// Key mocks base method. +func (m *MockIterator) Key() []byte { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Key") + ret0, _ := ret[0].([]byte) + return ret0 +} + +// Key indicates an expected call of Key. +func (mr *MockIteratorMockRecorder) Key() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Key", reflect.TypeOf((*MockIterator)(nil).Key)) +} + +// Next mocks base method. +func (m *MockIterator) Next() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Next") +} + +// Next indicates an expected call of Next. +func (mr *MockIteratorMockRecorder) Next() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Next", reflect.TypeOf((*MockIterator)(nil).Next)) +} + +// Valid mocks base method. +func (m *MockIterator) Valid() bool { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Valid") + ret0, _ := ret[0].(bool) + return ret0 +} + +// Valid indicates an expected call of Valid. +func (mr *MockIteratorMockRecorder) Valid() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Valid", reflect.TypeOf((*MockIterator)(nil).Valid)) +} + +// Value mocks base method. +func (m *MockIterator) Value() []byte { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Value") + ret0, _ := ret[0].([]byte) + return ret0 +} + +// Value indicates an expected call of Value. +func (mr *MockIteratorMockRecorder) Value() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Value", reflect.TypeOf((*MockIterator)(nil).Value)) +} diff --git a/pruning/types/options.go b/pruning/types/options.go new file mode 100644 index 000000000000..229dbed984d5 --- /dev/null +++ b/pruning/types/options.go @@ -0,0 +1,130 @@ +package types + +import ( + "errors" + "fmt" +) + +// PruningOptions defines the pruning strategy used when determining which +// heights are removed from disk when committing state. +type PruningOptions struct { + // KeepRecent defines how many recent heights to keep on disk. + KeepRecent uint64 + + // Interval defines when the pruned heights are removed from disk. + Interval uint64 + + // Strategy defines the kind of pruning strategy. See below for more information on each. + Strategy PruningStrategy +} + +type PruningStrategy int + +// Pruning option string constants +const ( + PruningOptionDefault = "default" + PruningOptionEverything = "everything" + PruningOptionNothing = "nothing" + PruningOptionCustom = "custom" +) + +const ( + // PruningDefault defines a pruning strategy where the last 362880 heights are + // kept where to-be pruned heights are pruned at every 10th height. + // The last 362880 heights are kept(approximately 3.5 weeks worth of state) assuming the typical + // block time is 6s. If these values do not match the applications' requirements, use the "custom" option. + PruningDefault PruningStrategy = iota + // PruningEverything defines a pruning strategy where all committed heights are + // deleted, storing only the current height and last 2 states. To-be pruned heights are + // pruned at every 10th height. + PruningEverything + // PruningNothing defines a pruning strategy where all heights are kept on disk. + // This is the only stretegy where KeepEvery=1 is allowed with state-sync snapshots disabled. + PruningNothing + // PruningCustom defines a pruning strategy where the user specifies the pruning. + PruningCustom + // PruningUndefined defines an undefined pruning strategy. It is to be returned by stores that do not support pruning. + PruningUndefined +) + +const ( + pruneEverythingKeepRecent = 2 + pruneEverythingInterval = 10 +) + +var ( + ErrPruningIntervalZero = errors.New("'pruning-interval' must not be 0. If you want to disable pruning, select pruning = \"nothing\"") + ErrPruningIntervalTooSmall = fmt.Errorf("'pruning-interval' must not be less than %d. For the most aggressive pruning, select pruning = \"everything\"", pruneEverythingInterval) + ErrPruningKeepRecentTooSmall = fmt.Errorf("'pruning-keep-recent' must not be less than %d. For the most aggressive pruning, select pruning = \"everything\"", pruneEverythingKeepRecent) +) + +func NewPruningOptions(pruningStrategy PruningStrategy) PruningOptions { + switch pruningStrategy { + case PruningDefault: + return PruningOptions{ + KeepRecent: 362880, + Interval: 10, + Strategy: PruningDefault, + } + case PruningEverything: + return PruningOptions{ + KeepRecent: pruneEverythingKeepRecent, + Interval: pruneEverythingInterval, + Strategy: PruningEverything, + } + case PruningNothing: + return PruningOptions{ + KeepRecent: 0, + Interval: 0, + Strategy: PruningNothing, + } + default: + return PruningOptions{ + Strategy: PruningCustom, + } + } +} + +func NewCustomPruningOptions(keepRecent, interval uint64) PruningOptions { + return PruningOptions{ + KeepRecent: keepRecent, + Interval: interval, + Strategy: PruningCustom, + } +} + +func (po PruningOptions) GetPruningStrategy() PruningStrategy { + return po.Strategy +} + +func (po PruningOptions) Validate() error { + if po.Strategy == PruningNothing { + return nil + } + if po.Interval == 0 { + return ErrPruningIntervalZero + } + if po.Interval < pruneEverythingInterval { + return ErrPruningIntervalTooSmall + } + if po.KeepRecent < pruneEverythingKeepRecent { + return ErrPruningKeepRecentTooSmall + } + return nil +} + +func NewPruningOptionsFromString(strategy string) PruningOptions { + switch strategy { + case PruningOptionEverything: + return NewPruningOptions(PruningEverything) + + case PruningOptionNothing: + return NewPruningOptions(PruningNothing) + + case PruningOptionDefault: + return NewPruningOptions(PruningDefault) + + default: + return NewPruningOptions(PruningDefault) + } +} diff --git a/pruning/types/options_test.go b/pruning/types/options_test.go new file mode 100644 index 000000000000..abc6bf39e2a3 --- /dev/null +++ b/pruning/types/options_test.go @@ -0,0 +1,65 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestPruningOptions_Validate(t *testing.T) { + testCases := []struct { + opts PruningOptions + expectErr error + }{ + {NewPruningOptions(PruningDefault), nil}, + {NewPruningOptions(PruningEverything), nil}, + {NewPruningOptions(PruningNothing), nil}, + {NewPruningOptions(PruningCustom), ErrPruningIntervalZero}, + {NewCustomPruningOptions(2, 10), nil}, + {NewCustomPruningOptions(100, 15), nil}, + {NewCustomPruningOptions(1, 10), ErrPruningKeepRecentTooSmall}, + {NewCustomPruningOptions(2, 9), ErrPruningIntervalTooSmall}, + {NewCustomPruningOptions(2, 0), ErrPruningIntervalZero}, + {NewCustomPruningOptions(2, 0), ErrPruningIntervalZero}, + } + + for _, tc := range testCases { + err := tc.opts.Validate() + require.Equal(t, tc.expectErr, err, "options: %v, err: %s", tc.opts, err) + } +} + +func TestPruningOptions_GetStrategy(t *testing.T) { + testCases := []struct { + opts PruningOptions + expectedStrategy PruningStrategy + }{ + {NewPruningOptions(PruningDefault), PruningDefault}, + {NewPruningOptions(PruningEverything), PruningEverything}, + {NewPruningOptions(PruningNothing), PruningNothing}, + {NewPruningOptions(PruningCustom), PruningCustom}, + {NewCustomPruningOptions(2, 10), PruningCustom}, + } + + for _, tc := range testCases { + actualStrategy := tc.opts.GetPruningStrategy() + require.Equal(t, tc.expectedStrategy, actualStrategy) + } +} + +func TestNewPruningOptionsFromString(t *testing.T) { + testCases := []struct { + optString string + expect PruningOptions + }{ + {PruningOptionDefault, NewPruningOptions(PruningDefault)}, + {PruningOptionEverything, NewPruningOptions(PruningEverything)}, + {PruningOptionNothing, NewPruningOptions(PruningNothing)}, + {"invalid", NewPruningOptions(PruningDefault)}, + } + + for _, tc := range testCases { + actual := NewPruningOptionsFromString(tc.optString) + require.Equal(t, tc.expect, actual) + } +} diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 02e498646cd2..234b84ae1d86 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -1,36 +1,24 @@ #!/usr/bin/env bash #== Requirements == - # - ## make sure your `go env GOPATH` is in the `$PATH` - ## Install: - ## + latest buf (v1.0.0-rc11 or later) - ## + protobuf v3 - # - ## All protoc dependencies must be installed not in the module scope - ## currently we must use grpc-gateway v1 - # cd ~ - # go install google.golang.org/protobuf/cmd/protoc-gen-go@latest - # go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest - # go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.16.0 - # go install github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest - # go get github.com/regen-network/cosmos-proto@latest # doesn't work in install mode +# +## make sure your `go env GOPATH` is in the `$PATH` +## Install: +## + latest buf (v1.0.0-rc11 or later) +## + protobuf v3 +# +## All protoc dependencies must be installed not in the module scope +## currently we must use grpc-gateway v1 +# cd ~ +# go install google.golang.org/protobuf/cmd/protoc-gen-go@latest +# go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest +# go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.16.0 +# go install github.com/cosmos/cosmos-proto/cmd/protoc-gen-go-pulsar@latest +# go get github.com/regen-network/cosmos-proto@latest # doesn't work in install mode +# go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@v0.3.1 set -eo pipefail -protoc_install_gocosmos() { - echo "Installing protobuf gocosmos plugin" - # we should use go install, but regen-network/cosmos-proto contains - # replace directives. It must not contain directives that would cause - # it to be interpreted differently than if it were the main module. - # So the command below issues a warning and we are muting it for now. - # - # Installing plugins must be done outside of the module - (go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@v0.3.1 2> /dev/null) - } - - protoc_install_gocosmos - echo "Generating gogo proto code" cd proto proto_dirs=$(find ./cosmos -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) @@ -51,6 +39,6 @@ cd .. cp -r github.com/cosmos/cosmos-sdk/* ./ rm -rf github.com -go mod tidy +go mod tidy -compat=1.17 ./scripts/protocgen2.sh diff --git a/server/api/server.go b/server/api/server.go index 18daefb83c8c..c052c03f52ca 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.MaxOpenConnections) 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/config/config.go b/server/config/config.go index 64e3aa22bd0d..030963fc3a58 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -2,11 +2,13 @@ package config import ( "fmt" + "math" "strings" "github.com/spf13/viper" - storetypes "github.com/cosmos/cosmos-sdk/store/types" + clientflags "github.com/cosmos/cosmos-sdk/client/flags" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -23,6 +25,14 @@ const ( // DefaultGRPCWebAddress defines the default address to bind the gRPC-web server to. DefaultGRPCWebAddress = "0.0.0.0:9091" + + // DefaultGRPCMaxRecvMsgSize defines the default gRPC max message size in + // bytes the server can receive. + DefaultGRPCMaxRecvMsgSize = 1024 * 1024 * 10 + + // DefaultGRPCMaxSendMsgSize defines the default gRPC max message size in + // bytes the server can send. + DefaultGRPCMaxSendMsgSize = math.MaxInt32 ) // BaseConfig defines the server's basic configuration @@ -131,6 +141,15 @@ type RosettaConfig struct { // Offline defines if the server must be run in offline mode Offline bool `mapstructure:"offline"` + + // EnableFeeSuggestion defines if the server should suggest fee by default + EnableFeeSuggestion bool `mapstructure:"enable-fee-suggestion"` + + // GasToSuggest defines gas limit when calculating the fee + GasToSuggest int `mapstructure:"gas-to-suggest"` + + // DenomToSuggest defines the defult denom for fee suggestion + DenomToSuggest string `mapstructure:"denom-to-suggest"` } // GRPCConfig defines configuration for the gRPC server. @@ -140,6 +159,14 @@ type GRPCConfig struct { // Address defines the API server to listen on Address string `mapstructure:"address"` + + // MaxRecvMsgSize defines the max message size in bytes the server can receive. + // The default value is 10MB. + MaxRecvMsgSize int `mapstructure:"max-recv-msg-size"` + + // MaxSendMsgSize defines the max message size in bytes the server can send. + // The default value is math.MaxInt32. + MaxSendMsgSize int `mapstructure:"max-send-msg-size"` } // GRPCWebConfig defines configuration for the gRPC-web server. @@ -157,7 +184,7 @@ type GRPCWebConfig struct { // StateSyncConfig defines the state sync snapshot configuration. type StateSyncConfig struct { // SnapshotInterval sets the interval at which state sync snapshots are taken. - // 0 disables snapshots. Must be a multiple of PruningKeepEvery. + // 0 disables snapshots. SnapshotInterval uint64 `mapstructure:"snapshot-interval"` // SnapshotKeepRecent sets the number of recent state sync snapshots to keep. @@ -211,7 +238,7 @@ func DefaultConfig() *Config { BaseConfig: BaseConfig{ MinGasPrices: defaultMinGasPrices, InterBlockCache: true, - Pruning: storetypes.PruningOptionDefault, + Pruning: pruningtypes.PruningOptionDefault, PruningKeepRecent: "0", PruningInterval: "0", MinRetainBlocks: 0, @@ -232,16 +259,21 @@ func DefaultConfig() *Config { RPCMaxBodyBytes: 1000000, }, GRPC: GRPCConfig{ - Enable: true, - Address: DefaultGRPCAddress, + Enable: true, + Address: DefaultGRPCAddress, + MaxRecvMsgSize: DefaultGRPCMaxRecvMsgSize, + MaxSendMsgSize: DefaultGRPCMaxSendMsgSize, }, Rosetta: RosettaConfig{ - Enable: false, - Address: ":8080", - Blockchain: "app", - Network: "network", - Retries: 3, - Offline: false, + Enable: false, + Address: ":8080", + Blockchain: "app", + Network: "network", + Retries: 3, + Offline: false, + EnableFeeSuggestion: false, + GasToSuggest: clientflags.DefaultGasLimit, + DenomToSuggest: "uatom", }, GRPCWeb: GRPCWebConfig{ Enable: true, @@ -299,16 +331,21 @@ func GetConfig(v *viper.Viper) Config { EnableUnsafeCORS: v.GetBool("api.enabled-unsafe-cors"), }, Rosetta: RosettaConfig{ - Enable: v.GetBool("rosetta.enable"), - Address: v.GetString("rosetta.address"), - Blockchain: v.GetString("rosetta.blockchain"), - Network: v.GetString("rosetta.network"), - Retries: v.GetInt("rosetta.retries"), - Offline: v.GetBool("rosetta.offline"), + Enable: v.GetBool("rosetta.enable"), + Address: v.GetString("rosetta.address"), + Blockchain: v.GetString("rosetta.blockchain"), + Network: v.GetString("rosetta.network"), + Retries: v.GetInt("rosetta.retries"), + Offline: v.GetBool("rosetta.offline"), + EnableFeeSuggestion: v.GetBool("rosetta.enable-fee-suggestion"), + GasToSuggest: v.GetInt("rosetta.gas-to-suggest"), + DenomToSuggest: v.GetString("rosetta.denom-to-suggest"), }, GRPC: GRPCConfig{ - Enable: v.GetBool("grpc.enable"), - Address: v.GetString("grpc.address"), + Enable: v.GetBool("grpc.enable"), + Address: v.GetString("grpc.address"), + MaxRecvMsgSize: v.GetInt("grpc.max-recv-msg-size"), + MaxSendMsgSize: v.GetInt("grpc.max-send-msg-size"), }, GRPCWeb: GRPCWebConfig{ Enable: v.GetBool("grpc-web.enable"), @@ -327,9 +364,9 @@ func (c Config) ValidateBasic() error { if c.BaseConfig.MinGasPrices == "" { return sdkerrors.ErrAppConfig.Wrap("set min gas price in app.toml or flag or env variable") } - if c.Pruning == storetypes.PruningOptionEverything && c.StateSync.SnapshotInterval > 0 { + if c.Pruning == pruningtypes.PruningOptionEverything && c.StateSync.SnapshotInterval > 0 { return sdkerrors.ErrAppConfig.Wrapf( - "cannot enable state sync snapshots with '%s' pruning setting", storetypes.PruningOptionEverything, + "cannot enable state sync snapshots with '%s' pruning setting", pruningtypes.PruningOptionEverything, ) } diff --git a/server/config/config_test.go b/server/config/config_test.go index 4c396cf45586..442e56026ec4 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -2,11 +2,11 @@ package config import ( "bytes" - "github.com/spf13/viper" - "github.com/stretchr/testify/assert" "path/filepath" "testing" + "github.com/spf13/viper" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/server/config/toml.go b/server/config/toml.go index 4b574b5e7849..a93fffd1ecd6 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -24,8 +24,8 @@ minimum-gas-prices = "{{ .BaseConfig.MinGasPrices }}" # default: the last 362880 states are kept, pruning at 10 block intervals # nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) -# everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals -# custom: allow pruning options to be manually specified through 'pruning-keep-recent' and 'pruning-interval' +# everything: 2 latest states will be kept; pruning at 10 block intervals. +# custom: allow pruning options to be manually specified through 'pruning-keep-recent', and 'pruning-interval' pruning = "{{ .BaseConfig.Pruning }}" # These are applied if and only if the pruning strategy is custom. @@ -170,6 +170,18 @@ retries = {{ .Rosetta.Retries }} # Offline defines if Rosetta server should run in offline mode. offline = {{ .Rosetta.Offline }} +# EnableDefaultSuggestedFee defines if the server should suggest fee by default. +# If 'construction/medata' is called without gas limit and gas price, +# suggested fee based on gas-to-suggest and denom-to-suggest will be given. +enable-fee-suggestion = {{ .Rosetta.EnableFeeSuggestion }} + +# GasToSuggest defines gas limit when calculating the fee +gas-to-suggest = {{ .Rosetta.GasToSuggest }} + +# DenomToSuggest defines the defult denom for fee suggestion. +# Price must be in minimum-gas-prices. +denom-to-suggest = "{{ .Rosetta.DenomToSuggest }}" + ############################################################################### ### gRPC Configuration ### ############################################################################### @@ -182,6 +194,14 @@ enable = {{ .GRPC.Enable }} # Address defines the gRPC server address to bind to. address = "{{ .GRPC.Address }}" +# MaxRecvMsgSize defines the max message size in bytes the server can receive. +# The default value is 10MB. +max-recv-msg-size = "{{ .GRPC.MaxRecvMsgSize }}" + +# MaxSendMsgSize defines the max message size in bytes the server can send. +# The default value is math.MaxInt32. +max-send-msg-size = "{{ .GRPC.MaxSendMsgSize }}" + ############################################################################### ### gRPC Web Configuration ### ############################################################################### @@ -256,7 +276,7 @@ func WriteConfigFile(configFilePath string, config interface{}) { panic(err) } - mustWriteFile(configFilePath, buffer.Bytes(), 0644) + mustWriteFile(configFilePath, buffer.Bytes(), 0o644) } func mustWriteFile(filePath string, contents []byte, mode os.FileMode) { diff --git a/server/export.go b/server/export.go index 512c3d86d284..1ee3659300c0 100644 --- a/server/export.go +++ b/server/export.go @@ -102,6 +102,7 @@ func ExportCmd(appExporter types.AppExporter, defaultNodeHome string) *cobra.Com return err } + cmd.SetOut(cmd.OutOrStdout()) cmd.Println(string(sdk.MustSortJSON(encoded))) return nil }, diff --git a/server/export_test.go b/server/export_test.go index bd6bbb41ecdd..01f0887af7ad 100644 --- a/server/export_test.go +++ b/server/export_test.go @@ -117,7 +117,6 @@ func TestExportCmd_Height(t *testing.T) { require.Equal(t, tc.expHeight, exportedGenDoc.InitialHeight) }) } - } func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *tmtypes.GenesisDoc, *cobra.Command) { @@ -173,7 +172,7 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, *t } func createConfigFolder(dir string) error { - return os.Mkdir(path.Join(dir, "config"), 0700) + return os.Mkdir(path.Join(dir, "config"), 0o700) } func saveGenesisFile(genDoc *tmtypes.GenesisDoc, dir string) error { diff --git a/server/grpc/grpc_web_test.go b/server/grpc/grpc_web_test.go index 37202fdfabbe..384b06453bad 100644 --- a/server/grpc/grpc_web_test.go +++ b/server/grpc/grpc_web_test.go @@ -195,7 +195,9 @@ func (s *GRPCWebTestSuite) makeGrpcRequest( if err != nil { return nil, Trailer{}, nil, err } - defer resp.Body.Close() + defer func() { + _ = resp.Body.Close() + }() contents, err := io.ReadAll(resp.Body) if err != nil { return nil, Trailer{}, nil, err diff --git a/server/grpc/server.go b/server/grpc/server.go index ae96ac647ff4..0bdea8bca2ea 100644 --- a/server/grpc/server.go +++ b/server/grpc/server.go @@ -2,13 +2,13 @@ package grpc import ( "fmt" - "github.com/cosmos/cosmos-sdk/codec" "net" "time" "google.golang.org/grpc" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/server/config" "github.com/cosmos/cosmos-sdk/server/grpc/gogoreflection" reflection "github.com/cosmos/cosmos-sdk/server/grpc/reflection/v2alpha1" "github.com/cosmos/cosmos-sdk/server/types" @@ -16,14 +16,27 @@ import ( ) // StartGRPCServer starts a gRPC server on the given address. -func StartGRPCServer(clientCtx client.Context, app types.Application, address string) (*grpc.Server, error) { +func StartGRPCServer(clientCtx client.Context, app types.Application, cfg config.GRPCConfig) (*grpc.Server, error) { + maxSendMsgSize := cfg.MaxSendMsgSize + if maxSendMsgSize == 0 { + maxSendMsgSize = config.DefaultGRPCMaxSendMsgSize + } + + maxRecvMsgSize := cfg.MaxRecvMsgSize + if maxRecvMsgSize == 0 { + maxRecvMsgSize = config.DefaultGRPCMaxRecvMsgSize + } + grpcSrv := grpc.NewServer( - grpc.ForceServerCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()), + grpc.MaxSendMsgSize(maxSendMsgSize), + grpc.MaxRecvMsgSize(maxRecvMsgSize), ) app.RegisterGRPCServer(grpcSrv) - // reflection allows consumers to build dynamic clients that can write - // to any cosmos-sdk application without relying on application packages at compile time + + // Reflection allows consumers to build dynamic clients that can write to any + // Cosmos SDK application without relying on application packages at compile + // time. err := reflection.Register(grpcSrv, reflection.Config{ SigningModes: func() map[string]int32 { modes := make(map[string]int32, len(clientCtx.TxConfig.SignModeHandler().Modes())) @@ -39,10 +52,12 @@ func StartGRPCServer(clientCtx client.Context, app types.Application, address st if err != nil { return nil, err } + // Reflection allows external clients to see what services and methods // the gRPC server exposes. gogoreflection.Register(grpcSrv) - listener, err := net.Listen("tcp", address) + + listener, err := net.Listen("tcp", cfg.Address) if err != nil { return nil, err } @@ -58,7 +73,9 @@ func StartGRPCServer(clientCtx client.Context, app types.Application, address st select { case err := <-errCh: return nil, err - case <-time.After(types.ServerStartTime): // assume server started successfully + + case <-time.After(types.ServerStartTime): + // assume server started successfully return grpcSrv, nil } } diff --git a/server/grpc/server_test.go b/server/grpc/server_test.go index 082399425306..5655d700c684 100644 --- a/server/grpc/server_test.go +++ b/server/grpc/server_test.go @@ -6,10 +6,11 @@ package grpc_test import ( "context" "fmt" - "github.com/cosmos/cosmos-sdk/codec" "testing" "time" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/jhump/protoreflect/grpcreflect" "github.com/stretchr/testify/require" diff --git a/server/mock/app.go b/server/mock/app.go index 6d41097ce28d..8d777612c198 100644 --- a/server/mock/app.go +++ b/server/mock/app.go @@ -12,25 +12,11 @@ import ( bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/db/badgerdb" - "github.com/cosmos/cosmos-sdk/simapp" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" ) -func testTxHandler(options middleware.TxHandlerOptions) tx.Handler { - return middleware.ComposeMiddlewares( - middleware.NewRunMsgsTxHandler(options.MsgServiceRouter, options.LegacyRouter), - middleware.NewTxDecoderMiddleware(options.TxDecoder), - middleware.GasTxMiddleware, - middleware.RecoveryTxMiddleware, - middleware.NewIndexEventsTxMiddleware(options.IndexEvents), - ) -} - // NewApp creates a simple mock kvstore app for testing. It should work // similar to a real app. Make sure rootDir is empty before running the test, // in order to guarantee consistent results @@ -45,27 +31,13 @@ func NewApp(rootDir string, logger log.Logger) (abci.Application, error) { // Create BaseApp. opt := bam.SetSubstores(capKeyMainStore) - baseApp := bam.NewBaseApp("kvstore", logger, db, opt) + baseApp := bam.NewBaseApp("kvstore", logger, db, decodeTx, opt) baseApp.SetInitChainer(InitChainer(capKeyMainStore)) // Set a Route. - encCfg := simapp.MakeTestEncodingConfig() - legacyRouter := middleware.NewLegacyRouter() - // We're adding a test legacy route here, which accesses the kvstore - // and simply sets the Msg's key/value pair in the kvstore. - legacyRouter.AddRoute(sdk.NewRoute("kvstore", KVStoreHandler(capKeyMainStore))) - txHandler := testTxHandler( - middleware.TxHandlerOptions{ - LegacyRouter: legacyRouter, - MsgServiceRouter: middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry), - TxDecoder: decodeTx, - }, - ) - baseApp.SetTxHandler(txHandler) - if err = baseApp.Init(); err != nil { - return nil, err - } + baseApp.Router().AddRoute(sdk.NewRoute("kvstore", KVStoreHandler(capKeyMainStore))) + return baseApp, nil } @@ -73,7 +45,7 @@ func NewApp(rootDir string, logger log.Logger) (abci.Application, error) { // them to the db func KVStoreHandler(storeKey storetypes.StoreKey) sdk.Handler { return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - dTx, ok := msg.(*kvstoreTx) + dTx, ok := msg.(kvstoreTx) if !ok { return nil, errors.New("KVStoreHandler should only receive kvstoreTx") } @@ -85,14 +57,8 @@ func KVStoreHandler(storeKey storetypes.StoreKey) sdk.Handler { store := ctx.KVStore(storeKey) store.Set(key, value) - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return nil, err - } - return &sdk.Result{ - Log: fmt.Sprintf("set %s=%s", key, value), - MsgResponses: []*codectypes.Any{any}, + Log: fmt.Sprintf("set %s=%s", key, value), }, nil } } @@ -131,8 +97,7 @@ func InitChainer(key storetypes.StoreKey) func(sdk.Context, abci.RequestInitChai // AppGenState can be passed into InitCmd, returns a static string of a few // key-values that can be parsed by InitChainer -func AppGenState(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) (appState json. - RawMessage, err error) { +func AppGenState(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) (appState json.RawMessage, err error) { appState = json.RawMessage(`{ "values": [ { @@ -149,8 +114,7 @@ func AppGenState(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) } // AppGenStateEmpty returns an empty transaction state for mocking. -func AppGenStateEmpty(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) ( - appState json.RawMessage, err error) { +func AppGenStateEmpty(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) (appState json.RawMessage, err error) { appState = json.RawMessage(``) return } diff --git a/server/mock/app_test.go b/server/mock/app_test.go index 2741925df026..94362c887068 100644 --- a/server/mock/app_test.go +++ b/server/mock/app_test.go @@ -24,7 +24,7 @@ func TestInitApp(t *testing.T) { appState, err := AppGenState(nil, types.GenesisDoc{}, nil) require.NoError(t, err) - //TODO test validators in the init chain? + // TODO test validators in the init chain? req := abci.RequestInitChain{ AppStateBytes: appState, } diff --git a/server/mock/store.go b/server/mock/store.go index 3b37ef69dcd1..8d76f35bca1d 100644 --- a/server/mock/store.go +++ b/server/mock/store.go @@ -5,6 +5,7 @@ import ( protoio "github.com/gogo/protobuf/io" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" storetypes "github.com/cosmos/cosmos-sdk/store/v2alpha1" sdk "github.com/cosmos/cosmos-sdk/types" @@ -64,11 +65,11 @@ func (ms multiStore) LastCommitID() storetypes.CommitID { panic("not implemented") } -func (ms multiStore) SetPruning(opts sdk.PruningOptions) { +func (ms multiStore) SetPruning(opts pruningtypes.PruningOptions) { panic("not implemented") } -func (ms multiStore) GetPruning() sdk.PruningOptions { +func (ms multiStore) GetPruning() pruningtypes.PruningOptions { panic("not implemented") } @@ -88,6 +89,18 @@ func (ms multiStore) GetAllVersions() []int { panic("not implemented") } +func (ms multiStore) PruneSnapshotHeight(height int64) { + panic("not implemented") +} + +func (ms multiStore) SetSnapshotInterval(snapshotInterval uint64) { + panic("not implemented") +} + +func (ms multiStore) SetInterBlockCache(_ sdk.MultiStorePersistentCache) { + panic("not implemented") +} + func (ms multiStore) Close() error { panic("not implemented") } diff --git a/server/mock/tx.go b/server/mock/tx.go index bfa6e6ad6b4b..0cb79c28986f 100644 --- a/server/mock/tx.go +++ b/server/mock/tx.go @@ -4,16 +4,12 @@ package mock import ( "bytes" "fmt" - "math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" ) -// kvstoreTx defines a tx for mock purposes. The `key` and `value` fields will -// set those bytes in the kvstore, and the `bytes` field represents its -// GetSignBytes value. +// An sdk.Tx which is its own sdk.Msg. type kvstoreTx struct { key []byte value []byte @@ -21,13 +17,12 @@ type kvstoreTx struct { } // dummy implementation of proto.Message -func (msg *kvstoreTx) Reset() {} -func (msg *kvstoreTx) String() string { return "TODO" } -func (msg *kvstoreTx) ProtoMessage() {} +func (msg kvstoreTx) Reset() {} +func (msg kvstoreTx) String() string { return "TODO" } +func (msg kvstoreTx) ProtoMessage() {} -var _ sdk.Tx = &kvstoreTx{} -var _ sdk.Msg = &kvstoreTx{} -var _ middleware.GasTx = &kvstoreTx{} +var _ sdk.Tx = kvstoreTx{} +var _ sdk.Msg = kvstoreTx{} func NewTx(key, value string) kvstoreTx { bytes := fmt.Sprintf("%s=%s", key, value) @@ -46,7 +41,7 @@ func (tx kvstoreTx) Type() string { return "kvstore_tx" } -func (tx *kvstoreTx) GetMsgs() []sdk.Msg { +func (tx kvstoreTx) GetMsgs() []sdk.Msg { return []sdk.Msg{tx} } @@ -67,10 +62,6 @@ func (tx kvstoreTx) GetSigners() []sdk.AccAddress { return nil } -func (tx kvstoreTx) GetGas() uint64 { - return math.MaxUint64 -} - // takes raw transaction bytes and decodes them into an sdk.Tx. An sdk.Tx has // all the signatures and can be used to authenticate. func decodeTx(txBytes []byte) (sdk.Tx, error) { @@ -79,10 +70,10 @@ func decodeTx(txBytes []byte) (sdk.Tx, error) { split := bytes.Split(txBytes, []byte("=")) if len(split) == 1 { k := split[0] - tx = &kvstoreTx{k, k, txBytes} + tx = kvstoreTx{k, k, txBytes} } else if len(split) == 2 { k, v := split[0], split[1] - tx = &kvstoreTx{k, v, txBytes} + tx = kvstoreTx{k, v, txBytes} } else { return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "too many '='") } diff --git a/server/pruning.go b/server/pruning.go index fb2ba34e8f87..2e21579032c1 100644 --- a/server/pruning.go +++ b/server/pruning.go @@ -6,23 +6,22 @@ import ( "github.com/spf13/cast" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/store" - storetypes "github.com/cosmos/cosmos-sdk/store/types" ) // GetPruningOptionsFromFlags parses command flags and returns the correct // PruningOptions. If a pruning strategy is provided, that will be parsed and // returned, otherwise, it is assumed custom pruning options are provided. -func GetPruningOptionsFromFlags(appOpts types.AppOptions) (storetypes.PruningOptions, error) { +func GetPruningOptionsFromFlags(appOpts types.AppOptions) (pruningtypes.PruningOptions, error) { strategy := strings.ToLower(cast.ToString(appOpts.Get(FlagPruning))) switch strategy { - case storetypes.PruningOptionDefault, storetypes.PruningOptionNothing, storetypes.PruningOptionEverything: - return storetypes.NewPruningOptionsFromString(strategy), nil + case pruningtypes.PruningOptionDefault, pruningtypes.PruningOptionNothing, pruningtypes.PruningOptionEverything: + return pruningtypes.NewPruningOptionsFromString(strategy), nil - case storetypes.PruningOptionCustom: - opts := storetypes.NewPruningOptions( + case pruningtypes.PruningOptionCustom: + opts := pruningtypes.NewCustomPruningOptions( cast.ToUint64(appOpts.Get(FlagPruningKeepRecent)), cast.ToUint64(appOpts.Get(FlagPruningInterval)), ) @@ -34,6 +33,6 @@ func GetPruningOptionsFromFlags(appOpts types.AppOptions) (storetypes.PruningOpt return opts, nil default: - return store.PruningOptions{}, fmt.Errorf("unknown pruning strategy %s", strategy) + return pruningtypes.PruningOptions{}, fmt.Errorf("unknown pruning strategy %s", strategy) } } diff --git a/server/pruning_test.go b/server/pruning_test.go index 8b4af74cad8b..2d7bc976d92e 100644 --- a/server/pruning_test.go +++ b/server/pruning_test.go @@ -6,48 +6,45 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" - "github.com/cosmos/cosmos-sdk/store/types" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" ) func TestGetPruningOptionsFromFlags(t *testing.T) { tests := []struct { name string initParams func() *viper.Viper - expectedOptions types.PruningOptions + expectedOptions pruningtypes.PruningOptions wantErr bool }{ { name: FlagPruning, initParams: func() *viper.Viper { v := viper.New() - v.Set(FlagPruning, types.PruningOptionNothing) + v.Set(FlagPruning, pruningtypes.PruningOptionNothing) return v }, - expectedOptions: types.PruneNothing, + expectedOptions: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), }, { name: "custom pruning options", initParams: func() *viper.Viper { v := viper.New() - v.Set(FlagPruning, types.PruningOptionCustom) + v.Set(FlagPruning, pruningtypes.PruningOptionCustom) v.Set(FlagPruningKeepRecent, 1234) v.Set(FlagPruningInterval, 10) return v }, - expectedOptions: types.PruningOptions{ - KeepRecent: 1234, - Interval: 10, - }, + expectedOptions: pruningtypes.NewCustomPruningOptions(1234, 10), }, { - name: types.PruningOptionDefault, + name: pruningtypes.PruningOptionDefault, initParams: func() *viper.Viper { v := viper.New() - v.Set(FlagPruning, types.PruningOptionDefault) + v.Set(FlagPruning, pruningtypes.PruningOptionDefault) return v }, - expectedOptions: types.PruneDefault, + expectedOptions: pruningtypes.NewPruningOptions(pruningtypes.PruningDefault), }, } @@ -56,7 +53,7 @@ func TestGetPruningOptionsFromFlags(t *testing.T) { t.Run(tt.name, func(j *testing.T) { viper.Reset() - viper.SetDefault(FlagPruning, types.PruningOptionDefault) + viper.SetDefault(FlagPruning, pruningtypes.PruningOptionDefault) v := tt.initParams() opts, err := GetPruningOptionsFromFlags(v) diff --git a/server/rollback.go b/server/rollback.go index 01df238552e5..a0e772b2cf2f 100644 --- a/server/rollback.go +++ b/server/rollback.go @@ -17,7 +17,7 @@ func NewRollbackCmd(defaultNodeHome string) *cobra.Command { 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 +The application also rolls 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. `, diff --git a/server/rosetta/client_online.go b/server/rosetta/client_online.go index dc46e187e8cc..9fc033b460ff 100644 --- a/server/rosetta/client_online.go +++ b/server/rosetta/client_online.go @@ -11,27 +11,32 @@ import ( "strconv" "time" - rosettatypes "github.com/coinbase/rosetta-sdk-go/types" + "github.com/cosmos/cosmos-sdk/version" + abcitypes "github.com/tendermint/tendermint/abci/types" - tmrpc "github.com/tendermint/tendermint/rpc/client" + + rosettatypes "github.com/coinbase/rosetta-sdk-go/types" + "google.golang.org/grpc/metadata" + "github.com/tendermint/tendermint/rpc/client/http" "google.golang.org/grpc" - "google.golang.org/grpc/metadata" crgerrs "github.com/cosmos/cosmos-sdk/server/rosetta/lib/errors" crgtypes "github.com/cosmos/cosmos-sdk/server/rosetta/lib/types" + sdk "github.com/cosmos/cosmos-sdk/types" grpctypes "github.com/cosmos/cosmos-sdk/types/grpc" - "github.com/cosmos/cosmos-sdk/version" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" auth "github.com/cosmos/cosmos-sdk/x/auth/types" bank "github.com/cosmos/cosmos-sdk/x/bank/types" + + tmrpc "github.com/tendermint/tendermint/rpc/client" ) // interface assertion var _ crgtypes.Client = (*Client)(nil) -const defaultNodeTimeout = 15 * time.Second +const defaultNodeTimeout = time.Minute // Client implements a single network client to interact with cosmos based chains type Client struct { @@ -121,6 +126,14 @@ func (c *Client) Ready() error { if err != nil { return err } + + // to prevent timeout of reading genesis block + var height int64 = -1 + _, err = c.BlockByHeight(ctx, &height) + if err != nil { + return err + } + _, err = c.bank.TotalSupply(ctx, &bank.QueryTotalSupplyRequest{}) if err != nil { return err @@ -395,6 +408,27 @@ func (c *Client) ConstructionMetadataFromOptions(ctx context.Context, options ma return nil, err } + // if default fees suggestion is enabled and gas limit or price is unset, use default + if c.config.EnableFeeSuggestion { + if constructionOptions.GasLimit <= 0 { + constructionOptions.GasLimit = uint64(c.config.GasToSuggest) + } + if constructionOptions.GasPrice == "" { + denom := c.config.DenomToSuggest + constructionOptions.GasPrice = c.config.GasPrices.AmountOf(denom).String() + denom + } + } + + if constructionOptions.GasLimit > 0 && constructionOptions.GasPrice != "" { + gasPrice, err := sdk.ParseDecCoin(constructionOptions.GasPrice) + if err != nil { + return nil, err + } + if !gasPrice.IsPositive() { + return nil, crgerrs.WrapError(crgerrs.ErrBadArgument, "gas price must be positive") + } + } + signersData := make([]*SignerData, len(constructionOptions.ExpectedSigners)) for i, signer := range constructionOptions.ExpectedSigners { diff --git a/server/rosetta/config.go b/server/rosetta/config.go index dac86e25de93..a6492cd1f193 100644 --- a/server/rosetta/config.go +++ b/server/rosetta/config.go @@ -10,8 +10,10 @@ import ( crg "github.com/cosmos/cosmos-sdk/server/rosetta/lib/server" + clientflags "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) // configuration defaults constants @@ -30,17 +32,27 @@ const ( DefaultNetwork = "network" // DefaultOffline defines the default offline value DefaultOffline = false + // DefaultEnableFeeSuggestion indicates to use fee suggestion if `construction/metadata` is called without gas limit and price + DefaultEnableFeeSuggestion = false + // DenomToSuggest defines the default denom for fee suggestion + DenomToSuggest = "uatom" + // DefaultPrices defines the default list of prices to suggest + DefaultPrices = "1uatom,1stake" ) // configuration flags const ( - FlagBlockchain = "blockchain" - FlagNetwork = "network" - FlagTendermintEndpoint = "tendermint" - FlagGRPCEndpoint = "grpc" - FlagAddr = "addr" - FlagRetries = "retries" - FlagOffline = "offline" + FlagBlockchain = "blockchain" + FlagNetwork = "network" + FlagTendermintEndpoint = "tendermint" + FlagGRPCEndpoint = "grpc" + FlagAddr = "addr" + FlagRetries = "retries" + FlagOffline = "offline" + FlagEnableFeeSuggestion = "enable-fee-suggestion" + FlagGasToSuggest = "gas-to-suggest" + FlagDenomToSuggest = "denom-to-suggest" + FlagPricesToSuggest = "prices-to-suggest" ) // Config defines the configuration of the rosetta server @@ -65,6 +77,14 @@ type Config struct { Retries int // Offline defines if the server must be run in offline mode Offline bool + // EnableFeeSuggestion indicates to use fee suggestion when `construction/metadata` is called without gas limit and price + EnableFeeSuggestion bool + // GasToSuggest defines the gas limit for fee suggestion + GasToSuggest int + // DenomToSuggest defines the default denom for fee suggestion + DenomToSuggest string + // GasPrices defines the gas prices for fee suggestion + GasPrices sdk.DecCoins // Codec overrides the default data and construction api client codecs Codec *codec.ProtoCodec // InterfaceRegistry overrides the default data and construction api interface registry @@ -99,8 +119,20 @@ func (c *Config) validate() error { if c.Network == "" { return fmt.Errorf("network not provided") } - if c.Offline { - return fmt.Errorf("offline mode is not supported for stargate implementation due to how sigv2 works") + if c.GasToSuggest <= 0 { + return fmt.Errorf("gas to suggest must be positive") + } + if c.EnableFeeSuggestion { + found := false + for i := 0; i < c.GasPrices.Len(); i++ { + if c.GasPrices.GetDenomByIndex(i) == c.DenomToSuggest { + found = true + break + } + } + if !found { + return fmt.Errorf("default suggest denom is not found in prices to suggest") + } } // these are optional but it must be online @@ -153,14 +185,43 @@ func FromFlags(flags *pflag.FlagSet) (*Config, error) { if err != nil { return nil, err } + enableDefaultFeeSuggestion, err := flags.GetBool(FlagEnableFeeSuggestion) + if err != nil { + return nil, err + } + gasToSuggest, err := flags.GetInt(FlagGasToSuggest) + if err != nil { + return nil, err + } + denomToSuggest, err := flags.GetString(FlagDenomToSuggest) + if err != nil { + return nil, err + } + + var prices sdk.DecCoins + if enableDefaultFeeSuggestion { + pricesToSuggest, err := flags.GetString(FlagPricesToSuggest) + if err != nil { + return nil, err + } + prices, err = sdk.ParseDecCoins(pricesToSuggest) + if err != nil { + return nil, err + } + } + conf := &Config{ - Blockchain: blockchain, - Network: network, - TendermintRPC: tendermintRPC, - GRPCEndpoint: gRPCEndpoint, - Addr: addr, - Retries: retries, - Offline: offline, + Blockchain: blockchain, + Network: network, + TendermintRPC: tendermintRPC, + GRPCEndpoint: gRPCEndpoint, + Addr: addr, + Retries: retries, + Offline: offline, + EnableFeeSuggestion: enableDefaultFeeSuggestion, + GasToSuggest: gasToSuggest, + DenomToSuggest: denomToSuggest, + GasPrices: prices, } err = conf.validate() if err != nil { @@ -201,4 +262,8 @@ func SetFlags(flags *pflag.FlagSet) { flags.String(FlagAddr, DefaultAddr, "the address rosetta will bind to") flags.Int(FlagRetries, DefaultRetries, "the number of retries that will be done before quitting") flags.Bool(FlagOffline, DefaultOffline, "run rosetta only with construction API") + flags.Bool(FlagEnableFeeSuggestion, DefaultEnableFeeSuggestion, "enable default fee suggestion") + flags.Int(FlagGasToSuggest, clientflags.DefaultGasLimit, "default gas for fee suggestion") + flags.String(FlagDenomToSuggest, DenomToSuggest, "default denom for fee suggestion") + flags.String(FlagPricesToSuggest, DefaultPrices, "default prices for fee suggestion") } diff --git a/server/rosetta/converter.go b/server/rosetta/converter.go index 6782073aaff6..54c154579861 100644 --- a/server/rosetta/converter.go +++ b/server/rosetta/converter.go @@ -206,7 +206,6 @@ func (c converter) UnsignedTx(ops []*rosettatypes.Operation) (tx authsigning.Tx, } return builder.GetTx(), nil - } // Msg unmarshals the rosetta metadata to the given sdk.Msg @@ -297,7 +296,7 @@ func (c converter) Tx(rawTx tmtypes.Tx, txResult *abci.ResponseDeliverTx) (*rose var balanceOps []*rosettatypes.Operation // tx result might be nil, in case we're querying an unconfirmed tx from the mempool if txResult != nil { - balanceOps = c.BalanceOps(status, txResult.Events) + balanceOps = c.BalanceOps(StatusTxSuccess, txResult.Events) // force set to success because no events for failed tx } // now normalize indexes @@ -328,7 +327,6 @@ func (c converter) BalanceOps(status string, events []abci.Event) []*rosettatype // has changed and rosetta needs to reflect those changes too. // The balance operations are multiple, one for each denom. func sdkEventToBalanceOperations(status string, event abci.Event) (operations []*rosettatypes.Operation, isBalanceEvent bool) { - var ( accountIdentifier string coinChange sdk.Coins @@ -510,7 +508,7 @@ func (c converter) HashToTxType(hashBytes []byte) (txType TransactionType, realH // StatusToSyncStatus converts a tendermint status to rosetta sync status func (c converter) SyncStatus(status *tmcoretypes.ResultStatus) *rosettatypes.SyncStatus { // determine sync status - var stage = StatusPeerSynced + stage := StatusPeerSynced if status.SyncInfo.CatchingUp { stage = StatusPeerSyncing } @@ -578,7 +576,6 @@ func (c converter) Peers(peers []tmcoretypes.Peer) []*rosettatypes.Peer { // OpsAndSigners takes transactions bytes and returns the operation, is signed is true it will return // the account identifiers which have signed the transaction func (c converter) OpsAndSigners(txBytes []byte) (ops []*rosettatypes.Operation, signers []*rosettatypes.AccountIdentifier, err error) { - rosTx, err := c.ToRosetta().Tx(txBytes, nil) if err != nil { return nil, nil, err @@ -672,7 +669,6 @@ func (c converter) PubKey(pubKey *rosettatypes.PublicKey) (cryptotypes.PubKey, e // SigningComponents takes a sdk tx and construction metadata and returns signable components func (c converter) SigningComponents(tx authsigning.Tx, metadata *ConstructionMetadata, rosPubKeys []*rosettatypes.PublicKey) (txBytes []byte, payloadsToSign []*rosettatypes.SigningPayload, err error) { - // verify metadata correctness feeAmount, err := sdk.ParseCoinsNormalized(metadata.GasPrice) if err != nil { diff --git a/server/rosetta/converter_test.go b/server/rosetta/converter_test.go index 1177d33405df..4fecf99dc51b 100644 --- a/server/rosetta/converter_test.go +++ b/server/rosetta/converter_test.go @@ -92,7 +92,6 @@ func (s *ConverterTestSuite) TestFromRosettaOpsToTxSuccess() { s.Require().Equal(getMsgs[0], msg1) s.Require().Equal(getMsgs[1], msg2) - } func (s *ConverterTestSuite) TestFromRosettaOpsToTxErrors() { @@ -114,9 +113,7 @@ func (s *ConverterTestSuite) TestFromRosettaOpsToTxErrors() { _, err := s.c.ToSDK().UnsignedTx([]*rosettatypes.Operation{op}) s.Require().ErrorIs(err, crgerrs.ErrBadArgument) - }) - } func (s *ConverterTestSuite) TestMsgToMetaMetaToMsg() { @@ -137,7 +134,6 @@ func (s *ConverterTestSuite) TestMsgToMetaMetaToMsg() { } func (s *ConverterTestSuite) TestSignedTx() { - s.Run("success", func() { const payloadsJSON = `[{"hex_bytes":"82ccce81a3e4a7272249f0e25c3037a316ee2acce76eb0c25db00ef6634a4d57303b2420edfdb4c9a635ad8851fe5c7a9379b7bc2baadc7d74f7e76ac97459b5","signing_payload":{"address":"cosmos147klh7th5jkjy3aajsj2rqvhtvh9mfde37wq5g","hex_bytes":"ed574d84b095250280de38bf8c254e4a1f8755e5bd300b1f6ca2671688136ecc","account_identifier":{"address":"cosmos147klh7th5jkjy3aajsj2rqvhtvh9mfde37wq5g"},"signature_type":"ecdsa"},"public_key":{"hex_bytes":"034c92046950c876f4a5cb6c7797d6eeb9ef80d67ced4d45fb62b1e859240ba9ad","curve_type":"secp256k1"},"signature_type":"ecdsa"}]` const expectedSignedTxHex = "0a8e010a8b010a1c2f636f736d6f732e62616e6b2e763162657461312e4d736753656e64126b0a2d636f736d6f733134376b6c68377468356a6b6a793361616a736a3272717668747668396d666465333777713567122d636f736d6f73316d6e7670386c786b616679346c787777617175356561653764787630647a36687767797436331a0b0a057374616b651202313612620a4e0a460a1f2f636f736d6f732e63727970746f2e736563703235366b312e5075624b657912230a21034c92046950c876f4a5cb6c7797d6eeb9ef80d67ced4d45fb62b1e859240ba9ad12040a02087f12100a0a0a057374616b651201311090a10f1a4082ccce81a3e4a7272249f0e25c3037a316ee2acce76eb0c25db00ef6634a4d57303b2420edfdb4c9a635ad8851fe5c7a9379b7bc2baadc7d74f7e76ac97459b5" @@ -291,7 +287,6 @@ func (s *ConverterTestSuite) TestSigningComponents() { }) s.Require().NoError(err) }) - } func (s *ConverterTestSuite) TestBalanceOps() { diff --git a/server/rosetta/lib/errors/errors_test.go b/server/rosetta/lib/errors/errors_test.go index 6efe446f5b2c..84be297e0ba1 100644 --- a/server/rosetta/lib/errors/errors_test.go +++ b/server/rosetta/lib/errors/errors_test.go @@ -30,7 +30,6 @@ func TestRegisterError(t *testing.T) { // add a new error on a sealed registry error = RegisterError(1024, "bytes", false, "bytes") assert.NotNil(t, error) - } func TestError_Error(t *testing.T) { @@ -58,12 +57,12 @@ func TestToRosetta(t *testing.T) { assert.NotNil(t, ToRosetta(&MyError{})) } -type MyError struct { -} +type MyError struct{} func (e *MyError) Error() string { return "" } + func (e *MyError) Is(err error) bool { return true } diff --git a/server/rosetta/lib/internal/service/construction.go b/server/rosetta/lib/internal/service/construction.go index 4be6e9461241..6f2d0f85da6e 100644 --- a/server/rosetta/lib/internal/service/construction.go +++ b/server/rosetta/lib/internal/service/construction.go @@ -4,8 +4,11 @@ import ( "context" "crypto/sha256" "encoding/hex" + "strconv" "strings" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/coinbase/rosetta-sdk-go/types" "github.com/cosmos/cosmos-sdk/server/rosetta/lib/errors" @@ -69,9 +72,43 @@ func (on OnlineNetwork) ConstructionMetadata(ctx context.Context, request *types return nil, errors.ToRosetta(err) } - return &types.ConstructionMetadataResponse{ + response := &types.ConstructionMetadataResponse{ Metadata: metadata, - }, nil + } + + if metadata["gas_price"] != nil && metadata["gas_limit"] != nil { + gasPrice, ok := metadata["gas_price"].(string) + if !ok { + return nil, errors.ToRosetta(errors.WrapError(errors.ErrBadArgument, "invalid gas_price")) + } + if gasPrice == "" { // gas_price is unset. skip fee suggestion + return response, nil + } + price, err := sdk.ParseDecCoin(gasPrice) + if err != nil { + return nil, errors.ToRosetta(err) + } + + gasLimit, ok := metadata["gas_limit"].(float64) + if !ok { + return nil, errors.ToRosetta(errors.WrapError(errors.ErrBadArgument, "invalid gas_limit")) + } + if gasLimit == 0 { // gas_limit is unset. skip fee suggestion + return response, nil + } + gas := sdk.NewIntFromUint64(uint64(gasLimit)) + + suggestedFee := types.Amount{ + Value: strconv.FormatInt(price.Amount.MulInt64(gas.Int64()).Ceil().TruncateInt64(), 10), + Currency: &(types.Currency{ + Symbol: price.Denom, + Decimals: 0, + }), + } + response.SuggestedFee = []*types.Amount{&suggestedFee} + } + + return response, nil } // ConstructionParse Parse is called on both unsigned and signed transactions to understand the @@ -92,7 +129,6 @@ func (on OnlineNetwork) ConstructionParse(ctx context.Context, request *types.Co AccountIdentifierSigners: signers, Metadata: nil, }, nil - } // ConstructionPayloads Payloads is called with an array of operations and the response from diff --git a/server/rosetta/lib/internal/service/data.go b/server/rosetta/lib/internal/service/data.go index cda420487202..c814ff4c7289 100644 --- a/server/rosetta/lib/internal/service/data.go +++ b/server/rosetta/lib/internal/service/data.go @@ -4,7 +4,6 @@ import ( "context" "github.com/coinbase/rosetta-sdk-go/types" - "github.com/cosmos/cosmos-sdk/server/rosetta/lib/errors" crgtypes "github.com/cosmos/cosmos-sdk/server/rosetta/lib/types" ) @@ -56,9 +55,14 @@ func (on OnlineNetwork) Block(ctx context.Context, request *types.BlockRequest) blockResponse crgtypes.BlockTransactionsResponse err error ) - // block identifier is assumed not to be nil as rosetta will do this check for us - // check if we have to query via hash or block number + + // When fetching data by BlockIdentifier, it may be possible to only specify the index or hash. + // If neither property is specified, it is assumed that the client is making a request at the current block. switch { + case request.BlockIdentifier == nil: // unlike AccountBalance(), BlockIdentifer is mandatory by spec 1.4.10. + err := errors.WrapError(errors.ErrBadArgument, "block identifier needs to be specified") + return nil, errors.ToRosetta(err) + case request.BlockIdentifier.Hash != nil: blockResponse, err = on.client.BlockTransactionsByHash(ctx, *request.BlockIdentifier.Hash) if err != nil { @@ -69,8 +73,23 @@ func (on OnlineNetwork) Block(ctx context.Context, request *types.BlockRequest) if err != nil { return nil, errors.ToRosetta(err) } + default: - err := errors.WrapError(errors.ErrBadArgument, "at least one of hash or index needs to be specified") + // both empty + blockResponse, err = on.client.BlockTransactionsByHeight(ctx, nil) + if err != nil { + return nil, errors.ToRosetta(err) + } + } + + // Both of index and hash can be specified in reuqest, so make sure they are not mismatching. + if request.BlockIdentifier.Index != nil && *request.BlockIdentifier.Index != blockResponse.Block.Index { + err := errors.WrapError(errors.ErrBadArgument, "mismatching index") + return nil, errors.ToRosetta(err) + } + + if request.BlockIdentifier.Hash != nil && *request.BlockIdentifier.Hash != blockResponse.Block.Hash { + err := errors.WrapError(errors.ErrBadArgument, "mismatching hash") return nil, errors.ToRosetta(err) } diff --git a/server/rosetta/lib/server/server.go b/server/rosetta/lib/server/server.go index 1d82ce8a6ff5..238583103ae6 100644 --- a/server/rosetta/lib/server/server.go +++ b/server/rosetta/lib/server/server.go @@ -13,8 +13,10 @@ import ( crgtypes "github.com/cosmos/cosmos-sdk/server/rosetta/lib/types" ) -const DefaultRetries = 5 -const DefaultRetryWait = 5 * time.Second +const ( + DefaultRetries = 5 + DefaultRetryWait = 5 * time.Second +) // Settings define the rosetta server settings type Settings struct { @@ -55,9 +57,7 @@ func NewServer(settings Settings) (Server, error) { return Server{}, fmt.Errorf("cannot build asserter: %w", err) } - var ( - adapter crgtypes.API - ) + var adapter crgtypes.API switch settings.Offline { case true: adapter, err = newOfflineAdapter(settings) diff --git a/server/start.go b/server/start.go index f93ace066dd1..9c76dbdffa06 100644 --- a/server/start.go +++ b/server/start.go @@ -25,13 +25,14 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/server/api" - "github.com/cosmos/cosmos-sdk/server/config" + serverconfig "github.com/cosmos/cosmos-sdk/server/config" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" "github.com/cosmos/cosmos-sdk/server/rosetta" 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" + sdktypes "github.com/cosmos/cosmos-sdk/types" ) const ( @@ -86,15 +87,15 @@ func StartCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Comman Long: `Run the full node application with Tendermint in or out of process. By default, the application will run with Tendermint in process. -Pruning options can be provided via the '--pruning' flag or alternatively with '--pruning-keep-recent' -and 'pruning-interval' together. +Pruning options can be provided via the '--pruning' flag or alternatively with '--pruning-keep-recent', and +'pruning-interval' together. For '--pruning' the options are as follows: default: the last 362880 states are kept, pruning at 10 block intervals nothing: all historic states will be saved, nothing will be deleted (i.e. archiving node) -everything: all saved states will be deleted, storing only the current and previous state; pruning at 10 block intervals -custom: allow pruning options to be manually specified through 'pruning-keep-recent' and 'pruning-interval' +everything: 2 latest states will be kept; pruning at 10 block intervals. +custom: allow pruning options to be manually specified through 'pruning-keep-recent', and 'pruning-interval' Node halting configurations exist in the form of two flags: '--halt-height' and '--halt-time'. During the ABCI Commit phase, the node will check if the current block height is greater than or equal to @@ -115,7 +116,9 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. // Bind flags to the Context's Viper so the app construction can set // options accordingly. - serverCtx.Viper.BindPFlags(cmd.Flags()) + if err := serverCtx.Viper.BindPFlags(cmd.Flags()); err != nil { + return err + } _, err := GetPruningOptionsFromFlags(serverCtx.Viper) return err @@ -157,15 +160,15 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. cmd.Flags().Bool(FlagInterBlockCache, true, "Enable inter-block caching") cmd.Flags().String(flagCPUProfile, "", "Enable CPU profiling and write to the provided file") cmd.Flags().Bool(FlagTrace, false, "Provide full stack traces for errors in ABCI Log") - cmd.Flags().String(FlagPruning, storetypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)") + cmd.Flags().String(FlagPruning, pruningtypes.PruningOptionDefault, "Pruning strategy (default|nothing|everything|custom)") cmd.Flags().Uint64(FlagPruningKeepRecent, 0, "Number of recent heights to keep on disk (ignored if pruning is not 'custom')") cmd.Flags().Uint64(FlagPruningInterval, 0, "Height interval at which pruned heights are removed from disk (ignored if pruning is not 'custom')") 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(FlagAPIEnable, false, "Define if the API server should be enabled") - cmd.Flags().Bool(FlagAPISwagger, false, "Define if swagger documentation should automatically be registered (Note: api must also be enabled.)") - cmd.Flags().String(FlagAPIAddress, config.DefaultAPIAddress, "the API server address to listen on") + cmd.Flags().Bool(FlagAPISwagger, false, "Define if swagger documentation should automatically be registered (Note: the API must also be enabled)") + cmd.Flags().String(FlagAPIAddress, serverconfig.DefaultAPIAddress, "the API server address to listen on") cmd.Flags().Uint(FlagAPIMaxOpenConnections, 1000, "Define the number of maximum open connections") cmd.Flags().Uint(FlagRPCReadTimeout, 10, "Define the Tendermint RPC read timeout (in seconds)") cmd.Flags().Uint(FlagRPCWriteTimeout, 0, "Define the Tendermint RPC write timeout (in seconds)") @@ -174,10 +177,10 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. 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") + cmd.Flags().String(flagGRPCAddress, serverconfig.DefaultGRPCAddress, "the gRPC server address to listen on") - cmd.Flags().Bool(flagGRPCWebEnable, true, "Define if the gRPC-Web server should be enabled. (Note: gRPC must also be enabled.)") - cmd.Flags().String(flagGRPCWebAddress, config.DefaultGRPCWebAddress, "The gRPC-Web server address to listen on") + cmd.Flags().Bool(flagGRPCWebEnable, true, "Define if the gRPC-Web server should be enabled. (Note: gRPC must also be enabled)") + cmd.Flags().String(flagGRPCWebAddress, serverconfig.DefaultGRPCWebAddress, "The gRPC-Web server address to listen on") cmd.Flags().Uint64(FlagStateSyncSnapshotInterval, 0, "State sync snapshot interval") cmd.Flags().Uint32(FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep") @@ -246,7 +249,9 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App cpuProfileCleanup = func() { ctx.Logger.Info("stopping CPU profiler", "profile", cpuProfile) pprof.StopCPUProfile() - f.Close() + if err := f.Close(); err != nil { + ctx.Logger.Info("failed to close cpu-profile file", "profile", cpuProfile, "err", err.Error()) + } } } @@ -261,7 +266,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App return err } - config := config.GetConfig(ctx.Viper) + config := serverconfig.GetConfig(ctx.Viper) if err := config.ValidateBasic(); err != nil { return err } @@ -328,13 +333,27 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App return err } + maxSendMsgSize := config.GRPC.MaxSendMsgSize + if maxSendMsgSize == 0 { + maxSendMsgSize = serverconfig.DefaultGRPCMaxSendMsgSize + } + + maxRecvMsgSize := config.GRPC.MaxRecvMsgSize + if maxRecvMsgSize == 0 { + maxRecvMsgSize = serverconfig.DefaultGRPCMaxRecvMsgSize + } + grpcAddress := fmt.Sprintf("127.0.0.1:%s", port) // If grpc is enabled, configure grpc client for grpc gateway. grpcClient, err := grpc.Dial( grpcAddress, grpc.WithTransportCredentials(insecure.NewCredentials()), - grpc.WithDefaultCallOptions(grpc.ForceCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec())), + grpc.WithDefaultCallOptions( + grpc.ForceCodec(codec.NewProtoCodec(clientCtx.InterfaceRegistry).GRPCCodec()), + grpc.MaxCallRecvMsgSize(maxRecvMsgSize), + grpc.MaxCallSendMsgSize(maxSendMsgSize), + ), ) if err != nil { return err @@ -368,7 +387,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App ) if config.GRPC.Enable { - grpcSrv, err = servergrpc.StartGRPCServer(clientCtx, app, config.GRPC.Address) + grpcSrv, err = servergrpc.StartGRPCServer(clientCtx, app, config.GRPC) if err != nil { return err } @@ -399,16 +418,25 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App offlineMode = true } + minGasPrices, err := sdktypes.ParseDecCoins(config.MinGasPrices) + if err != nil { + ctx.Logger.Error("failed to parse minimum-gas-prices: ", err) + return err + } + 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, - Codec: clientCtx.Codec.(*codec.ProtoCodec), - InterfaceRegistry: clientCtx.InterfaceRegistry, + 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, + GasToSuggest: config.Rosetta.GasToSuggest, + EnableFeeSuggestion: config.Rosetta.EnableFeeSuggestion, + GasPrices: minGasPrices.Sort(), + Codec: clientCtx.Codec.(*codec.ProtoCodec), + InterfaceRegistry: clientCtx.InterfaceRegistry, } rosettaSrv, err = rosetta.ServerFromConfig(conf) @@ -447,7 +475,9 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App if grpcSrv != nil { grpcSrv.Stop() if grpcWebSrv != nil { - grpcWebSrv.Close() + if err := grpcWebSrv.Close(); err != nil { + ctx.Logger.Error("failed to close grpc-web http server: ", err) + } } } diff --git a/server/tm_cmds.go b/server/tm_cmds.go index 1f9840c10356..0f243e5a8f32 100644 --- a/server/tm_cmds.go +++ b/server/tm_cmds.go @@ -6,7 +6,6 @@ import ( "fmt" "github.com/spf13/cobra" - tmcmd "github.com/tendermint/tendermint/cmd/tendermint/commands" pvm "github.com/tendermint/tendermint/privval" tversion "github.com/tendermint/tendermint/version" "sigs.k8s.io/yaml" @@ -124,23 +123,3 @@ func VersionCmd() *cobra.Command { }, } } - -// 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 - - return tmcmd.ResetAll( - cfg.DBDir(), - cfg.P2P.AddrBookFile(), - cfg.PrivValidator.KeyFile(), - cfg.PrivValidator.StateFile(), - serverCtx.Logger, - ) - }, - } -} diff --git a/server/util.go b/server/util.go index 78c92cb5e8db..44823b28bb6c 100644 --- a/server/util.go +++ b/server/util.go @@ -68,7 +68,9 @@ func NewContext(v *viper.Viper, config *tmcfg.Config, logger tmlog.Logger) *Cont func bindFlags(basename string, cmd *cobra.Command, v *viper.Viper) (err error) { defer func() { - recover() + if r := recover(); r != nil { + err = fmt.Errorf("bindFlags failed: %v", r) + } }() cmd.Flags().VisitAll(func(f *pflag.Flag) { @@ -121,8 +123,12 @@ func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate s basename := path.Base(executableName) // Configure the viper instance - serverCtx.Viper.BindPFlags(cmd.Flags()) - serverCtx.Viper.BindPFlags(cmd.PersistentFlags()) + if err := serverCtx.Viper.BindPFlags(cmd.Flags()); err != nil { + return err + } + if err := serverCtx.Viper.BindPFlags(cmd.PersistentFlags()); err != nil { + return err + } serverCtx.Viper.SetEnvPrefix(basename) serverCtx.Viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_", "-", "_")) serverCtx.Viper.AutomaticEnv() @@ -198,14 +204,16 @@ func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customCo tmcfg.EnsureRoot(rootDir) if err = conf.ValidateBasic(); err != nil { - return nil, fmt.Errorf("error in config file: %v", err) + return nil, fmt.Errorf("error in config file: %w", err) } conf.RPC.PprofListenAddress = "localhost:6060" conf.P2P.RecvRate = 5120000 conf.P2P.SendRate = 5120000 conf.Consensus.TimeoutCommit = 5 * time.Second - tmcfg.WriteConfigFile(rootDir, conf) + if err := tmcfg.WriteConfigFile(rootDir, conf); err != nil { + return nil, fmt.Errorf("error writing config file: %w", err) + } case err != nil: return nil, err @@ -272,6 +280,8 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type ShowValidatorCmd(), ShowAddressCmd(), VersionCmd(), + tmcmd.ResetAllCmd, + tmcmd.ResetStateCmd, tmcmd.InspectCmd, ) @@ -280,7 +290,6 @@ func AddCommands(rootCmd *cobra.Command, defaultNodeHome string, appCreator type rootCmd.AddCommand( startCmd, - UnsafeResetAllCmd(), tendermintCmd, ExportCmd(appExport, defaultNodeHome), version.NewVersionCommand(), @@ -403,6 +412,6 @@ func openTraceWriter(traceWriterFile string) (w io.Writer, err error) { return os.OpenFile( traceWriterFile, os.O_WRONLY|os.O_APPEND|os.O_CREATE, - 0666, + 0o666, ) } diff --git a/server/util_test.go b/server/util_test.go index 7c1e8cb152ff..30a7e802ff63 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -218,9 +218,9 @@ func TestInterceptConfigsPreRunHandlerReadsEnvVars(t *testing.T) { basename = strings.ReplaceAll(basename, ".", "_") // This is added by tendermint envVarName := fmt.Sprintf("%s_RPC_LADDR", strings.ToUpper(basename)) - os.Setenv(envVarName, testAddr) + require.NoError(t, os.Setenv(envVarName, testAddr)) t.Cleanup(func() { - os.Unsetenv(envVarName) + require.NoError(t, os.Unsetenv(envVarName)) }) cmd.PreRunE = preRunETestImpl @@ -305,7 +305,7 @@ func (v precedenceCommon) setAll(t *testing.T, setFlag *string, setEnvVar *strin } if setEnvVar != nil { - os.Setenv(v.envVarName, *setEnvVar) + require.NoError(t, os.Setenv(v.envVarName, *setEnvVar)) } if setConfigFile != nil { @@ -395,7 +395,7 @@ func TestInterceptConfigsPreRunHandlerPrecedenceConfigDefault(t *testing.T) { func TestInterceptConfigsWithBadPermissions(t *testing.T) { tempDir := t.TempDir() subDir := filepath.Join(tempDir, "nonPerms") - if err := os.Mkdir(subDir, 0600); err != nil { + if err := os.Mkdir(subDir, 0o600); err != nil { t.Fatalf("Failed to create sub directory: %v", err) } cmd := server.StartCmd(nil, "/foobar") diff --git a/simapp/README.md b/simapp/README.md index 4179392c9a0d..cf271661b29b 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/simapp/app.go b/simapp/app.go index 99e885353fc7..2af2dae79b39 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -8,8 +8,6 @@ import ( "os" "path/filepath" - "github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar" - "github.com/gorilla/mux" "github.com/rakyll/statik/fs" "github.com/spf13/cast" @@ -31,12 +29,14 @@ import ( "github.com/cosmos/cosmos-sdk/store/streaming" storetypes "github.com/cosmos/cosmos-sdk/store/v2alpha1" "github.com/cosmos/cosmos-sdk/store/v2alpha1/multi" + "github.com/cosmos/cosmos-sdk/testutil/testdata_pulsar" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" + "github.com/cosmos/cosmos-sdk/x/auth/ante" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware" + "github.com/cosmos/cosmos-sdk/x/auth/posthandler" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -158,8 +158,6 @@ type SimApp struct { legacyAmino *codec.LegacyAmino appCodec codec.Codec interfaceRegistry types.InterfaceRegistry - msgSvcRouter *authmiddleware.MsgServiceRouter - legacyRouter sdk.Router invCheckPeriod uint @@ -217,7 +215,6 @@ func NewSimApp( encodingConfig simappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...baseapp.AppOption, ) *SimApp { - appCodec := encodingConfig.Codec legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -266,7 +263,13 @@ func NewSimApp( } baseAppOptions = append(baseAppOptions, baseapp.StoreOption(setNamespaces)) - bApp := baseapp.NewBaseApp(appName, logger, db, baseAppOptions...) + // set the governance module account as the authority for conducting upgrades + upgradeKeeper := upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, nil, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + if upgradeOpt := GetUpgradeStoreOption(upgradeKeeper); upgradeOpt != nil { + baseAppOptions = append(baseAppOptions, upgradeOpt) + } + + bApp := baseapp.NewBaseApp(appName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) bApp.SetVersion(version.Version) bApp.SetInterfaceRegistry(interfaceRegistry) @@ -282,8 +285,6 @@ func NewSimApp( legacyAmino: legacyAmino, appCodec: appCodec, interfaceRegistry: interfaceRegistry, - legacyRouter: authmiddleware.NewLegacyRouter(), - msgSvcRouter: authmiddleware.NewMsgServiceRouter(interfaceRegistry), invCheckPeriod: invCheckPeriod, keys: keys, tkeys: tkeys, @@ -333,14 +334,14 @@ func NewSimApp( stakingtypes.NewMultiStakingHooks(app.DistrKeeper.Hooks(), app.SlashingKeeper.Hooks()), ) - app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.msgSvcRouter, app.AccountKeeper) + app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper) groupConfig := group.DefaultConfig() /* Example of setting group params: groupConfig.MaxMetadataLen = 1000 */ - app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.msgSvcRouter, app.AccountKeeper, groupConfig) + app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper, groupConfig) // register the proposal types govRouter := govv1beta1.NewRouter() @@ -355,7 +356,7 @@ func NewSimApp( */ govKeeper := govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, govRouter, app.msgSvcRouter, govConfig, + &stakingKeeper, govRouter, app.MsgServiceRouter(), govConfig, ) app.GovKeeper = *govKeeper.SetHooks( @@ -363,8 +364,12 @@ func NewSimApp( // register the governance hooks ), ) - // set the governance module account as the authority for conducting upgrades - app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + + upgradeKeeper.SetVersionSetter(app.BaseApp) + app.UpgradeKeeper = upgradeKeeper + // RegisterUpgradeHandlers is used for registering any on-chain upgrades + app.RegisterUpgradeHandlers() + app.NFTKeeper = nftkeeper.NewKeeper(keys[nftkeeper.StoreKey], appCodec, app.AccountKeeper, app.BankKeeper) // create evidence keeper with router @@ -378,7 +383,7 @@ func NewSimApp( // NOTE: we may consider parsing `appOpts` inside module constructors. For the moment // we prefer to be more strict in what arguments the modules expect. - var skipGenesisInvariants = cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) + skipGenesisInvariants := cast.ToBool(appOpts.Get(crisis.FlagSkipGenesisInvariants)) // NOTE: Any module instantiated in the module manager that is later modified // must be passed by reference here. @@ -445,8 +450,8 @@ func NewSimApp( // app.mm.SetOrderMigrations(custom order) app.mm.RegisterInvariants(&app.CrisisKeeper) - app.mm.RegisterRoutes(app.legacyRouter, app.QueryRouter(), encodingConfig.Amino) - app.configurator = module.NewConfigurator(app.appCodec, app.msgSvcRouter, app.GRPCQueryRouter()) + app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) + app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) app.mm.RegisterServices(app.configurator) // add test gRPC service for testing gRPC queries in isolation @@ -479,33 +484,63 @@ func NewSimApp( app.SetInitChainer(app.InitChainer) app.SetBeginBlocker(app.BeginBlocker) app.SetEndBlocker(app.EndBlocker) - app.setTxHandler(encodingConfig.TxConfig, cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))) + app.setAnteHandler(encodingConfig.TxConfig, cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))) + // In v0.46, the SDK introduces _postHandlers_. PostHandlers are like + // antehandlers, but are run _after_ the `runMsgs` execution. They are also + // defined as a chain, and have the same signature as antehandlers. + // + // In baseapp, postHandlers are run in the same store branch as `runMsgs`, + // meaning that both `runMsgs` and `postHandler` state will be committed if + // both are successful, and both will be reverted if any of the two fails. + // + // The SDK exposes a default postHandlers chain, which comprises of only + // one decorator: the Transaction Tips decorator. However, some chains do + // not need it by default, so feel free to comment the next line if you do + // not need tips. + // To read more about tips: + // https://docs.cosmos.network/main/core/tips.html + // + // Please note that changing any of the anteHandler or postHandler chain is + // likely to be a state-machine breaking change, which needs a coordinated + // upgrade. + app.setPostHandler() return app } -func (app *SimApp) setTxHandler(txConfig client.TxConfig, indexEventsStr []string) { +func (app *SimApp) setAnteHandler(txConfig client.TxConfig, indexEventsStr []string) { indexEvents := map[string]struct{}{} for _, e := range indexEventsStr { indexEvents[e] = struct{}{} } - txHandler, err := authmiddleware.NewDefaultTxHandler(authmiddleware.TxHandlerOptions{ - Debug: app.Trace(), - IndexEvents: indexEvents, - LegacyRouter: app.legacyRouter, - MsgServiceRouter: app.msgSvcRouter, - AccountKeeper: app.AccountKeeper, - BankKeeper: app.BankKeeper, - FeegrantKeeper: app.FeeGrantKeeper, - SignModeHandler: txConfig.SignModeHandler(), - SigGasConsumer: authmiddleware.DefaultSigVerificationGasConsumer, - TxDecoder: txConfig.TxDecoder(), - }) + anteHandler, err := ante.NewAnteHandler( + ante.HandlerOptions{ + AccountKeeper: app.AccountKeeper, + BankKeeper: app.BankKeeper, + SignModeHandler: txConfig.SignModeHandler(), + FeegrantKeeper: app.FeeGrantKeeper, + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + ) + if err != nil { panic(err) } - app.SetTxHandler(txHandler) + app.SetAnteHandler(anteHandler) +} + +func (app *SimApp) setPostHandler() { + postHandler, err := posthandler.NewPostHandler( + posthandler.HandlerOptions{ + BankKeeper: app.BankKeeper, + }, + ) + if err != nil { + panic(err) + } + + app.SetPostHandler(postHandler) } // Name returns the name of the App @@ -611,8 +646,7 @@ func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICon // Register new tendermint queries routes from grpc-gateway. tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - // Register legacy and grpc-gateway routes for all modules. - ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router) + // Register grpc-gateway routes for all modules. ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // register swagger API from root so that other applications can override easily @@ -628,11 +662,16 @@ func (app *SimApp) RegisterTxService(clientCtx client.Context) { // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) + tmservice.RegisterTendermintService( + clientCtx, + app.BaseApp.GRPCQueryRouter(), + app.interfaceRegistry, + app.Query, + ) } // RegisterSwaggerAPI registers swagger route with API Server -func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) { +func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) { statikFS, err := fs.New() if err != nil { panic(err) diff --git a/simapp/app_test.go b/simapp/app_test.go index 10929e7a12e3..996f0a622692 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -16,7 +16,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" - authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware" "github.com/cosmos/cosmos-sdk/x/auth/vesting" authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module" "github.com/cosmos/cosmos-sdk/x/bank" @@ -80,12 +79,11 @@ func TestRunMigrations(t *testing.T) { app := NewSimApp(logger, memdb.NewDB(), nil, true, map[int64]bool{}, DefaultNodeHome, 0, encCfg, EmptyAppOptions{}) // Create a new baseapp and configurator for the purpose of this test. - bApp := baseapp.NewBaseApp(appName, logger, memdb.NewDB()) + bApp := baseapp.NewBaseApp(appName, logger, memdb.NewDB(), encCfg.TxConfig.TxDecoder()) bApp.SetCommitMultiStoreTracer(nil) bApp.SetInterfaceRegistry(encCfg.InterfaceRegistry) - msr := authmiddleware.NewMsgServiceRouter(encCfg.InterfaceRegistry) app.BaseApp = bApp - app.configurator = module.NewConfigurator(app.appCodec, msr, app.GRPCQueryRouter()) + app.configurator = module.NewConfigurator(app.appCodec, bApp.MsgServiceRouter(), app.GRPCQueryRouter()) // We register all modules on the Configurator, except x/bank. x/bank will // serve as the test subject on which we run the migration tests. diff --git a/simapp/export.go b/simapp/export.go index d2cf26aab86d..3c5b9799010b 100644 --- a/simapp/export.go +++ b/simapp/export.go @@ -2,6 +2,7 @@ package simapp import ( "encoding/json" + "fmt" "log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -139,8 +140,16 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] if err != nil { panic(err) } - app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) - app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) + + if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil { + // never called as BeforeDelegationCreated always returns nil + panic(fmt.Errorf("error while incrementing period: %w", err)) + } + + if err := app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr); err != nil { + // never called as AfterDelegationModified always returns nil + panic(fmt.Errorf("error while creating a new delegation period record: %w", err)) + } } // reset context height @@ -188,7 +197,10 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] counter++ } - iter.Close() + if err := iter.Close(); err != nil { + app.Logger().Error("error while closing the key-value store reverse prefix iterator: ", err) + return + } _, err := app.StakingKeeper.ApplyAndReturnValidatorSetUpdates(ctx) if err != nil { diff --git a/simapp/helpers/test_helpers.go b/simapp/helpers/test_helpers.go index f0be36ad42fe..0dc88f9b4623 100644 --- a/simapp/helpers/test_helpers.go +++ b/simapp/helpers/test_helpers.go @@ -14,12 +14,12 @@ import ( // SimAppChainID hardcoded chainID for simulation const ( - DefaultGenTxGas = 1000000 + DefaultGenTxGas = 10000000 SimAppChainID = "simulation-app" ) -// GenTx generates a signed mock transaction. -func GenTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { +// GenSignedMockTx generates a signed mock transaction. +func GenSignedMockTx(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { sigs := make([]signing.SignatureV2, len(priv)) // create a random length memo diff --git a/simapp/params/amino.go b/simapp/params/amino.go index cdf86d0ea2e0..d603987dd5f5 100644 --- a/simapp/params/amino.go +++ b/simapp/params/amino.go @@ -1,3 +1,4 @@ +//go:build test_amino // +build test_amino package params diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go index b5592051001f..788299dc11aa 100644 --- a/simapp/sim_bench_test.go +++ b/simapp/sim_bench_test.go @@ -5,6 +5,7 @@ import ( "os" "testing" + "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -25,11 +26,8 @@ func BenchmarkFullAppSimulation(b *testing.B) { } defer func() { - db.Close() - err = os.RemoveAll(dir) - if err != nil { - b.Fatal(err) - } + require.NoError(b, db.Close()) + require.NoError(b, os.RemoveAll(dir)) }() app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, MakeTestEncodingConfig(), EmptyAppOptions{}, interBlockCacheOpt()) @@ -75,11 +73,8 @@ func BenchmarkInvariants(b *testing.B) { config.AllInvariants = false defer func() { - db.Close() - err = os.RemoveAll(dir) - if err != nil { - b.Fatal(err) - } + require.NoError(b, db.Close()) + require.NoError(b, os.RemoveAll(dir)) }() app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, MakeTestEncodingConfig(), EmptyAppOptions{}, interBlockCacheOpt()) diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 39ccdd1c99f4..2f774d34dc30 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -66,7 +66,7 @@ func TestFullAppSimulation(t *testing.T) { require.NoError(t, err, "simulation setup failed") defer func() { - db.Close() + require.NoError(t, db.Close()) require.NoError(t, os.RemoveAll(dir)) }() @@ -104,7 +104,7 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, err, "simulation setup failed") defer func() { - db.Close() + require.NoError(t, db.Close()) require.NoError(t, os.RemoveAll(dir)) }() @@ -144,7 +144,7 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, err, "simulation setup failed") defer func() { - newDB.Close() + require.NoError(t, newDB.Close()) require.NoError(t, os.RemoveAll(newDir)) }() @@ -175,11 +175,13 @@ func TestAppImportExport(t *testing.T) { storeKeysPrefixes := []StoreKeysPrefixes{ {app.keys[authtypes.StoreKey], newApp.keys[authtypes.StoreKey], [][]byte{}}, - {app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], + { + app.keys[stakingtypes.StoreKey], newApp.keys[stakingtypes.StoreKey], [][]byte{ stakingtypes.UnbondingQueueKey, stakingtypes.RedelegationQueueKey, stakingtypes.ValidatorQueueKey, stakingtypes.HistoricalInfoKey, - }}, // ordering may change but it doesn't matter + }, + }, // ordering may change but it doesn't matter {app.keys[slashingtypes.StoreKey], newApp.keys[slashingtypes.StoreKey], [][]byte{}}, {app.keys[minttypes.StoreKey], newApp.keys[minttypes.StoreKey], [][]byte{}}, {app.keys[distrtypes.StoreKey], newApp.keys[distrtypes.StoreKey], [][]byte{}}, @@ -211,7 +213,7 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, err, "simulation setup failed") defer func() { - db.Close() + require.NoError(t, db.Close()) require.NoError(t, os.RemoveAll(dir)) }() @@ -256,7 +258,7 @@ func TestAppSimulationAfterImport(t *testing.T) { require.NoError(t, err, "simulation setup failed") defer func() { - newDB.Close() + require.NoError(t, newDB.Close()) require.NoError(t, os.RemoveAll(newDir)) }() diff --git a/simapp/simd/cmd/cmd_test.go b/simapp/simd/cmd/cmd_test.go index 0e2a291e9c74..ab9d8de71064 100644 --- a/simapp/simd/cmd/cmd_test.go +++ b/simapp/simd/cmd/cmd_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/client/flags" svrcmd "github.com/cosmos/cosmos-sdk/server/cmd" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/simapp/simd/cmd" @@ -22,3 +23,21 @@ func TestInitCmd(t *testing.T) { require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome)) } + +func TestHomeFlagRegistration(t *testing.T) { + homeDir := "/tmp/foo" + + rootCmd, _ := cmd.NewRootCmd() + + rootCmd.SetArgs([]string{ + "query", + fmt.Sprintf("--%s", flags.FlagHome), + homeDir, + }) + + require.NoError(t, svrcmd.Execute(rootCmd, "", simapp.DefaultNodeHome)) + + result, err := rootCmd.Flags().GetString(flags.FlagHome) + require.NoError(t, err) + require.Equal(t, result, homeDir) +} diff --git a/simapp/simd/cmd/genaccounts_test.go b/simapp/simd/cmd/genaccounts_test.go index ed6d93508567..ca751fc34f62 100644 --- a/simapp/simd/cmd/genaccounts_test.go +++ b/simapp/simd/cmd/genaccounts_test.go @@ -3,10 +3,11 @@ package cmd_test import ( "context" "fmt" + "testing" + "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" - "testing" "github.com/spf13/viper" "github.com/stretchr/testify/require" @@ -96,7 +97,8 @@ func TestAddGenesisAccountCmd(t *testing.T) { cmd.SetArgs([]string{ tc.addr, tc.denom, - fmt.Sprintf("--%s=home", flags.FlagHome)}) + fmt.Sprintf("--%s=home", flags.FlagHome), + }) if tc.expectErr { require.Error(t, cmd.ExecuteContext(ctx)) diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 1a247af3b93b..b9e0bd77c78d 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -27,6 +27,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/snapshots" + snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli" @@ -193,7 +194,7 @@ func queryCommand() *cobra.Command { Use: "query", Aliases: []string{"q"}, Short: "Querying subcommands", - DisableFlagParsing: true, + DisableFlagParsing: false, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } @@ -216,7 +217,7 @@ func txCommand() *cobra.Command { cmd := &cobra.Command{ Use: "tx", Short: "Transactions subcommands", - DisableFlagParsing: true, + DisableFlagParsing: false, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } @@ -276,6 +277,11 @@ func (a appCreator) newApp( panic(err) } + snapshotOptions := snapshottypes.NewSnapshotOptions( + cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval)), + cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent)), + ) + return simapp.NewSimApp( logger, db, traceStore, true, skipUpgradeHeights, cast.ToString(appOpts.Get(flags.FlagHome)), @@ -290,24 +296,22 @@ func (a appCreator) newApp( baseapp.SetInterBlockCache(cache), baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))), baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))), - baseapp.SetSnapshotStore(snapshotStore), - baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))), - baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))), + baseapp.SetSnapshot(snapshotStore, snapshotOptions), ) } // appExport creates a new simapp (optionally at a given height) // and exports state. func (a appCreator) appExport( - logger log.Logger, db dbm.DBConnection, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, - appOpts servertypes.AppOptions) (servertypes.ExportedApp, error) { - + logger log.Logger, db dbm.DBConnection, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts servertypes.AppOptions, +) (servertypes.ExportedApp, error) { + var simApp *simapp.SimApp homePath, ok := appOpts.Get(flags.FlagHome).(string) if !ok || homePath == "" { return servertypes.ExportedApp{}, errors.New("application home not set") } - simApp := simapp.NewSimApp(logger, db, traceStore, false, map[int64]bool{}, homePath, uint(1), a.encCfg, appOpts) + simApp = simapp.NewSimApp(logger, db, traceStore, false, map[int64]bool{}, homePath, uint(1), a.encCfg, appOpts) if height != -1 { return simApp.ExportAppStateAndValidatorsAt(forZeroHeight, jailAllowedAddrs, height) } diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index 20ded76a92e1..2b03f8a53235 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -100,7 +100,7 @@ func NewTestnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBala return testnetCmd } -// get cmd to initialize all files for tendermint testnet and application +// testnetInitFilesCmd returns a cmd to initialize all files for tendermint testnet and application func testnetInitFilesCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command { cmd := &cobra.Command{ Use: "init-files", @@ -137,7 +137,6 @@ Example: args.algo, _ = cmd.Flags().GetString(flags.FlagKeyAlgorithm) return initTestnetFiles(clientCtx, cmd, config, mbm, genBalIterator, args) - }, } @@ -150,7 +149,7 @@ Example: return cmd } -// get cmd to start multi validator in-process testnet +// testnetStartCmd returns a cmd to start multi validator in-process testnet func testnetStartCmd() *cobra.Command { cmd := &cobra.Command{ Use: "start", @@ -163,7 +162,6 @@ Example: simd testnet --v 4 --output-dir ./.testnets `, RunE: func(cmd *cobra.Command, _ []string) error { - args := startArgs{} args.outputDir, _ = cmd.Flags().GetString(flagOutputDir) args.chainID, _ = cmd.Flags().GetString(flags.FlagChainID) @@ -177,7 +175,6 @@ Example: args.printMnemonic, _ = cmd.Flags().GetBool(flagPrintMnemonic) return startTestnet(cmd, args) - }, } @@ -190,7 +187,7 @@ Example: return cmd } -const nodeDirPerm = 0755 +const nodeDirPerm = 0o755 // initTestnetFiles initializes testnet files for a testnet to be run in a separate process func initTestnetFiles( @@ -356,7 +353,6 @@ func initGenFiles( genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string, numValidators int, ) error { - appGenState := mbm.DefaultGenesis(clientCtx.Codec) // set the accounts in the genesis state @@ -406,7 +402,6 @@ func collectGenFiles( nodeIDs []string, valPubKeys []cryptotypes.PubKey, numValidators int, outputDir, nodeDirPrefix, nodeDaemonHome string, genBalIterator banktypes.GenesisBalancesIterator, ) error { - var appState json.RawMessage genTime := tmtime.Now() @@ -475,12 +470,12 @@ func writeFile(name string, dir string, contents []byte) error { writePath := filepath.Join(dir) file := filepath.Join(writePath, name) - err := tmos.EnsureDir(writePath, 0755) + err := tmos.EnsureDir(writePath, 0o755) if err != nil { return err } - err = ioutil.WriteFile(file, contents, 0644) // nolint: gosec + err = ioutil.WriteFile(file, contents, 0o644) // nolint: gosec if err != nil { return err } @@ -519,9 +514,13 @@ func startTestnet(cmd *cobra.Command, args startArgs) error { return err } - testnet.WaitForHeight(1) + if _, err := testnet.WaitForHeight(1); err != nil { + return err + } cmd.Println("press the Enter Key to terminate") - fmt.Scanln() // wait for Enter Key + if _, err := fmt.Scanln(); err != nil { // wait for Enter Key + return err + } testnet.Cleanup() return nil diff --git a/simapp/state.go b/simapp/state.go index f888a45bcd8b..135863c5bd7c 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -11,6 +11,7 @@ import ( tmjson "github.com/tendermint/tendermint/libs/json" tmtypes "github.com/tendermint/tendermint/types" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -28,7 +29,6 @@ import ( func AppStateFn(cdc codec.JSONCodec, simManager *module.SimulationManager) simtypes.AppStateFn { return func(r *rand.Rand, accs []simtypes.Account, config simtypes.Config, ) (appState json.RawMessage, simAccs []simtypes.Account, chainID string, genesisTimestamp time.Time) { - if FlagGenesisTimeValue == 0 { genesisTimestamp = simtypes.RandTimestamp(r) } else { @@ -147,10 +147,13 @@ func AppStateRandomizedFn( // generate a random amount of initial stake coins and a random initial // number of bonded accounts - var initialStake, numInitiallyBonded int64 + var ( + numInitiallyBonded int64 + initialStake sdkmath.Int + ) appParams.GetOrGenerate( cdc, simappparams.StakePerAccount, &initialStake, r, - func(r *rand.Rand) { initialStake = r.Int63n(1e12) }, + func(r *rand.Rand) { initialStake = sdkmath.NewInt(r.Int63n(1e12)) }, ) appParams.GetOrGenerate( cdc, simappparams.InitiallyBondedValidators, &numInitiallyBonded, r, diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 9029b1e14874..119b68f261f0 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -146,7 +146,8 @@ func Setup(t *testing.T, isCheckTx bool) *SimApp { func genesisStateWithValSet(t *testing.T, app *SimApp, genesisState GenesisState, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, - balances ...banktypes.Balance) GenesisState { + balances ...banktypes.Balance, +) GenesisState { // set genesis accounts authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) @@ -256,7 +257,7 @@ func SetupWithGenesisAccounts(t *testing.T, genAccs []authtypes.GenesisAccount, return SetupWithGenesisValSet(t, valSet, genAccs, balances...) } -// SetupWithGenesisValSet initializes GenesisState with a single validator and genesis accounts +// GenesisStateWithSingleValidator initializes GenesisState with a single validator and genesis accounts // that also act as delegators. func GenesisStateWithSingleValidator(t *testing.T, app *SimApp) GenesisState { t.Helper() @@ -309,7 +310,7 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress { buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string buffer.WriteString(numString) // adding on final two digits to make addresses unique - res, _ := sdk.AccAddressFromHex(buffer.String()) + res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) bech := res.String() addr, _ := TestAddr(buffer.String(), bech) @@ -335,7 +336,7 @@ func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sd return addTestAddrs(app, ctx, accNum, accAmt, createRandomAccounts) } -// AddTestAddrs constructs and returns accNum amount of accounts with an +// AddTestAddrsIncremental constructs and returns accNum amount of accounts with an // initial balance of accAmt in random order func AddTestAddrsIncremental(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress { return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts) @@ -377,7 +378,7 @@ func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { } func TestAddr(addr string, bech string) (sdk.AccAddress, error) { - res, err := sdk.AccAddressFromHex(addr) + res, err := sdk.AccAddressFromHexUnsafe(addr) if err != nil { return nil, err } @@ -411,8 +412,7 @@ func SignCheckDeliver( t *testing.T, txCfg client.TxConfig, app *bam.BaseApp, header tmproto.Header, msgs []sdk.Msg, chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { - - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, @@ -462,7 +462,7 @@ func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, i txs := make([]sdk.Tx, numToGenerate) var err error for i := 0; i < numToGenerate; i++ { - txs[i], err = helpers.GenTx( + txs[i], err = helpers.GenSignedMockTx( txGen, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, diff --git a/simapp/upgrades.go b/simapp/upgrades.go new file mode 100644 index 000000000000..dd44a8d5633e --- /dev/null +++ b/simapp/upgrades.go @@ -0,0 +1,73 @@ +package simapp + +import ( + "github.com/cosmos/cosmos-sdk/baseapp" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/group" + "github.com/cosmos/cosmos-sdk/x/nft" + upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// UpgradeName defines the on-chain upgrade name for the sample simap upgrade from v045 to v046. +// +// NOTE: This upgrade defines a reference implementation of what an upgrade could look like +// when an application is migrating from Cosmos SDK version v0.45.x to v0.46.x. +const UpgradeName = "v045-to-v046" + +func GetUpgradeStoreOption(keeper upgradekeeper.Keeper) baseapp.StoreOption { + upgradeInfo, err := keeper.ReadUpgradeInfoFromDisk() + if err != nil { + panic(err) + } + + if upgradeInfo.Name == UpgradeName && !keeper.IsSkipHeight(upgradeInfo.Height) { + storeUpgrades := storetypes.StoreUpgrades{ + Added: []string{ + group.ModuleName, + nft.ModuleName, + }, + } + + // configure store loader that checks if version == upgradeHeight and applies store upgrades + return upgradetypes.UpgradeStoreOption(uint64(upgradeInfo.Height), &storeUpgrades) + } + return nil +} + +func (app SimApp) RegisterUpgradeHandlers() { + app.UpgradeKeeper.SetUpgradeHandler(UpgradeName, + func(ctx sdk.Context, plan upgradetypes.Plan, _ module.VersionMap) (module.VersionMap, error) { + // We set fromVersion to 1 to avoid running InitGenesis for modules for + // in-store migrations. + // + // If you wish to skip any module migrations, i.e. they were already migrated + // in an older version, you can use `modulename.AppModule{}.ConsensusVersion()` + // instead of `1` below. + // + // For example: + // "auth": auth.AppModule{}.ConsensusVersion() + fromVM := map[string]uint64{ + "auth": 1, + "authz": 1, + "bank": 1, + "capability": 1, + "crisis": 1, + "distribution": 1, + "evidence": 1, + "feegrant": 1, + "gov": 1, + "mint": 1, + "params": 1, + "slashing": 1, + "staking": 1, + "upgrade": 1, + "vesting": 1, + "genutil": 1, + } + + return app.mm.RunMigrations(ctx, app.configurator, fromVM) + }) +} diff --git a/simapp/utils.go b/simapp/utils.go index 05ee80c504e7..b20dba86318b 100644 --- a/simapp/utils.go +++ b/simapp/utils.go @@ -85,7 +85,7 @@ func CheckExportSimulation( return err } - if err := os.WriteFile(config.ExportStatePath, []byte(exported.AppState), 0600); err != nil { + if err := os.WriteFile(config.ExportStatePath, []byte(exported.AppState), 0o600); err != nil { return err } } @@ -97,7 +97,7 @@ func CheckExportSimulation( return err } - if err := os.WriteFile(config.ExportParamsPath, paramsBz, 0600); err != nil { + if err := os.WriteFile(config.ExportParamsPath, paramsBz, 0o600); err != nil { return err } } diff --git a/snapshots/README.md b/snapshots/README.md index 8f6e526f0832..db0247a61673 100644 --- a/snapshots/README.md +++ b/snapshots/README.md @@ -28,7 +28,9 @@ filesystem under `/data/snapshots/`, with metadata in a LevelDB datab Snapshots are taken asynchronously, i.e. new blocks will be applied concurrently with snapshots being taken. This is possible because IAVL supports querying -immutable historical heights. +immutable historical heights. However, this requires heights that are multiples of `state-sync.snapshot-interval` +to be kept until after the snapshot is complete. It is done to prevent a height from being removed +while it is being snapshotted. When a remote node is state syncing, Tendermint calls the ABCI method `ListSnapshots` to list available local snapshots and `LoadSnapshotChunk` to @@ -47,6 +49,52 @@ can be trivially forged by an adversary. This was considered out of scope for the initial implementation, but can be added later without changes to the ABCI state sync protocol. +## Relationship to Pruning + +Snapshot settings are optional. However, if set, they have an effect on how pruning is done by +persisting the heights that are multiples of `state-sync.snapshot-interval` until after the snapshot is complete. + +If pruning is enabled (not `pruning = "nothing"`), we avoid pruning heights that are multiples of +`state-sync.snapshot-interval` in the regular logic determined by the +pruning settings and applied after every `Commit()`. This is done to prevent a +height from being removed before a snapshot is complete. Therefore, we keep +such heights until after a snapshot is done. At this point, the height is sent to +the `pruning.Manager` to be pruned according to the pruning settings after the next `Commit()`. + +To illustrate, assume that we are currently at height 960 with `pruning-keep-recent = 50`, +`pruning-interval = 10`, and `state-sync.snapshot-interval = 100`. Let's assume that +the snapshot that was triggered at height `900` **just finishes**. Then, we can prune height +`900` right away (that is, when we call `Commit()` at height 960 because 900 is less than `960 - 50 = 910`. + +Let's now assume that all conditions stay the same but the snapshot at height 900 is **not complete yet**. +Then, we cannot prune it to avoid deleting a height that is still being snapshotted. Therefore, we keep track +of this height until the snapshot is complete. The height 900 will be pruned at the first height h that satisfied the following conditions: +- the snapshot is complete +- h is a multiple of `pruning-interval` +- snapshot height is less than h - `pruning-keep-recent` + +Note that in both examples, if we let current height = C, and previous height P = C - 1, then for every height h that is: + +P - `pruning-keep-recent` - `pruning-interval` <= h <= P - `pruning-keep-recent` + +we can prune height h. In our first example, all heights 899 - 909 fall in this range and are pruned at height 960 as long as +h is not a snapshot height (E.g. 900). + +That is, we always use current height to determine at which height to prune (960) while we use previous +to determine which heights are to be pruned (959 - 50 - 10 = 899-909 = 959 - 50). + + +## Configuration + +- `state-sync.snapshot-interval` + * the interval at which to take snapshots. + * the value of 0 disables snapshots. + * if pruning is enabled, it is done after a snapshot is complete for the heights that are multiples of this interval. + +- `state-sync.snapshot-keep-recent`: + * the number of recent snapshots to keep. + * 0 means keep all. + ## Snapshot Metadata The ABCI Protobuf type for a snapshot is listed below (refer to the ABCI spec @@ -181,7 +229,9 @@ concurrently. During `BaseApp.Commit`, once a state transition has been committed, the height is checked against the `state-sync.snapshot-interval` setting. If the committed height should be snapshotted, a goroutine `BaseApp.snapshot()` is spawned that -calls `snapshots.Manager.Create()` to create the snapshot. +calls `snapshots.Manager.Create()` to create the snapshot. Once a snapshot is +complete and if pruning is enabled, the snapshot height is pruned away by the manager +with the call `PruneSnapshotHeight(...)` to the `snapshots.types.Snapshotter`. `Manager.Create()` will do some basic pre-flight checks, and then start generating a snapshot by calling `rootmulti.Store.Snapshot()`. The chunk stream diff --git a/snapshots/chunk.go b/snapshots/chunk.go index 4f02fccd7b06..74503f058027 100644 --- a/snapshots/chunk.go +++ b/snapshots/chunk.go @@ -1,10 +1,10 @@ package snapshots import ( - snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "io" "math" + snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -61,7 +61,7 @@ func (w *ChunkWriter) CloseWithError(err error) { w.closed = true close(w.ch) if w.pipe != nil { - w.pipe.CloseWithError(err) + _ = w.pipe.CloseWithError(err) // CloseWithError always returns nil } } } diff --git a/snapshots/chunk_test.go b/snapshots/chunk_test.go index 6935c082ad75..49440e00f390 100644 --- a/snapshots/chunk_test.go +++ b/snapshots/chunk_test.go @@ -132,7 +132,7 @@ func TestChunkReader(t *testing.T) { pr, pw := io.Pipe() pch := make(chan io.ReadCloser, 1) pch <- pr - pw.CloseWithError(theErr) + _ = pw.CloseWithError(theErr) chunkReader = snapshots.NewChunkReader(pch) buf = make([]byte, 4) diff --git a/snapshots/helpers_test.go b/snapshots/helpers_test.go index b54b8912a355..34d4fa0b0a59 100644 --- a/snapshots/helpers_test.go +++ b/snapshots/helpers_test.go @@ -7,17 +7,17 @@ import ( "crypto/sha256" "errors" "io" - "os" "testing" "time" protoio "github.com/gogo/protobuf/io" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/db/memdb" "github.com/cosmos/cosmos-sdk/snapshots" - "github.com/cosmos/cosmos-sdk/snapshots/types" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" + "github.com/cosmos/cosmos-sdk/testutil" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -74,12 +74,12 @@ func snapshotItems(items [][]byte) [][]byte { zWriter, _ := zlib.NewWriterLevel(bufWriter, 7) protoWriter := protoio.NewDelimitedWriter(zWriter) for _, item := range items { - types.WriteExtensionItem(protoWriter, item) + _ = snapshottypes.WriteExtensionItem(protoWriter, item) } - protoWriter.Close() - zWriter.Close() - bufWriter.Flush() - chunkWriter.Close() + _ = protoWriter.Close() + _ = zWriter.Close() + _ = bufWriter.Flush() + _ = chunkWriter.Close() }() var chunks [][]byte @@ -90,18 +90,21 @@ func snapshotItems(items [][]byte) [][]byte { } chunks = append(chunks, chunk) } + return chunks } type mockSnapshotter struct { - items [][]byte + items [][]byte + prunedHeights map[int64]struct{} + snapshotInterval uint64 } func (m *mockSnapshotter) Restore( height uint64, format uint32, protoReader protoio.Reader, ) (snapshottypes.SnapshotItem, error) { if format == 0 { - return snapshottypes.SnapshotItem{}, types.ErrUnknownFormat + return snapshottypes.SnapshotItem{}, snapshottypes.ErrUnknownFormat } if m.items != nil { return snapshottypes.SnapshotItem{}, errors.New("already has contents") @@ -128,7 +131,7 @@ func (m *mockSnapshotter) Restore( func (m *mockSnapshotter) Snapshot(height uint64, protoWriter protoio.Writer) error { for _, item := range m.items { - if err := types.WriteExtensionItem(protoWriter, item); err != nil { + if err := snapshottypes.WriteExtensionItem(protoWriter, item); err != nil { return err } } @@ -138,28 +141,38 @@ func (m *mockSnapshotter) Snapshot(height uint64, protoWriter protoio.Writer) er func (m *mockSnapshotter) SnapshotFormat() uint32 { return snapshottypes.CurrentFormat } + func (m *mockSnapshotter) SupportedFormats() []uint32 { return []uint32{snapshottypes.CurrentFormat} } +func (m *mockSnapshotter) PruneSnapshotHeight(height int64) { + m.prunedHeights[height] = struct{}{} +} + +func (m *mockSnapshotter) GetSnapshotInterval() uint64 { + return m.snapshotInterval +} + +func (m *mockSnapshotter) SetSnapshotInterval(snapshotInterval uint64) { + m.snapshotInterval = snapshotInterval +} + // setupBusyManager creates a manager with an empty store that is busy creating a snapshot at height 1. // The snapshot will complete when the returned closer is called. func setupBusyManager(t *testing.T) *snapshots.Manager { - // os.MkdirTemp() is used instead of testing.T.TempDir() - // see https://github.com/cosmos/cosmos-sdk/pull/8475 for - // this change's rationale. - tempdir, err := os.MkdirTemp("", "") - require.NoError(t, err) - t.Cleanup(func() { _ = os.RemoveAll(tempdir) }) - - store, err := snapshots.NewStore(memdb.NewDB(), tempdir) + store, err := snapshots.NewStore(memdb.NewDB(), testutil.GetTempDir(t)) require.NoError(t, err) hung := newHungSnapshotter() - mgr := snapshots.NewManager(store, hung, nil) + hung.SetSnapshotInterval(opts.Interval) + mgr := snapshots.NewManager(store, opts, hung, nil, log.NewNopLogger()) + require.Equal(t, opts.Interval, hung.snapshotInterval) go func() { _, err := mgr.Create(1) require.NoError(t, err) + _, didPruneHeight := hung.prunedHeights[1] + require.True(t, didPruneHeight) }() time.Sleep(10 * time.Millisecond) t.Cleanup(hung.Close) @@ -169,12 +182,15 @@ func setupBusyManager(t *testing.T) *snapshots.Manager { // hungSnapshotter can be used to test operations in progress. Call close to end the snapshot. type hungSnapshotter struct { - ch chan struct{} + ch chan struct{} + prunedHeights map[int64]struct{} + snapshotInterval uint64 } func newHungSnapshotter() *hungSnapshotter { return &hungSnapshotter{ - ch: make(chan struct{}), + ch: make(chan struct{}), + prunedHeights: make(map[int64]struct{}), } } @@ -187,6 +203,14 @@ func (m *hungSnapshotter) Snapshot(height uint64, protoWriter protoio.Writer) er return nil } +func (m *hungSnapshotter) PruneSnapshotHeight(height int64) { + m.prunedHeights[height] = struct{}{} +} + +func (m *hungSnapshotter) SetSnapshotInterval(snapshotInterval uint64) { + m.snapshotInterval = snapshotInterval +} + func (m *hungSnapshotter) Restore( height uint64, format uint32, protoReader protoio.Reader, ) (snapshottypes.SnapshotItem, error) { diff --git a/snapshots/manager.go b/snapshots/manager.go index bdcbfe0a9357..8d10dcc9c713 100644 --- a/snapshots/manager.go +++ b/snapshots/manager.go @@ -3,36 +3,19 @@ package snapshots import ( "bytes" "crypto/sha256" + "errors" "fmt" "io" "math" "sort" "sync" + "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/cosmos-sdk/snapshots/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -const ( - opNone operation = "" - opSnapshot operation = "snapshot" - opPrune operation = "prune" - 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. -type operation string - -// restoreDone represents the result of a restore operation. -type restoreDone struct { - complete bool // if true, restore completed successfully (not prematurely) - err error // if non-nil, restore errored -} - // Manager manages snapshot and restore operations for an app, making sure only a single // long-running operation is in progress at any given time, and provides convenience methods // mirroring the ABCI interface. @@ -47,9 +30,13 @@ 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 - multistore types.Snapshotter extensions map[string]types.ExtensionSnapshotter + // store is the snapshot store where all completed snapshots are persisted. + store *Store + opts types.SnapshotOptions + // multistore is the store from which snapshots are taken. + multistore types.Snapshotter + logger log.Logger mtx sync.Mutex operation operation @@ -59,12 +46,36 @@ type Manager struct { restoreChunkIndex uint32 } +// operation represents a Manager operation. Only one operation can be in progress at a time. +type operation string + +// restoreDone represents the result of a restore operation. +type restoreDone struct { + complete bool // if true, restore completed successfully (not prematurely) + err error // if non-nil, restore errored +} + +const ( + opNone operation = "" + opSnapshot operation = "snapshot" + opPrune operation = "prune" + opRestore operation = "restore" + + chunkBufferSize = 4 + + snapshotMaxItemSize = int(64e6) // SDK has no key/value size limit, so we set an arbitrary limit +) + +var ErrOptsZeroSnapshotInterval = errors.New("snaphot-interval must not be 0") + // NewManager creates a new manager. -func NewManager(store *Store, multistore types.Snapshotter, extensions map[string]types.ExtensionSnapshotter) *Manager { +func NewManager(store *Store, opts types.SnapshotOptions, multistore types.Snapshotter, extensions map[string]types.ExtensionSnapshotter, logger log.Logger) *Manager { return &Manager{ store: store, + opts: opts, multistore: multistore, extensions: extensions, + logger: logger, } } @@ -121,15 +132,22 @@ 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) - } +// GetInterval returns snapshot interval represented in heights. +func (m *Manager) GetInterval() uint64 { + return m.opts.Interval +} - sort.Strings(names) - return names +// GetKeepRecent returns snapshot keep-recent represented in heights. +func (m *Manager) GetKeepRecent() uint32 { + return m.opts.KeepRecent +} + +// GetSnapshotBlockRetentionHeights returns the number of heights needed +// for block retention. Blocks since the oldest available snapshot must be +// available for state sync nodes to catch up (oldest because a node may be +// restoring an old snapshot while a new snapshot was taken). +func (m *Manager) GetSnapshotBlockRetentionHeights() int64 { + return int64(m.opts.Interval * uint64(m.opts.KeepRecent)) } // Create creates a snapshot and returns its metadata. @@ -137,6 +155,9 @@ func (m *Manager) Create(height uint64) (*types.Snapshot, error) { if m == nil { return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "no snapshot store configured") } + + defer m.multistore.PruneSnapshotHeight(int64(height)) + err := m.begin(opSnapshot) if err != nil { return nil, err @@ -166,7 +187,12 @@ func (m *Manager) createSnapshot(height uint64, ch chan<- io.ReadCloser) { if streamWriter == nil { return } - defer streamWriter.Close() + defer func() { + if err := streamWriter.Close(); err != nil { + streamWriter.CloseWithError(err) + } + }() + if err := m.multistore.Snapshot(height, streamWriter); err != nil { streamWriter.CloseWithError(err) return @@ -362,6 +388,17 @@ func (m *Manager) RestoreChunk(chunk []byte) (bool, error) { return false, nil } +// 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 +} + // IsFormatSupported returns if the snapshotter supports restoration from given format. func IsFormatSupported(snapshotter types.ExtensionSnapshotter, format uint32) bool { for _, i := range snapshotter.SupportedFormats() { @@ -371,3 +408,50 @@ func IsFormatSupported(snapshotter types.ExtensionSnapshotter, format uint32) bo } return false } + +// SnapshotIfApplicable takes a snapshot of the current state if we are on a snapshot height. +// It also prunes any old snapshots. +func (m *Manager) SnapshotIfApplicable(height int64) { + if m == nil { + return + } + if !m.shouldTakeSnapshot(height) { + m.logger.Debug("snapshot is skipped", "height", height) + return + } + m.snapshot(height) +} + +// shouldTakeSnapshot returns true is snapshot should be taken at height. +func (m *Manager) shouldTakeSnapshot(height int64) bool { + return m.opts.Interval > 0 && uint64(height)%m.opts.Interval == 0 +} + +func (m *Manager) snapshot(height int64) { + m.logger.Info("creating state snapshot", "height", height) + + if height <= 0 { + m.logger.Error("snapshot height must be positive", "height", height) + return + } + + snapshot, err := m.Create(uint64(height)) + if err != nil { + m.logger.Error("failed to create state snapshot", "height", height, "err", err) + return + } + + m.logger.Info("completed state snapshot", "height", height, "format", snapshot.Format) + + if m.opts.KeepRecent > 0 { + m.logger.Debug("pruning state snapshots") + + pruned, err := m.Prune(m.opts.KeepRecent) + if err != nil { + m.logger.Error("Failed to prune state snapshots", "err", err) + return + } + + m.logger.Debug("pruned state snapshots", "pruned", pruned) + } +} diff --git a/snapshots/manager_test.go b/snapshots/manager_test.go index 0989bb4bd210..7fbddd6c7d6d 100644 --- a/snapshots/manager_test.go +++ b/snapshots/manager_test.go @@ -6,14 +6,20 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/snapshots/types" ) +var opts = types.NewSnapshotOptions(1500, 2) + func TestManager_List(t *testing.T) { store := setupStore(t) - manager := snapshots.NewManager(store, nil, nil) + snapshotter := &mockSnapshotter{} + snapshotter.SetSnapshotInterval(opts.Interval) + manager := snapshots.NewManager(store, opts, snapshotter, nil, log.NewNopLogger()) + require.Equal(t, opts.Interval, snapshotter.GetSnapshotInterval()) mgrList, err := manager.List() require.NoError(t, err) @@ -32,7 +38,7 @@ func TestManager_List(t *testing.T) { func TestManager_LoadChunk(t *testing.T) { store := setupStore(t) - manager := snapshots.NewManager(store, nil, nil) + manager := snapshots.NewManager(store, opts, &mockSnapshotter{}, nil, log.NewNopLogger()) // Existing chunk should return body chunk, err := manager.LoadChunk(2, 1, 1) @@ -59,10 +65,11 @@ func TestManager_Take(t *testing.T) { {7, 8, 9}, } snapshotter := &mockSnapshotter{ - items: items, + items: items, + prunedHeights: make(map[int64]struct{}), } expectChunks := snapshotItems(items) - manager := snapshots.NewManager(store, snapshotter, nil) + manager := snapshots.NewManager(store, opts, snapshotter, nil, log.NewNopLogger()) // nil manager should return error _, err := (*snapshots.Manager)(nil).Create(1) @@ -71,10 +78,15 @@ func TestManager_Take(t *testing.T) { // creating a snapshot at a lower height than the latest should error _, err = manager.Create(3) require.Error(t, err) + _, didPruneHeight := snapshotter.prunedHeights[3] + require.True(t, didPruneHeight) // creating a snapshot at a higher height should be fine, and should return it snapshot, err := manager.Create(5) require.NoError(t, err) + _, didPruneHeight = snapshotter.prunedHeights[5] + require.True(t, didPruneHeight) + assert.Equal(t, &types.Snapshot{ Height: 5, Format: snapshotter.SnapshotFormat(), @@ -98,7 +110,9 @@ func TestManager_Take(t *testing.T) { func TestManager_Prune(t *testing.T) { store := setupStore(t) - manager := snapshots.NewManager(store, nil, nil) + snapshotter := &mockSnapshotter{} + snapshotter.SetSnapshotInterval(opts.Interval) + manager := snapshots.NewManager(store, opts, snapshotter, nil, log.NewNopLogger()) pruned, err := manager.Prune(2) require.NoError(t, err) @@ -116,8 +130,10 @@ func TestManager_Prune(t *testing.T) { func TestManager_Restore(t *testing.T) { store := setupStore(t) - target := &mockSnapshotter{} - manager := snapshots.NewManager(store, target, nil) + target := &mockSnapshotter{ + prunedHeights: make(map[int64]struct{}), + } + manager := snapshots.NewManager(store, opts, target, nil, log.NewNopLogger()) expectItems := [][]byte{ {1, 2, 3}, @@ -165,6 +181,8 @@ func TestManager_Restore(t *testing.T) { // While the restore is in progress, any other operations fail _, err = manager.Create(4) require.Error(t, err) + _, didPruneHeight := target.prunedHeights[4] + require.True(t, didPruneHeight) _, err = manager.Prune(1) require.Error(t, err) diff --git a/snapshots/store.go b/snapshots/store.go index 7b0f157191fb..2ab7b48709eb 100644 --- a/snapshots/store.go +++ b/snapshots/store.go @@ -36,7 +36,7 @@ func NewStore(db dbm.DBConnection, dir string) (*Store, error) { if dir == "" { return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "snapshot directory not given") } - err := os.MkdirAll(dir, 0755) + err := os.MkdirAll(dir, 0o755) if err != nil { return nil, sdkerrors.Wrapf(err, "failed to create snapshot directory %q", dir) } @@ -158,13 +158,13 @@ func (s *Store) Load(height uint64, format uint32) (*types.Snapshot, <-chan io.R ch <- pr chunk, err := s.loadChunkFile(height, format, i) if err != nil { - pw.CloseWithError(err) + _ = pw.CloseWithError(err) return } defer chunk.Close() _, err = io.Copy(pw, chunk) if err != nil { - pw.CloseWithError(err) + _ = pw.CloseWithError(err) return } chunk.Close() @@ -279,7 +279,7 @@ func (s *Store) Save( for chunkBody := range chunks { defer chunkBody.Close() // nolint: staticcheck dir := s.pathSnapshot(height, format) - err = os.MkdirAll(dir, 0755) + err = os.MkdirAll(dir, 0o755) if err != nil { return nil, sdkerrors.Wrapf(err, "failed to create snapshot directory %q", dir) } diff --git a/snapshots/store_test.go b/snapshots/store_test.go index 1f8131a994e7..bca46300e563 100644 --- a/snapshots/store_test.go +++ b/snapshots/store_test.go @@ -4,7 +4,6 @@ import ( "bytes" "errors" "io" - "os" "path/filepath" "testing" "time" @@ -19,14 +18,7 @@ import ( ) func setupStore(t *testing.T) *snapshots.Store { - // os.MkdirTemp() is used instead of testing.T.TempDir() - // see https://github.com/cosmos/cosmos-sdk/pull/8475 for - // this change's rationale. - tempdir, err := os.MkdirTemp("", "") - require.NoError(t, err) - t.Cleanup(func() { _ = os.RemoveAll(tempdir) }) - - store, err := snapshots.NewStore(memdb.NewDB(), tempdir) + store, err := snapshots.NewStore(memdb.NewDB(), testutil.GetTempDir(t)) require.NoError(t, err) _, err = store.Save(1, 1, makeChunks([][]byte{ @@ -88,7 +80,10 @@ func TestStore_Delete(t *testing.T) { // Deleting a snapshot being saved should error ch := make(chan io.ReadCloser) - go store.Save(9, 1, ch) + go func() { + _, err := store.Save(9, 1, ch) + require.NoError(t, err) + }() time.Sleep(10 * time.Millisecond) err = store.Delete(9, 1) @@ -119,7 +114,8 @@ func TestStore_Get(t *testing.T) { Hash: hash([][]byte{{2, 1, 0}, {2, 1, 1}}), Metadata: types.Metadata{ ChunkHashes: checksums([][]byte{ - {2, 1, 0}, {2, 1, 1}}), + {2, 1, 0}, {2, 1, 1}, + }), }, }, snapshot) } @@ -154,16 +150,20 @@ func TestStore_List(t *testing.T) { require.NoError(t, err) require.Equal(t, []*types.Snapshot{ - {Height: 3, Format: 2, Chunks: 3, Hash: hash([][]byte{{3, 2, 0}, {3, 2, 1}, {3, 2, 2}}), + { + Height: 3, Format: 2, Chunks: 3, Hash: hash([][]byte{{3, 2, 0}, {3, 2, 1}, {3, 2, 2}}), Metadata: types.Metadata{ChunkHashes: checksums([][]byte{{3, 2, 0}, {3, 2, 1}, {3, 2, 2}})}, }, - {Height: 2, Format: 2, Chunks: 3, Hash: hash([][]byte{{2, 2, 0}, {2, 2, 1}, {2, 2, 2}}), + { + Height: 2, Format: 2, Chunks: 3, Hash: hash([][]byte{{2, 2, 0}, {2, 2, 1}, {2, 2, 2}}), Metadata: types.Metadata{ChunkHashes: checksums([][]byte{{2, 2, 0}, {2, 2, 1}, {2, 2, 2}})}, }, - {Height: 2, Format: 1, Chunks: 2, Hash: hash([][]byte{{2, 1, 0}, {2, 1, 1}}), + { + Height: 2, Format: 1, Chunks: 2, Hash: hash([][]byte{{2, 1, 0}, {2, 1, 1}}), Metadata: types.Metadata{ChunkHashes: checksums([][]byte{{2, 1, 0}, {2, 1, 1}})}, }, - {Height: 1, Format: 1, Chunks: 2, Hash: hash([][]byte{{1, 1, 0}, {1, 1, 1}}), + { + Height: 1, Format: 1, Chunks: 2, Hash: hash([][]byte{{1, 1, 0}, {1, 1, 1}}), Metadata: types.Metadata{ChunkHashes: checksums([][]byte{{1, 1, 0}, {1, 1, 1}})}, }, }, snapshots) @@ -187,7 +187,8 @@ func TestStore_Load(t *testing.T) { Hash: hash([][]byte{{2, 1, 0}, {2, 1, 1}}), Metadata: types.Metadata{ ChunkHashes: checksums([][]byte{ - {2, 1, 0}, {2, 1, 1}}), + {2, 1, 0}, {2, 1, 1}, + }), }, }, snapshot) @@ -245,13 +246,16 @@ func TestStore_Prune(t *testing.T) { snapshots, err = store.List() require.NoError(t, err) require.Equal(t, []*types.Snapshot{ - {Height: 3, Format: 2, Chunks: 3, Hash: hash([][]byte{{3, 2, 0}, {3, 2, 1}, {3, 2, 2}}), + { + Height: 3, Format: 2, Chunks: 3, Hash: hash([][]byte{{3, 2, 0}, {3, 2, 1}, {3, 2, 2}}), Metadata: types.Metadata{ChunkHashes: checksums([][]byte{{3, 2, 0}, {3, 2, 1}, {3, 2, 2}})}, }, - {Height: 2, Format: 2, Chunks: 3, Hash: hash([][]byte{{2, 2, 0}, {2, 2, 1}, {2, 2, 2}}), + { + Height: 2, Format: 2, Chunks: 3, Hash: hash([][]byte{{2, 2, 0}, {2, 2, 1}, {2, 2, 2}}), Metadata: types.Metadata{ChunkHashes: checksums([][]byte{{2, 2, 0}, {2, 2, 1}, {2, 2, 2}})}, }, - {Height: 2, Format: 1, Chunks: 2, Hash: hash([][]byte{{2, 1, 0}, {2, 1, 1}}), + { + Height: 2, Format: 1, Chunks: 2, Hash: hash([][]byte{{2, 1, 0}, {2, 1, 1}}), Metadata: types.Metadata{ChunkHashes: checksums([][]byte{{2, 1, 0}, {2, 1, 1}})}, }, }, snapshots) @@ -324,7 +328,10 @@ func TestStore_Save(t *testing.T) { // Saving a snapshot should error if a snapshot is already in progress for the same height, // regardless of format. However, a different height should succeed. ch = make(chan io.ReadCloser) - go store.Save(7, 1, ch) + go func() { + _, err := store.Save(7, 1, ch) + require.NoError(t, err) + }() time.Sleep(10 * time.Millisecond) _, err = store.Save(7, 2, makeChunks(nil)) require.Error(t, err) diff --git a/snapshots/stream.go b/snapshots/stream.go index 80cd5c3dfdcb..935028313bb5 100644 --- a/snapshots/stream.go +++ b/snapshots/stream.go @@ -103,7 +103,15 @@ func (sr *StreamReader) ReadMsg(msg proto.Message) error { // Close implements io.Closer interface func (sr *StreamReader) Close() error { - sr.protoReader.Close() - sr.zReader.Close() - return sr.chunkReader.Close() + var err error + if err1 := sr.protoReader.Close(); err1 != nil { + err = err1 + } + if err2 := sr.zReader.Close(); err2 != nil { + err = err2 + } + if err3 := sr.chunkReader.Close(); err3 != nil { + err = err3 + } + return err } diff --git a/snapshots/types/options.go b/snapshots/types/options.go new file mode 100644 index 000000000000..1ce39d486adb --- /dev/null +++ b/snapshots/types/options.go @@ -0,0 +1,22 @@ +package types + +// SnapshotOptions defines the snapshot strategy used when determining which +// heights are snapshotted for state sync. +type SnapshotOptions struct { + // Interval defines at which heights the snapshot is taken. + Interval uint64 + + // KeepRecent defines how many snapshots to keep in heights. + KeepRecent uint32 +} + +// SnapshotIntervalOff represents the snapshot interval, at which +// no snapshots are taken. +const SnapshotIntervalOff uint64 = 0 + +func NewSnapshotOptions(interval uint64, keepRecent uint32) SnapshotOptions { + return SnapshotOptions{ + Interval: interval, + KeepRecent: keepRecent, + } +} diff --git a/snapshots/types/snapshot.pb.go b/snapshots/types/snapshot.pb.go index fa3f5e2a8633..703e9769e9cb 100644 --- a/snapshots/types/snapshot.pb.go +++ b/snapshots/types/snapshot.pb.go @@ -146,6 +146,8 @@ func (m *Metadata) GetChunkHashes() [][]byte { } // SnapshotItem is an item contained in a rootmulti.Store snapshot. +// +// Since: cosmos-sdk 0.46 type SnapshotItem struct { // item is the specific type of snapshot item. // @@ -286,6 +288,8 @@ func (*SnapshotItem) XXX_OneofWrappers() []interface{} { } // SnapshotStoreItem contains metadata about a snapshotted store. +// +// Since: cosmos-sdk 0.46 type SnapshotStoreItem struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` } @@ -331,6 +335,8 @@ func (m *SnapshotStoreItem) GetName() string { } // SnapshotIAVLItem is an exported IAVL node. +// +// Since: cosmos-sdk 0.46 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"` @@ -402,6 +408,8 @@ func (m *SnapshotIAVLItem) GetHeight() int32 { } // SnapshotExtensionMeta contains metadata about an external snapshotter. +// +// Since: cosmos-sdk 0.46 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"` @@ -455,6 +463,8 @@ func (m *SnapshotExtensionMeta) GetFormat() uint32 { } // SnapshotExtensionPayload contains payloads of an external snapshotter. +// +// Since: cosmos-sdk 0.46 type SnapshotExtensionPayload struct { Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` } @@ -500,6 +510,8 @@ func (m *SnapshotExtensionPayload) GetPayload() []byte { } // SnapshotKVItem is an exported Key/Value Pair +// +// Since: cosmos-sdk 0.46 type SnapshotKVItem 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"` @@ -553,6 +565,8 @@ func (m *SnapshotKVItem) GetValue() []byte { } // SnapshotSchema is an exported schema of smt store +// +// Since: cosmos-sdk 0.46 type SnapshotSchema struct { Keys [][]byte `protobuf:"bytes,1,rep,name=keys,proto3" json:"keys,omitempty"` } diff --git a/snapshots/types/snapshotter.go b/snapshots/types/snapshotter.go index f747920d13ad..76f800484a49 100644 --- a/snapshots/types/snapshotter.go +++ b/snapshots/types/snapshotter.go @@ -11,7 +11,18 @@ type Snapshotter interface { // Snapshot writes snapshot items into the protobuf writer. Snapshot(height uint64, protoWriter protoio.Writer) error - // Restore restores a state snapshot from the protobuf items read from the reader. + // PruneSnapshotHeight prunes the given height according to the prune strategy. + // If PruneNothing, this is a no-op. + // If other strategy, this height is persisted until it is + // less than - KeepRecent and % Interval == 0 + PruneSnapshotHeight(height int64) + + // SetSnapshotInterval sets the interval at which the snapshots are taken. + // It is used by the store that implements the Snapshotter interface + // to determine which heights to retain until after the snapshot is complete. + SetSnapshotInterval(snapshotInterval uint64) + + // Restore restores a state snapshot, taking snapshot chunk readers as input. // 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, protoReader protoio.Reader) (SnapshotItem, error) diff --git a/store/cachekv/memiterator.go b/store/cachekv/memiterator.go index 04df40ff56aa..e65e8a580fce 100644 --- a/store/cachekv/memiterator.go +++ b/store/cachekv/memiterator.go @@ -8,7 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/types" ) -// Iterates over iterKVCache items. +// memIterator iterates over iterKVCache items. // if key is nil, means it was deleted. // Implements Iterator. type memIterator struct { diff --git a/store/cachekv/store.go b/store/cachekv/store.go index 68fe7213dbfa..28063504b208 100644 --- a/store/cachekv/store.go +++ b/store/cachekv/store.go @@ -15,14 +15,16 @@ import ( "github.com/cosmos/cosmos-sdk/types/kv" ) -// If value is nil but deleted is false, it means the parent doesn't have the -// key. (No need to delete upon Write()) +// cValue represents a cached value. +// If dirty is true, it indicates the cached value is different from the underlying value. type cValue struct { value []byte dirty bool } // Store wraps an in-memory cache around an underlying types.KVStore. +// If a cached value is nil but deleted is defined for the corresponding key, +// it means the parent doesn't have the key. (No need to delete upon Write()) type Store struct { mtx sync.Mutex cache map[string]*cValue diff --git a/store/cachekv/store_test.go b/store/cachekv/store_test.go index 0404f33f2a28..d589932d30fc 100644 --- a/store/cachekv/store_test.go +++ b/store/cachekv/store_test.go @@ -112,7 +112,7 @@ func TestCacheKVIteratorBounds(t *testing.T) { // iterate over all of them itr := st.Iterator(nil, nil) - var i = 0 + i := 0 for ; itr.Valid(); itr.Next() { k, v := itr.Key(), itr.Value() require.Equal(t, keyFmt(i), k) @@ -380,7 +380,7 @@ func doRandomOp(t *testing.T, st types.CacheKVStore, truth dbm.DB, maxKey int) { // iterate over whole domain func assertIterateDomain(t *testing.T, st types.KVStore, expectedN int) { itr := st.Iterator(nil, nil) - var i = 0 + i := 0 for ; itr.Valid(); itr.Next() { k, v := itr.Key(), itr.Value() require.Equal(t, keyFmt(i), k) diff --git a/store/cachemulti/store.go b/store/cachemulti/store.go index b60ed0465392..2e39554e17ce 100644 --- a/store/cachemulti/store.go +++ b/store/cachemulti/store.go @@ -13,6 +13,10 @@ import ( "github.com/cosmos/cosmos-sdk/store/types" ) +// storeNameCtxKey is the TraceContext metadata key that identifies +// the store which emitted a given trace. +const storeNameCtxKey = "store_name" + //---------------------------------------- // Store @@ -52,7 +56,11 @@ func NewFromKVStore( for key, store := range stores { if cms.TracingEnabled() { - store = tracekv.NewStore(store.(types.KVStore), cms.traceWriter, cms.traceContext) + tctx := cms.traceContext.Clone().Merge(types.TraceContext{ + storeNameCtxKey: key.Name(), + }) + + store = tracekv.NewStore(store.(types.KVStore), cms.traceWriter, tctx) } if cms.ListeningEnabled(key) { store = listenkv.NewStore(store.(types.KVStore), key, listeners[key]) @@ -69,7 +77,6 @@ func NewStore( db dbm.DB, stores map[types.StoreKey]types.CacheWrapper, keys map[string]types.StoreKey, traceWriter io.Writer, traceContext types.TraceContext, listeners map[types.StoreKey][]types.WriteListener, ) Store { - return NewFromKVStore(dbadapter.Store{DB: db}, stores, keys, traceWriter, traceContext, listeners) } diff --git a/store/dbadapter/store.go b/store/dbadapter/store.go index 2f0ceb5df54a..815c1f12ec1c 100644 --- a/store/dbadapter/store.go +++ b/store/dbadapter/store.go @@ -36,7 +36,7 @@ func (dsa Store) Has(key []byte) bool { return ok } -// Set wraps the underlying DB's Set method panicing on error. +// Set wraps the underlying DB's Set method panicking on error. func (dsa Store) Set(key, value []byte) { types.AssertValidKey(key) if err := dsa.DB.Set(key, value); err != nil { @@ -44,14 +44,14 @@ func (dsa Store) Set(key, value []byte) { } } -// Delete wraps the underlying DB's Delete method panicing on error. +// Delete wraps the underlying DB's Delete method panicking on error. func (dsa Store) Delete(key []byte) { if err := dsa.DB.Delete(key); err != nil { panic(err) } } -// Iterator wraps the underlying DB's Iterator method panicing on error. +// Iterator wraps the underlying DB's Iterator method panicking on error. func (dsa Store) Iterator(start, end []byte) types.Iterator { iter, err := dsa.DB.Iterator(start, end) if err != nil { @@ -61,7 +61,7 @@ func (dsa Store) Iterator(start, end []byte) types.Iterator { return iter } -// ReverseIterator wraps the underlying DB's ReverseIterator method panicing on error. +// ReverseIterator wraps the underlying DB's ReverseIterator method panicking on error. func (dsa Store) ReverseIterator(start, end []byte) types.Iterator { iter, err := dsa.DB.ReverseIterator(start, end) if err != nil { diff --git a/store/firstlast.go b/store/firstlast.go index 307f932fb0c8..0ab4e319e08a 100644 --- a/store/firstlast.go +++ b/store/firstlast.go @@ -7,7 +7,7 @@ import ( sdkkv "github.com/cosmos/cosmos-sdk/types/kv" ) -// Gets the first item. +// First gets the first item. func First(st KVStore, start, end []byte) (kv sdkkv.Pair, ok bool) { iter := st.Iterator(start, end) if !iter.Valid() { @@ -18,7 +18,7 @@ func First(st KVStore, start, end []byte) (kv sdkkv.Pair, ok bool) { return sdkkv.Pair{Key: iter.Key(), Value: iter.Value()}, true } -// Gets the last item. `end` is exclusive. +// Last gets the last item. `end` is exclusive. func Last(st KVStore, start, end []byte) (kv sdkkv.Pair, ok bool) { iter := st.ReverseIterator(end, start) if !iter.Valid() { diff --git a/store/iavl/store.go b/store/iavl/store.go index a5706553668c..c47e7171ad32 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -12,6 +12,7 @@ import ( tmcrypto "github.com/tendermint/tendermint/proto/tendermint/crypto" dbm "github.com/tendermint/tm-db" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/store/cachekv" "github.com/cosmos/cosmos-sdk/store/listenkv" "github.com/cosmos/cosmos-sdk/store/tracekv" @@ -128,13 +129,13 @@ func (st *Store) LastCommitID() types.CommitID { // SetPruning panics as pruning options should be provided at initialization // since IAVl accepts pruning options directly. -func (st *Store) SetPruning(_ types.PruningOptions) { +func (st *Store) SetPruning(_ pruningtypes.PruningOptions) { panic("cannot set pruning options on an initialized IAVL store") } // SetPruning panics as pruning options should be provided at initialization // since IAVl accepts pruning options directly. -func (st *Store) GetPruning() types.PruningOptions { +func (st *Store) GetPruning() pruningtypes.PruningOptions { panic("cannot get pruning options on an initialized IAVL store") } @@ -379,7 +380,7 @@ func getProofFromTree(tree *iavl.MutableTree, key []byte, exists bool) *tmcrypto //---------------------------------------- -// Implements types.Iterator. +// iavlIterator implements types.Iterator. type iavlIterator struct { *iavl.Iterator } diff --git a/store/iavl/store_test.go b/store/iavl/store_test.go index b9c9e25ad43d..e39a6ebee15b 100644 --- a/store/iavl/store_test.go +++ b/store/iavl/store_test.go @@ -284,7 +284,7 @@ func TestIAVLReverseIterator(t *testing.T) { iavlStore.Set([]byte{0x00, 0x02}, []byte("0 2")) iavlStore.Set([]byte{0x01}, []byte("1")) - var testReverseIterator = func(t *testing.T, start []byte, end []byte, expected []string) { + testReverseIterator := func(t *testing.T, start []byte, end []byte, expected []string) { iter := iavlStore.ReverseIterator(start, end) var i int for i = 0; iter.Valid(); iter.Next() { diff --git a/store/internal/maps/maps_test.go b/store/internal/maps/maps_test.go index 8f6b1163eaec..ce7ad72e649d 100644 --- a/store/internal/maps/maps_test.go +++ b/store/internal/maps/maps_test.go @@ -12,6 +12,7 @@ func TestEmptyKeyMerkleMap(t *testing.T) { db := newMerkleMap() require.Panics(t, func() { db.set("", []byte("value")) }, "setting an empty key should panic") } + func TestMerkleMap(t *testing.T) { tests := []struct { keys []string @@ -59,6 +60,7 @@ func TestEmptyKeySimpleMap(t *testing.T) { db := newSimpleMap() require.Panics(t, func() { db.Set("", []byte("value")) }, "setting an empty key should panic") } + func TestSimpleMap(t *testing.T) { tests := []struct { keys []string diff --git a/store/listenkv/store_test.go b/store/listenkv/store_test.go index 5d4fd0cca9c4..8d0510ba49ce 100644 --- a/store/listenkv/store_test.go +++ b/store/listenkv/store_test.go @@ -29,9 +29,11 @@ var kvPairs = []types.KVPair{ {Key: keyFmt(3), Value: valFmt(3)}, } -var testStoreKey = types.NewKVStoreKey("listen_test") -var interfaceRegistry = codecTypes.NewInterfaceRegistry() -var testMarshaller = codec.NewProtoCodec(interfaceRegistry) +var ( + testStoreKey = types.NewKVStoreKey("listen_test") + interfaceRegistry = codecTypes.NewInterfaceRegistry() + testMarshaller = codec.NewProtoCodec(interfaceRegistry) +) func newListenKVStore(w io.Writer) *listenkv.Store { store := newEmptyListenKVStore(w) @@ -130,7 +132,6 @@ func TestListenKVStoreSet(t *testing.T) { store := newEmptyListenKVStore(&buf) require.Panics(t, func() { store.Set([]byte(""), []byte("value")) }, "setting an empty key should panic") require.Panics(t, func() { store.Set(nil, []byte("value")) }, "setting a nil key should panic") - } func TestListenKVStoreDelete(t *testing.T) { diff --git a/store/mem/store.go b/store/mem/store.go index c8aa6dca5997..06d7b63f5506 100644 --- a/store/mem/store.go +++ b/store/mem/store.go @@ -5,6 +5,7 @@ import ( dbm "github.com/tendermint/tm-db" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/store/cachekv" "github.com/cosmos/cosmos-sdk/store/dbadapter" "github.com/cosmos/cosmos-sdk/store/listenkv" @@ -54,10 +55,12 @@ func (s Store) CacheWrapWithListeners(storeKey types.StoreKey, listeners []types // Commit performs a no-op as entries are persistent between commitments. func (s *Store) Commit() (id types.CommitID) { return } -func (s *Store) SetPruning(pruning types.PruningOptions) {} +func (s *Store) SetPruning(pruning pruningtypes.PruningOptions) {} // GetPruning is a no-op as pruning options cannot be directly set on this store. // They must be set on the root commit multi-store. -func (s *Store) GetPruning() types.PruningOptions { return types.PruningOptions{} } +func (s *Store) GetPruning() pruningtypes.PruningOptions { + return pruningtypes.NewPruningOptions(pruningtypes.PruningUndefined) +} func (s Store) LastCommitID() (id types.CommitID) { return } diff --git a/store/reexport.go b/store/reexport.go index 8a365ab758fd..5b101b4ac30f 100644 --- a/store/reexport.go +++ b/store/reexport.go @@ -6,7 +6,6 @@ import ( // Import cosmos-sdk/types/store.go for convenience. type ( - PruningOptions = types.PruningOptions Store = types.Store Committer = types.Committer CommitStore = types.CommitStore diff --git a/store/rootmulti/dbadapter.go b/store/rootmulti/dbadapter.go index 4d6e5afeb875..00ca37553823 100644 --- a/store/rootmulti/dbadapter.go +++ b/store/rootmulti/dbadapter.go @@ -3,6 +3,8 @@ package rootmulti import ( "github.com/cosmos/cosmos-sdk/store/dbadapter" "github.com/cosmos/cosmos-sdk/store/types" + + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" ) var commithash = []byte("FAKE_HASH") @@ -30,8 +32,10 @@ func (cdsa commitDBStoreAdapter) LastCommitID() types.CommitID { } } -func (cdsa commitDBStoreAdapter) SetPruning(_ types.PruningOptions) {} +func (cdsa commitDBStoreAdapter) SetPruning(_ pruningtypes.PruningOptions) {} // GetPruning is a no-op as pruning options cannot be directly set on this store. // They must be set on the root commit multi-store. -func (cdsa commitDBStoreAdapter) GetPruning() types.PruningOptions { return types.PruningOptions{} } +func (cdsa commitDBStoreAdapter) GetPruning() pruningtypes.PruningOptions { + return pruningtypes.NewPruningOptions(pruningtypes.PruningUndefined) +} diff --git a/store/rootmulti/proof_test.go b/store/rootmulti/proof_test.go index 10f8397e7284..d593732d4c66 100644 --- a/store/rootmulti/proof_test.go +++ b/store/rootmulti/proof_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/store/iavl" @@ -57,7 +58,7 @@ func TestVerifyIAVLStoreQueryProof(t *testing.T) { func TestVerifyMultiStoreQueryProof(t *testing.T) { // Create main tree for testing. db := dbm.NewMemDB() - store := NewStore(db) + store := NewStore(db, log.NewNopLogger()) iavlStoreKey := types.NewKVStoreKey("iavlStoreKey") store.MountStoreWithDB(iavlStoreKey, types.StoreTypeIAVL, nil) @@ -112,7 +113,7 @@ func TestVerifyMultiStoreQueryProof(t *testing.T) { func TestVerifyMultiStoreQueryProofAbsence(t *testing.T) { // Create main tree for testing. db := dbm.NewMemDB() - store := NewStore(db) + store := NewStore(db, log.NewNopLogger()) iavlStoreKey := types.NewKVStoreKey("iavlStoreKey") store.MountStoreWithDB(iavlStoreKey, types.StoreTypeIAVL, nil) diff --git a/store/rootmulti/snapshot_test.go b/store/rootmulti/snapshot_test.go index 92e1311fdd81..bad1603da7c9 100644 --- a/store/rootmulti/snapshot_test.go +++ b/store/rootmulti/snapshot_test.go @@ -18,11 +18,12 @@ import ( "github.com/cosmos/cosmos-sdk/store/iavl" "github.com/cosmos/cosmos-sdk/store/rootmulti" "github.com/cosmos/cosmos-sdk/store/types" + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" ) func newMultiStoreWithGeneratedData(db dbm.DB, stores uint8, storeKeys uint64) *rootmulti.Store { - multiStore := rootmulti.NewStore(db) + multiStore := rootmulti.NewStore(db, log.NewNopLogger()) r := rand.New(rand.NewSource(49872768940)) // Fixed seed for deterministic tests keys := []*types.KVStoreKey{} @@ -54,7 +55,7 @@ func newMultiStoreWithGeneratedData(db dbm.DB, stores uint8, storeKeys uint64) * } func newMultiStoreWithMixedMounts(db dbm.DB) *rootmulti.Store { - store := rootmulti.NewStore(db) + store := rootmulti.NewStore(db, log.NewNopLogger()) store.MountStoreWithDB(types.NewKVStoreKey("iavl1"), types.StoreTypeIAVL, nil) store.MountStoreWithDB(types.NewKVStoreKey("iavl2"), types.StoreTypeIAVL, nil) store.MountStoreWithDB(types.NewKVStoreKey("iavl3"), types.StoreTypeIAVL, nil) @@ -234,7 +235,7 @@ func benchmarkMultistoreSnapshot(b *testing.B, stores uint8, storeKeys uint64) { b.StartTimer() for i := 0; i < b.N; i++ { - target := rootmulti.NewStore(dbm.NewMemDB()) + target := rootmulti.NewStore(dbm.NewMemDB(), log.NewNopLogger()) for _, key := range source.StoreKeysByName() { target.MountStoreWithDB(key, types.StoreTypeIAVL, nil) } @@ -269,7 +270,7 @@ func benchmarkMultistoreSnapshotRestore(b *testing.B, stores uint8, storeKeys ui b.StartTimer() for i := 0; i < b.N; i++ { - target := rootmulti.NewStore(dbm.NewMemDB()) + target := rootmulti.NewStore(dbm.NewMemDB(), log.NewNopLogger()) for _, key := range source.StoreKeysByName() { target.MountStoreWithDB(key, types.StoreTypeIAVL, nil) } diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index bd9502187cd5..d31cb2e42b03 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -1,7 +1,6 @@ package rootmulti import ( - "encoding/binary" "fmt" "io" "math" @@ -14,8 +13,11 @@ import ( gogotypes "github.com/gogo/protobuf/types" "github.com/pkg/errors" abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" + "github.com/cosmos/cosmos-sdk/pruning" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store/cachemulti" "github.com/cosmos/cosmos-sdk/store/dbadapter" @@ -30,7 +32,6 @@ import ( const ( latestVersionKey = "s/latest" - pruneHeightsKey = "s/pruneheights" commitInfoKeyFmt = "s/%d" // s/ ) @@ -39,14 +40,14 @@ const ( // the CommitMultiStore interface. type Store struct { db dbm.DB + logger log.Logger lastCommitInfo *types.CommitInfo - pruningOpts types.PruningOptions + pruningManager *pruning.Manager iavlCacheSize int storesParams map[types.StoreKey]storeParams stores map[types.StoreKey]types.CommitKVStore keysByName map[string]types.StoreKey lazyLoading bool - pruneHeights []int64 initialVersion int64 removalMap map[types.StoreKey]bool @@ -68,30 +69,36 @@ var ( // store will be created with a PruneNothing pruning strategy by default. After // a store is created, KVStores must be mounted and finally LoadLatestVersion or // LoadVersion must be called. -func NewStore(db dbm.DB) *Store { +func NewStore(db dbm.DB, logger log.Logger) *Store { return &Store{ - db: db, - pruningOpts: types.PruneNothing, - iavlCacheSize: iavl.DefaultIAVLCacheSize, - storesParams: make(map[types.StoreKey]storeParams), - stores: make(map[types.StoreKey]types.CommitKVStore), - keysByName: make(map[string]types.StoreKey), - pruneHeights: make([]int64, 0), - listeners: make(map[types.StoreKey][]types.WriteListener), - removalMap: make(map[types.StoreKey]bool), + db: db, + logger: logger, + iavlCacheSize: iavl.DefaultIAVLCacheSize, + storesParams: make(map[types.StoreKey]storeParams), + stores: make(map[types.StoreKey]types.CommitKVStore), + keysByName: make(map[string]types.StoreKey), + listeners: make(map[types.StoreKey][]types.WriteListener), + removalMap: make(map[types.StoreKey]bool), + pruningManager: pruning.NewManager(db, logger), } } // GetPruning fetches the pruning strategy from the root store. -func (rs *Store) GetPruning() types.PruningOptions { - return rs.pruningOpts +func (rs *Store) GetPruning() pruningtypes.PruningOptions { + return rs.pruningManager.GetOptions() } // SetPruning sets the pruning strategy on the root store and all the sub-stores. // Note, calling SetPruning on the root store prior to LoadVersion or // LoadLatestVersion performs a no-op as the stores aren't mounted yet. -func (rs *Store) SetPruning(pruningOpts types.PruningOptions) { - rs.pruningOpts = pruningOpts +func (rs *Store) SetPruning(pruningOpts pruningtypes.PruningOptions) { + rs.pruningManager.SetOptions(pruningOpts) +} + +// SetSnapshotInterval sets the interval at which the snapshots are taken. +// It is used by the store to determine which heights to retain until after the snapshot is complete. +func (rs *Store) SetSnapshotInterval(snapshotInterval uint64) { + rs.pruningManager.SetSnapshotInterval(snapshotInterval) } func (rs *Store) SetIAVLCacheSize(cacheSize int) { @@ -195,7 +202,7 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error { } // load each Store (note this doesn't panic on unmounted keys now) - var newStores = make(map[types.StoreKey]types.CommitKVStore) + newStores := make(map[types.StoreKey]types.CommitKVStore) storesKeys := make([]types.StoreKey, 0, len(rs.storesParams)) @@ -262,9 +269,8 @@ func (rs *Store) loadVersion(ver int64, upgrades *types.StoreUpgrades) error { rs.stores = newStores // load any pruned heights we missed from disk to be pruned on the next run - ph, err := getPruningHeights(rs.db) - if err == nil && len(ph) > 0 { - rs.pruneHeights = ph + if err := rs.pruningManager.LoadPruningHeights(rs.db); err != nil { + return err } return nil @@ -309,6 +315,14 @@ func moveKVStoreData(oldDB types.KVStore, newDB types.KVStore) error { return deleteKVStore(oldDB) } +// PruneSnapshotHeight prunes the given height according to the prune strategy. +// If PruneNothing, this is a no-op. +// If other strategy, this height is persisted until it is +// less than - KeepRecent and % Interval == 0 +func (rs *Store) PruneSnapshotHeight(height int64) { + rs.pruningManager.HandleHeightSnapshot(height) +} + // SetInterBlockCache sets the Store's internal inter-block (persistent) cache. // When this is defined, all CommitKVStores will be wrapped with their respective // inter-block cache. @@ -330,13 +344,7 @@ func (rs *Store) SetTracer(w io.Writer) types.MultiStore { func (rs *Store) SetTracingContext(tc types.TraceContext) types.MultiStore { rs.traceContextMutex.Lock() defer rs.traceContextMutex.Unlock() - if rs.traceContext != nil { - for k, v := range tc { - rs.traceContext[k] = v - } - } else { - rs.traceContext = tc - } + rs.traceContext = rs.traceContext.Merge(tc) return rs } @@ -397,7 +405,6 @@ func (rs *Store) Commit() types.CommitID { // This case means that no commit has been made in the store, we // start from initialVersion. version = rs.initialVersion - } else { // This case can means two things: // - either there was already a previous commit in the store, in which @@ -409,6 +416,7 @@ func (rs *Store) Commit() types.CommitID { } rs.lastCommitInfo = commitStores(version, rs.stores, rs.removalMap) + defer rs.flushMetadata(rs.db, version, rs.lastCommitInfo) // remove remnants of removed stores for sk := range rs.removalMap { @@ -418,54 +426,19 @@ func (rs *Store) Commit() types.CommitID { delete(rs.keysByName, sk.Name()) } } - // reset the removalMap rs.removalMap = make(map[types.StoreKey]bool) - // Determine if pruneHeight height needs to be added to the list of heights to - // be pruned, where pruneHeight = (commitHeight - 1) - KeepRecent. - if rs.pruningOpts.Interval > 0 && int64(rs.pruningOpts.KeepRecent) < previousHeight { - pruneHeight := previousHeight - int64(rs.pruningOpts.KeepRecent) - rs.pruneHeights = append(rs.pruneHeights, pruneHeight) - } - - // batch prune if the current height is a pruning interval height - if rs.pruningOpts.Interval > 0 && version%int64(rs.pruningOpts.Interval) == 0 { - rs.pruneStores() + if err := rs.handlePruning(version); err != nil { + panic(err) } - flushMetadata(rs.db, version, rs.lastCommitInfo, rs.pruneHeights) - return types.CommitID{ Version: version, Hash: rs.lastCommitInfo.Hash(), } } -// pruneStores will batch delete a list of heights from each mounted sub-store. -// Afterwards, pruneHeights is reset. -func (rs *Store) pruneStores() { - if len(rs.pruneHeights) == 0 { - return - } - - for key, store := range rs.stores { - if store.GetStoreType() == types.StoreTypeIAVL { - // If the store is wrapped with an inter-block cache, we must first unwrap - // it to get the underlying IAVL store. - store = rs.GetCommitKVStore(key) - - if err := store.(*iavl.Store).DeleteVersions(rs.pruneHeights...); err != nil { - if errCause := errors.Cause(err); errCause != nil && errCause != iavltree.ErrVersionDoesNotExist { - panic(err) - } - } - } - } - - rs.pruneHeights = make([]int64, 0) -} - // CacheWrap implements CacheWrapper/Store/CommitStore. func (rs *Store) CacheWrap() types.CacheWrap { return rs.CacheMultiStore().(types.CacheWrap) @@ -559,7 +532,51 @@ func (rs *Store) GetKVStore(key types.StoreKey) types.KVStore { return store } -// GetStoreByName performs a lookup of a StoreKey given a store name typically +func (rs *Store) handlePruning(version int64) error { + rs.pruningManager.HandleHeight(version - 1) // we should never prune the current version. + if !rs.pruningManager.ShouldPruneAtHeight(version) { + return nil + } + rs.logger.Info("prune start", "height", version) + defer rs.logger.Info("prune end", "height", version) + return rs.pruneStores() +} + +func (rs *Store) pruneStores() error { + pruningHeights, err := rs.pruningManager.GetFlushAndResetPruningHeights() + if err != nil { + return err + } + + if len(pruningHeights) == 0 { + rs.logger.Debug("pruning skipped; no heights to prune") + return nil + } + + rs.logger.Debug("pruning heights", "heights", pruningHeights) + + for key, store := range rs.stores { + // If the store is wrapped with an inter-block cache, we must first unwrap + // it to get the underlying IAVL store. + if store.GetStoreType() != types.StoreTypeIAVL { + continue + } + + store = rs.GetCommitKVStore(key) + + err := store.(*iavl.Store).DeleteVersions(pruningHeights...) + if err == nil { + continue + } + + if errCause := errors.Cause(err); errCause != nil && errCause != iavltree.ErrVersionDoesNotExist { + return err + } + } + return nil +} + +// 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. @@ -672,7 +689,7 @@ func (rs *Store) Snapshot(height uint64, protoWriter protoio.Writer) error { if height == 0 { return sdkerrors.Wrap(sdkerrors.ErrLogic, "cannot snapshot height 0") } - if height > uint64(rs.LastCommitID().Version) { + if height > uint64(getLatestVersion(rs.db)) { return sdkerrors.Wrapf(sdkerrors.ErrLogic, "cannot snapshot future height %v", height) } @@ -825,7 +842,7 @@ loop: importer.Close() } - flushMetadata(rs.db, int64(height), rs.buildCommitInfo(int64(height)), []int64{}) + rs.flushMetadata(rs.db, int64(height), rs.buildCommitInfo(int64(height))) return snapshotItem, rs.LoadLatestVersion() } @@ -916,9 +933,11 @@ func (rs *Store) RollbackToVersion(target int64) int64 { return current } for ; current > target; current-- { - rs.pruneHeights = append(rs.pruneHeights, current) + rs.pruningManager.HandleHeight(current) + } + if err := rs.pruneStores(); err != nil { + panic(err) } - rs.pruneStores() // update latest height bz, err := gogotypes.StdInt64Marshal(current) @@ -930,6 +949,25 @@ func (rs *Store) RollbackToVersion(target int64) int64 { return current } +func (rs *Store) flushMetadata(db dbm.DB, version int64, cInfo *types.CommitInfo) { + rs.logger.Debug("flushing metadata", "height", version) + batch := db.NewBatch() + defer batch.Close() + + if cInfo != nil { + flushCommitInfo(batch, version, cInfo) + } else { + rs.logger.Debug("commitInfo is nil, not flushed", "height", version) + } + + flushLatestVersion(batch, version) + + if err := batch.WriteSync(); err != nil { + panic(fmt.Errorf("error on batch write %w", err)) + } + rs.logger.Debug("flushing metadata finished", "height", version) +} + type storeParams struct { key types.StoreKey db dbm.DB @@ -973,6 +1011,10 @@ func commitStores(version int64, storeMap map[types.StoreKey]types.CommitKVStore } } + sort.SliceStable(storeInfos, func(i, j int) bool { + return strings.Compare(storeInfos[i].Name, storeInfos[j].Name) < 0 + }) + return &types.CommitInfo{ Version: version, StoreInfos: storeInfos, @@ -998,7 +1040,7 @@ func getCommitInfo(db dbm.DB, ver int64) (*types.CommitInfo, error) { return cInfo, nil } -func setCommitInfo(batch dbm.Batch, version int64, cInfo *types.CommitInfo) { +func flushCommitInfo(batch dbm.Batch, version int64, cInfo *types.CommitInfo) { bz, err := cInfo.Marshal() if err != nil { panic(err) @@ -1008,7 +1050,7 @@ func setCommitInfo(batch dbm.Batch, version int64, cInfo *types.CommitInfo) { batch.Set([]byte(cInfoKey), bz) } -func setLatestVersion(batch dbm.Batch, version int64) { +func flushLatestVersion(batch dbm.Batch, version int64) { bz, err := gogotypes.StdInt64Marshal(version) if err != nil { panic(err) @@ -1016,47 +1058,3 @@ func setLatestVersion(batch dbm.Batch, version int64) { batch.Set([]byte(latestVersionKey), bz) } - -func setPruningHeights(batch dbm.Batch, pruneHeights []int64) { - bz := make([]byte, 0) - for _, ph := range pruneHeights { - buf := make([]byte, 8) - binary.BigEndian.PutUint64(buf, uint64(ph)) - bz = append(bz, buf...) - } - - batch.Set([]byte(pruneHeightsKey), bz) -} - -func getPruningHeights(db dbm.DB) ([]int64, error) { - bz, err := db.Get([]byte(pruneHeightsKey)) - if err != nil { - return nil, fmt.Errorf("failed to get pruned heights: %w", err) - } - if len(bz) == 0 { - return nil, errors.New("no pruned heights found") - } - - prunedHeights := make([]int64, len(bz)/8) - i, offset := 0, 0 - for offset < len(bz) { - prunedHeights[i] = int64(binary.BigEndian.Uint64(bz[offset : offset+8])) - i++ - offset += 8 - } - - return prunedHeights, nil -} - -func flushMetadata(db dbm.DB, version int64, cInfo *types.CommitInfo, pruneHeights []int64) { - batch := db.NewBatch() - defer batch.Close() - - setCommitInfo(batch, version, cInfo) - setLatestVersion(batch, version) - setPruningHeights(batch, pruneHeights) - - if err := batch.Write(); err != nil { - panic(fmt.Errorf("error on batch write %w", err)) - } -} diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index 80cbcf68cbd0..ccd58b153feb 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -8,10 +8,12 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/codec" codecTypes "github.com/cosmos/cosmos-sdk/codec/types" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/store/cachemulti" "github.com/cosmos/cosmos-sdk/store/iavl" sdkmaps "github.com/cosmos/cosmos-sdk/store/internal/maps" @@ -22,13 +24,13 @@ import ( func TestStoreType(t *testing.T) { db := dbm.NewMemDB() - store := NewStore(db) + store := NewStore(db, log.NewNopLogger()) store.MountStoreWithDB(types.NewKVStoreKey("store1"), types.StoreTypeIAVL, db) } func TestGetCommitKVStore(t *testing.T) { var db dbm.DB = dbm.NewMemDB() - ms := newMultiStoreWithMounts(db, types.PruneDefault) + ms := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningDefault)) err := ms.LoadLatestVersion() require.Nil(t, err) @@ -45,7 +47,7 @@ func TestGetCommitKVStore(t *testing.T) { func TestStoreMount(t *testing.T) { db := dbm.NewMemDB() - store := NewStore(db) + store := NewStore(db, log.NewNopLogger()) key1 := types.NewKVStoreKey("store1") key2 := types.NewKVStoreKey("store2") @@ -61,7 +63,7 @@ func TestStoreMount(t *testing.T) { func TestCacheMultiStore(t *testing.T) { var db dbm.DB = dbm.NewMemDB() - ms := newMultiStoreWithMounts(db, types.PruneNothing) + ms := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) cacheMulti := ms.CacheMultiStore() require.IsType(t, cachemulti.Store{}, cacheMulti) @@ -69,7 +71,7 @@ func TestCacheMultiStore(t *testing.T) { func TestCacheMultiStoreWithVersion(t *testing.T) { var db dbm.DB = dbm.NewMemDB() - ms := newMultiStoreWithMounts(db, types.PruneNothing) + ms := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err := ms.LoadLatestVersion() require.Nil(t, err) @@ -106,7 +108,7 @@ func TestCacheMultiStoreWithVersion(t *testing.T) { func TestHashStableWithEmptyCommit(t *testing.T) { var db dbm.DB = dbm.NewMemDB() - ms := newMultiStoreWithMounts(db, types.PruneNothing) + ms := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err := ms.LoadLatestVersion() require.Nil(t, err) @@ -130,7 +132,7 @@ func TestHashStableWithEmptyCommit(t *testing.T) { func TestMultistoreCommitLoad(t *testing.T) { var db dbm.DB = dbm.NewMemDB() - store := newMultiStoreWithMounts(db, types.PruneNothing) + store := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err := store.LoadLatestVersion() require.Nil(t, err) @@ -155,7 +157,7 @@ func TestMultistoreCommitLoad(t *testing.T) { } // Load the latest multistore again and check version. - store = newMultiStoreWithMounts(db, types.PruneNothing) + store = newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err = store.LoadLatestVersion() require.Nil(t, err) commitID = getExpectedCommitID(store, nCommits) @@ -168,7 +170,7 @@ func TestMultistoreCommitLoad(t *testing.T) { // Load an older multistore and check version. ver := nCommits - 1 - store = newMultiStoreWithMounts(db, types.PruneNothing) + store = newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err = store.LoadVersion(ver) require.Nil(t, err) commitID = getExpectedCommitID(store, ver) @@ -177,7 +179,7 @@ func TestMultistoreCommitLoad(t *testing.T) { func TestMultistoreLoadWithUpgrade(t *testing.T) { var db dbm.DB = dbm.NewMemDB() - store := newMultiStoreWithMounts(db, types.PruneNothing) + store := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err := store.LoadLatestVersion() require.Nil(t, err) @@ -212,7 +214,7 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { checkContains(t, ci.StoreInfos, []string{"store1", "store2", "store3"}) // Load without changes and make sure it is sensible - store = newMultiStoreWithMounts(db, types.PruneNothing) + store = newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err = store.LoadLatestVersion() require.Nil(t, err) @@ -225,7 +227,7 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { require.Equal(t, v2, s2.Get(k2)) // now, let's load with upgrades... - restore, upgrades := newMultiStoreWithModifiedMounts(db, types.PruneNothing) + restore, upgrades := newMultiStoreWithModifiedMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err = restore.LoadLatestVersionAndUpgrade(upgrades) require.Nil(t, err) @@ -270,7 +272,7 @@ func TestMultistoreLoadWithUpgrade(t *testing.T) { migratedID := restore.Commit() require.Equal(t, migratedID.Version, int64(2)) - reload, _ := newMultiStoreWithModifiedMounts(db, types.PruneNothing) + reload, _ := newMultiStoreWithModifiedMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err = reload.LoadLatestVersion() require.Nil(t, err) require.Equal(t, migratedID, reload.LastCommitID()) @@ -314,15 +316,11 @@ func TestParsePath(t *testing.T) { require.NoError(t, err) require.Equal(t, substore, "bang") require.Equal(t, subsubpath, "/baz") - } func TestMultiStoreRestart(t *testing.T) { db := dbm.NewMemDB() - pruning := types.PruningOptions{ - KeepRecent: 2, - Interval: 1, - } + pruning := pruningtypes.NewCustomPruningOptions(2, 1) multi := newMultiStoreWithMounts(db, pruning) err := multi.LoadLatestVersion() require.Nil(t, err) @@ -401,7 +399,7 @@ func TestMultiStoreRestart(t *testing.T) { func TestMultiStoreQuery(t *testing.T) { db := dbm.NewMemDB() - multi := newMultiStoreWithMounts(db, types.PruneNothing) + multi := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err := multi.LoadLatestVersion() require.Nil(t, err) @@ -428,7 +426,7 @@ func TestMultiStoreQuery(t *testing.T) { ver := cid.Version // Reload multistore from database - multi = newMultiStoreWithMounts(db, types.PruneNothing) + multi = newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err = multi.LoadLatestVersion() require.Nil(t, err) @@ -473,15 +471,15 @@ func TestMultiStore_Pruning(t *testing.T) { testCases := []struct { name string numVersions int64 - po types.PruningOptions + po pruningtypes.PruningOptions deleted []int64 saved []int64 }{ - {"prune nothing", 10, types.PruneNothing, nil, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}, - {"prune everything", 10, types.PruneEverything, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9}, []int64{10}}, - {"prune some; no batch", 10, types.NewPruningOptions(2, 1), []int64{1, 2, 4, 5, 7}, []int64{3, 6, 8, 9, 10}}, - {"prune some; small batch", 10, types.NewPruningOptions(2, 3), []int64{1, 2, 4, 5}, []int64{3, 6, 7, 8, 9, 10}}, - {"prune some; large batch", 10, types.NewPruningOptions(2, 11), nil, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}, + {"prune nothing", 10, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), nil, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}, + {"prune everything", 10, pruningtypes.NewPruningOptions(pruningtypes.PruningEverything), []int64{1, 2, 3, 4, 5, 6, 7, 8, 9}, []int64{10}}, + {"prune some; no batch", 10, pruningtypes.NewCustomPruningOptions(2, 1), []int64{1, 2, 4, 5, 7}, []int64{3, 6, 8, 9, 10}}, + {"prune some; small batch", 10, pruningtypes.NewCustomPruningOptions(2, 3), []int64{1, 2, 4, 5}, []int64{3, 6, 7, 8, 9, 10}}, + {"prune some; large batch", 10, pruningtypes.NewCustomPruningOptions(2, 11), nil, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}, } for _, tc := range testCases { @@ -509,9 +507,64 @@ func TestMultiStore_Pruning(t *testing.T) { } } +func TestMultiStore_Pruning_SameHeightsTwice(t *testing.T) { + const ( + numVersions int64 = 10 + keepRecent uint64 = 2 + interval uint64 = 10 + ) + + expectedHeights := []int64{} + for i := int64(1); i < numVersions-int64(keepRecent); i++ { + expectedHeights = append(expectedHeights, i) + } + + db := dbm.NewMemDB() + + ms := newMultiStoreWithMounts(db, pruningtypes.NewCustomPruningOptions(keepRecent, interval)) + require.NoError(t, ms.LoadLatestVersion()) + + var lastCommitInfo types.CommitID + for i := int64(0); i < numVersions; i++ { + lastCommitInfo = ms.Commit() + } + + require.Equal(t, numVersions, lastCommitInfo.Version) + + for v := int64(1); v < numVersions-int64(keepRecent); v++ { + err := ms.LoadVersion(v) + require.Error(t, err, "expected error when loading pruned height: %d", v) + } + + for v := int64(numVersions - int64(keepRecent)); v < numVersions; v++ { + err := ms.LoadVersion(v) + require.NoError(t, err, "expected no error when loading height: %d", v) + } + + // Get latest + err := ms.LoadVersion(numVersions - 1) + require.NoError(t, err) + + // Ensure already pruned heights were loaded + heights, err := ms.pruningManager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, expectedHeights, heights) + + require.NoError(t, ms.pruningManager.LoadPruningHeights(db)) + + // Test pruning the same heights again + lastCommitInfo = ms.Commit() + require.Equal(t, numVersions, lastCommitInfo.Version) + + // Ensure that can commit one more height with no panic + lastCommitInfo = ms.Commit() + require.Equal(t, numVersions+1, lastCommitInfo.Version) +} + func TestMultiStore_PruningRestart(t *testing.T) { db := dbm.NewMemDB() - ms := newMultiStoreWithMounts(db, types.NewPruningOptions(2, 11)) + ms := newMultiStoreWithMounts(db, pruningtypes.NewCustomPruningOptions(2, 11)) + ms.SetSnapshotInterval(3) require.NoError(t, ms.LoadLatestVersion()) // Commit enough to build up heights to prune, where on the next block we should @@ -523,19 +576,30 @@ func TestMultiStore_PruningRestart(t *testing.T) { pruneHeights := []int64{1, 2, 4, 5, 7} // ensure we've persisted the current batch of heights to prune to the store's DB - ph, err := getPruningHeights(ms.db) + err := ms.pruningManager.LoadPruningHeights(ms.db) + require.NoError(t, err) + + actualHeightsToPrune, err := ms.pruningManager.GetFlushAndResetPruningHeights() require.NoError(t, err) - require.Equal(t, []int64{1, 2, 3, 4, 5, 6, 7}, ph) + require.Equal(t, len(pruneHeights), len(actualHeightsToPrune)) + require.Equal(t, pruneHeights, actualHeightsToPrune) // "restart" - ms = newMultiStoreWithMounts(db, types.NewPruningOptions(2, 11)) + ms = newMultiStoreWithMounts(db, pruningtypes.NewCustomPruningOptions(2, 11)) + ms.SetSnapshotInterval(3) err = ms.LoadLatestVersion() require.NoError(t, err) - require.Equal(t, []int64{1, 2, 3, 4, 5, 6, 7}, ms.pruneHeights) + + actualHeightsToPrune, err = ms.pruningManager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Equal(t, pruneHeights, actualHeightsToPrune) // commit one more block and ensure the heights have been pruned ms.Commit() - require.Empty(t, ms.pruneHeights) + + actualHeightsToPrune, err = ms.pruningManager.GetFlushAndResetPruningHeights() + require.NoError(t, err) + require.Empty(t, actualHeightsToPrune) for _, v := range pruneHeights { _, err := ms.CacheMultiStoreWithVersion(v) @@ -545,7 +609,7 @@ func TestMultiStore_PruningRestart(t *testing.T) { func TestSetInitialVersion(t *testing.T) { db := dbm.NewMemDB() - multi := newMultiStoreWithMounts(db, types.PruneNothing) + multi := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) require.NoError(t, multi.LoadLatestVersion()) @@ -563,7 +627,7 @@ func TestSetInitialVersion(t *testing.T) { func TestAddListenersAndListeningEnabled(t *testing.T) { db := dbm.NewMemDB() - multi := newMultiStoreWithMounts(db, types.PruneNothing) + multi := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) testKey := types.NewKVStoreKey("listening_test_key") enabled := multi.ListeningEnabled(testKey) require.False(t, enabled) @@ -594,7 +658,7 @@ var ( func TestGetListenWrappedKVStore(t *testing.T) { buf := new(bytes.Buffer) var db dbm.DB = dbm.NewMemDB() - ms := newMultiStoreWithMounts(db, types.PruneNothing) + ms := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) ms.LoadLatestVersion() mockListeners := []types.WriteListener{types.NewStoreKVPairWriteListener(buf, testMarshaller)} ms.AddListeners(testStoreKey1, mockListeners) @@ -637,6 +701,7 @@ func TestGetListenWrappedKVStore(t *testing.T) { StoreKey: testStoreKey2.Name(), Delete: false, }) + require.NoError(t, err) kvPairSet2Bytes := buf.Bytes() buf.Reset() require.Equal(t, expectedOutputKVPairSet2, kvPairSet2Bytes) @@ -648,6 +713,7 @@ func TestGetListenWrappedKVStore(t *testing.T) { StoreKey: testStoreKey2.Name(), Delete: true, }) + require.NoError(t, err) kvPairDelete2Bytes := buf.Bytes() buf.Reset() require.Equal(t, expectedOutputKVPairDelete2, kvPairDelete2Bytes) @@ -668,7 +734,7 @@ func TestGetListenWrappedKVStore(t *testing.T) { func TestCacheWraps(t *testing.T) { db := dbm.NewMemDB() - multi := newMultiStoreWithMounts(db, types.PruneNothing) + multi := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) cacheWrapper := multi.CacheWrap() require.IsType(t, cachemulti.Store{}, cacheWrapper) @@ -682,7 +748,7 @@ func TestCacheWraps(t *testing.T) { func TestTraceConcurrency(t *testing.T) { db := dbm.NewMemDB() - multi := newMultiStoreWithMounts(db, types.PruneNothing) + multi := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) err := multi.LoadLatestVersion() require.NoError(t, err) @@ -730,6 +796,40 @@ func TestTraceConcurrency(t *testing.T) { stopW <- struct{}{} } +func TestCommitOrdered(t *testing.T) { + var db dbm.DB = dbm.NewMemDB() + multi := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) + err := multi.LoadLatestVersion() + require.Nil(t, err) + + commitID := types.CommitID{} + checkStore(t, multi, commitID, commitID) + + k, v := []byte("wind"), []byte("blows") + k2, v2 := []byte("water"), []byte("flows") + k3, v3 := []byte("fire"), []byte("burns") + + store1 := multi.GetStoreByName("store1").(types.KVStore) + store1.Set(k, v) + + store2 := multi.GetStoreByName("store2").(types.KVStore) + store2.Set(k2, v2) + + store3 := multi.GetStoreByName("store3").(types.KVStore) + store3.Set(k3, v3) + + typeID := multi.Commit() + require.Equal(t, int64(1), typeID.Version) + + ci, err := getCommitInfo(db, 1) + require.NoError(t, err) + require.Equal(t, int64(1), ci.Version) + require.Equal(t, 3, len(ci.StoreInfos)) + for i, s := range ci.StoreInfos { + require.Equal(t, s.Name, fmt.Sprintf("store%d", i+1)) + } +} + //----------------------------------------------------------------------- // utils @@ -739,9 +839,9 @@ var ( testStoreKey3 = types.NewKVStoreKey("store3") ) -func newMultiStoreWithMounts(db dbm.DB, pruningOpts types.PruningOptions) *Store { - store := NewStore(db) - store.pruningOpts = pruningOpts +func newMultiStoreWithMounts(db dbm.DB, pruningOpts pruningtypes.PruningOptions) *Store { + store := NewStore(db, log.NewNopLogger()) + store.SetPruning(pruningOpts) store.MountStoreWithDB(testStoreKey1, types.StoreTypeIAVL, nil) store.MountStoreWithDB(testStoreKey2, types.StoreTypeIAVL, nil) @@ -750,9 +850,9 @@ func newMultiStoreWithMounts(db dbm.DB, pruningOpts types.PruningOptions) *Store return store } -func newMultiStoreWithModifiedMounts(db dbm.DB, pruningOpts types.PruningOptions) (*Store, *types.StoreUpgrades) { - store := NewStore(db) - store.pruningOpts = pruningOpts +func newMultiStoreWithModifiedMounts(db dbm.DB, pruningOpts pruningtypes.PruningOptions) (*Store, *types.StoreUpgrades) { + store := NewStore(db, log.NewNopLogger()) + store.SetPruning(pruningOpts) store.MountStoreWithDB(types.NewKVStoreKey("store1"), types.StoreTypeIAVL, nil) store.MountStoreWithDB(types.NewKVStoreKey("restore2"), types.StoreTypeIAVL, nil) diff --git a/store/store.go b/store/store.go index 2c068c413f47..492bd4fee1dc 100644 --- a/store/store.go +++ b/store/store.go @@ -1,6 +1,7 @@ package store import ( + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/store/cache" @@ -9,7 +10,7 @@ import ( ) func NewCommitMultiStore(db dbm.DB) types.CommitMultiStore { - return rootmulti.NewStore(db) + return rootmulti.NewStore(db, log.NewNopLogger()) } func NewCommitKVStoreCacheManager() types.MultiStorePersistentCache { diff --git a/store/streaming/constructor_test.go b/store/streaming/constructor_test.go index 5f9d58016f68..e4955a9ceb06 100644 --- a/store/streaming/constructor_test.go +++ b/store/streaming/constructor_test.go @@ -1,14 +1,21 @@ -package streaming +package streaming_test import ( "testing" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" codecTypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/db/memdb" + serverTypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/store/streaming" "github.com/cosmos/cosmos-sdk/store/streaming/file" "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/libs/log" + "github.com/stretchr/testify/require" ) @@ -24,12 +31,12 @@ var ( ) func TestStreamingServiceConstructor(t *testing.T) { - _, err := NewServiceConstructor("unexpectedName") + _, err := streaming.NewServiceConstructor("unexpectedName") require.NotNil(t, err) - constructor, err := NewServiceConstructor("file") + constructor, err := streaming.NewServiceConstructor("file") require.Nil(t, err) - var expectedType ServiceConstructor + var expectedType streaming.ServiceConstructor require.IsType(t, expectedType, constructor) serv, err := constructor(mockOptions, mockKeys, testMarshaller) @@ -41,3 +48,54 @@ func TestStreamingServiceConstructor(t *testing.T) { require.True(t, ok) } } + +func TestLoadStreamingServices(t *testing.T) { + db := memdb.NewDB() + encCdc := simapp.MakeTestEncodingConfig() + keys := sdk.NewKVStoreKeys("mockKey1", "mockKey2") + bApp := baseapp.NewBaseApp("appName", log.NewNopLogger(), db, nil) + + testCases := map[string]struct { + appOpts serverTypes.AppOptions + activeStreamersLen int + }{ + "empty app options": { + appOpts: simapp.EmptyAppOptions{}, + }, + "all StoreKeys exposed": { + appOpts: streamingAppOptions{keys: []string{"*"}}, + activeStreamersLen: 1, + }, + "some StoreKey exposed": { + appOpts: streamingAppOptions{keys: []string{"mockKey1"}}, + activeStreamersLen: 1, + }, + "not exposing anything": { + appOpts: streamingAppOptions{keys: []string{"mockKey3"}}, + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + activeStreamers, _, err := streaming.LoadStreamingServices(bApp, tc.appOpts, encCdc.Codec, keys) + require.NoError(t, err) + require.Equal(t, tc.activeStreamersLen, len(activeStreamers)) + }) + } + +} + +type streamingAppOptions struct { + keys []string +} + +func (ao streamingAppOptions) Get(o string) interface{} { + switch o { + case "store.streamers": + return []string{"file"} + case "streamers.file.keys": + return ao.keys + default: + return nil + } +} diff --git a/store/streaming/file/service.go b/store/streaming/file/service.go index 02feb403e99b..28e77a52fa39 100644 --- a/store/streaming/file/service.go +++ b/store/streaming/file/service.go @@ -39,7 +39,7 @@ type IntermediateWriter struct { outChan chan<- []byte } -// NewIntermediateWriter create an instance of an intermediateWriter that sends to the provided channel +// NewIntermediateWriter create an instance of an IntermediateWriter that sends to the provided channel func NewIntermediateWriter(outChan chan<- []byte) *IntermediateWriter { return &IntermediateWriter{ outChan: outChan, @@ -62,7 +62,7 @@ func NewStreamingService(writeDir, filePrefix string, storeKeys []types.StoreKey for _, key := range storeKeys { listeners[key] = append(listeners[key], listener) } - // check that the writeDir exists and is writeable so that we can catch the error here at initialization if it is not + // check that the writeDir exists and is writable so that we can catch the error here at initialization if it is not // we don't open a dstFile until we receive our first ABCI message if err := isDirWriteable(writeDir); err != nil { return nil, err @@ -133,7 +133,7 @@ func (fss *StreamingService) openBeginBlockFile(req abci.RequestBeginBlock) (*os if fss.filePrefix != "" { fileName = fmt.Sprintf("%s-%s", fss.filePrefix, fileName) } - return os.OpenFile(filepath.Join(fss.writeDir, fileName), os.O_CREATE|os.O_WRONLY, 0600) + return os.OpenFile(filepath.Join(fss.writeDir, fileName), os.O_CREATE|os.O_WRONLY, 0o600) } // ListenDeliverTx satisfies the baseapp.ABCIListener interface @@ -183,7 +183,7 @@ func (fss *StreamingService) openDeliverTxFile() (*os.File, error) { fileName = fmt.Sprintf("%s-%s", fss.filePrefix, fileName) } fss.currentTxIndex++ - return os.OpenFile(filepath.Join(fss.writeDir, fileName), os.O_CREATE|os.O_WRONLY, 0600) + return os.OpenFile(filepath.Join(fss.writeDir, fileName), os.O_CREATE|os.O_WRONLY, 0o600) } // ListenEndBlock satisfies the baseapp.ABCIListener interface @@ -232,7 +232,7 @@ func (fss *StreamingService) openEndBlockFile() (*os.File, error) { if fss.filePrefix != "" { fileName = fmt.Sprintf("%s-%s", fss.filePrefix, fileName) } - return os.OpenFile(filepath.Join(fss.writeDir, fileName), os.O_CREATE|os.O_WRONLY, 0600) + return os.OpenFile(filepath.Join(fss.writeDir, fileName), os.O_CREATE|os.O_WRONLY, 0o600) } // Stream satisfies the baseapp.StreamingService interface @@ -272,7 +272,7 @@ func (fss *StreamingService) Close() error { // to dir. It returns nil if dir is writable. func isDirWriteable(dir string) error { f := path.Join(dir, ".touch") - if err := ioutil.WriteFile(f, []byte(""), 0600); err != nil { + if err := ioutil.WriteFile(f, []byte(""), 0o600); err != nil { return err } return os.Remove(f) diff --git a/store/streaming/file/service_test.go b/store/streaming/file/service_test.go index 1276b163642d..cc9fdca88136 100644 --- a/store/streaming/file/service_test.go +++ b/store/streaming/file/service_test.go @@ -128,7 +128,7 @@ func TestFileStreamingService(t *testing.T) { if os.Getenv("CI") != "" { t.Skip("Skipping TestFileStreamingService in CI environment") } - err := os.Mkdir(testDir, 0700) + err := os.Mkdir(testDir, 0o700) require.Nil(t, err) defer os.RemoveAll(testDir) @@ -372,7 +372,7 @@ func readInFile(name string) ([]byte, error) { return ioutil.ReadFile(path) } -// Returns all of the protobuf messages contained in the byte array as an array of byte arrays +// segmentBytes returns all of the protobuf messages contained in the byte array as an array of byte arrays // The messages have their length prefix removed func segmentBytes(bz []byte) ([][]byte, error) { var err error @@ -388,7 +388,7 @@ func segmentBytes(bz []byte) ([][]byte, error) { return segments, nil } -// Returns the bytes for the leading protobuf object in the byte array (removing the length prefix) and returns the remainder of the byte array +// getHeadSegment returns the bytes for the leading protobuf object in the byte array (removing the length prefix) and returns the remainder of the byte array func getHeadSegment(bz []byte) ([]byte, []byte, error) { size, prefixSize := binary.Uvarint(bz) if prefixSize < 0 { diff --git a/store/tools/ics23/go.mod b/store/tools/ics23/go.mod index 5d82c0ef4d36..d03e1523aebf 100644 --- a/store/tools/ics23/go.mod +++ b/store/tools/ics23/go.mod @@ -1,6 +1,6 @@ module github.com/cosmos/cosmos-sdk/store/tools/ics23 -go 1.17 +go 1.18 require ( github.com/confio/ics23/go v0.6.7-0.20220201201850-606d5105384e diff --git a/store/tools/ics23/iavl/README.md b/store/tools/ics23/iavl/README.md index 45f2e81a5e83..756f04871079 100644 --- a/store/tools/ics23/iavl/README.md +++ b/store/tools/ics23/iavl/README.md @@ -13,7 +13,7 @@ current value). This returns an error if the key does not exist in the tree. `func CreateNonMembershipProof(tree *iavl.MutableTree, key []byte) (*proofs.CommitmentProof, error)` produces a CommitmentProof that the given key doesn't exist in the iavl tree. -This returns an error if the key does not exist in the tree. +This returns an error if the key exists in the tree. Generalized range proofs are lower in priority, as they are just an optimization of the two basic proof types, and don't provide any additional capabilities. diff --git a/store/tools/ics23/iavl/helpers/helpers.go b/store/tools/ics23/iavl/helpers/helpers.go index c39da851c651..26f1f09dcfc9 100644 --- a/store/tools/ics23/iavl/helpers/helpers.go +++ b/store/tools/ics23/iavl/helpers/helpers.go @@ -1,7 +1,7 @@ /* Package helpers contains functions to build sample data for tests/testgen -In it's own package to avoid poluting the godoc for ics23-iavl +In it's own package to avoid polluting the godoc for ics23-iavl */ package helpers @@ -56,7 +56,7 @@ func GenerateIavlResult(size int, loc tmproofs.Where) (*IavlResult, error) { return res, nil } -// GetKey this returns a key, on Left/Right/Middle +// GetKey returns a key, on Left/Right/Middle func GetKey(allkeys [][]byte, loc tmproofs.Where) []byte { if loc == tmproofs.Left { return allkeys[0] diff --git a/store/tools/ics23/smt/README.md b/store/tools/ics23/smt/README.md index 0e65e87e2249..82c06eddcbf1 100644 --- a/store/tools/ics23/smt/README.md +++ b/store/tools/ics23/smt/README.md @@ -10,7 +10,7 @@ It exposes a two main functions : produces a CommitmentProof that the given key exists in the SMT (and contains the current value). This returns an error if the key does not exist in the tree. `func CreateNonMembershipProof(tree *smt.SparseMerkleTree, key []byte, preimages PreimageMap) (*ics23.CommitmentProof, error)` -produces a CommitmentProof that the given key doesn't exist in the SMT. This returns an error if the key does not exist in the tree. +produces a CommitmentProof that the given key doesn't exist in the SMT. This returns an error if the key exists in the tree. This relies on an auxiliary `PreimageMap` object which provides access to the preimages of all keys in the tree based on their (hashed) path ordering. diff --git a/store/tools/ics23/smt/create_test.go b/store/tools/ics23/smt/create_test.go index 1a3e74e70869..71ec7722661e 100644 --- a/store/tools/ics23/smt/create_test.go +++ b/store/tools/ics23/smt/create_test.go @@ -10,21 +10,23 @@ import ( "github.com/cosmos/cosmos-sdk/store/tools/ics23/smt/helpers" ) -var numKeys = 50 -var cases = map[string]struct { - size int - loc tmproofs.Where -}{ - "tiny left": {size: 10, loc: tmproofs.Left}, - "tiny middle": {size: 10, loc: tmproofs.Middle}, - "tiny right": {size: 10, loc: tmproofs.Right}, - "small left": {size: 100, loc: tmproofs.Left}, - "small middle": {size: 100, loc: tmproofs.Middle}, - "small right": {size: 100, loc: tmproofs.Right}, - "big left": {size: 5431, loc: tmproofs.Left}, - "big middle": {size: 5431, loc: tmproofs.Middle}, - "big right": {size: 5431, loc: tmproofs.Right}, -} +var ( + numKeys = 50 + cases = map[string]struct { + size int + loc tmproofs.Where + }{ + "tiny left": {size: 10, loc: tmproofs.Left}, + "tiny middle": {size: 10, loc: tmproofs.Middle}, + "tiny right": {size: 10, loc: tmproofs.Right}, + "small left": {size: 100, loc: tmproofs.Left}, + "small middle": {size: 100, loc: tmproofs.Middle}, + "small right": {size: 100, loc: tmproofs.Right}, + "big left": {size: 5431, loc: tmproofs.Left}, + "big middle": {size: 5431, loc: tmproofs.Middle}, + "big right": {size: 5431, loc: tmproofs.Right}, + } +) func TestCreateMembership(t *testing.T) { for name, tc := range cases { diff --git a/store/tools/ics23/smt/helpers/helpers.go b/store/tools/ics23/smt/helpers/helpers.go index 1c8a1415a7c6..d444c47d61ec 100644 --- a/store/tools/ics23/smt/helpers/helpers.go +++ b/store/tools/ics23/smt/helpers/helpers.go @@ -1,7 +1,7 @@ /* Package helpers contains functions to build sample data for tests/testgen -In it's own package to avoid poluting the godoc for ics23-smt +In it's own package to avoid polluting the godoc for ics23-smt */ package helpers diff --git a/store/tracekv/store.go b/store/tracekv/store.go index a454edc7dd5f..91f3c657682c 100644 --- a/store/tracekv/store.go +++ b/store/tracekv/store.go @@ -79,13 +79,13 @@ func (tkv *Store) Has(key []byte) bool { } // Iterator implements the KVStore interface. It delegates the Iterator call -// the to the parent KVStore. +// to the parent KVStore. func (tkv *Store) Iterator(start, end []byte) types.Iterator { return tkv.iterator(start, end, true) } // ReverseIterator implements the KVStore interface. It delegates the -// ReverseIterator call the to the parent KVStore. +// ReverseIterator call to the parent KVStore. func (tkv *Store) ReverseIterator(start, end []byte) types.Iterator { return tkv.iterator(start, end, false) } diff --git a/store/tracekv/store_test.go b/store/tracekv/store_test.go index db9a981237f4..1b81e89bafd2 100644 --- a/store/tracekv/store_test.go +++ b/store/tracekv/store_test.go @@ -111,7 +111,6 @@ func TestTraceKVStoreSet(t *testing.T) { store := newEmptyTraceKVStore(&buf) require.Panics(t, func() { store.Set([]byte(""), []byte("value")) }, "setting an empty key should panic") require.Panics(t, func() { store.Set(nil, []byte("value")) }, "setting a nil key should panic") - } func TestTraceKVStoreDelete(t *testing.T) { diff --git a/store/transient/store.go b/store/transient/store.go index 572ab55f7697..4d4fc5b81d6e 100644 --- a/store/transient/store.go +++ b/store/transient/store.go @@ -3,12 +3,15 @@ package transient import ( dbm "github.com/tendermint/tm-db" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/store/dbadapter" "github.com/cosmos/cosmos-sdk/store/types" ) -var _ types.Committer = (*Store)(nil) -var _ types.KVStore = (*Store)(nil) +var ( + _ types.Committer = (*Store)(nil) + _ types.KVStore = (*Store)(nil) +) // Store is a wrapper for a MemDB with Commiter implementation type Store struct { @@ -27,11 +30,13 @@ func (ts *Store) Commit() (id types.CommitID) { return } -func (ts *Store) SetPruning(_ types.PruningOptions) {} +func (ts *Store) SetPruning(_ pruningtypes.PruningOptions) {} // GetPruning is a no-op as pruning options cannot be directly set on this store. // They must be set on the root commit multi-store. -func (ts *Store) GetPruning() types.PruningOptions { return types.PruningOptions{} } +func (ts *Store) GetPruning() pruningtypes.PruningOptions { + return pruningtypes.NewPruningOptions(pruningtypes.PruningUndefined) +} // Implements CommitStore func (ts *Store) LastCommitID() (id types.CommitID) { diff --git a/store/transient/store_test.go b/store/transient/store_test.go index 16a165b3ba2e..900e6cb7a918 100644 --- a/store/transient/store_test.go +++ b/store/transient/store_test.go @@ -6,8 +6,9 @@ import ( "github.com/stretchr/testify/require" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" + "github.com/cosmos/cosmos-sdk/store/transient" types "github.com/cosmos/cosmos-sdk/store/v2alpha1" - "github.com/cosmos/cosmos-sdk/store/v2alpha1/transient" ) var k, v = []byte("hello"), []byte("world") @@ -26,7 +27,7 @@ func TestTransientStore(t *testing.T) { require.Nil(t, tstore.Get(k)) // no-op - tstore.SetPruning(types.PruningOptions{}) + tstore.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningUndefined)) emptyCommitID := tstore.LastCommitID() require.Equal(t, emptyCommitID.Version, int64(0)) diff --git a/store/types/errors.go b/store/types/errors.go index 780fcdef37ab..f2f395aea806 100644 --- a/store/types/errors.go +++ b/store/types/errors.go @@ -6,6 +6,4 @@ import ( const StoreCodespace = "store" -var ( - ErrInvalidProof = sdkerrors.Register(StoreCodespace, 2, "invalid proof") -) +var ErrInvalidProof = sdkerrors.Register(StoreCodespace, 2, "invalid proof") diff --git a/store/types/iterator.go b/store/types/iterator.go index cfce4124e397..a328e87a68a6 100644 --- a/store/types/iterator.go +++ b/store/types/iterator.go @@ -34,7 +34,6 @@ type PaginatedIterator struct { page, limit uint // provided during initialization iterated uint // incremented in a call to Next - } func (pi *PaginatedIterator) skip() { diff --git a/store/types/listening.go b/store/types/listening.go index 2294a5ada531..02cde4c715c7 100644 --- a/store/types/listening.go +++ b/store/types/listening.go @@ -9,7 +9,7 @@ import ( // WriteListener interface for streaming data out from a listenkv.Store type WriteListener interface { // if value is nil then it was deleted - // storeKey indicates the source KVStore, to facilitate using the the same WriteListener across separate KVStores + // storeKey indicates the source KVStore, to facilitate using the same WriteListener across separate KVStores // delete bool indicates if it was a delete; true: delete, false: set OnWrite(storeKey StoreKey, key []byte, value []byte, delete bool) error } diff --git a/store/types/pruning.go b/store/types/pruning.go deleted file mode 100644 index 3dd05b02bd12..000000000000 --- a/store/types/pruning.go +++ /dev/null @@ -1,71 +0,0 @@ -package types - -import ( - "fmt" -) - -// Pruning option string constants -const ( - PruningOptionDefault = "default" - PruningOptionEverything = "everything" - PruningOptionNothing = "nothing" - PruningOptionCustom = "custom" -) - -var ( - // PruneDefault defines a pruning strategy where the last 362880 heights are - // kept in addition to every 100th and where to-be pruned heights are pruned - // at every 10th height. The last 362880 heights are kept assuming the typical - // block time is 5s and typical unbonding period is 21 days. If these values - // do not match the applications' requirements, use the "custom" option. - PruneDefault = NewPruningOptions(362880, 10) - - // PruneEverything defines a pruning strategy where all committed heights are - // deleted, storing only the current and previous height and where to-be pruned - // heights are pruned at every 10th height. - PruneEverything = NewPruningOptions(2, 10) - - // PruneNothing defines a pruning strategy where all heights are kept on disk. - PruneNothing = NewPruningOptions(0, 0) -) - -// PruningOptions defines the pruning strategy used when determining which -// heights are removed from disk when committing state. -type PruningOptions struct { - // KeepRecent defines how many recent heights to keep on disk. - KeepRecent uint64 - - // Interval defines when the pruned heights are removed from disk. - Interval uint64 -} - -func NewPruningOptions(keepRecent, interval uint64) PruningOptions { - return PruningOptions{ - KeepRecent: keepRecent, - Interval: interval, - } -} - -func (po PruningOptions) Validate() error { - if po.KeepRecent > 0 && po.Interval == 0 { - return fmt.Errorf("invalid 'Interval' when pruning recent heights: %d", po.Interval) - } - - return nil -} - -func NewPruningOptionsFromString(strategy string) PruningOptions { - switch strategy { - case PruningOptionEverything: - return PruneEverything - - case PruningOptionNothing: - return PruneNothing - - case PruningOptionDefault: - return PruneDefault - - default: - return PruneDefault - } -} diff --git a/store/types/pruning_test.go b/store/types/pruning_test.go deleted file mode 100644 index d524aea70ed4..000000000000 --- a/store/types/pruning_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package types - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestPruningOptions_Validate(t *testing.T) { - testCases := []struct { - keepRecent uint64 - interval uint64 - expectErr bool - }{ - {100, 10, false}, // default - {0, 10, false}, // everything - {0, 0, false}, // nothing - {100, 0, true}, // invalid interval - } - - for _, tc := range testCases { - po := NewPruningOptions(tc.keepRecent, tc.interval) - err := po.Validate() - require.Equal(t, tc.expectErr, err != nil, "options: %v, err: %s", po, err) - } -} diff --git a/store/types/store.go b/store/types/store.go index bbf1b875803f..bb628dd26922 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -8,6 +8,7 @@ import ( tmstrings "github.com/tendermint/tendermint/libs/strings" dbm "github.com/tendermint/tm-db" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/types/kv" ) @@ -22,8 +23,8 @@ type Committer interface { Commit() CommitID LastCommitID() CommitID - SetPruning(PruningOptions) - GetPruning() PruningOptions + SetPruning(pruningtypes.PruningOptions) + GetPruning() pruningtypes.PruningOptions } // Stores of MultiStore must implement CommitStore. @@ -58,7 +59,7 @@ type StoreRename struct { NewKey string `json:"new_key"` } -// IsDeleted returns true if the given key should be added +// IsAdded returns true if the given key should be added func (s *StoreUpgrades) IsAdded(key string) bool { if s == nil { return false @@ -91,7 +92,6 @@ func (s *StoreUpgrades) RenamedFrom(key string) string { } } return "" - } type MultiStore interface { @@ -191,7 +191,7 @@ type CommitMultiStore interface { // BasicKVStore is a simple interface to get/set data type BasicKVStore interface { - // Get returns nil iff key doesn't exist. Panics on nil key. + // Get returns nil if key doesn't exist. Panics on nil key. Get(key []byte) []byte // Has checks if a key exists. Panics on nil key. @@ -337,7 +337,7 @@ type StoreKey interface { } // CapabilityKey represent the Cosmos SDK keys for object-capability -// generation in the IBC protocol as defined in https://github.com/cosmos/ics/tree/master/spec/ics-005-port-allocation#data-structures +// generation in the IBC protocol as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-005-port-allocation#data-structures type CapabilityKey StoreKey // KVStoreKey is used for accessing substores. @@ -418,6 +418,29 @@ type KVPair kv.Pair // every trace operation. type TraceContext map[string]interface{} +// Clone clones tc into another instance of TraceContext. +func (tc TraceContext) Clone() TraceContext { + ret := TraceContext{} + for k, v := range tc { + ret[k] = v + } + + return ret +} + +// Merge merges value of newTc into tc. +func (tc TraceContext) Merge(newTc TraceContext) TraceContext { + if tc == nil { + tc = TraceContext{} + } + + for k, v := range newTc { + tc[k] = v + } + + return tc +} + // MultiStorePersistentCache defines an interface which provides inter-block // (persistent) caching capabilities for multiple CommitKVStores based on StoreKeys. type MultiStorePersistentCache interface { diff --git a/store/types/store_test.go b/store/types/store_test.go index f86144af7fbd..39087cd6a820 100644 --- a/store/types/store_test.go +++ b/store/types/store_test.go @@ -90,3 +90,120 @@ func TestTransientStoreKey(t *testing.T) { require.Equal(t, key.name, key.Name()) require.Equal(t, fmt.Sprintf("TransientStoreKey{%p, test}", key), key.String()) } + +func TestTraceContext_Clone(t *testing.T) { + tests := []struct { + name string + tc TraceContext + want TraceContext + }{ + { + "nil TraceContext yields empty TraceContext", + nil, + TraceContext{}, + }, + { + "non-nil TraceContext yields equal TraceContext", + TraceContext{ + "value": 42, + }, + TraceContext{ + "value": 42, + }, + }, + { + "non-nil TraceContext yields equal TraceContext, for more than one key", + TraceContext{ + "value": 42, + "another": 24, + "weird": "string", + }, + TraceContext{ + "value": 42, + "another": 24, + "weird": "string", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, tt.tc.Clone()) + }) + } +} + +func TestTraceContext_Clone_is_deep(t *testing.T) { + original := TraceContext{ + "value": 42, + "another": 24, + "weird": "string", + } + + clone := original.Clone() + + clone["other"] = true + + require.NotEqual(t, original, clone) +} + +func TestTraceContext_Merge(t *testing.T) { + tests := []struct { + name string + tc TraceContext + other TraceContext + want TraceContext + }{ + { + "tc is nil, other is empty, yields an empty TraceContext", + nil, + TraceContext{}, + TraceContext{}, + }, + { + "tc is nil, other is nil, yields an empty TraceContext", + nil, + nil, + TraceContext{}, + }, + { + "tc is not nil, other is nil, yields tc", + TraceContext{ + "data": 42, + }, + nil, + TraceContext{ + "data": 42, + }, + }, + { + "tc is not nil, other is not nil, yields tc + other", + TraceContext{ + "data": 42, + }, + TraceContext{ + "data2": 42, + }, + TraceContext{ + "data": 42, + "data2": 42, + }, + }, + { + "tc is not nil, other is not nil, other updates value in tc, yields tc updated with value from other", + TraceContext{ + "data": 42, + }, + TraceContext{ + "data": 24, + }, + TraceContext{ + "data": 24, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + require.Equal(t, tt.want, tt.tc.Merge(tt.other)) + }) + } +} diff --git a/store/types/utils.go b/store/types/utils.go index 22c8ca0761f9..f0cf469871d9 100644 --- a/store/types/utils.go +++ b/store/types/utils.go @@ -6,12 +6,12 @@ import ( "github.com/cosmos/cosmos-sdk/types/kv" ) -// Iterator over all the keys with a certain prefix in ascending order +// KVStorePrefixIterator iterates over all the keys with a certain prefix in ascending order func KVStorePrefixIterator(kvs KVStore, prefix []byte) Iterator { return kvs.Iterator(prefix, PrefixEndBytes(prefix)) } -// Iterator over all the keys with a certain prefix in descending order. +// KVStoreReversePrefixIterator iterates over all the keys with a certain prefix in descending order. func KVStoreReversePrefixIterator(kvs KVStore, prefix []byte) Iterator { return kvs.ReverseIterator(prefix, PrefixEndBytes(prefix)) } diff --git a/store/types/utils_test.go b/store/types/utils_test.go index 32064d7e1821..a13a2d9a5a55 100644 --- a/store/types/utils_test.go +++ b/store/types/utils_test.go @@ -5,20 +5,21 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/store/rootmulti" - "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/store/types" ) -func initTestStores(t *testing.T) (types.KVStore, types.KVStore) { +func initTestStores(t *testing.T) (sdk.KVStore, sdk.KVStore) { db := dbm.NewMemDB() - ms := rootmulti.NewStore(db) + ms := rootmulti.NewStore(db, log.NewNopLogger()) - key1 := types.NewKVStoreKey("store1") - key2 := types.NewKVStoreKey("store2") - require.NotPanics(t, func() { ms.MountStoreWithDB(key1, types.StoreTypeIAVL, db) }) - require.NotPanics(t, func() { ms.MountStoreWithDB(key2, types.StoreTypeIAVL, db) }) + key1 := sdk.NewKVStoreKey("store1") + key2 := sdk.NewKVStoreKey("store2") + require.NotPanics(t, func() { ms.MountStoreWithDB(key1, sdk.StoreTypeIAVL, db) }) + require.NotPanics(t, func() { ms.MountStoreWithDB(key2, sdk.StoreTypeIAVL, db) }) require.NoError(t, ms.LoadLatestVersion()) return ms.GetKVStore(key1), ms.GetKVStore(key2) } @@ -31,27 +32,27 @@ func TestDiffKVStores(t *testing.T) { store1.Set(k1, v1) store2.Set(k1, v1) - kvAs, kvBs := types.DiffKVStores(store1, store2, nil) + kvAs, kvBs := sdk.DiffKVStores(store1, store2, nil) require.Equal(t, 0, len(kvAs)) require.Equal(t, len(kvAs), len(kvBs)) // delete k1 from store2, which is now empty store2.Delete(k1) - kvAs, kvBs = types.DiffKVStores(store1, store2, nil) + kvAs, kvBs = sdk.DiffKVStores(store1, store2, nil) require.Equal(t, 1, len(kvAs)) require.Equal(t, len(kvAs), len(kvBs)) // set k1 in store2, different value than what store1 holds for k1 v2 := []byte("v2") store2.Set(k1, v2) - kvAs, kvBs = types.DiffKVStores(store1, store2, nil) + kvAs, kvBs = sdk.DiffKVStores(store1, store2, nil) require.Equal(t, 1, len(kvAs)) require.Equal(t, len(kvAs), len(kvBs)) // add k2 to store2 k2 := []byte("k2") store2.Set(k2, v2) - kvAs, kvBs = types.DiffKVStores(store1, store2, nil) + kvAs, kvBs = sdk.DiffKVStores(store1, store2, nil) require.Equal(t, 2, len(kvAs)) require.Equal(t, len(kvAs), len(kvBs)) @@ -65,7 +66,7 @@ func TestDiffKVStores(t *testing.T) { k1Prefixed := append(prefix, k1...) store1.Set(k1Prefixed, v1) store2.Set(k1Prefixed, v2) - kvAs, kvBs = types.DiffKVStores(store1, store2, [][]byte{prefix}) + kvAs, kvBs = sdk.DiffKVStores(store1, store2, [][]byte{prefix}) require.Equal(t, 0, len(kvAs)) require.Equal(t, len(kvAs), len(kvBs)) } @@ -73,16 +74,16 @@ func TestDiffKVStores(t *testing.T) { func TestPrefixEndBytes(t *testing.T) { t.Parallel() bs1 := []byte{0x23, 0xA5, 0x06} - require.True(t, bytes.Equal([]byte{0x23, 0xA5, 0x07}, types.PrefixEndBytes(bs1))) + require.True(t, bytes.Equal([]byte{0x23, 0xA5, 0x07}, sdk.PrefixEndBytes(bs1))) bs2 := []byte{0x23, 0xA5, 0xFF} - require.True(t, bytes.Equal([]byte{0x23, 0xA6}, types.PrefixEndBytes(bs2))) - require.Nil(t, types.PrefixEndBytes([]byte{0xFF})) - require.Nil(t, types.PrefixEndBytes(nil)) + require.True(t, bytes.Equal([]byte{0x23, 0xA6}, sdk.PrefixEndBytes(bs2))) + require.Nil(t, sdk.PrefixEndBytes([]byte{0xFF})) + require.Nil(t, sdk.PrefixEndBytes(nil)) } func TestInclusiveEndBytes(t *testing.T) { t.Parallel() - require.True(t, bytes.Equal([]byte{0x00}, types.InclusiveEndBytes(nil))) + require.True(t, bytes.Equal([]byte{0x00}, sdk.InclusiveEndBytes(nil))) bs := []byte("test") - require.True(t, bytes.Equal(append(bs, byte(0x00)), types.InclusiveEndBytes(bs))) + require.True(t, bytes.Equal(append(bs, byte(0x00)), sdk.InclusiveEndBytes(bs))) } diff --git a/store/types/validity.go b/store/types/validity.go index ef2387a69269..32619271b488 100644 --- a/store/types/validity.go +++ b/store/types/validity.go @@ -1,13 +1,13 @@ package types -// Check if the key is valid(key is not nil) +// AssertValidKey checks if the key is valid(key is not nil) func AssertValidKey(key []byte) { if len(key) == 0 { panic("key is nil") } } -// Check if the value is valid(value is not nil) +// AssertValidValue checks if the value is valid(value is not nil) func AssertValidValue(value []byte) { if value == nil { panic("value is nil") diff --git a/store/v2alpha1/dbadapter/store.go b/store/v2alpha1/dbadapter/store.go index 1cbd6c83585b..9745c7597615 100644 --- a/store/v2alpha1/dbadapter/store.go +++ b/store/v2alpha1/dbadapter/store.go @@ -18,7 +18,7 @@ type Store struct { DB dbm.DBReadWriter } -// Get wraps the underlying DB's Get method panicing on error. +// Get wraps the underlying DB's Get method, panicking on error. func (dsa Store) Get(key []byte) []byte { v, err := dsa.DB.Get(key) if err != nil { @@ -28,7 +28,7 @@ func (dsa Store) Get(key []byte) []byte { return v } -// Has wraps the underlying DB's Has method panicing on error. +// Has wraps the underlying DB's Has method, panicking on error. func (dsa Store) Has(key []byte) bool { ok, err := dsa.DB.Has(key) if err != nil { @@ -38,7 +38,7 @@ func (dsa Store) Has(key []byte) bool { return ok } -// Set wraps the underlying DB's Set method panicing on error. +// Set wraps the underlying DB's Set method, panicking on error. func (dsa Store) Set(key, value []byte) { types.AssertValidKey(key) if err := dsa.DB.Set(key, value); err != nil { @@ -46,14 +46,14 @@ func (dsa Store) Set(key, value []byte) { } } -// Delete wraps the underlying DB's Delete method panicing on error. +// Delete wraps the underlying DB's Delete method, panicking on error. func (dsa Store) Delete(key []byte) { if err := dsa.DB.Delete(key); err != nil { panic(err) } } -// Iterator wraps the underlying DB's Iterator method panicing on error. +// Iterator wraps the underlying DB's Iterator method, panicking on error. func (dsa Store) Iterator(start, end []byte) types.Iterator { iter, err := dsa.DB.Iterator(start, end) if err != nil { @@ -62,7 +62,7 @@ func (dsa Store) Iterator(start, end []byte) types.Iterator { return dbutil.DBToStoreIterator(iter) } -// ReverseIterator wraps the underlying DB's ReverseIterator method panicing on error. +// ReverseIterator wraps the underlying DB's ReverseIterator method, panicking on error. func (dsa Store) ReverseIterator(start, end []byte) types.Iterator { iter, err := dsa.DB.ReverseIterator(start, end) if err != nil { diff --git a/store/v2alpha1/mem/store.go b/store/v2alpha1/mem/store.go index b984aac81dc8..3c8fa82bbaba 100644 --- a/store/v2alpha1/mem/store.go +++ b/store/v2alpha1/mem/store.go @@ -3,6 +3,7 @@ package mem import ( dbm "github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/db/memdb" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/store/v2alpha1/dbadapter" ) @@ -38,7 +39,7 @@ func (s *Store) Commit() (id types.CommitID) { return } -func (s *Store) SetPruning(pruning types.PruningOptions) {} -func (s *Store) GetPruning() types.PruningOptions { return types.PruningOptions{} } +func (s *Store) SetPruning(pruningtypes.PruningOptions) {} +func (s *Store) GetPruning() pruningtypes.PruningOptions { return pruningtypes.PruningOptions{} } func (s Store) LastCommitID() (id types.CommitID) { return } diff --git a/store/v2alpha1/multi/migration_test.go b/store/v2alpha1/multi/migration_test.go index d2ed43ff753e..d723c5433b15 100644 --- a/store/v2alpha1/multi/migration_test.go +++ b/store/v2alpha1/multi/migration_test.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/rootmulti" "github.com/cosmos/cosmos-sdk/store/types" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" ) @@ -19,7 +20,7 @@ func TestMigrationV2(t *testing.T) { // setup a rootmulti store db := dbm.NewMemDB() - v1Store := rootmulti.NewStore(db) + v1Store := rootmulti.NewStore(db, log.NewNopLogger()) // mount the kvStores var keys []*types.KVStoreKey @@ -94,7 +95,7 @@ func TestMigrationV2(t *testing.T) { func TestMigrateV2ForEmptyStore(t *testing.T) { // setup a rootmulti store db := dbm.NewMemDB() - v1Store := rootmulti.NewStore(db) + v1Store := rootmulti.NewStore(db, log.NewNopLogger()) err := v1Store.LoadLatestVersion() require.Nil(t, err) db2 := memdb.NewDB() diff --git a/store/v2alpha1/multi/proof_test.go b/store/v2alpha1/multi/proof_test.go index cdccee65da3d..13c69a5d616c 100644 --- a/store/v2alpha1/multi/proof_test.go +++ b/store/v2alpha1/multi/proof_test.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/v2alpha1/smt" ) -// We hash keys produce SMT paths, so reflect that here +// We hash keys to produce SMT paths, so reflect that here func keyPath(prefix, key string) string { hashed := sha256.Sum256([]byte(key)) return prefix + string(hashed[:]) diff --git a/store/v2alpha1/multi/snapshot_test.go b/store/v2alpha1/multi/snapshot_test.go index d61e330a32f4..308520d04945 100644 --- a/store/v2alpha1/multi/snapshot_test.go +++ b/store/v2alpha1/multi/snapshot_test.go @@ -17,6 +17,7 @@ import ( dbm "github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/db/memdb" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/snapshots" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store/types" @@ -36,7 +37,7 @@ func makeStoreKeys(upto int) { func multiStoreConfig(t *testing.T, stores int) StoreParams { opts := DefaultStoreParams() - opts.Pruning = types.PruneNothing + opts.Pruning = pruningtypes.NewPruningOptions(pruningtypes.PruningNothing) makeStoreKeys(stores) for i := 0; i < stores; i++ { diff --git a/store/v2alpha1/multi/store.go b/store/v2alpha1/multi/store.go index fae729c4ae53..300a0d4e8ad7 100644 --- a/store/v2alpha1/multi/store.go +++ b/store/v2alpha1/multi/store.go @@ -13,6 +13,7 @@ import ( dbm "github.com/cosmos/cosmos-sdk/db" prefixdb "github.com/cosmos/cosmos-sdk/db/prefix" util "github.com/cosmos/cosmos-sdk/internal" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" sdkmaps "github.com/cosmos/cosmos-sdk/store/internal/maps" "github.com/cosmos/cosmos-sdk/store/listenkv" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -56,7 +57,7 @@ func ErrStoreNotFound(key string) error { // StoreParams is used to define a schema and other options and pass them to the MultiStore constructor. type StoreParams struct { // Version pruning options for backing DBs. - Pruning types.PruningOptions + Pruning pruningtypes.PruningOptions // The minimum allowed version number. InitialVersion uint64 // The optional backing DB to use for the state commitment Merkle tree data. @@ -100,7 +101,7 @@ type Store struct { mtx sync.RWMutex // Copied from StoreParams - Pruning types.PruningOptions + Pruning pruningtypes.PruningOptions InitialVersion uint64 *traceListenMixin @@ -141,15 +142,29 @@ func newSchemaBuilder() SchemaBuilder { // pruning with PruneDefault, no listeners and no tracer. func DefaultStoreParams() StoreParams { return StoreParams{ - Pruning: types.PruneDefault, + Pruning: pruningtypes.NewPruningOptions(pruningtypes.PruningDefault), SchemaBuilder: newSchemaBuilder(), storeKeys: storeKeys{}, traceListenMixin: newTraceListenMixin(), } } -// func (pr *SchemaBuilder) registerName(key string, typ types.StoreType) error { func (par *StoreParams) RegisterSubstore(skey types.StoreKey, typ types.StoreType) error { + if !validSubStoreType(typ) { + return fmt.Errorf("StoreType not supported: %v", typ) + } + var ok bool + switch typ { + case types.StoreTypePersistent: + _, ok = skey.(*types.KVStoreKey) + case types.StoreTypeMemory: + _, ok = skey.(*types.MemoryStoreKey) + case types.StoreTypeTransient: + _, ok = skey.(*types.TransientStoreKey) + } + if !ok { + return fmt.Errorf("invalid StoreKey for %v: %T", typ, skey) + } if err := par.registerName(skey.Name(), typ); err != nil { return err } @@ -180,12 +195,12 @@ func validSubStoreType(sst types.StoreType) bool { } // Returns true iff both schema maps match exactly (including mem/tran stores) -func (this StoreSchema) equal(that StoreSchema) bool { - if len(this) != len(that) { +func (ss StoreSchema) equal(that StoreSchema) bool { + if len(ss) != len(that) { return false } for key, val := range that { - myval, has := this[key] + myval, has := ss[key] if !has { return false } @@ -269,7 +284,7 @@ func NewStore(db dbm.DBConnection, opts StoreParams) (ret *Store, err error) { } // Version sets of each DB must match if !versions.Equal(scVersions) { - err = fmt.Errorf("Storage and StateCommitment DB have different version history") //nolint:stylecheck + err = fmt.Errorf("different version history between Storage and StateCommitment DB ") return } err = opts.StateCommitmentDB.Revert() @@ -542,26 +557,32 @@ func (s *Store) Commit() types.CommitID { panic(err) } - // Prune if necessary - previous := cid.Version - 1 - if s.Pruning.Interval != 0 && cid.Version%int64(s.Pruning.Interval) == 0 { - // The range of newly prunable versions - lastPrunable := previous - int64(s.Pruning.KeepRecent) - firstPrunable := lastPrunable - int64(s.Pruning.Interval) - - for version := firstPrunable; version <= lastPrunable; version++ { - s.stateDB.DeleteVersion(uint64(version)) + pruneVersions(cid.Version, s.Pruning, func(ver int64) { + s.stateDB.DeleteVersion(uint64(ver)) - if s.StateCommitmentDB != nil { - s.StateCommitmentDB.DeleteVersion(uint64(version)) - } + if s.StateCommitmentDB != nil { + s.StateCommitmentDB.DeleteVersion(uint64(ver)) } - } + }) s.tran.Commit() return *cid } +// Performs necessary pruning via callback +func pruneVersions(current int64, opts pruningtypes.PruningOptions, prune func(int64)) { + previous := current - 1 + if opts.Interval != 0 && current%int64(opts.Interval) == 0 { + // The range of newly prunable versions + lastPrunable := previous - int64(opts.KeepRecent) + firstPrunable := lastPrunable - int64(opts.Interval) + + for version := firstPrunable; version <= lastPrunable; version++ { + prune(version) + } + } +} + func (s *Store) getMerkleRoots() (ret map[string][]byte, err error) { ret = map[string][]byte{} for key := range s.schema { @@ -702,6 +723,20 @@ func (rs *Store) GetAllVersions() []uint64 { return ret } +// PruneSnapshotHeight prunes the given height according to the prune strategy. +// If PruneNothing, this is a no-op. +// If other strategy, this height is persisted until it is +// less than - KeepRecent and % Interval == 0 +func (rs *Store) PruneSnapshotHeight(height int64) { + panic("not implemented") +} + +// SetSnapshotInterval sets the interval at which the snapshots are taken. +// It is used by the store to determine which heights to retain until after the snapshot is complete. +func (rs *Store) SetSnapshotInterval(snapshotInterval uint64) { + panic("not implemented") +} + // parsePath expects a format like /[/] // Must start with /, subpath may be empty // Returns error if it doesn't start with / @@ -779,7 +814,7 @@ func (rs *Store) Query(req abci.RequestQuery) (res abci.ResponseQuery) { // TODO: actual IBC compatible proof. This is a placeholder so unit tests can pass res.ProofOps, err = substore.GetProof(res.Key) if err != nil { - return sdkerrors.QueryResult(fmt.Errorf("Merkle proof creation failed for key: %v", res.Key), false) //nolint: stylecheck // proper name + return sdkerrors.QueryResult(fmt.Errorf("merkle proof creation failed for key: %v", res.Key), false) } case "/subspace": @@ -887,10 +922,6 @@ func (reg *SchemaBuilder) storeInfo(key string) (sst types.StoreType, ix int, er // registerName registers a store key by name only func (reg *SchemaBuilder) registerName(key string, typ types.StoreType) error { - if !validSubStoreType(typ) { - return fmt.Errorf("StoreType not supported: %v", typ) - } - // Find the neighboring reserved prefix, and check for duplicates and conflicts i, has := binarySearch(reg.reserved, key) if has { @@ -924,6 +955,7 @@ func (tlm *traceListenMixin) ListeningEnabled(key types.StoreKey) bool { func (tlm *traceListenMixin) TracingEnabled() bool { return tlm.TraceWriter != nil } + func (tlm *traceListenMixin) SetTracer(w io.Writer) { tlm.TraceWriter = w } @@ -964,5 +996,5 @@ func (tlm *traceListenMixin) wrapTraceListen(store types.KVStore, skey types.Sto return store } -func (s *Store) GetPruning() types.PruningOptions { return s.Pruning } -func (s *Store) SetPruning(po types.PruningOptions) { s.Pruning = po } +func (s *Store) GetPruning() pruningtypes.PruningOptions { return s.Pruning } +func (s *Store) SetPruning(po pruningtypes.PruningOptions) { s.Pruning = po } diff --git a/store/v2alpha1/multi/store_test.go b/store/v2alpha1/multi/store_test.go index 27c637e4c668..d2da0940f7c7 100644 --- a/store/v2alpha1/multi/store_test.go +++ b/store/v2alpha1/multi/store_test.go @@ -14,12 +14,12 @@ import ( codecTypes "github.com/cosmos/cosmos-sdk/codec/types" dbm "github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/db/memdb" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" types "github.com/cosmos/cosmos-sdk/store/v2alpha1" "github.com/cosmos/cosmos-sdk/types/kv" ) var ( - cacheSize = 100 alohaData = map[string]string{ "hello": "goodbye", "aloha": "shalom", @@ -31,8 +31,18 @@ var ( skey_1b = types.NewKVStoreKey("store1b") skey_2b = types.NewKVStoreKey("store2b") skey_3b = types.NewKVStoreKey("store3b") + + skey_mem1 = types.NewMemoryStoreKey("mstore1") + skey_tran1 = types.NewTransientStoreKey("tstore1") ) +// Factored out so the same tests can be run on Store and adaptor (v1asv2) +type storeConstructor = func(dbm.DBConnection, StoreParams) (types.CommitMultiStore, error) + +func multistoreConstructor(db dbm.DBConnection, params StoreParams) (types.CommitMultiStore, error) { + return NewStore(db, params) +} + func storeParams1(t *testing.T) StoreParams { opts := DefaultStoreParams() require.NoError(t, opts.RegisterSubstore(skey_1, types.StoreTypePersistent)) @@ -41,7 +51,7 @@ func storeParams1(t *testing.T) StoreParams { func storeParams123(t *testing.T) StoreParams { opts := DefaultStoreParams() - opts.Pruning = types.PruneNothing + opts.Pruning = pruningtypes.NewPruningOptions(pruningtypes.PruningNothing) require.NoError(t, opts.RegisterSubstore(skey_1, types.StoreTypePersistent)) require.NoError(t, opts.RegisterSubstore(skey_2, types.StoreTypePersistent)) require.NoError(t, opts.RegisterSubstore(skey_3, types.StoreTypePersistent)) @@ -59,6 +69,46 @@ func newSubStoreWithData(t *testing.T, db dbm.DBConnection, storeData map[string return root, store } +func TestStoreParams(t *testing.T) { + opts := DefaultStoreParams() + // Fail with invalid type enum + require.Error(t, opts.RegisterSubstore(skey_1, types.StoreTypeDB)) + require.Error(t, opts.RegisterSubstore(skey_1, types.StoreTypeSMT)) + // Mem & tranient stores require a bespoke concrete type + require.Error(t, opts.RegisterSubstore(skey_1, types.StoreTypeMemory)) + require.Error(t, opts.RegisterSubstore(skey_1, types.StoreTypeTransient)) + require.NoError(t, opts.RegisterSubstore(skey_mem1, types.StoreTypeMemory)) + require.NoError(t, opts.RegisterSubstore(skey_tran1, types.StoreTypeTransient)) + // Ensure that no prefix conflicts are allowed + require.NoError(t, opts.RegisterSubstore(skey_1, types.StoreTypePersistent)) + require.NoError(t, opts.RegisterSubstore(skey_2, types.StoreTypePersistent)) + require.NoError(t, opts.RegisterSubstore(skey_3b, types.StoreTypePersistent)) + require.Error(t, opts.RegisterSubstore(skey_1b, types.StoreTypePersistent)) + require.Error(t, opts.RegisterSubstore(skey_2b, types.StoreTypePersistent)) + require.Error(t, opts.RegisterSubstore(skey_3, types.StoreTypePersistent)) +} + +func TestMultiStoreBasic(t *testing.T) { + doTestMultiStoreBasic(t, multistoreConstructor) +} + +func doTestMultiStoreBasic(t *testing.T, ctor storeConstructor) { + opts := DefaultStoreParams() + err := opts.RegisterSubstore(skey_1, types.StoreTypePersistent) + require.NoError(t, err) + store, err := ctor(memdb.NewDB(), opts) + require.NoError(t, err) + + store_1 := store.GetKVStore(skey_1) + require.NotNil(t, store_1) + store_1.Set([]byte{0}, []byte{0}) + val := store_1.Get([]byte{0}) + require.Equal(t, []byte{0}, val) + store_1.Delete([]byte{0}) + val = store_1.Get([]byte{0}) + require.Equal(t, []byte(nil), val) +} + func TestGetSetHasDelete(t *testing.T) { _, store := newSubStoreWithData(t, memdb.NewDB(), alohaData) key := "hello" @@ -87,6 +137,67 @@ func TestGetSetHasDelete(t *testing.T) { require.Panics(t, func() { store.Set([]byte("key"), nil) }, "Set(nil value) should panic") } +func TestIterators(t *testing.T) { + _, store := newSubStoreWithData(t, memdb.NewDB(), map[string]string{ + string([]byte{0x00}): "0", + string([]byte{0x00, 0x00}): "0 0", + string([]byte{0x00, 0x01}): "0 1", + string([]byte{0x00, 0x02}): "0 2", + string([]byte{0x01}): "1", + }) + + testCase := func(t *testing.T, iter types.Iterator, expected []string) { + var i int + for i = 0; iter.Valid(); iter.Next() { + expectedValue := expected[i] + value := iter.Value() + require.EqualValues(t, string(value), expectedValue) + i++ + } + require.Equal(t, len(expected), i) + } + + testCase(t, store.Iterator(nil, nil), + []string{"0", "0 0", "0 1", "0 2", "1"}) + testCase(t, store.Iterator([]byte{0}, nil), + []string{"0", "0 0", "0 1", "0 2", "1"}) + testCase(t, store.Iterator([]byte{0}, []byte{0, 1}), + []string{"0", "0 0"}) + testCase(t, store.Iterator([]byte{0}, []byte{1}), + []string{"0", "0 0", "0 1", "0 2"}) + testCase(t, store.Iterator([]byte{0, 1}, []byte{1}), + []string{"0 1", "0 2"}) + testCase(t, store.Iterator(nil, []byte{1}), + []string{"0", "0 0", "0 1", "0 2"}) + testCase(t, store.Iterator([]byte{0}, []byte{0}), []string{}) // start = end + testCase(t, store.Iterator([]byte{1}, []byte{0}), []string{}) // start > end + + testCase(t, store.ReverseIterator(nil, nil), + []string{"1", "0 2", "0 1", "0 0", "0"}) + testCase(t, store.ReverseIterator([]byte{0}, nil), + []string{"1", "0 2", "0 1", "0 0", "0"}) + testCase(t, store.ReverseIterator([]byte{0}, []byte{0, 1}), + []string{"0 0", "0"}) + testCase(t, store.ReverseIterator([]byte{0}, []byte{1}), + []string{"0 2", "0 1", "0 0", "0"}) + testCase(t, store.ReverseIterator([]byte{0, 1}, []byte{1}), + []string{"0 2", "0 1"}) + testCase(t, store.ReverseIterator(nil, []byte{1}), + []string{"0 2", "0 1", "0 0", "0"}) + testCase(t, store.ReverseIterator([]byte{0}, []byte{0}), []string{}) // start = end + testCase(t, store.ReverseIterator([]byte{1}, []byte{0}), []string{}) // start > end + + testCase(t, types.KVStorePrefixIterator(store, []byte{0}), + []string{"0", "0 0", "0 1", "0 2"}) + testCase(t, types.KVStoreReversePrefixIterator(store, []byte{0}), + []string{"0 2", "0 1", "0 0", "0"}) + + require.Panics(t, func() { store.Iterator([]byte{}, nil) }, "Iterator(empty key) should panic") + require.Panics(t, func() { store.Iterator(nil, []byte{}) }, "Iterator(empty key) should panic") + require.Panics(t, func() { store.ReverseIterator([]byte{}, nil) }, "Iterator(empty key) should panic") + require.Panics(t, func() { store.ReverseIterator(nil, []byte{}) }, "Iterator(empty key) should panic") +} + func TestConstructors(t *testing.T) { db := memdb.NewDB() @@ -97,7 +208,7 @@ func TestConstructors(t *testing.T) { require.NoError(t, store.Close()) t.Run("fail to load if InitialVersion > lowest existing version", func(t *testing.T) { - opts := StoreParams{InitialVersion: 5, Pruning: types.PruneNothing} + opts := StoreParams{InitialVersion: 5, Pruning: pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)} store, err = NewStore(db, opts) require.Error(t, err) db.Close() @@ -150,67 +261,6 @@ func TestConstructors(t *testing.T) { }) } -func TestIterators(t *testing.T) { - _, store := newSubStoreWithData(t, memdb.NewDB(), map[string]string{ - string([]byte{0x00}): "0", - string([]byte{0x00, 0x00}): "0 0", - string([]byte{0x00, 0x01}): "0 1", - string([]byte{0x00, 0x02}): "0 2", - string([]byte{0x01}): "1", - }) - - var testCase = func(t *testing.T, iter types.Iterator, expected []string) { - var i int - for i = 0; iter.Valid(); iter.Next() { - expectedValue := expected[i] - value := iter.Value() - require.EqualValues(t, string(value), expectedValue) - i++ - } - require.Equal(t, len(expected), i) - } - - testCase(t, store.Iterator(nil, nil), - []string{"0", "0 0", "0 1", "0 2", "1"}) - testCase(t, store.Iterator([]byte{0}, nil), - []string{"0", "0 0", "0 1", "0 2", "1"}) - testCase(t, store.Iterator([]byte{0}, []byte{0, 1}), - []string{"0", "0 0"}) - testCase(t, store.Iterator([]byte{0}, []byte{1}), - []string{"0", "0 0", "0 1", "0 2"}) - testCase(t, store.Iterator([]byte{0, 1}, []byte{1}), - []string{"0 1", "0 2"}) - testCase(t, store.Iterator(nil, []byte{1}), - []string{"0", "0 0", "0 1", "0 2"}) - testCase(t, store.Iterator([]byte{0}, []byte{0}), []string{}) // start = end - testCase(t, store.Iterator([]byte{1}, []byte{0}), []string{}) // start > end - - testCase(t, store.ReverseIterator(nil, nil), - []string{"1", "0 2", "0 1", "0 0", "0"}) - testCase(t, store.ReverseIterator([]byte{0}, nil), - []string{"1", "0 2", "0 1", "0 0", "0"}) - testCase(t, store.ReverseIterator([]byte{0}, []byte{0, 1}), - []string{"0 0", "0"}) - testCase(t, store.ReverseIterator([]byte{0}, []byte{1}), - []string{"0 2", "0 1", "0 0", "0"}) - testCase(t, store.ReverseIterator([]byte{0, 1}, []byte{1}), - []string{"0 2", "0 1"}) - testCase(t, store.ReverseIterator(nil, []byte{1}), - []string{"0 2", "0 1", "0 0", "0"}) - testCase(t, store.ReverseIterator([]byte{0}, []byte{0}), []string{}) // start = end - testCase(t, store.ReverseIterator([]byte{1}, []byte{0}), []string{}) // start > end - - testCase(t, types.KVStorePrefixIterator(store, []byte{0}), - []string{"0", "0 0", "0 1", "0 2"}) - testCase(t, types.KVStoreReversePrefixIterator(store, []byte{0}), - []string{"0 2", "0 1", "0 0", "0"}) - - require.Panics(t, func() { store.Iterator([]byte{}, nil) }, "Iterator(empty key) should panic") - require.Panics(t, func() { store.Iterator(nil, []byte{}) }, "Iterator(empty key) should panic") - require.Panics(t, func() { store.ReverseIterator([]byte{}, nil) }, "Iterator(empty key) should panic") - require.Panics(t, func() { store.ReverseIterator(nil, []byte{}) }, "Iterator(empty key) should panic") -} - func TestCommit(t *testing.T) { testBasic := func(opts StoreParams) { db := memdb.NewDB() @@ -249,7 +299,7 @@ func TestCommit(t *testing.T) { } } basicOpts := storeParams1(t) - basicOpts.Pruning = types.PruneNothing + basicOpts.Pruning = pruningtypes.NewPruningOptions(pruningtypes.PruningNothing) t.Run("sanity tests for Merkle hashing", func(t *testing.T) { testBasic(basicOpts) }) @@ -288,7 +338,7 @@ func TestCommit(t *testing.T) { } opts := storeParams1(t) - opts.Pruning = types.PruneNothing + opts.Pruning = pruningtypes.NewPruningOptions(pruningtypes.PruningNothing) // Ensure Store's commit is rolled back in each failure case... t.Run("recover after failed Commit", func(t *testing.T) { @@ -351,7 +401,7 @@ func TestCommit(t *testing.T) { t.Run("height overflow triggers failure", func(t *testing.T) { opts.StateCommitmentDB = nil opts.InitialVersion = math.MaxInt64 - opts.Pruning = types.PruneNothing + opts.Pruning = pruningtypes.NewPruningOptions(pruningtypes.PruningNothing) store, err := NewStore(memdb.NewDB(), opts) require.NoError(t, err) require.Equal(t, int64(math.MaxInt64), store.Commit().Version) @@ -362,7 +412,7 @@ func TestCommit(t *testing.T) { t.Run("first commit version matches InitialVersion", func(t *testing.T) { opts = storeParams1(t) opts.InitialVersion = 5 - opts.Pruning = types.PruneNothing + opts.Pruning = pruningtypes.NewPruningOptions(pruningtypes.PruningNothing) opts.StateCommitmentDB = memdb.NewDB() store, err := NewStore(memdb.NewDB(), opts) require.NoError(t, err) @@ -395,23 +445,30 @@ func sliceToSet(slice []uint64) map[uint64]struct{} { } func TestPruning(t *testing.T) { + doTestPruning(t, multistoreConstructor, true) +} + +func doTestPruning(t *testing.T, ctor storeConstructor, sepDBs bool) { // Save versions up to 10 and verify pruning at final commit testCases := []struct { - types.PruningOptions + pruningtypes.PruningOptions kept []uint64 }{ - {types.PruningOptions{2, 10}, []uint64{8, 9, 10}}, - {types.PruningOptions{0, 10}, []uint64{10}}, - {types.PruneEverything, []uint64{8, 9, 10}}, - {types.PruneNothing, []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}, + {pruningtypes.NewCustomPruningOptions(2, 10), []uint64{8, 9, 10}}, + {pruningtypes.NewCustomPruningOptions(0, 10), []uint64{10}}, + {pruningtypes.NewPruningOptions(pruningtypes.PruningEverything), []uint64{8, 9, 10}}, + {pruningtypes.NewPruningOptions(pruningtypes.PruningNothing), []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}}, } for tci, tc := range testCases { - dbs := []dbm.DBConnection{memdb.NewDB(), memdb.NewDB()} opts := storeParams1(t) opts.Pruning = tc.PruningOptions - opts.StateCommitmentDB = dbs[1] - store, err := NewStore(dbs[0], opts) + dbs := []dbm.DBConnection{memdb.NewDB()} + if sepDBs { + dbs = append(dbs, memdb.NewDB()) + opts.StateCommitmentDB = dbs[1] + } + store, err := ctor(dbs[0], opts) require.NoError(t, err) s1 := store.GetKVStore(skey_1) @@ -445,8 +502,8 @@ func TestPruning(t *testing.T) { db := memdb.NewDB() opts := storeParams1(t) - opts.Pruning = types.PruningOptions{0, 10} - store, err := NewStore(db, opts) + opts.Pruning = pruningtypes.NewCustomPruningOptions(0, 10) + store, err := ctor(db, opts) require.NoError(t, err) for i := byte(1); i <= 20; i++ { @@ -472,9 +529,13 @@ func TestPruning(t *testing.T) { } } +func TestQuery(t *testing.T) { + doTestQuery(t, multistoreConstructor) +} + func queryPath(skey types.StoreKey, endp string) string { return "/" + skey.Name() + endp } -func TestQuery(t *testing.T) { +func doTestQuery(t *testing.T, ctor storeConstructor) { k1, v1 := []byte("k1"), []byte("v1") k2, v2 := []byte("k2"), []byte("v2") v3 := []byte("v3") @@ -676,42 +737,14 @@ func TestQuery(t *testing.T) { }) } -func TestStoreParams(t *testing.T) { - opts := DefaultStoreParams() - // Fail with invalid types - require.Error(t, opts.RegisterSubstore(skey_1, types.StoreTypeDB)) - require.Error(t, opts.RegisterSubstore(skey_1, types.StoreTypeSMT)) - // Ensure that no prefix conflicts are allowed - require.NoError(t, opts.RegisterSubstore(skey_1, types.StoreTypePersistent)) - require.NoError(t, opts.RegisterSubstore(skey_2, types.StoreTypeMemory)) - require.NoError(t, opts.RegisterSubstore(skey_3b, types.StoreTypeTransient)) - require.Error(t, opts.RegisterSubstore(skey_1b, types.StoreTypePersistent)) - require.Error(t, opts.RegisterSubstore(skey_2b, types.StoreTypePersistent)) - require.Error(t, opts.RegisterSubstore(skey_3, types.StoreTypePersistent)) -} - -func TestMultiStoreBasic(t *testing.T) { - opts := DefaultStoreParams() - err := opts.RegisterSubstore(skey_1, types.StoreTypePersistent) - require.NoError(t, err) - db := memdb.NewDB() - store, err := NewStore(db, opts) - require.NoError(t, err) - - store_1 := store.GetKVStore(skey_1) - require.NotNil(t, store_1) - store_1.Set([]byte{0}, []byte{0}) - val := store_1.Get([]byte{0}) - require.Equal(t, []byte{0}, val) - store_1.Delete([]byte{0}) - val = store_1.Get([]byte{0}) - require.Equal(t, []byte(nil), val) +func TestGetVersion(t *testing.T) { + doTestGetVersion(t, multistoreConstructor) } -func TestGetVersion(t *testing.T) { +func doTestGetVersion(t *testing.T, ctor storeConstructor) { db := memdb.NewDB() opts := storeParams123(t) - store, err := NewStore(db, opts) + store, err := ctor(db, opts) require.NoError(t, err) cid := store.Commit() @@ -724,7 +757,7 @@ func TestGetVersion(t *testing.T) { require.Panics(t, func() { subview.Set([]byte{1}, []byte{1}) }) require.Panics(t, func() { subview.Delete([]byte{0}) }) // nonexistent version shouldn't be accessible - view, err = store.GetVersion(cid.Version + 1) + _, err = store.GetVersion(cid.Version + 1) require.Equal(t, ErrVersionDoesNotExist, err) substore := store.GetKVStore(skey_1) @@ -743,10 +776,14 @@ func TestGetVersion(t *testing.T) { require.Equal(t, []byte{0}, subview.Get([]byte{0})) } -func TestMultiStoreMigration(t *testing.T) { +func TestStoreSchemaMigration(t *testing.T) { + doTestStoreSchemaMigration(t, multistoreConstructor) +} + +func doTestStoreSchemaMigration(t *testing.T, ctor storeConstructor) { db := memdb.NewDB() opts := storeParams123(t) - store, err := NewStore(db, opts) + store, err := ctor(db, opts) require.NoError(t, err) // write some data in all stores @@ -773,7 +810,7 @@ func TestMultiStoreMigration(t *testing.T) { var migratedID types.CommitID // Load without changes and make sure it is sensible - store, err = NewStore(db, opts) + store, err = ctor(db, opts) require.NoError(t, err) // let's query data to see it was saved properly @@ -796,7 +833,7 @@ func TestMultiStoreMigration(t *testing.T) { // store must be loaded with post-migration schema, so this fails opts := storeParams123(t) opts.Upgrades = upgrades - store, err = NewStore(db, opts) + store, err = ctor(db, opts) require.Error(t, err) opts = DefaultStoreParams() @@ -804,7 +841,7 @@ func TestMultiStoreMigration(t *testing.T) { require.NoError(t, opts.RegisterSubstore(skey_1, types.StoreTypePersistent)) require.NoError(t, opts.RegisterSubstore(skey_2b, types.StoreTypePersistent)) require.NoError(t, opts.RegisterSubstore(skey_4, types.StoreTypePersistent)) - store, err = NewStore(db, opts) + store, err = ctor(db, opts) require.NoError(t, err) // store1 was not changed @@ -843,7 +880,7 @@ func TestMultiStoreMigration(t *testing.T) { t.Run("reload after migrations", func(t *testing.T) { // fail to load the migrated store with the old schema - store, err = NewStore(db, storeParams123(t)) + store, err = ctor(db, storeParams123(t)) require.Error(t, err) // pass in a schema reflecting the migrations @@ -851,7 +888,7 @@ func TestMultiStoreMigration(t *testing.T) { require.NoError(t, migratedOpts.RegisterSubstore(skey_1, types.StoreTypePersistent)) require.NoError(t, migratedOpts.RegisterSubstore(skey_2b, types.StoreTypePersistent)) require.NoError(t, migratedOpts.RegisterSubstore(skey_4, types.StoreTypePersistent)) - store, err = NewStore(db, migratedOpts) + store, err = ctor(db, migratedOpts) require.NoError(t, err) require.Equal(t, migratedID, store.LastCommitID()) @@ -893,6 +930,10 @@ func TestMultiStoreMigration(t *testing.T) { } func TestTrace(t *testing.T) { + doTestTrace(t, multistoreConstructor) +} + +func doTestTrace(t *testing.T, ctor storeConstructor) { key, value := []byte("test-key"), []byte("test-value") tc := types.TraceContext(map[string]interface{}{"blockHeight": 64}) @@ -905,10 +946,10 @@ func TestTrace(t *testing.T) { db := memdb.NewDB() opts := storeParams1(t) - require.NoError(t, opts.RegisterSubstore(skey_2, types.StoreTypeMemory)) - require.NoError(t, opts.RegisterSubstore(skey_3, types.StoreTypeTransient)) + require.NoError(t, opts.RegisterSubstore(skey_mem1, types.StoreTypeMemory)) + require.NoError(t, opts.RegisterSubstore(skey_tran1, types.StoreTypeTransient)) - store, err := NewStore(db, opts) + store, err := ctor(db, opts) require.NoError(t, err) store.SetTracingContext(tc) require.False(t, store.TracingEnabled()) @@ -917,7 +958,7 @@ func TestTrace(t *testing.T) { store.SetTracer(&buf) require.True(t, store.TracingEnabled()) - for _, skey := range []types.StoreKey{skey_1, skey_2, skey_3} { + for _, skey := range []types.StoreKey{skey_1, skey_mem1, skey_tran1} { buf.Reset() store.GetKVStore(skey).Get(key) require.Equal(t, expected_Get_missing, buf.String()) @@ -950,9 +991,13 @@ func TestTrace(t *testing.T) { } func TestTraceConcurrency(t *testing.T) { + doTestTraceConcurrency(t, multistoreConstructor) +} + +func doTestTraceConcurrency(t *testing.T, ctor storeConstructor) { db := memdb.NewDB() opts := storeParams123(t) - store, err := NewStore(db, opts) + store, err := ctor(db, opts) require.NoError(t, err) b := &bytes.Buffer{} @@ -997,6 +1042,10 @@ func TestTraceConcurrency(t *testing.T) { } func TestListeners(t *testing.T) { + doTestListeners(t, multistoreConstructor) +} + +func doTestListeners(t *testing.T, ctor storeConstructor) { kvPairs := []types.KVPair{ {Key: []byte{1}, Value: []byte("v1")}, {Key: []byte{2}, Value: []byte("v2")}, @@ -1016,24 +1065,24 @@ func TestListeners(t *testing.T) { { key: kvPairs[1].Key, value: kvPairs[1].Value, - skey: skey_2, + skey: skey_mem1, }, { key: kvPairs[2].Key, value: kvPairs[2].Value, - skey: skey_3, + skey: skey_tran1, }, } - var interfaceRegistry = codecTypes.NewInterfaceRegistry() - var marshaller = codec.NewProtoCodec(interfaceRegistry) + interfaceRegistry := codecTypes.NewInterfaceRegistry() + marshaller := codec.NewProtoCodec(interfaceRegistry) db := memdb.NewDB() opts := storeParams1(t) - require.NoError(t, opts.RegisterSubstore(skey_2, types.StoreTypeMemory)) - require.NoError(t, opts.RegisterSubstore(skey_3, types.StoreTypeTransient)) + require.NoError(t, opts.RegisterSubstore(skey_mem1, types.StoreTypeMemory)) + require.NoError(t, opts.RegisterSubstore(skey_tran1, types.StoreTypeTransient)) - store, err := NewStore(db, opts) + store, err := ctor(db, opts) require.NoError(t, err) for i, tc := range testCases { diff --git a/store/v2alpha1/multi/test_util.go b/store/v2alpha1/multi/test_util.go index cc03639906d9..a03d60f54f03 100644 --- a/store/v2alpha1/multi/test_util.go +++ b/store/v2alpha1/multi/test_util.go @@ -7,25 +7,30 @@ import ( dbm "github.com/cosmos/cosmos-sdk/db" ) -type dbDeleteVersionFails struct{ dbm.DBConnection } -type dbRWCommitFails struct{ dbm.DBConnection } -type dbRWCrudFails struct{ dbm.DBConnection } -type dbSaveVersionFails struct{ dbm.DBConnection } -type dbRevertFails struct { - dbm.DBConnection - // order of calls to fail on (eg. [1, 0] => first call fails; second succeeds) - failOn []bool -} +type ( + dbDeleteVersionFails struct{ dbm.DBConnection } + dbRWCommitFails struct{ dbm.DBConnection } + dbRWCrudFails struct{ dbm.DBConnection } + dbSaveVersionFails struct{ dbm.DBConnection } + dbRevertFails struct { + dbm.DBConnection + // order of calls to fail on (eg. [1, 0] => first call fails; second succeeds) + failOn []bool + } +) + type dbVersionsIs struct { dbm.DBConnection vset dbm.VersionSet } -type dbVersionsFails struct{ dbm.DBConnection } -type rwCommitFails struct{ dbm.DBReadWriter } -type rwCrudFails struct { - dbm.DBReadWriter - onKey []byte -} +type ( + dbVersionsFails struct{ dbm.DBConnection } + rwCommitFails struct{ dbm.DBReadWriter } + rwCrudFails struct { + dbm.DBReadWriter + onKey []byte + } +) func (dbVersionsFails) Versions() (dbm.VersionSet, error) { return nil, errors.New("dbVersionsFails") } func (db dbVersionsIs) Versions() (dbm.VersionSet, error) { return db.vset, nil } @@ -48,6 +53,7 @@ func (tx rwCommitFails) Commit() error { tx.Discard() return errors.New("rwCommitFails") } + func (db dbRWCommitFails) ReadWriter() dbm.DBReadWriter { return rwCommitFails{db.DBConnection.ReadWriter()} } @@ -58,18 +64,21 @@ func (rw rwCrudFails) Get(k []byte) ([]byte, error) { } return rw.DBReadWriter.Get(k) } + func (rw rwCrudFails) Has(k []byte) (bool, error) { if rw.onKey == nil || bytes.Equal(rw.onKey, k) { return false, errors.New("rwCrudFails.Has") } return rw.DBReadWriter.Has(k) } + func (rw rwCrudFails) Set(k []byte, v []byte) error { if rw.onKey == nil || bytes.Equal(rw.onKey, k) { return errors.New("rwCrudFails.Set") } return rw.DBReadWriter.Set(k, v) } + func (rw rwCrudFails) Delete(k []byte) error { if rw.onKey == nil || bytes.Equal(rw.onKey, k) { return errors.New("rwCrudFails.Delete") diff --git a/store/v2alpha1/multi/v1asv2.go b/store/v2alpha1/multi/v1asv2.go index 55d11b596fa9..4a05f9a99c33 100644 --- a/store/v2alpha1/multi/v1asv2.go +++ b/store/v2alpha1/multi/v1asv2.go @@ -3,6 +3,8 @@ package multi import ( "io" + "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/cosmos-sdk/db" dbutil "github.com/cosmos/cosmos-sdk/internal/db" "github.com/cosmos/cosmos-sdk/store/rootmulti" @@ -25,10 +27,16 @@ type cacheStore1as2 struct { v1.CacheMultiStore } +type viewStore1as2 struct{ cacheStore1as2 } + +type readonlyKVStore struct { + v2.KVStore +} + // NewV1MultiStoreAsV2 constructs a v1 CommitMultiStore from v2.StoreParams func NewV1MultiStoreAsV2(database db.DBConnection, opts StoreParams) (v2.CommitMultiStore, error) { adapter := dbutil.ConnectionAsTmdb(database) - cms := rootmulti.NewStore(adapter) + cms := rootmulti.NewStore(adapter, log.NewNopLogger()) for name, typ := range opts.StoreSchema { switch typ { case v2.StoreTypePersistent: @@ -62,9 +70,17 @@ func NewV1MultiStoreAsV2(database db.DBConnection, opts StoreParams) (v2.CommitM func (s *store1as2) CacheWrap() v2.CacheMultiStore { return cacheStore1as2{s.CacheMultiStore()} } + func (s *store1as2) GetVersion(ver int64) (v2.MultiStore, error) { ret, err := s.CacheMultiStoreWithVersion(ver) - return cacheStore1as2{ret}, err + versions, err := s.database.Connection.Versions() + if err != nil { + return nil, err + } + if !versions.Exists(uint64(ver)) { + return nil, db.ErrVersionDoesNotExist + } + return viewStore1as2{cacheStore1as2{ret}}, err } // CommitMultiStore @@ -79,6 +95,9 @@ func (s *store1as2) Commit() v2.CommitID { if err != nil { panic(err) } + pruneVersions(ret.Version, s.GetPruning(), func(ver int64) { + s.database.Connection.DeleteVersion(uint64(ver)) + }) return ret } @@ -86,8 +105,8 @@ func (s *store1as2) SetInitialVersion(ver uint64) error { return s.Store.SetInitialVersion(int64(ver)) } -func (s *store1as2) SetTracer(w io.Writer) { s.SetTracer(w) } -func (s *store1as2) SetTracingContext(tc v2.TraceContext) { s.SetTracingContext(tc) } +func (s *store1as2) SetTracer(w io.Writer) { s.Store.SetTracer(w) } +func (s *store1as2) SetTracingContext(tc v2.TraceContext) { s.Store.SetTracingContext(tc) } func (s *store1as2) GetAllVersions() []int { panic("unsupported: GetAllVersions") } @@ -97,5 +116,20 @@ func (s cacheStore1as2) CacheWrap() v2.CacheMultiStore { return cacheStore1as2{s.CacheMultiStore.CacheMultiStore()} } -func (s cacheStore1as2) SetTracer(w io.Writer) { s.SetTracer(w) } -func (s cacheStore1as2) SetTracingContext(tc v2.TraceContext) { s.SetTracingContext(tc) } +func (s cacheStore1as2) SetTracer(w io.Writer) { s.CacheMultiStore.SetTracer(w) } +func (s cacheStore1as2) SetTracingContext(tc v2.TraceContext) { + s.CacheMultiStore.SetTracingContext(tc) +} + +func (s viewStore1as2) GetKVStore(skey v2.StoreKey) v2.KVStore { + sub := s.CacheMultiStore.GetKVStore(skey) + return readonlyKVStore{sub} +} + +func (kv readonlyKVStore) Set(key []byte, value []byte) { + panic(ErrReadOnly) +} + +func (kv readonlyKVStore) Delete(key []byte) { + panic(ErrReadOnly) +} diff --git a/store/v2alpha1/multi/v1asv2_test.go b/store/v2alpha1/multi/v1asv2_test.go new file mode 100644 index 000000000000..9e1c057712a0 --- /dev/null +++ b/store/v2alpha1/multi/v1asv2_test.go @@ -0,0 +1,29 @@ +package multi + +import ( + "testing" +) + +func TestV1asV2MultiStoreBasic(t *testing.T) { + doTestMultiStoreBasic(t, NewV1MultiStoreAsV2) +} + +func TestV1asV2GetVersion(t *testing.T) { + doTestGetVersion(t, NewV1MultiStoreAsV2) +} + +func TestV1asV2Pruning(t *testing.T) { + doTestPruning(t, NewV1MultiStoreAsV2, false) +} + +func TestV1asV2Trace(t *testing.T) { + doTestTrace(t, NewV1MultiStoreAsV2) +} + +func TestV1asV2TraceConcurrency(t *testing.T) { + doTestTraceConcurrency(t, NewV1MultiStoreAsV2) +} + +func TestV1asV2Listeners(t *testing.T) { + doTestListeners(t, NewV1MultiStoreAsV2) +} diff --git a/store/v2alpha1/multi/view_store.go b/store/v2alpha1/multi/view_store.go index 5b794ed046cc..e9dda6259c66 100644 --- a/store/v2alpha1/multi/view_store.go +++ b/store/v2alpha1/multi/view_store.go @@ -140,7 +140,7 @@ func (st *viewSubstore) CacheWrapWithListeners(storeKey types.StoreKey, listener func (s *viewStore) getMerkleRoots() (ret map[string][]byte, err error) { ret = map[string][]byte{} - for key, _ := range s.schema { + for key := range s.schema { sub, has := s.substoreCache[key] if !has { sub, err = s.getSubstore(key) diff --git a/store/v2alpha1/smt/ics23_test.go b/store/v2alpha1/smt/ics23_test.go index a94cc6f0a477..5667dbe16e78 100644 --- a/store/v2alpha1/smt/ics23_test.go +++ b/store/v2alpha1/smt/ics23_test.go @@ -6,6 +6,7 @@ import ( ics23 "github.com/confio/ics23/go" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/db/memdb" store "github.com/cosmos/cosmos-sdk/store/v2alpha1/smt" @@ -33,7 +34,7 @@ func TestProofICS23(t *testing.T) { nonexist := proof.GetNonexist() assert.Nil(t, nonexist) exist := proof.GetExist() - assert.NotNil(t, exist) + require.NotNil(t, exist) assert.Equal(t, 0, len(exist.Path)) assert.NoError(t, exist.Verify(ics23.SmtSpec, s.Root(), path01[:], val1)) @@ -41,18 +42,18 @@ func TestProofICS23(t *testing.T) { proof, err = s.GetProofICS23(key00) // When leaf is leftmost node assert.NoError(t, err) nonexist = proof.GetNonexist() - assert.NotNil(t, nonexist) + require.NotNil(t, nonexist) assert.Nil(t, nonexist.Left) assert.Equal(t, path00[:], nonexist.Key) - assert.NotNil(t, nonexist.Right) + require.NotNil(t, nonexist.Right) assert.Equal(t, 0, len(nonexist.Right.Path)) assert.NoError(t, nonexist.Verify(ics23.SmtSpec, s.Root(), path00[:])) proof, err = s.GetProofICS23(key10) // When rightmost assert.NoError(t, err) nonexist = proof.GetNonexist() - assert.NotNil(t, nonexist) - assert.NotNil(t, nonexist.Left) + require.NotNil(t, nonexist) + require.NotNil(t, nonexist.Left) assert.Equal(t, 0, len(nonexist.Left.Path)) assert.Nil(t, nonexist.Right) assert.NoError(t, nonexist.Verify(ics23.SmtSpec, s.Root(), path10[:])) @@ -63,11 +64,11 @@ func TestProofICS23(t *testing.T) { proof, err = s.GetProofICS23(key10) // In between two keys assert.NoError(t, err) nonexist = proof.GetNonexist() - assert.NotNil(t, nonexist) + require.NotNil(t, nonexist) assert.Equal(t, path10[:], nonexist.Key) - assert.NotNil(t, nonexist.Left) + require.NotNil(t, nonexist.Left) assert.Equal(t, 1, len(nonexist.Left.Path)) - assert.NotNil(t, nonexist.Right) + require.NotNil(t, nonexist.Right) assert.Equal(t, 1, len(nonexist.Right.Path)) assert.NoError(t, nonexist.Verify(ics23.SmtSpec, s.Root(), path10[:])) @@ -78,9 +79,9 @@ func TestProofICS23(t *testing.T) { assert.NoError(t, err) nonexist = proof.GetNonexist() assert.Equal(t, path10[:], nonexist.Key) - assert.NotNil(t, nonexist.Left) + require.NotNil(t, nonexist.Left) assert.Equal(t, 1, len(nonexist.Left.Path)) - assert.NotNil(t, nonexist.Right) + require.NotNil(t, nonexist.Right) assert.Equal(t, 1, len(nonexist.Right.Path)) assert.NoError(t, nonexist.Verify(ics23.SmtSpec, s.Root(), path10[:])) diff --git a/store/v2alpha1/smt/proof_test.go b/store/v2alpha1/smt/proof_test.go index 3ef6573dab32..b2d3b191929e 100644 --- a/store/v2alpha1/smt/proof_test.go +++ b/store/v2alpha1/smt/proof_test.go @@ -55,7 +55,7 @@ func TestProofOpInterface(t *testing.T) { assert.Equal(t, key, tmProofOp.Key, key) assert.NotEmpty(t, tmProofOp.Data) - //decode + // decode decoded, err := smtstore.ProofDecoder(tmProofOp) assert.NoError(t, err) assert.NotNil(t, decoded) diff --git a/store/v2alpha1/transient/store.go b/store/v2alpha1/transient/store.go index 2a9609afb12b..586cc4e9d36e 100644 --- a/store/v2alpha1/transient/store.go +++ b/store/v2alpha1/transient/store.go @@ -3,6 +3,7 @@ package transient import ( dbm "github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/db/memdb" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/store/v2alpha1/dbadapter" ) @@ -40,7 +41,7 @@ func (ts *Store) Commit() (id types.CommitID) { return } -func (ts *Store) SetPruning(types.PruningOptions) {} -func (ts *Store) GetPruning() types.PruningOptions { return types.PruningOptions{} } +func (ts *Store) SetPruning(pruningtypes.PruningOptions) {} +func (ts *Store) GetPruning() pruningtypes.PruningOptions { return pruningtypes.PruningOptions{} } func (ts *Store) LastCommitID() (id types.CommitID) { return } diff --git a/store/v2alpha1/types.go b/store/v2alpha1/types.go index 3fd04def2c78..e133e2bf7c71 100644 --- a/store/v2alpha1/types.go +++ b/store/v2alpha1/types.go @@ -9,13 +9,12 @@ import ( // Re-export relevant original store types type ( - StoreKey = v1.StoreKey - StoreType = v1.StoreType - CommitID = v1.CommitID - StoreUpgrades = v1.StoreUpgrades - StoreRename = v1.StoreRename - Iterator = v1.Iterator - PruningOptions = v1.PruningOptions + StoreKey = v1.StoreKey + StoreType = v1.StoreType + CommitID = v1.CommitID + StoreUpgrades = v1.StoreUpgrades + StoreRename = v1.StoreRename + Iterator = v1.Iterator TraceContext = v1.TraceContext WriteListener = v1.WriteListener @@ -46,11 +45,9 @@ const ( ) var ( - PruneDefault = v1.PruneDefault - PruneEverything = v1.PruneEverything - PruneNothing = v1.PruneNothing - NewKVStoreKey = v1.NewKVStoreKey + NewMemoryStoreKey = v1.NewMemoryStoreKey + NewTransientStoreKey = v1.NewTransientStoreKey PrefixEndBytes = v1.PrefixEndBytes KVStorePrefixIterator = v1.KVStorePrefixIterator KVStoreReversePrefixIterator = v1.KVStoreReversePrefixIterator diff --git a/tests/mocks/types_module_module.go b/tests/mocks/types_module_module.go index 772dc5de6ebe..5a07c7563d61 100644 --- a/tests/mocks/types_module_module.go +++ b/tests/mocks/types_module_module.go @@ -14,7 +14,6 @@ import ( types0 "github.com/cosmos/cosmos-sdk/types" module "github.com/cosmos/cosmos-sdk/types/module" gomock "github.com/golang/mock/gomock" - mux "github.com/gorilla/mux" runtime "github.com/grpc-ecosystem/grpc-gateway/runtime" cobra "github.com/spf13/cobra" types1 "github.com/tendermint/tendermint/abci/types" @@ -135,18 +134,6 @@ func (mr *MockAppModuleBasicMockRecorder) RegisterLegacyAminoCodec(arg0 interfac return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterLegacyAminoCodec", reflect.TypeOf((*MockAppModuleBasic)(nil).RegisterLegacyAminoCodec), arg0) } -// RegisterRESTRoutes mocks base method. -func (m *MockAppModuleBasic) RegisterRESTRoutes(arg0 client.Context, arg1 *mux.Router) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RegisterRESTRoutes", arg0, arg1) -} - -// RegisterRESTRoutes indicates an expected call of RegisterRESTRoutes. -func (mr *MockAppModuleBasicMockRecorder) RegisterRESTRoutes(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterRESTRoutes", reflect.TypeOf((*MockAppModuleBasic)(nil).RegisterRESTRoutes), arg0, arg1) -} - // ValidateGenesis mocks base method. func (m *MockAppModuleBasic) ValidateGenesis(arg0 codec.JSONCodec, arg1 client.TxEncodingConfig, arg2 json.RawMessage) error { m.ctrl.T.Helper() @@ -304,18 +291,6 @@ func (mr *MockAppModuleGenesisMockRecorder) RegisterLegacyAminoCodec(arg0 interf return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterLegacyAminoCodec", reflect.TypeOf((*MockAppModuleGenesis)(nil).RegisterLegacyAminoCodec), arg0) } -// RegisterRESTRoutes mocks base method. -func (m *MockAppModuleGenesis) RegisterRESTRoutes(arg0 client.Context, arg1 *mux.Router) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RegisterRESTRoutes", arg0, arg1) -} - -// RegisterRESTRoutes indicates an expected call of RegisterRESTRoutes. -func (mr *MockAppModuleGenesisMockRecorder) RegisterRESTRoutes(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterRESTRoutes", reflect.TypeOf((*MockAppModuleGenesis)(nil).RegisterRESTRoutes), arg0, arg1) -} - // ValidateGenesis mocks base method. func (m *MockAppModuleGenesis) ValidateGenesis(arg0 codec.JSONCodec, arg1 client.TxEncodingConfig, arg2 json.RawMessage) error { m.ctrl.T.Helper() @@ -553,18 +528,6 @@ func (mr *MockAppModuleMockRecorder) RegisterLegacyAminoCodec(arg0 interface{}) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterLegacyAminoCodec", reflect.TypeOf((*MockAppModule)(nil).RegisterLegacyAminoCodec), arg0) } -// RegisterRESTRoutes mocks base method. -func (m *MockAppModule) RegisterRESTRoutes(arg0 client.Context, arg1 *mux.Router) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "RegisterRESTRoutes", arg0, arg1) -} - -// RegisterRESTRoutes indicates an expected call of RegisterRESTRoutes. -func (mr *MockAppModuleMockRecorder) RegisterRESTRoutes(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RegisterRESTRoutes", reflect.TypeOf((*MockAppModule)(nil).RegisterRESTRoutes), arg0, arg1) -} - // RegisterServices mocks base method. func (m *MockAppModule) RegisterServices(arg0 module.Configurator) { m.ctrl.T.Helper() diff --git a/testutil/ioutil.go b/testutil/ioutil.go index 6ff54d24ecb0..ef33eaa4411e 100644 --- a/testutil/ioutil.go +++ b/testutil/ioutil.go @@ -67,8 +67,21 @@ func WriteToNewTempFile(t testing.TB, s string) *os.File { func TempFile(t testing.TB) *os.File { t.Helper() - fp, err := os.CreateTemp(t.TempDir(), "") + fp, err := os.CreateTemp(GetTempDir(t), "") require.NoError(t, err) return fp } + +// GetTempDir returns a writable temporary director for the test to use. +func GetTempDir(t testing.TB) string { + t.Helper() + // os.MkDir() is used instead of testing.T.TempDir() + // see https://github.com/cosmos/cosmos-sdk/pull/8475 and + // https://github.com/cosmos/cosmos-sdk/pull/10341 for + // this change's rationale. + tempdir, err := os.MkdirTemp("", "") + require.NoError(t, err) + t.Cleanup(func() { _ = os.RemoveAll(tempdir) }) + return tempdir +} diff --git a/testutil/ioutil_test.go b/testutil/ioutil_test.go index 03250fbab6a3..59b4a0a840a6 100644 --- a/testutil/ioutil_test.go +++ b/testutil/ioutil_test.go @@ -27,7 +27,7 @@ func TestApplyMockIO(t *testing.T) { func TestWriteToNewTempFile(t *testing.T) { tempfile := testutil.WriteToNewTempFile(t, "test string") - tempfile.Close() + require.NoError(t, tempfile.Close()) bs, err := os.ReadFile(tempfile.Name()) require.NoError(t, err) diff --git a/testutil/mock/privval.go b/testutil/mock/privval.go index 6aaceedd2e34..9c5a745d1b55 100644 --- a/testutil/mock/privval.go +++ b/testutil/mock/privval.go @@ -14,7 +14,7 @@ import ( var _ tmtypes.PrivValidator = PV{} -// MockPV implements PrivValidator without any safety or persistence. +// PV implements PrivValidator without any safety or persistence. // Only use it for testing. type PV struct { PrivKey cryptotypes.PrivKey diff --git a/testutil/mock/privval_test.go b/testutil/mock/privval_test.go new file mode 100644 index 000000000000..a3326dbe4a09 --- /dev/null +++ b/testutil/mock/privval_test.go @@ -0,0 +1,32 @@ +package mock + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +func TestGetPubKey(t *testing.T) { + pv := NewPV() + pb, err := pv.GetPubKey(context.Background()) + require.NoError(t, err) + require.NotNil(t, pb) +} + +func TestSignVote(t *testing.T) { + pv := NewPV() + v := tmproto.Vote{} + err := pv.SignVote(context.Background(), "chain-id", &v) + require.NoError(t, err) + require.NotNil(t, v.Signature) +} + +func TestSignProposal(t *testing.T) { + pv := NewPV() + p := tmproto.Proposal{} + err := pv.SignProposal(context.Background(), "chain-id", &p) + require.NoError(t, err) + require.NotNil(t, p.Signature) +} diff --git a/testutil/network/doc.go b/testutil/network/doc.go index 9e44f371ab6c..fa7cc7d7715c 100644 --- a/testutil/network/doc.go +++ b/testutil/network/doc.go @@ -24,20 +24,22 @@ A typical testing flow might look like the following: type IntegrationTestSuite struct { suite.Suite - cfg testutil.Config - network *testutil.Network + cfg network.Config + network *network.Network } func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") - cfg := testutil.DefaultConfig() + cfg := network.DefaultConfig() cfg.NumValidators = 1 - s.cfg = cfg - s.network = testutil.New(s.T(), cfg) - _, err := s.network.WaitForHeight(1) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/testutil/network/network.go b/testutil/network/network.go index 7747b49600d8..ce2f7b72b63f 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -32,13 +32,13 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/db/memdb" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/server" "github.com/cosmos/cosmos-sdk/server/api" srvconfig "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/simapp/params" - storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -61,7 +61,7 @@ func NewAppConstructor(encodingCfg params.EncodingConfig) AppConstructor { val.Ctx.Logger, memdb.NewDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, encodingCfg, simapp.EmptyAppOptions{}, - baseapp.SetPruning(storetypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), + baseapp.SetPruning(pruningtypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), baseapp.SetMinGasPrices(val.AppConfig.MinGasPrices), ) } @@ -77,7 +77,7 @@ type Config struct { TxConfig client.TxConfig AccountRetriever client.AccountRetriever AppConstructor AppConstructor // the ABCI application constructor - GenesisState map[string]json.RawMessage // custom gensis state to provide + GenesisState map[string]json.RawMessage // custom genesis state to provide TimeoutCommit time.Duration // the consensus commitment timeout ChainID string // the network chain-id NumValidators int // the total number of validators to create and bond @@ -119,7 +119,7 @@ func DefaultConfig() Config { AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.DefaultPowerReduction), StakingTokens: sdk.TokensFromConsensusPower(500, sdk.DefaultPowerReduction), BondedTokens: sdk.TokensFromConsensusPower(100, sdk.DefaultPowerReduction), - PruningStrategy: storetypes.PruningOptionNothing, + PruningStrategy: pruningtypes.PruningOptionNothing, CleanupDir: true, SigningAlgo: string(hd.Secp256k1Type), KeyringOptions: []keyring.Option{}, @@ -178,21 +178,27 @@ type Logger interface { Logf(format string, args ...interface{}) } -var _ Logger = (*testing.T)(nil) -var _ Logger = (*CLILogger)(nil) +var ( + _ Logger = (*testing.T)(nil) + _ Logger = (*CLILogger)(nil) +) +// CLILogger wraps a cobra.Command and provides command logging methods. type CLILogger struct { cmd *cobra.Command } +// Log logs given args. func (s CLILogger) Log(args ...interface{}) { s.cmd.Println(args...) } +// Logf logs given args according to a format specifier. func (s CLILogger) Logf(format string, args ...interface{}) { s.cmd.Printf(format, args...) } +// NewCLILogger creates a new CLILogger. func NewCLILogger(cmd *cobra.Command) CLILogger { return CLILogger{cmd} } @@ -305,12 +311,12 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { clientDir := filepath.Join(network.BaseDir, nodeDirName, "simcli") gentxsDir := filepath.Join(network.BaseDir, "gentxs") - err := os.MkdirAll(filepath.Join(nodeDir, "config"), 0755) + err := os.MkdirAll(filepath.Join(nodeDir, "config"), 0o755) if err != nil { return nil, err } - err = os.MkdirAll(clientDir, 0755) + err = os.MkdirAll(clientDir, 0o755) if err != nil { return nil, err } diff --git a/testutil/network/network_test.go b/testutil/network/network_test.go index 43859ff5a8a4..c7b5e4291ccc 100644 --- a/testutil/network/network_test.go +++ b/testutil/network/network_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package network_test diff --git a/testutil/network/util.go b/testutil/network/util.go index eeeb043003da..7aa84703ac93 100644 --- a/testutil/network/util.go +++ b/testutil/network/util.go @@ -2,6 +2,7 @@ package network import ( "encoding/json" + "fmt" "io/ioutil" "path/filepath" "time" @@ -16,6 +17,7 @@ import ( "github.com/cosmos/cosmos-sdk/server/api" servergrpc "github.com/cosmos/cosmos-sdk/server/grpc" srvtypes "github.com/cosmos/cosmos-sdk/server/types" + "github.com/cosmos/cosmos-sdk/types/errors" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil" @@ -55,11 +57,11 @@ func startInProcess(cfg Config, val *Validator) error { if val.RPCAddress != "" { node, ok := val.tmNode.(local.NodeService) if !ok { - panic("can't cast service.Service to NodeService") + return fmt.Errorf("failed to cast %T to NodeService", val.tmNode) } val.RPCClient, err = local.New(node) if err != nil { - panic("cant create a local node") + return errors.Wrap(err, "failed to create a local node") } } @@ -97,7 +99,7 @@ func startInProcess(cfg Config, val *Validator) error { } if val.AppConfig.GRPC.Enable { - grpcSrv, err := servergrpc.StartGRPCServer(val.ClientCtx, app, val.AppConfig.GRPC.Address) + grpcSrv, err := servergrpc.StartGRPCServer(val.ClientCtx, app, val.AppConfig.GRPC) if err != nil { return err } @@ -150,7 +152,6 @@ func collectGenFiles(cfg Config, vals []*Validator, outputDir string) error { } func initGenFiles(cfg Config, genAccounts []authtypes.GenesisAccount, genBalances []banktypes.Balance, genFiles []string) error { - // set the accounts in the genesis state var authGenState authtypes.GenesisState cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[authtypes.ModuleName], &authGenState) @@ -195,12 +196,12 @@ func writeFile(name string, dir string, contents []byte) error { writePath := filepath.Join(dir) file := filepath.Join(writePath, name) - err := tmos.EnsureDir(writePath, 0755) + err := tmos.EnsureDir(writePath, 0o755) if err != nil { return err } - err = ioutil.WriteFile(file, contents, 0644) // nolint: gosec + err = ioutil.WriteFile(file, contents, 0o644) // nolint: gosec if err != nil { return err } diff --git a/testutil/rest/rest.go b/testutil/rest/rest.go index e56ef90a201e..c2cd418d0d14 100644 --- a/testutil/rest/rest.go +++ b/testutil/rest/rest.go @@ -16,7 +16,9 @@ func GetRequest(url string) ([]byte, error) { if err != nil { return nil, err } - defer res.Body.Close() + defer func() { + _ = res.Body.Close() + }() body, err := io.ReadAll(res.Body) if err != nil { @@ -33,7 +35,9 @@ func PostRequest(url string, contentType string, data []byte) ([]byte, error) { if err != nil { return nil, fmt.Errorf("error while sending post request: %w", err) } - defer res.Body.Close() + defer func() { + _ = res.Body.Close() + }() bz, err := io.ReadAll(res.Body) if err != nil { diff --git a/testutil/testdata/buf.gen.pulsar.yaml b/testutil/testdata/buf.gen.pulsar.yaml index 1565993c4a94..fbfec36e7610 100644 --- a/testutil/testdata/buf.gen.pulsar.yaml +++ b/testutil/testdata/buf.gen.pulsar.yaml @@ -8,7 +8,7 @@ managed: - buf.build/cosmos/gogo-proto - buf.build/cosmos/cosmos-proto override: - buf.build/cosmos/cosmos-sdk: github.com/cosmos/cosmos-sdk/api + buf.build/cosmos/cosmos-sdk: cosmossdk.io/api plugins: - name: go-pulsar out: ../testdata_pulsar diff --git a/testutil/testdata/table.go b/testutil/testdata/table.go index 8faae88a451d..691d6c8cc34a 100644 --- a/testutil/testdata/table.go +++ b/testutil/testdata/table.go @@ -2,9 +2,7 @@ package testdata import "github.com/cosmos/cosmos-sdk/types/errors" -var ( - ErrTest = errors.Register("table_testdata", 2, "test") -) +var ErrTest = errors.Register("table_testdata", 2, "test") func (g TableModel) PrimaryKeyFields() []interface{} { return []interface{}{g.Id} diff --git a/testutil/testdata/tx.go b/testutil/testdata/tx.go index 5d0051f41a6a..d16dd06d0ebd 100644 --- a/testutil/testdata/tx.go +++ b/testutil/testdata/tx.go @@ -63,6 +63,7 @@ func (msg *TestMsg) GetSignBytes() []byte { } return sdk.MustSortJSON(bz) } + func (msg *TestMsg) GetSigners() []sdk.AccAddress { signers := make([]sdk.AccAddress, 0, len(msg.Signers)) for _, addr := range msg.Signers { @@ -71,6 +72,7 @@ func (msg *TestMsg) GetSigners() []sdk.AccAddress { } return signers } + func (msg *TestMsg) ValidateBasic() error { for _, addr := range msg.Signers { if _, err := sdk.AccAddressFromBech32(addr); err != nil { diff --git a/testutil/testdata_pulsar/unknonwnproto.pulsar.go b/testutil/testdata_pulsar/unknonwnproto.pulsar.go index c362fee3fbf0..db259f82d89e 100644 --- a/testutil/testdata_pulsar/unknonwnproto.pulsar.go +++ b/testutil/testdata_pulsar/unknonwnproto.pulsar.go @@ -2,10 +2,10 @@ package testdata_pulsar import ( + v1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1" binary "encoding/binary" fmt "fmt" runtime "github.com/cosmos/cosmos-proto/runtime" - v1beta1 "github.com/cosmos/cosmos-sdk/api/cosmos/tx/v1beta1" _ "github.com/gogo/protobuf/gogoproto" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoiface "google.golang.org/protobuf/runtime/protoiface" diff --git a/types/abci.pb.go b/types/abci.pb.go index b7f135248421..3aa472625baf 100644 --- a/types/abci.pb.go +++ b/types/abci.pb.go @@ -59,7 +59,7 @@ type TxResponse struct { Timestamp string `protobuf:"bytes,12,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Events defines all the events emitted by processing a transaction. Note, // these events include those emitted by processing all the messages and those - // emitted from the ante handler. Whereas Logs contains the events, with + // emitted from the middleware. Whereas Logs contains the events, with // additional metadata, emitted only by processing the messages. // // Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 diff --git a/types/address.go b/types/address.go index e7486e27a95f..5fd3fa051b32 100644 --- a/types/address.go +++ b/types/address.go @@ -85,6 +85,11 @@ var ( valAddrCache *simplelru.LRU ) +// sentinel errors +var ( + ErrEmptyHexAddress = errors.New("decoding address from hex string failed: empty address") +) + func init() { var err error // in total the cache size is 61k entries. Key is 32 bytes and value is around 50-70 bytes. @@ -113,8 +118,11 @@ type Address interface { // Ensure that different address types implement the interface var _ Address = AccAddress{} -var _ Address = ValAddress{} -var _ Address = ConsAddress{} + +var ( + _ Address = ValAddress{} + _ Address = ConsAddress{} +) // ---------------------------------------------------------------------------- // account @@ -124,8 +132,12 @@ var _ Address = ConsAddress{} // When marshaled to a string or JSON, it uses Bech32. type AccAddress []byte -// AccAddressFromHex creates an AccAddress from a hex string. -func AccAddressFromHex(address string) (addr AccAddress, err error) { +// AccAddressFromHexUnsafe creates an AccAddress from a HEX-encoded string. +// +// Note, this function is considered unsafe as it may produce an AccAddress from +// otherwise invalid input, such as a transaction hash. Please use +// AccAddressFromBech32. +func AccAddressFromHexUnsafe(address string) (addr AccAddress, err error) { bz, err := addressBytesFromHexString(address) return AccAddress(bz), err } @@ -214,7 +226,6 @@ func (aa AccAddress) MarshalYAML() (interface{}, error) { func (aa *AccAddress) UnmarshalJSON(data []byte) error { var s string err := json.Unmarshal(data, &s) - if err != nil { return err } @@ -264,7 +275,7 @@ func (aa AccAddress) String() string { return "" } - var key = conv.UnsafeBytesToStr(aa) + key := conv.UnsafeBytesToStr(aa) accAddrMu.Lock() defer accAddrMu.Unlock() addr, ok := accAddrCache.Get(key) @@ -414,7 +425,7 @@ func (va ValAddress) String() string { return "" } - var key = conv.UnsafeBytesToStr(va) + key := conv.UnsafeBytesToStr(va) valAddrMu.Lock() defer valAddrMu.Unlock() addr, ok := valAddrCache.Get(key) @@ -569,7 +580,7 @@ func (ca ConsAddress) String() string { return "" } - var key = conv.UnsafeBytesToStr(ca) + key := conv.UnsafeBytesToStr(ca) consAddrMu.Lock() defer consAddrMu.Unlock() addr, ok := consAddrCache.Get(key) @@ -642,7 +653,7 @@ func GetFromBech32(bech32str, prefix string) ([]byte, error) { func addressBytesFromHexString(address string) ([]byte, error) { if len(address) == 0 { - return nil, errors.New("decoding Bech32 address failed: must provide an address") + return nil, ErrEmptyHexAddress } return hex.DecodeString(address) diff --git a/types/address/hash_test.go b/types/address/hash_test.go index ae712c18dd4a..06fede65948c 100644 --- a/types/address/hash_test.go +++ b/types/address/hash_test.go @@ -63,7 +63,7 @@ func (suite *AddressSuite) TestComposed() { func (suite *AddressSuite) TestModule() { assert := suite.Assert() - var modName, key = "myModule", []byte{1, 2} + modName, key := "myModule", []byte{1, 2} addr := Module(modName, key) assert.Len(addr, Len, "must have address length") @@ -77,7 +77,7 @@ func (suite *AddressSuite) TestModule() { func (suite *AddressSuite) TestDerive() { assert := suite.Assert() - var addr, key1, key2 = []byte{1, 2}, []byte{3, 4}, []byte{1, 2} + addr, key1, key2 := []byte{1, 2}, []byte{3, 4}, []byte{1, 2} d1 := Derive(addr, key1) d2 := Derive(addr, key2) d3 := Derive(key1, key2) diff --git a/types/address_race_test.go b/types/address_race_test.go index c603df976207..5d363fda1381 100644 --- a/types/address_race_test.go +++ b/types/address_race_test.go @@ -2,7 +2,6 @@ package types_test import ( "encoding/binary" - "fmt" "testing" "time" @@ -33,19 +32,22 @@ func addressStringCaller(require *require.Assertions, prefix byte, max uint32, c } func (s *addressTestSuite) TestAddressRace() { - fmt.Println("starting test") if testing.Short() { s.T().Skip("AddressRace test is not short") } + workers := 4 done := make(chan bool, workers) cancel := make(chan bool) + for i := byte(1); i <= 2; i++ { // workes which will loop in first 100 addresses go addressStringCaller(s.Require(), i, 100, cancel, done) } + for i := byte(1); i <= 2; i++ { // workes which will generate 1e6 new addresses go addressStringCaller(s.Require(), i, 1000000, cancel, done) } + <-time.After(time.Millisecond * 30) close(cancel) diff --git a/types/address_test.go b/types/address_test.go index 251732c03a01..18bb929c61fa 100644 --- a/types/address_test.go +++ b/types/address_test.go @@ -105,13 +105,13 @@ func (s *addressTestSuite) TestRandBech32AccAddrConsistency() { s.Require().Equal(acc, res) str = hex.EncodeToString(acc) - res, err = types.AccAddressFromHex(str) + res, err = types.AccAddressFromHexUnsafe(str) s.Require().Nil(err) s.Require().Equal(acc, res) } for _, str := range invalidStrs { - _, err := types.AccAddressFromHex(str) + _, err := types.AccAddressFromHexUnsafe(str) s.Require().NotNil(err) _, err = types.AccAddressFromBech32(str) @@ -121,8 +121,8 @@ func (s *addressTestSuite) TestRandBech32AccAddrConsistency() { s.Require().NotNil(err) } - _, err := types.AccAddressFromHex("") - s.Require().Equal("decoding Bech32 address failed: must provide an address", err.Error()) + _, err := types.AccAddressFromHexUnsafe("") + s.Require().Equal(types.ErrEmptyHexAddress, err) } func (s *addressTestSuite) TestValAddr() { @@ -163,7 +163,7 @@ func (s *addressTestSuite) TestValAddr() { // test empty string _, err := types.ValAddressFromHex("") - s.Require().Equal("decoding Bech32 address failed: must provide an address", err.Error()) + s.Require().Equal(types.ErrEmptyHexAddress, err) } func (s *addressTestSuite) TestConsAddress() { @@ -203,7 +203,7 @@ func (s *addressTestSuite) TestConsAddress() { // test empty string _, err := types.ConsAddressFromHex("") - s.Require().Equal("decoding Bech32 address failed: must provide an address", err.Error()) + s.Require().Equal(types.ErrEmptyHexAddress, err) } const letterBytes = "abcdefghijklmnopqrstuvwxyz" @@ -298,7 +298,6 @@ func (s *addressTestSuite) TestAddressInterface() { s.T().Fail() } } - } func (s *addressTestSuite) TestVerifyAddressFormat() { diff --git a/types/bench_test.go b/types/bench_test.go index e9ed9fa12bff..639ba471d214 100644 --- a/types/bench_test.go +++ b/types/bench_test.go @@ -3,7 +3,7 @@ package types_test import ( "testing" - "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) var coinStrs = []string{ @@ -14,11 +14,11 @@ var coinStrs = []string{ } func BenchmarkParseCoin(b *testing.B) { - var blankCoin types.Coin + var blankCoin sdk.Coin b.ReportAllocs() for i := 0; i < b.N; i++ { for _, coinStr := range coinStrs { - coin, err := types.ParseCoinNormalized(coinStr) + coin, err := sdk.ParseCoinNormalized(coinStr) if err != nil { b.Fatal(err) } @@ -30,7 +30,7 @@ func BenchmarkParseCoin(b *testing.B) { } func BenchmarkUintMarshal(b *testing.B) { - var values = []uint64{ + values := []uint64{ 0, 1, 1 << 10, @@ -44,7 +44,7 @@ func BenchmarkUintMarshal(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { for _, value := range values { - u := types.NewUint(value) + u := sdk.NewUint(value) n, err := u.MarshalTo(scratch[:]) if err != nil { b.Fatal(err) @@ -55,7 +55,7 @@ func BenchmarkUintMarshal(b *testing.B) { } func BenchmarkIntMarshal(b *testing.B) { - var values = []int64{ + values := []int64{ 0, 1, 1 << 10, @@ -69,7 +69,7 @@ func BenchmarkIntMarshal(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { for _, value := range values { - in := types.NewInt(value) + in := sdk.NewInt(value) n, err := in.MarshalTo(scratch[:]) if err != nil { b.Fatal(err) diff --git a/types/coin.go b/types/coin.go index d523c806154a..c5bf96aeac04 100644 --- a/types/coin.go +++ b/types/coin.go @@ -115,19 +115,29 @@ func (coin Coin) AddAmount(amount Int) Coin { return Coin{coin.Denom, coin.Amount.Add(amount)} } -// Sub subtracts amounts of two coins with same denom. If the coins differ in denom -// then it panics. +// Sub subtracts amounts of two coins with same denom and panics on error. func (coin Coin) Sub(coinB Coin) Coin { + res, err := coin.SafeSub(coinB) + if err != nil { + panic(err) + } + + return res +} + +// SafeSub safely subtracts the amounts of two coins. It returns an error if the coins differ +// in denom or subtraction results in negative coin denom. +func (coin Coin) SafeSub(coinB Coin) (Coin, error) { if coin.Denom != coinB.Denom { - panic(fmt.Sprintf("invalid coin denominations; %s, %s", coin.Denom, coinB.Denom)) + return Coin{}, fmt.Errorf("invalid coin denoms: %s, %s", coin.Denom, coinB.Denom) } res := Coin{coin.Denom, coin.Amount.Sub(coinB.Amount)} if res.IsNegative() { - panic("negative coin amount") + return Coin{}, fmt.Errorf("negative coin amount") } - return res + return res, nil } // SubAmount subtracts an amount from the Coin. @@ -156,7 +166,7 @@ func (coin Coin) IsNegative() bool { // IsNil returns true if the coin amount is nil and false otherwise. func (coin Coin) IsNil() bool { - return coin.Amount.i == nil + return coin.Amount.BigInt() == nil } //----------------------------------------------------------------------------- @@ -383,8 +393,8 @@ func (coins Coins) DenomsSubsetOf(coinsB Coins) bool { // // CONTRACT: Sub will never return Coins where one Coin has a non-positive // amount. In otherwords, IsValid will always return true. -func (coins Coins) Sub(coinsB Coins) Coins { - diff, hasNeg := coins.SafeSub(coinsB) +func (coins Coins) Sub(coinsB ...Coin) Coins { + diff, hasNeg := coins.SafeSub(coinsB...) if hasNeg { panic("negative coin amount") } @@ -395,11 +405,76 @@ func (coins Coins) Sub(coinsB Coins) Coins { // SafeSub performs the same arithmetic as Sub but returns a boolean if any // negative coin amount was returned. // The function panics if `coins` or `coinsB` are not sorted (ascending). -func (coins Coins) SafeSub(coinsB Coins) (Coins, bool) { - diff := coins.safeAdd(coinsB.negative()) +func (coins Coins) SafeSub(coinsB ...Coin) (Coins, bool) { + diff := coins.safeAdd(NewCoins(coinsB...).negative()) return diff, diff.IsAnyNegative() } +// MulInt performs the scalar multiplication of coins with a `multiplier` +// All coins are multipled by x +// e.g. +// {2A, 3B} * 2 = {4A, 6B} +// {2A} * 0 panics +// Note, if IsValid was true on Coins, IsValid stays true. +func (coins Coins) MulInt(x Int) Coins { + coins, ok := coins.SafeMulInt(x) + if !ok { + panic("multiplying by zero is an invalid operation on coins") + } + + return coins +} + +// SafeMulInt performs the same arithmetic as MulInt but returns false +// if the `multiplier` is zero because it makes IsValid return false. +func (coins Coins) SafeMulInt(x Int) (Coins, bool) { + if x.IsZero() { + return nil, false + } + + res := make(Coins, len(coins)) + for i, coin := range coins { + coin := coin + res[i] = NewCoin(coin.Denom, coin.Amount.Mul(x)) + } + + return res, true +} + +// QuoInt performs the scalar division of coins with a `divisor` +// All coins are divided by x and trucated. +// e.g. +// {2A, 30B} / 2 = {1A, 15B} +// {2A} / 2 = {1A} +// {4A} / {8A} = {0A} +// {2A} / 0 = panics +// Note, if IsValid was true on Coins, IsValid stays true, +// unless the `divisor` is greater than the smallest coin amount. +func (coins Coins) QuoInt(x Int) Coins { + coins, ok := coins.SafeQuoInt(x) + if !ok { + panic("dividing by zero is an invalid operation on coins") + } + + return coins +} + +// SafeQuoInt performs the same arithmetic as QuoInt but returns an error +// if the division cannot be done. +func (coins Coins) SafeQuoInt(x Int) (Coins, bool) { + if x.IsZero() { + return nil, false + } + + var res Coins + for _, coin := range coins { + coin := coin + res = append(res, NewCoin(coin.Denom, coin.Amount.Quo(x))) + } + + return res, true +} + // Max takes two valid Coins inputs and returns a valid Coins result // where for every denom D, AmountOf(D) of the result is the maximum // of AmountOf(D) of the inputs. Note that the result might be not @@ -628,28 +703,37 @@ func (coins Coins) AmountOf(denom string) Int { // AmountOfNoDenomValidation returns the amount of a denom from coins // without validating the denomination. func (coins Coins) AmountOfNoDenomValidation(denom string) Int { + if ok, c := coins.Find(denom); ok { + return c.Amount + } + return ZeroInt() +} + +// Find returns true and coin if the denom exists in coins. Otherwise it returns false +// and a zero coin. Uses binary search. +// CONTRACT: coins must be valid (sorted). +func (coins Coins) Find(denom string) (bool, Coin) { switch len(coins) { case 0: - return ZeroInt() + return false, Coin{} case 1: coin := coins[0] if coin.Denom == denom { - return coin.Amount + return true, coin } - return ZeroInt() + return false, Coin{} default: - // Binary search the amount of coins remaining midIdx := len(coins) / 2 // 2:1, 3:1, 4:2 coin := coins[midIdx] switch { case denom < coin.Denom: - return coins[:midIdx].AmountOfNoDenomValidation(denom) + return coins[:midIdx].Find(denom) case denom == coin.Denom: - return coin.Amount + return true, coin default: - return coins[midIdx+1:].AmountOfNoDenomValidation(denom) + return coins[midIdx+1:].Find(denom) } } } @@ -824,13 +908,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/coin_test.go b/types/coin_test.go index 8252b0f1b462..361ddf9ea2d4 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -18,7 +18,7 @@ var ( type coinTestSuite struct { suite.Suite - ca0, ca1, ca2, cm0, cm1, cm2 sdk.Coin + ca0, ca1, ca2, ca4, cm0, cm1, cm2, cm4 sdk.Coin } func TestCoinTestSuite(t *testing.T) { @@ -30,8 +30,10 @@ func (s *coinTestSuite) SetupSuite() { zero := sdk.NewInt(0) one := sdk.OneInt() two := sdk.NewInt(2) - s.ca0, s.ca1, s.ca2 = sdk.Coin{testDenom1, zero}, sdk.Coin{testDenom1, one}, sdk.Coin{testDenom1, two} - s.cm0, s.cm1, s.cm2 = sdk.Coin{testDenom2, zero}, sdk.Coin{testDenom2, one}, sdk.Coin{testDenom2, two} + four := sdk.NewInt(4) + + s.ca0, s.ca1, s.ca2, s.ca4 = sdk.NewCoin(testDenom1, zero), sdk.NewCoin(testDenom1, one), sdk.NewCoin(testDenom1, two), sdk.NewCoin(testDenom1, four) + s.cm0, s.cm1, s.cm2, s.cm4 = sdk.NewCoin(testDenom2, zero), sdk.NewCoin(testDenom2, one), sdk.NewCoin(testDenom2, two), sdk.NewCoin(testDenom2, four) } // ---------------------------------------------------------------------------- @@ -106,7 +108,6 @@ func (s *coinTestSuite) TestCoinIsValid() { } func (s *coinTestSuite) TestCustomValidation() { - newDnmRegex := `[\x{1F600}-\x{1F6FF}]` sdk.SetCoinDenomRegex(func() string { return newDnmRegex @@ -224,6 +225,58 @@ func (s *coinTestSuite) TestSubCoinAmount() { } } +func (s *coinTestSuite) TestMulIntCoins() { + testCases := []struct { + input sdk.Coins + multiplier sdk.Int + expected sdk.Coins + shouldPanic bool + }{ + {sdk.Coins{s.ca2}, sdk.NewInt(0), sdk.Coins{s.ca0}, true}, + {sdk.Coins{s.ca2}, sdk.NewInt(2), sdk.Coins{s.ca4}, false}, + {sdk.Coins{s.ca1, s.cm2}, sdk.NewInt(2), sdk.Coins{s.ca2, s.cm4}, false}, + } + + assert := s.Assert() + for i, tc := range testCases { + tc := tc + if tc.shouldPanic { + assert.Panics(func() { tc.input.MulInt(tc.multiplier) }) + } else { + res := tc.input.MulInt(tc.multiplier) + assert.True(res.IsValid()) + assert.Equal(tc.expected, res, "multiplication of coins is incorrect, tc #%d", i) + } + } +} + +func (s *coinTestSuite) TestQuoIntCoins() { + testCases := []struct { + input sdk.Coins + divisor sdk.Int + expected sdk.Coins + isValid bool + shouldPanic bool + }{ + {sdk.Coins{s.ca2, s.ca1}, sdk.NewInt(0), sdk.Coins{s.ca0, s.ca0}, true, true}, + {sdk.Coins{s.ca2}, sdk.NewInt(4), sdk.Coins{s.ca0}, false, false}, + {sdk.Coins{s.ca2, s.cm4}, sdk.NewInt(2), sdk.Coins{s.ca1, s.cm2}, true, false}, + {sdk.Coins{s.ca4}, sdk.NewInt(2), sdk.Coins{s.ca2}, true, false}, + } + + assert := s.Assert() + for i, tc := range testCases { + tc := tc + if tc.shouldPanic { + assert.Panics(func() { tc.input.QuoInt(tc.divisor) }) + } else { + res := tc.input.QuoInt(tc.divisor) + assert.Equal(tc.isValid, res.IsValid()) + assert.Equal(tc.expected, res, "quotient of coins is incorrect, tc #%d", i) + } + } +} + func (s *coinTestSuite) TestIsGTECoin() { cases := []struct { inputOne sdk.Coin @@ -496,15 +549,39 @@ func (s *coinTestSuite) TestSubCoins() { for i, tc := range testCases { tc := tc if tc.shouldPanic { - assert.Panics(func() { tc.inputOne.Sub(tc.inputTwo) }) + assert.Panics(func() { tc.inputOne.Sub(tc.inputTwo...) }) } else { - res := tc.inputOne.Sub(tc.inputTwo) + res := tc.inputOne.Sub(tc.inputTwo...) assert.True(res.IsValid()) assert.Equal(tc.expected, res, "sum of coins is incorrect, tc #%d", i) } } } +func (s *coinTestSuite) TestSafeSubCoin() { + cases := []struct { + inputOne sdk.Coin + inputTwo sdk.Coin + expected sdk.Coin + expErrMsg string + }{ + {sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt64Coin(testDenom2, 1), sdk.NewInt64Coin(testDenom1, 1), "invalid coin denoms"}, + {sdk.NewInt64Coin(testDenom1, 10), sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt64Coin(testDenom1, 9), ""}, + {sdk.NewInt64Coin(testDenom1, 5), sdk.NewInt64Coin(testDenom1, 0), sdk.NewInt64Coin(testDenom1, 5), ""}, + {sdk.NewInt64Coin(testDenom1, 1), sdk.NewInt64Coin(testDenom1, 5), sdk.Coin{}, "negative coin amount"}, + } + + for _, tc := range cases { + tc := tc + res, err := tc.inputOne.SafeSub(tc.inputTwo) + if err != nil { + s.Require().Contains(err.Error(), tc.expErrMsg) + return + } + s.Require().Equal(tc.expected, res) + } +} + func (s *coinTestSuite) TestCoins_Validate() { testCases := []struct { name string @@ -661,7 +738,8 @@ func (s *coinTestSuite) TestCoins_Validate() { {"mineral", sdk.OneInt()}, }, false, - }, { + }, + { "duplicate denomination", sdk.Coins{ {"gas", sdk.OneInt()}, @@ -697,8 +775,13 @@ func (s *coinTestSuite) TestMinMax() { {"zero-one", sdk.Coins{}, sdk.Coins{{testDenom1, one}}, sdk.Coins{}, sdk.Coins{{testDenom1, one}}}, {"two-zero", sdk.Coins{{testDenom2, two}}, sdk.Coins{}, sdk.Coins{}, sdk.Coins{{testDenom2, two}}}, {"disjoint", sdk.Coins{{testDenom1, one}}, sdk.Coins{{testDenom2, two}}, sdk.Coins{}, sdk.Coins{{testDenom1, one}, {testDenom2, two}}}, - {"overlap", sdk.Coins{{testDenom1, one}, {testDenom2, two}}, sdk.Coins{{testDenom1, two}, {testDenom2, one}}, - sdk.Coins{{testDenom1, one}, {testDenom2, one}}, sdk.Coins{{testDenom1, two}, {testDenom2, two}}}, + { + "overlap", + sdk.Coins{{testDenom1, one}, {testDenom2, two}}, + sdk.Coins{{testDenom1, two}, {testDenom2, one}}, + sdk.Coins{{testDenom1, one}, {testDenom2, one}}, + sdk.Coins{{testDenom1, two}, {testDenom2, two}}, + }, } for _, tc := range cases { @@ -777,6 +860,7 @@ func (s *coinTestSuite) TestParseCoins() { {"10atom10", true, sdk.Coins{{"atom10", sdk.NewInt(10)}}}, {"200transfer/channelToA/uatom", true, sdk.Coins{{"transfer/channelToA/uatom", sdk.NewInt(200)}}}, {"50ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", true, sdk.Coins{{"ibc/7F1D3FCF4AE79E1554D670D1AD949A9BA4E4A3C76C63093E17E446A46061A7A2", sdk.NewInt(50)}}}, + {"120000000000000000000000000000000000000000000000000000000000000000000000000000btc", false, nil}, } for tcIndex, tc := range cases { @@ -852,7 +936,8 @@ func (s *coinTestSuite) TestSortCoins() { } } -func (s *coinTestSuite) TestAmountOf() { +func (s *coinTestSuite) TestSearch() { + require := s.Require() case0 := sdk.Coins{} case1 := sdk.Coins{ sdk.NewInt64Coin("gold", 0), @@ -870,7 +955,7 @@ func (s *coinTestSuite) TestAmountOf() { sdk.NewInt64Coin("gas", 8), } - cases := []struct { + amountOfCases := []struct { coins sdk.Coins amountOf int64 amountOfSpace int64 @@ -885,13 +970,38 @@ func (s *coinTestSuite) TestAmountOf() { {case4, 0, 0, 8, 0, 0}, } - for _, tc := range cases { - s.Require().Equal(sdk.NewInt(tc.amountOfGAS), tc.coins.AmountOf("gas")) - s.Require().Equal(sdk.NewInt(tc.amountOfMINERAL), tc.coins.AmountOf("mineral")) - s.Require().Equal(sdk.NewInt(tc.amountOfTREE), tc.coins.AmountOf("tree")) - } + s.Run("AmountOf", func() { + for i, tc := range amountOfCases { + require.Equal(sdk.NewInt(tc.amountOfGAS), tc.coins.AmountOf("gas"), i) + require.Equal(sdk.NewInt(tc.amountOfMINERAL), tc.coins.AmountOf("mineral"), i) + require.Equal(sdk.NewInt(tc.amountOfTREE), tc.coins.AmountOf("tree"), i) + } + require.Panics(func() { amountOfCases[0].coins.AmountOf("10Invalid") }) + }) - s.Require().Panics(func() { cases[0].coins.AmountOf("10Invalid") }) + zeroCoin := sdk.Coin{} + findCases := []struct { + coins sdk.Coins + denom string + expectedOk bool + expectedCoin sdk.Coin + }{ + {case0, "any", false, zeroCoin}, + {case1, "other", false, zeroCoin}, + {case1, "gold", true, case1[0]}, + {case4, "gas", true, case4[0]}, + {case2, "gas", true, case2[0]}, + {case2, "mineral", true, case2[1]}, + {case2, "tree", true, case2[2]}, + {case2, "other", false, zeroCoin}, + } + s.Run("Find", func() { + for i, tc := range findCases { + ok, c := tc.coins.Find(tc.denom) + require.Equal(tc.expectedOk, ok, i) + require.Equal(tc.expectedCoin, c, i) + } + }) } func (s *coinTestSuite) TestCoinsIsAnyGTE() { @@ -1021,7 +1131,6 @@ func (s *coinTestSuite) TestCoinsIsAnyNil() { s.Require().True(sdk.Coins{twoAtom, nilAtom, fiveAtom, threeEth}.IsAnyNil()) s.Require().True(sdk.Coins{nilAtom, twoAtom, fiveAtom, threeEth}.IsAnyNil()) s.Require().False(sdk.Coins{twoAtom, fiveAtom, threeEth}.IsAnyNil()) - } func (s *coinTestSuite) TestMarshalJSONCoins() { diff --git a/types/context.go b/types/context.go index ffa423f89ef8..38f84843cc1d 100644 --- a/types/context.go +++ b/types/context.go @@ -39,6 +39,7 @@ type Context struct { minGasPrice DecCoins consParams *tmproto.ConsensusParams eventManager *EventManager + priority int64 // The tx priority, only relevant in CheckTx } // Proposed rename, not done to avoid API breakage @@ -59,10 +60,11 @@ func (c Context) IsCheckTx() bool { return c.checkTx } func (c Context) IsReCheckTx() bool { return c.recheckTx } func (c Context) MinGasPrices() DecCoins { return c.minGasPrice } func (c Context) EventManager() *EventManager { return c.eventManager } +func (c Context) Priority() int64 { return c.priority } // clone the header before returning func (c Context) BlockHeader() tmproto.Header { - var msg = proto.Clone(&c.header).(*tmproto.Header) + msg := proto.Clone(&c.header).(*tmproto.Header) return *msg } @@ -227,6 +229,12 @@ func (c Context) WithEventManager(em *EventManager) Context { return c } +// WithEventManager returns a Context with an updated tx priority +func (c Context) WithPriority(p int64) Context { + c.priority = p + return c +} + // TODO: remove??? func (c Context) IsZero() bool { return c.store == nil diff --git a/types/dec_coin.go b/types/dec_coin.go index aebfcc12192c..99c77a970668 100644 --- a/types/dec_coin.go +++ b/types/dec_coin.go @@ -17,7 +17,7 @@ func NewDecCoin(denom string, amount Int) DecCoin { return DecCoin{ Denom: coin.Denom, - Amount: coin.Amount.ToDec(), + Amount: NewDecFromInt(coin.Amount), } } @@ -43,7 +43,7 @@ func NewDecCoinFromCoin(coin Coin) DecCoin { return DecCoin{ Denom: coin.Denom, - Amount: coin.Amount.ToDec(), + Amount: NewDecFromInt(coin.Amount), } } @@ -111,7 +111,7 @@ func (coin DecCoin) Sub(coinB DecCoin) DecCoin { // change. Note, the change may be zero. func (coin DecCoin) TruncateDecimal() (Coin, DecCoin) { truncated := coin.Amount.TruncateInt() - change := coin.Amount.Sub(truncated.ToDec()) + change := coin.Amount.Sub(NewDecFromInt(truncated)) return NewCoin(coin.Denom, truncated), NewDecCoinFromDec(coin.Denom, change) } diff --git a/types/dec_coin_test.go b/types/dec_coin_test.go index 52f50d24fc22..170ec0e53519 100644 --- a/types/dec_coin_test.go +++ b/types/dec_coin_test.go @@ -399,7 +399,8 @@ func (s *decCoinTestSuite) TestParseDecCoins() { }, false, }, - {"0.0stake,0.004stake,5.04atom", // remove zero coins + { + "0.0stake,0.004stake,5.04atom", // remove zero coins sdk.DecCoins{ sdk.NewDecCoinFromDec("atom", sdk.NewDecWithPrec(5040000000000000000, sdk.Precision)), sdk.NewDecCoinFromDec("stake", sdk.NewDecWithPrec(4000000000000000, sdk.Precision)), @@ -644,7 +645,8 @@ func (s *decCoinTestSuite) TestDecCoins_GetDenomByIndex() { sdk.DecCoins{ sdk.DecCoin{testDenom1, sdk.NewDec(5)}, sdk.DecCoin{testDenom2, sdk.NewDec(57)}, - }, 1, testDenom2, false, + }, + 1, testDenom2, false, }, } @@ -710,7 +712,6 @@ func (s *decCoinTestSuite) TestDecCoin_IsLT() { expectedResult bool expectedPanic bool }{ - {"Same Denom - Less than other coin", sdk.DecCoin{testDenom1, sdk.NewDec(3)}, sdk.DecCoin{testDenom1, sdk.NewDec(19)}, true, false}, {"Same Denom - Greater than other coin", sdk.DecCoin{testDenom1, sdk.NewDec(343340)}, sdk.DecCoin{testDenom1, sdk.NewDec(14)}, false, false}, @@ -748,7 +749,6 @@ func (s *decCoinTestSuite) TestDecCoin_IsGTE() { expectedResult bool expectedPanic bool }{ - {"Same Denom - Less than other coin", sdk.DecCoin{testDenom1, sdk.NewDec(3)}, sdk.DecCoin{testDenom1, sdk.NewDec(19)}, false, false}, {"Same Denom - Greater than other coin", sdk.DecCoin{testDenom1, sdk.NewDec(343340)}, sdk.DecCoin{testDenom1, sdk.NewDec(14)}, true, false}, @@ -924,7 +924,6 @@ func (s *decCoinTestSuite) TestDecCoins_MulDecTruncate() { } func (s *decCoinTestSuite) TestDecCoins_QuoDec() { - testCases := []struct { name string coins sdk.DecCoins @@ -985,22 +984,33 @@ func (s *decCoinTestSuite) TestDecCoin_IsEqual() { expectedResult bool expectedPanic bool }{ - - {"Different Denom Same Amount", sdk.DecCoin{testDenom1, sdk.NewDec(20)}, + { + "Different Denom Same Amount", + sdk.DecCoin{testDenom1, sdk.NewDec(20)}, sdk.DecCoin{testDenom2, sdk.NewDec(20)}, - false, true}, + false, true, + }, - {"Different Denom Different Amount", sdk.DecCoin{testDenom1, sdk.NewDec(20)}, + { + "Different Denom Different Amount", + sdk.DecCoin{testDenom1, sdk.NewDec(20)}, sdk.DecCoin{testDenom2, sdk.NewDec(10)}, - false, true}, + false, true, + }, - {"Same Denom Different Amount", sdk.DecCoin{testDenom1, sdk.NewDec(20)}, + { + "Same Denom Different Amount", + sdk.DecCoin{testDenom1, sdk.NewDec(20)}, sdk.DecCoin{testDenom1, sdk.NewDec(10)}, - false, false}, + false, false, + }, - {"Same Denom Same Amount", sdk.DecCoin{testDenom1, sdk.NewDec(20)}, + { + "Same Denom Same Amount", sdk.DecCoin{testDenom1, sdk.NewDec(20)}, - true, false}, + sdk.DecCoin{testDenom1, sdk.NewDec(20)}, + true, false, + }, } for i, tc := range testCases { diff --git a/types/decimal.go b/types/decimal.go index f7d7ad9ffe66..795f4e693139 100644 --- a/types/decimal.go +++ b/types/decimal.go @@ -22,11 +22,16 @@ const ( // number of decimal places Precision = 18 - // bytes required to represent the above precision - // Ceiling[Log2[999 999 999 999 999 999]] + // bits required to represent the above precision + // Ceiling[Log2[10^Precision - 1]] DecimalPrecisionBits = 60 - maxDecBitLen = maxBitLen + DecimalPrecisionBits + // decimalTruncateBits is the minimum number of bits removed + // by a truncate operation. It is equal to + // Floor[Log2[10^Precision - 1]]. + decimalTruncateBits = DecimalPrecisionBits - 1 + + maxDecBitLen = MaxBitLen + decimalTruncateBits // max number of iterations in ApproxRoot function maxApproxRootIterations = 100 @@ -138,7 +143,7 @@ func NewDecFromIntWithPrec(i Int, prec int64) Dec { // CONTRACT - This function does not mutate the input str. func NewDecFromStr(str string) (Dec, error) { if len(str) == 0 { - return Dec{}, ErrEmptyDecimalStr + return Dec{}, fmt.Errorf("%s: %w", str, ErrEmptyDecimalStr) } // first extract any negative symbol @@ -149,7 +154,7 @@ func NewDecFromStr(str string) (Dec, error) { } if len(str) == 0 { - return Dec{}, ErrEmptyDecimalStr + return Dec{}, fmt.Errorf("%s: %w", str, ErrEmptyDecimalStr) } strs := strings.Split(str, ".") @@ -167,7 +172,7 @@ func NewDecFromStr(str string) (Dec, error) { } if lenDecs > Precision { - return Dec{}, fmt.Errorf("invalid precision; max: %d, got: %d", Precision, lenDecs) + return Dec{}, fmt.Errorf("value '%s' exceeds max precision by %d decimal places: max precision %d", str, Precision-lenDecs, Precision) } // add some extra zero's to correct to the Precision factor @@ -177,10 +182,10 @@ func NewDecFromStr(str string) (Dec, error) { combined, ok := new(big.Int).SetString(combinedStr, 10) // base 10 if !ok { - return Dec{}, fmt.Errorf("failed to set decimal string: %s", combinedStr) + return Dec{}, fmt.Errorf("failed to set decimal string with base 10: %s", combinedStr) } if combined.BitLen() > maxDecBitLen { - return Dec{}, fmt.Errorf("decimal out of range; bitLen: got %d, max %d", combined.BitLen(), maxDecBitLen) + return Dec{}, fmt.Errorf("decimal '%s' out of range; bitLen: got %d, max %d", str, combined.BitLen(), maxDecBitLen) } if neg { combined = new(big.Int).Neg(combined) @@ -313,7 +318,7 @@ func (d Dec) MulInt(i Int) Dec { } func (d Dec) MulIntMut(i Int) Dec { - d.i.Mul(d.i, i.i) + d.i.Mul(d.i, i.BigInt()) if d.i.BitLen() > maxDecBitLen { panic("Int overflow") } @@ -397,7 +402,7 @@ func (d Dec) QuoInt(i Int) Dec { } func (d Dec) QuoIntMut(i Int) Dec { - d.i.Quo(d.i, i.i) + d.i.Quo(d.i, i.BigInt()) return d } diff --git a/types/decimal_test.go b/types/decimal_test.go index 742edb60c1e0..a6939c5f7a05 100644 --- a/types/decimal_test.go +++ b/types/decimal_test.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "math/big" + "strings" "testing" "github.com/stretchr/testify/require" @@ -57,10 +58,10 @@ func (s *decimalTestSuite) TestNewDecFromStr() { largeBigInt, ok := new(big.Int).SetString("3144605511029693144278234343371835", 10) s.Require().True(ok) - largerBigInt, ok := new(big.Int).SetString("88888888888888888888888888888888888888888888888888888888888888888888844444440", 10) + largerBigInt, ok := new(big.Int).SetString("8888888888888888888888888888888888888888888888888888888888888888888844444440", 10) s.Require().True(ok) - largestBigInt, ok := new(big.Int).SetString("133499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535", 10) + largestBigInt, ok := new(big.Int).SetString("33499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535", 10) s.Require().True(ok) tests := []struct { @@ -77,18 +78,22 @@ func (s *decimalTestSuite) TestNewDecFromStr() { {"0.8", false, sdk.NewDecWithPrec(8, 1)}, {"0.11111", false, sdk.NewDecWithPrec(11111, 5)}, {"314460551102969.3144278234343371835", true, sdk.NewDec(3141203149163817869)}, - {"314460551102969314427823434337.1835718092488231350", - true, sdk.NewDecFromBigIntWithPrec(largeBigInt, 4)}, - {"314460551102969314427823434337.1835", - false, sdk.NewDecFromBigIntWithPrec(largeBigInt, 4)}, + { + "314460551102969314427823434337.1835718092488231350", + true, sdk.NewDecFromBigIntWithPrec(largeBigInt, 4), + }, + { + "314460551102969314427823434337.1835", + false, sdk.NewDecFromBigIntWithPrec(largeBigInt, 4), + }, {".", true, sdk.Dec{}}, {".0", true, sdk.NewDec(0)}, {"1.", true, sdk.NewDec(1)}, {"foobar", true, sdk.Dec{}}, {"0.foobar", true, sdk.Dec{}}, {"0.foobar.", true, sdk.Dec{}}, - {"88888888888888888888888888888888888888888888888888888888888888888888844444440", false, sdk.NewDecFromBigInt(largerBigInt)}, - {"133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535", false, sdk.NewDecFromBigIntWithPrec(largestBigInt, 18)}, + {"8888888888888888888888888888888888888888888888888888888888888888888844444440", false, sdk.NewDecFromBigInt(largerBigInt)}, + {"33499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535", false, sdk.NewDecFromBigIntWithPrec(largestBigInt, 18)}, {"133499189745056880149688856635597007162669032647290798121690100488888732861291", true, sdk.Dec{}}, } @@ -188,7 +193,6 @@ func (s *decimalTestSuite) TestEqualities() { s.Require().Equal(tc.lt, tc.d1.LT(tc.d2), "LT result is incorrect, tc %d", tcIndex) s.Require().Equal(tc.eq, tc.d1.Equal(tc.d2), "equality result is incorrect, tc %d", tcIndex) } - } func (s *decimalTestSuite) TestDecsEqual() { @@ -232,19 +236,27 @@ func (s *decimalTestSuite) TestArithmetic() { {sdk.NewDec(1), sdk.NewDec(-1), sdk.NewDec(-1), sdk.NewDec(-1), sdk.NewDec(-1), sdk.NewDec(-1), sdk.NewDec(-1), sdk.NewDec(0), sdk.NewDec(2)}, {sdk.NewDec(-1), sdk.NewDec(1), sdk.NewDec(-1), sdk.NewDec(-1), sdk.NewDec(-1), sdk.NewDec(-1), sdk.NewDec(-1), sdk.NewDec(0), sdk.NewDec(-2)}, - {sdk.NewDec(3), sdk.NewDec(7), sdk.NewDec(21), sdk.NewDec(21), + { + sdk.NewDec(3), sdk.NewDec(7), sdk.NewDec(21), sdk.NewDec(21), sdk.NewDecWithPrec(428571428571428571, 18), sdk.NewDecWithPrec(428571428571428572, 18), sdk.NewDecWithPrec(428571428571428571, 18), - sdk.NewDec(10), sdk.NewDec(-4)}, - {sdk.NewDec(2), sdk.NewDec(4), sdk.NewDec(8), sdk.NewDec(8), sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), - sdk.NewDec(6), sdk.NewDec(-2)}, + sdk.NewDec(10), sdk.NewDec(-4), + }, + { + sdk.NewDec(2), sdk.NewDec(4), sdk.NewDec(8), sdk.NewDec(8), sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), + sdk.NewDec(6), sdk.NewDec(-2), + }, {sdk.NewDec(100), sdk.NewDec(100), sdk.NewDec(10000), sdk.NewDec(10000), sdk.NewDec(1), sdk.NewDec(1), sdk.NewDec(1), sdk.NewDec(200), sdk.NewDec(0)}, - {sdk.NewDecWithPrec(15, 1), sdk.NewDecWithPrec(15, 1), sdk.NewDecWithPrec(225, 2), sdk.NewDecWithPrec(225, 2), - sdk.NewDec(1), sdk.NewDec(1), sdk.NewDec(1), sdk.NewDec(3), sdk.NewDec(0)}, - {sdk.NewDecWithPrec(3333, 4), sdk.NewDecWithPrec(333, 4), sdk.NewDecWithPrec(1109889, 8), sdk.NewDecWithPrec(1109889, 8), + { + sdk.NewDecWithPrec(15, 1), sdk.NewDecWithPrec(15, 1), sdk.NewDecWithPrec(225, 2), sdk.NewDecWithPrec(225, 2), + sdk.NewDec(1), sdk.NewDec(1), sdk.NewDec(1), sdk.NewDec(3), sdk.NewDec(0), + }, + { + sdk.NewDecWithPrec(3333, 4), sdk.NewDecWithPrec(333, 4), sdk.NewDecWithPrec(1109889, 8), sdk.NewDecWithPrec(1109889, 8), sdk.MustNewDecFromStr("10.009009009009009009"), sdk.MustNewDecFromStr("10.009009009009009010"), sdk.MustNewDecFromStr("10.009009009009009009"), - sdk.NewDecWithPrec(3666, 4), sdk.NewDecWithPrec(3, 1)}, + sdk.NewDecWithPrec(3666, 4), sdk.NewDecWithPrec(3, 1), + }, } for tcIndex, tc := range tests { @@ -480,10 +492,14 @@ func (s *decimalTestSuite) TestDecSortableBytes() { } func (s *decimalTestSuite) TestDecEncoding() { - largestBigInt, ok := new(big.Int).SetString("133499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535", 10) + largestBigInt, ok := new(big.Int).SetString("33499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535", 10) s.Require().True(ok) - smallestBigInt, ok := new(big.Int).SetString("-133499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535", 10) + smallestBigInt, ok := new(big.Int).SetString("-33499189745056880149688856635597007162669032647290798121690100488888732861290034376435130433535", 10) + s.Require().True(ok) + + const maxDecBitLen = 315 + maxInt, ok := new(big.Int).SetString(strings.Repeat("1", maxDecBitLen), 2) s.Require().True(ok) testCases := []struct { @@ -523,15 +539,21 @@ func (s *decimalTestSuite) TestDecEncoding() { }, { sdk.NewDecFromBigIntWithPrec(largestBigInt, 18), - "313333343939313839373435303536383830313439363838383536363335353937303037313632363639303332363437323930373938313231363930313030343838383838373332383631323930303334333736343335313330343333353335", - "\"133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"", - "\"133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"\n", + "3333343939313839373435303536383830313439363838383536363335353937303037313632363639303332363437323930373938313231363930313030343838383838373332383631323930303334333736343335313330343333353335", + "\"33499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"", + "\"33499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"\n", }, { sdk.NewDecFromBigIntWithPrec(smallestBigInt, 18), - "2D313333343939313839373435303536383830313439363838383536363335353937303037313632363639303332363437323930373938313231363930313030343838383838373332383631323930303334333736343335313330343333353335", - "\"-133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"", - "\"-133499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"\n", + "2D3333343939313839373435303536383830313439363838383536363335353937303037313632363639303332363437323930373938313231363930313030343838383838373332383631323930303334333736343335313330343333353335", + "\"-33499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"", + "\"-33499189745056880149688856635597007162669032647290798121690100488888732861290.034376435130433535\"\n", + }, + { + sdk.NewDecFromBigIntWithPrec(maxInt, 18), + "3636373439353934383732353238343430303734383434343238333137373938353033353831333334353136333233363435333939303630383435303530323434343434333636343330363435303137313838323137353635323136373637", + "\"66749594872528440074844428317798503581334516323645399060845050244444366430645.017188217565216767\"", + "\"66749594872528440074844428317798503581334516323645399060845050244444366430645.017188217565216767\"\n", }, } diff --git a/types/denom.go b/types/denom.go index 0e8d716a2670..df25dd4b55ed 100644 --- a/types/denom.go +++ b/types/denom.go @@ -75,7 +75,7 @@ func ConvertCoin(coin Coin, denom string) (Coin, error) { return NewCoin(denom, coin.Amount), nil } - return NewCoin(denom, coin.Amount.ToDec().Mul(srcUnit).Quo(dstUnit).TruncateInt()), nil + return NewCoin(denom, NewDecFromInt(coin.Amount).Mul(srcUnit).Quo(dstUnit).TruncateInt()), nil } // ConvertDecCoin attempts to convert a decimal coin to a given denomination. If the given diff --git a/types/errors/abci.go b/types/errors/abci.go index fef8dfa8ab69..729e3c554085 100644 --- a/types/errors/abci.go +++ b/types/errors/abci.go @@ -17,6 +17,20 @@ func ResponseCheckTx(err error, gw, gu uint64, debug bool) abci.ResponseCheckTx } } +// ResponseCheckTxWithEvents returns an ABCI ResponseCheckTx object with fields filled in +// from the given error, gas values and events. +func ResponseCheckTxWithEvents(err error, gw, gu uint64, events []abci.Event, debug bool) abci.ResponseCheckTx { + space, code, log := ABCIInfo(err, debug) + return abci.ResponseCheckTx{ + Codespace: space, + Code: code, + Log: log, + GasWanted: int64(gw), + GasUsed: int64(gu), + Events: events, + } +} + // ResponseDeliverTx returns an ABCI ResponseDeliverTx object with fields filled in // from the given error and gas values. func ResponseDeliverTx(err error, gw, gu uint64, debug bool) abci.ResponseDeliverTx { @@ -30,6 +44,20 @@ func ResponseDeliverTx(err error, gw, gu uint64, debug bool) abci.ResponseDelive } } +// ResponseDeliverTxWithEvents returns an ABCI ResponseDeliverTx object with fields filled in +// from the given error, gas values and events. +func ResponseDeliverTxWithEvents(err error, gw, gu uint64, events []abci.Event, debug bool) abci.ResponseDeliverTx { + space, code, log := ABCIInfo(err, debug) + return abci.ResponseDeliverTx{ + Codespace: space, + Code: code, + Log: log, + GasWanted: int64(gw), + GasUsed: int64(gu), + Events: events, + } +} + // QueryResult returns a ResponseQuery from an error. It will try to parse ABCI // info from the error. func QueryResult(err error, debug bool) abci.ResponseQuery { diff --git a/types/errors/doc.go b/types/errors/doc.go index 31f9e6cdaa1d..e55370a43d39 100644 --- a/types/errors/doc.go +++ b/types/errors/doc.go @@ -1,9 +1,9 @@ // Package errors provides a shared set of errors for use in the SDK, -// aliases functionality in the github.com/cosmos/cosmos-sdk/errors module +// aliases functionality in the cosmossdk.io/errors module // that used to be in this package, and provides some helpers for converting // errors to ABCI response code. // -// New code should generally import github.com/cosmos/cosmos-sdk/errors directly +// New code should generally import cosmossdk.io/errors directly // and define a custom set of errors in custom codespace, rather than importing // this package. package errors diff --git a/types/errors/errors.go b/types/errors/errors.go index aa6bffe0616d..f16464eca45b 100644 --- a/types/errors/errors.go +++ b/types/errors/errors.go @@ -1,13 +1,13 @@ package errors import ( - errorsmod "github.com/cosmos/cosmos-sdk/errors" + errorsmod "cosmossdk.io/errors" ) // Type Aliases to errors module // // Deprecated: functionality of this package has been moved to it's own module: -// github.com/cosmos/cosmos-sdk/errors +// cosmossdk.io/errors // Please use the above module instead of this package. var ( SuccessABCICode = errorsmod.SuccessABCICode @@ -27,7 +27,7 @@ var ( // Error type alias for errorsmod.Error // -// Deprecated: the type has been moved to github.com/cosmos/cosmos-sdk/errors +// Deprecated: the type has been moved to cosmossdk.io/errors // module. Please use the above module instead of this package. type Error = errorsmod.Error diff --git a/types/events.go b/types/events.go index 664a0082f8aa..dbff89ce2d02 100644 --- a/types/events.go +++ b/types/events.go @@ -211,7 +211,7 @@ func (e Events) ToABCIEvents() []abci.Event { } // Common event types and attribute keys -var ( +const ( EventTypeTx = "tx" AttributeKeyAccountSequence = "acc_seq" diff --git a/types/events_test.go b/types/events_test.go index 87622550d26a..df49138d4f09 100644 --- a/types/events_test.go +++ b/types/events_test.go @@ -103,20 +103,43 @@ func (s *eventsTestSuite) TestEventManagerTypedEvents() { } func (s *eventsTestSuite) TestStringifyEvents() { - e := sdk.Events{ - sdk.NewEvent("message", sdk.NewAttribute("sender", "foo")), - sdk.NewEvent("message", sdk.NewAttribute("module", "bank")), + cases := []struct { + name string + events sdk.Events + expTxtStr string + expJSONStr string + }{ + { + name: "default", + events: sdk.Events{ + sdk.NewEvent("message", sdk.NewAttribute(sdk.AttributeKeySender, "foo")), + sdk.NewEvent("message", sdk.NewAttribute(sdk.AttributeKeyModule, "bank")), + }, + expTxtStr: "\t\t- message\n\t\t\t- sender: foo\n\t\t\t- module: bank", + expJSONStr: "[{\"type\":\"message\",\"attributes\":[{\"key\":\"sender\",\"value\":\"foo\"},{\"key\":\"module\",\"value\":\"bank\"}]}]", + }, + { + name: "multiple events with same attributes", + events: sdk.Events{ + sdk.NewEvent( + "message", + sdk.NewAttribute(sdk.AttributeKeyModule, "staking"), + sdk.NewAttribute(sdk.AttributeKeySender, "cosmos1foo"), + ), + sdk.NewEvent("message", sdk.NewAttribute(sdk.AttributeKeySender, "foo")), + }, + expTxtStr: "\t\t- message\n\t\t\t- module: staking\n\t\t\t- sender: cosmos1foo\n\t\t\t- sender: foo", + expJSONStr: `[{"type":"message","attributes":[{"key":"module","value":"staking"},{"key":"sender","value":"cosmos1foo"},{"key":"sender","value":"foo"}]}]`, + }, } - se := sdk.StringifyEvents(e.ToABCIEvents()) - - expectedTxtStr := "\t\t- message\n\t\t\t- sender: foo\n\t\t\t- module: bank" - s.Require().Equal(expectedTxtStr, se.String()) - bz, err := json.Marshal(se) - s.Require().NoError(err) - - expectedJSONStr := "[{\"type\":\"message\",\"attributes\":[{\"key\":\"sender\",\"value\":\"foo\"},{\"key\":\"module\",\"value\":\"bank\"}]}]" - s.Require().Equal(expectedJSONStr, string(bz)) + for _, test := range cases { + se := sdk.StringifyEvents(test.events.ToABCIEvents()) + s.Require().Equal(test.expTxtStr, se.String()) + bz, err := json.Marshal(se) + s.Require().NoError(err) + s.Require().Equal(test.expJSONStr, string(bz)) + } } func (s *eventsTestSuite) TestMarkEventsToIndex() { diff --git a/types/math.go b/types/math.go new file mode 100644 index 000000000000..be46b0591677 --- /dev/null +++ b/types/math.go @@ -0,0 +1,37 @@ +package types + +import ( + sdkmath "cosmossdk.io/math" +) + +// Type aliases to the SDK's math sub-module +// +// Deprecated: Functionality of this package has been moved to it's own module: +// cosmossdk.io/math +// +// Please use the above module instead of this package. +type ( + Int = sdkmath.Int + Uint = sdkmath.Uint +) + +var ( + NewIntFromBigInt = sdkmath.NewIntFromBigInt + OneInt = sdkmath.OneInt + NewInt = sdkmath.NewInt + ZeroInt = sdkmath.ZeroInt + IntEq = sdkmath.IntEq + NewIntFromString = sdkmath.NewIntFromString + NewUint = sdkmath.NewUint + NewIntFromUint64 = sdkmath.NewIntFromUint64 + MaxInt = sdkmath.MaxInt + MinInt = sdkmath.MinInt +) + +const ( + MaxBitLen = sdkmath.MaxBitLen +) + +func (ip IntProto) String() string { + return ip.Int.String() +} diff --git a/types/module/module.go b/types/module/module.go index 4128d781adfc..81bd7b246913 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -33,7 +33,6 @@ import ( "fmt" "sort" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -55,7 +54,6 @@ type AppModuleBasic interface { ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage) error // client functionality - RegisterRESTRoutes(client.Context, *mux.Router) RegisterGRPCGatewayRoutes(client.Context, *runtime.ServeMux) GetTxCmd() *cobra.Command GetQueryCmd() *cobra.Command @@ -108,13 +106,6 @@ func (bm BasicManager) ValidateGenesis(cdc codec.JSONCodec, txEncCfg client.TxEn return nil } -// RegisterRESTRoutes registers all module rest routes -func (bm BasicManager) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - for _, b := range bm { - b.RegisterRESTRoutes(clientCtx, rtr) - } -} - // RegisterGRPCGatewayRoutes registers all module rest routes func (bm BasicManager) RegisterGRPCGatewayRoutes(clientCtx client.Context, rtr *runtime.ServeMux) { for _, b := range bm { @@ -235,7 +226,6 @@ type Manager struct { // NewManager creates a new Manager object func NewManager(modules ...AppModule) *Manager { - moduleMap := make(map[string]AppModule) modulesStr := make([]string, 0, len(modules)) for _, module := range modules { @@ -368,7 +358,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)) } } @@ -431,7 +421,7 @@ func (m Manager) RunMigrations(ctx sdk.Context, cfg Configurator, fromVM Version if !ok { return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", configurator{}, cfg) } - var modules = m.OrderMigrations + modules := m.OrderMigrations if modules == nil { modules = DefaultMigrationsOrder(m.ModuleNames()) } diff --git a/types/module/module_test.go b/types/module/module_test.go index 4dbb4a73c5b6..37bbf088cc70 100644 --- a/types/module/module_test.go +++ b/types/module/module_test.go @@ -5,7 +5,6 @@ import ( "errors" "testing" - "github.com/gorilla/mux" "github.com/golang/mock/gomock" "github.com/spf13/cobra" "github.com/stretchr/testify/require" @@ -13,9 +12,9 @@ import ( "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/tests/mocks" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -41,7 +40,6 @@ func TestBasicManager(t *testing.T) { mockAppModuleBasic1.EXPECT().ValidateGenesis(gomock.Eq(cdc), gomock.Eq(nil), gomock.Eq(wantDefaultGenesis["mockAppModuleBasic1"])).Times(1).Return(errFoo) mockAppModuleBasic1.EXPECT().RegisterLegacyAminoCodec(gomock.Eq(legacyAmino)).Times(1) mockAppModuleBasic1.EXPECT().RegisterInterfaces(gomock.Eq(interfaceRegistry)).Times(1) - mockAppModuleBasic1.EXPECT().RegisterRESTRoutes(gomock.Eq(client.Context{}), gomock.Eq(&mux.Router{})).Times(1) mockAppModuleBasic1.EXPECT().GetTxCmd().Times(1).Return(nil) mockAppModuleBasic1.EXPECT().GetQueryCmd().Times(1).Return(nil) @@ -58,8 +56,6 @@ func TestBasicManager(t *testing.T) { require.True(t, errors.Is(errFoo, mm.ValidateGenesis(cdc, nil, wantDefaultGenesis))) - mm.RegisterRESTRoutes(client.Context{}, &mux.Router{}) - mockCmd := &cobra.Command{Use: "root"} mm.AddTxCommands(mockCmd) @@ -213,7 +209,8 @@ func TestManager_InitGenesis(t *testing.T) { // test panic genesisData = map[string]json.RawMessage{ "module1": json.RawMessage(`{"key": "value"}`), - "module2": json.RawMessage(`{"key": "value"}`)} + "module2": json.RawMessage(`{"key": "value"}`), + } mockAppModule1.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(cdc), gomock.Eq(genesisData["module1"])).Times(1).Return([]abci.ValidatorUpdate{{}}) mockAppModule2.EXPECT().InitGenesis(gomock.Eq(ctx), gomock.Eq(cdc), gomock.Eq(genesisData["module2"])).Times(1).Return([]abci.ValidatorUpdate{{}}) require.Panics(t, func() { mm.InitGenesis(ctx, cdc, genesisData) }) @@ -239,7 +236,8 @@ func TestManager_ExportGenesis(t *testing.T) { want := map[string]json.RawMessage{ "module1": json.RawMessage(`{"key1": "value1"}`), - "module2": json.RawMessage(`{"key2": "value2"}`)} + "module2": json.RawMessage(`{"key2": "value2"}`), + } require.Equal(t, want, mm.ExportGenesis(ctx, cdc)) } diff --git a/types/module/simulation.go b/types/module/simulation.go index 252cf268f837..591e11e0846a 100644 --- a/types/module/simulation.go +++ b/types/module/simulation.go @@ -2,10 +2,10 @@ package module import ( "encoding/json" - "math/rand" "time" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/simulation" @@ -103,7 +103,7 @@ type SimulationState struct { Rand *rand.Rand // random number GenState map[string]json.RawMessage // genesis state Accounts []simulation.Account // simulation accounts - InitialStake int64 // initial coins per account + InitialStake sdkmath.Int // initial coins per account NumBonded int64 // number of initially bonded accounts GenTimestamp time.Time // genesis timestamp UnbondTime time.Duration // staking unbond time stored to use it as the slashing maximum evidence duration diff --git a/types/query/filtered_pagination.go b/types/query/filtered_pagination.go index 47dd31aaba71..0f755c55e788 100644 --- a/types/query/filtered_pagination.go +++ b/types/query/filtered_pagination.go @@ -19,7 +19,6 @@ func FilteredPaginate( pageRequest *PageRequest, onResult func(key []byte, value []byte, accumulate bool) (bool, error), ) (*PageResponse, error) { - // if the PageRequest is nil, use default PageRequest if pageRequest == nil { pageRequest = &PageRequest{} diff --git a/types/query/filtered_pagination_test.go b/types/query/filtered_pagination_test.go index 694d0c3cbbcd..08ba8513a9d1 100644 --- a/types/query/filtered_pagination_test.go +++ b/types/query/filtered_pagination_test.go @@ -168,7 +168,6 @@ func (s *paginationTestSuite) TestReverseFilteredPaginations() { s.T().Log("verify Reverse pagination returns valid result") s.Require().Equal(balances[235:241].String(), balns.Sort().String()) - } func ExampleFilteredPaginate(t *testing.T) { @@ -218,7 +217,6 @@ func ExampleFilteredPaginate(t *testing.T) { return false, nil }) - if err != nil { // should return no error fmt.Println(err) } diff --git a/types/query/pagination.go b/types/query/pagination.go index e5cd71b71c83..a01587387d12 100644 --- a/types/query/pagination.go +++ b/types/query/pagination.go @@ -54,7 +54,6 @@ func Paginate( pageRequest *PageRequest, onResult func(key []byte, value []byte) error, ) (*PageResponse, error) { - // if the PageRequest is nil, use default PageRequest if pageRequest == nil { pageRequest = &PageRequest{} diff --git a/types/result.go b/types/result.go index 38787e8eb5eb..29b607a298cc 100644 --- a/types/result.go +++ b/types/result.go @@ -230,8 +230,8 @@ func (r TxResponse) GetTx() Tx { return nil } -// WrapServiceResult wraps a result from a protobuf RPC service method call in -// a Result object or error. This method takes care of marshaling the res param to +// WrapServiceResult wraps a result from a protobuf RPC service method call (res proto.Message, err error) +// in a Result object or error. This method takes care of marshaling the res param to // protobuf and attaching any events on the ctx.EventManager() to the Result. func WrapServiceResult(ctx Context, res proto.Message, err error) (*Result, error) { if err != nil { diff --git a/types/simulation/rand_util.go b/types/simulation/rand_util.go index f136da396990..ce64bd7e8645 100644 --- a/types/simulation/rand_util.go +++ b/types/simulation/rand_util.go @@ -53,7 +53,7 @@ func RandPositiveInt(r *rand.Rand, max sdk.Int) (sdk.Int, error) { // RandomAmount generates a random amount // Note: The range of RandomAmount includes max, and is, in fact, biased to return max as well as 0. func RandomAmount(r *rand.Rand, max sdk.Int) sdk.Int { - var randInt = big.NewInt(0) + randInt := big.NewInt(0) switch r.Intn(10) { case 0: @@ -70,7 +70,7 @@ func RandomAmount(r *rand.Rand, max sdk.Int) sdk.Int { // RandomDecAmount generates a random decimal amount // Note: The range of RandomDecAmount includes max, and is, in fact, biased to return max as well as 0. func RandomDecAmount(r *rand.Rand, max sdk.Dec) sdk.Dec { - var randInt = big.NewInt(0) + randInt := big.NewInt(0) switch r.Intn(10) { case 0: diff --git a/types/simulation/types.go b/types/simulation/types.go index 7efb64ba3149..199f47fa38e2 100644 --- a/types/simulation/types.go +++ b/types/simulation/types.go @@ -84,7 +84,6 @@ func NewOperationMsg(msg sdk.Msg, ok bool, comment string, cdc *codec.ProtoCodec bz := cdc.MustMarshalJSON(msg) return NewOperationMsgBasic(sdk.MsgTypeURL(msg), sdk.MsgTypeURL(msg), comment, ok, bz) - } // NoOpMsg - create a no-operation message diff --git a/types/store.go b/types/store.go index 70a9b4c645aa..1de65928024e 100644 --- a/types/store.go +++ b/types/store.go @@ -11,7 +11,6 @@ import ( ) type ( - PruningOptions = types2.PruningOptions Queryable = types2.Queryable KVStore = types2.KVStore Iterator = types2.Iterator @@ -150,15 +149,15 @@ type ( GasConfig = types.GasConfig ) -func NewGasMeter(limit Gas) GasMeter { - return types.NewGasMeter(limit) -} - type ( ErrorOutOfGas = types.ErrorOutOfGas ErrorGasOverflow = types.ErrorGasOverflow ) +func NewGasMeter(limit Gas) GasMeter { + return types.NewGasMeter(limit) +} + func NewInfiniteGasMeter() GasMeter { return types.NewInfiniteGasMeter() } diff --git a/types/store_internal_test.go b/types/store_internal_test.go index e55ae175dbdc..2ec4c6944cf0 100644 --- a/types/store_internal_test.go +++ b/types/store_internal_test.go @@ -16,7 +16,7 @@ func TestStoreIntSuite(t *testing.T) { } func (s *storeIntSuite) TestAssertNoPrefix() { - var testCases = []struct { + testCases := []struct { keys []string expectPanic bool }{ diff --git a/types/store_test.go b/types/store_test.go index d2039f8cb896..0588e40b6e4d 100644 --- a/types/store_test.go +++ b/types/store_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/stretchr/testify/suite" + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/store/rootmulti" @@ -24,7 +25,7 @@ func (s *storeTestSuite) SetupSuite() { } func (s *storeTestSuite) TestPrefixEndBytes() { - var testCases = []struct { + testCases := []struct { prefix []byte expected []byte }{ @@ -47,7 +48,7 @@ func (s *storeTestSuite) TestCommitID() { var empty types.CommitID s.Require().True(empty.IsZero()) - var nonempty = types.CommitID{ + nonempty := types.CommitID{ Version: 1, Hash: []byte("testhash"), } @@ -108,7 +109,7 @@ func (s *storeTestSuite) TestDiffKVStores() { func (s *storeTestSuite) initTestStores() (types.KVStore, types.KVStore) { db := dbm.NewMemDB() - ms := rootmulti.NewStore(db) + ms := rootmulti.NewStore(db, log.NewNopLogger()) key1 := types.NewKVStoreKey("store1") key2 := types.NewKVStoreKey("store2") diff --git a/types/tx/middleware.go b/types/tx/middleware.go deleted file mode 100644 index abe29be672d8..000000000000 --- a/types/tx/middleware.go +++ /dev/null @@ -1,71 +0,0 @@ -package tx - -import ( - context "context" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - abci "github.com/tendermint/tendermint/abci/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// RequestSimulateTx is the request type for the tx.Handler.RequestSimulateTx -// method. -type RequestSimulateTx struct { - TxBytes []byte -} - -// ResponseSimulateTx is the response type for the tx.Handler.RequestSimulateTx -// method. -type ResponseSimulateTx struct { - GasInfo sdk.GasInfo - Result *sdk.Result -} - -// Request is the tx request type used in middlewares. -// At least one of Tx or TxBytes must be set. If only TxBytes is set, then -// Tx will be populated by the TxDecoderMiddleware. If only Tx is set, then -// some middlewares (such as signature verification) will fail. -// -// In practice, the middleware stack is called from {Check,Deliver}Tx, which -// only passes the TxBytes. Then, the TxDecoderMiddleware decodes the bytes -// into the Tx field. -type Request struct { - Tx sdk.Tx - TxBytes []byte -} - -// Response is the tx response type used in middlewares. -type Response struct { - GasWanted uint64 - GasUsed uint64 - // MsgResponses is an array containing each Msg service handler's response - // type, packed in an Any. This will get proto-serialized into the `Data` field - // in the ABCI Check/DeliverTx responses. - MsgResponses []*codectypes.Any - Log string - Events []abci.Event -} - -// RequestCheckTx is the additional request type used in middlewares CheckTx -// method. -type RequestCheckTx struct { - Type abci.CheckTxType -} - -// RequestCheckTx is the additional response type used in middlewares CheckTx -// method. -type ResponseCheckTx struct { - Priority int64 -} - -// TxHandler defines the baseapp's CheckTx, DeliverTx and Simulate respective -// handlers. It is designed as a middleware stack. -type Handler interface { - CheckTx(ctx context.Context, req Request, checkReq RequestCheckTx) (Response, ResponseCheckTx, error) - DeliverTx(ctx context.Context, req Request) (Response, error) - SimulateTx(ctx context.Context, req Request) (Response, error) -} - -// TxMiddleware defines one layer of the TxHandler middleware stack. -type Middleware func(Handler) Handler diff --git a/types/tx/signing/signature.go b/types/tx/signing/signature.go index 1323543f023a..c5faf4b8d1d4 100644 --- a/types/tx/signing/signature.go +++ b/types/tx/signing/signature.go @@ -92,7 +92,6 @@ var _, _ codectypes.UnpackInterfacesMessage = &SignatureDescriptors{}, &Signatur func (sds *SignatureDescriptors) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error { for _, sig := range sds.Signatures { err := sig.UnpackInterfaces(unpacker) - if err != nil { return err } diff --git a/types/tx/signing/signing.pb.go b/types/tx/signing/signing.pb.go index 10226405243b..95989270b493 100644 --- a/types/tx/signing/signing.pb.go +++ b/types/tx/signing/signing.pb.go @@ -58,7 +58,13 @@ const ( // 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 + // 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 SignMode_SIGN_MODE_EIP_191 SignMode = 191 ) diff --git a/types/tx/tx.pb.go b/types/tx/tx.pb.go index d16c7898116b..ca8ae7806c86 100644 --- a/types/tx/tx.pb.go +++ b/types/tx/tx.pb.go @@ -922,11 +922,11 @@ type AuxSignerData struct { // AuxSignerData across different chains, the bech32 prefix of the target // chain (where the final transaction is broadcasted) should be used. Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - // sign_doc is the SIGN_MOD_DIRECT_AUX sign doc that the auxiliary signer + // sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the auxiliary signer // signs. Note: we use the same sign doc even if we're signing with // LEGACY_AMINO_JSON. SignDoc *SignDocDirectAux `protobuf:"bytes,2,opt,name=sign_doc,json=signDoc,proto3" json:"sign_doc,omitempty"` - // mode is the signing mode of the single signer + // mode is the signing mode of the single signer. Mode signing.SignMode `protobuf:"varint,3,opt,name=mode,proto3,enum=cosmos.tx.signing.v1beta1.SignMode" json:"mode,omitempty"` // sig is the signature of the sign doc. Sig []byte `protobuf:"bytes,4,opt,name=sig,proto3" json:"sig,omitempty"` diff --git a/types/tx/types.go b/types/tx/types.go index cbdb50a43ca4..a4816b1283a6 100644 --- a/types/tx/types.go +++ b/types/tx/types.go @@ -128,9 +128,11 @@ func (t *Tx) GetSigners() []sdk.AccAddress { func (t *Tx) GetGas() uint64 { return t.AuthInfo.Fee.GasLimit } + func (t *Tx) GetFee() sdk.Coins { return t.AuthInfo.Fee.Amount } + func (t *Tx) FeePayer() sdk.AccAddress { feePayer := t.AuthInfo.Fee.Payer if feePayer != "" { diff --git a/types/uint_test.go b/types/uint_test.go deleted file mode 100644 index b91f9ab4a96a..000000000000 --- a/types/uint_test.go +++ /dev/null @@ -1,326 +0,0 @@ -package types_test - -import ( - "fmt" - "math" - "math/big" - "math/rand" - "testing" - - "github.com/stretchr/testify/suite" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type uintTestSuite struct { - suite.Suite -} - -func TestUnitTestSuite(t *testing.T) { - suite.Run(t, new(uintTestSuite)) -} - -func (s *uintTestSuite) SetupSuite() { - s.T().Parallel() -} - -func (s *uintTestSuite) TestUintPanics() { - // Max Uint = 1.15e+77 - // Min Uint = 0 - u1 := sdk.NewUint(0) - u2 := sdk.OneUint() - - s.Require().Equal(uint64(0), u1.Uint64()) - s.Require().Equal(uint64(1), u2.Uint64()) - - s.Require().Panics(func() { sdk.NewUintFromBigInt(big.NewInt(-5)) }) - s.Require().Panics(func() { sdk.NewUintFromString("-1") }) - s.Require().NotPanics(func() { - s.Require().True(sdk.NewUintFromString("0").Equal(sdk.ZeroUint())) - s.Require().True(sdk.NewUintFromString("5").Equal(sdk.NewUint(5))) - }) - - // Overflow check - s.Require().True(u1.Add(u1).Equal(sdk.ZeroUint())) - s.Require().True(u1.Add(sdk.OneUint()).Equal(sdk.OneUint())) - s.Require().Equal(uint64(0), u1.Uint64()) - s.Require().Equal(uint64(1), sdk.OneUint().Uint64()) - s.Require().Panics(func() { u1.SubUint64(2) }) - s.Require().True(u1.SubUint64(0).Equal(sdk.ZeroUint())) - s.Require().True(u2.Add(sdk.OneUint()).Sub(sdk.OneUint()).Equal(sdk.OneUint())) // i2 == 1 - s.Require().True(u2.Add(sdk.OneUint()).Mul(sdk.NewUint(5)).Equal(sdk.NewUint(10))) // i2 == 10 - s.Require().True(sdk.NewUint(7).Quo(sdk.NewUint(2)).Equal(sdk.NewUint(3))) - s.Require().True(sdk.NewUint(0).Quo(sdk.NewUint(2)).Equal(sdk.ZeroUint())) - s.Require().True(sdk.NewUint(5).MulUint64(4).Equal(sdk.NewUint(20))) - s.Require().True(sdk.NewUint(5).MulUint64(0).Equal(sdk.ZeroUint())) - - uintmax := sdk.NewUintFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(256), nil), big.NewInt(1))) - uintmin := sdk.ZeroUint() - - // divs by zero - s.Require().Panics(func() { sdk.OneUint().Mul(sdk.ZeroUint().SubUint64(uint64(1))) }) - s.Require().Panics(func() { sdk.OneUint().QuoUint64(0) }) - s.Require().Panics(func() { sdk.OneUint().Quo(sdk.ZeroUint()) }) - s.Require().Panics(func() { sdk.ZeroUint().QuoUint64(0) }) - s.Require().Panics(func() { sdk.OneUint().Quo(sdk.ZeroUint().Sub(sdk.OneUint())) }) - s.Require().Panics(func() { uintmax.Add(sdk.OneUint()) }) - s.Require().Panics(func() { uintmax.Incr() }) - s.Require().Panics(func() { uintmin.Sub(sdk.OneUint()) }) - s.Require().Panics(func() { uintmin.Decr() }) - - s.Require().Equal(uint64(0), sdk.MinUint(sdk.ZeroUint(), sdk.OneUint()).Uint64()) - s.Require().Equal(uint64(1), sdk.MaxUint(sdk.ZeroUint(), sdk.OneUint()).Uint64()) - - // comparison ops - s.Require().True( - sdk.OneUint().GT(sdk.ZeroUint()), - ) - s.Require().False( - sdk.OneUint().LT(sdk.ZeroUint()), - ) - s.Require().True( - sdk.OneUint().GTE(sdk.ZeroUint()), - ) - s.Require().False( - sdk.OneUint().LTE(sdk.ZeroUint()), - ) - - s.Require().False(sdk.ZeroUint().GT(sdk.OneUint())) - s.Require().True(sdk.ZeroUint().LT(sdk.OneUint())) - s.Require().False(sdk.ZeroUint().GTE(sdk.OneUint())) - s.Require().True(sdk.ZeroUint().LTE(sdk.OneUint())) -} - -func (s *uintTestSuite) TestArithUint() { - for d := 0; d < 1000; d++ { - n1 := uint64(rand.Uint32()) - u1 := sdk.NewUint(n1) - n2 := uint64(rand.Uint32()) - u2 := sdk.NewUint(n2) - - cases := []struct { - ures sdk.Uint - nres uint64 - }{ - {u1.Add(u2), n1 + n2}, - {u1.Mul(u2), n1 * n2}, - {u1.Quo(u2), n1 / n2}, - {u1.AddUint64(n2), n1 + n2}, - {u1.MulUint64(n2), n1 * n2}, - {u1.QuoUint64(n2), n1 / n2}, - {sdk.MinUint(u1, u2), minuint(n1, n2)}, - {sdk.MaxUint(u1, u2), maxuint(n1, n2)}, - {u1.Incr(), n1 + 1}, - } - - for tcnum, tc := range cases { - s.Require().Equal(tc.nres, tc.ures.Uint64(), "Uint arithmetic operation does not match with uint64 operation. tc #%d", tcnum) - } - - if n2 > n1 { - n1, n2 = n2, n1 - u1, u2 = sdk.NewUint(n1), sdk.NewUint(n2) - } - - subs := []struct { - ures sdk.Uint - nres uint64 - }{ - {u1.Sub(u2), n1 - n2}, - {u1.SubUint64(n2), n1 - n2}, - {u1.Decr(), n1 - 1}, - } - - for tcnum, tc := range subs { - s.Require().Equal(tc.nres, tc.ures.Uint64(), "Uint subtraction does not match with uint64 operation. tc #%d", tcnum) - } - } -} - -func (s *uintTestSuite) TestCompUint() { - for d := 0; d < 10000; d++ { - n1 := rand.Uint64() - i1 := sdk.NewUint(n1) - n2 := rand.Uint64() - i2 := sdk.NewUint(n2) - - cases := []struct { - ires bool - nres bool - }{ - {i1.Equal(i2), n1 == n2}, - {i1.GT(i2), n1 > n2}, - {i1.LT(i2), n1 < n2}, - {i1.GTE(i2), !i1.LT(i2)}, - {!i1.GTE(i2), i1.LT(i2)}, - {i1.LTE(i2), n1 <= n2}, - {i2.LTE(i1), n2 <= n1}, - } - - for tcnum, tc := range cases { - s.Require().Equal(tc.nres, tc.ires, "Uint comparison operation does not match with uint64 operation. tc #%d", tcnum) - } - } -} - -func (s *uintTestSuite) TestImmutabilityAllUint() { - ops := []func(*sdk.Uint){ - func(i *sdk.Uint) { _ = i.Add(sdk.NewUint(rand.Uint64())) }, - func(i *sdk.Uint) { _ = i.Sub(sdk.NewUint(rand.Uint64() % i.Uint64())) }, - func(i *sdk.Uint) { _ = i.Mul(randuint()) }, - func(i *sdk.Uint) { _ = i.Quo(randuint()) }, - func(i *sdk.Uint) { _ = i.AddUint64(rand.Uint64()) }, - func(i *sdk.Uint) { _ = i.SubUint64(rand.Uint64() % i.Uint64()) }, - func(i *sdk.Uint) { _ = i.MulUint64(rand.Uint64()) }, - func(i *sdk.Uint) { _ = i.QuoUint64(rand.Uint64()) }, - func(i *sdk.Uint) { _ = i.IsZero() }, - func(i *sdk.Uint) { _ = i.Equal(randuint()) }, - func(i *sdk.Uint) { _ = i.GT(randuint()) }, - func(i *sdk.Uint) { _ = i.GTE(randuint()) }, - func(i *sdk.Uint) { _ = i.LT(randuint()) }, - func(i *sdk.Uint) { _ = i.LTE(randuint()) }, - func(i *sdk.Uint) { _ = i.String() }, - func(i *sdk.Uint) { _ = i.Incr() }, - func(i *sdk.Uint) { - if i.IsZero() { - return - } - - _ = i.Decr() - }, - } - - for i := 0; i < 1000; i++ { - n := rand.Uint64() - ni := sdk.NewUint(n) - - for opnum, op := range ops { - op(&ni) - - s.Require().Equal(n, ni.Uint64(), "Uint is modified by operation. #%d", opnum) - s.Require().Equal(sdk.NewUint(n), ni, "Uint is modified by operation. #%d", opnum) - } - } -} - -func (s *uintTestSuite) TestSafeSub() { - testCases := []struct { - x, y sdk.Uint - expected uint64 - panic bool - }{ - {sdk.NewUint(0), sdk.NewUint(0), 0, false}, - {sdk.NewUint(10), sdk.NewUint(5), 5, false}, - {sdk.NewUint(5), sdk.NewUint(10), 5, true}, - {sdk.NewUint(math.MaxUint64), sdk.NewUint(0), math.MaxUint64, false}, - } - - for i, tc := range testCases { - tc := tc - if tc.panic { - s.Require().Panics(func() { tc.x.Sub(tc.y) }) - continue - } - s.Require().Equal( - tc.expected, tc.x.Sub(tc.y).Uint64(), - "invalid subtraction result; x: %s, y: %s, tc: #%d", tc.x, tc.y, i, - ) - } -} - -func (s *uintTestSuite) TestParseUint() { - type args struct { - s string - } - tests := []struct { - name string - args args - want sdk.Uint - wantErr bool - }{ - {"malformed", args{"malformed"}, sdk.Uint{}, true}, - {"empty", args{""}, sdk.Uint{}, true}, - {"positive", args{"50"}, sdk.NewUint(uint64(50)), false}, - {"negative", args{"-1"}, sdk.Uint{}, true}, - {"zero", args{"0"}, sdk.ZeroUint(), false}, - } - for _, tt := range tests { - got, err := sdk.ParseUint(tt.args.s) - if tt.wantErr { - s.Require().Error(err) - continue - } - s.Require().NoError(err) - s.Require().True(got.Equal(tt.want)) - } -} - -func randuint() sdk.Uint { - return sdk.NewUint(rand.Uint64()) -} - -func (s *uintTestSuite) TestRelativePow() { - tests := []struct { - args []sdk.Uint - want sdk.Uint - }{ - {[]sdk.Uint{sdk.ZeroUint(), sdk.ZeroUint(), sdk.OneUint()}, sdk.OneUint()}, - {[]sdk.Uint{sdk.ZeroUint(), sdk.ZeroUint(), sdk.NewUint(10)}, sdk.NewUint(10)}, - {[]sdk.Uint{sdk.ZeroUint(), sdk.OneUint(), sdk.NewUint(10)}, sdk.ZeroUint()}, - {[]sdk.Uint{sdk.NewUint(10), sdk.NewUint(2), sdk.OneUint()}, sdk.NewUint(100)}, - {[]sdk.Uint{sdk.NewUint(210), sdk.NewUint(2), sdk.NewUint(100)}, sdk.NewUint(441)}, - {[]sdk.Uint{sdk.NewUint(2100), sdk.NewUint(2), sdk.NewUint(1000)}, sdk.NewUint(4410)}, - {[]sdk.Uint{sdk.NewUint(1000000001547125958), sdk.NewUint(600), sdk.NewUint(1000000000000000000)}, sdk.NewUint(1000000928276004850)}, - } - for i, tc := range tests { - res := sdk.RelativePow(tc.args[0], tc.args[1], tc.args[2]) - s.Require().Equal(tc.want, res, "unexpected result for test case %d, input: %v, got: %v", i, tc.args, res) - } -} - -func minuint(i1, i2 uint64) uint64 { - if i1 < i2 { - return i1 - } - return i2 -} - -func maxuint(i1, i2 uint64) uint64 { - if i1 > i2 { - return i1 - } - return i2 -} - -func TestRoundTripMarshalToUint(t *testing.T) { - var values = []uint64{ - 0, - 1, - 1 << 10, - 1<<10 - 3, - 1<<63 - 1, - 1<<32 - 7, - 1<<22 - 8, - } - - for _, value := range values { - value := value - t.Run(fmt.Sprintf("%d", value), func(t *testing.T) { - t.Parallel() - - var scratch [20]byte - uv := sdk.NewUint(value) - n, err := uv.MarshalTo(scratch[:]) - if err != nil { - t.Fatal(err) - } - rt := new(sdk.Uint) - if err := rt.Unmarshal(scratch[:n]); err != nil { - t.Fatal(err) - } - if !rt.Equal(uv) { - t.Fatalf("roundtrip=%q != original=%q", rt, uv) - } - }) - } -} diff --git a/types/utils.go b/types/utils.go index 7295dc1e567b..a754178c0801 100644 --- a/types/utils.go +++ b/types/utils.go @@ -6,6 +6,7 @@ import ( "time" "github.com/cosmos/cosmos-sdk/db" + "github.com/cosmos/cosmos-sdk/types/kv" ) var ( @@ -92,3 +93,30 @@ func CopyBytes(bz []byte) (ret []byte) { copy(ret, bz) return ret } + +// AppendLengthPrefixedBytes combines the slices of bytes to one slice of bytes. +func AppendLengthPrefixedBytes(args ...[]byte) []byte { + length := 0 + for _, v := range args { + length += len(v) + } + res := make([]byte, length) + + length = 0 + for _, v := range args { + copy(res[length:length+len(v)], v) + length += len(v) + } + + return res +} + +// ParseLengthPrefixedBytes panics when store key length is not equal to the given length. +func ParseLengthPrefixedBytes(key []byte, startIndex int, sliceLength int) ([]byte, int) { + neededLength := startIndex + sliceLength + endIndex := neededLength - 1 + kv.AssertKeyAtLeastLength(key, neededLength) + byteSlice := key[startIndex:neededLength] + + return byteSlice, endIndex +} diff --git a/types/utils_test.go b/types/utils_test.go index c04c9c81f3e1..7a196acafe2c 100644 --- a/types/utils_test.go +++ b/types/utils_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" ) type utilsTestSuite struct { @@ -29,20 +30,28 @@ func (s *utilsTestSuite) TestSortJSON() { wantErr bool }{ // simple case - {unsortedJSON: `{"cosmos":"foo", "atom":"bar", "tendermint":"foobar"}`, - want: `{"atom":"bar","cosmos":"foo","tendermint":"foobar"}`, wantErr: false}, + { + unsortedJSON: `{"cosmos":"foo", "atom":"bar", "tendermint":"foobar"}`, + want: `{"atom":"bar","cosmos":"foo","tendermint":"foobar"}`, wantErr: false, + }, // failing case (invalid JSON): - {unsortedJSON: `"cosmos":"foo",,,, "atom":"bar", "tendermint":"foobar"}`, - want: "", - wantErr: true}, + { + unsortedJSON: `"cosmos":"foo",,,, "atom":"bar", "tendermint":"foobar"}`, + want: "", + wantErr: true, + }, // genesis.json - {unsortedJSON: `{"consensus_params":{"block_size_params":{"max_bytes":22020096,"max_txs":100000,"max_gas":-1},"tx_size_params":{"max_bytes":10240,"max_gas":-1},"block_gossip_params":{"block_part_size_bytes":65536},"evidence_params":{"max_age":100000}},"validators":[{"pub_key":{"type":"AC26791624DE60","value":"c7UMMAbjFuc5GhGPy0E5q5tefy12p9Tq0imXqdrKXwo="},"power":100,"name":""}],"app_hash":"","genesis_time":"2018-05-11T15:52:25.424795506Z","chain_id":"test-chain-Q6VeoW","app_state":{"accounts":[{"address":"718C9C23F98C9642569742ADDD9F9AB9743FBD5D","coins":[{"denom":"Token","amount":1000},{"denom":"stake","amount":50}]}],"stake":{"pool":{"total_supply":50,"bonded_shares":"0","unbonded_shares":"0","bonded_pool":0,"unbonded_pool":0,"inflation_last_time":0,"inflation":"7/100"},"params":{"inflation_rate_change":"13/100","inflation_max":"1/5","inflation_min":"7/100","goal_bonded":"67/100","max_validators":100,"bond_denom":"stake"},"candidates":null,"bonds":null}}}`, - want: `{"app_hash":"","app_state":{"accounts":[{"address":"718C9C23F98C9642569742ADDD9F9AB9743FBD5D","coins":[{"amount":1000,"denom":"Token"},{"amount":50,"denom":"stake"}]}],"stake":{"bonds":null,"candidates":null,"params":{"bond_denom":"stake","goal_bonded":"67/100","inflation_max":"1/5","inflation_min":"7/100","inflation_rate_change":"13/100","max_validators":100},"pool":{"bonded_pool":0,"bonded_shares":"0","inflation":"7/100","inflation_last_time":0,"total_supply":50,"unbonded_pool":0,"unbonded_shares":"0"}}},"chain_id":"test-chain-Q6VeoW","consensus_params":{"block_gossip_params":{"block_part_size_bytes":65536},"block_size_params":{"max_bytes":22020096,"max_gas":-1,"max_txs":100000},"evidence_params":{"max_age":100000},"tx_size_params":{"max_bytes":10240,"max_gas":-1}},"genesis_time":"2018-05-11T15:52:25.424795506Z","validators":[{"name":"","power":100,"pub_key":{"type":"AC26791624DE60","value":"c7UMMAbjFuc5GhGPy0E5q5tefy12p9Tq0imXqdrKXwo="}}]}`, - wantErr: false}, + { + unsortedJSON: `{"consensus_params":{"block_size_params":{"max_bytes":22020096,"max_txs":100000,"max_gas":-1},"tx_size_params":{"max_bytes":10240,"max_gas":-1},"block_gossip_params":{"block_part_size_bytes":65536},"evidence_params":{"max_age":100000}},"validators":[{"pub_key":{"type":"AC26791624DE60","value":"c7UMMAbjFuc5GhGPy0E5q5tefy12p9Tq0imXqdrKXwo="},"power":100,"name":""}],"app_hash":"","genesis_time":"2018-05-11T15:52:25.424795506Z","chain_id":"test-chain-Q6VeoW","app_state":{"accounts":[{"address":"718C9C23F98C9642569742ADDD9F9AB9743FBD5D","coins":[{"denom":"Token","amount":1000},{"denom":"stake","amount":50}]}],"stake":{"pool":{"total_supply":50,"bonded_shares":"0","unbonded_shares":"0","bonded_pool":0,"unbonded_pool":0,"inflation_last_time":0,"inflation":"7/100"},"params":{"inflation_rate_change":"13/100","inflation_max":"1/5","inflation_min":"7/100","goal_bonded":"67/100","max_validators":100,"bond_denom":"stake"},"candidates":null,"bonds":null}}}`, + want: `{"app_hash":"","app_state":{"accounts":[{"address":"718C9C23F98C9642569742ADDD9F9AB9743FBD5D","coins":[{"amount":1000,"denom":"Token"},{"amount":50,"denom":"stake"}]}],"stake":{"bonds":null,"candidates":null,"params":{"bond_denom":"stake","goal_bonded":"67/100","inflation_max":"1/5","inflation_min":"7/100","inflation_rate_change":"13/100","max_validators":100},"pool":{"bonded_pool":0,"bonded_shares":"0","inflation":"7/100","inflation_last_time":0,"total_supply":50,"unbonded_pool":0,"unbonded_shares":"0"}}},"chain_id":"test-chain-Q6VeoW","consensus_params":{"block_gossip_params":{"block_part_size_bytes":65536},"block_size_params":{"max_bytes":22020096,"max_gas":-1,"max_txs":100000},"evidence_params":{"max_age":100000},"tx_size_params":{"max_bytes":10240,"max_gas":-1}},"genesis_time":"2018-05-11T15:52:25.424795506Z","validators":[{"name":"","power":100,"pub_key":{"type":"AC26791624DE60","value":"c7UMMAbjFuc5GhGPy0E5q5tefy12p9Tq0imXqdrKXwo="}}]}`, + wantErr: false, + }, // from the TXSpec: - {unsortedJSON: `{"chain_id":"test-chain-1","sequence":1,"fee_bytes":{"amount":[{"amount":5,"denom":"photon"}],"gas":10000},"msg_bytes":{"inputs":[{"address":"696E707574","coins":[{"amount":10,"denom":"atom"}]}],"outputs":[{"address":"6F7574707574","coins":[{"amount":10,"denom":"atom"}]}]},"alt_bytes":null}`, - want: `{"alt_bytes":null,"chain_id":"test-chain-1","fee_bytes":{"amount":[{"amount":5,"denom":"photon"}],"gas":10000},"msg_bytes":{"inputs":[{"address":"696E707574","coins":[{"amount":10,"denom":"atom"}]}],"outputs":[{"address":"6F7574707574","coins":[{"amount":10,"denom":"atom"}]}]},"sequence":1}`, - wantErr: false}, + { + unsortedJSON: `{"chain_id":"test-chain-1","sequence":1,"fee_bytes":{"amount":[{"amount":5,"denom":"photon"}],"gas":10000},"msg_bytes":{"inputs":[{"address":"696E707574","coins":[{"amount":10,"denom":"atom"}]}],"outputs":[{"address":"6F7574707574","coins":[{"amount":10,"denom":"atom"}]}]},"alt_bytes":null}`, + want: `{"alt_bytes":null,"chain_id":"test-chain-1","fee_bytes":{"amount":[{"amount":5,"denom":"photon"}],"gas":10000},"msg_bytes":{"inputs":[{"address":"696E707574","coins":[{"amount":10,"denom":"atom"}]}],"outputs":[{"address":"6F7574707574","coins":[{"amount":10,"denom":"atom"}]}]},"sequence":1}`, + wantErr: false, + }, } for tcIndex, tc := range cases { @@ -109,3 +118,23 @@ func (s *utilsTestSuite) TestParseTimeBytes() { _, err = sdk.ParseTimeBytes([]byte{}) s.Require().Error(err) } + +func (s *utilsTestSuite) TestAppendParseBytes() { + test1 := "test1" + test2 := "testString2" + testByte1 := []byte(test1) + testByte2 := []byte(test2) + + combinedBytes := sdk.AppendLengthPrefixedBytes(address.MustLengthPrefix(testByte1), address.MustLengthPrefix(testByte2)) + testCombineBytes := append([]byte{}, address.MustLengthPrefix(testByte1)...) + testCombineBytes = append(testCombineBytes, address.MustLengthPrefix(testByte2)...) + s.Require().Equal(combinedBytes, testCombineBytes) + + test1Len, test1LenEndIndex := sdk.ParseLengthPrefixedBytes(combinedBytes, 0, 1) + parseTest1, parseTest1EndIndex := sdk.ParseLengthPrefixedBytes(combinedBytes, test1LenEndIndex+1, int(test1Len[0])) + s.Require().Equal(testByte1, parseTest1) + + test2Len, test2LenEndIndex := sdk.ParseLengthPrefixedBytes(combinedBytes, parseTest1EndIndex+1, 1) + parseTest2, _ := sdk.ParseLengthPrefixedBytes(combinedBytes, test2LenEndIndex+1, int(test2Len[0])) + s.Require().Equal(testByte2, parseTest2) +} diff --git a/x/auth/ante/ante.go b/x/auth/ante/ante.go new file mode 100644 index 000000000000..a562e67ee39c --- /dev/null +++ b/x/auth/ante/ante.go @@ -0,0 +1,54 @@ +package ante + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// HandlerOptions are the options required for constructing a default SDK AnteHandler. +type HandlerOptions struct { + AccountKeeper AccountKeeper + BankKeeper types.BankKeeper + ExtensionOptionChecker ExtensionOptionChecker + FeegrantKeeper FeegrantKeeper + SignModeHandler authsigning.SignModeHandler + SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error + TxFeeChecker TxFeeChecker +} + +// NewAnteHandler returns an AnteHandler that checks and increments sequence +// numbers, checks signatures & account numbers, and deducts fees from the first +// signer. +func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) { + if options.AccountKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for ante builder") + } + + if options.BankKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for ante builder") + } + + if options.SignModeHandler == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for ante builder") + } + + anteDecorators := []sdk.AnteDecorator{ + NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first + NewExtensionOptionsDecorator(options.ExtensionOptionChecker), + NewValidateBasicDecorator(), + NewTxTimeoutHeightDecorator(), + NewValidateMemoDecorator(options.AccountKeeper), + NewConsumeGasForTxSizeDecorator(options.AccountKeeper), + NewDeductFeeDecorator(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), + NewSetPubKeyDecorator(options.AccountKeeper), // SetPubKeyDecorator must be called before all signature verification decorators + NewValidateSigCountDecorator(options.AccountKeeper), + NewSigGasConsumeDecorator(options.AccountKeeper, options.SigGasConsumer), + NewSigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), + NewIncrementSequenceDecorator(options.AccountKeeper), + } + + return sdk.ChainAnteDecorators(anteDecorators...), nil +} diff --git a/x/auth/middleware/middleware_test.go b/x/auth/ante/ante_test.go similarity index 67% rename from x/auth/middleware/middleware_test.go rename to x/auth/ante/ante_test.go index d923b84b2c3d..a86845984643 100644 --- a/x/auth/middleware/middleware_test.go +++ b/x/auth/ante/ante_test.go @@ -1,4 +1,4 @@ -package middleware_test +package ante_test import ( "encoding/json" @@ -7,6 +7,11 @@ import ( "strings" "testing" + "github.com/cosmos/cosmos-sdk/x/bank/testutil" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + + "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -14,25 +19,17 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" + "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" ) -var testCoins = sdk.Coins{sdk.NewInt64Coin("atom", 10000000)} - // Test that simulate transaction accurately estimates gas cost -func (s *MWTestSuite) TestSimulateGasCost() { - ctx := s.SetupTest(false) // reset - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestSimulateGasCost() { + suite.SetupTest(false) // reset // Same data for every test cases - accounts := s.createTestAccounts(ctx, 3, testCoins) + accounts := suite.CreateTestAccounts(3) msgs := []sdk.Msg{ testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()), testdata.NewTestMsg(accounts[2].acc.GetAddress(), accounts[0].acc.GetAddress()), @@ -48,8 +45,8 @@ func (s *MWTestSuite) TestSimulateGasCost() { { "tx with 150atom fee", func() { - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) }, true, true, @@ -58,11 +55,11 @@ func (s *MWTestSuite) TestSimulateGasCost() { { "with previously estimated gas", func() { - simulatedGas := ctx.GasMeter().GasConsumed() + simulatedGas := suite.ctx.GasMeter().GasConsumed() accSeqs = []uint64{1, 1, 1} - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(simulatedGas) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(simulatedGas) }, false, true, @@ -71,18 +68,18 @@ func (s *MWTestSuite) TestSimulateGasCost() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } -// Test various error cases in the TxHandler control flow. -func (s *MWTestSuite) TestTxHandlerSigErrors() { - ctx := s.SetupTest(false) // reset - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +// Test various error cases in the AnteHandler control flow. +func (suite *AnteTestSuite) TestAnteHandlerSigErrors() { + suite.SetupTest(false) // reset // Same data for every test cases priv0, _, addr0 := testdata.KeyTestPubAddr() @@ -109,12 +106,12 @@ func (s *MWTestSuite) TestTxHandlerSigErrors() { privs, accNums, accSeqs = []cryptotypes.PrivKey{}, []uint64{}, []uint64{} // Create tx manually to test the tx's signers - s.Require().NoError(txBuilder.SetMsgs(msgs...)) - tx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) + suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) // tx.GetSigners returns addresses in correct order: addr1, addr2, addr3 expectedSigners := []sdk.AccAddress{addr0, addr1, addr2} - s.Require().Equal(expectedSigners, tx.GetSigners()) + suite.Require().Equal(expectedSigners, tx.GetSigners()) }, false, false, @@ -141,12 +138,12 @@ func (s *MWTestSuite) TestTxHandlerSigErrors() { { "save the first account, but second is still unrecognized", func() { - acc1 := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr0) - s.app.AccountKeeper.SetAccount(ctx, acc1) - err := s.app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, feeAmount) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr0, feeAmount) - s.Require().NoError(err) + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr0) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + err := suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, feeAmount) + suite.Require().NoError(err) + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr0, feeAmount) + suite.Require().NoError(err) }, false, false, @@ -155,21 +152,21 @@ func (s *MWTestSuite) TestTxHandlerSigErrors() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } // Test logic around account number checking with one signer and many signers. -func (s *MWTestSuite) TestTxHandlerAccountNumbers() { - ctx := s.SetupTest(false) // reset - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestAnteHandlerAccountNumbers() { + suite.SetupTest(false) // reset // Same data for every test cases - accounts := s.createTestAccounts(ctx, 2, testCoins) + accounts := suite.CreateTestAccounts(2) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() @@ -236,22 +233,22 @@ func (s *MWTestSuite) TestTxHandlerAccountNumbers() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } // Test logic around account number checking with many signers when BlockHeight is 0. -func (s *MWTestSuite) TestTxHandlerAccountNumbersAtBlockHeightZero() { - ctx := s.SetupTest(false) // setup - ctx = ctx.WithBlockHeight(0) - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestAnteHandlerAccountNumbersAtBlockHeightZero() { + suite.SetupTest(false) // setup + suite.ctx = suite.ctx.WithBlockHeight(0) // Same data for every test cases - accounts := s.createTestAccounts(ctx, 2, testCoins) + accounts := suite.CreateTestAccounts(2) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() @@ -320,21 +317,21 @@ func (s *MWTestSuite) TestTxHandlerAccountNumbersAtBlockHeightZero() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } // Test logic around sequence checking with one signer and many signers. -func (s *MWTestSuite) TestTxHandlerSequences() { - ctx := s.SetupTest(false) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestAnteHandlerSequences() { + suite.SetupTest(false) // setup // Same data for every test cases - accounts := s.createTestAccounts(ctx, 3, testCoins) + accounts := suite.CreateTestAccounts(3) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() @@ -432,24 +429,24 @@ func (s *MWTestSuite) TestTxHandlerSequences() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } // Test logic around fee deduction. -func (s *MWTestSuite) TestTxHandlerFees() { - ctx := s.SetupTest(false) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestAnteHandlerFees() { + suite.SetupTest(false) // setup // Same data for every test cases priv0, _, addr0 := testdata.KeyTestPubAddr() - acc1 := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr0) - s.app.AccountKeeper.SetAccount(ctx, acc1) + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr0) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) msgs := []sdk.Msg{testdata.NewTestMsg(addr0)} feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() @@ -474,8 +471,8 @@ func (s *MWTestSuite) TestTxHandlerFees() { { "signer does not have enough funds to pay the fee", func() { - err := testutil.FundAccount(s.app.BankKeeper, ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 149))) - s.Require().NoError(err) + err := testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 149))) + suite.Require().NoError(err) }, false, false, @@ -486,13 +483,13 @@ func (s *MWTestSuite) TestTxHandlerFees() { func() { accNums = []uint64{acc1.GetAccountNumber()} - modAcc := s.app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) + modAcc := suite.app.AccountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName) - s.Require().True(s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).Empty()) - require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdk.NewInt(149))) + suite.Require().True(suite.app.BankKeeper.GetAllBalances(suite.ctx, modAcc.GetAddress()).Empty()) + require.True(sdk.IntEq(suite.T(), suite.app.BankKeeper.GetAllBalances(suite.ctx, addr0).AmountOf("atom"), sdk.NewInt(149))) - err := testutil.FundAccount(s.app.BankKeeper, ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 1))) - s.Require().NoError(err) + err := testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr0, sdk.NewCoins(sdk.NewInt64Coin("atom", 1))) + suite.Require().NoError(err) }, false, true, @@ -501,10 +498,10 @@ func (s *MWTestSuite) TestTxHandlerFees() { { "signer doesn't have any more funds", func() { - modAcc := s.app.AccountKeeper.GetModuleAccount(ctx, types.FeeCollectorName) + modAcc := suite.app.AccountKeeper.GetModuleAccount(suite.ctx, types.FeeCollectorName) - require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, modAcc.GetAddress()).AmountOf("atom"), sdk.NewInt(150))) - require.True(sdk.IntEq(s.T(), s.app.BankKeeper.GetAllBalances(ctx, addr0).AmountOf("atom"), sdk.NewInt(0))) + require.True(sdk.IntEq(suite.T(), suite.app.BankKeeper.GetAllBalances(suite.ctx, modAcc.GetAddress()).AmountOf("atom"), sdk.NewInt(150))) + require.True(sdk.IntEq(suite.T(), suite.app.BankKeeper.GetAllBalances(suite.ctx, addr0).AmountOf("atom"), sdk.NewInt(0))) }, false, false, @@ -513,21 +510,22 @@ func (s *MWTestSuite) TestTxHandlerFees() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } // Test logic around memo gas consumption. -func (s *MWTestSuite) TestTxHandlerMemoGas() { - ctx := s.SetupTest(false) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestAnteHandlerMemoGas() { + suite.SetupTest(false) // setup // Same data for every test cases - accounts := s.createTestAccounts(ctx, 1, testCoins) + accounts := suite.CreateTestAccounts(1) msgs := []sdk.Msg{testdata.NewTestMsg(accounts[0].acc.GetAddress())} privs, accNums, accSeqs := []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} @@ -553,7 +551,7 @@ func (s *MWTestSuite) TestTxHandlerMemoGas() { func() { feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) gasLimit = 801 - txBuilder.SetMemo("abcininasidniandsinasindiansdiansdinaisndiasndiadninsd") + suite.txBuilder.SetMemo("abcininasidniandsinasindiansdiansdinaisndiasndiadninsd") }, false, false, @@ -564,7 +562,7 @@ func (s *MWTestSuite) TestTxHandlerMemoGas() { func() { feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) gasLimit = 50000 - txBuilder.SetMemo(strings.Repeat("01234567890", 500)) + suite.txBuilder.SetMemo(strings.Repeat("01234567890", 500)) }, false, false, @@ -575,7 +573,7 @@ func (s *MWTestSuite) TestTxHandlerMemoGas() { func() { feeAmount = sdk.NewCoins(sdk.NewInt64Coin("atom", 0)) gasLimit = 50000 - txBuilder.SetMemo(strings.Repeat("0123456789", 10)) + suite.txBuilder.SetMemo(strings.Repeat("0123456789", 10)) }, false, true, @@ -584,20 +582,20 @@ func (s *MWTestSuite) TestTxHandlerMemoGas() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } -func (s *MWTestSuite) TestTxHandlerMultiSigner() { - ctx := s.SetupTest(false) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestAnteHandlerMultiSigner() { + suite.SetupTest(false) // setup // Same data for every test cases - accounts := s.createTestAccounts(ctx, 3, testCoins) + accounts := suite.CreateTestAccounts(3) msg1 := testdata.NewTestMsg(accounts[0].acc.GetAddress(), accounts[1].acc.GetAddress()) msg2 := testdata.NewTestMsg(accounts[2].acc.GetAddress(), accounts[0].acc.GetAddress()) msg3 := testdata.NewTestMsg(accounts[1].acc.GetAddress(), accounts[2].acc.GetAddress()) @@ -618,7 +616,7 @@ func (s *MWTestSuite) TestTxHandlerMultiSigner() { func() { msgs = []sdk.Msg{msg1, msg2, msg3} privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv, accounts[1].priv, accounts[2].priv}, []uint64{0, 1, 2}, []uint64{0, 0, 0} - txBuilder.SetMemo("Check signers are in expected order and different account numbers works") + suite.txBuilder.SetMemo("Check signers are in expected order and different account numbers works") }, false, true, @@ -657,20 +655,20 @@ func (s *MWTestSuite) TestTxHandlerMultiSigner() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } -func (s *MWTestSuite) TestTxHandlerBadSignBytes() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestAnteHandlerBadSignBytes() { + suite.SetupTest(false) // setup // Same data for every test cases - accounts := s.createTestAccounts(ctx, 2, testCoins) + accounts := suite.CreateTestAccounts(2) msg0 := testdata.NewTestMsg(accounts[0].acc.GetAddress()) // Variable data per test case @@ -688,7 +686,7 @@ func (s *MWTestSuite) TestTxHandlerBadSignBytes() { { "test good tx and signBytes", func() { - chainID = ctx.ChainID() + chainID = suite.ctx.ChainID() feeAmount = testdata.NewTestFeeAmount() gasLimit = testdata.NewTestGasLimit() msgs = []sdk.Msg{msg0} @@ -711,7 +709,7 @@ func (s *MWTestSuite) TestTxHandlerBadSignBytes() { { "test wrong accSeqs", func() { - chainID = ctx.ChainID() // Back to correct chainID + chainID = suite.ctx.ChainID() // Back to correct chainID accSeqs = []uint64{2} }, false, @@ -783,20 +781,20 @@ func (s *MWTestSuite) TestTxHandlerBadSignBytes() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, chainID, tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, chainID, tc) }) } } -func (s *MWTestSuite) TestTxHandlerSetPubKey() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestAnteHandlerSetPubKey() { + suite.SetupTest(false) // setup // Same data for every test cases - accounts := s.createTestAccounts(ctx, 2, testCoins) + accounts := suite.CreateTestAccounts(2) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() @@ -823,8 +821,8 @@ func (s *MWTestSuite) TestTxHandlerSetPubKey() { "make sure public key has been set (tx itself should fail because of replay protection)", func() { // Make sure public key has been set from previous test. - acc0 := s.app.AccountKeeper.GetAccount(ctx, accounts[0].acc.GetAddress()) - s.Require().Equal(acc0.GetPubKey(), accounts[0].priv.PubKey()) + acc0 := suite.app.AccountKeeper.GetAccount(suite.ctx, accounts[0].acc.GetAddress()) + suite.Require().Equal(acc0.GetPubKey(), accounts[0].priv.PubKey()) }, false, false, @@ -844,30 +842,30 @@ func (s *MWTestSuite) TestTxHandlerSetPubKey() { "make sure public key is not set, when tx has no pubkey or signature", func() { // Make sure public key has not been set from previous test. - acc1 := s.app.AccountKeeper.GetAccount(ctx, accounts[1].acc.GetAddress()) - s.Require().Nil(acc1.GetPubKey()) + acc1 := suite.app.AccountKeeper.GetAccount(suite.ctx, accounts[1].acc.GetAddress()) + suite.Require().Nil(acc1.GetPubKey()) privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{0} msgs = []sdk.Msg{testdata.NewTestMsg(accounts[1].acc.GetAddress())} - txBuilder.SetMsgs(msgs...) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) + suite.txBuilder.SetMsgs(msgs...) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) // Manually create tx, and remove signature. - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - txBuilder, err := s.clientCtx.TxConfig.WrapTxBuilder(testTx) - s.Require().NoError(err) - s.Require().NoError(txBuilder.SetSignatures()) + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + txBuilder, err := suite.clientCtx.TxConfig.WrapTxBuilder(tx) + suite.Require().NoError(err) + suite.Require().NoError(txBuilder.SetSignatures()) - // Run txHandler manually, expect ErrNoSignatures. - _, _, err = s.txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: txBuilder.GetTx()}, tx.RequestCheckTx{}) - s.Require().Error(err) - s.Require().True(errors.Is(err, sdkerrors.ErrNoSignatures)) + // Run anteHandler manually, expect ErrNoSignatures. + _, err = suite.anteHandler(suite.ctx, txBuilder.GetTx(), false) + suite.Require().Error(err) + suite.Require().True(errors.Is(err, sdkerrors.ErrNoSignatures)) // Make sure public key has not been set. - acc1 = s.app.AccountKeeper.GetAccount(ctx, accounts[1].acc.GetAddress()) - s.Require().Nil(acc1.GetPubKey()) + acc1 = suite.app.AccountKeeper.GetAccount(suite.ctx, accounts[1].acc.GetAddress()) + suite.Require().Nil(acc1.GetPubKey()) // Set incorrect accSeq, to generate incorrect signature. privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[1].priv}, []uint64{1}, []uint64{1} @@ -879,10 +877,10 @@ func (s *MWTestSuite) TestTxHandlerSetPubKey() { { "make sure previous public key has been set after wrong signature", func() { - // Make sure public key has been set, as SetPubKeyMiddleware - // is called before all signature verification middlewares. - acc1 := s.app.AccountKeeper.GetAccount(ctx, accounts[1].acc.GetAddress()) - s.Require().Equal(acc1.GetPubKey(), accounts[1].priv.PubKey()) + // Make sure public key has been set, as SetPubKeyDecorator + // is called before all signature verification decorators. + acc1 := suite.app.AccountKeeper.GetAccount(suite.ctx, accounts[1].acc.GetAddress()) + suite.Require().Equal(acc1.GetPubKey(), accounts[1].priv.PubKey()) }, false, false, @@ -891,10 +889,11 @@ func (s *MWTestSuite) TestTxHandlerSetPubKey() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } @@ -949,7 +948,8 @@ func TestCountSubkeys(t *testing.T) { multiLevelSubKey1 := kmultisig.NewLegacyAminoPubKey(4, genPubKeys(5)) multiLevelSubKey2 := kmultisig.NewLegacyAminoPubKey(4, genPubKeys(5)) multiLevelMultiKey := kmultisig.NewLegacyAminoPubKey(2, []cryptotypes.PubKey{ - multiLevelSubKey1, multiLevelSubKey2, secp256k1.GenPrivKey().PubKey()}) + multiLevelSubKey1, multiLevelSubKey2, secp256k1.GenPrivKey().PubKey(), + }) type args struct { pub cryptotypes.PubKey } @@ -964,17 +964,16 @@ func TestCountSubkeys(t *testing.T) { } for _, tc := range testCases { t.Run(tc.name, func(T *testing.T) { - require.Equal(t, tc.want, middleware.CountSubKeys(tc.args.pub)) + require.Equal(t, tc.want, ante.CountSubKeys(tc.args.pub)) }) } } -func (s *MWTestSuite) TestTxHandlerSigLimitExceeded() { - ctx := s.SetupTest(false) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestAnteHandlerSigLimitExceeded() { + suite.SetupTest(false) // setup // Same data for every test cases - accounts := s.createTestAccounts(ctx, 8, testCoins) + accounts := suite.CreateTestAccounts(8) var addrs []sdk.AccAddress var privs []cryptotypes.PrivKey for i := 0; i < 8; i++ { @@ -997,25 +996,26 @@ func (s *MWTestSuite) TestTxHandlerSigLimitExceeded() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - s.runTestCase(ctx, txBuilder, privs, msgs, feeAmount, gasLimit, accNums, accSeqs, ctx.ChainID(), tc) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } // Test custom SignatureVerificationGasConsumer -func (s *MWTestSuite) TestCustomSignatureVerificationGasConsumer() { - ctx := s.SetupTest(false) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - - txHandler, err := middleware.NewDefaultTxHandler( - middleware.TxHandlerOptions{ - AccountKeeper: s.app.AccountKeeper, - BankKeeper: s.app.BankKeeper, - FeegrantKeeper: s.app.FeeGrantKeeper, - SignModeHandler: s.clientCtx.TxConfig.SignModeHandler(), +func (suite *AnteTestSuite) TestCustomSignatureVerificationGasConsumer() { + suite.SetupTest(false) // setup + + // setup an ante handler that only accepts PubKeyEd25519 + anteHandler, err := ante.NewAnteHandler( + ante.HandlerOptions{ + AccountKeeper: suite.app.AccountKeeper, + BankKeeper: suite.app.BankKeeper, + FeegrantKeeper: suite.app.FeeGrantKeeper, + SignModeHandler: suite.clientCtx.TxConfig.SignModeHandler(), SigGasConsumer: func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error { switch pubkey := sig.PubKey.(type) { case *ed25519.PubKey: @@ -1025,22 +1025,21 @@ func (s *MWTestSuite) TestCustomSignatureVerificationGasConsumer() { return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey) } }, - TxDecoder: s.clientCtx.TxConfig.TxDecoder(), }, ) - s.Require().NoError(err) - s.Require().NoError(err) + suite.Require().NoError(err) + suite.anteHandler = anteHandler // Same data for every test cases - accounts := s.createTestAccounts(ctx, 1, testCoins) - txBuilder.SetFeeAmount(testdata.NewTestFeeAmount()) - txBuilder.SetGasLimit(testdata.NewTestGasLimit()) - txBuilder.SetMsgs(testdata.NewTestMsg(accounts[0].acc.GetAddress())) + accounts := suite.CreateTestAccounts(1) + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() // Variable data per test case var ( accNums []uint64 + msgs []sdk.Msg privs []cryptotypes.PrivKey accSeqs []uint64 ) @@ -1049,6 +1048,7 @@ func (s *MWTestSuite) TestCustomSignatureVerificationGasConsumer() { { "verify that an secp256k1 account gets rejected", func() { + msgs = []sdk.Msg{testdata.NewTestMsg(accounts[0].acc.GetAddress())} privs, accNums, accSeqs = []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} }, false, @@ -1058,57 +1058,54 @@ func (s *MWTestSuite) TestCustomSignatureVerificationGasConsumer() { } for _, tc := range testCases { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() tc.malleate() - testTx, txBytes, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx, TxBytes: txBytes}) - s.Require().Error(err) - s.Require().True(errors.Is(err, tc.expErr)) + suite.RunTestCase(privs, msgs, feeAmount, gasLimit, accNums, accSeqs, suite.ctx.ChainID(), tc) }) } } -func (s *MWTestSuite) TestTxHandlerReCheck() { - ctx := s.SetupTest(false) // setup +func (suite *AnteTestSuite) TestAnteHandlerReCheck() { + suite.SetupTest(false) // setup // Set recheck=true - ctx = ctx.WithIsReCheckTx(true) - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() + suite.ctx = suite.ctx.WithIsReCheckTx(true) + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Same data for every test cases - accounts := s.createTestAccounts(ctx, 1, testCoins) + accounts := suite.CreateTestAccounts(1) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) msg := testdata.NewTestMsg(accounts[0].acc.GetAddress()) msgs := []sdk.Msg{msg} - s.Require().NoError(txBuilder.SetMsgs(msgs...)) + suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) - txBuilder.SetMemo("thisisatestmemo") + suite.txBuilder.SetMemo("thisisatestmemo") // test that operations skipped on recheck do not run privs, accNums, accSeqs := []cryptotypes.PrivKey{accounts[0].priv}, []uint64{0}, []uint64{0} - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) - // make signature array empty which would normally cause ValidateBasicMiddleware and SigVerificationMiddleware fail - // since these middlewares don't run on recheck, the tx should pass the middleware - txBuilder, err = s.clientCtx.TxConfig.WrapTxBuilder(testTx) - s.Require().NoError(err) - s.Require().NoError(txBuilder.SetSignatures()) + // make signature array empty which would normally cause ValidateBasicDecorator and SigVerificationDecorator fail + // since these decorators don't run on recheck, the tx should pass the antehandler + txBuilder, err := suite.clientCtx.TxConfig.WrapTxBuilder(tx) + suite.Require().NoError(err) + suite.Require().NoError(txBuilder.SetSignatures()) - _, _, err = s.txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: txBuilder.GetTx()}, tx.RequestCheckTx{Type: abci.CheckTxType_Recheck}) - s.Require().Nil(err, "TxHandler errored on recheck unexpectedly: %v", err) + _, err = suite.anteHandler(suite.ctx, txBuilder.GetTx(), false) + suite.Require().Nil(err, "AnteHandler errored on recheck unexpectedly: %v", err) - testTx, _, err = s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - txBytes, err := json.Marshal(testTx) - s.Require().Nil(err, "Error marshalling tx: %v", err) - ctx = ctx.WithTxBytes(txBytes) + tx, err = suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + txBytes, err := json.Marshal(tx) + suite.Require().Nil(err, "Error marshalling tx: %v", err) + suite.ctx = suite.ctx.WithTxBytes(txBytes) // require that state machine param-dependent checking is still run on recheck since parameters can change between check and recheck testCases := []struct { @@ -1119,37 +1116,35 @@ func (s *MWTestSuite) TestTxHandlerReCheck() { {"txsize check", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, 10000000, types.DefaultSigVerifyCostED25519, types.DefaultSigVerifyCostSecp256k1)}, {"sig verify cost check", types.NewParams(types.DefaultMaxMemoCharacters, types.DefaultTxSigLimit, types.DefaultTxSizeCostPerByte, types.DefaultSigVerifyCostED25519, 100000000)}, } - for _, tc := range testCases { // set testcase parameters - s.app.AccountKeeper.SetParams(ctx, tc.params) + suite.app.AccountKeeper.SetParams(suite.ctx, tc.params) - _, _, err = s.txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx, TxBytes: txBytes}, tx.RequestCheckTx{Type: abci.CheckTxType_Recheck}) + _, err := suite.anteHandler(suite.ctx, tx, false) - s.Require().NotNil(err, "tx does not fail on recheck with updated params in test case: %s", tc.name) + suite.Require().NotNil(err, "tx does not fail on recheck with updated params in test case: %s", tc.name) // reset parameters to default values - s.app.AccountKeeper.SetParams(ctx, types.DefaultParams()) + suite.app.AccountKeeper.SetParams(suite.ctx, types.DefaultParams()) } // require that local mempool fee check is still run on recheck since validator may change minFee between check and recheck - // create new minimum gas price so txhandler fails on recheck - ctx = ctx.WithMinGasPrices([]sdk.DecCoin{{ + // create new minimum gas price so antehandler fails on recheck + suite.ctx = suite.ctx.WithMinGasPrices([]sdk.DecCoin{{ Denom: "dnecoin", // fee does not have this denom Amount: sdk.NewDec(5), }}) - _, _, err = s.txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) - - s.Require().NotNil(err, "txhandler on recheck did not fail when mingasPrice was changed") + _, err = suite.anteHandler(suite.ctx, tx, false) + suite.Require().NotNil(err, "antehandler on recheck did not fail when mingasPrice was changed") // reset min gasprice - ctx = ctx.WithMinGasPrices(sdk.DecCoins{}) + suite.ctx = suite.ctx.WithMinGasPrices(sdk.DecCoins{}) - // remove funds for account so txhandler fails on recheck - s.app.AccountKeeper.SetAccount(ctx, accounts[0].acc) - balances := s.app.BankKeeper.GetAllBalances(ctx, accounts[0].acc.GetAddress()) - err = s.app.BankKeeper.SendCoinsFromAccountToModule(ctx, accounts[0].acc.GetAddress(), minttypes.ModuleName, balances) - s.Require().NoError(err) + // remove funds for account so antehandler fails on recheck + suite.app.AccountKeeper.SetAccount(suite.ctx, accounts[0].acc) + balances := suite.app.BankKeeper.GetAllBalances(suite.ctx, accounts[0].acc.GetAddress()) + err = suite.app.BankKeeper.SendCoinsFromAccountToModule(suite.ctx, accounts[0].acc.GetAddress(), minttypes.ModuleName, balances) + suite.Require().NoError(err) - _, _, err = s.txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) - s.Require().NotNil(err, "txhandler on recheck did not fail once feePayer no longer has sufficient funds") + _, err = suite.anteHandler(suite.ctx, tx, false) + suite.Require().NotNil(err, "antehandler on recheck did not fail once feePayer no longer has sufficient funds") } diff --git a/x/auth/ante/basic.go b/x/auth/ante/basic.go new file mode 100644 index 000000000000..52c219f79e4d --- /dev/null +++ b/x/auth/ante/basic.go @@ -0,0 +1,206 @@ +package ante + +import ( + "github.com/cosmos/cosmos-sdk/codec/legacy" + "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" +) + +// ValidateBasicDecorator will call tx.ValidateBasic and return any non-nil error. +// If ValidateBasic passes, decorator calls next AnteHandler in chain. Note, +// ValidateBasicDecorator decorator will not get executed on ReCheckTx since it +// is not dependent on application state. +type ValidateBasicDecorator struct{} + +func NewValidateBasicDecorator() ValidateBasicDecorator { + return ValidateBasicDecorator{} +} + +func (vbd ValidateBasicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + // no need to validate basic on recheck tx, call next antehandler + if ctx.IsReCheckTx() { + return next(ctx, tx, simulate) + } + + if err := tx.ValidateBasic(); err != nil { + return ctx, err + } + + return next(ctx, tx, simulate) +} + +// ValidateMemoDecorator will validate memo given the parameters passed in +// If memo is too large decorator returns with error, otherwise call next AnteHandler +// CONTRACT: Tx must implement TxWithMemo interface +type ValidateMemoDecorator struct { + ak AccountKeeper +} + +func NewValidateMemoDecorator(ak AccountKeeper) ValidateMemoDecorator { + return ValidateMemoDecorator{ + ak: ak, + } +} + +func (vmd ValidateMemoDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + memoTx, ok := tx.(sdk.TxWithMemo) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") + } + + params := vmd.ak.GetParams(ctx) + + memoLength := len(memoTx.GetMemo()) + if uint64(memoLength) > params.MaxMemoCharacters { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrMemoTooLarge, + "maximum number of characters is %d but received %d characters", + params.MaxMemoCharacters, memoLength, + ) + } + + return next(ctx, tx, simulate) +} + +// ConsumeTxSizeGasDecorator will take in parameters and consume gas proportional +// to the size of tx before calling next AnteHandler. Note, the gas costs will be +// slightly over estimated due to the fact that any given signing account may need +// to be retrieved from state. +// +// CONTRACT: If simulate=true, then signatures must either be completely filled +// in or empty. +// CONTRACT: To use this decorator, signatures of transaction must be represented +// as legacytx.StdSignature otherwise simulate mode will incorrectly estimate gas cost. +type ConsumeTxSizeGasDecorator struct { + ak AccountKeeper +} + +func NewConsumeGasForTxSizeDecorator(ak AccountKeeper) ConsumeTxSizeGasDecorator { + return ConsumeTxSizeGasDecorator{ + ak: ak, + } +} + +func (cgts ConsumeTxSizeGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + sigTx, ok := tx.(authsigning.SigVerifiableTx) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") + } + params := cgts.ak.GetParams(ctx) + + ctx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*sdk.Gas(len(ctx.TxBytes())), "txSize") + + // simulate gas cost for signatures in simulate mode + if simulate { + // in simulate mode, each element should be a nil signature + sigs, err := sigTx.GetSignaturesV2() + if err != nil { + return ctx, err + } + n := len(sigs) + + for i, signer := range sigTx.GetSigners() { + // if signature is already filled in, no need to simulate gas cost + if i < n && !isIncompleteSignature(sigs[i].Data) { + continue + } + + var pubkey cryptotypes.PubKey + + acc := cgts.ak.GetAccount(ctx, signer) + + // use placeholder simSecp256k1Pubkey if sig is nil + if acc == nil || acc.GetPubKey() == nil { + pubkey = simSecp256k1Pubkey + } else { + pubkey = acc.GetPubKey() + } + + // use stdsignature to mock the size of a full signature + simSig := legacytx.StdSignature{ //nolint:staticcheck // this will be removed when proto is ready + Signature: simSecp256k1Sig[:], + PubKey: pubkey, + } + + sigBz := legacy.Cdc.MustMarshal(simSig) + cost := sdk.Gas(len(sigBz) + 6) + + // If the pubkey is a multi-signature pubkey, then we estimate for the maximum + // number of signers. + if _, ok := pubkey.(*multisig.LegacyAminoPubKey); ok { + cost *= params.TxSigLimit + } + + ctx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*cost, "txSize") + } + } + + return next(ctx, tx, simulate) +} + +// isIncompleteSignature tests whether SignatureData is fully filled in for simulation purposes +func isIncompleteSignature(data signing.SignatureData) bool { + if data == nil { + return true + } + + switch data := data.(type) { + case *signing.SingleSignatureData: + return len(data.Signature) == 0 + case *signing.MultiSignatureData: + if len(data.Signatures) == 0 { + return true + } + for _, s := range data.Signatures { + if isIncompleteSignature(s) { + return true + } + } + } + + return false +} + +type ( + // TxTimeoutHeightDecorator defines an AnteHandler decorator that checks for a + // tx height timeout. + TxTimeoutHeightDecorator struct{} + + // TxWithTimeoutHeight defines the interface a tx must implement in order for + // TxHeightTimeoutDecorator to process the tx. + TxWithTimeoutHeight interface { + sdk.Tx + + GetTimeoutHeight() uint64 + } +) + +// TxTimeoutHeightDecorator defines an AnteHandler decorator that checks for a +// tx height timeout. +func NewTxTimeoutHeightDecorator() TxTimeoutHeightDecorator { + return TxTimeoutHeightDecorator{} +} + +// AnteHandle implements an AnteHandler decorator for the TxHeightTimeoutDecorator +// type where the current block height is checked against the tx's height timeout. +// If a height timeout is provided (non-zero) and is less than the current block +// height, then an error is returned. +func (txh TxTimeoutHeightDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + timeoutTx, ok := tx.(TxWithTimeoutHeight) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "expected tx to implement TxWithTimeoutHeight") + } + + timeoutHeight := timeoutTx.GetTimeoutHeight() + if timeoutHeight > 0 && uint64(ctx.BlockHeight()) > timeoutHeight { + return ctx, sdkerrors.Wrapf( + sdkerrors.ErrTxTimeoutHeight, "block height: %d, timeout height: %d", ctx.BlockHeight(), timeoutHeight, + ) + } + + return next(ctx, tx, simulate) +} diff --git a/x/auth/ante/basic_test.go b/x/auth/ante/basic_test.go new file mode 100644 index 000000000000..4a8cb830fdf6 --- /dev/null +++ b/x/auth/ante/basic_test.go @@ -0,0 +1,224 @@ +package ante_test + +import ( + "strings" + + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/crypto/types/multisig" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/ante" +) + +func (suite *AnteTestSuite) TestValidateBasic() { + suite.SetupTest(true) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + + // keys and addresses + priv1, _, addr1 := testdata.KeyTestPubAddr() + + // msg and signatures + msg := testdata.NewTestMsg(addr1) + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() + suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{}, []uint64{}, []uint64{} + invalidTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + vbd := ante.NewValidateBasicDecorator() + antehandler := sdk.ChainAnteDecorators(vbd) + _, err = antehandler(suite.ctx, invalidTx, false) + + suite.Require().NotNil(err, "Did not error on invalid tx") + + privs, accNums, accSeqs = []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + validTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + _, err = antehandler(suite.ctx, validTx, false) + suite.Require().Nil(err, "ValidateBasicDecorator returned error on valid tx. err: %v", err) + + // test decorator skips on recheck + suite.ctx = suite.ctx.WithIsReCheckTx(true) + + // decorator should skip processing invalidTx on recheck and thus return nil-error + _, err = antehandler(suite.ctx, invalidTx, false) + + suite.Require().Nil(err, "ValidateBasicDecorator ran on ReCheck") +} + +func (suite *AnteTestSuite) TestValidateMemo() { + suite.SetupTest(true) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + + // keys and addresses + priv1, _, addr1 := testdata.KeyTestPubAddr() + + // msg and signatures + msg := testdata.NewTestMsg(addr1) + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() + suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + suite.txBuilder.SetMemo(strings.Repeat("01234567890", 500)) + invalidTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + // require that long memos get rejected + vmd := ante.NewValidateMemoDecorator(suite.app.AccountKeeper) + antehandler := sdk.ChainAnteDecorators(vmd) + _, err = antehandler(suite.ctx, invalidTx, false) + + suite.Require().NotNil(err, "Did not error on tx with high memo") + + suite.txBuilder.SetMemo(strings.Repeat("01234567890", 10)) + validTx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + // require small memos pass ValidateMemo Decorator + _, err = antehandler(suite.ctx, validTx, false) + suite.Require().Nil(err, "ValidateBasicDecorator returned error on valid tx. err: %v", err) +} + +func (suite *AnteTestSuite) TestConsumeGasForTxSize() { + suite.SetupTest(true) // setup + + // keys and addresses + priv1, _, addr1 := testdata.KeyTestPubAddr() + + // msg and signatures + msg := testdata.NewTestMsg(addr1) + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() + + cgtsd := ante.NewConsumeGasForTxSizeDecorator(suite.app.AccountKeeper) + antehandler := sdk.ChainAnteDecorators(cgtsd) + + testCases := []struct { + name string + sigV2 signing.SignatureV2 + }{ + {"SingleSignatureData", signing.SignatureV2{PubKey: priv1.PubKey()}}, + {"MultiSignatureData", signing.SignatureV2{PubKey: priv1.PubKey(), Data: multisig.NewMultisig(2)}}, + } + + for _, tc := range testCases { + suite.Run(tc.name, func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + suite.txBuilder.SetMemo(strings.Repeat("01234567890", 10)) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + txBytes, err := suite.clientCtx.TxConfig.TxJSONEncoder()(tx) + suite.Require().Nil(err, "Cannot marshal tx: %v", err) + + params := suite.app.AccountKeeper.GetParams(suite.ctx) + expectedGas := sdk.Gas(len(txBytes)) * params.TxSizeCostPerByte + + // Set suite.ctx with TxBytes manually + suite.ctx = suite.ctx.WithTxBytes(txBytes) + + // track how much gas is necessary to retrieve parameters + beforeGas := suite.ctx.GasMeter().GasConsumed() + suite.app.AccountKeeper.GetParams(suite.ctx) + afterGas := suite.ctx.GasMeter().GasConsumed() + expectedGas += afterGas - beforeGas + + beforeGas = suite.ctx.GasMeter().GasConsumed() + suite.ctx, err = antehandler(suite.ctx, tx, false) + suite.Require().Nil(err, "ConsumeTxSizeGasDecorator returned error: %v", err) + + // require that decorator consumes expected amount of gas + consumedGas := suite.ctx.GasMeter().GasConsumed() - beforeGas + suite.Require().Equal(expectedGas, consumedGas, "Decorator did not consume the correct amount of gas") + + // simulation must not underestimate gas of this decorator even with nil signatures + txBuilder, err := suite.clientCtx.TxConfig.WrapTxBuilder(tx) + suite.Require().NoError(err) + suite.Require().NoError(txBuilder.SetSignatures(tc.sigV2)) + tx = txBuilder.GetTx() + + simTxBytes, err := suite.clientCtx.TxConfig.TxJSONEncoder()(tx) + suite.Require().Nil(err, "Cannot marshal tx: %v", err) + // require that simulated tx is smaller than tx with signatures + suite.Require().True(len(simTxBytes) < len(txBytes), "simulated tx still has signatures") + + // Set suite.ctx with smaller simulated TxBytes manually + suite.ctx = suite.ctx.WithTxBytes(simTxBytes) + + beforeSimGas := suite.ctx.GasMeter().GasConsumed() + + // run antehandler with simulate=true + suite.ctx, err = antehandler(suite.ctx, tx, true) + consumedSimGas := suite.ctx.GasMeter().GasConsumed() - beforeSimGas + + // require that antehandler passes and does not underestimate decorator cost + suite.Require().Nil(err, "ConsumeTxSizeGasDecorator returned error: %v", err) + suite.Require().True(consumedSimGas >= expectedGas, "Simulate mode underestimates gas on AnteDecorator. Simulated cost: %d, expected cost: %d", consumedSimGas, expectedGas) + + }) + } + +} + +func (suite *AnteTestSuite) TestTxHeightTimeoutDecorator() { + suite.SetupTest(true) + + antehandler := sdk.ChainAnteDecorators(ante.NewTxTimeoutHeightDecorator()) + + // keys and addresses + priv1, _, addr1 := testdata.KeyTestPubAddr() + + // msg and signatures + msg := testdata.NewTestMsg(addr1) + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() + + testCases := []struct { + name string + timeout uint64 + height int64 + expectErr bool + }{ + {"default value", 0, 10, false}, + {"no timeout (greater height)", 15, 10, false}, + {"no timeout (same height)", 10, 10, false}, + {"timeout (smaller height)", 9, 10, true}, + } + + for _, tc := range testCases { + tc := tc + + suite.Run(tc.name, func() { + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + + suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + suite.txBuilder.SetMemo(strings.Repeat("01234567890", 10)) + suite.txBuilder.SetTimeoutHeight(tc.timeout) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + ctx := suite.ctx.WithBlockHeight(tc.height) + _, err = antehandler(ctx, tx, true) + suite.Require().Equal(tc.expectErr, err != nil, err) + }) + } +} diff --git a/x/auth/middleware/expected_keepers.go b/x/auth/ante/expected_keepers.go similarity index 85% rename from x/auth/middleware/expected_keepers.go rename to x/auth/ante/expected_keepers.go index 33bb6339c1f3..4dbbbd21c713 100644 --- a/x/auth/middleware/expected_keepers.go +++ b/x/auth/ante/expected_keepers.go @@ -1,4 +1,4 @@ -package middleware +package ante import ( sdk "github.com/cosmos/cosmos-sdk/types" @@ -6,7 +6,7 @@ import ( ) // AccountKeeper defines the contract needed for AccountKeeper related APIs. -// Interface provides support to use non-sdk AccountKeeper for TxHandler's middlewares. +// Interface provides support to use non-sdk AccountKeeper for AnteHandler's decorators. type AccountKeeper interface { GetParams(ctx sdk.Context) (params types.Params) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI diff --git a/x/auth/ante/ext.go b/x/auth/ante/ext.go new file mode 100644 index 000000000000..6a072526aa0f --- /dev/null +++ b/x/auth/ante/ext.go @@ -0,0 +1,65 @@ +package ante + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +type HasExtensionOptionsTx interface { + GetExtensionOptions() []*codectypes.Any + GetNonCriticalExtensionOptions() []*codectypes.Any +} + +// ExtensionOptionChecker is a function that returns true if the extension option is accepted. +type ExtensionOptionChecker func(*codectypes.Any) bool + +// rejectExtensionOption is the default extension check that reject all tx +// extensions. +func rejectExtensionOption(*codectypes.Any) bool { + return false +} + +// RejectExtensionOptionsDecorator is an AnteDecorator that rejects all extension +// options which can optionally be included in protobuf transactions. Users that +// need extension options should create a custom AnteHandler chain that handles +// needed extension options properly and rejects unknown ones. +type RejectExtensionOptionsDecorator struct { + checker ExtensionOptionChecker +} + +// NewExtensionOptionsDecorator creates a new antehandler that rejects all extension +// options which can optionally be included in protobuf transactions that don't pass the checker. +// Users that need extension options should pass a custom checker that returns true for the +// needed extension options. +func NewExtensionOptionsDecorator(checker ExtensionOptionChecker) sdk.AnteDecorator { + if checker == nil { + checker = rejectExtensionOption + } + + return RejectExtensionOptionsDecorator{checker: checker} +} + +var _ sdk.AnteDecorator = RejectExtensionOptionsDecorator{} + +// AnteHandle implements the AnteDecorator.AnteHandle method +func (r RejectExtensionOptionsDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + err = checkExtOpts(tx, r.checker) + if err != nil { + return ctx, err + } + + return next(ctx, tx, simulate) +} + +func checkExtOpts(tx sdk.Tx, checker ExtensionOptionChecker) error { + if hasExtOptsTx, ok := tx.(HasExtensionOptionsTx); ok { + for _, opt := range hasExtOptsTx.GetExtensionOptions() { + if !checker(opt) { + return sdkerrors.ErrUnknownExtensionOptions + } + } + } + + return nil +} diff --git a/x/auth/ante/ext_test.go b/x/auth/ante/ext_test.go new file mode 100644 index 000000000000..3bd0f8f60275 --- /dev/null +++ b/x/auth/ante/ext_test.go @@ -0,0 +1,54 @@ +package ante_test + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/ante" + "github.com/cosmos/cosmos-sdk/x/auth/tx" +) + +func (suite *AnteTestSuite) TestRejectExtensionOptionsDecorator() { + suite.SetupTest(true) // setup + + testCases := []struct { + msg string + allow bool + }{ + {"allow extension", true}, + {"reject extension", false}, + } + for _, tc := range testCases { + suite.Run(tc.msg, func() { + txBuilder := suite.clientCtx.TxConfig.NewTxBuilder() + + reod := ante.NewExtensionOptionsDecorator(func(_ *codectypes.Any) bool { + return tc.allow + }) + antehandler := sdk.ChainAnteDecorators(reod) + + // no extension options should not trigger an error + theTx := txBuilder.GetTx() + _, err := antehandler(suite.ctx, theTx, false) + suite.Require().NoError(err) + + extOptsTxBldr, ok := txBuilder.(tx.ExtensionOptionsTxBuilder) + if !ok { + // if we can't set extension options, this decorator doesn't apply and we're done + return + } + + // set an extension option and check + any, err := codectypes.NewAnyWithValue(testdata.NewTestMsg()) + suite.Require().NoError(err) + extOptsTxBldr.SetExtensionOptions(any) + theTx = txBuilder.GetTx() + _, err = antehandler(suite.ctx, theTx, false) + if tc.allow { + suite.Require().NoError(err) + } else { + suite.Require().EqualError(err, "unknown extension options") + } + }) + } +} diff --git a/x/auth/middleware/fee.go b/x/auth/ante/fee.go similarity index 51% rename from x/auth/middleware/fee.go rename to x/auth/ante/fee.go index 2ae83c37269e..7a38dbc399d6 100644 --- a/x/auth/middleware/fee.go +++ b/x/auth/ante/fee.go @@ -1,12 +1,10 @@ -package middleware +package ante import ( - "context" "fmt" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -14,36 +12,45 @@ import ( // the effective fee should be deducted later, and the priority should be returned in abci response. type TxFeeChecker func(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) -var _ tx.Handler = deductFeeTxHandler{} - -type deductFeeTxHandler struct { +// DeductFeeDecorator deducts fees from the first signer of the tx +// If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error +// Call next AnteHandler if fees successfully deducted +// CONTRACT: Tx must implement FeeTx interface to use DeductFeeDecorator +type DeductFeeDecorator struct { accountKeeper AccountKeeper bankKeeper types.BankKeeper feegrantKeeper FeegrantKeeper txFeeChecker TxFeeChecker - next tx.Handler } -// DeductFeeMiddleware deducts fees from the first signer of the tx -// If the first signer does not have the funds to pay for the fees, return with InsufficientFunds error -// Call next middleware if fees successfully deducted -// CONTRACT: Tx must implement FeeTx interface to use deductFeeTxHandler -func DeductFeeMiddleware(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, tfc TxFeeChecker) tx.Middleware { +func NewDeductFeeDecorator(ak AccountKeeper, bk types.BankKeeper, fk FeegrantKeeper, tfc TxFeeChecker) DeductFeeDecorator { if tfc == nil { tfc = checkTxFeeWithValidatorMinGasPrices } - return func(txh tx.Handler) tx.Handler { - return deductFeeTxHandler{ - accountKeeper: ak, - bankKeeper: bk, - feegrantKeeper: fk, - txFeeChecker: tfc, - next: txh, - } + + return DeductFeeDecorator{ + accountKeeper: ak, + bankKeeper: bk, + feegrantKeeper: fk, + txFeeChecker: tfc, + } +} + +func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + fee, priority, err := dfd.txFeeChecker(ctx, tx) + if err != nil { + return ctx, err + } + if err := dfd.checkDeductFee(ctx, tx, fee); err != nil { + return ctx, err } + + newCtx := ctx.WithPriority(priority) + + return next(newCtx, tx, simulate) } -func (dfd deductFeeTxHandler) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee sdk.Coins) error { +func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee sdk.Coins) error { feeTx, ok := sdkTx.(sdk.FeeTx) if !ok { return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx") @@ -93,60 +100,15 @@ func (dfd deductFeeTxHandler) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee return nil } -// CheckTx implements tx.Handler.CheckTx. -func (dfd deductFeeTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - fee, priority, err := dfd.txFeeChecker(sdkCtx, req.Tx) - if err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - if err := dfd.checkDeductFee(sdkCtx, req.Tx, fee); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - res, checkRes, err := dfd.next.CheckTx(ctx, req, checkReq) - checkRes.Priority = priority - - return res, checkRes, err -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (dfd deductFeeTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - fee, _, err := dfd.txFeeChecker(sdkCtx, req.Tx) - if err != nil { - return tx.Response{}, err - } - if err := dfd.checkDeductFee(sdkCtx, req.Tx, fee); err != nil { - return tx.Response{}, err - } - - return dfd.next.DeliverTx(ctx, req) -} - -func (dfd deductFeeTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - fee, _, err := dfd.txFeeChecker(sdkCtx, req.Tx) - if err != nil { - return tx.Response{}, err - } - if err := dfd.checkDeductFee(sdkCtx, req.Tx, fee); err != nil { - return tx.Response{}, err - } - - return dfd.next.SimulateTx(ctx, req) -} - -// Deprecated: DeductFees deducts fees from the given account. -// This function will be private in the next release. +// DeductFees deducts fees from the given account. func DeductFees(bankKeeper types.BankKeeper, ctx sdk.Context, acc types.AccountI, fees sdk.Coins) error { if !fees.IsValid() { - return sdkerrors.ErrInsufficientFee.Wrapf("invalid fee amount: %s", fees) + return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "invalid fee amount: %s", fees) } err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorName, fees) if err != nil { - return sdkerrors.ErrInsufficientFunds.Wrap(err.Error()) + return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } return nil diff --git a/x/auth/ante/fee_test.go b/x/auth/ante/fee_test.go new file mode 100644 index 000000000000..21a0a2d7ff8e --- /dev/null +++ b/x/auth/ante/fee_test.go @@ -0,0 +1,109 @@ +package ante_test + +import ( + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/ante" + "github.com/cosmos/cosmos-sdk/x/bank/testutil" +) + +func (suite *AnteTestSuite) TestEnsureMempoolFees() { + suite.SetupTest(true) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + + mfd := ante.NewDeductFeeDecorator(suite.app.AccountKeeper, suite.app.BankKeeper, suite.app.FeeGrantKeeper, nil) + antehandler := sdk.ChainAnteDecorators(mfd) + + // keys and addresses + priv1, _, addr1 := testdata.KeyTestPubAddr() + coins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(300))) + testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, coins) + + // msg and signatures + msg := testdata.NewTestMsg(addr1) + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() + suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + // Set high gas price so standard test fee fails + atomPrice := sdk.NewDecCoinFromDec("atom", sdk.NewDec(200).Quo(sdk.NewDec(100000))) + highGasPrice := []sdk.DecCoin{atomPrice} + suite.ctx = suite.ctx.WithMinGasPrices(highGasPrice) + + // Set IsCheckTx to true + suite.ctx = suite.ctx.WithIsCheckTx(true) + + // antehandler errors with insufficient fees + _, err = antehandler(suite.ctx, tx, false) + suite.Require().NotNil(err, "Decorator should have errored on too low fee for local gasPrice") + + // Set IsCheckTx to false + suite.ctx = suite.ctx.WithIsCheckTx(false) + + // antehandler should not error since we do not check minGasPrice in DeliverTx + _, err = antehandler(suite.ctx, tx, false) + suite.Require().Nil(err, "MempoolFeeDecorator returned error in DeliverTx") + + // Set IsCheckTx back to true for testing sufficient mempool fee + suite.ctx = suite.ctx.WithIsCheckTx(true) + + atomPrice = sdk.NewDecCoinFromDec("atom", sdk.NewDec(0).Quo(sdk.NewDec(100000))) + lowGasPrice := []sdk.DecCoin{atomPrice} + suite.ctx = suite.ctx.WithMinGasPrices(lowGasPrice) + + newCtx, err := antehandler(suite.ctx, tx, false) + suite.Require().Nil(err, "Decorator should not have errored on fee higher than local gasPrice") + // Priority is the smallest amount in any denom. Since we have only 1 fee + // of 150atom, the priority here is 150. + suite.Require().Equal(feeAmount.AmountOf("atom").Int64(), newCtx.Priority()) +} + +func (suite *AnteTestSuite) TestDeductFees() { + suite.SetupTest(false) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + + // keys and addresses + priv1, _, addr1 := testdata.KeyTestPubAddr() + + // msg and signatures + msg := testdata.NewTestMsg(addr1) + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() + suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + // Set account with insufficient funds + acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc) + coins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(10))) + err = testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, coins) + suite.Require().NoError(err) + + dfd := ante.NewDeductFeeDecorator(suite.app.AccountKeeper, suite.app.BankKeeper, nil, nil) + antehandler := sdk.ChainAnteDecorators(dfd) + + _, err = antehandler(suite.ctx, tx, false) + + suite.Require().NotNil(err, "Tx did not error when fee payer had insufficient funds") + + // Set account with sufficient funds + suite.app.AccountKeeper.SetAccount(suite.ctx, acc) + err = testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200)))) + suite.Require().NoError(err) + + _, err = antehandler(suite.ctx, tx, false) + + suite.Require().Nil(err, "Tx errored after account has been set with sufficient funds") +} diff --git a/x/auth/middleware/feegrant_test.go b/x/auth/ante/feegrant_test.go similarity index 78% rename from x/auth/middleware/feegrant_test.go rename to x/auth/ante/feegrant_test.go index 547f57a589d1..c8689ca3c7a1 100644 --- a/x/auth/middleware/feegrant_test.go +++ b/x/auth/ante/feegrant_test.go @@ -1,4 +1,4 @@ -package middleware_test +package ante_test import ( "math/rand" @@ -10,13 +10,13 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/simapp/helpers" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/simulation" - txtypes "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" + "github.com/cosmos/cosmos-sdk/x/auth/ante" authsign "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/tx" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -24,21 +24,19 @@ import ( "github.com/cosmos/cosmos-sdk/x/feegrant" ) -func (s *MWTestSuite) TestDeductFeesNoDelegation() { - ctx := s.SetupTest(false) // setup - app := s.app +func (suite *AnteTestSuite) TestDeductFeesNoDelegation() { + suite.SetupTest(false) + // setup + app, ctx := suite.app, suite.ctx protoTxCfg := tx.NewTxConfig(codec.NewProtoCodec(app.InterfaceRegistry()), tx.DefaultSignModes) - txHandler := middleware.ComposeMiddlewares( - noopTxHandler, - middleware.DeductFeeMiddleware( - s.app.AccountKeeper, - s.app.BankKeeper, - s.app.FeeGrantKeeper, - nil, - ), - ) + // this just tests our handler + dfd := ante.NewDeductFeeDecorator(app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, nil) + feeAnteHandler := sdk.ChainAnteDecorators(dfd) + + // this tests the whole stack + anteHandlerStack := suite.anteHandler // keys and addresses priv1, _, addr1 := testdata.KeyTestPubAddr() @@ -48,24 +46,24 @@ func (s *MWTestSuite) TestDeductFeesNoDelegation() { priv5, _, addr5 := testdata.KeyTestPubAddr() // Set addr1 with insufficient funds - err := testutil.FundAccount(s.app.BankKeeper, ctx, addr1, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))}) - s.Require().NoError(err) + err := testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(10))}) + suite.Require().NoError(err) // Set addr2 with more funds - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) - s.Require().NoError(err) + err = testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr2, []sdk.Coin{sdk.NewCoin("atom", sdk.NewInt(99999))}) + suite.Require().NoError(err) // grant fee allowance from `addr2` to `addr3` (plenty to pay) err = app.FeeGrantKeeper.GrantAllowance(ctx, addr2, addr3, &feegrant.BasicAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 500)), }) - s.Require().NoError(err) + suite.Require().NoError(err) // grant low fee allowance (20atom), to check the tx requesting more than allowed. err = app.FeeGrantKeeper.GrantAllowance(ctx, addr2, addr4, &feegrant.BasicAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 20)), }) - s.Require().NoError(err) + suite.Require().NoError(err) cases := map[string]struct { signerKey cryptotypes.PrivKey @@ -136,7 +134,7 @@ func (s *MWTestSuite) TestDeductFeesNoDelegation() { for name, stc := range cases { tc := stc // to make scopelint happy - s.T().Run(name, func(t *testing.T) { + suite.T().Run(name, func(t *testing.T) { fee := sdk.NewCoins(sdk.NewInt64Coin("atom", tc.fee)) msgs := []sdk.Msg{testdata.NewTestMsg(tc.signer)} @@ -146,23 +144,20 @@ func (s *MWTestSuite) TestDeductFeesNoDelegation() { accNums, seqs = []uint64{acc.GetAccountNumber()}, []uint64{acc.GetSequence()} } - testTx, err := genTxWithFeeGranter(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...) - s.Require().NoError(err) - - // tests only feegrant middleware - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), txtypes.Request{Tx: testTx}) + tx, err := genTxWithFeeGranter(protoTxCfg, msgs, fee, helpers.DefaultGenTxGas, ctx.ChainID(), accNums, seqs, tc.feeAccount, privs...) + suite.Require().NoError(err) + _, err = feeAnteHandler(ctx, tx, false) // tests only feegrant ante if tc.valid { - s.Require().NoError(err) + suite.Require().NoError(err) } else { - s.Require().Error(err) + suite.Require().Error(err) } - // tests while stack - _, err = s.txHandler.DeliverTx(sdk.WrapSDKContext(ctx), txtypes.Request{Tx: testTx}) + _, err = anteHandlerStack(ctx, tx, false) // tests while stack if tc.valid { - s.Require().NoError(err) + suite.Require().NoError(err) } else { - s.Require().Error(err) + suite.Require().Error(err) } }) } @@ -174,7 +169,8 @@ func SigGasNoConsumer(meter sdk.GasMeter, sig []byte, pubkey crypto.PubKey, para } func genTxWithFeeGranter(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, gas uint64, chainID string, accNums, - accSeqs []uint64, feeGranter sdk.AccAddress, priv ...cryptotypes.PrivKey) (sdk.Tx, error) { + accSeqs []uint64, feeGranter sdk.AccAddress, priv ...cryptotypes.PrivKey, +) (sdk.Tx, error) { sigs := make([]signing.SignatureV2, len(priv)) // create a random length memo @@ -213,11 +209,9 @@ func genTxWithFeeGranter(gen client.TxConfig, msgs []sdk.Msg, feeAmt sdk.Coins, // 2nd round: once all signer infos are set, every signer can sign. for i, p := range priv { signerData := authsign.SignerData{ - Address: sdk.AccAddress(p.PubKey().Address()).String(), ChainID: chainID, AccountNumber: accNums[i], Sequence: accSeqs[i], - PubKey: p.PubKey(), } signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx()) if err != nil { diff --git a/x/auth/ante/setup.go b/x/auth/ante/setup.go new file mode 100644 index 000000000000..6d6d4344c0c3 --- /dev/null +++ b/x/auth/ante/setup.go @@ -0,0 +1,76 @@ +package ante + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" +) + +var ( + _ GasTx = (*legacytx.StdTx)(nil) // assert StdTx implements GasTx +) + +// GasTx defines a Tx with a GetGas() method which is needed to use SetUpContextDecorator +type GasTx interface { + sdk.Tx + GetGas() uint64 +} + +// SetUpContextDecorator sets the GasMeter in the Context and wraps the next AnteHandler with a defer clause +// to recover from any downstream OutOfGas panics in the AnteHandler chain to return an error with information +// on gas provided and gas used. +// CONTRACT: Must be first decorator in the chain +// CONTRACT: Tx must implement GasTx interface +type SetUpContextDecorator struct{} + +func NewSetUpContextDecorator() SetUpContextDecorator { + return SetUpContextDecorator{} +} + +func (sud SetUpContextDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + // all transactions must implement GasTx + gasTx, ok := tx.(GasTx) + if !ok { + // Set a gas meter with limit 0 as to prevent an infinite gas meter attack + // during runTx. + newCtx = SetGasMeter(simulate, ctx, 0) + return newCtx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be GasTx") + } + + newCtx = SetGasMeter(simulate, ctx, gasTx.GetGas()) + + // Decorator will catch an OutOfGasPanic caused in the next antehandler + // AnteHandlers must have their own defer/recover in order for the BaseApp + // to know how much gas was used! This is because the GasMeter is created in + // the AnteHandler, but if it panics the context won't be set properly in + // runTx's recover call. + defer func() { + if r := recover(); r != nil { + switch rType := r.(type) { + case sdk.ErrorOutOfGas: + log := fmt.Sprintf( + "out of gas in location: %v; gasWanted: %d, gasUsed: %d", + rType.Descriptor, gasTx.GetGas(), newCtx.GasMeter().GasConsumed()) + + err = sdkerrors.Wrap(sdkerrors.ErrOutOfGas, log) + default: + panic(r) + } + } + }() + + return next(newCtx, tx, simulate) +} + +// SetGasMeter returns a new context with a gas meter set from a given context. +func SetGasMeter(simulate bool, ctx sdk.Context, gasLimit uint64) sdk.Context { + // In various cases such as simulation and during the genesis block, we do not + // meter any gas utilization. + if simulate || ctx.BlockHeight() == 0 { + return ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) + } + + return ctx.WithGasMeter(sdk.NewGasMeter(gasLimit)) +} diff --git a/x/auth/ante/setup_test.go b/x/auth/ante/setup_test.go new file mode 100644 index 000000000000..ed4e543b56a4 --- /dev/null +++ b/x/auth/ante/setup_test.go @@ -0,0 +1,99 @@ +package ante_test + +import ( + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/ante" +) + +func (suite *AnteTestSuite) TestSetup() { + suite.SetupTest(true) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + + // keys and addresses + priv1, _, addr1 := testdata.KeyTestPubAddr() + + // msg and signatures + msg := testdata.NewTestMsg(addr1) + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() + suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + sud := ante.NewSetUpContextDecorator() + antehandler := sdk.ChainAnteDecorators(sud) + + // Set height to non-zero value for GasMeter to be set + suite.ctx = suite.ctx.WithBlockHeight(1).WithGasMeter(sdk.NewGasMeter(0)) + + // Context GasMeter Limit not set + suite.Require().Equal(uint64(0), suite.ctx.GasMeter().Limit(), "GasMeter set with limit before setup") + + newCtx, err := antehandler(suite.ctx, tx, false) + suite.Require().Nil(err, "SetUpContextDecorator returned error") + + // Context GasMeter Limit should be set after SetUpContextDecorator runs + suite.Require().Equal(gasLimit, newCtx.GasMeter().Limit(), "GasMeter not set correctly") +} + +func (suite *AnteTestSuite) TestRecoverPanic() { + suite.SetupTest(true) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + + // keys and addresses + priv1, _, addr1 := testdata.KeyTestPubAddr() + + // msg and signatures + msg := testdata.NewTestMsg(addr1) + feeAmount := testdata.NewTestFeeAmount() + gasLimit := testdata.NewTestGasLimit() + suite.Require().NoError(suite.txBuilder.SetMsgs(msg)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) + + sud := ante.NewSetUpContextDecorator() + antehandler := sdk.ChainAnteDecorators(sud, OutOfGasDecorator{}) + + // Set height to non-zero value for GasMeter to be set + suite.ctx = suite.ctx.WithBlockHeight(1) + + newCtx, err := antehandler(suite.ctx, tx, false) + + suite.Require().NotNil(err, "Did not return error on OutOfGas panic") + + suite.Require().True(sdkerrors.ErrOutOfGas.Is(err), "Returned error is not an out of gas error") + suite.Require().Equal(gasLimit, newCtx.GasMeter().Limit()) + + antehandler = sdk.ChainAnteDecorators(sud, PanicDecorator{}) + suite.Require().Panics(func() { antehandler(suite.ctx, tx, false) }, "Recovered from non-Out-of-Gas panic") // nolint:errcheck +} + +type OutOfGasDecorator struct{} + +// AnteDecorator that will throw OutOfGas panic +func (ogd OutOfGasDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + overLimit := ctx.GasMeter().Limit() + 1 + + // Should panic with outofgas error + ctx.GasMeter().ConsumeGas(overLimit, "test panic") + + // not reached + return next(ctx, tx, simulate) +} + +type PanicDecorator struct{} + +func (pd PanicDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + panic("random error") +} diff --git a/x/auth/middleware/sigverify.go b/x/auth/ante/sigverify.go similarity index 52% rename from x/auth/middleware/sigverify.go rename to x/auth/ante/sigverify.go index 0e13b4142a29..b32f46728ff1 100644 --- a/x/auth/middleware/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -1,9 +1,9 @@ -package middleware +package ante import ( "bytes" - "context" "encoding/base64" + "encoding/hex" "fmt" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -14,11 +14,10 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/types" - abci "github.com/tendermint/tendermint/abci/types" ) var ( @@ -26,42 +25,44 @@ var ( key = make([]byte, secp256k1.PubKeySize) simSecp256k1Pubkey = &secp256k1.PubKey{Key: key} simSecp256k1Sig [64]byte + + _ authsigning.SigVerifiableTx = (*legacytx.StdTx)(nil) // assert StdTx implements SigVerifiableTx ) +func init() { + // This decodes a valid hex string into a sepc256k1Pubkey for use in transaction simulation + bz, _ := hex.DecodeString("035AD6810A47F073553FF30D2FCC7E0D3B1C0B74B61A1AAA2582344037151E143A") + copy(key, bz) + simSecp256k1Pubkey.Key = key +} + // SignatureVerificationGasConsumer is the type of function that is used to both // consume gas when verifying signatures and also to accept or reject different types of pubkeys // This is where apps can define their own PubKey type SignatureVerificationGasConsumer = func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error -var _ tx.Handler = setPubKeyTxHandler{} - -type setPubKeyTxHandler struct { - ak AccountKeeper - next tx.Handler +// SetPubKeyDecorator sets PubKeys in context for any signer which does not already have pubkey set +// PubKeys must be set in context for all signers before any other sigverify decorators run +// CONTRACT: Tx must implement SigVerifiableTx interface +type SetPubKeyDecorator struct { + ak AccountKeeper } -// SetPubKeyMiddleware sets PubKeys in context for any signer which does not already have pubkey set -// PubKeys must be set in context for all signers before any other sigverify middlewares run -// CONTRACT: Tx must implement SigVerifiableTx interface -func SetPubKeyMiddleware(ak AccountKeeper) tx.Middleware { - return func(txh tx.Handler) tx.Handler { - return setPubKeyTxHandler{ - ak: ak, - next: txh, - } +func NewSetPubKeyDecorator(ak AccountKeeper) SetPubKeyDecorator { + return SetPubKeyDecorator{ + ak: ak, } } -func (spkm setPubKeyTxHandler) setPubKey(ctx context.Context, req tx.Request, simulate bool) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - sigTx, ok := req.Tx.(authsigning.SigVerifiableTx) +func (spkd SetPubKeyDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + sigTx, ok := tx.(authsigning.SigVerifiableTx) if !ok { - return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") } pubkeys, err := sigTx.GetPubKeys() if err != nil { - return err + return ctx, err } signers := sigTx.GetSigners() @@ -75,13 +76,13 @@ func (spkm setPubKeyTxHandler) setPubKey(ctx context.Context, req tx.Request, si } // Only make check if simulate=false if !simulate && !bytes.Equal(pk.Address(), signers[i]) { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, + return ctx, sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "pubKey does not match signer address %s with signer index: %d", signers[i], i) } - acc, err := GetSignerAcc(sdkCtx, spkm.ak, signers[i]) + acc, err := GetSignerAcc(ctx, spkd.ak, signers[i]) if err != nil { - return err + return ctx, err } // account already has pubkey set,no need to reset if acc.GetPubKey() != nil { @@ -89,9 +90,9 @@ func (spkm setPubKeyTxHandler) setPubKey(ctx context.Context, req tx.Request, si } err = acc.SetPubKey(pk) if err != nil { - return sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, err.Error()) } - spkm.ak.SetAccount(sdkCtx, acc) + spkd.ak.SetAccount(ctx, acc) } // Also emit the following events, so that txs can be indexed by these @@ -100,7 +101,7 @@ func (spkm setPubKeyTxHandler) setPubKey(ctx context.Context, req tx.Request, si // - concat(address,"/",sequence) (via `tx.acc_seq='cosmos1abc...def/42'`). sigs, err := sigTx.GetSignaturesV2() if err != nil { - return err + return ctx, err } var events sdk.Events @@ -111,7 +112,7 @@ func (spkm setPubKeyTxHandler) setPubKey(ctx context.Context, req tx.Request, si sigBzs, err := signatureDataToBz(sig.Data) if err != nil { - return err + return ctx, err } for _, sigBz := range sigBzs { events = append(events, sdk.NewEvent(sdk.EventTypeTx, @@ -120,210 +121,41 @@ func (spkm setPubKeyTxHandler) setPubKey(ctx context.Context, req tx.Request, si } } - sdkCtx.EventManager().EmitEvents(events) - - return nil -} - -// CheckTx implements tx.Handler.CheckTx. -func (spkm setPubKeyTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := spkm.setPubKey(ctx, req, false); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } + ctx.EventManager().EmitEvents(events) - return spkm.next.CheckTx(ctx, req, checkReq) + return next(ctx, tx, simulate) } -// DeliverTx implements tx.Handler.DeliverTx. -func (spkm setPubKeyTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := spkm.setPubKey(ctx, req, false); err != nil { - return tx.Response{}, err - } - return spkm.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx. -func (spkm setPubKeyTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := spkm.setPubKey(ctx, req, true); err != nil { - return tx.Response{}, err - } - return spkm.next.SimulateTx(ctx, req) -} - -var _ tx.Handler = validateSigCountTxHandler{} - -type validateSigCountTxHandler struct { - ak AccountKeeper - next tx.Handler -} - -// ValidateSigCountMiddleware takes in Params and returns errors if there are too many signatures in the tx for the given params -// otherwise it calls next middleware -// Use this middleware to set parameterized limit on number of signatures in tx +// Consume parameter-defined amount of gas for each signature according to the passed-in SignatureVerificationGasConsumer function +// before calling the next AnteHandler +// CONTRACT: Pubkeys are set in context for all signers before this decorator runs // CONTRACT: Tx must implement SigVerifiableTx interface -func ValidateSigCountMiddleware(ak AccountKeeper) tx.Middleware { - return func(txh tx.Handler) tx.Handler { - return validateSigCountTxHandler{ - ak: ak, - next: txh, - } - } -} - -func (vscd validateSigCountTxHandler) checkSigCount(ctx context.Context, req tx.Request) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - sigTx, ok := req.Tx.(authsigning.SigVerifiableTx) - if !ok { - return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a sigTx") - } - - params := vscd.ak.GetParams(sdkCtx) - pubKeys, err := sigTx.GetPubKeys() - if err != nil { - return err - } - - sigCount := 0 - for _, pk := range pubKeys { - sigCount += CountSubKeys(pk) - if uint64(sigCount) > params.TxSigLimit { - return sdkerrors.Wrapf(sdkerrors.ErrTooManySignatures, - "signatures: %d, limit: %d", sigCount, params.TxSigLimit) - } - } - return nil -} - -// CheckTx implements tx.Handler.CheckTx. -func (vscd validateSigCountTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := vscd.checkSigCount(ctx, req); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return vscd.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (vscd validateSigCountTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := vscd.checkSigCount(ctx, req); err != nil { - return tx.Response{}, err - } - - return vscd.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx. -func (vscd validateSigCountTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := vscd.checkSigCount(ctx, req); err != nil { - return tx.Response{}, err - } - - return vscd.next.SimulateTx(ctx, req) -} - -// DefaultSigVerificationGasConsumer is the default implementation of SignatureVerificationGasConsumer. It consumes gas -// for signature verification based upon the public key type. The cost is fetched from the given params and is matched -// by the concrete type. -func DefaultSigVerificationGasConsumer( - meter sdk.GasMeter, sig signing.SignatureV2, params types.Params, -) error { - pubkey := sig.PubKey - switch pubkey := pubkey.(type) { - case *ed25519.PubKey: - meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519") - return sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "ED25519 public keys are unsupported") - - case *secp256k1.PubKey: - meter.ConsumeGas(params.SigVerifyCostSecp256k1, "ante verify: secp256k1") - return nil - - case *secp256r1.PubKey: - meter.ConsumeGas(params.SigVerifyCostSecp256r1(), "ante verify: secp256r1") - return nil - - case multisig.PubKey: - multisignature, ok := sig.Data.(*signing.MultiSignatureData) - if !ok { - return fmt.Errorf("expected %T, got, %T", &signing.MultiSignatureData{}, sig.Data) - } - err := ConsumeMultisignatureVerificationGas(meter, multisignature, pubkey, params, sig.Sequence) - if err != nil { - return err - } - return nil - - default: - return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey) - } -} - -// ConsumeMultisignatureVerificationGas consumes gas from a GasMeter for verifying a multisig pubkey signature -func ConsumeMultisignatureVerificationGas( - meter sdk.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey, - params types.Params, accSeq uint64, -) error { - - size := sig.BitArray.Count() - sigIndex := 0 - - for i := 0; i < size; i++ { - if !sig.BitArray.GetIndex(i) { - continue - } - sigV2 := signing.SignatureV2{ - PubKey: pubkey.GetPubKeys()[i], - Data: sig.Signatures[sigIndex], - Sequence: accSeq, - } - err := DefaultSigVerificationGasConsumer(meter, sigV2, params) - if err != nil { - return err - } - sigIndex++ - } - - return nil -} - -var _ tx.Handler = sigGasConsumeTxHandler{} - -type sigGasConsumeTxHandler struct { +type SigGasConsumeDecorator struct { ak AccountKeeper sigGasConsumer SignatureVerificationGasConsumer - next tx.Handler } -// SigGasConsumeMiddleware consumes parameter-defined amount of gas for each signature according to the passed-in SignatureVerificationGasConsumer function -// before calling the next middleware -// CONTRACT: Pubkeys are set in context for all signers before this middleware runs -// CONTRACT: Tx must implement SigVerifiableTx interface -func SigGasConsumeMiddleware(ak AccountKeeper, sigGasConsumer SignatureVerificationGasConsumer) tx.Middleware { +func NewSigGasConsumeDecorator(ak AccountKeeper, sigGasConsumer SignatureVerificationGasConsumer) SigGasConsumeDecorator { if sigGasConsumer == nil { sigGasConsumer = DefaultSigVerificationGasConsumer } - return func(h tx.Handler) tx.Handler { - return sigGasConsumeTxHandler{ - ak: ak, - sigGasConsumer: sigGasConsumer, - next: h, - } + return SigGasConsumeDecorator{ + ak: ak, + sigGasConsumer: sigGasConsumer, } } -func (sgcm sigGasConsumeTxHandler) sigGasConsume(ctx context.Context, req tx.Request, simulate bool) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - - sigTx, ok := req.Tx.(authsigning.SigVerifiableTx) +func (sgcd SigGasConsumeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { + sigTx, ok := tx.(authsigning.SigVerifiableTx) if !ok { - return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") } - params := sgcm.ak.GetParams(sdkCtx) + params := sgcd.ak.GetParams(ctx) sigs, err := sigTx.GetSignaturesV2() if err != nil { - return err + return ctx, err } // stdSigs contains the sequence number, account number, and signatures. @@ -331,9 +163,9 @@ func (sgcm sigGasConsumeTxHandler) sigGasConsume(ctx context.Context, req tx.Req signerAddrs := sigTx.GetSigners() for i, sig := range sigs { - signerAcc, err := GetSignerAcc(sdkCtx, sgcm.ak, signerAddrs[i]) + signerAcc, err := GetSignerAcc(ctx, sgcd.ak, signerAddrs[i]) if err != nil { - return err + return ctx, err } pubKey := signerAcc.GetPubKey() @@ -353,62 +185,29 @@ func (sgcm sigGasConsumeTxHandler) sigGasConsume(ctx context.Context, req tx.Req Sequence: sig.Sequence, } - err = sgcm.sigGasConsumer(sdkCtx.GasMeter(), sig, params) + err = sgcd.sigGasConsumer(ctx.GasMeter(), sig, params) if err != nil { - return err + return ctx, err } } - return nil -} - -// CheckTx implements tx.Handler.CheckTx. -func (sgcm sigGasConsumeTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := sgcm.sigGasConsume(ctx, req, false); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return sgcm.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (sgcm sigGasConsumeTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := sgcm.sigGasConsume(ctx, req, false); err != nil { - return tx.Response{}, err - } - - return sgcm.next.DeliverTx(ctx, req) + return next(ctx, tx, simulate) } -// SimulateTx implements tx.Handler.SimulateTx. -func (sgcm sigGasConsumeTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := sgcm.sigGasConsume(ctx, req, true); err != nil { - return tx.Response{}, err - } - - return sgcm.next.SimulateTx(ctx, req) -} - -var _ tx.Handler = sigVerificationTxHandler{} - -type sigVerificationTxHandler struct { +// Verify all signatures for a tx and return an error if any are invalid. Note, +// the SigVerificationDecorator decorator will not get executed on ReCheck. +// +// CONTRACT: Pubkeys are set in context for all signers before this decorator runs +// CONTRACT: Tx must implement SigVerifiableTx interface +type SigVerificationDecorator struct { ak AccountKeeper signModeHandler authsigning.SignModeHandler - next tx.Handler } -// SigVerificationMiddleware verifies all signatures for a tx and return an error if any are invalid. Note, -// the sigVerificationTxHandler middleware will not get executed on ReCheck. -// -// CONTRACT: Pubkeys are set in context for all signers before this middleware runs -// CONTRACT: Tx must implement SigVerifiableTx interface -func SigVerificationMiddleware(ak AccountKeeper, signModeHandler authsigning.SignModeHandler) tx.Middleware { - return func(h tx.Handler) tx.Handler { - return sigVerificationTxHandler{ - ak: ak, - signModeHandler: signModeHandler, - next: h, - } +func NewSigVerificationDecorator(ak AccountKeeper, signModeHandler authsigning.SignModeHandler) SigVerificationDecorator { + return SigVerificationDecorator{ + ak: ak, + signModeHandler: signModeHandler, } } @@ -416,7 +215,7 @@ func SigVerificationMiddleware(ak AccountKeeper, signModeHandler authsigning.Sig // signers are using SIGN_MODE_LEGACY_AMINO_JSON. If this is the case // then the corresponding SignatureV2 struct will not have account sequence // explicitly set, and we should skip the explicit verification of sig.Sequence -// in the SigVerificationMiddleware's middleware function. +// in the SigVerificationDecorator's AnteHandler function. func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool { switch v := sigData.(type) { case *signing.SingleSignatureData: @@ -433,61 +232,59 @@ func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool { } } -func (svd sigVerificationTxHandler) sigVerify(ctx context.Context, req tx.Request, isReCheckTx, simulate bool) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) +func (svd SigVerificationDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (newCtx sdk.Context, err error) { // no need to verify signatures on recheck tx - if isReCheckTx { - return nil + if ctx.IsReCheckTx() { + return next(ctx, tx, simulate) } - sigTx, ok := req.Tx.(authsigning.SigVerifiableTx) + sigTx, ok := tx.(authsigning.SigVerifiableTx) if !ok { - return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") } // stdSigs contains the sequence number, account number, and signatures. // When simulating, this would just be a 0-length slice. sigs, err := sigTx.GetSignaturesV2() if err != nil { - return err + return ctx, err } signerAddrs := sigTx.GetSigners() // check that signer length and signature length are the same if len(sigs) != len(signerAddrs) { - return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "invalid number of signer; expected: %d, got %d", len(signerAddrs), len(sigs)) + return ctx, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "invalid number of signer; expected: %d, got %d", len(signerAddrs), len(sigs)) } for i, sig := range sigs { - acc, err := GetSignerAcc(sdkCtx, svd.ak, signerAddrs[i]) + acc, err := GetSignerAcc(ctx, svd.ak, signerAddrs[i]) if err != nil { - return err + return ctx, err } // retrieve pubkey pubKey := acc.GetPubKey() if !simulate && pubKey == nil { - return sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "pubkey on account is not set") + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "pubkey on account is not set") } // Check account sequence number. if sig.Sequence != acc.GetSequence() { - return sdkerrors.Wrapf( + return ctx, sdkerrors.Wrapf( sdkerrors.ErrWrongSequence, "account sequence mismatch, expected %d, got %d", acc.GetSequence(), sig.Sequence, ) } // retrieve signer data - genesis := sdkCtx.BlockHeight() == 0 - chainID := sdkCtx.ChainID() + genesis := ctx.BlockHeight() == 0 + chainID := ctx.ChainID() var accNum uint64 if !genesis { accNum = acc.GetAccountNumber() } - signerData := authsigning.SignerData{ - Address: signerAddrs[i].String(), + Address: acc.GetAddress().String(), ChainID: chainID, AccountNumber: accNum, Sequence: acc.GetSequence(), @@ -495,7 +292,7 @@ func (svd sigVerificationTxHandler) sigVerify(ctx context.Context, req tx.Reques } if !simulate { - err := authsigning.VerifySignature(pubKey, signerData, sig.Data, svd.signModeHandler, req.Tx) + err := authsigning.VerifySignature(pubKey, signerData, sig.Data, svd.signModeHandler, tx) if err != nil { var errMsg string if OnlyLegacyAminoSigners(sig.Data) { @@ -505,112 +302,153 @@ func (svd sigVerificationTxHandler) sigVerify(ctx context.Context, req tx.Reques } else { errMsg = fmt.Sprintf("signature verification failed; please verify account number (%d) and chain-id (%s)", accNum, chainID) } - return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, errMsg) + return ctx, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, errMsg) } } } - return nil -} - -// CheckTx implements tx.Handler.CheckTx. -func (svd sigVerificationTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := svd.sigVerify(ctx, req, checkReq.Type == abci.CheckTxType_Recheck, false); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return svd.next.CheckTx(ctx, req, checkReq) + return next(ctx, tx, simulate) } -// DeliverTx implements tx.Handler.DeliverTx. -func (svd sigVerificationTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := svd.sigVerify(ctx, req, false, false); err != nil { - return tx.Response{}, err - } - - return svd.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx. -func (svd sigVerificationTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := svd.sigVerify(ctx, req, false, true); err != nil { - return tx.Response{}, err - } - - return svd.next.SimulateTx(ctx, req) -} - -var _ tx.Handler = incrementSequenceTxHandler{} - -type incrementSequenceTxHandler struct { - ak AccountKeeper - next tx.Handler -} - -// IncrementSequenceMiddleware handles incrementing sequences of all signers. -// Use the incrementSequenceTxHandler middleware to prevent replay attacks. Note, -// there is no need to execute incrementSequenceTxHandler on RecheckTX since +// IncrementSequenceDecorator handles incrementing sequences of all signers. +// Use the IncrementSequenceDecorator decorator to prevent replay attacks. Note, +// there is no need to execute IncrementSequenceDecorator on RecheckTX since // CheckTx would already bump the sequence number. // // NOTE: Since CheckTx and DeliverTx state are managed separately, subsequent and // sequential txs orginating from the same account cannot be handled correctly in // a reliable way unless sequence numbers are managed and tracked manually by a // client. It is recommended to instead use multiple messages in a tx. -func IncrementSequenceMiddleware(ak AccountKeeper) tx.Middleware { - return func(h tx.Handler) tx.Handler { - return incrementSequenceTxHandler{ - ak: ak, - next: h, - } +type IncrementSequenceDecorator struct { + ak AccountKeeper +} + +func NewIncrementSequenceDecorator(ak AccountKeeper) IncrementSequenceDecorator { + return IncrementSequenceDecorator{ + ak: ak, } } -func (isd incrementSequenceTxHandler) incrementSeq(ctx context.Context, req tx.Request) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - sigTx, ok := req.Tx.(authsigning.SigVerifiableTx) +func (isd IncrementSequenceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + sigTx, ok := tx.(authsigning.SigVerifiableTx) if !ok { - return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") } // increment sequence of all signers for _, addr := range sigTx.GetSigners() { - acc := isd.ak.GetAccount(sdkCtx, addr) + acc := isd.ak.GetAccount(ctx, addr) if err := acc.SetSequence(acc.GetSequence() + 1); err != nil { panic(err) } - isd.ak.SetAccount(sdkCtx, acc) + isd.ak.SetAccount(ctx, acc) } - return nil + return next(ctx, tx, simulate) } -// CheckTx implements tx.Handler.CheckTx. -func (isd incrementSequenceTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := isd.incrementSeq(ctx, req); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } +// ValidateSigCountDecorator takes in Params and returns errors if there are too many signatures in the tx for the given params +// otherwise it calls next AnteHandler +// Use this decorator to set parameterized limit on number of signatures in tx +// CONTRACT: Tx must implement SigVerifiableTx interface +type ValidateSigCountDecorator struct { + ak AccountKeeper +} - return isd.next.CheckTx(ctx, req, checkReq) +func NewValidateSigCountDecorator(ak AccountKeeper) ValidateSigCountDecorator { + return ValidateSigCountDecorator{ + ak: ak, + } } -// DeliverTx implements tx.Handler.DeliverTx. -func (isd incrementSequenceTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := isd.incrementSeq(ctx, req); err != nil { - return tx.Response{}, err +func (vscd ValidateSigCountDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + sigTx, ok := tx.(authsigning.SigVerifiableTx) + if !ok { + return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a sigTx") + } + + params := vscd.ak.GetParams(ctx) + pubKeys, err := sigTx.GetPubKeys() + if err != nil { + return ctx, err } - return isd.next.DeliverTx(ctx, req) + sigCount := 0 + for _, pk := range pubKeys { + sigCount += CountSubKeys(pk) + if uint64(sigCount) > params.TxSigLimit { + return ctx, sdkerrors.Wrapf(sdkerrors.ErrTooManySignatures, + "signatures: %d, limit: %d", sigCount, params.TxSigLimit) + } + } + + return next(ctx, tx, simulate) } -// SimulateTx implements tx.Handler.SimulateTx. -func (isd incrementSequenceTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := isd.incrementSeq(ctx, req); err != nil { - return tx.Response{}, err +// DefaultSigVerificationGasConsumer is the default implementation of SignatureVerificationGasConsumer. It consumes gas +// for signature verification based upon the public key type. The cost is fetched from the given params and is matched +// by the concrete type. +func DefaultSigVerificationGasConsumer( + meter sdk.GasMeter, sig signing.SignatureV2, params types.Params, +) error { + pubkey := sig.PubKey + switch pubkey := pubkey.(type) { + case *ed25519.PubKey: + meter.ConsumeGas(params.SigVerifyCostED25519, "ante verify: ed25519") + return sdkerrors.Wrap(sdkerrors.ErrInvalidPubKey, "ED25519 public keys are unsupported") + + case *secp256k1.PubKey: + meter.ConsumeGas(params.SigVerifyCostSecp256k1, "ante verify: secp256k1") + return nil + + case *secp256r1.PubKey: + meter.ConsumeGas(params.SigVerifyCostSecp256r1(), "ante verify: secp256r1") + return nil + + case multisig.PubKey: + multisignature, ok := sig.Data.(*signing.MultiSignatureData) + if !ok { + return fmt.Errorf("expected %T, got, %T", &signing.MultiSignatureData{}, sig.Data) + } + err := ConsumeMultisignatureVerificationGas(meter, multisignature, pubkey, params, sig.Sequence) + if err != nil { + return err + } + return nil + + default: + return sdkerrors.Wrapf(sdkerrors.ErrInvalidPubKey, "unrecognized public key type: %T", pubkey) + } +} + +// ConsumeMultisignatureVerificationGas consumes gas from a GasMeter for verifying a multisig pubkey signature +func ConsumeMultisignatureVerificationGas( + meter sdk.GasMeter, sig *signing.MultiSignatureData, pubkey multisig.PubKey, + params types.Params, accSeq uint64, +) error { + + size := sig.BitArray.Count() + sigIndex := 0 + + for i := 0; i < size; i++ { + if !sig.BitArray.GetIndex(i) { + continue + } + sigV2 := signing.SignatureV2{ + PubKey: pubkey.GetPubKeys()[i], + Data: sig.Signatures[sigIndex], + Sequence: accSeq, + } + err := DefaultSigVerificationGasConsumer(meter, sigV2, params) + if err != nil { + return err + } + sigIndex++ } - return isd.next.SimulateTx(ctx, req) + return nil } // GetSignerAcc returns an account for a given address that is expected to sign diff --git a/x/auth/middleware/sigverify_benchmark_test.go b/x/auth/ante/sigverify_benchmark_test.go similarity index 89% rename from x/auth/middleware/sigverify_benchmark_test.go rename to x/auth/ante/sigverify_benchmark_test.go index dc635985170b..56e596fa6b55 100644 --- a/x/auth/middleware/sigverify_benchmark_test.go +++ b/x/auth/ante/sigverify_benchmark_test.go @@ -1,4 +1,4 @@ -package middleware_test +package ante_test import ( "testing" @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256r1" ) -// This benchmark is used to asses the middleware.Secp256k1ToR1GasFactor value +// This benchmark is used to asses the ante.Secp256k1ToR1GasFactor value func BenchmarkSig(b *testing.B) { require := require.New(b) msg := tmcrypto.CRandBytes(1000) diff --git a/x/auth/middleware/sigverify_test.go b/x/auth/ante/sigverify_test.go similarity index 52% rename from x/auth/middleware/sigverify_test.go rename to x/auth/ante/sigverify_test.go index a0c68062a968..074f4c33afc1 100644 --- a/x/auth/middleware/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -1,10 +1,10 @@ -package middleware_test +package ante_test import ( "fmt" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec/legacy" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" @@ -14,22 +14,16 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" + "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/types" - abci "github.com/tendermint/tendermint/abci/types" ) -func (s *MWTestSuite) TestSetPubKey() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - require := s.Require() - txHandler := middleware.ComposeMiddlewares( - noopTxHandler, - middleware.SetPubKeyMiddleware(s.app.AccountKeeper), - ) +func (suite *AnteTestSuite) TestSetPubKey() { + suite.SetupTest(true) // setup + require := suite.Require() + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // keys and addresses priv1, pub1, addr1 := testdata.KeyTestPubAddr() @@ -42,32 +36,35 @@ func (s *MWTestSuite) TestSetPubKey() { msgs := make([]sdk.Msg, len(addrs)) // set accounts and create msg for each address for i, addr := range addrs { - acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr) + acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) require.NoError(acc.SetAccountNumber(uint64(i))) - s.app.AccountKeeper.SetAccount(ctx, acc) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) } - require.NoError(txBuilder.SetMsgs(msgs...)) - txBuilder.SetFeeAmount(testdata.NewTestFeeAmount()) - txBuilder.SetGasLimit(testdata.NewTestGasLimit()) + require.NoError(suite.txBuilder.SetMsgs(msgs...)) + suite.txBuilder.SetFeeAmount(testdata.NewTestFeeAmount()) + suite.txBuilder.SetGasLimit(testdata.NewTestGasLimit()) privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0} - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) require.NoError(err) - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) + spkd := ante.NewSetPubKeyDecorator(suite.app.AccountKeeper) + antehandler := sdk.ChainAnteDecorators(spkd) + + ctx, err := antehandler(suite.ctx, tx, false) require.NoError(err) - // Require that all accounts have pubkey set after middleware runs + // Require that all accounts have pubkey set after Decorator runs for i, addr := range addrs { - pk, err := s.app.AccountKeeper.GetPubKey(ctx, addr) + pk, err := suite.app.AccountKeeper.GetPubKey(ctx, addr) require.NoError(err, "Error on retrieving pubkey from account") require.True(pubs[i].Equals(pk), "Wrong Pubkey retrieved from AccountKeeper, idx=%d\nexpected=%s\n got=%s", i, pubs[i], pk) } } -func (s *MWTestSuite) TestConsumeSignatureVerificationGas() { +func (suite *AnteTestSuite) TestConsumeSignatureVerificationGas() { params := types.DefaultParams() msg := []byte{1, 2, 3, 4} cdc := simapp.MakeTestEncodingConfig().Amino @@ -81,9 +78,9 @@ func (s *MWTestSuite) TestConsumeSignatureVerificationGas() { for i := 0; i < len(pkSet1); i++ { stdSig := legacytx.StdSignature{PubKey: pkSet1[i], Signature: sigSet1[i]} sigV2, err := legacytx.StdSignatureToSignatureV2(cdc, stdSig) - s.Require().NoError(err) + suite.Require().NoError(err) err = multisig.AddSignatureV2(multisignature1, sigV2, pkSet1) - s.Require().NoError(err) + suite.Require().NoError(err) } type args struct { @@ -110,30 +107,23 @@ func (s *MWTestSuite) TestConsumeSignatureVerificationGas() { Data: tt.args.sig, Sequence: 0, // Arbitrary account sequence } - err := middleware.DefaultSigVerificationGasConsumer(tt.args.meter, sigV2, tt.args.params) + err := ante.DefaultSigVerificationGasConsumer(tt.args.meter, sigV2, tt.args.params) if tt.shouldErr { - s.Require().NotNil(err) + suite.Require().NotNil(err) } else { - s.Require().Nil(err) - s.Require().Equal(tt.gasConsumed, tt.args.meter.GasConsumed(), fmt.Sprintf("%d != %d", tt.gasConsumed, tt.args.meter.GasConsumed())) + suite.Require().Nil(err) + suite.Require().Equal(tt.gasConsumed, tt.args.meter.GasConsumed(), fmt.Sprintf("%d != %d", tt.gasConsumed, tt.args.meter.GasConsumed())) } } } -func (s *MWTestSuite) TestSigVerification() { - ctx := s.SetupTest(true) // setup +func (suite *AnteTestSuite) TestSigVerification() { + suite.SetupTest(true) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // make block height non-zero to ensure account numbers part of signBytes - ctx = ctx.WithBlockHeight(1) - txHandler := middleware.ComposeMiddlewares( - noopTxHandler, - middleware.SetPubKeyMiddleware(s.app.AccountKeeper), - middleware.SigVerificationMiddleware( - s.app.AccountKeeper, - s.clientCtx.TxConfig.SignModeHandler(), - ), - ) + suite.ctx = suite.ctx.WithBlockHeight(1) // keys and addresses priv1, _, addr1 := testdata.KeyTestPubAddr() @@ -145,15 +135,19 @@ func (s *MWTestSuite) TestSigVerification() { msgs := make([]sdk.Msg, len(addrs)) // set accounts and create msg for each address for i, addr := range addrs { - acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr) - s.Require().NoError(acc.SetAccountNumber(uint64(i))) - s.app.AccountKeeper.SetAccount(ctx, acc) + acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) + suite.Require().NoError(acc.SetAccountNumber(uint64(i))) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) } feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() + spkd := ante.NewSetPubKeyDecorator(suite.app.AccountKeeper) + svd := ante.NewSigVerificationDecorator(suite.app.AccountKeeper, suite.clientCtx.TxConfig.SignModeHandler()) + antehandler := sdk.ChainAnteDecorators(spkd, svd) + type testCase struct { name string privs []cryptotypes.PrivKey @@ -172,25 +166,21 @@ func (s *MWTestSuite) TestSigVerification() { {"no err on recheck", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, true, false}, } for i, tc := range testCases { - ctx = ctx.WithIsReCheckTx(tc.recheck) - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test + suite.ctx = suite.ctx.WithIsReCheckTx(tc.recheck) + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test - s.Require().NoError(txBuilder.SetMsgs(msgs...)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) + suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) - testTx, _, err := s.createTestTx(txBuilder, tc.privs, tc.accNums, tc.accSeqs, ctx.ChainID()) - s.Require().NoError(err) + tx, err := suite.CreateTestTx(tc.privs, tc.accNums, tc.accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) - if tc.recheck { - _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{Type: abci.CheckTxType_Recheck}) - } else { - _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) - } + _, err = antehandler(suite.ctx, tx, false) if tc.shouldErr { - s.Require().NotNil(err, "TestCase %d: %s did not error as expected", i, tc.name) + suite.Require().NotNil(err, "TestCase %d: %s did not error as expected", i, tc.name) } else { - s.Require().Nil(err, "TestCase %d: %s errored unexpectedly. Err: %v", i, tc.name, err) + suite.Require().Nil(err, "TestCase %d: %s errored unexpectedly. Err: %v", i, tc.name, err) } } } @@ -201,22 +191,35 @@ func (s *MWTestSuite) TestSigVerification() { // this, since it'll be handled by the test matrix. // In the meantime, we want to make double-sure amino compatibility works. // ref: https://github.com/cosmos/cosmos-sdk/issues/7229 -func (s *MWTestSuite) TestSigVerification_ExplicitAmino() { - ctx := s.SetupTest(true) - ctx = ctx.WithBlockHeight(1) +func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() { + suite.app, suite.ctx = createTestApp(suite.T(), true) + suite.ctx = suite.ctx.WithBlockHeight(1) // Set up TxConfig. - aminoCdc := legacy.Cdc - aminoCdc.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) - + aminoCdc := codec.NewLegacyAmino() // We're using TestMsg amino encoding in some tests, so register it here. txConfig := legacytx.StdTxConfig{Cdc: aminoCdc} - s.clientCtx = client.Context{}. + suite.clientCtx = client.Context{}. WithTxConfig(txConfig) + anteHandler, err := ante.NewAnteHandler( + ante.HandlerOptions{ + AccountKeeper: suite.app.AccountKeeper, + BankKeeper: suite.app.BankKeeper, + FeegrantKeeper: suite.app.FeeGrantKeeper, + SignModeHandler: txConfig.SignModeHandler(), + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + ) + + suite.Require().NoError(err) + suite.anteHandler = anteHandler + + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() + // make block height non-zero to ensure account numbers part of signBytes - ctx = ctx.WithBlockHeight(1) + suite.ctx = suite.ctx.WithBlockHeight(1) // keys and addresses priv1, _, addr1 := testdata.KeyTestPubAddr() @@ -228,23 +231,18 @@ func (s *MWTestSuite) TestSigVerification_ExplicitAmino() { msgs := make([]sdk.Msg, len(addrs)) // set accounts and create msg for each address for i, addr := range addrs { - acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr) - s.Require().NoError(acc.SetAccountNumber(uint64(i))) - s.app.AccountKeeper.SetAccount(ctx, acc) + acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) + suite.Require().NoError(acc.SetAccountNumber(uint64(i))) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) } feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - txHandler := middleware.ComposeMiddlewares( - noopTxHandler, - middleware.SetPubKeyMiddleware(s.app.AccountKeeper), - middleware.SigVerificationMiddleware( - s.app.AccountKeeper, - s.clientCtx.TxConfig.SignModeHandler(), - ), - ) + spkd := ante.NewSetPubKeyDecorator(suite.app.AccountKeeper) + svd := ante.NewSigVerificationDecorator(suite.app.AccountKeeper, suite.clientCtx.TxConfig.SignModeHandler()) + antehandler := sdk.ChainAnteDecorators(spkd, svd) type testCase struct { name string @@ -254,7 +252,6 @@ func (s *MWTestSuite) TestSigVerification_ExplicitAmino() { recheck bool shouldErr bool } - testCases := []testCase{ {"no signers", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, false, true}, {"not enough signers", []cryptotypes.PrivKey{priv1, priv2}, []uint64{0, 1}, []uint64{0, 0}, false, true}, @@ -264,32 +261,27 @@ func (s *MWTestSuite) TestSigVerification_ExplicitAmino() { {"valid tx", []cryptotypes.PrivKey{priv1, priv2, priv3}, []uint64{0, 1, 2}, []uint64{0, 0, 0}, false, false}, {"no err on recheck", []cryptotypes.PrivKey{}, []uint64{}, []uint64{}, true, false}, } - for i, tc := range testCases { - ctx = ctx.WithIsReCheckTx(tc.recheck) - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test + suite.ctx = suite.ctx.WithIsReCheckTx(tc.recheck) + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Create new txBuilder for each test - s.Require().NoError(txBuilder.SetMsgs(msgs...)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) + suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) - testTx, _, err := s.createTestTx(txBuilder, tc.privs, tc.accNums, tc.accSeqs, ctx.ChainID()) - s.Require().NoError(err) + tx, err := suite.CreateTestTx(tc.privs, tc.accNums, tc.accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) - if tc.recheck { - _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{Type: abci.CheckTxType_Recheck}) - } else { - _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) - } + _, err = antehandler(suite.ctx, tx, false) if tc.shouldErr { - s.Require().NotNil(err, "TestCase %d: %s did not error as expected", i, tc.name) + suite.Require().NotNil(err, "TestCase %d: %s did not error as expected", i, tc.name) } else { - s.Require().Nil(err, "TestCase %d: %s errored unexpectedly. Err: %v", i, tc.name, err) + suite.Require().Nil(err, "TestCase %d: %s errored unexpectedly. Err: %v", i, tc.name, err) } } } -func (s *MWTestSuite) TestSigIntegration() { +func (suite *AnteTestSuite) TestSigIntegration() { // generate private keys privs := []cryptotypes.PrivKey{ secp256k1.GenPrivKey(), @@ -299,23 +291,23 @@ func (s *MWTestSuite) TestSigIntegration() { params := types.DefaultParams() initialSigCost := params.SigVerifyCostSecp256k1 - initialCost, err := s.runSigMiddlewares(params, false, privs...) - s.Require().Nil(err) + initialCost, err := suite.runSigDecorators(params, false, privs...) + suite.Require().Nil(err) params.SigVerifyCostSecp256k1 *= 2 - doubleCost, err := s.runSigMiddlewares(params, false, privs...) - s.Require().Nil(err) + doubleCost, err := suite.runSigDecorators(params, false, privs...) + suite.Require().Nil(err) - s.Require().Equal(initialSigCost*uint64(len(privs)), doubleCost-initialCost) + suite.Require().Equal(initialSigCost*uint64(len(privs)), doubleCost-initialCost) } -func (s *MWTestSuite) runSigMiddlewares(params types.Params, _ bool, privs ...cryptotypes.PrivKey) (sdk.Gas, error) { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs ...cryptotypes.PrivKey) (sdk.Gas, error) { + suite.SetupTest(true) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() // Make block-height non-zero to include accNum in SignBytes - ctx = ctx.WithBlockHeight(1) - s.app.AccountKeeper.SetParams(ctx, params) + suite.ctx = suite.ctx.WithBlockHeight(1) + suite.app.AccountKeeper.SetParams(suite.ctx, params) msgs := make([]sdk.Msg, len(privs)) accNums := make([]uint64, len(privs)) @@ -323,89 +315,76 @@ func (s *MWTestSuite) runSigMiddlewares(params types.Params, _ bool, privs ...cr // set accounts and create msg for each address for i, priv := range privs { addr := sdk.AccAddress(priv.PubKey().Address()) - acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr) - s.Require().NoError(acc.SetAccountNumber(uint64(i))) - s.app.AccountKeeper.SetAccount(ctx, acc) + acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) + suite.Require().NoError(acc.SetAccountNumber(uint64(i))) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs[i] = testdata.NewTestMsg(addr) accNums[i] = uint64(i) accSeqs[i] = uint64(0) } - s.Require().NoError(txBuilder.SetMsgs(msgs...)) + suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - txHandler := middleware.ComposeMiddlewares( - noopTxHandler, - middleware.SetPubKeyMiddleware(s.app.AccountKeeper), - middleware.SigGasConsumeMiddleware(s.app.AccountKeeper, middleware.DefaultSigVerificationGasConsumer), - middleware.SigVerificationMiddleware( - s.app.AccountKeeper, - s.clientCtx.TxConfig.SignModeHandler(), - ), - ) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) - // Determine gas consumption of txhandler with default params - before := ctx.GasMeter().GasConsumed() - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) + spkd := ante.NewSetPubKeyDecorator(suite.app.AccountKeeper) + svgc := ante.NewSigGasConsumeDecorator(suite.app.AccountKeeper, ante.DefaultSigVerificationGasConsumer) + svd := ante.NewSigVerificationDecorator(suite.app.AccountKeeper, suite.clientCtx.TxConfig.SignModeHandler()) + antehandler := sdk.ChainAnteDecorators(spkd, svgc, svd) + + // Determine gas consumption of antehandler with default params + before := suite.ctx.GasMeter().GasConsumed() + ctx, err := antehandler(suite.ctx, tx, false) after := ctx.GasMeter().GasConsumed() return after - before, err } -func (s *MWTestSuite) TestIncrementSequenceMiddleware() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() +func (suite *AnteTestSuite) TestIncrementSequenceDecorator() { + suite.SetupTest(true) // setup + suite.txBuilder = suite.clientCtx.TxConfig.NewTxBuilder() priv, _, addr := testdata.KeyTestPubAddr() - acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr) - s.Require().NoError(acc.SetAccountNumber(uint64(50))) - s.app.AccountKeeper.SetAccount(ctx, acc) + acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) + suite.Require().NoError(acc.SetAccountNumber(uint64(50))) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc) msgs := []sdk.Msg{testdata.NewTestMsg(addr)} - s.Require().NoError(txBuilder.SetMsgs(msgs...)) + suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) privs := []cryptotypes.PrivKey{priv} - accNums := []uint64{s.app.AccountKeeper.GetAccount(ctx, addr).GetAccountNumber()} - accSeqs := []uint64{s.app.AccountKeeper.GetAccount(ctx, addr).GetSequence()} + accNums := []uint64{suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetAccountNumber()} + accSeqs := []uint64{suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetSequence()} feeAmount := testdata.NewTestFeeAmount() gasLimit := testdata.NewTestGasLimit() - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) + tx, err := suite.CreateTestTx(privs, accNums, accSeqs, suite.ctx.ChainID()) + suite.Require().NoError(err) - txHandler := middleware.ComposeMiddlewares( - noopTxHandler, - middleware.IncrementSequenceMiddleware(s.app.AccountKeeper), - ) + isd := ante.NewIncrementSequenceDecorator(suite.app.AccountKeeper) + antehandler := sdk.ChainAnteDecorators(isd) testCases := []struct { ctx sdk.Context simulate bool expectedSeq uint64 }{ - {ctx.WithIsReCheckTx(true), false, 1}, - {ctx.WithIsCheckTx(true).WithIsReCheckTx(false), false, 2}, - {ctx.WithIsReCheckTx(true), false, 3}, - {ctx.WithIsReCheckTx(true), false, 4}, - {ctx.WithIsReCheckTx(true), true, 5}, + {suite.ctx.WithIsReCheckTx(true), false, 1}, + {suite.ctx.WithIsCheckTx(true).WithIsReCheckTx(false), false, 2}, + {suite.ctx.WithIsReCheckTx(true), false, 3}, + {suite.ctx.WithIsReCheckTx(true), false, 4}, + {suite.ctx.WithIsReCheckTx(true), true, 5}, } for i, tc := range testCases { - var err error - if tc.simulate { - _, err = txHandler.SimulateTx(sdk.WrapSDKContext(tc.ctx), tx.Request{Tx: testTx}) - } else { - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(tc.ctx), tx.Request{Tx: testTx}) - } - - s.Require().NoError(err, "unexpected error; tc #%d, %v", i, tc) - s.Require().Equal(tc.expectedSeq, s.app.AccountKeeper.GetAccount(ctx, addr).GetSequence()) + _, err := antehandler(tc.ctx, tx, tc.simulate) + suite.Require().NoError(err, "unexpected error; tc #%d, %v", i, tc) + suite.Require().Equal(tc.expectedSeq, suite.app.AccountKeeper.GetAccount(suite.ctx, addr).GetSequence()) } } diff --git a/x/auth/ante/testutil_test.go b/x/auth/ante/testutil_test.go new file mode 100644 index 000000000000..15598b3b23b0 --- /dev/null +++ b/x/auth/ante/testutil_test.go @@ -0,0 +1,200 @@ +package ante_test + +import ( + "errors" + "fmt" + "testing" + + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/testdata" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + "github.com/cosmos/cosmos-sdk/x/auth/ante" + xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/cosmos/cosmos-sdk/x/auth/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// TestAccount represents an account used in the tests in x/auth/ante. +type TestAccount struct { + acc types.AccountI + priv cryptotypes.PrivKey +} + +// AnteTestSuite is a test suite to be used with ante handler tests. +type AnteTestSuite struct { + suite.Suite + + app *simapp.SimApp + anteHandler sdk.AnteHandler + ctx sdk.Context + clientCtx client.Context + txBuilder client.TxBuilder +} + +// returns context and app with params set on account keeper +func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) { + app := simapp.Setup(t, isCheckTx) + ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) + app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) + + return app, ctx +} + +// SetupTest setups a new test, with new app, context, and anteHandler. +func (suite *AnteTestSuite) SetupTest(isCheckTx bool) { + suite.app, suite.ctx = createTestApp(suite.T(), isCheckTx) + suite.ctx = suite.ctx.WithBlockHeight(1) + + // Set up TxConfig. + encodingConfig := simapp.MakeTestEncodingConfig() + // We're using TestMsg encoding in some tests, so register it here. + encodingConfig.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) + testdata.RegisterInterfaces(encodingConfig.InterfaceRegistry) + + suite.clientCtx = client.Context{}. + WithTxConfig(encodingConfig.TxConfig) + + anteHandler, err := ante.NewAnteHandler( + ante.HandlerOptions{ + AccountKeeper: suite.app.AccountKeeper, + BankKeeper: suite.app.BankKeeper, + FeegrantKeeper: suite.app.FeeGrantKeeper, + SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), + SigGasConsumer: ante.DefaultSigVerificationGasConsumer, + }, + ) + + suite.Require().NoError(err) + suite.anteHandler = anteHandler +} + +// CreateTestAccounts creates `numAccs` accounts, and return all relevant +// information about them including their private keys. +func (suite *AnteTestSuite) CreateTestAccounts(numAccs int) []TestAccount { + var accounts []TestAccount + + for i := 0; i < numAccs; i++ { + priv, _, addr := testdata.KeyTestPubAddr() + acc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr) + err := acc.SetAccountNumber(uint64(i)) + suite.Require().NoError(err) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc) + someCoins := sdk.Coins{ + sdk.NewInt64Coin("atom", 10000000), + } + err = suite.app.BankKeeper.MintCoins(suite.ctx, minttypes.ModuleName, someCoins) + suite.Require().NoError(err) + + err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, minttypes.ModuleName, addr, someCoins) + suite.Require().NoError(err) + + accounts = append(accounts, TestAccount{acc, priv}) + } + + return accounts +} + +// CreateTestTx is a helper function to create a tx given multiple inputs. +func (suite *AnteTestSuite) CreateTestTx(privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, error) { + // First round: we gather all the signer infos. We use the "set empty + // signature" hack to do that. + var sigsV2 []signing.SignatureV2 + for i, priv := range privs { + sigV2 := signing.SignatureV2{ + PubKey: priv.PubKey(), + Data: &signing.SingleSignatureData{ + SignMode: suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), + Signature: nil, + }, + Sequence: accSeqs[i], + } + + sigsV2 = append(sigsV2, sigV2) + } + err := suite.txBuilder.SetSignatures(sigsV2...) + if err != nil { + return nil, err + } + + // Second round: all signer infos are set, so each signer can sign. + sigsV2 = []signing.SignatureV2{} + for i, priv := range privs { + signerData := xauthsigning.SignerData{ + ChainID: chainID, + AccountNumber: accNums[i], + Sequence: accSeqs[i], + } + sigV2, err := tx.SignWithPrivKey( + suite.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, + suite.txBuilder, priv, suite.clientCtx.TxConfig, accSeqs[i]) + if err != nil { + return nil, err + } + + sigsV2 = append(sigsV2, sigV2) + } + err = suite.txBuilder.SetSignatures(sigsV2...) + if err != nil { + return nil, err + } + + return suite.txBuilder.GetTx(), nil +} + +// TestCase represents a test case used in test tables. +type TestCase struct { + desc string + malleate func() + simulate bool + expPass bool + expErr error +} + +// CreateTestTx is a helper function to create a tx given multiple inputs. +func (suite *AnteTestSuite) RunTestCase(privs []cryptotypes.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, accNums, accSeqs []uint64, chainID string, tc TestCase) { + suite.Run(fmt.Sprintf("Case %s", tc.desc), func() { + suite.Require().NoError(suite.txBuilder.SetMsgs(msgs...)) + suite.txBuilder.SetFeeAmount(feeAmount) + suite.txBuilder.SetGasLimit(gasLimit) + + // Theoretically speaking, ante handler unit tests should only test + // ante handlers, but here we sometimes also test the tx creation + // process. + tx, txErr := suite.CreateTestTx(privs, accNums, accSeqs, chainID) + newCtx, anteErr := suite.anteHandler(suite.ctx, tx, tc.simulate) + + if tc.expPass { + suite.Require().NoError(txErr) + suite.Require().NoError(anteErr) + suite.Require().NotNil(newCtx) + + suite.ctx = newCtx + } else { + switch { + case txErr != nil: + suite.Require().Error(txErr) + suite.Require().True(errors.Is(txErr, tc.expErr)) + + case anteErr != nil: + suite.Require().Error(anteErr) + suite.Require().True(errors.Is(anteErr, tc.expErr)) + + default: + suite.Fail("expected one of txErr,anteErr to be an error") + } + } + }) +} + +func TestAnteTestSuite(t *testing.T) { + suite.Run(t, new(AnteTestSuite)) +} diff --git a/x/auth/middleware/validator_tx_fee.go b/x/auth/ante/validator_tx_fee.go similarity index 59% rename from x/auth/middleware/validator_tx_fee.go rename to x/auth/ante/validator_tx_fee.go index 687608da55a9..b1725d62ddc0 100644 --- a/x/auth/middleware/validator_tx_fee.go +++ b/x/auth/ante/validator_tx_fee.go @@ -1,4 +1,4 @@ -package middleware +package ante import ( "math" @@ -19,21 +19,24 @@ func checkTxFeeWithValidatorMinGasPrices(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, gas := feeTx.GetGas() // Ensure that the provided fees meet a minimum threshold for the validator, - // This is only for local mempool purposes, if this is a DeliverTx, the `MinGasPrices` should be zero. - minGasPrices := ctx.MinGasPrices() - if !minGasPrices.IsZero() { - requiredFees := make(sdk.Coins, len(minGasPrices)) - - // Determine the required fees by multiplying each required minimum gas - // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). - glDec := sdk.NewDec(int64(gas)) - for i, gp := range minGasPrices { - fee := gp.Amount.Mul(glDec) - requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) - } - - if !feeCoins.IsAnyGTE(requiredFees) { - return nil, 0, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) + // if this is a CheckTx. This is only for local mempool purposes, and thus + // is only ran on check tx. + if ctx.IsCheckTx() { + minGasPrices := ctx.MinGasPrices() + if !minGasPrices.IsZero() { + requiredFees := make(sdk.Coins, len(minGasPrices)) + + // Determine the required fees by multiplying each required minimum gas + // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). + glDec := sdk.NewDec(int64(gas)) + for i, gp := range minGasPrices { + fee := gp.Amount.Mul(glDec) + requiredFees[i] = sdk.NewCoin(gp.Denom, fee.Ceil().RoundInt()) + } + + if !feeCoins.IsAnyGTE(requiredFees) { + return nil, 0, sdkerrors.Wrapf(sdkerrors.ErrInsufficientFee, "insufficient fees; got: %s required: %s", feeCoins, requiredFees) + } } } diff --git a/x/auth/client/cli/tx_multisign.go b/x/auth/client/cli/tx_multisign.go index 9c0432df7956..48c819cb8eab 100644 --- a/x/auth/client/cli/tx_multisign.go +++ b/x/auth/client/cli/tx_multisign.go @@ -32,8 +32,9 @@ type BroadcastReq struct { // GetSignCommand returns the sign command func GetMultiSignCommand() *cobra.Command { cmd := &cobra.Command{ - Use: "multisign [file] [name] [[signature]...]", - Short: "Generate multisig signatures for transactions generated offline", + Use: "multi-sign [file] [name] [[signature]...]", + Aliases: []string{"multisign"}, + Short: "Generate multisig signatures for transactions generated offline", Long: strings.TrimSpace( fmt.Sprintf(`Sign transactions created with the --generate-only flag that require multisig signatures. @@ -138,7 +139,7 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) { err = signing.VerifySignature(sig.PubKey, signingData, sig.Data, txCfg.SignModeHandler(), txBuilder.GetTx()) if err != nil { - addr, _ := sdk.AccAddressFromHex(sig.PubKey.Address().String()) + addr, _ := sdk.AccAddressFromHexUnsafe(sig.PubKey.Address().String()) return fmt.Errorf("couldn't verify signature for address %s", addr) } @@ -191,7 +192,7 @@ func makeMultiSignCmd() func(cmd *cobra.Command, args []string) (err error) { return } - fp, err := os.OpenFile(outputDoc, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644) + fp, err := os.OpenFile(outputDoc, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return err } @@ -258,7 +259,7 @@ func makeBatchMultisignCmd() func(cmd *cobra.Command, args []string) error { txFactory = txFactory.WithSignMode(signingtypes.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) } - var infile = os.Stdin + infile := os.Stdin if args[0] != "-" { infile, err = os.Open(args[0]) defer func() { diff --git a/x/auth/client/cli/tx_sign.go b/x/auth/client/cli/tx_sign.go index fd32d96767fe..39626e5ed1ac 100644 --- a/x/auth/client/cli/tx_sign.go +++ b/x/auth/client/cli/tx_sign.go @@ -54,9 +54,10 @@ account key. It implies --signature-only. cmd.Flags().String(flags.FlagOutputDocument, "", "The document will be written to the given file instead of STDOUT") cmd.Flags().Bool(flagSigOnly, true, "Print only the generated signature, then exit") cmd.Flags().String(flags.FlagChainID, "", "network chain ID") - cmd.MarkFlagRequired(flags.FlagFrom) flags.AddTxFlagsToCmd(cmd) + cmd.MarkFlagRequired(flags.FlagFrom) + return cmd } @@ -106,7 +107,7 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error { } if ms == "" { from, _ := cmd.Flags().GetString(flags.FlagFrom) - _, fromName, _, err := client.GetFromFields(txFactory.Keybase(), from, clientCtx.GenerateOnly) + _, fromName, _, err := client.GetFromFields(clientCtx, txFactory.Keybase(), from) if err != nil { return fmt.Errorf("error getting account from keybase: %w", err) } @@ -115,7 +116,7 @@ func makeSignBatchCmd() func(cmd *cobra.Command, args []string) error { return err } } else { - multisigAddr, _, _, err := client.GetFromFields(txFactory.Keybase(), ms, clientCtx.GenerateOnly) + multisigAddr, _, _, err := client.GetFromFields(clientCtx, txFactory.Keybase(), ms) if err != nil { return fmt.Errorf("error getting account from keybase: %w", err) } @@ -152,7 +153,7 @@ func setOutputFile(cmd *cobra.Command) (func(), error) { return func() {}, nil } - fp, err := os.OpenFile(outputDoc, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644) + fp, err := os.OpenFile(outputDoc, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return func() {}, err } @@ -192,9 +193,10 @@ be generated via the 'multisign' command. cmd.Flags().String(flags.FlagOutputDocument, "", "The document will be written to the given file instead of STDOUT") cmd.Flags().String(flags.FlagChainID, "", "The network chain ID") cmd.Flags().Bool(flagAmino, false, "Generate Amino encoded JSON suitable for submiting to the txs REST endpoint") - cmd.MarkFlagRequired(flags.FlagFrom) flags.AddTxFlagsToCmd(cmd) + cmd.MarkFlagRequired(flags.FlagFrom) + return cmd } @@ -235,7 +237,7 @@ func makeSignCmd() func(cmd *cobra.Command, args []string) error { return err } from, _ := cmd.Flags().GetString(flags.FlagFrom) - _, fromName, _, err := client.GetFromFields(txF.Keybase(), from, clientCtx.GenerateOnly) + _, fromName, _, err := client.GetFromFields(clientCtx, txF.Keybase(), from) if err != nil { return fmt.Errorf("error getting account from keybase: %w", err) } @@ -245,7 +247,7 @@ func makeSignCmd() func(cmd *cobra.Command, args []string) error { multisigAddr, err := sdk.AccAddressFromBech32(multisig) if err != nil { // Bech32 decode error, maybe it's a name, we try to fetch from keyring - multisigAddr, _, _, err = client.GetFromFields(txFactory.Keybase(), multisig, clientCtx.GenerateOnly) + multisigAddr, _, _, err = client.GetFromFields(clientCtx, txFactory.Keybase(), multisig) if err != nil { return fmt.Errorf("error getting account from keybase: %w", err) } @@ -300,7 +302,7 @@ func makeSignCmd() func(cmd *cobra.Command, args []string) error { return nil } - fp, err := os.OpenFile(outputDoc, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644) + fp, err := os.OpenFile(outputDoc, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o644) if err != nil { return err } diff --git a/x/auth/client/testutil/cli_test.go b/x/auth/client/testutil/cli_test.go index 0a7a5cc25871..f23e88847c30 100644 --- a/x/auth/client/testutil/cli_test.go +++ b/x/auth/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/auth/client/testutil/suite.go b/x/auth/client/testutil/suite.go index 8e5d25d652e7..a56885920220 100644 --- a/x/auth/client/testutil/suite.go +++ b/x/auth/client/testutil/suite.go @@ -231,7 +231,7 @@ func (s *IntegrationTestSuite) TestCLISignGenOnly() { func (s *IntegrationTestSuite) TestCLISignBatch() { val := s.network.Validators[0] - var sendTokens = sdk.NewCoins( + sendTokens := sdk.NewCoins( sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ) @@ -284,7 +284,7 @@ func (s *IntegrationTestSuite) TestCLISignAminoJSON() { require := s.Require() val1 := s.network.Validators[0] txCfg := val1.ClientCtx.TxConfig - var sendTokens = sdk.NewCoins( + sendTokens := sdk.NewCoins( sdk.NewCoin(fmt.Sprintf("%stoken", val1.Moniker), sdk.NewInt(10)), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), ) @@ -917,7 +917,7 @@ func (s *IntegrationTestSuite) TestCLIMultisignSortSignatures() { err = val1.ClientCtx.Codec.UnmarshalJSON(resp.Bytes(), &balRes) s.Require().NoError(err) - diff, _ := balRes.Balances.SafeSub(intialCoins) + diff, _ := balRes.Balances.SafeSub(intialCoins...) s.Require().Equal(sendTokens.Amount, diff.AmountOf(s.cfg.BondDenom)) // Generate multisig transaction. @@ -1561,7 +1561,7 @@ func (s *IntegrationTestSuite) TestAuxSigner() { } } -func (s *IntegrationTestSuite) TestAuxToFee() { +func (s *IntegrationTestSuite) TestAuxToFeeWithTips() { require := s.Require() val := s.network.Validators[0] @@ -1577,13 +1577,13 @@ func (s *IntegrationTestSuite) TestAuxToFee() { fee := sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(1000)) tip := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(1000)) - s.Require().NoError(s.network.WaitForNextBlock()) + require.NoError(s.network.WaitForNextBlock()) _, err = s.createBankMsg(val, tipper, sdk.NewCoins(tipperInitialBal)) require.NoError(err) - s.Require().NoError(s.network.WaitForNextBlock()) + require.NoError(s.network.WaitForNextBlock()) bal := s.getBalances(val.ClientCtx, tipper, tip.Denom) - s.Require().True(bal.Equal(tipperInitialBal.Amount)) + require.True(bal.Equal(tipperInitialBal.Amount)) testCases := []struct { name string @@ -1596,24 +1596,6 @@ func (s *IntegrationTestSuite) TestAuxToFee() { tipperArgs []string feePayerArgs []string }{ - { - name: "when --aux and --sign-mode = direct set: error", - tipper: tipper, - feePayer: feePayer, - tip: tip, - tipperArgs: []string{ - fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirect), - fmt.Sprintf("--%s=%s", flags.FlagTip, tip), - fmt.Sprintf("--%s=true", flags.FlagAux), - }, - expectErrAux: true, - feePayerArgs: []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), - fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer), - fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()), - }, - }, { name: "when --aux and --sign-mode = direct set: error", tipper: tipper, @@ -1752,7 +1734,7 @@ func (s *IntegrationTestSuite) TestAuxToFee() { feePayerArgs: []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeDirect), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFrom, feePayer), fmt.Sprintf("--%s=%s", flags.FlagFees, fee.String()), }, @@ -1809,21 +1791,21 @@ func (s *IntegrationTestSuite) TestAuxToFee() { require.NoError(err) var txRes sdk.TxResponse - s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(res.Bytes(), &txRes)) + require.NoError(val.ClientCtx.Codec.UnmarshalJSON(res.Bytes(), &txRes)) require.Contains(txRes.RawLog, tc.errMsg) } else { require.NoError(err) var txRes sdk.TxResponse - s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(res.Bytes(), &txRes)) + require.NoError(val.ClientCtx.Codec.UnmarshalJSON(res.Bytes(), &txRes)) - s.Require().Equal(uint32(0), txRes.Code) - s.Require().NotNil(int64(0), txRes.Height) + require.Equal(uint32(0), txRes.Code) + require.NotNil(int64(0), txRes.Height) bal = s.getBalances(val.ClientCtx, tipper, tc.tip.Denom) tipperInitialBal = tipperInitialBal.Sub(tc.tip) - s.Require().True(bal.Equal(tipperInitialBal.Amount)) + require.True(bal.Equal(tipperInitialBal.Amount)) } } }) @@ -1831,7 +1813,8 @@ func (s *IntegrationTestSuite) TestAuxToFee() { } func (s *IntegrationTestSuite) createBankMsg(val *network.Validator, toAddr sdk.AccAddress, amount sdk.Coins, extraFlags ...string) (testutil.BufferWriter, error) { - flags := []string{fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + flags := []string{ + 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()), diff --git a/x/auth/client/tx.go b/x/auth/client/tx.go index a57f28d3d956..38203299de87 100644 --- a/x/auth/client/tx.go +++ b/x/auth/client/tx.go @@ -68,7 +68,8 @@ func SignTx(txFactory tx.Factory, clientCtx client.Context, name string, txBuild // This function should only be used when signing with a multisig. For // normal keys, please use SignTx directly. func SignTxWithSignerAddress(txFactory tx.Factory, clientCtx client.Context, addr sdk.AccAddress, - name string, txBuilder client.TxBuilder, offline, overwrite bool) (err error) { + name string, txBuilder client.TxBuilder, offline, overwrite bool, +) (err error) { // Multisigs only support LEGACY_AMINO_JSON signing. if txFactory.SignMode() == signing.SignMode_SIGN_MODE_UNSPECIFIED { txFactory = txFactory.WithSignMode(signing.SignMode_SIGN_MODE_LEGACY_AMINO_JSON) @@ -145,7 +146,6 @@ func (bs *BatchScanner) Scan() bool { func populateAccountFromState( txBldr tx.Factory, clientCtx client.Context, addr sdk.AccAddress, ) (tx.Factory, error) { - num, seq, err := clientCtx.AccountRetriever.GetAccountNumberSequence(clientCtx, addr) if err != nil { return txBldr, err diff --git a/x/auth/client/tx_test.go b/x/auth/client/tx_test.go index fc52206d6e07..4934e0febc91 100644 --- a/x/auth/client/tx_test.go +++ b/x/auth/client/tx_test.go @@ -149,7 +149,7 @@ func compareEncoders(t *testing.T, expected sdk.TxEncoder, actual sdk.TxEncoder) } func makeCodec() *codec.LegacyAmino { - var cdc = codec.NewLegacyAmino() + cdc := codec.NewLegacyAmino() sdk.RegisterLegacyAminoCodec(cdc) cryptocodec.RegisterCrypto(cdc) authtypes.RegisterLegacyAminoCodec(cdc) diff --git a/x/auth/genesis.go b/x/auth/keeper/genesis.go similarity index 81% rename from x/auth/genesis.go rename to x/auth/keeper/genesis.go index 851b588083d4..50d36381fd6f 100644 --- a/x/auth/genesis.go +++ b/x/auth/keeper/genesis.go @@ -1,8 +1,7 @@ -package auth +package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/keeper" "github.com/cosmos/cosmos-sdk/x/auth/types" ) @@ -10,7 +9,7 @@ import ( // // CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through // a genesis port script to the new fee collector account -func InitGenesis(ctx sdk.Context, ak keeper.AccountKeeper, data types.GenesisState) { +func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { ak.SetParams(ctx, data.Params) accounts, err := types.UnpackAccounts(data.Accounts) @@ -28,7 +27,7 @@ func InitGenesis(ctx sdk.Context, ak keeper.AccountKeeper, data types.GenesisSta } // ExportGenesis returns a GenesisState for a given context and keeper -func ExportGenesis(ctx sdk.Context, ak keeper.AccountKeeper) *types.GenesisState { +func (ak AccountKeeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { params := ak.GetParams(ctx) var genAccounts types.GenesisAccounts diff --git a/x/auth/keeper/grpc_query.go b/x/auth/keeper/grpc_query.go index a18de05d0730..8bd3a40e0aec 100644 --- a/x/auth/keeper/grpc_query.go +++ b/x/auth/keeper/grpc_query.go @@ -3,6 +3,7 @@ package keeper import ( "context" "errors" + "sort" "strings" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -38,7 +39,6 @@ func (ak AccountKeeper) Accounts(c context.Context, req *types.QueryAccountsRequ accounts = append(accounts, any) return nil }) - if err != nil { return nil, status.Errorf(codes.Internal, "paginate: %v", err) } @@ -58,7 +58,6 @@ func (ak AccountKeeper) Account(c context.Context, req *types.QueryAccountReques ctx := sdk.UnwrapSDKContext(c) addr, err := sdk.AccAddressFromBech32(req.Address) - if err != nil { return nil, err } @@ -94,9 +93,16 @@ func (ak AccountKeeper) ModuleAccounts(c context.Context, req *types.QueryModule ctx := sdk.UnwrapSDKContext(c) + // For deterministic output, sort the permAddrs by module name. + sortedPermAddrs := make([]string, 0, len(ak.permAddrs)) + for moduleName := range ak.permAddrs { + sortedPermAddrs = append(sortedPermAddrs, moduleName) + } + sort.Strings(sortedPermAddrs) + modAccounts := make([]*codectypes.Any, 0, len(ak.permAddrs)) - for moduleName := range ak.permAddrs { + for _, moduleName := range sortedPermAddrs { account := ak.GetModuleAccount(ctx, moduleName) if account == nil { return nil, status.Errorf(codes.NotFound, "account %s not found", moduleName) @@ -111,6 +117,7 @@ func (ak AccountKeeper) ModuleAccounts(c context.Context, req *types.QueryModule return &types.QueryModuleAccountsResponse{Accounts: modAccounts}, nil } +// Bech32Prefix returns the keeper internally stored bech32 prefix. func (ak AccountKeeper) Bech32Prefix(ctx context.Context, req *types.Bech32PrefixRequest) (*types.Bech32PrefixResponse, error) { bech32Prefix, err := ak.getBech32Prefix() if err != nil { @@ -120,6 +127,8 @@ func (ak AccountKeeper) Bech32Prefix(ctx context.Context, req *types.Bech32Prefi return &types.Bech32PrefixResponse{Bech32Prefix: bech32Prefix}, nil } +// AddressBytesToString converts an address from bytes to string, using the +// keeper's bech32 prefix. func (ak AccountKeeper) AddressBytesToString(ctx context.Context, req *types.AddressBytesToStringRequest) (*types.AddressBytesToStringResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") @@ -137,6 +146,8 @@ func (ak AccountKeeper) AddressBytesToString(ctx context.Context, req *types.Add return &types.AddressBytesToStringResponse{AddressString: text}, nil } +// AddressStringToBytes converts an address from string to bytes, using the +// keeper's bech32 prefix. func (ak AccountKeeper) AddressStringToBytes(ctx context.Context, req *types.AddressStringToBytesRequest) (*types.AddressStringToBytesResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") diff --git a/x/auth/keeper/grpc_query_test.go b/x/auth/keeper/grpc_query_test.go index 9052873d94ae..307fda03356f 100644 --- a/x/auth/keeper/grpc_query_test.go +++ b/x/auth/keeper/grpc_query_test.go @@ -1,9 +1,10 @@ package keeper_test import ( - "fmt" - "context" "bytes" + "context" + "fmt" + "sort" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,12 +12,11 @@ import ( ) const addrStr = "cosmos13c3d4wq2t22dl0dstraf8jc3f902e3fsy9n3wv" + var addrBytes = []byte{0x8e, 0x22, 0xda, 0xb8, 0xa, 0x5a, 0x94, 0xdf, 0xbd, 0xb0, 0x58, 0xfa, 0x93, 0xcb, 0x11, 0x49, 0x5e, 0xac, 0xc5, 0x30} func (suite *KeeperTestSuite) TestGRPCQueryAccounts() { - var ( - req *types.QueryAccountsRequest - ) + var req *types.QueryAccountsRequest _, _, first := testdata.KeyTestPubAddr() _, _, second := testdata.KeyTestPubAddr() @@ -72,9 +72,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryAccounts() { } func (suite *KeeperTestSuite) TestGRPCQueryAccount() { - var ( - req *types.QueryAccountRequest - ) + var req *types.QueryAccountRequest _, _, addr := testdata.KeyTestPubAddr() testCases := []struct { @@ -198,9 +196,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryParameters() { } func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { - var ( - req *types.QueryModuleAccountsRequest - ) + var req *types.QueryModuleAccountsRequest testCases := []struct { msg string @@ -215,7 +211,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { }, true, func(res *types.QueryModuleAccountsResponse) { - var mintModuleExists = false + mintModuleExists := false for _, acc := range res.Accounts { var account types.AccountI err := suite.app.InterfaceRegistry().UnpackAny(acc, &account) @@ -238,7 +234,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { }, true, func(res *types.QueryModuleAccountsResponse) { - var mintModuleExists = false + mintModuleExists := false for _, acc := range res.Accounts { var account types.AccountI err := suite.app.InterfaceRegistry().UnpackAny(acc, &account) @@ -268,6 +264,17 @@ func (suite *KeeperTestSuite) TestGRPCQueryModuleAccounts() { if tc.expPass { suite.Require().NoError(err) suite.Require().NotNil(res) + // Make sure output is sorted alphabetically. + var moduleNames []string + for _, any := range res.Accounts { + var account types.AccountI + err := suite.app.InterfaceRegistry().UnpackAny(any, &account) + suite.Require().NoError(err) + moduleAccount, ok := account.(types.ModuleAccountI) + suite.Require().True(ok) + moduleNames = append(moduleNames, moduleAccount.GetName()) + } + suite.Require().True(sort.StringsAreSorted(moduleNames)) } else { suite.Require().Error(err) suite.Require().Nil(res) @@ -289,9 +296,9 @@ func (suite *KeeperTestSuite) TestBech32Prefix() { func (suite *KeeperTestSuite) TestAddressBytesToString() { testCases := []struct { - msg string - req *types.AddressBytesToStringRequest - expPass bool + msg string + req *types.AddressBytesToStringRequest + expPass bool }{ { "success", @@ -324,16 +331,15 @@ func (suite *KeeperTestSuite) TestAddressBytesToString() { suite.Require().Error(err) suite.Require().Nil(res) } - }) } } func (suite *KeeperTestSuite) TestAddressStringToBytes() { testCases := []struct { - msg string - req *types.AddressStringToBytesRequest - expPass bool + msg string + req *types.AddressStringToBytesRequest + expPass bool }{ { "success", @@ -352,10 +358,9 @@ func (suite *KeeperTestSuite) TestAddressStringToBytes() { }, { "address prefix is incorrect", - &types.AddressStringToBytesRequest{AddressString: "regen13c3d4wq2t22dl0dstraf8jc3f902e3fsy9n3wv" }, + &types.AddressStringToBytesRequest{AddressString: "regen13c3d4wq2t22dl0dstraf8jc3f902e3fsy9n3wv"}, false, }, - } for _, tc := range testCases { @@ -372,7 +377,6 @@ func (suite *KeeperTestSuite) TestAddressStringToBytes() { suite.Require().Error(err) suite.Require().Nil(res) } - }) } } diff --git a/x/auth/keeper/keeper.go b/x/auth/keeper/keeper.go index 25592115a3e9..207f65b0f838 100644 --- a/x/auth/keeper/keeper.go +++ b/x/auth/keeper/keeper.go @@ -1,7 +1,6 @@ package keeper import ( - "errors" "fmt" gogotypes "github.com/gogo/protobuf/types" @@ -9,10 +8,9 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - - storetypes "github.com/cosmos/cosmos-sdk/store/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -76,7 +74,6 @@ func NewAccountKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, paramstore paramtypes.Subspace, proto func() types.AccountI, maccPerms map[string][]string, bech32Prefix string, ) AccountKeeper { - // set KeyTable if it has not already been set if !paramstore.HasKeyTable() { paramstore = paramstore.WithKeyTable(types.ParamKeyTable()) @@ -249,7 +246,7 @@ func (ak AccountKeeper) GetCodec() codec.BinaryCodec { return ak.cdc } func (ak AccountKeeper) getBech32Prefix() (string, error) { bech32Codec, ok := ak.addressCdc.(bech32Codec) if !ok { - return "", errors.New("unable cast addressCdc to bech32Codec") + return "", fmt.Errorf("unable cast addressCdc to bech32Codec; expected %T got %T", bech32Codec, ak.addressCdc) } return bech32Codec.bech32Prefix, nil diff --git a/x/auth/middleware/basic.go b/x/auth/middleware/basic.go deleted file mode 100644 index 429c9a39537f..000000000000 --- a/x/auth/middleware/basic.go +++ /dev/null @@ -1,359 +0,0 @@ -package middleware - -import ( - "context" - - "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/crypto/keys/multisig" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" - authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - abci "github.com/tendermint/tendermint/abci/types" -) - -type validateBasicTxHandler struct { - next tx.Handler -} - -// ValidateBasicMiddleware will call tx.ValidateBasic, msg.ValidateBasic(for each msg inside tx) -// and return any non-nil error. -// If ValidateBasic passes, middleware calls next middleware in chain. Note, -// validateBasicTxHandler will not get executed on ReCheckTx since it -// is not dependent on application state. -func ValidateBasicMiddleware(txh tx.Handler) tx.Handler { - return validateBasicTxHandler{ - next: txh, - } -} - -var _ tx.Handler = validateBasicTxHandler{} - -// validateBasicTxMsgs executes basic validator calls for messages. -func validateBasicTxMsgs(msgs []sdk.Msg) error { - if len(msgs) == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "must contain at least one message") - } - - for _, msg := range msgs { - err := msg.ValidateBasic() - if err != nil { - return err - } - } - - return nil -} - -// CheckTx implements tx.Handler.CheckTx. -func (txh validateBasicTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - // no need to validate basic on recheck tx, call next middleware - if checkReq.Type == abci.CheckTxType_Recheck { - return txh.next.CheckTx(ctx, req, checkReq) - } - - if err := validateBasicTxMsgs(req.Tx.GetMsgs()); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - if err := req.Tx.ValidateBasic(); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return txh.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (txh validateBasicTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := req.Tx.ValidateBasic(); err != nil { - return tx.Response{}, err - } - - if err := validateBasicTxMsgs(req.Tx.GetMsgs()); err != nil { - return tx.Response{}, err - } - - return txh.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx. -func (txh validateBasicTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := req.Tx.ValidateBasic(); err != nil { - return tx.Response{}, err - } - - if err := validateBasicTxMsgs(req.Tx.GetMsgs()); err != nil { - return tx.Response{}, err - } - - return txh.next.SimulateTx(ctx, req) -} - -var _ tx.Handler = txTimeoutHeightTxHandler{} - -type txTimeoutHeightTxHandler struct { - next tx.Handler -} - -// TxTimeoutHeightMiddleware defines a middleware that checks for a -// tx height timeout. -func TxTimeoutHeightMiddleware(txh tx.Handler) tx.Handler { - return txTimeoutHeightTxHandler{ - next: txh, - } -} - -func checkTimeout(ctx context.Context, tx sdk.Tx) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - timeoutTx, ok := tx.(sdk.TxWithTimeoutHeight) - if !ok { - return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "expected tx to implement TxWithTimeoutHeight") - } - - timeoutHeight := timeoutTx.GetTimeoutHeight() - if timeoutHeight > 0 && uint64(sdkCtx.BlockHeight()) > timeoutHeight { - return sdkerrors.Wrapf( - sdkerrors.ErrTxTimeoutHeight, "block height: %d, timeout height: %d", sdkCtx.BlockHeight(), timeoutHeight, - ) - } - - return nil -} - -// CheckTx implements tx.Handler.CheckTx. -func (txh txTimeoutHeightTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := checkTimeout(ctx, req.Tx); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return txh.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (txh txTimeoutHeightTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := checkTimeout(ctx, req.Tx); err != nil { - return tx.Response{}, err - } - - return txh.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx. -func (txh txTimeoutHeightTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := checkTimeout(ctx, req.Tx); err != nil { - return tx.Response{}, err - } - - return txh.next.SimulateTx(ctx, req) -} - -type validateMemoTxHandler struct { - ak AccountKeeper - next tx.Handler -} - -// ValidateMemoMiddleware will validate memo given the parameters passed in -// If memo is too large middleware returns with error, otherwise call next middleware -// CONTRACT: Tx must implement TxWithMemo interface -func ValidateMemoMiddleware(ak AccountKeeper) tx.Middleware { - return func(txHandler tx.Handler) tx.Handler { - return validateMemoTxHandler{ - ak: ak, - next: txHandler, - } - } -} - -var _ tx.Handler = validateMemoTxHandler{} - -func (vmm validateMemoTxHandler) checkForValidMemo(ctx context.Context, tx sdk.Tx) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - memoTx, ok := tx.(sdk.TxWithMemo) - if !ok { - return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid transaction type") - } - - params := vmm.ak.GetParams(sdkCtx) - - memoLength := len(memoTx.GetMemo()) - if uint64(memoLength) > params.MaxMemoCharacters { - return sdkerrors.Wrapf(sdkerrors.ErrMemoTooLarge, - "maximum number of characters is %d but received %d characters", - params.MaxMemoCharacters, memoLength, - ) - } - - return nil -} - -// CheckTx implements tx.Handler.CheckTx method. -func (vmm validateMemoTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := vmm.checkForValidMemo(ctx, req.Tx); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return vmm.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx method. -func (vmm validateMemoTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := vmm.checkForValidMemo(ctx, req.Tx); err != nil { - return tx.Response{}, err - } - - return vmm.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (vmm validateMemoTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := vmm.checkForValidMemo(ctx, req.Tx); err != nil { - return tx.Response{}, err - } - - return vmm.next.SimulateTx(ctx, req) -} - -var _ tx.Handler = consumeTxSizeGasTxHandler{} - -type consumeTxSizeGasTxHandler struct { - ak AccountKeeper - next tx.Handler -} - -// ConsumeTxSizeGasMiddleware will take in parameters and consume gas proportional -// to the size of tx before calling next middleware. Note, the gas costs will be -// slightly over estimated due to the fact that any given signing account may need -// to be retrieved from state. -// -// CONTRACT: If simulate=true, then signatures must either be completely filled -// in or empty. -// CONTRACT: To use this middleware, signatures of transaction must be represented -// as legacytx.StdSignature otherwise simulate mode will incorrectly estimate gas cost. -func ConsumeTxSizeGasMiddleware(ak AccountKeeper) tx.Middleware { - return func(txHandler tx.Handler) tx.Handler { - return consumeTxSizeGasTxHandler{ - ak: ak, - next: txHandler, - } - } -} - -func (cgts consumeTxSizeGasTxHandler) simulateSigGasCost(ctx context.Context, tx sdk.Tx) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - params := cgts.ak.GetParams(sdkCtx) - - sigTx, ok := tx.(authsigning.SigVerifiableTx) - if !ok { - return sdkerrors.Wrap(sdkerrors.ErrTxDecode, "invalid tx type") - } - - // in simulate mode, each element should be a nil signature - sigs, err := sigTx.GetSignaturesV2() - if err != nil { - return err - } - n := len(sigs) - - for i, signer := range sigTx.GetSigners() { - // if signature is already filled in, no need to simulate gas cost - if i < n && !isIncompleteSignature(sigs[i].Data) { - continue - } - - var pubkey cryptotypes.PubKey - - acc := cgts.ak.GetAccount(sdkCtx, signer) - - // use placeholder simSecp256k1Pubkey if sig is nil - if acc == nil || acc.GetPubKey() == nil { - pubkey = simSecp256k1Pubkey - } else { - pubkey = acc.GetPubKey() - } - - // use stdsignature to mock the size of a full signature - simSig := legacytx.StdSignature{ //nolint:staticcheck // this will be removed when proto is ready - Signature: simSecp256k1Sig[:], - PubKey: pubkey, - } - - sigBz := legacy.Cdc.MustMarshal(simSig) - cost := sdk.Gas(len(sigBz) + 6) - - // If the pubkey is a multi-signature pubkey, then we estimate for the maximum - // number of signers. - if _, ok := pubkey.(*multisig.LegacyAminoPubKey); ok { - cost *= params.TxSigLimit - } - - sdkCtx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*cost, "txSize") - } - - return nil -} - -//nolint:unparam -func (cgts consumeTxSizeGasTxHandler) consumeTxSizeGas(ctx context.Context, _ sdk.Tx, txBytes []byte) error { - sdkCtx := sdk.UnwrapSDKContext(ctx) - params := cgts.ak.GetParams(sdkCtx) - sdkCtx.GasMeter().ConsumeGas(params.TxSizeCostPerByte*sdk.Gas(len(txBytes)), "txSize") - - return nil -} - -// CheckTx implements tx.Handler.CheckTx. -func (cgts consumeTxSizeGasTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := cgts.consumeTxSizeGas(ctx, req.Tx, req.TxBytes); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return cgts.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (cgts consumeTxSizeGasTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := cgts.consumeTxSizeGas(ctx, req.Tx, req.TxBytes); err != nil { - return tx.Response{}, err - } - - return cgts.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx. -func (cgts consumeTxSizeGasTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := cgts.consumeTxSizeGas(ctx, req.Tx, req.TxBytes); err != nil { - return tx.Response{}, err - } - - if err := cgts.simulateSigGasCost(ctx, req.Tx); err != nil { - return tx.Response{}, err - } - - return cgts.next.SimulateTx(ctx, req) -} - -// isIncompleteSignature tests whether SignatureData is fully filled in for simulation purposes -func isIncompleteSignature(data signing.SignatureData) bool { - if data == nil { - return true - } - - switch data := data.(type) { - case *signing.SingleSignatureData: - return len(data.Signature) == 0 - case *signing.MultiSignatureData: - if len(data.Signatures) == 0 { - return true - } - for _, s := range data.Signatures { - if isIncompleteSignature(s) { - return true - } - } - } - - return false -} diff --git a/x/auth/middleware/basic_test.go b/x/auth/middleware/basic_test.go deleted file mode 100644 index 1c44e292eb93..000000000000 --- a/x/auth/middleware/basic_test.go +++ /dev/null @@ -1,221 +0,0 @@ -package middleware_test - -import ( - "strings" - - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/crypto/types/multisig" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" -) - -func (s *MWTestSuite) TestValidateBasic() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.ValidateBasicMiddleware) - - // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - - // msg and signatures - msg := testdata.NewTestMsg(addr1) - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - s.Require().NoError(txBuilder.SetMsgs(msg)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - - privs, accNums, accSeqs := []cryptotypes.PrivKey{}, []uint64{}, []uint64{} - invalidTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: invalidTx}) - s.Require().NotNil(err, "Did not error on invalid tx") - - privs, accNums, accSeqs = []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - validTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: validTx}) - s.Require().Nil(err, "ValidateBasicMiddleware returned error on valid tx. err: %v", err) - - // test middleware skips on recheck - ctx = ctx.WithIsReCheckTx(true) - - // middleware should skip processing invalidTx on recheck and thus return nil-error - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: invalidTx}) - s.Require().Nil(err, "ValidateBasicMiddleware ran on ReCheck") -} - -func (s *MWTestSuite) TestValidateMemo() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.ValidateMemoMiddleware(s.app.AccountKeeper)) - - // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - - // msg and signatures - msg := testdata.NewTestMsg(addr1) - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - s.Require().NoError(txBuilder.SetMsgs(msg)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - txBuilder.SetMemo(strings.Repeat("01234567890", 500)) - invalidTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - // require that long memos get rejected - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: invalidTx}) - - s.Require().NotNil(err, "Did not error on tx with high memo") - - txBuilder.SetMemo(strings.Repeat("01234567890", 10)) - validTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - // require small memos pass ValidateMemo middleware - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: validTx}) - s.Require().Nil(err, "ValidateBasicMiddleware returned error on valid tx. err: %v", err) -} - -func (s *MWTestSuite) TestConsumeGasForTxSize() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.ConsumeTxSizeGasMiddleware(s.app.AccountKeeper)) - - // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - - // msg and signatures - msg := testdata.NewTestMsg(addr1) - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - - testCases := []struct { - name string - sigV2 signing.SignatureV2 - }{ - {"SingleSignatureData", signing.SignatureV2{PubKey: priv1.PubKey()}}, - {"MultiSignatureData", signing.SignatureV2{PubKey: priv1.PubKey(), Data: multisig.NewMultisig(2)}}, - } - - for _, tc := range testCases { - s.Run(tc.name, func() { - txBuilder = s.clientCtx.TxConfig.NewTxBuilder() - s.Require().NoError(txBuilder.SetMsgs(msg)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - txBuilder.SetMemo(strings.Repeat("01234567890", 10)) - - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - txBytes, err := s.clientCtx.TxConfig.TxJSONEncoder()(testTx) - s.Require().Nil(err, "Cannot marshal tx: %v", err) - - params := s.app.AccountKeeper.GetParams(ctx) - expectedGas := sdk.Gas(len(txBytes)) * params.TxSizeCostPerByte - - // Set ctx with TxBytes manually - ctx = ctx.WithTxBytes(txBytes) - - // track how much gas is necessary to retrieve parameters - beforeGas := ctx.GasMeter().GasConsumed() - s.app.AccountKeeper.GetParams(ctx) - afterGas := ctx.GasMeter().GasConsumed() - expectedGas += afterGas - beforeGas - - beforeGas = ctx.GasMeter().GasConsumed() - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx, TxBytes: txBytes}) - - s.Require().Nil(err, "ConsumeTxSizeGasMiddleware returned error: %v", err) - - // require that middleware consumes expected amount of gas - consumedGas := ctx.GasMeter().GasConsumed() - beforeGas - s.Require().Equal(expectedGas, consumedGas, "Middleware did not consume the correct amount of gas") - - // simulation must not underestimate gas of this middleware even with nil signatures - txBuilder, err := s.clientCtx.TxConfig.WrapTxBuilder(testTx) - s.Require().NoError(err) - s.Require().NoError(txBuilder.SetSignatures(tc.sigV2)) - testTx = txBuilder.GetTx() - - simTxBytes, err := s.clientCtx.TxConfig.TxJSONEncoder()(testTx) - s.Require().Nil(err, "Cannot marshal tx: %v", err) - // require that simulated tx is smaller than tx with signatures - s.Require().True(len(simTxBytes) < len(txBytes), "simulated tx still has signatures") - - // Set s.ctx with smaller simulated TxBytes manually - ctx = ctx.WithTxBytes(simTxBytes) - - beforeSimGas := ctx.GasMeter().GasConsumed() - - // run txhandler in simulate mode - _, err = txHandler.SimulateTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx, TxBytes: simTxBytes}) - consumedSimGas := ctx.GasMeter().GasConsumed() - beforeSimGas - - // require that txhandler passes and does not underestimate middleware cost - s.Require().Nil(err, "ConsumeTxSizeGasMiddleware returned error: %v", err) - s.Require().True(consumedSimGas >= expectedGas, "Simulate mode underestimates gas on Middleware. Simulated cost: %d, expected cost: %d", consumedSimGas, expectedGas) - }) - } -} - -func (s *MWTestSuite) TestTxHeightTimeoutMiddleware() { - ctx := s.SetupTest(true) - - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.TxTimeoutHeightMiddleware) - - // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - - // msg and signatures - msg := testdata.NewTestMsg(addr1) - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - - testCases := []struct { - name string - timeout uint64 - height int64 - expectErr bool - }{ - {"default value", 0, 10, false}, - {"no timeout (greater height)", 15, 10, false}, - {"no timeout (same height)", 10, 10, false}, - {"timeout (smaller height)", 9, 10, true}, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - - s.Require().NoError(txBuilder.SetMsgs(msg)) - - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - txBuilder.SetMemo(strings.Repeat("01234567890", 10)) - txBuilder.SetTimeoutHeight(tc.timeout) - - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - ctx := ctx.WithBlockHeight(tc.height) - _, err = txHandler.SimulateTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) - s.Require().Equal(tc.expectErr, err != nil, err) - }) - } -} diff --git a/x/auth/middleware/block_gas.go b/x/auth/middleware/block_gas.go deleted file mode 100644 index bfd67f92ecbe..000000000000 --- a/x/auth/middleware/block_gas.go +++ /dev/null @@ -1,53 +0,0 @@ -package middleware - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" -) - -type consumeBlockGasHandler struct { - next tx.Handler -} - -// ConsumeBlockGasMiddleware check and consume block gas meter. -func ConsumeBlockGasMiddleware(txh tx.Handler) tx.Handler { - return consumeBlockGasHandler{next: txh} -} - -var _ tx.Handler = consumeBlockGasHandler{} - -// CheckTx implements tx.Handler.CheckTx method. -func (cbgh consumeBlockGasHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (res tx.Response, resCheckTx tx.ResponseCheckTx, err error) { - return cbgh.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx method. -// Consume block gas meter, panic when block gas meter exceeded, -// the panic should be caught by `RecoveryTxMiddleware`. -func (cbgh consumeBlockGasHandler) DeliverTx(ctx context.Context, req tx.Request) (res tx.Response, err error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - // only run the tx if there is block gas remaining - if sdkCtx.BlockGasMeter().IsOutOfGas() { - err = sdkerrors.Wrap(sdkerrors.ErrOutOfGas, "no block gas left to run tx") - return - } - - // If BlockGasMeter() panics it will be caught by the `RecoveryTxMiddleware` and will - // return an error - in any case BlockGasMeter will consume gas past the limit. - defer func() { - sdkCtx.BlockGasMeter().ConsumeGas( - sdkCtx.GasMeter().GasConsumedToLimit(), "block gas meter", - ) - - }() - - return cbgh.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (cbgh consumeBlockGasHandler) SimulateTx(ctx context.Context, req tx.Request) (res tx.Response, err error) { - return cbgh.next.SimulateTx(ctx, req) -} diff --git a/x/auth/middleware/branch_store.go b/x/auth/middleware/branch_store.go deleted file mode 100644 index 6269dfbcc995..000000000000 --- a/x/auth/middleware/branch_store.go +++ /dev/null @@ -1,70 +0,0 @@ -package middleware - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - tmtypes "github.com/tendermint/tendermint/types" -) - -type branchStoreHandler struct { - next tx.Handler -} - -// WithBranchedStore creates a new MultiStore branch and commits the store if the downstream -// returned no error. It cancels writes from the failed transactions. -func WithBranchedStore(txh tx.Handler) tx.Handler { - return branchStoreHandler{next: txh} -} - -// CheckTx implements tx.Handler.CheckTx method. -// Do nothing during CheckTx. -func (sh branchStoreHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - return sh.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx method. -func (sh branchStoreHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return branchAndRun(ctx, req, sh.next.DeliverTx) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (sh branchStoreHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return branchAndRun(ctx, req, sh.next.SimulateTx) -} - -type nextFn func(ctx context.Context, req tx.Request) (tx.Response, error) - -// branchAndRun creates a new Context based on the existing Context with a MultiStore branch -// in case message processing fails. -func branchAndRun(ctx context.Context, req tx.Request, fn nextFn) (tx.Response, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - runMsgCtx, branchedStore := branchStore(sdkCtx, tmtypes.Tx(req.TxBytes)) - - rsp, err := fn(sdk.WrapSDKContext(runMsgCtx), req) - if err == nil { - // commit storage iff no error - branchedStore.Write() - } - - return rsp, err -} - -// branchStore returns a new context based off of the provided context with -// a branched multi-store. -func branchStore(sdkCtx sdk.Context, tx tmtypes.Tx) (sdk.Context, sdk.CacheMultiStore) { - ms := sdkCtx.MultiStore() - msCache := ms.CacheWrap() - if msCache.TracingEnabled() { - msCache.SetTracingContext( - sdk.TraceContext( - map[string]interface{}{ - "txHash": tx.Hash(), - }, - ), - ) - } - - return sdkCtx.WithMultiStore(msCache), msCache -} diff --git a/x/auth/middleware/branch_store_test.go b/x/auth/middleware/branch_store_test.go deleted file mode 100644 index 80e116fb2a82..000000000000 --- a/x/auth/middleware/branch_store_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package middleware_test - -import ( - "context" - "fmt" - "math" - - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -var blockMaxGas = uint64(simapp.DefaultConsensusParams.Block.MaxGas) - -func (s *MWTestSuite) TestBranchStore() { - testcases := []struct { - name string - gasToConsume uint64 // gas to consume in the msg execution - panicTx bool // panic explicitly in tx execution - expErr bool - }{ - {"less than block gas meter", 10, false, false}, - {"more than block gas meter", blockMaxGas, false, true}, - {"more than block gas meter", uint64(float64(blockMaxGas) * 1.2), false, true}, - {"consume MaxUint64", math.MaxUint64, false, true}, - {"consume block gas when paniced", 10, true, true}, - } - - for _, tc := range testcases { - s.Run(tc.name, func() { - ctx := s.SetupTest(true).WithBlockGasMeter(sdk.NewGasMeter(blockMaxGas)) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - - // tx fee - feeCoin := sdk.NewCoin("atom", sdk.NewInt(150)) - feeAmount := sdk.NewCoins(feeCoin) - - // test account and fund - priv1, _, addr1 := testdata.KeyTestPubAddr() - err := s.app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, feeAmount) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr1, feeAmount) - s.Require().NoError(err) - s.Require().Equal(feeCoin.Amount, s.app.BankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount) - seq, _ := s.app.AccountKeeper.GetSequence(ctx, addr1) - s.Require().Equal(uint64(0), seq) - - // testMsgTxHandler is a test txHandler that handles one single TestMsg, - // consumes the given `tc.gasToConsume`, and sets the bank store "ok" key to "ok". - var testMsgTxHandler = customTxHandler{func(ctx context.Context, req tx.Request) (tx.Response, error) { - msg, ok := req.Tx.GetMsgs()[0].(*testdata.TestMsg) - if !ok { - return tx.Response{}, fmt.Errorf("Wrong Msg type, expected %T, got %T", (*testdata.TestMsg)(nil), msg) - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - sdkCtx.KVStore(s.app.GetKey("bank")).Set([]byte("ok"), []byte("ok")) - sdkCtx.GasMeter().ConsumeGas(tc.gasToConsume, "TestMsg") - if tc.panicTx { - panic("panic in tx execution") - } - return tx.Response{}, nil - }} - - txHandler := middleware.ComposeMiddlewares( - testMsgTxHandler, - middleware.NewTxDecoderMiddleware(s.clientCtx.TxConfig.TxDecoder()), - middleware.GasTxMiddleware, - middleware.RecoveryTxMiddleware, - middleware.DeductFeeMiddleware(s.app.AccountKeeper, s.app.BankKeeper, s.app.FeeGrantKeeper, nil), - middleware.IncrementSequenceMiddleware(s.app.AccountKeeper), - middleware.WithBranchedStore, - middleware.ConsumeBlockGasMiddleware, - ) - - // msg and signatures - msg := testdata.NewTestMsg(addr1) - var gasLimit uint64 = math.MaxUint64 // no limit on sdk.GasMeter - s.Require().NoError(txBuilder.SetMsgs(msg)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) - - bankStore := ctx.KVStore(s.app.GetKey("bank")) - okValue := bankStore.Get([]byte("ok")) - - if tc.expErr { - s.Require().Error(err) - if tc.panicTx { - s.Require().True(sdkerrors.IsOf(err, sdkerrors.ErrPanic)) - } else { - s.Require().True(sdkerrors.IsOf(err, sdkerrors.ErrOutOfGas)) - } - s.Require().Empty(okValue) - } else { - s.Require().NoError(err) - s.Require().Equal([]byte("ok"), okValue) - } - // block gas is always consumed - baseGas := uint64(24564) // baseGas is the gas consumed by middlewares - expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas) - s.Require().Equal(expGasConsumed, ctx.BlockGasMeter().GasConsumed()) - // tx fee is always deducted - s.Require().Equal(int64(0), s.app.BankKeeper.GetBalance(ctx, addr1, feeCoin.Denom).Amount.Int64()) - // sender's sequence is always increased - seq, err = s.app.AccountKeeper.GetSequence(ctx, addr1) - s.Require().NoError(err) - s.Require().Equal(uint64(1), seq) - }) - } -} - -func addUint64Saturating(a, b uint64) uint64 { - if math.MaxUint64-a < b { - return math.MaxUint64 - } - - return a + b -} diff --git a/x/auth/middleware/ext.go b/x/auth/middleware/ext.go deleted file mode 100644 index 5159e3c5f1f8..000000000000 --- a/x/auth/middleware/ext.go +++ /dev/null @@ -1,86 +0,0 @@ -package middleware - -import ( - "context" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" -) - -type HasExtensionOptionsTx interface { - GetExtensionOptions() []*codectypes.Any - GetNonCriticalExtensionOptions() []*codectypes.Any -} - -// ExtensionOptionChecker is a function that returns true if the extension option is accepted. -type ExtensionOptionChecker func(*codectypes.Any) bool - -// rejectExtensionOption is the default extension check that reject all tx -// extensions. -func rejectExtensionOption(*codectypes.Any) bool { - return false -} - -type rejectExtensionOptionsTxHandler struct { - next tx.Handler - checker ExtensionOptionChecker -} - -// NewExtensionOptionsMiddleware creates a new middleware that rejects all extension -// options which can optionally be included in protobuf transactions that don't pass the checker. -// Users that need extension options should pass a custom checker that returns true for the -// needed extension options. -func NewExtensionOptionsMiddleware(checker ExtensionOptionChecker) tx.Middleware { - if checker == nil { - checker = rejectExtensionOption - } - return func(txh tx.Handler) tx.Handler { - return rejectExtensionOptionsTxHandler{ - next: txh, - checker: checker, - } - } -} - -var _ tx.Handler = rejectExtensionOptionsTxHandler{} - -func checkExtOpts(tx sdk.Tx, checker ExtensionOptionChecker) error { - if hasExtOptsTx, ok := tx.(HasExtensionOptionsTx); ok { - for _, opt := range hasExtOptsTx.GetExtensionOptions() { - if !checker(opt) { - return sdkerrors.ErrUnknownExtensionOptions - } - } - } - - return nil -} - -// CheckTx implements tx.Handler.CheckTx. -func (txh rejectExtensionOptionsTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - if err := checkExtOpts(req.Tx, txh.checker); err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return txh.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (txh rejectExtensionOptionsTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := checkExtOpts(req.Tx, txh.checker); err != nil { - return tx.Response{}, err - } - - return txh.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (txh rejectExtensionOptionsTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - if err := checkExtOpts(req.Tx, txh.checker); err != nil { - return tx.Response{}, err - } - - return txh.next.SimulateTx(ctx, req) -} diff --git a/x/auth/middleware/ext_test.go b/x/auth/middleware/ext_test.go deleted file mode 100644 index 27c294794cfb..000000000000 --- a/x/auth/middleware/ext_test.go +++ /dev/null @@ -1,54 +0,0 @@ -package middleware_test - -import ( - "github.com/cosmos/cosmos-sdk/codec/types" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - typestx "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" - "github.com/cosmos/cosmos-sdk/x/auth/tx" -) - -func (s *MWTestSuite) TestExtensionOptionsMiddleware() { - testCases := []struct { - msg string - allow bool - }{ - {"allow extension", true}, - {"reject extension", false}, - } - for _, tc := range testCases { - s.Run(tc.msg, func() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.NewExtensionOptionsMiddleware(func(_ *codectypes.Any) bool { - return tc.allow - })) - - // no extension options should not trigger an error - theTx := txBuilder.GetTx() - _, _, err := txHandler.CheckTx(sdk.WrapSDKContext(ctx), typestx.Request{Tx: theTx}, typestx.RequestCheckTx{}) - s.Require().NoError(err) - - extOptsTxBldr, ok := txBuilder.(tx.ExtensionOptionsTxBuilder) - if !ok { - // if we can't set extension options, this middleware doesn't apply and we're done - return - } - - // set an extension option and check - any, err := types.NewAnyWithValue(testdata.NewTestMsg()) - s.Require().NoError(err) - extOptsTxBldr.SetExtensionOptions(any) - theTx = txBuilder.GetTx() - _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), typestx.Request{Tx: theTx}, typestx.RequestCheckTx{}) - if tc.allow { - s.Require().NoError(err) - } else { - s.Require().EqualError(err, "unknown extension options") - } - }) - } -} diff --git a/x/auth/middleware/fee_test.go b/x/auth/middleware/fee_test.go deleted file mode 100644 index 7c1f54463fff..000000000000 --- a/x/auth/middleware/fee_test.go +++ /dev/null @@ -1,114 +0,0 @@ -package middleware_test - -import ( - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" -) - -func (s *MWTestSuite) TestEnsureMempoolFees() { - ctx := s.SetupTest(true) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.DeductFeeMiddleware( - s.app.AccountKeeper, - s.app.BankKeeper, - s.app.FeeGrantKeeper, - nil, - )) - - // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - - // msg and signatures - msg := testdata.NewTestMsg(addr1) - atomCoin := sdk.NewCoin("atom", sdk.NewInt(150)) - apeCoin := sdk.NewInt64Coin("ape", 1500000) - feeAmount := sdk.NewCoins(apeCoin, atomCoin) - gasLimit := testdata.NewTestGasLimit() - s.Require().NoError(txBuilder.SetMsgs(msg)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - // Set high gas price so standard test fee fails - atomPrice := sdk.NewDecCoinFromDec("atom", sdk.NewDec(200).Quo(sdk.NewDec(100000))) - highGasPrice := []sdk.DecCoin{atomPrice} - ctx = ctx.WithMinGasPrices(highGasPrice) - - // txHandler errors with insufficient fees - _, _, err = txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) - s.Require().NotNil(err, "Middleware should have errored on too low fee for local gasPrice") - - // txHandler should fail since we also check minGasPrice in DeliverTx - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) - s.Require().Error(err, "MempoolFeeMiddleware don't error in DeliverTx") - - atomPrice = sdk.NewDecCoinFromDec("atom", sdk.NewDec(0).Quo(sdk.NewDec(100000))) - lowGasPrice := []sdk.DecCoin{atomPrice} - ctx = ctx.WithMinGasPrices(lowGasPrice) - - // Set account with sufficient funds - acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr1) - s.app.AccountKeeper.SetAccount(ctx, acc) - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, feeAmount) - s.Require().NoError(err) - - _, checkTxRes, err := txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}, tx.RequestCheckTx{}) - s.Require().Nil(err, "Middleware should not have errored on fee higher than local gasPrice") - s.Require().Equal(atomCoin.Amount.Int64(), checkTxRes.Priority, "priority should be atom amount") -} - -func (s *MWTestSuite) TestDeductFees() { - ctx := s.SetupTest(false) // setup - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - txHandler := middleware.ComposeMiddlewares( - noopTxHandler, - middleware.DeductFeeMiddleware( - s.app.AccountKeeper, - s.app.BankKeeper, - s.app.FeeGrantKeeper, - nil, - ), - ) - - // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - - // msg and signatures - msg := testdata.NewTestMsg(addr1) - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - s.Require().NoError(txBuilder.SetMsgs(msg)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - // Set account with insufficient funds - acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr1) - s.app.AccountKeeper.SetAccount(ctx, acc) - coins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(10))) - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, coins) - s.Require().NoError(err) - - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) - s.Require().NotNil(err, "Tx did not error when fee payer had insufficient funds") - - // Set account with sufficient funds - s.app.AccountKeeper.SetAccount(ctx, acc) - err = testutil.FundAccount(s.app.BankKeeper, ctx, addr1, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(200)))) - s.Require().NoError(err) - - _, err = txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx}) - - s.Require().Nil(err, "Tx errored after account has been set with sufficient funds") -} diff --git a/x/auth/middleware/gas.go b/x/auth/middleware/gas.go deleted file mode 100644 index ee31fc1bff89..000000000000 --- a/x/auth/middleware/gas.go +++ /dev/null @@ -1,97 +0,0 @@ -package middleware - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" -) - -// GasTx defines a Tx with a GetGas() method which is needed to use gasTxHandler. -type GasTx interface { - sdk.Tx - GetGas() uint64 -} - -type gasTxHandler struct { - next tx.Handler -} - -// GasTxMiddleware defines a simple middleware that sets a new GasMeter on -// the sdk.Context, and sets the GasInfo on the result. It reads the tx.GetGas() -// by default, or sets to infinity in simulate mode. -func GasTxMiddleware(txh tx.Handler) tx.Handler { - return gasTxHandler{next: txh} -} - -var _ tx.Handler = gasTxHandler{} - -// CheckTx implements tx.Handler.CheckTx. -func (txh gasTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - sdkCtx, err := gasContext(sdk.UnwrapSDKContext(ctx), req.Tx, false) - if err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - res, resCheckTx, err := txh.next.CheckTx(sdk.WrapSDKContext(sdkCtx), req, checkReq) - - return populateGas(res, sdkCtx), resCheckTx, err -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (txh gasTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - sdkCtx, err := gasContext(sdk.UnwrapSDKContext(ctx), req.Tx, false) - if err != nil { - return tx.Response{}, err - } - - res, err := txh.next.DeliverTx(sdk.WrapSDKContext(sdkCtx), req) - - return populateGas(res, sdkCtx), err -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (txh gasTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - sdkCtx, err := gasContext(sdk.UnwrapSDKContext(ctx), req.Tx, true) - if err != nil { - return tx.Response{}, err - } - - res, err := txh.next.SimulateTx(sdk.WrapSDKContext(sdkCtx), req) - - return populateGas(res, sdkCtx), err -} - -// populateGas returns a new tx.Response with gas fields populated. -func populateGas(res tx.Response, sdkCtx sdk.Context) tx.Response { - res.GasWanted = sdkCtx.GasMeter().Limit() - res.GasUsed = sdkCtx.GasMeter().GasConsumed() - - return res -} - -// gasContext returns a new context with a gas meter set from a given context. -func gasContext(ctx sdk.Context, tx sdk.Tx, isSimulate bool) (sdk.Context, error) { - // all transactions must implement GasTx - gasTx, ok := tx.(GasTx) - if !ok { - // Set a gas meter with limit 0 as to prevent an infinite gas meter attack - // during runTx. - newCtx := setGasMeter(ctx, 0, isSimulate) - return newCtx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be GasTx") - } - - return setGasMeter(ctx, gasTx.GetGas(), isSimulate), nil -} - -// setGasMeter returns a new context with a gas meter set from a given context. -func setGasMeter(ctx sdk.Context, gasLimit uint64, simulate bool) sdk.Context { - // In various cases such as simulation and during the genesis block, we do not - // meter any gas utilization. - if simulate || ctx.BlockHeight() == 0 { - return ctx.WithGasMeter(sdk.NewInfiniteGasMeter()) - } - - return ctx.WithGasMeter(sdk.NewGasMeter(gasLimit)) -} diff --git a/x/auth/middleware/gas_test.go b/x/auth/middleware/gas_test.go deleted file mode 100644 index 78685fa6c766..000000000000 --- a/x/auth/middleware/gas_test.go +++ /dev/null @@ -1,124 +0,0 @@ -package middleware_test - -import ( - "context" - "errors" - - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" - "github.com/cosmos/cosmos-sdk/x/auth/signing" -) - -// txTest is a dummy tx that doesn't implement GasTx. It should set the GasMeter -// to 0 in this case. -type txTest struct{} - -var _ sdk.Tx = txTest{} - -func (t txTest) GetMsgs() []sdk.Msg { return []sdk.Msg{} } -func (t txTest) ValidateBasic() error { return nil } - -func (s *MWTestSuite) setupGasTx() (signing.Tx, []byte, sdk.Context, uint64) { - ctx := s.SetupTest(true) - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - - // keys and addresses - priv1, _, addr1 := testdata.KeyTestPubAddr() - - // msg and signatures - msg := testdata.NewTestMsg(addr1) - feeAmount := testdata.NewTestFeeAmount() - gasLimit := testdata.NewTestGasLimit() - s.Require().NoError(txBuilder.SetMsgs(msg)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - - // test tx - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv1}, []uint64{0}, []uint64{0} - tx, txBytes, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - - // Set height to non-zero value for GasMeter to be set - ctx = ctx.WithBlockHeight(1) - - return tx, txBytes, ctx, gasLimit -} - -func (s *MWTestSuite) TestSetup() { - testTx, _, ctx, gasLimit := s.setupGasTx() - txHandler := middleware.ComposeMiddlewares(noopTxHandler, middleware.GasTxMiddleware) - - testcases := []struct { - name string - tx sdk.Tx - expGasLimit uint64 - expErr bool - errorStr string - }{ - {"not a gas tx", txTest{}, 0, true, "Tx must be GasTx: tx parse error"}, - {"tx with its own gas limit", testTx, gasLimit, false, ""}, - } - for _, tc := range testcases { - s.Run(tc.name, func() { - res, _, err := txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: tc.tx}, tx.RequestCheckTx{}) - if tc.expErr { - s.Require().EqualError(err, tc.errorStr) - } else { - s.Require().Nil(err, "SetUpContextMiddleware returned error") - s.Require().Equal(tc.expGasLimit, uint64(res.GasWanted)) - } - }) - } -} - -func (s *MWTestSuite) TestRecoverPanic() { - testTx, txBytes, ctx, gasLimit := s.setupGasTx() - txHandler := middleware.ComposeMiddlewares(outOfGasTxHandler, middleware.GasTxMiddleware, middleware.RecoveryTxMiddleware) - res, _, err := txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx, TxBytes: txBytes}, tx.RequestCheckTx{}) - s.Require().Error(err, "Did not return error on OutOfGas panic") - s.Require().True(errors.Is(sdkerrors.ErrOutOfGas, err), "Returned error is not an out of gas error") - s.Require().Equal(gasLimit, uint64(res.GasWanted)) - - txHandler = middleware.ComposeMiddlewares(outOfGasTxHandler, middleware.GasTxMiddleware) - s.Require().Panics(func() { - txHandler.CheckTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx, TxBytes: txBytes}, tx.RequestCheckTx{}) - }, "Recovered from non-Out-of-Gas panic") -} - -// customTxHandler is a test middleware that will run a custom function. -type customTxHandler struct { - fn func(context.Context, tx.Request) (tx.Response, error) -} - -var _ tx.Handler = customTxHandler{} - -func (h customTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return h.fn(ctx, req) -} -func (h customTxHandler) CheckTx(ctx context.Context, req tx.Request, _ tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - res, err := h.fn(ctx, req) - return res, tx.ResponseCheckTx{}, err -} -func (h customTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return h.fn(ctx, req) -} - -// noopTxHandler is a test middleware that returns an empty response. -var noopTxHandler = customTxHandler{func(_ context.Context, _ tx.Request) (tx.Response, error) { - return tx.Response{}, nil -}} - -// outOfGasTxHandler is a test middleware that panics with an outOfGas error. -var outOfGasTxHandler = customTxHandler{func(ctx context.Context, _ tx.Request) (tx.Response, error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - overLimit := sdkCtx.GasMeter().Limit() + 1 - - // Should panic with outofgas error - sdkCtx.GasMeter().ConsumeGas(overLimit, "test panic") - - panic("not reached") -}} diff --git a/x/auth/middleware/index_events.go b/x/auth/middleware/index_events.go deleted file mode 100644 index 2dd831417c2e..000000000000 --- a/x/auth/middleware/index_events.go +++ /dev/null @@ -1,61 +0,0 @@ -package middleware - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" -) - -type indexEventsTxHandler struct { - // indexEvents defines the set of events in the form {eventType}.{attributeKey}, - // which informs Tendermint what to index. If empty, all events will be indexed. - indexEvents map[string]struct{} - next tx.Handler -} - -// NewIndexEventsTxMiddleware defines a middleware to optionally only index a -// subset of the emitted events inside the Tendermint events indexer. -func NewIndexEventsTxMiddleware(indexEvents map[string]struct{}) tx.Middleware { - return func(txHandler tx.Handler) tx.Handler { - return indexEventsTxHandler{ - indexEvents: indexEvents, - next: txHandler, - } - } -} - -var _ tx.Handler = indexEventsTxHandler{} - -// CheckTx implements tx.Handler.CheckTx method. -func (txh indexEventsTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - res, resCheckTx, err := txh.next.CheckTx(ctx, req, checkReq) - if err != nil { - return res, tx.ResponseCheckTx{}, err - } - - res.Events = sdk.MarkEventsToIndex(res.Events, txh.indexEvents) - return res, resCheckTx, nil -} - -// DeliverTx implements tx.Handler.DeliverTx method. -func (txh indexEventsTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - res, err := txh.next.DeliverTx(ctx, req) - if err != nil { - return res, err - } - - res.Events = sdk.MarkEventsToIndex(res.Events, txh.indexEvents) - return res, nil -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (txh indexEventsTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - res, err := txh.next.SimulateTx(ctx, req) - if err != nil { - return res, err - } - - res.Events = sdk.MarkEventsToIndex(res.Events, txh.indexEvents) - return res, nil -} diff --git a/x/auth/middleware/middleware.go b/x/auth/middleware/middleware.go deleted file mode 100644 index 812bd96038a3..000000000000 --- a/x/auth/middleware/middleware.go +++ /dev/null @@ -1,115 +0,0 @@ -package middleware - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - "github.com/cosmos/cosmos-sdk/x/auth/types" -) - -// ComposeMiddlewares compose multiple middlewares on top of a tx.Handler. The -// middleware order in the variadic arguments is from outer to inner. -// -// Example: Given a base tx.Handler H, and two middlewares A and B, the -// middleware stack: -// ``` -// A.pre -// B.pre -// H -// B.post -// A.post -// ``` -// is created by calling `ComposeMiddlewares(H, A, B)`. -func ComposeMiddlewares(txHandler tx.Handler, middlewares ...tx.Middleware) tx.Handler { - for i := len(middlewares) - 1; i >= 0; i-- { - txHandler = middlewares[i](txHandler) - } - - return txHandler -} - -type TxHandlerOptions struct { - Debug bool - - // TxDecoder is used to decode the raw tx bytes into a sdk.Tx. - TxDecoder sdk.TxDecoder - - // IndexEvents defines the set of events in the form {eventType}.{attributeKey}, - // which informs Tendermint what to index. If empty, all events will be indexed. - IndexEvents map[string]struct{} - - LegacyRouter sdk.Router - MsgServiceRouter *MsgServiceRouter - - AccountKeeper AccountKeeper - BankKeeper types.BankKeeper - FeegrantKeeper FeegrantKeeper - SignModeHandler authsigning.SignModeHandler - SigGasConsumer func(meter sdk.GasMeter, sig signing.SignatureV2, params types.Params) error - ExtensionOptionChecker ExtensionOptionChecker - TxFeeChecker TxFeeChecker -} - -// NewDefaultTxHandler defines a TxHandler middleware stacks that should work -// for most applications. -func NewDefaultTxHandler(options TxHandlerOptions) (tx.Handler, error) { - if options.TxDecoder == nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "txDecoder is required for middlewares") - } - - if options.AccountKeeper == nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "account keeper is required for middlewares") - } - - if options.BankKeeper == nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for middlewares") - } - - if options.SignModeHandler == nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "sign mode handler is required for middlewares") - } - - return ComposeMiddlewares( - NewRunMsgsTxHandler(options.MsgServiceRouter, options.LegacyRouter), - NewTxDecoderMiddleware(options.TxDecoder), - // Set a new GasMeter on sdk.Context. - // - // Make sure the Gas middleware is outside of all other middlewares - // that reads the GasMeter. In our case, the Recovery middleware reads - // the GasMeter to populate GasInfo. - GasTxMiddleware, - // Recover from panics. Panics outside of this middleware won't be - // caught, be careful! - RecoveryTxMiddleware, - // Choose which events to index in Tendermint. Make sure no events are - // emitted outside of this middleware. - NewIndexEventsTxMiddleware(options.IndexEvents), - // Reject all extension options other than the ones needed by the feemarket. - NewExtensionOptionsMiddleware(options.ExtensionOptionChecker), - ValidateBasicMiddleware, - TxTimeoutHeightMiddleware, - ValidateMemoMiddleware(options.AccountKeeper), - ConsumeTxSizeGasMiddleware(options.AccountKeeper), - // No gas should be consumed in any middleware above in a "post" handler part. See - // ComposeMiddlewares godoc for details. - // `DeductFeeMiddleware` and `IncrementSequenceMiddleware` should be put outside of `WithBranchedStore` middleware, - // so their storage writes are not discarded when tx fails. - DeductFeeMiddleware(options.AccountKeeper, options.BankKeeper, options.FeegrantKeeper, options.TxFeeChecker), - SetPubKeyMiddleware(options.AccountKeeper), - ValidateSigCountMiddleware(options.AccountKeeper), - SigGasConsumeMiddleware(options.AccountKeeper, options.SigGasConsumer), - SigVerificationMiddleware(options.AccountKeeper, options.SignModeHandler), - IncrementSequenceMiddleware(options.AccountKeeper), - // Creates a new MultiStore branch, discards downstream writes if the downstream returns error. - // These kinds of middlewares should be put under this: - // - Could return error after messages executed succesfully. - // - Storage writes should be discarded together when tx failed. - WithBranchedStore, - // Consume block gas. All middlewares whose gas consumption after their `next` handler - // should be accounted for, should go below this middleware. - ConsumeBlockGasMiddleware, - NewTipMiddleware(options.BankKeeper), - ), nil -} diff --git a/x/auth/middleware/msg_service_router_test.go b/x/auth/middleware/msg_service_router_test.go deleted file mode 100644 index ca6ec79b5b9a..000000000000 --- a/x/auth/middleware/msg_service_router_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package middleware_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" -) - -func TestRegisterMsgService(t *testing.T) { - // Create an encoding config that doesn't register testdata Msg services. - encCfg := simapp.MakeTestEncodingConfig() - msr := middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry) - require.Panics(t, func() { - testdata.RegisterMsgServer( - msr, - testdata.MsgServerImpl{}, - ) - }) - - // Register testdata Msg services, and rerun `RegisterService`. - testdata.RegisterInterfaces(encCfg.InterfaceRegistry) - require.NotPanics(t, func() { - testdata.RegisterMsgServer( - msr, - testdata.MsgServerImpl{}, - ) - }) -} - -func TestRegisterMsgServiceTwice(t *testing.T) { - // Setup baseapp. - encCfg := simapp.MakeTestEncodingConfig() - msr := middleware.NewMsgServiceRouter(encCfg.InterfaceRegistry) - testdata.RegisterInterfaces(encCfg.InterfaceRegistry) - - // First time registering service shouldn't panic. - require.NotPanics(t, func() { - testdata.RegisterMsgServer( - msr, - testdata.MsgServerImpl{}, - ) - }) - - // Second time should panic. - require.Panics(t, func() { - testdata.RegisterMsgServer( - msr, - testdata.MsgServerImpl{}, - ) - }) -} diff --git a/x/auth/middleware/recovery.go b/x/auth/middleware/recovery.go deleted file mode 100644 index 563389d85fc5..000000000000 --- a/x/auth/middleware/recovery.go +++ /dev/null @@ -1,78 +0,0 @@ -package middleware - -import ( - "context" - "runtime/debug" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" -) - -type recoveryTxHandler struct { - next tx.Handler -} - -// RecoveryTxMiddleware defines a middleware that catches all panics that -// happen in inner middlewares. -// -// Be careful, it won't catch any panics happening outside! -func RecoveryTxMiddleware(txh tx.Handler) tx.Handler { - return recoveryTxHandler{next: txh} -} - -var _ tx.Handler = recoveryTxHandler{} - -// CheckTx implements tx.Handler.CheckTx method. -func (txh recoveryTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (res tx.Response, resCheckTx tx.ResponseCheckTx, err error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - // Panic recovery. - defer func() { - if r := recover(); r != nil { - err = handleRecovery(r, sdkCtx) - } - }() - - return txh.next.CheckTx(ctx, req, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx method. -func (txh recoveryTxHandler) DeliverTx(ctx context.Context, req tx.Request) (res tx.Response, err error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - // Panic recovery. - defer func() { - if r := recover(); r != nil { - err = handleRecovery(r, sdkCtx) - } - }() - - return txh.next.DeliverTx(ctx, req) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (txh recoveryTxHandler) SimulateTx(ctx context.Context, req tx.Request) (res tx.Response, err error) { - sdkCtx := sdk.UnwrapSDKContext(ctx) - // Panic recovery. - defer func() { - if r := recover(); r != nil { - err = handleRecovery(r, sdkCtx) - } - }() - - return txh.next.SimulateTx(ctx, req) -} - -func handleRecovery(r interface{}, sdkCtx sdk.Context) error { - switch r := r.(type) { - case sdk.ErrorOutOfGas: - return sdkerrors.Wrapf(sdkerrors.ErrOutOfGas, - "out of gas in location: %v; gasWanted: %d, gasUsed: %d", - r.Descriptor, sdkCtx.GasMeter().Limit(), sdkCtx.GasMeter().GasConsumed(), - ) - - default: - return sdkerrors.ErrPanic.Wrapf( - "recovered: %v\nstack:\n%v", r, string(debug.Stack()), - ) - } -} diff --git a/x/auth/middleware/run_msgs.go b/x/auth/middleware/run_msgs.go deleted file mode 100644 index d333e5918995..000000000000 --- a/x/auth/middleware/run_msgs.go +++ /dev/null @@ -1,117 +0,0 @@ -package middleware - -import ( - "context" - "strings" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" -) - -type runMsgsTxHandler struct { - legacyRouter sdk.Router // router for redirecting legacy Msgs - msgServiceRouter *MsgServiceRouter // router for redirecting Msg service messages -} - -func NewRunMsgsTxHandler(msr *MsgServiceRouter, legacyRouter sdk.Router) tx.Handler { - return runMsgsTxHandler{ - legacyRouter: legacyRouter, - msgServiceRouter: msr, - } -} - -var _ tx.Handler = runMsgsTxHandler{} - -// CheckTx implements tx.Handler.CheckTx method. -func (txh runMsgsTxHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - // Don't run Msgs during CheckTx. - return tx.Response{}, tx.ResponseCheckTx{}, nil -} - -// DeliverTx implements tx.Handler.DeliverTx method. -func (txh runMsgsTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return txh.runMsgs(sdk.UnwrapSDKContext(ctx), req.Tx.GetMsgs(), req.TxBytes) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (txh runMsgsTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - return txh.runMsgs(sdk.UnwrapSDKContext(ctx), req.Tx.GetMsgs(), req.TxBytes) -} - -// runMsgs iterates through a list of messages and executes them with the provided -// Context and execution mode. Messages will only be executed during simulation -// and DeliverTx. An error is returned if any single message fails or if a -// Handler does not exist for a given message route. Otherwise, a reference to a -// Result is returned. The caller must not commit state if an error is returned. -func (txh runMsgsTxHandler) runMsgs(sdkCtx sdk.Context, msgs []sdk.Msg, txBytes []byte) (tx.Response, error) { - // Attempt to execute all messages and only update state if all messages pass - // and we're in DeliverTx. Note, runMsgs will never return a reference to a - // Result if any single message fails or does not have a registered Handler. - msgLogs := make(sdk.ABCIMessageLogs, 0, len(msgs)) - events := sdkCtx.EventManager().Events() - msgResponses := make([]*codectypes.Any, len(msgs)) - - // NOTE: GasWanted is determined by the Gas TxHandler and GasUsed by the GasMeter. - for i, msg := range msgs { - var ( - msgResult *sdk.Result - eventMsgName string // name to use as value in event `message.action` - err error - ) - - if handler := txh.msgServiceRouter.Handler(msg); handler != nil { - // ADR 031 request type routing - msgResult, err = handler(sdkCtx, msg) - eventMsgName = sdk.MsgTypeURL(msg) - } else if legacyMsg, ok := msg.(legacytx.LegacyMsg); ok { - // legacy sdk.Msg routing - // Assuming that the app developer has migrated all their Msgs to - // proto messages and has registered all `Msg services`, then this - // path should never be called, because all those Msgs should be - // registered within the `MsgServiceRouter` already. - msgRoute := legacyMsg.Route() - eventMsgName = legacyMsg.Type() - handler := txh.legacyRouter.Route(sdkCtx, msgRoute) - if handler == nil { - return tx.Response{}, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized message route: %s; message index: %d", msgRoute, i) - } - - msgResult, err = handler(sdkCtx, msg) - } else { - return tx.Response{}, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "can't route message %+v", msg) - } - - if err != nil { - return tx.Response{}, sdkerrors.Wrapf(err, "failed to execute message; message index: %d", i) - } - - msgEvents := sdk.Events{ - sdk.NewEvent(sdk.EventTypeMessage, sdk.NewAttribute(sdk.AttributeKeyAction, eventMsgName)), - } - msgEvents = msgEvents.AppendEvents(msgResult.GetEvents()) - - // append message events, data and logs - // - // Note: Each message result's data must be length-prefixed in order to - // separate each result. - events = events.AppendEvents(msgEvents) - - // Each individual sdk.Result has exactly one Msg response. We aggregate here. - msgResponse := msgResult.MsgResponses[0] - if msgResponse == nil { - return tx.Response{}, sdkerrors.ErrLogic.Wrapf("got nil Msg response at index %d for msg %s", i, sdk.MsgTypeURL(msg)) - } - msgResponses[i] = msgResponse - msgLogs = append(msgLogs, sdk.NewABCIMessageLog(uint32(i), msgResult.Log, msgEvents)) - } - - return tx.Response{ - // GasInfo will be populated by the Gas middleware. - Log: strings.TrimSpace(msgLogs.String()), - Events: events.ToABCIEvents(), - MsgResponses: msgResponses, - }, nil -} diff --git a/x/auth/middleware/run_msgs_test.go b/x/auth/middleware/run_msgs_test.go deleted file mode 100644 index 6278d5c023d2..000000000000 --- a/x/auth/middleware/run_msgs_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package middleware_test - -import ( - "fmt" - - "github.com/gogo/protobuf/proto" - - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" -) - -func (s *MWTestSuite) TestRunMsgs() { - ctx := s.SetupTest(true) // setup - - msr := middleware.NewMsgServiceRouter(s.clientCtx.InterfaceRegistry) - testdata.RegisterMsgServer(msr, testdata.MsgServerImpl{}) - txHandler := middleware.NewRunMsgsTxHandler(msr, nil) - - priv, _, _ := testdata.KeyTestPubAddr() - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - txBuilder.SetMsgs(&testdata.MsgCreateDog{Dog: &testdata.Dog{Name: "Spot"}}) - privs, accNums, accSeqs := []cryptotypes.PrivKey{priv}, []uint64{0}, []uint64{0} - testTx, _, err := s.createTestTx(txBuilder, privs, accNums, accSeqs, ctx.ChainID()) - s.Require().NoError(err) - txBytes, err := s.clientCtx.TxConfig.TxEncoder()(testTx) - s.Require().NoError(err) - - res, err := txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tx.Request{Tx: testTx, TxBytes: txBytes}) - s.Require().NoError(err) - s.Require().Len(res.MsgResponses, 1) - s.Require().Equal(fmt.Sprintf("/%s", proto.MessageName(&testdata.MsgCreateDogResponse{})), res.MsgResponses[0].TypeUrl) -} diff --git a/x/auth/middleware/testutil_test.go b/x/auth/middleware/testutil_test.go deleted file mode 100644 index f493a463fa2a..000000000000 --- a/x/auth/middleware/testutil_test.go +++ /dev/null @@ -1,222 +0,0 @@ -package middleware_test - -import ( - "errors" - "fmt" - "testing" - - "github.com/stretchr/testify/suite" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - txtypes "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" - xauthsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -// testAccount represents an account used in the tests in x/auth/middleware. -type testAccount struct { - acc authtypes.AccountI - priv cryptotypes.PrivKey - accNum uint64 -} - -// MWTestSuite is a test suite to be used with middleware tests. -type MWTestSuite struct { - suite.Suite - - app *simapp.SimApp - clientCtx client.Context - txHandler txtypes.Handler -} - -// returns context and app with params set on account keeper -func createTestApp(t *testing.T, isCheckTx bool) (*simapp.SimApp, sdk.Context) { - app := simapp.Setup(t, isCheckTx) - ctx := app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: app.LastBlockHeight() + 1}).WithBlockGasMeter(sdk.NewInfiniteGasMeter()) - app.AccountKeeper.SetParams(ctx, authtypes.DefaultParams()) - - return app, ctx -} - -// setupTest setups a new test, with new app and context. -func (s *MWTestSuite) SetupTest(isCheckTx bool) sdk.Context { - var ctx sdk.Context - s.app, ctx = createTestApp(s.T(), isCheckTx) - - // Set up TxConfig. - encodingConfig := simapp.MakeTestEncodingConfig() - // We're using TestMsg encoding in some tests, so register it here. - encodingConfig.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil) - testdata.RegisterInterfaces(encodingConfig.InterfaceRegistry) - - s.clientCtx = client.Context{}. - WithTxConfig(encodingConfig.TxConfig). - WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithCodec(codec.NewAminoCodec(encodingConfig.Amino)) - - // We don't use simapp's own txHandler. For more flexibility (i.e. around - // using testdata), we create own own txHandler for this test suite. - msr := middleware.NewMsgServiceRouter(encodingConfig.InterfaceRegistry) - testdata.RegisterMsgServer(msr, testdata.MsgServerImpl{}) - legacyRouter := middleware.NewLegacyRouter() - legacyRouter.AddRoute(sdk.NewRoute((&testdata.TestMsg{}).Route(), func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - any, err := codectypes.NewAnyWithValue(msg) - if err != nil { - return nil, err - } - - return &sdk.Result{ - MsgResponses: []*codectypes.Any{any}, - }, nil - })) - txHandler, err := middleware.NewDefaultTxHandler(middleware.TxHandlerOptions{ - Debug: s.app.Trace(), - MsgServiceRouter: msr, - LegacyRouter: legacyRouter, - AccountKeeper: s.app.AccountKeeper, - BankKeeper: s.app.BankKeeper, - FeegrantKeeper: s.app.FeeGrantKeeper, - SignModeHandler: encodingConfig.TxConfig.SignModeHandler(), - SigGasConsumer: middleware.DefaultSigVerificationGasConsumer, - TxDecoder: s.clientCtx.TxConfig.TxDecoder(), - }) - s.Require().NoError(err) - s.txHandler = txHandler - - return ctx -} - -// createTestAccounts creates `numAccs` accounts, and return all relevant -// information about them including their private keys. -func (s *MWTestSuite) createTestAccounts(ctx sdk.Context, numAccs int, coins sdk.Coins) []testAccount { - var accounts []testAccount - - for i := 0; i < numAccs; i++ { - priv, _, addr := testdata.KeyTestPubAddr() - acc := s.app.AccountKeeper.NewAccountWithAddress(ctx, addr) - accNum := uint64(i) - err := acc.SetAccountNumber(accNum) - s.Require().NoError(err) - s.app.AccountKeeper.SetAccount(ctx, acc) - err = s.app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, coins) - s.Require().NoError(err) - - err = s.app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, coins) - s.Require().NoError(err) - - accounts = append(accounts, testAccount{acc, priv, accNum}) - } - - return accounts -} - -// createTestTx is a helper function to create a tx given multiple inputs. -func (s *MWTestSuite) createTestTx(txBuilder client.TxBuilder, privs []cryptotypes.PrivKey, accNums []uint64, accSeqs []uint64, chainID string) (xauthsigning.Tx, []byte, error) { - // First round: we gather all the signer infos. We use the "set empty - // signature" hack to do that. - var sigsV2 []signing.SignatureV2 - for i, priv := range privs { - sigV2 := signing.SignatureV2{ - PubKey: priv.PubKey(), - Data: &signing.SingleSignatureData{ - SignMode: s.clientCtx.TxConfig.SignModeHandler().DefaultMode(), - Signature: nil, - }, - Sequence: accSeqs[i], - } - - sigsV2 = append(sigsV2, sigV2) - } - err := txBuilder.SetSignatures(sigsV2...) - if err != nil { - return nil, nil, err - } - - // Second round: all signer infos are set, so each signer can sign. - sigsV2 = []signing.SignatureV2{} - for i, priv := range privs { - signerData := xauthsigning.SignerData{ - Address: sdk.AccAddress(priv.PubKey().Address()).String(), - ChainID: chainID, - AccountNumber: accNums[i], - Sequence: accSeqs[i], - PubKey: priv.PubKey(), - } - sigV2, err := tx.SignWithPrivKey( - s.clientCtx.TxConfig.SignModeHandler().DefaultMode(), signerData, - txBuilder, priv, s.clientCtx.TxConfig, accSeqs[i]) - if err != nil { - return nil, nil, err - } - - sigsV2 = append(sigsV2, sigV2) - } - err = txBuilder.SetSignatures(sigsV2...) - if err != nil { - return nil, nil, err - } - - txBytes, err := s.clientCtx.TxConfig.TxEncoder()(txBuilder.GetTx()) - if err != nil { - return nil, nil, err - } - - return txBuilder.GetTx(), txBytes, nil -} - -func (s *MWTestSuite) runTestCase(ctx sdk.Context, txBuilder client.TxBuilder, privs []cryptotypes.PrivKey, msgs []sdk.Msg, feeAmount sdk.Coins, gasLimit uint64, accNums, accSeqs []uint64, chainID string, tc TestCase) { - s.Run(fmt.Sprintf("Case %s", tc.desc), func() { - s.Require().NoError(txBuilder.SetMsgs(msgs...)) - txBuilder.SetFeeAmount(feeAmount) - txBuilder.SetGasLimit(gasLimit) - - // Theoretically speaking, middleware unit tests should only test - // middlewares, but here we sometimes also test the tx creation - // process. - testTx, _, txErr := s.createTestTx(txBuilder, privs, accNums, accSeqs, chainID) - newCtx, txHandlerErr := s.txHandler.DeliverTx(sdk.WrapSDKContext(ctx), txtypes.Request{Tx: testTx}) - - if tc.expPass { - s.Require().NoError(txErr) - s.Require().NoError(txHandlerErr) - s.Require().NotNil(newCtx) - } else { - switch { - case txErr != nil: - s.Require().Error(txErr) - s.Require().True(errors.Is(txErr, tc.expErr)) - - case txHandlerErr != nil: - s.Require().Error(txHandlerErr) - s.Require().True(errors.Is(txHandlerErr, tc.expErr)) - - default: - s.Fail("expected one of txErr,txHandlerErr to be an error") - } - } - }) -} - -// TestCase represents a test case used in test tables. -type TestCase struct { - desc string - malleate func() - simulate bool - expPass bool - expErr error -} - -func TestMWTestSuite(t *testing.T) { - suite.Run(t, new(MWTestSuite)) -} diff --git a/x/auth/middleware/tips.go b/x/auth/middleware/tips.go deleted file mode 100644 index 68749b020647..000000000000 --- a/x/auth/middleware/tips.go +++ /dev/null @@ -1,69 +0,0 @@ -package middleware - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/types" -) - -type tipsTxHandler struct { - next tx.Handler - bankKeeper types.BankKeeper -} - -// NewTipMiddleware returns a new middleware for handling transactions with -// tips. -func NewTipMiddleware(bankKeeper types.BankKeeper) tx.Middleware { - return func(txh tx.Handler) tx.Handler { - return tipsTxHandler{txh, bankKeeper} - } -} - -var _ tx.Handler = tipsTxHandler{} - -// CheckTx implements tx.Handler.CheckTx. -func (txh tipsTxHandler) CheckTx(ctx context.Context, req tx.Request, checkTx tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - res, resCheckTx, err := txh.next.CheckTx(ctx, req, checkTx) - res, err = txh.transferTip(ctx, req, res, err) - - return res, resCheckTx, err -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (txh tipsTxHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - res, err := txh.next.DeliverTx(ctx, req) - - return txh.transferTip(ctx, req, res, err) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (txh tipsTxHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - res, err := txh.next.SimulateTx(ctx, req) - - return txh.transferTip(ctx, req, res, err) -} - -// transferTip transfers the tip from the tipper to the fee payer. -func (txh tipsTxHandler) transferTip(ctx context.Context, req tx.Request, res tx.Response, err error) (tx.Response, error) { - tipTx, ok := req.Tx.(tx.TipTx) - - // No-op if the tx doesn't have tips. - if !ok || tipTx.GetTip() == nil { - return res, err - } - - sdkCtx := sdk.UnwrapSDKContext(ctx) - tipper, err := sdk.AccAddressFromBech32(tipTx.GetTip().Tipper) - if err != nil { - return tx.Response{}, err - } - - err = txh.bankKeeper.SendCoins(sdkCtx, tipper, tipTx.FeePayer(), tipTx.GetTip().Amount) - if err != nil { - return tx.Response{}, err - } - - return res, nil -} diff --git a/x/auth/middleware/tips_test.go b/x/auth/middleware/tips_test.go deleted file mode 100644 index 769aa0c4194a..000000000000 --- a/x/auth/middleware/tips_test.go +++ /dev/null @@ -1,206 +0,0 @@ -package middleware_test - -import ( - "time" - - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/client" - clienttx "github.com/cosmos/cosmos-sdk/client/tx" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -var initialRegens = sdk.NewCoins(sdk.NewCoin("regen", sdk.NewInt(1000))) -var initialAtoms = sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(1000))) - -// setupAcctsForTips sets up 2 accounts: -// - tipper has 1000 regens -// - feePayer has 1000 atoms and 1000 regens -func (s *MWTestSuite) setupAcctsForTips(ctx sdk.Context) (sdk.Context, []testAccount) { - accts := s.createTestAccounts(ctx, 2, initialRegens) - feePayer := accts[1] - err := s.app.BankKeeper.MintCoins(ctx, minttypes.ModuleName, initialAtoms) - s.Require().NoError(err) - err = s.app.BankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, feePayer.acc.GetAddress(), initialAtoms) - s.Require().NoError(err) - - // Create dummy proposal for tipper to vote on. - prop, err := govtypes.NewProposal([]sdk.Msg{banktypes.NewMsgSend(accts[0].acc.GetAddress(), accts[0].acc.GetAddress(), initialRegens)}, 1, "", time.Now(), time.Now().Add(time.Hour)) - s.Require().NoError(err) - s.app.GovKeeper.SetProposal(ctx, prop) - s.app.GovKeeper.ActivateVotingPeriod(ctx, prop) - - // Move to next block to commit previous data to state. - s.app.EndBlock(abci.RequestEndBlock{Height: ctx.BlockHeight()}) - s.app.Commit() - - ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) - s.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: ctx.BlockHeight()}}) - - return ctx, accts -} - -func (s *MWTestSuite) TestTips() { - var msg sdk.Msg - - testcases := []struct { - name string - tip sdk.Coins - fee sdk.Coins - gasLimit uint64 - expErr bool - expErrStr string - }{ - { - "wrong tip denom", - sdk.NewCoins(sdk.NewCoin("foobar", sdk.NewInt(1000))), initialAtoms, 200000, - true, "0foobar is smaller than 1000foobar: insufficient funds", - }, - { - "insufficient tip from tipper", - sdk.NewCoins(sdk.NewCoin("regen", sdk.NewInt(5000))), initialAtoms, 200000, - true, "1000regen is smaller than 5000regen: insufficient funds", - }, - { - "insufficient fees from feePayer", - initialRegens, sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(5000))), 200000, - true, "1000atom is smaller than 5000atom: insufficient funds: insufficient funds", - }, - { - "insufficient gas", - initialRegens, initialAtoms, 100, - true, "out of gas in location: ReadFlat; gasWanted: 100, gasUsed: 1000: out of gas", - }, - { - "happy case", - initialRegens, initialAtoms, 200000, - false, "", - }, - } - - for _, tc := range testcases { - tc := tc - s.Run(tc.name, func() { - ctx := s.SetupTest(false) // reset - ctx, accts := s.setupAcctsForTips(ctx) - tipper, feePayer := accts[0], accts[1] - - msg = govtypes.NewMsgVote(tipper.acc.GetAddress(), 1, govtypes.OptionYes, "") - - auxSignerData := s.mkTipperAuxSignerData(tipper.priv, msg, tc.tip, signing.SignMode_SIGN_MODE_DIRECT_AUX, tipper.accNum, 0, ctx.ChainID()) - feePayerTxBuilder := s.mkFeePayerTxBuilder(s.clientCtx, auxSignerData, feePayer.priv, signing.SignMode_SIGN_MODE_DIRECT, tx.Fee{Amount: tc.fee, GasLimit: tc.gasLimit}, feePayer.accNum, 0, ctx.ChainID()) - - _, res, err := s.app.SimDeliver(s.clientCtx.TxConfig.TxEncoder(), feePayerTxBuilder.GetTx()) - - if tc.expErr { - s.Require().Error(err) - s.Require().Contains(err.Error(), tc.expErrStr) - } else { - s.Require().NoError(err) - s.Require().NotNil(res) - - // Move to next block to commit previous data to state. - s.app.EndBlock(abci.RequestEndBlock{Height: ctx.BlockHeight()}) - s.app.Commit() - - ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) - s.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: ctx.BlockHeight()}}) - - // Make sure tip is correctly transferred to feepayer, and fee is paid. - expTipperRegens := initialRegens.Sub(tc.tip) - expFeePayerRegens := initialRegens.Add(tc.tip...) - expFeePayerAtoms := initialAtoms.Sub(tc.fee) - s.Require().True(expTipperRegens.AmountOf("regen").Equal(s.app.BankKeeper.GetBalance(ctx, tipper.acc.GetAddress(), "regen").Amount)) - s.Require().True(expFeePayerRegens.AmountOf("regen").Equal(s.app.BankKeeper.GetBalance(ctx, feePayer.acc.GetAddress(), "regen").Amount)) - s.Require().True(expFeePayerAtoms.AmountOf("atom").Equal(s.app.BankKeeper.GetBalance(ctx, feePayer.acc.GetAddress(), "atom").Amount)) - // Make sure MsgVote has been submitted by tipper. - votes := s.app.GovKeeper.GetAllVotes(ctx) - s.Require().Len(votes, 1) - s.Require().Equal(tipper.acc.GetAddress().String(), votes[0].Voter) - } - }) - } -} - -func (s *MWTestSuite) mkTipperAuxSignerData( - tipperPriv cryptotypes.PrivKey, msg sdk.Msg, tip sdk.Coins, - signMode signing.SignMode, accNum, accSeq uint64, chainID string, -) tx.AuxSignerData { - tipperAddr := sdk.AccAddress(tipperPriv.PubKey().Address()).String() - b := clienttx.NewAuxTxBuilder() - b.SetAddress(tipperAddr) - b.SetAccountNumber(accNum) - b.SetSequence(accSeq) - err := b.SetMsgs(msg) - s.Require().NoError(err) - b.SetTip(&tx.Tip{Amount: tip, Tipper: tipperAddr}) - err = b.SetSignMode(signMode) - s.Require().NoError(err) - b.SetSequence(accSeq) - err = b.SetPubKey(tipperPriv.PubKey()) - s.Require().NoError(err) - b.SetChainID(chainID) - - signBz, err := b.GetSignBytes() - s.Require().NoError(err) - sig, err := tipperPriv.Sign(signBz) - s.Require().NoError(err) - b.SetSignature(sig) - - auxSignerData, err := b.GetAuxSignerData() - s.Require().NoError(err) - - return auxSignerData -} - -func (s *MWTestSuite) mkFeePayerTxBuilder( - clientCtx client.Context, - auxSignerData tx.AuxSignerData, - feePayerPriv cryptotypes.PrivKey, signMode signing.SignMode, - fee tx.Fee, accNum, accSeq uint64, chainID string, -) client.TxBuilder { - txBuilder := clientCtx.TxConfig.NewTxBuilder() - err := txBuilder.AddAuxSignerData(auxSignerData) - s.Require().NoError(err) - txBuilder.SetFeePayer(sdk.AccAddress(feePayerPriv.PubKey().Address())) - txBuilder.SetFeeAmount(fee.Amount) - txBuilder.SetGasLimit(fee.GasLimit) - - // Calling SetSignatures with empty sig to populate AuthInfo. - tipperSigsV2, err := auxSignerData.GetSignatureV2() - s.Require().NoError(err) - feePayerSigV2 := signing.SignatureV2{ - PubKey: feePayerPriv.PubKey(), - Data: &signing.SingleSignatureData{ - SignMode: signMode, - Signature: nil, - }} - sigsV2 := append([]signing.SignatureV2{tipperSigsV2}, feePayerSigV2) - txBuilder.SetSignatures(sigsV2...) - - // Actually sign the data. - signerData := authsigning.SignerData{ - Address: sdk.AccAddress(feePayerPriv.PubKey().Address()).String(), - ChainID: chainID, - AccountNumber: accNum, - Sequence: accSeq, - PubKey: feePayerPriv.PubKey(), - } - feePayerSigV2, err = clienttx.SignWithPrivKey( - signMode, signerData, - txBuilder, feePayerPriv, clientCtx.TxConfig, accSeq) - s.Require().NoError(err) - sigsV2 = append([]signing.SignatureV2{tipperSigsV2}, feePayerSigV2) - err = txBuilder.SetSignatures(sigsV2...) - s.Require().NoError(err) - - return txBuilder -} diff --git a/x/auth/middleware/tx.go b/x/auth/middleware/tx.go deleted file mode 100644 index f543524f3fa7..000000000000 --- a/x/auth/middleware/tx.go +++ /dev/null @@ -1,77 +0,0 @@ -package middleware - -import ( - "context" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/tx" -) - -type txDecoderHandler struct { - next tx.Handler - txDecoder sdk.TxDecoder -} - -// NewTxDecoderMiddleware creates a new middleware that will decode tx bytes -// into a sdk.Tx. As input request, at least one of Tx or TxBytes must be set. -// If only TxBytes is set, then TxDecoderMiddleware will populate the Tx field. -// If only Tx is set, then TxBytes will be left empty, but some middlewares -// such as signature verification might fail. -func NewTxDecoderMiddleware(txDecoder sdk.TxDecoder) tx.Middleware { - return func(txh tx.Handler) tx.Handler { - return txDecoderHandler{next: txh, txDecoder: txDecoder} - } -} - -var _ tx.Handler = gasTxHandler{} - -// CheckTx implements tx.Handler.CheckTx. -func (h txDecoderHandler) CheckTx(ctx context.Context, req tx.Request, checkReq tx.RequestCheckTx) (tx.Response, tx.ResponseCheckTx, error) { - newReq, err := h.populateReq(req) - if err != nil { - return tx.Response{}, tx.ResponseCheckTx{}, err - } - - return h.next.CheckTx(ctx, newReq, checkReq) -} - -// DeliverTx implements tx.Handler.DeliverTx. -func (h txDecoderHandler) DeliverTx(ctx context.Context, req tx.Request) (tx.Response, error) { - newReq, err := h.populateReq(req) - if err != nil { - return tx.Response{}, err - } - - return h.next.DeliverTx(ctx, newReq) -} - -// SimulateTx implements tx.Handler.SimulateTx method. -func (h txDecoderHandler) SimulateTx(ctx context.Context, req tx.Request) (tx.Response, error) { - newReq, err := h.populateReq(req) - if err != nil { - return tx.Response{}, err - } - - return h.next.SimulateTx(ctx, newReq) -} - -// populateReq takes a tx.Request, and if its Tx field is not set, then -// decodes the TxBytes and populates the decoded Tx field. It leaves -// req.TxBytes untouched. -func (h txDecoderHandler) populateReq(req tx.Request) (tx.Request, error) { - if len(req.TxBytes) == 0 && req.Tx == nil { - return tx.Request{}, sdkerrors.ErrInvalidRequest.Wrap("got empty tx request") - } - - sdkTx := req.Tx - var err error - if len(req.TxBytes) != 0 { - sdkTx, err = h.txDecoder(req.TxBytes) - if err != nil { - return tx.Request{}, err - } - } - - return tx.Request{Tx: sdkTx, TxBytes: req.TxBytes}, nil -} diff --git a/x/auth/middleware/tx_test.go b/x/auth/middleware/tx_test.go deleted file mode 100644 index 8624aadbfea2..000000000000 --- a/x/auth/middleware/tx_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package middleware_test - -import ( - "context" - - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/tx" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" -) - -func (s *MWTestSuite) TestTxDecoderMiddleware() { - ctx := s.SetupTest(true) // setup - require := s.Require() - - // Create a tx. - priv1, _, addr1 := testdata.KeyTestPubAddr() - txBuilder := s.clientCtx.TxConfig.NewTxBuilder() - err := txBuilder.SetMsgs(testdata.NewTestMsg(addr1)) - require.NoError(err) - sdkTx, txBz, err := s.createTestTx(txBuilder, []cryptotypes.PrivKey{priv1}, []uint64{1}, []uint64{0}, ctx.ChainID()) - require.NoError(err) - - // Create a custom tx.Handler that checks that the req.Tx field is - // correctly populated. - txReqChecker := customTxHandler{func(c context.Context, r tx.Request) (tx.Response, error) { - require.NotNil(r.Tx) - require.Equal(sdkTx.GetMsgs()[0], r.Tx.GetMsgs()[0]) - return tx.Response{}, nil - }} - - testcases := []struct { - name string - req tx.Request - expErr bool - }{ - {"empty tx bz", tx.Request{}, true}, - {"tx bz and tx both given as inputs", tx.Request{Tx: sdkTx, TxBytes: txBz}, false}, - {"tx bz only given as input", tx.Request{TxBytes: txBz}, false}, - {"tx only given as input", tx.Request{Tx: sdkTx}, false}, - } - for _, tc := range testcases { - s.Run(tc.name, func() { - txHandler := middleware.ComposeMiddlewares( - txReqChecker, - middleware.NewTxDecoderMiddleware(s.clientCtx.TxConfig.TxDecoder()), - ) - _, err := txHandler.DeliverTx(sdk.WrapSDKContext(ctx), tc.req) - if tc.expErr { - require.Error(err) - } else { - require.NoError(err) - } - }) - } -} diff --git a/x/auth/migrations/legacytx/stdtx_builder.go b/x/auth/migrations/legacytx/stdtx_builder.go index 0c0454034947..35d26ce02e1f 100644 --- a/x/auth/migrations/legacytx/stdtx_builder.go +++ b/x/auth/migrations/legacytx/stdtx_builder.go @@ -190,7 +190,7 @@ func mkDecoder(unmarshaler Unmarshaler) sdk.TxDecoder { if len(txBytes) == 0 { return nil, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "tx bytes are empty") } - var tx = StdTx{} + tx := StdTx{} // StdTx.Msg is an interface. The concrete types // are registered by MakeTxCodec err := unmarshaler(txBytes, &tx) diff --git a/x/auth/migrations/legacytx/stdtx_test.go b/x/auth/migrations/legacytx/stdtx_test.go index c883a2faa2ea..2e69427c5af2 100644 --- a/x/auth/migrations/legacytx/stdtx_test.go +++ b/x/auth/migrations/legacytx/stdtx_test.go @@ -26,7 +26,7 @@ var ( ) func init() { - var amino = codec.NewLegacyAmino() + amino := codec.NewLegacyAmino() RegisterLegacyAminoCodec(amino) } diff --git a/x/auth/migrations/v034/types.go b/x/auth/migrations/v034/types.go deleted file mode 100644 index e028b0874044..000000000000 --- a/x/auth/migrations/v034/types.go +++ /dev/null @@ -1,28 +0,0 @@ -// Package v034 is used for legacy migration scripts. Actual migration scripts -// for v034 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -// DONTCOVER -package v034 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -const ( - ModuleName = "auth" -) - -type ( - Params struct { - MaxMemoCharacters uint64 `json:"max_memo_characters"` - TxSigLimit uint64 `json:"tx_sig_limit"` - TxSizeCostPerByte uint64 `json:"tx_size_cost_per_byte"` - SigVerifyCostED25519 uint64 `json:"sig_verify_cost_ed25519"` - SigVerifyCostSecp256k1 uint64 `json:"sig_verify_cost_secp256k1"` - } - - GenesisState struct { - CollectedFees sdk.Coins `json:"collected_fees"` - Params Params `json:"params"` - } -) diff --git a/x/auth/migrations/v038/types.go b/x/auth/migrations/v038/types.go deleted file mode 100644 index be782a05bfa6..000000000000 --- a/x/auth/migrations/v038/types.go +++ /dev/null @@ -1,533 +0,0 @@ -// Package v038 is used for legacy migration scripts. Actual migration scripts -// for v038 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -package v038 - -// DONTCOVER - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "sort" - "strings" - - tmcrypto "github.com/tendermint/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/codec" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" - v034auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v034" -) - -const ( - ModuleName = "auth" -) - -type ( - // partial interface needed only for amino encoding and sanitization - Account interface { - GetAddress() sdk.AccAddress - GetAccountNumber() uint64 - GetCoins() sdk.Coins - SetCoins(sdk.Coins) error - } - - GenesisAccount interface { - Account - - Validate() error - } - - GenesisAccounts []GenesisAccount - - GenesisState struct { - Params v034auth.Params `json:"params" yaml:"params"` - Accounts GenesisAccounts `json:"accounts" yaml:"accounts"` - } - - BaseAccount struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins,omitempty"` - PubKey cryptotypes.PubKey `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - } - - baseAccountPretty struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins,omitempty"` - PubKey string `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - } - - BaseVestingAccount struct { - *BaseAccount - - OriginalVesting sdk.Coins `json:"original_vesting"` - DelegatedFree sdk.Coins `json:"delegated_free"` - DelegatedVesting sdk.Coins `json:"delegated_vesting"` - - EndTime int64 `json:"end_time"` - } - - vestingAccountPretty struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins,omitempty"` - PubKey string `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` - DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` - DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` - EndTime int64 `json:"end_time" yaml:"end_time"` - - // custom fields based on concrete vesting type which can be omitted - StartTime int64 `json:"start_time,omitempty" yaml:"start_time,omitempty"` - } - - ContinuousVestingAccount struct { - *BaseVestingAccount - - StartTime int64 `json:"start_time"` - } - - DelayedVestingAccount struct { - *BaseVestingAccount - } - - ModuleAccount struct { - *BaseAccount - - Name string `json:"name" yaml:"name"` - Permissions []string `json:"permissions" yaml:"permissions"` - } - - moduleAccountPretty struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins,omitempty"` - PubKey string `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - Name string `json:"name" yaml:"name"` - Permissions []string `json:"permissions" yaml:"permissions"` - } -) - -func NewGenesisState(params v034auth.Params, accounts GenesisAccounts) GenesisState { - return GenesisState{ - Params: params, - Accounts: accounts, - } -} - -func NewBaseAccountWithAddress(addr sdk.AccAddress) BaseAccount { - return BaseAccount{ - Address: addr, - } -} - -func NewBaseAccount( - address sdk.AccAddress, coins sdk.Coins, pk cryptotypes.PubKey, accountNumber, sequence uint64, -) *BaseAccount { - - return &BaseAccount{ - Address: address, - Coins: coins, - PubKey: pk, - AccountNumber: accountNumber, - Sequence: sequence, - } -} - -func (acc BaseAccount) GetAddress() sdk.AccAddress { - return acc.Address -} - -func (acc *BaseAccount) GetAccountNumber() uint64 { - return acc.AccountNumber -} - -func (acc *BaseAccount) GetCoins() sdk.Coins { - return acc.Coins -} - -func (acc *BaseAccount) SetCoins(coins sdk.Coins) error { - acc.Coins = coins - return nil -} - -func (acc BaseAccount) Validate() error { - if acc.PubKey != nil && acc.Address != nil && - !bytes.Equal(acc.PubKey.Address().Bytes(), acc.Address.Bytes()) { - return errors.New("pubkey and address pair is invalid") - } - - return nil -} - -func (acc BaseAccount) MarshalJSON() ([]byte, error) { - alias := baseAccountPretty{ - Address: acc.Address, - Coins: acc.Coins, - AccountNumber: acc.AccountNumber, - Sequence: acc.Sequence, - } - - if acc.PubKey != nil { - pks, err := legacybech32.MarshalPubKey(legacybech32.AccPK, acc.PubKey) - if err != nil { - return nil, err - } - - alias.PubKey = pks - } - - return json.Marshal(alias) -} - -// UnmarshalJSON unmarshals raw JSON bytes into a BaseAccount. -func (acc *BaseAccount) UnmarshalJSON(bz []byte) error { - var alias baseAccountPretty - if err := json.Unmarshal(bz, &alias); err != nil { - return err - } - - if alias.PubKey != "" { - pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, alias.PubKey) - if err != nil { - return err - } - - acc.PubKey = pk - } - - acc.Address = alias.Address - acc.Coins = alias.Coins - acc.AccountNumber = alias.AccountNumber - acc.Sequence = alias.Sequence - - return nil -} - -func NewBaseVestingAccount( - baseAccount *BaseAccount, originalVesting, delegatedFree, delegatedVesting sdk.Coins, endTime int64, -) *BaseVestingAccount { - - return &BaseVestingAccount{ - BaseAccount: baseAccount, - OriginalVesting: originalVesting, - DelegatedFree: delegatedFree, - DelegatedVesting: delegatedVesting, - EndTime: endTime, - } -} - -func (bva BaseVestingAccount) Validate() error { - return bva.BaseAccount.Validate() -} - -// MarshalJSON returns the JSON representation of a BaseVestingAccount. -func (bva BaseVestingAccount) MarshalJSON() ([]byte, error) { - alias := vestingAccountPretty{ - Address: bva.Address, - Coins: bva.Coins, - AccountNumber: bva.AccountNumber, - Sequence: bva.Sequence, - OriginalVesting: bva.OriginalVesting, - DelegatedFree: bva.DelegatedFree, - DelegatedVesting: bva.DelegatedVesting, - EndTime: bva.EndTime, - } - - if bva.PubKey != nil { - pks, err := legacybech32.MarshalPubKey(legacybech32.AccPK, bva.PubKey) - if err != nil { - return nil, err - } - - alias.PubKey = pks - } - - return json.Marshal(alias) -} - -// UnmarshalJSON unmarshals raw JSON bytes into a BaseVestingAccount. -func (bva *BaseVestingAccount) UnmarshalJSON(bz []byte) error { - var alias vestingAccountPretty - if err := json.Unmarshal(bz, &alias); err != nil { - return err - } - - var ( - pk cryptotypes.PubKey - err error - ) - - if alias.PubKey != "" { - pk, err = legacybech32.UnmarshalPubKey(legacybech32.AccPK, alias.PubKey) - if err != nil { - return err - } - } - - bva.BaseAccount = NewBaseAccount(alias.Address, alias.Coins, pk, alias.AccountNumber, alias.Sequence) - bva.OriginalVesting = alias.OriginalVesting - bva.DelegatedFree = alias.DelegatedFree - bva.DelegatedVesting = alias.DelegatedVesting - bva.EndTime = alias.EndTime - - return nil -} - -func NewContinuousVestingAccountRaw(bva *BaseVestingAccount, startTime int64) *ContinuousVestingAccount { - return &ContinuousVestingAccount{ - BaseVestingAccount: bva, - StartTime: startTime, - } -} - -func (cva ContinuousVestingAccount) Validate() error { - if cva.StartTime >= cva.EndTime { - return errors.New("vesting start-time cannot be before end-time") - } - - return cva.BaseVestingAccount.Validate() -} - -// MarshalJSON returns the JSON representation of a ContinuousVestingAccount. -func (cva ContinuousVestingAccount) MarshalJSON() ([]byte, error) { - alias := vestingAccountPretty{ - Address: cva.Address, - Coins: cva.Coins, - AccountNumber: cva.AccountNumber, - Sequence: cva.Sequence, - OriginalVesting: cva.OriginalVesting, - DelegatedFree: cva.DelegatedFree, - DelegatedVesting: cva.DelegatedVesting, - EndTime: cva.EndTime, - StartTime: cva.StartTime, - } - - if cva.PubKey != nil { - pks, err := legacybech32.MarshalPubKey(legacybech32.AccPK, cva.PubKey) - if err != nil { - return nil, err - } - - alias.PubKey = pks - } - - return json.Marshal(alias) -} - -// UnmarshalJSON unmarshals raw JSON bytes into a ContinuousVestingAccount. -func (cva *ContinuousVestingAccount) UnmarshalJSON(bz []byte) error { - var alias vestingAccountPretty - if err := json.Unmarshal(bz, &alias); err != nil { - return err - } - - var ( - pk cryptotypes.PubKey - err error - ) - - if alias.PubKey != "" { - pk, err = legacybech32.UnmarshalPubKey(legacybech32.AccPK, alias.PubKey) - if err != nil { - return err - } - } - - cva.BaseVestingAccount = &BaseVestingAccount{ - BaseAccount: NewBaseAccount(alias.Address, alias.Coins, pk, alias.AccountNumber, alias.Sequence), - OriginalVesting: alias.OriginalVesting, - DelegatedFree: alias.DelegatedFree, - DelegatedVesting: alias.DelegatedVesting, - EndTime: alias.EndTime, - } - cva.StartTime = alias.StartTime - - return nil -} - -func NewDelayedVestingAccountRaw(bva *BaseVestingAccount) *DelayedVestingAccount { - return &DelayedVestingAccount{ - BaseVestingAccount: bva, - } -} - -func (dva DelayedVestingAccount) Validate() error { - return dva.BaseVestingAccount.Validate() -} - -// MarshalJSON returns the JSON representation of a DelayedVestingAccount. -func (dva DelayedVestingAccount) MarshalJSON() ([]byte, error) { - alias := vestingAccountPretty{ - Address: dva.Address, - Coins: dva.Coins, - AccountNumber: dva.AccountNumber, - Sequence: dva.Sequence, - OriginalVesting: dva.OriginalVesting, - DelegatedFree: dva.DelegatedFree, - DelegatedVesting: dva.DelegatedVesting, - EndTime: dva.EndTime, - } - - if dva.PubKey != nil { - pks, err := legacybech32.MarshalPubKey(legacybech32.AccPK, dva.PubKey) - if err != nil { - return nil, err - } - - alias.PubKey = pks - } - - return json.Marshal(alias) -} - -// UnmarshalJSON unmarshals raw JSON bytes into a DelayedVestingAccount. -func (dva *DelayedVestingAccount) UnmarshalJSON(bz []byte) error { - var alias vestingAccountPretty - if err := json.Unmarshal(bz, &alias); err != nil { - return err - } - - var ( - pk cryptotypes.PubKey - err error - ) - - if alias.PubKey != "" { - pk, err = legacybech32.UnmarshalPubKey(legacybech32.AccPK, alias.PubKey) - if err != nil { - return err - } - } - - dva.BaseVestingAccount = &BaseVestingAccount{ - BaseAccount: NewBaseAccount(alias.Address, alias.Coins, pk, alias.AccountNumber, alias.Sequence), - OriginalVesting: alias.OriginalVesting, - DelegatedFree: alias.DelegatedFree, - DelegatedVesting: alias.DelegatedVesting, - EndTime: alias.EndTime, - } - - return nil -} - -func NewModuleAddress(name string) sdk.AccAddress { - return sdk.AccAddress(tmcrypto.AddressHash([]byte(name))) -} - -func NewModuleAccount(baseAccount *BaseAccount, name string, permissions ...string) *ModuleAccount { - return &ModuleAccount{ - BaseAccount: baseAccount, - Name: name, - Permissions: permissions, - } -} - -func (ma ModuleAccount) Validate() error { - if err := ValidatePermissions(ma.Permissions...); err != nil { - return err - } - - if strings.TrimSpace(ma.Name) == "" { - return errors.New("module account name cannot be blank") - } - - if !ma.Address.Equals(sdk.AccAddress(tmcrypto.AddressHash([]byte(ma.Name)))) { - return fmt.Errorf("address %s cannot be derived from the module name '%s'", ma.Address, ma.Name) - } - - return ma.BaseAccount.Validate() -} - -// MarshalJSON returns the JSON representation of a ModuleAccount. -func (ma ModuleAccount) MarshalJSON() ([]byte, error) { - return json.Marshal(moduleAccountPretty{ - Address: ma.Address, - Coins: ma.Coins, - PubKey: "", - AccountNumber: ma.AccountNumber, - Sequence: ma.Sequence, - Name: ma.Name, - Permissions: ma.Permissions, - }) -} - -// UnmarshalJSON unmarshals raw JSON bytes into a ModuleAccount. -func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { - var alias moduleAccountPretty - if err := json.Unmarshal(bz, &alias); err != nil { - return err - } - - ma.BaseAccount = NewBaseAccount(alias.Address, alias.Coins, nil, alias.AccountNumber, alias.Sequence) - ma.Name = alias.Name - ma.Permissions = alias.Permissions - - return nil -} - -func ValidatePermissions(permissions ...string) error { - for _, perm := range permissions { - if strings.TrimSpace(perm) == "" { - return fmt.Errorf("module permission is empty") - } - } - - return nil -} - -func SanitizeGenesisAccounts(genAccounts GenesisAccounts) GenesisAccounts { - sort.Slice(genAccounts, func(i, j int) bool { - return genAccounts[i].GetAccountNumber() < genAccounts[j].GetAccountNumber() - }) - - for _, acc := range genAccounts { - if err := acc.SetCoins(acc.GetCoins().Sort()); err != nil { - panic(err) - } - } - - return genAccounts -} - -func ValidateGenAccounts(genAccounts GenesisAccounts) error { - addrMap := make(map[string]bool, len(genAccounts)) - for _, acc := range genAccounts { - - // check for duplicated accounts - addrStr := acc.GetAddress().String() - if _, ok := addrMap[addrStr]; ok { - return fmt.Errorf("duplicate account found in genesis state; address: %s", addrStr) - } - - addrMap[addrStr] = true - - // check account specific validation - if err := acc.Validate(); err != nil { - return fmt.Errorf("invalid account found in genesis state; address: %s, error: %s", addrStr, err.Error()) - } - } - - return nil -} - -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cryptocodec.RegisterCrypto(cdc) - cdc.RegisterInterface((*GenesisAccount)(nil), nil) - cdc.RegisterInterface((*Account)(nil), nil) - cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/Account", nil) - cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount", nil) - cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount", nil) - cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount", nil) - cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil) -} diff --git a/x/auth/migrations/v039/types.go b/x/auth/migrations/v039/types.go deleted file mode 100644 index 0f4b7f6c15bc..000000000000 --- a/x/auth/migrations/v039/types.go +++ /dev/null @@ -1,428 +0,0 @@ -package v039 - -// DONTCOVER - -import ( - "bytes" - "errors" - "fmt" - "strings" - - tmcrypto "github.com/tendermint/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/legacy" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - v034auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v034" - v038auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v038" -) - -const ( - ModuleName = "auth" -) - -type ( - GenesisState struct { - Params v034auth.Params `json:"params" yaml:"params"` - Accounts v038auth.GenesisAccounts `json:"accounts" yaml:"accounts"` - } - - BaseAccount struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins,omitempty"` - PubKey cryptotypes.PubKey `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - } - - BaseVestingAccount struct { - *BaseAccount - - OriginalVesting sdk.Coins `json:"original_vesting"` - DelegatedFree sdk.Coins `json:"delegated_free"` - DelegatedVesting sdk.Coins `json:"delegated_vesting"` - - EndTime int64 `json:"end_time"` - } - - vestingAccountJSON struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins"` - PubKey cryptotypes.PubKey `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"` - DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"` - DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"` - EndTime int64 `json:"end_time" yaml:"end_time"` - - // custom fields based on concrete vesting type which can be omitted - StartTime int64 `json:"start_time,omitempty" yaml:"start_time,omitempty"` - VestingPeriods Periods `json:"vesting_periods,omitempty" yaml:"vesting_periods,omitempty"` - } - - ContinuousVestingAccount struct { - *BaseVestingAccount - - StartTime int64 `json:"start_time"` - } - - DelayedVestingAccount struct { - *BaseVestingAccount - } - - Period struct { - Length int64 `json:"length" yaml:"length"` // length of the period, in seconds - Amount sdk.Coins `json:"amount" yaml:"amount"` // amount of coins vesting during this period - } - - Periods []Period - - PeriodicVestingAccount struct { - *BaseVestingAccount - StartTime int64 `json:"start_time" yaml:"start_time"` // when the coins start to vest - VestingPeriods Periods `json:"vesting_periods" yaml:"vesting_periods"` // the vesting schedule - } - - ModuleAccount struct { - *BaseAccount - - Name string `json:"name" yaml:"name"` - Permissions []string `json:"permissions" yaml:"permissions"` - } - - moduleAccountPretty struct { - Address sdk.AccAddress `json:"address" yaml:"address"` - Coins sdk.Coins `json:"coins,omitempty" yaml:"coins"` - PubKey string `json:"public_key" yaml:"public_key"` - AccountNumber uint64 `json:"account_number" yaml:"account_number"` - Sequence uint64 `json:"sequence" yaml:"sequence"` - Name string `json:"name" yaml:"name"` - Permissions []string `json:"permissions" yaml:"permissions"` - } -) - -func NewGenesisState(params v034auth.Params, accounts v038auth.GenesisAccounts) GenesisState { - return GenesisState{ - Params: params, - Accounts: accounts, - } -} - -func NewBaseAccountWithAddress(addr sdk.AccAddress) BaseAccount { - return BaseAccount{ - Address: addr, - } -} - -func NewBaseAccount( - address sdk.AccAddress, coins sdk.Coins, pk cryptotypes.PubKey, accountNumber, sequence uint64, -) *BaseAccount { - - return &BaseAccount{ - Address: address, - Coins: coins, - PubKey: pk, - AccountNumber: accountNumber, - Sequence: sequence, - } -} - -func (acc BaseAccount) GetAddress() sdk.AccAddress { - return acc.Address -} - -func (acc *BaseAccount) GetAccountNumber() uint64 { - return acc.AccountNumber -} - -func (acc *BaseAccount) GetCoins() sdk.Coins { - return acc.Coins -} - -func (acc *BaseAccount) SetCoins(coins sdk.Coins) error { - acc.Coins = coins - return nil -} - -func (acc BaseAccount) Validate() error { - if acc.PubKey != nil && acc.Address != nil && - !bytes.Equal(acc.PubKey.Address().Bytes(), acc.Address.Bytes()) { - return errors.New("pubkey and address pair is invalid") - } - - return nil -} - -func NewBaseVestingAccount( - baseAccount *BaseAccount, originalVesting, delegatedFree, delegatedVesting sdk.Coins, endTime int64, -) *BaseVestingAccount { - - return &BaseVestingAccount{ - BaseAccount: baseAccount, - OriginalVesting: originalVesting, - DelegatedFree: delegatedFree, - DelegatedVesting: delegatedVesting, - EndTime: endTime, - } -} - -func (bva BaseVestingAccount) MarshalJSON() ([]byte, error) { - alias := vestingAccountJSON{ - Address: bva.Address, - Coins: bva.Coins, - PubKey: bva.PubKey, - AccountNumber: bva.AccountNumber, - Sequence: bva.Sequence, - OriginalVesting: bva.OriginalVesting, - DelegatedFree: bva.DelegatedFree, - DelegatedVesting: bva.DelegatedVesting, - EndTime: bva.EndTime, - } - - return legacy.Cdc.MarshalJSON(alias) -} - -func (bva *BaseVestingAccount) UnmarshalJSON(bz []byte) error { - var alias vestingAccountJSON - if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil { - return err - } - - bva.BaseAccount = NewBaseAccount(alias.Address, alias.Coins, alias.PubKey, alias.AccountNumber, alias.Sequence) - bva.OriginalVesting = alias.OriginalVesting - bva.DelegatedFree = alias.DelegatedFree - bva.DelegatedVesting = alias.DelegatedVesting - bva.EndTime = alias.EndTime - - return nil -} - -func (bva BaseVestingAccount) GetEndTime() int64 { - return bva.EndTime -} - -func (bva BaseVestingAccount) Validate() error { - return bva.BaseAccount.Validate() -} - -func NewContinuousVestingAccountRaw(bva *BaseVestingAccount, startTime int64) *ContinuousVestingAccount { - return &ContinuousVestingAccount{ - BaseVestingAccount: bva, - StartTime: startTime, - } -} - -func (cva ContinuousVestingAccount) Validate() error { - if cva.StartTime >= cva.EndTime { - return errors.New("vesting start-time cannot be before end-time") - } - - return cva.BaseVestingAccount.Validate() -} - -func (cva ContinuousVestingAccount) MarshalJSON() ([]byte, error) { - alias := vestingAccountJSON{ - Address: cva.Address, - Coins: cva.Coins, - PubKey: cva.PubKey, - AccountNumber: cva.AccountNumber, - Sequence: cva.Sequence, - OriginalVesting: cva.OriginalVesting, - DelegatedFree: cva.DelegatedFree, - DelegatedVesting: cva.DelegatedVesting, - EndTime: cva.EndTime, - StartTime: cva.StartTime, - } - - return legacy.Cdc.MarshalJSON(alias) -} - -func (cva *ContinuousVestingAccount) UnmarshalJSON(bz []byte) error { - var alias vestingAccountJSON - if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil { - return err - } - - cva.BaseVestingAccount = &BaseVestingAccount{ - BaseAccount: NewBaseAccount(alias.Address, alias.Coins, alias.PubKey, alias.AccountNumber, alias.Sequence), - OriginalVesting: alias.OriginalVesting, - DelegatedFree: alias.DelegatedFree, - DelegatedVesting: alias.DelegatedVesting, - EndTime: alias.EndTime, - } - cva.StartTime = alias.StartTime - - return nil -} - -func NewDelayedVestingAccountRaw(bva *BaseVestingAccount) *DelayedVestingAccount { - return &DelayedVestingAccount{ - BaseVestingAccount: bva, - } -} - -func (dva DelayedVestingAccount) Validate() error { - return dva.BaseVestingAccount.Validate() -} - -func (dva DelayedVestingAccount) MarshalJSON() ([]byte, error) { - alias := vestingAccountJSON{ - Address: dva.Address, - Coins: dva.Coins, - PubKey: dva.PubKey, - AccountNumber: dva.AccountNumber, - Sequence: dva.Sequence, - OriginalVesting: dva.OriginalVesting, - DelegatedFree: dva.DelegatedFree, - DelegatedVesting: dva.DelegatedVesting, - EndTime: dva.EndTime, - } - - return legacy.Cdc.MarshalJSON(alias) -} - -// UnmarshalJSON unmarshals raw JSON bytes into a DelayedVestingAccount. -func (dva *DelayedVestingAccount) UnmarshalJSON(bz []byte) error { - var alias vestingAccountJSON - if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil { - return err - } - - dva.BaseVestingAccount = &BaseVestingAccount{ - BaseAccount: NewBaseAccount(alias.Address, alias.Coins, alias.PubKey, alias.AccountNumber, alias.Sequence), - OriginalVesting: alias.OriginalVesting, - DelegatedFree: alias.DelegatedFree, - DelegatedVesting: alias.DelegatedVesting, - EndTime: alias.EndTime, - } - - return nil -} - -func (pva PeriodicVestingAccount) GetStartTime() int64 { - return pva.StartTime -} - -func (pva PeriodicVestingAccount) Validate() error { - if pva.GetStartTime() >= pva.GetEndTime() { - return errors.New("vesting start-time cannot be before end-time") - } - endTime := pva.StartTime - originalVesting := sdk.NewCoins() - for _, p := range pva.VestingPeriods { - endTime += p.Length - originalVesting = originalVesting.Add(p.Amount...) - } - if endTime != pva.EndTime { - return errors.New("vesting end time does not match length of all vesting periods") - } - if !originalVesting.IsEqual(pva.OriginalVesting) { - return errors.New("original vesting coins does not match the sum of all coins in vesting periods") - } - - return pva.BaseVestingAccount.Validate() -} - -func (pva PeriodicVestingAccount) MarshalJSON() ([]byte, error) { - alias := vestingAccountJSON{ - Address: pva.Address, - Coins: pva.Coins, - PubKey: pva.PubKey, - AccountNumber: pva.AccountNumber, - Sequence: pva.Sequence, - OriginalVesting: pva.OriginalVesting, - DelegatedFree: pva.DelegatedFree, - DelegatedVesting: pva.DelegatedVesting, - EndTime: pva.EndTime, - StartTime: pva.StartTime, - VestingPeriods: pva.VestingPeriods, - } - - return legacy.Cdc.MarshalJSON(alias) -} - -// UnmarshalJSON unmarshals raw JSON bytes into a PeriodicVestingAccount. -func (pva *PeriodicVestingAccount) UnmarshalJSON(bz []byte) error { - var alias vestingAccountJSON - if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil { - return err - } - - pva.BaseVestingAccount = &BaseVestingAccount{ - BaseAccount: NewBaseAccount(alias.Address, alias.Coins, alias.PubKey, alias.AccountNumber, alias.Sequence), - OriginalVesting: alias.OriginalVesting, - DelegatedFree: alias.DelegatedFree, - DelegatedVesting: alias.DelegatedVesting, - EndTime: alias.EndTime, - } - pva.StartTime = alias.StartTime - pva.VestingPeriods = alias.VestingPeriods - - return nil -} - -func NewModuleAccount(baseAccount *BaseAccount, name string, permissions ...string) *ModuleAccount { - return &ModuleAccount{ - BaseAccount: baseAccount, - Name: name, - Permissions: permissions, - } -} - -func (ma ModuleAccount) Validate() error { - if err := v038auth.ValidatePermissions(ma.Permissions...); err != nil { - return err - } - - if strings.TrimSpace(ma.Name) == "" { - return errors.New("module account name cannot be blank") - } - - if x := sdk.AccAddress(tmcrypto.AddressHash([]byte(ma.Name))); !ma.Address.Equals(x) { - return fmt.Errorf("address %s cannot be derived from the module name '%s'; expected: %s", ma.Address, ma.Name, x) - } - - return ma.BaseAccount.Validate() -} - -// MarshalJSON returns the JSON representation of a ModuleAccount. -func (ma ModuleAccount) MarshalJSON() ([]byte, error) { - return legacy.Cdc.MarshalJSON(moduleAccountPretty{ - Address: ma.Address, - Coins: ma.Coins, - PubKey: "", - AccountNumber: ma.AccountNumber, - Sequence: ma.Sequence, - Name: ma.Name, - Permissions: ma.Permissions, - }) -} - -// UnmarshalJSON unmarshals raw JSON bytes into a ModuleAccount. -func (ma *ModuleAccount) UnmarshalJSON(bz []byte) error { - var alias moduleAccountPretty - if err := legacy.Cdc.UnmarshalJSON(bz, &alias); err != nil { - return err - } - - ma.BaseAccount = NewBaseAccount(alias.Address, alias.Coins, nil, alias.AccountNumber, alias.Sequence) - ma.Name = alias.Name - ma.Permissions = alias.Permissions - - return nil -} - -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cryptocodec.RegisterCrypto(cdc) - cdc.RegisterInterface((*v038auth.GenesisAccount)(nil), nil) - cdc.RegisterInterface((*v038auth.Account)(nil), nil) - cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/Account", nil) - cdc.RegisterConcrete(&BaseVestingAccount{}, "cosmos-sdk/BaseVestingAccount", nil) - cdc.RegisterConcrete(&ContinuousVestingAccount{}, "cosmos-sdk/ContinuousVestingAccount", nil) - cdc.RegisterConcrete(&DelayedVestingAccount{}, "cosmos-sdk/DelayedVestingAccount", nil) - cdc.RegisterConcrete(&PeriodicVestingAccount{}, "cosmos-sdk/PeriodicVestingAccount", nil) - cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil) -} diff --git a/x/auth/migrations/v040/migrate.go b/x/auth/migrations/v040/migrate.go deleted file mode 100644 index 3c46f5b9acde..000000000000 --- a/x/auth/migrations/v040/migrate.go +++ /dev/null @@ -1,125 +0,0 @@ -package v040 - -import ( - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - v039auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v039" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/types" - v040vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" -) - -// convertBaseAccount converts a 0.39 BaseAccount to a 0.40 BaseAccount. -func convertBaseAccount(old *v039auth.BaseAccount) *v040auth.BaseAccount { - var any *codectypes.Any - - if old.PubKey != nil { - var err error - any, err = codectypes.NewAnyWithValue(old.PubKey) - if err != nil { - panic(err) - } - } - - return &v040auth.BaseAccount{ - Address: old.Address.String(), - PubKey: any, - AccountNumber: old.AccountNumber, - Sequence: old.Sequence, - } -} - -// convertBaseVestingAccount converts a 0.39 BaseVestingAccount to a 0.40 BaseVestingAccount. -func convertBaseVestingAccount(old *v039auth.BaseVestingAccount) *v040vesting.BaseVestingAccount { - baseAccount := convertBaseAccount(old.BaseAccount) - - return &v040vesting.BaseVestingAccount{ - BaseAccount: baseAccount, - OriginalVesting: old.OriginalVesting, - DelegatedFree: old.DelegatedFree, - DelegatedVesting: old.DelegatedVesting, - EndTime: old.EndTime, - } -} - -// Migrate accepts exported x/auth genesis state from v0.38/v0.39 and migrates -// it to v0.40 x/auth genesis state. The migration includes: -// -// - Removing coins from account encoding. -// - Re-encode in v0.40 GenesisState. -func Migrate(authGenState v039auth.GenesisState) *v040auth.GenesisState { - // Convert v0.39 accounts to v0.40 ones. - var v040Accounts = make([]v040auth.GenesisAccount, len(authGenState.Accounts)) - for i, v039Account := range authGenState.Accounts { - switch v039Account := v039Account.(type) { - case *v039auth.BaseAccount: - { - v040Accounts[i] = convertBaseAccount(v039Account) - } - case *v039auth.ModuleAccount: - { - v040Accounts[i] = &v040auth.ModuleAccount{ - BaseAccount: convertBaseAccount(v039Account.BaseAccount), - Name: v039Account.Name, - Permissions: v039Account.Permissions, - } - } - case *v039auth.BaseVestingAccount: - { - v040Accounts[i] = convertBaseVestingAccount(v039Account) - } - case *v039auth.ContinuousVestingAccount: - { - v040Accounts[i] = &v040vesting.ContinuousVestingAccount{ - BaseVestingAccount: convertBaseVestingAccount(v039Account.BaseVestingAccount), - StartTime: v039Account.StartTime, - } - } - case *v039auth.DelayedVestingAccount: - { - v040Accounts[i] = &v040vesting.DelayedVestingAccount{ - BaseVestingAccount: convertBaseVestingAccount(v039Account.BaseVestingAccount), - } - } - case *v039auth.PeriodicVestingAccount: - { - vestingPeriods := make([]v040vesting.Period, len(v039Account.VestingPeriods)) - for j, period := range v039Account.VestingPeriods { - vestingPeriods[j] = v040vesting.Period{ - Length: period.Length, - Amount: period.Amount, - } - } - v040Accounts[i] = &v040vesting.PeriodicVestingAccount{ - BaseVestingAccount: convertBaseVestingAccount(v039Account.BaseVestingAccount), - StartTime: v039Account.StartTime, - VestingPeriods: vestingPeriods, - } - } - default: - panic(sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "got invalid type %T", v039Account)) - } - - } - - // Convert v0.40 accounts into Anys. - anys := make([]*codectypes.Any, len(v040Accounts)) - for i, v040Account := range v040Accounts { - any, err := codectypes.NewAnyWithValue(v040Account) - if err != nil { - panic(err) - } - - anys[i] = any - } - - return &v040auth.GenesisState{ - Params: v040auth.Params{ - MaxMemoCharacters: authGenState.Params.MaxMemoCharacters, - TxSigLimit: authGenState.Params.TxSigLimit, - TxSizeCostPerByte: authGenState.Params.TxSizeCostPerByte, - SigVerifyCostED25519: authGenState.Params.SigVerifyCostED25519, - SigVerifyCostSecp256k1: authGenState.Params.SigVerifyCostSecp256k1, - }, - Accounts: anys, - } -} diff --git a/x/auth/migrations/v040/migrate_test.go b/x/auth/migrations/v040/migrate_test.go deleted file mode 100644 index cc9bb532193a..000000000000 --- a/x/auth/migrations/v040/migrate_test.go +++ /dev/null @@ -1,255 +0,0 @@ -package v040_test - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" - v034 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v034" - v038auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v038" - v039auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v039" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" -) - -func TestMigrate(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() - clientCtx := client.Context{}. - WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithTxConfig(encodingConfig.TxConfig). - WithLegacyAmino(encodingConfig.Amino). - WithCodec(encodingConfig.Codec) - - coins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) - - // BaseAccount - pk1 := secp256k1.GenPrivKeyFromSecret([]byte("acc1")).PubKey() - acc1 := v039auth.NewBaseAccount(sdk.AccAddress(pk1.Address()), coins, pk1, 1, 0) - - // ModuleAccount - pk2 := secp256k1.GenPrivKeyFromSecret([]byte("acc2")).PubKey() - acc2 := v039auth.NewModuleAccount( - v039auth.NewBaseAccount(sdk.AccAddress(pk2.Address()), coins, pk2, 1, 0), - "module2", - "permission2", - ) - - // BaseVestingAccount - pk3 := secp256k1.GenPrivKeyFromSecret([]byte("acc3")).PubKey() - acc3 := v039auth.NewBaseVestingAccount( - v039auth.NewBaseAccount(sdk.AccAddress(pk3.Address()), coins, pk3, 1, 0), - coins, coins, coins, - 1580309973, - ) - - // ContinuousVestingAccount - pk4 := secp256k1.GenPrivKeyFromSecret([]byte("acc4")).PubKey() - acc4 := v039auth.NewContinuousVestingAccountRaw( - v039auth.NewBaseVestingAccount(v039auth.NewBaseAccount(sdk.AccAddress(pk4.Address()), coins, pk4, 1, 0), coins, nil, nil, 3160620846), - 1580309974, - ) - - // PeriodicVestingAccount - pk5 := secp256k1.GenPrivKeyFromSecret([]byte("acc5")).PubKey() - acc5 := &v039auth.PeriodicVestingAccount{ - BaseVestingAccount: v039auth.NewBaseVestingAccount(v039auth.NewBaseAccount(sdk.AccAddress(pk5.Address()), coins, pk5, 1, 0), coins, nil, nil, 3160620846), - StartTime: 1580309975, - VestingPeriods: v039auth.Periods{v039auth.Period{Length: 32, Amount: coins}}, - } - - // DelayedVestingAccount - pk6 := secp256k1.GenPrivKeyFromSecret([]byte("acc6")).PubKey() - acc6 := &v039auth.DelayedVestingAccount{ - BaseVestingAccount: v039auth.NewBaseVestingAccount(v039auth.NewBaseAccount(sdk.AccAddress(pk6.Address()), coins, pk6, 1, 0), coins, nil, nil, 3160620846), - } - - // BaseAccount with nil pubkey (coming from older genesis). - pk7 := secp256k1.GenPrivKeyFromSecret([]byte("acc7")).PubKey() - acc7 := v039auth.NewBaseAccount(sdk.AccAddress(pk7.Address()), coins, nil, 1, 0) - - gs := v039auth.GenesisState{ - Params: v034.Params{ - MaxMemoCharacters: 10, - TxSigLimit: 20, - TxSizeCostPerByte: 30, - SigVerifyCostED25519: 40, - SigVerifyCostSecp256k1: 50, - }, - Accounts: v038auth.GenesisAccounts{acc1, acc2, acc3, acc4, acc5, acc6, acc7}, - } - - migrated := v040auth.Migrate(gs) - expected := `{ - "accounts": [ - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "1", - "address": "cosmos13syh7de9xndv9wmklccpfvc0d8dcyvay4s6z6l", - "pub_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A8oWyJkohwy8XZ0Df92jFMBTtTPMvYJplYIrlEHTKPYk" - }, - "sequence": "0" - }, - { - "@type": "/cosmos.auth.v1beta1.ModuleAccount", - "base_account": { - "account_number": "1", - "address": "cosmos1v57fx2l2rt6ehujuu99u2fw05779m5e2ux4z2h", - "pub_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "AruDygh5HprMOpHOEato85dLgAsybMJVyxBGUa3KuWCr" - }, - "sequence": "0" - }, - "name": "module2", - "permissions": [ - "permission2" - ] - }, - { - "@type": "/cosmos.vesting.v1beta1.BaseVestingAccount", - "base_account": { - "account_number": "1", - "address": "cosmos18hnp9fjflrkeeqn4gmhjhzljusxzmjeartdckw", - "pub_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A5aEFDIdQHh0OYmNXNv1sHBNURDWWgVkXC2IALcWLLwJ" - }, - "sequence": "0" - }, - "delegated_free": [ - { - "amount": "50", - "denom": "stake" - } - ], - "delegated_vesting": [ - { - "amount": "50", - "denom": "stake" - } - ], - "end_time": "1580309973", - "original_vesting": [ - { - "amount": "50", - "denom": "stake" - } - ] - }, - { - "@type": "/cosmos.vesting.v1beta1.ContinuousVestingAccount", - "base_vesting_account": { - "base_account": { - "account_number": "1", - "address": "cosmos1t9kvvejvk6hjtddx6antck39s206csqduq3ke3", - "pub_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "AoXDzxwTnljemHxfnJcwrKqODBP6Q2l3K3U3UhVDzyah" - }, - "sequence": "0" - }, - "delegated_free": [], - "delegated_vesting": [], - "end_time": "3160620846", - "original_vesting": [ - { - "amount": "50", - "denom": "stake" - } - ] - }, - "start_time": "1580309974" - }, - { - "@type": "/cosmos.vesting.v1beta1.PeriodicVestingAccount", - "base_vesting_account": { - "base_account": { - "account_number": "1", - "address": "cosmos1s4ss9zquz7skvguechzlk3na635jdrecl0sgy2", - "pub_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A2a4P4TQ1OKzpfu0eKnCoEtmTvoiclSx0G9higenUGws" - }, - "sequence": "0" - }, - "delegated_free": [], - "delegated_vesting": [], - "end_time": "3160620846", - "original_vesting": [ - { - "amount": "50", - "denom": "stake" - } - ] - }, - "start_time": "1580309975", - "vesting_periods": [ - { - "amount": [ - { - "amount": "50", - "denom": "stake" - } - ], - "length": "32" - } - ] - }, - { - "@type": "/cosmos.vesting.v1beta1.DelayedVestingAccount", - "base_vesting_account": { - "base_account": { - "account_number": "1", - "address": "cosmos1mcc6rwrj4hswf8p9ct82c7lmf77w9tuk07rha4", - "pub_key": { - "@type": "/cosmos.crypto.secp256k1.PubKey", - "key": "A4tuAfmZlhjK5cjp6ImR704miybHnITVNOyJORdDPFu3" - }, - "sequence": "0" - }, - "delegated_free": [], - "delegated_vesting": [], - "end_time": "3160620846", - "original_vesting": [ - { - "amount": "50", - "denom": "stake" - } - ] - } - }, - { - "@type": "/cosmos.auth.v1beta1.BaseAccount", - "account_number": "1", - "address": "cosmos16ydaqh0fcnh4qt7a3jme4mmztm2qel5axcpw00", - "pub_key": null, - "sequence": "0" - } - ], - "params": { - "max_memo_characters": "10", - "sig_verify_cost_ed25519": "40", - "sig_verify_cost_secp256k1": "50", - "tx_sig_limit": "20", - "tx_size_cost_per_byte": "30" - } -}` - - bz, err := clientCtx.Codec.MarshalJSON(migrated) - require.NoError(t, err) - - // Indent the JSON bz correctly. - var jsonObj map[string]interface{} - err = json.Unmarshal(bz, &jsonObj) - require.NoError(t, err) - indentedBz, err := json.MarshalIndent(jsonObj, "", " ") - require.NoError(t, err) - - require.Equal(t, expected, string(indentedBz)) -} diff --git a/x/auth/migrations/v040/store.go b/x/auth/migrations/v040/store.go deleted file mode 100644 index 9fb81b60a749..000000000000 --- a/x/auth/migrations/v040/store.go +++ /dev/null @@ -1,4 +0,0 @@ -package v040 - -// AddrLen defines a valid address length -const AddrLen = 20 diff --git a/x/auth/migrations/v040/types.go b/x/auth/migrations/v042/types.go similarity index 51% rename from x/auth/migrations/v040/types.go rename to x/auth/migrations/v042/types.go index 1e1f3eee9791..ecc3dc7b3c6c 100644 --- a/x/auth/migrations/v040/types.go +++ b/x/auth/migrations/v042/types.go @@ -1,5 +1,6 @@ -package v040 +package v042 const ( ModuleName = "auth" + AddrLen = 20 ) diff --git a/x/auth/migrations/v043/store.go b/x/auth/migrations/v043/store.go index f95f1b3a1bb7..a097d0ef0400 100644 --- a/x/auth/migrations/v043/store.go +++ b/x/auth/migrations/v043/store.go @@ -48,7 +48,6 @@ const ( // PLEASE DO NOT REPLICATE THIS PATTERN IN YOUR OWN APP. func migrateVestingAccounts(ctx sdk.Context, account types.AccountI, queryServer grpc.Server) (types.AccountI, error) { bondDenom, err := getBondDenom(ctx, queryServer) - if err != nil { return nil, err } @@ -64,7 +63,6 @@ func migrateVestingAccounts(ctx sdk.Context, account types.AccountI, queryServer addr, queryServer, ) - if err != nil { return nil, err } @@ -74,7 +72,6 @@ func migrateVestingAccounts(ctx sdk.Context, account types.AccountI, queryServer addr, queryServer, ) - if err != nil { return nil, err } @@ -85,7 +82,6 @@ func migrateVestingAccounts(ctx sdk.Context, account types.AccountI, queryServer bondDenom, queryServer, ) - if err != nil { return nil, err } diff --git a/x/auth/migrations/v043/store_test.go b/x/auth/migrations/v043/store_test.go index cae87b96885c..df7902c191bd 100644 --- a/x/auth/migrations/v043/store_test.go +++ b/x/auth/migrations/v043/store_test.go @@ -32,7 +32,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "delayed vesting has vested, multiple delegations less than the total account balance", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) @@ -57,7 +56,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "delayed vesting has vested, single delegations which exceed the vested amount", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) @@ -78,7 +76,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "delayed vesting has vested, multiple delegations which exceed the vested amount", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) @@ -103,7 +100,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "delayed vesting has not vested, single delegations which exceed the vested amount", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) @@ -122,7 +118,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "delayed vesting has not vested, multiple delegations which exceed the vested amount", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(200))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().AddDate(1, 0, 0).Unix()) @@ -185,7 +180,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "delayed vesting has vested, single delegation greater than the total account balance", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(300))) delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix()) @@ -206,7 +200,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "continuous vesting, start time after blocktime", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - startTime := ctx.BlockTime().AddDate(1, 0, 0).Unix() endTime := ctx.BlockTime().AddDate(2, 0, 0).Unix() baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) @@ -229,7 +222,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "continuous vesting, start time passed but not ended", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - startTime := ctx.BlockTime().AddDate(-1, 0, 0).Unix() endTime := ctx.BlockTime().AddDate(2, 0, 0).Unix() baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) @@ -252,7 +244,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "continuous vesting, start time and endtime passed", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - startTime := ctx.BlockTime().AddDate(-2, 0, 0).Unix() endTime := ctx.BlockTime().AddDate(-1, 0, 0).Unix() baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) @@ -275,7 +266,6 @@ func TestMigrateVestingAccounts(t *testing.T) { { "periodic vesting account, yet to be vested, some rewards delegated", func(app *simapp.SimApp, ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) { - baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr) vestedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), sdk.NewInt(100))) @@ -597,7 +587,6 @@ func TestMigrateVestingAccounts(t *testing.T) { ) }) } - } func trackingCorrected(ctx sdk.Context, t *testing.T, ak authkeeper.AccountKeeper, addr sdk.AccAddress, expDelVesting sdk.Coins, expDelFree sdk.Coins) { diff --git a/x/auth/module.go b/x/auth/module.go index dfb125058bd9..e1b7ceec2a7c 100644 --- a/x/auth/module.go +++ b/x/auth/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -59,11 +58,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the auth module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/auth` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the auth module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { @@ -142,14 +136,14 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - InitGenesis(ctx, am.accountKeeper, genesisState) + am.accountKeeper.InitGenesis(ctx, genesisState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the auth // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - gs := ExportGenesis(ctx, am.accountKeeper) + gs := am.accountKeeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(gs) } diff --git a/x/auth/posthandler/post.go b/x/auth/posthandler/post.go new file mode 100644 index 000000000000..604b1203c4e4 --- /dev/null +++ b/x/auth/posthandler/post.go @@ -0,0 +1,27 @@ +package posthandler + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// HandlerOptions are the options required for constructing a default SDK PostHandler. +type HandlerOptions struct { + BankKeeper types.BankKeeper +} + +// NewAnteHandler returns an AnteHandler that checks and increments sequence +// numbers, checks signatures & account numbers, and deducts fees from the first +// signer. +func NewPostHandler(options HandlerOptions) (sdk.AnteHandler, error) { + if options.BankKeeper == nil { + return nil, sdkerrors.Wrap(sdkerrors.ErrLogic, "bank keeper is required for posthandler") + } + + postDecorators := []sdk.AnteDecorator{ + NewTipDecorator(options.BankKeeper), + } + + return sdk.ChainAnteDecorators(postDecorators...), nil +} diff --git a/x/auth/posthandler/tips.go b/x/auth/posthandler/tips.go new file mode 100644 index 000000000000..a112a3e1c4a2 --- /dev/null +++ b/x/auth/posthandler/tips.go @@ -0,0 +1,49 @@ +package posthandler + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// ValidateBasicDecorator will call tx.ValidateBasic and return any non-nil error. +// If ValidateBasic passes, decorator calls next AnteHandler in chain. Note, +// ValidateBasicDecorator decorator will not get executed on ReCheckTx since it +// is not dependent on application state. +type tipDecorator struct { + bankKeeper types.BankKeeper +} + +// NewTipDecorator returns a new decorator for handling transactions with +// tips. +func NewTipDecorator(bankKeeper types.BankKeeper) sdk.AnteDecorator { + return tipDecorator{ + bankKeeper: bankKeeper, + } +} + +func (d tipDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + err := d.transferTip(ctx, tx) + if err != nil { + return ctx, err + } + + return next(ctx, tx, simulate) +} + +// transferTip transfers the tip from the tipper to the fee payer. +func (d tipDecorator) transferTip(ctx sdk.Context, sdkTx sdk.Tx) error { + tipTx, ok := sdkTx.(tx.TipTx) + + // No-op if the tx doesn't have tips. + if !ok || tipTx.GetTip() == nil { + return nil + } + + tipper, err := sdk.AccAddressFromBech32(tipTx.GetTip().Tipper) + if err != nil { + return err + } + + return d.bankKeeper.SendCoins(ctx, tipper, tipTx.FeePayer(), tipTx.GetTip().Amount) +} diff --git a/x/auth/signing/sign_mode_handler.go b/x/auth/signing/sign_mode_handler.go index 57d201dbdedd..d4faff3d05cf 100644 --- a/x/auth/signing/sign_mode_handler.go +++ b/x/auth/signing/sign_mode_handler.go @@ -42,7 +42,7 @@ type SignerData struct { // since in SIGN_MODE_DIRECT the account sequence is already in the signer // info. // - // In case of multisigs, this should be the multisig account number. + // In case of multisigs, this should be the multisig sequence. Sequence uint64 // PubKey is the public key of the signer. diff --git a/x/auth/signing/verify_test.go b/x/auth/signing/verify_test.go index 3d138e1f7742..db91bc15e06d 100644 --- a/x/auth/signing/verify_test.go +++ b/x/auth/signing/verify_test.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" + "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -42,7 +42,7 @@ func TestVerifySignature(t *testing.T) { app.AccountKeeper.SetAccount(ctx, acc1) balances := sdk.NewCoins(sdk.NewInt64Coin("atom", 200)) require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr, balances)) - acc, err := middleware.GetSignerAcc(ctx, app.AccountKeeper, addr) + acc, err := ante.GetSignerAcc(ctx, app.AccountKeeper, addr) require.NoError(t, err) require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, addr, balances)) diff --git a/x/auth/simulation/genesis.go b/x/auth/simulation/genesis.go index 2da36b54fa82..4b31bf7d49e0 100644 --- a/x/auth/simulation/genesis.go +++ b/x/auth/simulation/genesis.go @@ -35,7 +35,7 @@ func RandomGenesisAccounts(simState *module.SimulationState) types.GenesisAccoun continue } - initialVesting := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, simState.Rand.Int63n(simState.InitialStake))) + initialVesting := sdk.NewCoins(sdk.NewInt64Coin(sdk.DefaultBondDenom, simState.Rand.Int63n(simState.InitialStake.Int64()))) var endTime int64 startTime := simState.GenTimestamp.Unix() diff --git a/x/auth/simulation/genesis_test.go b/x/auth/simulation/genesis_test.go index 830a264ff4c6..4b8f48ef76b0 100644 --- a/x/auth/simulation/genesis_test.go +++ b/x/auth/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -31,7 +32,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/auth/spec/03_antehandlers.md b/x/auth/spec/03_antehandlers.md deleted file mode 100644 index b695d8597dc5..000000000000 --- a/x/auth/spec/03_antehandlers.md +++ /dev/null @@ -1,40 +0,0 @@ - - -# AnteHandlers - -The `x/auth` module presently has no transaction handlers of its own, but does expose the special `AnteHandler`, used for performing basic validity checks on a transaction, such that it could be thrown out of the mempool. -The `AnteHandler` can be seen as a set of decorators that check transactions within the current context, per [ADR 010](https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-alpha1/docs/architecture/adr-010-modular-antehandler.md). - -Note that the `AnteHandler` is called on both `CheckTx` and `DeliverTx`, as Tendermint proposers presently have the ability to include in their proposed block transactions which fail `CheckTx`. - -## Decorators - -The auth module provides `AnteDecorator`s that are recursively chained together into a single `AnteHandler` in the following order: - -* `SetUpContextDecorator`: Sets the `GasMeter` in the `Context` and wraps the next `AnteHandler` with a defer clause to recover from any downstream `OutOfGas` panics in the `AnteHandler` chain to return an error with information on gas provided and gas used. - -* `RejectExtensionOptionsDecorator`: Rejects all extension options which can optionally be included in protobuf transactions. - -* `MempoolFeeDecorator`: Checks if the `tx` fee is above local mempool `minFee` parameter during `CheckTx`. - -* `ValidateBasicDecorator`: Calls `tx.ValidateBasic` and returns any non-nil error. - -* `TxTimeoutHeightDecorator`: Check for a `tx` height timeout. - -* `ValidateMemoDecorator`: Validates `tx` memo with application parameters and returns any non-nil error. - -* `ConsumeGasTxSizeDecorator`: Consumes gas proportional to the `tx` size based on application parameters. - -* `DeductFeeDecorator`: Deducts the `FeeAmount` from first signer of the `tx`. If the `x/feegrant` module is enabled and a fee granter is set, it deducts fees from the fee granter account. - -* `SetPubKeyDecorator`: Sets the pubkey from a `tx`'s signers that does not already have its corresponding pubkey saved in the state machine and in the current context. - -* `ValidateSigCountDecorator`: Validates the number of signatures in `tx` based on app-parameters. - -* `SigGasConsumeDecorator`: Consumes parameter-defined amount of gas for each signature. This requires pubkeys to be set in context for all signers as part of `SetPubKeyDecorator`. - -* `SigVerificationDecorator`: Verifies all signatures are valid. This requires pubkeys to be set in context for all signers as part of `SetPubKeyDecorator`. - -* `IncrementSequenceDecorator`: Increments the account sequence for each signer to prevent replay attacks. diff --git a/x/auth/spec/03_middlewares.md b/x/auth/spec/03_middlewares.md new file mode 100644 index 000000000000..3686430bdf6f --- /dev/null +++ b/x/auth/spec/03_middlewares.md @@ -0,0 +1,38 @@ + + +# Middlewares + +The `x/auth` module presently has no transaction handlers of its own, but does expose middlewares directly called from BaseApp's `CheckTx` and `DeliverTx`, which can be used for performing any operations on transactions, such as basic validity checks on a transaction such that it could be thrown out of the mempool, or routing the transactions to their `Msg` service to perform state transitions. +The middlewares can be seen as a set of decorators wrapped one on top of the other, that check transactions within the current context, per [ADR-045](https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/docs/architecture/adr-045-check-delivertx-middlewares.md). + +Note that the middlewares are called on both `CheckTx` and `DeliverTx`, as Tendermint proposers presently have the ability to include in their proposed block transactions which fail `CheckTx`. + +## List of Middleware + +The auth module provides: + +* one `tx.Handler`, called `RunMsgsTxHandler`, which routes each `sdk.Msg` from a transaction to the correct module `Msg` service, and runs each `sdk.Msg` to perform state transitions, +* a set of middlewares that are recursively chained together around the base `tx.Handler` in the following order (the first middleware's `pre`-hook is run first, and `post`-hook is run last): + + * `NewTxDecoderMiddleware`: Decodes the transaction bytes from ABCI `CheckTx` and `DeliverTx` into the SDK transaction type. This middleware is generally called first, as most middlewares logic rely on a decoded SDK transaction. + * `GasTxMiddleware`: Sets the `GasMeter` in the `Context`. + * `RecoveryTxMiddleware`: Wraps the next middleware with a defer clause to recover from any downstream panics in the middleware chain to return an error with information on gas provided and gas used. + * `RejectExtensionOptionsMiddleware`: Rejects all extension options which can optionally be included in protobuf transactions. + * `IndexEventsTxMiddleware`: Choose which events to index in Tendermint. Make sure no events are emitted outside of this middleware. + * `ValidateBasicMiddleware`: Calls `tx.ValidateBasic` and returns any non-nil error. + * `TxTimeoutHeightMiddleware`: Check for a `tx` height timeout. + * `ValidateMemoMiddleware`: Validates `tx` memo with application parameters and returns any non-nil error. + * `ConsumeGasTxSizeMiddleware`: Consumes gas proportional to the `tx` size based on application parameters. + * `DeductFeeMiddleware`: Deducts the `FeeAmount` from first signer of the `tx`. If the `x/feegrant` module is enabled and a fee granter is set, it deducts fees from the fee granter account. + * `SetPubKeyMiddleware`: Sets the pubkey from a `tx`'s signers that does not already have its corresponding pubkey saved in the state machine and in the current context. + * `ValidateSigCountMiddleware`: Validates the number of signatures in the `tx` based on app-parameters. + * `SigGasConsumeMiddleware`: Consumes parameter-defined amount of gas for each signature. This requires pubkeys to be set in context for all signers as part of `SetPubKeyMiddleware`. + * `SigVerificationMiddleware`: Verifies all signatures are valid. This requires pubkeys to be set in context for all signers as part of `SetPubKeyMiddleware`. + * `IncrementSequenceMiddleware`: Increments the account sequence for each signer to prevent replay attacks. + * `WithBranchedStore`: Creates a new MultiStore branch, discards downstream writes if the downstream returns error. + * `ConsumeBlockGasMiddleware`: Consume block gas. + * `TipMiddleware`: Transfer tips to the fee payer in transactions with tips. + +This default list of middlewares can be instantiated using the `NewDefaultTxHandler` function. If a chain wants to tweak the list of middlewares, they can create their own `NewTxHandler` function using the same template as `NewDefaultTxHandler`, and chain new middlewares in the `ComposeMiddleware` function. diff --git a/x/auth/spec/README.md b/x/auth/spec/README.md index 789c376e96fd..81d8ccd1c99b 100644 --- a/x/auth/spec/README.md +++ b/x/auth/spec/README.md @@ -13,7 +13,7 @@ This document specifies the auth module of the Cosmos SDK. The auth module is responsible for specifying the base transaction and account types for an application, since the SDK itself is agnostic to these particulars. It contains -the ante handler, where all basic transaction validity checks (signatures, nonces, auxiliary fields) +the middlewares, where all basic transaction validity checks (signatures, nonces, auxiliary fields) are performed, and exposes the account keeper, which allows other modules to read, write, and modify accounts. This module is used in the Cosmos Hub. @@ -24,8 +24,7 @@ This module is used in the Cosmos Hub. * [Gas & Fees](01_concepts.md#gas-&-fees) 2. **[State](02_state.md)** * [Accounts](02_state.md#accounts) -3. **[AnteHandlers](03_antehandlers.md)** - * [Handlers](03_antehandlers.md#handlers) +3. **[Middlewares](03_middlewares.md)** 4. **[Keepers](04_keepers.md)** * [Account Keeper](04_keepers.md#account-keeper) 5. **[Vesting](05_vesting.md)** diff --git a/x/auth/testutil/suite.go b/x/auth/testutil/suite.go index d1ef1ba5f7c9..924f2366ca3b 100644 --- a/x/auth/testutil/suite.go +++ b/x/auth/testutil/suite.go @@ -154,9 +154,11 @@ func (s *TxConfigTestSuite) TestTxBuilderSetSignatures() { s.Require().NoError(err) msigData = multisig.NewMultisig(2) multisig.AddSignature(msigData, &signingtypes.SingleSignatureData{ - SignMode: signModeHandler.DefaultMode(), Signature: mSigBz1}, 0) + SignMode: signModeHandler.DefaultMode(), Signature: mSigBz1, + }, 0) multisig.AddSignature(msigData, &signingtypes.SingleSignatureData{ - SignMode: signModeHandler.DefaultMode(), Signature: mSigBz2}, 0) + SignMode: signModeHandler.DefaultMode(), Signature: mSigBz2, + }, 0) // set signature sigData1.Signature = sigBz diff --git a/x/auth/tx/builder.go b/x/auth/tx/builder.go index edcfd630ca82..052da8785ee8 100644 --- a/x/auth/tx/builder.go +++ b/x/auth/tx/builder.go @@ -11,7 +11,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" + "github.com/cosmos/cosmos-sdk/x/auth/ante" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" ) @@ -37,7 +37,7 @@ var ( _ authsigning.Tx = &wrapper{} _ client.TxBuilder = &wrapper{} _ tx.TipTx = &wrapper{} - _ middleware.HasExtensionOptionsTx = &wrapper{} + _ ante.HasExtensionOptionsTx = &wrapper{} _ ExtensionOptionsTxBuilder = &wrapper{} _ tx.TipTx = &wrapper{} ) diff --git a/x/auth/tx/direct_aux.go b/x/auth/tx/direct_aux.go index 475b4e2e3522..636130981377 100644 --- a/x/auth/tx/direct_aux.go +++ b/x/auth/tx/direct_aux.go @@ -30,7 +30,6 @@ func (signModeDirectAuxHandler) Modes() []signingtypes.SignMode { func (signModeDirectAuxHandler) GetSignBytes( mode signingtypes.SignMode, data signing.SignerData, tx sdk.Tx, ) ([]byte, error) { - if mode != signingtypes.SignMode_SIGN_MODE_DIRECT_AUX { return nil, fmt.Errorf("expected %s, got %s", signingtypes.SignMode_SIGN_MODE_DIRECT_AUX, mode) } diff --git a/x/auth/tx/encode_decode_test.go b/x/auth/tx/encode_decode_test.go index 5991f6653450..db6c3d995ed9 100644 --- a/x/auth/tx/encode_decode_test.go +++ b/x/auth/tx/encode_decode_test.go @@ -198,7 +198,7 @@ func TestRejectNonADR027(t *testing.T) { // bodyBz's length prefix is 5, with `5` as varint encoding. We also try a // longer varint encoding for 5: `133 00`. - longVarintBodyBz := append(append([]byte{bodyBz[0]}, byte(133), byte(00)), bodyBz[2:]...) + longVarintBodyBz := append(append([]byte{bodyBz[0]}, byte(133), byte(0o0)), bodyBz[2:]...) tests := []struct { name string @@ -259,15 +259,24 @@ func TestVarintMinLength(t *testing.T) { tests := []struct { n uint64 }{ - {1<<7 - 1}, {1 << 7}, - {1<<14 - 1}, {1 << 14}, - {1<<21 - 1}, {1 << 21}, - {1<<28 - 1}, {1 << 28}, - {1<<35 - 1}, {1 << 35}, - {1<<42 - 1}, {1 << 42}, - {1<<49 - 1}, {1 << 49}, - {1<<56 - 1}, {1 << 56}, - {1<<63 - 1}, {1 << 63}, + {1<<7 - 1}, + {1 << 7}, + {1<<14 - 1}, + {1 << 14}, + {1<<21 - 1}, + {1 << 21}, + {1<<28 - 1}, + {1 << 28}, + {1<<35 - 1}, + {1 << 35}, + {1<<42 - 1}, + {1 << 42}, + {1<<49 - 1}, + {1 << 49}, + {1<<56 - 1}, + {1 << 56}, + {1<<63 - 1}, + {1 << 63}, {math.MaxUint64}, } diff --git a/x/auth/tx/encoder.go b/x/auth/tx/encoder.go index 35cecac556eb..e594ee24cfc8 100644 --- a/x/auth/tx/encoder.go +++ b/x/auth/tx/encoder.go @@ -42,6 +42,5 @@ func DefaultJSONTxEncoder(cdc codec.ProtoCodecMarshaler) sdk.TxEncoder { } return nil, fmt.Errorf("expected %T, got %T", &wrapper{}, tx) - } } diff --git a/x/auth/tx/query.go b/x/auth/tx/query.go index a508bd32f0a0..837170a3e20b 100644 --- a/x/auth/tx/query.go +++ b/x/auth/tx/query.go @@ -77,7 +77,7 @@ func QueryTx(clientCtx client.Context, hashHexStr string) (*sdk.TxResponse, erro return nil, err } - //TODO: this may not always need to be proven + // TODO: this may not always need to be proven // https://github.com/cosmos/cosmos-sdk/issues/6807 resTx, err := node.Tx(context.Background(), hash, true) if err != nil { diff --git a/x/auth/tx/service.go b/x/auth/tx/service.go index 293542f4d383..e00b7a519aa2 100644 --- a/x/auth/tx/service.go +++ b/x/auth/tx/service.go @@ -3,9 +3,10 @@ package tx import ( "context" "fmt" + "strings" + "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "strings" gogogrpc "github.com/gogo/protobuf/grpc" "github.com/golang/protobuf/proto" // nolint: staticcheck @@ -235,7 +236,6 @@ func (s txServer) GetBlockWithTxs(ctx context.Context, req *txtypes.GetBlockWith Total: blockTxsLn, }, }, nil - } func (s txServer) BroadcastTx(ctx context.Context, req *txtypes.BroadcastTxRequest) (*txtypes.BroadcastTxResponse, error) { diff --git a/x/auth/tx/service_test.go b/x/auth/tx/service_test.go index 28481c57c38c..4b670684c017 100644 --- a/x/auth/tx/service_test.go +++ b/x/auth/tx/service_test.go @@ -79,7 +79,7 @@ func (s *IntegrationTestSuite) SetupSuite() { ) s.Require().NoError(err) s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &s.txRes)) - s.Require().Equal(uint32(0), s.txRes.Code) + s.Require().Equal(uint32(0), s.txRes.Code, s.txRes) out, err = bankcli.MsgSendExec( val.ClientCtx, @@ -151,10 +151,8 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPC() { // - tx.* events: tx.fee, tx.acc_seq, tx.signature // - Sending Amount to recipient: coin_spent, coin_received, transfer and message.sender= // - Msg events: message.module=bank and message.action=/cosmos.bank.v1beta1.MsgSend - s.Require().Equal(len(res.GetResult().GetEvents()), 13) - s.Require().Len(res.GetResult().MsgResponses, 1) - // Check the result and gas used are correct. - s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. + s.Require().Equal(len(res.GetResult().GetEvents()), 13) // 1 coin recv 1 coin spent, 1 transfer, 3 messages. + s.Require().True(res.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. } }) } @@ -194,9 +192,9 @@ func (s IntegrationTestSuite) TestSimulateTx_GRPCGateway() { err = val.ClientCtx.Codec.UnmarshalJSON(res, &result) s.Require().NoError(err) // Check the result and gas used are correct. - s.Require().Equal(len(result.GetResult().GetEvents()), 13) // See TestSimulateTx_GRPC for the 13 events. s.Require().Len(result.GetResult().MsgResponses, 1) - s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, just check it's not empty. + s.Require().Equal(len(result.GetResult().GetEvents()), 13) // See TestSimulateTx_GRPC for the 13 events. + s.Require().True(result.GetGasInfo().GetGasUsed() > 0) // Gas used sometimes change, jus } }) } diff --git a/x/auth/tx/sigs.go b/x/auth/tx/sigs.go index e2d5d63a6015..7d4716acec75 100644 --- a/x/auth/tx/sigs.go +++ b/x/auth/tx/sigs.go @@ -89,7 +89,7 @@ func ModeInfoAndSigToSignatureData(modeInfo *tx.ModeInfo, sig []byte) (signing.S } } -// decodeMultisignatures safely decodes the the raw bytes as a MultiSignature protobuf message +// decodeMultisignatures safely decodes the raw bytes as a MultiSignature protobuf message func decodeMultisignatures(bz []byte) ([][]byte, error) { multisig := cryptotypes.MultiSignature{} err := multisig.Unmarshal(bz) diff --git a/x/auth/types/account.go b/x/auth/types/account.go index 762a416b0f8a..a8331c82c8eb 100644 --- a/x/auth/types/account.go +++ b/x/auth/types/account.go @@ -203,7 +203,7 @@ func (ma ModuleAccount) HasPermission(permission string) bool { return false } -// GetName returns the the name of the holder's module +// GetName returns the name of the holder's module func (ma ModuleAccount) GetName() string { return ma.Name } diff --git a/x/auth/types/codec.go b/x/auth/types/codec.go index fa8f0589fcfb..29561dfe018c 100644 --- a/x/auth/types/codec.go +++ b/x/auth/types/codec.go @@ -2,9 +2,11 @@ package types import ( "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers the account interfaces and concrete types on the @@ -37,6 +39,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { ) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index 1030885e799e..7e96036053fc 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -81,9 +81,7 @@ func TestGenesisAccountIterator(t *testing.T) { } func TestPackAccountsAny(t *testing.T) { - var ( - accounts []*codectypes.Any - ) + var accounts []*codectypes.Any testCases := []struct { msg string diff --git a/x/auth/types/permissions_test.go b/x/auth/types/permissions_test.go index 75281a689ec3..de5c25645769 100644 --- a/x/auth/types/permissions_test.go +++ b/x/auth/types/permissions_test.go @@ -26,7 +26,6 @@ func TestHasPermission(t *testing.T) { has = permAddr.HasPermission(tc.permission) require.Equal(t, tc.expectHas, has, "test case #%d", i) } - } func TestValidatePermissions(t *testing.T) { diff --git a/x/auth/types/query.pb.go b/x/auth/types/query.pb.go index 2a3f8493aa21..6903dfc8ecac 100644 --- a/x/auth/types/query.pb.go +++ b/x/auth/types/query.pb.go @@ -177,6 +177,8 @@ func (m *QueryAccountRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAccountRequest proto.InternalMessageInfo // QueryModuleAccountsRequest is the request type for the Query/ModuleAccounts RPC method. +// +// Since: cosmos-sdk 0.46 type QueryModuleAccountsRequest struct { } @@ -343,6 +345,8 @@ func (m *QueryParamsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo // QueryModuleAccountsResponse is the response type for the Query/ModuleAccounts RPC method. +// +// Since: cosmos-sdk 0.46 type QueryModuleAccountsResponse struct { Accounts []*types.Any `protobuf:"bytes,1,rep,name=accounts,proto3" json:"accounts,omitempty"` } @@ -387,7 +391,9 @@ func (m *QueryModuleAccountsResponse) GetAccounts() []*types.Any { return nil } -// Bech32PrefixRequest is the request type for Bech32Prefix rpc method +// Bech32PrefixRequest is the request type for Bech32Prefix rpc method. +// +// Since: cosmos-sdk 0.46 type Bech32PrefixRequest struct { } @@ -424,7 +430,9 @@ func (m *Bech32PrefixRequest) XXX_DiscardUnknown() { var xxx_messageInfo_Bech32PrefixRequest proto.InternalMessageInfo -// Bech32PrefixResponse is the response type for Bech32Prefix rpc method +// Bech32PrefixResponse is the response type for Bech32Prefix rpc method. +// +// Since: cosmos-sdk 0.46 type Bech32PrefixResponse struct { Bech32Prefix string `protobuf:"bytes,1,opt,name=bech32_prefix,json=bech32Prefix,proto3" json:"bech32_prefix,omitempty"` } @@ -469,7 +477,9 @@ func (m *Bech32PrefixResponse) GetBech32Prefix() string { return "" } -// AddressBytesToStringRequest is the request type for AddressString rpc method +// AddressBytesToStringRequest is the request type for AddressString rpc method. +// +// Since: cosmos-sdk 0.46 type AddressBytesToStringRequest struct { AddressBytes []byte `protobuf:"bytes,1,opt,name=address_bytes,json=addressBytes,proto3" json:"address_bytes,omitempty"` } @@ -514,7 +524,9 @@ func (m *AddressBytesToStringRequest) GetAddressBytes() []byte { return nil } -// AddressBytesToStringResponse is the response type for AddressString rpc method +// AddressBytesToStringResponse is the response type for AddressString rpc method. +// +// Since: cosmos-sdk 0.46 type AddressBytesToStringResponse struct { AddressString string `protobuf:"bytes,1,opt,name=address_string,json=addressString,proto3" json:"address_string,omitempty"` } @@ -559,7 +571,9 @@ func (m *AddressBytesToStringResponse) GetAddressString() string { return "" } -// AddressStringToBytesRequest is the request type for AccountBytes rpc method +// AddressStringToBytesRequest is the request type for AccountBytes rpc method. +// +// Since: cosmos-sdk 0.46 type AddressStringToBytesRequest struct { AddressString string `protobuf:"bytes,1,opt,name=address_string,json=addressString,proto3" json:"address_string,omitempty"` } @@ -604,7 +618,9 @@ func (m *AddressStringToBytesRequest) GetAddressString() string { return "" } -// AddressStringToBytesResponse is the response type for AddressBytes rpc method +// AddressStringToBytesResponse is the response type for AddressBytes rpc method. +// +// Since: cosmos-sdk 0.46 type AddressStringToBytesResponse struct { AddressBytes []byte `protobuf:"bytes,1,opt,name=address_bytes,json=addressBytes,proto3" json:"address_bytes,omitempty"` } @@ -744,12 +760,20 @@ type QueryClient interface { // Params queries all parameters. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // ModuleAccounts returns all the existing module accounts. + // + // Since: cosmos-sdk 0.46 ModuleAccounts(ctx context.Context, in *QueryModuleAccountsRequest, opts ...grpc.CallOption) (*QueryModuleAccountsResponse, error) - // Bech32 queries bech32Prefix + // Bech32Prefix queries bech32Prefix + // + // Since: cosmos-sdk 0.46 Bech32Prefix(ctx context.Context, in *Bech32PrefixRequest, opts ...grpc.CallOption) (*Bech32PrefixResponse, error) // AddressBytesToString converts Account Address bytes to string + // + // Since: cosmos-sdk 0.46 AddressBytesToString(ctx context.Context, in *AddressBytesToStringRequest, opts ...grpc.CallOption) (*AddressBytesToStringResponse, error) // AddressStringToBytes converts Address string to bytes + // + // Since: cosmos-sdk 0.46 AddressStringToBytes(ctx context.Context, in *AddressStringToBytesRequest, opts ...grpc.CallOption) (*AddressStringToBytesResponse, error) } @@ -835,12 +859,20 @@ type QueryServer interface { // Params queries all parameters. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // ModuleAccounts returns all the existing module accounts. + // + // Since: cosmos-sdk 0.46 ModuleAccounts(context.Context, *QueryModuleAccountsRequest) (*QueryModuleAccountsResponse, error) - // Bech32 queries bech32Prefix + // Bech32Prefix queries bech32Prefix + // + // Since: cosmos-sdk 0.46 Bech32Prefix(context.Context, *Bech32PrefixRequest) (*Bech32PrefixResponse, error) // AddressBytesToString converts Account Address bytes to string + // + // Since: cosmos-sdk 0.46 AddressBytesToString(context.Context, *AddressBytesToStringRequest) (*AddressBytesToStringResponse, error) // AddressStringToBytes converts Address string to bytes + // + // Since: cosmos-sdk 0.46 AddressStringToBytes(context.Context, *AddressStringToBytesRequest) (*AddressStringToBytesResponse, error) } diff --git a/x/auth/vesting/client/cli/tx.go b/x/auth/vesting/client/cli/tx.go index e64411fd7c89..3c88d04500fa 100644 --- a/x/auth/vesting/client/cli/tx.go +++ b/x/auth/vesting/client/cli/tx.go @@ -47,7 +47,7 @@ func NewMsgCreateVestingAccountCmd() *cobra.Command { Short: "Create a new vesting account funded with an allocation of tokens.", Long: `Create a new vesting account funded with an allocation of tokens. The account can either be a delayed or continuous vesting account, which is determined -by the '--delayed' flag. All vesting accouts created will have their start time +by the '--delayed' flag. All vesting accounts created will have their start time set by the committed block's time. The end_time must be provided as a UNIX epoch timestamp.`, Args: cobra.ExactArgs(3), diff --git a/x/auth/vesting/client/testutil/cli_test.go b/x/auth/vesting/client/testutil/cli_test.go index dd36a6af2d3e..1035ca750264 100644 --- a/x/auth/vesting/client/testutil/cli_test.go +++ b/x/auth/vesting/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 272ebf2656bf..49925dd61f2c 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -3,7 +3,6 @@ package vesting import ( "encoding/json" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -54,10 +53,6 @@ func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConf return nil } -// RegisterRESTRoutes registers the REST routes for the vesting module. Currently, this is a no-op. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the module's gRPC Gateway routes. Currently, this // is a no-op. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} diff --git a/x/auth/vesting/msg_server.go b/x/auth/vesting/msg_server.go index aa7d391ea46d..90377947a002 100644 --- a/x/auth/vesting/msg_server.go +++ b/x/auth/vesting/msg_server.go @@ -222,5 +222,4 @@ func (s msgServer) CreatePeriodicVestingAccount(goCtx context.Context, msg *type ), ) return &types.MsgCreatePeriodicVestingAccountResponse{}, nil - } diff --git a/x/auth/vesting/types/codec.go b/x/auth/vesting/types/codec.go index 318c1ceea238..270116671e91 100644 --- a/x/auth/vesting/types/codec.go +++ b/x/auth/vesting/types/codec.go @@ -4,10 +4,12 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers the vesting interfaces and concrete types on the @@ -62,6 +64,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/auth/vesting/types/msgs.go b/x/auth/vesting/types/msgs.go index 0948daac702b..2387513cb3dd 100644 --- a/x/auth/vesting/types/msgs.go +++ b/x/auth/vesting/types/msgs.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -68,7 +67,7 @@ func (msg MsgCreateVestingAccount) ValidateBasic() error { // GetSignBytes returns the bytes all expected signers must sign over for a // MsgCreateVestingAccount. func (msg MsgCreateVestingAccount) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } // GetSigners returns the expected signers for a MsgCreateVestingAccount. @@ -116,7 +115,7 @@ func (msg MsgCreatePermanentLockedAccount) ValidateBasic() error { // GetSignBytes returns the bytes all expected signers must sign over for a // MsgCreatePermanentLockedAccount. func (msg MsgCreatePermanentLockedAccount) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } // GetSigners returns the expected signers for a MsgCreatePermanentLockedAccount. @@ -154,7 +153,7 @@ func (msg MsgCreatePeriodicVestingAccount) GetSigners() []sdk.AccAddress { // GetSignBytes returns the bytes all expected signers must sign over for a // MsgCreatePeriodicVestingAccount. func (msg MsgCreatePeriodicVestingAccount) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } // ValidateBasic Implements Msg. diff --git a/x/auth/vesting/types/period.go b/x/auth/vesting/types/period.go index e78eab31f2af..2d64fd6199db 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" "sigs.k8s.io/yaml" + + 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/auth/vesting/types/tx.pb.go b/x/auth/vesting/types/tx.pb.go index bcf2bc30e4ac..96b06cdb922b 100644 --- a/x/auth/vesting/types/tx.pb.go +++ b/x/auth/vesting/types/tx.pb.go @@ -149,6 +149,8 @@ var xxx_messageInfo_MsgCreateVestingAccountResponse proto.InternalMessageInfo // MsgCreatePermanentLockedAccount defines a message that enables creating a permanent // locked account. +// +// Since: cosmos-sdk 0.46 type MsgCreatePermanentLockedAccount struct { FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty" yaml:"from_address"` ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty" yaml:"to_address"` @@ -210,6 +212,8 @@ func (m *MsgCreatePermanentLockedAccount) GetAmount() github_com_cosmos_cosmos_s } // MsgCreatePermanentLockedAccountResponse defines the Msg/CreatePermanentLockedAccount response type. +// +// Since: cosmos-sdk 0.46 type MsgCreatePermanentLockedAccountResponse struct { } @@ -250,6 +254,8 @@ var xxx_messageInfo_MsgCreatePermanentLockedAccountResponse proto.InternalMessag // MsgCreateVestingAccount defines a message that enables creating a vesting // account. +// +// Since: cosmos-sdk 0.46 type MsgCreatePeriodicVestingAccount struct { FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty"` @@ -320,6 +326,8 @@ func (m *MsgCreatePeriodicVestingAccount) GetVestingPeriods() []Period { // MsgCreateVestingAccountResponse defines the Msg/CreatePeriodicVestingAccount // response type. +// +// Since: cosmos-sdk 0.46 type MsgCreatePeriodicVestingAccountResponse struct { } @@ -506,9 +514,13 @@ type MsgClient interface { CreateVestingAccount(ctx context.Context, in *MsgCreateVestingAccount, opts ...grpc.CallOption) (*MsgCreateVestingAccountResponse, error) // CreatePermanentLockedAccount defines a method that enables creating a permanent // locked account. + // + // Since: cosmos-sdk 0.46 CreatePermanentLockedAccount(ctx context.Context, in *MsgCreatePermanentLockedAccount, opts ...grpc.CallOption) (*MsgCreatePermanentLockedAccountResponse, error) // CreatePeriodicVestingAccount defines a method that enables creating a // periodic vesting account. + // + // Since: cosmos-sdk 0.46 CreatePeriodicVestingAccount(ctx context.Context, in *MsgCreatePeriodicVestingAccount, opts ...grpc.CallOption) (*MsgCreatePeriodicVestingAccountResponse, error) } @@ -554,9 +566,13 @@ type MsgServer interface { CreateVestingAccount(context.Context, *MsgCreateVestingAccount) (*MsgCreateVestingAccountResponse, error) // CreatePermanentLockedAccount defines a method that enables creating a permanent // locked account. + // + // Since: cosmos-sdk 0.46 CreatePermanentLockedAccount(context.Context, *MsgCreatePermanentLockedAccount) (*MsgCreatePermanentLockedAccountResponse, error) // CreatePeriodicVestingAccount defines a method that enables creating a // periodic vesting account. + // + // Since: cosmos-sdk 0.46 CreatePeriodicVestingAccount(context.Context, *MsgCreatePeriodicVestingAccount) (*MsgCreatePeriodicVestingAccountResponse, error) } diff --git a/x/auth/vesting/types/vesting_account.go b/x/auth/vesting/types/vesting_account.go index 1b21e882f0a9..6db8d7b29922 100644 --- a/x/auth/vesting/types/vesting_account.go +++ b/x/auth/vesting/types/vesting_account.go @@ -41,7 +41,7 @@ func NewBaseVestingAccount(baseAccount *authtypes.BaseAccount, originalVesting s // // CONTRACT: Delegated vesting coins and vestingCoins must be sorted. func (bva BaseVestingAccount) LockedCoinsFromVesting(vestingCoins sdk.Coins) sdk.Coins { - lockedCoins := vestingCoins.Sub(vestingCoins.Min(bva.DelegatedVesting)) + lockedCoins := vestingCoins.Sub(vestingCoins.Min(bva.DelegatedVesting)...) if lockedCoins == nil { return sdk.Coins{} } @@ -111,12 +111,12 @@ func (bva *BaseVestingAccount) TrackUndelegation(amount sdk.Coins) { if !x.IsZero() { xCoin := sdk.NewCoin(coin.Denom, x) - bva.DelegatedFree = bva.DelegatedFree.Sub(sdk.Coins{xCoin}) + bva.DelegatedFree = bva.DelegatedFree.Sub(xCoin) } if !y.IsZero() { yCoin := sdk.NewCoin(coin.Denom, y) - bva.DelegatedVesting = bva.DelegatedVesting.Sub(sdk.Coins{yCoin}) + bva.DelegatedVesting = bva.DelegatedVesting.Sub(yCoin) } } } @@ -193,8 +193,10 @@ func (bva BaseVestingAccount) MarshalYAML() (interface{}, error) { // Continuous Vesting Account -var _ vestexported.VestingAccount = (*ContinuousVestingAccount)(nil) -var _ authtypes.GenesisAccount = (*ContinuousVestingAccount)(nil) +var ( + _ vestexported.VestingAccount = (*ContinuousVestingAccount)(nil) + _ authtypes.GenesisAccount = (*ContinuousVestingAccount)(nil) +) // NewContinuousVestingAccountRaw creates a new ContinuousVestingAccount object from BaseVestingAccount func NewContinuousVestingAccountRaw(bva *BaseVestingAccount, startTime int64) *ContinuousVestingAccount { @@ -238,7 +240,7 @@ func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coin s := sdk.NewDec(x).Quo(sdk.NewDec(y)) for _, ovc := range cva.OriginalVesting { - vestedAmt := ovc.Amount.ToDec().Mul(s).RoundInt() + vestedAmt := sdk.NewDecFromInt(ovc.Amount).Mul(s).RoundInt() vestedCoins = append(vestedCoins, sdk.NewCoin(ovc.Denom, vestedAmt)) } @@ -248,7 +250,7 @@ func (cva ContinuousVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coin // GetVestingCoins returns the total number of vesting coins. If no coins are // vesting, nil is returned. func (cva ContinuousVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins { - return cva.OriginalVesting.Sub(cva.GetVestedCoins(blockTime)) + return cva.OriginalVesting.Sub(cva.GetVestedCoins(blockTime)...) } // LockedCoins returns the set of coins that are not spendable (i.e. locked), @@ -307,8 +309,10 @@ func (cva ContinuousVestingAccount) MarshalYAML() (interface{}, error) { // Periodic Vesting Account -var _ vestexported.VestingAccount = (*PeriodicVestingAccount)(nil) -var _ authtypes.GenesisAccount = (*PeriodicVestingAccount)(nil) +var ( + _ vestexported.VestingAccount = (*PeriodicVestingAccount)(nil) + _ authtypes.GenesisAccount = (*PeriodicVestingAccount)(nil) +) // NewPeriodicVestingAccountRaw creates a new PeriodicVestingAccount object from BaseVestingAccount func NewPeriodicVestingAccountRaw(bva *BaseVestingAccount, startTime int64, periods Periods) *PeriodicVestingAccount { @@ -374,7 +378,7 @@ func (pva PeriodicVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins // GetVestingCoins returns the total number of vesting coins. If no coins are // vesting, nil is returned. func (pva PeriodicVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins { - return pva.OriginalVesting.Sub(pva.GetVestedCoins(blockTime)) + return pva.OriginalVesting.Sub(pva.GetVestedCoins(blockTime)...) } // LockedCoins returns the set of coins that are not spendable (i.e. locked), @@ -451,8 +455,10 @@ func (pva PeriodicVestingAccount) MarshalYAML() (interface{}, error) { // Delayed Vesting Account -var _ vestexported.VestingAccount = (*DelayedVestingAccount)(nil) -var _ authtypes.GenesisAccount = (*DelayedVestingAccount)(nil) +var ( + _ vestexported.VestingAccount = (*DelayedVestingAccount)(nil) + _ authtypes.GenesisAccount = (*DelayedVestingAccount)(nil) +) // NewDelayedVestingAccountRaw creates a new DelayedVestingAccount object from BaseVestingAccount func NewDelayedVestingAccountRaw(bva *BaseVestingAccount) *DelayedVestingAccount { @@ -485,7 +491,7 @@ func (dva DelayedVestingAccount) GetVestedCoins(blockTime time.Time) sdk.Coins { // GetVestingCoins returns the total number of vesting coins for a delayed // vesting account. func (dva DelayedVestingAccount) GetVestingCoins(blockTime time.Time) sdk.Coins { - return dva.OriginalVesting.Sub(dva.GetVestedCoins(blockTime)) + return dva.OriginalVesting.Sub(dva.GetVestedCoins(blockTime)...) } // LockedCoins returns the set of coins that are not spendable (i.e. locked), @@ -519,8 +525,10 @@ func (dva DelayedVestingAccount) String() string { //----------------------------------------------------------------------------- // Permanent Locked Vesting Account -var _ vestexported.VestingAccount = (*PermanentLockedAccount)(nil) -var _ authtypes.GenesisAccount = (*PermanentLockedAccount)(nil) +var ( + _ vestexported.VestingAccount = (*PermanentLockedAccount)(nil) + _ authtypes.GenesisAccount = (*PermanentLockedAccount)(nil) +) // NewPermanentLockedAccount returns a PermanentLockedAccount func NewPermanentLockedAccount(baseAcc *authtypes.BaseAccount, coins sdk.Coins) *PermanentLockedAccount { diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index 6d85b8e7580d..3607b881a478 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -242,7 +242,7 @@ func TestSpendableCoinsDelVestingAcc(t *testing.T) { delegatedAmount := sdk.NewCoins(sdk.NewInt64Coin(stakeDenom, 50)) dva.TrackDelegation(now.Add(12*time.Hour), origCoins, delegatedAmount) lockedCoins = dva.LockedCoins(now.Add(12 * time.Hour)) - require.True(t, lockedCoins.IsEqual(origCoins.Sub(delegatedAmount))) + require.True(t, lockedCoins.IsEqual(origCoins.Sub(delegatedAmount...))) } func TestTrackDelegationDelVestingAcc(t *testing.T) { @@ -362,7 +362,8 @@ func TestGetVestedCoinsPeriodicVestingAcc(t *testing.T) { vestedCoins = pva.GetVestedCoins(now.Add(18 * time.Hour)) require.Equal(t, sdk.Coins{ - sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75)}, vestedCoins) + sdk.NewInt64Coin(feeDenom, 750), sdk.NewInt64Coin(stakeDenom, 75), + }, vestedCoins) // require 100% of coins vested vestedCoins = pva.GetVestedCoins(now.Add(48 * time.Hour)) @@ -600,7 +601,7 @@ func TestSpendableCoinsPermLockedVestingAcc(t *testing.T) { delegatedAmount := sdk.NewCoins(sdk.NewInt64Coin(stakeDenom, 50)) plva.TrackDelegation(now.Add(12*time.Hour), origCoins, delegatedAmount) lockedCoins = plva.LockedCoins(now.Add(12 * time.Hour)) - require.True(t, lockedCoins.IsEqual(origCoins.Sub(delegatedAmount))) + require.True(t, lockedCoins.IsEqual(origCoins.Sub(delegatedAmount...))) } func TestTrackDelegationPermLockedVestingAcc(t *testing.T) { @@ -809,6 +810,7 @@ func (s *VestingAccountTestSuite) TestDelayedVestingAccountMarshal() { _, err = app.AccountKeeper.UnmarshalAccount(bz[:len(bz)/2]) require.NotNil(err) } + func (s *VestingAccountTestSuite) TestPermanentLockedAccountMarshal() { app := s.app require := s.Require() diff --git a/x/authz/authorization_grant.go b/x/authz/authorization_grant.go index bd94977ab67b..4344bd3b7b58 100644 --- a/x/authz/authorization_grant.go +++ b/x/authz/authorization_grant.go @@ -14,11 +14,11 @@ import ( // which is passed into the `blockTime` arg. func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Grant, error) { if expiration != nil && !expiration.After(blockTime) { - return Grant{}, sdkerrors.ErrInvalidRequest.Wrapf("expiration must be after the current block time (%v), got %v", blockTime.Format(time.RFC3339), expiration.Format(time.RFC3339)) + return Grant{}, sdkerrors.Wrapf(ErrInvalidExpirationTime, "expiration must be after the current block time (%v), got %v", blockTime.Format(time.RFC3339), expiration.Format(time.RFC3339)) } msg, ok := a.(proto.Message) if !ok { - return Grant{}, sdkerrors.Wrapf(sdkerrors.ErrPackAny, "cannot proto marshal %T", a) + return Grant{}, sdkerrors.ErrPackAny.Wrapf("cannot proto marshal %T", a) } any, err := cdctypes.NewAnyWithValue(msg) if err != nil { @@ -30,9 +30,7 @@ func NewGrant(blockTime time.Time, a Authorization, expiration *time.Time) (Gran }, nil } -var ( - _ cdctypes.UnpackInterfacesMessage = &Grant{} -) +var _ cdctypes.UnpackInterfacesMessage = &Grant{} // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (g Grant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { @@ -43,11 +41,12 @@ func (g Grant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error { // GetAuthorization returns the cached value from the Grant.Authorization if present. func (g Grant) GetAuthorization() (Authorization, error) { if g.Authorization == nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidType, "authorization is nil") + return nil, sdkerrors.ErrInvalidType.Wrap("authorization is nil") } - a, ok := g.Authorization.GetCachedValue().(Authorization) + av := g.Authorization.GetCachedValue() + a, ok := av.(Authorization) if !ok { - return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (Authorization)(nil), g.Authorization.GetCachedValue()) + return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (Authorization)(nil), av) } return a, nil } @@ -56,7 +55,7 @@ func (g Grant) ValidateBasic() error { av := g.Authorization.GetCachedValue() a, ok := av.(Authorization) if !ok { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", (Authorization)(nil), av) + return sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (Authorization)(nil), av) } return a.ValidateBasic() } diff --git a/x/authz/authorization_grant_test.go b/x/authz/authorization_grant_test.go index 2501b5de1dba..ce14692c0b5a 100644 --- a/x/authz/authorization_grant_test.go +++ b/x/authz/authorization_grant_test.go @@ -19,7 +19,7 @@ func expecError(r *require.Assertions, expected string, received error) { func TestNewGrant(t *testing.T) { a := NewGenericAuthorization("some-type") - var tcs = []struct { + tcs := []struct { title string a Authorization blockTime time.Time @@ -40,7 +40,6 @@ func TestNewGrant(t *testing.T) { expecError(require.New(t), tc.err, err) }) } - } func unixTime(s, ns int64) *time.Time { diff --git a/x/authz/client/cli/query.go b/x/authz/client/cli/query.go index dfc997c445e4..62e40b290580 100644 --- a/x/authz/client/cli/query.go +++ b/x/authz/client/cli/query.go @@ -65,7 +65,7 @@ $ %s query %s grants cosmos1skjw.. cosmos1skjwj.. %s if err != nil { return err } - var msgAuthorized = "" + msgAuthorized := "" if len(args) >= 3 { msgAuthorized = args[2] } @@ -80,7 +80,8 @@ $ %s query %s grants cosmos1skjw.. cosmos1skjwj.. %s Granter: granter.String(), Grantee: grantee.String(), MsgTypeUrl: msgAuthorized, - Pagination: pageReq}, + Pagination: pageReq, + }, ) if err != nil { return err @@ -94,15 +95,16 @@ $ %s query %s grants cosmos1skjw.. cosmos1skjwj.. %s return cmd } +// GetQueryGranterGrants returns cmd to query for all grants for a granter. func GetQueryGranterGrants() *cobra.Command { cmd := &cobra.Command{ - Use: "granter-grants [granter-addr]", + Use: "grants-by-granter [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.. +$ %s q %s grants-by-granter cosmos1skj.. `, version.AppName, authz.ModuleName), ), @@ -142,15 +144,16 @@ $ %s q %s granter-grants cosmos1skj.. return cmd } +// GetQueryGranteeGrants returns cmd to query for all grants for a grantee. func GetQueryGranteeGrants() *cobra.Command { cmd := &cobra.Command{ - Use: "grantee-grants [grantee-addr]", + Use: "grants-by-grantee [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.. +$ %s q %s grants-by-grantee cosmos1skj.. `, version.AppName, authz.ModuleName), ), diff --git a/x/authz/client/cli/tx.go b/x/authz/client/cli/tx.go index e6f37343ffbc..d03e3d228b77 100644 --- a/x/authz/client/cli/tx.go +++ b/x/authz/client/cli/tx.go @@ -51,6 +51,7 @@ func GetTxCmd() *cobra.Command { return AuthorizationTxCmd } +// NewCmdGrantAuthorization returns a CLI command handler for creating a MsgGrant transaction. func NewCmdGrantAuthorization() *cobra.Command { cmd := &cobra.Command{ Use: "grant --from ", @@ -118,15 +119,25 @@ Examples: var delegateLimit *sdk.Coin if limit != "" { - spendLimit, err := sdk.ParseCoinsNormalized(limit) + spendLimit, err := sdk.ParseCoinNormalized(limit) if err != nil { return err } + queryClient := staking.NewQueryClient(clientCtx) - if !spendLimit.IsAllPositive() { + res, err := queryClient.Params(cmd.Context(), &staking.QueryParamsRequest{}) + if err != nil { + return err + } + + if spendLimit.Denom != res.Params.BondDenom { + return fmt.Errorf("invalid denom %s; coin denom should match the current bond denom %s", spendLimit.Denom, res.Params.BondDenom) + } + + if !spendLimit.IsPositive() { return fmt.Errorf("spend-limit should be greater than zero") } - delegateLimit = &spendLimit[0] + delegateLimit = &spendLimit } allowed, err := bech32toValidatorAddresses(allowValidators) @@ -189,6 +200,7 @@ func getExpireTime(cmd *cobra.Command) (*time.Time, error) { return &e, nil } +// NewCmdRevokeAuthorization returns a CLI command handler for creating a MsgRevoke transaction. func NewCmdRevokeAuthorization() *cobra.Command { cmd := &cobra.Command{ Use: "revoke [grantee] [msg-type-url] --from=[granter]", @@ -222,6 +234,7 @@ Example: return cmd } +// NewCmdExecAuthorization returns a CLI command handler for creating a MsgExec transaction. func NewCmdExecAuthorization() *cobra.Command { cmd := &cobra.Command{ Use: "exec [tx-json-file] --from [grantee]", @@ -235,7 +248,6 @@ Example: ), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err diff --git a/x/authz/client/testutil/grpc.go b/x/authz/client/testutil/grpc.go index 6cf5e65ab76a..20a0f7c903fc 100644 --- a/x/authz/client/testutil/grpc.go +++ b/x/authz/client/testutil/grpc.go @@ -160,7 +160,6 @@ func (s *IntegrationTestSuite) TestQueryGrantsGRPC() { s.Require().NoError(err) tc.postRun(&authorizations) } - }) } } @@ -213,7 +212,6 @@ func (s *IntegrationTestSuite) TestQueryGranterGrantsGRPC() { // FIXME: https://github.com/cosmos/cosmos-sdk/issues/10965 require.Len(authorizations.Grants, tc.numItems) } - }) } } @@ -266,7 +264,6 @@ func (s *IntegrationTestSuite) TestQueryGranteeGrantsGRPC() { // FIXME: https://github.com/cosmos/cosmos-sdk/issues/10965 require.Len(authorizations.Grants, tc.numItems) } - }) } } diff --git a/x/authz/client/testutil/query.go b/x/authz/client/testutil/query.go index 56296576507b..45921a054de6 100644 --- a/x/authz/client/testutil/query.go +++ b/x/authz/client/testutil/query.go @@ -25,7 +25,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorizations() { []string{ grantee.String(), "send", - fmt.Sprintf("--%s=100steak", cli.FlagSpendLimit), + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -103,7 +103,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() { []string{ grantee.String(), "send", - fmt.Sprintf("--%s=100steak", cli.FlagSpendLimit), + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -161,7 +161,7 @@ func (s *IntegrationTestSuite) TestQueryAuthorization() { fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, false, - `{"@type":"/cosmos.bank.v1beta1.SendAuthorization","spend_limit":[{"denom":"steak","amount":"100"}]}`, + `{"@type":"/cosmos.bank.v1beta1.SendAuthorization","spend_limit":[{"denom":"stake","amount":"100"}]}`, }, } for _, tc := range testCases { diff --git a/x/authz/client/testutil/tx.go b/x/authz/client/testutil/tx.go index f7db4fe644be..ecac6abce78e 100644 --- a/x/authz/client/testutil/tx.go +++ b/x/authz/client/testutil/tx.go @@ -14,6 +14,7 @@ import ( clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" "github.com/cosmos/cosmos-sdk/x/authz/client/cli" banktestutil "github.com/cosmos/cosmos-sdk/x/bank/client/testutil" bank "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -68,7 +69,7 @@ func (s *IntegrationTestSuite) SetupSuite() { out, err := CreateGrant(val, []string{ s.grantee[1].String(), "send", - fmt.Sprintf("--%s=100steak", cli.FlagSpendLimit), + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -88,7 +89,7 @@ func (s *IntegrationTestSuite) SetupSuite() { out, err = CreateGrant(val, []string{ s.grantee[2].String(), "send", - fmt.Sprintf("--%s=100steak", cli.FlagSpendLimit), + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -104,7 +105,6 @@ func (s *IntegrationTestSuite) SetupSuite() { s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &response), out.String()) s.Require().Equal(int(response.Code), 0) s.Require().NotEqual(int(response.Height), 0) - } func (s *IntegrationTestSuite) createAccount(uid string) sdk.AccAddress { @@ -139,9 +139,11 @@ func (s *IntegrationTestSuite) TearDownSuite() { s.network.Cleanup() } -var typeMsgSend = bank.SendAuthorization{}.MsgTypeURL() -var typeMsgVote = sdk.MsgTypeURL(&govv1.MsgVote{}) -var typeMsgSubmitProposal = sdk.MsgTypeURL(&govv1.MsgSubmitProposal{}) +var ( + typeMsgSend = bank.SendAuthorization{}.MsgTypeURL() + typeMsgVote = sdk.MsgTypeURL(&govv1.MsgVote{}) + typeMsgSubmitProposal = sdk.MsgTypeURL(&govv1.MsgSubmitProposal{}) +) func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { val := s.network.Validators[0] @@ -155,45 +157,49 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { args []string expectedCode uint32 expectErr bool + expErrMsg string }{ { "Invalid granter Address", []string{ "grantee_addr", "send", - fmt.Sprintf("--%s=100steak", cli.FlagSpendLimit), + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), fmt.Sprintf("--%s=%s", flags.FlagFrom, "granter"), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), }, 0, true, + "key not found", }, { "Invalid grantee Address", []string{ "grantee_addr", "send", - fmt.Sprintf("--%s=100steak", cli.FlagSpendLimit), + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), }, 0, true, + "invalid separator index", }, { "Invalid expiration time", []string{ grantee.String(), "send", - fmt.Sprintf("--%s=100steak", cli.FlagSpendLimit), + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagBroadcastMode), fmt.Sprintf("--%s=%d", cli.FlagExpiration, pastHour), }, 0, true, + "", }, { "fail with error invalid msg-type", @@ -209,6 +215,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0x1d, false, + "", }, { "failed with error both validators not allowed", @@ -226,6 +233,92 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0, true, + "cannot set both allowed & deny list", + }, + { + "invalid bond denom for tx delegate authorization allowed validators", + []string{ + grantee.String(), + "delegate", + fmt.Sprintf("--%s=100xyz", cli.FlagSpendLimit), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), + fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + 0, + true, + "invalid denom", + }, + { + "invalid bond denom for tx delegate authorization deny validators", + []string{ + grantee.String(), + "delegate", + fmt.Sprintf("--%s=100xyz", cli.FlagSpendLimit), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), + fmt.Sprintf("--%s=%s", cli.FlagDenyValidators, val.ValAddress.String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + 0, + true, + "invalid denom", + }, + { + "invalid bond denom for tx undelegate authorization", + []string{ + grantee.String(), + "unbond", + fmt.Sprintf("--%s=100xyz", cli.FlagSpendLimit), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), + fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + 0, + true, + "invalid denom", + }, + { + "invalid bond denon for tx redelegate authorization", + []string{ + grantee.String(), + "redelegate", + fmt.Sprintf("--%s=100xyz", cli.FlagSpendLimit), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), + fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + 0, + true, + "invalid denom", + }, + { + "invalid decimal coin expression with more than single coin", + []string{ + grantee.String(), + "delegate", + fmt.Sprintf("--%s=100stake,20xyz", cli.FlagSpendLimit), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), + fmt.Sprintf("--%s=%s", cli.FlagAllowedValidators, val.ValAddress.String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + }, + 0, + true, + "invalid decimal coin expression", }, { "valid tx delegate authorization allowed validators", @@ -242,6 +335,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0, false, + "", }, { "valid tx delegate authorization deny validators", @@ -258,6 +352,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0, false, + "", }, { "valid tx undelegate authorization", @@ -274,6 +369,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0, false, + "", }, { "valid tx redelegate authorization", @@ -290,13 +386,14 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0, false, + "", }, { "Valid tx send authorization", []string{ grantee.String(), "send", - fmt.Sprintf("--%s=100steak", cli.FlagSpendLimit), + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%d", cli.FlagExpiration, twoHours), @@ -305,6 +402,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0, false, + "", }, { "Valid tx generic authorization", @@ -320,6 +418,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0, false, + "", }, { "fail when granter = grantee", @@ -335,6 +434,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0, true, + "grantee and granter should be different", }, { "Valid tx with amino", @@ -351,6 +451,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { }, 0, false, + "", }, } @@ -363,6 +464,7 @@ func (s *IntegrationTestSuite) TestCLITxGrantAuthorization() { ) if tc.expectErr { s.Require().Error(err, out) + s.Require().Contains(err.Error(), tc.expErrMsg) } else { var txResp sdk.TxResponse s.Require().NoError(err) @@ -391,7 +493,7 @@ func (s *IntegrationTestSuite) TestCmdRevokeAuthorizations() { []string{ grantee.String(), "send", - fmt.Sprintf("--%s=100steak", cli.FlagSpendLimit), + fmt.Sprintf("--%s=100stake", cli.FlagSpendLimit), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -563,7 +665,7 @@ func (s *IntegrationTestSuite) TestExecAuthorizationWithExpiration() { fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }) s.Require().NoError(err) - s.Require().Contains(res.String(), "authorization not found") + s.Require().Contains(res.String(), authz.ErrNoAuthorizationFound.Error()) } func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { @@ -651,7 +753,6 @@ func (s *IntegrationTestSuite) TestNewExecGenericAuthorized() { for _, tc := range testCases { tc := tc s.Run(tc.name, func() { - cmd := cli.NewCmdExecAuthorization() clientCtx := val.ClientCtx @@ -745,7 +846,7 @@ func (s *IntegrationTestSuite) TestNewExecGrantAuthorized() { fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, - 4, + authz.ErrNoAuthorizationFound.ABCICode(), false, "", }, @@ -844,9 +945,9 @@ func (s *IntegrationTestSuite) TestExecDelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, - 4, + authz.ErrNoAuthorizationFound.ABCICode(), false, - "authorization not found", + authz.ErrNoAuthorizationFound.Error(), }, } @@ -1065,9 +1166,9 @@ func (s *IntegrationTestSuite) TestExecUndelegateAuthorization() { fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), }, - 4, + authz.ErrNoAuthorizationFound.ABCICode(), false, - "authorization not found", + authz.ErrNoAuthorizationFound.Error(), }, } diff --git a/x/authz/codec.go b/x/authz/codec.go index 8d44c4f41f9e..77a6fa24e4f9 100644 --- a/x/authz/codec.go +++ b/x/authz/codec.go @@ -6,6 +6,7 @@ import ( types "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers the necessary x/authz interfaces and concrete types @@ -35,8 +36,9 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, MsgServiceDesc()) } + func init() { - // Register all Amino interfaces and concrete types on the global Amino codec so that this can later be + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be // used to properly serialize MsgGrant and MsgExec instances - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/authz/codec/cdc.go b/x/authz/codec/cdc.go new file mode 100644 index 000000000000..520e435afd69 --- /dev/null +++ b/x/authz/codec/cdc.go @@ -0,0 +1,18 @@ +package codec + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(Amino) +) + +func init() { + cryptocodec.RegisterCrypto(Amino) + codec.RegisterEvidences(Amino) + sdk.RegisterLegacyAminoCodec(Amino) +} diff --git a/x/authz/codec/doc.go b/x/authz/codec/doc.go new file mode 100644 index 000000000000..ecc365a2211b --- /dev/null +++ b/x/authz/codec/doc.go @@ -0,0 +1,18 @@ +/* +Package codec provides a singleton instance of Amino codec that should be used to register +any concrete type that can later be referenced inside a MsgGrant or MsgExec instance so that they +can be (de)serialized properly. + +Amino types should be ideally registered inside this codec within the init function of each module's +codec.go file as follows: + +func init() { + // ... + + RegisterLegacyAminoCodec(authzcodec.Amino) +} + +The codec instance is put inside this package and not the x/authz package in order to avoid any dependency cycle. + +*/ +package codec diff --git a/x/authz/errors.go b/x/authz/errors.go index 02251c8d6f7e..2aaac7122f9c 100644 --- a/x/authz/errors.go +++ b/x/authz/errors.go @@ -6,5 +6,20 @@ import ( // x/authz module sentinel errors var ( + // ErrNoAuthorizationFound error if there is no authorization found given a grant key + ErrNoAuthorizationFound = sdkerrors.Register(ModuleName, 2, "authorization not found") + // ErrInvalidExpirationTime error if the set expiration time is in the past ErrInvalidExpirationTime = sdkerrors.Register(ModuleName, 3, "expiration time of authorization should be more than current time") + // ErrUnknownAuthorizationType error for unknown authorization type + ErrUnknownAuthorizationType = sdkerrors.Register(ModuleName, 4, "unknown authorization type") + // ErrNoGrantKeyFound error if the requested grant key does not exist + ErrNoGrantKeyFound = sdkerrors.Register(ModuleName, 5, "grant key not found") + // ErrAuthorizationExpired error if the authorization has expired + ErrAuthorizationExpired = sdkerrors.Register(ModuleName, 6, "authorization expired") + // ErrGranteeIsGranter error if the grantee and the granter are the same + ErrGranteeIsGranter = sdkerrors.Register(ModuleName, 7, "grantee and granter should be different") + // ErrAuthorizationNumOfSigners error if an authorization message does not have only one signer + ErrAuthorizationNumOfSigners = sdkerrors.Register(ModuleName, 9, "authorization can be given to msg with only one signer") + // ErrNegativeMaxTokens error if the max tokens is negative + ErrNegativeMaxTokens = sdkerrors.Register(ModuleName, 12, "max tokens should be positive") ) diff --git a/x/authz/generic_authorization.go b/x/authz/generic_authorization.go index d6249b137a28..23853d250a7a 100644 --- a/x/authz/generic_authorization.go +++ b/x/authz/generic_authorization.go @@ -4,9 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var ( - _ Authorization = &GenericAuthorization{} -) +var _ Authorization = &GenericAuthorization{} // NewGenericAuthorization creates a new GenericAuthorization object. func NewGenericAuthorization(msgTypeURL string) *GenericAuthorization { diff --git a/x/authz/keeper/genesis.go b/x/authz/keeper/genesis.go new file mode 100644 index 000000000000..f2619cba7484 --- /dev/null +++ b/x/authz/keeper/genesis.go @@ -0,0 +1,53 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" +) + +// InitGenesis new authz genesis +func (k Keeper) InitGenesis(ctx sdk.Context, data *authz.GenesisState) { + now := ctx.BlockTime() + for _, entry := range data.Authorization { + // ignore expired authorizations + if entry.Expiration != nil && entry.Expiration.Before(now) { + continue + } + + grantee, err := sdk.AccAddressFromBech32(entry.Grantee) + if err != nil { + panic(err) + } + + granter, err := sdk.AccAddressFromBech32(entry.Granter) + if err != nil { + panic(err) + } + + a, ok := entry.Authorization.GetCachedValue().(authz.Authorization) + if !ok { + panic("expected authorization") + } + + err = k.SaveGrant(ctx, grantee, granter, a, entry.Expiration) + if err != nil { + panic(err) + } + } +} + +// ExportGenesis returns a GenesisState for a given context. +func (k Keeper) ExportGenesis(ctx sdk.Context) *authz.GenesisState { + var entries []authz.GrantAuthorization + k.IterateGrants(ctx, func(granter, grantee sdk.AccAddress, grant authz.Grant) bool { + entries = append(entries, authz.GrantAuthorization{ + Granter: granter.String(), + Grantee: grantee.String(), + Expiration: grant.Expiration, + Authorization: grant.Authorization, + }) + return false + }) + + return authz.NewGenesisState(entries) +} diff --git a/x/authz/keeper/grpc_query.go b/x/authz/keeper/grpc_query.go index 6f1947b1bbb7..1156ac23521d 100644 --- a/x/authz/keeper/grpc_query.go +++ b/x/authz/keeper/grpc_query.go @@ -20,6 +20,7 @@ import ( var _ authz.QueryServer = Keeper{} // Authorizations implements the Query/Grants gRPC method. +// It returns grants for a granter-grantee pair. If msg type URL is set, it returns grants only for that msg type. func (k Keeper) Grants(c context.Context, req *authz.QueryGrantsRequest) (*authz.QueryGrantsResponse, error) { if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") @@ -39,7 +40,7 @@ func (k Keeper) Grants(c context.Context, req *authz.QueryGrantsRequest) (*authz if req.MsgTypeUrl != "" { grant, found := k.getGrant(ctx, grantStoreKey(grantee, granter, req.MsgTypeUrl)) if !found { - return nil, sdkerrors.ErrNotFound.Wrapf("authorization not found for %s type", req.MsgTypeUrl) + return nil, sdkerrors.Wrapf(authz.ErrNoAuthorizationFound, "authorization not found for %s type", req.MsgTypeUrl) } authorization, err := grant.GetAuthorization() @@ -118,8 +119,7 @@ func (k Keeper) GranterGrants(c context.Context, req *authz.QueryGranterGrantsRe 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) { + 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 @@ -171,8 +171,7 @@ func (k Keeper) GranteeGrants(c context.Context, req *authz.QueryGranteeGrantsRe 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) { + 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 diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index a9917cf12119..5ccb7e0de6fd 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -8,13 +8,13 @@ import ( "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" "github.com/cosmos/cosmos-sdk/x/authz" ) @@ -26,12 +26,12 @@ const gasCostPerIteration = uint64(20) type Keeper struct { storeKey storetypes.StoreKey cdc codec.BinaryCodec - router *middleware.MsgServiceRouter + router *baseapp.MsgServiceRouter authKeeper authkeeper.AccountKeeper } // NewKeeper constructs a message authorization Keeper -func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, router *middleware.MsgServiceRouter, ak authkeeper.AccountKeeper) Keeper { +func NewKeeper(storeKey storetypes.StoreKey, cdc codec.BinaryCodec, router *baseapp.MsgServiceRouter, ak authkeeper.AccountKeeper) Keeper { return Keeper{ storeKey: storeKey, cdc: cdc, @@ -60,12 +60,12 @@ func (k Keeper) update(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccA skey := grantStoreKey(grantee, granter, updated.MsgTypeURL()) grant, found := k.getGrant(ctx, skey) if !found { - return sdkerrors.ErrNotFound.Wrap("authorization not found") + return authz.ErrNoAuthorizationFound } msg, ok := updated.(proto.Message) if !ok { - sdkerrors.ErrPackAny.Wrapf("cannot proto marshal %T", updated) + return sdkerrors.ErrPackAny.Wrapf("cannot proto marshal %T", updated) } any, err := codectypes.NewAnyWithValue(msg) @@ -76,30 +76,33 @@ func (k Keeper) update(ctx sdk.Context, grantee sdk.AccAddress, granter sdk.AccA grant.Authorization = any store := ctx.KVStore(k.storeKey) store.Set(skey, k.cdc.MustMarshal(&grant)) + return nil } // DispatchActions attempts to execute the provided messages via authorization // grants from the message signer to the grantee. func (k Keeper) DispatchActions(ctx sdk.Context, grantee sdk.AccAddress, msgs []sdk.Msg) ([][]byte, error) { - var results = make([][]byte, len(msgs)) + results := make([][]byte, len(msgs)) now := ctx.BlockTime() for i, msg := range msgs { signers := msg.GetSigners() if len(signers) != 1 { - return nil, sdkerrors.ErrInvalidRequest.Wrap("authorization can be given to msg with only one signer") + return nil, authz.ErrAuthorizationNumOfSigners } granter := signers[0] // if granter != grantee then check authorization.Accept, otherwise we implicitly accept. if !granter.Equals(grantee) { - grant, found := k.getGrant(ctx, grantStoreKey(grantee, granter, sdk.MsgTypeURL(msg))) + skey := grantStoreKey(grantee, granter, sdk.MsgTypeURL(msg)) + + grant, found := k.getGrant(ctx, skey) if !found { - return nil, sdkerrors.ErrUnauthorized.Wrap("authorization not found") + return nil, sdkerrors.Wrapf(authz.ErrNoAuthorizationFound, "failed to update grant with key %s", string(skey)) } if grant.Expiration != nil && grant.Expiration.Before(now) { - return nil, sdkerrors.ErrUnauthorized.Wrap("authorization expired") + return nil, authz.ErrAuthorizationExpired } authorization, err := grant.GetAuthorization() @@ -193,11 +196,9 @@ func (k Keeper) DeleteGrant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk skey := grantStoreKey(grantee, granter, msgType) grant, found := k.getGrant(ctx, skey) if !found { - return sdkerrors.ErrNotFound.Wrap("authorization not found") + return sdkerrors.Wrapf(authz.ErrNoAuthorizationFound, "failed to delete grant with key %s", string(skey)) } - store.Delete(skey) - if grant.Expiration != nil { err := k.removeFromGrantQueue(ctx, skey, granter, grantee, *grant.Expiration) if err != nil { @@ -205,6 +206,8 @@ func (k Keeper) DeleteGrant(ctx sdk.Context, grantee sdk.AccAddress, granter sdk } } + store.Delete(skey) + return ctx.EventManager().EmitTypedEvent(&authz.EventRevoke{ MsgTypeUrl: msgType, Granter: granter.String(), @@ -242,7 +245,8 @@ func (k Keeper) GetAuthorizations(ctx sdk.Context, grantee sdk.AccAddress, grant // It should not be used in query or msg services without charging additional gas. // The iteration stops when the handler function returns true or the iterator exhaust. func (k Keeper) IterateGrants(ctx sdk.Context, - handler func(granterAddr sdk.AccAddress, granteeAddr sdk.AccAddress, grant authz.Grant) bool) { + handler func(granterAddr sdk.AccAddress, granteeAddr sdk.AccAddress, grant authz.Grant) bool, +) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, GrantKey) defer iter.Close() @@ -256,53 +260,6 @@ func (k Keeper) IterateGrants(ctx sdk.Context, } } -// ExportGenesis returns a GenesisState for a given context. -func (k Keeper) ExportGenesis(ctx sdk.Context) *authz.GenesisState { - var entries []authz.GrantAuthorization - k.IterateGrants(ctx, func(granter, grantee sdk.AccAddress, grant authz.Grant) bool { - entries = append(entries, authz.GrantAuthorization{ - Granter: granter.String(), - Grantee: grantee.String(), - Expiration: grant.Expiration, - Authorization: grant.Authorization, - }) - return false - }) - - return authz.NewGenesisState(entries) -} - -// InitGenesis new authz genesis -func (k Keeper) InitGenesis(ctx sdk.Context, data *authz.GenesisState) { - now := ctx.BlockTime() - for _, entry := range data.Authorization { - // ignore expired authorizations - if entry.Expiration != nil && entry.Expiration.Before(now) { - continue - } - - grantee, err := sdk.AccAddressFromBech32(entry.Grantee) - if err != nil { - panic(err) - } - - granter, err := sdk.AccAddressFromBech32(entry.Granter) - if err != nil { - panic(err) - } - - a, ok := entry.Authorization.GetCachedValue().(authz.Authorization) - if !ok { - panic("expected authorization") - } - - err = k.SaveGrant(ctx, grantee, granter, a, entry.Expiration) - if err != nil { - panic(err) - } - } -} - func (keeper Keeper) getGrantQueueItem(ctx sdk.Context, expiration time.Time, granter, grantee sdk.AccAddress) (*authz.GrantQueueItem, error) { store := ctx.KVStore(keeper.storeKey) bz := store.Get(GrantQueueKey(expiration, granter, grantee)) @@ -318,7 +275,8 @@ func (keeper Keeper) getGrantQueueItem(ctx sdk.Context, expiration time.Time, gr } func (k Keeper) setGrantQueueItem(ctx sdk.Context, expiration time.Time, - granter sdk.AccAddress, grantee sdk.AccAddress, queueItems *authz.GrantQueueItem) error { + granter sdk.AccAddress, grantee sdk.AccAddress, queueItems *authz.GrantQueueItem, +) error { store := ctx.KVStore(k.storeKey) bz, err := k.cdc.Marshal(queueItems) if err != nil { @@ -330,8 +288,7 @@ func (k Keeper) setGrantQueueItem(ctx sdk.Context, expiration time.Time, } // insertIntoGrantQueue inserts a grant key into the grant queue -func (keeper Keeper) insertIntoGrantQueue(ctx sdk.Context, granter, grantee sdk.AccAddress, msgType string, - expiration time.Time) error { +func (keeper Keeper) insertIntoGrantQueue(ctx sdk.Context, granter, grantee sdk.AccAddress, msgType string, expiration time.Time) error { queueItems, err := keeper.getGrantQueueItem(ctx, expiration, granter, grantee) if err != nil { return err @@ -355,7 +312,7 @@ func (keeper Keeper) removeFromGrantQueue(ctx sdk.Context, grantKey []byte, gran key := GrantQueueKey(expiration, granter, grantee) bz := store.Get(key) if bz == nil { - return sdkerrors.ErrLogic.Wrap("can't remove grant from the expire queue, grant key not found") + return sdkerrors.Wrap(authz.ErrNoGrantKeyFound, "can't remove grant from the expire queue, grant key not found") } var queueItem authz.GrantQueueItem diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index de57acf71c10..b9f41bc74919 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -118,7 +118,6 @@ func (s *TestSuite) TestKeeperIter() { s.Require().Contains([]sdk.AccAddress{granterAddr, granter2Addr}, granter) return true }) - } func (s *TestSuite) TestDispatchAction() { @@ -220,7 +219,7 @@ func (s *TestSuite) TestDispatchAction() { require.Len(authzs, 1) authorization := authzs[0].(*banktypes.SendAuthorization) require.NotNil(authorization) - require.Equal(authorization.SpendLimit, coins100.Sub(coins10)) + require.Equal(authorization.SpendLimit, coins100.Sub(coins10...)) }, }, { @@ -265,7 +264,6 @@ func (s *TestSuite) TestDispatchAction() { tc.postRun() }) } - } // Tests that all msg events included in an authz MsgExec tx diff --git a/x/authz/keeper/keys.go b/x/authz/keeper/keys.go index 9a935e5b2778..a079b71ddd6c 100644 --- a/x/authz/keeper/keys.go +++ b/x/authz/keeper/keys.go @@ -34,14 +34,8 @@ func grantStoreKey(grantee sdk.AccAddress, granter sdk.AccAddress, msgType strin m := conv.UnsafeStrToBytes(msgType) granter = address.MustLengthPrefix(granter) grantee = address.MustLengthPrefix(grantee) + key := sdk.AppendLengthPrefixedBytes(GrantKey, granter, grantee, m) - l := 1 + len(grantee) + len(granter) + len(m) - var key = make([]byte, l) - copy(key, GrantKey) - copy(key[1:], granter) - copy(key[1+len(granter):], grantee) - copy(key[l-len(m):], m) - // fmt.Println(">>>> len", l, key) return key } @@ -49,15 +43,15 @@ func grantStoreKey(grantee sdk.AccAddress, granter sdk.AccAddress, msgType strin func parseGrantStoreKey(key []byte) (granterAddr, granteeAddr sdk.AccAddress, msgType string) { // key is of format: // 0x01 - kv.AssertKeyAtLeastLength(key, 2) - granterAddrLen := key[1] // remove prefix key - kv.AssertKeyAtLeastLength(key, int(3+granterAddrLen)) - granterAddr = sdk.AccAddress(key[2 : 2+granterAddrLen]) - granteeAddrLen := int(key[2+granterAddrLen]) - kv.AssertKeyAtLeastLength(key, 4+int(granterAddrLen+byte(granteeAddrLen))) - granteeAddr = sdk.AccAddress(key[3+granterAddrLen : 3+granterAddrLen+byte(granteeAddrLen)]) - - return granterAddr, granteeAddr, conv.UnsafeBytesToStr(key[3+granterAddrLen+byte(granteeAddrLen):]) + + granterAddrLen, granterAddrLenEndIndex := sdk.ParseLengthPrefixedBytes(key, 1, 1) // ignore key[0] since it is a prefix key + granterAddr, granterAddrEndIndex := sdk.ParseLengthPrefixedBytes(key, granterAddrLenEndIndex+1, int(granterAddrLen[0])) + + granteeAddrLen, granteeAddrLenEndIndex := sdk.ParseLengthPrefixedBytes(key, granterAddrEndIndex+1, 1) + granteeAddr, granteeAddrEndIndex := sdk.ParseLengthPrefixedBytes(key, granteeAddrLenEndIndex+1, int(granteeAddrLen[0])) + + kv.AssertKeyAtLeastLength(key, granteeAddrEndIndex+1) + return granterAddr, granteeAddr, conv.UnsafeBytesToStr(key[(granteeAddrEndIndex + 1):]) } // parseGrantQueueKey split expiration time, granter and grantee from the grant queue key @@ -65,20 +59,18 @@ func parseGrantQueueKey(key []byte) (time.Time, sdk.AccAddress, sdk.AccAddress, // key is of format: // 0x02 - kv.AssertKeyAtLeastLength(key, 1+lenTime) - exp, err := sdk.ParseTimeBytes(key[1 : 1+lenTime]) + expBytes, expEndIndex := sdk.ParseLengthPrefixedBytes(key, 1, lenTime) + + exp, err := sdk.ParseTimeBytes(expBytes) if err != nil { return exp, nil, nil, err } - granterAddrLen := key[1+lenTime] - kv.AssertKeyAtLeastLength(key, 1+lenTime+int(granterAddrLen)) - granter := sdk.AccAddress(key[2+lenTime : byte(2+lenTime)+granterAddrLen]) + granterAddrLen, granterAddrLenEndIndex := sdk.ParseLengthPrefixedBytes(key, expEndIndex+1, 1) + granter, granterEndIndex := sdk.ParseLengthPrefixedBytes(key, granterAddrLenEndIndex+1, int(granterAddrLen[0])) - granteeAddrLen := key[byte(2+lenTime)+granterAddrLen] - granteeStart := byte(3+lenTime) + granterAddrLen - kv.AssertKeyAtLeastLength(key, int(granteeStart)) - grantee := sdk.AccAddress(key[granteeStart : granteeStart+granteeAddrLen]) + granteeAddrLen, granteeAddrLenEndIndex := sdk.ParseLengthPrefixedBytes(key, granterEndIndex+1, 1) + grantee, _ := sdk.ParseLengthPrefixedBytes(key, granteeAddrLenEndIndex+1, int(granteeAddrLen[0])) return exp, granter, grantee, nil } @@ -92,13 +84,7 @@ func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.Acc granter = address.MustLengthPrefix(granter) grantee = address.MustLengthPrefix(grantee) - l := 1 + len(exp) + len(granter) + len(grantee) - var key = make([]byte, l) - copy(key, GrantQueuePrefix) - copy(key[1:], exp) - copy(key[1+len(exp):], granter) - copy(key[1+len(exp)+len(granter):], grantee) - return key + return sdk.AppendLengthPrefixedBytes(GrantQueuePrefix, exp, granter, grantee) } // GrantQueueTimePrefix - return grant queue time prefix diff --git a/x/authz/keeper/keys_test.go b/x/authz/keeper/keys_test.go index 7a7858f704ff..531e441511c0 100644 --- a/x/authz/keeper/keys_test.go +++ b/x/authz/keeper/keys_test.go @@ -12,9 +12,11 @@ import ( bank "github.com/cosmos/cosmos-sdk/x/bank/types" ) -var granter = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) -var grantee = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) -var msgType = bank.SendAuthorization{}.MsgTypeURL() +var ( + granter = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + grantee = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + msgType = bank.SendAuthorization{}.MsgTypeURL() +) func TestGrantkey(t *testing.T) { require := require.New(t) diff --git a/x/authz/keeper/msg_server.go b/x/authz/keeper/msg_server.go index ac81b60b6469..24047e921c8a 100644 --- a/x/authz/keeper/msg_server.go +++ b/x/authz/keeper/msg_server.go @@ -35,7 +35,7 @@ func (k Keeper) Grant(goCtx context.Context, msg *authz.MsgGrant) (*authz.MsgGra } t := authorization.MsgTypeURL() if k.router.HandlerByTypeURL(t) == nil { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "%s doesn't exist.", t) + return nil, sdkerrors.ErrInvalidType.Wrapf("%s doesn't exist.", t) } err = k.SaveGrant(ctx, grantee, granter, authorization, msg.Grant.Expiration) diff --git a/x/authz/migrations/v046/keys.go b/x/authz/migrations/v046/keys.go index b4348df3bec1..9b4c74fb9f3d 100644 --- a/x/authz/migrations/v046/keys.go +++ b/x/authz/migrations/v046/keys.go @@ -30,7 +30,7 @@ func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.Acc grantee = address.MustLengthPrefix(grantee) l := 1 + len(exp) + len(granter) + len(grantee) - var key = make([]byte, l) + key := make([]byte, l) copy(key, GrantQueuePrefix) copy(key[1:], exp) copy(key[1+len(exp):], granter) @@ -48,7 +48,7 @@ func GrantStoreKey(grantee sdk.AccAddress, granter sdk.AccAddress, msgType strin grantee = address.MustLengthPrefix(grantee) l := 1 + len(grantee) + len(granter) + len(m) - var key = make([]byte, l) + key := make([]byte, l) copy(key, GrantPrefix) copy(key[1:], granter) copy(key[1+len(granter):], grantee) diff --git a/x/authz/migrations/v046/keys_test.go b/x/authz/migrations/v046/keys_test.go index 05a5bd6b1b6e..9a73edbc32dd 100644 --- a/x/authz/migrations/v046/keys_test.go +++ b/x/authz/migrations/v046/keys_test.go @@ -10,9 +10,11 @@ import ( "github.com/stretchr/testify/require" ) -var granter = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) -var grantee = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) -var msgType = bank.SendAuthorization{}.MsgTypeURL() +var ( + granter = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + grantee = sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address()) + msgType = bank.SendAuthorization{}.MsgTypeURL() +) func TestGrantkey(t *testing.T) { require := require.New(t) diff --git a/x/authz/module/abci.go b/x/authz/module/abci.go index e85044a95df4..c9e6fef5e7a6 100644 --- a/x/authz/module/abci.go +++ b/x/authz/module/abci.go @@ -7,7 +7,6 @@ import ( // BeginBlocker is called at the begining of every block func BeginBlocker(ctx sdk.Context, keeper keeper.Keeper) { - // delete all the mature grants if err := keeper.DequeueAndDeleteExpiredGrants(ctx); err != nil { panic(err) diff --git a/x/authz/module/abci_test.go b/x/authz/module/abci_test.go index 5858476aeac5..9b58c5eadbc7 100644 --- a/x/authz/module/abci_test.go +++ b/x/authz/module/abci_test.go @@ -27,7 +27,7 @@ func TestExpiredGrantsQueue(t *testing.T) { expiration2 := expiration.AddDate(1, 0, 0) smallCoins := sdk.NewCoins(sdk.NewInt64Coin("stake", 10)) - var save = func(grantee sdk.AccAddress, exp *time.Time) { + save := func(grantee sdk.AccAddress, exp *time.Time) { err := app.AuthzKeeper.SaveGrant(ctx, grantee, granter, banktypes.NewSendAuthorization(smallCoins), exp) require.NoError(t, err, "Grant from %s", grantee.String()) } @@ -40,7 +40,7 @@ func TestExpiredGrantsQueue(t *testing.T) { authz.RegisterQueryServer(queryHelper, app.AuthzKeeper) queryClient := authz.NewQueryClient(queryHelper) - var checkGrants = func(ctx sdk.Context, expectedNum int) { + checkGrants := func(ctx sdk.Context, expectedNum int) { authzmodule.BeginBlocker(ctx, app.AuthzKeeper) res, err := queryClient.GranterGrants(ctx.Context(), &authz.QueryGranterGrantsRequest{ diff --git a/x/authz/module/module.go b/x/authz/module/module.go index 219969f34f36..7ff061c691f5 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -77,10 +76,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.TxEn return authz.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the authz module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the authz module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { if err := authz.RegisterQueryHandlerClient(context.Background(), mux, authz.NewQueryClient(clientCtx)); err != nil { diff --git a/x/authz/msgs.go b/x/authz/msgs.go index 877932b75e11..8fbe17623f52 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -1,9 +1,10 @@ package authz import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" "time" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" + "github.com/gogo/protobuf/proto" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -59,7 +60,7 @@ func (msg MsgGrant) ValidateBasic() error { } if granter.Equals(grantee) { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "granter and grantee cannot be same") + return ErrGranteeIsGranter } return msg.Grant.ValidateBasic() } @@ -76,7 +77,7 @@ func (msg MsgGrant) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (msg MsgGrant) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg)) } // GetAuthorization returns the cache value from the MsgGrant.Authorization if present. @@ -88,7 +89,7 @@ func (msg *MsgGrant) GetAuthorization() (Authorization, error) { func (msg *MsgGrant) SetAuthorization(a Authorization) error { m, ok := a.(proto.Message) if !ok { - return sdkerrors.Wrapf(sdkerrors.ErrPackAny, "can't proto marshal %T", m) + return sdkerrors.ErrPackAny.Wrapf("can't proto marshal %T", m) } any, err := cdctypes.NewAnyWithValue(m) if err != nil { @@ -144,11 +145,11 @@ func (msg MsgRevoke) ValidateBasic() error { } if granter.Equals(grantee) { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "granter and grantee cannot be same") + return ErrGranteeIsGranter } if msg.MsgTypeUrl == "" { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "missing method name") + return sdkerrors.ErrInvalidRequest.Wrap("missing method name") } return nil @@ -166,7 +167,7 @@ func (msg MsgRevoke) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (msg MsgRevoke) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg)) } // NewMsgExec creates a new MsgExecAuthorized @@ -194,7 +195,7 @@ func (msg MsgExec) GetMessages() ([]sdk.Msg, error) { for i, msgAny := range msg.Msgs { msg, ok := msgAny.GetCachedValue().(sdk.Msg) if !ok { - return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "messages contains %T which is not a sdk.MsgRequest", msgAny) + return nil, sdkerrors.ErrInvalidRequest.Wrapf("messages contains %T which is not a sdk.MsgRequest", msgAny) } msgs[i] = msg } @@ -215,7 +216,7 @@ func (msg MsgExec) ValidateBasic() error { } if len(msg.Msgs) == 0 { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "messages cannot be empty") + return sdkerrors.ErrInvalidRequest.Wrapf("messages cannot be empty") } return nil @@ -233,5 +234,5 @@ func (msg MsgExec) Route() string { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (msg MsgExec) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg)) } diff --git a/x/authz/msgs_test.go b/x/authz/msgs_test.go index 7f85584121ed..0318225df226 100644 --- a/x/authz/msgs_test.go +++ b/x/authz/msgs_test.go @@ -1,10 +1,11 @@ package authz_test import ( - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "testing" "time" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/stretchr/testify/require" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -46,6 +47,7 @@ func TestMsgExecAuthorized(t *testing.T) { } } } + func TestMsgRevokeAuthorization(t *testing.T) { tests := []struct { title string @@ -84,21 +86,35 @@ func TestMsgGrantAuthorization(t *testing.T) { expectErr bool valBasic bool }{ - {"nil granter address", - nil, grantee, &banktypes.SendAuthorization{SpendLimit: coinsPos}, &now, false, false}, - {"nil grantee address", - granter, nil, &banktypes.SendAuthorization{SpendLimit: coinsPos}, &now, false, false}, - {"nil granter and grantee address", - nil, nil, &banktypes.SendAuthorization{SpendLimit: coinsPos}, &now, false, false}, - {"nil authorization should fail", - granter, grantee, nil, &now, true, false}, - {"valid test case", - granter, grantee, &banktypes.SendAuthorization{SpendLimit: coinsPos}, addDatePtr(&now, 1, 0), false, true}, - {"valid test case with nil expire time", - granter, grantee, &banktypes.SendAuthorization{SpendLimit: coinsPos}, nil, false, true}, + { + "nil granter address", + nil, grantee, &banktypes.SendAuthorization{SpendLimit: coinsPos}, &now, false, false, + }, + { + "nil grantee address", + granter, nil, &banktypes.SendAuthorization{SpendLimit: coinsPos}, &now, false, false, + }, + { + "nil granter and grantee address", + nil, nil, &banktypes.SendAuthorization{SpendLimit: coinsPos}, &now, false, false, + }, + { + "nil authorization should fail", + granter, grantee, nil, &now, true, false, + }, + { + "valid test case", + granter, grantee, &banktypes.SendAuthorization{SpendLimit: coinsPos}, addDatePtr(&now, 1, 0), false, true, + }, + { + "valid test case with nil expire time", + granter, grantee, &banktypes.SendAuthorization{SpendLimit: coinsPos}, nil, false, true, + }, // we don't access the block time / nor time.Now, so we don't know if it's in the past at this level. - {"past expire time should not fail", - granter, grantee, &banktypes.SendAuthorization{SpendLimit: coinsPos}, addDatePtr(&now, 0, -1), false, true}, + { + "past expire time should not fail", + granter, grantee, &banktypes.SendAuthorization{SpendLimit: coinsPos}, addDatePtr(&now, 0, -1), false, true, + }, } for _, tc := range tests { msg, err := authz.NewMsgGrant( diff --git a/x/authz/simulation/genesis_test.go b/x/authz/simulation/genesis_test.go index 4236b068055b..8f313be8eab1 100644 --- a/x/authz/simulation/genesis_test.go +++ b/x/authz/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -26,7 +27,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/authz/simulation/operations.go b/x/authz/simulation/operations.go index 1879522b0ce1..956a7b4c325d 100644 --- a/x/authz/simulation/operations.go +++ b/x/authz/simulation/operations.go @@ -41,8 +41,8 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( - appParams simtypes.AppParams, cdc codec.JSONCodec, ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keeper, appCdc cdctypes.AnyUnpacker) simulation.WeightedOperations { - + appParams simtypes.AppParams, cdc codec.JSONCodec, ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keeper, appCdc cdctypes.AnyUnpacker, +) simulation.WeightedOperations { var ( weightMsgGrant int weightExec int @@ -102,7 +102,7 @@ func SimulateMsgGrant(ak authz.AccountKeeper, bk authz.BankKeeper, _ keeper.Keep return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, err.Error()), nil, err } - spendLimit := spendableCoins.Sub(fees) + spendLimit := spendableCoins.Sub(fees...) if spendLimit == nil { return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, "spend limit is nil"), nil, nil } @@ -117,7 +117,7 @@ func SimulateMsgGrant(ak authz.AccountKeeper, bk authz.BankKeeper, _ keeper.Keep return simtypes.NoOpMsg(authz.ModuleName, TypeMsgGrant, err.Error()), nil, err } txCfg := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, []sdk.Msg{msg}, fees, @@ -170,7 +170,7 @@ func SimulateMsgRevoke(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Kee granterAcc, ok := simtypes.FindAccount(accs, granterAddr) if !ok { - return simtypes.NoOpMsg(authz.ModuleName, TypeMsgRevoke, "account not found"), nil, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "account not found") + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgRevoke, "account not found"), nil, sdkerrors.ErrNotFound.Wrapf("account not found") } spendableCoins := bk.SpendableCoins(ctx, granterAddr) @@ -187,7 +187,7 @@ func SimulateMsgRevoke(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Kee msg := authz.NewMsgRevoke(granterAddr, granteeAddr, a.MsgTypeURL()) txCfg := simappparams.MakeTestEncodingConfig().TxConfig account := ak.GetAccount(ctx, granterAddr) - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, []sdk.Msg{&msg}, fees, @@ -241,11 +241,11 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe 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") + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgRevoke, "Account not found"), nil, sdkerrors.ErrNotFound.Wrapf("grantee account not found") } if _, ok := simtypes.FindAccount(accs, granterAddr); !ok { - return simtypes.NoOpMsg(authz.ModuleName, TypeMsgRevoke, "Account not found"), nil, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "granter account not found") + return simtypes.NoOpMsg(authz.ModuleName, TypeMsgRevoke, "Account not found"), nil, sdkerrors.ErrNotFound.Wrapf("granter account not found") } granterspendableCoins := bk.SpendableCoins(ctx, granterAddr) @@ -276,7 +276,7 @@ func SimulateMsgExec(ak authz.AccountKeeper, bk authz.BankKeeper, k keeper.Keepe txCfg := simappparams.MakeTestEncodingConfig().TxConfig granteeAcc := ak.GetAccount(ctx, granteeAddr) - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, []sdk.Msg{&msgExec}, fees, diff --git a/x/authz/simulation/operations_test.go b/x/authz/simulation/operations_test.go index c1cfe27cc26b..fab35b4d63c9 100644 --- a/x/authz/simulation/operations_test.go +++ b/x/authz/simulation/operations_test.go @@ -114,7 +114,6 @@ func (suite *SimTestSuite) TestSimulateGrant() { suite.Require().Equal(granter.Address.String(), msg.Granter) suite.Require().Equal(grantee.Address.String(), msg.Grantee) suite.Require().Len(futureOperations, 0) - } func (suite *SimTestSuite) TestSimulateRevoke() { @@ -128,7 +127,8 @@ func (suite *SimTestSuite) TestSimulateRevoke() { Header: tmproto.Header{ Height: suite.app.LastBlockHeight() + 1, AppHash: suite.app.LastCommitID().Hash, - }}) + }, + }) initAmt := suite.app.StakingKeeper.TokensFromConsensusPower(suite.ctx, 200000) initCoins := sdk.NewCoins(sdk.NewCoin("stake", initAmt)) @@ -154,7 +154,6 @@ func (suite *SimTestSuite) TestSimulateRevoke() { suite.Require().Equal(grantee.Address.String(), msg.Grantee) suite.Require().Equal(banktypes.SendAuthorization{}.MsgTypeURL(), msg.MsgTypeUrl) suite.Require().Len(futureOperations, 0) - } func (suite *SimTestSuite) TestSimulateExec() { @@ -189,7 +188,6 @@ func (suite *SimTestSuite) TestSimulateExec() { suite.Require().True(operationMsg.OK) suite.Require().Equal(grantee.Address.String(), msg.Grantee) suite.Require().Len(futureOperations, 0) - } func TestSimTestSuite(t *testing.T) { diff --git a/x/authz/spec/01_concepts.md b/x/authz/spec/01_concepts.md index c4cc63acc4e3..9fa522ae5c10 100644 --- a/x/authz/spec/01_concepts.md +++ b/x/authz/spec/01_concepts.md @@ -42,7 +42,7 @@ The Cosmos SDK `x/authz` module comes with following authorization types: ### StakeAuthorization -`StakeAuthorization` implements the `Authorization` interface for messages in the [staking module](https://docs.cosmos.network/v0.44/modules/staking/). It takes an `AuthorizationType` to specify whether you want to authorise delegating, undelegating or redelegating (i.e. these have to be authorised seperately). It also takes a `MaxTokens` that keeps track of a limit to the amount of tokens that can be delegated/undelegated/redelegated. If left empty, the amount is unlimited. Additionally, this Msg takes an `AllowList` and a `DenyList`, which allows you to select which validators you allow grantees to stake with. +`StakeAuthorization` implements the `Authorization` interface for messages in the [staking module](https://docs.cosmos.network/v0.44/modules/staking/). It takes an `AuthorizationType` to specify whether you want to authorise delegating, undelegating or redelegating (i.e. these have to be authorised seperately). It also takes a required `MaxTokens` that keeps track of a limit to the amount of tokens that can be delegated/undelegated/redelegated. If left empty, the amount is unlimited. Additionally, this Msg takes an `AllowList` or a `DenyList`, which allows you to select which validators you allow or deny grantees to stake with. +++ https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/proto/cosmos/staking/v1beta1/authz.proto#L11-L31 @@ -51,3 +51,5 @@ The Cosmos SDK `x/authz` module comes with following authorization types: ## Gas In order to prevent DoS attacks, granting `StakeAuthorization`s with `x/authz` incurs gas. `StakeAuthorization` allows you to authorize another account to delegate, undelegate, or redelegate to validators. The authorizer can define a list of validators they allow or deny delegations to. The Cosmos SDK iterates over these lists and charge 10 gas for each validator in both of the lists. + +Since the state maintaining a list for granter, grantee pair with same expiration, we are iterating over the list to remove the grant (incase of any revoke of paritcular `msgType`) from the list and we are charging 20 gas per iteration. diff --git a/x/authz/spec/02_state.md b/x/authz/spec/02_state.md index 4aa7ac143234..4bd35e94f714 100644 --- a/x/authz/spec/02_state.md +++ b/x/authz/spec/02_state.md @@ -12,4 +12,12 @@ Grants are identified by combining granter address (the address bytes of the gra The grant object encapsulates an `Authorization` type and an expiration timestamp: -+++ https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/proto/cosmos/authz/v1beta1/authz.proto#L21-L26 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/authz/v1beta1/authz.proto#L22-L30 + +## GrantQueue + +We are maintaining a queue for authz pruning, whenever a grant created an item will be added to `GrantQueue` with a key of granter, grantee, expiration and value added as array of msg type urls. + +* GrantQueue: `0x02 | granter_address_len (1 byte) | granter_address_bytes | grantee_address_len (1 byte) | grantee_address_bytes | expiration_bytes -> ProtocalBuffer([]string{msgTypeUrls})` + ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/x/authz/keeper/keys.go#L86-L102 \ No newline at end of file diff --git a/x/authz/spec/03_messages.md b/x/authz/spec/03_messages.md index 22007980a226..8afdcf187c4d 100644 --- a/x/authz/spec/03_messages.md +++ b/x/authz/spec/03_messages.md @@ -16,7 +16,7 @@ If there is already a grant for the `(granter, grantee, Authorization)` triple, The message handling should fail if: * both granter and grantee have the same address. -* provided `Expiration` time is less than current unix timestamp. +* provided `Expiration` time is less than current unix timestamp (but a grant will be created if no `expiration` time is provided since `expiration` is optional). * provided `Grant.Authorization` is not implemented. * `Authorization.MsgTypeURL()` is not defined in the router (there is no defined handler in the app router to handle that Msg types). diff --git a/x/bank/client/cli/tx.go b/x/bank/client/cli/tx.go index 4fee9ffd1e81..5deb617b8952 100644 --- a/x/bank/client/cli/tx.go +++ b/x/bank/client/cli/tx.go @@ -1,6 +1,8 @@ package cli import ( + "fmt" + "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" @@ -10,6 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/bank/types" ) +var FlagSplit = "split" + // NewTxCmd returns a root CLI command handler for all x/bank transaction commands. func NewTxCmd() *cobra.Command { txCmd := &cobra.Command{ @@ -20,7 +24,10 @@ func NewTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - txCmd.AddCommand(NewSendTxCmd()) + txCmd.AddCommand( + NewSendTxCmd(), + NewMultiSendTxCmd(), + ) return txCmd } @@ -28,9 +35,12 @@ func NewTxCmd() *cobra.Command { // NewSendTxCmd returns a CLI command handler for creating a MsgSend transaction. func NewSendTxCmd() *cobra.Command { cmd := &cobra.Command{ - Use: "send [from_key_or_address] [to_address] [amount]", - Short: `Send funds from one account to another. Note, the'--from' flag is -ignored as it is implied from [from_key_or_address].`, + Use: "send [from_key_or_address] [to_address] [amount]", + Short: "Send funds from one account to another.", + Long: `Send funds from one account to another. +Note, the '--from' flag is ignored as it is implied from [from_key_or_address]. +When using '--dry-run' a key name cannot be used, only a bech32 address. +`, Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { cmd.Flags().Set(flags.FlagFrom, args[0]) @@ -38,6 +48,7 @@ ignored as it is implied from [from_key_or_address].`, if err != nil { return err } + toAddr, err := sdk.AccAddressFromBech32(args[1]) if err != nil { return err @@ -58,3 +69,77 @@ ignored as it is implied from [from_key_or_address].`, return cmd } + +// NewMultiSendTxCmd returns a CLI command handler for creating a MsgMultiSend transaction. +// For a better UX this command is limited to send funds from one account to two or more accounts. +func NewMultiSendTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "multi-send [from_key_or_address] [to_address_1, to_address_2, ...] [amount]", + Short: "Send funds from one account to two or more accounts.", + Long: `Send funds from one account to two or more accounts. +By default, sends the [amount] to each address of the list. +Using the '--split' flag, the [amount] is split equally between the addresses. +Note, the '--from' flag is ignored as it is implied from [from_key_or_address]. +When using '--dry-run' a key name cannot be used, only a bech32 address. +`, + Args: cobra.MinimumNArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + cmd.Flags().Set(flags.FlagFrom, args[0]) + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + coins, err := sdk.ParseCoinsNormalized(args[len(args)-1]) + if err != nil { + return err + } + + if coins.IsZero() { + return fmt.Errorf("must send positive amount") + } + + split, err := cmd.Flags().GetBool(FlagSplit) + if err != nil { + return err + } + + totalAddrs := sdk.NewInt(int64(len(args) - 2)) + // coins to be received by the addresses + sendCoins := coins + if split { + sendCoins = coins.QuoInt(totalAddrs) + } + + var output []types.Output + for _, arg := range args[1 : len(args)-1] { + toAddr, err := sdk.AccAddressFromBech32(arg) + if err != nil { + return err + } + + output = append(output, types.NewOutput(toAddr, sendCoins)) + } + + // amount to be send from the from address + var amount sdk.Coins + if split { + // user input: 1000stake to send to 3 addresses + // actual: 333stake to each address (=> 999stake actually sent) + amount = sendCoins.MulInt(totalAddrs) + } else { + amount = coins.MulInt(totalAddrs) + } + + msg := types.NewMsgMultiSend([]types.Input{types.NewInput(clientCtx.FromAddress, amount)}, output) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().Bool(FlagSplit, false, "Send the equally split token amount to each address") + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/bank/client/testutil/cli_helpers.go b/x/bank/client/testutil/cli_helpers.go index a1a33c4f67bc..60a240f4731b 100644 --- a/x/bank/client/testutil/cli_helpers.go +++ b/x/bank/client/testutil/cli_helpers.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli" ) @@ -18,6 +19,18 @@ func MsgSendExec(clientCtx client.Context, from, to, amount fmt.Stringer, extraA return clitestutil.ExecTestCLICmd(clientCtx, bankcli.NewSendTxCmd(), args) } +func MsgMultiSendExec(clientCtx client.Context, from sdk.AccAddress, to []sdk.AccAddress, amount fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) { + args := []string{from.String()} + for _, addr := range to { + args = append(args, addr.String()) + } + + args = append(args, amount.String()) + args = append(args, extraArgs...) + + return clitestutil.ExecTestCLICmd(clientCtx, bankcli.NewMultiSendTxCmd(), args) +} + func QueryBalancesExec(clientCtx client.Context, address fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{address.String(), fmt.Sprintf("--%s=json", cli.OutputFlag)} args = append(args, extraArgs...) diff --git a/x/bank/client/testutil/cli_test.go b/x/bank/client/testutil/cli_test.go index dd36a6af2d3e..1035ca750264 100644 --- a/x/bank/client/testutil/cli_test.go +++ b/x/bank/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/bank/client/testutil/suite.go b/x/bank/client/testutil/suite.go index 539dfc5f3039..2c6c79316ffe 100644 --- a/x/bank/client/testutil/suite.go +++ b/x/bank/client/testutil/suite.go @@ -471,6 +471,7 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { for _, tc := range testCases { tc := tc + s.Require().NoError(s.network.WaitForNextBlock()) s.Run(tc.name, func() { clientCtx := val.ClientCtx @@ -488,6 +489,141 @@ func (s *IntegrationTestSuite) TestNewSendTxCmd() { } } +func (s *IntegrationTestSuite) TestNewMultiSendTxCmd() { + val := s.network.Validators[0] + testAddr := sdk.AccAddress("cosmos139f7kncmglres2nf3h4hc4tade85ekfr8sulz5") + + testCases := []struct { + name string + from sdk.AccAddress + to []sdk.AccAddress + amount sdk.Coins + args []string + expectErr bool + expectedCode uint32 + respType proto.Message + }{ + { + "valid transaction", + val.Address, + []sdk.AccAddress{val.Address, testAddr}, + sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + ), + []string{ + 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()), + }, + false, 0, &sdk.TxResponse{}, + }, + { + "valid split transaction", + val.Address, + []sdk.AccAddress{val.Address, testAddr}, + sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + ), + []string{ + fmt.Sprintf("--%s=true", cli.FlagSplit), + 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()), + }, + false, 0, &sdk.TxResponse{}, + }, + { + "not enough arguments", + val.Address, + []sdk.AccAddress{val.Address}, + sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + ), + []string{ + 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()), + }, + true, 0, &sdk.TxResponse{}, + }, + { + "chain-id shouldn't be used with offline and generate-only flags", + val.Address, + []sdk.AccAddress{val.Address, testAddr}, + sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + ), + []string{ + 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.FlagOffline), + fmt.Sprintf("--%s=true", flags.FlagGenerateOnly), + }, + true, 0, &sdk.TxResponse{}, + }, + { + "not enough fees", + val.Address, + []sdk.AccAddress{val.Address, testAddr}, + sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + ), + []string{ + 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(1))).String()), + }, + false, + sdkerrors.ErrInsufficientFee.ABCICode(), + &sdk.TxResponse{}, + }, + { + "not enough gas", + val.Address, + []sdk.AccAddress{val.Address, testAddr}, + sdk.NewCoins( + sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10)), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)), + ), + []string{ + 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()), + "--gas=10", + }, + false, + sdkerrors.ErrOutOfGas.ABCICode(), + &sdk.TxResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Require().NoError(s.network.WaitForNextBlock()) + s.Run(tc.name, func() { + clientCtx := val.ClientCtx + + bz, err := MsgMultiSendExec(clientCtx, tc.from, tc.to, tc.amount, tc.args...) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(bz.Bytes(), tc.respType), bz.String()) + txResp := tc.respType.(*sdk.TxResponse) + s.Require().Equal(tc.expectedCode, txResp.Code) + } + }) + } +} + func NewCoin(denom string, amount sdk.Int) *sdk.Coin { coin := sdk.NewCoin(denom, amount) return &coin diff --git a/x/bank/keeper/grpc_query.go b/x/bank/keeper/grpc_query.go index 032e9e5ecfff..2afc4c585f70 100644 --- a/x/bank/keeper/grpc_query.go +++ b/x/bank/keeper/grpc_query.go @@ -67,7 +67,6 @@ func (k BaseKeeper) AllBalances(ctx context.Context, req *types.QueryAllBalances balances = append(balances, sdk.NewCoin(string(key), amount)) return nil }) - if err != nil { return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) } @@ -167,7 +166,6 @@ func (k BaseKeeper) DenomsMetadata(c context.Context, req *types.QueryDenomsMeta metadatas = append(metadatas, metadata) return nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -204,7 +202,6 @@ func (k BaseKeeper) DenomOwners( goCtx context.Context, req *types.QueryDenomOwnersRequest, ) (*types.QueryDenomOwnersResponse, error) { - if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } @@ -239,7 +236,6 @@ func (k BaseKeeper) DenomOwners( return true, nil }, ) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/x/bank/keeper/invariants.go b/x/bank/keeper/invariants.go index 52da98381fc6..dead9dca0334 100644 --- a/x/bank/keeper/invariants.go +++ b/x/bank/keeper/invariants.go @@ -52,7 +52,6 @@ func TotalSupply(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { expectedTotal := sdk.Coins{} supply, _, err := k.GetPaginatedTotalSupply(ctx, &query.PageRequest{Limit: query.MaxLimit}) - if err != nil { return sdk.FormatInvariant(types.ModuleName, "query supply", fmt.Sprintf("error querying total supply %v", err)), false diff --git a/x/bank/keeper/keeper.go b/x/bank/keeper/keeper.go index 40492e33a358..e25d8b809097 100644 --- a/x/bank/keeper/keeper.go +++ b/x/bank/keeper/keeper.go @@ -100,7 +100,6 @@ func NewBaseKeeper( paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, ) BaseKeeper { - // set KeyTable if it has not already been set if !paramSpace.HasKeyTable() { paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) @@ -318,7 +317,6 @@ func (k BaseKeeper) SetDenomMetaData(ctx sdk.Context, denomMetaData types.Metada func (k BaseKeeper) SendCoinsFromModuleToAccount( ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins, ) error { - senderAddr := k.ak.GetModuleAddress(senderModule) if senderAddr == nil { panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", senderModule)) @@ -336,7 +334,6 @@ func (k BaseKeeper) SendCoinsFromModuleToAccount( func (k BaseKeeper) SendCoinsFromModuleToModule( ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins, ) error { - senderAddr := k.ak.GetModuleAddress(senderModule) if senderAddr == nil { panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", senderModule)) @@ -355,7 +352,6 @@ func (k BaseKeeper) SendCoinsFromModuleToModule( func (k BaseKeeper) SendCoinsFromAccountToModule( ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins, ) error { - recipientAcc := k.ak.GetModuleAccount(ctx, recipientModule) if recipientAcc == nil { panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", recipientModule)) @@ -370,7 +366,6 @@ func (k BaseKeeper) SendCoinsFromAccountToModule( func (k BaseKeeper) DelegateCoinsFromAccountToModule( ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins, ) error { - recipientAcc := k.ak.GetModuleAccount(ctx, recipientModule) if recipientAcc == nil { panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", recipientModule)) @@ -389,7 +384,6 @@ func (k BaseKeeper) DelegateCoinsFromAccountToModule( func (k BaseKeeper) UndelegateCoinsFromModuleToAccount( ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins, ) error { - acc := k.ak.GetModuleAccount(ctx, senderModule) if acc == nil { panic(sdkerrors.Wrapf(sdkerrors.ErrUnknownAddress, "module account %s does not exist", senderModule)) diff --git a/x/bank/keeper/keeper_test.go b/x/bank/keeper/keeper_test.go index 3c181d65d9fd..7c3feb4c1c2f 100644 --- a/x/bank/keeper/keeper_test.go +++ b/x/bank/keeper/keeper_test.go @@ -287,7 +287,7 @@ func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { supplyAfterBurn, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{}) suite.Require().NoError(err) suite.Require().Equal(sdk.NewCoins().String(), getCoinsByName(ctx, keeper, authKeeper, authtypes.Burner).String()) - suite.Require().Equal(supplyAfterInflation.Sub(initCoins), supplyAfterBurn) + suite.Require().Equal(supplyAfterInflation.Sub(initCoins...), supplyAfterBurn) // test same functionality on module account with multiple permissions suite. @@ -304,7 +304,7 @@ func (suite *IntegrationTestSuite) TestSupply_BurnCoins() { suite.Require().NoError(err) suite.Require().NoError(err) suite.Require().Equal(sdk.NewCoins().String(), getCoinsByName(ctx, keeper, authKeeper, multiPermAcc.GetName()).String()) - suite.Require().Equal(supplyAfterInflation.Sub(initCoins), supplyAfterBurn) + suite.Require().Equal(supplyAfterInflation.Sub(initCoins...), supplyAfterBurn) } func (suite *IntegrationTestSuite) TestSendCoinsNewAccount() { @@ -331,7 +331,7 @@ func (suite *IntegrationTestSuite) TestSendCoinsNewAccount() { acc2Balances := app.BankKeeper.GetAllBalances(ctx, addr2) acc1Balances = app.BankKeeper.GetAllBalances(ctx, addr1) suite.Require().Equal(sendAmt, acc2Balances) - updatedAcc1Bal := balances.Sub(sendAmt) + updatedAcc1Bal := balances.Sub(sendAmt...) suite.Require().Len(acc1Balances, len(updatedAcc1Bal)) suite.Require().Equal(acc1Balances, updatedAcc1Bal) suite.Require().NotNil(app.AccountKeeper.GetAccount(ctx, addr2)) @@ -713,7 +713,7 @@ func (suite *IntegrationTestSuite) TestSpendableCoins() { ctx = ctx.WithBlockTime(now.Add(12 * time.Hour)) suite.Require().NoError(app.BankKeeper.DelegateCoins(ctx, addr2, addrModule, delCoins)) - suite.Require().Equal(origCoins.Sub(delCoins), app.BankKeeper.SpendableCoins(ctx, addr1)) + suite.Require().Equal(origCoins.Sub(delCoins...), app.BankKeeper.SpendableCoins(ctx, addr1)) } func (suite *IntegrationTestSuite) TestVestingAccountSend() { @@ -806,10 +806,10 @@ func (suite *IntegrationTestSuite) TestVestingAccountReceive() { vacc = app.AccountKeeper.GetAccount(ctx, addr1).(*vesting.ContinuousVestingAccount) balances := app.BankKeeper.GetAllBalances(ctx, addr1) suite.Require().Equal(origCoins.Add(sendCoins...), balances) - suite.Require().Equal(balances.Sub(vacc.LockedCoins(now)), sendCoins) + suite.Require().Equal(balances.Sub(vacc.LockedCoins(now)...), sendCoins) // require coins are spendable plus any that have vested - suite.Require().Equal(balances.Sub(vacc.LockedCoins(now.Add(12*time.Hour))), origCoins) + suite.Require().Equal(balances.Sub(vacc.LockedCoins(now.Add(12*time.Hour))...), origCoins) } func (suite *IntegrationTestSuite) TestPeriodicVestingAccountReceive() { @@ -845,10 +845,10 @@ func (suite *IntegrationTestSuite) TestPeriodicVestingAccountReceive() { vacc = app.AccountKeeper.GetAccount(ctx, addr1).(*vesting.PeriodicVestingAccount) balances := app.BankKeeper.GetAllBalances(ctx, addr1) suite.Require().Equal(origCoins.Add(sendCoins...), balances) - suite.Require().Equal(balances.Sub(vacc.LockedCoins(now)), sendCoins) + suite.Require().Equal(balances.Sub(vacc.LockedCoins(now)...), sendCoins) // require coins are spendable plus any that have vested - suite.Require().Equal(balances.Sub(vacc.LockedCoins(now.Add(12*time.Hour))), origCoins) + suite.Require().Equal(balances.Sub(vacc.LockedCoins(now.Add(12*time.Hour))...), origCoins) } func (suite *IntegrationTestSuite) TestDelegateCoins() { @@ -879,7 +879,7 @@ func (suite *IntegrationTestSuite) TestDelegateCoins() { // require the ability for a non-vesting account to delegate suite.Require().NoError(app.BankKeeper.DelegateCoins(ctx, addr2, addrModule, delCoins)) - suite.Require().Equal(origCoins.Sub(delCoins), app.BankKeeper.GetAllBalances(ctx, addr2)) + suite.Require().Equal(origCoins.Sub(delCoins...), app.BankKeeper.GetAllBalances(ctx, addr2)) suite.Require().Equal(delCoins, app.BankKeeper.GetAllBalances(ctx, addrModule)) // require the ability for a vesting account to delegate @@ -945,7 +945,7 @@ func (suite *IntegrationTestSuite) TestUndelegateCoins() { err := app.BankKeeper.DelegateCoins(ctx, addr2, addrModule, delCoins) suite.Require().NoError(err) - suite.Require().Equal(origCoins.Sub(delCoins), app.BankKeeper.GetAllBalances(ctx, addr2)) + suite.Require().Equal(origCoins.Sub(delCoins...), app.BankKeeper.GetAllBalances(ctx, addr2)) suite.Require().Equal(delCoins, app.BankKeeper.GetAllBalances(ctx, addrModule)) // require the ability for a non-vesting account to undelegate @@ -957,7 +957,7 @@ func (suite *IntegrationTestSuite) TestUndelegateCoins() { // require the ability for a vesting account to delegate suite.Require().NoError(app.BankKeeper.DelegateCoins(ctx, addr1, addrModule, delCoins)) - suite.Require().Equal(origCoins.Sub(delCoins), app.BankKeeper.GetAllBalances(ctx, addr1)) + suite.Require().Equal(origCoins.Sub(delCoins...), app.BankKeeper.GetAllBalances(ctx, addr1)) suite.Require().Equal(delCoins, app.BankKeeper.GetAllBalances(ctx, addrModule)) // require the ability for a vesting account to undelegate @@ -1095,7 +1095,7 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { case types.EventTypeCoinBurn: burnedCoins, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) suite.Require().NoError(err) - supply = supply.Sub(burnedCoins) + supply = supply.Sub(burnedCoins...) case types.EventTypeCoinMint: mintedCoins, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) @@ -1107,7 +1107,7 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() { suite.Require().NoError(err) spender, err := sdk.AccAddressFromBech32((string)(e.Attributes[0].Value)) suite.Require().NoError(err) - balances[spender.String()] = balances[spender.String()].Sub(coinsSpent) + balances[spender.String()] = balances[spender.String()].Sub(coinsSpent...) case types.EventTypeCoinReceived: coinsRecv, err := sdk.ParseCoinsNormalized((string)(e.Attributes[1].Value)) diff --git a/x/bank/keeper/send.go b/x/bank/keeper/send.go index fb68fc9c4a03..356be5ac1c93 100644 --- a/x/bank/keeper/send.go +++ b/x/bank/keeper/send.go @@ -48,7 +48,6 @@ type BaseSendKeeper struct { func NewBaseSendKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak types.AccountKeeper, paramSpace paramtypes.Subspace, blockedAddrs map[string]bool, ) BaseSendKeeper { - return BaseSendKeeper{ BaseViewKeeper: NewBaseViewKeeper(cdc, storeKey, ak), cdc: cdc, @@ -187,7 +186,7 @@ func (k BaseSendKeeper) subUnlockedCoins(ctx sdk.Context, addr sdk.AccAddress, a locked := sdk.NewCoin(coin.Denom, lockedCoins.AmountOf(coin.Denom)) spendable := balance.Sub(locked) - _, hasNeg := sdk.Coins{spendable}.SafeSub(sdk.Coins{coin}) + _, hasNeg := sdk.Coins{spendable}.SafeSub(coin) if hasNeg { return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "%s is smaller than %s", spendable, coin) } diff --git a/x/bank/keeper/view.go b/x/bank/keeper/view.go index c6feb72786dc..cf66c1962002 100644 --- a/x/bank/keeper/view.go +++ b/x/bank/keeper/view.go @@ -192,7 +192,7 @@ func (k BaseViewKeeper) spendableCoins(ctx sdk.Context, addr sdk.AccAddress) (sp total = k.GetAllBalances(ctx, addr) locked := k.LockedCoins(ctx, addr) - spendable, hasNeg := total.SafeSub(locked) + spendable, hasNeg := total.SafeSub(locked...) if hasNeg { spendable = sdk.NewCoins() return diff --git a/x/bank/migrations/v036/types.go b/x/bank/migrations/v036/types.go deleted file mode 100644 index 081a41fc11fa..000000000000 --- a/x/bank/migrations/v036/types.go +++ /dev/null @@ -1,17 +0,0 @@ -// Package v036 is used for legacy migration scripts. Actual migration scripts -// for v036 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -// DONTCOVER -package v036 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -const ModuleName = "supply" - -type ( - GenesisState struct { - Supply sdk.Coins `json:"supply" yaml:"supply"` - } -) diff --git a/x/bank/migrations/v038/types.go b/x/bank/migrations/v038/types.go deleted file mode 100644 index 563182c10725..000000000000 --- a/x/bank/migrations/v038/types.go +++ /dev/null @@ -1,16 +0,0 @@ -// Package v038 is used for legacy migration scripts. Actual migration scripts -// for v038 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -package v038 - -// DONTCOVER - -const ( - ModuleName = "bank" -) - -type ( - GenesisState struct { - SendEnabled bool `json:"send_enabled" yaml:"send_enabled"` - } -) diff --git a/x/bank/migrations/v040/keys.go b/x/bank/migrations/v040/keys.go deleted file mode 100644 index 38bb49a0032d..000000000000 --- a/x/bank/migrations/v040/keys.go +++ /dev/null @@ -1,46 +0,0 @@ -// Package v040 is copy-pasted from: -// https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/x/bank/types/key.go -package v040 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/kv" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" -) - -const ( - // ModuleName defines the module name - ModuleName = "bank" - - // StoreKey defines the primary module store key - StoreKey = ModuleName - - // RouterKey defines the module's message routing key - RouterKey = ModuleName - - // QuerierRoute defines the module's query routing key - QuerierRoute = ModuleName -) - -// KVStore keys -var ( - BalancesPrefix = []byte("balances") - SupplyKey = []byte{0x00} - DenomMetadataPrefix = []byte{0x1} -) - -// DenomMetadataKey returns the denomination metadata key. -func DenomMetadataKey(denom string) []byte { - d := []byte(denom) - return append(DenomMetadataPrefix, d...) -} - -// AddressFromBalancesStore returns an account address from a balances prefix -// store. The key must not contain the perfix BalancesPrefix as the prefix store -// iterator discards the actual prefix. -func AddressFromBalancesStore(key []byte) sdk.AccAddress { - kv.AssertKeyAtLeastLength(key, 1+v040auth.AddrLen) - addr := key[:v040auth.AddrLen] - kv.AssertKeyLength(addr, v040auth.AddrLen) - return sdk.AccAddress(addr) -} diff --git a/x/bank/migrations/v040/migrate.go b/x/bank/migrations/v040/migrate.go deleted file mode 100644 index 9a7f82a0705c..000000000000 --- a/x/bank/migrations/v040/migrate.go +++ /dev/null @@ -1,38 +0,0 @@ -package v040 - -import ( - v039auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v039" - v036supply "github.com/cosmos/cosmos-sdk/x/bank/migrations/v036" - v038bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v038" - "github.com/cosmos/cosmos-sdk/x/bank/types" -) - -// Migrate accepts exported v0.39 x/auth and v0.38 x/bank genesis state and -// migrates it to v0.40 x/bank genesis state. The migration includes: -// -// - Moving balances from x/auth to x/bank genesis state. -// - Moving supply from x/supply to x/bank genesis state. -// - Re-encode in v0.40 GenesisState. -func Migrate( - bankGenState v038bank.GenesisState, - authGenState v039auth.GenesisState, - supplyGenState v036supply.GenesisState, -) *types.GenesisState { - balances := make([]types.Balance, len(authGenState.Accounts)) - for i, acc := range authGenState.Accounts { - balances[i] = types.Balance{ - Address: acc.GetAddress().String(), - Coins: acc.GetCoins(), - } - } - - return &types.GenesisState{ - Params: types.Params{ - SendEnabled: []*types.SendEnabled{}, - DefaultSendEnabled: bankGenState.SendEnabled, - }, - Balances: balances, - Supply: supplyGenState.Supply, - DenomMetadata: []types.Metadata{}, - } -} diff --git a/x/bank/migrations/v040/migrate_test.go b/x/bank/migrations/v040/migrate_test.go deleted file mode 100644 index 2a4053e9b44e..000000000000 --- a/x/bank/migrations/v040/migrate_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package v040_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" - v038auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v038" - v039auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v039" - v036supply "github.com/cosmos/cosmos-sdk/x/bank/migrations/v036" - v038bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v038" - v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" -) - -func TestMigrate(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() - clientCtx := client.Context{}. - WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithTxConfig(encodingConfig.TxConfig). - WithLegacyAmino(encodingConfig.Amino). - WithCodec(encodingConfig.Codec) - - coins := sdk.NewCoins(sdk.NewInt64Coin("stake", 50)) - addr1, _ := sdk.AccAddressFromBech32("cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u") - acc1 := v038auth.NewBaseAccount(addr1, coins, nil, 1, 0) - - addr2, _ := sdk.AccAddressFromBech32("cosmos15v50ymp6n5dn73erkqtmq0u8adpl8d3ujv2e74") - vaac := v038auth.NewContinuousVestingAccountRaw( - v038auth.NewBaseVestingAccount( - v038auth.NewBaseAccount(addr2, coins, nil, 1, 0), coins, nil, nil, 3160620846, - ), - 1580309972, - ) - - supply := sdk.NewCoins(sdk.NewInt64Coin("stake", 1000)) - - bankGenState := v038bank.GenesisState{ - SendEnabled: true, - } - authGenState := v039auth.GenesisState{ - Accounts: v038auth.GenesisAccounts{acc1, vaac}, - } - supplyGenState := v036supply.GenesisState{ - Supply: supply, - } - - migrated := v040bank.Migrate(bankGenState, authGenState, supplyGenState) - expected := `{"params":{"send_enabled":[],"default_send_enabled":true},"balances":[{"address":"cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u","coins":[{"denom":"stake","amount":"50"}]},{"address":"cosmos15v50ymp6n5dn73erkqtmq0u8adpl8d3ujv2e74","coins":[{"denom":"stake","amount":"50"}]}],"supply":[{"denom":"stake","amount":"1000"}],"denom_metadata":[]}` - - bz, err := clientCtx.Codec.MarshalJSON(migrated) - require.NoError(t, err) - require.Equal(t, expected, string(bz)) -} diff --git a/x/bank/migrations/v040/types.go b/x/bank/migrations/v040/types.go deleted file mode 100644 index 11fdf1dfe8c5..000000000000 --- a/x/bank/migrations/v040/types.go +++ /dev/null @@ -1,31 +0,0 @@ -package v040 - -import ( - "github.com/golang/protobuf/proto" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/x/bank/types" -) - -// SupplyI defines an inflationary supply interface for modules that handle -// token supply. -// It is copy-pasted from: -// https://github.com/cosmos/cosmos-sdk/blob/v042.3/x/bank/exported/exported.go -// where we stripped off the unnecessary methods. -// -// It is used in the migration script, because we save this interface as an Any -// in the supply state. -// -// Deprecated. -type SupplyI interface { - proto.Message -} - -// RegisterInterfaces registers interfaces required for the v0.40 migrations. -func RegisterInterfaces(registry codectypes.InterfaceRegistry) { - registry.RegisterInterface( - "cosmos.bank.v1beta1.SupplyI", - (*SupplyI)(nil), - &types.Supply{}, - ) -} diff --git a/x/bank/migrations/v042/types.go b/x/bank/migrations/v042/types.go new file mode 100644 index 000000000000..bbfba526e9b3 --- /dev/null +++ b/x/bank/migrations/v042/types.go @@ -0,0 +1,70 @@ +package v042 + +import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/kv" + v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" + "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/golang/protobuf/proto" +) + +const ( + // ModuleName defines the module name + ModuleName = "bank" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName +) + +// KVStore keys +var ( + BalancesPrefix = []byte("balances") + SupplyKey = []byte{0x00} + DenomMetadataPrefix = []byte{0x1} +) + +// DenomMetadataKey returns the denomination metadata key. +func DenomMetadataKey(denom string) []byte { + d := []byte(denom) + return append(DenomMetadataPrefix, d...) +} + +// AddressFromBalancesStore returns an account address from a balances prefix +// store. The key must not contain the perfix BalancesPrefix as the prefix store +// iterator discards the actual prefix. +func AddressFromBalancesStore(key []byte) sdk.AccAddress { + kv.AssertKeyAtLeastLength(key, 1+v042auth.AddrLen) + addr := key[:v042auth.AddrLen] + kv.AssertKeyLength(addr, v042auth.AddrLen) + return sdk.AccAddress(addr) +} + +// SupplyI defines an inflationary supply interface for modules that handle +// token supply. +// It is copy-pasted from: +// https://github.com/cosmos/cosmos-sdk/blob/v042.3/x/bank/exported/exported.go +// where we stripped off the unnecessary methods. +// +// It is used in the migration script, because we save this interface as an Any +// in the supply state. +// +// Deprecated. +type SupplyI interface { + proto.Message +} + +// RegisterInterfaces registers interfaces required for the v0.40 migrations. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterInterface( + "cosmos.bank.v1beta1.SupplyI", + (*SupplyI)(nil), + &types.Supply{}, + ) +} diff --git a/x/bank/migrations/v043/store.go b/x/bank/migrations/v043/store.go index 4c6b56e2b3ee..d745f7807cf6 100644 --- a/x/bank/migrations/v043/store.go +++ b/x/bank/migrations/v043/store.go @@ -5,8 +5,8 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" - v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" + v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" + v042bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v042" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -15,14 +15,14 @@ import ( // ref: https://github.com/cosmos/cosmos-sdk/issues/7092 func migrateSupply(store sdk.KVStore, cdc codec.BinaryCodec) error { // Old supply was stored as a single blob under the SupplyKey. - var oldSupplyI v040bank.SupplyI - err := cdc.UnmarshalInterface(store.Get(v040bank.SupplyKey), &oldSupplyI) + var oldSupplyI v042bank.SupplyI + err := cdc.UnmarshalInterface(store.Get(v042bank.SupplyKey), &oldSupplyI) if err != nil { return err } // We delete the single key holding the whole blob. - store.Delete(v040bank.SupplyKey) + store.Delete(v042bank.SupplyKey) if oldSupplyI == nil { return nil @@ -54,14 +54,14 @@ func migrateBalanceKeys(store sdk.KVStore) { // prefix ("balances") || addrBytes (20 bytes) || denomBytes // new key is of format // prefix (0x02) || addrLen (1 byte) || addrBytes || denomBytes - oldStore := prefix.NewStore(store, v040bank.BalancesPrefix) + oldStore := prefix.NewStore(store, v042bank.BalancesPrefix) oldStoreIter := oldStore.Iterator(nil, nil) defer oldStoreIter.Close() for ; oldStoreIter.Valid(); oldStoreIter.Next() { - addr := v040bank.AddressFromBalancesStore(oldStoreIter.Key()) - denom := oldStoreIter.Key()[v040auth.AddrLen:] + addr := v042bank.AddressFromBalancesStore(oldStoreIter.Key()) + denom := oldStoreIter.Key()[v042auth.AddrLen:] newStoreKey := append(CreateAccountBalancesPrefix(addr), denom...) // Set new key on store. Values don't change. diff --git a/x/bank/migrations/v043/store_test.go b/x/bank/migrations/v043/store_test.go index d1b7eae50b35..04117b3c3b32 100644 --- a/x/bank/migrations/v043/store_test.go +++ b/x/bank/migrations/v043/store_test.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" + v042bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v042" v043bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -26,11 +26,11 @@ func TestSupplyMigration(t *testing.T) { oldFooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) // to ensure the zero denom coins pruned. // Old supply was stored as a single blob under the `SupplyKey`. - var oldSupply v040bank.SupplyI + var oldSupply v042bank.SupplyI oldSupply = &types.Supply{Total: sdk.Coins{oldFooCoin, oldBarCoin, oldFooBarCoin}} oldSupplyBz, err := encCfg.Codec.MarshalInterface(oldSupply) require.NoError(t, err) - store.Set(v040bank.SupplyKey, oldSupplyBz) + store.Set(v042bank.SupplyKey, oldSupplyBz) // Run migration. err = v043bank.MigrateStore(ctx, bankKey, encCfg.Codec) @@ -74,14 +74,14 @@ func TestBalanceKeysMigration(t *testing.T) { // set 10 foo coin fooCoin := sdk.NewCoin("foo", sdk.NewInt(10)) - oldFooKey := append(append(v040bank.BalancesPrefix, addr...), []byte(fooCoin.Denom)...) + oldFooKey := append(append(v042bank.BalancesPrefix, addr...), []byte(fooCoin.Denom)...) fooBz, err := encCfg.Codec.Marshal(&fooCoin) require.NoError(t, err) store.Set(oldFooKey, fooBz) // set 0 foobar coin fooBarCoin := sdk.NewCoin("foobar", sdk.NewInt(0)) - oldKeyFooBar := append(append(v040bank.BalancesPrefix, addr...), []byte(fooBarCoin.Denom)...) + oldKeyFooBar := append(append(v042bank.BalancesPrefix, addr...), []byte(fooBarCoin.Denom)...) fooBarBz, err := encCfg.Codec.Marshal(&fooBarCoin) require.NoError(t, err) store.Set(oldKeyFooBar, fooBarBz) diff --git a/x/bank/migrations/v046/keys.go b/x/bank/migrations/v046/keys.go index 6593ad91d811..c86aae935805 100644 --- a/x/bank/migrations/v046/keys.go +++ b/x/bank/migrations/v046/keys.go @@ -1,8 +1,6 @@ package v046 -var ( - DenomAddressPrefix = []byte{0x03} -) +var DenomAddressPrefix = []byte{0x03} // CreateDenomAddressPrefix creates a prefix for a reverse index of denomination // to account balance for that denomination. diff --git a/x/bank/migrations/v046/store.go b/x/bank/migrations/v046/store.go index b24501872aea..8f4e628a11ea 100644 --- a/x/bank/migrations/v046/store.go +++ b/x/bank/migrations/v046/store.go @@ -82,7 +82,7 @@ func migrateDenomMetadata(store sdk.KVStore) error { oldKey := oldDenomMetaDataIter.Key() l := len(oldKey)/2 + 1 - var newKey = make([]byte, len(types.DenomMetadataPrefix)+l) + newKey := make([]byte, len(types.DenomMetadataPrefix)+l) // old key: prefix_bytes | denom_bytes | denom_bytes copy(newKey, types.DenomMetadataPrefix) copy(newKey[len(types.DenomMetadataPrefix):], oldKey[:l]) diff --git a/x/bank/module.go b/x/bank/module.go index 169f5b26ac4b..bfeee7eed6ba 100644 --- a/x/bank/module.go +++ b/x/bank/module.go @@ -7,7 +7,6 @@ import ( "math/rand" "time" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -21,7 +20,7 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/bank/client/cli" "github.com/cosmos/cosmos-sdk/x/bank/keeper" - v040 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" + v040 "github.com/cosmos/cosmos-sdk/x/bank/migrations/v042" "github.com/cosmos/cosmos-sdk/x/bank/simulation" "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -61,11 +60,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingCo return data.Validate() } -// RegisterRESTRoutes registers the REST routes for the bank module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/bank` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bank module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/bank/simulation/genesis.go b/x/bank/simulation/genesis.go index 9031d0336451..38e3b34b30d9 100644 --- a/x/bank/simulation/genesis.go +++ b/x/bank/simulation/genesis.go @@ -43,7 +43,7 @@ func RandomGenesisBalances(simState *module.SimulationState) []types.Balance { for _, acc := range simState.Accounts { genesisBalances = append(genesisBalances, types.Balance{ Address: acc.Address.String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(simState.InitialStake))), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, simState.InitialStake)), }) } @@ -65,7 +65,7 @@ func RandomizedGenState(simState *module.SimulationState) { ) numAccs := int64(len(simState.Accounts)) - totalSupply := sdk.NewInt(simState.InitialStake * (numAccs + simState.NumBonded)) + totalSupply := simState.InitialStake.Mul(sdk.NewInt((numAccs + simState.NumBonded))) supply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, totalSupply)) bankGenesis := types.GenesisState{ diff --git a/x/bank/simulation/genesis_test.go b/x/bank/simulation/genesis_test.go index fc31ca38e9ef..d2b38f6d06ed 100644 --- a/x/bank/simulation/genesis_test.go +++ b/x/bank/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -29,7 +30,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/bank/simulation/operations.go b/x/bank/simulation/operations.go index 05d14a7375f7..56a9919224b7 100644 --- a/x/bank/simulation/operations.go +++ b/x/bank/simulation/operations.go @@ -26,7 +26,6 @@ const ( func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk keeper.Keeper, ) simulation.WeightedOperations { - var weightMsgSend, weightMsgMultiSend int appParams.GetOrGenerate(cdc, OpWeightMsgSend, &weightMsgSend, nil, func(_ *rand.Rand) { @@ -116,7 +115,6 @@ func sendMsgSend( r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper, msg *types.MsgSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, ) error { - var ( fees sdk.Coins err error @@ -130,7 +128,7 @@ func sendMsgSend( account := ak.GetAccount(ctx, from) spendable := bk.SpendableCoins(ctx, account.GetAddress()) - coins, hasNeg := spendable.SafeSub(msg.Amount) + coins, hasNeg := spendable.SafeSub(msg.Amount...) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coins) if err != nil { @@ -138,7 +136,7 @@ func sendMsgSend( } } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -167,7 +165,6 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - // random number of inputs/outputs between [1, 3] inputs := make([]types.Input, r.Intn(3)+1) outputs := make([]types.Output, r.Intn(3)+1) @@ -219,7 +216,7 @@ func SimulateMsgMultiSend(ak types.AccountKeeper, bk keeper.Keeper) simtypes.Ope // take random subset of remaining coins for output // and update remaining coins outCoins = simtypes.RandSubsetCoins(r, totalSentCoins) - totalSentCoins = totalSentCoins.Sub(outCoins) + totalSentCoins = totalSentCoins.Sub(outCoins...) } outputs[o] = types.NewOutput(outAddr.Address, outCoins) @@ -256,7 +253,6 @@ func SimulateMsgMultiSendToModuleAccount(ak types.AccountKeeper, bk keeper.Keepe r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - inputs := make([]types.Input, 2) outputs := make([]types.Output, moduleAccCount) // collect signer privKeys @@ -286,7 +282,7 @@ func SimulateMsgMultiSendToModuleAccount(ak types.AccountKeeper, bk keeper.Keepe // take random subset of remaining coins for output // and update remaining coins outCoins = simtypes.RandSubsetCoins(r, totalSentCoins) - totalSentCoins = totalSentCoins.Sub(outCoins) + totalSentCoins = totalSentCoins.Sub(outCoins...) } outputs[i] = types.NewOutput(moduleAccounts[i].Address, outCoins) @@ -323,7 +319,6 @@ func sendMsgMultiSend( r *rand.Rand, app *baseapp.BaseApp, bk keeper.Keeper, ak types.AccountKeeper, msg *types.MsgMultiSend, ctx sdk.Context, chainID string, privkeys []cryptotypes.PrivKey, ) error { - accountNumbers := make([]uint64, len(msg.Inputs)) sequenceNumbers := make([]uint64, len(msg.Inputs)) @@ -351,7 +346,7 @@ func sendMsgMultiSend( feePayer := ak.GetAccount(ctx, addr) spendable := bk.SpendableCoins(ctx, feePayer.GetAddress()) - coins, hasNeg := spendable.SafeSub(msg.Inputs[0].Coins) + coins, hasNeg := spendable.SafeSub(msg.Inputs[0].Coins...) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coins) if err != nil { @@ -360,7 +355,7 @@ func sendMsgMultiSend( } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -387,7 +382,6 @@ func sendMsgMultiSend( func randomSendFields( r *rand.Rand, ctx sdk.Context, accs []simtypes.Account, bk keeper.Keeper, ak types.AccountKeeper, ) (simtypes.Account, simtypes.Account, sdk.Coins, bool) { - from, _ := simtypes.RandomAcc(r, accs) to, _ := simtypes.RandomAcc(r, accs) @@ -412,7 +406,6 @@ func randomSendFields( } func getModuleAccounts(ak types.AccountKeeper, ctx sdk.Context, moduleAccCount int) []simtypes.Account { - moduleAccounts := make([]simtypes.Account, moduleAccCount) for i := 0; i < moduleAccCount; i++ { diff --git a/x/bank/simulation/operations_test.go b/x/bank/simulation/operations_test.go index 77ad02ff2c76..f50c2b944885 100644 --- a/x/bank/simulation/operations_test.go +++ b/x/bank/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" "math/rand" "testing" @@ -81,7 +80,7 @@ func (suite *SimTestSuite) TestSimulateMsgSend() { suite.Require().NoError(err) var msg types.MsgSend - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().True(operationMsg.OK) suite.Require().Equal("65337742stake", msg.Amount.String()) @@ -110,7 +109,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSend() { require.NoError(err) var msg types.MsgMultiSend - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(operationMsg.OK) require.Len(msg.Inputs, 3) @@ -147,7 +146,7 @@ func (suite *SimTestSuite) TestSimulateModuleAccountMsgSend() { suite.Require().Error(err) var msg types.MsgSend - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().False(operationMsg.OK) suite.Require().Equal(operationMsg.Comment, "invalid transfers") @@ -176,7 +175,7 @@ func (suite *SimTestSuite) TestSimulateMsgMultiSendToModuleAccount() { suite.Require().Error(err) var msg types.MsgMultiSend - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().False(operationMsg.OK) // sending tokens to a module account should fail suite.Require().Equal(operationMsg.Comment, "invalid transfers") diff --git a/x/bank/spec/02_keepers.md b/x/bank/spec/02_keepers.md index 3671819a755d..71d35942b802 100644 --- a/x/bank/spec/02_keepers.md +++ b/x/bank/spec/02_keepers.md @@ -22,7 +22,7 @@ Typically, these addresses are module accounts. If these addresses receive funds outside the expected rules of the state machine, invariants are likely to be broken and could result in a halted network. -By providing the `x/bank` module with a blocklisted set of addresses, an error occurs for the operation if a user or client attempts to directly or indirectly send funds to a blocklisted account, for example, by using [IBC](http://docs.cosmos.network/master/ibc/). +By providing the `x/bank` module with a blocklisted set of addresses, an error occurs for the operation if a user or client attempts to directly or indirectly send funds to a blocklisted account, for example, by using [IBC](https://ibc.cosmos.network). ## Common Types diff --git a/x/bank/types/balance.go b/x/bank/types/balance.go index 78539ace6cff..56f73ae98219 100644 --- a/x/bank/types/balance.go +++ b/x/bank/types/balance.go @@ -50,6 +50,7 @@ func (b balanceByAddress) Len() int { return len(b.addresses) } func (b balanceByAddress) Less(i, j int) bool { return bytes.Compare(b.addresses[i], b.addresses[j]) < 0 } + func (b balanceByAddress) Swap(i, j int) { b.addresses[i], b.addresses[j] = b.addresses[j], b.addresses[i] b.balances[i], b.balances[j] = b.balances[j], b.balances[i] diff --git a/x/bank/types/balance_test.go b/x/bank/types/balance_test.go index 10ee2a74bf6e..5219388b7c2e 100644 --- a/x/bank/types/balance_test.go +++ b/x/bank/types/balance_test.go @@ -104,7 +104,6 @@ func TestBalanceValidate(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - err := tc.balance.Validate() if tc.expErr { diff --git a/x/bank/types/codec.go b/x/bank/types/codec.go index 498fb3272e0f..a4107c1cfdb6 100644 --- a/x/bank/types/codec.go +++ b/x/bank/types/codec.go @@ -4,9 +4,11 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/x/authz" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers the necessary x/bank interfaces and concrete types @@ -30,6 +32,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/bank/types/events.go b/x/bank/types/events.go index 9f06b85e491c..2293083e512e 100644 --- a/x/bank/types/events.go +++ b/x/bank/types/events.go @@ -9,7 +9,7 @@ const ( EventTypeTransfer = "transfer" AttributeKeyRecipient = "recipient" - AttributeKeySender = "sender" + AttributeKeySender = sdk.AttributeKeySender AttributeValueCategory = ModuleName diff --git a/x/bank/types/genesis_test.go b/x/bank/types/genesis_test.go index fa1c836c9cbe..f13329f71427 100644 --- a/x/bank/types/genesis_test.go +++ b/x/bank/types/genesis_test.go @@ -9,7 +9,6 @@ import ( ) func TestGenesisStateValidate(t *testing.T) { - testCases := []struct { name string genesisState GenesisState @@ -146,7 +145,6 @@ func TestGenesisStateValidate(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - err := tc.genesisState.Validate() if tc.expErr { diff --git a/x/bank/types/metadata_test.go b/x/bank/types/metadata_test.go index 3d4fe0a0e634..34ff32f6a0f1 100644 --- a/x/bank/types/metadata_test.go +++ b/x/bank/types/metadata_test.go @@ -218,7 +218,6 @@ func TestMetadataValidate(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - err := tc.metadata.Validate() if tc.expErr { @@ -240,18 +239,22 @@ func TestMarshalJSONMetaData(t *testing.T) { }{ {"nil metadata", nil, `null`}, {"empty metadata", []types.Metadata{}, `[]`}, - {"non-empty coins", []types.Metadata{{ - Description: "The native staking token of the Cosmos Hub.", - DenomUnits: []*types.DenomUnit{ - {"uatom", uint32(0), []string{"microatom"}}, // The default exponent value 0 is omitted in the json - {"matom", uint32(3), []string{"milliatom"}}, - {"atom", uint32(6), nil}, + { + "non-empty coins", + []types.Metadata{ + { + Description: "The native staking token of the Cosmos Hub.", + DenomUnits: []*types.DenomUnit{ + {"uatom", uint32(0), []string{"microatom"}}, // The default exponent value 0 is omitted in the json + {"matom", uint32(3), []string{"milliatom"}}, + {"atom", uint32(6), nil}, + }, + Base: "uatom", + Display: "atom", + }, }, - Base: "uatom", - Display: "atom", - }, + `[{"description":"The native staking token of the Cosmos Hub.","denom_units":[{"denom":"uatom","aliases":["microatom"]},{"denom":"matom","exponent":3,"aliases":["milliatom"]},{"denom":"atom","exponent":6}],"base":"uatom","display":"atom"}]`, }, - `[{"description":"The native staking token of the Cosmos Hub.","denom_units":[{"denom":"uatom","aliases":["microatom"]},{"denom":"matom","exponent":3,"aliases":["milliatom"]},{"denom":"atom","exponent":6}],"base":"uatom","display":"atom"}]`}, } for _, tc := range testCases { diff --git a/x/bank/types/msgs.go b/x/bank/types/msgs.go index f04433a6bb14..8030e04519f3 100644 --- a/x/bank/types/msgs.go +++ b/x/bank/types/msgs.go @@ -1,7 +1,6 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -49,7 +48,7 @@ func (msg MsgSend) ValidateBasic() error { // GetSignBytes Implements Msg. func (msg MsgSend) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } // GetSigners Implements Msg. @@ -88,7 +87,7 @@ func (msg MsgMultiSend) ValidateBasic() error { // GetSignBytes Implements Msg. func (msg MsgMultiSend) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } // GetSigners Implements Msg. diff --git a/x/bank/types/msgs_test.go b/x/bank/types/msgs_test.go index d11f78711591..523a57f28f38 100644 --- a/x/bank/types/msgs_test.go +++ b/x/bank/types/msgs_test.go @@ -6,13 +6,14 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" ) func TestMsgSendRoute(t *testing.T) { addr1 := sdk.AccAddress([]byte("from")) addr2 := sdk.AccAddress([]byte("to")) coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10)) - var msg = NewMsgSend(addr1, addr2, coins) + msg := NewMsgSend(addr1, addr2, coins) require.Equal(t, msg.Route(), RouterKey) require.Equal(t, msg.Type(), "send") @@ -57,7 +58,7 @@ func TestMsgSendGetSignBytes(t *testing.T) { addr1 := sdk.AccAddress([]byte("input")) addr2 := sdk.AccAddress([]byte("output")) coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10)) - var msg = NewMsgSend(addr1, addr2, coins) + msg := NewMsgSend(addr1, addr2, coins) res := msg.GetSignBytes() expected := `{"type":"cosmos-sdk/MsgSend","value":{"amount":[{"amount":"10","denom":"atom"}],"from_address":"cosmos1d9h8qat57ljhcm","to_address":"cosmos1da6hgur4wsmpnjyg"}}` @@ -69,7 +70,7 @@ func TestMsgMultiSendRoute(t *testing.T) { addr1 := sdk.AccAddress([]byte("input")) addr2 := sdk.AccAddress([]byte("output")) coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10)) - var msg = MsgMultiSend{ + msg := MsgMultiSend{ Inputs: []Input{NewInput(addr1, coins)}, Outputs: []Output{NewOutput(addr2, coins)}, } @@ -184,24 +185,47 @@ func TestMsgMultiSendValidation(t *testing.T) { {false, MsgMultiSend{}}, // no input or output {false, MsgMultiSend{Inputs: []Input{input1}}}, // just input {false, MsgMultiSend{Outputs: []Output{output1}}}, // just output - {false, MsgMultiSend{ - Inputs: []Input{NewInput(emptyAddr, atom123)}, // invalid input - Outputs: []Output{output1}}}, - {false, MsgMultiSend{ - Inputs: []Input{input1}, - Outputs: []Output{{emptyAddr.String(), atom123}}}, // invalid output + { + false, + MsgMultiSend{ + Inputs: []Input{NewInput(emptyAddr, atom123)}, // invalid input + Outputs: []Output{output1}, + }, }, - {false, MsgMultiSend{ - Inputs: []Input{input1}, - Outputs: []Output{output2}}, // amounts dont match + { + false, + MsgMultiSend{ + Inputs: []Input{input1}, + Outputs: []Output{{emptyAddr.String(), atom123}}, // invalid output + }, }, - {true, MsgMultiSend{ - Inputs: []Input{input1}, - Outputs: []Output{output1}}, + { + false, + MsgMultiSend{ + Inputs: []Input{input1}, + Outputs: []Output{output2}, // amounts dont match + }, }, - {true, MsgMultiSend{ - Inputs: []Input{input1, input2}, - Outputs: []Output{outputMulti}}, + { + true, + MsgMultiSend{ + Inputs: []Input{input1}, + Outputs: []Output{output1}, + }, + }, + { + true, + MsgMultiSend{ + Inputs: []Input{input1, input2}, + Outputs: []Output{outputMulti}, + }, + }, + { + true, + MsgMultiSend{ + Inputs: []Input{NewInput(addr2, atom123.MulInt(types.NewInt(2)))}, + Outputs: []Output{output1, output1}, + }, }, } @@ -219,7 +243,7 @@ func TestMsgMultiSendGetSignBytes(t *testing.T) { addr1 := sdk.AccAddress([]byte("input")) addr2 := sdk.AccAddress([]byte("output")) coins := sdk.NewCoins(sdk.NewInt64Coin("atom", 10)) - var msg = MsgMultiSend{ + msg := MsgMultiSend{ Inputs: []Input{NewInput(addr1, coins)}, Outputs: []Output{NewOutput(addr2, coins)}, } @@ -237,7 +261,7 @@ func TestMsgMultiSendGetSigners(t *testing.T) { inputs[i] = NewInput(addr, nil) addrs[i] = addr.String() } - var msg = NewMsgMultiSend(inputs, nil) + msg := NewMsgMultiSend(inputs, nil) res := msg.GetSigners() for i, signer := range res { diff --git a/x/bank/types/query.pb.go b/x/bank/types/query.pb.go index 922e7f5a27d9..80f94f5ec6ff 100644 --- a/x/bank/types/query.pb.go +++ b/x/bank/types/query.pb.go @@ -219,6 +219,8 @@ func (m *QueryAllBalancesResponse) GetPagination() *query.PageResponse { // QuerySpendableBalancesRequest defines the gRPC request structure for querying // an account's spendable balances. +// +// Since: cosmos-sdk 0.46 type QuerySpendableBalancesRequest struct { // address is the address to query spendable balances for. Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` @@ -261,6 +263,8 @@ var xxx_messageInfo_QuerySpendableBalancesRequest proto.InternalMessageInfo // QuerySpendableBalancesResponse defines the gRPC response structure for querying // an account's spendable balances. +// +// Since: cosmos-sdk 0.46 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"` @@ -844,6 +848,8 @@ func (m *QueryDenomOwnersRequest) GetPagination() *query.PageRequest { // DenomOwner defines structure representing an account that owns or holds a // particular denominated token. It contains the account address and account // balance of the denominated token. +// +// Since: cosmos-sdk 0.46 type DenomOwner struct { // address defines the address that owns a particular denomination. Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` @@ -899,6 +905,8 @@ func (m *DenomOwner) GetBalance() types.Coin { } // QueryDenomOwnersResponse defines the RPC response of a DenomOwners RPC query. +// +// Since: cosmos-sdk 0.46 type QueryDenomOwnersResponse struct { DenomOwners []*DenomOwner `protobuf:"bytes,1,rep,name=denom_owners,json=denomOwners,proto3" json:"denom_owners,omitempty"` // pagination defines the pagination in the response. @@ -1061,6 +1069,8 @@ type QueryClient interface { AllBalances(ctx context.Context, in *QueryAllBalancesRequest, opts ...grpc.CallOption) (*QueryAllBalancesResponse, error) // SpendableBalances queries the spenable balance of all coins for a single // account. + // + // Since: cosmos-sdk 0.46 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) @@ -1075,6 +1085,8 @@ type QueryClient interface { DenomsMetadata(ctx context.Context, in *QueryDenomsMetadataRequest, opts ...grpc.CallOption) (*QueryDenomsMetadataResponse, error) // DenomOwners queries for all account addresses that own a particular token // denomination. + // + // Since: cosmos-sdk 0.46 DenomOwners(ctx context.Context, in *QueryDenomOwnersRequest, opts ...grpc.CallOption) (*QueryDenomOwnersResponse, error) } @@ -1175,6 +1187,8 @@ type QueryServer interface { AllBalances(context.Context, *QueryAllBalancesRequest) (*QueryAllBalancesResponse, error) // SpendableBalances queries the spenable balance of all coins for a single // account. + // + // Since: cosmos-sdk 0.46 SpendableBalances(context.Context, *QuerySpendableBalancesRequest) (*QuerySpendableBalancesResponse, error) // TotalSupply queries the total supply of all coins. TotalSupply(context.Context, *QueryTotalSupplyRequest) (*QueryTotalSupplyResponse, error) @@ -1189,6 +1203,8 @@ type QueryServer interface { DenomsMetadata(context.Context, *QueryDenomsMetadataRequest) (*QueryDenomsMetadataResponse, error) // DenomOwners queries for all account addresses that own a particular token // denomination. + // + // Since: cosmos-sdk 0.46 DenomOwners(context.Context, *QueryDenomOwnersRequest) (*QueryDenomOwnersResponse, error) } diff --git a/x/bank/types/send_authorization.go b/x/bank/types/send_authorization.go index 08a7b641fe48..7eb90b594918 100644 --- a/x/bank/types/send_authorization.go +++ b/x/bank/types/send_authorization.go @@ -6,9 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/authz" ) -var ( - _ authz.Authorization = &SendAuthorization{} -) +var _ authz.Authorization = &SendAuthorization{} // NewSendAuthorization creates a new SendAuthorization object. func NewSendAuthorization(spendLimit sdk.Coins) *SendAuthorization { @@ -28,7 +26,7 @@ func (a SendAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRes if !ok { return authz.AcceptResponse{}, sdkerrors.ErrInvalidType.Wrap("type mismatch") } - limitLeft, isNegative := a.SpendLimit.SafeSub(mSend.Amount) + limitLeft, isNegative := a.SpendLimit.SafeSub(mSend.Amount...) if isNegative { return authz.AcceptResponse{}, sdkerrors.ErrInsufficientFunds.Wrapf("requested amount is more than spend limit") } diff --git a/x/capability/keeper/keeper.go b/x/capability/keeper/keeper.go index cea524563491..708456ed3c64 100644 --- a/x/capability/keeper/keeper.go +++ b/x/capability/keeper/keeper.go @@ -197,7 +197,6 @@ func (k Keeper) GetOwners(ctx sdk.Context, index uint64) (types.CapabilityOwners // and sets the fwd and reverse keys for each owner in the memstore. // It is used during initialization from genesis. func (k Keeper) InitializeCapability(ctx sdk.Context, index uint64, owners types.CapabilityOwners) { - memStore := ctx.KVStore(k.memKey) cap := types.NewCapability(index) @@ -215,7 +214,6 @@ func (k Keeper) InitializeCapability(ctx sdk.Context, index uint64, owners types // Set the mapping from index from index to in-memory capability in the go map k.capMap[index] = cap } - } // NewCapability attempts to create a new capability with a given name. If the diff --git a/x/capability/module.go b/x/capability/module.go index f8295948d9b7..e2ac1709795c 100644 --- a/x/capability/module.go +++ b/x/capability/module.go @@ -6,7 +6,6 @@ import ( "math/rand" "time" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -68,10 +67,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return genState.Validate() } -// RegisterRESTRoutes registers the REST routes for the capability module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the capability module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) { } diff --git a/x/capability/simulation/genesis_test.go b/x/capability/simulation/genesis_test.go index 16d54c177a50..14eb344cc093 100644 --- a/x/capability/simulation/genesis_test.go +++ b/x/capability/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -29,7 +30,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/capability/spec/01_concepts.md b/x/capability/spec/01_concepts.md index bb236a21ea86..93ecb6354ac7 100644 --- a/x/capability/spec/01_concepts.md +++ b/x/capability/spec/01_concepts.md @@ -32,3 +32,4 @@ not own. ## Stores * MemStore +* KeyStore diff --git a/x/capability/spec/02_state.md b/x/capability/spec/02_state.md index b93de4bf4ab7..3ab713bdb90d 100644 --- a/x/capability/spec/02_state.md +++ b/x/capability/spec/02_state.md @@ -3,9 +3,24 @@ order: 2 --> # State +## In persisted KV store -## Index +1. Global unique capability index +2. Capability owners -## CapabilityOwners +Indexes: -## Capability +* Unique index: `[]byte("index") -> []byte(currentGlobalIndex)` +* Capability Index: `[]byte("capability_index") | []byte(index) -> ProtocolBuffer(CapabilityOwners)` + +## In-memory KV store + +1. Initialized flag +2. Mapping between the module and capability tuple and the capability name +3. Mapping between the module and capability name and its index + +Indexes: + +* Initialized flag: `[]byte("mem_initialized")` +* RevCapabilityKey: `[]byte(moduleName + "/rev/" + capabilityName) -> []byte(index)` +* FwdCapabilityKey: `[]byte(moduleName + "/fwd/" + capabilityPointerAddress) -> []byte(capabilityName)` diff --git a/x/capability/spec/README.md b/x/capability/spec/README.md index ec612ba97697..db5289df5bc2 100644 --- a/x/capability/spec/README.md +++ b/x/capability/spec/README.md @@ -53,18 +53,19 @@ func NewApp(...) *App { After the keeper is created, it can be used to create scoped sub-keepers which are passed to other modules that can create, authenticate, and claim capabilities. After all the necessary scoped keepers are created and the state is loaded, the -main capability keeper must be initialized and sealed to populate the in-memory -state and to prevent further scoped keepers from being created. +main capability keeper must be sealed to prevent further scoped keepers from +being created. ```go func NewApp(...) *App { // ... - // Initialize and seal the capability keeper so all persistent capabilities - // are loaded in-memory and prevent any further modules from creating scoped + // Creating a scoped keeper + scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName) + + // Seal the capability keeper to prevent any further modules from creating scoped // sub-keepers. - ctx := app.BaseApp.NewContext(true, tmproto.Header{}) - app.capabilityKeeper.InitializeAndSeal(ctx) + app.capabilityKeeper.Seal() return app } diff --git a/x/capability/types/genesis_test.go b/x/capability/types/genesis_test.go index d8a02e019254..5208a2b59043 100644 --- a/x/capability/types/genesis_test.go +++ b/x/capability/types/genesis_test.go @@ -40,7 +40,6 @@ func TestValidateGenesis(t *testing.T) { } genState.Owners = append(genState.Owners, genOwner) - }, expPass: false, }, @@ -55,7 +54,6 @@ func TestValidateGenesis(t *testing.T) { } genState.Owners = append(genState.Owners, genOwner) - }, expPass: false, }, @@ -69,7 +67,6 @@ func TestValidateGenesis(t *testing.T) { } genState.Owners = append(genState.Owners, genOwner) - }, expPass: false, }, @@ -83,7 +80,6 @@ func TestValidateGenesis(t *testing.T) { } genState.Owners = append(genState.Owners, genOwner) - }, expPass: false, }, @@ -97,7 +93,6 @@ func TestValidateGenesis(t *testing.T) { } genState.Owners = append(genState.Owners, genOwner) - }, expPass: false, }, @@ -111,7 +106,6 @@ func TestValidateGenesis(t *testing.T) { } genState.Owners = append(genState.Owners, genOwner) - }, expPass: false, }, diff --git a/x/capability/types/keys.go b/x/capability/types/keys.go index aefd13ba2286..eccfba00a55f 100644 --- a/x/capability/types/keys.go +++ b/x/capability/types/keys.go @@ -23,7 +23,7 @@ var ( KeyIndex = []byte("index") // KeyPrefixIndexCapability defines a key prefix that stores index to capability - // name mappings. + // owners mappings. KeyPrefixIndexCapability = []byte("capability_index") // KeyMemInitialized defines the key that stores the initialized flag in the memory store @@ -39,7 +39,7 @@ func RevCapabilityKey(module, name string) []byte { // FwdCapabilityKey returns a forward lookup key for a given module and capability // reference. func FwdCapabilityKey(module string, cap *Capability) []byte { - return []byte(fmt.Sprintf("%s/fwd/%p", module, cap)) + return []byte(fmt.Sprintf("%s/fwd/%#016p", module, cap)) } // IndexToKey returns bytes to be used as a key for a given capability index. diff --git a/x/capability/types/keys_test.go b/x/capability/types/keys_test.go index e767c3d34222..1ac4702ba581 100644 --- a/x/capability/types/keys_test.go +++ b/x/capability/types/keys_test.go @@ -16,7 +16,7 @@ func TestRevCapabilityKey(t *testing.T) { func TestFwdCapabilityKey(t *testing.T) { cap := types.NewCapability(23) - expected := []byte(fmt.Sprintf("bank/fwd/%p", cap)) + expected := []byte(fmt.Sprintf("bank/fwd/%#016p", cap)) require.Equal(t, expected, types.FwdCapabilityKey("bank", cap)) } diff --git a/x/crisis/client/testsuite/cli_test.go b/x/crisis/client/testsuite/cli_test.go index 3c083e694726..5b3ef61c5a45 100644 --- a/x/crisis/client/testsuite/cli_test.go +++ b/x/crisis/client/testsuite/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/crisis/keeper/keeper.go b/x/crisis/keeper/keeper.go index b9c563d5293d..2408b0bd0aa1 100644 --- a/x/crisis/keeper/keeper.go +++ b/x/crisis/keeper/keeper.go @@ -27,7 +27,6 @@ func NewKeeper( paramSpace paramtypes.Subspace, invCheckPeriod uint, supplyKeeper types.SupplyKeeper, feeCollectorName string, ) Keeper { - // set KeyTable if it has not already been set if !paramSpace.HasKeyTable() { paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) diff --git a/x/crisis/migrations/v039/types.go b/x/crisis/migrations/v039/types.go deleted file mode 100644 index 44903e349118..000000000000 --- a/x/crisis/migrations/v039/types.go +++ /dev/null @@ -1,13 +0,0 @@ -package v039 - -import sdk "github.com/cosmos/cosmos-sdk/types" - -const ( - ModuleName = "crisis" -) - -type ( - GenesisState struct { - ConstantFee sdk.Coin `json:"constant_fee" yaml:"constant_fee"` - } -) diff --git a/x/crisis/migrations/v040/migrate.go b/x/crisis/migrations/v040/migrate.go deleted file mode 100644 index ed8255723ff6..000000000000 --- a/x/crisis/migrations/v040/migrate.go +++ /dev/null @@ -1,16 +0,0 @@ -package v040 - -import ( - v039crisis "github.com/cosmos/cosmos-sdk/x/crisis/migrations/v039" - v040crisis "github.com/cosmos/cosmos-sdk/x/crisis/types" -) - -// Migrate accepts exported v0.39 x/crisis genesis state and -// migrates it to v0.40 x/crisis genesis state. The migration includes: -// -// - Re-encode in v0.40 GenesisState. -func Migrate(crisisGenState v039crisis.GenesisState) *v040crisis.GenesisState { - return &v040crisis.GenesisState{ - ConstantFee: crisisGenState.ConstantFee, - } -} diff --git a/x/crisis/migrations/v040/types.go b/x/crisis/migrations/v040/types.go deleted file mode 100644 index 68c25e93eec1..000000000000 --- a/x/crisis/migrations/v040/types.go +++ /dev/null @@ -1,5 +0,0 @@ -package v040 - -const ( - ModuleName = "crisis" -) diff --git a/x/crisis/module.go b/x/crisis/module.go index 428e8adc1a05..7c058a4f22e0 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -5,7 +5,6 @@ import ( "fmt" "time" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -60,10 +59,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(&data) } -// RegisterRESTRoutes registers REST routes for the crisis module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the capability module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} diff --git a/x/crisis/types/codec.go b/x/crisis/types/codec.go index 868ebaa919bb..324ef56891ea 100644 --- a/x/crisis/types/codec.go +++ b/x/crisis/types/codec.go @@ -4,8 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers the necessary x/crisis interfaces and concrete types @@ -22,6 +24,17 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/crisis/types/msgs.go b/x/crisis/types/msgs.go index bd9c60e936d9..a5450b010e7f 100644 --- a/x/crisis/types/msgs.go +++ b/x/crisis/types/msgs.go @@ -1,7 +1,6 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -30,7 +29,7 @@ func (msg MsgVerifyInvariant) GetSigners() []sdk.AccAddress { // GetSignBytes gets the sign bytes for the msg MsgVerifyInvariant func (msg MsgVerifyInvariant) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } diff --git a/x/crisis/types/params.go b/x/crisis/types/params.go index 880f350f117c..03c8dd82883f 100644 --- a/x/crisis/types/params.go +++ b/x/crisis/types/params.go @@ -7,10 +7,8 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) -var ( - // key for constant fee parameter - ParamStoreKeyConstantFee = []byte("ConstantFee") -) +// key for constant fee parameter +var ParamStoreKeyConstantFee = []byte("ConstantFee") // type declaration for parameters func ParamKeyTable() paramtypes.KeyTable { diff --git a/x/distribution/client/cli/tx.go b/x/distribution/client/cli/tx.go index 9971bc938034..24174d9d080c 100644 --- a/x/distribution/client/cli/tx.go +++ b/x/distribution/client/cli/tx.go @@ -52,7 +52,6 @@ func newSplitAndApply( genOrBroadcastFn newGenerateOrBroadcastFunc, clientCtx client.Context, fs *pflag.FlagSet, msgs []sdk.Msg, chunkSize int, ) error { - if chunkSize == 0 { return genOrBroadcastFn(clientCtx, fs, msgs...) } @@ -75,6 +74,7 @@ func newSplitAndApply( return nil } +// NewWithdrawRewardsCmd returns a CLI command handler for creating a MsgWithdrawDelegatorReward transaction. func NewWithdrawRewardsCmd() *cobra.Command { bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() @@ -120,6 +120,7 @@ $ %s tx distribution withdraw-rewards %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj return cmd } +// NewWithdrawAllRewardsCmd returns a CLI command handler for creating a MsgWithdrawDelegatorReward transaction. func NewWithdrawAllRewardsCmd() *cobra.Command { cmd := &cobra.Command{ Use: "withdraw-all-rewards", @@ -183,6 +184,7 @@ $ %[1]s tx distribution withdraw-all-rewards --from mykey return cmd } +// NewSetWithdrawAddrCmd returns a CLI command handler for creating a MsgSetWithdrawAddress transaction. func NewSetWithdrawAddrCmd() *cobra.Command { bech32PrefixAccAddr := sdk.GetConfig().GetBech32AccountAddrPrefix() @@ -221,6 +223,7 @@ $ %s tx distribution set-withdraw-addr %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p return cmd } +// NewFundCommunityPoolCmd returns a CLI command handler for creating a MsgFundCommunityPool transaction. func NewFundCommunityPoolCmd() *cobra.Command { cmd := &cobra.Command{ Use: "fund-community-pool [amount]", diff --git a/x/distribution/client/common/common_test.go b/x/distribution/client/common/common_test.go index 3a6cf8c9b547..ff9bb88d1766 100644 --- a/x/distribution/client/common/common_test.go +++ b/x/distribution/client/common/common_test.go @@ -1,9 +1,10 @@ package common import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" "testing" + "github.com/cosmos/cosmos-sdk/codec/legacy" + "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/client" diff --git a/x/distribution/client/testutil/suite.go b/x/distribution/client/testutil/suite.go index ac912952be25..fdf9648b659e 100644 --- a/x/distribution/client/testutil/suite.go +++ b/x/distribution/client/testutil/suite.go @@ -472,7 +472,8 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, - true, 0, nil, []string{}, + true, 0, nil, + []string{}, }, { "valid transaction", @@ -483,7 +484,8 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, - false, 0, &sdk.TxResponse{}, []string{ + false, 0, &sdk.TxResponse{}, + []string{ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", }, }, @@ -497,7 +499,8 @@ func (s *IntegrationTestSuite) TestNewWithdrawRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, - false, 0, &sdk.TxResponse{}, []string{ + false, 0, &sdk.TxResponse{}, + []string{ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommissionResponse", }, @@ -570,7 +573,8 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, - true, 0, nil, []string{}, + true, 0, nil, + []string{}, }, { "valid transaction", @@ -580,7 +584,8 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), }, - false, 0, &sdk.TxResponse{}, []string{ + false, 0, &sdk.TxResponse{}, + []string{ "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorRewardResponse", }, }, @@ -590,7 +595,6 @@ func (s *IntegrationTestSuite) TestNewWithdrawAllRewardsCmd() { tc := tc s.Run(tc.name, func() { - cmd := cli.NewWithdrawAllRewardsCmd() clientCtx := val.ClientCtx @@ -757,11 +761,13 @@ func (s *IntegrationTestSuite) TestGetCmdSubmitProposal() { }` // fund some tokens to the community pool - args := []string{sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))).String(), + args := []string{ + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5431))).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String())} + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } invalidPropFile := testutil.WriteToNewTempFile(s.T(), invalidProp) cmd := cli.NewFundCommunityPoolCmd() diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index ad9ef55ad07c..273db1314eb8 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -17,7 +17,6 @@ func (k Keeper) AllocateTokens( ctx sdk.Context, sumPreviousPrecommitPower, totalPreviousPower int64, previousProposer sdk.ConsAddress, bondedVotes []abci.VoteInfo, ) { - logger := k.Logger(ctx) // fetch and clear the collected fees for distribution, since this is diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go index 61631da5dc22..3b158c15585e 100644 --- a/x/distribution/keeper/delegation.go +++ b/x/distribution/keeper/delegation.go @@ -29,7 +29,8 @@ func (k Keeper) initializeDelegation(ctx sdk.Context, val sdk.ValAddress, del sd // calculate the rewards accrued by a delegation between two periods func (k Keeper) calculateDelegationRewardsBetween(ctx sdk.Context, val stakingtypes.ValidatorI, - startingPeriod, endingPeriod uint64, stake sdk.Dec) (rewards sdk.DecCoins) { + startingPeriod, endingPeriod uint64, stake sdk.Dec, +) (rewards sdk.DecCoins) { // sanity check if startingPeriod > endingPeriod { panic("startingPeriod cannot be greater than endingPeriod") diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index a1916913c424..7b18c0241f3b 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -117,7 +117,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { // allocate some rewards initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}} + tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial)}} app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens) // end period @@ -127,10 +127,10 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod) // rewards should be half the tokens - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoRaw(2).ToDec()}}, rewards) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial.QuoRaw(2))}}, rewards) // commission should be the other half - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoRaw(2).ToDec()}}, + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial.QuoRaw(2))}}, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission) } @@ -180,7 +180,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { // allocate some rewards initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}} + tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial)}} app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens) // slash the validator by 50% again @@ -202,10 +202,10 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { rewards = app.DistrKeeper.CalculateDelegationRewards(ctx, val, del, endingPeriod) // rewards should be half the tokens - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}, rewards) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial)}}, rewards) // commission should be the other half - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}, + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecFromInt(initial)}}, app.DistrKeeper.GetValidatorAccumulatedCommission(ctx, valAddrs[0]).Commission) } @@ -381,7 +381,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 3) // allocate some rewards - initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec() + initial := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)) tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}} app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens) @@ -437,7 +437,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { del1 := app.StakingKeeper.Delegation(ctx, sdk.AccAddress(valAddrs[0]), valAddrs[0]) // allocate some rewards - initial := app.StakingKeeper.TokensFromConsensusPower(ctx, 30).ToDec() + initial := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 30)) tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}} app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens) diff --git a/x/distribution/keeper/grpc_query.go b/x/distribution/keeper/grpc_query.go index 5cf71bbb102d..2779822293fe 100644 --- a/x/distribution/keeper/grpc_query.go +++ b/x/distribution/keeper/grpc_query.go @@ -93,7 +93,6 @@ func (k Keeper) ValidatorSlashes(c context.Context, req *types.QueryValidatorSla pageRes, err := query.FilteredPaginate(slashesStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { var result types.ValidatorSlashEvent err := k.cdc.Unmarshal(value, &result) - if err != nil { return false, err } @@ -107,7 +106,6 @@ func (k Keeper) ValidatorSlashes(c context.Context, req *types.QueryValidatorSla } return true, nil }) - if err != nil { return nil, err } diff --git a/x/distribution/keeper/hooks.go b/x/distribution/keeper/hooks.go index 0c66d44e33e7..bfae8482da5e 100644 --- a/x/distribution/keeper/hooks.go +++ b/x/distribution/keeper/hooks.go @@ -113,9 +113,11 @@ func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress) error { func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error { return nil } + func (h Hooks) AfterValidatorBeginUnbonding(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error { return nil } + func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { return nil } diff --git a/x/distribution/keeper/invariants.go b/x/distribution/keeper/invariants.go index 0a23d36be8f7..50300b977379 100644 --- a/x/distribution/keeper/invariants.go +++ b/x/distribution/keeper/invariants.go @@ -64,7 +64,6 @@ func NonNegativeOutstandingInvariant(k Keeper) sdk.Invariant { // CanWithdrawInvariant checks that current rewards can be completely withdrawn func CanWithdrawInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { - // cache, we don't want to write changes ctx, _ = ctx.CacheContext() @@ -106,7 +105,6 @@ func CanWithdrawInvariant(k Keeper) sdk.Invariant { // ReferenceCountInvariant checks that the number of historical rewards records is correct func ReferenceCountInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { - valCount := uint64(0) k.stakingKeeper.IterateValidators(ctx, func(_ int64, val stakingtypes.ValidatorI) (stop bool) { valCount++ @@ -137,7 +135,6 @@ func ReferenceCountInvariant(k Keeper) sdk.Invariant { // is consistent with the sum of validator outstanding rewards func ModuleAccountInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { - var expectedCoins sdk.DecCoins k.IterateValidatorOutstandingRewards(ctx, func(_ sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool) { expectedCoins = expectedCoins.Add(rewards.Rewards...) diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index 50536b2698e8..6af1ede7e5cd 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -31,7 +31,6 @@ func NewKeeper( ak types.AccountKeeper, bk types.BankKeeper, sk types.StakingKeeper, feeCollectorName string, ) Keeper { - // ensure distribution module account is set if addr := ak.GetModuleAddress(types.ModuleName); addr == nil { panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) diff --git a/x/distribution/keeper/store.go b/x/distribution/keeper/store.go index 0203ee13f672..3def35163f5c 100644 --- a/x/distribution/keeper/store.go +++ b/x/distribution/keeper/store.go @@ -331,7 +331,8 @@ func (k Keeper) SetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, heig // iterate over slash events between heights, inclusive func (k Keeper) IterateValidatorSlashEventsBetween(ctx sdk.Context, val sdk.ValAddress, startingHeight uint64, endingHeight uint64, - handler func(height uint64, event types.ValidatorSlashEvent) (stop bool)) { + handler func(height uint64, event types.ValidatorSlashEvent) (stop bool), +) { store := ctx.KVStore(k.storeKey) iter := store.Iterator( types.GetValidatorSlashEventKeyPrefix(val, startingHeight), diff --git a/x/distribution/keeper/validator.go b/x/distribution/keeper/validator.go index 3d1953c3b5fa..38654e771a0b 100644 --- a/x/distribution/keeper/validator.go +++ b/x/distribution/keeper/validator.go @@ -45,7 +45,7 @@ func (k Keeper) IncrementValidatorPeriod(ctx sdk.Context, val stakingtypes.Valid current = sdk.DecCoins{} } else { // note: necessary to truncate so we don't allow withdrawing more rewards than owed - current = rewards.Rewards.QuoDecTruncate(val.GetTokens().ToDec()) + current = rewards.Rewards.QuoDecTruncate(sdk.NewDecFromInt(val.GetTokens())) } // fetch historical rewards for last period diff --git a/x/distribution/migrations/v034/types.go b/x/distribution/migrations/v034/types.go deleted file mode 100644 index e32b92a5cf55..000000000000 --- a/x/distribution/migrations/v034/types.go +++ /dev/null @@ -1,100 +0,0 @@ -// Package v034 is used for legacy migration scripts. Actual migration scripts -// for v034 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -// DONTCOVER -package v034 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// ---------------------------------------------------------------------------- -// Types and Constants -// ---------------------------------------------------------------------------- - -const ( - ModuleName = "distr" -) - -type ( - ValidatorAccumulatedCommission = sdk.DecCoins - - DelegatorStartingInfo struct { - PreviousPeriod uint64 `json:"previous_period"` - Stake sdk.Dec `json:"stake"` - Height uint64 `json:"height"` - } - - DelegatorWithdrawInfo struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - WithdrawAddress sdk.AccAddress `json:"withdraw_address"` - } - - ValidatorOutstandingRewardsRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - OutstandingRewards sdk.DecCoins `json:"outstanding_rewards"` - } - - ValidatorAccumulatedCommissionRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Accumulated ValidatorAccumulatedCommission `json:"accumulated"` - } - - ValidatorHistoricalRewardsRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Period uint64 `json:"period"` - Rewards ValidatorHistoricalRewards `json:"rewards"` - } - - ValidatorHistoricalRewards struct { - CumulativeRewardRatio sdk.DecCoins `json:"cumulative_reward_ratio"` - ReferenceCount uint16 `json:"reference_count"` - } - - ValidatorCurrentRewards struct { - Rewards sdk.DecCoins `json:"rewards"` - Period uint64 `json:"period"` - } - - ValidatorCurrentRewardsRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Rewards ValidatorCurrentRewards `json:"rewards"` - } - - DelegatorStartingInfoRecord struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` - StartingInfo DelegatorStartingInfo `json:"starting_info"` - } - - ValidatorSlashEventRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Height uint64 `json:"height"` - Event ValidatorSlashEvent `json:"validator_slash_event"` - } - - FeePool struct { - CommunityPool sdk.DecCoins `json:"community_pool"` - } - - ValidatorSlashEvent struct { - ValidatorPeriod uint64 `json:"validator_period"` - Fraction sdk.Dec `json:"fraction"` - } - - GenesisState struct { - FeePool FeePool `json:"fee_pool"` - CommunityTax sdk.Dec `json:"community_tax"` - BaseProposerReward sdk.Dec `json:"base_proposer_reward"` - BonusProposerReward sdk.Dec `json:"bonus_proposer_reward"` - WithdrawAddrEnabled bool `json:"withdraw_addr_enabled"` - DelegatorWithdrawInfos []DelegatorWithdrawInfo `json:"delegator_withdraw_infos"` - PreviousProposer sdk.ConsAddress `json:"previous_proposer"` - OutstandingRewards []ValidatorOutstandingRewardsRecord `json:"outstanding_rewards"` - ValidatorAccumulatedCommissions []ValidatorAccumulatedCommissionRecord `json:"validator_accumulated_commissions"` - ValidatorHistoricalRewards []ValidatorHistoricalRewardsRecord `json:"validator_historical_rewards"` - ValidatorCurrentRewards []ValidatorCurrentRewardsRecord `json:"validator_current_rewards"` - DelegatorStartingInfos []DelegatorStartingInfoRecord `json:"delegator_starting_infos"` - ValidatorSlashEvents []ValidatorSlashEventRecord `json:"validator_slash_events"` - } -) diff --git a/x/distribution/migrations/v036/types.go b/x/distribution/migrations/v036/types.go deleted file mode 100644 index df1e55a99350..000000000000 --- a/x/distribution/migrations/v036/types.go +++ /dev/null @@ -1,136 +0,0 @@ -// Package v036 is used for legacy migration scripts. Actual migration scripts -// for v036 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -// DONTCOVER -package v036 - -import ( - "fmt" - "strings" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - v034distr "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v034" - "github.com/cosmos/cosmos-sdk/x/distribution/types" - v036gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v036" -) - -// ---------------------------------------------------------------------------- -// Types and Constants -// ---------------------------------------------------------------------------- - -const ( - ModuleName = "distribution" - - // RouterKey is the message route for distribution - RouterKey = ModuleName - - // ProposalTypeCommunityPoolSpend defines the type for a CommunityPoolSpendProposal - ProposalTypeCommunityPoolSpend = "CommunityPoolSpend" -) - -type ( - ValidatorAccumulatedCommission = sdk.DecCoins - - ValidatorSlashEventRecord struct { - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Height uint64 `json:"height"` - Period uint64 `json:"period"` - Event v034distr.ValidatorSlashEvent `json:"validator_slash_event"` - } - - GenesisState struct { - FeePool v034distr.FeePool `json:"fee_pool"` - CommunityTax sdk.Dec `json:"community_tax"` - BaseProposerReward sdk.Dec `json:"base_proposer_reward"` - BonusProposerReward sdk.Dec `json:"bonus_proposer_reward"` - WithdrawAddrEnabled bool `json:"withdraw_addr_enabled"` - DelegatorWithdrawInfos []v034distr.DelegatorWithdrawInfo `json:"delegator_withdraw_infos"` - PreviousProposer sdk.ConsAddress `json:"previous_proposer"` - OutstandingRewards []v034distr.ValidatorOutstandingRewardsRecord `json:"outstanding_rewards"` - ValidatorAccumulatedCommissions []v034distr.ValidatorAccumulatedCommissionRecord `json:"validator_accumulated_commissions"` - ValidatorHistoricalRewards []v034distr.ValidatorHistoricalRewardsRecord `json:"validator_historical_rewards"` - ValidatorCurrentRewards []v034distr.ValidatorCurrentRewardsRecord `json:"validator_current_rewards"` - DelegatorStartingInfos []v034distr.DelegatorStartingInfoRecord `json:"delegator_starting_infos"` - ValidatorSlashEvents []ValidatorSlashEventRecord `json:"validator_slash_events"` - } - - // CommunityPoolSpendProposal spends from the community pool - CommunityPoolSpendProposal struct { - Title string `json:"title" yaml:"title"` - Description string `json:"description" yaml:"description"` - Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"` - Amount sdk.Coins `json:"amount" yaml:"amount"` - } -) - -func NewGenesisState( - feePool v034distr.FeePool, communityTax, baseProposerReward, bonusProposerReward sdk.Dec, - withdrawAddrEnabled bool, dwis []v034distr.DelegatorWithdrawInfo, pp sdk.ConsAddress, - r []v034distr.ValidatorOutstandingRewardsRecord, acc []v034distr.ValidatorAccumulatedCommissionRecord, - historical []v034distr.ValidatorHistoricalRewardsRecord, cur []v034distr.ValidatorCurrentRewardsRecord, - dels []v034distr.DelegatorStartingInfoRecord, slashes []ValidatorSlashEventRecord, -) GenesisState { - - return GenesisState{ - FeePool: feePool, - CommunityTax: communityTax, - BaseProposerReward: baseProposerReward, - BonusProposerReward: bonusProposerReward, - WithdrawAddrEnabled: withdrawAddrEnabled, - DelegatorWithdrawInfos: dwis, - PreviousProposer: pp, - OutstandingRewards: r, - ValidatorAccumulatedCommissions: acc, - ValidatorHistoricalRewards: historical, - ValidatorCurrentRewards: cur, - DelegatorStartingInfos: dels, - ValidatorSlashEvents: slashes, - } -} - -var _ v036gov.Content = CommunityPoolSpendProposal{} - -// GetTitle returns the title of a community pool spend proposal. -func (csp CommunityPoolSpendProposal) GetTitle() string { return csp.Title } - -// GetDescription returns the description of a community pool spend proposal. -func (csp CommunityPoolSpendProposal) GetDescription() string { return csp.Description } - -// GetDescription returns the routing key of a community pool spend proposal. -func (csp CommunityPoolSpendProposal) ProposalRoute() string { return RouterKey } - -// ProposalType returns the type of a community pool spend proposal. -func (csp CommunityPoolSpendProposal) ProposalType() string { return ProposalTypeCommunityPoolSpend } - -// ValidateBasic runs basic stateless validity checks -func (csp CommunityPoolSpendProposal) ValidateBasic() error { - err := v036gov.ValidateAbstract(csp) - if err != nil { - return err - } - if !csp.Amount.IsValid() { - return types.ErrInvalidProposalAmount - } - if csp.Recipient.Empty() { - return types.ErrEmptyProposalRecipient - } - - return nil -} - -// String implements the Stringer interface. -func (csp CommunityPoolSpendProposal) String() string { - var b strings.Builder - b.WriteString(fmt.Sprintf(`Community Pool Spend Proposal: - Title: %s - Description: %s - Recipient: %s - Amount: %s -`, csp.Title, csp.Description, csp.Recipient, csp.Amount)) - return b.String() -} - -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal", nil) -} diff --git a/x/distribution/migrations/v038/types.go b/x/distribution/migrations/v038/types.go deleted file mode 100644 index cfdc0d508d99..000000000000 --- a/x/distribution/migrations/v038/types.go +++ /dev/null @@ -1,59 +0,0 @@ -// Package v038 is used for legacy migration scripts. Actual migration scripts -// for v038 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -package v038 - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - v034distr "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v034" - v036distr "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v036" -) - -// DONTCOVER - -const ( - ModuleName = "distribution" -) - -type ( - GenesisState struct { - Params Params `json:"params" yaml:"params"` - FeePool v034distr.FeePool `json:"fee_pool"` - DelegatorWithdrawInfos []v034distr.DelegatorWithdrawInfo `json:"delegator_withdraw_infos"` - PreviousProposer sdk.ConsAddress `json:"previous_proposer" yaml:"previous_proposer"` - OutstandingRewards []v034distr.ValidatorOutstandingRewardsRecord `json:"outstanding_rewards"` - ValidatorAccumulatedCommissions []v034distr.ValidatorAccumulatedCommissionRecord `json:"validator_accumulated_commissions"` - ValidatorHistoricalRewards []v034distr.ValidatorHistoricalRewardsRecord `json:"validator_historical_rewards"` - ValidatorCurrentRewards []v034distr.ValidatorCurrentRewardsRecord `json:"validator_current_rewards"` - DelegatorStartingInfos []v034distr.DelegatorStartingInfoRecord `json:"delegator_starting_infos"` - ValidatorSlashEvents []v036distr.ValidatorSlashEventRecord `json:"validator_slash_events" yaml:"validator_slash_events"` - } - - Params struct { - CommunityTax sdk.Dec `json:"community_tax" yaml:"community_tax"` - BaseProposerReward sdk.Dec `json:"base_proposer_reward" yaml:"base_proposer_reward"` - BonusProposerReward sdk.Dec `json:"bonus_proposer_reward" yaml:"bonus_proposer_reward"` - WithdrawAddrEnabled bool `json:"withdraw_addr_enabled" yaml:"withdraw_addr_enabled"` - } -) - -func NewGenesisState( - params Params, feePool v034distr.FeePool, dwis []v034distr.DelegatorWithdrawInfo, pp sdk.ConsAddress, - r []v034distr.ValidatorOutstandingRewardsRecord, acc []v034distr.ValidatorAccumulatedCommissionRecord, - historical []v034distr.ValidatorHistoricalRewardsRecord, cur []v034distr.ValidatorCurrentRewardsRecord, - dels []v034distr.DelegatorStartingInfoRecord, slashes []v036distr.ValidatorSlashEventRecord, -) GenesisState { - - return GenesisState{ - FeePool: feePool, - Params: params, - DelegatorWithdrawInfos: dwis, - PreviousProposer: pp, - OutstandingRewards: r, - ValidatorAccumulatedCommissions: acc, - ValidatorHistoricalRewards: historical, - ValidatorCurrentRewards: cur, - DelegatorStartingInfos: dels, - ValidatorSlashEvents: slashes, - } -} diff --git a/x/distribution/migrations/v040/migrate.go b/x/distribution/migrations/v040/migrate.go deleted file mode 100644 index a5024e44a4e7..000000000000 --- a/x/distribution/migrations/v040/migrate.go +++ /dev/null @@ -1,108 +0,0 @@ -package v040 - -import ( - v038distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v038" - v040distribution "github.com/cosmos/cosmos-sdk/x/distribution/types" -) - -// Migrate accepts exported x/distribution genesis state from v0.38 and migrates it -// to v0.40 x/distribution genesis state. The migration includes: -// -// - Convert addresses from bytes to bech32 strings. -// - Re-encode in v0.40 GenesisState. -func Migrate(oldDistributionState v038distribution.GenesisState) *v040distribution.GenesisState { - newDelegatorWithdrawInfos := make([]v040distribution.DelegatorWithdrawInfo, len(oldDistributionState.DelegatorWithdrawInfos)) - for i, oldDelegatorWithdrawInfo := range oldDistributionState.DelegatorWithdrawInfos { - newDelegatorWithdrawInfos[i] = v040distribution.DelegatorWithdrawInfo{ - DelegatorAddress: oldDelegatorWithdrawInfo.DelegatorAddress.String(), - WithdrawAddress: oldDelegatorWithdrawInfo.WithdrawAddress.String(), - } - } - - newValidatorOutstandingRewards := make([]v040distribution.ValidatorOutstandingRewardsRecord, len(oldDistributionState.OutstandingRewards)) - for i, oldValidatorOutstandingReward := range oldDistributionState.OutstandingRewards { - newValidatorOutstandingRewards[i] = v040distribution.ValidatorOutstandingRewardsRecord{ - ValidatorAddress: oldValidatorOutstandingReward.ValidatorAddress.String(), - OutstandingRewards: oldValidatorOutstandingReward.OutstandingRewards, - } - } - - newValidatorAccumulatedCommissions := make([]v040distribution.ValidatorAccumulatedCommissionRecord, len(oldDistributionState.ValidatorAccumulatedCommissions)) - for i, oldValidatorAccumulatedCommission := range oldDistributionState.ValidatorAccumulatedCommissions { - newValidatorAccumulatedCommissions[i] = v040distribution.ValidatorAccumulatedCommissionRecord{ - ValidatorAddress: oldValidatorAccumulatedCommission.ValidatorAddress.String(), - Accumulated: v040distribution.ValidatorAccumulatedCommission{ - Commission: oldValidatorAccumulatedCommission.Accumulated, - }, - } - } - - newValidatorHistoricalRewards := make([]v040distribution.ValidatorHistoricalRewardsRecord, len(oldDistributionState.ValidatorHistoricalRewards)) - for i, oldValidatorHistoricalReward := range oldDistributionState.ValidatorHistoricalRewards { - newValidatorHistoricalRewards[i] = v040distribution.ValidatorHistoricalRewardsRecord{ - ValidatorAddress: oldValidatorHistoricalReward.ValidatorAddress.String(), - Period: oldValidatorHistoricalReward.Period, - Rewards: v040distribution.ValidatorHistoricalRewards{ - CumulativeRewardRatio: oldValidatorHistoricalReward.Rewards.CumulativeRewardRatio, - ReferenceCount: uint32(oldValidatorHistoricalReward.Rewards.ReferenceCount), - }, - } - } - - newValidatorCurrentRewards := make([]v040distribution.ValidatorCurrentRewardsRecord, len(oldDistributionState.ValidatorCurrentRewards)) - for i, oldValidatorCurrentReward := range oldDistributionState.ValidatorCurrentRewards { - newValidatorCurrentRewards[i] = v040distribution.ValidatorCurrentRewardsRecord{ - ValidatorAddress: oldValidatorCurrentReward.ValidatorAddress.String(), - Rewards: v040distribution.ValidatorCurrentRewards{ - Rewards: oldValidatorCurrentReward.Rewards.Rewards, - Period: oldValidatorCurrentReward.Rewards.Period, - }, - } - } - - newDelegatorStartingInfos := make([]v040distribution.DelegatorStartingInfoRecord, len(oldDistributionState.DelegatorStartingInfos)) - for i, oldDelegatorStartingInfo := range oldDistributionState.DelegatorStartingInfos { - newDelegatorStartingInfos[i] = v040distribution.DelegatorStartingInfoRecord{ - DelegatorAddress: oldDelegatorStartingInfo.DelegatorAddress.String(), - ValidatorAddress: oldDelegatorStartingInfo.ValidatorAddress.String(), - StartingInfo: v040distribution.DelegatorStartingInfo{ - PreviousPeriod: oldDelegatorStartingInfo.StartingInfo.PreviousPeriod, - Stake: oldDelegatorStartingInfo.StartingInfo.Stake, - Height: oldDelegatorStartingInfo.StartingInfo.Height, - }, - } - } - - newValidatorSlashEvents := make([]v040distribution.ValidatorSlashEventRecord, len(oldDistributionState.ValidatorSlashEvents)) - for i, oldValidatorSlashEvent := range oldDistributionState.ValidatorSlashEvents { - newValidatorSlashEvents[i] = v040distribution.ValidatorSlashEventRecord{ - ValidatorAddress: oldValidatorSlashEvent.ValidatorAddress.String(), - Height: oldValidatorSlashEvent.Height, - Period: oldValidatorSlashEvent.Period, - ValidatorSlashEvent: v040distribution.ValidatorSlashEvent{ - ValidatorPeriod: oldValidatorSlashEvent.Event.ValidatorPeriod, - Fraction: oldValidatorSlashEvent.Event.Fraction, - }, - } - } - - return &v040distribution.GenesisState{ - Params: v040distribution.Params{ - CommunityTax: oldDistributionState.Params.CommunityTax, - BaseProposerReward: oldDistributionState.Params.BaseProposerReward, - BonusProposerReward: oldDistributionState.Params.BonusProposerReward, - WithdrawAddrEnabled: oldDistributionState.Params.WithdrawAddrEnabled, - }, - FeePool: v040distribution.FeePool{ - CommunityPool: oldDistributionState.FeePool.CommunityPool, - }, - DelegatorWithdrawInfos: newDelegatorWithdrawInfos, - PreviousProposer: oldDistributionState.PreviousProposer.String(), - OutstandingRewards: newValidatorOutstandingRewards, - ValidatorAccumulatedCommissions: newValidatorAccumulatedCommissions, - ValidatorHistoricalRewards: newValidatorHistoricalRewards, - ValidatorCurrentRewards: newValidatorCurrentRewards, - DelegatorStartingInfos: newDelegatorStartingInfos, - ValidatorSlashEvents: newValidatorSlashEvents, - } -} diff --git a/x/distribution/migrations/v040/keys.go b/x/distribution/migrations/v042/types.go similarity index 86% rename from x/distribution/migrations/v040/keys.go rename to x/distribution/migrations/v042/types.go index db8b1548a343..dc5cc6c746d0 100644 --- a/x/distribution/migrations/v040/keys.go +++ b/x/distribution/migrations/v042/types.go @@ -1,13 +1,11 @@ -// Package v040 is copy-pasted from: -// https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/x/distribution/types/keys.go -package v040 +package legacy import ( "encoding/binary" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" + v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" ) const ( @@ -61,7 +59,7 @@ var ( func GetValidatorOutstandingRewardsAddress(key []byte) (valAddr sdk.ValAddress) { kv.AssertKeyAtLeastLength(key, 2) addr := key[1:] - kv.AssertKeyLength(addr, v040auth.AddrLen) + kv.AssertKeyLength(addr, v042auth.AddrLen) return sdk.ValAddress(addr) } @@ -69,29 +67,29 @@ func GetValidatorOutstandingRewardsAddress(key []byte) (valAddr sdk.ValAddress) func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress) { kv.AssertKeyAtLeastLength(key, 2) addr := key[1:] - kv.AssertKeyLength(addr, v040auth.AddrLen) + kv.AssertKeyLength(addr, v042auth.AddrLen) return sdk.AccAddress(addr) } // gets the addresses from a delegator starting info key func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress) { - kv.AssertKeyAtLeastLength(key, 2+v040auth.AddrLen) - addr := key[1 : 1+v040auth.AddrLen] - kv.AssertKeyLength(addr, v040auth.AddrLen) + kv.AssertKeyAtLeastLength(key, 2+v042auth.AddrLen) + addr := key[1 : 1+v042auth.AddrLen] + kv.AssertKeyLength(addr, v042auth.AddrLen) valAddr = sdk.ValAddress(addr) - addr = key[1+v040auth.AddrLen:] - kv.AssertKeyLength(addr, v040auth.AddrLen) + addr = key[1+v042auth.AddrLen:] + kv.AssertKeyLength(addr, v042auth.AddrLen) delAddr = sdk.AccAddress(addr) return } // gets the address & period from a validator's historical rewards key func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64) { - kv.AssertKeyAtLeastLength(key, 2+v040auth.AddrLen) - addr := key[1 : 1+v040auth.AddrLen] - kv.AssertKeyLength(addr, v040auth.AddrLen) + kv.AssertKeyAtLeastLength(key, 2+v042auth.AddrLen) + addr := key[1 : 1+v042auth.AddrLen] + kv.AssertKeyLength(addr, v042auth.AddrLen) valAddr = sdk.ValAddress(addr) - b := key[1+v040auth.AddrLen:] + b := key[1+v042auth.AddrLen:] kv.AssertKeyLength(addr, 8) period = binary.LittleEndian.Uint64(b) return @@ -101,7 +99,7 @@ func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddr func GetValidatorCurrentRewardsAddress(key []byte) (valAddr sdk.ValAddress) { kv.AssertKeyAtLeastLength(key, 2) addr := key[1:] - kv.AssertKeyLength(addr, v040auth.AddrLen) + kv.AssertKeyLength(addr, v042auth.AddrLen) return sdk.ValAddress(addr) } @@ -109,17 +107,17 @@ func GetValidatorCurrentRewardsAddress(key []byte) (valAddr sdk.ValAddress) { func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress) { kv.AssertKeyAtLeastLength(key, 2) addr := key[1:] - kv.AssertKeyLength(addr, v040auth.AddrLen) + kv.AssertKeyLength(addr, v042auth.AddrLen) return sdk.ValAddress(addr) } // gets the height from a validator's slash event key func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64) { - kv.AssertKeyAtLeastLength(key, 2+v040auth.AddrLen) - addr := key[1 : 1+v040auth.AddrLen] - kv.AssertKeyLength(addr, v040auth.AddrLen) + kv.AssertKeyAtLeastLength(key, 2+v042auth.AddrLen) + addr := key[1 : 1+v042auth.AddrLen] + kv.AssertKeyLength(addr, v042auth.AddrLen) valAddr = sdk.ValAddress(addr) - startB := 1 + v040auth.AddrLen + startB := 1 + v042auth.AddrLen kv.AssertKeyAtLeastLength(key, startB+9) b := key[startB : startB+8] // the next 8 bytes represent the height height = binary.BigEndian.Uint64(b) diff --git a/x/distribution/migrations/v043/helpers.go b/x/distribution/migrations/v043/helpers.go index 185682217809..0e846a72ffae 100644 --- a/x/distribution/migrations/v043/helpers.go +++ b/x/distribution/migrations/v043/helpers.go @@ -4,7 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" + v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" ) // MigratePrefixAddress is a helper function that migrates all keys of format: @@ -19,7 +19,7 @@ func MigratePrefixAddress(store sdk.KVStore, prefixBz []byte) { for ; oldStoreIter.Valid(); oldStoreIter.Next() { addr := oldStoreIter.Key() - var newStoreKey = prefixBz + newStoreKey := prefixBz newStoreKey = append(newStoreKey, address.MustLengthPrefix(addr)...) // Set new key on store. Values don't change. @@ -39,8 +39,8 @@ func MigratePrefixAddressBytes(store sdk.KVStore, prefixBz []byte) { defer oldStoreIter.Close() for ; oldStoreIter.Valid(); oldStoreIter.Next() { - addr := oldStoreIter.Key()[:v040auth.AddrLen] - endBz := oldStoreIter.Key()[v040auth.AddrLen:] + addr := oldStoreIter.Key()[:v042auth.AddrLen] + endBz := oldStoreIter.Key()[v042auth.AddrLen:] newStoreKey := append(append(prefixBz, address.MustLengthPrefix(addr)...), endBz...) // Set new key on store. Values don't change. @@ -60,8 +60,8 @@ func MigratePrefixAddressAddress(store sdk.KVStore, prefixBz []byte) { defer oldStoreIter.Close() for ; oldStoreIter.Valid(); oldStoreIter.Next() { - addr1 := oldStoreIter.Key()[:v040auth.AddrLen] - addr2 := oldStoreIter.Key()[v040auth.AddrLen:] + addr1 := oldStoreIter.Key()[:v042auth.AddrLen] + addr2 := oldStoreIter.Key()[v042auth.AddrLen:] newStoreKey := append(append(prefixBz, address.MustLengthPrefix(addr1)...), address.MustLengthPrefix(addr2)...) // Set new key on store. Values don't change. diff --git a/x/distribution/migrations/v043/store.go b/x/distribution/migrations/v043/store.go index b757c7f2ac10..12fa534f9bf4 100644 --- a/x/distribution/migrations/v043/store.go +++ b/x/distribution/migrations/v043/store.go @@ -3,7 +3,7 @@ package v043 import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - v040distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v040" + v042distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v042" ) // MigrateStore performs in-place store migrations from v0.40 to v0.43. The @@ -12,13 +12,13 @@ import ( // - Change addresses to be length-prefixed. func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error { store := ctx.KVStore(storeKey) - MigratePrefixAddress(store, v040distribution.ValidatorOutstandingRewardsPrefix) - MigratePrefixAddress(store, v040distribution.DelegatorWithdrawAddrPrefix) - MigratePrefixAddressAddress(store, v040distribution.DelegatorStartingInfoPrefix) - MigratePrefixAddressBytes(store, v040distribution.ValidatorHistoricalRewardsPrefix) - MigratePrefixAddress(store, v040distribution.ValidatorCurrentRewardsPrefix) - MigratePrefixAddress(store, v040distribution.ValidatorAccumulatedCommissionPrefix) - MigratePrefixAddressBytes(store, v040distribution.ValidatorSlashEventPrefix) + MigratePrefixAddress(store, v042distribution.ValidatorOutstandingRewardsPrefix) + MigratePrefixAddress(store, v042distribution.DelegatorWithdrawAddrPrefix) + MigratePrefixAddressAddress(store, v042distribution.DelegatorStartingInfoPrefix) + MigratePrefixAddressBytes(store, v042distribution.ValidatorHistoricalRewardsPrefix) + MigratePrefixAddress(store, v042distribution.ValidatorCurrentRewardsPrefix) + MigratePrefixAddress(store, v042distribution.ValidatorAccumulatedCommissionPrefix) + MigratePrefixAddressBytes(store, v042distribution.ValidatorSlashEventPrefix) return nil } diff --git a/x/distribution/migrations/v043/store_test.go b/x/distribution/migrations/v043/store_test.go index 9804e97d2f69..9c055f72e553 100644 --- a/x/distribution/migrations/v043/store_test.go +++ b/x/distribution/migrations/v043/store_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - v040distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v040" + v042distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v042" v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v043" "github.com/cosmos/cosmos-sdk/x/distribution/types" ) @@ -32,47 +32,47 @@ func TestStoreMigration(t *testing.T) { }{ { "FeePoolKey", - v040distribution.FeePoolKey, + v042distribution.FeePoolKey, types.FeePoolKey, }, { "ProposerKey", - v040distribution.ProposerKey, + v042distribution.ProposerKey, types.ProposerKey, }, { "ValidatorOutstandingRewards", - v040distribution.GetValidatorOutstandingRewardsKey(valAddr), + v042distribution.GetValidatorOutstandingRewardsKey(valAddr), types.GetValidatorOutstandingRewardsKey(valAddr), }, { "DelegatorWithdrawAddr", - v040distribution.GetDelegatorWithdrawAddrKey(addr2), + v042distribution.GetDelegatorWithdrawAddrKey(addr2), types.GetDelegatorWithdrawAddrKey(addr2), }, { "DelegatorStartingInfo", - v040distribution.GetDelegatorStartingInfoKey(valAddr, addr2), + v042distribution.GetDelegatorStartingInfoKey(valAddr, addr2), types.GetDelegatorStartingInfoKey(valAddr, addr2), }, { "ValidatorHistoricalRewards", - v040distribution.GetValidatorHistoricalRewardsKey(valAddr, 6), + v042distribution.GetValidatorHistoricalRewardsKey(valAddr, 6), types.GetValidatorHistoricalRewardsKey(valAddr, 6), }, { "ValidatorCurrentRewards", - v040distribution.GetValidatorCurrentRewardsKey(valAddr), + v042distribution.GetValidatorCurrentRewardsKey(valAddr), types.GetValidatorCurrentRewardsKey(valAddr), }, { "ValidatorAccumulatedCommission", - v040distribution.GetValidatorAccumulatedCommissionKey(valAddr), + v042distribution.GetValidatorAccumulatedCommissionKey(valAddr), types.GetValidatorAccumulatedCommissionKey(valAddr), }, { "ValidatorSlashEvent", - v040distribution.GetValidatorSlashEventKey(valAddr, 6, 8), + v042distribution.GetValidatorSlashEventKey(valAddr, 6, 8), types.GetValidatorSlashEventKey(valAddr, 6, 8), }, } diff --git a/x/distribution/module.go b/x/distribution/module.go index 13cf674e3be0..e2f240b1edaf 100644 --- a/x/distribution/module.go +++ b/x/distribution/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -61,11 +60,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.TxEn return types.ValidateGenesis(&data) } -// RegisterRESTRoutes registers the REST routes for the distribution module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/distribution` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the distribution module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/distribution/simulation/genesis_test.go b/x/distribution/simulation/genesis_test.go index e923fbd4c833..259f0512d7a0 100644 --- a/x/distribution/simulation/genesis_test.go +++ b/x/distribution/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -30,7 +31,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index f82e921290b4..44aa71a8e156 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -28,7 +28,6 @@ func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, sk stakingkeeper.Keeper, ) simulation.WeightedOperations { - var weightMsgSetWithdrawAddress int appParams.GetOrGenerate(cdc, OpWeightMsgSetWithdrawAddress, &weightMsgSetWithdrawAddress, nil, func(_ *rand.Rand) { @@ -160,7 +159,6 @@ func SimulateMsgWithdrawValidatorCommission(ak types.AccountKeeper, bk types.Ban return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - validator, ok := stakingkeeper.RandomValidator(r, sk, ctx) if !ok { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgWithdrawValidatorCommission, "random validator is not ok"), nil, nil @@ -206,7 +204,6 @@ func SimulateMsgFundCommunityPool(ak types.AccountKeeper, bk types.BankKeeper, k return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - funder, _ := simtypes.RandomAcc(r, accs) account := ak.GetAccount(ctx, funder.Address) @@ -222,7 +219,7 @@ func SimulateMsgFundCommunityPool(ak types.AccountKeeper, bk types.BankKeeper, k err error ) - coins, hasNeg := spendable.SafeSub(fundAmount) + coins, hasNeg := spendable.SafeSub(fundAmount...) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coins) if err != nil { diff --git a/x/distribution/simulation/operations_test.go b/x/distribution/simulation/operations_test.go index bc902a0f1f6b..fdde63e43caa 100644 --- a/x/distribution/simulation/operations_test.go +++ b/x/distribution/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" "math/rand" "testing" @@ -59,7 +58,6 @@ func (suite *SimTestSuite) TestWeightedOperations() { // TestSimulateMsgSetWithdrawAddress tests the normal scenario of a valid message of type TypeMsgSetWithdrawAddress. // Abonormal scenarios, where the message is created by an errors, are not tested here. func (suite *SimTestSuite) TestSimulateMsgSetWithdrawAddress() { - // setup 3 accounts s := rand.NewSource(1) r := rand.New(s) @@ -74,7 +72,7 @@ func (suite *SimTestSuite) TestSimulateMsgSetWithdrawAddress() { suite.Require().NoError(err) var msg types.MsgSetWithdrawAddress - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().True(operationMsg.OK) suite.Require().Equal("cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.DelegatorAddress) @@ -115,7 +113,7 @@ func (suite *SimTestSuite) TestSimulateMsgWithdrawDelegatorReward() { suite.Require().NoError(err) var msg types.MsgWithdrawDelegatorReward - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().True(operationMsg.OK) suite.Require().Equal("cosmosvaloper1l4s054098kk9hmr5753c6k3m2kw65h686d3mhr", msg.ValidatorAddress) @@ -176,7 +174,7 @@ func (suite *SimTestSuite) testSimulateMsgWithdrawValidatorCommission(tokenName suite.Require().NoError(err) var msg types.MsgWithdrawValidatorCommission - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().True(operationMsg.OK) suite.Require().Equal("cosmosvaloper1tnh2q55v8wyygtt9srz5safamzdengsn9dsd7z", msg.ValidatorAddress) @@ -203,7 +201,7 @@ func (suite *SimTestSuite) TestSimulateMsgFundCommunityPool() { suite.Require().NoError(err) var msg types.MsgFundCommunityPool - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().True(operationMsg.OK) suite.Require().Equal("4896096stake", msg.Amount.String()) @@ -277,7 +275,6 @@ func (suite *SimTestSuite) setupValidatorRewards(valAddress sdk.ValAddress) { // setup current revards currentRewards := distrtypes.NewValidatorCurrentRewards(decCoins, 3) suite.app.DistrKeeper.SetValidatorCurrentRewards(suite.ctx, valAddress, currentRewards) - } func TestSimTestSuite(t *testing.T) { diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index 6fe51998e4d3..0bff07d87340 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -4,8 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) @@ -35,6 +37,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 983a1673daaf..82eee3eabef4 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -20,8 +20,7 @@ type AccountKeeper interface { // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin - LockedCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins SendCoinsFromModuleToModule(ctx sdk.Context, senderModule string, recipientModule string, amt sdk.Coins) error @@ -37,45 +36,21 @@ type StakingKeeper interface { IterateValidators(sdk.Context, func(index int64, validator stakingtypes.ValidatorI) (stop bool)) - // iterate through bonded validators by operator address, execute func for each validator - IterateBondedValidatorsByPower(sdk.Context, - func(index int64, validator stakingtypes.ValidatorI) (stop bool)) - - // iterate through the consensus validator set of the last block by operator address, execute func for each validator - IterateLastValidators(sdk.Context, - func(index int64, validator stakingtypes.ValidatorI) (stop bool)) - Validator(sdk.Context, sdk.ValAddress) stakingtypes.ValidatorI // get a particular validator by operator address ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) stakingtypes.ValidatorI // get a particular validator by consensus address - // slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction - Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec) sdk.Int - Jail(sdk.Context, sdk.ConsAddress) // jail a validator - Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator - // Delegation allows for getting a particular delegation for a given validator // and delegator outside the scope of the staking module. Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingtypes.DelegationI - // MaxValidators returns the maximum amount of bonded validators - MaxValidators(sdk.Context) uint32 - IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingtypes.DelegationI) (stop bool)) - GetLastTotalPower(ctx sdk.Context) sdk.Int - GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64 - GetAllSDKDelegations(ctx sdk.Context) []stakingtypes.Delegation } // StakingHooks event hooks for staking validator object (noalias) type StakingHooks interface { - AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created - AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is deleted - - BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) // Must be called when a delegation is created - BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) // Must be called when a delegation's shares are modified + AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) - BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) } diff --git a/x/distribution/types/fee_pool_test.go b/x/distribution/types/fee_pool_test.go index de774ca3cc0f..7eabc04d0bfa 100644 --- a/x/distribution/types/fee_pool_test.go +++ b/x/distribution/types/fee_pool_test.go @@ -10,7 +10,6 @@ import ( ) func TestValidateGenesis(t *testing.T) { - fp := types.InitialFeePool() require.Nil(t, fp.ValidateGenesis()) diff --git a/x/distribution/types/genesis.go b/x/distribution/types/genesis.go index 3aa251bba997..9ceb0737a13e 100644 --- a/x/distribution/types/genesis.go +++ b/x/distribution/types/genesis.go @@ -10,7 +10,6 @@ func NewGenesisState( acc []ValidatorAccumulatedCommissionRecord, historical []ValidatorHistoricalRewardsRecord, cur []ValidatorCurrentRewardsRecord, dels []DelegatorStartingInfoRecord, slashes []ValidatorSlashEventRecord, ) *GenesisState { - return &GenesisState{ Params: params, FeePool: fp, diff --git a/x/distribution/types/msg.go b/x/distribution/types/msg.go index 5f7b9b371075..2071ca0282e8 100644 --- a/x/distribution/types/msg.go +++ b/x/distribution/types/msg.go @@ -1,7 +1,6 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -35,7 +34,7 @@ func (msg MsgSetWithdrawAddress) GetSigners() []sdk.AccAddress { // get the bytes for the message signer to sign on func (msg MsgSetWithdrawAddress) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -69,7 +68,7 @@ func (msg MsgWithdrawDelegatorReward) GetSigners() []sdk.AccAddress { // get the bytes for the message signer to sign on func (msg MsgWithdrawDelegatorReward) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -101,7 +100,7 @@ func (msg MsgWithdrawValidatorCommission) GetSigners() []sdk.AccAddress { // get the bytes for the message signer to sign on func (msg MsgWithdrawValidatorCommission) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -138,7 +137,7 @@ func (msg MsgFundCommunityPool) GetSigners() []sdk.AccAddress { // GetSignBytes returns the raw bytes for a MsgFundCommunityPool message that // the expected signer needs to sign. func (msg MsgFundCommunityPool) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } diff --git a/x/distribution/types/query.go b/x/distribution/types/query.go index caaf2b7860be..ef3d34ceae5a 100644 --- a/x/distribution/types/query.go +++ b/x/distribution/types/query.go @@ -15,8 +15,7 @@ type QueryDelegatorTotalRewardsResponse struct { } // NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse -func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward, - total sdk.DecCoins) QueryDelegatorTotalRewardsResponse { +func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward, total sdk.DecCoins) QueryDelegatorTotalRewardsResponse { return QueryDelegatorTotalRewardsResponse{Rewards: rewards, Total: total} } @@ -34,7 +33,6 @@ func (res QueryDelegatorTotalRewardsResponse) String() string { // NewDelegationDelegatorReward constructs a DelegationDelegatorReward. //nolint:interfacer -func NewDelegationDelegatorReward(valAddr sdk.ValAddress, - reward sdk.DecCoins) DelegationDelegatorReward { +func NewDelegationDelegatorReward(valAddr sdk.ValAddress, reward sdk.DecCoins) DelegationDelegatorReward { return DelegationDelegatorReward{ValidatorAddress: valAddr.String(), Reward: reward} } diff --git a/x/evidence/client/cli/query.go b/x/evidence/client/cli/query.go index 9c987fb15e36..bf74325f949f 100644 --- a/x/evidence/client/cli/query.go +++ b/x/evidence/client/cli/query.go @@ -74,7 +74,6 @@ func queryEvidence(clientCtx client.Context, hash string) error { params := &types.QueryEvidenceRequest{EvidenceHash: decodedHash} res, err := queryClient.Evidence(context.Background(), params) - if err != nil { return err } diff --git a/x/evidence/client/testutil/cli_test.go b/x/evidence/client/testutil/cli_test.go index dd36a6af2d3e..1035ca750264 100644 --- a/x/evidence/client/testutil/cli_test.go +++ b/x/evidence/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/evidence/keeper/grpc_query.go b/x/evidence/keeper/grpc_query.go index f084c16717a0..06764fc97a64 100644 --- a/x/evidence/keeper/grpc_query.go +++ b/x/evidence/keeper/grpc_query.go @@ -79,7 +79,6 @@ func (k Keeper) AllEvidence(c context.Context, req *types.QueryAllEvidenceReques evidence = append(evidence, evidenceAny) return nil }) - if err != nil { return &types.QueryAllEvidenceResponse{}, err } diff --git a/x/evidence/keeper/grpc_query_test.go b/x/evidence/keeper/grpc_query_test.go index df760c8edfe0..b6856f19c654 100644 --- a/x/evidence/keeper/grpc_query_test.go +++ b/x/evidence/keeper/grpc_query_test.go @@ -80,9 +80,7 @@ func (suite *KeeperTestSuite) TestQueryEvidence() { } func (suite *KeeperTestSuite) TestQueryAllEvidence() { - var ( - req *types.QueryAllEvidenceRequest - ) + var req *types.QueryAllEvidenceRequest testCases := []struct { msg string diff --git a/x/evidence/keeper/keeper.go b/x/evidence/keeper/keeper.go index 366f46b83182..cbab55320d3a 100644 --- a/x/evidence/keeper/keeper.go +++ b/x/evidence/keeper/keeper.go @@ -30,7 +30,6 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey storetypes.StoreKey, stakingKeeper types.StakingKeeper, slashingKeeper types.SlashingKeeper, ) *Keeper { - return &Keeper{ cdc: cdc, storeKey: storeKey, diff --git a/x/evidence/migrations/v038/types.go b/x/evidence/migrations/v038/types.go deleted file mode 100644 index 246754cf122f..000000000000 --- a/x/evidence/migrations/v038/types.go +++ /dev/null @@ -1,116 +0,0 @@ -// Package v038 is used for legacy migration scripts. Actual migration scripts -// for v038 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -package v038 - -import ( - "fmt" - "time" - - "github.com/tendermint/tendermint/crypto/tmhash" - tmbytes "github.com/tendermint/tendermint/libs/bytes" - "sigs.k8s.io/yaml" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// Default parameter values -const ( - ModuleName = "evidence" - DefaultParamspace = ModuleName - DefaultMaxEvidenceAge = 60 * 2 * time.Second -) - -// Evidence type constants -const ( - RouteEquivocation = "equivocation" - TypeEquivocation = "equivocation" -) - -var ( - amino = codec.NewLegacyAmino() - - // ModuleCdc references the global x/evidence module codec. Note, the codec should - // ONLY be used in certain instances of tests and for JSON encoding as Amino is - // still used for that purpose. - // - // The actual codec used for serialization should be provided to x/evidence and - // defined at the application level. - ModuleCdc = codec.NewAminoCodec(amino) -) - -// Evidence defines the contract which concrete evidence types of misbehavior -// must implement. -type Evidence interface { - Route() string - Type() string - String() string - Hash() tmbytes.HexBytes - ValidateBasic() error - - // Height at which the infraction occurred - GetHeight() int64 -} - -// Params defines the total set of parameters for the evidence module -type Params struct { - MaxEvidenceAge time.Duration `json:"max_evidence_age" yaml:"max_evidence_age"` -} - -// GenesisState defines the evidence module's genesis state. -type GenesisState struct { - Params Params `json:"params" yaml:"params"` - Evidence []Evidence `json:"evidence" yaml:"evidence"` -} - -// Assert interface implementation. -var _ Evidence = Equivocation{} - -// Equivocation implements the Evidence interface and defines evidence of double -// signing misbehavior. -type Equivocation struct { - Height int64 `json:"height" yaml:"height"` - Time time.Time `json:"time" yaml:"time"` - Power int64 `json:"power" yaml:"power"` - ConsensusAddress sdk.ConsAddress `json:"consensus_address" yaml:"consensus_address"` -} - -// Route returns the Evidence Handler route for an Equivocation type. -func (e Equivocation) Route() string { return RouteEquivocation } - -// Type returns the Evidence Handler type for an Equivocation type. -func (e Equivocation) Type() string { return TypeEquivocation } - -func (e Equivocation) String() string { - bz, _ := yaml.Marshal(e) - return string(bz) -} - -// Hash returns the hash of an Equivocation object. -func (e Equivocation) Hash() tmbytes.HexBytes { - return tmhash.Sum(ModuleCdc.LegacyAmino.MustMarshal(e)) -} - -// ValidateBasic performs basic stateless validation checks on an Equivocation object. -func (e Equivocation) ValidateBasic() error { - if e.Time.Unix() <= 0 { - return fmt.Errorf("invalid equivocation time: %s", e.Time) - } - if e.Height < 1 { - return fmt.Errorf("invalid equivocation height: %d", e.Height) - } - if e.Power < 1 { - return fmt.Errorf("invalid equivocation validator power: %d", e.Power) - } - if e.ConsensusAddress.Empty() { - return fmt.Errorf("invalid equivocation validator consensus address: %s", e.ConsensusAddress) - } - - return nil -} - -// GetHeight returns the height at time of the Equivocation infraction. -func (e Equivocation) GetHeight() int64 { - return e.Height -} diff --git a/x/evidence/migrations/v040/migrate.go b/x/evidence/migrations/v040/migrate.go deleted file mode 100644 index 1ddb1ac6f238..000000000000 --- a/x/evidence/migrations/v040/migrate.go +++ /dev/null @@ -1,48 +0,0 @@ -package v040 - -import ( - "fmt" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - v038evidence "github.com/cosmos/cosmos-sdk/x/evidence/migrations/v038" - v040evidence "github.com/cosmos/cosmos-sdk/x/evidence/types" -) - -func migrateEvidence(oldEvidence v038evidence.Evidence) *codectypes.Any { - switch oldEvidence := oldEvidence.(type) { - case v038evidence.Equivocation: - { - newEquivocation := &v040evidence.Equivocation{ - Height: oldEvidence.Height, - Time: oldEvidence.Time, - Power: oldEvidence.Power, - ConsensusAddress: oldEvidence.ConsensusAddress.String(), - } - any, err := codectypes.NewAnyWithValue(newEquivocation) - if err != nil { - panic(err) - } - - return any - } - default: - panic(fmt.Errorf("'%T' is not a valid evidence type", oldEvidence)) - } -} - -// Migrate accepts exported v0.38 x/evidence genesis state and migrates it to -// v0.40 x/evidence genesis state. The migration includes: -// -// - Removing the `Params` field. -// - Converting Equivocations into Anys. -// - Re-encode in v0.40 GenesisState. -func Migrate(evidenceState v038evidence.GenesisState) *v040evidence.GenesisState { - var newEvidences = make([]*codectypes.Any, len(evidenceState.Evidence)) - for i, oldEvidence := range evidenceState.Evidence { - newEvidences[i] = migrateEvidence(oldEvidence) - } - - return &v040evidence.GenesisState{ - Evidence: newEvidences, - } -} diff --git a/x/evidence/migrations/v040/migrate_test.go b/x/evidence/migrations/v040/migrate_test.go deleted file mode 100644 index aba5b81f9185..000000000000 --- a/x/evidence/migrations/v040/migrate_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package v040_test - -import ( - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" - v038evidence "github.com/cosmos/cosmos-sdk/x/evidence/migrations/v038" - v040evidence "github.com/cosmos/cosmos-sdk/x/evidence/migrations/v040" -) - -func TestMigrate(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() - clientCtx := client.Context{}. - WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithTxConfig(encodingConfig.TxConfig). - WithLegacyAmino(encodingConfig.Amino). - WithCodec(encodingConfig.Codec) - - addr1, _ := sdk.AccAddressFromBech32("cosmos1xxkueklal9vejv9unqu80w9vptyepfa95pd53u") - - evidenceGenState := v038evidence.GenesisState{ - Params: v038evidence.Params{MaxEvidenceAge: v038evidence.DefaultMaxEvidenceAge}, - Evidence: []v038evidence.Evidence{v038evidence.Equivocation{ - Height: 20, - Power: 100, - ConsensusAddress: addr1.Bytes(), - }}, - } - - migrated := v040evidence.Migrate(evidenceGenState) - expected := `{"evidence":[{"@type":"/cosmos.evidence.v1beta1.Equivocation","height":"20","time":"0001-01-01T00:00:00Z","power":"100","consensus_address":"cosmosvalcons1xxkueklal9vejv9unqu80w9vptyepfa99x2a3w"}]}` - - bz, err := clientCtx.Codec.MarshalJSON(migrated) - require.NoError(t, err) - require.Equal(t, expected, string(bz)) -} diff --git a/x/evidence/migrations/v040/types.go b/x/evidence/migrations/v040/types.go deleted file mode 100644 index 41556b96b81c..000000000000 --- a/x/evidence/migrations/v040/types.go +++ /dev/null @@ -1,6 +0,0 @@ -package v040 - -// Default parameter values -const ( - ModuleName = "evidence" -) diff --git a/x/evidence/module.go b/x/evidence/module.go index 2d65ef8ead8a..0dcf1ac3fac3 100644 --- a/x/evidence/module.go +++ b/x/evidence/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -71,11 +70,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return gs.Validate() } -// RegisterRESTRoutes registers the evidence module's REST service handlers. -// Deprecated: RegisterRESTRoutes is deprecated. `x/evidence` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the evidence module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { diff --git a/x/evidence/simulation/genesis_test.go b/x/evidence/simulation/genesis_test.go index 8cfa086adc97..4999015bfd67 100644 --- a/x/evidence/simulation/genesis_test.go +++ b/x/evidence/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -30,7 +31,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/evidence/types/codec.go b/x/evidence/types/codec.go index 559a119f81db..19dcd12cbee9 100644 --- a/x/evidence/types/codec.go +++ b/x/evidence/types/codec.go @@ -4,8 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" "github.com/cosmos/cosmos-sdk/x/evidence/exported" ) @@ -28,6 +30,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/evidence/types/genesis.go b/x/evidence/types/genesis.go index b274ea20714f..c7a8b1041e67 100644 --- a/x/evidence/types/genesis.go +++ b/x/evidence/types/genesis.go @@ -37,7 +37,7 @@ func DefaultGenesisState() *GenesisState { } } -// Validate performs basic gensis state validation returning an error upon any +// Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { for _, e := range gs.Evidence { diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index 339696c82e1f..d2b3e655db11 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -22,9 +22,7 @@ func TestDefaultGenesisState(t *testing.T) { } func TestNewGenesisState(t *testing.T) { - var ( - evidence []exported.Evidence - ) + var evidence []exported.Evidence testCases := []struct { msg string @@ -126,7 +124,7 @@ func TestGenesisStateValidate(t *testing.T) { } func TestUnpackInterfaces(t *testing.T) { - var gs = types.GenesisState{ + gs := types.GenesisState{ Evidence: []*codectypes.Any{{}}, } @@ -149,7 +147,6 @@ func TestUnpackInterfaces(t *testing.T) { for _, tc := range testCases { t.Run(fmt.Sprintf("Case %s", tc.msg), func(t *testing.T) { - if tc.expPass { require.NoError(t, gs.UnpackInterfaces(tc.unpacker)) } else { diff --git a/x/evidence/types/msgs.go b/x/evidence/types/msgs.go index 6227040fd4e9..89b0d414d05d 100644 --- a/x/evidence/types/msgs.go +++ b/x/evidence/types/msgs.go @@ -2,7 +2,6 @@ package types import ( "fmt" - "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/gogo/protobuf/proto" @@ -63,7 +62,7 @@ func (m MsgSubmitEvidence) ValidateBasic() error { // GetSignBytes returns the raw bytes a signer is expected to sign when submitting // a MsgSubmitEvidence message. func (m MsgSubmitEvidence) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the single expected signer for a MsgSubmitEvidence. diff --git a/x/feegrant/basic_fee.go b/x/feegrant/basic_fee.go index 703b509b3a68..81419b6d5764 100644 --- a/x/feegrant/basic_fee.go +++ b/x/feegrant/basic_fee.go @@ -25,7 +25,7 @@ func (a *BasicAllowance) Accept(ctx sdk.Context, fee sdk.Coins, _ []sdk.Msg) (bo } if a.SpendLimit != nil { - left, invalid := a.SpendLimit.SafeSub(fee) + left, invalid := a.SpendLimit.SafeSub(fee...) if invalid { return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "basic allowance") } diff --git a/x/feegrant/client/cli/query.go b/x/feegrant/client/cli/query.go index 66e26b328e18..ba01417167c7 100644 --- a/x/feegrant/client/cli/query.go +++ b/x/feegrant/client/cli/query.go @@ -67,7 +67,6 @@ $ %s query feegrant grant [granter] [grantee] Grantee: granteeAddr.String(), }, ) - if err != nil { return err } @@ -84,14 +83,14 @@ $ %s query feegrant grant [granter] [grantee] // GetCmdQueryFeeGrantsByGrantee returns cmd to query for all grants for a grantee. func GetCmdQueryFeeGrantsByGrantee() *cobra.Command { cmd := &cobra.Command{ - Use: "grants [grantee]", + Use: "grants-by-grantee [grantee]", Args: cobra.ExactArgs(1), Short: "Query all grants of a grantee", Long: strings.TrimSpace( fmt.Sprintf(`Queries all the grants for a grantee address. Example: -$ %s query feegrant grants [grantee] +$ %s query feegrant grants-by-grantee [grantee] `, version.AppName), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -115,7 +114,6 @@ $ %s query feegrant grants [grantee] Pagination: pageReq, }, ) - if err != nil { return err } @@ -133,14 +131,14 @@ $ %s query feegrant grants [grantee] // GetCmdQueryFeeGrantsByGranter returns cmd to query for all grants by a granter. func GetCmdQueryFeeGrantsByGranter() *cobra.Command { cmd := &cobra.Command{ - Use: "grants [granter]", + Use: "grants-by-granter [granter]", Args: cobra.ExactArgs(1), Short: "Query all grants by a granter", Long: strings.TrimSpace( fmt.Sprintf(`Queries all the grants issued for a granter address. Example: -$ %s query feegrant grants [granter] +$ %s query feegrant grants-by-granter [granter] `, version.AppName), ), RunE: func(cmd *cobra.Command, args []string) error { @@ -164,7 +162,6 @@ $ %s query feegrant grants [granter] Pagination: pageReq, }, ) - if err != nil { return err } diff --git a/x/feegrant/client/cli/tx.go b/x/feegrant/client/cli/tx.go index 38cd58a1a2f6..12a90194ee0b 100644 --- a/x/feegrant/client/cli/tx.go +++ b/x/feegrant/client/cli/tx.go @@ -63,7 +63,6 @@ Examples: ), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - cmd.Flags().Set(flags.FlagFrom, args[0]) clientCtx, err := client.GetClientTxContext(cmd) if err != nil { diff --git a/x/feegrant/client/testutil/suite.go b/x/feegrant/client/testutil/suite.go index dc2acc3cd63c..d3bd39e313b7 100644 --- a/x/feegrant/client/testutil/suite.go +++ b/x/feegrant/client/testutil/suite.go @@ -316,7 +316,7 @@ func (s *IntegrationTestSuite) TestNewCmdFeeGrant() { alreadyExistedGrantee := s.addedGrantee clientCtx := val.ClientCtx - fromAddr, fromName, _, err := client.GetFromFields(clientCtx.Keyring, granter.String(), clientCtx.GenerateOnly) + fromAddr, fromName, _, err := client.GetFromFields(clientCtx, clientCtx.Keyring, granter.String()) s.Require().Equal(fromAddr, granter) s.Require().NoError(err) @@ -663,7 +663,7 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() { }, commonFlags..., ), - false, 4, &sdk.TxResponse{}, + false, 38, &sdk.TxResponse{}, }, { "Valid revoke", diff --git a/x/feegrant/codec.go b/x/feegrant/codec.go index 238c5f05f7ea..0fd6eaeb9e7f 100644 --- a/x/feegrant/codec.go +++ b/x/feegrant/codec.go @@ -4,8 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers the necessary x/feegrant interfaces and concrete types @@ -52,8 +54,10 @@ var ( func init() { RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) - // Register all Amino interfaces and concrete types on the global Amino codec so that this can later be - // used to properly serialize x/authz MsgExec instances - RegisterLegacyAminoCodec(legacy.Cdc) + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/feegrant/filtered_fee.go b/x/feegrant/filtered_fee.go index aeef392feb46..74255757fcfb 100644 --- a/x/feegrant/filtered_fee.go +++ b/x/feegrant/filtered_fee.go @@ -16,8 +16,10 @@ const ( gasCostPerIteration = uint64(10) ) -var _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) -var _ types.UnpackInterfacesMessage = (*AllowedMsgAllowance)(nil) +var ( + _ FeeAllowanceI = (*AllowedMsgAllowance)(nil) + _ types.UnpackInterfacesMessage = (*AllowedMsgAllowance)(nil) +) // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces func (a *AllowedMsgAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error { diff --git a/x/feegrant/grant.go b/x/feegrant/grant.go index a51e65ab5e1d..f8d7823ff06a 100644 --- a/x/feegrant/grant.go +++ b/x/feegrant/grant.go @@ -8,9 +8,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -var ( - _ types.UnpackInterfacesMessage = &Grant{} -) +var _ types.UnpackInterfacesMessage = &Grant{} // NewGrant creates a new FeeAllowanceGrant. //nolint:interfacer diff --git a/x/feegrant/keeper/grpc_query.go b/x/feegrant/keeper/grpc_query.go index 027eba648aa0..8d2b4c31145f 100644 --- a/x/feegrant/keeper/grpc_query.go +++ b/x/feegrant/keeper/grpc_query.go @@ -86,7 +86,6 @@ func (q Keeper) Allowances(c context.Context, req *feegrant.QueryAllowancesReque grants = append(grants, &grant) return nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -111,23 +110,23 @@ func (q Keeper) AllowancesByGranter(c context.Context, req *feegrant.QueryAllowa store := ctx.KVStore(q.storeKey) prefixStore := prefix.NewStore(store, feegrant.FeeAllowanceKeyPrefix) - pageRes, err := query.Paginate(prefixStore, req.Pagination, func(key []byte, value []byte) error { - var grant feegrant.Grant - + pageRes, err := query.FilteredPaginate(prefixStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { // ParseAddressesFromFeeAllowanceKey expects the full key including the prefix. granter, _ := feegrant.ParseAddressesFromFeeAllowanceKey(append(feegrant.FeeAllowanceKeyPrefix, key...)) if !granter.Equals(granterAddr) { - return nil + return false, nil } - if err := q.cdc.Unmarshal(value, &grant); err != nil { - return err + if accumulate { + var grant feegrant.Grant + if err := q.cdc.Unmarshal(value, &grant); err != nil { + return false, err + } + grants = append(grants, &grant) } - grants = append(grants, &grant) - return nil + return true, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/x/feegrant/keeper/grpc_query_test.go b/x/feegrant/keeper/grpc_query_test.go index cf813d1c19f5..fd46c5ec0653 100644 --- a/x/feegrant/keeper/grpc_query_test.go +++ b/x/feegrant/keeper/grpc_query_test.go @@ -6,7 +6,6 @@ import ( ) func (suite *KeeperTestSuite) TestFeeAllowance() { - testCases := []struct { name string req *feegrant.QueryAllowanceRequest @@ -59,7 +58,7 @@ func (suite *KeeperTestSuite) TestFeeAllowance() { }, false, func() { - grantFeeAllowance(suite) + suite.grantFeeAllowance(suite.addrs[0], suite.addrs[1]) }, func(response *feegrant.QueryAllowanceResponse) { suite.Require().Equal(response.Allowance.Granter, suite.addrs[0].String()) @@ -124,7 +123,7 @@ func (suite *KeeperTestSuite) TestFeeAllowances() { }, false, func() { - grantFeeAllowance(suite) + suite.grantFeeAllowance(suite.addrs[0], suite.addrs[1]) }, func(resp *feegrant.QueryAllowancesResponse) { suite.Require().Equal(len(resp.Allowances), 1) @@ -190,12 +189,16 @@ func (suite *KeeperTestSuite) TestFeeAllowancesByGranter() { }, false, func() { - grantFeeAllowance(suite) + suite.grantFeeAllowance(suite.addrs[0], suite.addrs[1]) + + // adding this allowance to check whether the pagination working fine. + suite.grantFeeAllowance(suite.addrs[1], suite.addrs[2]) }, func(resp *feegrant.QueryAllowancesByGranterResponse) { suite.Require().Equal(len(resp.Allowances), 1) suite.Require().Equal(resp.Allowances[0].Granter, suite.addrs[0].String()) suite.Require().Equal(resp.Allowances[0].Grantee, suite.addrs[1].String()) + suite.Require().Equal(resp.Pagination.Total, uint64(1)) }, }, } @@ -214,9 +217,9 @@ func (suite *KeeperTestSuite) TestFeeAllowancesByGranter() { } } -func grantFeeAllowance(suite *KeeperTestSuite) { +func (suite *KeeperTestSuite) grantFeeAllowance(granter, grantee sdk.AccAddress) { exp := suite.sdkCtx.BlockTime().AddDate(1, 0, 0) - err := suite.app.FeeGrantKeeper.GrantAllowance(suite.sdkCtx, suite.addrs[0], suite.addrs[1], &feegrant.BasicAllowance{ + err := suite.app.FeeGrantKeeper.GrantAllowance(suite.sdkCtx, granter, grantee, &feegrant.BasicAllowance{ SpendLimit: sdk.NewCoins(sdk.NewInt64Coin("atom", 555)), Expiration: &exp, }) diff --git a/x/feegrant/keeper/keeper.go b/x/feegrant/keeper/keeper.go index 408273f91af7..84abc4428bf4 100644 --- a/x/feegrant/keeper/keeper.go +++ b/x/feegrant/keeper/keeper.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" + "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/feegrant" ) @@ -22,7 +22,7 @@ type Keeper struct { authKeeper feegrant.AccountKeeper } -var _ middleware.FeegrantKeeper = &Keeper{} +var _ ante.FeegrantKeeper = &Keeper{} // NewKeeper creates a fee grant Keeper func NewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey, ak feegrant.AccountKeeper) Keeper { @@ -40,7 +40,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // GrantAllowance creates a new grant func (k Keeper) GrantAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress, feeAllowance feegrant.FeeAllowanceI) error { - // create the account if it is not in account state granteeAcc := k.authKeeper.GetAccount(ctx, grantee) if granteeAcc == nil { @@ -52,8 +51,15 @@ func (k Keeper) GrantAllowance(ctx sdk.Context, granter, grantee sdk.AccAddress, key := feegrant.FeeAllowanceKey(granter, grantee) var oldExp *time.Time - existingGrant, err := k.getGrant(ctx, grantee, granter) - if err != nil && existingGrant != nil && existingGrant.GetAllowance() != nil { + existingGrant, err := k.getGrant(ctx, granter, grantee) + + // If we didn't find any grant, we don't return any error. + // All other kinds of errors are returned. + if err != nil && !sdkerrors.IsOf(err, sdkerrors.ErrNotFound) { + return err + } + + if existingGrant != nil && existingGrant.GetAllowance() != nil { grantInfo, err := existingGrant.GetGrant() if err != nil { return err @@ -184,7 +190,7 @@ func (k Keeper) getGrant(ctx sdk.Context, granter sdk.AccAddress, grantee sdk.Ac key := feegrant.FeeAllowanceKey(granter, grantee) bz := store.Get(key) if len(bz) == 0 { - return nil, sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "fee-grant not found") + return nil, sdkerrors.ErrNotFound.Wrap("fee-grant not found") } var feegrant feegrant.Grant @@ -322,9 +328,8 @@ func (k Keeper) RemoveExpiredAllowances(ctx sdk.Context) { for ; iterator.Valid(); iterator.Next() { store.Delete(iterator.Key()) - expLen := len(sdk.FormatTimeBytes(ctx.BlockTime())) - // extract the fee allowance key by removing the allowance queue prefix length, expiration length from key. - store.Delete(append(feegrant.FeeAllowanceKeyPrefix, iterator.Key()[1+expLen:]...)) + granter, grantee := feegrant.ParseAddressesFromFeeAllowanceQueueKey(iterator.Key()) + store.Delete(feegrant.FeeAllowanceKey(granter, grantee)) } } diff --git a/x/feegrant/keeper/keeper_test.go b/x/feegrant/keeper/keeper_test.go index 933d85c7cefe..4f5500f976d4 100644 --- a/x/feegrant/keeper/keeper_test.go +++ b/x/feegrant/keeper/keeper_test.go @@ -46,6 +46,7 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { // some helpers eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 123)) exp := suite.sdkCtx.BlockTime().AddDate(1, 0, 0) + exp2 := suite.sdkCtx.BlockTime().AddDate(2, 0, 0) basic := &feegrant.BasicAllowance{ SpendLimit: suite.atom, Expiration: &exp, @@ -56,6 +57,11 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { Expiration: &exp, } + basic3 := &feegrant.BasicAllowance{ + SpendLimit: eth, + Expiration: &exp2, + } + // let's set up some initial state here err := suite.keeper.GrantAllowance(suite.sdkCtx, suite.addrs[0], suite.addrs[1], basic) suite.Require().NoError(err) @@ -85,7 +91,7 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { err = suite.keeper.GrantAllowance(suite.sdkCtx, suite.addrs[0], suite.addrs[2], basic) suite.Require().NoError(err) - err = suite.keeper.GrantAllowance(suite.sdkCtx, suite.addrs[1], suite.addrs[2], basic2) + err = suite.keeper.GrantAllowance(suite.sdkCtx, suite.addrs[1], suite.addrs[2], basic3) suite.Require().NoError(err) // end state: @@ -115,7 +121,7 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { "addr modified": { granter: suite.addrs[1], grantee: suite.addrs[2], - allowance: basic2, + allowance: basic3, }, } @@ -144,7 +150,6 @@ func (suite *KeeperTestSuite) TestKeeperCrud() { _, err = suite.msgSrvr.RevokeAllowance(suite.ctx, &feegrant.MsgRevokeAllowance{Granter: suite.addrs[3].String(), Grantee: accAddr.String()}) suite.Require().NoError(err) - } func (suite *KeeperTestSuite) TestUseGrantedFee() { @@ -265,6 +270,7 @@ func (suite *KeeperTestSuite) TestPruneGrants() { eth := sdk.NewCoins(sdk.NewInt64Coin("eth", 123)) now := suite.sdkCtx.BlockTime() oneYearExpiry := now.AddDate(1, 0, 0) + oneDay := now.AddDate(0, 0, 1) testCases := []struct { name string @@ -273,6 +279,8 @@ func (suite *KeeperTestSuite) TestPruneGrants() { grantee sdk.AccAddress allowance feegrant.FeeAllowanceI expErrMsg string + preRun func() + postRun func() }{ { name: "grant not pruned from state", @@ -326,12 +334,108 @@ func (suite *KeeperTestSuite) TestPruneGrants() { Expiration: &oneYearExpiry, }, }, + { + name: "grant created with a day expiry & overwritten with no expiry shouldn't be pruned: no error", + ctx: suite.sdkCtx.WithBlockTime(now.AddDate(0, 0, 2)), + granter: suite.addrs[2], + grantee: suite.addrs[1], + allowance: &feegrant.BasicAllowance{ + SpendLimit: eth, + }, + preRun: func() { + // create a grant with a day expiry. + allowance := &feegrant.BasicAllowance{ + SpendLimit: suite.atom, + Expiration: &oneDay, + } + err := suite.keeper.GrantAllowance(suite.sdkCtx, suite.addrs[2], suite.addrs[1], allowance) + suite.NoError(err) + }, + postRun: func() { + _, err := suite.msgSrvr.RevokeAllowance(suite.sdkCtx, &feegrant.MsgRevokeAllowance{ + Granter: suite.addrs[2].String(), + Grantee: suite.addrs[1].String(), + }) + suite.NoError(err) + }, + }, + { + name: "grant created with a day expiry & overwritten with a year expiry shouldn't be pruned: no error", + ctx: suite.sdkCtx.WithBlockTime(now.AddDate(0, 0, 2)), + granter: suite.addrs[2], + grantee: suite.addrs[1], + allowance: &feegrant.BasicAllowance{ + SpendLimit: eth, + Expiration: &oneYearExpiry, + }, + preRun: func() { + // create a grant with a day expiry. + allowance := &feegrant.BasicAllowance{ + SpendLimit: suite.atom, + Expiration: &oneDay, + } + err := suite.keeper.GrantAllowance(suite.sdkCtx, suite.addrs[2], suite.addrs[1], allowance) + suite.NoError(err) + }, + postRun: func() { + _, err := suite.msgSrvr.RevokeAllowance(suite.sdkCtx, &feegrant.MsgRevokeAllowance{ + Granter: suite.addrs[2].String(), + Grantee: suite.addrs[1].String(), + }) + suite.NoError(err) + }, + }, + { + name: "grant created with a year expiry & overwritten with a day expiry should be pruned after a day: error", + ctx: suite.sdkCtx.WithBlockTime(now.AddDate(0, 0, 2)), + granter: suite.addrs[2], + grantee: suite.addrs[1], + allowance: &feegrant.BasicAllowance{ + SpendLimit: eth, + Expiration: &oneDay, + }, + preRun: func() { + // create a grant with a year expiry. + allowance := &feegrant.BasicAllowance{ + SpendLimit: suite.atom, + Expiration: &oneYearExpiry, + } + err := suite.keeper.GrantAllowance(suite.sdkCtx, suite.addrs[2], suite.addrs[1], allowance) + suite.NoError(err) + }, + postRun: func() {}, + expErrMsg: "not found", + }, + { + name: "grant created with no expiry & overwritten with a day expiry should be pruned after a day: error", + ctx: suite.sdkCtx.WithBlockTime(now.AddDate(0, 0, 2)), + granter: suite.addrs[2], + grantee: suite.addrs[1], + allowance: &feegrant.BasicAllowance{ + SpendLimit: eth, + Expiration: &oneDay, + }, + preRun: func() { + // create a grant with no expiry. + allowance := &feegrant.BasicAllowance{ + SpendLimit: suite.atom, + } + err := suite.keeper.GrantAllowance(suite.sdkCtx, suite.addrs[2], suite.addrs[1], allowance) + suite.NoError(err) + }, + postRun: func() {}, + expErrMsg: "not found", + }, } for _, tc := range testCases { tc := tc suite.Run(tc.name, func() { - suite.keeper.GrantAllowance(suite.sdkCtx, tc.granter, tc.grantee, tc.allowance) + if tc.preRun != nil { + tc.preRun() + } + err := suite.keeper.GrantAllowance(suite.sdkCtx, tc.granter, tc.grantee, tc.allowance) + suite.NoError(err) suite.app.FeeGrantKeeper.RemoveExpiredAllowances(tc.ctx) grant, err := suite.keeper.GetAllowance(tc.ctx, tc.granter, tc.grantee) if tc.expErrMsg != "" { @@ -340,6 +444,9 @@ func (suite *KeeperTestSuite) TestPruneGrants() { } else { suite.NotNil(grant) } + if tc.postRun != nil { + tc.postRun() + } }) } } diff --git a/x/feegrant/keeper/msg_server_test.go b/x/feegrant/keeper/msg_server_test.go index aafebdb7d227..4fa3193e3af9 100644 --- a/x/feegrant/keeper/msg_server_test.go +++ b/x/feegrant/keeper/msg_server_test.go @@ -218,5 +218,4 @@ func (suite *KeeperTestSuite) TestRevokeAllowance() { } }) } - } diff --git a/x/feegrant/key.go b/x/feegrant/key.go index 3d2fdb56336b..9cf0e4437481 100644 --- a/x/feegrant/key.go +++ b/x/feegrant/key.go @@ -5,7 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - "github.com/cosmos/cosmos-sdk/types/kv" ) const ( @@ -67,17 +66,30 @@ func AllowanceByExpTimeKey(exp *time.Time) []byte { return append(FeeAllowanceQueueKeyPrefix, sdk.FormatTimeBytes(*exp)...) } -// ParseAddressesFromFeeAllowanceKey exrtacts and returns the granter, grantee from the given key. +// ParseAddressesFromFeeAllowanceKey extracts and returns the granter, grantee from the given key. func ParseAddressesFromFeeAllowanceKey(key []byte) (granter, grantee sdk.AccAddress) { // key is of format: // 0x00 - kv.AssertKeyAtLeastLength(key, 2) - granteeAddrLen := key[1] // remove prefix key - kv.AssertKeyAtLeastLength(key, 2+int(granteeAddrLen)) - grantee = sdk.AccAddress(key[2 : 2+int(granteeAddrLen)]) - granterAddrLen := int(key[2+granteeAddrLen]) - kv.AssertKeyAtLeastLength(key, 3+int(granteeAddrLen)+int(granterAddrLen)) - granter = sdk.AccAddress(key[3+granterAddrLen : 3+int(granteeAddrLen)+int(granterAddrLen)]) + granterAddrLen, granterAddrLenEndIndex := sdk.ParseLengthPrefixedBytes(key, 1, 1) // ignore key[0] since it is a prefix key + grantee, granterAddrEndIndex := sdk.ParseLengthPrefixedBytes(key, granterAddrLenEndIndex+1, int(granterAddrLen[0])) + + granteeAddrLen, granteeAddrLenEndIndex := sdk.ParseLengthPrefixedBytes(key, granterAddrEndIndex+1, 1) + granter, _ = sdk.ParseLengthPrefixedBytes(key, granteeAddrLenEndIndex+1, int(granteeAddrLen[0])) + + return granter, grantee +} + +// ParseAddressesFromFeeAllowanceQueueKey extracts and returns the granter, grantee from the given key. +func ParseAddressesFromFeeAllowanceQueueKey(key []byte) (granter, grantee sdk.AccAddress) { + lenTime := len(sdk.FormatTimeBytes(time.Now())) + + // key is of format: + // <0x01> + granterAddrLen, granterAddrLenEndIndex := sdk.ParseLengthPrefixedBytes(key, 1+lenTime, 1) // ignore key[0] since it is a prefix key + grantee, granterAddrEndIndex := sdk.ParseLengthPrefixedBytes(key, granterAddrLenEndIndex+1, int(granterAddrLen[0])) + + granteeAddrLen, granteeAddrLenEndIndex := sdk.ParseLengthPrefixedBytes(key, granterAddrEndIndex+1, 1) + granter, _ = sdk.ParseLengthPrefixedBytes(key, granteeAddrLenEndIndex+1, int(granteeAddrLen[0])) return granter, grantee } diff --git a/x/feegrant/key_test.go b/x/feegrant/key_test.go index 75a7964bec32..d08b53bb05ee 100644 --- a/x/feegrant/key_test.go +++ b/x/feegrant/key_test.go @@ -2,6 +2,7 @@ package feegrant_test import ( "testing" + "time" "github.com/stretchr/testify/require" @@ -23,3 +24,20 @@ func TestMarshalAndUnmarshalFeegrantKey(t *testing.T) { require.Equal(t, granter, g1) require.Equal(t, grantee, g2) } + +func TestMarshalAndUnmarshalFeegrantKeyQueueKey(t *testing.T) { + grantee, err := sdk.AccAddressFromBech32("cosmos1qk93t4j0yyzgqgt6k5qf8deh8fq6smpn3ntu3x") + require.NoError(t, err) + granter, err := sdk.AccAddressFromBech32("cosmos1p9qh4ldfd6n0qehujsal4k7g0e37kel90rc4ts") + require.NoError(t, err) + + exp := time.Now() + expBytes := sdk.FormatTimeBytes(exp) + + key := feegrant.FeeAllowancePrefixQueue(&exp, feegrant.FeeAllowanceKey(granter, grantee)[1:]) + require.Len(t, key, len(grantee.Bytes())+len(granter.Bytes())+3+len(expBytes)) + + granter1, grantee1 := feegrant.ParseAddressesFromFeeAllowanceQueueKey(key) + require.Equal(t, granter, granter1) + require.Equal(t, grantee, grantee1) +} diff --git a/x/feegrant/module/module.go b/x/feegrant/module/module.go index 2246de692456..6752b16f2331 100644 --- a/x/feegrant/module/module.go +++ b/x/feegrant/module/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -86,10 +85,6 @@ func (a AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.Tx return feegrant.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the feegrant module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx sdkclient.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the feegrant module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { if err := feegrant.RegisterQueryHandlerClient(context.Background(), mux, feegrant.NewQueryClient(clientCtx)); err != nil { diff --git a/x/feegrant/periodic_fee.go b/x/feegrant/periodic_fee.go index 43229247ff0c..0e496ce5a93b 100644 --- a/x/feegrant/periodic_fee.go +++ b/x/feegrant/periodic_fee.go @@ -30,13 +30,13 @@ func (a *PeriodicAllowance) Accept(ctx sdk.Context, fee sdk.Coins, _ []sdk.Msg) // deduct from both the current period and the max amount var isNeg bool - a.PeriodCanSpend, isNeg = a.PeriodCanSpend.SafeSub(fee) + a.PeriodCanSpend, isNeg = a.PeriodCanSpend.SafeSub(fee...) if isNeg { return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "period limit") } if a.Basic.SpendLimit != nil { - a.Basic.SpendLimit, isNeg = a.Basic.SpendLimit.SafeSub(fee) + a.Basic.SpendLimit, isNeg = a.Basic.SpendLimit.SafeSub(fee...) if isNeg { return false, sdkerrors.Wrap(ErrFeeLimitExceeded, "absolute limit") } @@ -59,7 +59,7 @@ func (a *PeriodicAllowance) tryResetPeriod(blockTime time.Time) { } // set PeriodCanSpend to the lesser of Basic.SpendLimit and PeriodSpendLimit - if _, isNeg := a.Basic.SpendLimit.SafeSub(a.PeriodSpendLimit); isNeg && !a.Basic.SpendLimit.Empty() { + if _, isNeg := a.Basic.SpendLimit.SafeSub(a.PeriodSpendLimit...); isNeg && !a.Basic.SpendLimit.Empty() { a.PeriodCanSpend = a.Basic.SpendLimit } else { a.PeriodCanSpend = a.PeriodSpendLimit diff --git a/x/feegrant/periodic_fee_test.go b/x/feegrant/periodic_fee_test.go index b6a8d39bd9dc..439ef19a0195 100644 --- a/x/feegrant/periodic_fee_test.go +++ b/x/feegrant/periodic_fee_test.go @@ -131,8 +131,8 @@ func TestPeriodicFeeValidAllow(t *testing.T) { blockTime: oneHour, accept: true, remove: false, - remainsPeriod: smallAtom.Sub(oneAtom), - remains: smallAtom.Sub(oneAtom), + remainsPeriod: smallAtom.Sub(oneAtom...), + remains: smallAtom.Sub(oneAtom...), periodReset: oneHour.Add(tenMinutes), // one step from last reset, not now }, "period reset no spend limit": { diff --git a/x/feegrant/query.pb.go b/x/feegrant/query.pb.go index d3038e9d5faa..aed09b2f2902 100644 --- a/x/feegrant/query.pb.go +++ b/x/feegrant/query.pb.go @@ -241,6 +241,8 @@ func (m *QueryAllowancesResponse) GetPagination() *query.PageResponse { } // QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. +// +// Since: cosmos-sdk 0.46 type QueryAllowancesByGranterRequest struct { Granter string `protobuf:"bytes,1,opt,name=granter,proto3" json:"granter,omitempty"` // pagination defines an pagination for the request. @@ -295,6 +297,8 @@ func (m *QueryAllowancesByGranterRequest) GetPagination() *query.PageRequest { } // QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. +// +// Since: cosmos-sdk 0.46 type QueryAllowancesByGranterResponse struct { // allowances that have been issued by the granter. Allowances []*Grant `protobuf:"bytes,1,rep,name=allowances,proto3" json:"allowances,omitempty"` @@ -416,7 +420,8 @@ type QueryClient interface { // Allowances returns all the grants for address. Allowances(ctx context.Context, in *QueryAllowancesRequest, opts ...grpc.CallOption) (*QueryAllowancesResponse, error) // AllowancesByGranter returns all the grants given by an address - // Since v0.46 + // + // Since: cosmos-sdk 0.46 AllowancesByGranter(ctx context.Context, in *QueryAllowancesByGranterRequest, opts ...grpc.CallOption) (*QueryAllowancesByGranterResponse, error) } @@ -462,7 +467,8 @@ type QueryServer interface { // Allowances returns all the grants for address. Allowances(context.Context, *QueryAllowancesRequest) (*QueryAllowancesResponse, error) // AllowancesByGranter returns all the grants given by an address - // Since v0.46 + // + // Since: cosmos-sdk 0.46 AllowancesByGranter(context.Context, *QueryAllowancesByGranterRequest) (*QueryAllowancesByGranterResponse, error) } diff --git a/x/feegrant/simulation/genesis_test.go b/x/feegrant/simulation/genesis_test.go index 88f057dd0fff..44669c04be98 100644 --- a/x/feegrant/simulation/genesis_test.go +++ b/x/feegrant/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -28,7 +29,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: accounts, - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/feegrant/simulation/operations.go b/x/feegrant/simulation/operations.go index 58095c138454..021e5ee79c96 100644 --- a/x/feegrant/simulation/operations.go +++ b/x/feegrant/simulation/operations.go @@ -28,7 +28,6 @@ func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak feegrant.AccountKeeper, bk feegrant.BankKeeper, k keeper.Keeper, ) simulation.WeightedOperations { - var ( weightMsgGrantAllowance int weightMsgRevokeAllowance int @@ -85,7 +84,6 @@ func SimulateMsgGrantAllowance(ak feegrant.AccountKeeper, bk feegrant.BankKeeper SpendLimit: spendableCoins, Expiration: &oneYear, }, granter.Address, grantee.Address) - if err != nil { return simtypes.NoOpMsg(feegrant.ModuleName, TypeMsgGrantAllowance, err.Error()), nil, err } @@ -114,12 +112,10 @@ func SimulateMsgRevokeAllowance(ak feegrant.AccountKeeper, bk feegrant.BankKeepe return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - hasGrant := false var granterAddr sdk.AccAddress var granteeAddr sdk.AccAddress k.IterateAllFeeAllowances(ctx, func(grant feegrant.Grant) bool { - granter, err := sdk.AccAddressFromBech32(grant.Granter) if err != nil { panic(err) diff --git a/x/feegrant/simulation/operations_test.go b/x/feegrant/simulation/operations_test.go index f958330d9810..71721becc0e7 100644 --- a/x/feegrant/simulation/operations_test.go +++ b/x/feegrant/simulation/operations_test.go @@ -32,7 +32,6 @@ func (suite *SimTestSuite) SetupTest() { suite.ctx = app.BaseApp.NewContext(checkTx, tmproto.Header{ Time: time.Now(), }) - } func (suite *SimTestSuite) getTestingAccounts(r *rand.Rand, n int) []simtypes.Account { diff --git a/x/feegrant/spec/01_concepts.md b/x/feegrant/spec/01_concepts.md index 523ff3e94fe0..06eccc936786 100644 --- a/x/feegrant/spec/01_concepts.md +++ b/x/feegrant/spec/01_concepts.md @@ -80,7 +80,7 @@ Example cmd: ## Granted Fee Deductions -Fees are deducted from grants in the `x/auth` ante handler. To learn more about how ante handlers work, read the [Auth Module AnteHandlers Guide](../../auth/spec/03_antehandlers.md). +Fees are deducted from grants in the `x/auth` middleware. To learn more about how middlewares work, read the [Auth Module Middlewares Guide](../../auth/spec/03_middlewares.md). ## Gas diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index 00ff11ab6f98..4880fa375503 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -130,9 +130,7 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o } txFactory := tx.NewFactoryCLI(clientCtx, cmd.Flags()) - if err != nil { - return errors.Wrap(err, "error creating tx builder") - } + pub, err := key.GetAddress() if err != nil { return err @@ -167,6 +165,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 = txBldr.PrintUnsignedTx(clientCtx, msg); err != nil { return errors.Wrap(err, "failed to print unsigned std tx") } @@ -216,7 +218,7 @@ $ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=o func makeOutputFilepath(rootDir, nodeID string) (string, error) { writePath := filepath.Join(rootDir, "config", "gentx") - if err := tmos.EnsureDir(writePath, 0700); err != nil { + if err := tmos.EnsureDir(writePath, 0o700); err != nil { return "", err } @@ -238,7 +240,7 @@ func readUnsignedGenTxFile(clientCtx client.Context, r io.Reader) (sdk.Tx, error } func writeSignedGenTx(clientCtx client.Context, outputDocument string, tx sdk.Tx) error { - outputFile, err := os.OpenFile(outputDocument, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0644) + outputFile, err := os.OpenFile(outputDocument, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0o644) if err != nil { return err } diff --git a/x/genutil/client/cli/init.go b/x/genutil/client/cli/init.go index 4f3ee1a9fe07..3107061c465a 100644 --- a/x/genutil/client/cli/init.go +++ b/x/genutil/client/cli/init.go @@ -163,7 +163,7 @@ func InitCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command { genDoc.AppState = appState if err = genutil.ExportGenesisFile(genDoc, genFile); err != nil { - return errors.Wrap(err, "Failed to export gensis file") + return errors.Wrap(err, "Failed to export genesis file") } toPrint := newPrintInfo(config.Moniker, chainID, nodeID, "", appState) diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index d5004d960d5a..705af61cace3 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -87,7 +87,6 @@ func TestInitCmd(t *testing.T) { } }) } - } func TestInitRecover(t *testing.T) { @@ -286,7 +285,7 @@ func TestInitConfig(t *testing.T) { // custom tx codec func makeCodec() *codec.LegacyAmino { - var cdc = codec.NewLegacyAmino() + cdc := codec.NewLegacyAmino() sdk.RegisterLegacyAminoCodec(cdc) cryptocodec.RegisterCrypto(cdc) return cdc diff --git a/x/genutil/client/cli/migrate.go b/x/genutil/client/cli/migrate.go index f27d979ad363..c16fcb843d06 100644 --- a/x/genutil/client/cli/migrate.go +++ b/x/genutil/client/cli/migrate.go @@ -14,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" - v040 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v040" v043 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v043" v046 "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v046" "github.com/cosmos/cosmos-sdk/x/genutil/types" @@ -26,7 +25,6 @@ const flagGenesisTime = "genesis-time" // // Ref: https://github.com/cosmos/cosmos-sdk/issues/5041 var migrationMap = types.MigrationMap{ - "v0.42": v040.Migrate, // NOTE: v0.40, v0.41 and v0.42 are genesis compatible. "v0.43": v043.Migrate, // NOTE: v0.43, v0.44 and v0.45 are genesis compatible. "v0.46": v046.Migrate, } diff --git a/x/genutil/client/testutil/cli_test.go b/x/genutil/client/testutil/cli_test.go index dd36a6af2d3e..1035ca750264 100644 --- a/x/genutil/client/testutil/cli_test.go +++ b/x/genutil/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/genutil/client/testutil/suite.go b/x/genutil/client/testutil/suite.go index f025160da6c7..755d20154eb3 100644 --- a/x/genutil/client/testutil/suite.go +++ b/x/genutil/client/testutil/suite.go @@ -1,7 +1,6 @@ package testutil import ( - "context" "fmt" "io" "os" @@ -9,10 +8,9 @@ import ( "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" @@ -50,84 +48,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 := 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()) -} - -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/client/testutil/validate_genesis.go b/x/genutil/client/testutil/validate_genesis.go index fe34e04bbc8a..c537dbf9dcf6 100644 --- a/x/genutil/client/testutil/validate_genesis.go +++ b/x/genutil/client/testutil/validate_genesis.go @@ -93,7 +93,6 @@ func (s *IntegrationTestSuite) TestValidateGenesis() { _, err := clitestutil.ExecTestCLICmd(val0.ClientCtx, cli.ValidateGenesisCmd(nil), []string{genesisFile.Name()}) if tc.expErr { s.Require().Contains(err.Error(), "Make sure that you have correctly migrated all Tendermint consensus params") - } else { s.Require().NoError(err) } diff --git a/x/genutil/collect.go b/x/genutil/collect.go index 8b06c12f7740..8f9fd611c764 100644 --- a/x/genutil/collect.go +++ b/x/genutil/collect.go @@ -27,7 +27,6 @@ import ( func GenAppStateFromConfig(cdc codec.JSONCodec, txEncodingConfig client.TxEncodingConfig, config *cfg.Config, initCfg types.InitConfig, genDoc tmtypes.GenesisDoc, genBalIterator types.GenesisBalancesIterator, ) (appState json.RawMessage, err error) { - // process genesis transactions, else create default genesis.json appGenTxs, persistentPeers, err := CollectTxs( cdc, txEncodingConfig.TxJSONDecoder(), config.Moniker, initCfg.GenTxsDir, genDoc, genBalIterator, diff --git a/x/genutil/collect_test.go b/x/genutil/collect_test.go index 837e16e6fc9b..c9befdd54720 100644 --- a/x/genutil/collect_test.go +++ b/x/genutil/collect_test.go @@ -45,7 +45,7 @@ func TestCollectTxsHandlesDirectories(t *testing.T) { // 1. We'll insert a directory as the first element before JSON file. subDirPath := filepath.Join(testDir, "_adir") - if err := os.MkdirAll(subDirPath, 0755); err != nil { + if err := os.MkdirAll(subDirPath, 0o755); err != nil { t.Fatal(err) } diff --git a/x/genutil/gentx.go b/x/genutil/gentx.go index 39fa600750d1..f7e4250def1d 100644 --- a/x/genutil/gentx.go +++ b/x/genutil/gentx.go @@ -18,7 +18,6 @@ import ( func SetGenTxsInAppGenesisState( cdc codec.JSONCodec, txJSONEncoder sdk.TxEncoder, appGenesisState map[string]json.RawMessage, genTxs []sdk.Tx, ) (map[string]json.RawMessage, error) { - genesisState := types.GetGenesisStateFromAppState(cdc, appGenesisState) genTxsBz := make([]json.RawMessage, 0, len(genTxs)) @@ -41,7 +40,6 @@ func ValidateAccountInGenesis( appGenesisState map[string]json.RawMessage, genBalIterator types.GenesisBalancesIterator, addr sdk.Address, coins sdk.Coins, cdc codec.JSONCodec, ) error { - var stakingData stakingtypes.GenesisState cdc.MustUnmarshalJSON(appGenesisState[stakingtypes.ModuleName], &stakingData) bondDenom := stakingData.Params.BondDenom @@ -96,7 +94,6 @@ func DeliverGenTxs( stakingKeeper types.StakingKeeper, deliverTx deliverTxfn, txEncodingConfig client.TxEncodingConfig, ) ([]abci.ValidatorUpdate, error) { - for _, genTx := range genTxs { tx, err := txEncodingConfig.TxJSONDecoder()(genTx) if err != nil { diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index b08ecb9750f2..a83b310c46d1 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -17,7 +17,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -65,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 := testutil.FundAccount(suite.app.BankKeeper, suite.ctx, addr, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 25)}) + err := testutil.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) @@ -181,7 +180,7 @@ func (suite *GenTxTestSuite) TestValidateAccountInGenesis() { cdc := suite.encodingConfig.Codec suite.app.StakingKeeper.SetParams(suite.ctx, stakingtypes.DefaultParams()) - stakingGenesisState := staking.ExportGenesis(suite.ctx, suite.app.StakingKeeper) + stakingGenesisState := suite.app.StakingKeeper.ExportGenesis(suite.ctx) suite.Require().Equal(stakingGenesisState.Params, stakingtypes.DefaultParams()) stakingGenesis, err := cdc.MarshalJSON(stakingGenesisState) // TODO switch this to use Marshaler suite.Require().NoError(err) @@ -198,7 +197,6 @@ func (suite *GenTxTestSuite) TestValidateAccountInGenesis() { } else { suite.Require().Error(err) } - }) } } @@ -231,10 +229,10 @@ 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( + tx, err := helpers.GenSignedMockTx( suite.encodingConfig.TxConfig, []sdk.Msg{msg}, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 10)}, diff --git a/x/genutil/migrations/v039/types.go b/x/genutil/migrations/v039/types.go deleted file mode 100644 index 12d082d1bc8a..000000000000 --- a/x/genutil/migrations/v039/types.go +++ /dev/null @@ -1,12 +0,0 @@ -package v039 - -import "encoding/json" - -const ( - ModuleName = "genutil" -) - -// GenesisState defines the raw genesis transaction in JSON -type GenesisState struct { - GenTxs []json.RawMessage `json:"gentxs" yaml:"gentxs"` -} diff --git a/x/genutil/migrations/v040/migrate.go b/x/genutil/migrations/v040/migrate.go deleted file mode 100644 index eb9686820981..000000000000 --- a/x/genutil/migrations/v040/migrate.go +++ /dev/null @@ -1,200 +0,0 @@ -package v040 - -import ( - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - v039auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v039" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" - v036supply "github.com/cosmos/cosmos-sdk/x/bank/migrations/v036" - v038bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v038" - v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" - v039crisis "github.com/cosmos/cosmos-sdk/x/crisis/migrations/v039" - v040crisis "github.com/cosmos/cosmos-sdk/x/crisis/migrations/v040" - v036distr "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v036" - v038distr "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v038" - v040distr "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v040" - v038evidence "github.com/cosmos/cosmos-sdk/x/evidence/migrations/v038" - v040evidence "github.com/cosmos/cosmos-sdk/x/evidence/migrations/v040" - v039genutil "github.com/cosmos/cosmos-sdk/x/genutil/migrations/v039" - "github.com/cosmos/cosmos-sdk/x/genutil/types" - v036gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v036" - v040gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v040" - v039mint "github.com/cosmos/cosmos-sdk/x/mint/migrations/v039" - v040mint "github.com/cosmos/cosmos-sdk/x/mint/migrations/v040" - v036params "github.com/cosmos/cosmos-sdk/x/params/migrations/v036" - v039slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v039" - v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v040" - v038staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v038" - v040staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v040" - v038upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/migrations/v038" -) - -func migrateGenutil(oldGenState v039genutil.GenesisState) *types.GenesisState { - return &types.GenesisState{ - GenTxs: oldGenState.GenTxs, - } -} - -// Migrate migrates exported state from v0.39 to a v0.40 genesis state. -func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap { - v039Codec := codec.NewLegacyAmino() - v039auth.RegisterLegacyAminoCodec(v039Codec) - v036gov.RegisterLegacyAminoCodec(v039Codec) - v036distr.RegisterLegacyAminoCodec(v039Codec) - v036params.RegisterLegacyAminoCodec(v039Codec) - v038upgrade.RegisterLegacyAminoCodec(v039Codec) - - v040Codec := clientCtx.Codec - - if appState[v038bank.ModuleName] != nil { - // unmarshal relative source genesis application state - var bankGenState v038bank.GenesisState - v039Codec.MustUnmarshalJSON(appState[v038bank.ModuleName], &bankGenState) - - // unmarshal x/auth genesis state to retrieve all account balances - var authGenState v039auth.GenesisState - v039Codec.MustUnmarshalJSON(appState[v039auth.ModuleName], &authGenState) - - // unmarshal x/supply genesis state to retrieve total supply - var supplyGenState v036supply.GenesisState - v039Codec.MustUnmarshalJSON(appState[v036supply.ModuleName], &supplyGenState) - - // delete deprecated x/bank genesis state - delete(appState, v038bank.ModuleName) - - // delete deprecated x/supply genesis state - delete(appState, v036supply.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[v040bank.ModuleName] = v040Codec.MustMarshalJSON(v040bank.Migrate(bankGenState, authGenState, supplyGenState)) - } - - // remove balances from existing accounts - if appState[v039auth.ModuleName] != nil { - // unmarshal relative source genesis application state - var authGenState v039auth.GenesisState - v039Codec.MustUnmarshalJSON(appState[v039auth.ModuleName], &authGenState) - - // delete deprecated x/auth genesis state - delete(appState, v039auth.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[v040auth.ModuleName] = v040Codec.MustMarshalJSON(v040auth.Migrate(authGenState)) - } - - // Migrate x/crisis. - if appState[v039crisis.ModuleName] != nil { - // unmarshal relative source genesis application state - var crisisGenState v039crisis.GenesisState - v039Codec.MustUnmarshalJSON(appState[v039crisis.ModuleName], &crisisGenState) - - // delete deprecated x/crisis genesis state - delete(appState, v039crisis.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[v040crisis.ModuleName] = v040Codec.MustMarshalJSON(v040crisis.Migrate(crisisGenState)) - } - - // Migrate x/distribution. - if appState[v038distr.ModuleName] != nil { - // unmarshal relative source genesis application state - var distributionGenState v038distr.GenesisState - v039Codec.MustUnmarshalJSON(appState[v038distr.ModuleName], &distributionGenState) - - // delete deprecated x/distribution genesis state - delete(appState, v038distr.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[v040distr.ModuleName] = v040Codec.MustMarshalJSON(v040distr.Migrate(distributionGenState)) - } - - // Migrate x/evidence. - if appState[v038evidence.ModuleName] != nil { - // unmarshal relative source genesis application state - var evidenceGenState v038evidence.GenesisState - v039Codec.MustUnmarshalJSON(appState[v038bank.ModuleName], &evidenceGenState) - - // delete deprecated x/evidence genesis state - delete(appState, v038evidence.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[v040evidence.ModuleName] = v040Codec.MustMarshalJSON(v040evidence.Migrate(evidenceGenState)) - } - - // Migrate x/gov. - if appState[v036gov.ModuleName] != nil { - // unmarshal relative source genesis application state - var govGenState v036gov.GenesisState - v039Codec.MustUnmarshalJSON(appState[v036gov.ModuleName], &govGenState) - - // delete deprecated x/gov genesis state - delete(appState, v036gov.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[v040gov.ModuleName] = v040Codec.MustMarshalJSON(v040gov.Migrate(govGenState)) - } - - // Migrate x/mint. - if appState[v039mint.ModuleName] != nil { - // unmarshal relative source genesis application state - var mintGenState v039mint.GenesisState - v039Codec.MustUnmarshalJSON(appState[v039mint.ModuleName], &mintGenState) - - // delete deprecated x/mint genesis state - delete(appState, v039mint.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[v040mint.ModuleName] = v040Codec.MustMarshalJSON(v040mint.Migrate(mintGenState)) - } - - // Migrate x/slashing. - if appState[v039slashing.ModuleName] != nil { - // unmarshal relative source genesis application state - var slashingGenState v039slashing.GenesisState - v039Codec.MustUnmarshalJSON(appState[v039slashing.ModuleName], &slashingGenState) - - // delete deprecated x/slashing genesis state - delete(appState, v039slashing.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[v040slashing.ModuleName] = v040Codec.MustMarshalJSON(v040slashing.Migrate(slashingGenState)) - } - - // Migrate x/staking. - if appState[v038staking.ModuleName] != nil { - // unmarshal relative source genesis application state - var stakingGenState v038staking.GenesisState - v039Codec.MustUnmarshalJSON(appState[v038staking.ModuleName], &stakingGenState) - - // delete deprecated x/staking genesis state - delete(appState, v038staking.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[v040staking.ModuleName] = v040Codec.MustMarshalJSON(v040staking.Migrate(stakingGenState)) - } - - // Migrate x/genutil - if appState[v039genutil.ModuleName] != nil { - // unmarshal relative source genesis application state - var genutilGenState v039genutil.GenesisState - v039Codec.MustUnmarshalJSON(appState[v039genutil.ModuleName], &genutilGenState) - - // delete deprecated x/staking genesis state - delete(appState, v039genutil.ModuleName) - - // Migrate relative source genesis application state and marshal it into - // the respective key. - appState[ModuleName] = v040Codec.MustMarshalJSON(migrateGenutil(genutilGenState)) - } - - return appState -} diff --git a/x/genutil/migrations/v040/types.go b/x/genutil/migrations/v040/types.go deleted file mode 100644 index f641dbff51e1..000000000000 --- a/x/genutil/migrations/v040/types.go +++ /dev/null @@ -1,5 +0,0 @@ -package v040 - -const ( - ModuleName = "genutil" -) diff --git a/x/genutil/migrations/v043/migrate.go b/x/genutil/migrations/v043/migrate.go index 8c37ee61d456..76676494443d 100644 --- a/x/genutil/migrations/v043/migrate.go +++ b/x/genutil/migrations/v043/migrate.go @@ -2,11 +2,11 @@ package v043 import ( "github.com/cosmos/cosmos-sdk/client" - v040bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v040" + v042bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v042" v043bank "github.com/cosmos/cosmos-sdk/x/bank/migrations/v043" bank "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil/types" - v040gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v040" + v042gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043" gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) @@ -14,26 +14,26 @@ import ( // Migrate migrates exported state from v0.40 to a v0.43 genesis state. func Migrate(appState types.AppMap, clientCtx client.Context) types.AppMap { // Migrate x/gov. - if appState[v040gov.ModuleName] != nil { + if appState[v042gov.ModuleName] != nil { // unmarshal relative source genesis application state var oldGovState gov.GenesisState - clientCtx.Codec.MustUnmarshalJSON(appState[v040gov.ModuleName], &oldGovState) + clientCtx.Codec.MustUnmarshalJSON(appState[v042gov.ModuleName], &oldGovState) // delete deprecated x/gov genesis state - delete(appState, v040gov.ModuleName) + delete(appState, v042gov.ModuleName) // Migrate relative source genesis application state and marshal it into // the respective key. appState[v043gov.ModuleName] = clientCtx.Codec.MustMarshalJSON(v043gov.MigrateJSON(&oldGovState)) } - if appState[v040bank.ModuleName] != nil { + if appState[v042bank.ModuleName] != nil { // unmarshal relative source genesis application state var oldBankState bank.GenesisState - clientCtx.Codec.MustUnmarshalJSON(appState[v040bank.ModuleName], &oldBankState) + clientCtx.Codec.MustUnmarshalJSON(appState[v042bank.ModuleName], &oldBankState) // delete deprecated x/bank genesis state - delete(appState, v040bank.ModuleName) + delete(appState, v042bank.ModuleName) // Migrate relative source genesis application state and marshal it into // the respective key. diff --git a/x/genutil/module.go b/x/genutil/module.go index db3071ca00c7..1b70eb5a151d 100644 --- a/x/genutil/module.go +++ b/x/genutil/module.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -53,10 +52,6 @@ func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, txEncodingConfig cl return types.ValidateGenesis(&data, txEncodingConfig.TxJSONDecoder()) } -// RegisterRESTRoutes registers the REST routes for the genutil module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the genutil module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) { } @@ -82,7 +77,6 @@ func NewAppModule(accountKeeper types.AccountKeeper, stakingKeeper types.StakingKeeper, deliverTx deliverTxfn, txEncodingConfig client.TxEncodingConfig, ) module.AppModule { - return module.NewGenesisOnlyAppModule(AppModule{ AppModuleBasic: AppModuleBasic{}, accountKeeper: accountKeeper, diff --git a/x/genutil/types/genesis_state.go b/x/genutil/types/genesis_state.go index 4a4dc957555a..9a71d50aae69 100644 --- a/x/genutil/types/genesis_state.go +++ b/x/genutil/types/genesis_state.go @@ -57,7 +57,6 @@ func GetGenesisStateFromAppState(cdc codec.JSONCodec, appState map[string]json.R func SetGenesisStateInAppState( cdc codec.JSONCodec, appState map[string]json.RawMessage, genesisState *GenesisState, ) map[string]json.RawMessage { - genesisStateBz := cdc.MustMarshalJSON(genesisState) appState[ModuleName] = genesisStateBz return appState diff --git a/x/genutil/types/genesis_state_test.go b/x/genutil/types/genesis_state_test.go index 01e1db9fd330..9c225fd3f7c4 100644 --- a/x/genutil/types/genesis_state_test.go +++ b/x/genutil/types/genesis_state_test.go @@ -91,5 +91,4 @@ func TestGenesisStateFromGenFile(t *testing.T) { require.Equal(t, "matom", bankGenesis.DenomMetadata[0].GetDenomUnits()[1].GetDenom()) require.Equal(t, []string{"milliatom"}, bankGenesis.DenomMetadata[0].GetDenomUnits()[1].GetAliases()) require.Equal(t, uint32(3), bankGenesis.DenomMetadata[0].GetDenomUnits()[1].GetExponent()) - } diff --git a/x/genutil/utils.go b/x/genutil/utils.go index 251b0f398f0b..0b77990d7cd7 100644 --- a/x/genutil/utils.go +++ b/x/genutil/utils.go @@ -34,7 +34,6 @@ func ExportGenesisFileWithTime( genFile, chainID string, validators []tmtypes.GenesisValidator, appState json.RawMessage, genTime time.Time, ) error { - genDoc := tmtypes.GenesisDoc{ GenesisTime: genTime, ChainID: chainID, @@ -68,12 +67,12 @@ func InitializeNodeValidatorFilesFromMnemonic(config *cfg.Config, mnemonic strin nodeID = string(nodeKey.ID) pvKeyFile := config.PrivValidator.KeyFile() - if err := tmos.EnsureDir(filepath.Dir(pvKeyFile), 0777); err != nil { + if err := tmos.EnsureDir(filepath.Dir(pvKeyFile), 0o777); err != nil { return "", nil, err } pvStateFile := config.PrivValidator.StateFile() - if err := tmos.EnsureDir(filepath.Dir(pvStateFile), 0777); err != nil { + if err := tmos.EnsureDir(filepath.Dir(pvStateFile), 0o777); err != nil { return "", nil, err } diff --git a/x/genutil/utils_test.go b/x/genutil/utils_test.go index 360f930e49b9..3541e29ae386 100644 --- a/x/genutil/utils_test.go +++ b/x/genutil/utils_test.go @@ -27,7 +27,7 @@ func TestInitializeNodeValidatorFilesFromMnemonic(t *testing.T) { cfg := config.TestConfig() cfg.RootDir = t.TempDir() - require.NoError(t, os.MkdirAll(filepath.Join(cfg.RootDir, "config"), 0755)) + require.NoError(t, os.MkdirAll(filepath.Join(cfg.RootDir, "config"), 0o755)) tests := []struct { name string diff --git a/x/gov/client/cli/parse.go b/x/gov/client/cli/parse.go index e5a6cc3cb9a7..a43d7f868cea 100644 --- a/x/gov/client/cli/parse.go +++ b/x/gov/client/cli/parse.go @@ -40,12 +40,6 @@ func parseSubmitLegacyProposalFlags(fs *pflag.FlagSet) (*legacyProposal, error) if proposalFile == "" { proposalType, _ := fs.GetString(FlagProposalType) - title, _ := fs.GetString(FlagTitle) - description, _ := fs.GetString(FlagDescription) - if proposalType == "" && title == "" && description == "" { - return nil, fmt.Errorf("one of the --proposal or (--title, --description and --type) flags are required") - } - proposal.Title, _ = fs.GetString(FlagTitle) proposal.Description, _ = fs.GetString(FlagDescription) proposal.Type = govutils.NormalizeProposalType(proposalType) diff --git a/x/gov/client/cli/parse_test.go b/x/gov/client/cli/parse_test.go index e3c1afa22fd0..e80c8c7c1a49 100644 --- a/x/gov/client/cli/parse_test.go +++ b/x/gov/client/cli/parse_test.go @@ -60,17 +60,57 @@ func TestParseSubmitLegacyProposalFlags(t *testing.T) { // no --proposal, only flags fs.Set(FlagProposal, "") - fs.Set(FlagTitle, proposal1.Title) - fs.Set(FlagDescription, proposal1.Description) - fs.Set(FlagProposalType, proposal1.Type) - fs.Set(FlagDeposit, proposal1.Deposit) - proposal2, err := parseSubmitLegacyProposalFlags(fs) - - require.Nil(t, err, "unexpected error") - require.Equal(t, proposal1.Title, proposal2.Title) - require.Equal(t, proposal1.Description, proposal2.Description) - require.Equal(t, proposal1.Type, proposal2.Type) - require.Equal(t, proposal1.Deposit, proposal2.Deposit) + flagTestCases := map[string]struct { + pTitle string + pDescription string + pType string + expErr bool + errMsg string + }{ + "valid flags": { + pTitle: proposal1.Title, + pDescription: proposal1.Description, + pType: proposal1.Type, + }, + "empty type": { + pTitle: proposal1.Title, + pDescription: proposal1.Description, + expErr: true, + errMsg: "proposal type is required", + }, + "empty title": { + pDescription: proposal1.Description, + pType: proposal1.Type, + expErr: true, + errMsg: "proposal title is required", + }, + "empty description": { + pTitle: proposal1.Title, + pType: proposal1.Type, + expErr: true, + errMsg: "proposal description is required", + }, + } + for name, tc := range flagTestCases { + t.Run(name, func(t *testing.T) { + fs.Set(FlagTitle, tc.pTitle) + fs.Set(FlagDescription, tc.pDescription) + fs.Set(FlagProposalType, tc.pType) + fs.Set(FlagDeposit, proposal1.Deposit) + proposal2, err := parseSubmitLegacyProposalFlags(fs) + + if tc.expErr { + require.Error(t, err) + require.Contains(t, err.Error(), tc.errMsg) + } else { + require.NoError(t, err) + require.Equal(t, proposal1.Title, proposal2.Title) + require.Equal(t, proposal1.Description, proposal2.Description) + require.Equal(t, proposal1.Type, proposal2.Type) + require.Equal(t, proposal1.Deposit, proposal2.Deposit) + } + }) + } err = okJSON.Close() require.Nil(t, err, "unexpected error") diff --git a/x/gov/client/cli/query.go b/x/gov/client/cli/query.go index c0f2eeaf329e..4700f8e753fa 100644 --- a/x/gov/client/cli/query.go +++ b/x/gov/client/cli/query.go @@ -234,7 +234,6 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk if vote.Empty() { params := v1.NewQueryVoteParams(proposalID, voterAddr) resByTxQuery, err := gcutils.QueryVoteByTxQuery(clientCtx, params) - if err != nil { return err } @@ -320,13 +319,11 @@ $ %[1]s query gov votes 1 --page=2 --limit=100 ctx, &v1.QueryVotesRequest{ProposalId: proposalID, Pagination: pageReq}, ) - if err != nil { return err } return clientCtx.PrintProto(res) - }, } @@ -440,7 +437,6 @@ $ %s query gov deposits 1 ctx, &v1.QueryDepositsRequest{ProposalId: proposalID, Pagination: pageReq}, ) - if err != nil { return err } diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index fcb030e146a1..85e821ddebee 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -35,7 +35,7 @@ const ( FlagProposal = "proposal" ) -// ProposalFlags defines the core required fields of a proposal. It is used to +// ProposalFlags defines the core required fields of a legacy proposal. It is used to // verify that these values are not provided in conjunction with a JSON proposal // file. var ProposalFlags = []string{ @@ -47,7 +47,7 @@ var ProposalFlags = []string{ // NewTxCmd returns the transaction commands for this module // governance ModuleClient is slightly different from other ModuleClients in that -// it contains a slice of "proposal" child commands. These commands are respective +// it contains a slice of legacy "proposal" child commands. These commands are respective // to the proposal type handlers that are implemented in other modules but are mounted // under the governance CLI (eg. parameter change proposals). func NewTxCmd(legacyPropCmds []*cobra.Command) *cobra.Command { @@ -81,12 +81,12 @@ func NewTxCmd(legacyPropCmds []*cobra.Command) *cobra.Command { // NewCmdSubmitProposal implements submitting a proposal transaction command. func NewCmdSubmitProposal() *cobra.Command { cmd := &cobra.Command{ - Use: "submit-proposal", - Short: "Submit a proposal along with some messages and metadata", + Use: "submit-proposal [path/to/proposal.json]", + Short: "Submit a proposal along with some messages, metadata and deposit", Args: cobra.ExactArgs(1), Long: strings.TrimSpace( - fmt.Sprintf(`Submit a proposal along with some messages and metadata. -Messages, metadata and deposit are defined in a JSON file. + fmt.Sprintf(`Submit a proposal along with some messages, metadata and deposit. +They should be defined in a JSON file. Example: $ %s tx gov submit-proposal path/to/proposal.json @@ -180,7 +180,11 @@ $ %s tx gov submit-legacy-proposal --title="Test Proposal" --description="My awe return err } - content := v1beta1.ContentFromProposalType(proposal.Title, proposal.Description, proposal.Type) + content, ok := v1beta1.ContentFromProposalType(proposal.Title, proposal.Description, proposal.Type) + if !ok { + return fmt.Errorf("failed to create proposal content: unknown proposal type %s", proposal.Type) + } + msg, err := v1beta1.NewMsgSubmitProposal(content, amount, clientCtx.GetFromAddress()) if err != nil { return fmt.Errorf("invalid message: %w", err) diff --git a/x/gov/client/testutil/deposits.go b/x/gov/client/testutil/deposits.go index 8fc74ba1cdc8..ee609ac9f451 100644 --- a/x/gov/client/testutil/deposits.go +++ b/x/gov/client/testutil/deposits.go @@ -42,6 +42,7 @@ func (s *DepositTestSuite) SetupSuite() { deposits := sdk.Coins{ sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(0)), + sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens), sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens.Sub(sdk.NewInt(50))), } s.deposits = deposits @@ -103,10 +104,6 @@ func (s *DepositTestSuite) TestQueryDepositsWithoutInitialDeposit() { _, err := MsgDeposit(clientCtx, val.Address.String(), proposalID, depositAmount) s.Require().NoError(err) - // waiting for voting period to end - _, err = s.network.WaitForHeight(2) - s.Require().NoError(err) - // query deposit deposit := s.queryDeposit(val, proposalID, false, "") s.Require().NotNil(deposit) @@ -120,68 +117,45 @@ func (s *DepositTestSuite) TestQueryDepositsWithoutInitialDeposit() { s.Require().Equal(sdk.Coins(deposits.Deposits[0].Amount).String(), depositAmount) } -func (s *DepositTestSuite) TestQueryProposalNotEnoughDeposits() { +func (s *DepositTestSuite) TestQueryDepositsWithInitialDeposit() { val := s.network.Validators[0] - clientCtx := val.ClientCtx proposalID := s.proposalIDs[1] + // query deposit + deposit := s.queryDeposit(val, proposalID, false, "") + s.Require().NotNil(deposit) + s.Require().Equal(sdk.Coins(deposit.Amount).String(), s.deposits[1].String()) + + // query deposits + deposits := s.queryDeposits(val, proposalID, false, "") + s.Require().NotNil(deposits) + s.Require().Len(deposits.Deposits, 1) + // verify initial deposit + s.Require().Equal(sdk.Coins(deposits.Deposits[0].Amount).String(), s.deposits[1].String()) +} + +func (s *DepositTestSuite) TestQueryProposalAfterVotingPeriod() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + proposalID := s.proposalIDs[2] + // query proposal args := []string{proposalID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)} cmd := cli.GetCmdQueryProposal() _, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args) s.Require().NoError(err) - // waiting for deposit period to end + // waiting for deposit and voting period to end time.Sleep(20 * time.Second) // query proposal _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) s.Require().Error(err) s.Require().Contains(err.Error(), fmt.Sprintf("proposal %s doesn't exist", proposalID)) -} - -func (s *DepositTestSuite) TestRejectedProposalDeposits() { - // resetting state required (proposal is getting removed from state and proposalID is not in sequence) - s.TearDownSuite() - s.SetupNewSuite() - - val := s.network.Validators[0] - clientCtx := val.ClientCtx - initialDeposit := sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens) - id := 1 - proposalID := fmt.Sprintf("%d", id) - - s.submitProposal(val, initialDeposit, id) // query deposits - var deposits v1.QueryDepositsResponse - args := []string{proposalID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)} - cmd := cli.GetCmdQueryDeposits() - out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, args) - s.Require().NoError(err) - s.Require().NoError(val.ClientCtx.LegacyAmino.UnmarshalJSON(out.Bytes(), &deposits)) - s.Require().Equal(len(deposits.Deposits), 1) - // verify initial deposit - s.Require().Equal(sdk.Coins(deposits.Deposits[0].Amount).String(), initialDeposit.String()) - - // vote - _, err = MsgVote(clientCtx, val.Address.String(), proposalID, "no") - s.Require().NoError(err) - - _, err = s.network.WaitForHeight(3) - s.Require().NoError(err) - - args = []string{proposalID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)} - cmd = cli.GetCmdQueryProposal() - _, err = clitestutil.ExecTestCLICmd(clientCtx, cmd, args) - s.Require().NoError(err) - - // query deposits - depositsRes := s.queryDeposits(val, proposalID, false, "") - s.Require().NotNil(depositsRes) - s.Require().Len(depositsRes.Deposits, 1) - // verify initial deposit - s.Require().Equal(sdk.Coins(depositsRes.Deposits[0].Amount).String(), initialDeposit.String()) + deposits := s.queryDeposits(val, proposalID, true, "proposal 3 doesn't exist") + s.Require().Nil(deposits) } func (s *DepositTestSuite) queryDeposits(val *network.Validator, proposalID string, exceptErr bool, message string) *v1.QueryDepositsResponse { diff --git a/x/gov/client/testutil/helpers.go b/x/gov/client/testutil/helpers.go index 0e17ead4a553..6dbb0d8722cb 100644 --- a/x/gov/client/testutil/helpers.go +++ b/x/gov/client/testutil/helpers.go @@ -17,20 +17,6 @@ var commonArgs = []string{ fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), } -// MsgSubmitProposal creates a tx for submit proposal -func MsgSubmitProposal(clientCtx client.Context, from, title, description, proposalType string, extraArgs ...string) (testutil.BufferWriter, error) { - args := append([]string{ - fmt.Sprintf("--%s=%s", govcli.FlagTitle, title), - fmt.Sprintf("--%s=%s", govcli.FlagDescription, description), - fmt.Sprintf("--%s=%s", govcli.FlagProposalType, proposalType), - fmt.Sprintf("--%s=%s", flags.FlagFrom, from), - }, commonArgs...) - - args = append(args, extraArgs...) - - return clitestutil.ExecTestCLICmd(clientCtx, govcli.NewCmdSubmitProposal(), args) -} - // MsgSubmitLegacyProposal creates a tx for submit legacy proposal func MsgSubmitLegacyProposal(clientCtx client.Context, from, title, description, proposalType string, extraArgs ...string) (testutil.BufferWriter, error) { args := append([]string{ diff --git a/x/gov/client/testutil/query.go b/x/gov/client/testutil/query.go new file mode 100644 index 000000000000..5f0502a8f039 --- /dev/null +++ b/x/gov/client/testutil/query.go @@ -0,0 +1,536 @@ +package testutil + +import ( + "fmt" + "strings" + + tmcli "github.com/tendermint/tendermint/libs/cli" + + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" +) + +func (s *IntegrationTestSuite) TestCmdParams() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectedOutput string + }{ + { + "json output", + []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, + `{"voting_params":{"voting_period":"172800000000000"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800000000000"}}`, + }, + { + "text output", + []string{}, + ` +deposit_params: + max_deposit_period: "172800000000000" + min_deposit: + - amount: "10000000" + denom: stake +tally_params: + quorum: "0.334000000000000000" + threshold: "0.500000000000000000" + veto_threshold: "0.334000000000000000" +voting_params: + voting_period: "172800000000000" + `, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryParams() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + s.Require().NoError(err) + s.Require().Equal(strings.TrimSpace(tc.expectedOutput), strings.TrimSpace(out.String())) + }) + } +} + +func (s *IntegrationTestSuite) TestCmdParam() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectedOutput string + }{ + { + "voting params", + []string{ + "voting", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + `{"voting_period":"172800000000000"}`, + }, + { + "tally params", + []string{ + "tallying", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + `{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"}`, + }, + { + "deposit params", + []string{ + "deposit", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + `{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800000000000"}`, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryParam() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + s.Require().NoError(err) + s.Require().Equal(strings.TrimSpace(tc.expectedOutput), strings.TrimSpace(out.String())) + }) + } +} + +func (s *IntegrationTestSuite) TestCmdProposer() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectErr bool + expectedOutput string + }{ + { + "without proposal id", + []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + true, + ``, + }, + { + "json output", + []string{ + "1", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + fmt.Sprintf("{\"proposal_id\":\"%s\",\"proposer\":\"%s\"}", "1", val.Address.String()), + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryProposer() + clientCtx := val.ClientCtx + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + s.Require().Equal(strings.TrimSpace(tc.expectedOutput), strings.TrimSpace(out.String())) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdTally() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectErr bool + expectedOutput v1.TallyResult + }{ + { + "without proposal id", + []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + true, + v1.TallyResult{}, + }, + { + "json output", + []string{ + "2", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + v1.NewTallyResult(sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)), + }, + { + "json output", + []string{ + "1", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + v1.NewTallyResult(s.cfg.BondedTokens, sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)), + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryTally() + clientCtx := val.ClientCtx + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + var tally v1.TallyResult + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &tally), out.String()) + s.Require().Equal(tally, tc.expectedOutput) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdGetProposal() { + val := s.network.Validators[0] + + title := "Text Proposal 1" + + testCases := []struct { + name string + args []string + expectErr bool + }{ + { + "get non existing proposal", + []string{ + "10", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + true, + }, + { + "get proposal with json response", + []string{ + "1", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryProposal() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + var proposal v1.Proposal + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposal), out.String()) + s.Require().Equal(title, proposal.Messages[0].GetCachedValue().(*v1.MsgExecLegacyContent).Content.GetCachedValue().(v1beta1.Content).GetTitle()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdGetProposals() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectErr bool + }{ + { + "get proposals as json response", + []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + }, + { + "get proposals with invalid status", + []string{ + "--status=unknown", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + true, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryProposals() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + var proposals v1.QueryProposalsResponse + + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposals), out.String()) + s.Require().Len(proposals.Proposals, 3) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdQueryDeposits() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectErr bool + }{ + { + "get deposits of non existing proposal", + []string{ + "10", + }, + true, + }, + { + "get deposits(valid req)", + []string{ + "1", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryDeposits() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + + var deposits v1.QueryDepositsResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &deposits), out.String()) + s.Require().Len(deposits.Deposits, 1) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdQueryDeposit() { + val := s.network.Validators[0] + depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens) + + testCases := []struct { + name string + args []string + expectErr bool + }{ + { + "get deposit with no depositer", + []string{ + "1", + }, + true, + }, + { + "get deposit with wrong deposit address", + []string{ + "1", + "wrong address", + }, + true, + }, + { + "get deposit (valid req)", + []string{ + "1", + val.Address.String(), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryDeposit() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + + var deposit v1.Deposit + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &deposit), out.String()) + s.Require().Equal(depositAmount.String(), sdk.Coins(deposit.Amount).String()) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdQueryVotes() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectErr bool + }{ + { + "get votes with no proposal id", + []string{}, + true, + }, + { + "get votes of non existed proposal", + []string{ + "10", + }, + true, + }, + { + "vote for invalid proposal", + []string{ + "1", + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryVotes() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + + var votes v1.QueryVotesResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &votes), out.String()) + s.Require().Len(votes.Votes, 1) + } + }) + } +} + +func (s *IntegrationTestSuite) TestCmdQueryVote() { + val := s.network.Validators[0] + + testCases := []struct { + name string + args []string + expectErr bool + expVoteOptions v1.WeightedVoteOptions + }{ + { + "get vote of non existing proposal", + []string{ + "10", + val.Address.String(), + }, + true, + v1.NewNonSplitVoteOption(v1.OptionYes), + }, + { + "get vote by wrong voter", + []string{ + "1", + "wrong address", + }, + true, + v1.NewNonSplitVoteOption(v1.OptionYes), + }, + { + "vote for valid proposal", + []string{ + "1", + val.Address.String(), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + v1.NewNonSplitVoteOption(v1.OptionYes), + }, + { + "split vote for valid proposal", + []string{ + "3", + val.Address.String(), + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + }, + false, + v1.WeightedVoteOptions{ + &v1.WeightedVoteOption{Option: v1.OptionYes, Weight: sdk.NewDecWithPrec(60, 2).String()}, + &v1.WeightedVoteOption{Option: v1.OptionNo, Weight: sdk.NewDecWithPrec(30, 2).String()}, + &v1.WeightedVoteOption{Option: v1.OptionAbstain, Weight: sdk.NewDecWithPrec(5, 2).String()}, + &v1.WeightedVoteOption{Option: v1.OptionNoWithVeto, Weight: sdk.NewDecWithPrec(5, 2).String()}, + }, + }, + } + + for _, tc := range testCases { + tc := tc + s.Run(tc.name, func() { + cmd := cli.GetCmdQueryVote() + clientCtx := val.ClientCtx + + out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) + + if tc.expectErr { + s.Require().Error(err) + } else { + s.Require().NoError(err) + + var vote v1.Vote + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &vote), out.String()) + s.Require().Equal(len(vote.Options), len(tc.expVoteOptions)) + for i, option := range tc.expVoteOptions { + s.Require().Equal(option.Option, vote.Options[i].Option) + s.Require().Equal(option.Weight, vote.Options[i].Weight) + } + } + }) + } +} diff --git a/x/gov/client/testutil/suite.go b/x/gov/client/testutil/tx.go similarity index 57% rename from x/gov/client/testutil/suite.go rename to x/gov/client/testutil/tx.go index bbd5bbc2c275..f3f5a52c4913 100644 --- a/x/gov/client/testutil/suite.go +++ b/x/gov/client/testutil/tx.go @@ -3,15 +3,12 @@ package testutil import ( "encoding/base64" "fmt" - "strings" "github.com/cosmos/cosmos-sdk/testutil" "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" - tmcli "github.com/tendermint/tendermint/libs/cli" - "github.com/cosmos/cosmos-sdk/client/flags" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -83,202 +80,6 @@ func (s *IntegrationTestSuite) TearDownSuite() { s.network.Cleanup() } -func (s *IntegrationTestSuite) TestCmdParams() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectedOutput string - }{ - { - "json output", - []string{fmt.Sprintf("--%s=json", tmcli.OutputFlag)}, - `{"voting_params":{"voting_period":"172800000000000"},"tally_params":{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"},"deposit_params":{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800000000000"}}`, - }, - { - "text output", - []string{}, - ` -deposit_params: - max_deposit_period: "172800000000000" - min_deposit: - - amount: "10000000" - denom: stake -tally_params: - quorum: "0.334000000000000000" - threshold: "0.500000000000000000" - veto_threshold: "0.334000000000000000" -voting_params: - voting_period: "172800000000000" - `, - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryParams() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - s.Require().NoError(err) - s.Require().Equal(strings.TrimSpace(tc.expectedOutput), strings.TrimSpace(out.String())) - }) - } -} - -func (s *IntegrationTestSuite) TestCmdParam() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectedOutput string - }{ - { - "voting params", - []string{ - "voting", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - `{"voting_period":"172800000000000"}`, - }, - { - "tally params", - []string{ - "tallying", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - `{"quorum":"0.334000000000000000","threshold":"0.500000000000000000","veto_threshold":"0.334000000000000000"}`, - }, - { - "deposit params", - []string{ - "deposit", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - `{"min_deposit":[{"denom":"stake","amount":"10000000"}],"max_deposit_period":"172800000000000"}`, - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryParam() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - s.Require().NoError(err) - s.Require().Equal(strings.TrimSpace(tc.expectedOutput), strings.TrimSpace(out.String())) - }) - } -} - -func (s *IntegrationTestSuite) TestCmdProposer() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectErr bool - expectedOutput string - }{ - { - "without proposal id", - []string{ - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - true, - ``, - }, - { - "json output", - []string{ - "1", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - fmt.Sprintf("{\"proposal_id\":\"%s\",\"proposer\":\"%s\"}", "1", val.Address.String()), - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryProposer() - clientCtx := val.ClientCtx - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err) - s.Require().Equal(strings.TrimSpace(tc.expectedOutput), strings.TrimSpace(out.String())) - } - }) - } -} - -func (s *IntegrationTestSuite) TestCmdTally() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectErr bool - expectedOutput v1.TallyResult - }{ - { - "without proposal id", - []string{ - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - true, - v1.TallyResult{}, - }, - { - "json output", - []string{ - "2", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - v1.NewTallyResult(sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)), - }, - { - "json output", - []string{ - "1", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - v1.NewTallyResult(s.cfg.BondedTokens, sdk.NewInt(0), sdk.NewInt(0), sdk.NewInt(0)), - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryTally() - clientCtx := val.ClientCtx - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - - if tc.expectErr { - s.Require().Error(err) - } else { - var tally v1.TallyResult - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &tally), out.String()) - s.Require().Equal(tally, tc.expectedOutput) - } - }) - } -} - func (s *IntegrationTestSuite) TestNewCmdSubmitProposal() { val := s.network.Validators[0] @@ -453,202 +254,6 @@ func (s *IntegrationTestSuite) TestNewCmdSubmitLegacyProposal() { } } -func (s *IntegrationTestSuite) TestCmdGetProposal() { - val := s.network.Validators[0] - - title := "Text Proposal 1" - - testCases := []struct { - name string - args []string - expectErr bool - }{ - { - "get non existing proposal", - []string{ - "10", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - true, - }, - { - "get proposal with json response", - []string{ - "1", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryProposal() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err) - var proposal v1.Proposal - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposal), out.String()) - s.Require().Equal(title, proposal.Messages[0].GetCachedValue().(*v1.MsgExecLegacyContent).Content.GetCachedValue().(v1beta1.Content).GetTitle()) - } - }) - } -} - -func (s *IntegrationTestSuite) TestCmdGetProposals() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectErr bool - }{ - { - "get proposals as json response", - []string{ - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - }, - { - "get proposals with invalid status", - []string{ - "--status=unknown", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - true, - }, - } - - for _, tc := range testCases { - tc := tc - - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryProposals() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err) - var proposals v1.QueryProposalsResponse - - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &proposals), out.String()) - s.Require().Len(proposals.Proposals, 3) - } - }) - } -} - -func (s *IntegrationTestSuite) TestCmdQueryDeposits() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectErr bool - }{ - { - "get deposits of non existing proposal", - []string{ - "10", - }, - true, - }, - { - "get deposits(valid req)", - []string{ - "1", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - }, - } - - for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryDeposits() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err) - - var deposits v1.QueryDepositsResponse - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &deposits), out.String()) - s.Require().Len(deposits.Deposits, 1) - } - }) - } -} - -func (s *IntegrationTestSuite) TestCmdQueryDeposit() { - val := s.network.Validators[0] - depositAmount := sdk.NewCoin(s.cfg.BondDenom, v1.DefaultMinDepositTokens) - - testCases := []struct { - name string - args []string - expectErr bool - }{ - { - "get deposit with no depositer", - []string{ - "1", - }, - true, - }, - { - "get deposit with wrong deposit address", - []string{ - "1", - "wrong address", - }, - true, - }, - { - "get deposit (valid req)", - []string{ - "1", - val.Address.String(), - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - }, - } - - for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryDeposit() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err) - - var deposit v1.Deposit - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &deposit), out.String()) - s.Require().Equal(depositAmount.String(), sdk.Coins(deposit.Amount).String()) - } - }) - } -} - func (s *IntegrationTestSuite) TestNewCmdDeposit() { val := s.network.Validators[0] @@ -727,136 +332,6 @@ func (s *IntegrationTestSuite) TestNewCmdDeposit() { } } -func (s *IntegrationTestSuite) TestCmdQueryVotes() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectErr bool - }{ - { - "get votes with no proposal id", - []string{}, - true, - }, - { - "get votes of non existed proposal", - []string{ - "10", - }, - true, - }, - { - "vote for invalid proposal", - []string{ - "1", - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - }, - } - - for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryVotes() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err) - - var votes v1.QueryVotesResponse - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &votes), out.String()) - s.Require().Len(votes.Votes, 1) - } - }) - } -} - -func (s *IntegrationTestSuite) TestCmdQueryVote() { - val := s.network.Validators[0] - - testCases := []struct { - name string - args []string - expectErr bool - expVoteOptions v1.WeightedVoteOptions - }{ - { - "get vote of non existing proposal", - []string{ - "10", - val.Address.String(), - }, - true, - v1.NewNonSplitVoteOption(v1.OptionYes), - }, - { - "get vote by wrong voter", - []string{ - "1", - "wrong address", - }, - true, - v1.NewNonSplitVoteOption(v1.OptionYes), - }, - { - "vote for valid proposal", - []string{ - "1", - val.Address.String(), - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - v1.NewNonSplitVoteOption(v1.OptionYes), - }, - { - "split vote for valid proposal", - []string{ - "3", - val.Address.String(), - fmt.Sprintf("--%s=json", tmcli.OutputFlag), - }, - false, - v1.WeightedVoteOptions{ - &v1.WeightedVoteOption{Option: v1.OptionYes, Weight: sdk.NewDecWithPrec(60, 2).String()}, - &v1.WeightedVoteOption{Option: v1.OptionNo, Weight: sdk.NewDecWithPrec(30, 2).String()}, - &v1.WeightedVoteOption{Option: v1.OptionAbstain, Weight: sdk.NewDecWithPrec(5, 2).String()}, - &v1.WeightedVoteOption{Option: v1.OptionNoWithVeto, Weight: sdk.NewDecWithPrec(5, 2).String()}, - }, - }, - } - - for _, tc := range testCases { - tc := tc - s.Run(tc.name, func() { - cmd := cli.GetCmdQueryVote() - clientCtx := val.ClientCtx - - out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) - - if tc.expectErr { - s.Require().Error(err) - } else { - s.Require().NoError(err) - - var vote v1.Vote - s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &vote), out.String()) - s.Require().Equal(len(vote.Options), len(tc.expVoteOptions)) - for i, option := range tc.expVoteOptions { - s.Require().Equal(option.Option, vote.Options[i].Option) - s.Require().Equal(option.Weight, vote.Options[i].Weight) - } - } - }) - } -} - func (s *IntegrationTestSuite) TestNewCmdVote() { val := s.network.Validators[0] diff --git a/x/gov/client/utils/query.go b/x/gov/client/utils/query.go index 97eb7e784cf2..a624d7769556 100644 --- a/x/gov/client/utils/query.go +++ b/x/gov/client/utils/query.go @@ -298,7 +298,6 @@ func QueryVoteByTxQuery(clientCtx client.Context, params v1.QueryVoteParams) ([] // QueryDepositByTxQuery will query for a single deposit via a direct txs tags // query. func QueryDepositByTxQuery(clientCtx client.Context, params v1.QueryDepositParams) ([]byte, error) { - // initial deposit was submitted with proposal, so must be queried separately initialDeposit, err := queryInitialDepositByTxQuery(clientCtx, params.ProposalID) if err != nil { @@ -477,7 +476,6 @@ func queryInitialDepositByTxQuery(clientCtx client.Context, proposalID uint64) ( fmt.Sprintf("%s.%s='%d'", types.EventTypeSubmitProposal, types.AttributeKeyProposalID, proposalID), }, ) - if err != nil { return v1.Deposit{}, err } diff --git a/x/gov/client/utils/query_test.go b/x/gov/client/utils/query_test.go index e5b1e9b115e0..8bc1a8e42a4e 100644 --- a/x/gov/client/utils/query_test.go +++ b/x/gov/client/utils/query_test.go @@ -106,7 +106,8 @@ func TestGetPaginatedVotes(t *testing.T) { }, votes: []v1.Vote{ v1.NewVote(0, acc1, v1.NewNonSplitVoteOption(v1.OptionYes), ""), - v1.NewVote(0, acc2, v1.NewNonSplitVoteOption(v1.OptionYes), "")}, + v1.NewVote(0, acc2, v1.NewNonSplitVoteOption(v1.OptionYes), ""), + }, }, { description: "2MsgPerTx1Chunk", @@ -162,7 +163,7 @@ func TestGetPaginatedVotes(t *testing.T) { tc := tc t.Run(tc.description, func(t *testing.T) { - var marshalled = make([]tmtypes.Tx, len(tc.msgs)) + marshalled := make([]tmtypes.Tx, len(tc.msgs)) cli := TxSearchMock{txs: marshalled, txConfig: encCfg.TxConfig} clientCtx := client.Context{}. WithLegacyAmino(encCfg.Amino). diff --git a/x/gov/common_test.go b/x/gov/common_test.go index ff20ec01cb6b..d4d9bd382d4c 100644 --- a/x/gov/common_test.go +++ b/x/gov/common_test.go @@ -80,10 +80,8 @@ func SortByteArrays(src [][]byte) [][]byte { const contextKeyBadProposal = "contextKeyBadProposal" -var ( - pubkeys = []cryptotypes.PubKey{ - ed25519.GenPrivKey().PubKey(), - ed25519.GenPrivKey().PubKey(), - ed25519.GenPrivKey().PubKey(), - } -) +var pubkeys = []cryptotypes.PubKey{ + ed25519.GenPrivKey().PubKey(), + ed25519.GenPrivKey().PubKey(), + ed25519.GenPrivKey().PubKey(), +} diff --git a/x/gov/genesis_test.go b/x/gov/genesis_test.go index ee8d2767f9f8..80cb4a4b87a2 100644 --- a/x/gov/genesis_test.go +++ b/x/gov/genesis_test.go @@ -12,14 +12,12 @@ import ( "github.com/cosmos/cosmos-sdk/db/memdb" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -54,9 +52,9 @@ func TestImportExportQueues(t *testing.T) { require.True(t, proposal1.Status == v1.StatusDepositPeriod) require.True(t, proposal2.Status == v1.StatusVotingPeriod) - authGenState := auth.ExportGenesis(ctx, app.AccountKeeper) + authGenState := app.AccountKeeper.ExportGenesis(ctx) bankGenState := app.BankKeeper.ExportGenesis(ctx) - stakingGenState := staking.ExportGenesis(ctx, app.StakingKeeper) + stakingGenState := app.StakingKeeper.ExportGenesis(ctx) distributionGenState := app.DistrKeeper.ExportGenesis(ctx) // export the state and import it into a new app diff --git a/x/gov/keeper/deposit_test.go b/x/gov/keeper/deposit_test.go index 9183f16deb55..8d0a1986aae0 100644 --- a/x/gov/keeper/deposit_test.go +++ b/x/gov/keeper/deposit_test.go @@ -47,7 +47,7 @@ func TestDeposits(t *testing.T) { proposal, ok = app.GovKeeper.GetProposal(ctx, proposalID) require.True(t, ok) require.Equal(t, fourStake, sdk.NewCoins(proposal.TotalDeposit...)) - require.Equal(t, addr0Initial.Sub(fourStake), app.BankKeeper.GetAllBalances(ctx, TestAddrs[0])) + require.Equal(t, addr0Initial.Sub(fourStake...), app.BankKeeper.GetAllBalances(ctx, TestAddrs[0])) // Check a second deposit from same address votingStarted, err = app.GovKeeper.AddDeposit(ctx, proposalID, TestAddrs[0], fiveStake) @@ -60,7 +60,7 @@ func TestDeposits(t *testing.T) { proposal, ok = app.GovKeeper.GetProposal(ctx, proposalID) require.True(t, ok) require.Equal(t, fourStake.Add(fiveStake...), sdk.NewCoins(proposal.TotalDeposit...)) - require.Equal(t, addr0Initial.Sub(fourStake).Sub(fiveStake), app.BankKeeper.GetAllBalances(ctx, TestAddrs[0])) + require.Equal(t, addr0Initial.Sub(fourStake...).Sub(fiveStake...), app.BankKeeper.GetAllBalances(ctx, TestAddrs[0])) // Check third deposit from a new address votingStarted, err = app.GovKeeper.AddDeposit(ctx, proposalID, TestAddrs[1], fourStake) @@ -73,7 +73,7 @@ func TestDeposits(t *testing.T) { proposal, ok = app.GovKeeper.GetProposal(ctx, proposalID) require.True(t, ok) require.Equal(t, fourStake.Add(fiveStake...).Add(fourStake...), sdk.NewCoins(proposal.TotalDeposit...)) - require.Equal(t, addr1Initial.Sub(fourStake), app.BankKeeper.GetAllBalances(ctx, TestAddrs[1])) + require.Equal(t, addr1Initial.Sub(fourStake...), app.BankKeeper.GetAllBalances(ctx, TestAddrs[1])) // Check that proposal moved to voting period proposal, ok = app.GovKeeper.GetProposal(ctx, proposalID) @@ -109,5 +109,5 @@ func TestDeposits(t *testing.T) { app.GovKeeper.DeleteAndBurnDeposits(ctx, proposalID) deposits = app.GovKeeper.GetDeposits(ctx, proposalID) require.Len(t, deposits, 0) - require.Equal(t, addr0Initial.Sub(fourStake), app.BankKeeper.GetAllBalances(ctx, TestAddrs[0])) + require.Equal(t, addr0Initial.Sub(fourStake...), app.BankKeeper.GetAllBalances(ctx, TestAddrs[0])) } diff --git a/x/gov/keeper/grpc_query.go b/x/gov/keeper/grpc_query.go index b1ed49010f97..3ae97a3d96a1 100644 --- a/x/gov/keeper/grpc_query.go +++ b/x/gov/keeper/grpc_query.go @@ -87,7 +87,6 @@ func (q Keeper) Proposals(c context.Context, req *v1.QueryProposalsRequest) (*v1 return false, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -149,7 +148,6 @@ func (q Keeper) Votes(c context.Context, req *v1.QueryVotesRequest) (*v1.QueryVo votes = append(votes, &vote) return nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -238,7 +236,6 @@ func (q Keeper) Deposits(c context.Context, req *v1.QueryDepositsRequest) (*v1.Q deposits = append(deposits, &deposit) return nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } diff --git a/x/gov/keeper/grpc_query_test.go b/x/gov/keeper/grpc_query_test.go index 14b4286eeb4e..03d93544a628 100644 --- a/x/gov/keeper/grpc_query_test.go +++ b/x/gov/keeper/grpc_query_test.go @@ -315,9 +315,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryProposals() { func (suite *KeeperTestSuite) TestLegacyGRPCQueryProposals() { app, ctx, queryClient := suite.app, suite.ctx, suite.legacyQueryClient - var ( - req *v1beta1.QueryProposalsRequest - ) + var req *v1beta1.QueryProposalsRequest testCases := []struct { msg string diff --git a/x/gov/keeper/hooks_test.go b/x/gov/keeper/hooks_test.go index 89a6a641e126..19be117333ba 100644 --- a/x/gov/keeper/hooks_test.go +++ b/x/gov/keeper/hooks_test.go @@ -37,9 +37,11 @@ func (h *MockGovHooksReceiver) AfterProposalDeposit(ctx sdk.Context, proposalID func (h *MockGovHooksReceiver) AfterProposalVote(ctx sdk.Context, proposalID uint64, voterAddr sdk.AccAddress) { h.AfterProposalVoteValid = true } + func (h *MockGovHooksReceiver) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) { h.AfterProposalFailedMinDepositValid = true } + func (h *MockGovHooksReceiver) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) { h.AfterProposalVotingPeriodEndedValid = true } diff --git a/x/gov/keeper/invariants.go b/x/gov/keeper/invariants.go index 5179db3d5f82..6e0f9d4e0a51 100644 --- a/x/gov/keeper/invariants.go +++ b/x/gov/keeper/invariants.go @@ -35,7 +35,11 @@ func ModuleAccountInvariant(keeper Keeper, bk types.BankKeeper) sdk.Invariant { macc := keeper.GetGovernanceAccount(ctx) balances := bk.GetAllBalances(ctx, macc.GetAddress()) - broken := !balances.IsEqual(expectedDeposits) + + // Require that the deposit balances are <= than the x/gov module's total + // balances. We use the <= operator since external funds can be sent to x/gov + // module's account and so the balance can be larger. + broken := !balances.IsAllGTE(expectedDeposits) return sdk.FormatInvariant(types.ModuleName, "deposits", fmt.Sprintf("\tgov ModuleAccount coins: %s\n\tsum of deposit amounts: %s\n", diff --git a/x/gov/keeper/keeper.go b/x/gov/keeper/keeper.go index bb4491eeb329..4558075f48ac 100644 --- a/x/gov/keeper/keeper.go +++ b/x/gov/keeper/keeper.go @@ -6,10 +6,10 @@ import ( "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/middleware" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/cosmos/cosmos-sdk/x/gov/types" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" @@ -40,7 +40,7 @@ type Keeper struct { legacyRouter v1beta1.Router // Msg server router - router *middleware.MsgServiceRouter + router *baseapp.MsgServiceRouter config types.Config } @@ -55,10 +55,9 @@ type Keeper struct { func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace types.ParamSubspace, authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, sk types.StakingKeeper, - legacyRouter v1beta1.Router, router *middleware.MsgServiceRouter, + legacyRouter v1beta1.Router, router *baseapp.MsgServiceRouter, config types.Config, ) Keeper { - // ensure governance module account is set if addr := authKeeper.GetModuleAddress(types.ModuleName); addr == nil { panic(fmt.Sprintf("%s module account has not been set", types.ModuleName)) @@ -104,7 +103,7 @@ func (keeper Keeper) Logger(ctx sdk.Context) log.Logger { } // Router returns the gov keeper's router -func (keeper Keeper) Router() *middleware.MsgServiceRouter { +func (keeper Keeper) Router() *baseapp.MsgServiceRouter { return keeper.router } diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index 848133cdce21..8800d2d79eca 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -12,8 +12,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) type msgServer struct { @@ -105,7 +105,6 @@ func (k msgServer) ExecLegacyContent(goCtx context.Context, msg *v1.MsgExecLegac } return &v1.MsgExecLegacyContentResponse{}, nil - } func (k msgServer) Vote(goCtx context.Context, msg *v1.MsgVote) (*v1.MsgVoteResponse, error) { diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go index 54a3e9fec49a..d47d87f2a256 100644 --- a/x/gov/keeper/querier_test.go +++ b/x/gov/keeper/querier_test.go @@ -64,7 +64,6 @@ func getQueriedProposals( t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, depositor, voter sdk.AccAddress, status v1.ProposalStatus, page, limit int, ) []*v1.Proposal { - query := abci.RequestQuery{ Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryProposals}, "/"), Data: cdc.MustMarshalJSON(v1.NewQueryProposalsParams(page, limit, status, voter, depositor)), @@ -128,8 +127,7 @@ func getQueriedVote(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, queri return vote } -func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, - proposalID uint64, page, limit int) []v1.Vote { +func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64, page, limit int) []v1.Vote { query := abci.RequestQuery{ Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryVote}, "/"), Data: cdc.MustMarshalJSON(v1.NewQueryProposalVotesParams(proposalID, page, limit)), diff --git a/x/gov/keeper/tally.go b/x/gov/keeper/tally.go index 52d7138e8388..3f1dd10ec7dd 100644 --- a/x/gov/keeper/tally.go +++ b/x/gov/keeper/tally.go @@ -36,7 +36,6 @@ func (keeper Keeper) Tally(ctx sdk.Context, proposal v1.Proposal) (passes bool, keeper.IterateVotes(ctx, proposal.Id, func(vote v1.Vote) bool { // if validator, just record it in the map voter, err := sdk.AccAddressFromBech32(vote.Voter) - if err != nil { panic(err) } @@ -102,7 +101,7 @@ func (keeper Keeper) Tally(ctx sdk.Context, proposal v1.Proposal) (passes bool, } // If there is not enough quorum of votes, the proposal fails - percentVoting := totalVotingPower.Quo(keeper.sk.TotalBondedTokens(ctx).ToDec()) + percentVoting := totalVotingPower.Quo(sdk.NewDecFromInt(keeper.sk.TotalBondedTokens(ctx))) quorum, _ := sdk.NewDecFromStr(tallyParams.Quorum) if percentVoting.LT(quorum) { return false, false, tallyResults diff --git a/x/gov/migrations/v034/types.go b/x/gov/migrations/v034/types.go deleted file mode 100644 index 83955badd7e8..000000000000 --- a/x/gov/migrations/v034/types.go +++ /dev/null @@ -1,334 +0,0 @@ -// Package v034 is used for legacy migration scripts. Actual migration scripts -// for v034 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -// DONTCOVER -package v034 - -import ( - "encoding/json" - "fmt" - "time" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var ( - _ ProposalContent = TextProposal{} -) - -const ( - ModuleName = "gov" - - StatusNil ProposalStatus = 0x00 - StatusDepositPeriod ProposalStatus = 0x01 - StatusVotingPeriod ProposalStatus = 0x02 - StatusPassed ProposalStatus = 0x03 - StatusRejected ProposalStatus = 0x04 - StatusFailed ProposalStatus = 0x05 - - OptionEmpty VoteOption = 0x00 - OptionYes VoteOption = 0x01 - OptionAbstain VoteOption = 0x02 - OptionNo VoteOption = 0x03 - OptionNoWithVeto VoteOption = 0x04 - - ProposalTypeNil ProposalKind = 0x00 - ProposalTypeText ProposalKind = 0x01 - ProposalTypeParameterChange ProposalKind = 0x02 -) - -type ( - ProposalQueue []uint64 - - ProposalKind byte - - VoteOption byte - ProposalStatus byte - - ProposalContent interface { - GetTitle() string - GetDescription() string - ProposalType() ProposalKind - } - - Proposals []Proposal - - TextProposal struct { - Title string `json:"title"` - Description string `json:"description"` - } - - Proposal struct { - ProposalContent `json:"proposal_content"` - - ProposalID uint64 `json:"proposal_id"` - - Status ProposalStatus `json:"proposal_status"` - FinalTallyResult TallyResult `json:"final_tally_result"` - - SubmitTime time.Time `json:"submit_time"` - DepositEndTime time.Time `json:"deposit_end_time"` - TotalDeposit sdk.Coins `json:"total_deposit"` - - VotingStartTime time.Time `json:"voting_start_time"` - VotingEndTime time.Time `json:"voting_end_time"` - } - - TallyParams struct { - Quorum sdk.Dec `json:"quorum,omitempty"` - Threshold sdk.Dec `json:"threshold,omitempty"` - Veto sdk.Dec `json:"veto,omitempty"` - } - - VotingParams struct { - VotingPeriod time.Duration `json:"voting_period,omitempty"` - } - - TallyResult struct { - Yes sdk.Int `json:"yes"` - Abstain sdk.Int `json:"abstain"` - No sdk.Int `json:"no"` - NoWithVeto sdk.Int `json:"no_with_veto"` - } - - Deposits []Deposit - - Vote struct { - ProposalID uint64 `json:"proposal_id"` - Voter sdk.AccAddress `json:"voter"` - Option VoteOption `json:"option"` - } - - Votes []Vote - - DepositParams struct { - MinDeposit sdk.Coins `json:"min_deposit,omitempty"` - MaxDepositPeriod time.Duration `json:"max_deposit_period,omitempty"` - } - - Deposit struct { - ProposalID uint64 `json:"proposal_id"` - Depositor sdk.AccAddress `json:"depositor"` - Amount sdk.Coins `json:"amount"` - } - - DepositWithMetadata struct { - ProposalID uint64 `json:"proposal_id"` - Deposit Deposit `json:"deposit"` - } - - VoteWithMetadata struct { - ProposalID uint64 `json:"proposal_id"` - Vote Vote `json:"vote"` - } - - GenesisState struct { - StartingProposalID uint64 `json:"starting_proposal_id"` - Deposits []DepositWithMetadata `json:"deposits"` - Votes []VoteWithMetadata `json:"votes"` - Proposals []Proposal `json:"proposals"` - DepositParams DepositParams `json:"deposit_params"` - VotingParams VotingParams `json:"voting_params"` - TallyParams TallyParams `json:"tally_params"` - } -) - -func (tp TextProposal) GetTitle() string { return tp.Title } -func (tp TextProposal) GetDescription() string { return tp.Description } -func (tp TextProposal) ProposalType() ProposalKind { return ProposalTypeText } - -// ProposalStatusToString turns a string into a ProposalStatus -func ProposalStatusFromString(str string) (ProposalStatus, error) { - switch str { - case "DepositPeriod": - return StatusDepositPeriod, nil - - case "VotingPeriod": - return StatusVotingPeriod, nil - - case "Passed": - return StatusPassed, nil - - case "Rejected": - return StatusRejected, nil - - case "Failed": - return StatusFailed, nil - - case "": - return StatusNil, nil - - default: - return ProposalStatus(0xff), fmt.Errorf("'%s' is not a valid proposal status", str) - } -} - -func (status ProposalStatus) Marshal() ([]byte, error) { - return []byte{byte(status)}, nil -} - -func (status *ProposalStatus) Unmarshal(data []byte) error { - *status = ProposalStatus(data[0]) - return nil -} - -func (status ProposalStatus) MarshalJSON() ([]byte, error) { - return json.Marshal(status.String()) -} - -func (status *ProposalStatus) UnmarshalJSON(data []byte) error { - var s string - err := json.Unmarshal(data, &s) - if err != nil { - return err - } - - bz2, err := ProposalStatusFromString(s) - if err != nil { - return err - } - - *status = bz2 - return nil -} - -func (status ProposalStatus) String() string { - switch status { - case StatusDepositPeriod: - return "DepositPeriod" - - case StatusVotingPeriod: - return "VotingPeriod" - - case StatusPassed: - return "Passed" - - case StatusRejected: - return "Rejected" - - case StatusFailed: - return "Failed" - - default: - return "" - } -} - -func VoteOptionFromString(str string) (VoteOption, error) { - switch str { - case "Yes": - return OptionYes, nil - - case "Abstain": - return OptionAbstain, nil - - case "No": - return OptionNo, nil - - case "NoWithVeto": - return OptionNoWithVeto, nil - - default: - return VoteOption(0xff), fmt.Errorf("'%s' is not a valid vote option", str) - } -} - -func (vo VoteOption) Marshal() ([]byte, error) { - return []byte{byte(vo)}, nil -} - -func (vo *VoteOption) Unmarshal(data []byte) error { - *vo = VoteOption(data[0]) - return nil -} - -func (vo VoteOption) MarshalJSON() ([]byte, error) { - return json.Marshal(vo.String()) -} - -func (vo *VoteOption) UnmarshalJSON(data []byte) error { - var s string - err := json.Unmarshal(data, &s) - if err != nil { - return err - } - - bz2, err := VoteOptionFromString(s) - if err != nil { - return err - } - - *vo = bz2 - return nil -} - -func (vo VoteOption) String() string { - switch vo { - case OptionYes: - return "Yes" - case OptionAbstain: - return "Abstain" - case OptionNo: - return "No" - case OptionNoWithVeto: - return "NoWithVeto" - default: - return "" - } -} - -func ProposalTypeFromString(str string) (ProposalKind, error) { - switch str { - case "Text": - return ProposalTypeText, nil - case "ParameterChange": - return ProposalTypeParameterChange, nil - default: - return ProposalKind(0xff), fmt.Errorf("'%s' is not a valid proposal type", str) - } -} - -func (pt ProposalKind) Marshal() ([]byte, error) { - return []byte{byte(pt)}, nil -} - -func (pt *ProposalKind) Unmarshal(data []byte) error { - *pt = ProposalKind(data[0]) - return nil -} - -func (pt ProposalKind) MarshalJSON() ([]byte, error) { - return json.Marshal(pt.String()) -} - -func (pt *ProposalKind) UnmarshalJSON(data []byte) error { - var s string - err := json.Unmarshal(data, &s) - if err != nil { - return err - } - - bz2, err := ProposalTypeFromString(s) - if err != nil { - return err - } - *pt = bz2 - return nil -} - -func (pt ProposalKind) String() string { - switch pt { - case ProposalTypeText: - return "Text" - case ProposalTypeParameterChange: - return "ParameterChange" - default: - return "" - } -} - -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterInterface((*ProposalContent)(nil), nil) - cdc.RegisterConcrete(TextProposal{}, "gov/TextProposal", nil) -} diff --git a/x/gov/migrations/v036/types.go b/x/gov/migrations/v036/types.go deleted file mode 100644 index f46d47f97b2e..000000000000 --- a/x/gov/migrations/v036/types.go +++ /dev/null @@ -1,135 +0,0 @@ -// Package v036 is used for legacy migration scripts. Actual migration scripts -// for v036 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -// DONTCOVER -package v036 - -import ( - "fmt" - "strings" - "time" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - v034gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v034" -) - -const ( - ModuleName = "gov" - RouterKey = ModuleName - - ProposalTypeText string = "Text" - - MaxDescriptionLength int = 5000 - MaxTitleLength int = 140 -) - -var ( - _ Content = TextProposal{} -) - -type ( - Proposals []Proposal - ProposalQueue []uint64 - - TextProposal struct { - Title string `json:"title"` - Description string `json:"description"` - } - - Content interface { - GetTitle() string - GetDescription() string - ProposalRoute() string - ProposalType() string - ValidateBasic() error - String() string - } - - Proposal struct { - Content `json:"content"` - - ProposalID uint64 `json:"id"` - Status v034gov.ProposalStatus `json:"proposal_status"` - FinalTallyResult v034gov.TallyResult `json:"final_tally_result"` - - SubmitTime time.Time `json:"submit_time"` - DepositEndTime time.Time `json:"deposit_end_time"` - TotalDeposit sdk.Coins `json:"total_deposit"` - - VotingStartTime time.Time `json:"voting_start_time"` - VotingEndTime time.Time `json:"voting_end_time"` - } - - GenesisState struct { - StartingProposalID uint64 `json:"starting_proposal_id"` - Deposits v034gov.Deposits `json:"deposits"` - Votes v034gov.Votes `json:"votes"` - Proposals []Proposal `json:"proposals"` - DepositParams v034gov.DepositParams `json:"deposit_params"` - VotingParams v034gov.VotingParams `json:"voting_params"` - TallyParams v034gov.TallyParams `json:"tally_params"` - } -) - -func NewGenesisState( - startingProposalID uint64, deposits v034gov.Deposits, votes v034gov.Votes, proposals []Proposal, - depositParams v034gov.DepositParams, votingParams v034gov.VotingParams, tallyParams v034gov.TallyParams, -) GenesisState { - - return GenesisState{ - StartingProposalID: startingProposalID, - Deposits: deposits, - Votes: votes, - Proposals: proposals, - DepositParams: depositParams, - VotingParams: votingParams, - TallyParams: tallyParams, - } -} - -func NewTextProposal(title, description string) Content { - return TextProposal{title, description} -} - -func (tp TextProposal) GetTitle() string { return tp.Title } -func (tp TextProposal) GetDescription() string { return tp.Description } -func (tp TextProposal) ProposalRoute() string { return RouterKey } -func (tp TextProposal) ProposalType() string { return ProposalTypeText } -func (tp TextProposal) ValidateBasic() error { return ValidateAbstract(tp) } - -func (tp TextProposal) String() string { - return fmt.Sprintf(`Text Proposal: - Title: %s - Description: %s -`, tp.Title, tp.Description) -} - -func ErrInvalidProposalContent(msg string) error { - return fmt.Errorf("invalid proposal content: %s", msg) -} - -func ValidateAbstract(c Content) error { - title := c.GetTitle() - if len(strings.TrimSpace(title)) == 0 { - return ErrInvalidProposalContent("proposal title cannot be blank") - } - if len(title) > MaxTitleLength { - return ErrInvalidProposalContent(fmt.Sprintf("proposal title is longer than max length of %d", MaxTitleLength)) - } - - description := c.GetDescription() - if len(description) == 0 { - return ErrInvalidProposalContent("proposal description cannot be blank") - } - if len(description) > MaxDescriptionLength { - return ErrInvalidProposalContent(fmt.Sprintf("proposal description is longer than max length of %d", MaxDescriptionLength)) - } - - return nil -} - -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterInterface((*Content)(nil), nil) - cdc.RegisterConcrete(TextProposal{}, "cosmos-sdk/TextProposal", nil) -} diff --git a/x/gov/migrations/v040/migrate.go b/x/gov/migrations/v040/migrate.go deleted file mode 100644 index fff6adb103a1..000000000000 --- a/x/gov/migrations/v040/migrate.go +++ /dev/null @@ -1,208 +0,0 @@ -package v040 - -import ( - "fmt" - - proto "github.com/gogo/protobuf/proto" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - v036distr "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v036" - v040distr "github.com/cosmos/cosmos-sdk/x/distribution/types" - v034gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v034" - v036gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v036" - v040gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - v036params "github.com/cosmos/cosmos-sdk/x/params/migrations/v036" - v040params "github.com/cosmos/cosmos-sdk/x/params/types/proposal" - v038upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/migrations/v038" - v040upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/types" -) - -func migrateVoteOption(oldVoteOption v034gov.VoteOption) v040gov.VoteOption { - switch oldVoteOption { - case v034gov.OptionEmpty: - return v040gov.OptionEmpty - - case v034gov.OptionYes: - return v040gov.OptionYes - - case v034gov.OptionAbstain: - return v040gov.OptionAbstain - - case v034gov.OptionNo: - return v040gov.OptionNo - - case v034gov.OptionNoWithVeto: - return v040gov.OptionNoWithVeto - - default: - panic(fmt.Errorf("'%s' is not a valid vote option", oldVoteOption)) - } -} - -func migrateProposalStatus(oldProposalStatus v034gov.ProposalStatus) v040gov.ProposalStatus { - switch oldProposalStatus { - - case v034gov.StatusNil: - return v040gov.StatusNil - - case v034gov.StatusDepositPeriod: - return v040gov.StatusDepositPeriod - - case v034gov.StatusVotingPeriod: - return v040gov.StatusVotingPeriod - - case v034gov.StatusPassed: - return v040gov.StatusPassed - - case v034gov.StatusRejected: - return v040gov.StatusRejected - - case v034gov.StatusFailed: - return v040gov.StatusFailed - - default: - panic(fmt.Errorf("'%s' is not a valid proposal status", oldProposalStatus)) - } -} - -func migrateContent(oldContent v036gov.Content) *codectypes.Any { - var protoProposal proto.Message - - switch oldContent := oldContent.(type) { - case v036gov.TextProposal: - { - protoProposal = &v040gov.TextProposal{ - Title: oldContent.Title, - Description: oldContent.Description, - } - // Convert the content into Any. - contentAny, err := codectypes.NewAnyWithValue(protoProposal) - if err != nil { - panic(err) - } - - return contentAny - } - case v036distr.CommunityPoolSpendProposal: - { - protoProposal = &v040distr.CommunityPoolSpendProposal{ - Title: oldContent.Title, - Description: oldContent.Description, - Recipient: oldContent.Recipient.String(), - Amount: oldContent.Amount, - } - } - case v038upgrade.CancelSoftwareUpgradeProposal: - { - protoProposal = &v040upgrade.CancelSoftwareUpgradeProposal{ - Description: oldContent.Description, - Title: oldContent.Title, - } - } - case v038upgrade.SoftwareUpgradeProposal: - { - protoProposal = &v040upgrade.SoftwareUpgradeProposal{ - Description: oldContent.Description, - Title: oldContent.Title, - Plan: v040upgrade.Plan{ - Name: oldContent.Plan.Name, - Height: oldContent.Plan.Height, - Info: oldContent.Plan.Info, - }, - } - } - case v036params.ParameterChangeProposal: - { - newChanges := make([]v040params.ParamChange, len(oldContent.Changes)) - for i, oldChange := range oldContent.Changes { - newChanges[i] = v040params.ParamChange{ - Subspace: oldChange.Subspace, - Key: oldChange.Key, - Value: oldChange.Value, - } - } - - protoProposal = &v040params.ParameterChangeProposal{ - Description: oldContent.Description, - Title: oldContent.Title, - Changes: newChanges, - } - } - default: - panic(fmt.Errorf("%T is not a valid proposal content type", oldContent)) - } - - // Convert the content into Any. - contentAny, err := codectypes.NewAnyWithValue(protoProposal) - if err != nil { - panic(err) - } - - return contentAny -} - -// Migrate accepts exported v0.36 x/gov genesis state and migrates it to -// v0.40 x/gov genesis state. The migration includes: -// -// - Convert vote option & proposal status from byte to enum. -// - Migrate proposal content to Any. -// - Convert addresses from bytes to bech32 strings. -// - Re-encode in v0.40 GenesisState. -func Migrate(oldGovState v036gov.GenesisState) *v040gov.GenesisState { - newDeposits := make([]v040gov.Deposit, len(oldGovState.Deposits)) - for i, oldDeposit := range oldGovState.Deposits { - newDeposits[i] = v040gov.Deposit{ - ProposalId: oldDeposit.ProposalID, - Depositor: oldDeposit.Depositor.String(), - Amount: oldDeposit.Amount, - } - } - - newVotes := make([]v040gov.Vote, len(oldGovState.Votes)) - for i, oldVote := range oldGovState.Votes { - newVotes[i] = v040gov.Vote{ - ProposalId: oldVote.ProposalID, - Voter: oldVote.Voter.String(), - Option: migrateVoteOption(oldVote.Option), - } - } - - newProposals := make([]v040gov.Proposal, len(oldGovState.Proposals)) - for i, oldProposal := range oldGovState.Proposals { - newProposals[i] = v040gov.Proposal{ - ProposalId: oldProposal.ProposalID, - Content: migrateContent(oldProposal.Content), - Status: migrateProposalStatus(oldProposal.Status), - FinalTallyResult: v040gov.TallyResult{ - Yes: oldProposal.FinalTallyResult.Yes, - Abstain: oldProposal.FinalTallyResult.Abstain, - No: oldProposal.FinalTallyResult.No, - NoWithVeto: oldProposal.FinalTallyResult.NoWithVeto, - }, - SubmitTime: oldProposal.SubmitTime, - DepositEndTime: oldProposal.DepositEndTime, - TotalDeposit: oldProposal.TotalDeposit, - VotingStartTime: oldProposal.VotingStartTime, - VotingEndTime: oldProposal.VotingEndTime, - } - } - - return &v040gov.GenesisState{ - StartingProposalId: oldGovState.StartingProposalID, - Deposits: newDeposits, - Votes: newVotes, - Proposals: newProposals, - DepositParams: v040gov.DepositParams{ - MinDeposit: oldGovState.DepositParams.MinDeposit, - MaxDepositPeriod: oldGovState.DepositParams.MaxDepositPeriod, - }, - VotingParams: v040gov.VotingParams{ - VotingPeriod: oldGovState.VotingParams.VotingPeriod, - }, - TallyParams: v040gov.TallyParams{ - Quorum: oldGovState.TallyParams.Quorum, - Threshold: oldGovState.TallyParams.Threshold, - VetoThreshold: oldGovState.TallyParams.Veto, - }, - } -} diff --git a/x/gov/migrations/v040/migrate_test.go b/x/gov/migrations/v040/migrate_test.go deleted file mode 100644 index 6aeace7b1444..000000000000 --- a/x/gov/migrations/v040/migrate_test.go +++ /dev/null @@ -1,239 +0,0 @@ -package v040_test - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" - v036distr "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v036" - v036gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v036" - v040gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v040" - v036params "github.com/cosmos/cosmos-sdk/x/params/migrations/v036" - v038upgrade "github.com/cosmos/cosmos-sdk/x/upgrade/migrations/v038" -) - -func TestMigrate(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() - clientCtx := client.Context{}. - WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithTxConfig(encodingConfig.TxConfig). - WithLegacyAmino(encodingConfig.Amino). - WithCodec(encodingConfig.Codec) - - recipient, err := sdk.AccAddressFromBech32("cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") - require.NoError(t, err) - govGenState := v036gov.GenesisState{ - Proposals: []v036gov.Proposal{ - { - Content: v036gov.TextProposal{ - Title: "foo_text", - Description: "bar_text", - }, - }, - { - Content: v036distr.CommunityPoolSpendProposal{ - Title: "foo_community", - Description: "bar_community", - Recipient: recipient, - Amount: sdk.NewCoins(sdk.NewCoin("footoken", sdk.NewInt(2))), - }, - }, - { - Content: v038upgrade.CancelSoftwareUpgradeProposal{ - Title: "foo_cancel_upgrade", - Description: "bar_cancel_upgrade", - }, - }, - { - Content: v038upgrade.SoftwareUpgradeProposal{ - Title: "foo_software_upgrade", - Description: "bar_software_upgrade", - Plan: v038upgrade.Plan{ - Name: "foo_upgrade_name", - Height: 123, - Info: "foo_upgrade_info", - }, - }, - }, - { - Content: v036params.ParameterChangeProposal{ - Title: "foo_param_change", - Description: "bar_param_change", - Changes: []v036params.ParamChange{ - { - Subspace: "foo_param_change_subspace", - Key: "foo_param_change_key", - Subkey: "foo_param_change_subkey", - Value: "foo_param_change_value", - }, - }, - }, - }, - }, - } - - migrated := v040gov.Migrate(govGenState) - - bz, err := clientCtx.Codec.MarshalJSON(migrated) - require.NoError(t, err) - - // Indent the JSON bz correctly. - var jsonObj map[string]interface{} - err = json.Unmarshal(bz, &jsonObj) - require.NoError(t, err) - indentedBz, err := json.MarshalIndent(jsonObj, "", "\t") - require.NoError(t, err) - - // Make sure about: - // - TextProposal has correct JSON. - // - CommunityPoolSpendProposal has correct JSON. - // - CancelSoftwareUpgradeProposal has correct JSON. - // - SoftwareUpgradeProposal has correct JSON. - // - ParameterChangeProposal has correct JSON. - expected := `{ - "deposit_params": { - "max_deposit_period": "0s", - "min_deposit": [] - }, - "deposits": [], - "proposals": [ - { - "content": { - "@type": "/cosmos.gov.v1beta1.TextProposal", - "description": "bar_text", - "title": "foo_text" - }, - "deposit_end_time": "0001-01-01T00:00:00Z", - "final_tally_result": { - "abstain": "0", - "no": "0", - "no_with_veto": "0", - "yes": "0" - }, - "proposal_id": "0", - "status": "PROPOSAL_STATUS_UNSPECIFIED", - "submit_time": "0001-01-01T00:00:00Z", - "total_deposit": [], - "voting_end_time": "0001-01-01T00:00:00Z", - "voting_start_time": "0001-01-01T00:00:00Z" - }, - { - "content": { - "@type": "/cosmos.distribution.v1beta1.CommunityPoolSpendProposal", - "amount": [ - { - "amount": "2", - "denom": "footoken" - } - ], - "description": "bar_community", - "recipient": "cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh", - "title": "foo_community" - }, - "deposit_end_time": "0001-01-01T00:00:00Z", - "final_tally_result": { - "abstain": "0", - "no": "0", - "no_with_veto": "0", - "yes": "0" - }, - "proposal_id": "0", - "status": "PROPOSAL_STATUS_UNSPECIFIED", - "submit_time": "0001-01-01T00:00:00Z", - "total_deposit": [], - "voting_end_time": "0001-01-01T00:00:00Z", - "voting_start_time": "0001-01-01T00:00:00Z" - }, - { - "content": { - "@type": "/cosmos.upgrade.v1beta1.CancelSoftwareUpgradeProposal", - "description": "bar_cancel_upgrade", - "title": "foo_cancel_upgrade" - }, - "deposit_end_time": "0001-01-01T00:00:00Z", - "final_tally_result": { - "abstain": "0", - "no": "0", - "no_with_veto": "0", - "yes": "0" - }, - "proposal_id": "0", - "status": "PROPOSAL_STATUS_UNSPECIFIED", - "submit_time": "0001-01-01T00:00:00Z", - "total_deposit": [], - "voting_end_time": "0001-01-01T00:00:00Z", - "voting_start_time": "0001-01-01T00:00:00Z" - }, - { - "content": { - "@type": "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", - "description": "bar_software_upgrade", - "plan": { - "height": "123", - "info": "foo_upgrade_info", - "name": "foo_upgrade_name", - "time": "0001-01-01T00:00:00Z", - "upgraded_client_state": null - }, - "title": "foo_software_upgrade" - }, - "deposit_end_time": "0001-01-01T00:00:00Z", - "final_tally_result": { - "abstain": "0", - "no": "0", - "no_with_veto": "0", - "yes": "0" - }, - "proposal_id": "0", - "status": "PROPOSAL_STATUS_UNSPECIFIED", - "submit_time": "0001-01-01T00:00:00Z", - "total_deposit": [], - "voting_end_time": "0001-01-01T00:00:00Z", - "voting_start_time": "0001-01-01T00:00:00Z" - }, - { - "content": { - "@type": "/cosmos.params.v1beta1.ParameterChangeProposal", - "changes": [ - { - "key": "foo_param_change_key", - "subspace": "foo_param_change_subspace", - "value": "foo_param_change_value" - } - ], - "description": "bar_param_change", - "title": "foo_param_change" - }, - "deposit_end_time": "0001-01-01T00:00:00Z", - "final_tally_result": { - "abstain": "0", - "no": "0", - "no_with_veto": "0", - "yes": "0" - }, - "proposal_id": "0", - "status": "PROPOSAL_STATUS_UNSPECIFIED", - "submit_time": "0001-01-01T00:00:00Z", - "total_deposit": [], - "voting_end_time": "0001-01-01T00:00:00Z", - "voting_start_time": "0001-01-01T00:00:00Z" - } - ], - "starting_proposal_id": "0", - "tally_params": { - "quorum": "0", - "threshold": "0", - "veto_threshold": "0" - }, - "votes": [], - "voting_params": { - "voting_period": "0s" - } -}` - - require.Equal(t, expected, string(indentedBz)) -} diff --git a/x/gov/migrations/v040/keys.go b/x/gov/migrations/v042/types.go similarity index 97% rename from x/gov/migrations/v040/keys.go rename to x/gov/migrations/v042/types.go index 5b8a6536cafa..417b2401fac6 100644 --- a/x/gov/migrations/v040/keys.go +++ b/x/gov/migrations/v042/types.go @@ -1,6 +1,7 @@ +package v042 + // Package v040 is copy-pasted from: // https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/x/gov/types/keys.go -package v040 import ( "encoding/binary" @@ -8,7 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" + v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" ) const ( @@ -153,7 +154,7 @@ func splitKeyWithTime(key []byte) (proposalID uint64, endTime time.Time) { } func splitKeyWithAddress(key []byte) (proposalID uint64, addr sdk.AccAddress) { - kv.AssertKeyLength(key[1:], 8+v040auth.AddrLen) + kv.AssertKeyLength(key[1:], 8+v042auth.AddrLen) kv.AssertKeyAtLeastLength(key, 10) proposalID = GetProposalIDFromBytes(key[1:9]) diff --git a/x/gov/migrations/v043/store_test.go b/x/gov/migrations/v043/store_test.go index 56d2ae2d815b..1ae662d818eb 100644 --- a/x/gov/migrations/v043/store_test.go +++ b/x/gov/migrations/v043/store_test.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - v040gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v040" + v042gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" v043gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v043" "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -40,32 +40,32 @@ func TestMigrateStore(t *testing.T) { }{ { "ProposalKey", - v040gov.ProposalKey(proposalID), dummyValue, + v042gov.ProposalKey(proposalID), dummyValue, types.ProposalKey(proposalID), dummyValue, }, { "ActiveProposalQueue", - v040gov.ActiveProposalQueueKey(proposalID, now), dummyValue, + v042gov.ActiveProposalQueueKey(proposalID, now), dummyValue, types.ActiveProposalQueueKey(proposalID, now), dummyValue, }, { "InactiveProposalQueue", - v040gov.InactiveProposalQueueKey(proposalID, now), dummyValue, + v042gov.InactiveProposalQueueKey(proposalID, now), dummyValue, types.InactiveProposalQueueKey(proposalID, now), dummyValue, }, { "ProposalIDKey", - v040gov.ProposalIDKey, dummyValue, + v042gov.ProposalIDKey, dummyValue, types.ProposalIDKey, dummyValue, }, { "DepositKey", - v040gov.DepositKey(proposalID, addr1), dummyValue, + v042gov.DepositKey(proposalID, addr1), dummyValue, types.DepositKey(proposalID, addr1), dummyValue, }, { "VotesKeyPrefix", - v040gov.VoteKey(proposalID, addr1), oldVoteValue, + v042gov.VoteKey(proposalID, addr1), oldVoteValue, types.VoteKey(proposalID, addr1), newVoteValue, }, } diff --git a/x/gov/migrations/v046/convert.go b/x/gov/migrations/v046/convert.go index edeb839acc17..a3f383006b5c 100644 --- a/x/gov/migrations/v046/convert.go +++ b/x/gov/migrations/v046/convert.go @@ -6,8 +6,8 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) // ConvertToLegacyProposal takes a new proposal and attempts to convert it to the diff --git a/x/gov/migrations/v046/convert_test.go b/x/gov/migrations/v046/convert_test.go new file mode 100644 index 000000000000..64375e796aef --- /dev/null +++ b/x/gov/migrations/v046/convert_test.go @@ -0,0 +1,174 @@ +package v046_test + +import ( + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx" + v046 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v046" + v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" + "github.com/stretchr/testify/require" +) + +func TestConvertToLegacyProposal(t *testing.T) { + propTime := time.Unix(1e9, 0) + legacyContentMsg, err := v1.NewLegacyContent(v1beta1.NewTextProposal("title", "description"), "cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh") + require.NoError(t, err) + msgs := []sdk.Msg{legacyContentMsg} + msgsAny, err := tx.SetMsgs(msgs) + require.NoError(t, err) + proposal := v1.Proposal{ + Id: 1, + Status: v1.StatusDepositPeriod, + Messages: msgsAny, + SubmitTime: &propTime, + DepositEndTime: &propTime, + VotingStartTime: &propTime, + VotingEndTime: &propTime, + Metadata: "proposal metadata", + } + + testCases := map[string]struct { + tallyResult v1.TallyResult + expErr bool + }{ + "valid": { + tallyResult: v1.EmptyTallyResult(), + }, + "invalid final tally result": { + tallyResult: v1.TallyResult{}, + expErr: true, + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + proposal.FinalTallyResult = &tc.tallyResult + v1beta1Proposal, err := v046.ConvertToLegacyProposal(proposal) + if tc.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, v1beta1Proposal.ProposalId, proposal.Id) + require.Equal(t, v1beta1Proposal.VotingStartTime, *proposal.VotingStartTime) + require.Equal(t, v1beta1Proposal.VotingEndTime, *proposal.VotingEndTime) + require.Equal(t, v1beta1Proposal.SubmitTime, *proposal.SubmitTime) + require.Equal(t, v1beta1Proposal.DepositEndTime, *proposal.DepositEndTime) + require.Equal(t, v1beta1Proposal.FinalTallyResult.Yes, sdk.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.No, sdk.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.NoWithVeto, sdk.NewInt(0)) + require.Equal(t, v1beta1Proposal.FinalTallyResult.Abstain, sdk.NewInt(0)) + } + }) + } +} + +func TestConvertToLegacyTallyResult(t *testing.T) { + tallyResult := v1.EmptyTallyResult() + testCases := map[string]struct { + tallyResult v1.TallyResult + expErr bool + }{ + "valid": { + tallyResult: tallyResult, + }, + "invalid yes count": { + tallyResult: v1.TallyResult{ + YesCount: "invalid", + NoCount: tallyResult.NoCount, + AbstainCount: tallyResult.AbstainCount, + NoWithVetoCount: tallyResult.NoWithVetoCount, + }, + expErr: true, + }, + "invalid no count": { + tallyResult: v1.TallyResult{ + YesCount: tallyResult.YesCount, + NoCount: "invalid", + AbstainCount: tallyResult.AbstainCount, + NoWithVetoCount: tallyResult.NoWithVetoCount, + }, + expErr: true, + }, + "invalid abstain count": { + tallyResult: v1.TallyResult{ + YesCount: tallyResult.YesCount, + NoCount: tallyResult.NoCount, + AbstainCount: "invalid", + NoWithVetoCount: tallyResult.NoWithVetoCount, + }, + expErr: true, + }, + "invalid no with veto count": { + tallyResult: v1.TallyResult{ + YesCount: tallyResult.YesCount, + NoCount: tallyResult.NoCount, + AbstainCount: tallyResult.AbstainCount, + NoWithVetoCount: "invalid", + }, + expErr: true, + }, + } + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + _, err := v046.ConvertToLegacyTallyResult(&tc.tallyResult) + if tc.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} + +func TestConvertToLegacyVote(t *testing.T) { + vote := v1.Vote{ + ProposalId: 1, + Voter: "cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh", + Metadata: "vote metadata", + } + + testCases := map[string]struct { + options []*v1.WeightedVoteOption + expErr bool + }{ + "valid": { + options: v1.NewNonSplitVoteOption(v1.OptionYes), + }, + "invalid options": { + options: []*v1.WeightedVoteOption{{Option: 1, Weight: "invalid"}}, + expErr: true, + }, + } + + for name, tc := range testCases { + t.Run(name, func(t *testing.T) { + vote.Options = tc.options + v1beta1Vote, err := v046.ConvertToLegacyVote(vote) + if tc.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + require.Equal(t, v1beta1Vote.ProposalId, vote.ProposalId) + require.Equal(t, v1beta1Vote.Voter, vote.Voter) + require.Equal(t, v1beta1Vote.Options[0].Option, v1beta1.OptionYes) + require.Equal(t, v1beta1Vote.Options[0].Weight, sdk.NewDec(1)) + } + }) + } +} + +func TestConvertToLegacyDeposit(t *testing.T) { + deposit := v1.Deposit{ + ProposalId: 1, + Depositor: "cosmos1fl48vsnmsdzcv85q5d2q4z5ajdha8yu34mf0eh", + Amount: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))), + } + + v1beta1Deposit := v046.ConvertToLegacyDeposit(&deposit) + require.Equal(t, v1beta1Deposit.ProposalId, deposit.ProposalId) + require.Equal(t, v1beta1Deposit.Depositor, deposit.Depositor) + require.Equal(t, v1beta1Deposit.Amount[0], deposit.Amount[0]) +} diff --git a/x/gov/migrations/v046/store.go b/x/gov/migrations/v046/store.go index 20f367fedeb0..c0ad36dfb4b7 100644 --- a/x/gov/migrations/v046/store.go +++ b/x/gov/migrations/v046/store.go @@ -5,14 +5,14 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - v040 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v040" + v042 "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) // migrateProposals migrates all legacy proposals into MsgExecLegacyContent // proposals. func migrateProposals(store sdk.KVStore, cdc codec.BinaryCodec) error { - propStore := prefix.NewStore(store, v040.ProposalsKeyPrefix) + propStore := prefix.NewStore(store, v042.ProposalsKeyPrefix) iter := propStore.Iterator(nil, nil) defer iter.Close() diff --git a/x/gov/migrations/v046/store_test.go b/x/gov/migrations/v046/store_test.go index 71f73b318f02..a9318f9390a9 100644 --- a/x/gov/migrations/v046/store_test.go +++ b/x/gov/migrations/v046/store_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" - v040gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v040" + v042gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v042" v046gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v046" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -36,20 +36,20 @@ func TestMigrateStore(t *testing.T) { prop2Bz, err := cdc.Marshal(&prop2) require.NoError(t, err) - store.Set(v040gov.ProposalKey(prop1.ProposalId), prop1Bz) - store.Set(v040gov.ProposalKey(prop2.ProposalId), prop2Bz) + store.Set(v042gov.ProposalKey(prop1.ProposalId), prop1Bz) + store.Set(v042gov.ProposalKey(prop2.ProposalId), prop2Bz) // Run migrations. err = v046gov.MigrateStore(ctx, govKey, cdc) require.NoError(t, err) var newProp1 v1.Proposal - err = cdc.Unmarshal(store.Get(v040gov.ProposalKey(prop1.ProposalId)), &newProp1) + err = cdc.Unmarshal(store.Get(v042gov.ProposalKey(prop1.ProposalId)), &newProp1) require.NoError(t, err) compareProps(t, prop1, newProp1) var newProp2 v1.Proposal - err = cdc.Unmarshal(store.Get(v040gov.ProposalKey(prop2.ProposalId)), &newProp2) + err = cdc.Unmarshal(store.Get(v042gov.ProposalKey(prop2.ProposalId)), &newProp2) require.NoError(t, err) compareProps(t, prop2, newProp2) } diff --git a/x/gov/module.go b/x/gov/module.go index 875c00437752..b93dab8f1f0a 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -8,7 +8,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -74,11 +73,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return v1.ValidateGenesis(&data) } -// RegisterRESTRoutes registers the REST routes for the gov module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/gov` legacy REST implementation -// has been removed from the SDK. -func (a AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the gov module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := v1.RegisterQueryHandlerClient(context.Background(), mux, v1.NewQueryClient(clientCtx)); err != nil { diff --git a/x/gov/simulation/decoder_test.go b/x/gov/simulation/decoder_test.go index 3f0d68a38263..7d9ac2e5bc90 100644 --- a/x/gov/simulation/decoder_test.go +++ b/x/gov/simulation/decoder_test.go @@ -27,7 +27,8 @@ func TestDecodeStore(t *testing.T) { dec := simulation.NewDecodeStore(cdc) endTime := time.Now().UTC() - content := v1beta1.ContentFromProposalType("test", "test", v1beta1.ProposalTypeText) + content, ok := v1beta1.ContentFromProposalType("test", "test", v1beta1.ProposalTypeText) + require.True(t, ok) proposalA, err := v1beta1.NewProposal(content, 1, endTime, endTime.Add(24*time.Hour)) require.NoError(t, err) proposalB, err := v1beta1.NewProposal(content, 2, endTime, endTime.Add(24*time.Hour)) diff --git a/x/gov/simulation/genesis_test.go b/x/gov/simulation/genesis_test.go index 35de56cd2751..281487751e38 100644 --- a/x/gov/simulation/genesis_test.go +++ b/x/gov/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,7 +33,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index e619dfabc96e..289c9413d6cd 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -39,7 +39,6 @@ func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, wContents []simtypes.WeightedProposalContent, ) simulation.WeightedOperations { - var ( weightMsgDeposit int weightMsgVote int @@ -161,7 +160,7 @@ func SimulateMsgSubmitProposal( spendable := bk.SpendableCoins(ctx, account.GetAddress()) var fees sdk.Coins - coins, hasNeg := spendable.SafeSub(deposit) + coins, hasNeg := spendable.SafeSub(deposit...) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coins) if err != nil { @@ -170,7 +169,7 @@ func SimulateMsgSubmitProposal( } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -248,7 +247,7 @@ func SimulateMsgDeposit(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Ke spendable := bk.SpendableCoins(ctx, account.GetAddress()) var fees sdk.Coins - coins, hasNeg := spendable.SafeSub(deposit) + coins, hasNeg := spendable.SafeSub(deposit...) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coins) if err != nil { @@ -278,7 +277,8 @@ func SimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keepe } func operationSimulateMsgVote(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, - simAccount simtypes.Account, proposalIDInt int64) simtypes.Operation { + simAccount simtypes.Account, proposalIDInt int64, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -331,7 +331,8 @@ func SimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeeper, k keep } func operationSimulateMsgVoteWeighted(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, - simAccount simtypes.Account, proposalIDInt int64) simtypes.Operation { + simAccount simtypes.Account, proposalIDInt int64, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, @@ -419,7 +420,8 @@ func randomDeposit(r *rand.Rand, ctx sdk.Context, // that matches a given Status. // It does not provide a default ID. func randomProposalID(r *rand.Rand, k keeper.Keeper, - ctx sdk.Context, status v1.ProposalStatus) (proposalID uint64, found bool) { + ctx sdk.Context, status v1.ProposalStatus, +) (proposalID uint64, found bool) { proposalID, _ = k.GetProposalID(ctx) switch { diff --git a/x/gov/simulation/operations_test.go b/x/gov/simulation/operations_test.go index 1d0ac256b49d..59c19d870707 100644 --- a/x/gov/simulation/operations_test.go +++ b/x/gov/simulation/operations_test.go @@ -10,7 +10,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" sdk "github.com/cosmos/cosmos-sdk/types" @@ -51,10 +50,8 @@ func mockWeightedProposalContent(n int) []simtypes.WeightedProposalContent { wpc := make([]simtypes.WeightedProposalContent, n) for i := 0; i < n; i++ { wpc[i] = MockWeightedProposalContent{i} - } return wpc - } // TestWeightedOperations tests the weights of the operations. @@ -117,7 +114,7 @@ func TestSimulateMsgSubmitProposal(t *testing.T) { require.NoError(t, err) var msg v1.MsgSubmitProposal - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = v1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.NoError(t, err) require.True(t, operationMsg.OK) @@ -164,7 +161,7 @@ func TestSimulateMsgDeposit(t *testing.T) { require.NoError(t, err) var msg v1.MsgDeposit - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = v1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.NoError(t, err) require.True(t, operationMsg.OK) @@ -210,7 +207,7 @@ func TestSimulateMsgVote(t *testing.T) { require.NoError(t, err) var msg v1.MsgVote - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + v1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(t, operationMsg.OK) require.Equal(t, uint64(1), msg.ProposalId) @@ -253,7 +250,7 @@ func TestSimulateMsgVoteWeighted(t *testing.T) { require.NoError(t, err) var msg v1.MsgVoteWeighted - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + v1.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(t, operationMsg.OK) require.Equal(t, uint64(1), msg.ProposalId) diff --git a/x/gov/spec/01_concepts.md b/x/gov/spec/01_concepts.md index 865eff89f663..7223e94a5343 100644 --- a/x/gov/spec/01_concepts.md +++ b/x/gov/spec/01_concepts.md @@ -140,12 +140,19 @@ casted on a proposal for the result to be valid. Threshold is defined as the minimum proportion of `Yes` votes (excluding `Abstain` votes) for the proposal to be accepted. -Initially, the threshold is set at 50% with a possibility to veto if more than -1/3rd of votes (excluding `Abstain` votes) are `NoWithVeto` votes. This means -that proposals are accepted if the proportion of `Yes` votes (excluding -`Abstain` votes) at the end of the voting period is superior to 50% and if the -proportion of `NoWithVeto` votes is inferior to 1/3 (excluding `Abstain` -votes). +Initially, the threshold is set at 50% of `Yes` votes, excluding `Abstain` +votes. A possibility to veto exists if more than 1/3rd of all votes are +`NoWithVeto` votes. Note, both of these values are derived from the `TallyParams` +on-chain parameter, which is modifiable by governance. +This means that proposals are accepted iff: + +* There exist bonded tokens. +* Quorum has been achieved. +* The proportion of `Abstain` votes is inferior to 1/1. +* The proportion of `NoWithVeto` votes is inferior to 1/3, including + `Abstain` votes. +* The proportion of `Yes` votes, excluding `Abstain` votes, at the end of + the voting period is superior to 1/2. ### Inheritance @@ -156,7 +163,7 @@ If a delegator does not vote, it will inherit its validator vote. * If the delegator votes after its validator, it will override its validator vote with its own. If the proposal is urgent, it is possible that the vote will close before delegators have a chance to react and - override their validator's vote. This is not a problem, as proposals require more than 2/3rd of the total voting power to pass before the end of the voting period. If more than 2/3rd of validators collude, they can censor the votes of delegators anyway. + override their validator's vote. This is not a problem, as proposals require more than 2/3rd of the total voting power to pass before the end of the voting period. Because as little as 1/3 + 1 validation power could collude to censor transactions, non-collusion is already assumed for ranges exceeding this threshold. ### Validator’s punishment for non-voting diff --git a/x/gov/spec/02_state.md b/x/gov/spec/02_state.md index 7c071531f2fd..f7032a368bc8 100644 --- a/x/gov/spec/02_state.md +++ b/x/gov/spec/02_state.md @@ -12,7 +12,7 @@ to resolve and then execute if the proposal passes. `Proposal`'s are identified unique id and contains a series of timestamps: `submit_time`, `deposit_end_time`, `voting_start_time`, `voting_end_time` which track the lifecycle of a proposal -+++ https://github.com/cosmos/cosmos-sdk/blob/4a129832eb16f37a89e97652a669f0cdc9196ca9/proto/cosmos/gov/v1beta2/gov.proto#L42-L52 ++++ https://github.com/cosmos/cosmos-sdk/blob/5bde3686c4538ce53356af6e9fe40b34e4ce4a06/proto/cosmos/gov/v1/gov.proto#L42-L59 A proposal will generally require more than just a set of messages to explain its purpose but need some greater justification and allow a means for interested participants diff --git a/x/gov/spec/03_messages.md b/x/gov/spec/03_messages.md index f1cb432028e3..7edc617f0f86 100644 --- a/x/gov/spec/03_messages.md +++ b/x/gov/spec/03_messages.md @@ -9,7 +9,7 @@ order: 3 Proposals can be submitted by any account via a `MsgSubmitProposal` transaction. -+++ https://github.com/cosmos/cosmos-sdk/blob/ab9545527d630fe38761aa61cc5c95eabd68e0e6/proto/cosmos/gov/v1beta2/tx.proto#L34-L44 ++++ https://github.com/cosmos/cosmos-sdk/blob/5bde3686c4538ce53356af6e9fe40b34e4ce4a06/proto/cosmos/gov/v1/tx.proto#L33-L43 All `sdk.Msgs` passed into the `messages` field of a `MsgSubmitProposal` message must be registered in the app's `MsgServiceRouter`. Each of these messages must diff --git a/x/gov/spec/07_client.md b/x/gov/spec/07_client.md index 900a6f690a64..0532ad907c09 100644 --- a/x/gov/spec/07_client.md +++ b/x/gov/spec/07_client.md @@ -392,10 +392,10 @@ Example: simd tx gov submit-legacy-proposal --title="Test Proposal" --description="testing" --type="Text" --deposit="100000000stake" --from cosmos1.. ``` -Example (`legacy-cancel-software-upgrade`): +Example (`cancel-software-upgrade`): ```bash -simd tx gov submit-legacy-proposal legacy-cancel-software-upgrade --title="Test Proposal" --description="testing" --deposit="100000000stake" --from cosmos1.. +simd tx gov submit-legacy-proposal cancel-software-upgrade --title="Test Proposal" --description="testing" --deposit="100000000stake" --from cosmos1.. ``` Example (`community-pool-spend`): @@ -435,10 +435,10 @@ simd tx gov submit-legacy-proposal param-change proposal.json --from cosmos1.. } ``` -Example (`legacy-software-upgrade`): +Example (`software-upgrade`): ```bash -simd tx gov submit-legacy-proposal legacy-software-upgrade v2 --title="Test Proposal" --description="testing, testing, 1, 2, 3" --upgrade-height 1000000 --from cosmos1.. +simd tx gov submit-legacy-proposal software-upgrade v2 --title="Test Proposal" --description="testing, testing, 1, 2, 3" --upgrade-height 1000000 --from cosmos1.. ``` #### vote diff --git a/x/gov/types/hooks.go b/x/gov/types/hooks.go index e90b19a08395..0a361687d9d2 100644 --- a/x/gov/types/hooks.go +++ b/x/gov/types/hooks.go @@ -30,11 +30,13 @@ func (h MultiGovHooks) AfterProposalVote(ctx sdk.Context, proposalID uint64, vot h[i].AfterProposalVote(ctx, proposalID, voterAddr) } } + func (h MultiGovHooks) AfterProposalFailedMinDeposit(ctx sdk.Context, proposalID uint64) { for i := range h { h[i].AfterProposalFailedMinDeposit(ctx, proposalID) } } + func (h MultiGovHooks) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint64) { for i := range h { h[i].AfterProposalVotingPeriodEnded(ctx, proposalID) diff --git a/x/gov/types/keys_test.go b/x/gov/types/keys_test.go index 30266f8f4d78..351863e9bfe4 100644 --- a/x/gov/types/keys_test.go +++ b/x/gov/types/keys_test.go @@ -37,7 +37,6 @@ func TestProposalKeys(t *testing.T) { } func TestDepositKeys(t *testing.T) { - key := DepositsKey(2) proposalID := SplitProposalKey(key) require.Equal(t, int(proposalID), 2) @@ -49,7 +48,6 @@ func TestDepositKeys(t *testing.T) { } func TestVoteKeys(t *testing.T) { - key := VotesKey(2) proposalID := SplitProposalKey(key) require.Equal(t, int(proposalID), 2) diff --git a/x/gov/types/v1/codec.go b/x/gov/types/v1/codec.go index 3f113e3b0095..327094960d7b 100644 --- a/x/gov/types/v1/codec.go +++ b/x/gov/types/v1/codec.go @@ -4,8 +4,11 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -30,6 +33,18 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + v1beta1.RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/gov/types/v1/genesis.go b/x/gov/types/v1/genesis.go index b05c582f59f0..0e661b4a2014 100644 --- a/x/gov/types/v1/genesis.go +++ b/x/gov/types/v1/genesis.go @@ -38,7 +38,7 @@ func (data GenesisState) Empty() bool { // ValidateGenesis checks if parameters are within valid ranges func ValidateGenesis(data *GenesisState) error { if data.StartingProposalId == 0 { - return errors.New("Starting proposal id must be greater than 0") + return errors.New("starting proposal id must be greater than 0") } if err := validateTallyParams(*data.TallyParams); err != nil { diff --git a/x/gov/types/v1/genesis_test.go b/x/gov/types/v1/genesis_test.go index e54c2ea5c628..16b90087833f 100644 --- a/x/gov/types/v1/genesis_test.go +++ b/x/gov/types/v1/genesis_test.go @@ -3,7 +3,7 @@ package v1_test import ( "testing" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/stretchr/testify/require" ) @@ -14,3 +14,72 @@ func TestEmptyGenesis(t *testing.T) { state2 := v1.DefaultGenesisState() require.False(t, state2.Empty()) } + +func TestValidateGenesis(t *testing.T) { + depositParams := v1.DefaultDepositParams() + votingParams := v1.DefaultVotingParams() + tallyParams := v1.DefaultTallyParams() + + testCases := []struct { + name string + genesisState *v1.GenesisState + expErr bool + }{ + { + name: "valid", + genesisState: v1.DefaultGenesisState(), + }, + { + name: "invalid StartingProposalId", + genesisState: &v1.GenesisState{ + StartingProposalId: 0, + DepositParams: &depositParams, + VotingParams: &votingParams, + TallyParams: &tallyParams, + }, + expErr: true, + }, + { + name: "invalid TallyParams", + genesisState: &v1.GenesisState{ + StartingProposalId: v1.DefaultStartingProposalID, + DepositParams: &depositParams, + VotingParams: &votingParams, + TallyParams: &v1.TallyParams{}, + }, + expErr: true, + }, + { + name: "invalid VotingParams", + genesisState: &v1.GenesisState{ + StartingProposalId: v1.DefaultStartingProposalID, + DepositParams: &depositParams, + VotingParams: &v1.VotingParams{}, + TallyParams: &tallyParams, + }, + expErr: true, + }, + { + name: "invalid DepositParams", + genesisState: &v1.GenesisState{ + StartingProposalId: v1.DefaultStartingProposalID, + DepositParams: &v1.DepositParams{}, + VotingParams: &votingParams, + TallyParams: &tallyParams, + }, + expErr: true, + }, + } + + for _, tc := range testCases { + tc := tc + t.Run(tc.name, func(t *testing.T) { + err := v1.ValidateGenesis(tc.genesisState) + if tc.expErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + }) + } +} diff --git a/x/gov/types/v1/msgs.go b/x/gov/types/v1/msgs.go index 6404d824ffba..1391cbf4c673 100644 --- a/x/gov/types/v1/msgs.go +++ b/x/gov/types/v1/msgs.go @@ -3,7 +3,6 @@ package v1 import ( "fmt" - "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -83,7 +82,7 @@ func (m MsgSubmitProposal) ValidateBasic() error { // GetSignBytes implements Msg func (m MsgSubmitProposal) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&m) + bz := ModuleCdc.MustMarshalJSON(&m) return sdk.MustSortJSON(bz) } @@ -128,7 +127,7 @@ func (msg MsgDeposit) ValidateBasic() error { // GetSignBytes implements Msg func (msg MsgDeposit) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -164,7 +163,7 @@ func (msg MsgVote) ValidateBasic() error { // GetSignBytes implements Msg func (msg MsgVote) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -225,7 +224,7 @@ func (msg MsgVoteWeighted) ValidateBasic() error { // GetSignBytes implements Msg func (msg MsgVoteWeighted) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } diff --git a/x/gov/types/v1/msgs_test.go b/x/gov/types/v1/msgs_test.go index 21d25bc20662..ad53ac5bf43e 100644 --- a/x/gov/types/v1/msgs_test.go +++ b/x/gov/types/v1/msgs_test.go @@ -6,8 +6,8 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) var ( diff --git a/x/gov/types/v1/proposal.go b/x/gov/types/v1/proposal.go index 514968bf85a4..63982fef0432 100644 --- a/x/gov/types/v1/proposal.go +++ b/x/gov/types/v1/proposal.go @@ -24,7 +24,6 @@ const ( // NewProposal creates a new Proposal instance func NewProposal(messages []sdk.Msg, id uint64, metadata string, submitTime, depositEndTime time.Time) (Proposal, error) { - msgs, err := sdktx.SetMsgs(messages) if err != nil { return Proposal{}, err diff --git a/x/gov/types/v1/proposals_test.go b/x/gov/types/v1/proposals_test.go index ab7ec4057db4..1f808bdefbaf 100644 --- a/x/gov/types/v1/proposals_test.go +++ b/x/gov/types/v1/proposals_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) func TestProposalStatus_Format(t *testing.T) { diff --git a/x/gov/types/v1/tally.go b/x/gov/types/v1/tally.go index cadb33f024e8..6613f640f6e5 100644 --- a/x/gov/types/v1/tally.go +++ b/x/gov/types/v1/tally.go @@ -15,8 +15,8 @@ type ValidatorGovInfo struct { // NewValidatorGovInfo creates a ValidatorGovInfo instance func NewValidatorGovInfo(address sdk.ValAddress, bondedTokens sdk.Int, delegatorShares, - delegatorDeductions sdk.Dec, options WeightedVoteOptions) ValidatorGovInfo { - + delegatorDeductions sdk.Dec, options WeightedVoteOptions, +) ValidatorGovInfo { return ValidatorGovInfo{ Address: address, BondedTokens: bondedTokens, diff --git a/x/gov/types/v1beta1/codec.go b/x/gov/types/v1beta1/codec.go index 583ab48963a8..f73f1082c5cd 100644 --- a/x/gov/types/v1beta1/codec.go +++ b/x/gov/types/v1beta1/codec.go @@ -4,8 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary types and interfaces for the @@ -35,6 +37,17 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/gov/types/v1beta1/msgs.go b/x/gov/types/v1beta1/msgs.go index 3fc309577b3c..9083ae9435cf 100644 --- a/x/gov/types/v1beta1/msgs.go +++ b/x/gov/types/v1beta1/msgs.go @@ -2,7 +2,6 @@ package v1beta1 import ( "fmt" - "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/gogo/protobuf/proto" "sigs.k8s.io/yaml" @@ -110,7 +109,7 @@ func (m MsgSubmitProposal) ValidateBasic() error { // GetSignBytes implements Msg func (m MsgSubmitProposal) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&m) + bz := ModuleCdc.MustMarshalJSON(&m) return sdk.MustSortJSON(bz) } @@ -167,7 +166,7 @@ func (msg MsgDeposit) String() string { // GetSignBytes implements Msg func (msg MsgDeposit) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -209,7 +208,7 @@ func (msg MsgVote) String() string { // GetSignBytes implements Msg func (msg MsgVote) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -272,7 +271,7 @@ func (msg MsgVoteWeighted) String() string { // GetSignBytes implements Msg func (msg MsgVoteWeighted) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } diff --git a/x/gov/types/v1beta1/msgs_test.go b/x/gov/types/v1beta1/msgs_test.go index 3d571a6559fc..bf6e78528c42 100644 --- a/x/gov/types/v1beta1/msgs_test.go +++ b/x/gov/types/v1beta1/msgs_test.go @@ -43,8 +43,11 @@ func TestMsgSubmitProposal(t *testing.T) { } for i, tc := range tests { + content, ok := ContentFromProposalType(tc.title, tc.description, tc.proposalType) + require.True(t, ok) + msg, err := NewMsgSubmitProposal( - ContentFromProposalType(tc.title, tc.description, tc.proposalType), + content, tc.initialDeposit, tc.proposerAddr, ) diff --git a/x/gov/types/v1beta1/proposal.go b/x/gov/types/v1beta1/proposal.go index bf735b276b29..6946a40216c4 100644 --- a/x/gov/types/v1beta1/proposal.go +++ b/x/gov/types/v1beta1/proposal.go @@ -246,14 +246,12 @@ func RegisterProposalType(ty string) { } // ContentFromProposalType returns a Content object based on the proposal type. -func ContentFromProposalType(title, desc, ty string) Content { - switch ty { - case ProposalTypeText: - return NewTextProposal(title, desc) - - default: - return nil +func ContentFromProposalType(title, desc, ty string) (Content, bool) { + if strings.EqualFold(ty, ProposalTypeText) { + return NewTextProposal(title, desc), true } + + return nil, false } // IsValidProposalType returns a boolean determining if the proposal type is diff --git a/x/gov/types/v1beta1/proposals_test.go b/x/gov/types/v1beta1/proposals_test.go index fd328b3ca471..2a29fda28753 100644 --- a/x/gov/types/v1beta1/proposals_test.go +++ b/x/gov/types/v1beta1/proposals_test.go @@ -1,16 +1,17 @@ -package v1beta1 +package v1beta1_test import ( "fmt" "testing" + "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/stretchr/testify/require" ) func TestProposalStatus_Format(t *testing.T) { - statusDepositPeriod, _ := ProposalStatusFromString("PROPOSAL_STATUS_DEPOSIT_PERIOD") + statusDepositPeriod, _ := v1beta1.ProposalStatusFromString("PROPOSAL_STATUS_DEPOSIT_PERIOD") tests := []struct { - pt ProposalStatus + pt v1beta1.ProposalStatus sprintFArgs string expectedStringOutput string }{ @@ -22,3 +23,36 @@ func TestProposalStatus_Format(t *testing.T) { require.Equal(t, tt.expectedStringOutput, got) } } + +func TestContentFromProposalType(t *testing.T) { + tests := []struct { + proposalType string + expectedType string + }{ + { + proposalType: "TextProposal", + expectedType: "", + }, + { + proposalType: "text", + expectedType: v1beta1.ProposalTypeText, + }, + { + proposalType: "Text", + expectedType: v1beta1.ProposalTypeText, + }, + } + + for _, test := range tests { + content, ok := v1beta1.ContentFromProposalType("title", "foo", test.proposalType) + if test.expectedType == "" { + require.False(t, ok) + continue + } + + require.True(t, ok) + require.NotNil(t, content) + require.Equal(t, test.expectedType, content.ProposalType()) + } + +} diff --git a/x/gov/types/v1beta1/tally.go b/x/gov/types/v1beta1/tally.go index c0f09a88ba0b..616ca6b7bb7c 100644 --- a/x/gov/types/v1beta1/tally.go +++ b/x/gov/types/v1beta1/tally.go @@ -17,8 +17,8 @@ type ValidatorGovInfo struct { // NewValidatorGovInfo creates a ValidatorGovInfo instance func NewValidatorGovInfo(address sdk.ValAddress, bondedTokens sdk.Int, delegatorShares, - delegatorDeductions sdk.Dec, options WeightedVoteOptions) ValidatorGovInfo { - + delegatorDeductions sdk.Dec, options WeightedVoteOptions, +) ValidatorGovInfo { return ValidatorGovInfo{ Address: address, BondedTokens: bondedTokens, diff --git a/x/group/client/cli/tx.go b/x/group/client/cli/tx.go index ff92542e90e6..5550241e755a 100644 --- a/x/group/client/cli/tx.go +++ b/x/group/client/cli/tx.go @@ -98,7 +98,7 @@ Where members.json contains: return err } - members, err := parseMembers(clientCtx, args[2]) + members, err := parseMembers(args[2]) if err != nil { return err } @@ -166,7 +166,7 @@ Set a member's weight to "0" to delete it. return err } - members, err := parseMembers(clientCtx, args[2]) + members, err := parseMembers(args[2]) if err != nil { return err } @@ -290,7 +290,8 @@ If group-policy-as-admin flag is set to true, the admin of the newly created gro Example: $ %s tx group create-group-with-policy [admin] [group-metadata] [group-policy-metadata] [members-json-file] \ -'{"@type":"/cosmos.group.v1.ThresholdDecisionPolicy", "threshold":"1", "timeout":"1s"}' +'{"@type":"/cosmos.group.v1.ThresholdDecisionPolicy", "threshold":"1", \ +"windows": {"voting_period": "120h", "min_execution_period": "0s"}}' where members.json contains: @@ -329,7 +330,7 @@ where members.json contains: return err } - members, err := parseMembers(clientCtx, args[3]) + members, err := parseMembers(args[3]) if err != nil { return err } @@ -378,10 +379,11 @@ Note, the '--from' flag is ignored as it is implied from [admin]. Example: $ %s tx group create-group-policy [admin] [group-id] [metadata] \ -'{"@type":"/cosmos.group.v1.ThresholdDecisionPolicy", "threshold":"1", "timeout":"1s"}' +'{"@type":"/cosmos.group.v1.ThresholdDecisionPolicy", "threshold":"1", \ +"windows": {"voting_period": "120h", "min_execution_period": "0s"}}' Here, we can use percentage decision policy when needed, where 0 < percentage <= 1. -Ex: '{"@type":"/cosmos.group.v1.PercentageDecisionPolicy", "percentage":"0.5", "timeout":"1s"}' +Ex: '{"@type":"/cosmos.group.v1.PercentageDecisionPolicy", "percentage":"0.5", "windows": {"voting_period": "120h", "min_execution_period": "0s"}} `, version.AppName, ), @@ -492,7 +494,7 @@ func MsgUpdateGroupPolicyDecisionPolicyCmd() *cobra.Command { return err } - msg, err := group.NewMsgUpdateGroupPolicyDecisionPolicyRequest( + msg, err := group.NewMsgUpdateGroupPolicyDecisionPolicy( clientCtx.GetFromAddress(), accountAddress, policy, @@ -560,7 +562,7 @@ Parameters: msg_tx_json_file: path to json file with messages that will be executed if the proposal is accepted. Example: - $ %s tx gov submit-proposal path/to/proposal.json + $ %s tx group submit-proposal path/to/proposal.json Where proposal.json contains: @@ -601,7 +603,7 @@ Example: execStr, _ := cmd.Flags().GetString(FlagExec) - msg, err := group.NewMsgSubmitProposalRequest( + msg, err := group.NewMsgSubmitProposal( prop.GroupPolicyAddress, prop.Proposers, msgs, diff --git a/x/group/client/cli/util.go b/x/group/client/cli/util.go index e7ac27998524..23a8aebcab75 100644 --- a/x/group/client/cli/util.go +++ b/x/group/client/cli/util.go @@ -5,14 +5,13 @@ import ( "io/ioutil" "os" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/group" ) -func parseMembers(clientCtx client.Context, membersFile string) ([]group.Member, error) { - members := group.Members{} +func parseMembers(membersFile string) ([]group.MemberRequest, error) { + members := group.MemberRequests{} if membersFile == "" { return members.Members, nil @@ -23,7 +22,7 @@ func parseMembers(clientCtx client.Context, membersFile string) ([]group.Member, return nil, err } - err = clientCtx.Codec.UnmarshalJSON(contents, &members) + err = json.Unmarshal(contents, &members) if err != nil { return nil, err } diff --git a/x/group/client/testutil/query.go b/x/group/client/testutil/query.go index 43ef6c585074..74c152b50978 100644 --- a/x/group/client/testutil/query.go +++ b/x/group/client/testutil/query.go @@ -327,7 +327,11 @@ func (s *IntegrationTestSuite) TestQueryGroupPolicyInfo() { s.Require().Equal(s.groupPolicies[0].Admin, g.Admin) s.Require().Equal(s.groupPolicies[0].Metadata, g.Metadata) s.Require().Equal(s.groupPolicies[0].Version, g.Version) - s.Require().Equal(s.groupPolicies[0].GetDecisionPolicy(), g.GetDecisionPolicy()) + dp1, err := s.groupPolicies[0].GetDecisionPolicy() + s.Require().NoError(err) + dp2, err := g.GetDecisionPolicy() + s.Require().NoError(err) + s.Require().Equal(dp1, dp2) } }) } @@ -398,7 +402,11 @@ func (s *IntegrationTestSuite) TestQueryGroupPoliciesByGroup() { s.Require().Equal(res.GroupPolicies[i].Metadata, tc.expectGroupPolicies[i].Metadata) s.Require().Equal(res.GroupPolicies[i].Version, tc.expectGroupPolicies[i].Version) s.Require().Equal(res.GroupPolicies[i].Admin, tc.expectGroupPolicies[i].Admin) - s.Require().Equal(res.GroupPolicies[i].GetDecisionPolicy(), tc.expectGroupPolicies[i].GetDecisionPolicy()) + dp1, err := s.groupPolicies[i].GetDecisionPolicy() + s.Require().NoError(err) + dp2, err := tc.expectGroupPolicies[i].GetDecisionPolicy() + s.Require().NoError(err) + s.Require().Equal(dp1, dp2) } } }) @@ -470,7 +478,11 @@ func (s *IntegrationTestSuite) TestQueryGroupPoliciesByAdmin() { s.Require().Equal(res.GroupPolicies[i].Metadata, tc.expectGroupPolicies[i].Metadata) s.Require().Equal(res.GroupPolicies[i].Version, tc.expectGroupPolicies[i].Version) s.Require().Equal(res.GroupPolicies[i].Admin, tc.expectGroupPolicies[i].Admin) - s.Require().Equal(res.GroupPolicies[i].GetDecisionPolicy(), tc.expectGroupPolicies[i].GetDecisionPolicy()) + dp1, err := s.groupPolicies[i].GetDecisionPolicy() + s.Require().NoError(err) + dp2, err := tc.expectGroupPolicies[i].GetDecisionPolicy() + s.Require().NoError(err) + s.Require().Equal(dp1, dp2) } } }) @@ -758,7 +770,7 @@ func (s *IntegrationTestSuite) TestTallyResult() { member := s.voter - var commonFlags = []string{ + commonFlags := []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), @@ -781,7 +793,7 @@ func (s *IntegrationTestSuite) TestTallyResult() { var txResp sdk.TxResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(uint32(0), txResp.Code, out.String()) - proposalId := s.getProposalIdFromTxResponse(txResp) + proposalID := s.getProposalIDFromTxResponse(txResp) testCases := []struct { name string @@ -816,7 +828,7 @@ func (s *IntegrationTestSuite) TestTallyResult() { { "valid proposal id with no votes", []string{ - proposalId, + proposalID, fmt.Sprintf("--%s=json", tmcli.OutputFlag), }, false, @@ -860,5 +872,4 @@ func (s *IntegrationTestSuite) TestTallyResult() { } }) } - } diff --git a/x/group/client/testutil/tx.go b/x/group/client/testutil/tx.go index 6fb7725ed81b..1458dc4fd338 100644 --- a/x/group/client/testutil/tx.go +++ b/x/group/client/testutil/tx.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/gogo/protobuf/proto" + "github.com/google/uuid" "github.com/stretchr/testify/suite" tmcli "github.com/tendermint/tendermint/libs/cli" @@ -35,6 +36,7 @@ type IntegrationTestSuite struct { proposal *group.Proposal vote *group.Vote voter *group.Member + commonFlags []string } const validMetadata = "metadata" @@ -48,6 +50,12 @@ func NewIntegrationTestSuite(cfg network.Config) *IntegrationTestSuite { func (s *IntegrationTestSuite) SetupSuite() { s.T().Log("setting up integration test suite") + s.commonFlags = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + var err error s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg) s.Require().NoError(err) @@ -75,12 +83,6 @@ func (s *IntegrationTestSuite) SetupSuite() { ) s.Require().NoError(err) - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } - memberWeight := "3" // create a group validMembers := fmt.Sprintf(` @@ -101,12 +103,12 @@ func (s *IntegrationTestSuite) SetupSuite() { validMetadata, validMembersFile.Name(), }, - commonFlags..., + s.commonFlags..., ), ) s.Require().NoError(err, out.String()) - var txResp = sdk.TxResponse{} + txResp := sdk.TxResponse{} s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(uint32(0), txResp.Code, out.String()) @@ -118,20 +120,8 @@ func (s *IntegrationTestSuite) SetupSuite() { if threshold > 3 { threshold = 3 } - out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgCreateGroupPolicyCmd(), - append( - []string{ - val.Address.String(), - "1", - validMetadata, - fmt.Sprintf("{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"%d\", \"windows\":{\"voting_period\":\"30000s\"}}", threshold), - }, - commonFlags..., - ), - ) - s.Require().NoError(err, out.String()) - s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) - s.Require().Equal(uint32(0), txResp.Code, out.String()) + + s.createGroupThresholdPolicyWithBalance(val.Address.String(), "1", threshold, 1000) out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{"1", fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) s.Require().NoError(err, out.String()) @@ -146,7 +136,7 @@ func (s *IntegrationTestSuite) SetupSuite() { validMetadata, fmt.Sprintf("{\"@type\":\"/cosmos.group.v1.PercentageDecisionPolicy\", \"percentage\":\"%f\", \"windows\":{\"voting_period\":\"30000s\"}}", percentage), }, - commonFlags..., + s.commonFlags..., ), ) s.Require().NoError(err, out.String()) @@ -170,7 +160,7 @@ func (s *IntegrationTestSuite) SetupSuite() { s.groupPolicies[0].Address, val.Address.String(), ""), }, - commonFlags..., + s.commonFlags..., ), ) s.Require().NoError(err, out.String()) @@ -186,7 +176,7 @@ func (s *IntegrationTestSuite) SetupSuite() { "VOTE_OPTION_YES", "", }, - commonFlags..., + s.commonFlags..., ), ) s.Require().NoError(err, out.String()) @@ -223,11 +213,6 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { val := s.network.Validators[0] clientCtx := val.ClientCtx - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } validMembers := fmt.Sprintf(`{"members": [{ "address": "%s", @@ -271,7 +256,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { "", validMembersFile.Name(), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -287,7 +272,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { validMembersFile.Name(), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -302,7 +287,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { strings.Repeat("a", 256), "", }, - commonFlags..., + s.commonFlags..., ), true, "group metadata: limit exceeded", @@ -317,7 +302,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { "null", invalidMembersAddressFile.Name(), }, - commonFlags..., + s.commonFlags..., ), true, "message validation failed: address: empty address string is not allowed", @@ -332,7 +317,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { "null", invalidMembersWeightFile.Name(), }, - commonFlags..., + s.commonFlags..., ), true, "expected a positive decimal, got 0: invalid decimal string", @@ -347,7 +332,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroup() { "null", invalidMembersMetadataFile.Name(), }, - commonFlags..., + s.commonFlags..., ), true, "member metadata: limit exceeded", @@ -381,11 +366,6 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { clientCtx := val.ClientCtx require := s.Require() - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } groupIDs := make([]string, 2) for i := 0; i < 2; i++ { @@ -402,14 +382,14 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { validMetadata, validMembersFile.Name(), }, - commonFlags..., + s.commonFlags..., ), ) require.NoError(err, out.String()) var txResp sdk.TxResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(uint32(0), txResp.Code, out.String()) - groupIDs[i] = s.getGroupIdFromTxResponse(txResp) + groupIDs[i] = s.getGroupIDFromTxResponse(txResp) } testCases := []struct { @@ -428,7 +408,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { groupIDs[0], s.network.Validators[1].Address.String(), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -444,7 +424,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { s.network.Validators[1].Address.String(), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -459,7 +439,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { "", s.network.Validators[1].Address.String(), }, - commonFlags..., + s.commonFlags..., ), true, "strconv.ParseUint: parsing \"\": invalid syntax", @@ -474,7 +454,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupAdmin() { "12345", s.network.Validators[1].Address.String(), }, - commonFlags..., + s.commonFlags..., ), true, "not found", @@ -507,11 +487,6 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { val := s.network.Validators[0] clientCtx := val.ClientCtx - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } testCases := []struct { name string @@ -526,10 +501,10 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { append( []string{ val.Address.String(), - "2", + "1", validMetadata, }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -541,11 +516,11 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { append( []string{ val.Address.String(), - "2", + "1", validMetadata, fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -560,7 +535,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMetadata() { strconv.FormatUint(s.group.Id, 10), strings.Repeat("a", 256), }, - commonFlags..., + s.commonFlags..., ), true, "group metadata: limit exceeded", @@ -593,11 +568,12 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { val := s.network.Validators[0] clientCtx := val.ClientCtx - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } + + weights := []string{"1", "1", "1"} + accounts := s.createAccounts(3) + + groupID := s.createGroupWithMembers(weights, accounts) + groupPolicyAddress := s.createGroupThresholdPolicyWithBalance(accounts[0], groupID, 3, 100) validUpdatedMembersFileName := testutil.WriteToNewTempFile(s.T(), fmt.Sprintf(`{"members": [{ "address": "%s", @@ -607,13 +583,13 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { "address": "%s", "weight": "1", "metadata": "%s" - }]}`, val.Address.String(), validMetadata, s.groupPolicies[0].Address, validMetadata)).Name() + }]}`, accounts[0], validMetadata, groupPolicyAddress, validMetadata)).Name() invalidMembersMetadata := fmt.Sprintf(`{"members": [{ "address": "%s", "weight": "1", "metadata": "%s" - }]}`, val.Address.String(), tooLongMetadata) + }]}`, accounts[0], tooLongMetadata) invalidMembersMetadataFileName := testutil.WriteToNewTempFile(s.T(), invalidMembersMetadata).Name() testCases := []struct { @@ -628,11 +604,11 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { "correct data", append( []string{ - val.Address.String(), - "2", + accounts[0], + groupID, validUpdatedMembersFileName, }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -643,8 +619,8 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { "with amino-json", append( []string{ - val.Address.String(), - "2", + accounts[0], + groupID, testutil.WriteToNewTempFile(s.T(), fmt.Sprintf(`{"members": [{ "address": "%s", "weight": "2", @@ -652,7 +628,7 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { }]}`, s.groupPolicies[0].Address, validMetadata)).Name(), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -663,11 +639,11 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { "group member metadata too long", append( []string{ - val.Address.String(), - strconv.FormatUint(s.group.Id, 10), + accounts[0], + groupID, invalidMembersMetadataFileName, }, - commonFlags..., + s.commonFlags..., ), true, "group member metadata: limit exceeded", @@ -678,11 +654,11 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupMembers() { "group doesn't exist", append( []string{ - val.Address.String(), + accounts[0], "12345", validUpdatedMembersFileName, }, - commonFlags..., + s.commonFlags..., ), true, "not found", @@ -715,11 +691,8 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { val := s.network.Validators[0] clientCtx := val.ClientCtx - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } + + validMembers := fmt.Sprintf(`{"members": [{ "address": "%s", @@ -766,7 +739,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", fmt.Sprintf("--%s=%v", client.FlagGroupPolicyAsAdmin, false), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -784,7 +757,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", fmt.Sprintf("--%s=%v", client.FlagGroupPolicyAsAdmin, true), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -803,7 +776,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { fmt.Sprintf("--%s=%v", client.FlagGroupPolicyAsAdmin, false), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -821,7 +794,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", fmt.Sprintf("--%s=%v", client.FlagGroupPolicyAsAdmin, false), }, - commonFlags..., + s.commonFlags..., ), true, "group metadata: limit exceeded", @@ -839,7 +812,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", fmt.Sprintf("--%s=%v", client.FlagGroupPolicyAsAdmin, false), }, - commonFlags..., + s.commonFlags..., ), true, "group policy metadata: limit exceeded", @@ -857,7 +830,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", fmt.Sprintf("--%s=%v", client.FlagGroupPolicyAsAdmin, false), }, - commonFlags..., + s.commonFlags..., ), true, "message validation failed: address: empty address string is not allowed", @@ -875,7 +848,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", fmt.Sprintf("--%s=%v", client.FlagGroupPolicyAsAdmin, false), }, - commonFlags..., + s.commonFlags..., ), true, "expected a positive decimal, got 0: invalid decimal string", @@ -893,7 +866,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupWithPolicy() { "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", fmt.Sprintf("--%s=%v", client.FlagGroupPolicyAsAdmin, false), }, - commonFlags..., + s.commonFlags..., ), true, "member metadata: limit exceeded", @@ -926,11 +899,6 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { wrongAdmin := s.network.Validators[1].Address clientCtx := val.ClientCtx - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } groupID := s.group.Id @@ -951,7 +919,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { validMetadata, "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -967,7 +935,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { validMetadata, "{\"@type\":\"/cosmos.group.v1.PercentageDecisionPolicy\", \"percentage\":\"0.5\", \"windows\":{\"voting_period\":\"1s\"}}", }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -984,7 +952,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1000,7 +968,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { validMetadata, "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", }, - commonFlags..., + s.commonFlags..., ), true, "key not found", @@ -1016,7 +984,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { strings.Repeat("a", 500), "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", }, - commonFlags..., + s.commonFlags..., ), true, "group policy metadata: limit exceeded", @@ -1032,7 +1000,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { validMetadata, "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"1\", \"windows\":{\"voting_period\":\"1s\"}}", }, - commonFlags..., + s.commonFlags..., ), true, "not found", @@ -1048,7 +1016,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { validMetadata, "{\"@type\":\"/cosmos.group.v1.PercentageDecisionPolicy\", \"percentage\":\"-0.5\", \"windows\":{\"voting_period\":\"1s\"}}", }, - commonFlags..., + s.commonFlags..., ), true, "expected a positive decimal", @@ -1064,7 +1032,7 @@ func (s *IntegrationTestSuite) TestTxCreateGroupPolicy() { validMetadata, "{\"@type\":\"/cosmos.group.v1.PercentageDecisionPolicy\", \"percentage\":\"2\", \"windows\":{\"voting_period\":\"1s\"}}", }, - commonFlags..., + s.commonFlags..., ), true, "percentage must be > 0 and <= 1", @@ -1099,11 +1067,9 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupPolicyAdmin() { clientCtx := val.ClientCtx groupPolicy := s.groupPolicies[3] - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } + + commonFlags := s.commonFlags + commonFlags = append(commonFlags, fmt.Sprintf("--%s=%d", flags.FlagGas, 300000)) testCases := []struct { name string @@ -1202,11 +1168,9 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupPolicyDecisionPolicy() { clientCtx := val.ClientCtx groupPolicy := s.groupPolicies[2] - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } + + commonFlags := s.commonFlags + commonFlags = append(commonFlags, fmt.Sprintf("--%s=%d", flags.FlagGas, 300000)) testCases := []struct { name string @@ -1350,11 +1314,9 @@ func (s *IntegrationTestSuite) TestTxUpdateGroupPolicyMetadata() { clientCtx := val.ClientCtx groupPolicy := s.groupPolicies[2] - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } + + commonFlags := s.commonFlags + commonFlags = append(commonFlags, fmt.Sprintf("--%s=%d", flags.FlagGas, 300000)) testCases := []struct { name string @@ -1466,11 +1428,6 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { val := s.network.Validators[0] clientCtx := val.ClientCtx - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } testCases := []struct { name string @@ -1490,7 +1447,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { "", ), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1508,7 +1465,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { ), fmt.Sprintf("--%s=try", client.FlagExec), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1525,7 +1482,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { ""), fmt.Sprintf("--%s=try", client.FlagExec), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1543,7 +1500,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { ), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1560,7 +1517,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { tooLongMetadata, ), }, - commonFlags..., + s.commonFlags..., ), true, "metadata: limit exceeded", @@ -1576,10 +1533,10 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { val.Address.String(), s.groupPolicies[0].Address, ""), }, - commonFlags..., + s.commonFlags..., ), true, - "msg does not have group policy authorization: unauthorized", + "msg does not have group policy authorization", nil, 0, }, @@ -1593,7 +1550,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { "", ), }, - commonFlags..., + s.commonFlags..., ), true, "invalid.info: key not found", @@ -1610,7 +1567,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { "", ), }, - commonFlags..., + s.commonFlags..., ), true, "group policy: decoding bech32 failed", @@ -1627,7 +1584,7 @@ func (s *IntegrationTestSuite) TestTxSubmitProposal() { "", ), }, - commonFlags..., + s.commonFlags..., ), true, "group policy: not found", @@ -1660,24 +1617,25 @@ func (s *IntegrationTestSuite) TestTxVote() { val := s.network.Validators[0] clientCtx := val.ClientCtx - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } ids := make([]string, 4) + weights := []string{"1", "1", "1"} + accounts := s.createAccounts(3) + + groupID := s.createGroupWithMembers(weights, accounts) + groupPolicyAddress := s.createGroupThresholdPolicyWithBalance(accounts[0], groupID, 3, 100) for i := 0; i < 4; i++ { out, err := cli.ExecTestCLICmd(val.ClientCtx, client.MsgSubmitProposalCmd(), append( []string{ s.createCLIProposal( - s.groupPolicies[1].Address, val.Address.String(), - s.groupPolicies[1].Address, val.Address.String(), - ""), + groupPolicyAddress, accounts[0], + groupPolicyAddress, accounts[0], + "", + ), }, - commonFlags..., + s.commonFlags..., ), ) s.Require().NoError(err, out.String()) @@ -1685,7 +1643,7 @@ func (s *IntegrationTestSuite) TestTxVote() { var txResp sdk.TxResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(uint32(0), txResp.Code, out.String()) - ids[i] = s.getProposalIdFromTxResponse(txResp) + ids[i] = s.getProposalIDFromTxResponse(txResp) } testCases := []struct { @@ -1701,11 +1659,11 @@ func (s *IntegrationTestSuite) TestTxVote() { append( []string{ ids[0], - val.Address.String(), + accounts[0], "VOTE_OPTION_YES", "", }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1717,12 +1675,12 @@ func (s *IntegrationTestSuite) TestTxVote() { append( []string{ ids[1], - val.Address.String(), + accounts[0], "VOTE_OPTION_YES", "", fmt.Sprintf("--%s=try", client.FlagExec), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1734,12 +1692,12 @@ func (s *IntegrationTestSuite) TestTxVote() { append( []string{ ids[2], - val.Address.String(), + accounts[0], "VOTE_OPTION_NO", "", fmt.Sprintf("--%s=try", client.FlagExec), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1751,12 +1709,12 @@ func (s *IntegrationTestSuite) TestTxVote() { append( []string{ ids[3], - val.Address.String(), + accounts[0], "VOTE_OPTION_YES", "", fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1768,11 +1726,11 @@ func (s *IntegrationTestSuite) TestTxVote() { append( []string{ "abcd", - val.Address.String(), + accounts[0], "VOTE_OPTION_YES", "", }, - commonFlags..., + s.commonFlags..., ), true, "invalid syntax", @@ -1784,11 +1742,11 @@ func (s *IntegrationTestSuite) TestTxVote() { append( []string{ "1234", - val.Address.String(), + accounts[0], "VOTE_OPTION_YES", "", }, - commonFlags..., + s.commonFlags..., ), true, "proposal: not found", @@ -1800,11 +1758,11 @@ func (s *IntegrationTestSuite) TestTxVote() { append( []string{ "2", - val.Address.String(), + accounts[0], "VOTE_OPTION_YES", tooLongMetadata, }, - commonFlags..., + s.commonFlags..., ), true, "metadata: limit exceeded", @@ -1816,11 +1774,11 @@ func (s *IntegrationTestSuite) TestTxVote() { append( []string{ "2", - val.Address.String(), + accounts[0], "INVALID_VOTE_OPTION", "", }, - commonFlags..., + s.commonFlags..., ), true, "not a valid vote option", @@ -1853,11 +1811,6 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { val := s.network.Validators[0] clientCtx := val.ClientCtx - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } ids := make([]string, 2) @@ -1870,7 +1823,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { s.groupPolicies[1].Address, val.Address.String(), ""), }, - commonFlags..., + s.commonFlags..., ), ) s.Require().NoError(err, out.String()) @@ -1878,7 +1831,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { var txResp sdk.TxResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) s.Require().Equal(uint32(0), txResp.Code, out.String()) - ids[i] = s.getProposalIdFromTxResponse(txResp) + ids[i] = s.getProposalIDFromTxResponse(txResp) } testCases := []struct { @@ -1896,7 +1849,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { ids[0], val.Address.String(), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -1910,7 +1863,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { ids[0], val.Address.String(), }, - commonFlags..., + s.commonFlags..., ), true, "cannot withdraw a proposal with the status of PROPOSAL_STATUS_WITHDRAWN", @@ -1924,7 +1877,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { "222", "wrongAdmin", }, - commonFlags..., + s.commonFlags..., ), true, "not found", @@ -1938,7 +1891,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { "abc", val.Address.String(), }, - commonFlags..., + s.commonFlags..., ), true, "invalid syntax", @@ -1952,7 +1905,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { ids[1], "wrongAdmin", }, - commonFlags..., + s.commonFlags..., ), true, "key not found", @@ -1981,7 +1934,7 @@ func (s *IntegrationTestSuite) TestTxWithdrawProposal() { } } -func (s *IntegrationTestSuite) getProposalIdFromTxResponse(txResp sdk.TxResponse) string { +func (s *IntegrationTestSuite) getProposalIDFromTxResponse(txResp sdk.TxResponse) string { s.Require().Greater(len(txResp.Logs), 0) s.Require().NotNil(txResp.Logs[0].Events) events := txResp.Logs[0].Events @@ -2001,11 +1954,6 @@ func (s *IntegrationTestSuite) TestTxExec() { clientCtx := val.ClientCtx require := s.Require() - var commonFlags = []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } var proposalIDs []string // create proposals and vote @@ -2019,7 +1967,7 @@ func (s *IntegrationTestSuite) TestTxExec() { "", ), }, - commonFlags..., + s.commonFlags..., ), ) require.NoError(err, out.String()) @@ -2027,7 +1975,7 @@ func (s *IntegrationTestSuite) TestTxExec() { var txResp sdk.TxResponse require.NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) require.Equal(uint32(0), txResp.Code, out.String()) - proposalID := s.getProposalIdFromTxResponse(txResp) + proposalID := s.getProposalIDFromTxResponse(txResp) proposalIDs = append(proposalIDs, proposalID) out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgVoteCmd(), @@ -2038,7 +1986,7 @@ func (s *IntegrationTestSuite) TestTxExec() { "VOTE_OPTION_YES", "", }, - commonFlags..., + s.commonFlags..., ), ) require.NoError(err, out.String()) @@ -2059,7 +2007,7 @@ func (s *IntegrationTestSuite) TestTxExec() { proposalIDs[0], fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -2074,7 +2022,7 @@ func (s *IntegrationTestSuite) TestTxExec() { fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=%s", flags.FlagSignMode, flags.SignModeLegacyAminoJSON), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -2088,7 +2036,7 @@ func (s *IntegrationTestSuite) TestTxExec() { "abcd", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), }, - commonFlags..., + s.commonFlags..., ), true, "invalid syntax", @@ -2102,7 +2050,7 @@ func (s *IntegrationTestSuite) TestTxExec() { "1234", fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), }, - commonFlags..., + s.commonFlags..., ), true, "proposal: not found", @@ -2136,31 +2084,8 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { clientCtx := val.ClientCtx require := s.Require() - commonFlags := []string{ - fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), - fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), - } - // create 3 accounts with some tokens - members := make([]string, 3) - for i := 1; i <= 3; i++ { - info, _, err := clientCtx.Keyring.NewMnemonic(fmt.Sprintf("member%d", i), keyring.English, sdk.FullFundraiserPath, - keyring.DefaultBIP39Passphrase, hd.Secp256k1) - require.NoError(err) - - pk, err := info.GetPubKey() - require.NoError(err) - - account := sdk.AccAddress(pk.Address()) - members[i-1] = account.String() - - _, err = banktestutil.MsgSendExec(clientCtx, val.Address, account, - sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))), - commonFlags..., - ) - require.NoError(err) - } + members := s.createAccounts(3) // create a group with three members validMembers := fmt.Sprintf(`{"members": [{ @@ -2184,13 +2109,13 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { validMetadata, validMembersFile.Name(), }, - commonFlags..., + s.commonFlags..., ), ) require.NoError(err, out.String()) var txResp sdk.TxResponse s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) - groupID := s.getGroupIdFromTxResponse(txResp) + groupID := s.getGroupIDFromTxResponse(txResp) // create group policy out, err = cli.ExecTestCLICmd(clientCtx, client.MsgCreateGroupPolicyCmd(), @@ -2201,7 +2126,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { "AQ==", "{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"3\", \"windows\":{\"voting_period\":\"1s\"}}", }, - commonFlags..., + s.commonFlags..., ), ) require.NoError(err, out.String()) @@ -2227,7 +2152,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { groupID, fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), }, - commonFlags..., + s.commonFlags..., ), true, "key not found", @@ -2240,7 +2165,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { "40", fmt.Sprintf("--%s=%s", flags.FlagFrom, members[0]), }, - commonFlags..., + s.commonFlags..., ), true, "group: not found", @@ -2253,7 +2178,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { groupID, fmt.Sprintf("--%s=%s", flags.FlagFrom, members[2]), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -2266,7 +2191,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { groupID, fmt.Sprintf("--%s=%s", flags.FlagFrom, members[2]), }, - commonFlags..., + s.commonFlags..., ), true, "is not part of group", @@ -2279,7 +2204,7 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { groupID, fmt.Sprintf("--%s=%s", flags.FlagFrom, members[1]), }, - commonFlags..., + s.commonFlags..., ), false, "", @@ -2303,7 +2228,213 @@ func (s *IntegrationTestSuite) TestTxLeaveGroup() { } } -func (s *IntegrationTestSuite) getGroupIdFromTxResponse(txResp sdk.TxResponse) string { +func (s *IntegrationTestSuite) TestExecProposalsWhenMemberLeavesOrIsUpdated() { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + weights := []string{"1", "1", "2"} + accounts := s.createAccounts(3) + testCases := []struct { + name string + votes []string + members []string + malleate func(groupID string) error + expectLogErr bool + errMsg string + respType proto.Message + }{ + { + "member leaves while all others vote yes", + []string{"VOTE_OPTION_YES", "VOTE_OPTION_YES", "VOTE_OPTION_YES"}, + accounts, + func(groupID string) error { + leavingMemberIdx := 1 + args := append( + []string{ + accounts[leavingMemberIdx], + groupID, + + fmt.Sprintf("--%s=%s", flags.FlagFrom, accounts[leavingMemberIdx]), + }, + s.commonFlags..., + ) + out, err := cli.ExecTestCLICmd(clientCtx, client.MsgLeaveGroupCmd(), args) + s.Require().NoError(err, out.String()) + var resp sdk.TxResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().Equal(uint32(0), resp.Code, out.String()) + + return err + }, + false, + "", + &sdk.TxResponse{}, + }, + { + "member leaves while all others vote yes and no", + []string{"VOTE_OPTION_NO", "VOTE_OPTION_YES", "VOTE_OPTION_YES"}, + accounts, + func(groupID string) error { + leavingMemberIdx := 1 + args := append( + []string{ + accounts[leavingMemberIdx], + groupID, + + fmt.Sprintf("--%s=%s", flags.FlagFrom, accounts[leavingMemberIdx]), + }, + s.commonFlags..., + ) + out, err := cli.ExecTestCLICmd(clientCtx, client.MsgLeaveGroupCmd(), args) + s.Require().NoError(err, out.String()) + var resp sdk.TxResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().Equal(uint32(0), resp.Code, out.String()) + + return err + }, + true, + "PROPOSAL_EXECUTOR_RESULT_NOT_RUN", + &sdk.TxResponse{}, + }, + { + "member that leaves does affect the threshold policy outcome", + []string{"VOTE_OPTION_YES", "VOTE_OPTION_YES"}, + accounts, + func(groupID string) error { + leavingMemberIdx := 2 + args := append( + []string{ + accounts[leavingMemberIdx], + groupID, + + fmt.Sprintf("--%s=%s", flags.FlagFrom, accounts[leavingMemberIdx]), + }, + s.commonFlags..., + ) + out, err := cli.ExecTestCLICmd(clientCtx, client.MsgLeaveGroupCmd(), args) + s.Require().NoError(err, out.String()) + var resp sdk.TxResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().Equal(uint32(0), resp.Code, out.String()) + + return err + }, + false, + "", + &sdk.TxResponse{}, + }, + { + "update group policy voids the proposal", + []string{"VOTE_OPTION_YES", "VOTE_OPTION_NO"}, + accounts, + func(groupID string) error { + updateGroup := s.newValidMembers(weights[0:1], accounts[0:1]) + + updateGroupByte, err := json.Marshal(updateGroup) + s.Require().NoError(err) + + validUpdateMemberFileName := testutil.WriteToNewTempFile(s.T(), string(updateGroupByte)).Name() + + args := append( + []string{ + accounts[0], + groupID, + validUpdateMemberFileName, + }, + s.commonFlags..., + ) + out, err := cli.ExecTestCLICmd(clientCtx, client.MsgUpdateGroupMembersCmd(), args) + s.Require().NoError(err, out.String()) + var resp sdk.TxResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &resp), out.String()) + s.Require().Equal(uint32(0), resp.Code, out.String()) + + return err + }, + true, + "PROPOSAL_EXECUTOR_RESULT_NOT_RUN", + &sdk.TxResponse{}, + }, + } + + for _, tc := range testCases { + tc := tc + + s.Run(tc.name, func() { + cmdSubmitProposal := client.MsgSubmitProposalCmd() + cmdMsgExec := client.MsgExecCmd() + + groupID := s.createGroupWithMembers(weights, accounts) + groupPolicyAddress := s.createGroupThresholdPolicyWithBalance(accounts[0], groupID, 3, 100) + + // Submit proposal + proposal := s.createCLIProposal( + groupPolicyAddress, tc.members[0], + groupPolicyAddress, tc.members[0], + "", + ) + submitProposalArgs := append([]string{ + proposal, + }, + s.commonFlags..., + ) + var submitProposalResp sdk.TxResponse + out, err := cli.ExecTestCLICmd(clientCtx, cmdSubmitProposal, submitProposalArgs) + s.Require().NoError(err, out.String()) + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &submitProposalResp), out.String()) + proposalID := s.getProposalIDFromTxResponse(submitProposalResp) + + for i, vote := range tc.votes { + memberAddress := tc.members[i] + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.MsgVoteCmd(), + append( + []string{ + proposalID, + memberAddress, + vote, + "", + }, + s.commonFlags..., + ), + ) + + var txResp sdk.TxResponse + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + } + + err = tc.malleate(groupID) + s.Require().NoError(err) + + err = s.network.WaitForNextBlock() + s.Require().NoError(err) + + args := append( + []string{ + proposalID, + fmt.Sprintf("--%s=%s", flags.FlagFrom, tc.members[0]), + }, + s.commonFlags..., + ) + out, err = cli.ExecTestCLICmd(clientCtx, cmdMsgExec, args) + s.Require().NoError(err) + + var execResp sdk.TxResponse + s.Require().NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &execResp), out.String()) + + if tc.expectLogErr { + s.Require().Contains(execResp.RawLog, tc.errMsg) + } + + }) + } + +} + +func (s *IntegrationTestSuite) getGroupIDFromTxResponse(txResp sdk.TxResponse) string { s.Require().Greater(len(txResp.Logs), 0) s.Require().NotNil(txResp.Logs[0].Events) events := txResp.Logs[0].Events @@ -2327,7 +2458,7 @@ func (s *IntegrationTestSuite) createCLIProposal(groupPolicyAddress, proposer, s msg := banktypes.MsgSend{ FromAddress: sendFrom, ToAddress: sendTo, - Amount: sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))), + Amount: sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(20))), } msgJSON, err := s.cfg.Codec.MarshalInterfaceJSON(&msg) s.Require().NoError(err) @@ -2344,3 +2475,135 @@ func (s *IntegrationTestSuite) createCLIProposal(groupPolicyAddress, proposer, s return testutil.WriteToNewTempFile(s.T(), string(bz)).Name() } + +func (s *IntegrationTestSuite) createAccounts(quantity int) []string { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + accounts := make([]string, quantity) + + for i := 1; i <= quantity; i++ { + memberNumber := uuid.New().String() + + info, _, err := clientCtx.Keyring.NewMnemonic(fmt.Sprintf("member%s", memberNumber), keyring.English, sdk.FullFundraiserPath, + keyring.DefaultBIP39Passphrase, hd.Secp256k1) + s.Require().NoError(err) + + pk, err := info.GetPubKey() + s.Require().NoError(err) + + account := sdk.AccAddress(pk.Address()) + accounts[i-1] = account.String() + + _, err = banktestutil.MsgSendExec( + val.ClientCtx, + val.Address, + account, + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(2000))), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + ) + s.Require().NoError(err) + s.Require().NoError(err) + } + return accounts +} + +func (s *IntegrationTestSuite) createGroupWithMembers(membersWeight, membersAddress []string) string { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + s.Require().Equal(len(membersWeight), len(membersAddress)) + + membersValid := s.newValidMembers(membersWeight, membersAddress) + membersByte, err := json.Marshal(membersValid) + + s.Require().NoError(err) + + validMembersFile := testutil.WriteToNewTempFile(s.T(), string(membersByte)) + out, err := cli.ExecTestCLICmd(clientCtx, client.MsgCreateGroupCmd(), + append( + []string{ + membersAddress[0], + validMetadata, + validMembersFile.Name(), + }, + s.commonFlags..., + ), + ) + s.Require().NoError(err, out.String()) + var txResp sdk.TxResponse + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + return s.getGroupIDFromTxResponse(txResp) +} + +func (s *IntegrationTestSuite) createGroupThresholdPolicyWithBalance(adminAddress, groupID string, threshold int, tokens int64) string { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + out, err := cli.ExecTestCLICmd(clientCtx, client.MsgCreateGroupPolicyCmd(), + append( + []string{ + adminAddress, + groupID, + validMetadata, + fmt.Sprintf("{\"@type\":\"/cosmos.group.v1.ThresholdDecisionPolicy\", \"threshold\":\"%d\", \"windows\":{\"voting_period\":\"30000s\"}}", threshold), + }, + s.commonFlags..., + ), + ) + var txResp = sdk.TxResponse{} + s.Require().NoError(err, out.String()) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txResp), out.String()) + s.Require().Equal(uint32(0), txResp.Code, out.String()) + + out, err = cli.ExecTestCLICmd(val.ClientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{groupID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + + var res group.QueryGroupPoliciesByGroupResponse + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + groupPolicyAddress := res.GroupPolicies[0].Address + + addr, err := sdk.AccAddressFromBech32(groupPolicyAddress) + s.Require().NoError(err) + _, err = banktestutil.MsgSendExec(clientCtx, val.Address, addr, + sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(tokens))), + s.commonFlags..., + ) + s.Require().NoError(err) + return groupPolicyAddress +} + +// fundAllGroupPolicies sends tokens to all group policies of a given group ID. +func (s *IntegrationTestSuite) fundAllGroupPolicies(groupID string, tokens sdk.Coin) { + val := s.network.Validators[0] + clientCtx := val.ClientCtx + + out, err := cli.ExecTestCLICmd(val.ClientCtx, client.QueryGroupPoliciesByGroupCmd(), []string{groupID, fmt.Sprintf("--%s=json", tmcli.OutputFlag)}) + s.Require().NoError(err, out.String()) + var res group.QueryGroupPoliciesByGroupResponse + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + + for _, policy := range res.GroupPolicies { + address := policy.Address + addr, err := sdk.AccAddressFromBech32(address) + s.Require().NoError(err) + _, err = banktestutil.MsgSendExec(clientCtx, val.Address, addr, + sdk.NewCoins(tokens), + s.commonFlags..., + ) + s.Require().NoError(err) + } +} + +func (s *IntegrationTestSuite) newValidMembers(weights, membersAddress []string) group.MemberRequests { + s.Require().Equal(len(weights), len(membersAddress)) + membersValid := group.MemberRequests{} + for i, address := range membersAddress { + membersValid.Members = append(membersValid.Members, group.MemberRequest{ + Address: address, + Weight: weights[i], + Metadata: validMetadata, + }) + } + return membersValid +} diff --git a/x/group/codec.go b/x/group/codec.go index 8e89e4ea0b30..32e1ec15c7cb 100644 --- a/x/group/codec.go +++ b/x/group/codec.go @@ -4,8 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers all the necessary group module concrete @@ -60,6 +62,17 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { ) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/group/events.pb.go b/x/group/events.pb.go index 0d13f3470779..3cbcb2d491d6 100644 --- a/x/group/events.pb.go +++ b/x/group/events.pb.go @@ -351,6 +351,8 @@ type EventExec struct { ProposalId uint64 `protobuf:"varint,1,opt,name=proposal_id,json=proposalId,proto3" json:"proposal_id,omitempty"` // result is the proposal execution result. Result ProposalExecutorResult `protobuf:"varint,2,opt,name=result,proto3,enum=cosmos.group.v1.ProposalExecutorResult" json:"result,omitempty"` + // logs contains error logs in case the execution result is FAILURE. + Logs string `protobuf:"bytes,3,opt,name=logs,proto3" json:"logs,omitempty"` } func (m *EventExec) Reset() { *m = EventExec{} } @@ -400,6 +402,13 @@ func (m *EventExec) GetResult() ProposalExecutorResult { return PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED } +func (m *EventExec) GetLogs() string { + if m != nil { + return m.Logs + } + return "" +} + // EventLeaveGroup is an event emitted when group member leaves the group. type EventLeaveGroup struct { // group_id is the unique ID of the group. @@ -470,7 +479,7 @@ func init() { func init() { proto.RegisterFile("cosmos/group/v1/events.proto", fileDescriptor_e8d753981546f032) } var fileDescriptor_e8d753981546f032 = []byte{ - // 366 bytes of a gzipped FileDescriptorProto + // 382 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0x2f, 0xce, 0xcd, 0x2f, 0xd6, 0x4f, 0x2f, 0xca, 0x2f, 0x2d, 0xd0, 0x2f, 0x33, 0xd4, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x87, 0xc8, 0xea, 0x81, 0x65, 0xf5, @@ -485,15 +494,16 @@ var fileDescriptor_e8d753981546f032 = []byte{ 0x94, 0x9b, 0x59, 0x12, 0x50, 0x94, 0x5f, 0x90, 0x5f, 0x9c, 0x98, 0x23, 0x24, 0xcf, 0xc5, 0x5d, 0x00, 0x65, 0x23, 0x3c, 0xc4, 0x05, 0x13, 0xf2, 0x4c, 0x51, 0xb2, 0xe0, 0x12, 0x05, 0xeb, 0x0b, 0xcf, 0x2c, 0xc9, 0x48, 0x29, 0x4a, 0x2c, 0x27, 0x5e, 0xa7, 0x0e, 0x17, 0x27, 0x58, 0x67, 0x58, - 0x7e, 0x49, 0x2a, 0x61, 0xd5, 0xb9, 0x50, 0xd5, 0xae, 0x15, 0xa9, 0xc9, 0x04, 0x55, 0x0b, 0xd9, - 0x73, 0xb1, 0x15, 0xa5, 0x16, 0x97, 0xe6, 0x94, 0x48, 0x30, 0x29, 0x30, 0x6a, 0xf0, 0x19, 0xa9, - 0xeb, 0xa1, 0xa5, 0x10, 0x3d, 0x98, 0x3b, 0x41, 0xe6, 0x95, 0x96, 0xe4, 0x17, 0x05, 0x81, 0x95, - 0x07, 0x41, 0xb5, 0x29, 0x25, 0x70, 0xf1, 0x83, 0xad, 0xf3, 0x49, 0x4d, 0x2c, 0x23, 0x18, 0xb1, - 0xc8, 0x01, 0xce, 0x44, 0x64, 0x80, 0x3b, 0xd9, 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, - 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, - 0x1c, 0x43, 0x94, 0x4a, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0x2e, 0x34, 0xe9, - 0x42, 0x29, 0xdd, 0xe2, 0x94, 0x6c, 0xfd, 0x0a, 0x48, 0xca, 0x4d, 0x62, 0x03, 0xa7, 0x58, 0x63, - 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xe6, 0x94, 0x89, 0xaf, 0x1a, 0x03, 0x00, 0x00, + 0x7e, 0x49, 0x2a, 0x61, 0xd5, 0x8d, 0x8c, 0x50, 0xe5, 0xae, 0x15, 0xa9, 0xc9, 0x04, 0x95, 0x0b, + 0xd9, 0x73, 0xb1, 0x15, 0xa5, 0x16, 0x97, 0xe6, 0x94, 0x48, 0x30, 0x29, 0x30, 0x6a, 0xf0, 0x19, + 0xa9, 0xeb, 0xa1, 0x25, 0x11, 0x3d, 0x98, 0x43, 0x41, 0xe6, 0x95, 0x96, 0xe4, 0x17, 0x05, 0x81, + 0x95, 0x07, 0x41, 0xb5, 0x09, 0x09, 0x71, 0xb1, 0xe4, 0xe4, 0xa7, 0x17, 0x4b, 0x30, 0x83, 0x02, + 0x30, 0x08, 0xcc, 0x56, 0x4a, 0xe0, 0xe2, 0x07, 0x3b, 0xc1, 0x27, 0x35, 0xb1, 0x8c, 0x60, 0x6c, + 0x23, 0xc7, 0x02, 0x13, 0x91, 0xb1, 0xe0, 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, 0xd0, 0xf4, + 0x0c, 0xa5, 0x74, 0x8b, 0x53, 0xb2, 0xf5, 0x2b, 0x20, 0xc9, 0x39, 0x89, 0x0d, 0x9c, 0x8c, 0x8d, + 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xc0, 0x98, 0xf8, 0x2f, 0x03, 0x00, 0x00, } func (m *EventCreateGroup) Marshal() (dAtA []byte, err error) { @@ -716,6 +726,13 @@ func (m *EventExec) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Logs) > 0 { + i -= len(m.Logs) + copy(dAtA[i:], m.Logs) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Logs))) + i-- + dAtA[i] = 0x1a + } if m.Result != 0 { i = encodeVarintEvents(dAtA, i, uint64(m.Result)) i-- @@ -873,6 +890,10 @@ func (m *EventExec) Size() (n int) { if m.Result != 0 { n += 1 + sovEvents(uint64(m.Result)) } + l = len(m.Logs) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } return n } @@ -1474,6 +1495,38 @@ func (m *EventExec) Unmarshal(dAtA []byte) error { break } } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Logs", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Logs = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipEvents(dAtA[iNdEx:]) diff --git a/x/group/genesis_test.go b/x/group/genesis_test.go index 99f7a008fa37..cf43ed699d41 100644 --- a/x/group/genesis_test.go +++ b/x/group/genesis_test.go @@ -18,7 +18,6 @@ var ( ) func TestGenesisStateValidate(t *testing.T) { - submittedAt := time.Now().UTC() timeout := submittedAt.Add(time.Second * 1).UTC() @@ -737,7 +736,6 @@ func TestGenesisStateValidate(t *testing.T) { for _, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - err := tc.genesisState.Validate() if tc.expErr { require.Error(t, err) diff --git a/x/group/internal/math/dec_test.go b/x/group/internal/math/dec_test.go index 73807f767104..6bf0edb5afe0 100644 --- a/x/group/internal/math/dec_test.go +++ b/x/group/internal/math/dec_test.go @@ -75,6 +75,9 @@ func TestDec(t *testing.T) { require.NoError(t, err) require.True(t, res.IsEqual(minusFivePointZero)) + _, err = four.Quo(zero) + require.Error(t, err) + res, err = four.Quo(two) require.NoError(t, err) require.True(t, res.IsEqual(two)) diff --git a/x/group/internal/orm/genesis.go b/x/group/internal/orm/genesis.go index 93460dcee80f..60a4c3ec78df 100644 --- a/x/group/internal/orm/genesis.go +++ b/x/group/internal/orm/genesis.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// TableExportable +// TableExportable defines the methods to import and export a table. type TableExportable interface { // Export stores all the values in the table in the passed // ModelSlicePtr. If the table has an associated sequence, then its diff --git a/x/group/internal/orm/index.go b/x/group/internal/orm/index.go index aff63c6e248d..f19de60d3e40 100644 --- a/x/group/internal/orm/index.go +++ b/x/group/internal/orm/index.go @@ -132,18 +132,11 @@ func (i MultiKeyIndex) GetPaginated(store sdk.KVStore, searchKey interface{}, pa // // CONTRACT: No writes may happen within a domain while an iterator exists over it. func (i MultiKeyIndex) PrefixScan(store sdk.KVStore, startI interface{}, endI interface{}) (Iterator, error) { - start, err := getPrefixScanKeyBytes(startI) - if err != nil { - return nil, err - } - end, err := getPrefixScanKeyBytes(endI) + start, end, err := getStartEndBz(startI, endI) if err != nil { return nil, err } - if start != nil && end != nil && bytes.Compare(start, end) >= 0 { - return NewInvalidIterator(), sdkerrors.Wrap(errors.ErrORMInvalidArgument, "start must be less than end") - } pStore := prefix.NewStore(store, []byte{i.prefix}) it := pStore.Iterator(start, end) return indexIterator{store: store, it: it, rowGetter: i.rowGetter, indexKey: i.indexKey}, nil @@ -159,21 +152,33 @@ func (i MultiKeyIndex) PrefixScan(store sdk.KVStore, startI interface{}, endI in // // CONTRACT: No writes may happen within a domain while an iterator exists over it. func (i MultiKeyIndex) ReversePrefixScan(store sdk.KVStore, startI interface{}, endI interface{}) (Iterator, error) { - start, err := getPrefixScanKeyBytes(startI) + start, end, err := getStartEndBz(startI, endI) if err != nil { return nil, err } + + pStore := prefix.NewStore(store, []byte{i.prefix}) + it := pStore.ReverseIterator(start, end) + return indexIterator{store: store, it: it, rowGetter: i.rowGetter, indexKey: i.indexKey}, nil +} + +// getStartEndBz gets the start and end bytes to be passed into the SDK store +// iterator. +func getStartEndBz(startI interface{}, endI interface{}) ([]byte, []byte, error) { + start, err := getPrefixScanKeyBytes(startI) + if err != nil { + return nil, nil, err + } end, err := getPrefixScanKeyBytes(endI) if err != nil { - return nil, err + return nil, nil, err } if start != nil && end != nil && bytes.Compare(start, end) >= 0 { - return NewInvalidIterator(), sdkerrors.Wrap(errors.ErrORMInvalidArgument, "start must be less than end") + return nil, nil, sdkerrors.Wrap(errors.ErrORMInvalidArgument, "start must be less than end") } - pStore := prefix.NewStore(store, []byte{i.prefix}) - it := pStore.ReverseIterator(start, end) - return indexIterator{store: store, it: it, rowGetter: i.rowGetter, indexKey: i.indexKey}, nil + + return start, end, nil } func getPrefixScanKeyBytes(keyI interface{}) ([]byte, error) { diff --git a/x/group/internal/orm/indexer_test.go b/x/group/internal/orm/indexer_test.go index d574fb63fd04..79278418c924 100644 --- a/x/group/internal/orm/indexer_test.go +++ b/x/group/internal/orm/indexer_test.go @@ -239,6 +239,7 @@ func TestIndexerOnDelete(t *testing.T) { }) } } + func TestIndexerOnUpdate(t *testing.T) { myRowID := EncodeSequence(1) @@ -377,7 +378,6 @@ func TestUniqueKeyAddFunc(t *testing.T) { expErr *sdkerrors.Error expExistingEntry []byte }{ - "create when not exists": { srcKey: []byte("my-index-key"), expExistingEntry: append(AddLengthPrefix([]byte("my-index-key")), myRowID...), @@ -421,7 +421,6 @@ func TestMultiKeyAddFunc(t *testing.T) { expErr *sdkerrors.Error expExistingEntry []byte }{ - "create when not exists": { srcKey: []byte("my-index-key"), expExistingEntry: append(AddLengthPrefix([]byte("my-index-key")), myRowID...), diff --git a/x/group/internal/orm/iterator.go b/x/group/internal/orm/iterator.go index ae61d61c48e4..71c3b32272ae 100644 --- a/x/group/internal/orm/iterator.go +++ b/x/group/internal/orm/iterator.go @@ -155,7 +155,7 @@ func Paginate( return nil, err } - var end = offset + limit + end := offset + limit var count uint64 var nextKey []byte for { diff --git a/x/group/internal/orm/iterator_test.go b/x/group/internal/orm/iterator_test.go index b2abbaaa403c..bbafa34a11f7 100644 --- a/x/group/internal/orm/iterator_test.go +++ b/x/group/internal/orm/iterator_test.go @@ -317,7 +317,6 @@ func TestPaginate(t *testing.T) { assert.EqualValues(t, spec.expPageRes.Total, res.Total) assert.EqualValues(t, spec.expPageRes.NextKey, res.NextKey) } - }) } diff --git a/x/group/internal/orm/primary_key.go b/x/group/internal/orm/primary_key.go index 46abfd0dbe63..7655c5a9d535 100644 --- a/x/group/internal/orm/primary_key.go +++ b/x/group/internal/orm/primary_key.go @@ -33,9 +33,9 @@ type PrimaryKeyed interface { // the primary key. The PrimaryKey function will encode and concatenate // the fields to build the primary key. // - // PrimaryKey parts can be []byte, string, and integer types. []byte is + // PrimaryKey parts can be []byte, string, and uint64 types. []byte is // encoded with a length prefix, strings are null-terminated, and - // integers are encoded using 8 byte big endian. + // uint64 are encoded using 8 byte big endian. // // IMPORTANT: []byte parts are encoded with a single byte length prefix, // so cannot be longer than 255 bytes. diff --git a/x/group/internal/orm/primary_key_test.go b/x/group/internal/orm/primary_key_test.go index 498e973c0c98..66adb3240d1c 100644 --- a/x/group/internal/orm/primary_key_test.go +++ b/x/group/internal/orm/primary_key_test.go @@ -223,7 +223,6 @@ func TestContains(t *testing.T) { src PrimaryKeyed exp bool }{ - "same object": {src: &obj, exp: true}, "clone": { src: &testdata.TableModel{ diff --git a/x/group/internal/orm/sequence_property_test.go b/x/group/internal/orm/sequence_property_test.go index c0e7dce2ebf4..2d3d9c10a2fd 100644 --- a/x/group/internal/orm/sequence_property_test.go +++ b/x/group/internal/orm/sequence_property_test.go @@ -56,7 +56,7 @@ func (m *sequenceMachine) NextVal(t *rapid.T) { // CurVal is one of the model commands. It checks that the current value of the // sequence matches the model. func (m *sequenceMachine) CurVal(t *rapid.T) { - // Check the the current value matches the model + // Check the current value matches the model require.Equal(t, m.state, m.seq.CurVal(m.store)) } diff --git a/x/group/internal/orm/spec/01_table.md b/x/group/internal/orm/spec/01_table.md index 7e7237f9d054..4c456b1f59cc 100644 --- a/x/group/internal/orm/spec/01_table.md +++ b/x/group/internal/orm/spec/01_table.md @@ -9,10 +9,11 @@ Regular CRUD operations can be performed on a table, these methods take a `sdk.K The `table` struct does not: -* enforce uniqueness of the `RowID` -* enforce prefix uniqueness of keys, i.e. not allowing one key to be a prefix - of another -* optimize Gas usage conditions +- enforce uniqueness of the `RowID` +- enforce prefix uniqueness of keys, i.e. not allowing one key to be a prefix + of another +- optimize Gas usage conditions + The `table` struct is private, so that we only have custom tables built on top of it, that do satisfy these requirements. `table` provides methods for exporting (using a [`PrefixScan` `Iterator`](03_iterator_pagination.md#iterator)) and importing genesis data. For the import to be successful, objects have to be aware of their primary key by implementing the [`PrimaryKeyed`](#primarykeyed) interface. @@ -42,6 +43,6 @@ The primary key parts can be []byte, string, and `uint64` types. Key parts, except the last part, follow these rules: -* []byte is encoded with a single byte length prefix -* strings are null-terminated -* `uint64` are encoded using 8 byte big endian. +- []byte is encoded with a single byte length prefix (which means the max []byte length is 255) +- strings are null-terminated +- `uint64` are encoded using 8 byte big endian. diff --git a/x/group/internal/orm/table.go b/x/group/internal/orm/table.go index 89e6a8db1a0d..a25615a965a4 100644 --- a/x/group/internal/orm/table.go +++ b/x/group/internal/orm/table.go @@ -149,7 +149,7 @@ func assertValid(obj codec.ProtoMarshaler) error { func (a table) Delete(store sdk.KVStore, rowID RowID) error { pStore := prefix.NewStore(store, a.prefix[:]) - var oldValue = reflect.New(a.model).Interface().(codec.ProtoMarshaler) + oldValue := reflect.New(a.model).Interface().(codec.ProtoMarshaler) if err := a.GetOne(store, rowID, oldValue); err != nil { return sdkerrors.Wrap(err, "load old value") } diff --git a/x/group/internal/orm/table_test.go b/x/group/internal/orm/table_test.go index 44146c7fea8f..164fecda3648 100644 --- a/x/group/internal/orm/table_test.go +++ b/x/group/internal/orm/table_test.go @@ -97,7 +97,7 @@ func TestCreate(t *testing.T) { ctx := NewMockContext() store := ctx.KVStore(sdk.NewKVStoreKey("test")) - var anyPrefix = [2]byte{0x10} + anyPrefix := [2]byte{0x10} myTable, err := newTable(anyPrefix, &testdata.TableModel{}, cdc) require.NoError(t, err) @@ -154,7 +154,7 @@ func TestUpdate(t *testing.T) { ctx := NewMockContext() store := ctx.KVStore(sdk.NewKVStoreKey("test")) - var anyPrefix = [2]byte{0x10} + anyPrefix := [2]byte{0x10} myTable, err := newTable(anyPrefix, &testdata.TableModel{}, cdc) require.NoError(t, err) @@ -203,7 +203,7 @@ func TestDelete(t *testing.T) { ctx := NewMockContext() store := ctx.KVStore(sdk.NewKVStoreKey("test")) - var anyPrefix = [2]byte{0x10} + anyPrefix := [2]byte{0x10} myTable, err := newTable(anyPrefix, &testdata.TableModel{}, cdc) require.NoError(t, err) diff --git a/x/group/internal/orm/types_test.go b/x/group/internal/orm/types_test.go index 9ef2472611c9..130f31bdde95 100644 --- a/x/group/internal/orm/types_test.go +++ b/x/group/internal/orm/types_test.go @@ -18,7 +18,7 @@ import ( func TestTypeSafeRowGetter(t *testing.T) { storeKey := sdk.NewKVStoreKey("test") ctx := NewMockContext() - var prefixKey = [2]byte{0x2} + prefixKey := [2]byte{0x2} store := prefix.NewStore(ctx.KVStore(storeKey), prefixKey[:]) md := testdata.TableModel{ Id: 1, diff --git a/x/group/keeper/genesis.go b/x/group/keeper/genesis.go index 311809de39c1..2e0766ed716e 100644 --- a/x/group/keeper/genesis.go +++ b/x/group/keeper/genesis.go @@ -40,7 +40,6 @@ func (k Keeper) InitGenesis(ctx types.Context, cdc codec.JSONCodec, data json.Ra } return []abci.ValidatorUpdate{} - } func (k Keeper) ExportGenesis(ctx types.Context, cdc codec.JSONCodec) *group.GenesisState { diff --git a/x/group/keeper/genesis_test.go b/x/group/keeper/genesis_test.go index aeacfab49ea4..c164ad47364b 100644 --- a/x/group/keeper/genesis_test.go +++ b/x/group/keeper/genesis_test.go @@ -2,7 +2,6 @@ package keeper_test import ( "context" - "encoding/json" "testing" "time" @@ -192,7 +191,6 @@ func (s *GenesisTestSuite) TestInitExportGenesis() { s.Require().Equal(genesisState.GroupSeq, exportedGenesisState.GroupSeq) s.Require().Equal(genesisState.GroupPolicySeq, exportedGenesisState.GroupPolicySeq) s.Require().Equal(genesisState.ProposalSeq, exportedGenesisState.ProposalSeq) - } func (s *GenesisTestSuite) assertGroupPoliciesEqual(g *group.GroupPolicyInfo, other *group.GroupPolicyInfo) { @@ -202,7 +200,11 @@ func (s *GenesisTestSuite) assertGroupPoliciesEqual(g *group.GroupPolicyInfo, ot require.Equal(g.Admin, other.Admin) require.Equal(g.Metadata, other.Metadata) require.Equal(g.Version, other.Version) - require.Equal(g.GetDecisionPolicy(), other.GetDecisionPolicy()) + dp1, err := g.GetDecisionPolicy() + require.NoError(err) + dp2, err := other.GetDecisionPolicy() + require.NoError(err) + require.Equal(dp1, dp2) } func (s *GenesisTestSuite) assertProposalsEqual(g *group.Proposal, other *group.Proposal) { @@ -218,5 +220,9 @@ func (s *GenesisTestSuite) assertProposalsEqual(g *group.Proposal, other *group. require.Equal(g.FinalTallyResult, other.FinalTallyResult) require.Equal(g.VotingPeriodEnd, other.VotingPeriodEnd) require.Equal(g.ExecutorResult, other.ExecutorResult) - require.Equal(g.GetMsgs(), other.GetMsgs()) + msgs1, err := g.GetMsgs() + require.NoError(err) + msgs2, err := other.GetMsgs() + require.NoError(err) + require.Equal(msgs1, msgs2) } diff --git a/x/group/keeper/grpc_query_test.go b/x/group/keeper/grpc_query_test.go index c9d91e728c26..21b390be9b0b 100644 --- a/x/group/keeper/grpc_query_test.go +++ b/x/group/keeper/grpc_query_test.go @@ -23,7 +23,7 @@ func TestQueryGroupsByMember(t *testing.T) { addrs := simapp.AddTestAddrsIncremental(app, ctx, 6, sdk.NewInt(30000000)) // Initial group, group policy and balance setup - members := []group.Member{ + members := []group.MemberRequest{ {Address: addrs[2].String(), Weight: "1"}, {Address: addrs[3].String(), Weight: "2"}, } _, err := app.GroupKeeper.CreateGroup(sdkCtx, &group.MsgCreateGroup{ @@ -32,7 +32,7 @@ func TestQueryGroupsByMember(t *testing.T) { }) require.NoError(t, err) - members = []group.Member{ + members = []group.MemberRequest{ {Address: addrs[3].String(), Weight: "1"}, {Address: addrs[4].String(), Weight: "2"}, } _, err = app.GroupKeeper.CreateGroup(sdkCtx, &group.MsgCreateGroup{ diff --git a/x/group/keeper/invariants.go b/x/group/keeper/invariants.go index 5db8057e5aea..2008fd3c9347 100644 --- a/x/group/keeper/invariants.go +++ b/x/group/keeper/invariants.go @@ -28,7 +28,6 @@ func GroupTotalWeightInvariant(keeper Keeper) sdk.Invariant { } func GroupTotalWeightInvariantHelper(ctx sdk.Context, key storetypes.StoreKey, groupTable orm.AutoUInt64Table, groupMemberByGroupIndex orm.Index) (string, bool) { - var msg string var broken bool @@ -73,7 +72,7 @@ func GroupTotalWeightInvariantHelper(ctx sdk.Context, key storetypes.StoreKey, g return msg, broken } - curMemWeight, err := groupmath.NewNonNegativeDecFromString(groupMember.GetMember().GetWeight()) + curMemWeight, err := groupmath.NewPositiveDecFromString(groupMember.GetMember().GetWeight()) if err != nil { msg += fmt.Sprintf("error while parsing non-nengative decimal for group member %s\n%v\n", groupMember.Member.Address, err) return msg, broken diff --git a/x/group/keeper/invariants_test.go b/x/group/keeper/invariants_test.go index e207a149f4e4..9a7ea308e118 100644 --- a/x/group/keeper/invariants_test.go +++ b/x/group/keeper/invariants_test.go @@ -47,7 +47,6 @@ func (s *invariantTestSuite) SetupSuite() { s.ctx = sdkCtx s.cdc = cdc s.key = key - } func (s *invariantTestSuite) TestGroupTotalWeightInvariant() { diff --git a/x/group/keeper/keeper.go b/x/group/keeper/keeper.go index f99c2bc398c5..93cd875da5a3 100644 --- a/x/group/keeper/keeper.go +++ b/x/group/keeper/keeper.go @@ -6,11 +6,11 @@ import ( "github.com/tendermint/tendermint/libs/log" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware" "github.com/cosmos/cosmos-sdk/x/group" "github.com/cosmos/cosmos-sdk/x/group/errors" "github.com/cosmos/cosmos-sdk/x/group/internal/orm" @@ -75,13 +75,13 @@ type Keeper struct { voteByProposalIndex orm.Index voteByVoterIndex orm.Index - router *authmiddleware.MsgServiceRouter + router *baseapp.MsgServiceRouter config group.Config } // NewKeeper creates a new group keeper. -func NewKeeper(storeKey storetypes.StoreKey, cdc codec.Codec, router *authmiddleware.MsgServiceRouter, accKeeper group.AccountKeeper, config group.Config) Keeper { +func NewKeeper(storeKey storetypes.StoreKey, cdc codec.Codec, router *baseapp.MsgServiceRouter, accKeeper group.AccountKeeper, config group.Config) Keeper { k := Keeper{ key: storeKey, router: router, @@ -211,7 +211,6 @@ func NewKeeper(storeKey storetypes.StoreKey, cdc codec.Codec, router *authmiddle k.config = config return k - } // Logger returns a module-specific logger. @@ -228,14 +227,13 @@ func (k Keeper) GetGroupSequence(ctx sdk.Context) uint64 { func (k Keeper) iterateProposalsByVPEnd(ctx sdk.Context, endTime time.Time, cb func(proposal group.Proposal) (bool, error)) error { timeBytes := sdk.FormatTimeBytes(endTime) it, err := k.proposalsByVotingPeriodEnd.PrefixScan(ctx.KVStore(k.key), nil, timeBytes) - if err != nil { return err } defer it.Close() for { - // Important: this following line cannot outside the for loop. + // Important: this following line cannot be outside of the for loop. // It seems that when one unmarshals into the same `group.Proposal` // reference, then gogoproto somehow "adds" the new bytes to the old // object for some fields. When running simulations, for proposals with @@ -278,6 +276,37 @@ func (k Keeper) pruneProposal(ctx sdk.Context, proposalID uint64) error { return nil } +// abortProposals iterates through all proposals by group policy index +// and marks submitted proposals as aborted. +func (k Keeper) abortProposals(ctx sdk.Context, groupPolicyAddr sdk.AccAddress) error { + proposalIt, err := k.proposalByGroupPolicyIndex.Get(ctx.KVStore(k.key), groupPolicyAddr.Bytes()) + if err != nil { + return err + } + defer proposalIt.Close() + + for { + var proposalInfo group.Proposal + _, err = proposalIt.LoadNext(&proposalInfo) + if errors.ErrORMIteratorDone.Is(err) { + break + } + if err != nil { + return err + } + + // Mark all proposals still in the voting phase as aborted. + if proposalInfo.Status == group.PROPOSAL_STATUS_SUBMITTED { + proposalInfo.Status = group.PROPOSAL_STATUS_ABORTED + + if err := k.proposalTable.Update(ctx.KVStore(k.key), proposalInfo.Id, &proposalInfo); err != nil { + return err + } + } + } + return nil +} + // pruneVotes prunes all votes for a proposal from state. func (k Keeper) pruneVotes(ctx sdk.Context, proposalID uint64) error { store := ctx.KVStore(k.key) @@ -340,13 +369,23 @@ func (k Keeper) TallyProposalsAtVPEnd(ctx sdk.Context) error { return true, sdkerrors.Wrap(err, "group") } - err = k.doTallyAndUpdate(ctx, &proposal, electorate, policyInfo) - if err != nil { - return true, sdkerrors.Wrap(err, "doTallyAndUpdate") - } - - if err := k.proposalTable.Update(ctx.KVStore(k.key), proposal.Id, &proposal); err != nil { - return true, sdkerrors.Wrap(err, "proposal update") + proposalId := proposal.Id + if proposal.Status == group.PROPOSAL_STATUS_ABORTED || proposal.Status == group.PROPOSAL_STATUS_WITHDRAWN { + if err := k.pruneProposal(ctx, proposalId); err != nil { + return true, err + } + if err := k.pruneVotes(ctx, proposalId); err != nil { + return true, err + } + } else { + err = k.doTallyAndUpdate(ctx, &proposal, electorate, policyInfo) + if err != nil { + return true, sdkerrors.Wrap(err, "doTallyAndUpdate") + } + + if err := k.proposalTable.Update(ctx.KVStore(k.key), proposal.Id, &proposal); err != nil { + return true, sdkerrors.Wrap(err, "proposal update") + } } return false, nil diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index 539ff6f9dc56..84ee34bcdf81 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -51,7 +51,7 @@ func (s *TestSuite) SetupTest() { s.addrs = simapp.AddTestAddrsIncremental(app, ctx, 6, sdk.NewInt(30000000)) // Initial group, group policy and balance setup - members := []group.Member{ + members := []group.MemberRequest{ {Address: s.addrs[4].String(), Weight: "1"}, {Address: s.addrs[1].String(), Weight: "2"}, } groupRes, err := s.keeper.CreateGroup(s.ctx, &group.MsgCreateGroup{ @@ -92,14 +92,12 @@ func (s *TestSuite) TestCreateGroup() { addr5 := addrs[4] addr6 := addrs[5] - members := []group.Member{{ + members := []group.MemberRequest{{ Address: addr5.String(), Weight: "1", - AddedAt: s.blockTime, }, { Address: addr6.String(), Weight: "2", - AddedAt: s.blockTime, }} expGroups := []*group.GroupInfo{ @@ -142,7 +140,7 @@ func (s *TestSuite) TestCreateGroup() { "member metadata too long": { req: &group.MsgCreateGroup{ Admin: addr1.String(), - Members: []group.Member{{ + Members: []group.MemberRequest{{ Address: addr3.String(), Weight: "1", Metadata: strings.Repeat("a", 256), @@ -153,7 +151,7 @@ func (s *TestSuite) TestCreateGroup() { "zero member weight": { req: &group.MsgCreateGroup{ Admin: addr1.String(), - Members: []group.Member{{ + Members: []group.MemberRequest{{ Address: addr3.String(), Weight: "0", }}, @@ -166,6 +164,7 @@ func (s *TestSuite) TestCreateGroup() { for msg, spec := range specs { spec := spec s.Run(msg, func() { + blockTime := sdk.UnwrapSDKContext(s.ctx).BlockTime() res, err := s.keeper.CreateGroup(s.ctx, spec.req) if spec.expErr { s.Require().Error(err) @@ -204,7 +203,7 @@ func (s *TestSuite) TestCreateGroup() { s.Assert().Equal(members[i].Metadata, loadedMembers[i].Member.Metadata) s.Assert().Equal(members[i].Address, loadedMembers[i].Member.Address) s.Assert().Equal(members[i].Weight, loadedMembers[i].Member.Weight) - s.Assert().Equal(members[i].AddedAt, loadedMembers[i].Member.AddedAt) + s.Assert().Equal(blockTime, loadedMembers[i].Member.AddedAt) s.Assert().Equal(id, loadedMembers[i].GroupId) } @@ -223,7 +222,6 @@ func (s *TestSuite) TestCreateGroup() { } }) } - } func (s *TestSuite) TestUpdateGroupAdmin() { @@ -233,10 +231,9 @@ func (s *TestSuite) TestUpdateGroupAdmin() { addr3 := addrs[2] addr4 := addrs[3] - members := []group.Member{{ + members := []group.MemberRequest{{ Address: addr1.String(), Weight: "1", - AddedAt: s.blockTime, }} oldAdmin := addr2.String() newAdmin := addr3.String() @@ -398,7 +395,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { member1 := addr5.String() member2 := addr6.String() - members := []group.Member{{ + members := []group.MemberRequest{{ Address: member1, Weight: "1", }} @@ -421,7 +418,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { req: &group.MsgUpdateGroupMembers{ GroupId: groupID, Admin: myAdmin, - MemberUpdates: []group.Member{{ + MemberUpdates: []group.MemberRequest{{ Address: member2, Weight: "2", }}, @@ -438,6 +435,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { Member: &group.Member{ Address: member2, Weight: "2", + AddedAt: s.sdkCtx.BlockTime(), }, GroupId: groupID, }, @@ -445,6 +443,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { Member: &group.Member{ Address: member1, Weight: "1", + AddedAt: s.blockTime, }, GroupId: groupID, }, @@ -454,7 +453,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { req: &group.MsgUpdateGroupMembers{ GroupId: groupID, Admin: myAdmin, - MemberUpdates: []group.Member{{ + MemberUpdates: []group.MemberRequest{{ Address: member1, Weight: "2", }}, @@ -472,6 +471,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { Member: &group.Member{ Address: member1, Weight: "2", + AddedAt: s.blockTime, }, }, }, @@ -480,7 +480,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { req: &group.MsgUpdateGroupMembers{ GroupId: groupID, Admin: myAdmin, - MemberUpdates: []group.Member{{ + MemberUpdates: []group.MemberRequest{{ Address: member1, Weight: "1", }}, @@ -498,6 +498,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { Member: &group.Member{ Address: member1, Weight: "1", + AddedAt: s.blockTime, }, }, }, @@ -506,7 +507,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { req: &group.MsgUpdateGroupMembers{ GroupId: groupID, Admin: myAdmin, - MemberUpdates: []group.Member{ + MemberUpdates: []group.MemberRequest{ { Address: member1, Weight: "0", @@ -529,6 +530,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { Member: &group.Member{ Address: member2, Weight: "1", + AddedAt: s.sdkCtx.BlockTime(), }, }}, }, @@ -536,7 +538,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { req: &group.MsgUpdateGroupMembers{ GroupId: groupID, Admin: myAdmin, - MemberUpdates: []group.Member{{ + MemberUpdates: []group.MemberRequest{{ Address: member1, Weight: "0", }}, @@ -554,7 +556,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { req: &group.MsgUpdateGroupMembers{ GroupId: groupID, Admin: myAdmin, - MemberUpdates: []group.Member{{ + MemberUpdates: []group.MemberRequest{{ Address: addr4.String(), Weight: "0", }}, @@ -579,7 +581,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { req: &group.MsgUpdateGroupMembers{ GroupId: groupID, Admin: addr3.String(), - MemberUpdates: []group.Member{{ + MemberUpdates: []group.MemberRequest{{ Address: member1, Weight: "2", }}, @@ -604,7 +606,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { req: &group.MsgUpdateGroupMembers{ GroupId: 999, Admin: myAdmin, - MemberUpdates: []group.Member{{ + MemberUpdates: []group.MemberRequest{{ Address: member1, Weight: "2", }}, @@ -660,6 +662,7 @@ func (s *TestSuite) TestUpdateGroupMembers() { s.Assert().Equal(spec.expMembers[i].Member.Metadata, loadedMembers[i].Member.Metadata) s.Assert().Equal(spec.expMembers[i].Member.Address, loadedMembers[i].Member.Address) s.Assert().Equal(spec.expMembers[i].Member.Weight, loadedMembers[i].Member.Weight) + s.Assert().Equal(spec.expMembers[i].Member.AddedAt, loadedMembers[i].Member.AddedAt) s.Assert().Equal(spec.expMembers[i].GroupId, loadedMembers[i].GroupId) } }) @@ -673,14 +676,12 @@ func (s *TestSuite) TestCreateGroupWithPolicy() { addr5 := addrs[4] addr6 := addrs[5] - members := []group.Member{{ + members := []group.MemberRequest{{ Address: addr5.String(), Weight: "1", - AddedAt: s.blockTime, }, { Address: addr6.String(), Weight: "2", - AddedAt: s.blockTime, }} specs := map[string]struct { @@ -746,7 +747,7 @@ func (s *TestSuite) TestCreateGroupWithPolicy() { "member metadata too long": { req: &group.MsgCreateGroupWithPolicy{ Admin: addr1.String(), - Members: []group.Member{{ + Members: []group.MemberRequest{{ Address: addr3.String(), Weight: "1", Metadata: strings.Repeat("a", 256), @@ -764,7 +765,7 @@ func (s *TestSuite) TestCreateGroupWithPolicy() { "zero member weight": { req: &group.MsgCreateGroupWithPolicy{ Admin: addr1.String(), - Members: []group.Member{{ + Members: []group.MemberRequest{{ Address: addr3.String(), Weight: "0", }}, @@ -799,6 +800,7 @@ func (s *TestSuite) TestCreateGroupWithPolicy() { err := spec.req.SetDecisionPolicy(spec.policy) s.Require().NoError(err) + blockTime := sdk.UnwrapSDKContext(s.ctx).BlockTime() res, err := s.keeper.CreateGroupWithPolicy(s.ctx, spec.req) if spec.expErr { s.Require().Error(err) @@ -838,7 +840,7 @@ func (s *TestSuite) TestCreateGroupWithPolicy() { s.Assert().Equal(members[i].Metadata, loadedMembers[i].Member.Metadata) s.Assert().Equal(members[i].Address, loadedMembers[i].Member.Address) s.Assert().Equal(members[i].Weight, loadedMembers[i].Member.Weight) - s.Assert().Equal(members[i].AddedAt, loadedMembers[i].Member.AddedAt) + s.Assert().Equal(blockTime, loadedMembers[i].Member.AddedAt) s.Assert().Equal(id, loadedMembers[i].GroupId) } @@ -850,7 +852,9 @@ func (s *TestSuite) TestCreateGroupWithPolicy() { s.Assert().Equal(groupPolicyAddr, groupPolicy.Address) s.Assert().Equal(id, groupPolicy.GroupId) s.Assert().Equal(spec.req.GroupPolicyMetadata, groupPolicy.Metadata) - s.Assert().Equal(spec.policy.(*group.ThresholdDecisionPolicy), groupPolicy.GetDecisionPolicy()) + dp, err := groupPolicy.GetDecisionPolicy() + s.Assert().NoError(err) + s.Assert().Equal(spec.policy.(*group.ThresholdDecisionPolicy), dp) if spec.req.GroupPolicyAsAdmin { s.Assert().NotEqual(spec.req.Admin, groupPolicy.Admin) s.Assert().Equal(groupPolicyAddr, groupPolicy.Admin) @@ -859,7 +863,6 @@ func (s *TestSuite) TestCreateGroupWithPolicy() { } }) } - } func (s *TestSuite) TestCreateGroupPolicy() { @@ -1007,9 +1010,13 @@ func (s *TestSuite) TestCreateGroupPolicy() { s.Assert().Equal(uint64(1), groupPolicy.Version) percentageDecisionPolicy, ok := spec.policy.(*group.PercentageDecisionPolicy) if ok { - s.Assert().Equal(percentageDecisionPolicy, groupPolicy.GetDecisionPolicy()) + dp, err := groupPolicy.GetDecisionPolicy() + s.Assert().NoError(err) + s.Assert().Equal(percentageDecisionPolicy, dp) } else { - s.Assert().Equal(spec.policy.(*group.ThresholdDecisionPolicy), groupPolicy.GetDecisionPolicy()) + dp, err := groupPolicy.GetDecisionPolicy() + s.Assert().NoError(err) + s.Assert().Equal(spec.policy.(*group.ThresholdDecisionPolicy), dp) } }) } @@ -1370,7 +1377,11 @@ func (s *TestSuite) TestGroupPoliciesByAdminOrGroup() { s.Assert().Equal(policyAccs[i].Metadata, expectAccs[i].Metadata) s.Assert().Equal(policyAccs[i].Version, expectAccs[i].Version) s.Assert().Equal(policyAccs[i].CreatedAt, expectAccs[i].CreatedAt) - s.Assert().Equal(policyAccs[i].GetDecisionPolicy(), expectAccs[i].GetDecisionPolicy()) + dp1, err := policyAccs[i].GetDecisionPolicy() + s.Assert().NoError(err) + dp2, err := expectAccs[i].GetDecisionPolicy() + s.Assert().NoError(err) + s.Assert().Equal(dp1, dp2) } // query group policy by admin @@ -1389,7 +1400,11 @@ func (s *TestSuite) TestGroupPoliciesByAdminOrGroup() { s.Assert().Equal(policyAccs[i].Metadata, expectAccs[i].Metadata) s.Assert().Equal(policyAccs[i].Version, expectAccs[i].Version) s.Assert().Equal(policyAccs[i].CreatedAt, expectAccs[i].CreatedAt) - s.Assert().Equal(policyAccs[i].GetDecisionPolicy(), expectAccs[i].GetDecisionPolicy()) + dp1, err := policyAccs[i].GetDecisionPolicy() + s.Assert().NoError(err) + dp2, err := expectAccs[i].GetDecisionPolicy() + s.Assert().NoError(err) + s.Assert().Equal(dp1, dp2) } } @@ -1611,10 +1626,12 @@ func (s *TestSuite) TestSubmitProposal() { s.Assert().Equal(spec.expProposal.ExecutorResult, proposal.ExecutorResult) s.Assert().Equal(s.blockTime.Add(time.Second), proposal.VotingPeriodEnd) + msgs, err := proposal.GetMsgs() + s.Assert().NoError(err) if spec.msgs == nil { // then empty list is ok - s.Assert().Len(proposal.GetMsgs(), 0) + s.Assert().Len(msgs, 0) } else { - s.Assert().Equal(spec.msgs, proposal.GetMsgs()) + s.Assert().Equal(spec.msgs, msgs) } } @@ -1627,7 +1644,6 @@ func (s *TestSuite) TestWithdrawProposal() { addrs := s.addrs addr2 := addrs[1] addr5 := addrs[4] - groupPolicy := s.groupPolicyAddr msgSend := &banktypes.MsgSend{ FromAddress: s.groupPolicyAddr.String(), @@ -1684,7 +1700,7 @@ func (s *TestSuite) TestWithdrawProposal() { return submitProposal(s.ctx, s, []sdk.Msg{msgSend}, proposers) }, proposalId: proposalID, - admin: groupPolicy.String(), + admin: proposers[0], }, } for msg, spec := range specs { @@ -1718,9 +1734,9 @@ func (s *TestSuite) TestVote() { addr3 := addrs[2] addr4 := addrs[3] addr5 := addrs[4] - members := []group.Member{ - {Address: addr4.String(), Weight: "1", AddedAt: s.blockTime}, - {Address: addr3.String(), Weight: "2", AddedAt: s.blockTime}, + members := []group.MemberRequest{ + {Address: addr4.String(), Weight: "1"}, + {Address: addr3.String(), Weight: "2"}, } groupRes, err := s.keeper.CreateGroup(s.ctx, &group.MsgCreateGroup{ Admin: addr1.String(), @@ -2121,10 +2137,10 @@ func (s *TestSuite) TestVote() { s.T().Log("test tally result should not take into account the member who left the group") require := s.Require() - members = []group.Member{ - {Address: addr2.String(), Weight: "3", AddedAt: s.blockTime}, - {Address: addr3.String(), Weight: "2", AddedAt: s.blockTime}, - {Address: addr4.String(), Weight: "1", AddedAt: s.blockTime}, + members = []group.MemberRequest{ + {Address: addr2.String(), Weight: "3"}, + {Address: addr3.String(), Weight: "2"}, + {Address: addr4.String(), Weight: "1"}, } reqCreate := &group.MsgCreateGroupWithPolicy{ Admin: addr1.String(), @@ -2430,6 +2446,8 @@ func (s *TestSuite) TestExecPrunedProposalsAndVotes() { s.Require().NoError(err) return myProposalID }, + expErr: true, // since proposal status will be `aborted` when group policy is modified + expErrMsg: "not possible to exec with proposal status", expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_NOT_RUN, }, "proposal exists when rollback all msg updates on failure": { @@ -2470,6 +2488,7 @@ func (s *TestSuite) TestExecPrunedProposalsAndVotes() { _, err := s.keeper.Exec(ctx, &group.MsgExec{Executor: addr1.String(), ProposalId: proposalID}) if spec.expErr { s.Require().Error(err) + s.Require().Contains(err.Error(), spec.expErrMsg) return } s.Require().NoError(err) @@ -2501,7 +2520,6 @@ func (s *TestSuite) TestExecPrunedProposalsAndVotes() { func (s *TestSuite) TestProposalsByVPEnd() { addrs := s.addrs addr2 := addrs[1] - groupPolicy := s.groupPolicyAddr votingPeriod := s.policy.GetVotingPeriod() ctx := s.sdkCtx @@ -2524,14 +2542,14 @@ func (s *TestSuite) TestProposalsByVPEnd() { tallyRes group.TallyResult expStatus group.ProposalStatus }{ - "tally updated after voting power end": { + "tally updated after voting period end": { preRun: func(sdkCtx sdk.Context) uint64 { return submitProposal(sdkCtx, s, []sdk.Msg{msgSend}, proposers) }, admin: proposers[0], newCtx: ctx.WithBlockTime(now.Add(votingPeriod).Add(time.Hour)), tallyRes: group.DefaultTallyResult(), - expStatus: group.PROPOSAL_STATUS_SUBMITTED, + expStatus: group.PROPOSAL_STATUS_REJECTED, }, "tally within voting period": { preRun: func(sdkCtx sdk.Context) uint64 { @@ -2542,7 +2560,7 @@ func (s *TestSuite) TestProposalsByVPEnd() { tallyRes: group.DefaultTallyResult(), expStatus: group.PROPOSAL_STATUS_SUBMITTED, }, - "tally within voting period(with votes)": { + "tally within voting period (with votes)": { preRun: func(sdkCtx sdk.Context) uint64 { return submitProposalAndVote(s.ctx, s, []sdk.Msg{msgSend}, proposers, group.VOTE_OPTION_YES) }, @@ -2551,7 +2569,7 @@ func (s *TestSuite) TestProposalsByVPEnd() { tallyRes: group.DefaultTallyResult(), expStatus: group.PROPOSAL_STATUS_SUBMITTED, }, - "tally after voting period(with votes)": { + "tally after voting period (with votes)": { preRun: func(sdkCtx sdk.Context) uint64 { return submitProposalAndVote(s.ctx, s, []sdk.Msg{msgSend}, proposers, group.VOTE_OPTION_YES) }, @@ -2565,12 +2583,27 @@ func (s *TestSuite) TestProposalsByVPEnd() { }, expStatus: group.PROPOSAL_STATUS_ACCEPTED, }, - "tally of closed proposal": { + "tally after voting period (not passing)": { + preRun: func(sdkCtx sdk.Context) uint64 { + // `s.addrs[4]` has weight 1 + return submitProposalAndVote(s.ctx, s, []sdk.Msg{msgSend}, []string{s.addrs[4].String()}, group.VOTE_OPTION_YES) + }, + admin: proposers[0], + newCtx: ctx.WithBlockTime(now.Add(votingPeriod).Add(time.Hour)), + tallyRes: group.TallyResult{ + YesCount: "1", + NoCount: "0", + NoWithVetoCount: "0", + AbstainCount: "0", + }, + expStatus: group.PROPOSAL_STATUS_REJECTED, + }, + "tally of withdrawn proposal": { preRun: func(sdkCtx sdk.Context) uint64 { pId := submitProposal(s.ctx, s, []sdk.Msg{msgSend}, proposers) _, err := s.keeper.WithdrawProposal(s.ctx, &group.MsgWithdrawProposal{ ProposalId: pId, - Address: groupPolicy.String(), + Address: proposers[0], }) s.Require().NoError(err) @@ -2581,12 +2614,12 @@ func (s *TestSuite) TestProposalsByVPEnd() { tallyRes: group.DefaultTallyResult(), expStatus: group.PROPOSAL_STATUS_WITHDRAWN, }, - "tally of closed proposal (with votes)": { + "tally of withdrawn proposal (with votes)": { preRun: func(sdkCtx sdk.Context) uint64 { pId := submitProposalAndVote(s.ctx, s, []sdk.Msg{msgSend}, proposers, group.VOTE_OPTION_YES) _, err := s.keeper.WithdrawProposal(s.ctx, &group.MsgWithdrawProposal{ ProposalId: pId, - Address: groupPolicy.String(), + Address: proposers[0], }) s.Require().NoError(err) @@ -2633,24 +2666,21 @@ func (s *TestSuite) TestLeaveGroup() { admin3 := addrs[6] require := s.Require() - members := []group.Member{ + members := []group.MemberRequest{ { Address: member1.String(), Weight: "1", Metadata: "metadata", - AddedAt: s.sdkCtx.BlockTime(), }, { Address: member2.String(), Weight: "2", Metadata: "metadata", - AddedAt: s.sdkCtx.BlockTime(), }, { Address: member3.String(), Weight: "3", Metadata: "metadata", - AddedAt: s.sdkCtx.BlockTime(), }, } policy := group.NewThresholdDecisionPolicy( @@ -2660,28 +2690,25 @@ func (s *TestSuite) TestLeaveGroup() { ) _, groupID1 := s.createGroupAndGroupPolicy(admin1, members, policy) - members = []group.Member{ + members = []group.MemberRequest{ { Address: member1.String(), Weight: "1", Metadata: "metadata", - AddedAt: s.sdkCtx.BlockTime(), }, } _, groupID2 := s.createGroupAndGroupPolicy(admin2, members, nil) - members = []group.Member{ + members = []group.MemberRequest{ { Address: member1.String(), Weight: "1", Metadata: "metadata", - AddedAt: s.sdkCtx.BlockTime(), }, { Address: member2.String(), Weight: "2", Metadata: "metadata", - AddedAt: s.sdkCtx.BlockTime(), }, } policy = &group.PercentageDecisionPolicy{ @@ -2721,7 +2748,7 @@ func (s *TestSuite) TestLeaveGroup() { math.NewDecFromInt64(0), }, { - "valid testcase: decision policy is not present", + "valid testcase: decision policy is not present (and group total weight can be 0)", &group.MsgLeaveGroup{ GroupId: groupID2, Address: member1.String(), @@ -2802,9 +2829,58 @@ func (s *TestSuite) TestLeaveGroup() { } } + +func (s *TestSuite) TestPruneProposals() { + addrs := s.addrs + expirationTime := time.Hour * 24 * 15 // 15 days + groupID := s.groupID + accountAddr := s.groupPolicyAddr + + msgSend := &banktypes.MsgSend{ + FromAddress: s.groupPolicyAddr.String(), + ToAddress: addrs[0].String(), + Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)}, + } + + policyReq := &group.MsgCreateGroupPolicy{ + Admin: addrs[0].String(), + GroupId: groupID, + } + + policy := group.NewThresholdDecisionPolicy("100", time.Microsecond, time.Microsecond) + err := policyReq.SetDecisionPolicy(policy) + s.Require().NoError(err) + _, err = s.keeper.CreateGroupPolicy(s.ctx, policyReq) + s.Require().NoError(err) + + req := &group.MsgSubmitProposal{ + GroupPolicyAddress: accountAddr.String(), + Proposers: []string{addrs[1].String()}, + } + err = req.SetMsgs([]sdk.Msg{msgSend}) + s.Require().NoError(err) + submittedProposal, err := s.keeper.SubmitProposal(s.ctx, req) + s.Require().NoError(err) + queryProposal := group.QueryProposalRequest{ProposalId: submittedProposal.ProposalId} + prePrune, err := s.keeper.Proposal(s.ctx, &queryProposal) + s.Require().NoError(err) + s.Require().Equal(prePrune.Proposal.Id, submittedProposal.ProposalId) + // Move Forward in time for 15 days, after voting period end + max_execution_period + s.sdkCtx = s.sdkCtx.WithBlockTime(s.sdkCtx.BlockTime().Add(expirationTime)) + + // Prune Expired Proposals + err = s.keeper.PruneProposals(s.sdkCtx) + s.Require().NoError(err) + postPrune, err := s.keeper.Proposal(s.ctx, &queryProposal) + s.Require().Nil(postPrune) + s.Require().Error(err) + s.Require().Contains(err.Error(), "load proposal: not found") +} + func submitProposal( ctx context.Context, s *TestSuite, msgs []sdk.Msg, - proposers []string) uint64 { + proposers []string, +) uint64 { proposalReq := &group.MsgSubmitProposal{ GroupPolicyAddress: s.groupPolicyAddr.String(), Proposers: proposers, @@ -2819,7 +2895,8 @@ func submitProposal( func submitProposalAndVote( ctx context.Context, s *TestSuite, msgs []sdk.Msg, - proposers []string, voteOption group.VoteOption) uint64 { + proposers []string, voteOption group.VoteOption, +) uint64 { s.Require().Greater(len(proposers), 0) myProposalID := submitProposal(ctx, s, msgs, proposers) @@ -2834,7 +2911,7 @@ func submitProposalAndVote( func (s *TestSuite) createGroupAndGroupPolicy( admin sdk.AccAddress, - members []group.Member, + members []group.MemberRequest, policy group.DecisionPolicy, ) (policyAddr string, groupID uint64) { groupRes, err := s.keeper.CreateGroup(s.ctx, &group.MsgCreateGroup{ diff --git a/x/group/keeper/msg_server.go b/x/group/keeper/msg_server.go index 142f8d7c9c29..6a25c5dce3f1 100644 --- a/x/group/keeper/msg_server.go +++ b/x/group/keeper/msg_server.go @@ -4,9 +4,6 @@ import ( "context" "encoding/binary" "fmt" - "reflect" - - gogotypes "github.com/gogo/protobuf/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" @@ -27,7 +24,7 @@ const gasCostPerIteration = uint64(20) func (k Keeper) CreateGroup(goCtx context.Context, req *group.MsgCreateGroup) (*group.MsgCreateGroupResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) metadata := req.Metadata - members := group.Members{Members: req.Members} + members := group.MemberRequests{Members: req.Members} admin := req.Admin if err := members.ValidateBasic(); err != nil { @@ -102,13 +99,14 @@ func (k Keeper) UpdateGroupMembers(goCtx context.Context, req *group.MsgUpdateGr action := func(g *group.GroupInfo) error { totalWeight, err := math.NewNonNegativeDecFromString(g.TotalWeight) if err != nil { - return err + return sdkerrors.Wrap(err, "group total weight") } for i := range req.MemberUpdates { if err := k.assertMetadataLength(req.MemberUpdates[i].Metadata, "group member metadata"); err != nil { return err } - groupMember := group.GroupMember{GroupId: req.GroupId, + groupMember := group.GroupMember{ + GroupId: req.GroupId, Member: &group.Member{ Address: req.MemberUpdates[i].Address, Weight: req.MemberUpdates[i].Weight, @@ -140,7 +138,7 @@ func (k Keeper) UpdateGroupMembers(goCtx context.Context, req *group.MsgUpdateGr return sdkerrors.Wrap(sdkerrors.ErrNotFound, "unknown member") } - previousMemberWeight, err := math.NewNonNegativeDecFromString(prevGroupMember.Member.Weight) + previousMemberWeight, err := math.NewPositiveDecFromString(prevGroupMember.Member.Weight) if err != nil { return err } @@ -159,22 +157,25 @@ func (k Keeper) UpdateGroupMembers(goCtx context.Context, req *group.MsgUpdateGr } // If group member already exists, handle update if found { - previousMemberWeight, err := math.NewNonNegativeDecFromString(prevGroupMember.Member.Weight) + previousMemberWeight, err := math.NewPositiveDecFromString(prevGroupMember.Member.Weight) if err != nil { return err } - // Subtract previous weight from the group total weight. + // Substract previous weight from the group total weight. totalWeight, err = math.SubNonNegative(totalWeight, previousMemberWeight) if err != nil { return err } // Save updated group member in the groupMemberTable. + groupMember.Member.AddedAt = prevGroupMember.Member.AddedAt if err := k.groupMemberTable.Update(ctx.KVStore(k.key), &groupMember); err != nil { return sdkerrors.Wrap(err, "add member") } - // else handle create. - } else if err := k.groupMemberTable.Create(ctx.KVStore(k.key), &groupMember); err != nil { - return sdkerrors.Wrap(err, "add member") + } else { // else handle create. + groupMember.Member.AddedAt = ctx.BlockTime() + if err := k.groupMemberTable.Create(ctx.KVStore(k.key), &groupMember); err != nil { + return sdkerrors.Wrap(err, "add member") + } } // In both cases (handle + update), we need to add the new member's weight to the group total weight. totalWeight, err = totalWeight.Add(newMemberWeight) @@ -298,7 +299,10 @@ func (k Keeper) CreateGroupPolicy(goCtx context.Context, req *group.MsgCreateGro if err != nil { return nil, sdkerrors.Wrap(err, "request admin") } - policy := req.GetDecisionPolicy() + policy, err := req.GetDecisionPolicy() + if err != nil { + return nil, sdkerrors.Wrap(err, "request decision policy") + } groupID := req.GetGroupID() metadata := req.GetMetadata() @@ -326,17 +330,19 @@ func (k Keeper) CreateGroupPolicy(goCtx context.Context, req *group.MsgCreateGro // Generate account address of group policy. var accountAddr sdk.AccAddress - // loop here in the rare case of a collision + // loop here in the rare case where a ADR-028-derived address creates a + // collision with an existing address. for { nextAccVal := k.groupPolicySeq.NextVal(ctx.KVStore(k.key)) - var buf = make([]byte, 8) + buf := make([]byte, 8) binary.BigEndian.PutUint64(buf, nextAccVal) parentAcc := address.Module(group.ModuleName, []byte{GroupPolicyTablePrefix}) accountAddr = address.Derive(parentAcc, buf) if k.accKeeper.GetAccount(ctx, accountAddr) != nil { - // handle a rare collision + // handle a rare collision, in which case we just go on to the + // next sequence value and derive a new address. continue } acc := k.accKeeper.NewAccount(ctx, &authtypes.ModuleAccount{ @@ -393,7 +399,10 @@ func (k Keeper) UpdateGroupPolicyAdmin(goCtx context.Context, req *group.MsgUpda func (k Keeper) UpdateGroupPolicyDecisionPolicy(goCtx context.Context, req *group.MsgUpdateGroupPolicyDecisionPolicy) (*group.MsgUpdateGroupPolicyDecisionPolicyResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - policy := req.GetDecisionPolicy() + policy, err := req.GetDecisionPolicy() + if err != nil { + return nil, err + } action := func(groupPolicy *group.GroupPolicyInfo) error { g, err := k.getGroupInfo(ctx, groupPolicy.GroupId) @@ -415,7 +424,7 @@ func (k Keeper) UpdateGroupPolicyDecisionPolicy(goCtx context.Context, req *grou return k.groupPolicyTable.Update(ctx.KVStore(k.key), groupPolicy) } - err := k.doUpdateGroupPolicy(ctx, req.GroupPolicyAddress, req.Admin, action, "group policy's decision policy updated") + err = k.doUpdateGroupPolicy(ctx, req.GroupPolicyAddress, req.Admin, action, "group policy's decision policy updated") if err != nil { return nil, err } @@ -447,13 +456,16 @@ func (k Keeper) UpdateGroupPolicyMetadata(goCtx context.Context, req *group.MsgU func (k Keeper) SubmitProposal(goCtx context.Context, req *group.MsgSubmitProposal) (*group.MsgSubmitProposalResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - accountAddress, err := sdk.AccAddressFromBech32(req.GroupPolicyAddress) + groupPolicyAddr, err := sdk.AccAddressFromBech32(req.GroupPolicyAddress) if err != nil { return nil, sdkerrors.Wrap(err, "request account address of group policy") } metadata := req.Metadata proposers := req.Proposers - msgs := req.GetMsgs() + msgs, err := req.GetMsgs() + if err != nil { + return nil, sdkerrors.Wrap(err, "request msgs") + } if err := k.assertMetadataLength(metadata, "metadata"); err != nil { return nil, err @@ -477,13 +489,13 @@ func (k Keeper) SubmitProposal(goCtx context.Context, req *group.MsgSubmitPropos } // Check that if the messages require signers, they are all equal to the given account address of group policy. - if err := ensureMsgAuthZ(msgs, accountAddress); err != nil { + if err := ensureMsgAuthZ(msgs, groupPolicyAddr); err != nil { return nil, err } - policy := policyAcc.GetDecisionPolicy() - if policy == nil { - return nil, sdkerrors.Wrap(errors.ErrEmpty, "nil policy") + policy, err := policyAcc.GetDecisionPolicy() + if err != nil { + return nil, sdkerrors.Wrap(err, "proposal group policy decision policy") } // Prevent proposal that can not succeed. @@ -531,7 +543,7 @@ func (k Keeper) SubmitProposal(goCtx context.Context, req *group.MsgSubmitPropos Option: group.VOTE_OPTION_YES, }) if err != nil { - return &group.MsgSubmitProposalResponse{ProposalId: id}, sdkerrors.Wrap(err, "The proposal was created but failed on vote") + return &group.MsgSubmitProposalResponse{ProposalId: id}, sdkerrors.Wrapf(err, "the proposal was created but failed on vote for voter %s", proposers[i]) } } @@ -543,7 +555,7 @@ func (k Keeper) SubmitProposal(goCtx context.Context, req *group.MsgSubmitPropos Executor: proposers[0], }) if err != nil { - return &group.MsgSubmitProposalResponse{ProposalId: id}, sdkerrors.Wrap(err, "The proposal was created but failed on exec") + return &group.MsgSubmitProposalResponse{ProposalId: id}, sdkerrors.Wrap(err, "the proposal was created but failed on exec") } } @@ -570,35 +582,14 @@ func (k Keeper) WithdrawProposal(goCtx context.Context, req *group.MsgWithdrawPr return nil, sdkerrors.Wrap(err, "load group policy") } - storeUpdates := func() (*group.MsgWithdrawProposalResponse, error) { - if err := k.proposalTable.Update(ctx.KVStore(k.key), id, &proposal); err != nil { - return nil, err - } - return &group.MsgWithdrawProposalResponse{}, nil - } - - // check address is the group policy admin. - if address == policyInfo.Address { - err = ctx.EventManager().EmitTypedEvent(&group.EventWithdrawProposal{ProposalId: id}) - if err != nil { - return nil, err - } - - proposal.Status = group.PROPOSAL_STATUS_WITHDRAWN - return storeUpdates() - } - - // if address is not group policy admin then check whether he is in proposers list. - validProposer := false - for _, proposer := range proposal.Proposers { - if proposer == address { - validProposer = true - break - } + // check address is the group policy admin he is in proposers list.. + if address != policyInfo.Admin && !isProposer(proposal, address) { + return nil, sdkerrors.Wrapf(errors.ErrUnauthorized, "given address is neither group policy admin nor in proposers: %s", address) } - if !validProposer { - return nil, sdkerrors.Wrapf(errors.ErrUnauthorized, "given address is neither group policy admin nor in proposers: %s", address) + proposal.Status = group.PROPOSAL_STATUS_WITHDRAWN + if err := k.proposalTable.Update(ctx.KVStore(k.key), id, &proposal); err != nil { + return nil, err } err = ctx.EventManager().EmitTypedEvent(&group.EventWithdrawProposal{ProposalId: id}) @@ -606,8 +597,7 @@ func (k Keeper) WithdrawProposal(goCtx context.Context, req *group.MsgWithdrawPr return nil, err } - proposal.Status = group.PROPOSAL_STATUS_WITHDRAWN - return storeUpdates() + return &group.MsgWithdrawProposalResponse{}, nil } func (k Keeper) Vote(goCtx context.Context, req *group.MsgVote) (*group.MsgVoteResponse, error) { @@ -632,9 +622,8 @@ func (k Keeper) Vote(goCtx context.Context, req *group.MsgVote) (*group.MsgVoteR return nil, sdkerrors.Wrap(errors.ErrExpired, "voting period has ended already") } - var policyInfo group.GroupPolicyInfo - - if policyInfo, err = k.getGroupPolicyInfo(ctx, proposal.GroupPolicyAddress); err != nil { + policyInfo, err := k.getGroupPolicyInfo(ctx, proposal.GroupPolicyAddress) + if err != nil { return nil, sdkerrors.Wrap(err, "load group policy") } @@ -647,7 +636,7 @@ func (k Keeper) Vote(goCtx context.Context, req *group.MsgVote) (*group.MsgVoteR voterAddr := req.Voter voter := group.GroupMember{GroupId: electorate.Id, Member: &group.Member{Address: voterAddr}} if err := k.groupMemberTable.GetOne(ctx.KVStore(k.key), orm.PrimaryKey(&voter), &voter); err != nil { - return nil, sdkerrors.Wrapf(err, "address: %s", voterAddr) + return nil, sdkerrors.Wrapf(err, "voter address: %s", voterAddr) } newVote := group.Vote{ ProposalId: id, @@ -682,15 +671,11 @@ func (k Keeper) Vote(goCtx context.Context, req *group.MsgVote) (*group.MsgVoteR return &group.MsgVoteResponse{}, nil } -// doTallyAndUpdate performs a tally, and updates the proposal's -// `FinalTallyResult` field only if the tally is final. +// doTallyAndUpdate performs a tally, and, if the tally result is final, then: +// - updates the proposal's `Status` and `FinalTallyResult` fields, +// - prune all the votes. func (k Keeper) doTallyAndUpdate(ctx sdk.Context, p *group.Proposal, electorate group.GroupInfo, policyInfo group.GroupPolicyInfo) error { - policy := policyInfo.GetDecisionPolicy() - pSubmittedAt, err := gogotypes.TimestampProto(p.SubmitTime) - if err != nil { - return err - } - submittedAt, err := gogotypes.TimestampFromProto(pSubmittedAt) + policy, err := policyInfo.GetDecisionPolicy() if err != nil { return err } @@ -700,11 +685,17 @@ func (k Keeper) doTallyAndUpdate(ctx sdk.Context, p *group.Proposal, electorate return err } - result, err := policy.Allow(tallyResult, electorate.TotalWeight, ctx.BlockTime().Sub(submittedAt)) + sinceSubmission := ctx.BlockTime().Sub(p.SubmitTime) // duration passed since proposal submission. + result, err := policy.Allow(tallyResult, electorate.TotalWeight, sinceSubmission) + // If the result was final (i.e. enough votes to pass) or if the voting + // period ended, then we consider the proposal as final. + isFinal := result.Final || ctx.BlockTime().After(p.VotingPeriodEnd) + switch { case err != nil: return sdkerrors.Wrap(err, "policy allow") - case result.Final: + + case isFinal: if err := k.pruneVotes(ctx, p.Id); err != nil { return err } @@ -730,31 +721,17 @@ func (k Keeper) Exec(goCtx context.Context, req *group.MsgExec) (*group.MsgExecR } if proposal.Status != group.PROPOSAL_STATUS_SUBMITTED && proposal.Status != group.PROPOSAL_STATUS_ACCEPTED { - return nil, sdkerrors.Wrapf(errors.ErrInvalid, "not possible with proposal status %s", proposal.Status.String()) + return nil, sdkerrors.Wrapf(errors.ErrInvalid, "not possible to exec with proposal status %s", proposal.Status.String()) } - var policyInfo group.GroupPolicyInfo - if policyInfo, err = k.getGroupPolicyInfo(ctx, proposal.GroupPolicyAddress); err != nil { + policyInfo, err := k.getGroupPolicyInfo(ctx, proposal.GroupPolicyAddress) + if err != nil { return nil, sdkerrors.Wrap(err, "load group policy") } - storeUpdates := func() (*group.MsgExecResponse, error) { - store := ctx.KVStore(k.key) - - // If proposal has successfully run, delete it from state. - if proposal.ExecutorResult == group.PROPOSAL_EXECUTOR_RESULT_SUCCESS { - if err := k.pruneProposal(ctx, proposal.Id); err != nil { - return nil, err - } - } else { - if err := k.proposalTable.Update(store, id, &proposal); err != nil { - return nil, err - } - } - - return &group.MsgExecResponse{}, nil - } - + // If proposal is still in SUBMITTED phase, it means that the voting period + // didn't end yet, and tallying hasn't been done. In this case, we need to + // tally first. if proposal.Status == group.PROPOSAL_STATUS_SUBMITTED { electorate, err := k.getGroupInfo(ctx, policyInfo.GroupId) if err != nil { @@ -767,8 +744,8 @@ func (k Keeper) Exec(goCtx context.Context, req *group.MsgExec) (*group.MsgExecR } // Execute proposal payload. + var logs string if proposal.Status == group.PROPOSAL_STATUS_ACCEPTED && proposal.ExecutorResult != group.PROPOSAL_EXECUTOR_RESULT_SUCCESS { - logger := ctx.Logger().With("module", fmt.Sprintf("x/%s", group.ModuleName)) // Caching context so that we don't update the store in case of failure. ctx, flush := ctx.CacheContext() @@ -779,8 +756,8 @@ func (k Keeper) Exec(goCtx context.Context, req *group.MsgExec) (*group.MsgExecR _, err = k.doExecuteMsgs(ctx, k.router, proposal, addr) if err != nil { proposal.ExecutorResult = group.PROPOSAL_EXECUTOR_RESULT_FAILURE - proposalType := reflect.TypeOf(proposal).String() - logger.Info("proposal execution failed", "cause", err, "type", proposalType, "proposalID", id) + logs = fmt.Sprintf("proposal execution failed on proposal %d, because of error %s", id, err.Error()) + k.Logger(ctx).Info("proposal execution failed", "cause", err, "proposalID", id) } else { proposal.ExecutorResult = group.PROPOSAL_EXECUTOR_RESULT_SUCCESS flush() @@ -788,20 +765,30 @@ func (k Keeper) Exec(goCtx context.Context, req *group.MsgExec) (*group.MsgExecR } // Update proposal in proposalTable - res, err := storeUpdates() - if err != nil { - return nil, err + // If proposal has successfully run, delete it from state. + if proposal.ExecutorResult == group.PROPOSAL_EXECUTOR_RESULT_SUCCESS { + if err := k.pruneProposal(ctx, proposal.Id); err != nil { + return nil, err + } + } else { + store := ctx.KVStore(k.key) + if err := k.proposalTable.Update(store, id, &proposal); err != nil { + return nil, err + } } err = ctx.EventManager().EmitTypedEvent(&group.EventExec{ ProposalId: id, + Logs: logs, Result: proposal.ExecutorResult, }) if err != nil { return nil, err } - return res, nil + return &group.MsgExecResponse{ + Result: proposal.ExecutorResult, + }, nil } // LeaveGroup implements the MsgServer/LeaveGroup method. @@ -830,7 +817,7 @@ func (k Keeper) LeaveGroup(goCtx context.Context, req *group.MsgLeaveGroup) (*gr return nil, err } - memberWeight, err := math.NewNonNegativeDecFromString(gm.Member.Weight) + memberWeight, err := math.NewPositiveDecFromString(gm.Member.Weight) if err != nil { return nil, err } @@ -847,11 +834,13 @@ func (k Keeper) LeaveGroup(goCtx context.Context, req *group.MsgLeaveGroup) (*gr // update group weight groupInfo.TotalWeight = updatedWeight.String() - if err := k.groupTable.Update(ctx.KVStore(k.key), groupInfo.Id, &groupInfo); err != nil { + groupInfo.Version++ + + if err := k.validateDecisionPolicies(ctx, groupInfo); err != nil { return nil, err } - if err := k.validateDecisionPolicies(ctx, groupInfo); err != nil { + if err := k.groupTable.Update(ctx.KVStore(k.key), groupInfo.Id, &groupInfo); err != nil { return nil, err } @@ -883,8 +872,10 @@ type authNGroupReq interface { GetAdmin() string } -type actionFn func(m *group.GroupInfo) error -type groupPolicyActionFn func(m *group.GroupPolicyInfo) error +type ( + actionFn func(m *group.GroupInfo) error + groupPolicyActionFn func(m *group.GroupPolicyInfo) error +) // doUpdateGroupPolicy first makes sure that the group policy admin initiated the group policy update, // before performing the group policy update and emitting an event. @@ -894,6 +885,11 @@ func (k Keeper) doUpdateGroupPolicy(ctx sdk.Context, groupPolicy string, admin s return sdkerrors.Wrap(err, "load group policy") } + groupPolicyAddr, err := sdk.AccAddressFromBech32(groupPolicy) + if err != nil { + return sdkerrors.Wrap(err, "group policy address") + } + groupPolicyAdmin, err := sdk.AccAddressFromBech32(admin) if err != nil { return sdkerrors.Wrap(err, "group policy admin") @@ -908,6 +904,10 @@ func (k Keeper) doUpdateGroupPolicy(ctx sdk.Context, groupPolicy string, admin s return sdkerrors.Wrap(err, note) } + if err = k.abortProposals(ctx, groupPolicyAddr); err != nil { + return err + } + err = ctx.EventManager().EmitTypedEvent(&group.EventUpdateGroupPolicy{Address: admin}) if err != nil { return err @@ -933,8 +933,8 @@ func (k Keeper) doUpdateGroup(ctx sdk.Context, req authNGroupReq, action actionF } // doAuthenticated makes sure that the group admin initiated the request, -// and perform the provided action on the -func (k Keeper) doAuthenticated(ctx sdk.Context, req authNGroupReq, action actionFn, note string) error { +// and perform the provided action on the group. +func (k Keeper) doAuthenticated(ctx sdk.Context, req authNGroupReq, action actionFn, errNote string) error { group, err := k.getGroupInfo(ctx, req.GetGroupID()) if err != nil { return err @@ -948,10 +948,10 @@ func (k Keeper) doAuthenticated(ctx sdk.Context, req authNGroupReq, action actio return sdkerrors.Wrap(err, "request admin") } if !admin.Equals(reqAdmin) { - return sdkerrors.Wrap(sdkerrors.ErrUnauthorized, "not group admin") + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "not group admin; got %s, expected %s", req.GetAdmin(), group.Admin) } if err := action(&group); err != nil { - return sdkerrors.Wrap(err, note) + return sdkerrors.Wrap(err, errNote) } return nil } @@ -992,3 +992,14 @@ func (k Keeper) validateDecisionPolicies(ctx sdk.Context, g group.GroupInfo) err return nil } + +// isProposer checks that an address is a proposer of a given proposal. +func isProposer(proposal group.Proposal, address string) bool { + for _, proposer := range proposal.Proposers { + if proposer == address { + return true + } + } + + return false +} diff --git a/x/group/keeper/proposal_executor.go b/x/group/keeper/proposal_executor.go index c63d9ad66f3a..29d9d1e8bed9 100644 --- a/x/group/keeper/proposal_executor.go +++ b/x/group/keeper/proposal_executor.go @@ -1,16 +1,18 @@ package keeper import ( + "fmt" + + "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" - authmiddleware "github.com/cosmos/cosmos-sdk/x/auth/middleware" "github.com/cosmos/cosmos-sdk/x/group" grouperrors "github.com/cosmos/cosmos-sdk/x/group/errors" ) // doExecuteMsgs routes the messages to the registered handlers. Messages are limited to those that require no authZ or // by the account of group policy only. Otherwise this gives access to other peoples accounts as the sdk middlewares are bypassed -func (s Keeper) doExecuteMsgs(ctx sdk.Context, router *authmiddleware.MsgServiceRouter, proposal group.Proposal, groupPolicyAcc sdk.AccAddress) ([]sdk.Result, error) { +func (s Keeper) doExecuteMsgs(ctx sdk.Context, router *baseapp.MsgServiceRouter, proposal group.Proposal, groupPolicyAcc sdk.AccAddress) ([]sdk.Result, error) { // Ensure it's not too late to execute the messages. // After https://github.com/cosmos/cosmos-sdk/issues/11245, proposals should // be pruned automatically, so this function should not even be called, as @@ -21,7 +23,10 @@ func (s Keeper) doExecuteMsgs(ctx sdk.Context, router *authmiddleware.MsgService return nil, grouperrors.ErrExpired.Wrapf("proposal expired on %s", expiryDate) } - msgs := proposal.GetMsgs() + msgs, err := proposal.GetMsgs() + if err != nil { + return nil, err + } results := make([]sdk.Result, len(msgs)) if err := ensureMsgAuthZ(msgs, groupPolicyAcc); err != nil { @@ -34,21 +39,29 @@ func (s Keeper) doExecuteMsgs(ctx sdk.Context, router *authmiddleware.MsgService } r, err := handler(ctx, msg) if err != nil { - return nil, errors.Wrapf(err, "message %q at position %d", msg, i) + return nil, errors.Wrapf(err, "message %s at position %d", sdk.MsgTypeURL(msg), i) } - if r != nil { - results[i] = *r + // Handler should always return non-nil sdk.Result. + if r == nil { + return nil, fmt.Errorf("got nil sdk.Result for message %q at position %d", msg, i) } + + results[i] = *r } return results, nil } -// ensureMsgAuthZ checks that if a message requires signers that all of them are equal to the given account address of group policy. +// ensureMsgAuthZ checks that if a message requires signers that all of them +// are equal to the given account address of group policy. func ensureMsgAuthZ(msgs []sdk.Msg, groupPolicyAcc sdk.AccAddress) error { for i := range msgs { + // In practice, GetSigners() should return a non-empty array without + // duplicates, so the code below is equivalent to: + // `msgs[i].GetSigners()[0] == groupPolicyAcc` + // but we prefer to loop through all GetSigners just to be sure. for _, acct := range msgs[i].GetSigners() { if !groupPolicyAcc.Equals(acct) { - return errors.Wrap(errors.ErrUnauthorized, "msg does not have group policy authorization") + return errors.Wrapf(errors.ErrUnauthorized, "msg does not have group policy authorization; expected %s, got %s", groupPolicyAcc.String(), acct.String()) } } } diff --git a/x/group/module/abci_test.go b/x/group/module/abci_test.go index ba4b31298692..fd298c14b54d 100644 --- a/x/group/module/abci_test.go +++ b/x/group/module/abci_test.go @@ -26,7 +26,7 @@ func TestEndBlockerPruning(t *testing.T) { addr3 := addrs[2] // Initial group, group policy and balance setup - members := []group.Member{ + members := []group.MemberRequest{ {Address: addr1.String(), Weight: "1"}, {Address: addr2.String(), Weight: "2"}, } @@ -34,9 +34,16 @@ func TestEndBlockerPruning(t *testing.T) { Admin: addr1.String(), Members: members, }) + require.NoError(t, err) + groupRes2, err := app.GroupKeeper.CreateGroup(ctx, &group.MsgCreateGroup{ + Admin: addr2.String(), + Members: members, + }) require.NoError(t, err) + groupID := groupRes.GroupId + groupID2 := groupRes2.GroupId policy := group.NewThresholdDecisionPolicy( "2", @@ -54,26 +61,54 @@ func TestEndBlockerPruning(t *testing.T) { policyRes, err := app.GroupKeeper.CreateGroupPolicy(ctx, policyReq) require.NoError(t, err) + policy2 := group.NewThresholdDecisionPolicy( + "1", + time.Second, + 0, + ) + + policyReq2 := &group.MsgCreateGroupPolicy{ + Admin: addr2.String(), + GroupId: groupID2, + } + + err = policyReq2.SetDecisionPolicy(policy2) + require.NoError(t, err) + policyRes2, err := app.GroupKeeper.CreateGroupPolicy(ctx, policyReq2) + require.NoError(t, err) + groupPolicyAddr, err := sdk.AccAddressFromBech32(policyRes.Address) require.NoError(t, err) require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, groupPolicyAddr, sdk.Coins{sdk.NewInt64Coin("test", 10000)})) + groupPolicyAddr2, err := sdk.AccAddressFromBech32(policyRes2.Address) + require.NoError(t, err) + require.NoError(t, testutil.FundAccount(app.BankKeeper, ctx, groupPolicyAddr2, sdk.Coins{sdk.NewInt64Coin("test", 10000)})) + + votingPeriod := policy.GetVotingPeriod() + msgSend1 := &banktypes.MsgSend{ FromAddress: groupPolicyAddr.String(), ToAddress: addr2.String(), Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)}, } + msgSend2 := &banktypes.MsgSend{ + FromAddress: groupPolicyAddr2.String(), + ToAddress: addr2.String(), + Amount: sdk.Coins{sdk.NewInt64Coin("test", 100)}, + } proposers := []string{addr2.String()} specs := map[string]struct { - srcBlockTime time.Time - setupProposal func(ctx context.Context) uint64 + setupProposal func(ctx sdk.Context) uint64 expErr bool expErrMsg string + newCtx sdk.Context expExecutorResult group.ProposalExecutorResult + expStatus group.ProposalStatus }{ "proposal pruned after executor result success": { - setupProposal: func(ctx context.Context) uint64 { + setupProposal: func(ctx sdk.Context) uint64 { msgs := []sdk.Msg{msgSend1} pID, err := submitProposalAndVote(app, ctx, msgs, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) require.NoError(t, err) @@ -85,10 +120,11 @@ func TestEndBlockerPruning(t *testing.T) { return pID }, expErrMsg: "load proposal: not found", + newCtx: ctx, expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_SUCCESS, }, "proposal with multiple messages pruned when executed with result success": { - setupProposal: func(ctx context.Context) uint64 { + setupProposal: func(ctx sdk.Context) uint64 { msgs := []sdk.Msg{msgSend1, msgSend1} pID, err := submitProposalAndVote(app, ctx, msgs, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) require.NoError(t, err) @@ -100,10 +136,11 @@ func TestEndBlockerPruning(t *testing.T) { return pID }, expErrMsg: "load proposal: not found", + newCtx: ctx, expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_SUCCESS, }, "proposal not pruned when not executed and rejected": { - setupProposal: func(ctx context.Context) uint64 { + setupProposal: func(ctx sdk.Context) uint64 { msgs := []sdk.Msg{msgSend1} pID, err := submitProposalAndVote(app, ctx, msgs, proposers, groupPolicyAddr, group.VOTE_OPTION_NO) require.NoError(t, err) @@ -114,10 +151,12 @@ func TestEndBlockerPruning(t *testing.T) { return pID }, + newCtx: ctx, expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_NOT_RUN, + expStatus: group.PROPOSAL_STATUS_REJECTED, }, "open proposal is not pruned which must not fail ": { - setupProposal: func(ctx context.Context) uint64 { + setupProposal: func(ctx sdk.Context) uint64 { pID, err := submitProposal(app, ctx, []sdk.Msg{msgSend1}, proposers, groupPolicyAddr) require.NoError(t, err) _, err = app.GroupKeeper.Exec(ctx, &group.MsgExec{Executor: addr3.String(), ProposalId: pID}) @@ -127,10 +166,12 @@ func TestEndBlockerPruning(t *testing.T) { return pID }, + newCtx: ctx, expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_NOT_RUN, + expStatus: group.PROPOSAL_STATUS_SUBMITTED, }, "proposal not pruned with group policy modified before tally": { - setupProposal: func(ctx context.Context) uint64 { + setupProposal: func(ctx sdk.Context) uint64 { pID, err := submitProposal(app, ctx, []sdk.Msg{msgSend1}, proposers, groupPolicyAddr) require.NoError(t, err) _, err = app.GroupKeeper.UpdateGroupPolicyMetadata(ctx, &group.MsgUpdateGroupPolicyMetadata{ @@ -139,16 +180,18 @@ func TestEndBlockerPruning(t *testing.T) { }) require.NoError(t, err) _, err = app.GroupKeeper.Exec(ctx, &group.MsgExec{Executor: addr3.String(), ProposalId: pID}) - require.NoError(t, err) + require.Error(t, err) // since proposal with status Aborted cannot be executed sdkCtx := sdk.UnwrapSDKContext(ctx) require.NoError(t, testutil.FundAccount(app.BankKeeper, sdkCtx, groupPolicyAddr, sdk.Coins{sdk.NewInt64Coin("test", 10002)})) return pID }, + newCtx: ctx, expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_NOT_RUN, + expStatus: group.PROPOSAL_STATUS_ABORTED, }, "pruned when proposal is executable when failed before": { - setupProposal: func(ctx context.Context) uint64 { + setupProposal: func(ctx sdk.Context) uint64 { msgs := []sdk.Msg{msgSend1} pID, err := submitProposalAndVote(app, ctx, msgs, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) require.NoError(t, err) @@ -156,27 +199,109 @@ func TestEndBlockerPruning(t *testing.T) { require.NoError(t, err) return pID }, + newCtx: ctx, expErrMsg: "load proposal: not found", expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_SUCCESS, }, + "proposal with status withdrawn is pruned after voting period end": { + setupProposal: func(sdkCtx sdk.Context) uint64 { + pId, err := submitProposal(app, sdkCtx, []sdk.Msg{msgSend1}, proposers, groupPolicyAddr) + require.NoError(t, err) + _, err = app.GroupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{ + ProposalId: pId, + Address: proposers[0], + }) + require.NoError(t, err) + return pId + }, + newCtx: ctx.WithBlockTime(ctx.BlockTime().Add(votingPeriod).Add(time.Hour)), + expErrMsg: "load proposal: not found", + expStatus: group.PROPOSAL_STATUS_WITHDRAWN, + }, + "proposal with status withdrawn is not pruned (before voting period)": { + setupProposal: func(sdkCtx sdk.Context) uint64 { + pId, err := submitProposal(app, sdkCtx, []sdk.Msg{msgSend1}, proposers, groupPolicyAddr) + require.NoError(t, err) + _, err = app.GroupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{ + ProposalId: pId, + Address: proposers[0], + }) + require.NoError(t, err) + return pId + }, + newCtx: ctx, + expErrMsg: "", + expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_NOT_RUN, + expStatus: group.PROPOSAL_STATUS_WITHDRAWN, + }, + "proposal with status aborted is pruned after voting period end (due to updated group policy decision policy)": { + setupProposal: func(sdkCtx sdk.Context) uint64 { + pId, err := submitProposal(app, sdkCtx, []sdk.Msg{msgSend2}, proposers, groupPolicyAddr2) + require.NoError(t, err) + + policy := group.NewThresholdDecisionPolicy("3", time.Second, 0) + msg := &group.MsgUpdateGroupPolicyDecisionPolicy{ + Admin: addrs[1].String(), + GroupPolicyAddress: groupPolicyAddr2.String(), + } + err = msg.SetDecisionPolicy(policy) + require.NoError(t, err) + _, err = app.GroupKeeper.UpdateGroupPolicyDecisionPolicy(ctx, msg) + require.NoError(t, err) + + return pId + }, + newCtx: ctx.WithBlockTime(ctx.BlockTime().Add(votingPeriod).Add(time.Hour)), + expErrMsg: "load proposal: not found", + expStatus: group.PROPOSAL_STATUS_ABORTED, + expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_NOT_RUN, + }, + "proposal with status aborted is not pruned before voting period end (due to updated group policy)": { + setupProposal: func(sdkCtx sdk.Context) uint64 { + pId, err := submitProposal(app, sdkCtx, []sdk.Msg{msgSend2}, proposers, groupPolicyAddr2) + require.NoError(t, err) + + policy := group.NewThresholdDecisionPolicy("3", time.Second, 0) + msg := &group.MsgUpdateGroupPolicyDecisionPolicy{ + Admin: addrs[1].String(), + GroupPolicyAddress: groupPolicyAddr2.String(), + } + err = msg.SetDecisionPolicy(policy) + require.NoError(t, err) + _, err = app.GroupKeeper.UpdateGroupPolicyDecisionPolicy(ctx, msg) + require.NoError(t, err) + + return pId + }, + newCtx: ctx, + expErrMsg: "", + expStatus: group.PROPOSAL_STATUS_ABORTED, + expExecutorResult: group.PROPOSAL_EXECUTOR_RESULT_NOT_RUN, + }, } for msg, spec := range specs { spec := spec t.Run(msg, func(t *testing.T) { proposalID := spec.setupProposal(ctx) - module.EndBlocker(ctx, app.GroupKeeper) + module.EndBlocker(spec.newCtx, app.GroupKeeper) + if spec.expErrMsg != "" && spec.expExecutorResult != group.PROPOSAL_EXECUTOR_RESULT_SUCCESS { + _, err = app.GroupKeeper.Proposal(spec.newCtx, &group.QueryProposalRequest{ProposalId: proposalID}) + require.Error(t, err) + require.Contains(t, err.Error(), spec.expErrMsg) + return + } if spec.expExecutorResult == group.PROPOSAL_EXECUTOR_RESULT_SUCCESS { // Make sure proposal is deleted from state - _, err = app.GroupKeeper.Proposal(ctx, &group.QueryProposalRequest{ProposalId: proposalID}) + _, err = app.GroupKeeper.Proposal(spec.newCtx, &group.QueryProposalRequest{ProposalId: proposalID}) require.Contains(t, err.Error(), spec.expErrMsg) res, err := app.GroupKeeper.VotesByProposal(ctx, &group.QueryVotesByProposalRequest{ProposalId: proposalID}) require.NoError(t, err) require.Empty(t, res.GetVotes()) } else { // Check that proposal and votes exists - res, err := app.GroupKeeper.Proposal(ctx, &group.QueryProposalRequest{ProposalId: proposalID}) + res, err := app.GroupKeeper.Proposal(spec.newCtx, &group.QueryProposalRequest{ProposalId: proposalID}) require.NoError(t, err) _, err = app.GroupKeeper.VotesByProposal(ctx, &group.QueryVotesByProposalRequest{ProposalId: res.Proposal.Id}) require.NoError(t, err) @@ -185,20 +310,21 @@ func TestEndBlockerPruning(t *testing.T) { exp := group.ProposalExecutorResult_name[int32(spec.expExecutorResult)] got := group.ProposalExecutorResult_name[int32(res.Proposal.ExecutorResult)] assert.Equal(t, exp, got) + + require.Equal(t, res.GetProposal().Status, spec.expStatus) } }) } - } -func TestEndBlocker(t *testing.T) { +func TestEndBlockerTallying(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) addrs := simapp.AddTestAddrsIncremental(app, ctx, 4, sdk.NewInt(30000000)) // Initial group, group policy and balance setup - members := []group.Member{ + members := []group.MemberRequest{ {Address: addrs[1].String(), Weight: "1"}, {Address: addrs[2].String(), Weight: "2"}, } @@ -240,15 +366,14 @@ func TestEndBlocker(t *testing.T) { proposers := []string{addrs[2].String()} specs := map[string]struct { - preRun func(sdkCtx sdk.Context) uint64 - proposalId uint64 - admin string - expErrMsg string - newCtx sdk.Context - tallyRes group.TallyResult - expStatus group.ProposalStatus + preRun func(sdkCtx sdk.Context) uint64 + admin string + expErrMsg string + newCtx sdk.Context + tallyRes group.TallyResult + expStatus group.ProposalStatus }{ - "tally updated after voting power end": { + "tally updated after voting period end": { preRun: func(sdkCtx sdk.Context) uint64 { pId, err := submitProposal(app, sdkCtx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr) require.NoError(t, err) @@ -257,7 +382,7 @@ func TestEndBlocker(t *testing.T) { admin: proposers[0], newCtx: ctx.WithBlockTime(ctx.BlockTime().Add(votingPeriod).Add(time.Hour)), tallyRes: group.DefaultTallyResult(), - expStatus: group.PROPOSAL_STATUS_SUBMITTED, + expStatus: group.PROPOSAL_STATUS_REJECTED, }, "tally within voting period": { preRun: func(sdkCtx sdk.Context) uint64 { @@ -283,6 +408,24 @@ func TestEndBlocker(t *testing.T) { tallyRes: group.DefaultTallyResult(), expStatus: group.PROPOSAL_STATUS_SUBMITTED, }, + "tally after voting period (not passing)": { + preRun: func(sdkCtx sdk.Context) uint64 { + // `addrs[1]` has weight 1 + pId, err := submitProposalAndVote(app, ctx, []sdk.Msg{msgSend}, []string{addrs[1].String()}, groupPolicyAddr, group.VOTE_OPTION_YES) + require.NoError(t, err) + + return pId + }, + admin: proposers[0], + newCtx: ctx.WithBlockTime(ctx.BlockTime().Add(votingPeriod).Add(time.Hour)), + tallyRes: group.TallyResult{ + YesCount: "1", + NoCount: "0", + NoWithVetoCount: "0", + AbstainCount: "0", + }, + expStatus: group.PROPOSAL_STATUS_REJECTED, + }, "tally after voting period(with votes)": { preRun: func(sdkCtx sdk.Context) uint64 { pId, err := submitProposalAndVote(app, ctx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) @@ -300,14 +443,14 @@ func TestEndBlocker(t *testing.T) { }, expStatus: group.PROPOSAL_STATUS_ACCEPTED, }, - "tally of closed proposal": { + "tally of withdrawn proposal": { preRun: func(sdkCtx sdk.Context) uint64 { pId, err := submitProposal(app, sdkCtx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr) require.NoError(t, err) _, err = app.GroupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{ ProposalId: pId, - Address: groupPolicyAddr.String(), + Address: proposers[0], }) require.NoError(t, err) @@ -318,14 +461,14 @@ func TestEndBlocker(t *testing.T) { tallyRes: group.DefaultTallyResult(), expStatus: group.PROPOSAL_STATUS_WITHDRAWN, }, - "tally of closed proposal (with votes)": { + "tally of withdrawn proposal (with votes)": { preRun: func(sdkCtx sdk.Context) uint64 { pId, err := submitProposalAndVote(app, ctx, []sdk.Msg{msgSend}, proposers, groupPolicyAddr, group.VOTE_OPTION_YES) require.NoError(t, err) _, err = app.GroupKeeper.WithdrawProposal(ctx, &group.MsgWithdrawProposal{ ProposalId: pId, - Address: groupPolicyAddr.String(), + Address: proposers[0], }) require.NoError(t, err) @@ -361,9 +504,7 @@ func TestEndBlocker(t *testing.T) { } } -func submitProposal( - app *simapp.SimApp, ctx context.Context, msgs []sdk.Msg, - proposers []string, groupPolicyAddr sdk.AccAddress) (uint64, error) { +func submitProposal(app *simapp.SimApp, ctx context.Context, msgs []sdk.Msg, proposers []string, groupPolicyAddr sdk.AccAddress) (uint64, error) { proposalReq := &group.MsgSubmitProposal{ GroupPolicyAddress: groupPolicyAddr.String(), Proposers: proposers, @@ -383,7 +524,8 @@ func submitProposal( func submitProposalAndVote( app *simapp.SimApp, ctx context.Context, msgs []sdk.Msg, - proposers []string, groupPolicyAddr sdk.AccAddress, voteOption group.VoteOption) (uint64, error) { + proposers []string, groupPolicyAddr sdk.AccAddress, voteOption group.VoteOption, +) (uint64, error) { myProposalID, err := submitProposal(app, ctx, msgs, proposers, groupPolicyAddr) if err != nil { return 0, err diff --git a/x/group/module/module.go b/x/group/module/module.go index 086728422ed4..7b8baf8538bf 100644 --- a/x/group/module/module.go +++ b/x/group/module/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -97,10 +96,6 @@ func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { // RegisterLegacyAminoCodec registers the group module's types for the given codec. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} -// RegisterRESTRoutes registers the REST routes for the group module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(_ sdkclient.Context, _ *mux.Router) {} - // Name returns the group module's name. func (AppModule) Name() string { return group.ModuleName diff --git a/x/group/msgs.go b/x/group/msgs.go index b3e6bb60cb96..04d52903240b 100644 --- a/x/group/msgs.go +++ b/x/group/msgs.go @@ -1,10 +1,6 @@ package group import ( - "fmt" - - "github.com/cosmos/cosmos-sdk/codec/legacy" - proto "github.com/gogo/protobuf/proto" "github.com/cosmos/cosmos-sdk/codec/types" @@ -25,7 +21,7 @@ func (m MsgCreateGroup) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgCreateGroup) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgCreateGroup. @@ -44,19 +40,15 @@ func (m MsgCreateGroup) ValidateBasic() error { return sdkerrors.Wrap(err, "admin") } - return m.validateMembers() + return strictValidateMembers(m.Members) } -func (m MsgCreateGroup) validateMembers() error { - - err := validateMembers(m.Members) - if err != nil { - return err - } - return nil -} - -func (m Member) ValidateBasic() error { +// ValidateBasic performs stateless validation on a group member, such as +// making sure the address is well-formed, and the weight is non-negative. +// Note: in state, a member's weight MUST be positive. However, in some Msgs, +// it's possible to set a zero member weight, for example in +// MsgUpdateGroupMembers to denote that we're removing a member. +func (m MemberRequest) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.Address) if err != nil { return sdkerrors.Wrap(err, "address") @@ -81,7 +73,7 @@ func (m MsgUpdateGroupAdmin) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgUpdateGroupAdmin) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgUpdateGroupAdmin. @@ -131,7 +123,7 @@ func (m MsgUpdateGroupMetadata) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgUpdateGroupMetadata) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgUpdateGroupMetadata. @@ -147,7 +139,6 @@ func (m MsgUpdateGroupMetadata) GetSigners() []sdk.AccAddress { func (m MsgUpdateGroupMetadata) ValidateBasic() error { if m.GroupId == 0 { return sdkerrors.Wrap(errors.ErrEmpty, "group id") - } _, err := sdk.AccAddressFromBech32(m.Admin) if err != nil { @@ -173,7 +164,7 @@ func (m MsgUpdateGroupMembers) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgUpdateGroupMembers) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } var _ sdk.Msg = &MsgUpdateGroupMembers{} @@ -191,7 +182,6 @@ func (m MsgUpdateGroupMembers) GetSigners() []sdk.AccAddress { func (m MsgUpdateGroupMembers) ValidateBasic() error { if m.GroupId == 0 { return sdkerrors.Wrap(errors.ErrEmpty, "group id") - } _, err := sdk.AccAddressFromBech32(m.Admin) if err != nil { @@ -201,7 +191,7 @@ func (m MsgUpdateGroupMembers) ValidateBasic() error { if len(m.MemberUpdates) == 0 { return sdkerrors.Wrap(errors.ErrEmpty, "member updates") } - members := Members{Members: m.MemberUpdates} + members := MemberRequests{Members: m.MemberUpdates} if err := members.ValidateBasic(); err != nil { return sdkerrors.Wrap(err, "members") } @@ -212,16 +202,18 @@ func (m *MsgUpdateGroupMembers) GetGroupID() uint64 { return m.GroupId } -var _ sdk.Msg = &MsgCreateGroupWithPolicy{} -var _ types.UnpackInterfacesMessage = MsgCreateGroupWithPolicy{} +var ( + _ sdk.Msg = &MsgCreateGroupWithPolicy{} + _ types.UnpackInterfacesMessage = MsgCreateGroupWithPolicy{} +) // NewMsgCreateGroupWithPolicy creates a new MsgCreateGroupWithPolicy. -func NewMsgCreateGroupWithPolicy(admin string, members []Member, group_metadata string, group_policy_metadata string, groupPolicyAsAdmin bool, decisionPolicy DecisionPolicy) (*MsgCreateGroupWithPolicy, error) { +func NewMsgCreateGroupWithPolicy(admin string, members []MemberRequest, groupMetadata string, groupPolicyMetadata string, groupPolicyAsAdmin bool, decisionPolicy DecisionPolicy) (*MsgCreateGroupWithPolicy, error) { m := &MsgCreateGroupWithPolicy{ Admin: admin, Members: members, - GroupMetadata: group_metadata, - GroupPolicyMetadata: group_policy_metadata, + GroupMetadata: groupMetadata, + GroupPolicyMetadata: groupPolicyMetadata, GroupPolicyAsAdmin: groupPolicyAsAdmin, } err := m.SetDecisionPolicy(decisionPolicy) @@ -231,20 +223,16 @@ func NewMsgCreateGroupWithPolicy(admin string, members []Member, group_metadata return m, nil } -func (m *MsgCreateGroupWithPolicy) GetDecisionPolicy() DecisionPolicy { +func (m *MsgCreateGroupWithPolicy) GetDecisionPolicy() (DecisionPolicy, error) { decisionPolicy, ok := m.DecisionPolicy.GetCachedValue().(DecisionPolicy) if !ok { - return nil + return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (DecisionPolicy)(nil), m.DecisionPolicy.GetCachedValue()) } - return decisionPolicy + return decisionPolicy, nil } func (m *MsgCreateGroupWithPolicy) SetDecisionPolicy(decisionPolicy DecisionPolicy) error { - msg, ok := decisionPolicy.(proto.Message) - if !ok { - return sdkerrors.ErrInvalidType.Wrapf("can't proto marshal %T", msg) - } - any, err := types.NewAnyWithValue(msg) + any, err := types.NewAnyWithValue(decisionPolicy) if err != nil { return err } @@ -270,7 +258,7 @@ func (m MsgCreateGroupWithPolicy) Type() string { // GetSignBytes Implements Msg. func (m MsgCreateGroupWithPolicy) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgCreateGroupWithPolicy. @@ -288,24 +276,15 @@ func (m MsgCreateGroupWithPolicy) ValidateBasic() error { if err != nil { return sdkerrors.Wrap(err, "admin") } - policy := m.GetDecisionPolicy() - if policy == nil { - return sdkerrors.Wrap(errors.ErrEmpty, "decision policy") + policy, err := m.GetDecisionPolicy() + if err != nil { + return sdkerrors.Wrap(err, "decision policy") } if err := policy.ValidateBasic(); err != nil { return sdkerrors.Wrap(err, "decision policy") } - return m.validateMembers() -} - -func (m MsgCreateGroupWithPolicy) validateMembers() error { - - err := validateMembers(m.Members) - if err != nil { - return err - } - return nil + return strictValidateMembers(m.Members) } var _ sdk.Msg = &MsgCreateGroupPolicy{} @@ -320,7 +299,7 @@ func (m MsgCreateGroupPolicy) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgCreateGroupPolicy) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgCreateGroupPolicy. @@ -342,9 +321,9 @@ func (m MsgCreateGroupPolicy) ValidateBasic() error { return sdkerrors.Wrap(errors.ErrEmpty, "group id") } - policy := m.GetDecisionPolicy() - if policy == nil { - return sdkerrors.Wrap(errors.ErrEmpty, "decision policy") + policy, err := m.GetDecisionPolicy() + if err != nil { + return sdkerrors.Wrap(err, "decision policy") } if err := policy.ValidateBasic(); err != nil { @@ -365,7 +344,7 @@ func (m MsgUpdateGroupPolicyAdmin) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgUpdateGroupPolicyAdmin) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgUpdateGroupPolicyAdmin. @@ -400,10 +379,13 @@ func (m MsgUpdateGroupPolicyAdmin) ValidateBasic() error { return nil } -var _ sdk.Msg = &MsgUpdateGroupPolicyDecisionPolicy{} -var _ types.UnpackInterfacesMessage = MsgUpdateGroupPolicyDecisionPolicy{} +var ( + _ sdk.Msg = &MsgUpdateGroupPolicyDecisionPolicy{} + _ types.UnpackInterfacesMessage = MsgUpdateGroupPolicyDecisionPolicy{} +) -func NewMsgUpdateGroupPolicyDecisionPolicyRequest(admin sdk.AccAddress, address sdk.AccAddress, decisionPolicy DecisionPolicy) (*MsgUpdateGroupPolicyDecisionPolicy, error) { +// NewMsgUpdateGroupPolicyDecisionPolicy creates a new MsgUpdateGroupPolicyDecisionPolicy. +func NewMsgUpdateGroupPolicyDecisionPolicy(admin sdk.AccAddress, address sdk.AccAddress, decisionPolicy DecisionPolicy) (*MsgUpdateGroupPolicyDecisionPolicy, error) { m := &MsgUpdateGroupPolicyDecisionPolicy{ Admin: admin.String(), GroupPolicyAddress: address.String(), @@ -440,7 +422,7 @@ func (m MsgUpdateGroupPolicyDecisionPolicy) Type() string { // GetSignBytes Implements Msg. func (m MsgUpdateGroupPolicyDecisionPolicy) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgUpdateGroupPolicyDecisionPolicy. @@ -464,9 +446,9 @@ func (m MsgUpdateGroupPolicyDecisionPolicy) ValidateBasic() error { return sdkerrors.Wrap(err, "group policy") } - policy := m.GetDecisionPolicy() - if policy == nil { - return sdkerrors.Wrap(errors.ErrEmpty, "decision policy") + policy, err := m.GetDecisionPolicy() + if err != nil { + return sdkerrors.Wrap(err, "decision policy") } if err := policy.ValidateBasic(); err != nil { @@ -476,12 +458,13 @@ func (m MsgUpdateGroupPolicyDecisionPolicy) ValidateBasic() error { return nil } -func (m *MsgUpdateGroupPolicyDecisionPolicy) GetDecisionPolicy() DecisionPolicy { +func (m *MsgUpdateGroupPolicyDecisionPolicy) GetDecisionPolicy() (DecisionPolicy, error) { decisionPolicy, ok := m.DecisionPolicy.GetCachedValue().(DecisionPolicy) if !ok { - return nil + return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (DecisionPolicy)(nil), m.DecisionPolicy.GetCachedValue()) } - return decisionPolicy + + return decisionPolicy, nil } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces @@ -502,7 +485,7 @@ func (m MsgUpdateGroupPolicyMetadata) Type() string { return sdk.MsgTypeURL(&m) // GetSignBytes Implements Msg. func (m MsgUpdateGroupPolicyMetadata) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgUpdateGroupPolicyMetadata. @@ -529,8 +512,10 @@ func (m MsgUpdateGroupPolicyMetadata) ValidateBasic() error { return nil } -var _ sdk.Msg = &MsgCreateGroupPolicy{} -var _ types.UnpackInterfacesMessage = MsgCreateGroupPolicy{} +var ( + _ sdk.Msg = &MsgCreateGroupPolicy{} + _ types.UnpackInterfacesMessage = MsgCreateGroupPolicy{} +) // NewMsgCreateGroupPolicy creates a new MsgCreateGroupPolicy. func NewMsgCreateGroupPolicy(admin sdk.AccAddress, group uint64, metadata string, decisionPolicy DecisionPolicy) (*MsgCreateGroupPolicy, error) { @@ -558,20 +543,16 @@ func (m *MsgCreateGroupPolicy) GetMetadata() string { return m.Metadata } -func (m *MsgCreateGroupPolicy) GetDecisionPolicy() DecisionPolicy { +func (m *MsgCreateGroupPolicy) GetDecisionPolicy() (DecisionPolicy, error) { decisionPolicy, ok := m.DecisionPolicy.GetCachedValue().(DecisionPolicy) if !ok { - return nil + return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (DecisionPolicy)(nil), m.DecisionPolicy.GetCachedValue()) } - return decisionPolicy + return decisionPolicy, nil } func (m *MsgCreateGroupPolicy) SetDecisionPolicy(decisionPolicy DecisionPolicy) error { - msg, ok := decisionPolicy.(proto.Message) - if !ok { - return fmt.Errorf("can't proto marshal %T", msg) - } - any, err := types.NewAnyWithValue(msg) + any, err := types.NewAnyWithValue(decisionPolicy) if err != nil { return err } @@ -587,8 +568,8 @@ func (m MsgCreateGroupPolicy) UnpackInterfaces(unpacker types.AnyUnpacker) error var _ sdk.Msg = &MsgSubmitProposal{} -// NewMsgSubmitProposalRequest creates a new MsgSubmitProposal. -func NewMsgSubmitProposalRequest(address string, proposers []string, msgs []sdk.Msg, metadata string, exec Exec) (*MsgSubmitProposal, error) { +// NewMsgSubmitProposal creates a new MsgSubmitProposal. +func NewMsgSubmitProposal(address string, proposers []string, msgs []sdk.Msg, metadata string, exec Exec) (*MsgSubmitProposal, error) { m := &MsgSubmitProposal{ GroupPolicyAddress: address, Proposers: proposers, @@ -612,23 +593,22 @@ func (m MsgSubmitProposal) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgSubmitProposal) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgSubmitProposal. func (m MsgSubmitProposal) GetSigners() []sdk.AccAddress { - addrs := make([]sdk.AccAddress, len(m.Proposers)) - for i, proposer := range m.Proposers { - addr, err := sdk.AccAddressFromBech32(proposer) - if err != nil { - panic(err) - } - addrs[i] = addr + addrs, err := m.getProposerAccAddresses() + if err != nil { + panic(err) } + return addrs } -// ValidateBasic does a sanity check on the provided data +// ValidateBasic does a sanity check on the provided proposal, such as +// verifying proposer addresses, and performing ValidateBasic on each +// individual `sdk.Msg`. func (m MsgSubmitProposal) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(m.GroupPolicyAddress) if err != nil { @@ -638,19 +618,21 @@ func (m MsgSubmitProposal) ValidateBasic() error { if len(m.Proposers) == 0 { return sdkerrors.Wrap(errors.ErrEmpty, "proposers") } - addrs := make([]sdk.AccAddress, len(m.Proposers)) - for i, proposer := range m.Proposers { - addr, err := sdk.AccAddressFromBech32(proposer) - if err != nil { - return sdkerrors.Wrap(err, "proposers") - } - addrs[i] = addr + + addrs, err := m.getProposerAccAddresses() + if err != nil { + return sdkerrors.Wrap(err, "group proposers") } - if err := AccAddresses(addrs).ValidateBasic(); err != nil { + + if err := accAddresses(addrs).ValidateBasic(); err != nil { return sdkerrors.Wrap(err, "proposers") } - msgs := m.GetMsgs() + msgs, err := m.GetMsgs() + if err != nil { + return err + } + for i, msg := range msgs { if err := msg.ValidateBasic(); err != nil { return sdkerrors.Wrapf(err, "msg %d", i) @@ -659,6 +641,20 @@ func (m MsgSubmitProposal) ValidateBasic() error { return nil } +// getProposerAccAddresses returns the proposers as `[]sdk.AccAddress`. +func (m *MsgSubmitProposal) getProposerAccAddresses() ([]sdk.AccAddress, error) { + addrs := make([]sdk.AccAddress, len(m.Proposers)) + for i, proposer := range m.Proposers { + addr, err := sdk.AccAddressFromBech32(proposer) + if err != nil { + return nil, sdkerrors.Wrap(err, "proposers") + } + addrs[i] = addr + } + + return addrs, nil +} + // SetMsgs packs msgs into Any's func (m *MsgSubmitProposal) SetMsgs(msgs []sdk.Msg) error { anys, err := tx.SetMsgs(msgs) @@ -670,12 +666,8 @@ func (m *MsgSubmitProposal) SetMsgs(msgs []sdk.Msg) error { } // GetMsgs unpacks m.Messages Any's into sdk.Msg's -func (m MsgSubmitProposal) GetMsgs() []sdk.Msg { - msgs, err := tx.GetMsgs(m.Messages, "proposal") - if err != nil { - panic(err) - } - return msgs +func (m MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) { + return tx.GetMsgs(m.Messages, "proposal") } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces @@ -693,7 +685,7 @@ func (m MsgWithdrawProposal) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgWithdrawProposal) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgWithdrawProposal. @@ -731,7 +723,7 @@ func (m MsgVote) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgVote) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgVote. @@ -773,7 +765,7 @@ func (m MsgExec) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg. func (m MsgExec) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgExec. @@ -809,7 +801,7 @@ func (m MsgLeaveGroup) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes Implements Msg func (m MsgLeaveGroup) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // GetSigners returns the expected signers for a MsgLeaveGroup @@ -818,6 +810,7 @@ func (m MsgLeaveGroup) GetSigners() []sdk.AccAddress { if err != nil { panic(err) } + return []sdk.AccAddress{signer} } @@ -834,24 +827,19 @@ func (m MsgLeaveGroup) ValidateBasic() error { return nil } -func validateMembers(members []Member) error { - index := make(map[string]struct{}, len(members)) - for i := range members { - member := members[i] - _, err := sdk.AccAddressFromBech32(member.Address) - if err != nil { - return sdkerrors.Wrap(err, "address") - } +// strictValidateMembers performs ValidateBasic on Members, but also checks +// that all members weights are positive (whereas `Members{members}.ValidateBasic()` +// only checks that they are non-negative. +func strictValidateMembers(members []MemberRequest) error { + err := MemberRequests{members}.ValidateBasic() + if err != nil { + return err + } - if _, err := math.NewPositiveDecFromString(member.Weight); err != nil { + for _, m := range members { + if _, err := math.NewPositiveDecFromString(m.Weight); err != nil { return sdkerrors.Wrap(err, "weight") } - - addr := member.Address - if _, exists := index[addr]; exists { - return sdkerrors.Wrapf(errors.ErrDuplicate, "address: %s", addr) - } - index[addr] = struct{}{} } return nil diff --git a/x/group/msgs_test.go b/x/group/msgs_test.go index 03e63ecc2ffd..5242f6ca79b9 100644 --- a/x/group/msgs_test.go +++ b/x/group/msgs_test.go @@ -38,7 +38,7 @@ func TestMsgCreateGroup(t *testing.T) { "invalid member address", &group.MsgCreateGroup{ Admin: admin.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: "invalid address", }, @@ -51,7 +51,7 @@ func TestMsgCreateGroup(t *testing.T) { "negitive member's weight not allowed", &group.MsgCreateGroup{ Admin: admin.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: member1.String(), Weight: "-1", @@ -59,13 +59,13 @@ func TestMsgCreateGroup(t *testing.T) { }, }, true, - "expected a positive decimal", + "expected a non-negative decimal", }, { "zero member's weight not allowed", &group.MsgCreateGroup{ Admin: admin.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: member1.String(), Weight: "0", @@ -79,7 +79,7 @@ func TestMsgCreateGroup(t *testing.T) { "duplicate member not allowed", &group.MsgCreateGroup{ Admin: admin.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: member1.String(), Weight: "1", @@ -99,7 +99,7 @@ func TestMsgCreateGroup(t *testing.T) { "valid test case with single member", &group.MsgCreateGroup{ Admin: admin.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: member1.String(), Weight: "1", @@ -114,7 +114,7 @@ func TestMsgCreateGroup(t *testing.T) { "minimum fields", &group.MsgCreateGroup{ Admin: admin.String(), - Members: []group.Member{}, + Members: []group.MemberRequest{}, }, false, "", @@ -123,7 +123,7 @@ func TestMsgCreateGroup(t *testing.T) { "valid test case with multiple members", &group.MsgCreateGroup{ Admin: admin.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: member1.String(), Weight: "1", @@ -303,7 +303,7 @@ func TestMsgUpdateGroupMembers(t *testing.T) { &group.MsgUpdateGroupMembers{ GroupId: 1, Admin: admin.String(), - MemberUpdates: []group.Member{}, + MemberUpdates: []group.MemberRequest{}, }, true, "member updates: value is empty", @@ -313,7 +313,7 @@ func TestMsgUpdateGroupMembers(t *testing.T) { &group.MsgUpdateGroupMembers{ GroupId: 1, Admin: admin.String(), - MemberUpdates: []group.Member{ + MemberUpdates: []group.MemberRequest{ { Address: member1.String(), Weight: "1", @@ -329,7 +329,7 @@ func TestMsgUpdateGroupMembers(t *testing.T) { &group.MsgUpdateGroupMembers{ GroupId: 1, Admin: admin.String(), - MemberUpdates: []group.Member{ + MemberUpdates: []group.MemberRequest{ { Address: member1.String(), Weight: "0", @@ -368,7 +368,7 @@ func TestMsgCreateGroupWithPolicy(t *testing.T) { func() *group.MsgCreateGroupWithPolicy { admin := "admin" policy := group.NewThresholdDecisionPolicy("1", time.Second, 0) - members := []group.Member{ + members := []group.MemberRequest{ { Address: member1.String(), Weight: "1", @@ -386,7 +386,7 @@ func TestMsgCreateGroupWithPolicy(t *testing.T) { "invalid member address", func() *group.MsgCreateGroupWithPolicy { policy := group.NewThresholdDecisionPolicy("1", time.Second, 0) - members := []group.Member{ + members := []group.MemberRequest{ { Address: "invalid_address", Weight: "1", @@ -404,7 +404,7 @@ func TestMsgCreateGroupWithPolicy(t *testing.T) { "negative member's weight not allowed", func() *group.MsgCreateGroupWithPolicy { policy := group.NewThresholdDecisionPolicy("1", time.Second, 0) - members := []group.Member{ + members := []group.MemberRequest{ { Address: member1.String(), Weight: "-1", @@ -416,13 +416,13 @@ func TestMsgCreateGroupWithPolicy(t *testing.T) { return req }, true, - "expected a positive decimal", + "expected a non-negative decimal", }, { "zero member's weight not allowed", func() *group.MsgCreateGroupWithPolicy { policy := group.NewThresholdDecisionPolicy("1", time.Second, 0) - members := []group.Member{ + members := []group.MemberRequest{ { Address: member1.String(), Weight: "0", @@ -440,7 +440,7 @@ func TestMsgCreateGroupWithPolicy(t *testing.T) { "duplicate member not allowed", func() *group.MsgCreateGroupWithPolicy { policy := group.NewThresholdDecisionPolicy("1", time.Second, 0) - members := []group.Member{ + members := []group.MemberRequest{ { Address: member1.String(), Weight: "1", @@ -463,7 +463,7 @@ func TestMsgCreateGroupWithPolicy(t *testing.T) { "invalid threshold policy", func() *group.MsgCreateGroupWithPolicy { policy := group.NewThresholdDecisionPolicy("-1", time.Second, 0) - members := []group.Member{ + members := []group.MemberRequest{ { Address: member1.String(), Weight: "1", @@ -481,7 +481,7 @@ func TestMsgCreateGroupWithPolicy(t *testing.T) { "valid test case with single member", func() *group.MsgCreateGroupWithPolicy { policy := group.NewThresholdDecisionPolicy("1", time.Second, 0) - members := []group.Member{ + members := []group.MemberRequest{ { Address: member1.String(), Weight: "1", @@ -499,7 +499,7 @@ func TestMsgCreateGroupWithPolicy(t *testing.T) { "valid test case with multiple members", func() *group.MsgCreateGroupWithPolicy { policy := group.NewThresholdDecisionPolicy("1", time.Second, 0) - members := []group.Member{ + members := []group.MemberRequest{ { Address: member1.String(), Weight: "1", @@ -692,23 +692,23 @@ func TestMsgCreateGroupPolicy(t *testing.T) { func TestMsgUpdateGroupPolicyDecisionPolicy(t *testing.T) { validPolicy := group.NewThresholdDecisionPolicy("1", time.Second, 0) - msg1, err := group.NewMsgUpdateGroupPolicyDecisionPolicyRequest(admin, member1, validPolicy) + msg1, err := group.NewMsgUpdateGroupPolicyDecisionPolicy(admin, member1, validPolicy) require.NoError(t, err) invalidPolicy := group.NewThresholdDecisionPolicy("-1", time.Second, 0) - msg2, err := group.NewMsgUpdateGroupPolicyDecisionPolicyRequest(admin, member2, invalidPolicy) + msg2, err := group.NewMsgUpdateGroupPolicyDecisionPolicy(admin, member2, invalidPolicy) require.NoError(t, err) validPercentagePolicy := group.NewPercentageDecisionPolicy("0.7", time.Second, 0) - msg3, err := group.NewMsgUpdateGroupPolicyDecisionPolicyRequest(admin, member3, validPercentagePolicy) + msg3, err := group.NewMsgUpdateGroupPolicyDecisionPolicy(admin, member3, validPercentagePolicy) require.NoError(t, err) invalidPercentagePolicy := group.NewPercentageDecisionPolicy("-0.1", time.Second, 0) - msg4, err := group.NewMsgUpdateGroupPolicyDecisionPolicyRequest(admin, member4, invalidPercentagePolicy) + msg4, err := group.NewMsgUpdateGroupPolicyDecisionPolicy(admin, member4, invalidPercentagePolicy) require.NoError(t, err) invalidPercentagePolicy2 := group.NewPercentageDecisionPolicy("2", time.Second, 0) - msg5, err := group.NewMsgUpdateGroupPolicyDecisionPolicyRequest(admin, member5, invalidPercentagePolicy2) + msg5, err := group.NewMsgUpdateGroupPolicyDecisionPolicy(admin, member5, invalidPercentagePolicy2) require.NoError(t, err) testCases := []struct { diff --git a/x/group/proposal.go b/x/group/proposal.go index 9764a1da908c..3b3870af2829 100644 --- a/x/group/proposal.go +++ b/x/group/proposal.go @@ -6,12 +6,8 @@ import ( "github.com/cosmos/cosmos-sdk/types/tx" ) -func (p *Proposal) GetMsgs() []sdk.Msg { - msgs, err := tx.GetMsgs(p.Messages, "proposal") - if err != nil { - panic(err) - } - return msgs +func (p *Proposal) GetMsgs() ([]sdk.Msg, error) { + return tx.GetMsgs(p.Messages, "proposal") } func (p *Proposal) SetMsgs(msgs []sdk.Msg) error { diff --git a/x/group/simulation/genesis.go b/x/group/simulation/genesis.go index 59040a502f60..7f30a4fc7303 100644 --- a/x/group/simulation/genesis.go +++ b/x/group/simulation/genesis.go @@ -147,7 +147,6 @@ func getVoteOption(index int) group.VoteOption { // RandomizedGenState generates a random GenesisState for the group module. func RandomizedGenState(simState *module.SimulationState) { - // groups var groups []*group.GroupInfo simState.AppParams.GetOrGenerate( diff --git a/x/group/simulation/genesis_test.go b/x/group/simulation/genesis_test.go index cf7b1cda6733..f87a5eb18f13 100644 --- a/x/group/simulation/genesis_test.go +++ b/x/group/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -26,7 +27,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } @@ -42,5 +43,4 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, int(groupGenesis.ProposalSeq), len(simState.Accounts)) require.Len(t, groupGenesis.Proposals, len(simState.Accounts)) require.Len(t, groupGenesis.Votes, len(simState.Accounts)) - } diff --git a/x/group/simulation/operations.go b/x/group/simulation/operations.go index 1bb8c205b0d2..f541393771a3 100644 --- a/x/group/simulation/operations.go +++ b/x/group/simulation/operations.go @@ -81,7 +81,8 @@ const ( // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper, appCdc cdctypes.AnyUnpacker) simulation.WeightedOperations { + bk group.BankKeeper, k keeper.Keeper, appCdc cdctypes.AnyUnpacker, +) simulation.WeightedOperations { var ( weightMsgCreateGroup int weightMsgUpdateGroupAdmin int @@ -243,7 +244,8 @@ func WeightedOperations( // SimulateMsgCreateGroup generates a MsgCreateGroup with random values func SimulateMsgCreateGroup(ak group.AccountKeeper, bk group.BankKeeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { acc, _ := simtypes.RandomAcc(r, accounts) account := ak.GetAccount(ctx, acc.Address) accAddr := acc.Address.String() @@ -258,7 +260,7 @@ func SimulateMsgCreateGroup(ak group.AccountKeeper, bk group.BankKeeper) simtype msg := &group.MsgCreateGroup{Admin: accAddr, Members: members, Metadata: simtypes.RandStringOfLength(r, 10)} txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -284,7 +286,8 @@ func SimulateMsgCreateGroup(ak group.AccountKeeper, bk group.BankKeeper) simtype // SimulateMsgCreateGroupWithPolicy generates a MsgCreateGroupWithPolicy with random values func SimulateMsgCreateGroupWithPolicy(ak group.AccountKeeper, bk group.BankKeeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { acc, _ := simtypes.RandomAcc(r, accounts) account := ak.GetAccount(ctx, acc.Address) accAddr := acc.Address.String() @@ -316,7 +319,7 @@ func SimulateMsgCreateGroupWithPolicy(ak group.AccountKeeper, bk group.BankKeepe } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -342,7 +345,8 @@ func SimulateMsgCreateGroupWithPolicy(ak group.AccountKeeper, bk group.BankKeepe // SimulateMsgCreateGroupPolicy generates a NewMsgCreateGroupPolicy with random values func SimulateMsgCreateGroupPolicy(ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgCreateGroupPolicy, ""), nil, err @@ -374,7 +378,7 @@ func SimulateMsgCreateGroupPolicy(ak group.AccountKeeper, bk group.BankKeeper, k } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -401,7 +405,8 @@ func SimulateMsgCreateGroupPolicy(ak group.AccountKeeper, bk group.BankKeeper, k // SimulateMsgSubmitProposal generates a NewMsgSubmitProposal with random values func SimulateMsgSubmitProposal(ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { g, groupPolicy, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgSubmitProposal, ""), nil, err @@ -416,7 +421,10 @@ func SimulateMsgSubmitProposal(ak group.AccountKeeper, bk group.BankKeeper, k ke groupPolicyAddr := groupPolicy.Address // Return a no-op if we know the proposal cannot be created - policy := groupPolicy.GetDecisionPolicy() + policy, err := groupPolicy.GetDecisionPolicy() + if err != nil { + return simtypes.NoOpMsg(group.ModuleName, TypeMsgSubmitProposal, ""), nil, nil + } err = policy.Validate(*g, group.DefaultConfig()) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgSubmitProposal, ""), nil, nil @@ -445,7 +453,7 @@ func SimulateMsgSubmitProposal(ak group.AccountKeeper, bk group.BankKeeper, k ke } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -471,7 +479,8 @@ func SimulateMsgSubmitProposal(ak group.AccountKeeper, bk group.BankKeeper, k ke // SimulateMsgUpdateGroupAdmin generates a MsgUpdateGroupAdmin with random values func SimulateMsgUpdateGroupAdmin(ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupAdmin, ""), nil, err @@ -503,7 +512,7 @@ func SimulateMsgUpdateGroupAdmin(ak group.AccountKeeper, bk group.BankKeeper, k } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -529,7 +538,8 @@ func SimulateMsgUpdateGroupAdmin(ak group.AccountKeeper, bk group.BankKeeper, k // SimulateMsgUpdateGroupMetadata generates a MsgUpdateGroupMetadata with random values func SimulateMsgUpdateGroupMetadata(ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupMetadata, ""), nil, err @@ -552,7 +562,7 @@ func SimulateMsgUpdateGroupMetadata(ak group.AccountKeeper, bk group.BankKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -577,9 +587,11 @@ func SimulateMsgUpdateGroupMetadata(ak group.AccountKeeper, bk group.BankKeeper, // SimulateMsgUpdateGroupMembers generates a MsgUpdateGroupMembers with random values func SimulateMsgUpdateGroupMembers(ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { + bk group.BankKeeper, k keeper.Keeper, +) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { groupInfo, acc, account, err := randomGroup(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupMembers, ""), nil, err @@ -602,7 +614,7 @@ func SimulateMsgUpdateGroupMembers(ak group.AccountKeeper, return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupMembers, "group members"), nil, err } - // set existing radnom group member weight to zero to remove from the group + // set existing random group member weight to zero to remove from the group existigMembers := res.Members if len(existigMembers) > 0 { memberToRemove := existigMembers[r.Intn(len(existigMembers))] @@ -618,7 +630,7 @@ func SimulateMsgUpdateGroupMembers(ak group.AccountKeeper, if !isDuplicateMember { m := memberToRemove.Member m.Weight = "0" - members = append(members, *m) + members = append(members, group.MemberToMemberRequest(m)) } } @@ -629,7 +641,7 @@ func SimulateMsgUpdateGroupMembers(ak group.AccountKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -655,7 +667,8 @@ func SimulateMsgUpdateGroupMembers(ak group.AccountKeeper, // SimulateMsgUpdateGroupPolicyAdmin generates a MsgUpdateGroupPolicyAdmin with random values func SimulateMsgUpdateGroupPolicyAdmin(ak group.AccountKeeper, bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupPolicyAdmin, ""), nil, err @@ -687,7 +700,7 @@ func SimulateMsgUpdateGroupPolicyAdmin(ak group.AccountKeeper, bk group.BankKeep } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -710,11 +723,13 @@ func SimulateMsgUpdateGroupPolicyAdmin(ak group.AccountKeeper, bk group.BankKeep } } -// // SimulateMsgUpdateGroupPolicyDecisionPolicy generates a NewMsgUpdateGroupPolicyDecisionPolicyRequest with random values +// // SimulateMsgUpdateGroupPolicyDecisionPolicy generates a NewMsgUpdateGroupPolicyDecisionPolicy with random values func SimulateMsgUpdateGroupPolicyDecisionPolicy(ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { + bk group.BankKeeper, k keeper.Keeper, +) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupPolicyDecisionPolicy, ""), nil, err @@ -735,7 +750,7 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy(ak group.AccountKeeper, return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupPolicyDecisionPolicy, fmt.Sprintf("fail to decide bech32 address: %s", err.Error())), nil, nil } - msg, err := group.NewMsgUpdateGroupPolicyDecisionPolicyRequest(acc.Address, groupPolicyBech32, &group.ThresholdDecisionPolicy{ + msg, err := group.NewMsgUpdateGroupPolicyDecisionPolicy(acc.Address, groupPolicyBech32, &group.ThresholdDecisionPolicy{ Threshold: fmt.Sprintf("%d", simtypes.RandIntBetween(r, 1, 10)), Windows: &group.DecisionPolicyWindows{ VotingPeriod: time.Second * time.Duration(simtypes.RandIntBetween(r, 100, 1000)), @@ -746,7 +761,7 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy(ak group.AccountKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -770,9 +785,11 @@ func SimulateMsgUpdateGroupPolicyDecisionPolicy(ak group.AccountKeeper, // // SimulateMsgUpdateGroupPolicyMetadata generates a MsgUpdateGroupPolicyMetadata with random values func SimulateMsgUpdateGroupPolicyMetadata(ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { + bk group.BankKeeper, k keeper.Keeper, +) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupPolicyMetadata, ""), nil, err @@ -795,7 +812,7 @@ func SimulateMsgUpdateGroupPolicyMetadata(ak group.AccountKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -820,9 +837,11 @@ func SimulateMsgUpdateGroupPolicyMetadata(ak group.AccountKeeper, // SimulateMsgWithdrawProposal generates a MsgWithdrawProposal with random values func SimulateMsgWithdrawProposal(ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { + bk group.BankKeeper, k keeper.Keeper, +) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { g, groupPolicy, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgWithdrawProposal, ""), nil, err @@ -837,7 +856,10 @@ func SimulateMsgWithdrawProposal(ak group.AccountKeeper, groupPolicyAddr := groupPolicy.Address ctx := sdk.WrapSDKContext(sdkCtx) - policy := groupPolicy.GetDecisionPolicy() + policy, err := groupPolicy.GetDecisionPolicy() + if err != nil { + return simtypes.NoOpMsg(group.ModuleName, TypeMsgWithdrawProposal, err.Error()), nil, nil + } err = policy.Validate(*g, group.DefaultConfig()) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgWithdrawProposal, err.Error()), nil, nil @@ -892,7 +914,7 @@ func SimulateMsgWithdrawProposal(ak group.AccountKeeper, } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -902,7 +924,6 @@ func SimulateMsgWithdrawProposal(ak group.AccountKeeper, []uint64{proposerAcc.GetSequence()}, proposer.PrivKey, ) - if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgUpdateGroupPolicyMetadata, "unable to generate mock tx"), nil, err } @@ -922,9 +943,11 @@ func SimulateMsgWithdrawProposal(ak group.AccountKeeper, // SimulateMsgVote generates a MsgVote with random values func SimulateMsgVote(ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { + bk group.BankKeeper, k keeper.Keeper, +) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { g, groupPolicy, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(group.ModuleName, TypeMsgVote, ""), nil, err @@ -996,7 +1019,7 @@ func SimulateMsgVote(ak group.AccountKeeper, Metadata: simtypes.RandStringOfLength(r, 10), } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -1025,9 +1048,11 @@ func SimulateMsgVote(ak group.AccountKeeper, // // SimulateMsgExec generates a MsgExec with random values func SimulateMsgExec(ak group.AccountKeeper, - bk group.BankKeeper, k keeper.Keeper) simtypes.Operation { + bk group.BankKeeper, k keeper.Keeper, +) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { _, groupPolicy, acc, account, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts) if err != nil { return simtypes.NoOpMsg(TypeMsgExec, TypeMsgExec, ""), nil, err @@ -1072,7 +1097,7 @@ func SimulateMsgExec(ak group.AccountKeeper, Executor: acc.Address.String(), } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{&msg}, fees, @@ -1101,8 +1126,8 @@ func SimulateMsgExec(ak group.AccountKeeper, // SimulateMsgLeaveGroup generates a MsgLeaveGroup with random values func SimulateMsgLeaveGroup(k keeper.Keeper, ak group.AccountKeeper, bk group.BankKeeper) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - + r *rand.Rand, app *baseapp.BaseApp, sdkCtx sdk.Context, accounts []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { ctx := sdk.WrapSDKContext(sdkCtx) groupInfo, policyInfo, _, _, err := randomGroupPolicy(r, k, ak, sdkCtx, accounts) if err != nil { @@ -1134,7 +1159,7 @@ func SimulateMsgLeaveGroup(k keeper.Keeper, ak group.AccountKeeper, bk group.Ban } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, @@ -1158,7 +1183,8 @@ func SimulateMsgLeaveGroup(k keeper.Keeper, ak group.AccountKeeper, bk group.Ban } func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, - ctx sdk.Context, accounts []simtypes.Account) (groupInfo *group.GroupInfo, acc simtypes.Account, account authtypes.AccountI, err error) { + ctx sdk.Context, accounts []simtypes.Account, +) (groupInfo *group.GroupInfo, acc simtypes.Account, account authtypes.AccountI, err error) { groupID := k.GetGroupSequence(ctx) switch { @@ -1195,7 +1221,8 @@ func randomGroup(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, } func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, - ctx sdk.Context, accounts []simtypes.Account) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account authtypes.AccountI, err error) { + ctx sdk.Context, accounts []simtypes.Account, +) (groupInfo *group.GroupInfo, groupPolicyInfo *group.GroupPolicyInfo, acc simtypes.Account, account authtypes.AccountI, err error) { groupInfo, _, _, err = randomGroup(r, k, ak, ctx, accounts) if err != nil { return nil, nil, simtypes.Account{}, nil, err @@ -1226,7 +1253,8 @@ func randomGroupPolicy(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, } func randomMember(r *rand.Rand, k keeper.Keeper, ak group.AccountKeeper, - ctx context.Context, accounts []simtypes.Account, groupID uint64) (acc simtypes.Account, account authtypes.AccountI, err error) { + ctx context.Context, accounts []simtypes.Account, groupID uint64, +) (acc simtypes.Account, account authtypes.AccountI, err error) { res, err := k.GroupMembers(ctx, &group.QueryGroupMembersRequest{ GroupId: groupID, }) @@ -1268,9 +1296,9 @@ func findAccount(accounts []simtypes.Account, addr string) (idx int) { return idx } -func genGroupMembers(r *rand.Rand, accounts []simtypes.Account) []group.Member { +func genGroupMembers(r *rand.Rand, accounts []simtypes.Account) []group.MemberRequest { if len(accounts) == 1 { - return []group.Member{ + return []group.MemberRequest{ { Address: accounts[0].Address.String(), Weight: fmt.Sprintf("%d", simtypes.RandIntBetween(r, 1, 10)), @@ -1285,10 +1313,10 @@ func genGroupMembers(r *rand.Rand, accounts []simtypes.Account) []group.Member { } membersLen := simtypes.RandIntBetween(r, 1, max) - members := make([]group.Member, membersLen) + members := make([]group.MemberRequest, membersLen) for i := 0; i < membersLen; i++ { - members[i] = group.Member{ + members[i] = group.MemberRequest{ Address: accounts[i].Address.String(), Weight: fmt.Sprintf("%d", simtypes.RandIntBetween(r, 1, 10)), Metadata: simtypes.RandStringOfLength(r, 10), diff --git a/x/group/simulation/operations_test.go b/x/group/simulation/operations_test.go index 86c07fd95fe7..90476db47fd6 100644 --- a/x/group/simulation/operations_test.go +++ b/x/group/simulation/operations_test.go @@ -5,8 +5,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/stretchr/testify/suite" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -117,7 +115,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroup() { suite.Require().NoError(err) var msg group.MsgCreateGroup - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(acc.Address.String(), msg.Admin) @@ -146,7 +144,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroupWithPolicy() { suite.Require().NoError(err) var msg group.MsgCreateGroupWithPolicy - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(acc.Address.String(), msg.Admin) @@ -164,7 +162,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroupPolicy() { _, err := suite.app.GroupKeeper.CreateGroup(sdk.WrapSDKContext(suite.ctx), &group.MsgCreateGroup{ Admin: acc.Address.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: acc.Address.String(), Weight: "1", @@ -188,7 +186,7 @@ func (suite *SimTestSuite) TestSimulateCreateGroupPolicy() { suite.Require().NoError(err) var msg group.MsgCreateGroupPolicy - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(acc.Address.String(), msg.Admin) @@ -207,7 +205,7 @@ func (suite *SimTestSuite) TestSimulateSubmitProposal() { groupRes, err := suite.app.GroupKeeper.CreateGroup(ctx, &group.MsgCreateGroup{ Admin: acc.Address.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: acc.Address.String(), Weight: "1", @@ -241,7 +239,7 @@ func (suite *SimTestSuite) TestSimulateSubmitProposal() { suite.Require().NoError(err) var msg group.MsgSubmitProposal - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(groupPolicyRes.Address, msg.GroupPolicyAddress) @@ -261,7 +259,7 @@ func (suite *SimTestSuite) TestWithdrawProposal() { groupRes, err := suite.app.GroupKeeper.CreateGroup(ctx, &group.MsgCreateGroup{ Admin: addr, - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: addr, Weight: "1", @@ -282,7 +280,7 @@ func (suite *SimTestSuite) TestWithdrawProposal() { suite.Require().NoError(err) // setup a proposal - proposalReq, err := group.NewMsgSubmitProposalRequest(groupPolicyRes.Address, []string{addr}, []sdk.Msg{ + proposalReq, err := group.NewMsgSubmitProposal(groupPolicyRes.Address, []string{addr}, []sdk.Msg{ &banktypes.MsgSend{ FromAddress: groupPolicyRes.Address, ToAddress: addr, @@ -307,7 +305,7 @@ func (suite *SimTestSuite) TestWithdrawProposal() { suite.Require().NoError(err) var msg group.MsgWithdrawProposal - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(addr, msg.Address) @@ -327,7 +325,7 @@ func (suite *SimTestSuite) TestSimulateVote() { groupRes, err := suite.app.GroupKeeper.CreateGroup(ctx, &group.MsgCreateGroup{ Admin: addr, - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: addr, Weight: "1", @@ -349,7 +347,7 @@ func (suite *SimTestSuite) TestSimulateVote() { suite.Require().NoError(err) // setup a proposal - proposalReq, err := group.NewMsgSubmitProposalRequest(groupPolicyRes.Address, []string{addr}, []sdk.Msg{ + proposalReq, err := group.NewMsgSubmitProposal(groupPolicyRes.Address, []string{addr}, []sdk.Msg{ &banktypes.MsgSend{ FromAddress: groupPolicyRes.Address, ToAddress: addr, @@ -374,7 +372,7 @@ func (suite *SimTestSuite) TestSimulateVote() { suite.Require().NoError(err) var msg group.MsgVote - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(addr, msg.Voter) @@ -394,7 +392,7 @@ func (suite *SimTestSuite) TestSimulateExec() { groupRes, err := suite.app.GroupKeeper.CreateGroup(ctx, &group.MsgCreateGroup{ Admin: addr, - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: addr, Weight: "1", @@ -415,7 +413,7 @@ func (suite *SimTestSuite) TestSimulateExec() { suite.Require().NoError(err) // setup a proposal - proposalReq, err := group.NewMsgSubmitProposalRequest(groupPolicyRes.Address, []string{addr}, []sdk.Msg{ + proposalReq, err := group.NewMsgSubmitProposal(groupPolicyRes.Address, []string{addr}, []sdk.Msg{ &banktypes.MsgSend{ FromAddress: groupPolicyRes.Address, ToAddress: addr, @@ -449,7 +447,7 @@ func (suite *SimTestSuite) TestSimulateExec() { suite.Require().NoError(err) var msg group.MsgExec - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(addr, msg.Executor) @@ -467,7 +465,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupAdmin() { _, err := suite.app.GroupKeeper.CreateGroup(sdk.WrapSDKContext(suite.ctx), &group.MsgCreateGroup{ Admin: acc.Address.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: acc.Address.String(), Weight: "1", @@ -491,7 +489,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupAdmin() { suite.Require().NoError(err) var msg group.MsgUpdateGroupAdmin - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(acc.Address.String(), msg.Admin) @@ -509,7 +507,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMetadata() { _, err := suite.app.GroupKeeper.CreateGroup(sdk.WrapSDKContext(suite.ctx), &group.MsgCreateGroup{ Admin: acc.Address.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: acc.Address.String(), Weight: "1", @@ -533,7 +531,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMetadata() { suite.Require().NoError(err) var msg group.MsgUpdateGroupMetadata - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(acc.Address.String(), msg.Admin) @@ -551,7 +549,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMembers() { _, err := suite.app.GroupKeeper.CreateGroup(sdk.WrapSDKContext(suite.ctx), &group.MsgCreateGroup{ Admin: acc.Address.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: acc.Address.String(), Weight: "1", @@ -575,7 +573,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupMembers() { suite.Require().NoError(err) var msg group.MsgUpdateGroupMembers - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(acc.Address.String(), msg.Admin) @@ -594,7 +592,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyAdmin() { groupRes, err := suite.app.GroupKeeper.CreateGroup(ctx, &group.MsgCreateGroup{ Admin: acc.Address.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: acc.Address.String(), Weight: "1", @@ -628,7 +626,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyAdmin() { suite.Require().NoError(err) var msg group.MsgUpdateGroupPolicyAdmin - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(groupPolicyRes.Address, msg.GroupPolicyAddress) @@ -647,7 +645,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyDecisionPolicy() { groupRes, err := suite.app.GroupKeeper.CreateGroup(ctx, &group.MsgCreateGroup{ Admin: acc.Address.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: acc.Address.String(), Weight: "1", @@ -681,7 +679,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyDecisionPolicy() { suite.Require().NoError(err) var msg group.MsgUpdateGroupPolicyDecisionPolicy - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(groupPolicyRes.Address, msg.GroupPolicyAddress) @@ -700,7 +698,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyMetadata() { groupRes, err := suite.app.GroupKeeper.CreateGroup(ctx, &group.MsgCreateGroup{ Admin: acc.Address.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: acc.Address.String(), Weight: "1", @@ -734,7 +732,7 @@ func (suite *SimTestSuite) TestSimulateUpdateGroupPolicyMetadata() { suite.Require().NoError(err) var msg group.MsgUpdateGroupPolicyMetadata - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(groupPolicyRes.Address, msg.GroupPolicyAddress) @@ -758,7 +756,7 @@ func (suite *SimTestSuite) TestSimulateLeaveGroup() { groupRes, err := suite.app.GroupKeeper.CreateGroup(ctx, &group.MsgCreateGroup{ Admin: admin.Address.String(), - Members: []group.Member{ + Members: []group.MemberRequest{ { Address: member1.Address.String(), Weight: "1", @@ -800,7 +798,7 @@ func (suite *SimTestSuite) TestSimulateLeaveGroup() { suite.Require().NoError(err) var msg group.MsgLeaveGroup - err = legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + err = group.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().NoError(err) suite.Require().True(operationMsg.OK) suite.Require().Equal(groupRes.GroupId, msg.GroupId) diff --git a/x/group/spec/01_concepts.md b/x/group/spec/01_concepts.md index 0194f7184744..de930a6c1ad9 100644 --- a/x/group/spec/01_concepts.md +++ b/x/group/spec/01_concepts.md @@ -10,7 +10,8 @@ A group is simply an aggregation of accounts with associated weights. It is not an account and doesn't have a balance. It doesn't in and of itself have any sort of voting or decision weight. It does have an "administrator" which has the ability to add, remove and update members in the group. Note that a -group policy account could be an administrator of a group. +group policy account could be an administrator of a group, and that the +administrator doesn't necessarily have to be a member of the group. ## Group Policy @@ -30,16 +31,23 @@ A decision policy is the mechanism by which members of a group can vote on proposals, as well as the rules that dictate whether a proposal should pass or not based on its tally outcome. -All decision policies generally would have a mininum execution perdio and a +All decision policies generally would have a mininum execution period and a maximum voting window. The minimum execution period is the minimum amount of time -that must pass in order for a proposal to potentially be executed, and it may -be set to 0. The maximum voting window is the maximum time that a proposal may -be voted on before it is closed. +that must pass after submission in order for a proposal to potentially be executed, and it may +be set to 0. The maximum voting window is the maximum time after submission that a proposal may +be voted on before it is tallied. The chain developer also defines an app-wide maximum execution period, which is the maximum amount of time after a proposal's voting period end where users are allowed to execute a proposal. +The current group module comes shipped with two decision policies: threshold +and percentage. Any chain developer can extend upon these two, by creating +custom decision policies, as long as they adhere to the `DecisionPolicy` +interface: + ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/x/group/types.go#L23-L37 + ### Threshold decision policy A threshold decision policy defines a threshold of yes votes (based on a tally @@ -56,18 +64,33 @@ weights get updated. ## Proposal -Any member of a group can submit a proposal for a group policy account to decide upon. +Any member(s) of a group can submit a proposal for a group policy account to decide upon. A proposal consists of a set of messages that will be executed if the proposal passes as well as any metadata associated with the proposal. -## Voting +### Voting There are four choices to choose while voting - yes, no, abstain and veto. Not -all decision policies will support them. Votes can contain some optional metadata. +all decision policies will take the four choices into account. Votes can contain some optional metadata. In the current implementation, the voting window begins as soon as a proposal -is submitted. +is submitted, and the end is defined by the group policy's decision policy. + +### Withdrawing Proposals + +Proposals can be withdrawn any time before the voting period end, either by the +admin of the group policy or by one of the proposers. Once withdrawn, it is +marked as `PROPOSAL_STATUS_WITHDRAWN`, and no more voting or execution is +allowed on it. -## Tallying +### Aborted Proposals + +If the group policy is updated during the voting period of the proposal, then +the proposal is marked as `PROPOSAL_STATUS_ABORTED`, and no more voting or +execution is allowed on it. This is because the group policy defines the rules +of proposal voting and execution, so if those rules change during the lifecycle +of a proposal, then the proposal should be marked as stale. + +### Tallying Tallying is the counting of all votes on a proposal. It happens only once in the lifecycle of a proposal, but can be triggered by two factors, whichever @@ -80,22 +103,36 @@ happens first: - or on `EndBlock` when the proposal's voting period end just passed. If the tally result passes the decision policy's rules, then the proposal is -marked as `STATUS_CLOSED`, so no more voting is allowed anymore, and the tally -result is persisted to state. +marked as `PROPOSAL_STATUS_ACCEPTED`, or else it is marked as +`PROPOSAL_STATUS_REJECTED`. In any case, no more voting is allowed anymore, and the tally +result is persisted to state in the proposal's `FinalTallyResult`. -## Executing Proposals +### Executing Proposals Proposals are executed only when the tallying is done, and the group account's -decision policy allows the proposal to pass based on the tally outcome. +decision policy allows the proposal to pass based on the tally outcome. They +are marked by the status `PROPOSAL_STATUS_ACCEPTED`. Execution must happen +before a duration of `MaxExecutionPeriod` (set by the chain developer) after +each proposal's voting period end. Proposals will not be automatically executed by the chain in this current design, but rather a user must submit a `Msg/Exec` transaction to attempt to execute the -proposal based on the current votes and decision policy. +proposal based on the current votes and decision policy. Any user (not only the +group members) can execute proposals that have been accepted, and execution fees are +paid by the proposal executor. It's also possible to try to execute a proposal immediately on creation or on new votes using the `Exec` field of `Msg/SubmitProposal` and `Msg/Vote` requests. In the former case, proposers signatures are considered as yes votes. -For now, if the proposal can't be executed, it'll still be opened for new votes and -could be executed later on. +In these cases, if the proposal can't be executed (i.e. it didn't pass the +decision policy's rules), it will still be opened for new votes and +could be tallied and executed later on. + +A successful proposal execution will have its `ExecutorResult` marked as +`PROPOSAL_EXECUTOR_RESULT_SUCCESS`. The proposal will be automatically pruned +after execution. On the other hand, a failed proposal execution will be marked +as `PROPOSAL_EXECUTOR_RESULT_FAILURE`. Such a proposal can be re-executed +multiple times, until it expires after `MaxExecutionPeriod` after voting period +end. ## Pruning @@ -105,14 +142,15 @@ Votes are pruned: - either after a successful tally, i.e. a tally whose result passes the decision policy's rules, which can be trigged by a `Msg/Exec` or a - `Msg/{SubmitProposal,Vote}` with the `Exec` field, -- or on `EndBlock` right after the proposal's voting period end, + `Msg/{SubmitProposal,Vote}` with the `Exec` field set, +- or on `EndBlock` right after the proposal's voting period end. This applies to proposals with status `aborted` or `withdrawn` too. whichever happens first. Proposals are pruned: -- either after a successful proposal execution, +- on `EndBlock` whose proposal status is `withdrawn` or `aborted` on proposal's voting period end before tallying, +- and either after a successful proposal execution, - or on `EndBlock` right after the proposal's `voting_period_end` + `max_execution_period` (defined as an app-wide configuration) is passed, diff --git a/x/group/spec/03_messages.md b/x/group/spec/03_messages.md index dc526725046b..e6566ce802be 100644 --- a/x/group/spec/03_messages.md +++ b/x/group/spec/03_messages.md @@ -6,134 +6,154 @@ order: 3 ## Msg/CreateGroup -A new group can be created with the `MsgCreateGroup`, which has an admin address, a list of members and some optional metadata bytes. +A new group can be created with the `MsgCreateGroup`, which has an admin address, a list of members and some optional metadata. The metadata has a maximum length that is chosen by the app developer, and passed into the group keeper as a config. -+++ https://github.com/cosmos/cosmos-sdk/blob/6f58963e7f6ce820e9b33f02f06f7b96f6d2e347/proto/cosmos/group/v1beta1/tx.proto#L54-L65 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L65-L76 -It's expecting to fail if metadata length is greater than `MaxMetadataLen` config. +It's expected to fail if + +- metadata length is greater than `MaxMetadataLen` + config +- members are not correctly set (e.g. wrong address format, duplicates, or with 0 weight). ## Msg/UpdateGroupMembers Group members can be updated with the `UpdateGroupMembers`. -+++https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L74-L86 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L85-L98 In the list of `MemberUpdates`, an existing member can be removed by setting its weight to 0. -It's expecting to fail if the signer is not the admin of the group. +It's expected to fail if: + +- the signer is not the admin of the group. +- for any one of the associated group policies, if its decision policy's `Validate()` method fails against the updated group. ## Msg/UpdateGroupAdmin The `UpdateGroupAdmin` can be used to update a group admin. -+++ https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L91-L102 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L103-L115 -It's expecting to fail if the signer is not the admin of the group. +It's expected to fail if the signer is not the admin of the group. ## Msg/UpdateGroupMetadata The `UpdateGroupMetadata` can be used to update a group metadata. -+++ https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L107-L118 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L120-L132 -It's expecting to fail if: +It's expected to fail if: -* new metadata length is greater than `MaxMetadataLen` config. -* the signer is not the admin of the group. +- new metadata length is greater than `MaxMetadataLen` config. +- the signer is not the admin of the group. ## Msg/CreateGroupPolicy -A new group policy can be created with the `MsgCreateGroupPolicy`, which has an admin address, a group id, a decision policy and some optional metadata bytes. +A new group policy can be created with the `MsgCreateGroupPolicy`, which has an admin address, a group id, a decision policy and some optional metadata. + ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L141-L158 -+++ https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L127-L142 +It's expected to fail if: -It's expecting to fail if metadata length is greater than `MaxMetadataLen` config. +- the signer is not the admin of the group. +- metadata length is greater than `MaxMetadataLen` config. +- the decision policy's `Validate()` method doesn't pass against the group. ## Msg/CreateGroupWithPolicy -A new group with policy can be created with the `MsgCreateGroupWithPolicy`, which has an admin address, a list of members, a decision policy, a group policy as admin field to optionally set group and group policy admin with group policy address and some optional metadata bytes for group and group policy. +A new group with policy can be created with the `MsgCreateGroupWithPolicy`, which has an admin address, a list of members, a decision policy, a `group_policy_as_admin` field to optionally set group and group policy admin with group policy address and some optional metadata for group and group policy. -+++ https://github.com/cosmos/cosmos-sdk/blob/likhita/MsgCreateGroupWithPolicy/proto/cosmos/group/v1beta1/tx.proto#L167-L188 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L181-L202 -It's expecting to fail if group metadata or group policy metadata length is greater than some `MaxMetadataLength`. +It's expected to fail for the same reasons as `Msg/CreateGroup` and `Msg/CreateGroupPolicy`. ## Msg/UpdateGroupPolicyAdmin The `UpdateGroupPolicyAdmin` can be used to update a group policy admin. -+++ https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L151-L162 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L167-L179 -It's expecting to fail if the signer is not the admin of the group policy. +It's expected to fail if the signer is not the admin of the group policy. ## Msg/UpdateGroupPolicyDecisionPolicy The `UpdateGroupPolicyDecisionPolicy` can be used to update a decision policy. -+++ https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L167-L179 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L217-L231 -It's expecting to fail if the signer is not the admin of the group policy. +It's expected to fail if: + +- the signer is not the admin of the group policy. +- the new decision policy's `Validate()` method doesn't pass against the group. ## Msg/UpdateGroupPolicyMetadata The `UpdateGroupPolicyMetadata` can be used to update a group policy metadata. -+++ https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L184-L195 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L236-L248 -It's expecting to fail if: +It's expected to fail if: -* new metadata length is greater than `MaxMetadataLen` config. -* the signer is not the admin of the group. +- new metadata length is greater than `MaxMetadataLen` config. +- the signer is not the admin of the group. -## Msg/CreateProposal +## Msg/SubmitProposal -A new proposal can be created with the `MsgCreateProposal`, which has a group policy account address, a list of proposers addresses, a list of messages to execute if the proposal is accepted and some optional metadata bytes. +A new proposal can be created with the `MsgSubmitProposal`, which has a group policy account address, a list of proposers addresses, a list of messages to execute if the proposal is accepted and some optional metadata. An optional `Exec` value can be provided to try to execute the proposal immediately after proposal creation. Proposers signatures are considered as yes votes in this case. -+++ https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L218-L239 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L271-L294 + +It's expected to fail if: -It's expecting to fail if metadata length is greater than `MaxMetadataLen` config. +- metadata length is greater than `MaxMetadataLen` config. +- if any of the proposers is not a group member. ## Msg/WithdrawProposal -A proposal can be withdrawn using `MsgWithdrawProposal` which has a `address` (can be either proposer or policy admin) and a `proposal_id` (which has to be withdrawn). +A proposal can be withdrawn using `MsgWithdrawProposal` which has an `address` (can be either a proposer or the group policy admin) and a `proposal_id` (which has to be withdrawn). -+++ https://github.com/cosmos/cosmos-sdk/blob/f2d6f0e4bb1a9bd7f7ae3cdc4702c9d3d1fc0329/proto/cosmos/group/v1beta1/tx.proto#L251-L258 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L303-L310 -It's expecting to fail if: +It's expected to fail if: -* the signer is neither policy address nor proposer of the proposal. -* the proposal is already closed or aborted. +- the signer is neither the group policy admin nor proposer of the proposal. +- the proposal is already closed or aborted. ## Msg/Vote -A new vote can be created with the `MsgVote`, given a proposal id, a voter address, a choice (yes, no, veto or abstain) and some optional metadata bytes. +A new vote can be created with the `MsgVote`, given a proposal id, a voter address, a choice (yes, no, veto or abstain) and some optional metadata. An optional `Exec` value can be provided to try to execute the proposal immediately after voting. -+++ https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L248-L265 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L315-L333 + +It's expected to fail if: -It's expecting to fail if metadata length is greater than `MaxMetadataLen` config. +- metadata length is greater than `MaxMetadataLen` config. +- the proposal is not in voting period anymore. ## Msg/Exec A proposal can be executed with the `MsgExec`. -+++ https://github.com/cosmos/cosmos-sdk/blob/9aef070625e9676d7c0acb212c17ae9dba3c32dc/proto/cosmos/group/v1beta1/tx.proto#L270-L278 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L338-L347 The messages that are part of this proposal won't be executed if: -* the proposal has not been accepted. -* the proposal status is not closed. -* the proposal has already been successfully executed. +- the proposal has not been accepted by the group policy. +- the proposal has already been successfully executed. ## Msg/LeaveGroup The `MsgLeaveGroup` allows group member to leave a group. -+++ https://github.com/cosmos/cosmos-sdk/blob/a635fd78663d04c5de23f4d032e5a3abea1b005a/proto/cosmos/group/v1beta1/tx.proto#L352-L361 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/group/v1/tx.proto#L352-L361 -It's expecting to fail if: +It's expected to fail if: -* the group member is not part of the group. +- the group member is not part of the group. +- for any one of the associated group policies, if its decision policy's `Validate()` method fails against the updated group. diff --git a/x/group/spec/04_events.md b/x/group/spec/04_events.md index 1918a7099bd8..ca4e2fdf20bb 100644 --- a/x/group/spec/04_events.md +++ b/x/group/spec/04_events.md @@ -8,56 +8,65 @@ The group module emits the following events: ## EventCreateGroup -| Type | Attribute Key | Attribute Value | -|---------------------------------------|---------------|---------------------------------------| -| message | action | /cosmos.group.v1beta1.Msg/CreateGroup | -| cosmos.group.v1beta1.EventCreateGroup | group_id | {groupId} | +| Type | Attribute Key | Attribute Value | +| -------------------------------- | ------------- | -------------------------------- | +| message | action | /cosmos.group.v1.Msg/CreateGroup | +| cosmos.group.v1.EventCreateGroup | group_id | {groupId} | ## EventUpdateGroup -| Type | Attribute Key | Attribute Value | -|---------------------------------------|---------------|-----------------------------------------------------------------| -| message | action | /cosmos.group.v1beta1.Msg/UpdateGroup{Admin\|Metadata\|Members} | -| cosmos.group.v1beta1.EventUpdateGroup | group_id | {groupId} | +| Type | Attribute Key | Attribute Value | +| -------------------------------- | ------------- | ---------------------------------------------------------- | +| message | action | /cosmos.group.v1.Msg/UpdateGroup{Admin\|Metadata\|Members} | +| cosmos.group.v1.EventUpdateGroup | group_id | {groupId} | ## EventCreateGroupPolicy -| Type | Attribute Key | Attribute Value | -|----------------------------------------------|---------------|----------------------------------------------| -| message | action | /cosmos.group.v1beta1.Msg/CreateGroupPolicy | -| cosmos.group.v1beta1.EventCreateGroupPolicy | address | {groupPolicyAddress} | +| Type | Attribute Key | Attribute Value | +| -------------------------------------- | ------------- | -------------------------------------- | +| message | action | /cosmos.group.v1.Msg/CreateGroupPolicy | +| cosmos.group.v1.EventCreateGroupPolicy | address | {groupPolicyAddress} | ## EventUpdateGroupPolicy -| Type | Attribute Key | Attribute Value | -|----------------------------------------------|---------------|-------------------------------------------------------------------------------| -| message | action | /cosmos.group.v1beta1.Msg/UpdateGroupPolicy{Admin\|Metadata\|DecisionPolicy} | -| cosmos.group.v1beta1.EventUpdateGroupPolicy | address | {groupPolicyAddress} | +| Type | Attribute Key | Attribute Value | +| -------------------------------------- | ------------- | ----------------------------------------------------------------------- | +| message | action | /cosmos.group.v1.Msg/UpdateGroupPolicy{Admin\|Metadata\|DecisionPolicy} | +| cosmos.group.v1.EventUpdateGroupPolicy | address | {groupPolicyAddress} | ## EventCreateProposal -| Type | Attribute Key | Attribute Value | -|------------------------------------------|---------------|------------------------------------------| -| message | action | /cosmos.group.v1beta1.Msg/CreateProposal | -| cosmos.group.v1beta1.EventCreateProposal | proposal_id | {proposalId} | +| Type | Attribute Key | Attribute Value | +| ----------------------------------- | ------------- | ----------------------------------- | +| message | action | /cosmos.group.v1.Msg/CreateProposal | +| cosmos.group.v1.EventCreateProposal | proposal_id | {proposalId} | ## EventWithdrawProposal -| Type | Attribute Key | Attribute Value | -|--------------------------------------------|---------------|--------------------------------------------| -| message | action | /cosmos.group.v1beta1.Msg/WithdrawProposal | -| cosmos.group.v1beta1.EventWithdrawProposal | proposal_id | {proposalId} | +| Type | Attribute Key | Attribute Value | +| ------------------------------------- | ------------- | ------------------------------------- | +| message | action | /cosmos.group.v1.Msg/WithdrawProposal | +| cosmos.group.v1.EventWithdrawProposal | proposal_id | {proposalId} | ## EventVote -| Type | Attribute Key | Attribute Value | -|--------------------------------|---------------|--------------------------------| -| message | action | /cosmos.group.v1beta1.Msg/Vote | -| cosmos.group.v1beta1.EventVote | proposal_id | {proposalId} | +| Type | Attribute Key | Attribute Value | +| ------------------------- | ------------- | ------------------------- | +| message | action | /cosmos.group.v1.Msg/Vote | +| cosmos.group.v1.EventVote | proposal_id | {proposalId} | ## EventExec -| Type | Attribute Key | Attribute Value | -|--------------------------------|---------------|--------------------------------| -| message | action | /cosmos.group.v1beta1.Msg/Exec | -| cosmos.group.v1beta1.EventExec | proposal_id | {proposalId} | +| Type | Attribute Key | Attribute Value | +| ------------------------- | ------------- | ------------------------- | +| message | action | /cosmos.group.v1.Msg/Exec | +| cosmos.group.v1.EventExec | proposal_id | {proposalId} | +| cosmos.group.v1.EventExec | logs | {logs_string} | + +## EventLeaveGroup + +| Type | Attribute Key | Attribute Value | +| ------------------------------- | ------------- | ------------------------------- | +| message | action | /cosmos.group.v1.Msg/LeaveGroup | +| cosmos.group.v1.EventLeaveGroup | proposal_id | {proposalId} | +| cosmos.group.v1.EventLeaveGroup | address | {address} | diff --git a/x/group/spec/05_client.md b/x/group/spec/05_client.md index 97db94944861..d46672fd3ef6 100644 --- a/x/group/spec/05_client.md +++ b/x/group/spec/05_client.md @@ -62,7 +62,9 @@ admin: cosmos1.. decision_policy: '@type': /cosmos.group.v1beta1.ThresholdDecisionPolicy threshold: "1" - timeout: 600s + windows: + min_execution_period: 0s + voting_period: 432000s group_id: "1" metadata: AQ== version: "1" @@ -145,7 +147,7 @@ simd query group group-policies-by-group [group-id] [flags] Example: ```bash -simd query group group-policies-by-group 1 +simd query group group-policies-by-group 1 ``` Example Output: @@ -157,7 +159,9 @@ group_policies: decision_policy: '@type': /cosmos.group.v1beta1.ThresholdDecisionPolicy threshold: "1" - timeout: 600s + windows: + min_execution_period: 0s + voting_period: 432000s group_id: "1" metadata: AQ== version: "1" @@ -166,7 +170,9 @@ group_policies: decision_policy: '@type': /cosmos.group.v1beta1.ThresholdDecisionPolicy threshold: "1" - timeout: 600s + windows: + min_execution_period: 0s + voting_period: 432000s group_id: "1" metadata: AQ== version: "1" @@ -198,7 +204,9 @@ group_policies: decision_policy: '@type': /cosmos.group.v1beta1.ThresholdDecisionPolicy threshold: "1" - timeout: 600s + windows: + min_execution_period: 0s + voting_period: 432000s group_id: "1" metadata: AQ== version: "1" @@ -207,7 +215,9 @@ group_policies: decision_policy: '@type': /cosmos.group.v1beta1.ThresholdDecisionPolicy threshold: "1" - timeout: 600s + windows: + min_execution_period: 0s + voting_period: 432000s group_id: "1" metadata: AQ== version: "1" @@ -252,7 +262,9 @@ proposal: result: RESULT_UNFINALIZED status: STATUS_SUBMITTED submitted_at: "2021-12-17T07:06:26.310638964Z" - timeout: "2021-12-17T07:06:27.310638964Z" + windows: + min_execution_period: 0s + voting_period: 432000s vote_state: abstain_count: "0" no_count: "0" @@ -299,7 +311,9 @@ proposals: result: RESULT_UNFINALIZED status: STATUS_SUBMITTED submitted_at: "2021-12-17T07:06:26.310638964Z" - timeout: "2021-12-17T07:06:27.310638964Z" + windows: + min_execution_period: 0s + voting_period: 432000s vote_state: abstain_count: "0" no_count: "0" @@ -343,7 +357,7 @@ simd query group votes-by-proposal [proposal-id] [flags] Example: ```bash -simd query group votes-by-proposal 1 +simd query group votes-by-proposal 1 ``` Example Output: @@ -408,7 +422,7 @@ simd tx group create-group [admin] [metadata] [members-json-file] Example: ```bash -simd tx group create-group cosmos1.. "AQ==" members.json +simd tx group create-group cosmos1.. "AQ==" members.json ``` #### update-group-admin @@ -455,7 +469,7 @@ simd tx group update-group-metadata cosmos1.. 1 "AQ==" #### create-group-policy -The `create-group-policy` command allows users to create a group policy which is an account associated with a group and a decision policy. +The `create-group-policy` command allows users to create a group policy which is an account associated with a group and a decision policy. ```bash simd tx group create-group-policy [admin] [group-id] [metadata] [decision-policy] [flags] @@ -464,10 +478,9 @@ simd tx group create-group-policy [admin] [group-id] [metadata] [decision-policy Example: ```bash -simd tx group create-group-policy cosmos1.. 1 "AQ==" '{"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold":"1", "timeout":"600s"}' +simd tx group create-group-policy cosmos1.. 1 "AQ==" '{"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold":"1", "windows": {"voting_period": "120h", "min_execution_period": "0s"}}' ``` - #### create-group-with-policy The `create-group-with-policy` command allows users to create a group which is an aggregation of member accounts with associated weights and an administrator account with decision policy. If the `--group-policy-as-admin` flag is set to `true`, the group policy address becomes the group and group policy admin. @@ -479,7 +492,7 @@ simd tx group create-group-with-policy [admin] [group-metadata] [group-policy-me Example: ```bash -simd tx group create-group-with-policy cosmos1.. "AQ==" "AQ==" members.json '{"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold":"1", "timeout":"600s"}' +simd tx group create-group-with-policy cosmos1.. "AQ==" "AQ==" members.json '{"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold":"1", "windows": {"voting_period": "120h", "min_execution_period": "0s"}}' ``` #### update-group-policy-admin @@ -521,7 +534,7 @@ simd tx group update-group-policy-decision-policy [admin] [group-policy-account Example: ```bash -simd tx group update-group-policy-decision-policy cosmos1.. cosmos1.. '{"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold":"2", "timeout":"1000s"}' +simd tx group update-group-policy-decision-policy cosmos1.. cosmos1.. '{"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold":"2", "windows": {"voting_period": "120h", "min_execution_period": "0s"}}' ``` #### create-proposal @@ -552,7 +565,7 @@ Example: simd tx group withdraw-proposal 1 cosmos1.. ``` -#### vote +#### vote The `vote` command allows users to vote on a proposal. @@ -594,7 +607,6 @@ Example: simd tx group leave-group cosmos1... 1 ``` - ## gRPC A user can query the `group` module using gRPC endpoints. @@ -607,7 +619,7 @@ The `GroupInfo` endpoint allows users to query for group info by given group id. cosmos.group.v1beta1.Query/GroupInfo ``` -Example: +Example: ```bash grpcurl -plaintext \ @@ -652,7 +664,7 @@ Example Output: "groupId": "1", "admin": "cosmos1..", "version": "1", - "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","timeout":"600s"}, + "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","windows": {"voting_period": "120h", "min_execution_period": "0s"}}, } } ``` @@ -764,14 +776,14 @@ Example Output: "groupId": "1", "admin": "cosmos1..", "version": "1", - "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","timeout":"600s"}, + "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","windows":{"voting_period": "120h", "min_execution_period": "0s"}}, }, { "address": "cosmos1..", "groupId": "1", "admin": "cosmos1..", "version": "1", - "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","timeout":"600s"}, + "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","windows":{"voting_period": "120h", "min_execution_period": "0s"}}, } ], "pagination": { @@ -805,14 +817,14 @@ Example Output: "groupId": "1", "admin": "cosmos1..", "version": "1", - "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","timeout":"600s"}, + "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","windows":{"voting_period": "120h", "min_execution_period": "0s"}}, }, { "address": "cosmos1..", "groupId": "1", "admin": "cosmos1..", "version": "1", - "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","timeout":"600s"}, + "decisionPolicy": {"@type":"/cosmos.group.v1beta1.ThresholdDecisionPolicy","threshold":"1","windows":{"voting_period": "120h", "min_execution_period": "0s"}}, } ], "pagination": { @@ -857,7 +869,10 @@ Example Output: "abstainCount": "0", "vetoCount": "0" }, - "timeout": "2021-12-17T07:06:27.310638964Z", + "windows": { + "min_execution_period": "0s", + "voting_period": "432000s" + }, "executorResult": "EXECUTOR_RESULT_NOT_RUN", "msgs": [ {"@type":"/cosmos.bank.v1beta1.MsgSend","amount":[{"denom":"stake","amount":"100000000"}],"fromAddress":"cosmos1..","toAddress":"cosmos1.."} @@ -903,7 +918,10 @@ Example Output: "abstainCount": "0", "vetoCount": "0" }, - "timeout": "2021-12-17T08:13:27.099649352Z", + "windows": { + "min_execution_period": "0s", + "voting_period": "432000s" + }, "executorResult": "EXECUTOR_RESULT_NOT_RUN", "msgs": [ {"@type":"/cosmos.bank.v1beta1.MsgSend","amount":[{"denom":"stake","amount":"100000000"}],"fromAddress":"cosmos1..","toAddress":"cosmos1.."} @@ -1069,7 +1087,10 @@ Example Output: "decision_policy": { "@type": "/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold": "1", - "timeout": "600s" + "windows": { + "voting_period": "120h", + "min_execution_period": "0s" + } }, } } @@ -1186,7 +1207,10 @@ Example Output: "decision_policy": { "@type": "/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold": "1", - "timeout": "600s" + "windows": { + "voting_period": "120h", + "min_execution_period": "0s" + } }, }, { @@ -1198,7 +1222,10 @@ Example Output: "decision_policy": { "@type": "/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold": "1", - "timeout": "600s" + "windows": { + "voting_period": "120h", + "min_execution_period": "0s" + } }, } ], @@ -1237,7 +1264,10 @@ Example Output: "decision_policy": { "@type": "/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold": "1", - "timeout": "600s" + "windows": { + "voting_period": "120h", + "min_execution_period": "0s" + } }, }, { @@ -1249,7 +1279,10 @@ Example Output: "decision_policy": { "@type": "/cosmos.group.v1beta1.ThresholdDecisionPolicy", "threshold": "1", - "timeout": "600s" + "windows": { + "voting_period": "120h", + "min_execution_period": "0s" + } }, } ], @@ -1295,7 +1328,10 @@ Example Output: "abstain_count": "0", "veto_count": "0" }, - "timeout": "2021-12-17T07:06:27.310638964Z", + "windows": { + "min_execution_period": "0s", + "voting_period": "432000s" + }, "executor_result": "EXECUTOR_RESULT_NOT_RUN", "msgs": [ { @@ -1351,7 +1387,10 @@ Example Output: "abstain_count": "0", "veto_count": "0" }, - "timeout": "2021-12-17T08:13:27.099649352Z", + "windows": { + "min_execution_period": "0s", + "voting_period": "432000s" + }, "executor_result": "EXECUTOR_RESULT_NOT_RUN", "msgs": [ { diff --git a/x/group/tx.pb.go b/x/group/tx.pb.go index 4c0eb24d93ec..a2407e87dc44 100644 --- a/x/group/tx.pb.go +++ b/x/group/tx.pb.go @@ -68,7 +68,7 @@ type MsgCreateGroup struct { // admin is the account address of the group admin. Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` // members defines the group members. - Members []Member `protobuf:"bytes,2,rep,name=members,proto3" json:"members"` + Members []MemberRequest `protobuf:"bytes,2,rep,name=members,proto3" json:"members"` // metadata is any arbitrary metadata to attached to the group. Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` } @@ -113,7 +113,7 @@ func (m *MsgCreateGroup) GetAdmin() string { return "" } -func (m *MsgCreateGroup) GetMembers() []Member { +func (m *MsgCreateGroup) GetMembers() []MemberRequest { if m != nil { return m.Members } @@ -181,7 +181,7 @@ type MsgUpdateGroupMembers struct { GroupId uint64 `protobuf:"varint,2,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` // member_updates is the list of members to update, // set weight to 0 to remove a member. - MemberUpdates []Member `protobuf:"bytes,3,rep,name=member_updates,json=memberUpdates,proto3" json:"member_updates"` + MemberUpdates []MemberRequest `protobuf:"bytes,3,rep,name=member_updates,json=memberUpdates,proto3" json:"member_updates"` } func (m *MsgUpdateGroupMembers) Reset() { *m = MsgUpdateGroupMembers{} } @@ -231,7 +231,7 @@ func (m *MsgUpdateGroupMembers) GetGroupId() uint64 { return 0 } -func (m *MsgUpdateGroupMembers) GetMemberUpdates() []Member { +func (m *MsgUpdateGroupMembers) GetMemberUpdates() []MemberRequest { if m != nil { return m.MemberUpdates } @@ -637,7 +637,7 @@ type MsgCreateGroupWithPolicy struct { // admin is the account address of the group and group policy admin. Admin string `protobuf:"bytes,1,opt,name=admin,proto3" json:"admin,omitempty"` // members defines the group members. - Members []Member `protobuf:"bytes,2,rep,name=members,proto3" json:"members"` + Members []MemberRequest `protobuf:"bytes,2,rep,name=members,proto3" json:"members"` // group_metadata is any arbitrary metadata attached to the group. GroupMetadata string `protobuf:"bytes,3,opt,name=group_metadata,json=groupMetadata,proto3" json:"group_metadata,omitempty"` // group_policy_metadata is any arbitrary metadata attached to the group policy. @@ -1324,6 +1324,8 @@ func (m *MsgExec) GetExecutor() string { // MsgExecResponse is the Msg/Exec request type. type MsgExecResponse struct { + // result is the final result of the proposal execution. + Result ProposalExecutorResult `protobuf:"varint,2,opt,name=result,proto3,enum=cosmos.group.v1.ProposalExecutorResult" json:"result,omitempty"` } func (m *MsgExecResponse) Reset() { *m = MsgExecResponse{} } @@ -1359,6 +1361,13 @@ func (m *MsgExecResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgExecResponse proto.InternalMessageInfo +func (m *MsgExecResponse) GetResult() ProposalExecutorResult { + if m != nil { + return m.Result + } + return PROPOSAL_EXECUTOR_RESULT_UNSPECIFIED +} + // MsgLeaveGroup is the Msg/LeaveGroup request type. type MsgLeaveGroup struct { // address is the account address of the group member. @@ -1486,85 +1495,87 @@ func init() { func init() { proto.RegisterFile("cosmos/group/v1/tx.proto", fileDescriptor_6b8d3d629f136420) } var fileDescriptor_6b8d3d629f136420 = []byte{ - // 1241 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0xcd, 0x6e, 0xe3, 0x54, - 0x14, 0x8e, 0x93, 0x4c, 0x9b, 0x9e, 0xcc, 0xa4, 0xad, 0x9b, 0x4e, 0x53, 0x77, 0x26, 0x09, 0xa6, - 0xd3, 0xe9, 0x44, 0x53, 0x87, 0xa6, 0x8c, 0x90, 0x0a, 0x42, 0xea, 0x1f, 0xa8, 0x88, 0x40, 0x71, - 0x67, 0x18, 0x60, 0x13, 0xdc, 0xd8, 0xe3, 0xb1, 0x48, 0x72, 0xad, 0x5c, 0xa7, 0x4d, 0x97, 0xc0, - 0x86, 0x9f, 0x0d, 0x12, 0x2f, 0x00, 0xe2, 0x05, 0x58, 0xf4, 0x09, 0x60, 0x33, 0x62, 0x35, 0x62, - 0x85, 0x58, 0xa0, 0x51, 0xbb, 0xe0, 0x05, 0x78, 0x00, 0xe4, 0x7b, 0xed, 0x1b, 0x3b, 0x71, 0x6a, - 0x37, 0x8a, 0x60, 0xd5, 0xda, 0xe7, 0x3b, 0xe7, 0x7c, 0xdf, 0xb9, 0xe7, 0xde, 0x73, 0x1d, 0xc8, - 0xd5, 0x11, 0x6e, 0x22, 0x5c, 0xd6, 0xdb, 0xa8, 0x63, 0x96, 0x8f, 0xd7, 0xcb, 0x56, 0x57, 0x32, - 0xdb, 0xc8, 0x42, 0xfc, 0x34, 0xb5, 0x48, 0xc4, 0x22, 0x1d, 0xaf, 0x0b, 0x59, 0x1d, 0xe9, 0x88, - 0xd8, 0xca, 0xf6, 0x7f, 0x14, 0x26, 0x2c, 0x52, 0x58, 0x8d, 0x1a, 0x1c, 0x1f, 0xc7, 0xa4, 0x23, - 0xa4, 0x37, 0xb4, 0x32, 0x79, 0x3a, 0xea, 0x3c, 0x29, 0x2b, 0xad, 0x53, 0xc7, 0xb4, 0x34, 0x90, - 0xf6, 0xd4, 0xd4, 0x5c, 0xbf, 0x05, 0xc7, 0xd8, 0xc4, 0xba, 0x6d, 0x6a, 0x62, 0x9d, 0x1a, 0xc4, - 0x1f, 0x39, 0xc8, 0x54, 0xb1, 0xbe, 0xd3, 0xd6, 0x14, 0x4b, 0x7b, 0xdb, 0x76, 0xe5, 0x25, 0xb8, - 0xa6, 0xa8, 0x4d, 0xa3, 0x95, 0xe3, 0x8a, 0xdc, 0xea, 0xd4, 0x76, 0xee, 0xf7, 0xb3, 0xb5, 0xac, - 0x43, 0x62, 0x4b, 0x55, 0xdb, 0x1a, 0xc6, 0x87, 0x56, 0xdb, 0x68, 0xe9, 0x32, 0x85, 0xf1, 0xaf, - 0xc1, 0x64, 0x53, 0x6b, 0x1e, 0x69, 0x6d, 0x9c, 0x8b, 0x17, 0x13, 0xab, 0xe9, 0xca, 0x82, 0xd4, - 0xa7, 0x53, 0xaa, 0x12, 0xfb, 0x76, 0xf2, 0xd9, 0x5f, 0x85, 0x98, 0xec, 0xa2, 0x79, 0x01, 0x52, - 0x4d, 0xcd, 0x52, 0x54, 0xc5, 0x52, 0x72, 0x09, 0x3b, 0x97, 0xcc, 0x9e, 0x37, 0xe1, 0x8b, 0xbf, - 0x7f, 0x2e, 0xd1, 0x04, 0xe2, 0x06, 0xdc, 0xf4, 0x53, 0x94, 0x35, 0x6c, 0xa2, 0x16, 0xd6, 0xf8, - 0x45, 0x48, 0x91, 0x1c, 0x35, 0x43, 0x25, 0x6c, 0x93, 0xf2, 0x24, 0x79, 0xde, 0x57, 0xc5, 0x33, - 0x0e, 0xe6, 0xab, 0x58, 0x7f, 0x64, 0xaa, 0xae, 0x57, 0xd5, 0x49, 0x7b, 0x55, 0x7d, 0xde, 0x24, - 0x71, 0x5f, 0x12, 0x7e, 0x17, 0x32, 0x54, 0x4c, 0xad, 0x43, 0xf2, 0xe0, 0x5c, 0x22, 0x4a, 0x05, - 0x6e, 0x50, 0x27, 0xca, 0x0d, 0xfb, 0xb4, 0x16, 0xe0, 0x76, 0x20, 0x6b, 0x57, 0xb2, 0xf8, 0x13, - 0x07, 0x73, 0x7e, 0xc4, 0x16, 0x61, 0x39, 0x46, 0x55, 0x0f, 0x60, 0xaa, 0xa5, 0x9d, 0xd4, 0x68, - 0xb8, 0x44, 0x48, 0xb8, 0x54, 0x4b, 0x3b, 0x21, 0x0c, 0x7c, 0x32, 0x6e, 0xc3, 0x52, 0x00, 0x49, - 0x26, 0xe2, 0x5b, 0x8e, 0x2c, 0xa9, 0x4f, 0x26, 0x5d, 0xf8, 0x71, 0xea, 0x88, 0xda, 0x5f, 0x45, - 0xc8, 0x07, 0x93, 0x61, 0x7c, 0x5f, 0x70, 0x90, 0xf5, 0xb7, 0xe0, 0x01, 0x6a, 0x18, 0xf5, 0xd3, - 0xff, 0x88, 0x2d, 0xff, 0x01, 0x4c, 0xab, 0x5a, 0xdd, 0xc0, 0x06, 0x6a, 0xd5, 0x4c, 0x92, 0x39, - 0x97, 0x2c, 0x72, 0xab, 0xe9, 0x4a, 0x56, 0xa2, 0x07, 0x82, 0xe4, 0x1e, 0x08, 0xd2, 0x56, 0xeb, - 0x74, 0x9b, 0xff, 0xed, 0x6c, 0x2d, 0xb3, 0xeb, 0x38, 0x50, 0xa6, 0x72, 0x46, 0xf5, 0x3d, 0x6f, - 0x66, 0xbe, 0xfa, 0xa1, 0x10, 0xf3, 0x14, 0x41, 0x86, 0x5b, 0x41, 0x0a, 0xd9, 0x56, 0xab, 0xc0, - 0xa4, 0x42, 0x15, 0x85, 0x6a, 0x75, 0x81, 0xe2, 0x9f, 0x1c, 0x2c, 0xfa, 0x2b, 0x4b, 0x83, 0x8e, - 0xd6, 0xb1, 0xef, 0x40, 0x96, 0xd6, 0x8e, 0x56, 0xa0, 0xe6, 0xd2, 0x89, 0x87, 0xb8, 0xf3, 0xba, - 0x37, 0x33, 0xb1, 0x8c, 0xa3, 0xc5, 0xff, 0x89, 0x43, 0xce, 0x5f, 0xb1, 0xc7, 0x86, 0xf5, 0x74, - 0xc4, 0xbe, 0x18, 0xf9, 0x0c, 0xbd, 0x03, 0x19, 0x5a, 0x94, 0xbe, 0xde, 0xb9, 0xa1, 0xfb, 0x76, - 0x55, 0x05, 0xe6, 0x7d, 0xb5, 0x63, 0xe8, 0x24, 0x41, 0xcf, 0x79, 0x4a, 0xc4, 0x7c, 0xd6, 0xfb, - 0x7c, 0x14, 0xec, 0xd4, 0xeb, 0x5a, 0x91, 0x5b, 0x4d, 0xf9, 0xcb, 0x8a, 0xe9, 0x92, 0x06, 0xf4, - 0xe9, 0xc4, 0x98, 0xfb, 0xf4, 0x6b, 0x0e, 0x8a, 0xc3, 0xca, 0x1e, 0x61, 0x2e, 0x8c, 0xb3, 0x8b, - 0xc4, 0x97, 0xe1, 0xa5, 0xa1, 0xed, 0xcd, 0xce, 0x8e, 0x2f, 0xe3, 0x20, 0x06, 0xa1, 0xfc, 0xba, - 0xff, 0xd7, 0xdd, 0x10, 0xb0, 0x6c, 0x89, 0x31, 0x2f, 0xdb, 0x7d, 0x28, 0x85, 0x17, 0x81, 0xd5, - 0xec, 0x17, 0x8e, 0x9c, 0x46, 0x03, 0xf0, 0x91, 0xa7, 0xc4, 0x38, 0xab, 0x15, 0x75, 0xac, 0xac, - 0xc0, 0xf2, 0x65, 0x1a, 0x98, 0xd8, 0x6f, 0xe2, 0x30, 0x5b, 0xc5, 0xfa, 0x61, 0xe7, 0xa8, 0x69, - 0x58, 0x07, 0x6d, 0x64, 0x22, 0xac, 0x34, 0x86, 0x32, 0xe6, 0x46, 0x60, 0x7c, 0x0b, 0xa6, 0x4c, - 0x12, 0xd7, 0x3d, 0x5f, 0xa6, 0xe4, 0xde, 0x8b, 0x4b, 0x07, 0xcf, 0x2b, 0xb6, 0x0d, 0x63, 0x45, - 0xd7, 0x70, 0x2e, 0x49, 0x0e, 0xa6, 0xc0, 0x96, 0x90, 0x19, 0x8a, 0xbf, 0x07, 0x49, 0xad, 0xab, - 0xd5, 0xc9, 0x21, 0x91, 0xa9, 0xcc, 0x0f, 0x1c, 0x63, 0x7b, 0x5d, 0xad, 0x2e, 0x13, 0xc8, 0x26, - 0xef, 0xf6, 0x48, 0x8f, 0x8c, 0xf8, 0x06, 0x99, 0x18, 0xfe, 0x5a, 0xb0, 0x6d, 0x5d, 0x80, 0xb4, - 0xe9, 0xbc, 0xeb, 0xed, 0x6c, 0x70, 0x5f, 0xed, 0xab, 0x62, 0x97, 0xdc, 0x8d, 0xec, 0x03, 0x41, - 0x6d, 0x2b, 0x27, 0xac, 0x96, 0x61, 0x7e, 0xde, 0xe1, 0x16, 0x8f, 0x38, 0xdc, 0x36, 0xaf, 0xdb, - 0xcc, 0xd9, 0xa8, 0xa3, 0x17, 0x9e, 0xfe, 0xcc, 0x6c, 0x8d, 0xcf, 0x39, 0x98, 0xac, 0x62, 0xfd, - 0x43, 0x64, 0x85, 0xab, 0xb0, 0x9b, 0xfb, 0x18, 0x59, 0x5a, 0x3b, 0x94, 0x0b, 0x85, 0xf1, 0x1b, - 0x30, 0x81, 0x4c, 0xcb, 0x40, 0x74, 0x92, 0x65, 0x2a, 0x4b, 0x03, 0x45, 0xb7, 0xf3, 0xbe, 0x4f, - 0x20, 0xb2, 0x03, 0xf5, 0xad, 0x7a, 0xb2, 0x6f, 0xd5, 0xaf, 0xb0, 0x86, 0xb4, 0xe1, 0x09, 0x0f, - 0x71, 0x16, 0xa6, 0x1d, 0x8d, 0x4c, 0x77, 0x93, 0xc8, 0xb6, 0xf1, 0xe1, 0xb2, 0x5f, 0x85, 0x94, - 0x1d, 0xb2, 0x63, 0xa1, 0x70, 0xe5, 0x0c, 0xb9, 0x99, 0xb6, 0x09, 0x4c, 0x60, 0x43, 0x6f, 0x31, - 0x06, 0x84, 0x9e, 0xcb, 0xa0, 0x01, 0x37, 0xaa, 0x58, 0x7f, 0x57, 0x53, 0x8e, 0x9d, 0xcf, 0x9b, - 0x11, 0x2e, 0x32, 0x97, 0x5c, 0xdb, 0xfa, 0xda, 0x60, 0x81, 0x7c, 0x74, 0xf4, 0xb2, 0xb9, 0x34, - 0x4a, 0x25, 0x48, 0x92, 0x2a, 0x64, 0x61, 0x66, 0xef, 0xa3, 0xbd, 0x9d, 0xda, 0xa3, 0xf7, 0x0e, - 0x0f, 0xf6, 0x76, 0xf6, 0xdf, 0xda, 0xdf, 0xdb, 0x9d, 0x89, 0xf1, 0xd7, 0x21, 0x45, 0xde, 0x3e, - 0x94, 0x3f, 0x9e, 0xe1, 0x2a, 0xbf, 0xa6, 0x21, 0x51, 0xc5, 0x3a, 0xff, 0x18, 0xd2, 0xde, 0xef, - 0xb2, 0xc2, 0xe0, 0x95, 0xc0, 0x37, 0x07, 0x85, 0xbb, 0x21, 0x00, 0xb6, 0x8f, 0x1a, 0xc0, 0x07, - 0x7c, 0x17, 0xad, 0x04, 0xb9, 0x0f, 0xe2, 0x04, 0x29, 0x1a, 0x8e, 0x65, 0x7b, 0x02, 0x33, 0x03, - 0x5f, 0x2b, 0xcb, 0x21, 0x31, 0x08, 0x4a, 0xb8, 0x1f, 0x05, 0xc5, 0xf2, 0x20, 0x98, 0x0b, 0xfa, - 0xa0, 0xb8, 0x1b, 0x4a, 0x97, 0x02, 0x85, 0x72, 0x44, 0x20, 0x4b, 0x68, 0xc0, 0xec, 0xe0, 0x17, - 0xc1, 0x9d, 0x90, 0x45, 0xa0, 0x30, 0x61, 0x2d, 0x12, 0x8c, 0xa5, 0xea, 0xc0, 0x7c, 0xf0, 0x45, - 0xf3, 0x5e, 0x48, 0x9c, 0x1e, 0x54, 0x58, 0x8f, 0x0c, 0x65, 0x69, 0xbb, 0x70, 0x73, 0xc8, 0xe5, - 0xbd, 0x14, 0x52, 0x2c, 0x0f, 0x56, 0xa8, 0x44, 0xc7, 0xb2, 0xcc, 0xdf, 0x73, 0x50, 0x08, 0xbb, - 0x32, 0x6d, 0x44, 0x8a, 0xeb, 0x77, 0x12, 0x5e, 0x1f, 0xc1, 0x89, 0xb1, 0xfa, 0x9c, 0x83, 0xc5, - 0xe1, 0x97, 0x92, 0xb5, 0x48, 0xa1, 0x59, 0xbf, 0x3d, 0xb8, 0x12, 0x9c, 0x71, 0xf8, 0x14, 0x32, - 0x7d, 0x57, 0x05, 0x31, 0x28, 0x90, 0x1f, 0x23, 0x94, 0xc2, 0x31, 0xde, 0x0d, 0x3b, 0x30, 0x42, - 0x03, 0x37, 0x6c, 0x3f, 0x2a, 0x78, 0xc3, 0x0e, 0x1b, 0x8a, 0xfc, 0x36, 0x24, 0xc9, 0x40, 0xcc, - 0x05, 0x79, 0xd9, 0x16, 0xa1, 0x38, 0xcc, 0xe2, 0x8d, 0x41, 0xce, 0xd5, 0xc0, 0x18, 0xb6, 0x25, - 0x38, 0x86, 0x77, 0x44, 0xf0, 0x0f, 0x01, 0x3c, 0xf3, 0x21, 0x1f, 0x84, 0xef, 0xd9, 0x85, 0x95, - 0xcb, 0xed, 0x6e, 0xd4, 0xed, 0x37, 0x9f, 0x9d, 0xe7, 0xb9, 0xe7, 0xe7, 0x79, 0xee, 0xc5, 0x79, - 0x9e, 0xfb, 0xee, 0x22, 0x1f, 0x7b, 0x7e, 0x91, 0x8f, 0xfd, 0x71, 0x91, 0x8f, 0x7d, 0xb2, 0xac, - 0x1b, 0xd6, 0xd3, 0xce, 0x91, 0x54, 0x47, 0x4d, 0xe7, 0xd7, 0x3d, 0xe7, 0xcf, 0x1a, 0x56, 0x3f, - 0x2b, 0x77, 0xe9, 0x2f, 0x78, 0x47, 0x13, 0xe4, 0x82, 0xb5, 0xf1, 0x6f, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x91, 0xea, 0x5a, 0x20, 0x4f, 0x14, 0x00, 0x00, + // 1276 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0x41, 0x73, 0xdb, 0x44, + 0x14, 0xb6, 0x6c, 0x37, 0x71, 0x9e, 0x1b, 0x27, 0x51, 0x9c, 0xd6, 0x51, 0x5a, 0xdb, 0x88, 0x34, + 0x49, 0x3d, 0x8d, 0x4c, 0x1c, 0x7a, 0x09, 0x4c, 0x99, 0x24, 0x35, 0x4c, 0x00, 0x43, 0x46, 0x69, + 0x29, 0x70, 0x31, 0x8a, 0xb5, 0x55, 0x35, 0xd8, 0x96, 0xd1, 0xca, 0x89, 0x73, 0x84, 0x13, 0xd0, + 0x0b, 0x33, 0xfd, 0x03, 0xcc, 0x70, 0xe1, 0xc8, 0xa1, 0x37, 0x6e, 0x70, 0xe9, 0x70, 0xea, 0x70, + 0x62, 0x38, 0x30, 0x4c, 0x72, 0xe0, 0xca, 0x4f, 0x60, 0xb4, 0x2b, 0xad, 0x2d, 0x5b, 0x8e, 0x14, + 0xe3, 0xc2, 0xa9, 0xb5, 0xde, 0xf7, 0xde, 0xfb, 0xbe, 0xb7, 0x6f, 0xf7, 0xed, 0x06, 0x32, 0x35, + 0x03, 0x37, 0x0c, 0x5c, 0xd4, 0x4c, 0xa3, 0xdd, 0x2a, 0x1e, 0x6d, 0x14, 0xad, 0x8e, 0xd4, 0x32, + 0x0d, 0xcb, 0xe0, 0x67, 0xa8, 0x45, 0x22, 0x16, 0xe9, 0x68, 0x43, 0x48, 0x6b, 0x86, 0x66, 0x10, + 0x5b, 0xd1, 0xfe, 0x1f, 0x85, 0x09, 0x8b, 0x14, 0x56, 0xa5, 0x06, 0xc7, 0xc7, 0x31, 0x69, 0x86, + 0xa1, 0xd5, 0x51, 0x91, 0xfc, 0x3a, 0x6c, 0x3f, 0x2c, 0x2a, 0xcd, 0x13, 0xc7, 0xb4, 0x34, 0x90, + 0xf6, 0xa4, 0x85, 0x5c, 0xbf, 0xab, 0x8e, 0xb1, 0x81, 0x35, 0xdb, 0xd4, 0xc0, 0x1a, 0x35, 0x88, + 0xdf, 0x73, 0x90, 0xaa, 0x60, 0x6d, 0xd7, 0x44, 0x8a, 0x85, 0xde, 0xb2, 0x5d, 0x79, 0x09, 0x2e, + 0x29, 0x6a, 0x43, 0x6f, 0x66, 0xb8, 0x3c, 0xb7, 0x36, 0xb5, 0x93, 0xf9, 0xf5, 0xe9, 0x7a, 0xda, + 0x21, 0xb1, 0xad, 0xaa, 0x26, 0xc2, 0xf8, 0xc0, 0x32, 0xf5, 0xa6, 0x26, 0x53, 0x18, 0x7f, 0x07, + 0x26, 0x1b, 0xa8, 0x71, 0x88, 0x4c, 0x9c, 0x89, 0xe6, 0x63, 0x6b, 0xc9, 0x52, 0x56, 0xea, 0xd3, + 0x29, 0x55, 0x88, 0x5d, 0x46, 0x9f, 0xb5, 0x11, 0xb6, 0x76, 0xe2, 0xcf, 0xfe, 0xc8, 0x45, 0x64, + 0xd7, 0x89, 0x17, 0x20, 0xd1, 0x40, 0x96, 0xa2, 0x2a, 0x96, 0x92, 0x89, 0xd9, 0x29, 0x65, 0xf6, + 0x7b, 0x0b, 0xbe, 0xf8, 0xeb, 0x87, 0x02, 0xcd, 0x23, 0x6e, 0xc2, 0x15, 0x2f, 0x53, 0x19, 0xe1, + 0x96, 0xd1, 0xc4, 0x88, 0x5f, 0x84, 0x04, 0x49, 0x55, 0xd5, 0x55, 0x42, 0x3a, 0x2e, 0x4f, 0x92, + 0xdf, 0x7b, 0xaa, 0xf8, 0x23, 0x07, 0x0b, 0x15, 0xac, 0xdd, 0x6f, 0xa9, 0xae, 0x57, 0xc5, 0x49, + 0x7b, 0x51, 0x99, 0xbd, 0x49, 0xa2, 0x9e, 0x24, 0xfc, 0x3b, 0x90, 0xa2, 0x62, 0xaa, 0x6d, 0x92, + 0x07, 0x67, 0x62, 0x17, 0x28, 0xc4, 0x34, 0xf5, 0xa5, 0x14, 0xb1, 0x47, 0x72, 0x0e, 0xae, 0xfb, + 0x92, 0x77, 0x95, 0x8b, 0xdf, 0x71, 0x30, 0xef, 0x45, 0x6c, 0x13, 0xb2, 0x63, 0x14, 0x77, 0x1b, + 0xa6, 0x9a, 0xe8, 0xb8, 0x4a, 0xc3, 0xc5, 0x02, 0xc2, 0x25, 0x9a, 0xe8, 0x98, 0x30, 0xf0, 0xc8, + 0xb8, 0x0e, 0x4b, 0x3e, 0x24, 0x99, 0x88, 0xc7, 0x1c, 0x59, 0x59, 0x8f, 0x4c, 0xba, 0xfe, 0xe3, + 0xd4, 0x11, 0xb6, 0xcd, 0xf2, 0x90, 0xf5, 0x27, 0xc3, 0xf8, 0xfe, 0xcd, 0x41, 0xda, 0xdb, 0x89, + 0xfb, 0x46, 0x5d, 0xaf, 0x9d, 0xfc, 0x47, 0x6c, 0x79, 0x05, 0x66, 0x54, 0x54, 0xd3, 0xb1, 0x6e, + 0x34, 0xab, 0x2d, 0x92, 0x39, 0x13, 0xcf, 0x73, 0x6b, 0xc9, 0x52, 0x5a, 0xa2, 0xc7, 0x83, 0xe4, + 0x1e, 0x0f, 0xd2, 0x76, 0xf3, 0x64, 0x47, 0xfc, 0xe5, 0xe9, 0x7a, 0xb6, 0xbf, 0x11, 0xef, 0x3a, + 0x01, 0x28, 0x73, 0x39, 0xa5, 0x7a, 0x7e, 0x6f, 0xa5, 0xbe, 0xfc, 0x36, 0x17, 0xe9, 0x29, 0x8a, + 0x0c, 0xd7, 0xfc, 0x14, 0xb3, 0x1d, 0x58, 0x82, 0x49, 0x85, 0x2a, 0x0c, 0xd4, 0xee, 0x02, 0xc5, + 0xdf, 0x39, 0x58, 0xf4, 0x56, 0x9a, 0x06, 0x1d, 0xad, 0x83, 0xdf, 0x86, 0x34, 0xad, 0x25, 0xad, + 0x48, 0xd5, 0xa5, 0x13, 0x0d, 0x70, 0xe7, 0xb5, 0xde, 0xcc, 0xc4, 0x32, 0x8e, 0x96, 0x7f, 0x1c, + 0x83, 0x8c, 0xb7, 0x62, 0x0f, 0x74, 0xeb, 0xd1, 0x88, 0x7d, 0xf2, 0x6f, 0x4f, 0xd8, 0x1b, 0x90, + 0xa2, 0xb5, 0xe9, 0x6b, 0xa9, 0x69, 0xcd, 0xb3, 0xd9, 0x4a, 0xb0, 0xe0, 0x29, 0x21, 0x43, 0xc7, + 0x09, 0x7a, 0xbe, 0xa7, 0x52, 0xcc, 0x67, 0xa3, 0xcf, 0x47, 0xc1, 0x4e, 0xd9, 0x2e, 0xe5, 0xb9, + 0xb5, 0x84, 0xb7, 0xba, 0x98, 0xae, 0xac, 0x4f, 0xfb, 0x4e, 0xbc, 0xe0, 0xf6, 0xfd, 0x8a, 0x83, + 0xfc, 0xb0, 0xd5, 0x08, 0x31, 0x45, 0xc6, 0xd9, 0x5c, 0xe2, 0xcb, 0xf0, 0xd2, 0xd0, 0xae, 0x67, + 0x47, 0xcc, 0x93, 0x28, 0x88, 0x7e, 0x28, 0xaf, 0xee, 0xff, 0x75, 0x93, 0xf8, 0x2c, 0x63, 0xec, + 0x05, 0x2f, 0xe3, 0x2d, 0x28, 0x04, 0x17, 0x85, 0xd5, 0xf0, 0x27, 0x8e, 0x1c, 0x5a, 0x03, 0xf0, + 0x91, 0x87, 0xcb, 0x38, 0xab, 0x17, 0x76, 0x1a, 0xad, 0xc0, 0xf2, 0x79, 0x1a, 0x98, 0xd8, 0xaf, + 0xa3, 0x30, 0x57, 0xc1, 0xda, 0x41, 0xfb, 0xb0, 0xa1, 0x5b, 0xfb, 0xa6, 0xd1, 0x32, 0xb0, 0x52, + 0x1f, 0xca, 0x98, 0x1b, 0x81, 0xf1, 0x35, 0x98, 0x6a, 0x91, 0xb8, 0xee, 0x31, 0x34, 0x25, 0x77, + 0x3f, 0x9c, 0x3b, 0xaf, 0x5e, 0xb1, 0x6d, 0x18, 0x2b, 0x1a, 0xc2, 0x99, 0x38, 0x39, 0xbf, 0x7c, + 0x5b, 0x44, 0x66, 0x28, 0xfe, 0x26, 0xc4, 0x51, 0x07, 0xd5, 0xc8, 0x21, 0x92, 0x2a, 0x2d, 0x0c, + 0x9c, 0x76, 0xe5, 0x0e, 0xaa, 0xc9, 0x04, 0xb2, 0xc5, 0xbb, 0x3d, 0xd2, 0x25, 0x23, 0xbe, 0x4e, + 0x06, 0x8b, 0xb7, 0x16, 0x6c, 0x9b, 0xe7, 0x20, 0xd9, 0x72, 0xbe, 0x75, 0x77, 0x3a, 0xb8, 0x9f, + 0xf6, 0x54, 0xb1, 0x43, 0xae, 0x54, 0xf6, 0x01, 0xa1, 0x9a, 0xca, 0x31, 0xab, 0x65, 0x90, 0x5f, + 0xef, 0x0c, 0x8c, 0x86, 0x9c, 0x81, 0x5b, 0x97, 0x6d, 0xe6, 0x6c, 0x22, 0xd2, 0x7b, 0x52, 0x7f, + 0x66, 0xb6, 0xc6, 0xa7, 0x1c, 0x4c, 0x56, 0xb0, 0xf6, 0x81, 0x61, 0x05, 0xab, 0xb0, 0x9b, 0xfb, + 0xc8, 0xb0, 0x90, 0x19, 0xc8, 0x85, 0xc2, 0xf8, 0x4d, 0x98, 0x30, 0x5a, 0x96, 0x6e, 0xd0, 0x81, + 0x97, 0x2a, 0x2d, 0x0d, 0x14, 0xdd, 0xce, 0xfb, 0x3e, 0x81, 0xc8, 0x0e, 0xd4, 0xb3, 0xea, 0xf1, + 0xbe, 0x55, 0xbf, 0xc0, 0x1a, 0xd2, 0x86, 0x27, 0x3c, 0xc4, 0x39, 0x98, 0x71, 0x34, 0x32, 0xdd, + 0x0d, 0x22, 0xdb, 0xc6, 0x07, 0xcb, 0x7e, 0x15, 0x12, 0x76, 0xc8, 0xb6, 0x65, 0x04, 0x2b, 0x67, + 0xc8, 0xad, 0xa4, 0x4d, 0x60, 0x02, 0xeb, 0x5a, 0x13, 0x99, 0xa2, 0x4c, 0x18, 0x10, 0x7a, 0x6e, + 0xcf, 0xbc, 0x01, 0x13, 0x26, 0xc2, 0xed, 0xba, 0x45, 0x62, 0xa6, 0x4a, 0xab, 0x03, 0x6a, 0xdc, + 0xc5, 0x2a, 0x3b, 0x21, 0x65, 0x02, 0x97, 0x1d, 0x37, 0xb1, 0x0e, 0xd3, 0x15, 0xac, 0xbd, 0x8b, + 0x94, 0x23, 0xe7, 0x91, 0x35, 0xc2, 0x85, 0xe9, 0x9c, 0xeb, 0x62, 0x5f, 0x1f, 0x5d, 0x25, 0x6f, + 0x9e, 0x6e, 0x36, 0x57, 0x47, 0xa1, 0x00, 0x71, 0x52, 0xc6, 0x34, 0xcc, 0x96, 0x3f, 0x2c, 0xef, + 0x56, 0xef, 0xbf, 0x77, 0xb0, 0x5f, 0xde, 0xdd, 0x7b, 0x73, 0xaf, 0x7c, 0x77, 0x36, 0xc2, 0x5f, + 0x86, 0x04, 0xf9, 0x7a, 0x4f, 0xfe, 0x68, 0x96, 0x2b, 0xfd, 0x9c, 0x84, 0x58, 0x05, 0x6b, 0xfc, + 0x03, 0x48, 0xf6, 0xbe, 0x0e, 0x73, 0x83, 0x57, 0x0f, 0xcf, 0x60, 0x15, 0x56, 0x03, 0x00, 0xac, + 0xa8, 0x75, 0xe0, 0x7d, 0x9e, 0x65, 0x2b, 0x7e, 0xee, 0x83, 0x38, 0x41, 0x0a, 0x87, 0x63, 0xd9, + 0x1e, 0xc2, 0xec, 0xc0, 0x2b, 0x69, 0x39, 0x20, 0x06, 0x41, 0x09, 0xb7, 0xc2, 0xa0, 0x58, 0x1e, + 0x03, 0xe6, 0xfd, 0x1e, 0x32, 0xab, 0x81, 0x74, 0x29, 0x50, 0x28, 0x86, 0x04, 0xb2, 0x84, 0x3a, + 0xcc, 0x0d, 0xbe, 0x44, 0x6e, 0x04, 0x2c, 0x02, 0x85, 0x09, 0xeb, 0xa1, 0x60, 0x2c, 0x55, 0x1b, + 0x16, 0xfc, 0x2f, 0xb4, 0x37, 0x03, 0xe2, 0x74, 0xa1, 0xc2, 0x46, 0x68, 0x28, 0x4b, 0xdb, 0x81, + 0x2b, 0x43, 0x1e, 0x09, 0x85, 0x80, 0x62, 0xf5, 0x60, 0x85, 0x52, 0x78, 0x2c, 0xcb, 0xfc, 0x84, + 0x83, 0x5c, 0xd0, 0x1d, 0x6c, 0x33, 0x54, 0x5c, 0xaf, 0x93, 0xf0, 0xda, 0x08, 0x4e, 0x8c, 0xd5, + 0xe7, 0x1c, 0x2c, 0x0e, 0xbf, 0xd5, 0xac, 0x87, 0x0a, 0xcd, 0xfa, 0xed, 0xf6, 0x85, 0xe0, 0x8c, + 0xc3, 0x27, 0x90, 0xea, 0xbb, 0x6b, 0x88, 0x7e, 0x81, 0xbc, 0x18, 0xa1, 0x10, 0x8c, 0xe9, 0xdd, + 0xb0, 0x03, 0x33, 0xd8, 0x77, 0xc3, 0xf6, 0xa3, 0xfc, 0x37, 0xec, 0xb0, 0xa9, 0xca, 0xef, 0x40, + 0x9c, 0x4c, 0xd4, 0x8c, 0x9f, 0x97, 0x6d, 0x11, 0xf2, 0xc3, 0x2c, 0xbd, 0x31, 0xc8, 0xb9, 0xea, + 0x1b, 0xc3, 0xb6, 0xf8, 0xc7, 0xf0, 0xcc, 0x98, 0x7b, 0x00, 0x3d, 0xf3, 0x21, 0xeb, 0x87, 0xef, + 0xda, 0x85, 0x95, 0xf3, 0xed, 0x6e, 0xd4, 0x9d, 0x3b, 0xcf, 0x4e, 0xb3, 0xdc, 0xf3, 0xd3, 0x2c, + 0xf7, 0xe7, 0x69, 0x96, 0xfb, 0xe6, 0x2c, 0x1b, 0x79, 0x7e, 0x96, 0x8d, 0xfc, 0x76, 0x96, 0x8d, + 0x7c, 0xbc, 0xac, 0xe9, 0xd6, 0xa3, 0xf6, 0xa1, 0x54, 0x33, 0x1a, 0xce, 0xdf, 0x18, 0x9d, 0x7f, + 0xd6, 0xb1, 0xfa, 0x69, 0xb1, 0x43, 0xff, 0x8e, 0x78, 0x38, 0x41, 0x6e, 0x68, 0x9b, 0xff, 0x04, + 0x00, 0x00, 0xff, 0xff, 0xee, 0x01, 0x59, 0xf1, 0xd5, 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1599,7 +1610,7 @@ type MsgClient interface { UpdateGroupPolicyMetadata(ctx context.Context, in *MsgUpdateGroupPolicyMetadata, opts ...grpc.CallOption) (*MsgUpdateGroupPolicyMetadataResponse, error) // SubmitProposal submits a new proposal. SubmitProposal(ctx context.Context, in *MsgSubmitProposal, opts ...grpc.CallOption) (*MsgSubmitProposalResponse, error) - // WithdrawProposal aborts a proposal. + // WithdrawProposal withdraws a proposal. WithdrawProposal(ctx context.Context, in *MsgWithdrawProposal, opts ...grpc.CallOption) (*MsgWithdrawProposalResponse, error) // Vote allows a voter to vote on a proposal. Vote(ctx context.Context, in *MsgVote, opts ...grpc.CallOption) (*MsgVoteResponse, error) @@ -1765,7 +1776,7 @@ type MsgServer interface { UpdateGroupPolicyMetadata(context.Context, *MsgUpdateGroupPolicyMetadata) (*MsgUpdateGroupPolicyMetadataResponse, error) // SubmitProposal submits a new proposal. SubmitProposal(context.Context, *MsgSubmitProposal) (*MsgSubmitProposalResponse, error) - // WithdrawProposal aborts a proposal. + // WithdrawProposal withdraws a proposal. WithdrawProposal(context.Context, *MsgWithdrawProposal) (*MsgWithdrawProposalResponse, error) // Vote allows a voter to vote on a proposal. Vote(context.Context, *MsgVote) (*MsgVoteResponse, error) @@ -3110,6 +3121,11 @@ func (m *MsgExecResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Result != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Result)) + i-- + dAtA[i] = 0x10 + } return len(dAtA) - i, nil } @@ -3609,6 +3625,9 @@ func (m *MsgExecResponse) Size() (n int) { } var l int _ = l + if m.Result != 0 { + n += 1 + sovTx(uint64(m.Result)) + } return n } @@ -3733,7 +3752,7 @@ func (m *MsgCreateGroup) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Members = append(m.Members, Member{}) + m.Members = append(m.Members, MemberRequest{}) if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3969,7 +3988,7 @@ func (m *MsgUpdateGroupMembers) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MemberUpdates = append(m.MemberUpdates, Member{}) + m.MemberUpdates = append(m.MemberUpdates, MemberRequest{}) if err := m.MemberUpdates[len(m.MemberUpdates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4898,7 +4917,7 @@ func (m *MsgCreateGroupWithPolicy) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Members = append(m.Members, Member{}) + m.Members = append(m.Members, MemberRequest{}) if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -6361,6 +6380,25 @@ func (m *MsgExecResponse) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: MsgExecResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Result", wireType) + } + m.Result = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Result |= ProposalExecutorResult(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) diff --git a/x/group/types.go b/x/group/types.go index feeab8387b46..86c0dfd9c1d7 100644 --- a/x/group/types.go +++ b/x/group/types.go @@ -4,8 +4,6 @@ import ( "fmt" "time" - proto "github.com/gogo/protobuf/proto" - "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -74,16 +72,16 @@ func (p ThresholdDecisionPolicy) Allow(tallyResult TallyResult, totalPower strin threshold, err := math.NewPositiveDecFromString(p.Threshold) if err != nil { - return DecisionPolicyResult{}, err + return DecisionPolicyResult{}, sdkerrors.Wrap(err, "threshold") } yesCount, err := math.NewNonNegativeDecFromString(tallyResult.YesCount) if err != nil { - return DecisionPolicyResult{}, err + return DecisionPolicyResult{}, sdkerrors.Wrap(err, "yes count") } totalPowerDec, err := math.NewNonNegativeDecFromString(totalPower) if err != nil { - return DecisionPolicyResult{}, err + return DecisionPolicyResult{}, sdkerrors.Wrap(err, "total power") } // the real threshold of the policy is `min(threshold,total_weight)`. If @@ -187,15 +185,15 @@ func (p PercentageDecisionPolicy) Allow(tally TallyResult, totalPower string, si percentage, err := math.NewPositiveDecFromString(p.Percentage) if err != nil { - return DecisionPolicyResult{}, err + return DecisionPolicyResult{}, sdkerrors.Wrap(err, "percentage") } yesCount, err := math.NewNonNegativeDecFromString(tally.YesCount) if err != nil { - return DecisionPolicyResult{}, err + return DecisionPolicyResult{}, sdkerrors.Wrap(err, "yes count") } totalPowerDec, err := math.NewNonNegativeDecFromString(totalPower) if err != nil { - return DecisionPolicyResult{}, err + return DecisionPolicyResult{}, sdkerrors.Wrap(err, "total power") } yesPercentage, err := yesCount.Quo(totalPowerDec) @@ -233,7 +231,8 @@ var _ orm.Validateable = GroupPolicyInfo{} // NewGroupPolicyInfo creates a new GroupPolicyInfo instance func NewGroupPolicyInfo(address sdk.AccAddress, group uint64, admin sdk.AccAddress, metadata string, - version uint64, decisionPolicy DecisionPolicy, createdAt time.Time) (GroupPolicyInfo, error) { + version uint64, decisionPolicy DecisionPolicy, createdAt time.Time, +) (GroupPolicyInfo, error) { p := GroupPolicyInfo{ Address: address.String(), GroupId: group, @@ -252,11 +251,7 @@ func NewGroupPolicyInfo(address sdk.AccAddress, group uint64, admin sdk.AccAddre } func (g *GroupPolicyInfo) SetDecisionPolicy(decisionPolicy DecisionPolicy) error { - msg, ok := decisionPolicy.(proto.Message) - if !ok { - return fmt.Errorf("can't proto marshal %T", msg) - } - any, err := codectypes.NewAnyWithValue(msg) + any, err := codectypes.NewAnyWithValue(decisionPolicy) if err != nil { return err } @@ -264,12 +259,13 @@ func (g *GroupPolicyInfo) SetDecisionPolicy(decisionPolicy DecisionPolicy) error return nil } -func (g GroupPolicyInfo) GetDecisionPolicy() DecisionPolicy { +func (g GroupPolicyInfo) GetDecisionPolicy() (DecisionPolicy, error) { decisionPolicy, ok := g.DecisionPolicy.GetCachedValue().(DecisionPolicy) if !ok { - return nil + return nil, sdkerrors.ErrInvalidType.Wrapf("expected %T, got %T", (DecisionPolicy)(nil), g.DecisionPolicy.GetCachedValue()) } - return decisionPolicy + + return decisionPolicy, nil } // UnpackInterfaces implements UnpackInterfacesMessage.UnpackInterfaces @@ -329,11 +325,11 @@ func (g GroupPolicyInfo) ValidateBasic() error { if g.Version == 0 { return sdkerrors.Wrap(errors.ErrEmpty, "group policy version") } - policy := g.GetDecisionPolicy() - - if policy == nil { - return sdkerrors.Wrap(errors.ErrEmpty, "group policy's decision policy") + policy, err := g.GetDecisionPolicy() + if err != nil { + return sdkerrors.Wrap(err, "group policy decision policy") } + if err := policy.ValidateBasic(); err != nil { return sdkerrors.Wrap(err, "group policy's decision policy") } @@ -353,15 +349,26 @@ func (g GroupMember) ValidateBasic() error { return sdkerrors.Wrap(errors.ErrEmpty, "group member's group id") } - err := g.Member.ValidateBasic() + err := MemberToMemberRequest(g.Member).ValidateBasic() if err != nil { return sdkerrors.Wrap(err, "group member") } return nil } -func (p Proposal) ValidateBasic() error { +// MemberToMemberRequest converts a `Member` (used for storage) +// to a `MemberRequest` (used in requests). The only difference +// between the two is that `MemberRequest` doesn't have any `AddedAt` field +// since it cannot be set as part of requests. +func MemberToMemberRequest(m *Member) MemberRequest { + return MemberRequest{ + Address: m.Address, + Weight: m.Weight, + Metadata: m.Metadata, + } +} +func (p Proposal) ValidateBasic() error { if p.Id == 0 { return sdkerrors.Wrap(errors.ErrEmpty, "proposal id") } @@ -405,7 +412,6 @@ func (v Vote) PrimaryKeyFields() []interface{} { var _ orm.Validateable = Vote{} func (v Vote) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(v.Voter) if err != nil { return sdkerrors.Wrap(err, "voter") diff --git a/x/group/types.pb.go b/x/group/types.pb.go index 0930b5a198f2..5815d7da7138 100644 --- a/x/group/types.pb.go +++ b/x/group/types.pb.go @@ -156,7 +156,7 @@ func (ProposalExecutorResult) EnumDescriptor() ([]byte, []int) { } // Member represents a group member with an account address, -// non-zero weight and metadata. +// non-zero weight, metadata and added_at timestamp. type Member struct { // address is the member's account address. Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` @@ -229,24 +229,30 @@ func (m *Member) GetAddedAt() time.Time { return time.Time{} } -// Members defines a repeated slice of Member objects. -type Members struct { - // members is the list of members. - Members []Member `protobuf:"bytes,1,rep,name=members,proto3" json:"members"` +// MemberRequest represents a group member to be used in Msg server requests. +// Contrary to `Member`, it doesn't have any `added_at` field +// since this field cannot be set as part of requests. +type MemberRequest struct { + // address is the member's account address. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // weight is the member's voting weight that should be greater than 0. + Weight string `protobuf:"bytes,2,opt,name=weight,proto3" json:"weight,omitempty"` + // metadata is any arbitrary metadata attached to the member. + Metadata string `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` } -func (m *Members) Reset() { *m = Members{} } -func (m *Members) String() string { return proto.CompactTextString(m) } -func (*Members) ProtoMessage() {} -func (*Members) Descriptor() ([]byte, []int) { +func (m *MemberRequest) Reset() { *m = MemberRequest{} } +func (m *MemberRequest) String() string { return proto.CompactTextString(m) } +func (*MemberRequest) ProtoMessage() {} +func (*MemberRequest) Descriptor() ([]byte, []int) { return fileDescriptor_f5bddd15d7a54a9d, []int{1} } -func (m *Members) XXX_Unmarshal(b []byte) error { +func (m *MemberRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *Members) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MemberRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_Members.Marshal(b, m, deterministic) + return xxx_messageInfo_MemberRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -256,23 +262,37 @@ func (m *Members) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *Members) XXX_Merge(src proto.Message) { - xxx_messageInfo_Members.Merge(m, src) +func (m *MemberRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MemberRequest.Merge(m, src) } -func (m *Members) XXX_Size() int { +func (m *MemberRequest) XXX_Size() int { return m.Size() } -func (m *Members) XXX_DiscardUnknown() { - xxx_messageInfo_Members.DiscardUnknown(m) +func (m *MemberRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MemberRequest.DiscardUnknown(m) } -var xxx_messageInfo_Members proto.InternalMessageInfo +var xxx_messageInfo_MemberRequest proto.InternalMessageInfo -func (m *Members) GetMembers() []Member { +func (m *MemberRequest) GetAddress() string { if m != nil { - return m.Members + return m.Address } - return nil + return "" +} + +func (m *MemberRequest) GetWeight() string { + if m != nil { + return m.Weight + } + return "" +} + +func (m *MemberRequest) GetMetadata() string { + if m != nil { + return m.Metadata + } + return "" } // ThresholdDecisionPolicy is a decision policy where a proposal passes when it @@ -700,7 +720,7 @@ type Proposal struct { // at this point, and the `final_tally_result`and `status` fields will be // accordingly updated. VotingPeriodEnd time.Time `protobuf:"bytes,10,opt,name=voting_period_end,json=votingPeriodEnd,proto3,stdtime" json:"voting_period_end"` - // executor_result is the final result based on the votes and election rule. Initial value is NotRun. + // executor_result is the final result of the proposal execution. Initial value is NotRun. ExecutorResult ProposalExecutorResult `protobuf:"varint,11,opt,name=executor_result,json=executorResult,proto3,enum=cosmos.group.v1.ProposalExecutorResult" json:"executor_result,omitempty"` // messages is a list of `sdk.Msg`s that will be executed if the proposal passes. Messages []*types.Any `protobuf:"bytes,12,rep,name=messages,proto3" json:"messages,omitempty"` @@ -871,7 +891,7 @@ func init() { proto.RegisterEnum("cosmos.group.v1.ProposalStatus", ProposalStatus_name, ProposalStatus_value) proto.RegisterEnum("cosmos.group.v1.ProposalExecutorResult", ProposalExecutorResult_name, ProposalExecutorResult_value) proto.RegisterType((*Member)(nil), "cosmos.group.v1.Member") - proto.RegisterType((*Members)(nil), "cosmos.group.v1.Members") + proto.RegisterType((*MemberRequest)(nil), "cosmos.group.v1.MemberRequest") proto.RegisterType((*ThresholdDecisionPolicy)(nil), "cosmos.group.v1.ThresholdDecisionPolicy") proto.RegisterType((*PercentageDecisionPolicy)(nil), "cosmos.group.v1.PercentageDecisionPolicy") proto.RegisterType((*DecisionPolicyWindows)(nil), "cosmos.group.v1.DecisionPolicyWindows") @@ -886,89 +906,89 @@ func init() { func init() { proto.RegisterFile("cosmos/group/v1/types.proto", fileDescriptor_f5bddd15d7a54a9d) } var fileDescriptor_f5bddd15d7a54a9d = []byte{ - // 1306 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x4d, 0x6f, 0x1b, 0xc5, - 0x1b, 0xf7, 0xda, 0x8e, 0x5f, 0x1e, 0xa7, 0xb6, 0xff, 0xd3, 0xfc, 0x9b, 0x4d, 0x52, 0xec, 0x60, - 0x2a, 0x88, 0x8a, 0x6a, 0xb7, 0xae, 0x44, 0xa5, 0x1e, 0x00, 0xdb, 0xd9, 0x52, 0x57, 0xad, 0x6d, - 0x76, 0xd7, 0x09, 0xe5, 0xb2, 0xda, 0x78, 0xa7, 0x9b, 0x15, 0xf6, 0x8e, 0xb5, 0x3b, 0x4e, 0xea, - 0x6f, 0xd0, 0x0b, 0xa2, 0x47, 0x2e, 0x48, 0x95, 0xf8, 0x04, 0x48, 0x3d, 0x20, 0x2e, 0x5c, 0x2b, - 0x0e, 0xa8, 0xe2, 0xc4, 0x09, 0x50, 0x7b, 0x29, 0x27, 0xbe, 0x02, 0xda, 0x99, 0xd9, 0xc4, 0x2f, - 0x89, 0x69, 0x2a, 0x38, 0xc5, 0xf3, 0xfc, 0x7e, 0xcf, 0x33, 0xcf, 0xfb, 0x64, 0x61, 0xa3, 0x47, - 0xfc, 0x01, 0xf1, 0x2b, 0xb6, 0x47, 0x46, 0xc3, 0xca, 0xc1, 0xb5, 0x0a, 0x1d, 0x0f, 0xb1, 0x5f, - 0x1e, 0x7a, 0x84, 0x12, 0x94, 0xe3, 0x60, 0x99, 0x81, 0xe5, 0x83, 0x6b, 0xeb, 0x2b, 0x36, 0xb1, - 0x09, 0xc3, 0x2a, 0xc1, 0x2f, 0x4e, 0x5b, 0x2f, 0xd8, 0x84, 0xd8, 0x7d, 0x5c, 0x61, 0xa7, 0xbd, - 0xd1, 0x83, 0x8a, 0x35, 0xf2, 0x4c, 0xea, 0x10, 0x57, 0xe0, 0xc5, 0x59, 0x9c, 0x3a, 0x03, 0xec, - 0x53, 0x73, 0x30, 0x14, 0x84, 0x35, 0x7e, 0x8f, 0xc1, 0x2d, 0x8b, 0x4b, 0x05, 0x34, 0xab, 0x6b, - 0xba, 0x63, 0x0e, 0x95, 0xbe, 0x93, 0x20, 0x71, 0x0f, 0x0f, 0xf6, 0xb0, 0x87, 0xaa, 0x90, 0x34, - 0x2d, 0xcb, 0xc3, 0xbe, 0x2f, 0x4b, 0x9b, 0xd2, 0x56, 0xba, 0x2e, 0xff, 0xf2, 0xf4, 0xca, 0x8a, - 0x30, 0x54, 0xe3, 0x88, 0x46, 0x3d, 0xc7, 0xb5, 0xd5, 0x90, 0x88, 0x2e, 0x40, 0xe2, 0x10, 0x3b, - 0xf6, 0x3e, 0x95, 0xa3, 0x81, 0x8a, 0x2a, 0x4e, 0x68, 0x1d, 0x52, 0x03, 0x4c, 0x4d, 0xcb, 0xa4, - 0xa6, 0x1c, 0x63, 0xc8, 0xd1, 0x19, 0x7d, 0x04, 0x29, 0xd3, 0xb2, 0xb0, 0x65, 0x98, 0x54, 0x8e, - 0x6f, 0x4a, 0x5b, 0x99, 0xea, 0x7a, 0x99, 0x3b, 0x58, 0x0e, 0x1d, 0x2c, 0xeb, 0x61, 0x70, 0xf5, - 0xd4, 0xb3, 0xdf, 0x8a, 0x91, 0xc7, 0xbf, 0x17, 0x25, 0x76, 0x29, 0xb6, 0x6a, 0xb4, 0x54, 0x87, - 0x24, 0x77, 0xd9, 0x47, 0x37, 0x20, 0x39, 0xe0, 0x3f, 0x65, 0x69, 0x33, 0xb6, 0x95, 0xa9, 0xae, - 0x96, 0x67, 0xd2, 0x5d, 0xe6, 0xd4, 0x7a, 0x3c, 0xb0, 0xa3, 0x86, 0xec, 0xd2, 0x97, 0x12, 0xac, - 0xea, 0xfb, 0x1e, 0xf6, 0xf7, 0x49, 0xdf, 0xda, 0xc6, 0x3d, 0xc7, 0x77, 0x88, 0xdb, 0x21, 0x7d, - 0xa7, 0x37, 0x46, 0x17, 0x21, 0x4d, 0x43, 0x88, 0xa7, 0x42, 0x3d, 0x16, 0xa0, 0x8f, 0x21, 0x79, - 0xe8, 0xb8, 0x16, 0x39, 0xf4, 0x59, 0xcc, 0x99, 0xea, 0xbb, 0x73, 0x57, 0x4e, 0xdb, 0xdb, 0xe5, - 0x6c, 0x35, 0x54, 0xbb, 0x89, 0x7e, 0x7a, 0x7a, 0x25, 0x3b, 0xcd, 0x29, 0x3d, 0x96, 0x40, 0xee, - 0x60, 0xaf, 0x87, 0x5d, 0x6a, 0xda, 0x78, 0xc6, 0xa1, 0x02, 0xc0, 0xf0, 0x08, 0x13, 0x1e, 0x4d, - 0x48, 0xfe, 0x23, 0x97, 0xbe, 0x97, 0xe0, 0xff, 0x27, 0xaa, 0xa1, 0xdb, 0x70, 0xee, 0x80, 0x50, - 0xc7, 0xb5, 0x8d, 0x21, 0xf6, 0x1c, 0xc2, 0x93, 0x94, 0xa9, 0xae, 0xcd, 0x95, 0x71, 0x5b, 0xf4, - 0x30, 0xaf, 0xe2, 0xd7, 0x41, 0x15, 0x97, 0xb9, 0x66, 0x87, 0x29, 0xa2, 0x2e, 0xac, 0x0c, 0x1c, - 0xd7, 0xc0, 0x0f, 0x71, 0x6f, 0x14, 0x10, 0x43, 0x83, 0xd1, 0xd7, 0x37, 0x88, 0x06, 0x8e, 0xab, - 0x84, 0xfa, 0xdc, 0x6c, 0xe9, 0x4f, 0x09, 0xd2, 0x9f, 0x04, 0xa1, 0x37, 0xdd, 0x07, 0x04, 0x65, - 0x21, 0xea, 0x70, 0x1f, 0xe3, 0x6a, 0xd4, 0xb1, 0x50, 0x19, 0x96, 0x4c, 0x6b, 0xe0, 0xb8, 0xbc, - 0x67, 0x17, 0xb4, 0x39, 0xa7, 0x2d, 0x6c, 0x66, 0x19, 0x92, 0x07, 0xd8, 0x0b, 0x52, 0xc4, 0x7a, - 0x39, 0xae, 0x86, 0x47, 0xf4, 0x36, 0x2c, 0x53, 0x42, 0xcd, 0xbe, 0x21, 0x06, 0x64, 0x89, 0x69, - 0x66, 0x98, 0x6c, 0x97, 0x4f, 0x49, 0x03, 0xa0, 0xe7, 0x61, 0x93, 0xf2, 0x59, 0x48, 0x9c, 0x61, - 0x16, 0xd2, 0x42, 0xaf, 0x46, 0x4b, 0xf7, 0x21, 0xc3, 0x42, 0x15, 0x53, 0xbc, 0x06, 0x29, 0x56, - 0x74, 0xe3, 0x28, 0xe4, 0x24, 0x3b, 0x37, 0x2d, 0x54, 0x81, 0x04, 0x6f, 0x7f, 0x91, 0xde, 0xd3, - 0x66, 0x45, 0x15, 0xb4, 0xd2, 0xab, 0x28, 0xe4, 0x98, 0x6d, 0x5e, 0x7e, 0x96, 0xcc, 0x37, 0xd9, - 0x12, 0x93, 0x3e, 0x45, 0xa7, 0x7d, 0x3a, 0xaa, 0x45, 0xec, 0xec, 0xb5, 0x88, 0x9f, 0x5e, 0x8b, - 0xa5, 0xe9, 0x5a, 0x7c, 0x0a, 0x39, 0x4b, 0x74, 0xb2, 0x31, 0x64, 0xb1, 0x88, 0x6c, 0xaf, 0xcc, - 0x65, 0xbb, 0xe6, 0x8e, 0xeb, 0x27, 0x4c, 0x83, 0x9a, 0xb5, 0xa6, 0x67, 0x72, 0xba, 0x76, 0xc9, - 0x37, 0xaa, 0xdd, 0xcd, 0xd4, 0xa3, 0x27, 0xc5, 0xc8, 0xab, 0x27, 0x45, 0xa9, 0xf4, 0xe3, 0x12, - 0xa4, 0x3a, 0x1e, 0x19, 0x12, 0xdf, 0xec, 0xcf, 0x35, 0xec, 0x1d, 0x58, 0xe1, 0xf9, 0xe3, 0xbe, - 0x1b, 0x61, 0x01, 0xfe, 0xa9, 0x7f, 0x91, 0x7d, 0x5c, 0x3c, 0x81, 0x2c, 0x6c, 0xe6, 0x0f, 0x20, - 0x3d, 0x64, 0x3e, 0x04, 0xfb, 0x34, 0xbe, 0x19, 0x5b, 0x68, 0xfc, 0x98, 0x8a, 0x14, 0xc8, 0xf8, - 0xa3, 0xbd, 0x81, 0x43, 0x8d, 0xe0, 0x51, 0x62, 0xc9, 0x7f, 0xdd, 0x64, 0x00, 0x57, 0x0c, 0x20, - 0xf4, 0x0e, 0x9c, 0xe3, 0x61, 0x86, 0x55, 0x4c, 0xb0, 0x0c, 0x2c, 0x33, 0xe1, 0x8e, 0x28, 0xe5, - 0xd5, 0x99, 0x5c, 0x84, 0xdc, 0x24, 0xe3, 0x4e, 0x46, 0x1c, 0x6a, 0xdc, 0x80, 0x84, 0x4f, 0x4d, - 0x3a, 0xf2, 0xe5, 0xd4, 0xa6, 0xb4, 0x95, 0xad, 0x16, 0xe7, 0xda, 0x3e, 0x4c, 0xbc, 0xc6, 0x68, - 0xaa, 0xa0, 0xa3, 0x0e, 0xa0, 0x07, 0x8e, 0x6b, 0xf6, 0x0d, 0x6a, 0xf6, 0xfb, 0x63, 0xc3, 0xc3, - 0xfe, 0xa8, 0x4f, 0xe5, 0x34, 0x8b, 0xee, 0xe2, 0x9c, 0x11, 0x3d, 0x20, 0xa9, 0x8c, 0x23, 0x1e, - 0x9b, 0x3c, 0xd3, 0x9e, 0x90, 0xa3, 0x0e, 0xfc, 0x6f, 0x6a, 0x71, 0x1a, 0xd8, 0xb5, 0x64, 0x38, - 0x43, 0xba, 0x72, 0x93, 0xdb, 0x53, 0x71, 0x2d, 0xd4, 0x81, 0x1c, 0x5f, 0x9e, 0xc4, 0x0b, 0x1d, - 0xcc, 0xb0, 0x28, 0xdf, 0x3b, 0x35, 0x4a, 0x45, 0xf0, 0xb9, 0x4f, 0x6a, 0x16, 0x4f, 0x9d, 0xd1, - 0xd5, 0xa0, 0x41, 0x7c, 0xdf, 0xb4, 0xb1, 0x2f, 0x2f, 0xb3, 0x37, 0xf5, 0xc4, 0x21, 0x51, 0x8f, - 0x58, 0x37, 0xe3, 0x41, 0x17, 0x97, 0xbe, 0x91, 0x20, 0x33, 0x19, 0xeb, 0x06, 0xa4, 0xc7, 0xd8, - 0x37, 0x7a, 0x64, 0xe4, 0x52, 0xf1, 0x66, 0xa5, 0xc6, 0xd8, 0x6f, 0x04, 0xe7, 0xa0, 0xd4, 0xe6, - 0x9e, 0x4f, 0x4d, 0xc7, 0x15, 0x04, 0xfe, 0xef, 0xc3, 0xb2, 0x10, 0x72, 0xd2, 0x1a, 0xa4, 0x5c, - 0x22, 0x70, 0xde, 0xaa, 0x49, 0x97, 0x70, 0xe8, 0x7d, 0x40, 0x2e, 0x31, 0x0e, 0x1d, 0xba, 0x6f, - 0x1c, 0x60, 0x1a, 0x92, 0xf8, 0x42, 0xc8, 0xb9, 0x64, 0xd7, 0xa1, 0xfb, 0x3b, 0x98, 0x72, 0xb2, - 0xf0, 0xef, 0x2f, 0x09, 0xe2, 0x3b, 0x84, 0x62, 0x54, 0x84, 0xcc, 0x50, 0xa4, 0xe2, 0x78, 0x49, - 0x42, 0x28, 0xe2, 0x3b, 0xe9, 0x80, 0x50, 0xb1, 0x26, 0x17, 0xee, 0x24, 0x46, 0x43, 0xd7, 0x21, - 0x41, 0x86, 0xc1, 0xeb, 0xc3, 0xbc, 0xcc, 0x56, 0x37, 0xe6, 0x52, 0x1f, 0xdc, 0xdb, 0x66, 0x14, - 0x55, 0x50, 0x17, 0x2e, 0xb2, 0x7f, 0x67, 0x9e, 0x2e, 0x7f, 0x25, 0x01, 0x1c, 0xdf, 0x8c, 0x36, - 0x60, 0x75, 0xa7, 0xad, 0x2b, 0x46, 0xbb, 0xa3, 0x37, 0xdb, 0x2d, 0xa3, 0xdb, 0xd2, 0x3a, 0x4a, - 0xa3, 0x79, 0xab, 0xa9, 0x6c, 0xe7, 0x23, 0xe8, 0x3c, 0xe4, 0x26, 0xc1, 0xfb, 0x8a, 0x96, 0x97, - 0xd0, 0x2a, 0x9c, 0x9f, 0x14, 0xd6, 0xea, 0x9a, 0x5e, 0x6b, 0xb6, 0xf2, 0x51, 0x84, 0x20, 0x3b, - 0x09, 0xb4, 0xda, 0xf9, 0x18, 0xba, 0x08, 0xf2, 0xb4, 0xcc, 0xd8, 0x6d, 0xea, 0xb7, 0x8d, 0x1d, - 0x45, 0x6f, 0xe7, 0xe3, 0xeb, 0xf1, 0x47, 0xdf, 0x16, 0x22, 0x97, 0x7f, 0x96, 0x20, 0x3b, 0x3d, - 0x6c, 0xa8, 0x08, 0x1b, 0x1d, 0xb5, 0xdd, 0x69, 0x6b, 0xb5, 0xbb, 0x86, 0xa6, 0xd7, 0xf4, 0xae, - 0x36, 0xe3, 0xd9, 0x5b, 0xb0, 0x36, 0x4b, 0xd0, 0xba, 0xf5, 0x7b, 0x4d, 0x5d, 0x57, 0xb6, 0xf3, - 0x52, 0x70, 0xed, 0x2c, 0x5c, 0x6b, 0x34, 0x94, 0x4e, 0x80, 0x46, 0x4f, 0x42, 0x55, 0xe5, 0x8e, - 0xd2, 0x08, 0xd0, 0x58, 0x90, 0x91, 0x39, 0xdd, 0x7a, 0x5b, 0x0d, 0xc0, 0xf8, 0x49, 0xf7, 0x06, - 0x01, 0x6d, 0xab, 0xb5, 0xdd, 0x56, 0x7e, 0x49, 0x04, 0xf4, 0x83, 0x04, 0x17, 0x4e, 0x9e, 0x2b, - 0xb4, 0x05, 0x97, 0x8e, 0xf4, 0x95, 0xcf, 0x94, 0x46, 0x57, 0x6f, 0xab, 0x86, 0xaa, 0x68, 0xdd, - 0xbb, 0xfa, 0x4c, 0x84, 0x97, 0x60, 0xf3, 0x54, 0x66, 0xab, 0xad, 0x1b, 0x6a, 0xb7, 0x95, 0x97, - 0x16, 0xb2, 0xb4, 0x6e, 0xa3, 0xa1, 0x68, 0x5a, 0x3e, 0xba, 0x90, 0x75, 0xab, 0xd6, 0xbc, 0xdb, - 0x55, 0x95, 0x7c, 0x8c, 0x3b, 0x5f, 0xff, 0xf0, 0xd9, 0x8b, 0x82, 0xf4, 0xfc, 0x45, 0x41, 0xfa, - 0xe3, 0x45, 0x41, 0x7a, 0xfc, 0xb2, 0x10, 0x79, 0xfe, 0xb2, 0x10, 0xf9, 0xf5, 0x65, 0x21, 0xf2, - 0xf9, 0x25, 0xdb, 0xa1, 0xfb, 0xa3, 0xbd, 0x72, 0x8f, 0x0c, 0xc4, 0x97, 0x84, 0xf8, 0x73, 0xc5, - 0xb7, 0xbe, 0xa8, 0x3c, 0xe4, 0x1f, 0x3a, 0x7b, 0x09, 0xd6, 0x89, 0xd7, 0xff, 0x0e, 0x00, 0x00, - 0xff, 0xff, 0x5b, 0x5c, 0x1c, 0x07, 0xff, 0x0c, 0x00, 0x00, + // 1299 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xf6, 0xda, 0x8e, 0x3f, 0x5e, 0xa7, 0xb6, 0x99, 0x86, 0x66, 0x93, 0x14, 0x3b, 0x98, 0x0a, + 0xa2, 0xa2, 0xd8, 0x6d, 0x2a, 0x81, 0xd4, 0x03, 0x60, 0x3b, 0x5b, 0xea, 0xaa, 0xb5, 0xad, 0xdd, + 0x75, 0x42, 0xb9, 0xac, 0x36, 0xde, 0xe9, 0x66, 0x85, 0xbd, 0x63, 0x76, 0xc7, 0x49, 0xfd, 0x0f, + 0x7a, 0x41, 0xf4, 0xc8, 0x05, 0xa9, 0x12, 0xbf, 0x00, 0xa9, 0x07, 0xc4, 0x85, 0x6b, 0xd5, 0x03, + 0xaa, 0x38, 0x71, 0x02, 0xd4, 0x5e, 0xe0, 0xc4, 0x95, 0x23, 0xda, 0x99, 0xd9, 0xc4, 0x1f, 0x89, + 0x69, 0x2a, 0xe0, 0x94, 0xcc, 0x3c, 0xcf, 0xfb, 0xce, 0xf3, 0x7e, 0xae, 0x0c, 0x6b, 0x5d, 0xe2, + 0xf7, 0x89, 0x5f, 0xb1, 0x3d, 0x32, 0x1c, 0x54, 0x0e, 0xae, 0x56, 0xe8, 0x68, 0x80, 0xfd, 0xf2, + 0xc0, 0x23, 0x94, 0xa0, 0x1c, 0x07, 0xcb, 0x0c, 0x2c, 0x1f, 0x5c, 0x5d, 0x5d, 0xb2, 0x89, 0x4d, + 0x18, 0x56, 0x09, 0xfe, 0xe3, 0xb4, 0xd5, 0x82, 0x4d, 0x88, 0xdd, 0xc3, 0x15, 0x76, 0xda, 0x1b, + 0xde, 0xab, 0x58, 0x43, 0xcf, 0xa4, 0x0e, 0x71, 0x05, 0x5e, 0x9c, 0xc6, 0xa9, 0xd3, 0xc7, 0x3e, + 0x35, 0xfb, 0x03, 0x41, 0x58, 0xe1, 0xef, 0x18, 0xdc, 0xb3, 0x78, 0x54, 0x40, 0xd3, 0xb6, 0xa6, + 0x3b, 0xe2, 0x50, 0xe9, 0x5b, 0x09, 0x12, 0x77, 0x70, 0x7f, 0x0f, 0x7b, 0x68, 0x0b, 0x92, 0xa6, + 0x65, 0x79, 0xd8, 0xf7, 0x65, 0x69, 0x5d, 0xda, 0x48, 0xd7, 0xe4, 0x9f, 0x1e, 0x6f, 0x2e, 0x09, + 0x47, 0x55, 0x8e, 0x68, 0xd4, 0x73, 0x5c, 0x5b, 0x0d, 0x89, 0xe8, 0x02, 0x24, 0x0e, 0xb1, 0x63, + 0xef, 0x53, 0x39, 0x1a, 0x98, 0xa8, 0xe2, 0x84, 0x56, 0x21, 0xd5, 0xc7, 0xd4, 0xb4, 0x4c, 0x6a, + 0xca, 0x31, 0x86, 0x1c, 0x9d, 0xd1, 0x87, 0x90, 0x32, 0x2d, 0x0b, 0x5b, 0x86, 0x49, 0xe5, 0xf8, + 0xba, 0xb4, 0x91, 0xd9, 0x5a, 0x2d, 0x73, 0x81, 0xe5, 0x50, 0x60, 0x59, 0x0f, 0x83, 0xab, 0xa5, + 0x9e, 0xfc, 0x52, 0x8c, 0x3c, 0xfc, 0xb5, 0x28, 0xb1, 0x47, 0xb1, 0x55, 0xa5, 0xa5, 0x43, 0x38, + 0xc7, 0x25, 0xab, 0xf8, 0xf3, 0x21, 0xf6, 0xe9, 0xff, 0xa5, 0xbc, 0xf4, 0x85, 0x04, 0xcb, 0xfa, + 0xbe, 0x87, 0xfd, 0x7d, 0xd2, 0xb3, 0xb6, 0x71, 0xd7, 0xf1, 0x1d, 0xe2, 0xb6, 0x49, 0xcf, 0xe9, + 0x8e, 0xd0, 0x45, 0x48, 0xd3, 0x10, 0xe2, 0x2a, 0xd4, 0xe3, 0x0b, 0xf4, 0x11, 0x24, 0x0f, 0x1d, + 0xd7, 0x22, 0x87, 0x3e, 0x7b, 0x2e, 0xb3, 0xf5, 0x76, 0x79, 0xaa, 0x2d, 0xca, 0x93, 0xfe, 0x76, + 0x39, 0x5b, 0x0d, 0xcd, 0xae, 0xa3, 0xa7, 0x8f, 0x37, 0xb3, 0x93, 0x9c, 0xd2, 0x43, 0x09, 0xe4, + 0x36, 0xf6, 0xba, 0xd8, 0xa5, 0xa6, 0x8d, 0xa7, 0x04, 0x15, 0x00, 0x06, 0x47, 0x98, 0x50, 0x34, + 0x76, 0xf3, 0x1f, 0x49, 0xfa, 0x4e, 0x82, 0xd7, 0x4f, 0x34, 0x43, 0x37, 0xe1, 0xdc, 0x01, 0xa1, + 0x8e, 0x6b, 0x1b, 0x03, 0xec, 0x39, 0x84, 0x27, 0x29, 0xb3, 0xb5, 0x32, 0x53, 0xfb, 0x6d, 0xd1, + 0xf8, 0xbc, 0xf4, 0x5f, 0x05, 0xa5, 0x5f, 0xe4, 0x96, 0x6d, 0x66, 0x88, 0x3a, 0xb0, 0xd4, 0x77, + 0x5c, 0x03, 0xdf, 0xc7, 0xdd, 0x61, 0x40, 0x0c, 0x1d, 0x46, 0x5f, 0xde, 0x21, 0xea, 0x3b, 0xae, + 0x12, 0xda, 0x73, 0xb7, 0xa5, 0x3f, 0x24, 0x48, 0x7f, 0x1c, 0x84, 0xde, 0x70, 0xef, 0x11, 0x94, + 0x85, 0xa8, 0xc3, 0x35, 0xc6, 0xd5, 0xa8, 0x63, 0xa1, 0x32, 0x2c, 0x98, 0x56, 0xdf, 0x71, 0x79, + 0xbb, 0xcc, 0xe9, 0x30, 0x4e, 0x9b, 0x3b, 0x01, 0x32, 0x24, 0x0f, 0xb0, 0x17, 0xa4, 0x88, 0x0d, + 0x40, 0x5c, 0x0d, 0x8f, 0xe8, 0x4d, 0x58, 0xa4, 0x84, 0x9a, 0x3d, 0x43, 0xf4, 0xe6, 0x02, 0xb3, + 0xcc, 0xb0, 0xbb, 0x5d, 0xde, 0xa0, 0x75, 0x80, 0xae, 0x87, 0x4d, 0xca, 0x07, 0x28, 0x71, 0x86, + 0x01, 0x4a, 0x0b, 0xbb, 0x2a, 0x2d, 0xdd, 0x85, 0x0c, 0x0b, 0x55, 0x8c, 0xfe, 0x0a, 0xa4, 0x58, + 0xd1, 0x8d, 0xa3, 0x90, 0x93, 0xec, 0xdc, 0xb0, 0x50, 0x05, 0x12, 0x7d, 0x46, 0x12, 0xe9, 0x5d, + 0x9e, 0xe9, 0x12, 0x31, 0x8b, 0x82, 0x56, 0xfa, 0x2b, 0x0a, 0x39, 0xe6, 0x9b, 0x97, 0x9f, 0x25, + 0xf3, 0x55, 0x06, 0x74, 0x5c, 0x53, 0x74, 0x52, 0xd3, 0x51, 0x2d, 0x62, 0x67, 0xaf, 0x45, 0xfc, + 0xf4, 0x5a, 0x2c, 0x4c, 0xd6, 0xc2, 0x84, 0x9c, 0x25, 0x3a, 0xd9, 0x18, 0xb0, 0x58, 0x44, 0xb6, + 0x97, 0x66, 0xb2, 0x5d, 0x75, 0x47, 0xb5, 0xd2, 0xd3, 0xc7, 0x9b, 0x85, 0xf9, 0x13, 0xa4, 0x66, + 0xad, 0xc9, 0x19, 0x9d, 0xac, 0x65, 0xf2, 0x95, 0x6a, 0x79, 0x3d, 0xf5, 0xe0, 0x51, 0x31, 0xf2, + 0xfb, 0xa3, 0xa2, 0x54, 0xfa, 0x61, 0x01, 0x52, 0x6d, 0x8f, 0x0c, 0x88, 0x6f, 0xf6, 0x66, 0x1a, + 0xf8, 0x16, 0x2c, 0xf1, 0x7c, 0xf2, 0x58, 0x8c, 0xb0, 0x20, 0xff, 0xd4, 0xcf, 0xc8, 0x3e, 0x2e, + 0xa6, 0x40, 0xe6, 0x36, 0xf7, 0x7b, 0x90, 0x1e, 0x30, 0x0d, 0xd8, 0xf3, 0xe5, 0xf8, 0x7a, 0x6c, + 0xae, 0xf3, 0x63, 0x2a, 0x52, 0x20, 0xe3, 0x0f, 0xf7, 0xfa, 0x0e, 0x35, 0x82, 0x2f, 0x1b, 0x2b, + 0xc6, 0xcb, 0x26, 0x03, 0xb8, 0x61, 0x00, 0xa1, 0xb7, 0xe0, 0x1c, 0x0f, 0x33, 0xac, 0x6a, 0x82, + 0x65, 0x60, 0x91, 0x5d, 0xee, 0x88, 0xd2, 0x5e, 0x99, 0xca, 0x45, 0xc8, 0x4d, 0x32, 0xee, 0x78, + 0xc4, 0xa1, 0xc5, 0xfb, 0x90, 0xf0, 0xa9, 0x49, 0x87, 0xbe, 0x9c, 0x5a, 0x97, 0x36, 0xb2, 0x5b, + 0xc5, 0x99, 0x31, 0x08, 0x13, 0xaf, 0x31, 0x9a, 0x2a, 0xe8, 0xa8, 0x0d, 0xe8, 0x9e, 0xe3, 0x9a, + 0x3d, 0x83, 0x9a, 0xbd, 0xde, 0xc8, 0xf0, 0xb0, 0x3f, 0xec, 0x51, 0x39, 0xcd, 0xa2, 0xbb, 0x38, + 0xe3, 0x44, 0x0f, 0x48, 0x2a, 0xe3, 0xd4, 0xe2, 0x41, 0x7c, 0x6a, 0x9e, 0x59, 0x8f, 0xdd, 0xa3, + 0x36, 0xbc, 0x36, 0xb1, 0x48, 0x0d, 0xec, 0x5a, 0x32, 0x9c, 0x21, 0x5d, 0xb9, 0xf1, 0x6d, 0xaa, + 0xb8, 0x16, 0x6a, 0x43, 0x8e, 0x2f, 0x53, 0xe2, 0x85, 0x02, 0x33, 0x2c, 0xca, 0x77, 0x4e, 0x8d, + 0x52, 0x11, 0x7c, 0xae, 0x49, 0xcd, 0xe2, 0x89, 0x33, 0xba, 0x12, 0x34, 0x88, 0xef, 0x9b, 0x36, + 0xf6, 0xe5, 0xc5, 0xf5, 0xd8, 0x69, 0x43, 0xa3, 0x1e, 0xb1, 0xae, 0xc7, 0x83, 0x2e, 0x2e, 0x7d, + 0x2d, 0x41, 0x66, 0x3c, 0xd6, 0x35, 0x48, 0x8f, 0xb0, 0x6f, 0x74, 0xc9, 0xd0, 0xa5, 0xe2, 0x1b, + 0x96, 0x1a, 0x61, 0xbf, 0x1e, 0x9c, 0x83, 0x52, 0x9b, 0x7b, 0x3e, 0x35, 0x1d, 0x57, 0x10, 0xf8, + 0x97, 0x7c, 0x51, 0x5c, 0x72, 0xd2, 0x0a, 0xa4, 0x5c, 0x22, 0x70, 0xde, 0xaa, 0x49, 0x97, 0x70, + 0xe8, 0x5d, 0x40, 0x2e, 0x31, 0x0e, 0x1d, 0xba, 0x6f, 0x1c, 0x60, 0x1a, 0x92, 0xf8, 0x82, 0xc8, + 0xb9, 0x64, 0xd7, 0xa1, 0xfb, 0x3b, 0x98, 0x72, 0xb2, 0xd0, 0xf7, 0xa7, 0x04, 0xf1, 0x1d, 0x42, + 0x31, 0x2a, 0x42, 0x66, 0x20, 0x52, 0x71, 0xbc, 0x34, 0x21, 0xbc, 0xe2, 0x3b, 0xea, 0x80, 0x50, + 0xb1, 0x36, 0xe7, 0xee, 0x28, 0x46, 0x43, 0xd7, 0x20, 0x41, 0x06, 0xc1, 0xd7, 0x88, 0xa9, 0xcc, + 0x6e, 0xad, 0xcd, 0xa4, 0x3e, 0x78, 0xb7, 0xc5, 0x28, 0xaa, 0xa0, 0xce, 0x5d, 0x6c, 0xff, 0xce, + 0x3c, 0x5d, 0xfe, 0x52, 0x02, 0x38, 0x7e, 0x19, 0xad, 0xc1, 0xf2, 0x4e, 0x4b, 0x57, 0x8c, 0x56, + 0x5b, 0x6f, 0xb4, 0x9a, 0x46, 0xa7, 0xa9, 0xb5, 0x95, 0x7a, 0xe3, 0x46, 0x43, 0xd9, 0xce, 0x47, + 0xd0, 0x79, 0xc8, 0x8d, 0x83, 0x77, 0x15, 0x2d, 0x2f, 0xa1, 0x65, 0x38, 0x3f, 0x7e, 0x59, 0xad, + 0x69, 0x7a, 0xb5, 0xd1, 0xcc, 0x47, 0x11, 0x82, 0xec, 0x38, 0xd0, 0x6c, 0xe5, 0x63, 0xe8, 0x22, + 0xc8, 0x93, 0x77, 0xc6, 0x6e, 0x43, 0xbf, 0x69, 0xec, 0x28, 0x7a, 0x2b, 0x1f, 0x5f, 0x8d, 0x3f, + 0xf8, 0xa6, 0x10, 0xb9, 0xfc, 0xa3, 0x04, 0xd9, 0xc9, 0x61, 0x43, 0x45, 0x58, 0x6b, 0xab, 0xad, + 0x76, 0x4b, 0xab, 0xde, 0x36, 0x34, 0xbd, 0xaa, 0x77, 0xb4, 0x29, 0x65, 0x6f, 0xc0, 0xca, 0x34, + 0x41, 0xeb, 0xd4, 0xee, 0x34, 0x74, 0x5d, 0xd9, 0xce, 0x4b, 0xc1, 0xb3, 0xd3, 0x70, 0xb5, 0x5e, + 0x57, 0xda, 0x01, 0x1a, 0x3d, 0x09, 0x55, 0x95, 0x5b, 0x4a, 0x3d, 0x40, 0x63, 0x41, 0x46, 0x66, + 0x6c, 0x6b, 0x2d, 0x35, 0x00, 0xe3, 0x27, 0xbd, 0x1b, 0x04, 0xb4, 0xad, 0x56, 0x77, 0x9b, 0xf9, + 0x05, 0x11, 0xd0, 0xf7, 0x12, 0x5c, 0x38, 0x79, 0xae, 0xd0, 0x06, 0x5c, 0x3a, 0xb2, 0x57, 0x3e, + 0x51, 0xea, 0x1d, 0xbd, 0xa5, 0x1a, 0xaa, 0xa2, 0x75, 0x6e, 0xeb, 0x53, 0x11, 0x5e, 0x82, 0xf5, + 0x53, 0x99, 0xcd, 0x96, 0x6e, 0xa8, 0x9d, 0x66, 0x5e, 0x9a, 0xcb, 0xd2, 0x3a, 0xf5, 0xba, 0xa2, + 0x69, 0xf9, 0xe8, 0x5c, 0xd6, 0x8d, 0x6a, 0xe3, 0x76, 0x47, 0x55, 0xf2, 0x31, 0x2e, 0xbe, 0xf6, + 0xc1, 0x93, 0xe7, 0x05, 0xe9, 0xd9, 0xf3, 0x82, 0xf4, 0xdb, 0xf3, 0x82, 0xf4, 0xf0, 0x45, 0x21, + 0xf2, 0xec, 0x45, 0x21, 0xf2, 0xf3, 0x8b, 0x42, 0xe4, 0xd3, 0x4b, 0xb6, 0x43, 0xf7, 0x87, 0x7b, + 0xe5, 0x2e, 0xe9, 0x8b, 0x9f, 0x23, 0xe2, 0xcf, 0xa6, 0x6f, 0x7d, 0x56, 0xb9, 0xcf, 0x7f, 0x2d, + 0xed, 0x25, 0x58, 0x27, 0x5e, 0xfb, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xea, 0x13, 0x0f, 0x14, 0x44, + 0x0d, 0x00, 0x00, } func (this *GroupPolicyInfo) Equal(that interface{}) bool { @@ -1065,7 +1085,7 @@ func (m *Member) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Members) Marshal() (dAtA []byte, err error) { +func (m *MemberRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1075,29 +1095,36 @@ func (m *Members) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Members) MarshalTo(dAtA []byte) (int, error) { +func (m *MemberRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Members) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MemberRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Members) > 0 { - for iNdEx := len(m.Members) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Members[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if len(m.Metadata) > 0 { + i -= len(m.Metadata) + copy(dAtA[i:], m.Metadata) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Metadata))) + i-- + dAtA[i] = 0x1a + } + if len(m.Weight) > 0 { + i -= len(m.Weight) + copy(dAtA[i:], m.Weight) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Weight))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -1652,17 +1679,23 @@ func (m *Member) Size() (n int) { return n } -func (m *Members) Size() (n int) { +func (m *MemberRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.Members) > 0 { - for _, e := range m.Members { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) - } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Weight) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Metadata) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) } return n } @@ -2077,7 +2110,7 @@ func (m *Member) Unmarshal(dAtA []byte) error { } return nil } -func (m *Members) Unmarshal(dAtA []byte) error { +func (m *MemberRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2100,17 +2133,17 @@ func (m *Members) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Members: wiretype end group for non-group") + return fmt.Errorf("proto: MemberRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Members: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MemberRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Members", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -2120,25 +2153,87 @@ func (m *Members) 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 ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - m.Members = append(m.Members, Member{}) - if err := m.Members[len(m.Members)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Weight", wireType) } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Weight = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + 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 ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Metadata = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/group/typesupport.go b/x/group/typesupport.go index f89dc2c3b83b..1b94a8b466de 100644 --- a/x/group/typesupport.go +++ b/x/group/typesupport.go @@ -6,7 +6,15 @@ import ( "github.com/cosmos/cosmos-sdk/x/group/errors" ) -func (ms Members) ValidateBasic() error { +// MemberRequests defines a repeated slice of MemberRequest objects. +type MemberRequests struct { + Members []MemberRequest +} + +// ValidateBasic performs stateless validation on an array of members. On top +// of validating each member individually, it also makes sure there are no +// duplicate addresses. +func (ms MemberRequests) ValidateBasic() error { index := make(map[string]struct{}, len(ms.Members)) for i := range ms.Members { member := ms.Members[i] @@ -22,11 +30,11 @@ func (ms Members) ValidateBasic() error { return nil } -type AccAddresses []sdk.AccAddress +type accAddresses []sdk.AccAddress // ValidateBasic verifies that there's no duplicate address. // Individual account address validation has to be done separately. -func (a AccAddresses) ValidateBasic() error { +func (a accAddresses) ValidateBasic() error { index := make(map[string]struct{}, len(a)) for i := range a { accAddr := a[i] diff --git a/x/mint/client/cli/query.go b/x/mint/client/cli/query.go index 792fa8a6798f..6bf31ba5a179 100644 --- a/x/mint/client/cli/query.go +++ b/x/mint/client/cli/query.go @@ -45,7 +45,6 @@ func GetCmdQueryParams() *cobra.Command { params := &types.QueryParamsRequest{} res, err := queryClient.Params(cmd.Context(), params) - if err != nil { return err } @@ -75,7 +74,6 @@ func GetCmdQueryInflation() *cobra.Command { params := &types.QueryInflationRequest{} res, err := queryClient.Inflation(cmd.Context(), params) - if err != nil { return err } @@ -105,7 +103,6 @@ func GetCmdQueryAnnualProvisions() *cobra.Command { params := &types.QueryAnnualProvisionsRequest{} res, err := queryClient.AnnualProvisions(cmd.Context(), params) - if err != nil { return err } diff --git a/x/mint/client/testutil/cli_test.go b/x/mint/client/testutil/cli_test.go index dd36a6af2d3e..1035ca750264 100644 --- a/x/mint/client/testutil/cli_test.go +++ b/x/mint/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/mint/genesis.go b/x/mint/keeper/genesis.go similarity index 63% rename from x/mint/genesis.go rename to x/mint/keeper/genesis.go index be7ac61d5019..c6a120bee7fe 100644 --- a/x/mint/genesis.go +++ b/x/mint/keeper/genesis.go @@ -1,20 +1,19 @@ -package mint +package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/mint/keeper" "github.com/cosmos/cosmos-sdk/x/mint/types" ) // InitGenesis new mint genesis -func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, ak types.AccountKeeper, data *types.GenesisState) { +func (keeper Keeper) InitGenesis(ctx sdk.Context, ak types.AccountKeeper, data *types.GenesisState) { keeper.SetMinter(ctx, data.Minter) keeper.SetParams(ctx, data.Params) ak.GetModuleAccount(ctx, types.ModuleName) } // ExportGenesis returns a GenesisState for a given context and keeper. -func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { +func (keeper Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { minter := keeper.GetMinter(ctx) params := keeper.GetParams(ctx) return types.NewGenesisState(minter, params) diff --git a/x/mint/migrations/v039/types.go b/x/mint/migrations/v039/types.go deleted file mode 100644 index 10b351b7fb8f..000000000000 --- a/x/mint/migrations/v039/types.go +++ /dev/null @@ -1,31 +0,0 @@ -package v039 - -import sdk "github.com/cosmos/cosmos-sdk/types" - -const ( - ModuleName = "mint" -) - -type ( - // Minter represents the minting state. - Minter struct { - Inflation sdk.Dec `json:"inflation" yaml:"inflation"` // current annual inflation rate - AnnualProvisions sdk.Dec `json:"annual_provisions" yaml:"annual_provisions"` // current annual expected provisions - } - - // mint parameters - Params struct { - MintDenom string `json:"mint_denom" yaml:"mint_denom"` // type of coin to mint - InflationRateChange sdk.Dec `json:"inflation_rate_change" yaml:"inflation_rate_change"` // maximum annual change in inflation rate - InflationMax sdk.Dec `json:"inflation_max" yaml:"inflation_max"` // maximum inflation rate - InflationMin sdk.Dec `json:"inflation_min" yaml:"inflation_min"` // minimum inflation rate - GoalBonded sdk.Dec `json:"goal_bonded" yaml:"goal_bonded"` // goal of percent bonded atoms - BlocksPerYear uint64 `json:"blocks_per_year" yaml:"blocks_per_year"` // expected blocks per year - } - - // GenesisState - minter state - GenesisState struct { - Minter Minter `json:"minter" yaml:"minter"` // minter object - Params Params `json:"params" yaml:"params"` // inflation params - } -) diff --git a/x/mint/migrations/v040/migrate.go b/x/mint/migrations/v040/migrate.go deleted file mode 100644 index 66eb0f000100..000000000000 --- a/x/mint/migrations/v040/migrate.go +++ /dev/null @@ -1,27 +0,0 @@ -package v040 - -import ( - v039mint "github.com/cosmos/cosmos-sdk/x/mint/migrations/v039" - v040mint "github.com/cosmos/cosmos-sdk/x/mint/types" -) - -// Migrate accepts exported v0.39 x/mint genesis state and -// migrates it to v0.40 x/mint genesis state. The migration includes: -// -// - Re-encode in v0.40 GenesisState. -func Migrate(mintGenState v039mint.GenesisState) *v040mint.GenesisState { - return &v040mint.GenesisState{ - Minter: v040mint.Minter{ - Inflation: mintGenState.Minter.Inflation, - AnnualProvisions: mintGenState.Minter.AnnualProvisions, - }, - Params: v040mint.Params{ - MintDenom: mintGenState.Params.MintDenom, - InflationRateChange: mintGenState.Params.InflationRateChange, - InflationMax: mintGenState.Params.InflationMax, - InflationMin: mintGenState.Params.InflationMin, - GoalBonded: mintGenState.Params.GoalBonded, - BlocksPerYear: mintGenState.Params.BlocksPerYear, - }, - } -} diff --git a/x/mint/migrations/v040/types.go b/x/mint/migrations/v040/types.go deleted file mode 100644 index d725b48c34fb..000000000000 --- a/x/mint/migrations/v040/types.go +++ /dev/null @@ -1,5 +0,0 @@ -package v040 - -const ( - ModuleName = "mint" -) diff --git a/x/mint/module.go b/x/mint/module.go index be5ba7fdf2f9..658d49ecd60e 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -63,11 +62,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the mint module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/mint` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the mint module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { @@ -142,14 +136,14 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - InitGenesis(ctx, am.keeper, am.authKeeper, &genesisState) + am.keeper.InitGenesis(ctx, am.authKeeper, &genesisState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the mint // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - gs := ExportGenesis(ctx, am.keeper) + gs := am.keeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(gs) } diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index ac57da7acc06..93abcff65d95 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -31,7 +32,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/mint/simulation/params_test.go b/x/mint/simulation/params_test.go index 6bc0f624cf37..3334fbd51a97 100644 --- a/x/mint/simulation/params_test.go +++ b/x/mint/simulation/params_test.go @@ -34,5 +34,4 @@ func TestParamChangest(t *testing.T) { require.Equal(t, expected[i].simValue, p.SimValue()(r)) require.Equal(t, expected[i].subspace, p.Subspace()) } - } diff --git a/x/mint/spec/03_begin_block.md b/x/mint/spec/03_begin_block.md index ede3d2c328a6..67bd7d8a8f53 100644 --- a/x/mint/spec/03_begin_block.md +++ b/x/mint/spec/03_begin_block.md @@ -7,7 +7,19 @@ order: 3 Minting parameters are recalculated and inflation paid at the beginning of each block. -## NextInflationRate +## Inflation rate calculation + +Inflation rate is calculated using an "inflation calculation function" that's +passed to the `NewAppModule` function. If no function is passed, then the SDK's +default inflation function will be used (`NextInflationRate`). In case a custom +inflation calculation logic is needed, this can be achieved by defining and +passing a function that matches `InflationCalculationFn`'s signature. + +```go +type InflationCalculationFn func(ctx sdk.Context, minter Minter, params Params, bondedRatio sdk.Dec) sdk.Dec +``` + +### NextInflationRate The target annual inflation rate is recalculated each block. The inflation is also subject to a rate change (positive or negative) diff --git a/x/mint/types/codec.go b/x/mint/types/codec.go index b436c10298d5..a7067d90c2c5 100644 --- a/x/mint/types/codec.go +++ b/x/mint/types/codec.go @@ -5,9 +5,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" ) -var ( - amino = codec.NewLegacyAmino() -) +var amino = codec.NewLegacyAmino() func init() { cryptocodec.RegisterCrypto(amino) diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index 4abedb51cd05..04de803a2e5e 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -25,12 +25,16 @@ func TestNextInflation(t *testing.T) { // 100% bonded, starting at 20% inflation and being reduced // (1 - (1/0.67))*(0.13/8667) - {sdk.OneDec(), sdk.NewDecWithPrec(20, 2), - sdk.OneDec().Sub(sdk.OneDec().Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr)}, + { + sdk.OneDec(), sdk.NewDecWithPrec(20, 2), + sdk.OneDec().Sub(sdk.OneDec().Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr), + }, // 50% bonded, starting at 10% inflation and being increased - {sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(10, 2), - sdk.OneDec().Sub(sdk.NewDecWithPrec(5, 1).Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr)}, + { + sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(10, 2), + sdk.OneDec().Sub(sdk.NewDecWithPrec(5, 1).Quo(params.GoalBonded)).Mul(params.InflationRateChange).Quo(blocksPerYr), + }, // test 7% minimum stop (testing with 100% bonded) {sdk.OneDec(), sdk.NewDecWithPrec(7, 2), sdk.ZeroDec()}, @@ -115,7 +119,6 @@ func BenchmarkNextInflation(b *testing.B) { for n := 0; n < b.N; n++ { minter.NextInflationRate(params, bondedRatio) } - } // Next annual provisions benchmarking @@ -130,5 +133,4 @@ func BenchmarkNextAnnualProvisions(b *testing.B) { for n := 0; n < b.N; n++ { minter.NextAnnualProvisions(params, totalSupply) } - } diff --git a/x/mint/types/params.go b/x/mint/types/params.go index c5bf838ac3f6..56c9b8aa783b 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -29,7 +29,6 @@ func ParamKeyTable() paramtypes.KeyTable { func NewParams( mintDenom string, inflationRateChange, inflationMax, inflationMin, goalBonded sdk.Dec, blocksPerYear uint64, ) Params { - return Params{ MintDenom: mintDenom, InflationRateChange: inflationRateChange, @@ -80,7 +79,6 @@ func (p Params) Validate() error { } return nil - } // String implements the Stringer interface. diff --git a/x/nft/keeper/genesis.go b/x/nft/keeper/genesis.go index f8cf05184c0c..6018ca2e076d 100644 --- a/x/nft/keeper/genesis.go +++ b/x/nft/keeper/genesis.go @@ -13,7 +13,6 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *nft.GenesisState) { if err := k.SaveClass(ctx, *class); err != nil { panic(err) } - } for _, entry := range data.Entries { for _, nft := range entry.Nfts { diff --git a/x/nft/keeper/grpc_query.go b/x/nft/keeper/grpc_query.go index f79641326e4c..e22fdf0b4a22 100644 --- a/x/nft/keeper/grpc_query.go +++ b/x/nft/keeper/grpc_query.go @@ -151,7 +151,6 @@ func (k Keeper) NFT(goCtx context.Context, r *nft.QueryNFTRequest) (*nft.QueryNF return nil, nft.ErrNFTNotExists.Wrapf("not found nft: class: %s, id: %s", r.ClassId, r.Id) } return &nft.QueryNFTResponse{Nft: &n}, nil - } // Class return an NFT class based on its id @@ -191,7 +190,6 @@ func (k Keeper) Classes(goCtx context.Context, r *nft.QueryClassesRequest) (*nft classes = append(classes, &class) return nil }) - if err != nil { return nil, err } diff --git a/x/nft/keeper/grpc_query_test.go b/x/nft/keeper/grpc_query_test.go index 20d0f0afbc7c..6f6090e5dd93 100644 --- a/x/nft/keeper/grpc_query_test.go +++ b/x/nft/keeper/grpc_query_test.go @@ -16,9 +16,7 @@ func TestGRPCQuery(t *testing.T) { } func (s *TestSuite) TestBalance() { - var ( - req *nft.QueryBalanceRequest - ) + var req *nft.QueryBalanceRequest testCases := []struct { msg string malleate func(index int, require *require.Assertions) @@ -169,9 +167,7 @@ func (s *TestSuite) TestOwner() { } func (s *TestSuite) TestSupply() { - var ( - req *nft.QuerySupplyRequest - ) + var req *nft.QuerySupplyRequest testCases := []struct { msg string malleate func(index int, require *require.Assertions) @@ -252,6 +248,7 @@ func (s *TestSuite) TestSupply() { }) } } + func (s *TestSuite) TestNFTs() { var ( req *nft.QueryNFTsRequest diff --git a/x/nft/keeper/keeper_test.go b/x/nft/keeper/keeper_test.go index 7e03f79eb582..9f18ab734116 100644 --- a/x/nft/keeper/keeper_test.go +++ b/x/nft/keeper/keeper_test.go @@ -279,7 +279,7 @@ func (s *TestSuite) TestTransfer() { err = s.app.NFTKeeper.Mint(s.ctx, expNFT, s.addrs[0]) s.Require().NoError(err) - //valid owner + // valid owner err = s.app.NFTKeeper.Transfer(s.ctx, testClassID, testID, s.addrs[1]) s.Require().NoError(err) diff --git a/x/nft/keeper/keys.go b/x/nft/keeper/keys.go index 6c65581db2d1..51df6e5c36a5 100644 --- a/x/nft/keeper/keys.go +++ b/x/nft/keeper/keys.go @@ -55,7 +55,7 @@ func nftOfClassByOwnerStoreKey(owner sdk.AccAddress, classID string) []byte { owner = address.MustLengthPrefix(owner) classIDBz := conv.UnsafeStrToBytes(classID) - var key = make([]byte, len(NFTOfClassByOwnerKey)+len(owner)+len(Delimiter)+len(classIDBz)+len(Delimiter)) + key := make([]byte, len(NFTOfClassByOwnerKey)+len(owner)+len(Delimiter)+len(classIDBz)+len(Delimiter)) copy(key, NFTOfClassByOwnerKey) copy(key[len(NFTOfClassByOwnerKey):], owner) copy(key[len(NFTOfClassByOwnerKey)+len(owner):], Delimiter) @@ -70,7 +70,7 @@ func nftOfClassByOwnerStoreKey(owner sdk.AccAddress, classID string) []byte { func prefixNftOfClassByOwnerStoreKey(owner sdk.AccAddress) []byte { owner = address.MustLengthPrefix(owner) - var key = make([]byte, len(NFTOfClassByOwnerKey)+len(owner)+len(Delimiter)) + key := make([]byte, len(NFTOfClassByOwnerKey)+len(owner)+len(Delimiter)) copy(key, NFTOfClassByOwnerKey) copy(key[len(NFTOfClassByOwnerKey):], owner) copy(key[len(NFTOfClassByOwnerKey)+len(owner):], Delimiter) @@ -97,7 +97,7 @@ func ownerStoreKey(classID, nftID string) []byte { classIDBz := conv.UnsafeStrToBytes(classID) nftIDBz := conv.UnsafeStrToBytes(nftID) - var key = make([]byte, len(OwnerKey)+len(classIDBz)+len(Delimiter)+len(nftIDBz)) + key := make([]byte, len(OwnerKey)+len(classIDBz)+len(Delimiter)+len(nftIDBz)) copy(key, OwnerKey) copy(key[len(OwnerKey):], classIDBz) copy(key[len(OwnerKey)+len(classIDBz):], Delimiter) diff --git a/x/nft/keeper/nft.go b/x/nft/keeper/nft.go index c3fb583db9d5..336aff41b677 100644 --- a/x/nft/keeper/nft.go +++ b/x/nft/keeper/nft.go @@ -20,6 +20,12 @@ func (k Keeper) Mint(ctx sdk.Context, token nft.NFT, receiver sdk.AccAddress) er k.setNFT(ctx, token) k.setOwner(ctx, token.ClassId, token.Id, receiver) k.incrTotalSupply(ctx, token.ClassId) + + ctx.EventManager().EmitTypedEvent(&nft.EventMint{ + ClassId: token.ClassId, + Id: token.Id, + Owner: receiver.String(), + }) return nil } @@ -40,6 +46,11 @@ func (k Keeper) Burn(ctx sdk.Context, classID string, nftID string) error { k.deleteOwner(ctx, classID, nftID, owner) k.decrTotalSupply(ctx, classID) + ctx.EventManager().EmitTypedEvent(&nft.EventBurn{ + ClassId: classID, + Id: nftID, + Owner: owner.String(), + }) return nil } @@ -62,7 +73,8 @@ func (k Keeper) Update(ctx sdk.Context, token nft.NFT) error { func (k Keeper) Transfer(ctx sdk.Context, classID string, nftID string, - receiver sdk.AccAddress) error { + receiver sdk.AccAddress, +) error { if !k.HasClass(ctx, classID) { return sdkerrors.Wrap(nft.ErrClassNotExists, classID) } diff --git a/x/nft/module/module.go b/x/nft/module/module.go index 0b456e55c33c..ab6fc9633cc9 100644 --- a/x/nft/module/module.go +++ b/x/nft/module/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -71,10 +70,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.TxEn return nft.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the nft module. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx sdkclient.Context, r *mux.Router) { -} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the nft module. func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *runtime.ServeMux) { if err := nft.RegisterQueryHandlerClient(context.Background(), mux, nft.NewQueryClient(clientCtx)); err != nil { diff --git a/x/nft/msgs.go b/x/nft/msgs.go index 4b85199cdc04..ec648e5f498c 100644 --- a/x/nft/msgs.go +++ b/x/nft/msgs.go @@ -10,9 +10,7 @@ const ( TypeMsgSend = "send" ) -var ( - _ sdk.Msg = &MsgSend{} -) +var _ sdk.Msg = &MsgSend{} // ValidateBasic implements the Msg.ValidateBasic method. func (m MsgSend) ValidateBasic() error { diff --git a/x/nft/simulation/genesis_test.go b/x/nft/simulation/genesis_test.go index cfd3d1f6fde7..3586229497a0 100644 --- a/x/nft/simulation/genesis_test.go +++ b/x/nft/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -26,7 +27,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } diff --git a/x/nft/simulation/operations.go b/x/nft/simulation/operations.go index d430c3c12e78..c71ab17c3175 100644 --- a/x/nft/simulation/operations.go +++ b/x/nft/simulation/operations.go @@ -27,9 +27,7 @@ const ( WeightSend = 100 ) -var ( - TypeMsgSend = sdk.MsgTypeURL(&nft.MsgSend{}) -) +var TypeMsgSend = sdk.MsgTypeURL(&nft.MsgSend{}) // WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( @@ -38,11 +36,9 @@ func WeightedOperations( cdc codec.JSONCodec, ak nft.AccountKeeper, bk nft.BankKeeper, - k keeper.Keeper) simulation.WeightedOperations { - - var ( - weightMsgSend int - ) + k keeper.Keeper, +) simulation.WeightedOperations { + var weightMsgSend int appParams.GetOrGenerate(cdc, OpWeightMsgSend, &weightMsgSend, nil, func(_ *rand.Rand) { @@ -63,7 +59,8 @@ func SimulateMsgSend( cdc *codec.ProtoCodec, ak nft.AccountKeeper, bk nft.BankKeeper, - k keeper.Keeper) simtypes.Operation { + k keeper.Keeper, +) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { @@ -81,7 +78,7 @@ func SimulateMsgSend( return simtypes.NoOpMsg(nft.ModuleName, TypeMsgSend, err.Error()), nil, err } - spendLimit := spendableCoins.Sub(fees) + spendLimit := spendableCoins.Sub(fees...) if spendLimit == nil { return simtypes.NoOpMsg(nft.ModuleName, TypeMsgSend, "spend limit is nil"), nil, nil } @@ -99,7 +96,7 @@ func SimulateMsgSend( } txCfg := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txCfg, []sdk.Msg{msg}, fees, diff --git a/x/nft/simulation/operations_test.go b/x/nft/simulation/operations_test.go index dd222ecbbc9a..0a500f5a971c 100644 --- a/x/nft/simulation/operations_test.go +++ b/x/nft/simulation/operations_test.go @@ -107,7 +107,6 @@ func (suite *SimTestSuite) TestSimulateMsgSend() { suite.app.AppCodec().UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().True(operationMsg.OK) suite.Require().Len(futureOperations, 0) - } func TestSimTestSuite(t *testing.T) { diff --git a/x/nft/spec/01_concepts.md b/x/nft/spec/01_concepts.md new file mode 100644 index 000000000000..ae4bbd99f7c9 --- /dev/null +++ b/x/nft/spec/01_concepts.md @@ -0,0 +1,13 @@ + + +# Concepts + +## Class + +`x/nft` module defines a struct `Class` to describe the common characteristics of a class of nft, under this class, you can create a variety of nft, which is equivalent to an erc721 contract for Ethereum. The design is defined in the [ADR 043](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-043-nft-module.md). + +## NFT + +The full name of NFT is Non-Fungible Tokens. Because of the irreplaceable nature of NFT, it means that it can be used to represent unique things. The nft implemented by this module is fully compatible with Ethereum ERC721 standard. diff --git a/x/nft/spec/02_state.md b/x/nft/spec/02_state.md new file mode 100644 index 000000000000..6edb0c1d0c59 --- /dev/null +++ b/x/nft/spec/02_state.md @@ -0,0 +1,35 @@ + + +# State + +## Class + +Class is mainly composed of `id`, `name`, `symbol`, `description`, `uri`, `uri_hash`,`data` where `id` is the unique identifier of the class, similar to the Ethereum ERC721 contract address, the others are optional. + +* Class: `0x01 | classID | -> ProtocolBuffer(Class)` + +## NFT + +NFT is mainly composed of `class_id`, `id`, `uri`, `uri_hash` and `data`. Among them, `class_id` and `id` are two-tuples that identify the uniqueness of nft, `uri` and `uri_hash` is optional, which identifies the off-chain storage location of the nft, and `data` is an Any type. Use Any chain of `x/nft` modules can be customized by extending this field + +* NFT: `0x02 | classID | 0x00 | nftID |-> ProtocolBuffer(NFT)` + +## NFTOfClassByOwner + +NFTOfClassByOwner is mainly to realize the function of querying all nfts using classID and owner, without other redundant functions. + +* NFTOfClassByOwner: `0x03 | owner | 0x00 | classID | 0x00 | nftID |-> 0x01` + +## Owner + +Since there is no extra field in NFT to indicate the owner of nft, an additional key-value pair is used to save the ownership of nft. With the transfer of nft, the key-value pair is updated synchronously. + +* OwnerKey: `0x04 | classID | 0x00 | nftID |-> owner` + +## TotalSupply + +TotalSupply is responsible for tracking the number of all nfts under a certain class. Mint operation is performed under the changed class, supply increases by one, burn operation, and supply decreases by one. + +* OwnerKey: `0x05 | classID |-> totalSupply` diff --git a/x/nft/spec/03_messages.md b/x/nft/spec/03_messages.md new file mode 100644 index 000000000000..fd1ce0c321e6 --- /dev/null +++ b/x/nft/spec/03_messages.md @@ -0,0 +1,17 @@ + + +# Messages + +In this section we describe the processing of messages for the nft module. + +## MsgSend + +You can use the `MsgSend` message to transfer the ownership of nft. This is a function provided by the `x/nft` module. Of course, you can use the `Transfer` method to implement your own transfer logic, but you need to pay extra attention to the transfer permissions. + +The message handling should fail if: + +* provided `ClassID` is not exist. +* provided `Id` is not exist. +* provided `Sender` is not the owner of nft. diff --git a/x/nft/spec/04_events.md b/x/nft/spec/04_events.md new file mode 100644 index 000000000000..a831c8b7b216 --- /dev/null +++ b/x/nft/spec/04_events.md @@ -0,0 +1,3 @@ +# Events + +The nft module emits proto events defined in [the Protobuf reference](https://buf.build/cosmos/cosmos-sdk/docs/main:cosmos.nft.v1beta1). diff --git a/x/nft/spec/README.md b/x/nft/spec/README.md new file mode 100644 index 000000000000..570a15058c35 --- /dev/null +++ b/x/nft/spec/README.md @@ -0,0 +1,22 @@ + + +# `nft` + +## Contents + +## Abstract + +`x/nft` is an implementation of a Cosmos SDK module, per [ADR 43](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-043-nft-module.md), that allows you to create nft classification, create nft, transfer nft, update nft, and support various queries by integrating the module. It is fully compatible with the ERC721 specification. + +1. **[Concept](01_concepts.md)** + * [Class](01_concepts.md#Class) + * [NFT](01_concepts.md#NFT) +2. **[State](02_state.md)** +3. **[Messages](03_messages.md)** + * [MsgSend](03_messages.md#MsgSend) +4. **[Events](04_events.md)** diff --git a/x/params/client/testutil/cli_test.go b/x/params/client/testutil/cli_test.go index dd36a6af2d3e..1035ca750264 100644 --- a/x/params/client/testutil/cli_test.go +++ b/x/params/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/params/keeper/grpc_query.go b/x/params/keeper/grpc_query.go index d918dc002a38..48fd9ec68694 100644 --- a/x/params/keeper/grpc_query.go +++ b/x/params/keeper/grpc_query.go @@ -41,7 +41,6 @@ func (k Keeper) Subspaces( goCtx context.Context, req *proposal.QuerySubspacesRequest, ) (*proposal.QuerySubspacesResponse, error) { - if req == nil { return nil, status.Errorf(codes.InvalidArgument, "empty request") } diff --git a/x/params/migrations/v036/types.go b/x/params/migrations/v036/types.go deleted file mode 100644 index 0e0b408ddab5..000000000000 --- a/x/params/migrations/v036/types.go +++ /dev/null @@ -1,175 +0,0 @@ -// Package v036 is used for legacy migration scripts. Actual migration scripts -// for v036 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -package v036 - -import ( - "fmt" - "strings" - - "github.com/cosmos/cosmos-sdk/codec" - v036gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v036" -) - -const ( - // ModuleName defines the name of the module - ModuleName = "params" - - // RouterKey defines the routing key for a ParameterChangeProposal - RouterKey = "params" -) - -const ( - // ProposalTypeChange defines the type for a ParameterChangeProposal - ProposalTypeChange = "ParameterChange" -) - -// Param module codespace constants -const ( - DefaultCodespace = "params" - - CodeUnknownSubspace = 1 - CodeSettingParameter = 2 - CodeEmptyData = 3 -) - -// Assert ParameterChangeProposal implements v036gov.Content at compile-time -var _ v036gov.Content = ParameterChangeProposal{} - -// ParameterChangeProposal defines a proposal which contains multiple parameter -// changes. -type ParameterChangeProposal struct { - Title string `json:"title" yaml:"title"` - Description string `json:"description" yaml:"description"` - Changes []ParamChange `json:"changes" yaml:"changes"` -} - -func NewParameterChangeProposal(title, description string, changes []ParamChange) ParameterChangeProposal { - return ParameterChangeProposal{title, description, changes} -} - -// GetTitle returns the title of a parameter change proposal. -func (pcp ParameterChangeProposal) GetTitle() string { return pcp.Title } - -// GetDescription returns the description of a parameter change proposal. -func (pcp ParameterChangeProposal) GetDescription() string { return pcp.Description } - -// GetDescription returns the routing key of a parameter change proposal. -func (pcp ParameterChangeProposal) ProposalRoute() string { return RouterKey } - -// ProposalType returns the type of a parameter change proposal. -func (pcp ParameterChangeProposal) ProposalType() string { return ProposalTypeChange } - -// ValidateBasic validates the parameter change proposal -func (pcp ParameterChangeProposal) ValidateBasic() error { - err := v036gov.ValidateAbstract(pcp) - if err != nil { - return err - } - - return ValidateChanges(pcp.Changes) -} - -// String implements the Stringer interface. -func (pcp ParameterChangeProposal) String() string { - var b strings.Builder - - b.WriteString(fmt.Sprintf(`Parameter Change Proposal: - Title: %s - Description: %s - Changes: -`, pcp.Title, pcp.Description)) - - for _, pc := range pcp.Changes { - b.WriteString(fmt.Sprintf(` Param Change: - Subspace: %s - Key: %s - Subkey: %X - Value: %X -`, pc.Subspace, pc.Key, pc.Subkey, pc.Value)) - } - - return b.String() -} - -// ParamChange defines a parameter change. -type ParamChange struct { - Subspace string `json:"subspace" yaml:"subspace"` - Key string `json:"key" yaml:"key"` - Subkey string `json:"subkey,omitempty" yaml:"subkey,omitempty"` - Value string `json:"value" yaml:"value"` -} - -func NewParamChange(subspace, key, value string) ParamChange { - return ParamChange{subspace, key, "", value} -} - -func NewParamChangeWithSubkey(subspace, key, subkey, value string) ParamChange { - return ParamChange{subspace, key, subkey, value} -} - -// String implements the Stringer interface. -func (pc ParamChange) String() string { - return fmt.Sprintf(`Param Change: - Subspace: %s - Key: %s - Subkey: %X - Value: %X -`, pc.Subspace, pc.Key, pc.Subkey, pc.Value) -} - -// ValidateChange performs basic validation checks over a set of ParamChange. It -// returns an error if any ParamChange is invalid. -func ValidateChanges(changes []ParamChange) error { - if len(changes) == 0 { - return ErrEmptyChanges(DefaultCodespace) - } - - for _, pc := range changes { - if len(pc.Subspace) == 0 { - return ErrEmptySubspace(DefaultCodespace) - } - if len(pc.Key) == 0 { - return ErrEmptyKey(DefaultCodespace) - } - if len(pc.Value) == 0 { - return ErrEmptyValue(DefaultCodespace) - } - } - - return nil -} - -// ErrUnknownSubspace returns an unknown subspace error. -func ErrUnknownSubspace(codespace string, space string) error { - return fmt.Errorf("unknown subspace %s", space) -} - -// ErrSettingParameter returns an error for failing to set a parameter. -func ErrSettingParameter(codespace string, key, subkey, value, msg string) error { - return fmt.Errorf("error setting parameter %s on %s (%s): %s", value, key, subkey, msg) -} - -// ErrEmptyChanges returns an error for empty parameter changes. -func ErrEmptyChanges(codespace string) error { - return fmt.Errorf("submitted parameter changes are empty") -} - -// ErrEmptySubspace returns an error for an empty subspace. -func ErrEmptySubspace(codespace string) error { - return fmt.Errorf("parameter subspace is empty") -} - -// ErrEmptyKey returns an error for when an empty key is given. -func ErrEmptyKey(codespace string) error { - return fmt.Errorf("parameter key is empty") -} - -// ErrEmptyValue returns an error for when an empty key is given. -func ErrEmptyValue(codespace string) error { - return fmt.Errorf("parameter value is empty") -} - -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil) -} diff --git a/x/params/module.go b/x/params/module.go index f17ab2199d44..ddee65dc5823 100644 --- a/x/params/module.go +++ b/x/params/module.go @@ -5,7 +5,6 @@ import ( "encoding/json" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -51,10 +50,6 @@ func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, config client.TxEncodin return nil } -// RegisterRESTRoutes registers the REST routes for the params module. -// Deprecated: RegisterRESTRoutes is deprecated. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the params module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := proposal.RegisterQueryHandlerClient(context.Background(), mux, proposal.NewQueryClient(clientCtx)); err != nil { @@ -116,7 +111,6 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd // module-specific gRPC queries. func (am AppModule) RegisterServices(cfg module.Configurator) { proposal.RegisterQueryServer(cfg.QueryServer(), am.keeper) - } // ProposalContents returns all the params content functions used to diff --git a/x/params/types/proposal/query.pb.go b/x/params/types/proposal/query.pb.go index 229f4f8e9bb0..25bacb04795e 100644 --- a/x/params/types/proposal/query.pb.go +++ b/x/params/types/proposal/query.pb.go @@ -132,6 +132,8 @@ func (m *QueryParamsResponse) GetParam() ParamChange { // QuerySubspacesRequest defines a request type for querying for all registered // subspaces and all keys for a subspace. +// +// Since: cosmos-sdk 0.46 type QuerySubspacesRequest struct { } @@ -170,6 +172,8 @@ var xxx_messageInfo_QuerySubspacesRequest proto.InternalMessageInfo // QuerySubspacesResponse defines the response types for querying for all // registered subspaces and all keys for a subspace. +// +// Since: cosmos-sdk 0.46 type QuerySubspacesResponse struct { Subspaces []*Subspace `protobuf:"bytes,1,rep,name=subspaces,proto3" json:"subspaces,omitempty"` } @@ -216,6 +220,8 @@ func (m *QuerySubspacesResponse) GetSubspaces() []*Subspace { // Subspace defines a parameter subspace name and all the keys that exist for // the subspace. +// +// Since: cosmos-sdk 0.46 type Subspace struct { Subspace string `protobuf:"bytes,1,opt,name=subspace,proto3" json:"subspace,omitempty"` Keys []string `protobuf:"bytes,2,rep,name=keys,proto3" json:"keys,omitempty"` @@ -324,6 +330,8 @@ type QueryClient interface { // key. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // Subspaces queries for all registered subspaces and all keys for a subspace. + // + // Since: cosmos-sdk 0.46 Subspaces(ctx context.Context, in *QuerySubspacesRequest, opts ...grpc.CallOption) (*QuerySubspacesResponse, error) } @@ -359,6 +367,8 @@ type QueryServer interface { // key. Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // Subspaces queries for all registered subspaces and all keys for a subspace. + // + // Since: cosmos-sdk 0.46 Subspaces(context.Context, *QuerySubspacesRequest) (*QuerySubspacesResponse, error) } diff --git a/x/simulation/event_stats.go b/x/simulation/event_stats.go index 9618385b8ffc..675380e8215a 100644 --- a/x/simulation/event_stats.go +++ b/x/simulation/event_stats.go @@ -48,7 +48,7 @@ func (es EventStats) ExportJSON(path string) { panic(err) } - err = os.WriteFile(path, bz, 0600) + err = os.WriteFile(path, bz, 0o600) if err != nil { panic(err) } diff --git a/x/simulation/log.go b/x/simulation/log.go index 96e84264fd35..8d775f87b70b 100644 --- a/x/simulation/log.go +++ b/x/simulation/log.go @@ -40,7 +40,6 @@ func (lw *StandardLogWriter) PrintLogs() { for i := 0; i < len(lw.OpEntries); i++ { writeEntry := fmt.Sprintf("%s\n", (lw.OpEntries[i]).MustMarshal()) _, err := f.WriteString(writeEntry) - if err != nil { panic("Failed to write logs to file") } diff --git a/x/simulation/mock_tendermint.go b/x/simulation/mock_tendermint.go index 55c2ca544465..7d7f1dc99725 100644 --- a/x/simulation/mock_tendermint.go +++ b/x/simulation/mock_tendermint.go @@ -86,7 +86,6 @@ func updateValidators( updates []abci.ValidatorUpdate, event func(route, op, evResult string), ) map[string]mockValidator { - for _, update := range updates { str := fmt.Sprintf("%X", update.PubKey.GetEd25519()) @@ -100,7 +99,6 @@ func updateValidators( } else if _, ok := current[str]; ok { // validator already exists event("end_block", "validator_updates", "updated") - } else { // Set this new validator current[str] = mockValidator{ @@ -119,7 +117,8 @@ func updateValidators( func RandomRequestBeginBlock(r *rand.Rand, params Params, validators mockValidators, pastTimes []time.Time, pastVoteInfos [][]abci.VoteInfo, - event func(route, op, evResult string), header tmproto.Header) abci.RequestBeginBlock { + event func(route, op, evResult string), header tmproto.Header, +) abci.RequestBeginBlock { if len(validators) == 0 { return abci.RequestBeginBlock{ Header: header, diff --git a/x/simulation/params_test.go b/x/simulation/params_test.go index d0b538c26e4d..90eb4f22a0a4 100644 --- a/x/simulation/params_test.go +++ b/x/simulation/params_test.go @@ -43,8 +43,7 @@ func TestNewWeightedProposalContent(t *testing.T) { require.Equal(t, content, pContent.ContentSimulatorFn()(nil, ctx, nil)) } -type testContent struct { -} +type testContent struct{} func (t testContent) GetTitle() string { return "" } func (t testContent) GetDescription() string { return "" } diff --git a/x/simulation/simulate.go b/x/simulation/simulate.go index 9b8c433be10a..cd792659bd15 100644 --- a/x/simulation/simulate.go +++ b/x/simulation/simulate.go @@ -31,7 +31,6 @@ func initChain( config simulation.Config, cdc codec.JSONCodec, ) (mockValidators, time.Time, []simulation.Account, string) { - appState, accounts, chainID, genesisTimestamp := appStateFn(r, accounts, config) consensusParams := randomConsensusParams(r, appState, cdc) req := abci.RequestInitChain{ @@ -256,8 +255,8 @@ type blockSimFn func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, func createBlockSimulator(testingMode bool, tb testing.TB, w io.Writer, params Params, event func(route, op, evResult string), ops WeightedOperations, operationQueue OperationQueue, timeOperationQueue []simulation.FutureOperation, - logWriter LogWriter, config simulation.Config) blockSimFn { - + logWriter LogWriter, config simulation.Config, +) blockSimFn { lastBlockSizeState := 0 // state for [4 * uniform distribution] blocksize := 0 selectOp := ops.getSelectOpFn() @@ -324,8 +323,8 @@ Comment: %s`, func runQueuedOperations(queueOps map[int][]simulation.Operation, height int, tb testing.TB, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simulation.Account, logWriter LogWriter, - event func(route, op, evResult string), lean bool, chainID string) (numOpsRan int, allFutureOps []simulation.FutureOperation) { - + event func(route, op, evResult string), lean bool, chainID string, +) (numOpsRan int, allFutureOps []simulation.FutureOperation) { queuedOp, ok := queueOps[height] if !ok { return 0, nil @@ -361,8 +360,8 @@ func runQueuedTimeOperations(queueOps []simulation.FutureOperation, height int, currentTime time.Time, tb testing.TB, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accounts []simulation.Account, logWriter LogWriter, event func(route, op, evResult string), - lean bool, chainID string) (numOpsRan int, allFutureOps []simulation.FutureOperation) { - + lean bool, chainID string, +) (numOpsRan int, allFutureOps []simulation.FutureOperation) { // Keep all future operations allFutureOps = make([]simulation.FutureOperation, 0) diff --git a/x/simulation/util.go b/x/simulation/util.go index 498c056ebdab..3c72f67538cb 100644 --- a/x/simulation/util.go +++ b/x/simulation/util.go @@ -85,7 +85,7 @@ func GenAndDeliverTxWithRandFees(txCtx OperationInput) (simtypes.OperationMsg, [ var fees sdk.Coins var err error - coins, hasNeg := spendable.SafeSub(txCtx.CoinsSpentInMsg) + coins, hasNeg := spendable.SafeSub(txCtx.CoinsSpentInMsg...) if hasNeg { return simtypes.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "message doesn't leave room for fees"), nil, err } @@ -100,7 +100,7 @@ func GenAndDeliverTxWithRandFees(txCtx OperationInput) (simtypes.OperationMsg, [ // GenAndDeliverTx generates a transactions and delivers it. func GenAndDeliverTx(txCtx OperationInput, fees sdk.Coins) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { account := txCtx.AccountKeeper.GetAccount(txCtx.Context, txCtx.SimAccount.Address) - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txCtx.TxGen, []sdk.Msg{txCtx.Msg}, fees, @@ -110,7 +110,6 @@ func GenAndDeliverTx(txCtx OperationInput, fees sdk.Coins) (simtypes.OperationMs []uint64{account.GetSequence()}, txCtx.SimAccount.PrivKey, ) - if err != nil { return simtypes.NoOpMsg(txCtx.ModuleName, txCtx.MsgType, "unable to generate mock tx"), nil, err } @@ -121,5 +120,4 @@ func GenAndDeliverTx(txCtx OperationInput, fees sdk.Coins) (simtypes.OperationMs } return simtypes.NewOperationMsg(txCtx.Msg, true, "", txCtx.Cdc), nil, nil - } diff --git a/x/slashing/client/cli/query.go b/x/slashing/client/cli/query.go index 08ae03301fbc..500a490d64eb 100644 --- a/x/slashing/client/cli/query.go +++ b/x/slashing/client/cli/query.go @@ -30,7 +30,6 @@ func GetQueryCmd() *cobra.Command { ) return slashingQueryCmd - } // GetCmdQuerySigningInfo implements the command to query signing info. diff --git a/x/slashing/client/cli/tx.go b/x/slashing/client/cli/tx.go index 6ef7f56c2925..bcb7836e6d7d 100644 --- a/x/slashing/client/cli/tx.go +++ b/x/slashing/client/cli/tx.go @@ -24,6 +24,7 @@ func NewTxCmd() *cobra.Command { return slashingTxCmd } +// NewUnjailTxCmd returns a CLI command handler for creating a MsgUnjail transaction. func NewUnjailTxCmd() *cobra.Command { cmd := &cobra.Command{ Use: "unjail", diff --git a/x/slashing/client/testutil/cli_test.go b/x/slashing/client/testutil/cli_test.go index dd36a6af2d3e..1035ca750264 100644 --- a/x/slashing/client/testutil/cli_test.go +++ b/x/slashing/client/testutil/cli_test.go @@ -1,3 +1,4 @@ +//go:build norace // +build norace package testutil diff --git a/x/slashing/init_test.go b/x/slashing/init_test.go index a2217cfda7b0..b9bbfe694e26 100644 --- a/x/slashing/init_test.go +++ b/x/slashing/init_test.go @@ -4,7 +4,5 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var ( - // The default power validators are initialized to have within tests - InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) -) +// The default power validators are initialized to have within tests +var InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) diff --git a/x/slashing/keeper/common_test.go b/x/slashing/keeper/common_test.go index 91a972ed1110..4e4be93b91e8 100644 --- a/x/slashing/keeper/common_test.go +++ b/x/slashing/keeper/common_test.go @@ -2,7 +2,5 @@ package keeper_test import sdk "github.com/cosmos/cosmos-sdk/types" -var ( - // The default power validators are initialized to have within tests - InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) -) +// The default power validators are initialized to have within tests +var InitTokens = sdk.TokensFromConsensusPower(200, sdk.DefaultPowerReduction) diff --git a/x/slashing/genesis.go b/x/slashing/keeper/genesis.go similarity index 87% rename from x/slashing/genesis.go rename to x/slashing/keeper/genesis.go index 2c8b6675762b..469947ed38f1 100644 --- a/x/slashing/genesis.go +++ b/x/slashing/keeper/genesis.go @@ -1,15 +1,14 @@ -package slashing +package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/slashing/keeper" "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) // InitGenesis initialize default parameters // and the keeper's address to pubkey map -func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, stakingKeeper types.StakingKeeper, data *types.GenesisState) { +func (keeper Keeper) InitGenesis(ctx sdk.Context, stakingKeeper types.StakingKeeper, data *types.GenesisState) { stakingKeeper.IterateValidators(ctx, func(index int64, validator stakingtypes.ValidatorI) bool { consPk, err := validator.ConsPubKey() @@ -45,7 +44,7 @@ func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, stakingKeeper types.Stak // ExportGenesis writes the current store values // to a genesis file, which can be imported again // with InitGenesis -func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) (data *types.GenesisState) { +func (keeper Keeper) ExportGenesis(ctx sdk.Context) (data *types.GenesisState) { params := keeper.GetParams(ctx) signingInfos := make([]types.SigningInfo, 0) missedBlocks := make([]types.ValidatorMissedBlocks, 0) diff --git a/x/slashing/genesis_test.go b/x/slashing/keeper/genesis_test.go similarity index 91% rename from x/slashing/genesis_test.go rename to x/slashing/keeper/genesis_test.go index 7cd0792bde4f..3cea49ea3863 100644 --- a/x/slashing/genesis_test.go +++ b/x/slashing/keeper/genesis_test.go @@ -1,4 +1,4 @@ -package slashing_test +package keeper_test import ( "testing" @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/slashing" "github.com/cosmos/cosmos-sdk/x/slashing/testslashing" "github.com/cosmos/cosmos-sdk/x/slashing/types" ) @@ -29,7 +28,7 @@ func TestExportAndInitGenesis(t *testing.T) { app.SlashingKeeper.SetValidatorSigningInfo(ctx, sdk.ConsAddress(addrDels[0]), info1) app.SlashingKeeper.SetValidatorSigningInfo(ctx, sdk.ConsAddress(addrDels[1]), info2) - genesisState := slashing.ExportGenesis(ctx, app.SlashingKeeper) + genesisState := app.SlashingKeeper.ExportGenesis(ctx) require.Equal(t, genesisState.Params, testslashing.TestParams()) require.Len(t, genesisState.SigningInfos, 2) @@ -45,7 +44,8 @@ func TestExportAndInitGenesis(t *testing.T) { newInfo1, ok := app.SlashingKeeper.GetValidatorSigningInfo(ctx, sdk.ConsAddress(addrDels[0])) require.NotEqual(t, info1, newInfo1) // Initialise genesis with genesis state before tombstone - slashing.InitGenesis(ctx, app.SlashingKeeper, app.StakingKeeper, genesisState) + + app.SlashingKeeper.InitGenesis(ctx, app.StakingKeeper, genesisState) // Validator isTombstoned should return false as GenesisState is initialised ok = app.SlashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(addrDels[0])) diff --git a/x/slashing/keeper/grpc_query_test.go b/x/slashing/keeper/grpc_query_test.go index ddb6694d0463..5a8733babeef 100644 --- a/x/slashing/keeper/grpc_query_test.go +++ b/x/slashing/keeper/grpc_query_test.go @@ -91,7 +91,7 @@ func (suite *SlashingTestSuite) TestGRPCSigningInfos() { }) // verify all values are returned without pagination - var infoResp, err = queryClient.SigningInfos(gocontext.Background(), + infoResp, err := queryClient.SigningInfos(gocontext.Background(), &types.QuerySigningInfosRequest{Pagination: nil}) suite.NoError(err) suite.Equal(signingInfos, infoResp.Info) diff --git a/x/slashing/keeper/hooks.go b/x/slashing/keeper/hooks.go index 09d1afe02fac..a306f76c210d 100644 --- a/x/slashing/keeper/hooks.go +++ b/x/slashing/keeper/hooks.go @@ -11,9 +11,11 @@ import ( func (k Keeper) AfterValidatorBonded(ctx sdk.Context, address sdk.ConsAddress, _ sdk.ValAddress) error { // Update the signing info start height or create a new signing info - _, found := k.GetValidatorSigningInfo(ctx, address) - if !found { - signingInfo := types.NewValidatorSigningInfo( + signingInfo, found := k.GetValidatorSigningInfo(ctx, address) + if found { + signingInfo.StartHeight = ctx.BlockHeight() + } else { + signingInfo = types.NewValidatorSigningInfo( address, ctx.BlockHeight(), 0, @@ -21,9 +23,10 @@ func (k Keeper) AfterValidatorBonded(ctx sdk.Context, address sdk.ConsAddress, _ false, 0, ) - k.SetValidatorSigningInfo(ctx, address, signingInfo) } + k.SetValidatorSigningInfo(ctx, address, signingInfo) + return nil } @@ -74,17 +77,27 @@ func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) er func (h Hooks) AfterValidatorBeginUnbonding(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress) error { return nil } -func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress) error { return nil } + +func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress) error { + return nil +} + func (h Hooks) BeforeDelegationCreated(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { return nil } + func (h Hooks) BeforeDelegationSharesModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { return nil } + func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { return nil } + func (h Hooks) AfterDelegationModified(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) error { return nil } -func (h Hooks) BeforeValidatorSlashed(_ sdk.Context, _ sdk.ValAddress, _ sdk.Dec) error { return nil } + +func (h Hooks) BeforeValidatorSlashed(_ sdk.Context, _ sdk.ValAddress, _ sdk.Dec) error { + return nil +} diff --git a/x/slashing/keeper/keeper_test.go b/x/slashing/keeper/keeper_test.go index 7385c1f4d7e2..03869e3a74c9 100644 --- a/x/slashing/keeper/keeper_test.go +++ b/x/slashing/keeper/keeper_test.go @@ -179,7 +179,6 @@ func TestHandleAlreadyJailed(t *testing.T) { // Ensure that missed blocks are tracked correctly and that // the start height of the signing info is reset correctly func TestValidatorDippingInAndOut(t *testing.T) { - // initial setup // TestParams set the SignedBlocksWindow to 1000 and MaxMissedBlocksPerWindow to 500 app := simapp.Setup(t, false) @@ -200,7 +199,9 @@ func TestValidatorDippingInAndOut(t *testing.T) { valAddr := sdk.ValAddress(addr) tstaking.CreateValidatorWithValPower(valAddr, val, power, true) - staking.EndBlocker(ctx, app.StakingKeeper) + validatorUpdates := staking.EndBlocker(ctx, app.StakingKeeper) + require.Equal(t, 2, len(validatorUpdates)) + tstaking.CheckValidator(valAddr, stakingtypes.Bonded, false) // 100 first blocks OK height := int64(0) @@ -210,22 +211,23 @@ func TestValidatorDippingInAndOut(t *testing.T) { } // kick first validator out of validator set - tstaking.CreateValidatorWithValPower(sdk.ValAddress(pks[1].Address()), pks[1], 101, true) - validatorUpdates := staking.EndBlocker(ctx, app.StakingKeeper) + tstaking.CreateValidatorWithValPower(sdk.ValAddress(pks[1].Address()), pks[1], power+1, true) + validatorUpdates = staking.EndBlocker(ctx, app.StakingKeeper) require.Equal(t, 2, len(validatorUpdates)) + tstaking.CheckValidator(sdk.ValAddress(pks[1].Address()), stakingtypes.Bonded, false) tstaking.CheckValidator(valAddr, stakingtypes.Unbonding, false) // 600 more blocks happened - height = 700 + height = height + 600 ctx = ctx.WithBlockHeight(height) // validator added back in - tstaking.DelegateWithPower(sdk.AccAddress(pks[2].Address()), sdk.ValAddress(pks[0].Address()), 50) + tstaking.DelegateWithPower(sdk.AccAddress(pks[2].Address()), valAddr, 50) validatorUpdates = staking.EndBlocker(ctx, app.StakingKeeper) require.Equal(t, 2, len(validatorUpdates)) tstaking.CheckValidator(valAddr, stakingtypes.Bonded, false) - newPower := int64(150) + newPower := power + 50 // validator misses a block app.SlashingKeeper.HandleValidatorSignature(ctx, val.Address(), newPower, false) @@ -234,9 +236,9 @@ func TestValidatorDippingInAndOut(t *testing.T) { // shouldn't be jailed/kicked yet tstaking.CheckValidator(valAddr, stakingtypes.Bonded, false) - // validator misses 500 more blocks, 501 total - latest := height - for ; height < latest+500; height++ { + // validator misses an additional 500 more blocks, after the cooling off period of SignedBlockWindow (here 1000 blocks). + latest := app.SlashingKeeper.SignedBlocksWindow(ctx) + height + for ; height < latest+app.SlashingKeeper.MinSignedPerWindow(ctx); height++ { ctx = ctx.WithBlockHeight(height) app.SlashingKeeper.HandleValidatorSignature(ctx, val.Address(), newPower, false) } @@ -248,13 +250,9 @@ func TestValidatorDippingInAndOut(t *testing.T) { // check all the signing information signInfo, found := app.SlashingKeeper.GetValidatorSigningInfo(ctx, consAddr) require.True(t, found) - require.Equal(t, int64(0), signInfo.MissedBlocksCounter) - require.Equal(t, int64(0), signInfo.IndexOffset) - // array should be cleared - for offset := int64(0); offset < app.SlashingKeeper.SignedBlocksWindow(ctx); offset++ { - missed := app.SlashingKeeper.GetValidatorMissedBlockBitArray(ctx, consAddr, offset) - require.False(t, missed) - } + require.Equal(t, int64(700), signInfo.StartHeight) + require.Equal(t, int64(499), signInfo.MissedBlocksCounter) + require.Equal(t, int64(499), signInfo.IndexOffset) // some blocks pass height = int64(5000) @@ -262,16 +260,21 @@ func TestValidatorDippingInAndOut(t *testing.T) { // validator rejoins and starts signing again app.StakingKeeper.Unjail(ctx, consAddr) + app.SlashingKeeper.HandleValidatorSignature(ctx, val.Address(), newPower, true) - height++ // validator should not be kicked since we reset counter/array when it was jailed staking.EndBlocker(ctx, app.StakingKeeper) tstaking.CheckValidator(valAddr, stakingtypes.Bonded, false) - // validator misses 501 blocks - latest = height - for ; height < latest+501; height++ { + // check start height is correctly set + signInfo, found = app.SlashingKeeper.GetValidatorSigningInfo(ctx, consAddr) + require.True(t, found) + require.Equal(t, height, signInfo.StartHeight) + + // validator misses 501 blocks after SignedBlockWindow period (1000 blocks) + latest = app.SlashingKeeper.SignedBlocksWindow(ctx) + height + for ; height < latest+app.SlashingKeeper.MinSignedPerWindow(ctx); height++ { ctx = ctx.WithBlockHeight(height) app.SlashingKeeper.HandleValidatorSignature(ctx, val.Address(), newPower, false) } diff --git a/x/slashing/keeper/signing_info.go b/x/slashing/keeper/signing_info.go index ed15ae3e4ff3..d65b773ebc66 100644 --- a/x/slashing/keeper/signing_info.go +++ b/x/slashing/keeper/signing_info.go @@ -39,8 +39,8 @@ func (k Keeper) SetValidatorSigningInfo(ctx sdk.Context, address sdk.ConsAddress // IterateValidatorSigningInfos iterates over the stored ValidatorSigningInfo func (k Keeper) IterateValidatorSigningInfos(ctx sdk.Context, - handler func(address sdk.ConsAddress, info types.ValidatorSigningInfo) (stop bool)) { - + handler func(address sdk.ConsAddress, info types.ValidatorSigningInfo) (stop bool), +) { store := ctx.KVStore(k.storeKey) iter := sdk.KVStorePrefixIterator(store, types.ValidatorSigningInfoKeyPrefix) defer iter.Close() @@ -71,8 +71,8 @@ func (k Keeper) GetValidatorMissedBlockBitArray(ctx sdk.Context, address sdk.Con // IterateValidatorMissedBlockBitArray iterates over the signed blocks window // and performs a callback function func (k Keeper) IterateValidatorMissedBlockBitArray(ctx sdk.Context, - address sdk.ConsAddress, handler func(index int64, missed bool) (stop bool)) { - + address sdk.ConsAddress, handler func(index int64, missed bool) (stop bool), +) { store := ctx.KVStore(k.storeKey) index := int64(0) // Array may be sparse diff --git a/x/slashing/migrations/v039/types.go b/x/slashing/migrations/v039/types.go deleted file mode 100644 index 34eed337173b..000000000000 --- a/x/slashing/migrations/v039/types.go +++ /dev/null @@ -1,79 +0,0 @@ -package v039 - -import ( - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -const ( - ModuleName = "slashing" -) - -// Default parameter namespace -const ( - DefaultParamspace = ModuleName - DefaultSignedBlocksWindow = int64(100) - DefaultDowntimeJailDuration = 60 * 10 * time.Second -) - -var ( - DefaultMinSignedPerWindow = sdk.NewDecWithPrec(5, 1) - DefaultSlashFractionDoubleSign = sdk.NewDec(1).Quo(sdk.NewDec(20)) - DefaultSlashFractionDowntime = sdk.NewDec(1).Quo(sdk.NewDec(100)) -) - -// Params - used for initializing default parameter for slashing at genesis -type Params struct { - SignedBlocksWindow int64 `json:"signed_blocks_window" yaml:"signed_blocks_window"` - MinSignedPerWindow sdk.Dec `json:"min_signed_per_window" yaml:"min_signed_per_window"` - DowntimeJailDuration time.Duration `json:"downtime_jail_duration" yaml:"downtime_jail_duration"` - SlashFractionDoubleSign sdk.Dec `json:"slash_fraction_double_sign" yaml:"slash_fraction_double_sign"` - SlashFractionDowntime sdk.Dec `json:"slash_fraction_downtime" yaml:"slash_fraction_downtime"` -} - -// NewParams creates a new Params object -func NewParams( - signedBlocksWindow int64, minSignedPerWindow sdk.Dec, downtimeJailDuration time.Duration, - slashFractionDoubleSign, slashFractionDowntime sdk.Dec, -) Params { - - return Params{ - SignedBlocksWindow: signedBlocksWindow, - MinSignedPerWindow: minSignedPerWindow, - DowntimeJailDuration: downtimeJailDuration, - SlashFractionDoubleSign: slashFractionDoubleSign, - SlashFractionDowntime: slashFractionDowntime, - } -} - -// DefaultParams defines the parameters for this module -func DefaultParams() Params { - return NewParams( - DefaultSignedBlocksWindow, DefaultMinSignedPerWindow, DefaultDowntimeJailDuration, - DefaultSlashFractionDoubleSign, DefaultSlashFractionDowntime, - ) -} - -// ValidatorSigningInfo defines the signing info for a validator -type ValidatorSigningInfo struct { - Address sdk.ConsAddress `json:"address" yaml:"address"` // validator consensus address - StartHeight int64 `json:"start_height" yaml:"start_height"` // height at which validator was first a candidate OR was unjailed - IndexOffset int64 `json:"index_offset" yaml:"index_offset"` // index offset into signed block bit array - JailedUntil time.Time `json:"jailed_until" yaml:"jailed_until"` // timestamp validator cannot be unjailed until - Tombstoned bool `json:"tombstoned" yaml:"tombstoned"` // whether or not a validator has been tombstoned (killed out of validator set) - MissedBlocksCounter int64 `json:"missed_blocks_counter" yaml:"missed_blocks_counter"` // missed blocks counter (to avoid scanning the array every time) -} - -// MissedBlock -type MissedBlock struct { - Index int64 `json:"index" yaml:"index"` - Missed bool `json:"missed" yaml:"missed"` -} - -// GenesisState - all slashing state that must be provided at genesis -type GenesisState struct { - Params Params `json:"params" yaml:"params"` - SigningInfos map[string]ValidatorSigningInfo `json:"signing_infos" yaml:"signing_infos"` - MissedBlocks map[string][]MissedBlock `json:"missed_blocks" yaml:"missed_blocks"` -} diff --git a/x/slashing/migrations/v040/migrate.go b/x/slashing/migrations/v040/migrate.go deleted file mode 100644 index 0dbd227425c0..000000000000 --- a/x/slashing/migrations/v040/migrate.go +++ /dev/null @@ -1,64 +0,0 @@ -package v040 - -import ( - "sort" - - v039slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v039" - v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/types" -) - -// Migrate accepts exported x/slashing genesis state from v0.39 and migrates it -// to v0.40 x/slashing genesis state. The migration includes: -// -// - Chaning SigningInfos and MissedBlocks from map to array. -// - Convert addresses from bytes to bech32 strings. -// - Re-encode in v0.40 GenesisState. -func Migrate(oldGenState v039slashing.GenesisState) *v040slashing.GenesisState { - // Note that the two following `for` loop over a map's keys, so are not - // deterministic. - var newSigningInfos = make([]v040slashing.SigningInfo, 0, len(oldGenState.SigningInfos)) - for address, signingInfo := range oldGenState.SigningInfos { - newSigningInfos = append(newSigningInfos, v040slashing.SigningInfo{ - Address: address, - ValidatorSigningInfo: v040slashing.ValidatorSigningInfo{ - Address: signingInfo.Address.String(), - StartHeight: signingInfo.StartHeight, - IndexOffset: signingInfo.IndexOffset, - JailedUntil: signingInfo.JailedUntil, - Tombstoned: signingInfo.Tombstoned, - MissedBlocksCounter: signingInfo.MissedBlocksCounter, - }, - }) - } - var newValidatorMissedBlocks = make([]v040slashing.ValidatorMissedBlocks, 0, len(oldGenState.MissedBlocks)) - for address, validatorMissedBlocks := range oldGenState.MissedBlocks { - var newMissedBlocks = make([]v040slashing.MissedBlock, len(validatorMissedBlocks)) - for i, missedBlock := range validatorMissedBlocks { - newMissedBlocks[i] = v040slashing.MissedBlock{ - Index: missedBlock.Index, - Missed: missedBlock.Missed, - } - } - - newValidatorMissedBlocks = append(newValidatorMissedBlocks, v040slashing.ValidatorMissedBlocks{ - Address: address, - MissedBlocks: newMissedBlocks, - }) - } - - // We sort these two arrays by address, so that we get determinstic states. - sort.Slice(newSigningInfos, func(i, j int) bool { return newSigningInfos[i].Address < newSigningInfos[j].Address }) - sort.Slice(newValidatorMissedBlocks, func(i, j int) bool { return newValidatorMissedBlocks[i].Address < newValidatorMissedBlocks[j].Address }) - - return &v040slashing.GenesisState{ - Params: v040slashing.Params{ - SignedBlocksWindow: oldGenState.Params.SignedBlocksWindow, - MinSignedPerWindow: oldGenState.Params.MinSignedPerWindow, - DowntimeJailDuration: oldGenState.Params.DowntimeJailDuration, - SlashFractionDoubleSign: oldGenState.Params.SlashFractionDoubleSign, - SlashFractionDowntime: oldGenState.Params.SlashFractionDowntime, - }, - SigningInfos: newSigningInfos, - MissedBlocks: newValidatorMissedBlocks, - } -} diff --git a/x/slashing/migrations/v040/migrate_test.go b/x/slashing/migrations/v040/migrate_test.go deleted file mode 100644 index 2f2bc66615f2..000000000000 --- a/x/slashing/migrations/v040/migrate_test.go +++ /dev/null @@ -1,140 +0,0 @@ -package v040_test - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/simapp" - sdk "github.com/cosmos/cosmos-sdk/types" - v039slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v039" - v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v040" -) - -func TestMigrate(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() - clientCtx := client.Context{}. - WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithTxConfig(encodingConfig.TxConfig). - WithLegacyAmino(encodingConfig.Amino). - WithCodec(encodingConfig.Codec) - - addr1, err := sdk.ConsAddressFromBech32("cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685") - require.NoError(t, err) - addr2, err := sdk.ConsAddressFromBech32("cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph") - require.NoError(t, err) - - gs := v039slashing.GenesisState{ - Params: v039slashing.DefaultParams(), - SigningInfos: map[string]v039slashing.ValidatorSigningInfo{ - "cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph": { - Address: addr2, - IndexOffset: 615501, - MissedBlocksCounter: 1, - Tombstoned: false, - }, - "cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685": { - Address: addr1, - IndexOffset: 2, - MissedBlocksCounter: 2, - Tombstoned: false, - }, - }, - MissedBlocks: map[string][]v039slashing.MissedBlock{ - "cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph": { - { - Index: 2, - Missed: true, - }, - }, - "cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685": { - { - Index: 3, - Missed: true, - }, - { - Index: 4, - Missed: true, - }, - }, - }, - } - - migrated := v040slashing.Migrate(gs) - // Check that in `signing_infos` and `missed_blocks`, the address - // cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685 - // should always come before the address - // cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph - // (in alphabetic order, basically). - expected := `{ - "missed_blocks": [ - { - "address": "cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685", - "missed_blocks": [ - { - "index": "3", - "missed": true - }, - { - "index": "4", - "missed": true - } - ] - }, - { - "address": "cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph", - "missed_blocks": [ - { - "index": "2", - "missed": true - } - ] - } - ], - "params": { - "downtime_jail_duration": "600s", - "min_signed_per_window": "0.500000000000000000", - "signed_blocks_window": "100", - "slash_fraction_double_sign": "0.050000000000000000", - "slash_fraction_downtime": "0.010000000000000000" - }, - "signing_infos": [ - { - "address": "cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685", - "validator_signing_info": { - "address": "cosmosvalcons104cjmxkrg8y8lmrp25de02e4zf00zle4mzs685", - "index_offset": "2", - "jailed_until": "0001-01-01T00:00:00Z", - "missed_blocks_counter": "2", - "start_height": "0", - "tombstoned": false - } - }, - { - "address": "cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph", - "validator_signing_info": { - "address": "cosmosvalcons10e4c5p6qk0sycy9u6u43t7csmlx9fyadr9yxph", - "index_offset": "615501", - "jailed_until": "0001-01-01T00:00:00Z", - "missed_blocks_counter": "1", - "start_height": "0", - "tombstoned": false - } - } - ] -}` - - bz, err := clientCtx.Codec.MarshalJSON(migrated) - require.NoError(t, err) - - // Indent the JSON bz correctly. - var jsonObj map[string]interface{} - err = json.Unmarshal(bz, &jsonObj) - require.NoError(t, err) - indentedBz, err := json.MarshalIndent(jsonObj, "", " ") - require.NoError(t, err) - - require.Equal(t, expected, string(indentedBz)) -} diff --git a/x/slashing/migrations/v040/keys.go b/x/slashing/migrations/v042/types.go similarity index 94% rename from x/slashing/migrations/v040/keys.go rename to x/slashing/migrations/v042/types.go index 367ead65e5cc..0089afe732fd 100644 --- a/x/slashing/migrations/v040/keys.go +++ b/x/slashing/migrations/v042/types.go @@ -1,13 +1,13 @@ // Package v040 is copy-pasted from: // https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/x/slashing/types/keys.go -package v040 +package legacy import ( "encoding/binary" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" + v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" ) const ( @@ -47,7 +47,7 @@ func ValidatorSigningInfoKey(v sdk.ConsAddress) []byte { func ValidatorSigningInfoAddress(key []byte) (v sdk.ConsAddress) { kv.AssertKeyAtLeastLength(key, 2) addr := key[1:] - kv.AssertKeyLength(addr, v040auth.AddrLen) + kv.AssertKeyLength(addr, v042auth.AddrLen) return sdk.ConsAddress(addr) } diff --git a/x/slashing/migrations/v043/store.go b/x/slashing/migrations/v043/store.go index 15da0982e27c..d9d44664c18f 100644 --- a/x/slashing/migrations/v043/store.go +++ b/x/slashing/migrations/v043/store.go @@ -4,7 +4,7 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v043" - v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v040" + v042slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v042" ) // MigrateStore performs in-place store migrations from v0.40 to v0.43. The @@ -13,9 +13,9 @@ import ( // - Change addresses to be length-prefixed. func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey) error { store := ctx.KVStore(storeKey) - v043distribution.MigratePrefixAddress(store, v040slashing.ValidatorSigningInfoKeyPrefix) - v043distribution.MigratePrefixAddressBytes(store, v040slashing.ValidatorMissedBlockBitArrayKeyPrefix) - v043distribution.MigratePrefixAddress(store, v040slashing.AddrPubkeyRelationKeyPrefix) + v043distribution.MigratePrefixAddress(store, v042slashing.ValidatorSigningInfoKeyPrefix) + v043distribution.MigratePrefixAddressBytes(store, v042slashing.ValidatorMissedBlockBitArrayKeyPrefix) + v043distribution.MigratePrefixAddress(store, v042slashing.AddrPubkeyRelationKeyPrefix) return nil } diff --git a/x/slashing/migrations/v043/store_test.go b/x/slashing/migrations/v043/store_test.go index 962e7af9d56a..17aa3387c2c2 100644 --- a/x/slashing/migrations/v043/store_test.go +++ b/x/slashing/migrations/v043/store_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v040" + v040slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v042" v043slashing "github.com/cosmos/cosmos-sdk/x/slashing/migrations/v043" "github.com/cosmos/cosmos-sdk/x/slashing/types" ) diff --git a/x/slashing/module.go b/x/slashing/module.go index cf51b57066ad..73991883aa03 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -68,11 +67,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the slashing module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/slashing` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the slashig module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { @@ -148,14 +142,14 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { var genesisState types.GenesisState cdc.MustUnmarshalJSON(data, &genesisState) - InitGenesis(ctx, am.keeper, am.stakingKeeper, &genesisState) + am.keeper.InitGenesis(ctx, am.stakingKeeper, &genesisState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the slashing // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - gs := ExportGenesis(ctx, am.keeper) + gs := am.keeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(gs) } diff --git a/x/slashing/simulation/genesis_test.go b/x/slashing/simulation/genesis_test.go index a386588d8369..55bce42a84a6 100644 --- a/x/slashing/simulation/genesis_test.go +++ b/x/slashing/simulation/genesis_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,7 +33,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } @@ -52,7 +53,6 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, time.Duration(34800000000000), slashingGenesis.Params.DowntimeJailDuration) require.Len(t, slashingGenesis.MissedBlocks, 0) require.Len(t, slashingGenesis.SigningInfos, 0) - } // TestRandomizedGenState tests abnormal scenarios of applying RandomizedGenState. diff --git a/x/slashing/simulation/operations.go b/x/slashing/simulation/operations.go index a4c82e0f4af4..56eef65d8a57 100644 --- a/x/slashing/simulation/operations.go +++ b/x/slashing/simulation/operations.go @@ -26,7 +26,6 @@ func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, sk stakingkeeper.Keeper, ) simulation.WeightedOperations { - var weightMsgUnjail int appParams.GetOrGenerate(cdc, OpWeightMsgUnjail, &weightMsgUnjail, nil, func(_ *rand.Rand) { @@ -48,7 +47,6 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - validator, ok := stakingkeeper.RandomValidator(r, sk, ctx) if !ok { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUnjail, "validator is not ok"), nil, nil // skip @@ -89,7 +87,7 @@ func SimulateMsgUnjail(ak types.AccountKeeper, bk types.BankKeeper, k keeper.Kee msg := types.NewMsgUnjail(validator.GetOperator()) txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( txGen, []sdk.Msg{msg}, fees, diff --git a/x/slashing/simulation/operations_test.go b/x/slashing/simulation/operations_test.go index 25b1473e4b1b..a0dbffb1f360 100644 --- a/x/slashing/simulation/operations_test.go +++ b/x/slashing/simulation/operations_test.go @@ -1,7 +1,6 @@ package simulation_test import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" "math/rand" "testing" "time" @@ -100,7 +99,7 @@ func TestSimulateMsgUnjail(t *testing.T) { require.NoError(t, err) var msg types.MsgUnjail - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(t, operationMsg.OK) require.Equal(t, types.TypeMsgUnjail, msg.Type()) diff --git a/x/slashing/spec/01_concepts.md b/x/slashing/spec/01_concepts.md index 9505706f90d3..ea7c6b319bae 100644 --- a/x/slashing/spec/01_concepts.md +++ b/x/slashing/spec/01_concepts.md @@ -43,16 +43,14 @@ _Vu_ : validator unbonded ### Single Double Sign Infraction -<-----------------> -[----------C1----D1,Vu-----] +\[----------C1----D1,Vu-----\] A single infraction is committed then later discovered, at which point the validator is unbonded and slashed at the full amount for the infraction. ### Multiple Double Sign Infractions -<---------------------------> -[----------C1--C2---C3---D1,D2,D3Vu-----] +\[----------C1--C2---C3---D1,D2,D3Vu-----\] Multiple infractions are committed and then later discovered, at which point the validator is jailed and slashed for only one infraction. Because the validator diff --git a/x/slashing/spec/05_hooks.md b/x/slashing/spec/05_hooks.md index d1234e58ee05..a839689429a8 100644 --- a/x/slashing/spec/05_hooks.md +++ b/x/slashing/spec/05_hooks.md @@ -21,6 +21,8 @@ The following hooks impact the slashing state: Upon successful first-time bonding of a new validator, we create a new `ValidatorSigningInfo` structure for the now-bonded validator, which `StartHeight` of the current block. +If the validator was out of the validator set and gets bonded again, its new bonded height is set. + ```go onValidatorBonded(address sdk.ValAddress) @@ -32,7 +34,10 @@ onValidatorBonded(address sdk.ValAddress) JailedUntil : time.Unix(0, 0), Tombstone : false, MissedBloskCounter : 0 + } else { + signingInfo.StartHeight = CurrentHeight } + setValidatorSigningInfo(signingInfo) } diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index ec1b44ec559d..d1b54a969ee1 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -4,8 +4,10 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers concrete types on LegacyAmino codec @@ -21,6 +23,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/slashing/types/genesis.go b/x/slashing/types/genesis.go index 9b427e725ac3..b891dec80e8b 100644 --- a/x/slashing/types/genesis.go +++ b/x/slashing/types/genesis.go @@ -11,7 +11,6 @@ import ( func NewGenesisState( params Params, signingInfos []SigningInfo, missedBlocks []ValidatorMissedBlocks, ) *GenesisState { - return &GenesisState{ Params: params, SigningInfos: signingInfos, diff --git a/x/slashing/types/msg.go b/x/slashing/types/msg.go index 374f0c3dd32c..e5e0ec0f24f2 100644 --- a/x/slashing/types/msg.go +++ b/x/slashing/types/msg.go @@ -1,7 +1,6 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -31,11 +30,11 @@ func (msg MsgUnjail) GetSigners() []sdk.AccAddress { // GetSignBytes gets the bytes for the message signer to sign on func (msg MsgUnjail) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } -// ValidateBasic validity check for the AnteHandler +// ValidateBasic does a sanity check on the provided message func (msg MsgUnjail) ValidateBasic() error { if _, err := sdk.ValAddressFromBech32(msg.ValidatorAddr); err != nil { return sdkerrors.ErrInvalidAddress.Wrapf("validator input address: %s", err) diff --git a/x/slashing/types/params.go b/x/slashing/types/params.go index aa9cd559e7db..ad1d98c37f15 100644 --- a/x/slashing/types/params.go +++ b/x/slashing/types/params.go @@ -39,7 +39,6 @@ func NewParams( signedBlocksWindow int64, minSignedPerWindow sdk.Dec, downtimeJailDuration time.Duration, slashFractionDoubleSign, slashFractionDowntime sdk.Dec, ) Params { - return Params{ SignedBlocksWindow: signedBlocksWindow, MinSignedPerWindow: minSignedPerWindow, diff --git a/x/slashing/types/signing_info.go b/x/slashing/types/signing_info.go index 43a052d22f7d..d9b00da199e6 100644 --- a/x/slashing/types/signing_info.go +++ b/x/slashing/types/signing_info.go @@ -14,7 +14,6 @@ func NewValidatorSigningInfo( condAddr sdk.ConsAddress, startHeight, indexOffset int64, jailedUntil time.Time, tombstoned bool, missedBlocksCounter int64, ) ValidatorSigningInfo { - return ValidatorSigningInfo{ Address: condAddr.String(), StartHeight: startHeight, diff --git a/x/staking/app_test.go b/x/staking/app_test.go index a97954254826..5a3bd723cb9c 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -26,7 +26,6 @@ func checkDelegation( t *testing.T, app *simapp.SimApp, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, expFound bool, expShares sdk.Dec, ) { - ctxCheck := app.BaseApp.NewContext(true, tmproto.Header{}) delegation, found := app.StakingKeeper.GetDelegation(ctxCheck, delegatorAddr, validatorAddr) if expFound { @@ -107,7 +106,7 @@ func TestStakingMsgs(t *testing.T) { require.NoError(t, err) simapp.CheckBalance(t, app, addr2, sdk.Coins{genCoin.Sub(bondCoin)}) - checkDelegation(t, app, addr2, sdk.ValAddress(addr1), true, bondTokens.ToDec()) + checkDelegation(t, app, addr2, sdk.ValAddress(addr1), true, sdk.NewDecFromInt(bondTokens)) // begin unbonding beginUnbondingMsg := types.NewMsgUndelegate(addr2, sdk.ValAddress(addr1), bondCoin) diff --git a/x/staking/client/cli/tx.go b/x/staking/client/cli/tx.go index 6a9d5393120f..f184d27d6a94 100644 --- a/x/staking/client/cli/tx.go +++ b/x/staking/client/cli/tx.go @@ -51,6 +51,7 @@ func NewTxCmd() *cobra.Command { return stakingTxCmd } +// NewCreateValidatorCmd returns a CLI command handler for creating a MsgCreateValidator transaction. func NewCreateValidatorCmd() *cobra.Command { cmd := &cobra.Command{ Use: "create-validator", @@ -90,6 +91,7 @@ func NewCreateValidatorCmd() *cobra.Command { return cmd } +// NewEditValidatorCmd returns a CLI command handler for creating a MsgEditValidator transaction. func NewEditValidatorCmd() *cobra.Command { cmd := &cobra.Command{ Use: "edit-validator", @@ -145,6 +147,7 @@ func NewEditValidatorCmd() *cobra.Command { return cmd } +// NewDelegateCmd returns a CLI command handler for creating a MsgDelegate transaction. func NewDelegateCmd() *cobra.Command { bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() @@ -188,6 +191,7 @@ $ %s tx staking delegate %s1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm 1000stake --f return cmd } +// NewRedelegateCmd returns a CLI command handler for creating a MsgBeginRedelegate transaction. func NewRedelegateCmd() *cobra.Command { bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() @@ -236,6 +240,7 @@ $ %s tx staking redelegate %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj %s1l2rsakp3 return cmd } +// NewUnbondCmd returns a CLI command handler for creating a MsgUndelegate transaction. func NewUnbondCmd() *cobra.Command { bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() @@ -279,6 +284,7 @@ $ %s tx staking unbond %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake --from return cmd } +// NewCancelUnbondingDelegation returns a CLI command handler for creating a MsgCancelUnbondingDelegation transaction. func NewCancelUnbondingDelegation() *cobra.Command { bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() @@ -549,7 +555,6 @@ func PrepareConfigForTxCreateValidator(flagSet *flag.FlagSet, moniker, nodeID, c func BuildCreateValidatorMsg(clientCtx client.Context, config TxCreateValidatorConfig, txBldr tx.Factory, generateOnly bool) (tx.Factory, sdk.Msg, error) { amounstStr := config.Amount amount, err := sdk.ParseCoinNormalized(amounstStr) - if err != nil { return txBldr, nil, err } @@ -568,7 +573,6 @@ func BuildCreateValidatorMsg(clientCtx client.Context, config TxCreateValidatorC maxRateStr := config.CommissionMaxRate maxChangeRateStr := config.CommissionMaxChangeRate commissionRates, err := buildCommissionRates(rateStr, maxRateStr, maxChangeRateStr) - if err != nil { return txBldr, nil, err } diff --git a/x/staking/client/cli/tx_test.go b/x/staking/client/cli/tx_test.go index a7eb30fde3c2..243780bc6e03 100644 --- a/x/staking/client/cli/tx_test.go +++ b/x/staking/client/cli/tx_test.go @@ -43,25 +43,29 @@ func TestPrepareConfigForTxCreateValidator(t *testing.T) { return }, expectedCfg: mkTxValCfg(defaultAmount, "0.1", "0.2", "0.01", "1"), - }, { + }, + { name: "Custom amount", fsModify: func(fs *pflag.FlagSet) { fs.Set(FlagAmount, "2000stake") }, expectedCfg: mkTxValCfg("2000stake", "0.1", "0.2", "0.01", "1"), - }, { + }, + { name: "Custom commission rate", fsModify: func(fs *pflag.FlagSet) { fs.Set(FlagCommissionRate, "0.54") }, expectedCfg: mkTxValCfg(defaultAmount, "0.54", "0.2", "0.01", "1"), - }, { + }, + { name: "Custom commission max rate", fsModify: func(fs *pflag.FlagSet) { fs.Set(FlagCommissionMaxRate, "0.89") }, expectedCfg: mkTxValCfg(defaultAmount, "0.1", "0.89", "0.01", "1"), - }, { + }, + { name: "Custom commission max change rate", fsModify: func(fs *pflag.FlagSet) { fs.Set(FlagCommissionMaxChangeRate, "0.55") diff --git a/x/staking/client/testutil/grpc.go b/x/staking/client/testutil/grpc.go index 78c39f857b59..26093aa15bc3 100644 --- a/x/staking/client/testutil/grpc.go +++ b/x/staking/client/testutil/grpc.go @@ -348,7 +348,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryUnbondingDelegation() { s.Require().NoError(err) s.Require().Equal(ubd.Unbond.DelegatorAddress, val.Address.String()) s.Require().Equal(ubd.Unbond.ValidatorAddress, val.ValAddress.String()) - s.Require().Len(ubd.Unbond.Entries, 1) + s.Require().Len(ubd.Unbond.Entries, 2) } }) } diff --git a/x/staking/client/testutil/suite.go b/x/staking/client/testutil/suite.go index e5ddab70b86a..879808868eb9 100644 --- a/x/staking/client/testutil/suite.go +++ b/x/staking/client/testutil/suite.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/testutil/rest" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/types/query" @@ -72,14 +73,21 @@ func (s *IntegrationTestSuite) SetupSuite() { s.Require().Equal(uint32(0), txRes.Code) _, err = s.network.WaitForHeight(1) s.Require().NoError(err) - // unbonding - out, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbond) + + unbondingAmount := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5)) + // unbonding the amount + out, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbondingAmount) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes)) + s.Require().Equal(uint32(0), txRes.Code) + // unbonding the amount + out, err = MsgUnbondExec(val.ClientCtx, val.Address, val.ValAddress, unbondingAmount) s.Require().NoError(err) s.Require().NoError(err) s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &txRes)) s.Require().Equal(uint32(0), txRes.Code) - _, err = s.network.WaitForHeight(1) + err = s.network.WaitForNextBlock() s.Require().NoError(err) } @@ -595,7 +603,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryUnbondingDelegation() { s.Require().NoError(err) s.Require().Equal(ubd.DelegatorAddress, val.Address.String()) s.Require().Equal(ubd.ValidatorAddress, val.ValAddress.String()) - s.Require().Len(ubd.Entries, 1) + s.Require().Len(ubd.Entries, 2) } }) } @@ -1362,7 +1370,6 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { []string{ val.ValAddress.String(), sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10000)).String(), - sdk.NewInt(3).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -1374,8 +1381,7 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { "valid transaction of canceling unbonding delegation", []string{ val.ValAddress.String(), - sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), - sdk.NewInt(3).String(), + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(5)).String(), fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), @@ -1391,6 +1397,22 @@ func (s *IntegrationTestSuite) TestNewCancelUnbondingDelegationCmd() { s.Run(tc.name, func() { cmd := cli.NewCancelUnbondingDelegation() clientCtx := val.ClientCtx + if !tc.expectErr && tc.expectedCode != sdkerrors.ErrNotFound.ABCICode() { + getCreationHeight := func() int64 { + // fethichg the unbonding delegations + resp, err := rest.GetRequest(fmt.Sprintf("%s/cosmos/staking/v1beta1/delegators/%s/unbonding_delegations", val.APIAddress, val.Address.String())) + s.Require().NoError(err) + + var ubds types.QueryDelegatorUnbondingDelegationsResponse + + err = val.ClientCtx.Codec.UnmarshalJSON(resp, &ubds) + s.Require().NoError(err) + s.Require().Len(ubds.UnbondingResponses, 1) + s.Require().Equal(ubds.UnbondingResponses[0].DelegatorAddress, val.Address.String()) + return ubds.UnbondingResponses[0].Entries[1].CreationHeight + } + tc.args = append(tc.args, fmt.Sprint(getCreationHeight())) + } out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args) if tc.expectErr { diff --git a/x/staking/client/testutil/test_helpers.go b/x/staking/client/testutil/test_helpers.go index 3a31ea004f3d..0fa752e05720 100644 --- a/x/staking/client/testutil/test_helpers.go +++ b/x/staking/client/testutil/test_helpers.go @@ -18,9 +18,7 @@ var commonArgs = []string{ } // MsgRedelegateExec creates a redelegate message. -func MsgRedelegateExec(clientCtx client.Context, from, src, dst, amount fmt.Stringer, - extraArgs ...string) (testutil.BufferWriter, error) { - +func MsgRedelegateExec(clientCtx client.Context, from, src, dst, amount fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ src.String(), dst.String(), @@ -36,8 +34,8 @@ func MsgRedelegateExec(clientCtx client.Context, from, src, dst, amount fmt.Stri // MsgUnbondExec creates a unbond message. func MsgUnbondExec(clientCtx client.Context, from fmt.Stringer, valAddress, - amount fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) { - + amount fmt.Stringer, extraArgs ...string, +) (testutil.BufferWriter, error) { args := []string{ valAddress.String(), amount.String(), diff --git a/x/staking/genesis.go b/x/staking/genesis.go index c019359c3526..5b94b8adf48b 100644 --- a/x/staking/genesis.go +++ b/x/staking/genesis.go @@ -3,7 +3,6 @@ package staking import ( "fmt" - abci "github.com/tendermint/tendermint/abci/types" tmtypes "github.com/tendermint/tendermint/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -12,201 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking/types" ) -// InitGenesis sets the pool and parameters for the provided keeper. For each -// validator in data, it sets that validator in the keeper along with manually -// setting the indexes. In addition, it also sets any delegations found in -// data. Finally, it updates the bonded validators. -// Returns final validator set after applying all declaration and delegations -func InitGenesis( - ctx sdk.Context, keeper keeper.Keeper, accountKeeper types.AccountKeeper, - bankKeeper types.BankKeeper, data *types.GenesisState, -) (res []abci.ValidatorUpdate) { - bondedTokens := sdk.ZeroInt() - notBondedTokens := sdk.ZeroInt() - - // We need to pretend to be "n blocks before genesis", where "n" is the - // validator update delay, so that e.g. slashing periods are correctly - // initialized for the validator set e.g. with a one-block offset - the - // first TM block is at height 1, so state updates applied from - // genesis.json are in block 0. - ctx = ctx.WithBlockHeight(1 - sdk.ValidatorUpdateDelay) - - keeper.SetParams(ctx, data.Params) - keeper.SetLastTotalPower(ctx, data.LastTotalPower) - - for _, validator := range data.Validators { - keeper.SetValidator(ctx, validator) - - // Manually set indices for the first time - keeper.SetValidatorByConsAddr(ctx, validator) - keeper.SetValidatorByPowerIndex(ctx, validator) - - // Call the creation hook if not exported - if !data.Exported { - if err := keeper.AfterValidatorCreated(ctx, validator.GetOperator()); err != nil { - panic(err) - } - } - - // update timeslice if necessary - if validator.IsUnbonding() { - keeper.InsertUnbondingValidatorQueue(ctx, validator) - } - - switch validator.GetStatus() { - case types.Bonded: - bondedTokens = bondedTokens.Add(validator.GetTokens()) - case types.Unbonding, types.Unbonded: - notBondedTokens = notBondedTokens.Add(validator.GetTokens()) - default: - panic("invalid validator status") - } - } - - for _, delegation := range data.Delegations { - delegatorAddress, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) - if err != nil { - panic(err) - } - - // Call the before-creation hook if not exported - if !data.Exported { - if err := keeper.BeforeDelegationCreated(ctx, delegatorAddress, delegation.GetValidatorAddr()); err != nil { - panic(err) - } - } - - keeper.SetDelegation(ctx, delegation) - - // Call the after-modification hook if not exported - if !data.Exported { - if err := keeper.AfterDelegationModified(ctx, delegatorAddress, delegation.GetValidatorAddr()); err != nil { - panic(err) - } - } - } - - for _, ubd := range data.UnbondingDelegations { - keeper.SetUnbondingDelegation(ctx, ubd) - - for _, entry := range ubd.Entries { - keeper.InsertUBDQueue(ctx, ubd, entry.CompletionTime) - notBondedTokens = notBondedTokens.Add(entry.Balance) - } - } - - for _, red := range data.Redelegations { - keeper.SetRedelegation(ctx, red) - - for _, entry := range red.Entries { - keeper.InsertRedelegationQueue(ctx, red, entry.CompletionTime) - } - } - - bondedCoins := sdk.NewCoins(sdk.NewCoin(data.Params.BondDenom, bondedTokens)) - notBondedCoins := sdk.NewCoins(sdk.NewCoin(data.Params.BondDenom, notBondedTokens)) - - // check if the unbonded and bonded pools accounts exists - bondedPool := keeper.GetBondedPool(ctx) - if bondedPool == nil { - panic(fmt.Sprintf("%s module account has not been set", types.BondedPoolName)) - } - - // TODO: remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 - bondedBalance := bankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) - if bondedBalance.IsZero() { - accountKeeper.SetModuleAccount(ctx, bondedPool) - } - - // if balance is different from bonded coins panic because genesis is most likely malformed - if !bondedBalance.IsEqual(bondedCoins) { - panic(fmt.Sprintf("bonded pool balance is different from bonded coins: %s <-> %s", bondedBalance, bondedCoins)) - } - - notBondedPool := keeper.GetNotBondedPool(ctx) - if notBondedPool == nil { - panic(fmt.Sprintf("%s module account has not been set", types.NotBondedPoolName)) - } - - notBondedBalance := bankKeeper.GetAllBalances(ctx, notBondedPool.GetAddress()) - if notBondedBalance.IsZero() { - accountKeeper.SetModuleAccount(ctx, notBondedPool) - } - - // If balance is different from non bonded coins panic because genesis is most - // likely malformed. - if !notBondedBalance.IsEqual(notBondedCoins) { - panic(fmt.Sprintf("not bonded pool balance is different from not bonded coins: %s <-> %s", notBondedBalance, notBondedCoins)) - } - - // don't need to run Tendermint updates if we exported - if data.Exported { - for _, lv := range data.LastValidatorPowers { - valAddr, err := sdk.ValAddressFromBech32(lv.Address) - if err != nil { - panic(err) - } - - keeper.SetLastValidatorPower(ctx, valAddr, lv.Power) - validator, found := keeper.GetValidator(ctx, valAddr) - - if !found { - panic(fmt.Sprintf("validator %s not found", lv.Address)) - } - - update := validator.ABCIValidatorUpdate(keeper.PowerReduction(ctx)) - update.Power = lv.Power // keep the next-val-set offset, use the last power for the first block - res = append(res, update) - } - } else { - var err error - - res, err = keeper.ApplyAndReturnValidatorSetUpdates(ctx) - if err != nil { - panic(err) - } - } - - return res -} - -// ExportGenesis returns a GenesisState for a given context and keeper. The -// GenesisState will contain the pool, params, validators, and bonds found in -// the keeper. -func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState { - var unbondingDelegations []types.UnbondingDelegation - - keeper.IterateUnbondingDelegations(ctx, func(_ int64, ubd types.UnbondingDelegation) (stop bool) { - unbondingDelegations = append(unbondingDelegations, ubd) - return false - }) - - var redelegations []types.Redelegation - - keeper.IterateRedelegations(ctx, func(_ int64, red types.Redelegation) (stop bool) { - redelegations = append(redelegations, red) - return false - }) - - var lastValidatorPowers []types.LastValidatorPower - - keeper.IterateLastValidatorPowers(ctx, func(addr sdk.ValAddress, power int64) (stop bool) { - lastValidatorPowers = append(lastValidatorPowers, types.LastValidatorPower{Address: addr.String(), Power: power}) - return false - }) - - return &types.GenesisState{ - Params: keeper.GetParams(ctx), - LastTotalPower: keeper.GetLastTotalPower(ctx), - LastValidatorPowers: lastValidatorPowers, - Validators: keeper.GetAllValidators(ctx), - Delegations: keeper.GetAllDelegations(ctx), - UnbondingDelegations: unbondingDelegations, - Redelegations: redelegations, - Exported: true, - } -} - // WriteValidators returns a slice of bonded genesis validators. func WriteValidators(ctx sdk.Context, keeper keeper.Keeper) (vals []tmtypes.GenesisValidator, err error) { keeper.IterateLastValidators(ctx, func(_ int64, validator types.ValidatorI) (stop bool) { diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index df6120b04361..6f4a8ad8bda0 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -1,218 +1,17 @@ package staking_test import ( - "fmt" - "log" "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/bank/testutil" "github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/staking/teststaking" "github.com/cosmos/cosmos-sdk/x/staking/types" ) -func bootstrapGenesisTest(t *testing.T, numAddrs int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress) { - _, app, ctx := getBaseSimappWithCustomKeeper(t) - - addrDels, _ := generateAddresses(app, ctx, numAddrs, sdk.NewInt(10000)) - return app, ctx, addrDels -} - -func TestInitGenesis(t *testing.T) { - app, ctx, addrs := bootstrapGenesisTest(t, 10) - - valTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 1) - - params := app.StakingKeeper.GetParams(ctx) - validators := app.StakingKeeper.GetAllValidators(ctx) - require.Len(t, validators, 1) - var delegations []types.Delegation - - pk0, err := codectypes.NewAnyWithValue(PKs[0]) - require.NoError(t, err) - - pk1, err := codectypes.NewAnyWithValue(PKs[1]) - require.NoError(t, err) - - // initialize the validators - bondedVal1 := types.Validator{ - OperatorAddress: sdk.ValAddress(addrs[0]).String(), - ConsensusPubkey: pk0, - Status: types.Bonded, - Tokens: valTokens, - DelegatorShares: valTokens.ToDec(), - Description: types.NewDescription("hoop", "", "", "", ""), - } - bondedVal2 := types.Validator{ - OperatorAddress: sdk.ValAddress(addrs[1]).String(), - ConsensusPubkey: pk1, - Status: types.Bonded, - Tokens: valTokens, - DelegatorShares: valTokens.ToDec(), - Description: types.NewDescription("bloop", "", "", "", ""), - } - - // append new bonded validators to the list - validators = append(validators, bondedVal1, bondedVal2) - log.Printf("%#v", len(validators)) - // mint coins in the bonded pool representing the validators coins - i2 := len(validators) - 1 // -1 to exclude genesis validator - require.NoError(t, - testutil.FundModuleAccount( - app.BankKeeper, - ctx, - types.BondedPoolName, - sdk.NewCoins( - sdk.NewCoin(params.BondDenom, valTokens.MulRaw((int64)(i2))), - ), - ), - ) - genesisDelegations := app.StakingKeeper.GetAllDelegations(ctx) - delegations = append(delegations, genesisDelegations...) - - genesisState := types.NewGenesisState(params, validators, delegations) - vals := staking.InitGenesis(ctx, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, genesisState) - - actualGenesis := staking.ExportGenesis(ctx, app.StakingKeeper) - require.Equal(t, genesisState.Params, actualGenesis.Params) - require.Equal(t, genesisState.Delegations, actualGenesis.Delegations) - require.EqualValues(t, app.StakingKeeper.GetAllValidators(ctx), actualGenesis.Validators) - - // Ensure validators have addresses. - vals2, err := staking.WriteValidators(ctx, app.StakingKeeper) - require.NoError(t, err) - for _, val := range vals2 { - require.NotEmpty(t, val.Address) - } - - // now make sure the validators are bonded and intra-tx counters are correct - resVal, found := app.StakingKeeper.GetValidator(ctx, sdk.ValAddress(addrs[0])) - require.True(t, found) - require.Equal(t, types.Bonded, resVal.Status) - - resVal, found = app.StakingKeeper.GetValidator(ctx, sdk.ValAddress(addrs[1])) - require.True(t, found) - require.Equal(t, types.Bonded, resVal.Status) - - abcivals := make([]abci.ValidatorUpdate, len(vals)) - - validators = validators[1:] // remove genesis validator - for i, val := range validators { - abcivals[i] = val.ABCIValidatorUpdate(app.StakingKeeper.PowerReduction(ctx)) - } - - require.Equal(t, abcivals, vals) -} - -func TestInitGenesis_PoolsBalanceMismatch(t *testing.T) { - app := simapp.Setup(t, false) - ctx := app.NewContext(false, tmproto.Header{}) - - consPub, err := codectypes.NewAnyWithValue(PKs[0]) - require.NoError(t, err) - - // create mock validator - validator := types.Validator{ - OperatorAddress: sdk.ValAddress("12345678901234567890").String(), - ConsensusPubkey: consPub, - Jailed: false, - Tokens: sdk.NewInt(10), - DelegatorShares: sdk.NewInt(10).ToDec(), - Description: types.NewDescription("bloop", "", "", "", ""), - } - // valid params - params := types.Params{ - UnbondingTime: 10000, - MaxValidators: 1, - MaxEntries: 10, - BondDenom: "stake", - } - - // test - - require.Panics(t, func() { - // setting validator status to bonded so the balance counts towards bonded pool - validator.Status = types.Bonded - staking.InitGenesis(ctx, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, &types.GenesisState{ - Params: params, - Validators: []types.Validator{validator}, - }) - }, "should panic because bonded pool balance is different from bonded pool coins") - - require.Panics(t, func() { - // setting validator status to unbonded so the balance counts towards not bonded pool - validator.Status = types.Unbonded - staking.InitGenesis(ctx, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, &types.GenesisState{ - Params: params, - Validators: []types.Validator{validator}, - }) - }, "should panic because not bonded pool balance is different from not bonded pool coins") -} - -func TestInitGenesisLargeValidatorSet(t *testing.T) { - size := 200 - require.True(t, size > 100) - - app, ctx, addrs := bootstrapGenesisTest(t, 200) - genesisValidators := app.StakingKeeper.GetAllValidators(ctx) - - params := app.StakingKeeper.GetParams(ctx) - delegations := []types.Delegation{} - validators := make([]types.Validator, size) - var err error - - bondedPoolAmt := sdk.ZeroInt() - for i := range validators { - validators[i], err = types.NewValidator(sdk.ValAddress(addrs[i]), - PKs[i], types.NewDescription(fmt.Sprintf("#%d", i), "", "", "", "")) - require.NoError(t, err) - validators[i].Status = types.Bonded - - tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 1) - if i < 100 { - tokens = app.StakingKeeper.TokensFromConsensusPower(ctx, 2) - } - validators[i].Tokens = tokens - validators[i].DelegatorShares = tokens.ToDec() - // add bonded coins - bondedPoolAmt = bondedPoolAmt.Add(tokens) - } - - validators = append(validators, genesisValidators...) - - genesisState := types.NewGenesisState(params, validators, delegations) - - // mint coins in the bonded pool representing the validators coins - require.NoError(t, - testutil.FundModuleAccount( - app.BankKeeper, - ctx, - types.BondedPoolName, - sdk.NewCoins(sdk.NewCoin(params.BondDenom, bondedPoolAmt)), - ), - ) - - vals := staking.InitGenesis(ctx, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, genesisState) - - abcivals := make([]abci.ValidatorUpdate, 100) - for i, val := range validators[:100] { - abcivals[i] = val.ABCIValidatorUpdate(app.StakingKeeper.PowerReduction(ctx)) - } - - // remove genesis validator - vals = vals[:100] - require.Equal(t, abcivals, vals) -} - func TestValidateGenesis(t *testing.T) { genValidators1 := make([]types.Validator, 1, 5) pk := ed25519.GenPrivKey().PubKey() @@ -244,9 +43,11 @@ func TestValidateGenesis(t *testing.T) { for _, tt := range tests { tt := tt + t.Run(tt.name, func(t *testing.T) { genesisState := types.DefaultGenesisState() tt.mutate(genesisState) + if tt.wantErr { assert.Error(t, staking.ValidateGenesis(genesisState)) } else { diff --git a/x/staking/keeper/alias_functions.go b/x/staking/keeper/alias_functions.go index 36c2d23661c6..59c4d23be2e8 100644 --- a/x/staking/keeper/alias_functions.go +++ b/x/staking/keeper/alias_functions.go @@ -114,7 +114,8 @@ func (k Keeper) Delegation(ctx sdk.Context, addrDel sdk.AccAddress, addrVal sdk. // iterate through all of the delegations from a delegator func (k Keeper) IterateDelegations(ctx sdk.Context, delAddr sdk.AccAddress, - fn func(index int64, del types.DelegationI) (stop bool)) { + fn func(index int64, del types.DelegationI) (stop bool), +) { store := ctx.KVStore(k.storeKey) delegatorPrefixKey := types.GetDelegationsKey(delAddr) diff --git a/x/staking/keeper/common_test.go b/x/staking/keeper/common_test.go index 6833ea4c0baf..ad31204ba43b 100644 --- a/x/staking/keeper/common_test.go +++ b/x/staking/keeper/common_test.go @@ -13,9 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking/types" ) -var ( - PKs = simapp.CreateTestPubKeys(500) -) +var PKs = simapp.CreateTestPubKeys(500) func init() { sdk.DefaultPowerReduction = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)) diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 6a9f404262b5..4c99e4adaedb 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -10,9 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/x/staking/types" ) -// return a specific delegation -func (k Keeper) GetDelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation types.Delegation, found bool) { +// 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) key := types.GetDelegationKey(delAddr, valAddr) @@ -26,7 +25,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 +40,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 +50,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,9 +68,9 @@ func (k Keeper) GetValidatorDelegations(ctx sdk.Context, valAddr sdk.ValAddress) return delegations } -// return 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) { +// 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) store := ctx.KVStore(k.storeKey) delegatorPrefixKey := types.GetDelegationsKey(delegator) @@ -88,7 +88,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 +100,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) error { delegatorAddress, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) if err != nil { @@ -116,9 +116,8 @@ func (k Keeper) RemoveDelegation(ctx sdk.Context, delegation types.Delegation) e return nil } -// return a given amount of all the delegator unbonding-delegations -func (k Keeper) GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress, - maxRetrieve uint16) (unbondingDelegations []types.UnbondingDelegation) { +// 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) store := ctx.KVStore(k.storeKey) @@ -137,10 +136,8 @@ func (k Keeper) GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddres return unbondingDelegations[:i] // trim if the array length < maxRetrieve } -// return a unbonding delegation -func (k Keeper) GetUnbondingDelegation( - ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, -) (ubd types.UnbondingDelegation, found bool) { +// GetUnbondingDelegation returns a unbonding delegation. +func (k Keeper) GetUnbondingDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (ubd types.UnbondingDelegation, found bool) { store := ctx.KVStore(k.storeKey) key := types.GetUBDKey(delAddr, valAddr) value := store.Get(key) @@ -154,7 +151,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) @@ -171,7 +169,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) @@ -187,9 +185,86 @@ func (k Keeper) IterateUnbondingDelegations(ctx sdk.Context, fn func(index int64 } } -// HasMaxUnbondingDelegationEntries - check if unbonding delegation has maximum number of entries -func (k Keeper) HasMaxUnbondingDelegationEntries(ctx sdk.Context, - delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) bool { +// 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) if !found { return false @@ -198,7 +273,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 { @@ -215,7 +290,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 { @@ -233,7 +308,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, @@ -252,8 +327,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) @@ -268,16 +344,16 @@ 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 -func (k Keeper) InsertUBDQueue(ctx sdk.Context, ubd types.UnbondingDelegation, - completionTime time.Time) { +// 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} timeSlice := k.GetUBDQueueTimeSlice(ctx, completionTime) @@ -289,15 +365,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) @@ -318,9 +394,8 @@ func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, currTime time.Time) (m return matureUnbonds } -// return a given amount of all the delegator redelegations -func (k Keeper) GetRedelegations(ctx sdk.Context, delegator sdk.AccAddress, - maxRetrieve uint16) (redelegations []types.Redelegation) { +// 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) store := ctx.KVStore(k.storeKey) @@ -339,9 +414,8 @@ func (k Keeper) GetRedelegations(ctx sdk.Context, delegator sdk.AccAddress, return redelegations[:i] // trim if the array length < maxRetrieve } -// return a redelegation -func (k Keeper) GetRedelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) (red types.Redelegation, found bool) { +// 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) key := types.GetREDKey(delAddr, valSrcAddr, valDstAddr) @@ -355,7 +429,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) @@ -372,9 +447,8 @@ func (k Keeper) GetRedelegationsFromSrcValidator(ctx sdk.Context, valAddr sdk.Va return reds } -// check if validator is receiving a redelegation -func (k Keeper) HasReceivingRedelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool { +// 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) prefix := types.GetREDsByDelToValDstIndexKey(delAddr, valDstAddr) @@ -384,10 +458,8 @@ func (k Keeper) HasReceivingRedelegation(ctx sdk.Context, return iterator.Valid() } -// HasMaxRedelegationEntries - redelegation has maximum number of entries -func (k Keeper) HasMaxRedelegationEntries(ctx sdk.Context, - delegatorAddr sdk.AccAddress, validatorSrcAddr, - validatorDstAddr sdk.ValAddress) bool { +// HasMaxRedelegationEntries checks if redelegation has maximum number of entries. +func (k Keeper) HasMaxRedelegationEntries(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorSrcAddr, validatorDstAddr sdk.ValAddress) bool { red, found := k.GetRedelegation(ctx, delegatorAddr, validatorSrcAddr, validatorDstAddr) if !found { return false @@ -396,7 +468,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 { @@ -419,13 +491,14 @@ 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, minTime time.Time, balance sdk.Int, - sharesSrc, sharesDst sdk.Dec) types.Redelegation { + sharesSrc, sharesDst sdk.Dec, +) types.Redelegation { red, found := k.GetRedelegation(ctx, delegatorAddr, validatorSrcAddr, validatorDstAddr) if found { red.AddEntry(creationHeight, minTime, balance, sharesDst) @@ -439,7 +512,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) @@ -455,7 +528,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 { @@ -478,8 +551,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) @@ -494,21 +568,22 @@ 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 -func (k Keeper) InsertRedelegationQueue(ctx sdk.Context, red types.Redelegation, - completionTime time.Time) { +// 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) dvvTriplet := types.DVVTriplet{ DelegatorAddress: red.DelegatorAddress, ValidatorSrcAddress: red.ValidatorSrcAddress, - ValidatorDstAddress: red.ValidatorDstAddress} + ValidatorDstAddress: red.ValidatorDstAddress, + } if len(timeSlice) == 0 { k.SetRedelegationQueueTimeSlice(ctx, completionTime, []types.DVVTriplet{dvvTriplet}) @@ -518,14 +593,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) @@ -636,7 +713,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) { @@ -814,7 +891,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 2246345c2e78..04d67c143c5f 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -31,7 +31,7 @@ func TestDelegation(t *testing.T) { addrDels := simapp.AddTestAddrsIncremental(app, ctx, 3, sdk.NewInt(10000)) valAddrs := simapp.ConvertAddrsToValAddrs(addrDels) - //construct the validators + // construct the validators amts := []sdk.Int{sdk.NewInt(9), sdk.NewInt(8), sdk.NewInt(7)} var validators [3]types.Validator for i, amt := range amts { @@ -117,6 +117,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]) @@ -162,7 +167,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) @@ -175,6 +181,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]) @@ -212,7 +221,7 @@ func TestUnbondDelegation(t *testing.T) { app.StakingKeeper.SetDelegation(ctx, delegation) bondTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - amount, err := app.StakingKeeper.Unbond(ctx, delAddrs[0], valAddrs[0], bondTokens.ToDec()) + amount, err := app.StakingKeeper.Unbond(ctx, delAddrs[0], valAddrs[0], sdk.NewDecFromInt(bondTokens)) require.NoError(t, err) require.Equal(t, bondTokens, amount) // shares to be added to an unbonding delegation @@ -316,7 +325,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) { delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) delCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), delTokens)) - //create a validator with a self-delegation + // create a validator with a self-delegation validator := teststaking.NewValidator(t, addrVals[0], PKs[0]) validator.MinSelfDelegation = delTokens @@ -355,7 +364,7 @@ func TestUndelegateSelfDelegationBelowMinSelfDelegation(t *testing.T) { app.StakingKeeper.SetDelegation(ctx, delegation) val0AccAddr := sdk.AccAddress(addrVals[0].Bytes()) - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], app.StakingKeeper.TokensFromConsensusPower(ctx, 6).ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 6))) require.NoError(t, err) // end block @@ -376,7 +385,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { addrDels := simapp.AddTestAddrsIncremental(app, ctx, 2, sdk.NewInt(0)) addrVals := simapp.ConvertAddrsToValAddrs(addrDels) - //create a validator with a self-delegation + // create a validator with a self-delegation validator := teststaking.NewValidator(t, addrVals[0], PKs[0]) app.StakingKeeper.SetValidatorByConsAddr(ctx, validator) @@ -424,7 +433,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { // unbond the all self-delegation to put validator in unbonding state val0AccAddr := sdk.AccAddress(addrVals[0]) - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], delTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // end block @@ -499,7 +508,7 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { ctx = ctx.WithBlockTime(time.Unix(333, 0)) // unbond the all self-delegation to put validator in unbonding state - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], valTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(valTokens)) require.NoError(t, err) // end block @@ -522,12 +531,12 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { // unbond some of the other delegation's shares unbondTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], unbondTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], sdk.NewDecFromInt(unbondTokens)) require.NoError(t, err) // unbond rest of the other delegation's shares remainingTokens := delTokens.Sub(unbondTokens) - _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], remainingTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], sdk.NewDecFromInt(remainingTokens)) require.NoError(t, err) // now validator should be deleted from state @@ -548,7 +557,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), delCoins)) app.AccountKeeper.SetModuleAccount(ctx, notBondedPool) - //create a validator with a self-delegation + // create a validator with a self-delegation validator := teststaking.NewValidator(t, addrVals[0], PKs[0]) app.StakingKeeper.SetValidatorByConsAddr(ctx, validator) @@ -583,14 +592,14 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { ctx = ctx.WithBlockTime(time.Unix(333, 0)) // unbond the all self-delegation to put validator in unbonding state - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], valTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(valTokens)) require.NoError(t, err) // end block applyValidatorSetUpdates(t, ctx, app.StakingKeeper, 1) // unbond all the remaining delegation - _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], delTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrDels[1], addrVals[0], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // validator should still be in state and still be in unbonding state @@ -797,7 +806,7 @@ func TestRedelegateSelfDelegation(t *testing.T) { require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins)) app.AccountKeeper.SetModuleAccount(ctx, notBondedPool) - //create a validator with a self-delegation + // create a validator with a self-delegation validator := teststaking.NewValidator(t, addrVals[0], PKs[0]) app.StakingKeeper.SetValidatorByConsAddr(ctx, validator) @@ -827,7 +836,7 @@ func TestRedelegateSelfDelegation(t *testing.T) { delegation := types.NewDelegation(addrDels[0], addrVals[0], issuedShares) app.StakingKeeper.SetDelegation(ctx, delegation) - _, err := app.StakingKeeper.BeginRedelegation(ctx, val0AccAddr, addrVals[0], addrVals[1], delTokens.ToDec()) + _, err := app.StakingKeeper.BeginRedelegation(ctx, val0AccAddr, addrVals[0], addrVals[1], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // end block @@ -853,7 +862,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins)) app.AccountKeeper.SetModuleAccount(ctx, notBondedPool) - //create a validator with a self-delegation + // create a validator with a self-delegation validator := teststaking.NewValidator(t, addrVals[0], PKs[0]) app.StakingKeeper.SetValidatorByConsAddr(ctx, validator) @@ -888,7 +897,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { ctx = ctx.WithBlockHeader(header) // unbond the all self-delegation to put validator in unbonding state - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], delTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // end block @@ -900,7 +909,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { params := app.StakingKeeper.GetParams(ctx) require.True(t, blockTime.Add(params.UnbondingTime).Equal(validator.UnbondingTime)) - //change the context + // change the context header = ctx.BlockHeader() blockHeight2 := int64(20) header.Height = blockHeight2 @@ -910,7 +919,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { // unbond some of the other delegation's shares redelegateTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrDels[1], addrVals[0], addrVals[1], redelegateTokens.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrDels[1], addrVals[0], addrVals[1], sdk.NewDecFromInt(redelegateTokens)) require.NoError(t, err) // retrieve the unbonding delegation @@ -935,7 +944,7 @@ func TestRedelegateFromUnbondedValidator(t *testing.T) { require.NoError(t, testutil.FundModuleAccount(app.BankKeeper, ctx, notBondedPool.GetName(), startCoins)) app.AccountKeeper.SetModuleAccount(ctx, notBondedPool) - //create a validator with a self-delegation + // create a validator with a self-delegation validator := teststaking.NewValidator(t, addrVals[0], PKs[0]) app.StakingKeeper.SetValidatorByConsAddr(ctx, validator) @@ -967,7 +976,7 @@ func TestRedelegateFromUnbondedValidator(t *testing.T) { ctx = ctx.WithBlockTime(time.Unix(333, 0)) // unbond the all self-delegation to put validator in unbonding state - _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], delTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, val0AccAddr, addrVals[0], sdk.NewDecFromInt(delTokens)) require.NoError(t, err) // end block @@ -984,7 +993,7 @@ func TestRedelegateFromUnbondedValidator(t *testing.T) { // redelegate some of the delegation's shares redelegationTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrDels[1], addrVals[0], addrVals[1], redelegationTokens.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrDels[1], addrVals[0], addrVals[1], sdk.NewDecFromInt(redelegationTokens)) require.NoError(t, err) // no red should have been found diff --git a/x/staking/keeper/genesis.go b/x/staking/keeper/genesis.go new file mode 100644 index 000000000000..86eae3ada04b --- /dev/null +++ b/x/staking/keeper/genesis.go @@ -0,0 +1,204 @@ +package keeper + +import ( + "fmt" + + abci "github.com/tendermint/tendermint/abci/types" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +// InitGenesis sets the pool and parameters for the provided keeper. For each +// validator in data, it sets that validator in the keeper along with manually +// setting the indexes. In addition, it also sets any delegations found in +// data. Finally, it updates the bonded validators. +// Returns final validator set after applying all declaration and delegations +func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) (res []abci.ValidatorUpdate) { + bondedTokens := sdk.ZeroInt() + notBondedTokens := sdk.ZeroInt() + + // We need to pretend to be "n blocks before genesis", where "n" is the + // validator update delay, so that e.g. slashing periods are correctly + // initialized for the validator set e.g. with a one-block offset - the + // first TM block is at height 1, so state updates applied from + // genesis.json are in block 0. + ctx = ctx.WithBlockHeight(1 - sdk.ValidatorUpdateDelay) + + k.SetParams(ctx, data.Params) + k.SetLastTotalPower(ctx, data.LastTotalPower) + + for _, validator := range data.Validators { + k.SetValidator(ctx, validator) + + // Manually set indices for the first time + k.SetValidatorByConsAddr(ctx, validator) + k.SetValidatorByPowerIndex(ctx, validator) + + // Call the creation hook if not exported + if !data.Exported { + if err := k.AfterValidatorCreated(ctx, validator.GetOperator()); err != nil { + panic(err) + } + } + + // update timeslice if necessary + if validator.IsUnbonding() { + k.InsertUnbondingValidatorQueue(ctx, validator) + } + + switch validator.GetStatus() { + case types.Bonded: + bondedTokens = bondedTokens.Add(validator.GetTokens()) + + case types.Unbonding, types.Unbonded: + notBondedTokens = notBondedTokens.Add(validator.GetTokens()) + + default: + panic("invalid validator status") + } + } + + for _, delegation := range data.Delegations { + delegatorAddress, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) + if err != nil { + panic(err) + } + + // Call the before-creation hook if not exported + if !data.Exported { + if err := k.BeforeDelegationCreated(ctx, delegatorAddress, delegation.GetValidatorAddr()); err != nil { + panic(err) + } + } + + k.SetDelegation(ctx, delegation) + + // Call the after-modification hook if not exported + if !data.Exported { + if err := k.AfterDelegationModified(ctx, delegatorAddress, delegation.GetValidatorAddr()); err != nil { + panic(err) + } + } + } + + for _, ubd := range data.UnbondingDelegations { + k.SetUnbondingDelegation(ctx, ubd) + + for _, entry := range ubd.Entries { + k.InsertUBDQueue(ctx, ubd, entry.CompletionTime) + notBondedTokens = notBondedTokens.Add(entry.Balance) + } + } + + for _, red := range data.Redelegations { + k.SetRedelegation(ctx, red) + + for _, entry := range red.Entries { + k.InsertRedelegationQueue(ctx, red, entry.CompletionTime) + } + } + + bondedCoins := sdk.NewCoins(sdk.NewCoin(data.Params.BondDenom, bondedTokens)) + notBondedCoins := sdk.NewCoins(sdk.NewCoin(data.Params.BondDenom, notBondedTokens)) + + // check if the unbonded and bonded pools accounts exists + bondedPool := k.GetBondedPool(ctx) + if bondedPool == nil { + panic(fmt.Sprintf("%s module account has not been set", types.BondedPoolName)) + } + + // TODO: remove with genesis 2-phases refactor https://github.com/cosmos/cosmos-sdk/issues/2862 + bondedBalance := k.bankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) + if bondedBalance.IsZero() { + k.authKeeper.SetModuleAccount(ctx, bondedPool) + } + + // if balance is different from bonded coins panic because genesis is most likely malformed + if !bondedBalance.IsEqual(bondedCoins) { + panic(fmt.Sprintf("bonded pool balance is different from bonded coins: %s <-> %s", bondedBalance, bondedCoins)) + } + + notBondedPool := k.GetNotBondedPool(ctx) + if notBondedPool == nil { + panic(fmt.Sprintf("%s module account has not been set", types.NotBondedPoolName)) + } + + notBondedBalance := k.bankKeeper.GetAllBalances(ctx, notBondedPool.GetAddress()) + if notBondedBalance.IsZero() { + k.authKeeper.SetModuleAccount(ctx, notBondedPool) + } + + // If balance is different from non bonded coins panic because genesis is most + // likely malformed. + if !notBondedBalance.IsEqual(notBondedCoins) { + panic(fmt.Sprintf("not bonded pool balance is different from not bonded coins: %s <-> %s", notBondedBalance, notBondedCoins)) + } + + // don't need to run Tendermint updates if we exported + if data.Exported { + for _, lv := range data.LastValidatorPowers { + valAddr, err := sdk.ValAddressFromBech32(lv.Address) + if err != nil { + panic(err) + } + + k.SetLastValidatorPower(ctx, valAddr, lv.Power) + validator, found := k.GetValidator(ctx, valAddr) + + if !found { + panic(fmt.Sprintf("validator %s not found", lv.Address)) + } + + update := validator.ABCIValidatorUpdate(k.PowerReduction(ctx)) + update.Power = lv.Power // keep the next-val-set offset, use the last power for the first block + res = append(res, update) + } + } else { + var err error + + res, err = k.ApplyAndReturnValidatorSetUpdates(ctx) + if err != nil { + panic(err) + } + } + + return res +} + +// ExportGenesis returns a GenesisState for a given context and keeper. The +// GenesisState will contain the pool, params, validators, and bonds found in +// the keeper. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + var unbondingDelegations []types.UnbondingDelegation + + k.IterateUnbondingDelegations(ctx, func(_ int64, ubd types.UnbondingDelegation) (stop bool) { + unbondingDelegations = append(unbondingDelegations, ubd) + return false + }) + + var redelegations []types.Redelegation + + k.IterateRedelegations(ctx, func(_ int64, red types.Redelegation) (stop bool) { + redelegations = append(redelegations, red) + return false + }) + + var lastValidatorPowers []types.LastValidatorPower + + k.IterateLastValidatorPowers(ctx, func(addr sdk.ValAddress, power int64) (stop bool) { + lastValidatorPowers = append(lastValidatorPowers, types.LastValidatorPower{Address: addr.String(), Power: power}) + return false + }) + + return &types.GenesisState{ + Params: k.GetParams(ctx), + LastTotalPower: k.GetLastTotalPower(ctx), + LastValidatorPowers: lastValidatorPowers, + Validators: k.GetAllValidators(ctx), + Delegations: k.GetAllDelegations(ctx), + UnbondingDelegations: unbondingDelegations, + Redelegations: redelegations, + Exported: true, + } +} diff --git a/x/staking/keeper/genesis_test.go b/x/staking/keeper/genesis_test.go new file mode 100644 index 000000000000..908e301decfa --- /dev/null +++ b/x/staking/keeper/genesis_test.go @@ -0,0 +1,219 @@ +package keeper_test + +import ( + "fmt" + "testing" + + "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/simapp" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/bank/testutil" + "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/staking/types" +) + +func bootstrapGenesisTest(t *testing.T, numAddrs int) (*simapp.SimApp, sdk.Context, []sdk.AccAddress) { + app := simapp.Setup(t, false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + + addrDels, _ := generateAddresses(app, ctx, numAddrs) + return app, ctx, addrDels +} + +func TestInitGenesis(t *testing.T) { + app, ctx, addrs := bootstrapGenesisTest(t, 10) + + valTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 1) + + params := app.StakingKeeper.GetParams(ctx) + validators := app.StakingKeeper.GetAllValidators(ctx) + require.Len(t, validators, 1) + var delegations []types.Delegation + + pk0, err := codectypes.NewAnyWithValue(PKs[0]) + require.NoError(t, err) + + pk1, err := codectypes.NewAnyWithValue(PKs[1]) + require.NoError(t, err) + + // initialize the validators + bondedVal1 := types.Validator{ + OperatorAddress: sdk.ValAddress(addrs[0]).String(), + ConsensusPubkey: pk0, + Status: types.Bonded, + Tokens: valTokens, + DelegatorShares: sdk.NewDecFromInt(valTokens), + Description: types.NewDescription("hoop", "", "", "", ""), + } + bondedVal2 := types.Validator{ + OperatorAddress: sdk.ValAddress(addrs[1]).String(), + ConsensusPubkey: pk1, + Status: types.Bonded, + Tokens: valTokens, + DelegatorShares: sdk.NewDecFromInt(valTokens), + Description: types.NewDescription("bloop", "", "", "", ""), + } + + // append new bonded validators to the list + validators = append(validators, bondedVal1, bondedVal2) + + // mint coins in the bonded pool representing the validators coins + i2 := len(validators) - 1 // -1 to exclude genesis validator + require.NoError(t, + testutil.FundModuleAccount( + app.BankKeeper, + ctx, + types.BondedPoolName, + sdk.NewCoins( + sdk.NewCoin(params.BondDenom, valTokens.MulRaw((int64)(i2))), + ), + ), + ) + + genesisDelegations := app.StakingKeeper.GetAllDelegations(ctx) + delegations = append(delegations, genesisDelegations...) + + genesisState := types.NewGenesisState(params, validators, delegations) + vals := app.StakingKeeper.InitGenesis(ctx, genesisState) + + actualGenesis := app.StakingKeeper.ExportGenesis(ctx) + require.Equal(t, genesisState.Params, actualGenesis.Params) + require.Equal(t, genesisState.Delegations, actualGenesis.Delegations) + require.EqualValues(t, app.StakingKeeper.GetAllValidators(ctx), actualGenesis.Validators) + + // Ensure validators have addresses. + vals2, err := staking.WriteValidators(ctx, app.StakingKeeper) + require.NoError(t, err) + + for _, val := range vals2 { + require.NotEmpty(t, val.Address) + } + + // now make sure the validators are bonded and intra-tx counters are correct + resVal, found := app.StakingKeeper.GetValidator(ctx, sdk.ValAddress(addrs[0])) + require.True(t, found) + require.Equal(t, types.Bonded, resVal.Status) + + resVal, found = app.StakingKeeper.GetValidator(ctx, sdk.ValAddress(addrs[1])) + require.True(t, found) + require.Equal(t, types.Bonded, resVal.Status) + + abcivals := make([]abci.ValidatorUpdate, len(vals)) + + validators = validators[1:] // remove genesis validator + for i, val := range validators { + abcivals[i] = val.ABCIValidatorUpdate(app.StakingKeeper.PowerReduction(ctx)) + } + + require.Equal(t, abcivals, vals) +} + +func TestInitGenesis_PoolsBalanceMismatch(t *testing.T) { + app := simapp.Setup(t, false) + ctx := app.NewContext(false, tmproto.Header{}) + + consPub, err := codectypes.NewAnyWithValue(PKs[0]) + require.NoError(t, err) + + validator := types.Validator{ + OperatorAddress: sdk.ValAddress("12345678901234567890").String(), + ConsensusPubkey: consPub, + Jailed: false, + Tokens: sdk.NewInt(10), + DelegatorShares: sdk.NewDecFromInt(sdk.NewInt(10)), + Description: types.NewDescription("bloop", "", "", "", ""), + } + + params := types.Params{ + UnbondingTime: 10000, + MaxValidators: 1, + MaxEntries: 10, + BondDenom: "stake", + } + + require.Panics(t, func() { + // setting validator status to bonded so the balance counts towards bonded pool + validator.Status = types.Bonded + app.StakingKeeper.InitGenesis(ctx, &types.GenesisState{ + Params: params, + Validators: []types.Validator{validator}, + }) + }, + "should panic because bonded pool balance is different from bonded pool coins", + ) + + require.Panics(t, func() { + // setting validator status to unbonded so the balance counts towards not bonded pool + validator.Status = types.Unbonded + app.StakingKeeper.InitGenesis(ctx, &types.GenesisState{ + Params: params, + Validators: []types.Validator{validator}, + }) + }, + "should panic because not bonded pool balance is different from not bonded pool coins", + ) +} + +func TestInitGenesisLargeValidatorSet(t *testing.T) { + size := 200 + require.True(t, size > 100) + + app, ctx, addrs := bootstrapGenesisTest(t, 200) + genesisValidators := app.StakingKeeper.GetAllValidators(ctx) + + params := app.StakingKeeper.GetParams(ctx) + delegations := []types.Delegation{} + validators := make([]types.Validator, size) + + var err error + + bondedPoolAmt := sdk.ZeroInt() + for i := range validators { + validators[i], err = types.NewValidator( + sdk.ValAddress(addrs[i]), + PKs[i], + types.NewDescription(fmt.Sprintf("#%d", i), "", "", "", ""), + ) + require.NoError(t, err) + validators[i].Status = types.Bonded + + tokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 1) + if i < 100 { + tokens = app.StakingKeeper.TokensFromConsensusPower(ctx, 2) + } + + validators[i].Tokens = tokens + validators[i].DelegatorShares = sdk.NewDecFromInt(tokens) + + // add bonded coins + bondedPoolAmt = bondedPoolAmt.Add(tokens) + } + + validators = append(validators, genesisValidators...) + genesisState := types.NewGenesisState(params, validators, delegations) + + // mint coins in the bonded pool representing the validators coins + require.NoError(t, + testutil.FundModuleAccount( + app.BankKeeper, + ctx, + types.BondedPoolName, + sdk.NewCoins(sdk.NewCoin(params.BondDenom, bondedPoolAmt)), + ), + ) + + vals := app.StakingKeeper.InitGenesis(ctx, genesisState) + + abcivals := make([]abci.ValidatorUpdate, 100) + for i, val := range validators[:100] { + abcivals[i] = val.ABCIValidatorUpdate(app.StakingKeeper.PowerReduction(ctx)) + } + + // remove genesis validator + vals = vals[:100] + require.Equal(t, abcivals, vals) +} diff --git a/x/staking/keeper/grpc_query.go b/x/staking/keeper/grpc_query.go index 8fa16354d48e..79f9542adf22 100644 --- a/x/staking/keeper/grpc_query.go +++ b/x/staking/keeper/grpc_query.go @@ -53,7 +53,6 @@ func (k Querier) Validators(c context.Context, req *types.QueryValidatorsRequest return true, nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -129,7 +128,8 @@ func (k Querier) ValidatorDelegations(c context.Context, req *types.QueryValidat } return &types.QueryValidatorDelegationsResponse{ - DelegationResponses: delResponses, Pagination: pageRes}, nil + DelegationResponses: delResponses, Pagination: pageRes, + }, nil } // ValidatorUnbondingDelegations queries unbonding delegations of a validator @@ -287,7 +287,6 @@ func (k Querier) DelegatorDelegations(c context.Context, req *types.QueryDelegat } return &types.QueryDelegatorDelegationsResponse{DelegationResponses: delegationResps, Pagination: pageRes}, nil - } // DelegatorValidator queries validator info for given delegator validator pair @@ -354,7 +353,8 @@ func (k Querier) DelegatorUnbondingDelegations(c context.Context, req *types.Que } return &types.QueryDelegatorUnbondingDelegationsResponse{ - UnbondingResponses: unbondingDelegations, Pagination: pageRes}, nil + UnbondingResponses: unbondingDelegations, Pagination: pageRes, + }, nil } // HistoricalInfo queries the historical info for given height @@ -439,7 +439,6 @@ func (k Querier) DelegatorValidators(c context.Context, req *types.QueryDelegato validators = append(validators, validator) return nil }) - if err != nil { return nil, status.Error(codes.Internal, err.Error()) } @@ -471,7 +470,6 @@ func (k Querier) Params(c context.Context, _ *types.QueryParamsRequest) (*types. } func queryRedelegation(ctx sdk.Context, k Querier, req *types.QueryRedelegationsRequest) (redels types.Redelegations, err error) { - delAddr, err := sdk.AccAddressFromBech32(req.DelegatorAddr) if err != nil { return nil, err diff --git a/x/staking/keeper/grpc_query_test.go b/x/staking/keeper/grpc_query_test.go index 8bb355571cd2..09cdb5e47cea 100644 --- a/x/staking/keeper/grpc_query_test.go +++ b/x/staking/keeper/grpc_query_test.go @@ -56,8 +56,10 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidators() { { "valid request", func() { - req = &types.QueryValidatorsRequest{Status: types.Bonded.String(), - Pagination: &query.PageRequest{Limit: 1, CountTotal: true}} + req = &types.QueryValidatorsRequest{ + Status: types.Bonded.String(), + Pagination: &query.PageRequest{Limit: 1, CountTotal: true}, + } }, true, 1, @@ -149,7 +151,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryDelegatorValidators() { func() { req = &types.QueryDelegatorValidatorsRequest{ DelegatorAddr: addrs[0].String(), - Pagination: &query.PageRequest{Limit: 1, CountTotal: true}} + Pagination: &query.PageRequest{Limit: 1, CountTotal: true}, + } }, true, }, @@ -321,8 +324,10 @@ func (suite *KeeperTestSuite) TestGRPCQueryDelegatorDelegations() { { "valid request", func() { - req = &types.QueryDelegatorDelegationsRequest{DelegatorAddr: addrAcc.String(), - Pagination: &query.PageRequest{Limit: 1, CountTotal: true}} + req = &types.QueryDelegatorDelegationsRequest{ + DelegatorAddr: addrAcc.String(), + Pagination: &query.PageRequest{Limit: 1, CountTotal: true}, + } }, func(suite *KeeperTestSuite, response *types.QueryDelegatorDelegationsResponse) { suite.Equal(uint64(2), response.Pagination.Total) @@ -384,8 +389,10 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidatorDelegations() { { "valid request", func() { - req = &types.QueryValidatorDelegationsRequest{ValidatorAddr: addrVal1, - Pagination: &query.PageRequest{Limit: 1, CountTotal: true}} + req = &types.QueryValidatorDelegationsRequest{ + ValidatorAddr: addrVal1, + Pagination: &query.PageRequest{Limit: 1, CountTotal: true}, + } }, true, false, @@ -422,7 +429,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryUnbondingDelegation() { unbondingTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 2) valAddr, err1 := sdk.ValAddressFromBech32(addrVal2) suite.NoError(err1) - _, err := app.StakingKeeper.Undelegate(ctx, addrAcc2, valAddr, unbondingTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, addrAcc2, valAddr, sdk.NewDecFromInt(unbondingTokens)) suite.NoError(err) unbond, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrAcc2, valAddr) @@ -451,7 +458,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryUnbondingDelegation() { "valid request", func() { req = &types.QueryUnbondingDelegationRequest{ - DelegatorAddr: addrAcc2.String(), ValidatorAddr: addrVal2} + DelegatorAddr: addrAcc2.String(), ValidatorAddr: addrVal2, + } }, true, }, @@ -480,11 +488,11 @@ func (suite *KeeperTestSuite) TestGRPCQueryDelegatorUnbondingDelegations() { unbondingTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 2) valAddr1, err1 := sdk.ValAddressFromBech32(addrVal) suite.NoError(err1) - _, err := app.StakingKeeper.Undelegate(ctx, addrAcc, valAddr1, unbondingTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, addrAcc, valAddr1, sdk.NewDecFromInt(unbondingTokens)) suite.NoError(err) valAddr2, err1 := sdk.ValAddressFromBech32(addrVal2) suite.NoError(err1) - _, err = app.StakingKeeper.Undelegate(ctx, addrAcc, valAddr2, unbondingTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrAcc, valAddr2, sdk.NewDecFromInt(unbondingTokens)) suite.NoError(err) unbond, found := app.StakingKeeper.GetUnbondingDelegation(ctx, addrAcc, valAddr1) @@ -515,8 +523,10 @@ func (suite *KeeperTestSuite) TestGRPCQueryDelegatorUnbondingDelegations() { { "valid request", func() { - req = &types.QueryDelegatorUnbondingDelegationsRequest{DelegatorAddr: addrAcc.String(), - Pagination: &query.PageRequest{Limit: 1, CountTotal: true}} + req = &types.QueryDelegatorUnbondingDelegationsRequest{ + DelegatorAddr: addrAcc.String(), + Pagination: &query.PageRequest{Limit: 1, CountTotal: true}, + } }, true, false, @@ -632,7 +642,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryRedelegations() { applyValidatorSetUpdates(suite.T(), ctx, app.StakingKeeper, -1) rdAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 1) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc1, val1.GetOperator(), val2.GetOperator(), rdAmount.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc1, val1.GetOperator(), val2.GetOperator(), sdk.NewDecFromInt(rdAmount)) suite.NoError(err) applyValidatorSetUpdates(suite.T(), ctx, app.StakingKeeper, -1) @@ -657,8 +667,10 @@ func (suite *KeeperTestSuite) TestGRPCQueryRedelegations() { { "request redelegations with non existent pairs", func() { - req = &types.QueryRedelegationsRequest{DelegatorAddr: addrAcc.String(), SrcValidatorAddr: val3.String(), - DstValidatorAddr: val4.String()} + req = &types.QueryRedelegationsRequest{ + DelegatorAddr: addrAcc.String(), SrcValidatorAddr: val3.String(), + DstValidatorAddr: val4.String(), + } }, false, true, @@ -668,7 +680,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryRedelegations() { func() { req = &types.QueryRedelegationsRequest{ DelegatorAddr: addrAcc1.String(), SrcValidatorAddr: val1.OperatorAddress, - DstValidatorAddr: val2.OperatorAddress, Pagination: &query.PageRequest{}} + DstValidatorAddr: val2.OperatorAddress, Pagination: &query.PageRequest{}, + } }, true, false, @@ -678,7 +691,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryRedelegations() { func() { req = &types.QueryRedelegationsRequest{ DelegatorAddr: addrAcc1.String(), SrcValidatorAddr: val1.OperatorAddress, - Pagination: &query.PageRequest{}} + Pagination: &query.PageRequest{}, + } }, true, false, @@ -688,7 +702,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryRedelegations() { func() { req = &types.QueryRedelegationsRequest{ SrcValidatorAddr: val1.GetOperator().String(), - Pagination: &query.PageRequest{Limit: 1, CountTotal: true}} + Pagination: &query.PageRequest{Limit: 1, CountTotal: true}, + } }, true, false, @@ -724,7 +739,7 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidatorUnbondingDelegations() { // undelegate undelAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 2) - _, err := app.StakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), undelAmount.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), sdk.NewDecFromInt(undelAmount)) suite.NoError(err) applyValidatorSetUpdates(suite.T(), ctx, app.StakingKeeper, -1) @@ -746,7 +761,8 @@ func (suite *KeeperTestSuite) TestGRPCQueryValidatorUnbondingDelegations() { func() { req = &types.QueryValidatorUnbondingDelegationsRequest{ ValidatorAddr: val1.GetOperator().String(), - Pagination: &query.PageRequest{Limit: 1, CountTotal: true}} + Pagination: &query.PageRequest{Limit: 1, CountTotal: true}, + } }, true, }, diff --git a/x/staking/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go index f15074d63bb4..610acf4cb030 100644 --- a/x/staking/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -53,17 +53,18 @@ func (suite *KeeperTestSuite) SetupTest() { suite.app, suite.ctx, suite.queryClient, suite.addrs, suite.vals = app, ctx, queryClient, addrs, validators } + func TestParams(t *testing.T) { app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) expParams := types.DefaultParams() - //check that the empty keeper loads the default + // check that the empty keeper loads the default resParams := app.StakingKeeper.GetParams(ctx) require.True(t, expParams.Equal(resParams)) - //modify a params, save, and retrieve + // modify a params, save, and retrieve expParams.MaxValidators = 777 app.StakingKeeper.SetParams(ctx, expParams) resParams = app.StakingKeeper.GetParams(ctx) diff --git a/x/staking/keeper/pool.go b/x/staking/keeper/pool.go index c24c87632358..b281b45784dc 100644 --- a/x/staking/keeper/pool.go +++ b/x/staking/keeper/pool.go @@ -71,7 +71,7 @@ func (k Keeper) StakingTokenSupply(ctx sdk.Context) sdk.Int { func (k Keeper) BondedRatio(ctx sdk.Context) sdk.Dec { stakeSupply := k.StakingTokenSupply(ctx) if stakeSupply.IsPositive() { - return k.TotalBondedTokens(ctx).ToDec().QuoInt(stakeSupply) + return sdk.NewDecFromInt(k.TotalBondedTokens(ctx)).QuoInt(stakeSupply) } return sdk.ZeroDec() diff --git a/x/staking/keeper/querier.go b/x/staking/keeper/querier.go index 06bab770467d..95c26d49a45d 100644 --- a/x/staking/keeper/querier.go +++ b/x/staking/keeper/querier.go @@ -190,7 +190,6 @@ func queryDelegatorDelegations(ctx sdk.Context, req abci.RequestQuery, k Keeper, delegations := k.GetAllDelegatorDelegations(ctx, params.DelegatorAddr) delegationResps, err := DelegationsToDelegationResponses(ctx, k, delegations) - if err != nil { return nil, err } diff --git a/x/staking/keeper/querier_test.go b/x/staking/keeper/querier_test.go index f50e95a1833e..ac5b1eed5a56 100644 --- a/x/staking/keeper/querier_test.go +++ b/x/staking/keeper/querier_test.go @@ -351,7 +351,7 @@ func TestQueryDelegation(t *testing.T) { // Query unbonding delegation unbondingTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - _, err = app.StakingKeeper.Undelegate(ctx, addrAcc2, val1.GetOperator(), unbondingTokens.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrAcc2, val1.GetOperator(), sdk.NewDecFromInt(unbondingTokens)) require.NoError(t, err) queryBondParams = types.QueryDelegatorValidatorRequest{DelegatorAddr: addrAcc2.String(), ValidatorAddr: addrVal1.String()} @@ -404,8 +404,7 @@ func TestQueryDelegation(t *testing.T) { // Query redelegation redelegationTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), - val2.GetOperator(), redelegationTokens.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator(), sdk.NewDecFromInt(redelegationTokens)) require.NoError(t, err) redel, found := app.StakingKeeper.GetRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator()) require.True(t, found) @@ -509,7 +508,7 @@ func TestQueryValidatorDelegations_Pagination(t *testing.T) { // Undelegate for _, addr := range addrs { delTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err := app.StakingKeeper.Undelegate(ctx, addr, val1.GetOperator(), delTokens.ToDec()) + _, err := app.StakingKeeper.Undelegate(ctx, addr, val1.GetOperator(), sdk.NewDecFromInt(delTokens)) require.NoError(t, err) } @@ -559,7 +558,7 @@ func TestQueryRedelegations(t *testing.T) { applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) rdAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator(), rdAmount.ToDec()) + _, err = app.StakingKeeper.BeginRedelegation(ctx, addrAcc2, val1.GetOperator(), val2.GetOperator(), sdk.NewDecFromInt(rdAmount)) require.NoError(t, err) applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) @@ -631,7 +630,7 @@ func TestQueryUnbondingDelegation(t *testing.T) { // undelegate undelAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) - _, err = app.StakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), undelAmount.ToDec()) + _, err = app.StakingKeeper.Undelegate(ctx, addrAcc1, val1.GetOperator(), sdk.NewDecFromInt(undelAmount)) require.NoError(t, err) applyValidatorSetUpdates(t, ctx, app.StakingKeeper, -1) diff --git a/x/staking/keeper/slash.go b/x/staking/keeper/slash.go index 279af3a85a35..d09fb56c270f 100644 --- a/x/staking/keeper/slash.go +++ b/x/staking/keeper/slash.go @@ -30,7 +30,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh // Amount of slashing = slash slashFactor * power at time of infraction amount := k.TokensFromConsensusPower(ctx, power) - slashAmountDec := amount.ToDec().Mul(slashFactor) + slashAmountDec := sdk.NewDecFromInt(amount).Mul(slashFactor) slashAmount := slashAmountDec.TruncateInt() // ref https://github.com/cosmos/cosmos-sdk/issues/1348 @@ -108,7 +108,7 @@ func (k Keeper) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeigh // we need to calculate the *effective* slash fraction for distribution if validator.Tokens.IsPositive() { - effectiveFraction := tokensToBurn.ToDec().QuoRoundUp(validator.Tokens.ToDec()) + effectiveFraction := sdk.NewDecFromInt(tokensToBurn).QuoRoundUp(sdk.NewDecFromInt(validator.Tokens)) // possible if power has changed if effectiveFraction.GT(sdk.OneDec()) { effectiveFraction = sdk.OneDec() @@ -165,7 +165,8 @@ func (k Keeper) Unjail(ctx sdk.Context, consAddr sdk.ConsAddress) { // (the amount actually slashed may be less if there's // insufficient stake remaining) func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation types.UnbondingDelegation, - infractionHeight int64, slashFactor sdk.Dec) (totalSlashAmount sdk.Int) { + infractionHeight int64, slashFactor sdk.Dec, +) (totalSlashAmount sdk.Int) { now := ctx.BlockHeader().Time totalSlashAmount = sdk.ZeroInt() burnedAmount := sdk.ZeroInt() @@ -218,7 +219,8 @@ func (k Keeper) SlashUnbondingDelegation(ctx sdk.Context, unbondingDelegation ty // insufficient stake remaining) // NOTE this is only slashing for prior infractions from the source validator func (k Keeper) SlashRedelegation(ctx sdk.Context, srcValidator types.Validator, redelegation types.Redelegation, - infractionHeight int64, slashFactor sdk.Dec) (totalSlashAmount sdk.Int) { + infractionHeight int64, slashFactor sdk.Dec, +) (totalSlashAmount sdk.Int) { now := ctx.BlockHeader().Time totalSlashAmount = sdk.ZeroInt() bondedBurnedAmount, notBondedBurnedAmount := sdk.ZeroInt(), sdk.ZeroInt() diff --git a/x/staking/keeper/slash_test.go b/x/staking/keeper/slash_test.go index 8b987d0e8d5e..ea83aab9dce2 100644 --- a/x/staking/keeper/slash_test.go +++ b/x/staking/keeper/slash_test.go @@ -112,7 +112,7 @@ func TestSlashUnbondingDelegation(t *testing.T) { // balance decreased require.Equal(t, sdk.NewInt(5), ubd.Entries[0].Balance) newUnbondedPoolBalances := app.BankKeeper.GetAllBalances(ctx, notBondedPool.GetAddress()) - diffTokens := oldUnbondedPoolBalances.Sub(newUnbondedPoolBalances) + diffTokens := oldUnbondedPoolBalances.Sub(newUnbondedPoolBalances...) require.True(t, diffTokens.AmountOf(app.StakingKeeper.BondDenom(ctx)).Equal(sdk.NewInt(5))) } @@ -180,7 +180,7 @@ func TestSlashRedelegation(t *testing.T) { // pool bonded tokens should decrease burnedCoins := sdk.NewCoins(sdk.NewCoin(app.StakingKeeper.BondDenom(ctx), slashAmount)) - require.Equal(t, balances.Sub(burnedCoins), app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress())) + require.Equal(t, balances.Sub(burnedCoins...), app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress())) } // tests Slash at a future height (must panic) @@ -220,7 +220,7 @@ func TestSlashAtNegativeHeight(t *testing.T) { // pool bonded shares decreased newBondedPoolBalances := app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) - diffTokens := oldBondedPoolBalances.Sub(newBondedPoolBalances).AmountOf(app.StakingKeeper.BondDenom(ctx)) + diffTokens := oldBondedPoolBalances.Sub(newBondedPoolBalances...).AmountOf(app.StakingKeeper.BondDenom(ctx)) require.Equal(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 5).String(), diffTokens.String()) } @@ -251,7 +251,7 @@ func TestSlashValidatorAtCurrentHeight(t *testing.T) { // pool bonded shares decreased newBondedPoolBalances := app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) - diffTokens := oldBondedPoolBalances.Sub(newBondedPoolBalances).AmountOf(app.StakingKeeper.BondDenom(ctx)) + diffTokens := oldBondedPoolBalances.Sub(newBondedPoolBalances...).AmountOf(app.StakingKeeper.BondDenom(ctx)) require.Equal(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 5).String(), diffTokens.String()) } @@ -290,7 +290,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { // bonded tokens burned newBondedPoolBalances := app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) - diffTokens := oldBondedPoolBalances.Sub(newBondedPoolBalances).AmountOf(app.StakingKeeper.BondDenom(ctx)) + diffTokens := oldBondedPoolBalances.Sub(newBondedPoolBalances...).AmountOf(app.StakingKeeper.BondDenom(ctx)) require.Equal(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 3), diffTokens) // read updated validator @@ -316,7 +316,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { // bonded tokens burned again newBondedPoolBalances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) - diffTokens = oldBondedPoolBalances.Sub(newBondedPoolBalances).AmountOf(app.StakingKeeper.BondDenom(ctx)) + diffTokens = oldBondedPoolBalances.Sub(newBondedPoolBalances...).AmountOf(app.StakingKeeper.BondDenom(ctx)) require.Equal(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 6), diffTokens) // read updated validator @@ -342,7 +342,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { // bonded tokens burned again newBondedPoolBalances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) - diffTokens = oldBondedPoolBalances.Sub(newBondedPoolBalances).AmountOf(app.StakingKeeper.BondDenom(ctx)) + diffTokens = oldBondedPoolBalances.Sub(newBondedPoolBalances...).AmountOf(app.StakingKeeper.BondDenom(ctx)) require.Equal(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 9), diffTokens) // read updated validator @@ -368,7 +368,7 @@ func TestSlashWithUnbondingDelegation(t *testing.T) { // just 1 bonded token burned again since that's all the validator now has newBondedPoolBalances = app.BankKeeper.GetAllBalances(ctx, bondedPool.GetAddress()) - diffTokens = oldBondedPoolBalances.Sub(newBondedPoolBalances).AmountOf(app.StakingKeeper.BondDenom(ctx)) + diffTokens = oldBondedPoolBalances.Sub(newBondedPoolBalances...).AmountOf(app.StakingKeeper.BondDenom(ctx)) require.Equal(t, app.StakingKeeper.TokensFromConsensusPower(ctx, 10), diffTokens) // apply TM updates @@ -390,12 +390,11 @@ func TestSlashWithRedelegation(t *testing.T) { // set a redelegation rdTokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, - time.Unix(0, 0), rdTokens, rdTokens.ToDec()) + rd := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, time.Unix(0, 0), rdTokens, sdk.NewDecFromInt(rdTokens)) app.StakingKeeper.SetRedelegation(ctx, rd) // set the associated delegation - del := types.NewDelegation(addrDels[0], addrVals[1], rdTokens.ToDec()) + del := types.NewDelegation(addrDels[0], addrVals[1], sdk.NewDecFromInt(rdTokens)) app.StakingKeeper.SetDelegation(ctx, del) // update bonded tokens @@ -416,7 +415,7 @@ func TestSlashWithRedelegation(t *testing.T) { require.True(t, found) require.NotPanics(t, func() { app.StakingKeeper.Slash(ctx, consAddr, 10, 10, fraction) }) - burnAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec().Mul(fraction).TruncateInt() + burnAmount := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(fraction).TruncateInt() bondedPool = app.StakingKeeper.GetBondedPool(ctx) notBondedPool = app.StakingKeeper.GetNotBondedPool(ctx) @@ -482,7 +481,7 @@ func TestSlashWithRedelegation(t *testing.T) { require.NotPanics(t, func() { app.StakingKeeper.Slash(ctx, consAddr, 10, 10, sdk.OneDec()) }) - burnAmount = app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec().Mul(sdk.OneDec()).TruncateInt() + burnAmount = sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(sdk.OneDec()).TruncateInt() burnAmount = burnAmount.Sub(sdk.OneDec().MulInt(rdTokens).TruncateInt()) // read updated pool @@ -543,13 +542,11 @@ func TestSlashBoth(t *testing.T) { // set a redelegation with expiration timestamp beyond which the // redelegation shouldn't be slashed rdATokens := app.StakingKeeper.TokensFromConsensusPower(ctx, 6) - rdA := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, - time.Unix(0, 0), rdATokens, - rdATokens.ToDec()) + rdA := types.NewRedelegation(addrDels[0], addrVals[0], addrVals[1], 11, time.Unix(0, 0), rdATokens, sdk.NewDecFromInt(rdATokens)) app.StakingKeeper.SetRedelegation(ctx, rdA) // set the associated delegation - delA := types.NewDelegation(addrDels[0], addrVals[1], rdATokens.ToDec()) + delA := types.NewDelegation(addrDels[0], addrVals[1], sdk.NewDecFromInt(rdATokens)) app.StakingKeeper.SetDelegation(ctx, delA) // set an unbonding delegation with expiration timestamp (beyond which the @@ -582,7 +579,7 @@ func TestSlashBoth(t *testing.T) { app.StakingKeeper.Slash(ctx, consAddr0, 10, 10, fraction) burnedNotBondedAmount := fraction.MulInt(ubdATokens).TruncateInt() - burnedBondAmount := app.StakingKeeper.TokensFromConsensusPower(ctx, 10).ToDec().Mul(fraction).TruncateInt() + burnedBondAmount := sdk.NewDecFromInt(app.StakingKeeper.TokensFromConsensusPower(ctx, 10)).Mul(fraction).TruncateInt() burnedBondAmount = burnedBondAmount.Sub(burnedNotBondedAmount) // read updated pool diff --git a/x/staking/keeper/validator.go b/x/staking/keeper/validator.go index 8539cbe0ec8a..9b51577c5a06 100644 --- a/x/staking/keeper/validator.go +++ b/x/staking/keeper/validator.go @@ -96,7 +96,8 @@ func (k Keeper) SetNewValidatorByPowerIndex(ctx sdk.Context, validator types.Val // Update the tokens of an existing validator, update the validators power index key func (k Keeper) AddValidatorTokensAndShares(ctx sdk.Context, validator types.Validator, - tokensToAdd sdk.Int) (valOut types.Validator, addedShares sdk.Dec) { + tokensToAdd sdk.Int, +) (valOut types.Validator, addedShares sdk.Dec) { k.DeleteValidatorByPowerIndex(ctx, validator) validator, addedShares = validator.AddTokensFromDel(tokensToAdd) k.SetValidator(ctx, validator) @@ -107,7 +108,8 @@ func (k Keeper) AddValidatorTokensAndShares(ctx sdk.Context, validator types.Val // Update the tokens of an existing validator, update the validators power index key func (k Keeper) RemoveValidatorTokensAndShares(ctx sdk.Context, validator types.Validator, - sharesToRemove sdk.Dec) (valOut types.Validator, removedTokens sdk.Int) { + sharesToRemove sdk.Dec, +) (valOut types.Validator, removedTokens sdk.Int) { k.DeleteValidatorByPowerIndex(ctx, validator) validator, removedTokens = validator.RemoveDelShares(sharesToRemove) k.SetValidator(ctx, validator) @@ -118,7 +120,8 @@ func (k Keeper) RemoveValidatorTokensAndShares(ctx sdk.Context, validator types. // Update the tokens of an existing validator, update the validators power index key func (k Keeper) RemoveValidatorTokens(ctx sdk.Context, - validator types.Validator, tokensToRemove sdk.Int) types.Validator { + validator types.Validator, tokensToRemove sdk.Int, +) types.Validator { k.DeleteValidatorByPowerIndex(ctx, validator) validator = validator.RemoveTokens(tokensToRemove) k.SetValidator(ctx, validator) @@ -130,7 +133,8 @@ func (k Keeper) RemoveValidatorTokens(ctx sdk.Context, // UpdateValidatorCommission attempts to update a validator's commission rate. // An error is returned if the new commission rate is invalid. func (k Keeper) UpdateValidatorCommission(ctx sdk.Context, - validator types.Validator, newRate sdk.Dec) (types.Commission, error) { + validator types.Validator, newRate sdk.Dec, +) (types.Commission, error) { commission := validator.Commission blockTime := ctx.BlockHeader().Time diff --git a/x/staking/keeper/validator_bench_test.go b/x/staking/keeper/validator_bench_test.go index 54a616c90e50..ea727b72457d 100644 --- a/x/staking/keeper/validator_bench_test.go +++ b/x/staking/keeper/validator_bench_test.go @@ -5,10 +5,10 @@ import "testing" func BenchmarkGetValidator(b *testing.B) { // 900 is the max number we are allowed to use in order to avoid simapp.CreateTestPubKeys // panic: encoding/hex: odd length hex string - var powersNumber = 900 + powersNumber := 900 var totalPower int64 = 0 - var powers = make([]int64, powersNumber) + powers := make([]int64, powersNumber) for i := range powers { powers[i] = int64(i) totalPower += int64(i) diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index c4109a9f3ddf..ffa6d595854f 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -196,7 +196,7 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) { // validator and next in line cliff validator app.StakingKeeper.DeleteValidatorByPowerIndex(ctx, nextCliffVal) shares := app.StakingKeeper.TokensFromConsensusPower(ctx, 21) - nextCliffVal, _ = nextCliffVal.RemoveDelShares(shares.ToDec()) + nextCliffVal, _ = nextCliffVal.RemoveDelShares(sdk.NewDecFromInt(shares)) nextCliffVal = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, nextCliffVal, true) expectedValStatus := map[int]types.BondStatus{ @@ -252,7 +252,7 @@ func TestSlashToZeroPowerRemoved(t *testing.T) { func TestValidatorBasics(t *testing.T) { app, ctx, _, addrVals := bootstrapValidatorTest(t, 1000, 20) - //construct the validators + // construct the validators var validators [3]types.Validator powers := []int64{9, 8, 7} for i, power := range powers { @@ -300,7 +300,7 @@ func TestValidatorBasics(t *testing.T) { // modify a records, save, and retrieve validators[0].Status = types.Bonded validators[0].Tokens = app.StakingKeeper.TokensFromConsensusPower(ctx, 10) - validators[0].DelegatorShares = validators[0].Tokens.ToDec() + validators[0].DelegatorShares = sdk.NewDecFromInt(validators[0].Tokens) validators[0] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[0], true) resVal, found = app.StakingKeeper.GetValidator(ctx, addrVals[0]) require.True(t, found) @@ -357,7 +357,8 @@ func TestGetValidatorSortingUnmixed(t *testing.T) { app.StakingKeeper.PowerReduction(ctx).MulRaw(100), app.StakingKeeper.PowerReduction(ctx), app.StakingKeeper.PowerReduction(ctx).MulRaw(400), - app.StakingKeeper.PowerReduction(ctx).MulRaw(200)} + app.StakingKeeper.PowerReduction(ctx).MulRaw(200), + } n := len(amts) var validators [5]types.Validator for i, amt := range amts { @@ -450,7 +451,8 @@ func TestGetValidatorSortingMixed(t *testing.T) { app.StakingKeeper.PowerReduction(ctx).MulRaw(100), app.StakingKeeper.PowerReduction(ctx), app.StakingKeeper.PowerReduction(ctx).MulRaw(400), - app.StakingKeeper.PowerReduction(ctx).MulRaw(200)} + app.StakingKeeper.PowerReduction(ctx).MulRaw(200), + } var validators [5]types.Validator for i, amt := range amts { @@ -881,8 +883,8 @@ func TestApplyAndReturnValidatorSetUpdatesPowerDecrease(t *testing.T) { // tendermintUpdate set: {c1, c3} -> {c1', c3'} delTokens1 := app.StakingKeeper.TokensFromConsensusPower(ctx, 20) delTokens2 := app.StakingKeeper.TokensFromConsensusPower(ctx, 30) - validators[0], _ = validators[0].RemoveDelShares(delTokens1.ToDec()) - validators[1], _ = validators[1].RemoveDelShares(delTokens2.ToDec()) + validators[0], _ = validators[0].RemoveDelShares(sdk.NewDecFromInt(delTokens1)) + validators[1], _ = validators[1].RemoveDelShares(sdk.NewDecFromInt(delTokens2)) validators[0] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[0], false) validators[1] = keeper.TestingUpdateValidator(app.StakingKeeper, ctx, validators[1], false) @@ -950,7 +952,7 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) { app.StakingKeeper.SetValidator(ctx, validator) - validator, _ = validator.RemoveDelShares(amt.ToDec()) + validator, _ = validator.RemoveDelShares(sdk.NewDecFromInt(amt)) app.StakingKeeper.SetValidator(ctx, validator) app.StakingKeeper.SetValidatorByPowerIndex(ctx, validator) diff --git a/x/staking/migrations/v034/types.go b/x/staking/migrations/v034/types.go deleted file mode 100644 index 868a6901f8a7..000000000000 --- a/x/staking/migrations/v034/types.go +++ /dev/null @@ -1,190 +0,0 @@ -// Package v034 is used for legacy migration scripts. Actual migration scripts -// for v034 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -// DONTCOVER -package v034 - -import ( - "time" - - "github.com/cosmos/cosmos-sdk/codec/legacy" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" -) - -const ( - ModuleName = "staking" -) - -// staking constants -const ( - Unbonded BondStatus = 0x00 - Unbonding BondStatus = 0x01 - Bonded BondStatus = 0x02 - - BondStatusUnbonded = "Unbonded" - BondStatusUnbonding = "Unbonding" - BondStatusBonded = "Bonded" -) - -type ( - // BondStatus is the status of a validator - BondStatus byte - - Pool struct { - NotBondedTokens sdk.Int `json:"not_bonded_tokens"` - BondedTokens sdk.Int `json:"bonded_tokens"` - } - - Params struct { - UnbondingTime time.Duration `json:"unbonding_time"` - MaxValidators uint16 `json:"max_validators"` - MaxEntries uint16 `json:"max_entries"` - BondDenom string `json:"bond_denom"` - } - - LastValidatorPower struct { - Address sdk.ValAddress - Power int64 - } - - Description struct { - Moniker string `json:"moniker"` - Identity string `json:"identity"` - Website string `json:"website"` - Details string `json:"details"` - } - - Commission struct { - Rate sdk.Dec `json:"rate"` - MaxRate sdk.Dec `json:"max_rate"` - MaxChangeRate sdk.Dec `json:"max_change_rate"` - UpdateTime time.Time `json:"update_time"` - } - - bechValidator struct { - OperatorAddress sdk.ValAddress `json:"operator_address"` // the bech32 address of the validator's operator - ConsPubKey string `json:"consensus_pubkey"` // the bech32 consensus public key of the validator - Jailed bool `json:"jailed"` // has the validator been jailed from bonded status? - Status BondStatus `json:"status"` // validator status (bonded/unbonding/unbonded) - Tokens sdk.Int `json:"tokens"` // delegated tokens (incl. self-delegation) - DelegatorShares sdk.Dec `json:"delegator_shares"` // total shares issued to a validator's delegators - Description Description `json:"description"` // description terms for the validator - UnbondingHeight int64 `json:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding - UnbondingCompletionTime time.Time `json:"unbonding_time"` // if unbonding, min time for the validator to complete unbonding - Commission Commission `json:"commission"` // commission parameters - MinSelfDelegation sdk.Int `json:"min_self_delegation"` // minimum self delegation - } - - Validator struct { - OperatorAddress sdk.ValAddress `json:"operator_address"` - ConsPubKey cryptotypes.PubKey `json:"consensus_pubkey"` - Jailed bool `json:"jailed"` - Status BondStatus `json:"status"` - Tokens sdk.Int `json:"tokens"` - DelegatorShares sdk.Dec `json:"delegator_shares"` - Description Description `json:"description"` - UnbondingHeight int64 `json:"unbonding_height"` - UnbondingCompletionTime time.Time `json:"unbonding_time"` - Commission Commission `json:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation"` - } - - Validators []Validator - - Delegation struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Shares sdk.Dec `json:"shares"` - } - - Delegations []Delegation - - UnbondingDelegationEntry struct { - CreationHeight int64 `json:"creation_height"` - CompletionTime time.Time `json:"completion_time"` - InitialBalance sdk.Int `json:"initial_balance"` - Balance sdk.Int `json:"balance"` - } - - UnbondingDelegation struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address"` - Entries []UnbondingDelegationEntry `json:"entries"` - } - - RedelegationEntry struct { - CreationHeight int64 `json:"creation_height"` - CompletionTime time.Time `json:"completion_time"` - InitialBalance sdk.Int `json:"initial_balance"` - SharesDst sdk.Dec `json:"shares_dst"` - } - - Redelegation struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address"` - ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address"` - ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address"` - Entries []RedelegationEntry `json:"entries"` - } - - GenesisState struct { - Pool Pool `json:"pool"` - Params Params `json:"params"` - LastTotalPower sdk.Int `json:"last_total_power"` - LastValidatorPowers []LastValidatorPower `json:"last_validator_powers"` - Validators Validators `json:"validators"` - Delegations Delegations `json:"delegations"` - UnbondingDelegations []UnbondingDelegation `json:"unbonding_delegations"` - Redelegations []Redelegation `json:"redelegations"` - Exported bool `json:"exported"` - } -) - -func (v Validator) MarshalJSON() ([]byte, error) { - bechConsPubKey, err := legacybech32.MarshalPubKey(legacybech32.ConsPK, v.ConsPubKey) - if err != nil { - return nil, err - } - - return legacy.Cdc.MarshalJSON(bechValidator{ - OperatorAddress: v.OperatorAddress, - ConsPubKey: bechConsPubKey, - Jailed: v.Jailed, - Status: v.Status, - Tokens: v.Tokens, - DelegatorShares: v.DelegatorShares, - Description: v.Description, - UnbondingHeight: v.UnbondingHeight, - UnbondingCompletionTime: v.UnbondingCompletionTime, - MinSelfDelegation: v.MinSelfDelegation, - Commission: v.Commission, - }) -} - -// UnmarshalJSON unmarshals the validator from JSON using Bech32 -func (v *Validator) UnmarshalJSON(data []byte) error { - bv := &bechValidator{} - if err := legacy.Cdc.UnmarshalJSON(data, bv); err != nil { - return err - } - consPubKey, err := legacybech32.UnmarshalPubKey(legacybech32.ConsPK, bv.ConsPubKey) - if err != nil { - return err - } - - *v = Validator{ - OperatorAddress: bv.OperatorAddress, - ConsPubKey: consPubKey, - Jailed: bv.Jailed, - Tokens: bv.Tokens, - Status: bv.Status, - DelegatorShares: bv.DelegatorShares, - Description: bv.Description, - UnbondingHeight: bv.UnbondingHeight, - UnbondingCompletionTime: bv.UnbondingCompletionTime, - Commission: bv.Commission, - MinSelfDelegation: bv.MinSelfDelegation, - } - return nil -} diff --git a/x/staking/migrations/v036/types.go b/x/staking/migrations/v036/types.go deleted file mode 100644 index c954add072e7..000000000000 --- a/x/staking/migrations/v036/types.go +++ /dev/null @@ -1,137 +0,0 @@ -// Package v036 is used for legacy migration scripts. Actual migration scripts -// for v036 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -// DONTCOVER -package v036 - -import ( - "time" - - "github.com/cosmos/cosmos-sdk/codec/legacy" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" - v034staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v034" -) - -const ( - ModuleName = "staking" -) - -type ( - Commission struct { - CommissionRates `json:"commission_rates" yaml:"commission_rates"` - UpdateTime time.Time `json:"update_time" yaml:"update_time"` - } - - CommissionRates struct { - Rate sdk.Dec `json:"rate" yaml:"rate"` - MaxRate sdk.Dec `json:"max_rate" yaml:"max_rate"` - MaxChangeRate sdk.Dec `json:"max_change_rate" yaml:"max_change_rate"` - } - - Validator struct { - OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` - ConsPubKey cryptotypes.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` - Jailed bool `json:"jailed" yaml:"jailed"` - Status v034staking.BondStatus `json:"status" yaml:"status"` - Tokens sdk.Int `json:"tokens" yaml:"tokens"` - DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` - Description v034staking.Description `json:"description" yaml:"description"` - UnbondingHeight int64 `json:"unbonding_height" yaml:"unbonding_height"` - UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` - Commission Commission `json:"commission" yaml:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` - } - - bechValidator struct { - OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` - ConsPubKey string `json:"consensus_pubkey" yaml:"consensus_pubkey"` - Jailed bool `json:"jailed" yaml:"jailed"` - Status v034staking.BondStatus `json:"status" yaml:"status"` - Tokens sdk.Int `json:"tokens" yaml:"tokens"` - DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` - Description v034staking.Description `json:"description" yaml:"description"` - UnbondingHeight int64 `json:"unbonding_height" yaml:"unbonding_height"` - UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` - Commission Commission `json:"commission" yaml:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` - } - - Validators []Validator - - GenesisState struct { - Params v034staking.Params `json:"params"` - LastTotalPower sdk.Int `json:"last_total_power"` - LastValidatorPowers []v034staking.LastValidatorPower `json:"last_validator_powers"` - Validators Validators `json:"validators"` - Delegations v034staking.Delegations `json:"delegations"` - UnbondingDelegations []v034staking.UnbondingDelegation `json:"unbonding_delegations"` - Redelegations []v034staking.Redelegation `json:"redelegations"` - Exported bool `json:"exported"` - } -) - -func NewGenesisState( - params v034staking.Params, lastTotalPower sdk.Int, lastValPowers []v034staking.LastValidatorPower, - validators Validators, delegations v034staking.Delegations, - ubds []v034staking.UnbondingDelegation, reds []v034staking.Redelegation, exported bool, -) GenesisState { - - return GenesisState{ - Params: params, - LastTotalPower: lastTotalPower, - LastValidatorPowers: lastValPowers, - Validators: validators, - Delegations: delegations, - UnbondingDelegations: ubds, - Redelegations: reds, - Exported: exported, - } -} - -func (v Validator) MarshalJSON() ([]byte, error) { - bechConsPubKey, err := legacybech32.MarshalPubKey(legacybech32.ConsPK, v.ConsPubKey) - if err != nil { - return nil, err - } - - return legacy.Cdc.MarshalJSON(bechValidator{ - OperatorAddress: v.OperatorAddress, - ConsPubKey: bechConsPubKey, - Jailed: v.Jailed, - Status: v.Status, - Tokens: v.Tokens, - DelegatorShares: v.DelegatorShares, - Description: v.Description, - UnbondingHeight: v.UnbondingHeight, - UnbondingCompletionTime: v.UnbondingCompletionTime, - MinSelfDelegation: v.MinSelfDelegation, - Commission: v.Commission, - }) -} - -func (v *Validator) UnmarshalJSON(data []byte) error { - bv := &bechValidator{} - if err := legacy.Cdc.UnmarshalJSON(data, bv); err != nil { - return err - } - consPubKey, err := legacybech32.UnmarshalPubKey(legacybech32.ConsPK, bv.ConsPubKey) - if err != nil { - return err - } - *v = Validator{ - OperatorAddress: bv.OperatorAddress, - ConsPubKey: consPubKey, - Jailed: bv.Jailed, - Tokens: bv.Tokens, - Status: bv.Status, - DelegatorShares: bv.DelegatorShares, - Description: bv.Description, - UnbondingHeight: bv.UnbondingHeight, - UnbondingCompletionTime: bv.UnbondingCompletionTime, - Commission: bv.Commission, - MinSelfDelegation: bv.MinSelfDelegation, - } - return nil -} diff --git a/x/staking/migrations/v038/types.go b/x/staking/migrations/v038/types.go deleted file mode 100644 index 027b3e693a8a..000000000000 --- a/x/staking/migrations/v038/types.go +++ /dev/null @@ -1,163 +0,0 @@ -// Package v038 is used for legacy migration scripts. Actual migration scripts -// for v038 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -// DONTCOVER -package v038 - -import ( - "time" - - "github.com/cosmos/cosmos-sdk/codec/legacy" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" - v034staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v034" - v036staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v036" -) - -const ( - ModuleName = "staking" -) - -type ( - Description struct { - Moniker string `json:"moniker" yaml:"moniker"` - Identity string `json:"identity" yaml:"identity"` - Website string `json:"website" yaml:"website"` - SecurityContact string `json:"security_contact" yaml:"security_contact"` - Details string `json:"details" yaml:"details"` - } - - Validator struct { - OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` - ConsPubKey cryptotypes.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` - Jailed bool `json:"jailed" yaml:"jailed"` - Status v034staking.BondStatus `json:"status" yaml:"status"` - Tokens sdk.Int `json:"tokens" yaml:"tokens"` - DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` - Description Description `json:"description" yaml:"description"` - UnbondingHeight int64 `json:"unbonding_height" yaml:"unbonding_height"` - UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` - Commission v036staking.Commission `json:"commission" yaml:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` - } - - bechValidator struct { - OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` - ConsPubKey string `json:"consensus_pubkey" yaml:"consensus_pubkey"` - Jailed bool `json:"jailed" yaml:"jailed"` - Status v034staking.BondStatus `json:"status" yaml:"status"` - Tokens sdk.Int `json:"tokens" yaml:"tokens"` - DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` - Description Description `json:"description" yaml:"description"` - UnbondingHeight int64 `json:"unbonding_height" yaml:"unbonding_height"` - UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` - Commission v036staking.Commission `json:"commission" yaml:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` - } - - Validators []Validator - - Params struct { - UnbondingTime time.Duration `json:"unbonding_time" yaml:"unbonding_time"` // time duration of unbonding - MaxValidators uint16 `json:"max_validators" yaml:"max_validators"` // maximum number of validators (max uint16 = 65535) - MaxEntries uint16 `json:"max_entries" yaml:"max_entries"` // max entries for either unbonding delegation or redelegation (per pair/trio) - HistoricalEntries uint16 `json:"historical_entries" yaml:"historical_entries"` // number of historical entries to persist - BondDenom string `json:"bond_denom" yaml:"bond_denom"` // bondable coin denomination - } - - GenesisState struct { - Params Params `json:"params"` - LastTotalPower sdk.Int `json:"last_total_power"` - LastValidatorPowers []v034staking.LastValidatorPower `json:"last_validator_powers"` - Validators Validators `json:"validators"` - Delegations v034staking.Delegations `json:"delegations"` - UnbondingDelegations []v034staking.UnbondingDelegation `json:"unbonding_delegations"` - Redelegations []v034staking.Redelegation `json:"redelegations"` - Exported bool `json:"exported"` - } -) - -// NewDescription creates a new Description object -func NewDescription(moniker, identity, website, securityContact, details string) Description { - return Description{ - Moniker: moniker, - Identity: identity, - Website: website, - SecurityContact: securityContact, - Details: details, - } -} - -// NewGenesisState creates a new GenesisState object -func NewGenesisState( - params v034staking.Params, lastTotalPower sdk.Int, lastValPowers []v034staking.LastValidatorPower, - validators Validators, delegations v034staking.Delegations, - ubds []v034staking.UnbondingDelegation, reds []v034staking.Redelegation, exported bool, -) GenesisState { - - return GenesisState{ - Params: Params{ - UnbondingTime: params.UnbondingTime, - MaxValidators: params.MaxValidators, - MaxEntries: params.MaxEntries, - BondDenom: params.BondDenom, - HistoricalEntries: 0, - }, - LastTotalPower: lastTotalPower, - LastValidatorPowers: lastValPowers, - Validators: validators, - Delegations: delegations, - UnbondingDelegations: ubds, - Redelegations: reds, - Exported: exported, - } -} - -// MarshalJSON marshals the validator to JSON using Bech32 -func (v Validator) MarshalJSON() ([]byte, error) { - bechConsPubKey, err := legacybech32.MarshalPubKey(legacybech32.ConsPK, v.ConsPubKey) - if err != nil { - return nil, err - } - - return legacy.Cdc.MarshalJSON(bechValidator{ - OperatorAddress: v.OperatorAddress, - ConsPubKey: bechConsPubKey, - Jailed: v.Jailed, - Status: v.Status, - Tokens: v.Tokens, - DelegatorShares: v.DelegatorShares, - Description: v.Description, - UnbondingHeight: v.UnbondingHeight, - UnbondingCompletionTime: v.UnbondingCompletionTime, - MinSelfDelegation: v.MinSelfDelegation, - Commission: v.Commission, - }) -} - -// UnmarshalJSON unmarshals the validator from JSON using Bech32 -func (v *Validator) UnmarshalJSON(data []byte) error { - bv := &bechValidator{} - if err := legacy.Cdc.UnmarshalJSON(data, bv); err != nil { - return err - } - consPubKey, err := legacybech32.UnmarshalPubKey(legacybech32.ConsPK, bv.ConsPubKey) - if err != nil { - return err - } - *v = Validator{ - OperatorAddress: bv.OperatorAddress, - ConsPubKey: consPubKey, - Jailed: bv.Jailed, - Tokens: bv.Tokens, - Status: bv.Status, - DelegatorShares: bv.DelegatorShares, - Description: bv.Description, - UnbondingHeight: bv.UnbondingHeight, - UnbondingCompletionTime: bv.UnbondingCompletionTime, - Commission: bv.Commission, - MinSelfDelegation: bv.MinSelfDelegation, - } - return nil -} diff --git a/x/staking/migrations/v040/genesis.pb.go b/x/staking/migrations/v040/genesis.pb.go deleted file mode 100644 index af9e607d28ac..000000000000 --- a/x/staking/migrations/v040/genesis.pb.go +++ /dev/null @@ -1,944 +0,0 @@ -// Package v040 is taken from: -// https://github.com/cosmos/cosmos-sdk/blob/v0.40.1/x/staking/types/genesis.pb.go -// by copy-pasted only the relevants parts for Genesis. -// nolint -package v040 - -import ( - fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" -) - -// 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 - -// GenesisState defines the staking module's genesis state. -type GenesisState struct { - // params defines all the paramaters of related to deposit. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - // last_total_power tracks the total amounts of bonded tokens recorded during - // the previous end block. - LastTotalPower github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=last_total_power,json=lastTotalPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"last_total_power" yaml:"last_total_power"` - // last_validator_powers is a special index that provides a historical list - // of the last-block's bonded validators. - LastValidatorPowers []LastValidatorPower `protobuf:"bytes,3,rep,name=last_validator_powers,json=lastValidatorPowers,proto3" json:"last_validator_powers" yaml:"last_validator_powers"` - // delegations defines the validator set at genesis. - Validators []Validator `protobuf:"bytes,4,rep,name=validators,proto3" json:"validators"` - // delegations defines the delegations active at genesis. - Delegations []Delegation `protobuf:"bytes,5,rep,name=delegations,proto3" json:"delegations"` - // unbonding_delegations defines the unbonding delegations active at genesis. - UnbondingDelegations []UnbondingDelegation `protobuf:"bytes,6,rep,name=unbonding_delegations,json=unbondingDelegations,proto3" json:"unbonding_delegations" yaml:"unbonding_delegations"` - // redelegations defines the redelegations active at genesis. - Redelegations []Redelegation `protobuf:"bytes,7,rep,name=redelegations,proto3" json:"redelegations"` - Exported bool `protobuf:"varint,8,opt,name=exported,proto3" json:"exported,omitempty"` -} - -func (m *GenesisState) Reset() { *m = GenesisState{} } -func (m *GenesisState) String() string { return proto.CompactTextString(m) } -func (*GenesisState) ProtoMessage() {} -func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_9b3dec8894f2831b, []int{0} -} -func (m *GenesisState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisState) XXX_Size() int { - return m.Size() -} -func (m *GenesisState) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -func (m *GenesisState) GetLastValidatorPowers() []LastValidatorPower { - if m != nil { - return m.LastValidatorPowers - } - return nil -} - -func (m *GenesisState) GetValidators() []Validator { - if m != nil { - return m.Validators - } - return nil -} - -func (m *GenesisState) GetDelegations() []Delegation { - if m != nil { - return m.Delegations - } - return nil -} - -func (m *GenesisState) GetUnbondingDelegations() []UnbondingDelegation { - if m != nil { - return m.UnbondingDelegations - } - return nil -} - -func (m *GenesisState) GetRedelegations() []Redelegation { - if m != nil { - return m.Redelegations - } - return nil -} - -func (m *GenesisState) GetExported() bool { - if m != nil { - return m.Exported - } - return false -} - -// LastValidatorPower required for validator set update logic. -type LastValidatorPower struct { - // address is the address of the validator. - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - // power defines the power of the validator. - Power int64 `protobuf:"varint,2,opt,name=power,proto3" json:"power,omitempty"` -} - -func (m *LastValidatorPower) Reset() { *m = LastValidatorPower{} } -func (m *LastValidatorPower) String() string { return proto.CompactTextString(m) } -func (*LastValidatorPower) ProtoMessage() {} -func (*LastValidatorPower) Descriptor() ([]byte, []int) { - return fileDescriptor_9b3dec8894f2831b, []int{1} -} -func (m *LastValidatorPower) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LastValidatorPower) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LastValidatorPower.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 *LastValidatorPower) XXX_Merge(src proto.Message) { - xxx_messageInfo_LastValidatorPower.Merge(m, src) -} -func (m *LastValidatorPower) XXX_Size() int { - return m.Size() -} -func (m *LastValidatorPower) XXX_DiscardUnknown() { - xxx_messageInfo_LastValidatorPower.DiscardUnknown(m) -} - -var xxx_messageInfo_LastValidatorPower proto.InternalMessageInfo - -func init() { - // proto.RegisterType((*GenesisState)(nil), "cosmos.staking.v1beta1.GenesisState") - // proto.RegisterType((*LastValidatorPower)(nil), "cosmos.staking.v1beta1.LastValidatorPower") -} - -func init() { - // proto.RegisterFile("cosmos/staking/v1beta1/genesis.proto", fileDescriptor_9b3dec8894f2831b) -} - -var fileDescriptor_9b3dec8894f2831b = []byte{ - // 493 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0x3d, 0x6f, 0xd3, 0x40, - 0x18, 0xc7, 0x7d, 0xa4, 0x49, 0xc3, 0xa5, 0x20, 0x74, 0xa4, 0x60, 0x45, 0xc8, 0x0e, 0x56, 0x84, - 0x22, 0x5e, 0x6c, 0xb5, 0x6c, 0x15, 0x53, 0x84, 0xa8, 0x8a, 0x10, 0x8a, 0x8e, 0x97, 0x81, 0x25, - 0xba, 0xd4, 0x27, 0x63, 0xd5, 0xf1, 0x59, 0x7e, 0x2e, 0xa5, 0xdd, 0x11, 0x62, 0xe4, 0x23, 0xf4, - 0xe3, 0x74, 0xec, 0xc0, 0x80, 0x18, 0x2c, 0x94, 0x2c, 0xcc, 0xfd, 0x04, 0xc8, 0xe7, 0x17, 0x4c, - 0x52, 0x33, 0x25, 0x77, 0xfa, 0xfd, 0x7f, 0x7f, 0xfb, 0xfc, 0x1c, 0x1e, 0x1c, 0x0a, 0x98, 0x09, - 0x70, 0x40, 0xb2, 0x23, 0x3f, 0xf4, 0x9c, 0xe3, 0x9d, 0x29, 0x97, 0x6c, 0xc7, 0xf1, 0x78, 0xc8, - 0xc1, 0x07, 0x3b, 0x8a, 0x85, 0x14, 0xe4, 0x4e, 0x46, 0xd9, 0x39, 0x65, 0xe7, 0x54, 0xaf, 0xeb, - 0x09, 0x4f, 0x28, 0xc4, 0x49, 0xff, 0x65, 0x74, 0xaf, 0xce, 0x59, 0xa4, 0x15, 0x65, 0x7d, 0x6f, - 0xe2, 0xad, 0xfd, 0xac, 0xe5, 0x8d, 0x64, 0x92, 0x93, 0x67, 0xb8, 0x15, 0xb1, 0x98, 0xcd, 0x40, - 0x47, 0x7d, 0x34, 0xec, 0xec, 0x1a, 0xf6, 0xd5, 0xad, 0xf6, 0x58, 0x51, 0xa3, 0x8d, 0xf3, 0xc4, - 0xd4, 0x68, 0x9e, 0x21, 0x80, 0x6f, 0x05, 0x0c, 0xe4, 0x44, 0x0a, 0xc9, 0x82, 0x49, 0x24, 0x3e, - 0xf1, 0x58, 0xbf, 0xd6, 0x47, 0xc3, 0xad, 0xd1, 0x41, 0xca, 0xfd, 0x4c, 0xcc, 0x07, 0x9e, 0x2f, - 0x3f, 0xce, 0xa7, 0xf6, 0xa1, 0x98, 0x39, 0xf9, 0x13, 0x66, 0x3f, 0x4f, 0xc0, 0x3d, 0x72, 0xe4, - 0x69, 0xc4, 0xc1, 0x3e, 0x08, 0xe5, 0x65, 0x62, 0xde, 0x3d, 0x65, 0xb3, 0x60, 0xcf, 0x5a, 0xf5, - 0x59, 0xf4, 0x66, 0xba, 0xf5, 0x36, 0xdd, 0x19, 0xa7, 0x1b, 0xe4, 0x33, 0xc2, 0xdb, 0x8a, 0x3a, - 0x66, 0x81, 0xef, 0x32, 0x29, 0xe2, 0x8c, 0x04, 0xbd, 0xd1, 0x6f, 0x0c, 0x3b, 0xbb, 0x0f, 0xeb, - 0x5e, 0xe1, 0x15, 0x03, 0xf9, 0xbe, 0xc8, 0x28, 0xd7, 0x68, 0x90, 0x3e, 0xe6, 0x65, 0x62, 0xde, - 0xab, 0x94, 0xaf, 0x6a, 0x2d, 0x7a, 0x3b, 0x58, 0x4b, 0x02, 0xd9, 0xc7, 0xb8, 0x24, 0x41, 0xdf, - 0x50, 0xd5, 0xf7, 0xeb, 0xaa, 0xcb, 0x70, 0x7e, 0x80, 0x95, 0x28, 0x79, 0x89, 0x3b, 0x2e, 0x0f, - 0xb8, 0xc7, 0xa4, 0x2f, 0x42, 0xd0, 0x9b, 0xca, 0x64, 0xd5, 0x99, 0x9e, 0x97, 0x68, 0xae, 0xaa, - 0x86, 0xc9, 0x17, 0x84, 0xb7, 0xe7, 0xe1, 0x54, 0x84, 0xae, 0x1f, 0x7a, 0x93, 0xaa, 0xb6, 0xa5, - 0xb4, 0x8f, 0xea, 0xb4, 0xef, 0x8a, 0x50, 0xc5, 0xbf, 0x72, 0x38, 0x57, 0x7a, 0x2d, 0xda, 0x9d, - 0xaf, 0x47, 0x81, 0x8c, 0xf1, 0x8d, 0x98, 0x57, 0xfb, 0x37, 0x55, 0xff, 0xa0, 0xae, 0x9f, 0x56, - 0xe0, 0xfc, 0xc5, 0xfe, 0x15, 0x90, 0x1e, 0x6e, 0xf3, 0x93, 0x48, 0xc4, 0x92, 0xbb, 0x7a, 0xbb, - 0x8f, 0x86, 0x6d, 0x5a, 0xae, 0xad, 0xd7, 0x98, 0xac, 0x7f, 0x5c, 0xa2, 0xe3, 0x4d, 0xe6, 0xba, - 0x31, 0x87, 0x6c, 0xb8, 0xaf, 0xd3, 0x62, 0x49, 0xba, 0xb8, 0xf9, 0x77, 0x58, 0x1b, 0x34, 0x5b, - 0xec, 0xb5, 0xbf, 0x9e, 0x99, 0xda, 0xef, 0x33, 0x53, 0x1b, 0xbd, 0x38, 0x5f, 0x18, 0xe8, 0x62, - 0x61, 0xa0, 0x5f, 0x0b, 0x03, 0x7d, 0x5b, 0x1a, 0xda, 0xc5, 0xd2, 0xd0, 0x7e, 0x2c, 0x0d, 0xed, - 0xc3, 0xe3, 0xff, 0xce, 0xf3, 0x49, 0x79, 0xfd, 0xd4, 0x64, 0x4f, 0x5b, 0xea, 0xd6, 0x3d, 0xfd, - 0x13, 0x00, 0x00, 0xff, 0xff, 0xff, 0x85, 0xad, 0xc8, 0xf1, 0x03, 0x00, 0x00, -} - -func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Exported { - i-- - if m.Exported { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x40 - } - if len(m.Redelegations) > 0 { - for iNdEx := len(m.Redelegations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Redelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - } - } - if len(m.UnbondingDelegations) > 0 { - for iNdEx := len(m.UnbondingDelegations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.UnbondingDelegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - } - if len(m.Delegations) > 0 { - for iNdEx := len(m.Delegations) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Delegations[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - } - } - if len(m.Validators) > 0 { - for iNdEx := len(m.Validators) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Validators[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.LastValidatorPowers) > 0 { - for iNdEx := len(m.LastValidatorPowers) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LastValidatorPowers[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - { - size := m.LastTotalPower.Size() - i -= size - if _, err := m.LastTotalPower.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *LastValidatorPower) 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 *LastValidatorPower) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LastValidatorPower) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Power != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.Power)) - i-- - dAtA[i] = 0x10 - } - if len(m.Address) > 0 { - i -= len(m.Address) - copy(dAtA[i:], m.Address) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.Address))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { - offset -= sovGenesis(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.LastTotalPower.Size() - n += 1 + l + sovGenesis(uint64(l)) - if len(m.LastValidatorPowers) > 0 { - for _, e := range m.LastValidatorPowers { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.Validators) > 0 { - for _, e := range m.Validators { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.Delegations) > 0 { - for _, e := range m.Delegations { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.UnbondingDelegations) > 0 { - for _, e := range m.UnbondingDelegations { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.Redelegations) > 0 { - for _, e := range m.Redelegations { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.Exported { - n += 2 - } - return n -} - -func (m *LastValidatorPower) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - if m.Power != 0 { - n += 1 + sovGenesis(uint64(m.Power)) - } - return n -} - -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *GenesisState) 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: GenesisState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastTotalPower", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LastTotalPower.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastValidatorPowers", 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 - } - m.LastValidatorPowers = append(m.LastValidatorPowers, LastValidatorPower{}) - if err := m.LastValidatorPowers[len(m.LastValidatorPowers)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Validators", 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 - } - m.Validators = append(m.Validators, Validator{}) - if err := m.Validators[len(m.Validators)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegations", 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 - } - m.Delegations = append(m.Delegations, Delegation{}) - if err := m.Delegations[len(m.Delegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingDelegations", 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 - } - m.UnbondingDelegations = append(m.UnbondingDelegations, UnbondingDelegation{}) - if err := m.UnbondingDelegations[len(m.UnbondingDelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Redelegations", 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 - } - m.Redelegations = append(m.Redelegations, Redelegation{}) - if err := m.Redelegations[len(m.Redelegations)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Exported", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Exported = bool(v != 0) - 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 (m *LastValidatorPower) 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: LastValidatorPower: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LastValidatorPower: 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 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.Address = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Power", wireType) - } - m.Power = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Power |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - 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, ErrIntOverflowGenesis - } - 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, ErrIntOverflowGenesis - } - 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, ErrInvalidLengthGenesis - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGenesis - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGenesis - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/staking/migrations/v040/migrate.go b/x/staking/migrations/v040/migrate.go deleted file mode 100644 index 6616e71a6123..000000000000 --- a/x/staking/migrations/v040/migrate.go +++ /dev/null @@ -1,140 +0,0 @@ -package v040 - -import ( - "fmt" - - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - v034staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v034" - v038staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v038" -) - -func migrateBondStatus(oldStatus v034staking.BondStatus) BondStatus { - switch oldStatus { - case v034staking.Unbonded: - return Unbonded - - case v034staking.Unbonding: - return Unbonding - - case v034staking.Bonded: - return Bonded - - default: - panic(fmt.Errorf("invalid bond status %d", oldStatus)) - } -} - -// Migrate accepts exported v0.38 x/staking genesis state and migrates it to -// v0.40 x/staking genesis state. The migration includes: -// -// - Convert addresses from bytes to bech32 strings. -// - Update BondStatus staking constants. -// - Re-encode in v0.40 GenesisState. -func Migrate(stakingState v038staking.GenesisState) *GenesisState { - newLastValidatorPowers := make([]LastValidatorPower, len(stakingState.LastValidatorPowers)) - for i, oldLastValidatorPower := range stakingState.LastValidatorPowers { - newLastValidatorPowers[i] = LastValidatorPower{ - Address: oldLastValidatorPower.Address.String(), - Power: oldLastValidatorPower.Power, - } - } - - newValidators := make([]Validator, len(stakingState.Validators)) - for i, oldValidator := range stakingState.Validators { - pkAny, err := codectypes.NewAnyWithValue(oldValidator.ConsPubKey) - if err != nil { - panic(fmt.Sprintf("Can't pack validator consensus PK as Any: %s", err)) - } - newValidators[i] = Validator{ - OperatorAddress: oldValidator.OperatorAddress.String(), - ConsensusPubkey: pkAny, - Jailed: oldValidator.Jailed, - Status: migrateBondStatus(oldValidator.Status), - Tokens: oldValidator.Tokens, - DelegatorShares: oldValidator.DelegatorShares, - Description: Description{ - Moniker: oldValidator.Description.Moniker, - Identity: oldValidator.Description.Identity, - Website: oldValidator.Description.Website, - SecurityContact: oldValidator.Description.SecurityContact, - Details: oldValidator.Description.Details, - }, - UnbondingHeight: oldValidator.UnbondingHeight, - UnbondingTime: oldValidator.UnbondingCompletionTime, - Commission: Commission{ - CommissionRates: CommissionRates{ - Rate: oldValidator.Commission.Rate, - MaxRate: oldValidator.Commission.MaxRate, - MaxChangeRate: oldValidator.Commission.MaxChangeRate, - }, - UpdateTime: oldValidator.Commission.UpdateTime, - }, - MinSelfDelegation: oldValidator.MinSelfDelegation, - } - } - - newDelegations := make([]Delegation, len(stakingState.Delegations)) - for i, oldDelegation := range stakingState.Delegations { - newDelegations[i] = Delegation{ - DelegatorAddress: oldDelegation.DelegatorAddress.String(), - ValidatorAddress: oldDelegation.ValidatorAddress.String(), - Shares: oldDelegation.Shares, - } - } - - newUnbondingDelegations := make([]UnbondingDelegation, len(stakingState.UnbondingDelegations)) - for i, oldUnbondingDelegation := range stakingState.UnbondingDelegations { - newEntries := make([]UnbondingDelegationEntry, len(oldUnbondingDelegation.Entries)) - for j, oldEntry := range oldUnbondingDelegation.Entries { - newEntries[j] = UnbondingDelegationEntry{ - CreationHeight: oldEntry.CreationHeight, - CompletionTime: oldEntry.CompletionTime, - InitialBalance: oldEntry.InitialBalance, - Balance: oldEntry.Balance, - } - } - - newUnbondingDelegations[i] = UnbondingDelegation{ - DelegatorAddress: oldUnbondingDelegation.DelegatorAddress.String(), - ValidatorAddress: oldUnbondingDelegation.ValidatorAddress.String(), - Entries: newEntries, - } - } - - newRedelegations := make([]Redelegation, len(stakingState.Redelegations)) - for i, oldRedelegation := range stakingState.Redelegations { - newEntries := make([]RedelegationEntry, len(oldRedelegation.Entries)) - for j, oldEntry := range oldRedelegation.Entries { - newEntries[j] = RedelegationEntry{ - CreationHeight: oldEntry.CreationHeight, - CompletionTime: oldEntry.CompletionTime, - InitialBalance: oldEntry.InitialBalance, - SharesDst: oldEntry.SharesDst, - } - } - - newRedelegations[i] = Redelegation{ - DelegatorAddress: oldRedelegation.DelegatorAddress.String(), - ValidatorSrcAddress: oldRedelegation.ValidatorSrcAddress.String(), - ValidatorDstAddress: oldRedelegation.ValidatorDstAddress.String(), - Entries: newEntries, - } - } - - return &GenesisState{ - Params: Params{ - UnbondingTime: stakingState.Params.UnbondingTime, - MaxValidators: uint32(stakingState.Params.MaxValidators), - MaxEntries: uint32(stakingState.Params.MaxEntries), - HistoricalEntries: uint32(stakingState.Params.HistoricalEntries), - BondDenom: stakingState.Params.BondDenom, - }, - LastTotalPower: stakingState.LastTotalPower, - LastValidatorPowers: newLastValidatorPowers, - Validators: newValidators, - Delegations: newDelegations, - UnbondingDelegations: newUnbondingDelegations, - Redelegations: newRedelegations, - Exported: stakingState.Exported, - } -} diff --git a/x/staking/migrations/v040/migrate_test.go b/x/staking/migrations/v040/migrate_test.go deleted file mode 100644 index 6835c97579b4..000000000000 --- a/x/staking/migrations/v040/migrate_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package v040_test - -import ( - "encoding/json" - "testing" - - "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/simapp" - v034staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v034" - v038staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v038" - v040staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v040" -) - -func TestMigrate(t *testing.T) { - encodingConfig := simapp.MakeTestEncodingConfig() - clientCtx := client.Context{}. - WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithTxConfig(encodingConfig.TxConfig). - WithLegacyAmino(encodingConfig.Amino). - WithCodec(encodingConfig.Codec) - - consPubKey := ed25519.GenPrivKeyFromSecret([]byte("val0")).PubKey() - stakingGenState := v038staking.GenesisState{ - Validators: v038staking.Validators{v038staking.Validator{ - ConsPubKey: consPubKey, - Status: v034staking.Unbonded, - }}, - } - - migrated := v040staking.Migrate(stakingGenState) - - bz, err := clientCtx.Codec.MarshalJSON(migrated) - require.NoError(t, err) - - // Indent the JSON bz correctly. - var jsonObj map[string]interface{} - err = json.Unmarshal(bz, &jsonObj) - require.NoError(t, err) - indentedBz, err := json.MarshalIndent(jsonObj, "", " ") - require.NoError(t, err) - - // Make sure about: - // - consensus_pubkey: should be an any - // - validator's status should be 1 (new unbonded) - expected := `{ - "delegations": [], - "exported": false, - "last_total_power": "0", - "last_validator_powers": [], - "params": { - "bond_denom": "", - "historical_entries": 0, - "max_entries": 0, - "max_validators": 0, - "unbonding_time": "0s" - }, - "redelegations": [], - "unbonding_delegations": [], - "validators": [ - { - "commission": { - "commission_rates": { - "max_change_rate": "0", - "max_rate": "0", - "rate": "0" - }, - "update_time": "0001-01-01T00:00:00Z" - }, - "consensus_pubkey": { - "@type": "/cosmos.crypto.ed25519.PubKey", - "key": "KTeVrjP7NJIufvgMJsQRxZjfFyD+Exda6O7x+oxIvmA=" - }, - "delegator_shares": "0", - "description": { - "details": "", - "identity": "", - "moniker": "", - "security_contact": "", - "website": "" - }, - "jailed": false, - "min_self_delegation": "0", - "operator_address": "", - "status": "BOND_STATUS_UNBONDED", - "tokens": "0", - "unbonding_height": "0", - "unbonding_time": "0001-01-01T00:00:00Z" - } - ] -}` - - require.Equal(t, expected, string(indentedBz)) -} diff --git a/x/staking/migrations/v040/staking.pb.go b/x/staking/migrations/v040/staking.pb.go deleted file mode 100644 index 3200520a71a4..000000000000 --- a/x/staking/migrations/v040/staking.pb.go +++ /dev/null @@ -1,6525 +0,0 @@ -// Package v040 is taken from: -// https://github.com/cosmos/cosmos-sdk/blob/v0.40.1/x/staking/types/staking.pb.go -// nolint -package v040 - -import ( - bytes "bytes" - compress_gzip "compress/gzip" - fmt "fmt" - io "io" - io_ioutil "io/ioutil" - math "math" - math_bits "math/bits" - reflect "reflect" - strings "strings" - time "time" - - types1 "github.com/cosmos/cosmos-sdk/codec/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types2 "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - github_com_gogo_protobuf_proto "github.com/gogo/protobuf/proto" - proto "github.com/gogo/protobuf/proto" - github_com_gogo_protobuf_protoc_gen_gogo_descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/golang/protobuf/ptypes/duration" - _ "github.com/golang/protobuf/ptypes/timestamp" - _ "github.com/regen-network/cosmos-proto" - types "github.com/tendermint/tendermint/proto/tendermint/types" -) - -// 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. -// 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 - -// BondStatus is the status of a validator. -type BondStatus int32 - -const ( - // UNSPECIFIED defines an invalid validator status. - Unspecified BondStatus = 0 - // UNBONDED defines a validator that is not bonded. - Unbonded BondStatus = 1 - // UNBONDING defines a validator that is unbonding. - Unbonding BondStatus = 2 - // BONDED defines a validator that is bonded. - Bonded BondStatus = 3 -) - -var BondStatus_name = map[int32]string{ - 0: "BOND_STATUS_UNSPECIFIED", - 1: "BOND_STATUS_UNBONDED", - 2: "BOND_STATUS_UNBONDING", - 3: "BOND_STATUS_BONDED", -} - -var BondStatus_value = map[string]int32{ - "BOND_STATUS_UNSPECIFIED": 0, - "BOND_STATUS_UNBONDED": 1, - "BOND_STATUS_UNBONDING": 2, - "BOND_STATUS_BONDED": 3, -} - -func (x BondStatus) String() string { - return proto.EnumName(BondStatus_name, int32(x)) -} - -func (BondStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{0} -} - -// HistoricalInfo contains header and validator information for a given block. -// It is stored as part of staking module's state, which persists the `n` most -// recent HistoricalInfo -// (`n` is set by the staking module's `historical_entries` parameter). -type HistoricalInfo struct { - Header types.Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"` - Valset []Validator `protobuf:"bytes,2,rep,name=valset,proto3" json:"valset"` -} - -func (m *HistoricalInfo) Reset() { *m = HistoricalInfo{} } -func (m *HistoricalInfo) String() string { return proto.CompactTextString(m) } -func (*HistoricalInfo) ProtoMessage() {} -func (*HistoricalInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{0} -} -func (m *HistoricalInfo) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HistoricalInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_HistoricalInfo.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 *HistoricalInfo) XXX_Merge(src proto.Message) { - xxx_messageInfo_HistoricalInfo.Merge(m, src) -} -func (m *HistoricalInfo) XXX_Size() int { - return m.Size() -} -func (m *HistoricalInfo) XXX_DiscardUnknown() { - xxx_messageInfo_HistoricalInfo.DiscardUnknown(m) -} - -var xxx_messageInfo_HistoricalInfo proto.InternalMessageInfo - -func (m *HistoricalInfo) GetHeader() types.Header { - if m != nil { - return m.Header - } - return types.Header{} -} - -func (m *HistoricalInfo) GetValset() []Validator { - if m != nil { - return m.Valset - } - return nil -} - -// CommissionRates defines the initial commission rates to be used for creating -// a validator. -type CommissionRates struct { - Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate"` - MaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=max_rate,json=maxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_rate" yaml:"max_rate"` - MaxChangeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=max_change_rate,json=maxChangeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_change_rate" yaml:"max_change_rate"` -} - -func (m *CommissionRates) Reset() { *m = CommissionRates{} } -func (*CommissionRates) ProtoMessage() {} -func (*CommissionRates) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{1} -} -func (m *CommissionRates) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CommissionRates) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CommissionRates.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 *CommissionRates) XXX_Merge(src proto.Message) { - xxx_messageInfo_CommissionRates.Merge(m, src) -} -func (m *CommissionRates) XXX_Size() int { - return m.Size() -} -func (m *CommissionRates) XXX_DiscardUnknown() { - xxx_messageInfo_CommissionRates.DiscardUnknown(m) -} - -var xxx_messageInfo_CommissionRates proto.InternalMessageInfo - -// Commission defines commission parameters for a given validator. -type Commission struct { - CommissionRates `protobuf:"bytes,1,opt,name=commission_rates,json=commissionRates,proto3,embedded=commission_rates" json:"commission_rates"` - UpdateTime time.Time `protobuf:"bytes,2,opt,name=update_time,json=updateTime,proto3,stdtime" json:"update_time" yaml:"update_time"` -} - -func (m *Commission) Reset() { *m = Commission{} } -func (*Commission) ProtoMessage() {} -func (*Commission) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{2} -} -func (m *Commission) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Commission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Commission.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 *Commission) XXX_Merge(src proto.Message) { - xxx_messageInfo_Commission.Merge(m, src) -} -func (m *Commission) XXX_Size() int { - return m.Size() -} -func (m *Commission) XXX_DiscardUnknown() { - xxx_messageInfo_Commission.DiscardUnknown(m) -} - -var xxx_messageInfo_Commission proto.InternalMessageInfo - -func (m *Commission) GetUpdateTime() time.Time { - if m != nil { - return m.UpdateTime - } - return time.Time{} -} - -// Description defines a validator description. -type Description struct { - Moniker string `protobuf:"bytes,1,opt,name=moniker,proto3" json:"moniker,omitempty"` - Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` - Website string `protobuf:"bytes,3,opt,name=website,proto3" json:"website,omitempty"` - SecurityContact string `protobuf:"bytes,4,opt,name=security_contact,json=securityContact,proto3" json:"security_contact,omitempty" yaml:"security_contact"` - Details string `protobuf:"bytes,5,opt,name=details,proto3" json:"details,omitempty"` -} - -func (m *Description) Reset() { *m = Description{} } -func (*Description) ProtoMessage() {} -func (*Description) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{3} -} -func (m *Description) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Description) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Description.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 *Description) XXX_Merge(src proto.Message) { - xxx_messageInfo_Description.Merge(m, src) -} -func (m *Description) XXX_Size() int { - return m.Size() -} -func (m *Description) XXX_DiscardUnknown() { - xxx_messageInfo_Description.DiscardUnknown(m) -} - -var xxx_messageInfo_Description proto.InternalMessageInfo - -func (m *Description) GetMoniker() string { - if m != nil { - return m.Moniker - } - return "" -} - -func (m *Description) GetIdentity() string { - if m != nil { - return m.Identity - } - return "" -} - -func (m *Description) GetWebsite() string { - if m != nil { - return m.Website - } - return "" -} - -func (m *Description) GetSecurityContact() string { - if m != nil { - return m.SecurityContact - } - return "" -} - -func (m *Description) GetDetails() string { - if m != nil { - return m.Details - } - return "" -} - -// Validator defines a validator, together with the total amount of the -// Validator's bond shares and their exchange rate to coins. Slashing results in -// a decrease in the exchange rate, allowing correct calculation of future -// undelegations without iterating over delegators. When coins are delegated to -// this validator, the validator is credited with a delegation whose number of -// bond shares is based on the amount of coins delegated divided by the current -// exchange rate. Voting power can be calculated as total bonded shares -// multiplied by exchange rate. -type Validator struct { - OperatorAddress string `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3" json:"operator_address,omitempty" yaml:"operator_address"` - ConsensusPubkey *types1.Any `protobuf:"bytes,2,opt,name=consensus_pubkey,json=consensusPubkey,proto3" json:"consensus_pubkey,omitempty" yaml:"consensus_pubkey"` - Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed,omitempty"` - Status BondStatus `protobuf:"varint,4,opt,name=status,proto3,enum=cosmos.staking.v1beta1.BondStatus" json:"status,omitempty"` - Tokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=tokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"tokens"` - DelegatorShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=delegator_shares,json=delegatorShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"delegator_shares" yaml:"delegator_shares"` - Description Description `protobuf:"bytes,7,opt,name=description,proto3" json:"description"` - UnbondingHeight int64 `protobuf:"varint,8,opt,name=unbonding_height,json=unbondingHeight,proto3" json:"unbonding_height,omitempty" yaml:"unbonding_height"` - UnbondingTime time.Time `protobuf:"bytes,9,opt,name=unbonding_time,json=unbondingTime,proto3,stdtime" json:"unbonding_time" yaml:"unbonding_time"` - Commission Commission `protobuf:"bytes,10,opt,name=commission,proto3" json:"commission"` - MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation" yaml:"min_self_delegation"` -} - -func (m *Validator) Reset() { *m = Validator{} } -func (*Validator) ProtoMessage() {} -func (*Validator) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{4} -} -func (m *Validator) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Validator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Validator.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 *Validator) XXX_Merge(src proto.Message) { - xxx_messageInfo_Validator.Merge(m, src) -} -func (m *Validator) XXX_Size() int { - return m.Size() -} -func (m *Validator) XXX_DiscardUnknown() { - xxx_messageInfo_Validator.DiscardUnknown(m) -} - -var xxx_messageInfo_Validator proto.InternalMessageInfo - -// ValAddresses defines a repeated set of validator addresses. -type ValAddresses struct { - Addresses []string `protobuf:"bytes,1,rep,name=addresses,proto3" json:"addresses,omitempty"` -} - -func (m *ValAddresses) Reset() { *m = ValAddresses{} } -func (*ValAddresses) ProtoMessage() {} -func (*ValAddresses) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{5} -} -func (m *ValAddresses) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ValAddresses) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ValAddresses.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 *ValAddresses) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValAddresses.Merge(m, src) -} -func (m *ValAddresses) XXX_Size() int { - return m.Size() -} -func (m *ValAddresses) XXX_DiscardUnknown() { - xxx_messageInfo_ValAddresses.DiscardUnknown(m) -} - -var xxx_messageInfo_ValAddresses proto.InternalMessageInfo - -func (m *ValAddresses) GetAddresses() []string { - if m != nil { - return m.Addresses - } - return nil -} - -// DVPair is struct that just has a delegator-validator pair with no other data. -// It is intended to be used as a marshalable pointer. For example, a DVPair can -// be used to construct the key to getting an UnbondingDelegation from state. -type DVPair struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` - ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"` -} - -func (m *DVPair) Reset() { *m = DVPair{} } -func (*DVPair) ProtoMessage() {} -func (*DVPair) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{6} -} -func (m *DVPair) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DVPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DVPair.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 *DVPair) XXX_Merge(src proto.Message) { - xxx_messageInfo_DVPair.Merge(m, src) -} -func (m *DVPair) XXX_Size() int { - return m.Size() -} -func (m *DVPair) XXX_DiscardUnknown() { - xxx_messageInfo_DVPair.DiscardUnknown(m) -} - -var xxx_messageInfo_DVPair proto.InternalMessageInfo - -// DVPairs defines an array of DVPair objects. -type DVPairs struct { - Pairs []DVPair `protobuf:"bytes,1,rep,name=pairs,proto3" json:"pairs"` -} - -func (m *DVPairs) Reset() { *m = DVPairs{} } -func (m *DVPairs) String() string { return proto.CompactTextString(m) } -func (*DVPairs) ProtoMessage() {} -func (*DVPairs) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{7} -} -func (m *DVPairs) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DVPairs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DVPairs.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 *DVPairs) XXX_Merge(src proto.Message) { - xxx_messageInfo_DVPairs.Merge(m, src) -} -func (m *DVPairs) XXX_Size() int { - return m.Size() -} -func (m *DVPairs) XXX_DiscardUnknown() { - xxx_messageInfo_DVPairs.DiscardUnknown(m) -} - -var xxx_messageInfo_DVPairs proto.InternalMessageInfo - -func (m *DVPairs) GetPairs() []DVPair { - if m != nil { - return m.Pairs - } - return nil -} - -// DVVTriplet is struct that just has a delegator-validator-validator triplet -// with no other data. It is intended to be used as a marshalable pointer. For -// example, a DVVTriplet can be used to construct the key to getting a -// Redelegation from state. -type DVVTriplet struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` - ValidatorSrcAddress string `protobuf:"bytes,2,opt,name=validator_src_address,json=validatorSrcAddress,proto3" json:"validator_src_address,omitempty" yaml:"validator_src_address"` - ValidatorDstAddress string `protobuf:"bytes,3,opt,name=validator_dst_address,json=validatorDstAddress,proto3" json:"validator_dst_address,omitempty" yaml:"validator_dst_address"` -} - -func (m *DVVTriplet) Reset() { *m = DVVTriplet{} } -func (*DVVTriplet) ProtoMessage() {} -func (*DVVTriplet) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{8} -} -func (m *DVVTriplet) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DVVTriplet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DVVTriplet.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 *DVVTriplet) XXX_Merge(src proto.Message) { - xxx_messageInfo_DVVTriplet.Merge(m, src) -} -func (m *DVVTriplet) XXX_Size() int { - return m.Size() -} -func (m *DVVTriplet) XXX_DiscardUnknown() { - xxx_messageInfo_DVVTriplet.DiscardUnknown(m) -} - -var xxx_messageInfo_DVVTriplet proto.InternalMessageInfo - -// DVVTriplets defines an array of DVVTriplet objects. -type DVVTriplets struct { - Triplets []DVVTriplet `protobuf:"bytes,1,rep,name=triplets,proto3" json:"triplets"` -} - -func (m *DVVTriplets) Reset() { *m = DVVTriplets{} } -func (m *DVVTriplets) String() string { return proto.CompactTextString(m) } -func (*DVVTriplets) ProtoMessage() {} -func (*DVVTriplets) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{9} -} -func (m *DVVTriplets) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DVVTriplets) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DVVTriplets.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 *DVVTriplets) XXX_Merge(src proto.Message) { - xxx_messageInfo_DVVTriplets.Merge(m, src) -} -func (m *DVVTriplets) XXX_Size() int { - return m.Size() -} -func (m *DVVTriplets) XXX_DiscardUnknown() { - xxx_messageInfo_DVVTriplets.DiscardUnknown(m) -} - -var xxx_messageInfo_DVVTriplets proto.InternalMessageInfo - -func (m *DVVTriplets) GetTriplets() []DVVTriplet { - if m != nil { - return m.Triplets - } - return nil -} - -// Delegation represents the bond with tokens held by an account. It is -// owned by one delegator, and is associated with the voting power of one -// validator. -type Delegation struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` - ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"` - Shares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=shares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"shares"` -} - -func (m *Delegation) Reset() { *m = Delegation{} } -func (*Delegation) ProtoMessage() {} -func (*Delegation) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{10} -} -func (m *Delegation) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Delegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Delegation.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 *Delegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_Delegation.Merge(m, src) -} -func (m *Delegation) XXX_Size() int { - return m.Size() -} -func (m *Delegation) XXX_DiscardUnknown() { - xxx_messageInfo_Delegation.DiscardUnknown(m) -} - -var xxx_messageInfo_Delegation proto.InternalMessageInfo - -// UnbondingDelegation stores all of a single delegator's unbonding bonds -// for a single validator in an time-ordered list. -type UnbondingDelegation struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` - ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty" yaml:"validator_address"` - Entries []UnbondingDelegationEntry `protobuf:"bytes,3,rep,name=entries,proto3" json:"entries"` -} - -func (m *UnbondingDelegation) Reset() { *m = UnbondingDelegation{} } -func (*UnbondingDelegation) ProtoMessage() {} -func (*UnbondingDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{11} -} -func (m *UnbondingDelegation) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UnbondingDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UnbondingDelegation.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 *UnbondingDelegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_UnbondingDelegation.Merge(m, src) -} -func (m *UnbondingDelegation) XXX_Size() int { - return m.Size() -} -func (m *UnbondingDelegation) XXX_DiscardUnknown() { - xxx_messageInfo_UnbondingDelegation.DiscardUnknown(m) -} - -var xxx_messageInfo_UnbondingDelegation proto.InternalMessageInfo - -// UnbondingDelegationEntry defines an unbonding object with relevant metadata. -type UnbondingDelegationEntry struct { - CreationHeight int64 `protobuf:"varint,1,opt,name=creation_height,json=creationHeight,proto3" json:"creation_height,omitempty" yaml:"creation_height"` - CompletionTime time.Time `protobuf:"bytes,2,opt,name=completion_time,json=completionTime,proto3,stdtime" json:"completion_time" yaml:"completion_time"` - InitialBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=initial_balance,json=initialBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"initial_balance" yaml:"initial_balance"` - Balance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=balance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"balance"` -} - -func (m *UnbondingDelegationEntry) Reset() { *m = UnbondingDelegationEntry{} } -func (*UnbondingDelegationEntry) ProtoMessage() {} -func (*UnbondingDelegationEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{12} -} -func (m *UnbondingDelegationEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UnbondingDelegationEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UnbondingDelegationEntry.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 *UnbondingDelegationEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_UnbondingDelegationEntry.Merge(m, src) -} -func (m *UnbondingDelegationEntry) XXX_Size() int { - return m.Size() -} -func (m *UnbondingDelegationEntry) XXX_DiscardUnknown() { - xxx_messageInfo_UnbondingDelegationEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_UnbondingDelegationEntry proto.InternalMessageInfo - -func (m *UnbondingDelegationEntry) GetCreationHeight() int64 { - if m != nil { - return m.CreationHeight - } - return 0 -} - -func (m *UnbondingDelegationEntry) GetCompletionTime() time.Time { - if m != nil { - return m.CompletionTime - } - return time.Time{} -} - -// RedelegationEntry defines a redelegation object with relevant metadata. -type RedelegationEntry struct { - CreationHeight int64 `protobuf:"varint,1,opt,name=creation_height,json=creationHeight,proto3" json:"creation_height,omitempty" yaml:"creation_height"` - CompletionTime time.Time `protobuf:"bytes,2,opt,name=completion_time,json=completionTime,proto3,stdtime" json:"completion_time" yaml:"completion_time"` - InitialBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=initial_balance,json=initialBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"initial_balance" yaml:"initial_balance"` - SharesDst github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=shares_dst,json=sharesDst,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"shares_dst"` -} - -func (m *RedelegationEntry) Reset() { *m = RedelegationEntry{} } -func (*RedelegationEntry) ProtoMessage() {} -func (*RedelegationEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{13} -} -func (m *RedelegationEntry) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RedelegationEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RedelegationEntry.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 *RedelegationEntry) XXX_Merge(src proto.Message) { - xxx_messageInfo_RedelegationEntry.Merge(m, src) -} -func (m *RedelegationEntry) XXX_Size() int { - return m.Size() -} -func (m *RedelegationEntry) XXX_DiscardUnknown() { - xxx_messageInfo_RedelegationEntry.DiscardUnknown(m) -} - -var xxx_messageInfo_RedelegationEntry proto.InternalMessageInfo - -func (m *RedelegationEntry) GetCreationHeight() int64 { - if m != nil { - return m.CreationHeight - } - return 0 -} - -func (m *RedelegationEntry) GetCompletionTime() time.Time { - if m != nil { - return m.CompletionTime - } - return time.Time{} -} - -// Redelegation contains the list of a particular delegator's redelegating bonds -// from a particular source validator to a particular destination validator. -type Redelegation struct { - DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty" yaml:"delegator_address"` - ValidatorSrcAddress string `protobuf:"bytes,2,opt,name=validator_src_address,json=validatorSrcAddress,proto3" json:"validator_src_address,omitempty" yaml:"validator_src_address"` - ValidatorDstAddress string `protobuf:"bytes,3,opt,name=validator_dst_address,json=validatorDstAddress,proto3" json:"validator_dst_address,omitempty" yaml:"validator_dst_address"` - Entries []RedelegationEntry `protobuf:"bytes,4,rep,name=entries,proto3" json:"entries"` -} - -func (m *Redelegation) Reset() { *m = Redelegation{} } -func (*Redelegation) ProtoMessage() {} -func (*Redelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{14} -} -func (m *Redelegation) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Redelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Redelegation.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 *Redelegation) XXX_Merge(src proto.Message) { - xxx_messageInfo_Redelegation.Merge(m, src) -} -func (m *Redelegation) XXX_Size() int { - return m.Size() -} -func (m *Redelegation) XXX_DiscardUnknown() { - xxx_messageInfo_Redelegation.DiscardUnknown(m) -} - -var xxx_messageInfo_Redelegation proto.InternalMessageInfo - -// Params defines the parameters for the staking module. -type Params struct { - UnbondingTime time.Duration `protobuf:"bytes,1,opt,name=unbonding_time,json=unbondingTime,proto3,stdduration" json:"unbonding_time" yaml:"unbonding_time"` - MaxValidators uint32 `protobuf:"varint,2,opt,name=max_validators,json=maxValidators,proto3" json:"max_validators,omitempty" yaml:"max_validators"` - MaxEntries uint32 `protobuf:"varint,3,opt,name=max_entries,json=maxEntries,proto3" json:"max_entries,omitempty" yaml:"max_entries"` - HistoricalEntries uint32 `protobuf:"varint,4,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty" yaml:"historical_entries"` - BondDenom string `protobuf:"bytes,5,opt,name=bond_denom,json=bondDenom,proto3" json:"bond_denom,omitempty" yaml:"bond_denom"` -} - -func (m *Params) Reset() { *m = Params{} } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{15} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetUnbondingTime() time.Duration { - if m != nil { - return m.UnbondingTime - } - return 0 -} - -func (m *Params) GetMaxValidators() uint32 { - if m != nil { - return m.MaxValidators - } - return 0 -} - -func (m *Params) GetMaxEntries() uint32 { - if m != nil { - return m.MaxEntries - } - return 0 -} - -func (m *Params) GetHistoricalEntries() uint32 { - if m != nil { - return m.HistoricalEntries - } - return 0 -} - -func (m *Params) GetBondDenom() string { - if m != nil { - return m.BondDenom - } - return "" -} - -// DelegationResponse is equivalent to Delegation except that it contains a -// balance in addition to shares which is more suitable for client responses. -type DelegationResponse struct { - Delegation Delegation `protobuf:"bytes,1,opt,name=delegation,proto3" json:"delegation"` - Balance types2.Coin `protobuf:"bytes,2,opt,name=balance,proto3" json:"balance"` -} - -func (m *DelegationResponse) Reset() { *m = DelegationResponse{} } -func (*DelegationResponse) ProtoMessage() {} -func (*DelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{16} -} -func (m *DelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DelegationResponse.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 *DelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DelegationResponse.Merge(m, src) -} -func (m *DelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *DelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DelegationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DelegationResponse proto.InternalMessageInfo - -func (m *DelegationResponse) GetDelegation() Delegation { - if m != nil { - return m.Delegation - } - return Delegation{} -} - -func (m *DelegationResponse) GetBalance() types2.Coin { - if m != nil { - return m.Balance - } - return types2.Coin{} -} - -// RedelegationEntryResponse is equivalent to a RedelegationEntry except that it -// contains a balance in addition to shares which is more suitable for client -// responses. -type RedelegationEntryResponse struct { - RedelegationEntry RedelegationEntry `protobuf:"bytes,1,opt,name=redelegation_entry,json=redelegationEntry,proto3" json:"redelegation_entry"` - Balance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=balance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"balance"` -} - -func (m *RedelegationEntryResponse) Reset() { *m = RedelegationEntryResponse{} } -func (m *RedelegationEntryResponse) String() string { return proto.CompactTextString(m) } -func (*RedelegationEntryResponse) ProtoMessage() {} -func (*RedelegationEntryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{17} -} -func (m *RedelegationEntryResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RedelegationEntryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RedelegationEntryResponse.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 *RedelegationEntryResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_RedelegationEntryResponse.Merge(m, src) -} -func (m *RedelegationEntryResponse) XXX_Size() int { - return m.Size() -} -func (m *RedelegationEntryResponse) XXX_DiscardUnknown() { - xxx_messageInfo_RedelegationEntryResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_RedelegationEntryResponse proto.InternalMessageInfo - -func (m *RedelegationEntryResponse) GetRedelegationEntry() RedelegationEntry { - if m != nil { - return m.RedelegationEntry - } - return RedelegationEntry{} -} - -// RedelegationResponse is equivalent to a Redelegation except that its entries -// contain a balance in addition to shares which is more suitable for client -// responses. -type RedelegationResponse struct { - Redelegation Redelegation `protobuf:"bytes,1,opt,name=redelegation,proto3" json:"redelegation"` - Entries []RedelegationEntryResponse `protobuf:"bytes,2,rep,name=entries,proto3" json:"entries"` -} - -func (m *RedelegationResponse) Reset() { *m = RedelegationResponse{} } -func (m *RedelegationResponse) String() string { return proto.CompactTextString(m) } -func (*RedelegationResponse) ProtoMessage() {} -func (*RedelegationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{18} -} -func (m *RedelegationResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RedelegationResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RedelegationResponse.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 *RedelegationResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_RedelegationResponse.Merge(m, src) -} -func (m *RedelegationResponse) XXX_Size() int { - return m.Size() -} -func (m *RedelegationResponse) XXX_DiscardUnknown() { - xxx_messageInfo_RedelegationResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_RedelegationResponse proto.InternalMessageInfo - -func (m *RedelegationResponse) GetRedelegation() Redelegation { - if m != nil { - return m.Redelegation - } - return Redelegation{} -} - -func (m *RedelegationResponse) GetEntries() []RedelegationEntryResponse { - if m != nil { - return m.Entries - } - return nil -} - -// Pool is used for tracking bonded and not-bonded token supply of the bond -// denomination. -type Pool struct { - NotBondedTokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=not_bonded_tokens,json=notBondedTokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"not_bonded_tokens"` - BondedTokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=bonded_tokens,json=bondedTokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"bonded_tokens" yaml:"bonded_tokens"` -} - -func (m *Pool) Reset() { *m = Pool{} } -func (m *Pool) String() string { return proto.CompactTextString(m) } -func (*Pool) ProtoMessage() {} -func (*Pool) Descriptor() ([]byte, []int) { - return fileDescriptor_64c30c6cf92913c9, []int{19} -} -func (m *Pool) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Pool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Pool.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 *Pool) XXX_Merge(src proto.Message) { - xxx_messageInfo_Pool.Merge(m, src) -} -func (m *Pool) XXX_Size() int { - return m.Size() -} -func (m *Pool) XXX_DiscardUnknown() { - xxx_messageInfo_Pool.DiscardUnknown(m) -} - -var xxx_messageInfo_Pool proto.InternalMessageInfo - -func init() { - // proto.RegisterEnum("cosmos.staking.v1beta1.BondStatus", BondStatus_name, BondStatus_value) - // proto.RegisterType((*HistoricalInfo)(nil), "cosmos.staking.v1beta1.HistoricalInfo") - // proto.RegisterType((*CommissionRates)(nil), "cosmos.staking.v1beta1.CommissionRates") - // proto.RegisterType((*Commission)(nil), "cosmos.staking.v1beta1.Commission") - // proto.RegisterType((*Description)(nil), "cosmos.staking.v1beta1.Description") - // proto.RegisterType((*Validator)(nil), "cosmos.staking.v1beta1.Validator") - // proto.RegisterType((*ValAddresses)(nil), "cosmos.staking.v1beta1.ValAddresses") - // proto.RegisterType((*DVPair)(nil), "cosmos.staking.v1beta1.DVPair") - // proto.RegisterType((*DVPairs)(nil), "cosmos.staking.v1beta1.DVPairs") - // proto.RegisterType((*DVVTriplet)(nil), "cosmos.staking.v1beta1.DVVTriplet") - // proto.RegisterType((*DVVTriplets)(nil), "cosmos.staking.v1beta1.DVVTriplets") - // proto.RegisterType((*Delegation)(nil), "cosmos.staking.v1beta1.Delegation") - // proto.RegisterType((*UnbondingDelegation)(nil), "cosmos.staking.v1beta1.UnbondingDelegation") - // proto.RegisterType((*UnbondingDelegationEntry)(nil), "cosmos.staking.v1beta1.UnbondingDelegationEntry") - // proto.RegisterType((*RedelegationEntry)(nil), "cosmos.staking.v1beta1.RedelegationEntry") - // proto.RegisterType((*Redelegation)(nil), "cosmos.staking.v1beta1.Redelegation") - // proto.RegisterType((*Params)(nil), "cosmos.staking.v1beta1.Params") - // proto.RegisterType((*DelegationResponse)(nil), "cosmos.staking.v1beta1.DelegationResponse") - // proto.RegisterType((*RedelegationEntryResponse)(nil), "cosmos.staking.v1beta1.RedelegationEntryResponse") - // proto.RegisterType((*RedelegationResponse)(nil), "cosmos.staking.v1beta1.RedelegationResponse") - // proto.RegisterType((*Pool)(nil), "cosmos.staking.v1beta1.Pool") -} - -func init() { - proto.RegisterFile("cosmos/staking/v1beta1/staking.proto", fileDescriptor_64c30c6cf92913c9) -} - -var fileDescriptor_64c30c6cf92913c9 = []byte{ - // 1796 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0x4d, 0x6c, 0x23, 0x49, - 0x15, 0x76, 0x3b, 0x5e, 0xc7, 0x7e, 0x4e, 0xe2, 0xa4, 0x26, 0x33, 0xeb, 0x98, 0xc1, 0xed, 0x6d, - 0x56, 0x4b, 0x40, 0xbb, 0x0e, 0x93, 0x45, 0x8b, 0xc8, 0x05, 0xc6, 0x71, 0x86, 0x58, 0xbb, 0x0c, - 0xa1, 0x93, 0x09, 0x12, 0xac, 0xb0, 0xca, 0xdd, 0x15, 0xa7, 0x89, 0xbb, 0xdb, 0x74, 0x95, 0x87, - 0x58, 0xda, 0x03, 0xc7, 0x65, 0x10, 0x62, 0xb9, 0xed, 0x65, 0xa4, 0x91, 0xf6, 0xba, 0x12, 0x17, - 0xc4, 0x95, 0xeb, 0x02, 0x97, 0xe1, 0x86, 0x10, 0x32, 0x68, 0xe6, 0x82, 0x38, 0x21, 0x1f, 0x10, - 0x37, 0x50, 0xfd, 0xf4, 0x4f, 0xda, 0xf1, 0xcc, 0x78, 0xb4, 0x87, 0x91, 0xd8, 0x4b, 0xe2, 0x7a, - 0xf5, 0xde, 0xf7, 0xea, 0xfd, 0xd6, 0xab, 0x86, 0x57, 0x2d, 0x9f, 0xba, 0x3e, 0xdd, 0xa2, 0x0c, - 0x9f, 0x39, 0x5e, 0x6f, 0xeb, 0xee, 0x8d, 0x2e, 0x61, 0xf8, 0x46, 0xb8, 0x6e, 0x0c, 0x02, 0x9f, - 0xf9, 0xe8, 0x9a, 0xe4, 0x6a, 0x84, 0x54, 0xc5, 0x55, 0x5d, 0xef, 0xf9, 0x3d, 0x5f, 0xb0, 0x6c, - 0xf1, 0x5f, 0x92, 0xbb, 0xba, 0xd1, 0xf3, 0xfd, 0x5e, 0x9f, 0x6c, 0x89, 0x55, 0x77, 0x78, 0xb2, - 0x85, 0xbd, 0x91, 0xda, 0xaa, 0xa5, 0xb7, 0xec, 0x61, 0x80, 0x99, 0xe3, 0x7b, 0x6a, 0x5f, 0x4f, - 0xef, 0x33, 0xc7, 0x25, 0x94, 0x61, 0x77, 0x10, 0x62, 0xcb, 0x93, 0x74, 0xa4, 0x52, 0x75, 0x2c, - 0x85, 0xad, 0x4c, 0xe9, 0x62, 0x4a, 0x22, 0x3b, 0x2c, 0xdf, 0x09, 0xb1, 0xaf, 0x33, 0xe2, 0xd9, - 0x24, 0x70, 0x1d, 0x8f, 0x6d, 0xb1, 0xd1, 0x80, 0x50, 0xf9, 0x57, 0xee, 0x1a, 0x3f, 0xd3, 0x60, - 0x65, 0xdf, 0xa1, 0xcc, 0x0f, 0x1c, 0x0b, 0xf7, 0xdb, 0xde, 0x89, 0x8f, 0xde, 0x82, 0xfc, 0x29, - 0xc1, 0x36, 0x09, 0x2a, 0x5a, 0x5d, 0xdb, 0x2c, 0x6d, 0x57, 0x1a, 0x31, 0x42, 0x43, 0xca, 0xee, - 0x8b, 0xfd, 0x66, 0xee, 0x93, 0xb1, 0x9e, 0x31, 0x15, 0x37, 0xfa, 0x06, 0xe4, 0xef, 0xe2, 0x3e, - 0x25, 0xac, 0x92, 0xad, 0x2f, 0x6c, 0x96, 0xb6, 0x5f, 0x69, 0x5c, 0xee, 0xbe, 0xc6, 0x31, 0xee, - 0x3b, 0x36, 0x66, 0x7e, 0x04, 0x20, 0xc5, 0x8c, 0x5f, 0x67, 0xa1, 0xbc, 0xeb, 0xbb, 0xae, 0x43, - 0xa9, 0xe3, 0x7b, 0x26, 0x66, 0x84, 0xa2, 0x26, 0xe4, 0x02, 0xcc, 0x88, 0x38, 0x4a, 0xb1, 0xd9, - 0xe0, 0xfc, 0x7f, 0x19, 0xeb, 0xaf, 0xf5, 0x1c, 0x76, 0x3a, 0xec, 0x36, 0x2c, 0xdf, 0x55, 0xce, - 0x50, 0xff, 0xde, 0xa0, 0xf6, 0x99, 0xb2, 0xaf, 0x45, 0x2c, 0x53, 0xc8, 0xa2, 0x77, 0xa1, 0xe0, - 0xe2, 0xf3, 0x8e, 0xc0, 0xc9, 0x0a, 0x9c, 0x9b, 0xf3, 0xe1, 0x4c, 0xc6, 0x7a, 0x79, 0x84, 0xdd, - 0xfe, 0x8e, 0x11, 0xe2, 0x18, 0xe6, 0xa2, 0x8b, 0xcf, 0xf9, 0x11, 0xd1, 0x00, 0xca, 0x9c, 0x6a, - 0x9d, 0x62, 0xaf, 0x47, 0xa4, 0x92, 0x05, 0xa1, 0x64, 0x7f, 0x6e, 0x25, 0xd7, 0x62, 0x25, 0x09, - 0x38, 0xc3, 0x5c, 0x76, 0xf1, 0xf9, 0xae, 0x20, 0x70, 0x8d, 0x3b, 0x85, 0x0f, 0x1f, 0xe8, 0x99, - 0x7f, 0x3c, 0xd0, 0x35, 0xe3, 0x4f, 0x1a, 0x40, 0xec, 0x31, 0xf4, 0x2e, 0xac, 0x5a, 0xd1, 0x4a, - 0xc8, 0x52, 0x15, 0xc3, 0x2f, 0xce, 0x8a, 0x45, 0xca, 0xdf, 0xcd, 0x02, 0x3f, 0xf4, 0xc3, 0xb1, - 0xae, 0x99, 0x65, 0x2b, 0x15, 0x8a, 0x1f, 0x40, 0x69, 0x38, 0xb0, 0x31, 0x23, 0x1d, 0x9e, 0x9d, - 0xc2, 0x93, 0xa5, 0xed, 0x6a, 0x43, 0xa6, 0x6e, 0x23, 0x4c, 0xdd, 0xc6, 0x51, 0x98, 0xba, 0xcd, - 0x1a, 0xc7, 0x9a, 0x8c, 0x75, 0x24, 0xcd, 0x4a, 0x08, 0x1b, 0x1f, 0xfc, 0x4d, 0xd7, 0x4c, 0x90, - 0x14, 0x2e, 0x90, 0xb0, 0xe9, 0xf7, 0x1a, 0x94, 0x5a, 0x84, 0x5a, 0x81, 0x33, 0xe0, 0x15, 0x82, - 0x2a, 0xb0, 0xe8, 0xfa, 0x9e, 0x73, 0xa6, 0xf2, 0xb1, 0x68, 0x86, 0x4b, 0x54, 0x85, 0x82, 0x63, - 0x13, 0x8f, 0x39, 0x6c, 0x24, 0xe3, 0x6a, 0x46, 0x6b, 0x2e, 0xf5, 0x13, 0xd2, 0xa5, 0x4e, 0x18, - 0x0d, 0x33, 0x5c, 0xa2, 0x5b, 0xb0, 0x4a, 0x89, 0x35, 0x0c, 0x1c, 0x36, 0xea, 0x58, 0xbe, 0xc7, - 0xb0, 0xc5, 0x2a, 0x39, 0x11, 0xb0, 0xcf, 0x4d, 0xc6, 0xfa, 0xcb, 0xf2, 0xac, 0x69, 0x0e, 0xc3, - 0x2c, 0x87, 0xa4, 0x5d, 0x49, 0xe1, 0x1a, 0x6c, 0xc2, 0xb0, 0xd3, 0xa7, 0x95, 0x97, 0xa4, 0x06, - 0xb5, 0x4c, 0xd8, 0xf2, 0xf1, 0x22, 0x14, 0xa3, 0x6c, 0xe7, 0x9a, 0xfd, 0x01, 0x09, 0xf8, 0xef, - 0x0e, 0xb6, 0xed, 0x80, 0x50, 0xaa, 0xf2, 0x3a, 0xa1, 0x39, 0xcd, 0x61, 0x98, 0xe5, 0x90, 0x74, - 0x53, 0x52, 0x10, 0xe3, 0x61, 0xf6, 0x28, 0xf1, 0xe8, 0x90, 0x76, 0x06, 0xc3, 0xee, 0x19, 0x19, - 0xa9, 0x68, 0xac, 0x4f, 0x45, 0xe3, 0xa6, 0x37, 0x6a, 0xbe, 0x19, 0xa3, 0xa7, 0xe5, 0x8c, 0x3f, - 0xfc, 0xe6, 0x8d, 0x75, 0x95, 0x1a, 0x56, 0x30, 0x1a, 0x30, 0xbf, 0x71, 0x30, 0xec, 0xbe, 0x4d, - 0x46, 0x3c, 0xfc, 0x8a, 0xf5, 0x40, 0x70, 0xa2, 0x6b, 0x90, 0xff, 0x11, 0x76, 0xfa, 0xc4, 0x16, - 0x0e, 0x2d, 0x98, 0x6a, 0x85, 0x76, 0x20, 0x4f, 0x19, 0x66, 0x43, 0x2a, 0xbc, 0xb8, 0xb2, 0x6d, - 0xcc, 0x4a, 0xb5, 0xa6, 0xef, 0xd9, 0x87, 0x82, 0xd3, 0x54, 0x12, 0xe8, 0x16, 0xe4, 0x99, 0x7f, - 0x46, 0x3c, 0xe5, 0xc2, 0xb9, 0xea, 0xbb, 0xed, 0x31, 0x53, 0x49, 0x73, 0x8f, 0xd8, 0xa4, 0x4f, - 0x7a, 0xc2, 0x71, 0xf4, 0x14, 0x07, 0x84, 0x56, 0xf2, 0x02, 0xb1, 0x3d, 0x77, 0x11, 0x2a, 0x4f, - 0xa5, 0xf1, 0x0c, 0xb3, 0x1c, 0x91, 0x0e, 0x05, 0x05, 0xbd, 0x0d, 0x25, 0x3b, 0x4e, 0xd4, 0xca, - 0xa2, 0x08, 0xc1, 0x17, 0x66, 0x99, 0x9f, 0xc8, 0x69, 0xd5, 0xf7, 0x92, 0xd2, 0x3c, 0x39, 0x86, - 0x5e, 0xd7, 0xf7, 0x6c, 0xc7, 0xeb, 0x75, 0x4e, 0x89, 0xd3, 0x3b, 0x65, 0x95, 0x42, 0x5d, 0xdb, - 0x5c, 0x48, 0x26, 0x47, 0x9a, 0xc3, 0x30, 0xcb, 0x11, 0x69, 0x5f, 0x50, 0x90, 0x0d, 0x2b, 0x31, - 0x97, 0x28, 0xd4, 0xe2, 0x53, 0x0b, 0xf5, 0x15, 0x55, 0xa8, 0x57, 0xd3, 0x5a, 0xe2, 0x5a, 0x5d, - 0x8e, 0x88, 0x5c, 0x0c, 0xed, 0x03, 0xc4, 0xed, 0xa1, 0x02, 0x42, 0x83, 0xf1, 0xf4, 0x1e, 0xa3, - 0x0c, 0x4f, 0xc8, 0xa2, 0xf7, 0xe0, 0x8a, 0xeb, 0x78, 0x1d, 0x4a, 0xfa, 0x27, 0x1d, 0xe5, 0x60, - 0x0e, 0x59, 0x12, 0xd1, 0x7b, 0x67, 0xbe, 0x7c, 0x98, 0x8c, 0xf5, 0xaa, 0x6a, 0xa1, 0xd3, 0x90, - 0x86, 0xb9, 0xe6, 0x3a, 0xde, 0x21, 0xe9, 0x9f, 0xb4, 0x22, 0xda, 0xce, 0xd2, 0xfb, 0x0f, 0xf4, - 0x8c, 0x2a, 0xd7, 0x8c, 0xf1, 0x16, 0x2c, 0x1d, 0xe3, 0xbe, 0x2a, 0x33, 0x42, 0xd1, 0x75, 0x28, - 0xe2, 0x70, 0x51, 0xd1, 0xea, 0x0b, 0x9b, 0x45, 0x33, 0x26, 0xc8, 0x32, 0xff, 0xe9, 0x5f, 0xeb, - 0x9a, 0xf1, 0xb1, 0x06, 0xf9, 0xd6, 0xf1, 0x01, 0x76, 0x02, 0xd4, 0x86, 0xb5, 0x38, 0x73, 0x2e, - 0x16, 0xf9, 0xf5, 0xc9, 0x58, 0xaf, 0xa4, 0x93, 0x2b, 0xaa, 0xf2, 0x38, 0x81, 0xc3, 0x32, 0x6f, - 0xc3, 0xda, 0xdd, 0xb0, 0x77, 0x44, 0x50, 0xd9, 0x34, 0xd4, 0x14, 0x8b, 0x61, 0xae, 0x46, 0x34, - 0x05, 0x95, 0x32, 0x73, 0x0f, 0x16, 0xe5, 0x69, 0x29, 0xda, 0x81, 0x97, 0x06, 0xfc, 0x87, 0xb0, - 0xae, 0xb4, 0x5d, 0x9b, 0x99, 0xbc, 0x82, 0x5f, 0x85, 0x4f, 0x8a, 0x18, 0xbf, 0xca, 0x02, 0xb4, - 0x8e, 0x8f, 0x8f, 0x02, 0x67, 0xd0, 0x27, 0xec, 0xd3, 0xb4, 0xfc, 0x08, 0xae, 0xc6, 0x66, 0xd1, - 0xc0, 0x4a, 0x59, 0x5f, 0x9f, 0x8c, 0xf5, 0xeb, 0x69, 0xeb, 0x13, 0x6c, 0x86, 0x79, 0x25, 0xa2, - 0x1f, 0x06, 0xd6, 0xa5, 0xa8, 0x36, 0x65, 0x11, 0xea, 0xc2, 0x6c, 0xd4, 0x04, 0x5b, 0x12, 0xb5, - 0x45, 0xd9, 0xe5, 0xae, 0x3d, 0x84, 0x52, 0xec, 0x12, 0x8a, 0x5a, 0x50, 0x60, 0xea, 0xb7, 0xf2, - 0xb0, 0x31, 0xdb, 0xc3, 0xa1, 0x98, 0xf2, 0x72, 0x24, 0x69, 0xfc, 0x47, 0x03, 0x88, 0x73, 0xf6, - 0xc5, 0x4c, 0x31, 0xde, 0xca, 0x55, 0xe3, 0x5d, 0x78, 0xae, 0x51, 0x4d, 0x49, 0xa7, 0xfc, 0xf9, - 0xf3, 0x2c, 0x5c, 0xb9, 0x13, 0x76, 0x9e, 0x17, 0xde, 0x07, 0x07, 0xb0, 0x48, 0x3c, 0x16, 0x38, - 0xc2, 0x09, 0x3c, 0xda, 0x5f, 0x99, 0x15, 0xed, 0x4b, 0x6c, 0xda, 0xf3, 0x58, 0x30, 0x52, 0xb1, - 0x0f, 0x61, 0x52, 0xde, 0xf8, 0xe5, 0x02, 0x54, 0x66, 0x49, 0xa2, 0x5d, 0x28, 0x5b, 0x01, 0x11, - 0x84, 0xf0, 0xfe, 0xd0, 0xc4, 0xfd, 0x51, 0x8d, 0x27, 0xcb, 0x14, 0x83, 0x61, 0xae, 0x84, 0x14, - 0x75, 0x7b, 0xf4, 0x80, 0x8f, 0x7d, 0x3c, 0xed, 0x38, 0xd7, 0x33, 0xce, 0x79, 0x86, 0xba, 0x3e, - 0x42, 0x25, 0x17, 0x01, 0xe4, 0xfd, 0xb1, 0x12, 0x53, 0xc5, 0x05, 0xf2, 0x63, 0x28, 0x3b, 0x9e, - 0xc3, 0x1c, 0xdc, 0xef, 0x74, 0x71, 0x1f, 0x7b, 0xd6, 0xf3, 0x4c, 0xcd, 0xb2, 0xe5, 0x2b, 0xb5, - 0x29, 0x38, 0xc3, 0x5c, 0x51, 0x94, 0xa6, 0x24, 0xa0, 0x7d, 0x58, 0x0c, 0x55, 0xe5, 0x9e, 0x6b, - 0xda, 0x08, 0xc5, 0x13, 0x03, 0xde, 0x2f, 0x16, 0x60, 0xcd, 0x24, 0xf6, 0x67, 0xa1, 0x98, 0x2f, - 0x14, 0xdf, 0x06, 0x90, 0xe5, 0xce, 0x1b, 0xec, 0x73, 0x44, 0x83, 0x37, 0x8c, 0xa2, 0x44, 0x68, - 0x51, 0x96, 0x88, 0xc7, 0x38, 0x0b, 0x4b, 0xc9, 0x78, 0xfc, 0x9f, 0xde, 0x4a, 0xa8, 0x1d, 0x77, - 0xa2, 0x9c, 0xe8, 0x44, 0x5f, 0x9a, 0xd5, 0x89, 0xa6, 0xb2, 0xf7, 0xc9, 0x2d, 0xe8, 0xdf, 0x59, - 0xc8, 0x1f, 0xe0, 0x00, 0xbb, 0x14, 0x59, 0x53, 0x93, 0xa6, 0x7c, 0x6b, 0x6e, 0x4c, 0xe5, 0x67, - 0x4b, 0x7d, 0xed, 0x78, 0xca, 0xa0, 0xf9, 0xe1, 0x25, 0x83, 0xe6, 0x37, 0x61, 0x85, 0x3f, 0x87, - 0x23, 0x1b, 0xa5, 0xb7, 0x97, 0x9b, 0x1b, 0x31, 0xca, 0xc5, 0x7d, 0xf9, 0x5a, 0x8e, 0x1e, 0x5d, - 0x14, 0x7d, 0x0d, 0x4a, 0x9c, 0x23, 0x6e, 0xcc, 0x5c, 0xfc, 0x5a, 0xfc, 0x2c, 0x4d, 0x6c, 0x1a, - 0x26, 0xb8, 0xf8, 0x7c, 0x4f, 0x2e, 0xd0, 0x3b, 0x80, 0x4e, 0xa3, 0x2f, 0x23, 0x9d, 0xd8, 0x9d, - 0x5c, 0xfe, 0xf3, 0x93, 0xb1, 0xbe, 0x21, 0xe5, 0xa7, 0x79, 0x0c, 0x73, 0x2d, 0x26, 0x86, 0x68, - 0x5f, 0x05, 0xe0, 0x76, 0x75, 0x6c, 0xe2, 0xf9, 0xae, 0x7a, 0xee, 0x5c, 0x9d, 0x8c, 0xf5, 0x35, - 0x89, 0x12, 0xef, 0x19, 0x66, 0x91, 0x2f, 0x5a, 0xfc, 0x77, 0x22, 0xb3, 0x3f, 0xd2, 0x00, 0xc5, - 0x2d, 0xdf, 0x24, 0x74, 0xc0, 0xdf, 0x67, 0x7c, 0x10, 0x4f, 0x4c, 0xcd, 0xda, 0x93, 0x07, 0xf1, - 0x58, 0x3e, 0x1c, 0xc4, 0x13, 0x95, 0xf2, 0xf5, 0xb8, 0x3d, 0x66, 0x55, 0x1c, 0x15, 0x4c, 0x17, - 0x53, 0x92, 0x18, 0xe6, 0x9d, 0x50, 0x7a, 0xaa, 0x1f, 0x66, 0x8c, 0x3f, 0x6a, 0xb0, 0x31, 0x95, - 0x51, 0xd1, 0x61, 0x7f, 0x08, 0x28, 0x48, 0x6c, 0x0a, 0x7f, 0x8d, 0xd4, 0xa1, 0xe7, 0x4e, 0xd0, - 0xb5, 0x60, 0xaa, 0xef, 0x7e, 0x7a, 0x1d, 0x3e, 0x27, 0x7c, 0xfe, 0x3b, 0x0d, 0xd6, 0x93, 0xea, - 0x23, 0x43, 0x6e, 0xc3, 0x52, 0x52, 0xbb, 0x32, 0xe1, 0xd5, 0x67, 0x31, 0x41, 0x9d, 0xfe, 0x82, - 0x3c, 0xfa, 0x6e, 0x5c, 0xae, 0xf2, 0xdb, 0xd9, 0x8d, 0x67, 0xf6, 0x46, 0x78, 0xa6, 0x74, 0xd9, - 0xe6, 0x44, 0x3c, 0xfe, 0xab, 0x41, 0xee, 0xc0, 0xf7, 0xfb, 0xc8, 0x87, 0x35, 0xcf, 0x67, 0x1d, - 0x9e, 0x59, 0xc4, 0xee, 0xa8, 0x47, 0xb7, 0xec, 0x83, 0xbb, 0xf3, 0x39, 0xe9, 0x9f, 0x63, 0x7d, - 0x1a, 0xca, 0x2c, 0x7b, 0x3e, 0x6b, 0x0a, 0xca, 0x91, 0x7c, 0x92, 0xbf, 0x07, 0xcb, 0x17, 0x95, - 0xc9, 0x2e, 0xf9, 0xbd, 0xb9, 0x95, 0x5d, 0x84, 0x99, 0x8c, 0xf5, 0xf5, 0xb8, 0x62, 0x22, 0xb2, - 0x61, 0x2e, 0x75, 0x13, 0xda, 0x77, 0x0a, 0x3c, 0x7e, 0xff, 0x7a, 0xa0, 0x6b, 0x5f, 0xfe, 0xad, - 0x06, 0x10, 0x7f, 0x79, 0x40, 0xaf, 0xc3, 0xcb, 0xcd, 0xef, 0xdc, 0x6e, 0x75, 0x0e, 0x8f, 0x6e, - 0x1e, 0xdd, 0x39, 0xec, 0xdc, 0xb9, 0x7d, 0x78, 0xb0, 0xb7, 0xdb, 0xbe, 0xd5, 0xde, 0x6b, 0xad, - 0x66, 0xaa, 0xe5, 0x7b, 0xf7, 0xeb, 0xa5, 0x3b, 0x1e, 0x1d, 0x10, 0xcb, 0x39, 0x71, 0x88, 0x8d, - 0x5e, 0x83, 0xf5, 0x8b, 0xdc, 0x7c, 0xb5, 0xd7, 0x5a, 0xd5, 0xaa, 0x4b, 0xf7, 0xee, 0xd7, 0x0b, - 0x72, 0x16, 0x23, 0x36, 0xda, 0x84, 0xab, 0xd3, 0x7c, 0xed, 0xdb, 0xdf, 0x5a, 0xcd, 0x56, 0x97, - 0xef, 0xdd, 0xaf, 0x17, 0xa3, 0xa1, 0x0d, 0x19, 0x80, 0x92, 0x9c, 0x0a, 0x6f, 0xa1, 0x0a, 0xf7, - 0xee, 0xd7, 0xf3, 0xd2, 0x81, 0xd5, 0xdc, 0xfb, 0x1f, 0xd5, 0x32, 0xcd, 0x5b, 0x9f, 0x3c, 0xaa, - 0x69, 0x0f, 0x1f, 0xd5, 0xb4, 0xbf, 0x3f, 0xaa, 0x69, 0x1f, 0x3c, 0xae, 0x65, 0x1e, 0x3e, 0xae, - 0x65, 0xfe, 0xfc, 0xb8, 0x96, 0xf9, 0xfe, 0xeb, 0x4f, 0xf4, 0xdd, 0x79, 0xf4, 0x51, 0x5b, 0x78, - 0xb1, 0x9b, 0x17, 0x6d, 0xf8, 0xcd, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x48, 0x4c, 0x86, - 0xf3, 0x16, 0x00, 0x00, -} - -func (this *Pool) Description() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) { - return StakingDescription() -} -func StakingDescription() (desc *github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet) { - d := &github_com_gogo_protobuf_protoc_gen_gogo_descriptor.FileDescriptorSet{} - var gzipped = []byte{ - // 9603 bytes of a gzipped FileDescriptorSet - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x7d, 0x6d, 0x70, 0x24, 0xd7, - 0x71, 0xd8, 0xcd, 0xee, 0x02, 0xd8, 0x6d, 0x2c, 0x80, 0xc5, 0x03, 0xee, 0x6e, 0x6f, 0x79, 0x04, - 0xc0, 0xe1, 0xd7, 0xf1, 0x48, 0x02, 0xe4, 0x91, 0x77, 0x24, 0xf7, 0x24, 0xd2, 0x58, 0x60, 0x0f, - 0x07, 0x1e, 0xbe, 0x38, 0x00, 0x8e, 0xd4, 0x87, 0xb3, 0x35, 0x98, 0x7d, 0x58, 0x0c, 0xb1, 0x3b, - 0x33, 0x9c, 0x99, 0xbd, 0x3b, 0x50, 0x52, 0x15, 0x2d, 0x29, 0x8a, 0x44, 0xc7, 0x91, 0x14, 0xb9, - 0x1c, 0x89, 0xd6, 0x29, 0x92, 0xe5, 0x44, 0x8e, 0xac, 0xc4, 0x1f, 0x52, 0x94, 0x38, 0x49, 0x55, - 0xa4, 0x24, 0x8e, 0x25, 0xa5, 0xe2, 0x92, 0x2a, 0xae, 0xc4, 0x71, 0x25, 0x67, 0x87, 0x52, 0x39, - 0x8c, 0xa2, 0xc4, 0xf2, 0x59, 0x4e, 0x9c, 0x52, 0xa5, 0x92, 0x7a, 0x5f, 0xf3, 0xb5, 0x1f, 0xb3, - 0x0b, 0xdd, 0x49, 0x72, 0x9c, 0x5f, 0xd8, 0xd7, 0xaf, 0xbb, 0x5f, 0xbf, 0x7e, 0xfd, 0xba, 0xfb, - 0x7d, 0x0d, 0xe0, 0x9f, 0x9f, 0x87, 0x99, 0x9a, 0x69, 0xd6, 0xea, 0x78, 0xce, 0xb2, 0x4d, 0xd7, - 0xdc, 0x69, 0xee, 0xce, 0x55, 0xb1, 0xa3, 0xd9, 0xba, 0xe5, 0x9a, 0xf6, 0x2c, 0x85, 0xa1, 0x31, - 0x86, 0x31, 0x2b, 0x30, 0xe4, 0x55, 0x18, 0xbf, 0xa0, 0xd7, 0xf1, 0xa2, 0x87, 0xb8, 0x89, 0x5d, - 0xf4, 0x24, 0xa4, 0x76, 0xf5, 0x3a, 0xce, 0x4b, 0x33, 0xc9, 0x53, 0xc3, 0x67, 0xee, 0x99, 0x8d, - 0x10, 0xcd, 0x86, 0x29, 0x36, 0x08, 0x58, 0xa1, 0x14, 0xf2, 0xb7, 0x52, 0x30, 0xd1, 0xa6, 0x16, - 0x21, 0x48, 0x19, 0x6a, 0x83, 0x70, 0x94, 0x4e, 0x65, 0x14, 0xfa, 0x1b, 0xe5, 0x61, 0xc8, 0x52, - 0xb5, 0x7d, 0xb5, 0x86, 0xf3, 0x09, 0x0a, 0x16, 0x45, 0x34, 0x05, 0x50, 0xc5, 0x16, 0x36, 0xaa, - 0xd8, 0xd0, 0x0e, 0xf2, 0xc9, 0x99, 0xe4, 0xa9, 0x8c, 0x12, 0x80, 0xa0, 0x07, 0x61, 0xdc, 0x6a, - 0xee, 0xd4, 0x75, 0xad, 0x12, 0x40, 0x83, 0x99, 0xe4, 0xa9, 0x01, 0x25, 0xc7, 0x2a, 0x16, 0x7d, - 0xe4, 0xfb, 0x61, 0xec, 0x2a, 0x56, 0xf7, 0x83, 0xa8, 0xc3, 0x14, 0x75, 0x94, 0x80, 0x03, 0x88, - 0x0b, 0x90, 0x6d, 0x60, 0xc7, 0x51, 0x6b, 0xb8, 0xe2, 0x1e, 0x58, 0x38, 0x9f, 0xa2, 0xbd, 0x9f, - 0x69, 0xe9, 0x7d, 0xb4, 0xe7, 0xc3, 0x9c, 0x6a, 0xeb, 0xc0, 0xc2, 0x68, 0x1e, 0x32, 0xd8, 0x68, - 0x36, 0x18, 0x87, 0x81, 0x0e, 0xfa, 0x2b, 0x1b, 0xcd, 0x46, 0x94, 0x4b, 0x9a, 0x90, 0x71, 0x16, - 0x43, 0x0e, 0xb6, 0xaf, 0xe8, 0x1a, 0xce, 0x0f, 0x52, 0x06, 0xf7, 0xb7, 0x30, 0xd8, 0x64, 0xf5, - 0x51, 0x1e, 0x82, 0x0e, 0x2d, 0x40, 0x06, 0x5f, 0x73, 0xb1, 0xe1, 0xe8, 0xa6, 0x91, 0x1f, 0xa2, - 0x4c, 0xee, 0x6d, 0x33, 0x8a, 0xb8, 0x5e, 0x8d, 0xb2, 0xf0, 0xe9, 0xd0, 0x39, 0x18, 0x32, 0x2d, - 0x57, 0x37, 0x0d, 0x27, 0x9f, 0x9e, 0x91, 0x4e, 0x0d, 0x9f, 0x39, 0xd9, 0xd6, 0x10, 0xd6, 0x19, - 0x8e, 0x22, 0x90, 0xd1, 0x32, 0xe4, 0x1c, 0xb3, 0x69, 0x6b, 0xb8, 0xa2, 0x99, 0x55, 0x5c, 0xd1, - 0x8d, 0x5d, 0x33, 0x9f, 0xa1, 0x0c, 0xa6, 0x5b, 0x3b, 0x42, 0x11, 0x17, 0xcc, 0x2a, 0x5e, 0x36, - 0x76, 0x4d, 0x65, 0xd4, 0x09, 0x95, 0xd1, 0x31, 0x18, 0x74, 0x0e, 0x0c, 0x57, 0xbd, 0x96, 0xcf, - 0x52, 0x0b, 0xe1, 0x25, 0xf9, 0x37, 0x06, 0x61, 0xac, 0x17, 0x13, 0x3b, 0x0f, 0x03, 0xbb, 0xa4, - 0x97, 0xf9, 0x44, 0x3f, 0x3a, 0x60, 0x34, 0x61, 0x25, 0x0e, 0x1e, 0x52, 0x89, 0xf3, 0x30, 0x6c, - 0x60, 0xc7, 0xc5, 0x55, 0x66, 0x11, 0xc9, 0x1e, 0x6d, 0x0a, 0x18, 0x51, 0xab, 0x49, 0xa5, 0x0e, - 0x65, 0x52, 0x2f, 0xc0, 0x98, 0x27, 0x52, 0xc5, 0x56, 0x8d, 0x9a, 0xb0, 0xcd, 0xb9, 0x38, 0x49, - 0x66, 0xcb, 0x82, 0x4e, 0x21, 0x64, 0xca, 0x28, 0x0e, 0x95, 0xd1, 0x22, 0x80, 0x69, 0x60, 0x73, - 0xb7, 0x52, 0xc5, 0x5a, 0x3d, 0x9f, 0xee, 0xa0, 0xa5, 0x75, 0x82, 0xd2, 0xa2, 0x25, 0x93, 0x41, - 0xb5, 0x3a, 0x7a, 0xca, 0x37, 0xb5, 0xa1, 0x0e, 0x96, 0xb2, 0xca, 0x26, 0x59, 0x8b, 0xb5, 0x6d, - 0xc3, 0xa8, 0x8d, 0x89, 0xdd, 0xe3, 0x2a, 0xef, 0x59, 0x86, 0x0a, 0x31, 0x1b, 0xdb, 0x33, 0x85, - 0x93, 0xb1, 0x8e, 0x8d, 0xd8, 0xc1, 0x22, 0xba, 0x1b, 0x3c, 0x40, 0x85, 0x9a, 0x15, 0x50, 0x2f, - 0x94, 0x15, 0xc0, 0x35, 0xb5, 0x81, 0x0b, 0x2f, 0xc3, 0x68, 0x58, 0x3d, 0x68, 0x12, 0x06, 0x1c, - 0x57, 0xb5, 0x5d, 0x6a, 0x85, 0x03, 0x0a, 0x2b, 0xa0, 0x1c, 0x24, 0xb1, 0x51, 0xa5, 0x5e, 0x6e, - 0x40, 0x21, 0x3f, 0xd1, 0x4f, 0xf8, 0x1d, 0x4e, 0xd2, 0x0e, 0xdf, 0xd7, 0x3a, 0xa2, 0x21, 0xce, - 0xd1, 0x7e, 0x17, 0x9e, 0x80, 0x91, 0x50, 0x07, 0x7a, 0x6d, 0x5a, 0x7e, 0x27, 0x1c, 0x6d, 0xcb, - 0x1a, 0xbd, 0x00, 0x93, 0x4d, 0x43, 0x37, 0x5c, 0x6c, 0x5b, 0x36, 0x26, 0x16, 0xcb, 0x9a, 0xca, - 0xff, 0xe7, 0xa1, 0x0e, 0x36, 0xb7, 0x1d, 0xc4, 0x66, 0x5c, 0x94, 0x89, 0x66, 0x2b, 0xf0, 0x74, - 0x26, 0xfd, 0xc6, 0x50, 0xee, 0x95, 0x57, 0x5e, 0x79, 0x25, 0x21, 0x7f, 0x79, 0x10, 0x26, 0xdb, - 0xcd, 0x99, 0xb6, 0xd3, 0xf7, 0x18, 0x0c, 0x1a, 0xcd, 0xc6, 0x0e, 0xb6, 0xa9, 0x92, 0x06, 0x14, - 0x5e, 0x42, 0xf3, 0x30, 0x50, 0x57, 0x77, 0x70, 0x3d, 0x9f, 0x9a, 0x91, 0x4e, 0x8d, 0x9e, 0x79, - 0xb0, 0xa7, 0x59, 0x39, 0xbb, 0x42, 0x48, 0x14, 0x46, 0x89, 0x9e, 0x86, 0x14, 0x77, 0xd1, 0x84, - 0xc3, 0xe9, 0xde, 0x38, 0x90, 0xb9, 0xa4, 0x50, 0x3a, 0x74, 0x07, 0x64, 0xc8, 0x5f, 0x66, 0x1b, - 0x83, 0x54, 0xe6, 0x34, 0x01, 0x10, 0xbb, 0x40, 0x05, 0x48, 0xd3, 0x69, 0x52, 0xc5, 0x22, 0xb4, - 0x79, 0x65, 0x62, 0x58, 0x55, 0xbc, 0xab, 0x36, 0xeb, 0x6e, 0xe5, 0x8a, 0x5a, 0x6f, 0x62, 0x6a, - 0xf0, 0x19, 0x25, 0xcb, 0x81, 0x97, 0x09, 0x0c, 0x4d, 0xc3, 0x30, 0x9b, 0x55, 0xba, 0x51, 0xc5, - 0xd7, 0xa8, 0xf7, 0x1c, 0x50, 0xd8, 0x44, 0x5b, 0x26, 0x10, 0xd2, 0xfc, 0x8b, 0x8e, 0x69, 0x08, - 0xd3, 0xa4, 0x4d, 0x10, 0x00, 0x6d, 0xfe, 0x89, 0xa8, 0xe3, 0xbe, 0xb3, 0x7d, 0xf7, 0x5a, 0xe6, - 0xd2, 0xfd, 0x30, 0x46, 0x31, 0x1e, 0xe3, 0x43, 0xaf, 0xd6, 0xf3, 0xe3, 0x33, 0xd2, 0xa9, 0xb4, - 0x32, 0xca, 0xc0, 0xeb, 0x1c, 0x2a, 0x7f, 0x31, 0x01, 0x29, 0xea, 0x58, 0xc6, 0x60, 0x78, 0xeb, - 0x2d, 0x1b, 0xe5, 0xca, 0xe2, 0xfa, 0x76, 0x69, 0xa5, 0x9c, 0x93, 0xd0, 0x28, 0x00, 0x05, 0x5c, - 0x58, 0x59, 0x9f, 0xdf, 0xca, 0x25, 0xbc, 0xf2, 0xf2, 0xda, 0xd6, 0xb9, 0xc7, 0x73, 0x49, 0x8f, - 0x60, 0x9b, 0x01, 0x52, 0x41, 0x84, 0xc7, 0xce, 0xe4, 0x06, 0x50, 0x0e, 0xb2, 0x8c, 0xc1, 0xf2, - 0x0b, 0xe5, 0xc5, 0x73, 0x8f, 0xe7, 0x06, 0xc3, 0x90, 0xc7, 0xce, 0xe4, 0x86, 0xd0, 0x08, 0x64, - 0x28, 0xa4, 0xb4, 0xbe, 0xbe, 0x92, 0x4b, 0x7b, 0x3c, 0x37, 0xb7, 0x94, 0xe5, 0xb5, 0xa5, 0x5c, - 0xc6, 0xe3, 0xb9, 0xa4, 0xac, 0x6f, 0x6f, 0xe4, 0xc0, 0xe3, 0xb0, 0x5a, 0xde, 0xdc, 0x9c, 0x5f, - 0x2a, 0xe7, 0x86, 0x3d, 0x8c, 0xd2, 0x5b, 0xb6, 0xca, 0x9b, 0xb9, 0x6c, 0x48, 0xac, 0xc7, 0xce, - 0xe4, 0x46, 0xbc, 0x26, 0xca, 0x6b, 0xdb, 0xab, 0xb9, 0x51, 0x34, 0x0e, 0x23, 0xac, 0x09, 0x21, - 0xc4, 0x58, 0x04, 0x74, 0xee, 0xf1, 0x5c, 0xce, 0x17, 0x84, 0x71, 0x19, 0x0f, 0x01, 0xce, 0x3d, - 0x9e, 0x43, 0xf2, 0x02, 0x0c, 0x50, 0x33, 0x44, 0x08, 0x46, 0x57, 0xe6, 0x4b, 0xe5, 0x95, 0xca, - 0xfa, 0xc6, 0xd6, 0xf2, 0xfa, 0xda, 0xfc, 0x4a, 0x4e, 0xf2, 0x61, 0x4a, 0xf9, 0xb9, 0xed, 0x65, - 0xa5, 0xbc, 0x98, 0x4b, 0x04, 0x61, 0x1b, 0xe5, 0xf9, 0xad, 0xf2, 0x62, 0x2e, 0x29, 0x6b, 0x30, - 0xd9, 0xce, 0xa1, 0xb6, 0x9d, 0x42, 0x01, 0x5b, 0x48, 0x74, 0xb0, 0x05, 0xca, 0x2b, 0x6a, 0x0b, - 0xf2, 0x37, 0x13, 0x30, 0xd1, 0x26, 0xa8, 0xb4, 0x6d, 0xe4, 0x19, 0x18, 0x60, 0xb6, 0xcc, 0xc2, - 0xec, 0x03, 0x6d, 0xa3, 0x13, 0xb5, 0xec, 0x96, 0x50, 0x4b, 0xe9, 0x82, 0xa9, 0x46, 0xb2, 0x43, - 0xaa, 0x41, 0x58, 0xb4, 0x18, 0xec, 0x4f, 0xb6, 0x38, 0x7f, 0x16, 0x1f, 0xcf, 0xf5, 0x12, 0x1f, - 0x29, 0xac, 0xbf, 0x20, 0x30, 0xd0, 0x26, 0x08, 0x9c, 0x87, 0xf1, 0x16, 0x46, 0x3d, 0x3b, 0xe3, - 0xf7, 0x48, 0x90, 0xef, 0xa4, 0x9c, 0x18, 0x97, 0x98, 0x08, 0xb9, 0xc4, 0xf3, 0x51, 0x0d, 0xde, - 0xd5, 0x79, 0x10, 0x5a, 0xc6, 0xfa, 0x33, 0x12, 0x1c, 0x6b, 0x9f, 0x52, 0xb6, 0x95, 0xe1, 0x69, - 0x18, 0x6c, 0x60, 0x77, 0xcf, 0x14, 0x69, 0xd5, 0x7d, 0x6d, 0x82, 0x35, 0xa9, 0x8e, 0x0e, 0x36, - 0xa7, 0x0a, 0x46, 0xfb, 0x64, 0xa7, 0xbc, 0x90, 0x49, 0xd3, 0x22, 0xe9, 0x07, 0x12, 0x70, 0xb4, - 0x2d, 0xf3, 0xb6, 0x82, 0xde, 0x09, 0xa0, 0x1b, 0x56, 0xd3, 0x65, 0xa9, 0x13, 0xf3, 0xc4, 0x19, - 0x0a, 0xa1, 0xce, 0x8b, 0x78, 0xd9, 0xa6, 0xeb, 0xd5, 0x27, 0x69, 0x3d, 0x30, 0x10, 0x45, 0x78, - 0xd2, 0x17, 0x34, 0x45, 0x05, 0x9d, 0xea, 0xd0, 0xd3, 0x16, 0xc3, 0x7c, 0x04, 0x72, 0x5a, 0x5d, - 0xc7, 0x86, 0x5b, 0x71, 0x5c, 0x1b, 0xab, 0x0d, 0xdd, 0xa8, 0xd1, 0x50, 0x93, 0x2e, 0x0e, 0xec, - 0xaa, 0x75, 0x07, 0x2b, 0x63, 0xac, 0x7a, 0x53, 0xd4, 0x12, 0x0a, 0x6a, 0x40, 0x76, 0x80, 0x62, - 0x30, 0x44, 0xc1, 0xaa, 0x3d, 0x0a, 0xf9, 0xc3, 0x19, 0x18, 0x0e, 0x24, 0xe0, 0xe8, 0x2e, 0xc8, - 0xbe, 0xa8, 0x5e, 0x51, 0x2b, 0x62, 0x51, 0xc5, 0x34, 0x31, 0x4c, 0x60, 0x1b, 0x7c, 0x61, 0xf5, - 0x08, 0x4c, 0x52, 0x14, 0xb3, 0xe9, 0x62, 0xbb, 0xa2, 0xd5, 0x55, 0xc7, 0xa1, 0x4a, 0x4b, 0x53, - 0x54, 0x44, 0xea, 0xd6, 0x49, 0xd5, 0x82, 0xa8, 0x41, 0x67, 0x61, 0x82, 0x52, 0x34, 0x9a, 0x75, - 0x57, 0xb7, 0xea, 0xb8, 0x42, 0x96, 0x79, 0x0e, 0x0d, 0x39, 0x9e, 0x64, 0xe3, 0x04, 0x63, 0x95, - 0x23, 0x10, 0x89, 0x1c, 0xb4, 0x08, 0x77, 0x52, 0xb2, 0x1a, 0x36, 0xb0, 0xad, 0xba, 0xb8, 0x82, - 0x5f, 0x6a, 0xaa, 0x75, 0xa7, 0xa2, 0x1a, 0xd5, 0xca, 0x9e, 0xea, 0xec, 0xe5, 0x27, 0x09, 0x83, - 0x52, 0x22, 0x2f, 0x29, 0x27, 0x08, 0xe2, 0x12, 0xc7, 0x2b, 0x53, 0xb4, 0x79, 0xa3, 0x7a, 0x51, - 0x75, 0xf6, 0x50, 0x11, 0x8e, 0x51, 0x2e, 0x8e, 0x6b, 0xeb, 0x46, 0xad, 0xa2, 0xed, 0x61, 0x6d, - 0xbf, 0xd2, 0x74, 0x77, 0x9f, 0xcc, 0xdf, 0x11, 0x6c, 0x9f, 0x4a, 0xb8, 0x49, 0x71, 0x16, 0x08, - 0xca, 0xb6, 0xbb, 0xfb, 0x24, 0xda, 0x84, 0x2c, 0x19, 0x8c, 0x86, 0xfe, 0x32, 0xae, 0xec, 0x9a, - 0x36, 0x8d, 0xa1, 0xa3, 0x6d, 0x5c, 0x53, 0x40, 0x83, 0xb3, 0xeb, 0x9c, 0x60, 0xd5, 0xac, 0xe2, - 0xe2, 0xc0, 0xe6, 0x46, 0xb9, 0xbc, 0xa8, 0x0c, 0x0b, 0x2e, 0x17, 0x4c, 0x9b, 0x18, 0x54, 0xcd, - 0xf4, 0x14, 0x3c, 0xcc, 0x0c, 0xaa, 0x66, 0x0a, 0xf5, 0x9e, 0x85, 0x09, 0x4d, 0x63, 0x7d, 0xd6, - 0xb5, 0x0a, 0x5f, 0x8c, 0x39, 0xf9, 0x5c, 0x48, 0x59, 0x9a, 0xb6, 0xc4, 0x10, 0xb8, 0x8d, 0x3b, - 0xe8, 0x29, 0x38, 0xea, 0x2b, 0x2b, 0x48, 0x38, 0xde, 0xd2, 0xcb, 0x28, 0xe9, 0x59, 0x98, 0xb0, - 0x0e, 0x5a, 0x09, 0x51, 0xa8, 0x45, 0xeb, 0x20, 0x4a, 0xf6, 0x04, 0x4c, 0x5a, 0x7b, 0x56, 0x2b, - 0xdd, 0xe9, 0x20, 0x1d, 0xb2, 0xf6, 0xac, 0x28, 0xe1, 0xbd, 0x74, 0x65, 0x6e, 0x63, 0x4d, 0x75, - 0x71, 0x35, 0x7f, 0x3c, 0x88, 0x1e, 0xa8, 0x40, 0xb3, 0x90, 0xd3, 0xb4, 0x0a, 0x36, 0xd4, 0x9d, - 0x3a, 0xae, 0xa8, 0x36, 0x36, 0x54, 0x27, 0x3f, 0x4d, 0x91, 0x53, 0xae, 0xdd, 0xc4, 0xca, 0xa8, - 0xa6, 0x95, 0x69, 0xe5, 0x3c, 0xad, 0x43, 0xa7, 0x61, 0xdc, 0xdc, 0x79, 0x51, 0x63, 0x16, 0x59, - 0xb1, 0x6c, 0xbc, 0xab, 0x5f, 0xcb, 0xdf, 0x43, 0xd5, 0x3b, 0x46, 0x2a, 0xa8, 0x3d, 0x6e, 0x50, - 0x30, 0x7a, 0x00, 0x72, 0x9a, 0xb3, 0xa7, 0xda, 0x16, 0x75, 0xc9, 0x8e, 0xa5, 0x6a, 0x38, 0x7f, - 0x2f, 0x43, 0x65, 0xf0, 0x35, 0x01, 0x26, 0x33, 0xc2, 0xb9, 0xaa, 0xef, 0xba, 0x82, 0xe3, 0xfd, - 0x6c, 0x46, 0x50, 0x18, 0xe7, 0x76, 0x0a, 0x72, 0x44, 0x13, 0xa1, 0x86, 0x4f, 0x51, 0xb4, 0x51, - 0x6b, 0xcf, 0x0a, 0xb6, 0x7b, 0x37, 0x8c, 0x10, 0x4c, 0xbf, 0xd1, 0x07, 0x58, 0xe2, 0x66, 0xed, - 0x05, 0x5a, 0x7c, 0x1c, 0x8e, 0x11, 0xa4, 0x06, 0x76, 0xd5, 0xaa, 0xea, 0xaa, 0x01, 0xec, 0x87, - 0x28, 0x36, 0x51, 0xfb, 0x2a, 0xaf, 0x0c, 0xc9, 0x69, 0x37, 0x77, 0x0e, 0x3c, 0xc3, 0x7a, 0x98, - 0xc9, 0x49, 0x60, 0xc2, 0xb4, 0x6e, 0x5b, 0x72, 0x2e, 0x17, 0x21, 0x1b, 0xb4, 0x7b, 0x94, 0x01, - 0x66, 0xf9, 0x39, 0x89, 0x24, 0x41, 0x0b, 0xeb, 0x8b, 0x24, 0x7d, 0x79, 0x6b, 0x39, 0x97, 0x20, - 0x69, 0xd4, 0xca, 0xf2, 0x56, 0xb9, 0xa2, 0x6c, 0xaf, 0x6d, 0x2d, 0xaf, 0x96, 0x73, 0xc9, 0x40, - 0x62, 0xff, 0x6c, 0x2a, 0x7d, 0x5f, 0xee, 0x7e, 0xf9, 0x1b, 0x09, 0x18, 0x0d, 0xaf, 0xd4, 0xd0, - 0x9b, 0xe0, 0xb8, 0xd8, 0x56, 0x71, 0xb0, 0x5b, 0xb9, 0xaa, 0xdb, 0x74, 0x42, 0x36, 0x54, 0x16, - 0x1c, 0x3d, 0xfb, 0x99, 0xe4, 0x58, 0x9b, 0xd8, 0x7d, 0x5e, 0xb7, 0xc9, 0x74, 0x6b, 0xa8, 0x2e, - 0x5a, 0x81, 0x69, 0xc3, 0xac, 0x38, 0xae, 0x6a, 0x54, 0x55, 0xbb, 0x5a, 0xf1, 0x37, 0xb4, 0x2a, - 0xaa, 0xa6, 0x61, 0xc7, 0x31, 0x59, 0x20, 0xf4, 0xb8, 0x9c, 0x34, 0xcc, 0x4d, 0x8e, 0xec, 0x47, - 0x88, 0x79, 0x8e, 0x1a, 0x31, 0xdf, 0x64, 0x27, 0xf3, 0xbd, 0x03, 0x32, 0x0d, 0xd5, 0xaa, 0x60, - 0xc3, 0xb5, 0x0f, 0x68, 0x7e, 0x9e, 0x56, 0xd2, 0x0d, 0xd5, 0x2a, 0x93, 0xf2, 0x0f, 0x65, 0x99, - 0xf4, 0x6c, 0x2a, 0x9d, 0xce, 0x65, 0x9e, 0x4d, 0xa5, 0x33, 0x39, 0x90, 0x5f, 0x4f, 0x42, 0x36, - 0x98, 0xaf, 0x93, 0xe5, 0x8f, 0x46, 0x23, 0x96, 0x44, 0x7d, 0xda, 0xdd, 0x5d, 0xb3, 0xfb, 0xd9, - 0x05, 0x12, 0xca, 0x8a, 0x83, 0x2c, 0x39, 0x56, 0x18, 0x25, 0x49, 0x23, 0x88, 0xb1, 0x61, 0x96, - 0x8c, 0xa4, 0x15, 0x5e, 0x42, 0x4b, 0x30, 0xf8, 0xa2, 0x43, 0x79, 0x0f, 0x52, 0xde, 0xf7, 0x74, - 0xe7, 0xfd, 0xec, 0x26, 0x65, 0x9e, 0x79, 0x76, 0xb3, 0xb2, 0xb6, 0xae, 0xac, 0xce, 0xaf, 0x28, - 0x9c, 0x1c, 0x9d, 0x80, 0x54, 0x5d, 0x7d, 0xf9, 0x20, 0x1c, 0xf4, 0x28, 0xa8, 0xd7, 0x41, 0x38, - 0x01, 0xa9, 0xab, 0x58, 0xdd, 0x0f, 0x87, 0x1a, 0x0a, 0xba, 0x8d, 0x93, 0x61, 0x0e, 0x06, 0xa8, - 0xbe, 0x10, 0x00, 0xd7, 0x58, 0xee, 0x08, 0x4a, 0x43, 0x6a, 0x61, 0x5d, 0x21, 0x13, 0x22, 0x07, - 0x59, 0x06, 0xad, 0x6c, 0x2c, 0x97, 0x17, 0xca, 0xb9, 0x84, 0x7c, 0x16, 0x06, 0x99, 0x12, 0xc8, - 0x64, 0xf1, 0xd4, 0x90, 0x3b, 0xc2, 0x8b, 0x9c, 0x87, 0x24, 0x6a, 0xb7, 0x57, 0x4b, 0x65, 0x25, - 0x97, 0x08, 0x0f, 0x75, 0x2a, 0x37, 0x20, 0x3b, 0x90, 0x0d, 0xe6, 0xe1, 0x3f, 0x9c, 0xc5, 0xf8, - 0x97, 0x24, 0x18, 0x0e, 0xe4, 0xd5, 0x24, 0x21, 0x52, 0xeb, 0x75, 0xf3, 0x6a, 0x45, 0xad, 0xeb, - 0xaa, 0xc3, 0x4d, 0x03, 0x28, 0x68, 0x9e, 0x40, 0x7a, 0x1d, 0xba, 0x1f, 0xd2, 0x14, 0x19, 0xc8, - 0x0d, 0xca, 0x9f, 0x90, 0x20, 0x17, 0x4d, 0x6c, 0x23, 0x62, 0x4a, 0x3f, 0x4a, 0x31, 0xe5, 0x8f, - 0x4b, 0x30, 0x1a, 0xce, 0x66, 0x23, 0xe2, 0xdd, 0xf5, 0x23, 0x15, 0xef, 0x0f, 0x12, 0x30, 0x12, - 0xca, 0x61, 0x7b, 0x95, 0xee, 0x25, 0x18, 0xd7, 0xab, 0xb8, 0x61, 0x99, 0x2e, 0x36, 0xb4, 0x83, - 0x4a, 0x1d, 0x5f, 0xc1, 0xf5, 0xbc, 0x4c, 0x9d, 0xc6, 0x5c, 0xf7, 0x2c, 0x79, 0x76, 0xd9, 0xa7, - 0x5b, 0x21, 0x64, 0xc5, 0x89, 0xe5, 0xc5, 0xf2, 0xea, 0xc6, 0xfa, 0x56, 0x79, 0x6d, 0xe1, 0x2d, - 0x95, 0xed, 0xb5, 0x4b, 0x6b, 0xeb, 0xcf, 0xaf, 0x29, 0x39, 0x3d, 0x82, 0x76, 0x1b, 0xa7, 0xfd, - 0x06, 0xe4, 0xa2, 0x42, 0xa1, 0xe3, 0xd0, 0x4e, 0xac, 0xdc, 0x11, 0x34, 0x01, 0x63, 0x6b, 0xeb, - 0x95, 0xcd, 0xe5, 0xc5, 0x72, 0xa5, 0x7c, 0xe1, 0x42, 0x79, 0x61, 0x6b, 0x93, 0xed, 0x7b, 0x78, - 0xd8, 0x5b, 0xa1, 0x09, 0x2e, 0xbf, 0x96, 0x84, 0x89, 0x36, 0x92, 0xa0, 0x79, 0xbe, 0x62, 0x61, - 0x8b, 0xa8, 0x87, 0x7b, 0x91, 0x7e, 0x96, 0xe4, 0x0c, 0x1b, 0xaa, 0xed, 0xf2, 0x05, 0xce, 0x03, - 0x40, 0xb4, 0x64, 0xb8, 0xfa, 0xae, 0x8e, 0x6d, 0xbe, 0x9f, 0xc4, 0x96, 0x31, 0x63, 0x3e, 0x9c, - 0x6d, 0x29, 0x3d, 0x04, 0xc8, 0x32, 0x1d, 0xdd, 0xd5, 0xaf, 0xe0, 0x8a, 0x6e, 0x88, 0xcd, 0x27, - 0xb2, 0xac, 0x49, 0x29, 0x39, 0x51, 0xb3, 0x6c, 0xb8, 0x1e, 0xb6, 0x81, 0x6b, 0x6a, 0x04, 0x9b, - 0x38, 0xf3, 0xa4, 0x92, 0x13, 0x35, 0x1e, 0xf6, 0x5d, 0x90, 0xad, 0x9a, 0x4d, 0x92, 0xeb, 0x31, - 0x3c, 0x12, 0x3b, 0x24, 0x65, 0x98, 0xc1, 0x3c, 0x14, 0x9e, 0xc5, 0xfb, 0xbb, 0x5e, 0x59, 0x65, - 0x98, 0xc1, 0x18, 0xca, 0xfd, 0x30, 0xa6, 0xd6, 0x6a, 0x36, 0x61, 0x2e, 0x18, 0xb1, 0x75, 0xc9, - 0xa8, 0x07, 0xa6, 0x88, 0x85, 0x67, 0x21, 0x2d, 0xf4, 0x40, 0x42, 0x35, 0xd1, 0x44, 0xc5, 0x62, - 0x8b, 0xed, 0xc4, 0xa9, 0x8c, 0x92, 0x36, 0x44, 0xe5, 0x5d, 0x90, 0xd5, 0x9d, 0x8a, 0xbf, 0x89, - 0x9f, 0x98, 0x49, 0x9c, 0x4a, 0x2b, 0xc3, 0xba, 0xe3, 0x6d, 0x80, 0xca, 0x9f, 0x49, 0xc0, 0x68, - 0xf8, 0x10, 0x02, 0x2d, 0x42, 0xba, 0x6e, 0x6a, 0x2a, 0x35, 0x2d, 0x76, 0x02, 0x76, 0x2a, 0xe6, - 0xdc, 0x62, 0x76, 0x85, 0xe3, 0x2b, 0x1e, 0x65, 0xe1, 0xb7, 0x25, 0x48, 0x0b, 0x30, 0x3a, 0x06, - 0x29, 0x4b, 0x75, 0xf7, 0x28, 0xbb, 0x81, 0x52, 0x22, 0x27, 0x29, 0xb4, 0x4c, 0xe0, 0x8e, 0xa5, - 0x1a, 0xd4, 0x04, 0x38, 0x9c, 0x94, 0xc9, 0xb8, 0xd6, 0xb1, 0x5a, 0xa5, 0x8b, 0x1e, 0xb3, 0xd1, - 0xc0, 0x86, 0xeb, 0x88, 0x71, 0xe5, 0xf0, 0x05, 0x0e, 0x46, 0x0f, 0xc2, 0xb8, 0x6b, 0xab, 0x7a, - 0x3d, 0x84, 0x9b, 0xa2, 0xb8, 0x39, 0x51, 0xe1, 0x21, 0x17, 0xe1, 0x84, 0xe0, 0x5b, 0xc5, 0xae, - 0xaa, 0xed, 0xe1, 0xaa, 0x4f, 0x34, 0x48, 0x37, 0x37, 0x8e, 0x73, 0x84, 0x45, 0x5e, 0x2f, 0x68, - 0xe5, 0x6f, 0x48, 0x30, 0x2e, 0x96, 0x69, 0x55, 0x4f, 0x59, 0xab, 0x00, 0xaa, 0x61, 0x98, 0x6e, - 0x50, 0x5d, 0xad, 0xa6, 0xdc, 0x42, 0x37, 0x3b, 0xef, 0x11, 0x29, 0x01, 0x06, 0x85, 0x06, 0x80, - 0x5f, 0xd3, 0x51, 0x6d, 0xd3, 0x30, 0xcc, 0x4f, 0x98, 0xe8, 0x31, 0x25, 0x5b, 0xd8, 0x03, 0x03, - 0x91, 0xf5, 0x1c, 0x9a, 0x84, 0x81, 0x1d, 0x5c, 0xd3, 0x0d, 0xbe, 0x6f, 0xcc, 0x0a, 0x62, 0xfb, - 0x25, 0xe5, 0x6d, 0xbf, 0x94, 0x3e, 0x28, 0xc1, 0x84, 0x66, 0x36, 0xa2, 0xf2, 0x96, 0x72, 0x91, - 0xdd, 0x05, 0xe7, 0xa2, 0xf4, 0xd6, 0xa7, 0x6b, 0xba, 0xbb, 0xd7, 0xdc, 0x99, 0xd5, 0xcc, 0xc6, - 0x5c, 0xcd, 0xac, 0xab, 0x46, 0xcd, 0x3f, 0x67, 0xa5, 0x3f, 0xb4, 0x87, 0x6b, 0xd8, 0x78, 0xb8, - 0x66, 0x06, 0x4e, 0x5d, 0xcf, 0xfb, 0x3f, 0xff, 0x4c, 0x92, 0x7e, 0x21, 0x91, 0x5c, 0xda, 0x28, - 0x7d, 0x36, 0x51, 0x58, 0x62, 0xcd, 0x6d, 0x08, 0xf5, 0x28, 0x78, 0xb7, 0x8e, 0x35, 0xd2, 0x65, - 0xf8, 0xf6, 0x83, 0x30, 0x59, 0x33, 0x6b, 0x26, 0xe5, 0x38, 0x47, 0x7e, 0xf1, 0x93, 0xdb, 0x8c, - 0x07, 0x2d, 0xc4, 0x1e, 0xf3, 0x16, 0xd7, 0x60, 0x82, 0x23, 0x57, 0xe8, 0xd1, 0x11, 0x5b, 0xd8, - 0xa0, 0xae, 0xbb, 0x6a, 0xf9, 0x5f, 0xfb, 0x16, 0x0d, 0xe8, 0xca, 0x38, 0x27, 0x25, 0x75, 0x6c, - 0xed, 0x53, 0x54, 0xe0, 0x68, 0x88, 0x1f, 0x9b, 0xb6, 0xd8, 0x8e, 0xe1, 0xf8, 0x9b, 0x9c, 0xe3, - 0x44, 0x80, 0xe3, 0x26, 0x27, 0x2d, 0x2e, 0xc0, 0x48, 0x3f, 0xbc, 0xfe, 0x25, 0xe7, 0x95, 0xc5, - 0x41, 0x26, 0x4b, 0x30, 0x46, 0x99, 0x68, 0x4d, 0xc7, 0x35, 0x1b, 0xd4, 0x27, 0x76, 0x67, 0xf3, - 0x5b, 0xdf, 0x62, 0xf3, 0x68, 0x94, 0x90, 0x2d, 0x78, 0x54, 0xc5, 0x22, 0xd0, 0xd3, 0xb2, 0x2a, - 0xd6, 0xea, 0x31, 0x1c, 0xbe, 0xc2, 0x05, 0xf1, 0xf0, 0x8b, 0x97, 0x61, 0x92, 0xfc, 0xa6, 0x2e, - 0x2b, 0x28, 0x49, 0xfc, 0x16, 0x5c, 0xfe, 0x1b, 0xef, 0x61, 0x53, 0x75, 0xc2, 0x63, 0x10, 0x90, - 0x29, 0x30, 0x8a, 0x35, 0xec, 0xba, 0xd8, 0x76, 0x2a, 0x6a, 0xbd, 0x9d, 0x78, 0x81, 0x3d, 0x8c, - 0xfc, 0xc7, 0xbe, 0x13, 0x1e, 0xc5, 0x25, 0x46, 0x39, 0x5f, 0xaf, 0x17, 0xb7, 0xe1, 0x78, 0x1b, - 0xab, 0xe8, 0x81, 0xe7, 0x6b, 0x9c, 0xe7, 0x64, 0x8b, 0x65, 0x10, 0xb6, 0x1b, 0x20, 0xe0, 0xde, - 0x58, 0xf6, 0xc0, 0xf3, 0xe7, 0x39, 0x4f, 0xc4, 0x69, 0xc5, 0x90, 0x12, 0x8e, 0xcf, 0xc2, 0xf8, - 0x15, 0x6c, 0xef, 0x98, 0x0e, 0xdf, 0x37, 0xea, 0x81, 0xdd, 0xc7, 0x39, 0xbb, 0x31, 0x4e, 0x48, - 0x37, 0x92, 0x08, 0xaf, 0xa7, 0x20, 0xbd, 0xab, 0x6a, 0xb8, 0x07, 0x16, 0xd7, 0x39, 0x8b, 0x21, - 0x82, 0x4f, 0x48, 0xe7, 0x21, 0x5b, 0x33, 0x79, 0xd4, 0x8a, 0x27, 0xff, 0x04, 0x27, 0x1f, 0x16, - 0x34, 0x9c, 0x85, 0x65, 0x5a, 0xcd, 0x3a, 0x09, 0x69, 0xf1, 0x2c, 0xfe, 0xa6, 0x60, 0x21, 0x68, - 0x38, 0x8b, 0x3e, 0xd4, 0xfa, 0x49, 0xc1, 0xc2, 0x09, 0xe8, 0xf3, 0x19, 0x18, 0x36, 0x8d, 0xfa, - 0x81, 0x69, 0xf4, 0x22, 0xc4, 0xa7, 0x38, 0x07, 0xe0, 0x24, 0x84, 0xc1, 0x79, 0xc8, 0xf4, 0x3a, - 0x10, 0x7f, 0xeb, 0x3b, 0x62, 0x7a, 0x88, 0x11, 0x58, 0x82, 0x31, 0xe1, 0xa0, 0x74, 0xd3, 0xe8, - 0x81, 0xc5, 0xdf, 0xe6, 0x2c, 0x46, 0x03, 0x64, 0xbc, 0x1b, 0x2e, 0x76, 0xdc, 0x1a, 0xee, 0x85, - 0xc9, 0x67, 0x44, 0x37, 0x38, 0x09, 0x57, 0xe5, 0x0e, 0x36, 0xb4, 0xbd, 0xde, 0x38, 0xfc, 0x92, - 0x50, 0xa5, 0xa0, 0x21, 0x2c, 0x16, 0x60, 0xa4, 0xa1, 0xda, 0xce, 0x9e, 0x5a, 0xef, 0x69, 0x38, - 0xfe, 0x0e, 0xe7, 0x91, 0xf5, 0x88, 0xb8, 0x46, 0x9a, 0x46, 0x3f, 0x6c, 0x3e, 0x2b, 0x34, 0x12, - 0x20, 0xe3, 0x53, 0xcf, 0x71, 0xe9, 0x26, 0x5b, 0x3f, 0xdc, 0x7e, 0x59, 0x4c, 0x3d, 0x46, 0xbb, - 0x1a, 0xe4, 0x78, 0x1e, 0x32, 0x8e, 0xfe, 0x72, 0x4f, 0x6c, 0x3e, 0x27, 0x46, 0x9a, 0x12, 0x10, - 0xe2, 0xb7, 0xc0, 0x89, 0xb6, 0x61, 0xa2, 0x07, 0x66, 0x7f, 0x97, 0x33, 0x3b, 0xd6, 0x26, 0x54, - 0x70, 0x97, 0xd0, 0x2f, 0xcb, 0xbf, 0x27, 0x5c, 0x02, 0x8e, 0xf0, 0xda, 0x20, 0xeb, 0x08, 0x47, - 0xdd, 0xed, 0x4f, 0x6b, 0xbf, 0x22, 0xb4, 0xc6, 0x68, 0x43, 0x5a, 0xdb, 0x82, 0x63, 0x9c, 0x63, - 0x7f, 0xe3, 0xfa, 0xab, 0xc2, 0xb1, 0x32, 0xea, 0xed, 0xf0, 0xe8, 0xbe, 0x0d, 0x0a, 0x9e, 0x3a, - 0x45, 0xc2, 0xea, 0x54, 0x1a, 0xaa, 0xd5, 0x03, 0xe7, 0x5f, 0xe3, 0x9c, 0x85, 0xc7, 0xf7, 0x32, - 0x5e, 0x67, 0x55, 0xb5, 0x08, 0xf3, 0x17, 0x20, 0x2f, 0x98, 0x37, 0x0d, 0x1b, 0x6b, 0x66, 0xcd, - 0xd0, 0x5f, 0xc6, 0xd5, 0x1e, 0x58, 0xff, 0x7a, 0x64, 0xa8, 0xb6, 0x03, 0xe4, 0x84, 0xf3, 0x32, - 0xe4, 0xbc, 0x5c, 0xa5, 0xa2, 0x37, 0x2c, 0xd3, 0x76, 0x63, 0x38, 0x7e, 0x5e, 0x8c, 0x94, 0x47, - 0xb7, 0x4c, 0xc9, 0x8a, 0x65, 0x60, 0x27, 0xcf, 0xbd, 0x9a, 0xe4, 0x17, 0x38, 0xa3, 0x11, 0x9f, - 0x8a, 0x3b, 0x0e, 0xcd, 0x6c, 0x58, 0xaa, 0xdd, 0x8b, 0xff, 0xfb, 0xfb, 0xc2, 0x71, 0x70, 0x12, - 0xee, 0x38, 0xdc, 0x03, 0x0b, 0x93, 0x68, 0xdf, 0x03, 0x87, 0x2f, 0x0a, 0xc7, 0x21, 0x68, 0x38, - 0x0b, 0x91, 0x30, 0xf4, 0xc0, 0xe2, 0x1f, 0x08, 0x16, 0x82, 0x86, 0xb0, 0x78, 0xce, 0x0f, 0xb4, - 0x36, 0xae, 0xe9, 0x8e, 0x6b, 0xb3, 0x34, 0xb9, 0x3b, 0xab, 0x7f, 0xf8, 0x9d, 0x70, 0x12, 0xa6, - 0x04, 0x48, 0x89, 0x27, 0xe2, 0xdb, 0xae, 0x74, 0x15, 0x15, 0x2f, 0xd8, 0x6f, 0x08, 0x4f, 0x14, - 0x20, 0x23, 0xb2, 0x05, 0x32, 0x44, 0xa2, 0x76, 0x8d, 0xac, 0x1d, 0x7a, 0x60, 0xf7, 0x8f, 0x22, - 0xc2, 0x6d, 0x0a, 0x5a, 0xc2, 0x33, 0x90, 0xff, 0x34, 0x8d, 0x7d, 0x7c, 0xd0, 0x93, 0x75, 0xfe, - 0xe3, 0x48, 0xfe, 0xb3, 0xcd, 0x28, 0x99, 0x0f, 0x19, 0x8b, 0xe4, 0x53, 0x28, 0xee, 0x9e, 0x51, - 0xfe, 0xa7, 0xbe, 0xc7, 0xfb, 0x1b, 0x4e, 0xa7, 0x8a, 0x2b, 0xc4, 0xc8, 0xc3, 0x49, 0x4f, 0x3c, - 0xb3, 0xf7, 0x7c, 0xcf, 0xb3, 0xf3, 0x50, 0xce, 0x53, 0xbc, 0x00, 0x23, 0xa1, 0x84, 0x27, 0x9e, - 0xd5, 0x7b, 0x39, 0xab, 0x6c, 0x30, 0xdf, 0x29, 0x9e, 0x85, 0x14, 0x49, 0x5e, 0xe2, 0xc9, 0xff, - 0x32, 0x27, 0xa7, 0xe8, 0xc5, 0x37, 0x43, 0x5a, 0x24, 0x2d, 0xf1, 0xa4, 0xef, 0xe3, 0xa4, 0x1e, - 0x09, 0x21, 0x17, 0x09, 0x4b, 0x3c, 0xf9, 0x5f, 0x11, 0xe4, 0x82, 0x84, 0x90, 0xf7, 0xae, 0xc2, - 0x2f, 0xfd, 0x74, 0x8a, 0x07, 0x1d, 0xa1, 0xbb, 0xf3, 0x30, 0xc4, 0x33, 0x95, 0x78, 0xea, 0x0f, - 0xf0, 0xc6, 0x05, 0x45, 0xf1, 0x09, 0x18, 0xe8, 0x51, 0xe1, 0x3f, 0xc3, 0x49, 0x19, 0x7e, 0x71, - 0x01, 0x86, 0x03, 0xd9, 0x49, 0x3c, 0xf9, 0x5f, 0xe3, 0xe4, 0x41, 0x2a, 0x22, 0x3a, 0xcf, 0x4e, - 0xe2, 0x19, 0x7c, 0x50, 0x88, 0xce, 0x29, 0x88, 0xda, 0x44, 0x62, 0x12, 0x4f, 0xfd, 0x21, 0xa1, - 0x75, 0x41, 0x52, 0x7c, 0x06, 0x32, 0x5e, 0xb0, 0x89, 0xa7, 0xff, 0x30, 0xa7, 0xf7, 0x69, 0x88, - 0x06, 0x02, 0xc1, 0x2e, 0x9e, 0xc5, 0x5f, 0x17, 0x1a, 0x08, 0x50, 0x91, 0x69, 0x14, 0x4d, 0x60, - 0xe2, 0x39, 0x7d, 0x44, 0x4c, 0xa3, 0x48, 0xfe, 0x42, 0x46, 0x93, 0xfa, 0xfc, 0x78, 0x16, 0x3f, - 0x2b, 0x46, 0x93, 0xe2, 0x13, 0x31, 0xa2, 0x19, 0x41, 0x3c, 0x8f, 0xbf, 0x21, 0xc4, 0x88, 0x24, - 0x04, 0xc5, 0x0d, 0x40, 0xad, 0xd9, 0x40, 0x3c, 0xbf, 0x8f, 0x72, 0x7e, 0xe3, 0x2d, 0xc9, 0x40, - 0xf1, 0x79, 0x38, 0xd6, 0x3e, 0x13, 0x88, 0xe7, 0xfa, 0xb1, 0xef, 0x45, 0xd6, 0x6e, 0xc1, 0x44, - 0xa0, 0xb8, 0xe5, 0x87, 0x94, 0x60, 0x16, 0x10, 0xcf, 0xf6, 0xb5, 0xef, 0x85, 0x1d, 0x77, 0x30, - 0x09, 0x28, 0xce, 0x03, 0xf8, 0x01, 0x38, 0x9e, 0xd7, 0xc7, 0x39, 0xaf, 0x00, 0x11, 0x99, 0x1a, - 0x3c, 0xfe, 0xc6, 0xd3, 0x5f, 0x17, 0x53, 0x83, 0x53, 0x90, 0xa9, 0x21, 0x42, 0x6f, 0x3c, 0xf5, - 0x27, 0xc4, 0xd4, 0x10, 0x24, 0xc4, 0xb2, 0x03, 0xd1, 0x2d, 0x9e, 0xc3, 0xa7, 0x84, 0x65, 0x07, - 0xa8, 0x8a, 0x6b, 0x30, 0xde, 0x12, 0x10, 0xe3, 0x59, 0xfd, 0x02, 0x67, 0x95, 0x8b, 0xc6, 0xc3, - 0x60, 0xf0, 0xe2, 0xc1, 0x30, 0x9e, 0xdb, 0xa7, 0x23, 0xc1, 0x8b, 0xc7, 0xc2, 0xe2, 0x79, 0x48, - 0x1b, 0xcd, 0x7a, 0x9d, 0x4c, 0x1e, 0xd4, 0xfd, 0x6e, 0x60, 0xfe, 0xbf, 0x7c, 0x9f, 0x6b, 0x47, - 0x10, 0x14, 0xcf, 0xc2, 0x00, 0x6e, 0xec, 0xe0, 0x6a, 0x1c, 0xe5, 0xb7, 0xbf, 0x2f, 0x1c, 0x26, - 0xc1, 0x2e, 0x3e, 0x03, 0xc0, 0xb6, 0x46, 0xe8, 0xf1, 0x60, 0x0c, 0xed, 0x7f, 0xfd, 0x3e, 0xbf, - 0x8c, 0xe3, 0x93, 0xf8, 0x0c, 0xd8, 0xd5, 0x9e, 0xee, 0x0c, 0xbe, 0x13, 0x66, 0x40, 0x47, 0xe4, - 0x29, 0x18, 0x7a, 0xd1, 0x31, 0x0d, 0x57, 0xad, 0xc5, 0x51, 0xff, 0x37, 0x4e, 0x2d, 0xf0, 0x89, - 0xc2, 0x1a, 0xa6, 0x8d, 0x5d, 0xb5, 0xe6, 0xc4, 0xd1, 0xfe, 0x77, 0x4e, 0xeb, 0x11, 0x10, 0x62, - 0x4d, 0x75, 0xdc, 0x5e, 0xfa, 0xfd, 0x47, 0x82, 0x58, 0x10, 0x10, 0xa1, 0xc9, 0xef, 0x7d, 0x7c, - 0x10, 0x47, 0xfb, 0x5d, 0x21, 0x34, 0xc7, 0x2f, 0xbe, 0x19, 0x32, 0xe4, 0x27, 0xbb, 0x61, 0x17, - 0x43, 0xfc, 0xc7, 0x9c, 0xd8, 0xa7, 0x20, 0x2d, 0x3b, 0x6e, 0xd5, 0xd5, 0xe3, 0x95, 0x7d, 0x93, - 0x8f, 0xb4, 0xc0, 0x2f, 0xce, 0xc3, 0xb0, 0xe3, 0x56, 0xab, 0x4d, 0x9e, 0x9f, 0xc6, 0x90, 0xff, - 0xc9, 0xf7, 0xbd, 0x2d, 0x0b, 0x8f, 0x86, 0x8c, 0xf6, 0xd5, 0x7d, 0xd7, 0x32, 0xe9, 0x11, 0x48, - 0x1c, 0x87, 0xef, 0x71, 0x0e, 0x01, 0x92, 0xe2, 0x02, 0x64, 0x49, 0x5f, 0x6c, 0x6c, 0x61, 0x7a, - 0x5e, 0x15, 0xc3, 0xe2, 0x4f, 0xb9, 0x02, 0x42, 0x44, 0xa5, 0x9f, 0xfc, 0xca, 0xeb, 0x53, 0xd2, - 0xd7, 0x5f, 0x9f, 0x92, 0xfe, 0xe0, 0xf5, 0x29, 0xe9, 0x43, 0xdf, 0x9c, 0x3a, 0xf2, 0xf5, 0x6f, - 0x4e, 0x1d, 0xf9, 0xdd, 0x6f, 0x4e, 0x1d, 0x69, 0xbf, 0x6d, 0x0c, 0x4b, 0xe6, 0x92, 0xc9, 0x36, - 0x8c, 0xdf, 0x2a, 0x87, 0xb6, 0x8b, 0x6b, 0xa6, 0xbf, 0x5b, 0xeb, 0x2d, 0x72, 0xe0, 0x4f, 0x25, - 0xb2, 0x60, 0x0e, 0xef, 0xe5, 0xaa, 0xc6, 0x41, 0x87, 0xb7, 0x3a, 0x85, 0xb6, 0x1b, 0xc3, 0xf2, - 0x9b, 0x20, 0x39, 0x6f, 0x1c, 0xa0, 0x13, 0xcc, 0xe7, 0x55, 0x9a, 0x76, 0x9d, 0xdf, 0xfc, 0x1a, - 0x22, 0xe5, 0x6d, 0xbb, 0x8e, 0x26, 0xfd, 0xeb, 0x99, 0xd2, 0xa9, 0x2c, 0xbf, 0x73, 0x59, 0x4c, - 0x7d, 0xf7, 0x53, 0xd3, 0x47, 0x4a, 0xfb, 0xd1, 0x1e, 0x7e, 0x29, 0xb6, 0x97, 0xe9, 0x79, 0xe3, - 0x80, 0x76, 0x72, 0x43, 0x7a, 0xeb, 0x00, 0x69, 0xc3, 0x11, 0x1b, 0xdb, 0x53, 0xd1, 0x8d, 0xed, - 0xe7, 0x71, 0xbd, 0x7e, 0xc9, 0x30, 0xaf, 0x1a, 0x5b, 0x04, 0x6d, 0x67, 0x90, 0x5d, 0x23, 0x86, - 0xbf, 0x9a, 0x80, 0xa9, 0x96, 0x3d, 0x6c, 0x3e, 0xf2, 0x9d, 0x1e, 0x2a, 0x15, 0x21, 0xbd, 0x28, - 0x0c, 0x2a, 0x0f, 0x43, 0x0e, 0xd6, 0x4c, 0xa3, 0xea, 0xd0, 0xae, 0x26, 0x15, 0x51, 0x24, 0x5d, - 0x35, 0x54, 0xc3, 0x74, 0xf8, 0xed, 0x48, 0x56, 0x28, 0xfd, 0xac, 0xd4, 0xdf, 0x38, 0x8e, 0x88, - 0x96, 0x44, 0x37, 0x4f, 0x77, 0xdb, 0xfb, 0xa7, 0x2a, 0xf0, 0xe4, 0x0f, 0xec, 0xf3, 0xf7, 0xaa, - 0x8e, 0x0f, 0x25, 0x60, 0x3a, 0xaa, 0x0e, 0x32, 0x8f, 0x1c, 0x57, 0x6d, 0x58, 0x9d, 0xf4, 0x71, - 0x1e, 0x32, 0x5b, 0x02, 0xa7, 0x6f, 0x85, 0xfc, 0x5c, 0x9f, 0x0a, 0x19, 0xf5, 0x9a, 0x12, 0x1a, - 0x79, 0x30, 0x5e, 0x23, 0x5e, 0x17, 0x0e, 0xa1, 0x92, 0x77, 0x27, 0xe1, 0x84, 0x66, 0x3a, 0x0d, - 0xd3, 0xa9, 0x30, 0x83, 0x67, 0x05, 0xae, 0x8c, 0x6c, 0xb0, 0xaa, 0x87, 0xe3, 0x90, 0x8b, 0x30, - 0x4a, 0x9d, 0x02, 0xdd, 0x08, 0xa6, 0x7e, 0x38, 0x36, 0x74, 0x7e, 0xf5, 0xdf, 0x0e, 0xd0, 0x49, - 0x34, 0xe2, 0x11, 0xd2, 0x9b, 0x2e, 0x5b, 0x30, 0xa9, 0x37, 0xac, 0x3a, 0xa6, 0x47, 0x62, 0x15, - 0xaf, 0x2e, 0x9e, 0xdf, 0xd7, 0x38, 0xbf, 0x09, 0x9f, 0x7c, 0x59, 0x50, 0x17, 0x57, 0x60, 0x5c, - 0xd5, 0x34, 0x6c, 0x85, 0x58, 0xc6, 0x38, 0x2c, 0x21, 0x60, 0x8e, 0x53, 0x7a, 0xdc, 0x4a, 0xcf, - 0x74, 0x1a, 0xdb, 0xb7, 0xde, 0x1b, 0x18, 0x34, 0x1b, 0xd7, 0xb0, 0xf1, 0xb0, 0x81, 0xdd, 0xab, - 0xa6, 0xbd, 0xcf, 0xd5, 0xfb, 0x30, 0x6b, 0x4a, 0x0c, 0xc2, 0x7b, 0x93, 0x30, 0xc5, 0x2a, 0xe6, - 0x76, 0x54, 0x07, 0xcf, 0x5d, 0x79, 0x74, 0x07, 0xbb, 0xea, 0xa3, 0x73, 0x9a, 0xa9, 0x8b, 0x69, - 0x3a, 0xc1, 0xc7, 0x85, 0xd4, 0xcf, 0xf2, 0xfa, 0x0e, 0x7e, 0x6a, 0x09, 0x52, 0x0b, 0xa6, 0x6e, - 0x10, 0x8b, 0xac, 0x62, 0xc3, 0x6c, 0x70, 0x2f, 0xc5, 0x0a, 0xe8, 0x6e, 0x18, 0x54, 0x1b, 0x66, - 0xd3, 0x70, 0xd9, 0x69, 0x5e, 0x69, 0xf8, 0x2b, 0x37, 0xa6, 0x8f, 0xfc, 0xde, 0x8d, 0xe9, 0xe4, - 0xb2, 0xe1, 0x2a, 0xbc, 0xaa, 0x98, 0x7a, 0xe3, 0x93, 0xd3, 0x92, 0xfc, 0x2c, 0x0c, 0x2d, 0x62, - 0xed, 0x30, 0xbc, 0x16, 0xb1, 0x16, 0xe1, 0xf5, 0x00, 0xa4, 0x97, 0x0d, 0x97, 0xdd, 0x20, 0xbe, - 0x13, 0x92, 0xba, 0xc1, 0x2e, 0xa5, 0x45, 0xda, 0x27, 0x70, 0x82, 0xba, 0x88, 0x35, 0x0f, 0xb5, - 0x8a, 0xb5, 0x28, 0x2a, 0x61, 0x4f, 0xe0, 0xa5, 0xc5, 0xdf, 0xfd, 0x4f, 0x53, 0x47, 0x5e, 0x79, - 0x7d, 0xea, 0x48, 0xc7, 0x91, 0x08, 0x46, 0x07, 0xae, 0x62, 0x3e, 0x04, 0x4e, 0x75, 0x7f, 0xce, - 0x0d, 0xcd, 0x85, 0xcf, 0xa6, 0xe0, 0x4e, 0xfa, 0x78, 0xc4, 0x6e, 0xe8, 0x86, 0x3b, 0xa7, 0xd9, - 0x07, 0x96, 0x4b, 0xc3, 0x89, 0xb9, 0xcb, 0x47, 0x61, 0xdc, 0xaf, 0x9e, 0x65, 0xd5, 0x1d, 0xc6, - 0x60, 0x17, 0x06, 0x36, 0x08, 0x1d, 0x51, 0x9c, 0x6b, 0xba, 0x6a, 0x9d, 0xbb, 0x0b, 0x56, 0x20, - 0x50, 0xf6, 0xe0, 0x24, 0xc1, 0xa0, 0xba, 0x78, 0x6b, 0x52, 0xc7, 0xea, 0x2e, 0xbb, 0xb7, 0x9b, - 0xa4, 0x21, 0x24, 0x4d, 0x00, 0xf4, 0x8a, 0xee, 0x24, 0x0c, 0xa8, 0x4d, 0x76, 0xe4, 0x9c, 0x24, - 0xb1, 0x85, 0x16, 0xe4, 0x4b, 0x30, 0xc4, 0x8f, 0xb9, 0x50, 0x0e, 0x92, 0xfb, 0xf8, 0x80, 0xb6, - 0x93, 0x55, 0xc8, 0x4f, 0x34, 0x0b, 0x03, 0x54, 0x78, 0xfe, 0x20, 0x21, 0x3f, 0xdb, 0x22, 0xfd, - 0x2c, 0x15, 0x52, 0x61, 0x68, 0xf2, 0xb3, 0x90, 0x5e, 0x34, 0x1b, 0xba, 0x61, 0x86, 0xb9, 0x65, - 0x18, 0x37, 0x2a, 0xb3, 0xd5, 0xe4, 0x63, 0xad, 0xb0, 0x02, 0x3a, 0x06, 0x83, 0xec, 0x1e, 0x37, - 0x3f, 0x36, 0xe7, 0x25, 0x79, 0x01, 0x86, 0x28, 0xef, 0x75, 0x0b, 0x21, 0xfe, 0x02, 0x88, 0x5f, - 0x18, 0xa7, 0x6e, 0x81, 0xb3, 0x4f, 0xf8, 0xc2, 0x22, 0x48, 0x55, 0x55, 0x57, 0xe5, 0xfd, 0xa6, - 0xbf, 0xe5, 0xa7, 0x21, 0xcd, 0x99, 0x38, 0xe8, 0x0c, 0x24, 0x4d, 0xcb, 0xe1, 0x07, 0xdf, 0x85, - 0x4e, 0x5d, 0x59, 0xb7, 0x4a, 0x29, 0x62, 0x25, 0x0a, 0x41, 0x2e, 0x29, 0x1d, 0xcd, 0xe2, 0xc9, - 0x80, 0x59, 0x04, 0x86, 0x3c, 0xf0, 0x93, 0x0d, 0x69, 0x8b, 0x39, 0x78, 0xc6, 0xf2, 0xa9, 0x04, - 0x4c, 0x05, 0x6a, 0xaf, 0x60, 0x9b, 0xac, 0xf5, 0x98, 0x45, 0x71, 0x6b, 0x41, 0x01, 0x21, 0x79, - 0x7d, 0x07, 0x73, 0x79, 0x33, 0x24, 0xe7, 0x2d, 0x0b, 0x15, 0x20, 0xcd, 0x0e, 0xb8, 0x4d, 0x66, - 0x2f, 0x29, 0xc5, 0x2b, 0x93, 0x3a, 0xc7, 0xdc, 0x75, 0xaf, 0xaa, 0xb6, 0xf7, 0xd4, 0x49, 0x94, - 0xe5, 0xa7, 0x20, 0xb3, 0x60, 0x1a, 0x0e, 0x36, 0x9c, 0x26, 0x0d, 0x44, 0x3b, 0x75, 0x53, 0xdb, - 0xe7, 0x1c, 0x58, 0x81, 0x28, 0x5c, 0xb5, 0x2c, 0x4a, 0x99, 0x52, 0xc8, 0x4f, 0x36, 0x2f, 0x4b, - 0x9b, 0x1d, 0x55, 0xf4, 0x54, 0xff, 0x2a, 0xe2, 0x9d, 0xf4, 0x74, 0xf4, 0xbf, 0x25, 0x38, 0xd9, - 0x3a, 0xa1, 0xf6, 0xf1, 0x81, 0xd3, 0xef, 0x7c, 0x7a, 0x01, 0x32, 0x1b, 0xf4, 0xbd, 0xf1, 0x25, - 0x7c, 0x80, 0x0a, 0x30, 0x84, 0xab, 0x67, 0xce, 0x9e, 0x7d, 0xf4, 0x29, 0x66, 0xed, 0x17, 0x8f, - 0x28, 0x02, 0x80, 0xa6, 0x20, 0xe3, 0x60, 0xcd, 0x3a, 0x73, 0xf6, 0xdc, 0xfe, 0xa3, 0xcc, 0xbc, - 0x2e, 0x1e, 0x51, 0x7c, 0x50, 0x31, 0x4d, 0x7a, 0xfd, 0xc6, 0xa7, 0xa6, 0xa5, 0xd2, 0x00, 0x24, - 0x9d, 0x66, 0xe3, 0xb6, 0xda, 0xc8, 0x6b, 0x03, 0x30, 0x13, 0xa4, 0xa4, 0xd1, 0xfa, 0x8a, 0x5a, - 0xd7, 0xab, 0xaa, 0xff, 0x52, 0x3c, 0x17, 0xd0, 0x01, 0xc5, 0x68, 0xaf, 0x82, 0x42, 0x57, 0x4d, - 0xca, 0xbf, 0x2e, 0x41, 0xf6, 0xb2, 0xe0, 0xbc, 0x89, 0x5d, 0x74, 0x1e, 0xc0, 0x6b, 0x49, 0x4c, - 0x9b, 0x3b, 0x66, 0xa3, 0x6d, 0xcd, 0x7a, 0x34, 0x4a, 0x00, 0x1d, 0x3d, 0x41, 0x0d, 0xd1, 0x32, - 0x1d, 0xfe, 0xfc, 0x25, 0x86, 0xd4, 0x43, 0x46, 0x0f, 0x01, 0xa2, 0x1e, 0xae, 0x72, 0xc5, 0x74, - 0x75, 0xa3, 0x56, 0xb1, 0xcc, 0xab, 0xfc, 0x51, 0x61, 0x52, 0xc9, 0xd1, 0x9a, 0xcb, 0xb4, 0x62, - 0x83, 0xc0, 0x89, 0xd0, 0x19, 0x8f, 0x0b, 0xc9, 0xad, 0xd4, 0x6a, 0xd5, 0xc6, 0x8e, 0xc3, 0x9d, - 0x98, 0x28, 0xa2, 0xf3, 0x30, 0x64, 0x35, 0x77, 0x2a, 0xc2, 0x63, 0x0c, 0x9f, 0x39, 0xd9, 0x6e, - 0xfe, 0x0b, 0xfb, 0xe0, 0x1e, 0x60, 0xd0, 0x6a, 0xee, 0x10, 0x6b, 0xb9, 0x0b, 0xb2, 0x6d, 0x84, - 0x19, 0xbe, 0xe2, 0xcb, 0x41, 0x9f, 0xb9, 0xf3, 0x1e, 0x54, 0x2c, 0x5b, 0x37, 0x6d, 0xdd, 0x3d, - 0xa0, 0xb7, 0x57, 0x92, 0x4a, 0x4e, 0x54, 0x6c, 0x70, 0xb8, 0xbc, 0x0f, 0x63, 0x9b, 0x34, 0xb7, - 0xf0, 0x25, 0x3f, 0xeb, 0xcb, 0x27, 0xc5, 0xcb, 0xd7, 0x51, 0xb2, 0x44, 0x8b, 0x64, 0xa5, 0xe7, - 0x3a, 0x5a, 0xe7, 0x13, 0xfd, 0x5b, 0x67, 0x38, 0xda, 0xfd, 0xd1, 0x89, 0xd0, 0xe4, 0xe4, 0xa9, - 0x64, 0xc0, 0x7d, 0xf5, 0x6a, 0x98, 0x71, 0x29, 0x75, 0xa1, 0x7b, 0x50, 0x2d, 0xc4, 0xb8, 0xd1, - 0x42, 0xec, 0x14, 0x92, 0x9f, 0x82, 0x91, 0x0d, 0xd5, 0x76, 0x37, 0xb1, 0x7b, 0x11, 0xab, 0x55, - 0x6c, 0x87, 0xa3, 0xee, 0x88, 0x88, 0xba, 0x08, 0x52, 0x34, 0xb4, 0xb2, 0xa8, 0x43, 0x7f, 0xcb, - 0x7b, 0x90, 0xa2, 0x37, 0xd8, 0xbc, 0x88, 0xcc, 0x29, 0x58, 0x44, 0x26, 0xbe, 0xf4, 0xc0, 0xc5, - 0x8e, 0x58, 0xd0, 0xd1, 0x02, 0x7a, 0x5c, 0xc4, 0xd5, 0x64, 0xf7, 0xb8, 0xca, 0x0d, 0x91, 0x47, - 0xd7, 0x3a, 0x0c, 0x95, 0x88, 0x2b, 0x5e, 0x5e, 0xf4, 0x04, 0x91, 0x7c, 0x41, 0xd0, 0x2a, 0x8c, - 0x59, 0xaa, 0xed, 0xd2, 0xab, 0xfb, 0x7b, 0xb4, 0x17, 0xdc, 0xd6, 0xa7, 0x5b, 0x67, 0x5e, 0xa8, - 0xb3, 0xbc, 0x95, 0x11, 0x2b, 0x08, 0x94, 0xff, 0x30, 0x05, 0x83, 0x5c, 0x19, 0x6f, 0x86, 0x21, - 0xae, 0x56, 0x6e, 0x9d, 0x77, 0xce, 0xb6, 0x06, 0xa6, 0x59, 0x2f, 0x80, 0x70, 0x7e, 0x82, 0x06, - 0xdd, 0x07, 0x69, 0x6d, 0x4f, 0xd5, 0x8d, 0x8a, 0x5e, 0x15, 0x69, 0xde, 0xeb, 0x37, 0xa6, 0x87, - 0x16, 0x08, 0x6c, 0x79, 0x51, 0x19, 0xa2, 0x95, 0xcb, 0x55, 0x92, 0x09, 0xec, 0x61, 0xbd, 0xb6, - 0xe7, 0xf2, 0x19, 0xc6, 0x4b, 0xe8, 0x49, 0x48, 0x11, 0x83, 0xe0, 0x0f, 0xbb, 0x0a, 0x2d, 0xc9, - 0xb6, 0xb7, 0xe2, 0x29, 0xa5, 0x49, 0xc3, 0x1f, 0xfa, 0xfd, 0x69, 0x49, 0xa1, 0x14, 0x68, 0x01, - 0x46, 0xea, 0xaa, 0xe3, 0x56, 0x68, 0x04, 0x23, 0xcd, 0x0f, 0x50, 0x16, 0x27, 0x5a, 0x15, 0xc2, - 0x15, 0xcb, 0x45, 0x1f, 0x26, 0x54, 0x0c, 0x54, 0x45, 0xa7, 0x20, 0x47, 0x99, 0x68, 0x66, 0xa3, - 0xa1, 0xbb, 0x2c, 0xb7, 0x1a, 0xa4, 0x7a, 0x1f, 0x25, 0xf0, 0x05, 0x0a, 0xa6, 0x19, 0xd6, 0x1d, - 0x90, 0xa1, 0x4f, 0x49, 0x28, 0x0a, 0xbb, 0x36, 0x99, 0x26, 0x00, 0x5a, 0x79, 0x3f, 0x8c, 0xf9, - 0xfe, 0x91, 0xa1, 0xa4, 0x19, 0x17, 0x1f, 0x4c, 0x11, 0x1f, 0x81, 0x49, 0x03, 0x5f, 0xa3, 0x17, - 0x39, 0x43, 0xd8, 0x19, 0x8a, 0x8d, 0x48, 0xdd, 0xe5, 0x30, 0xc5, 0xbd, 0x30, 0xaa, 0x09, 0xe5, - 0x33, 0x5c, 0xa0, 0xb8, 0x23, 0x1e, 0x94, 0xa2, 0x9d, 0x80, 0xb4, 0x6a, 0x59, 0x0c, 0x61, 0x98, - 0xfb, 0x47, 0xcb, 0xa2, 0x55, 0xa7, 0x61, 0x9c, 0xf6, 0xd1, 0xc6, 0x4e, 0xb3, 0xee, 0x72, 0x26, - 0x59, 0x8a, 0x33, 0x46, 0x2a, 0x14, 0x06, 0xa7, 0xb8, 0x77, 0xc3, 0x08, 0xbe, 0xa2, 0x57, 0xb1, - 0xa1, 0x61, 0x86, 0x37, 0x42, 0xf1, 0xb2, 0x02, 0x48, 0x91, 0x1e, 0x00, 0xcf, 0xef, 0x55, 0x84, - 0x4f, 0x1e, 0x65, 0xfc, 0x04, 0x7c, 0x9e, 0x81, 0xe5, 0x3c, 0xa4, 0x16, 0x55, 0x57, 0x25, 0x09, - 0x86, 0x7b, 0x8d, 0x05, 0x9a, 0xac, 0x42, 0x7e, 0xca, 0x6f, 0x24, 0x20, 0x75, 0xd9, 0x74, 0x31, - 0x7a, 0x2c, 0x90, 0x00, 0x8e, 0xb6, 0xb3, 0xe7, 0x4d, 0xbd, 0x66, 0xe0, 0xea, 0xaa, 0x53, 0x0b, - 0xbc, 0xfb, 0xf6, 0xcd, 0x29, 0x11, 0x32, 0xa7, 0x49, 0x18, 0xb0, 0xcd, 0xa6, 0x51, 0x15, 0x37, - 0x0e, 0x69, 0x01, 0x95, 0x21, 0xed, 0x59, 0x49, 0x2a, 0xce, 0x4a, 0xc6, 0x88, 0x95, 0x10, 0x1b, - 0xe6, 0x00, 0x65, 0x68, 0x87, 0x1b, 0x4b, 0x09, 0x32, 0x9e, 0xf3, 0xe2, 0xd6, 0xd6, 0x9b, 0xc1, - 0xfa, 0x64, 0x24, 0x98, 0x78, 0x63, 0xef, 0x29, 0x8f, 0x59, 0x5c, 0xce, 0xab, 0xe0, 0xda, 0x0b, - 0x99, 0x15, 0x7f, 0x83, 0x3e, 0x44, 0xfb, 0xe5, 0x9b, 0x15, 0x7b, 0x87, 0x7e, 0x12, 0x32, 0x8e, - 0x5e, 0x33, 0x54, 0xb7, 0x69, 0x63, 0x6e, 0x79, 0x3e, 0x40, 0xfe, 0x92, 0x04, 0x83, 0xcc, 0x92, - 0x03, 0x7a, 0x93, 0xda, 0xeb, 0x2d, 0xd1, 0x49, 0x6f, 0xc9, 0xc3, 0xeb, 0x6d, 0x1e, 0xc0, 0x13, - 0xc6, 0xe1, 0x4f, 0x83, 0xdb, 0x64, 0x0c, 0x4c, 0xc4, 0x4d, 0xbd, 0xc6, 0x27, 0x6a, 0x80, 0x48, - 0xfe, 0x8f, 0x12, 0x49, 0x62, 0x79, 0x3d, 0x9a, 0x87, 0x11, 0x21, 0x57, 0x65, 0xb7, 0xae, 0xd6, - 0xb8, 0xed, 0xdc, 0xd9, 0x51, 0xb8, 0x0b, 0x75, 0xb5, 0xa6, 0x0c, 0x73, 0x79, 0x48, 0xa1, 0xfd, - 0x38, 0x24, 0x3a, 0x8c, 0x43, 0x68, 0xe0, 0x93, 0x87, 0x1b, 0xf8, 0xd0, 0x10, 0xa5, 0xa2, 0x43, - 0xf4, 0xf9, 0x04, 0x5d, 0xcc, 0x58, 0xa6, 0xa3, 0xd6, 0x7f, 0x18, 0x33, 0xe2, 0x0e, 0xc8, 0x58, - 0x66, 0xbd, 0xc2, 0x6a, 0xd8, 0x4d, 0xdc, 0xb4, 0x65, 0xd6, 0x95, 0x96, 0x61, 0x1f, 0xb8, 0x45, - 0xd3, 0x65, 0xf0, 0x16, 0x68, 0x6d, 0x28, 0xaa, 0x35, 0x1b, 0xb2, 0x4c, 0x15, 0x3c, 0x96, 0x3d, - 0x42, 0x74, 0x40, 0x83, 0xa3, 0xd4, 0x1a, 0x7b, 0x99, 0xd8, 0x0c, 0x53, 0xe1, 0x78, 0x84, 0x82, - 0xb9, 0xfe, 0x76, 0xab, 0xe0, 0xa0, 0x59, 0x2a, 0x1c, 0x4f, 0xfe, 0x39, 0x09, 0x60, 0x85, 0x68, - 0x96, 0xf6, 0x97, 0x44, 0x21, 0x87, 0x8a, 0x50, 0x09, 0xb5, 0x3c, 0xd5, 0x69, 0xd0, 0x78, 0xfb, - 0x59, 0x27, 0x28, 0xf7, 0x02, 0x8c, 0xf8, 0xc6, 0xe8, 0x60, 0x21, 0xcc, 0x54, 0x97, 0xac, 0x7a, - 0x13, 0xbb, 0x4a, 0xf6, 0x4a, 0xa0, 0x24, 0xff, 0x33, 0x09, 0x32, 0x54, 0xa6, 0x55, 0xec, 0xaa, - 0xa1, 0x31, 0x94, 0x0e, 0x3f, 0x86, 0x77, 0x02, 0x30, 0x36, 0x8e, 0xfe, 0x32, 0xe6, 0x96, 0x95, - 0xa1, 0x90, 0x4d, 0xfd, 0x65, 0x8c, 0xce, 0x79, 0x0a, 0x4f, 0x76, 0x57, 0xb8, 0xc8, 0xba, 0xb9, - 0xda, 0x8f, 0xc3, 0x10, 0xfd, 0x94, 0xce, 0x35, 0x87, 0x27, 0xd2, 0x83, 0x46, 0xb3, 0xb1, 0x75, - 0xcd, 0x91, 0x5f, 0x84, 0xa1, 0xad, 0x6b, 0x6c, 0x6f, 0xe4, 0x0e, 0xc8, 0xd8, 0xa6, 0xc9, 0x63, - 0x32, 0xcb, 0x85, 0xd2, 0x04, 0x40, 0x43, 0x90, 0xd8, 0x0f, 0x48, 0xf8, 0xfb, 0x01, 0xfe, 0x86, - 0x46, 0xb2, 0xa7, 0x0d, 0x8d, 0xd3, 0xff, 0x4e, 0x82, 0xe1, 0x80, 0x7f, 0x40, 0x8f, 0xc2, 0xd1, - 0xd2, 0xca, 0xfa, 0xc2, 0xa5, 0xca, 0xf2, 0x62, 0xe5, 0xc2, 0xca, 0xfc, 0x92, 0xff, 0xd6, 0xa4, - 0x70, 0xec, 0xd5, 0xeb, 0x33, 0x28, 0x80, 0xbb, 0x6d, 0xec, 0x1b, 0xe6, 0x55, 0x03, 0xcd, 0xc1, - 0x64, 0x98, 0x64, 0xbe, 0xb4, 0x59, 0x5e, 0xdb, 0xca, 0x49, 0x85, 0xa3, 0xaf, 0x5e, 0x9f, 0x19, - 0x0f, 0x50, 0xcc, 0xef, 0x38, 0xd8, 0x70, 0x5b, 0x09, 0x16, 0xd6, 0x57, 0x57, 0x97, 0xb7, 0x72, - 0x89, 0x16, 0x02, 0xee, 0xb0, 0x1f, 0x80, 0xf1, 0x30, 0xc1, 0xda, 0xf2, 0x4a, 0x2e, 0x59, 0x40, - 0xaf, 0x5e, 0x9f, 0x19, 0x0d, 0x60, 0xaf, 0xe9, 0xf5, 0x42, 0xfa, 0xfd, 0x9f, 0x9e, 0x3a, 0xf2, - 0x4b, 0xbf, 0x38, 0x25, 0x91, 0x9e, 0x8d, 0x84, 0x7c, 0x04, 0x7a, 0x08, 0x8e, 0x6f, 0x2e, 0x2f, - 0xad, 0x95, 0x17, 0x2b, 0xab, 0x9b, 0x4b, 0x15, 0xf6, 0x8d, 0x0d, 0xaf, 0x77, 0x63, 0xaf, 0x5e, - 0x9f, 0x19, 0xe6, 0x5d, 0xea, 0x84, 0xbd, 0xa1, 0x94, 0x2f, 0xaf, 0x6f, 0x95, 0x73, 0x12, 0xc3, - 0xde, 0xb0, 0xf1, 0x15, 0xd3, 0x65, 0xdf, 0xda, 0x7a, 0x04, 0x4e, 0xb4, 0xc1, 0xf6, 0x3a, 0x36, - 0xfe, 0xea, 0xf5, 0x99, 0x91, 0x0d, 0x1b, 0xb3, 0xf9, 0x43, 0x29, 0x66, 0x21, 0xdf, 0x4a, 0xb1, - 0xbe, 0xb1, 0xbe, 0x39, 0xbf, 0x92, 0x9b, 0x29, 0xe4, 0x5e, 0xbd, 0x3e, 0x93, 0x15, 0xce, 0x90, - 0xe0, 0xfb, 0x3d, 0xbb, 0x9d, 0x2b, 0x9e, 0x3f, 0x79, 0x18, 0xee, 0xe1, 0x7b, 0x80, 0x8e, 0xab, - 0xee, 0xeb, 0x46, 0xcd, 0xdb, 0x69, 0xe5, 0x65, 0xbe, 0xf2, 0x39, 0xc6, 0x37, 0x5b, 0x05, 0xb4, - 0xeb, 0x7e, 0x6b, 0xa1, 0xf3, 0xc9, 0x52, 0x21, 0xe6, 0xf0, 0x25, 0x7e, 0xe9, 0xd4, 0x79, 0x6f, - 0xbe, 0x10, 0xb3, 0x63, 0x5c, 0xe8, 0xba, 0xb8, 0x93, 0x3f, 0x20, 0xc1, 0xe8, 0x45, 0xdd, 0x71, - 0x4d, 0x5b, 0xd7, 0xd4, 0x3a, 0x7d, 0x61, 0x72, 0xae, 0x57, 0xdf, 0x1a, 0x99, 0xea, 0xcf, 0xc0, - 0xe0, 0x15, 0xb5, 0xce, 0x9c, 0x5a, 0x92, 0x7e, 0x10, 0xa3, 0xbd, 0xfa, 0x7c, 0xd7, 0x26, 0x18, - 0x30, 0x32, 0xf9, 0x57, 0x12, 0x30, 0x46, 0x27, 0x83, 0xc3, 0x3e, 0x95, 0x44, 0xd6, 0x58, 0x25, - 0x48, 0xd9, 0xaa, 0xcb, 0x37, 0x0d, 0x4b, 0xb3, 0x7c, 0xe7, 0xf7, 0xbe, 0xf8, 0xdd, 0xdc, 0xd9, - 0x45, 0xac, 0x29, 0x94, 0x16, 0xbd, 0x1d, 0xd2, 0x0d, 0xf5, 0x5a, 0x85, 0xf2, 0x61, 0x2b, 0x97, - 0xf9, 0xfe, 0xf8, 0xdc, 0xbc, 0x31, 0x3d, 0x76, 0xa0, 0x36, 0xea, 0x45, 0x59, 0xf0, 0x91, 0x95, - 0xa1, 0x86, 0x7a, 0x8d, 0x88, 0x88, 0x2c, 0x18, 0x23, 0x50, 0x6d, 0x4f, 0x35, 0x6a, 0x98, 0x35, - 0x42, 0xb7, 0x40, 0x4b, 0x17, 0xfb, 0x6e, 0xe4, 0x98, 0xdf, 0x48, 0x80, 0x9d, 0xac, 0x8c, 0x34, - 0xd4, 0x6b, 0x0b, 0x14, 0x40, 0x5a, 0x2c, 0xa6, 0x3f, 0xfa, 0xc9, 0xe9, 0x23, 0x74, 0x37, 0xfd, - 0x1b, 0x12, 0x80, 0xaf, 0x31, 0xf4, 0x76, 0xc8, 0x69, 0x5e, 0x89, 0xd2, 0x3a, 0x7c, 0x0c, 0xef, - 0xef, 0x34, 0x16, 0x11, 0x7d, 0xb3, 0xd8, 0xfc, 0xf5, 0x1b, 0xd3, 0x92, 0x32, 0xa6, 0x45, 0x86, - 0xe2, 0x6d, 0x30, 0xdc, 0xb4, 0xaa, 0xaa, 0x8b, 0x2b, 0x74, 0x1d, 0x97, 0x88, 0x8d, 0xf3, 0x53, - 0x84, 0xd7, 0xcd, 0x1b, 0xd3, 0x88, 0x75, 0x2b, 0x40, 0x2c, 0xd3, 0xe8, 0x0f, 0x0c, 0x42, 0x08, - 0x02, 0x7d, 0xfa, 0xaa, 0x04, 0xc3, 0x8b, 0x81, 0x9b, 0x5e, 0x79, 0x18, 0x6a, 0x98, 0x86, 0xbe, - 0xcf, 0xed, 0x31, 0xa3, 0x88, 0x22, 0x2a, 0x40, 0x9a, 0x3d, 0xba, 0x73, 0x0f, 0xc4, 0x56, 0xa8, - 0x28, 0x13, 0xaa, 0xab, 0x78, 0xc7, 0xd1, 0xc5, 0x68, 0x28, 0xa2, 0x88, 0x2e, 0x40, 0xce, 0xc1, - 0x5a, 0xd3, 0xd6, 0xdd, 0x83, 0x8a, 0x66, 0x1a, 0xae, 0xaa, 0xb9, 0xec, 0xf9, 0x56, 0xe9, 0x8e, - 0x9b, 0x37, 0xa6, 0x8f, 0x33, 0x59, 0xa3, 0x18, 0xb2, 0x32, 0x26, 0x40, 0x0b, 0x0c, 0x42, 0x5a, - 0xa8, 0x62, 0x57, 0xd5, 0xeb, 0x4e, 0x9e, 0x1d, 0x0c, 0x89, 0x62, 0xa0, 0x2f, 0x9f, 0x1b, 0x0a, - 0x6e, 0x6c, 0x5d, 0x80, 0x9c, 0x69, 0x61, 0x3b, 0x94, 0x88, 0x4a, 0xd1, 0x96, 0xa3, 0x18, 0xb2, - 0x32, 0x26, 0x40, 0x22, 0x49, 0x75, 0xc9, 0x30, 0x8b, 0x85, 0xa2, 0xd5, 0xdc, 0xf1, 0xf7, 0xc3, - 0x26, 0x5b, 0x46, 0x63, 0xde, 0x38, 0x28, 0x3d, 0xe6, 0x73, 0x8f, 0xd2, 0xc9, 0x5f, 0xfb, 0xc2, - 0xc3, 0x93, 0xdc, 0x34, 0xfc, 0xfd, 0xa9, 0x4b, 0xf8, 0x80, 0x0c, 0x3f, 0x47, 0xdd, 0xa0, 0x98, - 0x24, 0xed, 0x7c, 0x51, 0xd5, 0xeb, 0xe2, 0x19, 0xb2, 0xc2, 0x4b, 0xa8, 0x08, 0x83, 0x8e, 0xab, - 0xba, 0x4d, 0x87, 0x7f, 0x1c, 0x4c, 0xee, 0x64, 0x6a, 0x25, 0xd3, 0xa8, 0x6e, 0x52, 0x4c, 0x85, - 0x53, 0xa0, 0x0b, 0x30, 0xe8, 0x9a, 0xfb, 0xd8, 0xe0, 0x2a, 0xec, 0x6b, 0x7e, 0xd3, 0x73, 0x2a, - 0x46, 0x4d, 0x34, 0x52, 0xc5, 0x75, 0x5c, 0x63, 0x69, 0xd5, 0x9e, 0x4a, 0x56, 0x1f, 0xf4, 0x1b, - 0x61, 0xa5, 0xe5, 0xbe, 0x27, 0x21, 0xd7, 0x54, 0x94, 0x9f, 0xac, 0x8c, 0x79, 0xa0, 0x4d, 0x0a, - 0x41, 0x97, 0x42, 0x57, 0x12, 0xf9, 0x87, 0xf4, 0xee, 0xee, 0xd4, 0xfd, 0x80, 0x4d, 0x8b, 0xfd, - 0x89, 0xe0, 0x85, 0xc6, 0x0b, 0x90, 0x6b, 0x1a, 0x3b, 0xa6, 0x41, 0xdf, 0x0a, 0xf2, 0xfc, 0x9e, - 0xac, 0xef, 0x92, 0x41, 0xe3, 0x88, 0x62, 0xc8, 0xca, 0x98, 0x07, 0xba, 0xc8, 0x56, 0x01, 0x55, - 0x18, 0xf5, 0xb1, 0xe8, 0x44, 0xcd, 0xc4, 0x4e, 0xd4, 0xbb, 0xf8, 0x44, 0x3d, 0x1a, 0x6d, 0xc5, - 0x9f, 0xab, 0x23, 0x1e, 0x90, 0x90, 0xa1, 0x8b, 0x00, 0xbe, 0x7b, 0xa0, 0xfb, 0x14, 0xc3, 0x9d, - 0x07, 0xde, 0xf7, 0x31, 0x62, 0xbd, 0xe7, 0xd3, 0xa2, 0x77, 0xc2, 0x44, 0x43, 0x37, 0x2a, 0x0e, - 0xae, 0xef, 0x56, 0xb8, 0x82, 0x09, 0x4b, 0xfa, 0xa9, 0x97, 0xd2, 0x4a, 0x7f, 0xf6, 0x70, 0xf3, - 0xc6, 0x74, 0x81, 0xbb, 0xd0, 0x56, 0x96, 0xb2, 0x32, 0xde, 0xd0, 0x8d, 0x4d, 0x5c, 0xdf, 0x5d, - 0xf4, 0x60, 0xc5, 0xec, 0xfb, 0x3f, 0x39, 0x7d, 0x84, 0x4f, 0xd7, 0x23, 0xf2, 0x39, 0xba, 0x77, - 0xce, 0xa7, 0x19, 0x76, 0xc8, 0x9a, 0x44, 0x15, 0x05, 0xba, 0xa3, 0x91, 0x51, 0x7c, 0x00, 0x9b, - 0xe6, 0xaf, 0xfc, 0x87, 0x19, 0x49, 0xfe, 0x9c, 0x04, 0x83, 0x8b, 0x97, 0x37, 0x54, 0xdd, 0x46, - 0xcb, 0x30, 0xee, 0x5b, 0x4e, 0x78, 0x92, 0x9f, 0xbc, 0x79, 0x63, 0x3a, 0x1f, 0x35, 0x2e, 0x6f, - 0x96, 0xfb, 0x06, 0x2c, 0xa6, 0xf9, 0x72, 0xa7, 0x85, 0x6b, 0x88, 0x55, 0x0b, 0x8a, 0xdc, 0xba, - 0xac, 0x8d, 0x74, 0xb3, 0x0c, 0x43, 0x4c, 0x5a, 0x07, 0x15, 0x61, 0xc0, 0x22, 0x3f, 0xf8, 0xc1, - 0xc0, 0x54, 0x47, 0xe3, 0xa5, 0xf8, 0xde, 0x46, 0x26, 0x21, 0x91, 0x3f, 0x9c, 0x00, 0x58, 0xbc, - 0x7c, 0x79, 0xcb, 0xd6, 0xad, 0x3a, 0x76, 0x6f, 0x65, 0xcf, 0xb7, 0xe0, 0x68, 0x60, 0x95, 0x64, - 0x6b, 0x91, 0xde, 0xcf, 0xdc, 0xbc, 0x31, 0x7d, 0x32, 0xda, 0xfb, 0x00, 0x9a, 0xac, 0x4c, 0xf8, - 0xeb, 0x25, 0x5b, 0x6b, 0xcb, 0xb5, 0xea, 0xb8, 0x1e, 0xd7, 0x64, 0x67, 0xae, 0x01, 0xb4, 0x20, - 0xd7, 0x45, 0xc7, 0x6d, 0xaf, 0xda, 0x4d, 0x18, 0xf6, 0x55, 0xe2, 0xa0, 0x45, 0x48, 0xbb, 0xfc, - 0x37, 0xd7, 0xb0, 0xdc, 0x59, 0xc3, 0x82, 0x8c, 0x6b, 0xd9, 0xa3, 0x94, 0xff, 0x4c, 0x02, 0xf0, - 0x6d, 0xf6, 0xc7, 0xd3, 0xc4, 0x88, 0x2b, 0xe7, 0x8e, 0x37, 0x79, 0xa8, 0x54, 0x8d, 0x53, 0x47, - 0xf4, 0xf9, 0xd3, 0x09, 0x98, 0xd8, 0x16, 0x9e, 0xe7, 0xc7, 0x5e, 0x07, 0x1b, 0x30, 0x84, 0x0d, - 0xd7, 0xd6, 0xa9, 0x12, 0xc8, 0x68, 0x3f, 0xd2, 0x69, 0xb4, 0xdb, 0xf4, 0x89, 0x7e, 0xec, 0x46, - 0x6c, 0xba, 0x73, 0x36, 0x11, 0x6d, 0x7c, 0x30, 0x09, 0xf9, 0x4e, 0x94, 0x68, 0x01, 0xc6, 0x34, - 0x1b, 0x53, 0x40, 0x25, 0xb8, 0xf3, 0x57, 0x2a, 0xf8, 0x99, 0x65, 0x04, 0x41, 0x56, 0x46, 0x05, - 0x84, 0x47, 0x8f, 0x1a, 0x90, 0xb4, 0x8f, 0x98, 0x1d, 0xc1, 0xea, 0x31, 0xcf, 0x93, 0x79, 0xf8, - 0x10, 0x8d, 0x84, 0x19, 0xb0, 0xf8, 0x31, 0xea, 0x43, 0x69, 0x00, 0x79, 0x09, 0xc6, 0x74, 0x43, - 0x77, 0x75, 0xb5, 0x5e, 0xd9, 0x51, 0xeb, 0xaa, 0xa1, 0x1d, 0x26, 0x6b, 0x66, 0x2e, 0x9f, 0x37, - 0x1b, 0x61, 0x27, 0x2b, 0xa3, 0x1c, 0x52, 0x62, 0x00, 0x74, 0x11, 0x86, 0x44, 0x53, 0xa9, 0x43, - 0x65, 0x1b, 0x82, 0x3c, 0x90, 0xe0, 0xfd, 0x4c, 0x12, 0xc6, 0x15, 0x5c, 0xfd, 0xff, 0x43, 0xd1, - 0xdf, 0x50, 0xac, 0x02, 0xb0, 0xe9, 0x4e, 0x1c, 0xec, 0x21, 0x46, 0x83, 0x38, 0x8c, 0x0c, 0xe3, - 0xb0, 0xe8, 0xb8, 0x81, 0xf1, 0xb8, 0x91, 0x80, 0x6c, 0x70, 0x3c, 0xfe, 0x82, 0x46, 0x25, 0xb4, - 0xec, 0x7b, 0xa2, 0x14, 0xff, 0x44, 0x68, 0x07, 0x4f, 0xd4, 0x62, 0xbd, 0xdd, 0x5d, 0xd0, 0xff, - 0x48, 0xc0, 0xe0, 0x86, 0x6a, 0xab, 0x0d, 0x07, 0x69, 0x2d, 0x99, 0xa6, 0xd8, 0x7e, 0x6c, 0xf9, - 0x10, 0x34, 0xdf, 0xed, 0x88, 0x49, 0x34, 0x3f, 0xda, 0x26, 0xd1, 0xfc, 0x09, 0x18, 0x25, 0xcb, - 0xe1, 0xc0, 0x15, 0x06, 0xa2, 0xed, 0x91, 0xd2, 0x09, 0x9f, 0x4b, 0xb8, 0x9e, 0xad, 0x96, 0x2f, - 0x07, 0xef, 0x30, 0x0c, 0x13, 0x0c, 0xdf, 0x31, 0x13, 0xf2, 0x63, 0xfe, 0xb2, 0x34, 0x50, 0x29, - 0x2b, 0xd0, 0x50, 0xaf, 0x95, 0x59, 0x01, 0xad, 0x00, 0xda, 0xf3, 0x76, 0x46, 0x2a, 0xbe, 0x3a, - 0x09, 0xfd, 0x9d, 0x37, 0x6f, 0x4c, 0x9f, 0x60, 0xf4, 0xad, 0x38, 0xb2, 0x32, 0xee, 0x03, 0x05, - 0xb7, 0xc7, 0x01, 0x48, 0xbf, 0x2a, 0xec, 0xfa, 0x1c, 0x5b, 0xee, 0x1c, 0xbd, 0x79, 0x63, 0x7a, - 0x9c, 0x71, 0xf1, 0xeb, 0x64, 0x25, 0x43, 0x0a, 0x8b, 0xe4, 0x77, 0xc0, 0xb2, 0x3f, 0x2d, 0x01, - 0xf2, 0x5d, 0xbe, 0x82, 0x1d, 0x8b, 0xac, 0xcf, 0x48, 0x22, 0x1e, 0xc8, 0x9a, 0xa5, 0xee, 0x89, - 0xb8, 0x4f, 0x2f, 0x12, 0xf1, 0xc0, 0x4c, 0x79, 0xca, 0x77, 0x8f, 0x09, 0x3e, 0x8e, 0x6d, 0xee, - 0x1a, 0xce, 0x2e, 0x98, 0xba, 0xa0, 0x6e, 0xf1, 0x87, 0x47, 0xe4, 0x7f, 0x25, 0xc1, 0x89, 0x16, - 0x8b, 0xf2, 0x84, 0xfd, 0x4b, 0x80, 0xec, 0x40, 0x25, 0xff, 0xde, 0x1b, 0x13, 0xba, 0x6f, 0x03, - 0x1d, 0xb7, 0x5b, 0xfc, 0xee, 0xad, 0xf3, 0xf0, 0xec, 0xb2, 0xe2, 0x3f, 0x95, 0x60, 0x32, 0xd8, - 0xbc, 0xd7, 0x91, 0x35, 0xc8, 0x06, 0x5b, 0xe7, 0x5d, 0xb8, 0xa7, 0x97, 0x2e, 0x70, 0xe9, 0x43, - 0xf4, 0xe8, 0x39, 0x7f, 0xba, 0xb2, 0xbd, 0xb3, 0x47, 0x7b, 0xd6, 0x86, 0x90, 0x29, 0x3a, 0x6d, - 0x53, 0x74, 0x3c, 0xfe, 0x8f, 0x04, 0xa9, 0x0d, 0xd3, 0xac, 0x23, 0x13, 0xc6, 0x0d, 0xd3, 0xad, - 0x10, 0xcb, 0xc2, 0xd5, 0x0a, 0x5f, 0x74, 0x33, 0x3f, 0xb8, 0xd0, 0x9f, 0x92, 0xbe, 0x7d, 0x63, - 0xba, 0x95, 0x95, 0x32, 0x66, 0x98, 0x6e, 0x89, 0x42, 0xb6, 0xd8, 0x92, 0xfc, 0x9d, 0x30, 0x12, - 0x6e, 0x8c, 0x79, 0xc9, 0xe7, 0xfb, 0x6e, 0x2c, 0xcc, 0xe6, 0xe6, 0x8d, 0xe9, 0x49, 0x7f, 0xc6, - 0x78, 0x60, 0x59, 0xc9, 0xee, 0x04, 0x5a, 0x67, 0xd7, 0xbb, 0xbe, 0xfb, 0xc9, 0x69, 0xe9, 0xf4, - 0x17, 0x25, 0x00, 0x7f, 0xe7, 0x01, 0x3d, 0x04, 0xc7, 0x4b, 0xeb, 0x6b, 0x8b, 0x95, 0xcd, 0xad, - 0xf9, 0xad, 0xed, 0xcd, 0xca, 0xf6, 0xda, 0xe6, 0x46, 0x79, 0x61, 0xf9, 0xc2, 0x72, 0x79, 0xd1, - 0xdf, 0x1e, 0x77, 0x2c, 0xac, 0xe9, 0xbb, 0x3a, 0xae, 0xa2, 0xfb, 0x60, 0x32, 0x8c, 0x4d, 0x4a, - 0xe5, 0xc5, 0x9c, 0x54, 0xc8, 0xbe, 0x7a, 0x7d, 0x26, 0xcd, 0x72, 0x31, 0x5c, 0x45, 0xa7, 0xe0, - 0x68, 0x2b, 0xde, 0xf2, 0xda, 0x52, 0x2e, 0x51, 0x18, 0x79, 0xf5, 0xfa, 0x4c, 0xc6, 0x4b, 0xda, - 0x90, 0x0c, 0x28, 0x88, 0xc9, 0xf9, 0x25, 0x0b, 0xf0, 0xea, 0xf5, 0x99, 0x41, 0xa6, 0xc0, 0x42, - 0xea, 0xfd, 0x9f, 0x9e, 0x3a, 0x52, 0xba, 0xd0, 0x71, 0x03, 0xfc, 0xa1, 0xae, 0xba, 0xbb, 0xe6, - 0x6d, 0x6a, 0x87, 0x77, 0xbd, 0xff, 0x78, 0xa8, 0xe3, 0xae, 0x77, 0x0d, 0x1b, 0xd8, 0xd1, 0x9d, - 0x43, 0xed, 0x7a, 0xf7, 0xb4, 0x93, 0x2e, 0xff, 0xce, 0x00, 0x64, 0x97, 0x58, 0x2b, 0x64, 0x20, - 0x30, 0x7a, 0x13, 0x0c, 0x5a, 0x34, 0x8c, 0x78, 0xc7, 0x68, 0x1d, 0x0c, 0x9e, 0x05, 0x1b, 0xef, - 0x2e, 0x17, 0x0b, 0x3d, 0x0e, 0xbf, 0xcc, 0xc1, 0xee, 0x98, 0xf9, 0xb7, 0xa6, 0xb2, 0x7d, 0xed, - 0xf7, 0xb0, 0x9c, 0x85, 0x6f, 0xad, 0x44, 0xf9, 0xc9, 0xec, 0x5e, 0xc8, 0x16, 0x81, 0xb0, 0xdb, - 0x61, 0xef, 0x95, 0xe0, 0x28, 0xc5, 0xf2, 0x03, 0x31, 0xc5, 0x14, 0xc9, 0xfe, 0xe9, 0x4e, 0x5d, - 0x58, 0x51, 0x1d, 0xff, 0xae, 0x07, 0xbb, 0xcf, 0x75, 0x0f, 0x0f, 0x84, 0x27, 0x03, 0x8d, 0x47, - 0xd9, 0xca, 0xca, 0x44, 0xbd, 0x85, 0xd2, 0x41, 0x4b, 0xa1, 0x0b, 0x7d, 0xa9, 0xfe, 0xb6, 0xda, - 0x83, 0x97, 0xfb, 0x9e, 0x85, 0x61, 0xdf, 0x97, 0x38, 0xfc, 0xff, 0x53, 0xf4, 0x1e, 0x3b, 0x82, - 0xc4, 0xe8, 0x7d, 0x12, 0x1c, 0xf5, 0xa3, 0x79, 0x90, 0x2d, 0xfb, 0x3f, 0x1e, 0x0f, 0xf6, 0xb1, - 0x10, 0x8a, 0x2a, 0xa7, 0x2d, 0x5f, 0x59, 0x99, 0x6c, 0xb6, 0x92, 0x92, 0x25, 0xd8, 0x48, 0xd0, - 0xb3, 0x3a, 0x79, 0xf1, 0xa9, 0xba, 0xde, 0x5d, 0x73, 0x98, 0x01, 0xfb, 0xdf, 0x02, 0x96, 0x69, - 0xbb, 0xb8, 0x4a, 0x37, 0xe4, 0xd2, 0x8a, 0x57, 0x96, 0xd7, 0x00, 0xb5, 0x0e, 0x6e, 0xf4, 0x02, - 0x63, 0xc6, 0xbf, 0xc0, 0x38, 0x09, 0x03, 0xc1, 0x2b, 0x7e, 0xac, 0x50, 0x4c, 0xbf, 0x9f, 0x87, - 0xcf, 0x5b, 0x3e, 0xe7, 0xff, 0x45, 0x02, 0x4e, 0x07, 0x8f, 0x87, 0x5e, 0x6a, 0x62, 0xfb, 0xc0, - 0x9b, 0xa2, 0x96, 0x5a, 0xd3, 0x8d, 0xe0, 0x1b, 0xa0, 0x13, 0xc1, 0x80, 0x4f, 0x71, 0x85, 0x9e, - 0x64, 0x03, 0x86, 0x37, 0xd4, 0x1a, 0x56, 0xf0, 0x4b, 0x4d, 0xec, 0xb8, 0x6d, 0x2e, 0x99, 0x1f, - 0x83, 0x41, 0x73, 0x77, 0x57, 0x1c, 0x69, 0xa7, 0x14, 0x5e, 0x22, 0x5d, 0xae, 0xeb, 0x0d, 0x9d, - 0xdd, 0x06, 0x4b, 0x29, 0xac, 0x80, 0xa6, 0x61, 0x58, 0x33, 0x9b, 0x06, 0x9f, 0x71, 0xf9, 0x94, - 0xf8, 0x00, 0x44, 0xd3, 0x60, 0x33, 0x4e, 0x7e, 0x06, 0xb2, 0xac, 0x3d, 0x1e, 0x71, 0x4f, 0x40, - 0x9a, 0x5e, 0xa7, 0xf2, 0x5b, 0x1d, 0x22, 0xe5, 0x4b, 0xec, 0x42, 0x3a, 0xe3, 0xc2, 0x1a, 0x66, - 0x85, 0x52, 0xa9, 0xa3, 0x2a, 0x4f, 0xc5, 0xbb, 0x06, 0xa6, 0x28, 0x4f, 0x8d, 0xbf, 0x39, 0x00, - 0x47, 0xf9, 0x09, 0x9d, 0x6a, 0xe9, 0x73, 0x7b, 0xae, 0x2b, 0x5e, 0x09, 0x01, 0x4f, 0x75, 0x55, - 0x4b, 0x97, 0x0f, 0x20, 0x75, 0xd1, 0x75, 0x2d, 0x74, 0x1a, 0x06, 0xec, 0x66, 0x1d, 0x8b, 0x1d, - 0x1f, 0x6f, 0x4f, 0x5e, 0xb5, 0xf4, 0x59, 0x82, 0xa0, 0x34, 0xeb, 0x58, 0x61, 0x28, 0xa8, 0x0c, - 0xd3, 0xbb, 0xcd, 0x7a, 0xfd, 0xa0, 0x52, 0xc5, 0xf4, 0x7f, 0xf7, 0x78, 0x5f, 0xbf, 0xc7, 0xd7, - 0x2c, 0x55, 0x7c, 0x43, 0x8f, 0xe8, 0xe6, 0x24, 0x45, 0x5b, 0xa4, 0x58, 0xe2, 0xcb, 0xf7, 0x65, - 0x81, 0x23, 0xff, 0x5e, 0x02, 0xd2, 0x82, 0x35, 0xbd, 0x21, 0x8e, 0xeb, 0x58, 0x73, 0x4d, 0x71, - 0x62, 0xe2, 0x95, 0x11, 0x82, 0x64, 0x8d, 0x0f, 0x51, 0xe6, 0xe2, 0x11, 0x85, 0x14, 0x08, 0xcc, - 0xbb, 0xb7, 0x4f, 0x60, 0x56, 0x93, 0x8c, 0x5a, 0xca, 0x32, 0xc5, 0xd2, 0xec, 0xe2, 0x11, 0x85, - 0x96, 0x50, 0x1e, 0x06, 0xc9, 0xcc, 0x70, 0xd9, 0x87, 0x09, 0x09, 0x9c, 0x97, 0xd1, 0x31, 0x18, - 0xb0, 0x54, 0x57, 0x63, 0x57, 0xea, 0x48, 0x05, 0x2b, 0xa2, 0x27, 0x60, 0x90, 0x3d, 0x08, 0x8d, - 0xfe, 0x63, 0x0c, 0xa2, 0x0c, 0xf6, 0xe5, 0x2d, 0x22, 0xf7, 0x86, 0xea, 0xba, 0xd8, 0x36, 0x08, - 0x43, 0x86, 0x8e, 0x10, 0xa4, 0x76, 0xcc, 0xea, 0x01, 0xff, 0x67, 0x1d, 0xf4, 0x37, 0xff, 0xef, - 0x00, 0xd4, 0x1e, 0x2a, 0xb4, 0x92, 0xfd, 0x8f, 0xa2, 0xac, 0x00, 0x96, 0x08, 0x52, 0x19, 0x26, - 0xd4, 0x6a, 0x55, 0x67, 0xff, 0x37, 0xa3, 0xb2, 0xa3, 0x53, 0x0f, 0xe1, 0xd0, 0xff, 0x40, 0xd5, - 0x69, 0x2c, 0x90, 0x4f, 0x50, 0xe2, 0xf8, 0xa5, 0x0c, 0x0c, 0x59, 0x4c, 0x28, 0xf9, 0x3c, 0x8c, - 0xb7, 0x48, 0x4a, 0xe4, 0xdb, 0xd7, 0x8d, 0xaa, 0x78, 0xcc, 0x40, 0x7e, 0x13, 0x18, 0xfd, 0x7a, - 0x1e, 0x3b, 0x8b, 0xa2, 0xbf, 0x4b, 0xef, 0xee, 0xfc, 0xf0, 0x6b, 0x34, 0xf0, 0xf0, 0x4b, 0xb5, - 0xf4, 0x52, 0x86, 0xf2, 0xe7, 0xcf, 0xbd, 0xe6, 0x79, 0x05, 0x7b, 0xea, 0x35, 0x6b, 0xda, 0x35, - 0x12, 0xa5, 0x45, 0xf4, 0x25, 0x55, 0xaa, 0xa5, 0x3b, 0xd4, 0x1c, 0xfd, 0xaf, 0xf9, 0x39, 0xe7, - 0x03, 0xbf, 0xe9, 0x23, 0xb0, 0xd4, 0xd2, 0xfc, 0xc6, 0xb2, 0x67, 0xc7, 0x5f, 0x4e, 0xc0, 0xc9, - 0x80, 0x1d, 0x07, 0x90, 0x5b, 0xcd, 0xb9, 0xd0, 0xde, 0xe2, 0x7b, 0x78, 0xfc, 0x75, 0x09, 0x52, - 0x04, 0x1f, 0xc5, 0x7c, 0xbb, 0x3f, 0xff, 0xab, 0x5f, 0xfb, 0x27, 0x72, 0xf8, 0xd4, 0x2a, 0x34, - 0x2a, 0x94, 0x49, 0xe9, 0x7d, 0xbd, 0xeb, 0x2f, 0xe7, 0x7f, 0xc8, 0xd0, 0xb9, 0x75, 0x6a, 0x8c, - 0xea, 0xf0, 0x5b, 0x67, 0x41, 0xee, 0x90, 0xf2, 0x30, 0x8f, 0xd9, 0x3d, 0x89, 0xea, 0xc3, 0x1d, - 0x77, 0xba, 0xff, 0xdf, 0x6d, 0x04, 0x7b, 0x4c, 0xc7, 0xae, 0xc1, 0xb1, 0xe7, 0x48, 0xdb, 0xfe, - 0x32, 0x59, 0x38, 0xf6, 0x63, 0xde, 0x69, 0x9e, 0xc4, 0xff, 0x01, 0x98, 0x38, 0xa9, 0x03, 0x5f, - 0x3e, 0xbe, 0x40, 0xbc, 0x6f, 0xb6, 0x63, 0xbc, 0x98, 0x0d, 0x04, 0x0b, 0x25, 0x40, 0x29, 0xff, - 0xb2, 0x04, 0xc7, 0x5b, 0x9a, 0xe6, 0x3e, 0x7e, 0xa9, 0xcd, 0x53, 0x85, 0x43, 0x65, 0x36, 0x4b, - 0x6d, 0x84, 0xbd, 0x3f, 0x56, 0x58, 0x26, 0x45, 0x48, 0xda, 0xa7, 0xe1, 0x68, 0x58, 0x58, 0xa1, - 0xa6, 0x7b, 0x61, 0x34, 0xbc, 0x23, 0xcc, 0xd5, 0x35, 0x12, 0xda, 0x13, 0x96, 0x2b, 0x51, 0x3d, - 0x7b, 0x7d, 0x2d, 0x43, 0xc6, 0x43, 0xe5, 0x29, 0x70, 0xcf, 0x5d, 0xf5, 0x29, 0xe5, 0x0f, 0x4b, - 0x30, 0x13, 0x6e, 0x21, 0x90, 0x0c, 0xf5, 0x27, 0xec, 0x2d, 0x1b, 0xe2, 0x37, 0x24, 0xb8, 0xab, - 0x8b, 0x4c, 0x5c, 0x01, 0x2f, 0xc3, 0x64, 0x60, 0x27, 0x40, 0xb8, 0x70, 0x31, 0xec, 0xa7, 0xe3, - 0xd3, 0x50, 0x6f, 0xe1, 0x7b, 0x07, 0x51, 0xca, 0x67, 0x7f, 0x7f, 0x7a, 0xa2, 0xb5, 0xce, 0x51, - 0x26, 0x5a, 0x57, 0xef, 0xb7, 0xd0, 0x3e, 0x5e, 0x93, 0xe0, 0x81, 0x70, 0x57, 0xdb, 0xe4, 0xb3, - 0x3f, 0xaa, 0x71, 0xf8, 0xf7, 0x12, 0x9c, 0xee, 0x45, 0x38, 0x3e, 0x20, 0x3b, 0x30, 0xe1, 0x67, - 0xda, 0xd1, 0xf1, 0xe8, 0x2b, 0x7f, 0x67, 0x56, 0x8a, 0x3c, 0x6e, 0xb7, 0x41, 0xf1, 0x16, 0x9f, - 0x58, 0xc1, 0x21, 0xf7, 0x94, 0x1c, 0xde, 0xcd, 0x15, 0x4a, 0x0e, 0xed, 0xe7, 0xb6, 0x19, 0x8b, - 0x44, 0x9b, 0xb1, 0xf0, 0x53, 0x73, 0xf9, 0x0a, 0xf7, 0x5b, 0x6d, 0xf6, 0xe0, 0xde, 0x06, 0x13, - 0x6d, 0x4c, 0x99, 0xcf, 0xea, 0x3e, 0x2c, 0x59, 0x41, 0xad, 0xc6, 0x2a, 0x1f, 0xc0, 0x34, 0x6d, - 0xb7, 0x8d, 0xa2, 0x6f, 0x77, 0x97, 0x1b, 0xdc, 0xb7, 0xb4, 0x6d, 0x9a, 0xf7, 0x7d, 0x19, 0x06, - 0xd9, 0x38, 0xf3, 0xee, 0x1e, 0xc2, 0x50, 0x38, 0x03, 0xf9, 0xe7, 0x85, 0x2f, 0x5b, 0x14, 0x62, - 0xb7, 0x9f, 0x43, 0xbd, 0xf4, 0xf5, 0x16, 0xcd, 0xa1, 0x80, 0x32, 0xbe, 0x21, 0xbc, 0x5a, 0x7b, - 0xe9, 0xb8, 0x3a, 0xb4, 0x5b, 0xe6, 0xd5, 0x98, 0x6e, 0x6e, 0xaf, 0xfb, 0xfa, 0x45, 0xe1, 0xbe, - 0xbc, 0x3e, 0xc5, 0xb8, 0xaf, 0x1f, 0x8d, 0xea, 0x3d, 0x47, 0x16, 0x23, 0xe6, 0x9f, 0x47, 0x47, - 0xf6, 0x5d, 0x09, 0x4e, 0xd0, 0xbe, 0x05, 0x37, 0x22, 0xfa, 0x55, 0xf9, 0x43, 0x80, 0x1c, 0x5b, - 0xab, 0xb4, 0x9d, 0xdd, 0x39, 0xc7, 0xd6, 0x2e, 0x87, 0xe2, 0xcb, 0x43, 0x80, 0xaa, 0xa1, 0xed, - 0x26, 0x8a, 0xcd, 0x6e, 0xc9, 0xe5, 0xaa, 0x81, 0xdd, 0x8c, 0x36, 0xc3, 0x99, 0xba, 0x05, 0xc3, - 0xf9, 0x75, 0x09, 0x0a, 0xed, 0xba, 0xcc, 0x87, 0x4f, 0x87, 0x63, 0xa1, 0x43, 0x82, 0xe8, 0x08, - 0x3e, 0xd4, 0xcb, 0x56, 0x4e, 0x64, 0x1a, 0x1d, 0xb5, 0xf1, 0xed, 0xce, 0x03, 0xa6, 0xc3, 0x16, - 0xda, 0x9a, 0x59, 0xff, 0xc8, 0xa6, 0xcf, 0x17, 0x5a, 0xfc, 0xea, 0x9f, 0x8b, 0xdc, 0xfb, 0x1a, - 0x4c, 0x75, 0x90, 0xfa, 0x76, 0xc7, 0xbd, 0xbd, 0x8e, 0x83, 0x79, 0xab, 0xd3, 0xf7, 0xc7, 0xf9, - 0x4c, 0x08, 0xdf, 0xc0, 0x0e, 0xac, 0xc5, 0xda, 0x3d, 0xe1, 0x92, 0xdf, 0x02, 0x77, 0xb4, 0xa5, - 0xe2, 0xb2, 0x15, 0x21, 0xb5, 0xa7, 0x3b, 0x2e, 0x17, 0xeb, 0xbe, 0x4e, 0x62, 0x45, 0xa8, 0x29, - 0x8d, 0x8c, 0x20, 0x47, 0x59, 0x6f, 0x98, 0x66, 0x9d, 0x8b, 0x21, 0x5f, 0x82, 0xf1, 0x00, 0x8c, - 0x37, 0x72, 0x0e, 0x52, 0x96, 0xc9, 0x3f, 0x4f, 0x30, 0x7c, 0xe6, 0x64, 0xc7, 0xdd, 0x7b, 0xd3, - 0xac, 0xf3, 0x6e, 0x53, 0x7c, 0x79, 0x12, 0x10, 0x63, 0x46, 0x37, 0xf2, 0x45, 0x13, 0x9b, 0x30, - 0x11, 0x82, 0xf2, 0x46, 0x7e, 0xa0, 0x43, 0x82, 0x33, 0xdf, 0x3e, 0x0a, 0x03, 0x94, 0x2b, 0xfa, - 0x98, 0x04, 0x10, 0x38, 0x11, 0x9e, 0xed, 0xc4, 0xa6, 0xfd, 0x9a, 0xb8, 0x30, 0xd7, 0x33, 0x3e, - 0xcf, 0xd9, 0x4e, 0xbf, 0xfb, 0xdf, 0x7c, 0xeb, 0x23, 0x89, 0x7b, 0x90, 0x3c, 0xd7, 0x61, 0x35, - 0x1e, 0x98, 0x2f, 0x9f, 0x09, 0xbd, 0x7d, 0x7f, 0xb8, 0xb7, 0xa6, 0x84, 0x64, 0xb3, 0xbd, 0xa2, - 0x73, 0xc1, 0xce, 0x53, 0xc1, 0xce, 0xa2, 0xc7, 0xe2, 0x05, 0x9b, 0x7b, 0x47, 0x78, 0xd2, 0xbc, - 0x0b, 0xfd, 0x8e, 0x04, 0x93, 0xed, 0x96, 0x74, 0xe8, 0xc9, 0xde, 0xa4, 0x68, 0x4d, 0x29, 0x0a, - 0x4f, 0x1d, 0x82, 0x92, 0x77, 0x65, 0x89, 0x76, 0x65, 0x1e, 0x3d, 0x73, 0x88, 0xae, 0xcc, 0x05, - 0xf7, 0xf7, 0xff, 0x97, 0x04, 0x77, 0x76, 0x5d, 0x21, 0xa1, 0xf9, 0xde, 0xa4, 0xec, 0x92, 0x3b, - 0x15, 0x4a, 0x3f, 0x08, 0x0b, 0xde, 0xe3, 0xe7, 0x68, 0x8f, 0x2f, 0xa1, 0xe5, 0xc3, 0xf4, 0xb8, - 0xed, 0x21, 0x0a, 0xfa, 0xad, 0xf0, 0xcd, 0xc2, 0xee, 0xe6, 0xd4, 0xb2, 0xf0, 0x88, 0x99, 0x18, - 0xad, 0x49, 0xad, 0xfc, 0x02, 0xed, 0x82, 0x82, 0x36, 0x7e, 0xc0, 0x41, 0x9b, 0x7b, 0x47, 0xd8, - 0xf1, 0xbf, 0x0b, 0xfd, 0x4f, 0xa9, 0xfd, 0x45, 0xc1, 0x27, 0xba, 0x8a, 0xd8, 0x79, 0x51, 0x55, - 0x78, 0xb2, 0x7f, 0x42, 0xde, 0xc9, 0x06, 0xed, 0x64, 0x0d, 0xe1, 0x5b, 0xdd, 0xc9, 0xb6, 0x83, - 0x88, 0xbe, 0x2a, 0xc1, 0x64, 0xbb, 0x35, 0x49, 0xcc, 0xb4, 0xec, 0xb2, 0xc8, 0x8a, 0x99, 0x96, - 0xdd, 0x16, 0x40, 0xf2, 0x9b, 0x68, 0xe7, 0xcf, 0xa1, 0xc7, 0x3b, 0x75, 0xbe, 0xeb, 0x28, 0x92, - 0xb9, 0xd8, 0x35, 0xc9, 0x8f, 0x99, 0x8b, 0xbd, 0xac, 0x63, 0x62, 0xe6, 0x62, 0x4f, 0x6b, 0x8c, - 0xf8, 0xb9, 0xe8, 0xf5, 0xac, 0xc7, 0x61, 0x74, 0xd0, 0x97, 0x25, 0x18, 0x09, 0x65, 0xc4, 0xe8, - 0xd1, 0xae, 0x82, 0xb6, 0x5b, 0x30, 0x14, 0xce, 0xf4, 0x43, 0xc2, 0xfb, 0xb2, 0x4c, 0xfb, 0xb2, - 0x80, 0xe6, 0x0f, 0xd3, 0x97, 0xf0, 0x59, 0xe9, 0xd7, 0x25, 0x98, 0x68, 0x93, 0x65, 0xc6, 0xcc, - 0xc2, 0xce, 0x49, 0x73, 0xe1, 0xc9, 0xfe, 0x09, 0x79, 0xaf, 0x2e, 0xd0, 0x5e, 0xfd, 0x04, 0x7a, - 0xfa, 0x30, 0xbd, 0x0a, 0xc4, 0xe7, 0x1b, 0xfe, 0xbd, 0xab, 0x40, 0x3b, 0xe8, 0x5c, 0x9f, 0x82, - 0x89, 0x0e, 0x3d, 0xd1, 0x37, 0x1d, 0xef, 0xcf, 0xf3, 0xb4, 0x3f, 0xcf, 0xa1, 0xf5, 0x1f, 0xac, - 0x3f, 0xad, 0x61, 0xfd, 0xf3, 0xad, 0x2f, 0x00, 0xbb, 0x5b, 0x51, 0xdb, 0x64, 0xb5, 0xf0, 0x58, - 0x5f, 0x34, 0xbc, 0x53, 0x4f, 0xd2, 0x4e, 0x9d, 0x41, 0x8f, 0x74, 0xea, 0x54, 0xe0, 0x72, 0x9d, - 0x6e, 0xec, 0x9a, 0x73, 0xef, 0x60, 0x29, 0xf0, 0xbb, 0xd0, 0x4f, 0x89, 0x8b, 0x4d, 0xa7, 0xba, - 0xb6, 0x1b, 0xc8, 0x63, 0x0b, 0x0f, 0xf4, 0x80, 0xc9, 0xe5, 0xba, 0x87, 0xca, 0x35, 0x85, 0x4e, - 0x76, 0x92, 0x8b, 0xe4, 0xb2, 0xe8, 0x03, 0x92, 0x77, 0x17, 0xf2, 0x74, 0x77, 0xde, 0xc1, 0x64, - 0xb7, 0xf0, 0x60, 0x4f, 0xb8, 0x5c, 0x92, 0xfb, 0xa8, 0x24, 0x33, 0x68, 0xaa, 0xa3, 0x24, 0x2c, - 0xf5, 0xbd, 0xd5, 0x37, 0x07, 0x5e, 0x3d, 0x0e, 0xd3, 0x1d, 0x5a, 0x74, 0xaf, 0xc5, 0x9c, 0x71, - 0x75, 0x79, 0x08, 0x1b, 0xfb, 0xd0, 0xb5, 0xc3, 0xd3, 0xda, 0xc3, 0x3f, 0x7f, 0xed, 0xed, 0x40, - 0xec, 0x5f, 0xa7, 0x00, 0xad, 0x3a, 0xb5, 0x05, 0x1b, 0xb3, 0x7f, 0x7a, 0xc7, 0x67, 0x79, 0xe4, - 0x85, 0x97, 0xf4, 0x03, 0xbd, 0xf0, 0x5a, 0x0d, 0xbd, 0x99, 0x4a, 0xf4, 0xf7, 0x2e, 0xb3, 0xe7, - 0x87, 0x53, 0xc9, 0x1f, 0xca, 0xc3, 0xa9, 0xf6, 0xf7, 0xaa, 0x53, 0xb7, 0xee, 0x01, 0xc6, 0xc0, - 0x61, 0x1f, 0xa1, 0xf0, 0xf7, 0x90, 0x83, 0x5d, 0xde, 0x43, 0xe6, 0x3b, 0x3e, 0x7a, 0xe4, 0xd4, - 0xe8, 0xac, 0xf8, 0x80, 0xef, 0x50, 0x6f, 0x37, 0x61, 0xf9, 0x17, 0x7e, 0xfd, 0x2d, 0x84, 0x93, - 0x50, 0x68, 0x35, 0x27, 0x6f, 0x52, 0x7f, 0x24, 0x09, 0xb9, 0x55, 0xa7, 0x56, 0xae, 0xea, 0xee, - 0x6d, 0xb2, 0xb5, 0x67, 0x3a, 0x3f, 0x6a, 0x41, 0x37, 0x6f, 0x4c, 0x8f, 0x32, 0x9d, 0x76, 0xd1, - 0x64, 0x03, 0xc6, 0x22, 0x4f, 0x89, 0xb9, 0x65, 0x2d, 0x1e, 0xe6, 0x45, 0x73, 0x84, 0x95, 0x4c, - 0xdf, 0x20, 0x04, 0xec, 0x1b, 0x5d, 0x6b, 0x6f, 0xcc, 0xcc, 0xa0, 0x2e, 0xde, 0xce, 0x17, 0x80, - 0xfe, 0x98, 0x15, 0x20, 0x1f, 0x1d, 0x14, 0x6f, 0xc4, 0xfe, 0x50, 0x82, 0xe1, 0x55, 0x47, 0xa4, - 0x82, 0xf8, 0xc7, 0xf4, 0xfd, 0xd1, 0x13, 0xde, 0x77, 0x58, 0x93, 0xbd, 0xd9, 0xad, 0xf8, 0x36, - 0xab, 0xaf, 0x84, 0xa3, 0x30, 0x11, 0xe8, 0xa7, 0xd7, 0xff, 0xdf, 0x4e, 0x50, 0xff, 0x58, 0xc2, - 0x35, 0xdd, 0xf0, 0xb2, 0x48, 0xfc, 0x17, 0xf5, 0x75, 0x85, 0xaf, 0xe7, 0xd4, 0x61, 0xf5, 0xbc, - 0x4f, 0x1d, 0x44, 0x44, 0x9f, 0xde, 0xc6, 0xd7, 0x6a, 0xeb, 0xdb, 0x1f, 0xa9, 0x8f, 0xcf, 0xea, - 0x44, 0x5e, 0xf8, 0xc8, 0x6f, 0x48, 0x30, 0xb2, 0xea, 0xd4, 0xb6, 0x8d, 0xea, 0xff, 0xf3, 0xf6, - 0xbb, 0x0b, 0x47, 0x43, 0x3d, 0xbd, 0x4d, 0x2a, 0x3d, 0xf3, 0x5a, 0x0a, 0x92, 0xab, 0x4e, 0x0d, - 0xbd, 0x04, 0x63, 0xd1, 0xa4, 0xa1, 0x63, 0x2e, 0xd8, 0x1a, 0x11, 0x3a, 0xaf, 0xd7, 0x3a, 0x47, - 0x0f, 0xb4, 0x0f, 0x23, 0xe1, 0xc8, 0x71, 0xaa, 0x0b, 0x93, 0x10, 0x66, 0xe1, 0x91, 0x5e, 0x31, - 0xbd, 0xc6, 0xde, 0x0e, 0x69, 0xcf, 0xe9, 0xdd, 0xdd, 0x85, 0x5a, 0x20, 0x75, 0xce, 0x6e, 0xdb, - 0xb8, 0x15, 0xa2, 0xbd, 0xa8, 0x4b, 0xe9, 0xa6, 0xbd, 0x08, 0x6e, 0x57, 0xed, 0x75, 0x9a, 0x5a, - 0x3b, 0x00, 0x81, 0x79, 0x70, 0x6f, 0x17, 0x0e, 0x3e, 0x5a, 0xe1, 0xe1, 0x9e, 0xd0, 0xbc, 0x43, - 0xa7, 0x5b, 0x9c, 0x8c, 0xff, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd5, 0xca, 0x34, 0x9e, 0x6a, - 0x94, 0x00, 0x00, - } - r := bytes.NewReader(gzipped) - gzipr, err := compress_gzip.NewReader(r) - if err != nil { - panic(err) - } - ungzipped, err := io_ioutil.ReadAll(gzipr) - if err != nil { - panic(err) - } - if err := github_com_gogo_protobuf_proto.Unmarshal(ungzipped, d); err != nil { - panic(err) - } - return d -} -func (this *CommissionRates) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*CommissionRates) - if !ok { - that2, ok := that.(CommissionRates) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.Rate.Equal(that1.Rate) { - return false - } - if !this.MaxRate.Equal(that1.MaxRate) { - return false - } - if !this.MaxChangeRate.Equal(that1.MaxChangeRate) { - return false - } - return true -} -func (this *Commission) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Commission) - if !ok { - that2, ok := that.(Commission) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.CommissionRates.Equal(&that1.CommissionRates) { - return false - } - if !this.UpdateTime.Equal(that1.UpdateTime) { - return false - } - return true -} -func (this *Description) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Description) - if !ok { - that2, ok := that.(Description) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.Moniker != that1.Moniker { - return false - } - if this.Identity != that1.Identity { - return false - } - if this.Website != that1.Website { - return false - } - if this.SecurityContact != that1.SecurityContact { - return false - } - if this.Details != that1.Details { - return false - } - return true -} -func (this *UnbondingDelegationEntry) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*UnbondingDelegationEntry) - if !ok { - that2, ok := that.(UnbondingDelegationEntry) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.CreationHeight != that1.CreationHeight { - return false - } - if !this.CompletionTime.Equal(that1.CompletionTime) { - return false - } - if !this.InitialBalance.Equal(that1.InitialBalance) { - return false - } - if !this.Balance.Equal(that1.Balance) { - return false - } - return true -} -func (this *RedelegationEntry) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*RedelegationEntry) - if !ok { - that2, ok := that.(RedelegationEntry) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.CreationHeight != that1.CreationHeight { - return false - } - if !this.CompletionTime.Equal(that1.CompletionTime) { - return false - } - if !this.InitialBalance.Equal(that1.InitialBalance) { - return false - } - if !this.SharesDst.Equal(that1.SharesDst) { - return false - } - return true -} -func (this *Params) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Params) - if !ok { - that2, ok := that.(Params) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if this.UnbondingTime != that1.UnbondingTime { - return false - } - if this.MaxValidators != that1.MaxValidators { - return false - } - if this.MaxEntries != that1.MaxEntries { - return false - } - if this.HistoricalEntries != that1.HistoricalEntries { - return false - } - if this.BondDenom != that1.BondDenom { - return false - } - return true -} -func (this *RedelegationEntryResponse) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*RedelegationEntryResponse) - if !ok { - that2, ok := that.(RedelegationEntryResponse) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.RedelegationEntry.Equal(&that1.RedelegationEntry) { - return false - } - if !this.Balance.Equal(that1.Balance) { - return false - } - return true -} -func (this *Pool) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*Pool) - if !ok { - that2, ok := that.(Pool) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !this.NotBondedTokens.Equal(that1.NotBondedTokens) { - return false - } - if !this.BondedTokens.Equal(that1.BondedTokens) { - return false - } - return true -} -func (m *HistoricalInfo) 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 *HistoricalInfo) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HistoricalInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Valset) > 0 { - for iNdEx := len(m.Valset) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Valset[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *CommissionRates) 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 *CommissionRates) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CommissionRates) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.MaxChangeRate.Size() - i -= size - if _, err := m.MaxChangeRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.MaxRate.Size() - i -= size - if _, err := m.MaxRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.Rate.Size() - i -= size - if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Commission) 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 *Commission) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Commission) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdateTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdateTime):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintStaking(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x12 - { - size, err := m.CommissionRates.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Description) 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 *Description) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Description) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Details) > 0 { - i -= len(m.Details) - copy(dAtA[i:], m.Details) - i = encodeVarintStaking(dAtA, i, uint64(len(m.Details))) - i-- - dAtA[i] = 0x2a - } - if len(m.SecurityContact) > 0 { - i -= len(m.SecurityContact) - copy(dAtA[i:], m.SecurityContact) - i = encodeVarintStaking(dAtA, i, uint64(len(m.SecurityContact))) - i-- - dAtA[i] = 0x22 - } - if len(m.Website) > 0 { - i -= len(m.Website) - copy(dAtA[i:], m.Website) - i = encodeVarintStaking(dAtA, i, uint64(len(m.Website))) - i-- - dAtA[i] = 0x1a - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintStaking(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x12 - } - if len(m.Moniker) > 0 { - i -= len(m.Moniker) - copy(dAtA[i:], m.Moniker) - i = encodeVarintStaking(dAtA, i, uint64(len(m.Moniker))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Validator) 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 *Validator) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Validator) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.MinSelfDelegation.Size() - i -= size - if _, err := m.MinSelfDelegation.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - { - size, err := m.Commission.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UnbondingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UnbondingTime):]) - if err5 != nil { - return 0, err5 - } - i -= n5 - i = encodeVarintStaking(dAtA, i, uint64(n5)) - i-- - dAtA[i] = 0x4a - if m.UnbondingHeight != 0 { - i = encodeVarintStaking(dAtA, i, uint64(m.UnbondingHeight)) - i-- - dAtA[i] = 0x40 - } - { - size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x3a - { - size := m.DelegatorShares.Size() - i -= size - if _, err := m.DelegatorShares.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size := m.Tokens.Size() - i -= size - if _, err := m.Tokens.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if m.Status != 0 { - i = encodeVarintStaking(dAtA, i, uint64(m.Status)) - i-- - dAtA[i] = 0x20 - } - if m.Jailed { - i-- - if m.Jailed { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x18 - } - if m.ConsensusPubkey != nil { - { - size, err := m.ConsensusPubkey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.OperatorAddress) > 0 { - i -= len(m.OperatorAddress) - copy(dAtA[i:], m.OperatorAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.OperatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ValAddresses) 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 *ValAddresses) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ValAddresses) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Addresses) > 0 { - for iNdEx := len(m.Addresses) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Addresses[iNdEx]) - copy(dAtA[i:], m.Addresses[iNdEx]) - i = encodeVarintStaking(dAtA, i, uint64(len(m.Addresses[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *DVPair) 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 *DVPair) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DVPair) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) - copy(dAtA[i:], m.ValidatorAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.ValidatorAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DVPairs) 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 *DVPairs) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DVPairs) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Pairs) > 0 { - for iNdEx := len(m.Pairs) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Pairs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *DVVTriplet) 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 *DVVTriplet) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DVVTriplet) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ValidatorDstAddress) > 0 { - i -= len(m.ValidatorDstAddress) - copy(dAtA[i:], m.ValidatorDstAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.ValidatorDstAddress))) - i-- - dAtA[i] = 0x1a - } - if len(m.ValidatorSrcAddress) > 0 { - i -= len(m.ValidatorSrcAddress) - copy(dAtA[i:], m.ValidatorSrcAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.ValidatorSrcAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *DVVTriplets) 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 *DVVTriplets) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DVVTriplets) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Triplets) > 0 { - for iNdEx := len(m.Triplets) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Triplets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *Delegation) 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 *Delegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Delegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Shares.Size() - i -= size - if _, err := m.Shares.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) - copy(dAtA[i:], m.ValidatorAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.ValidatorAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UnbondingDelegation) 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 *UnbondingDelegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UnbondingDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Entries) > 0 { - for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - } - if len(m.ValidatorAddress) > 0 { - i -= len(m.ValidatorAddress) - copy(dAtA[i:], m.ValidatorAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.ValidatorAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UnbondingDelegationEntry) 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 *UnbondingDelegationEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UnbondingDelegationEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Balance.Size() - i -= size - if _, err := m.Balance.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.InitialBalance.Size() - i -= size - if _, err := m.InitialBalance.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - n8, err8 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) - if err8 != nil { - return 0, err8 - } - i -= n8 - i = encodeVarintStaking(dAtA, i, uint64(n8)) - i-- - dAtA[i] = 0x12 - if m.CreationHeight != 0 { - i = encodeVarintStaking(dAtA, i, uint64(m.CreationHeight)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *RedelegationEntry) 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 *RedelegationEntry) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RedelegationEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.SharesDst.Size() - i -= size - if _, err := m.SharesDst.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.InitialBalance.Size() - i -= size - if _, err := m.InitialBalance.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) - if err9 != nil { - return 0, err9 - } - i -= n9 - i = encodeVarintStaking(dAtA, i, uint64(n9)) - i-- - dAtA[i] = 0x12 - if m.CreationHeight != 0 { - i = encodeVarintStaking(dAtA, i, uint64(m.CreationHeight)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *Redelegation) 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 *Redelegation) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Redelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Entries) > 0 { - for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - if len(m.ValidatorDstAddress) > 0 { - i -= len(m.ValidatorDstAddress) - copy(dAtA[i:], m.ValidatorDstAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.ValidatorDstAddress))) - i-- - dAtA[i] = 0x1a - } - if len(m.ValidatorSrcAddress) > 0 { - i -= len(m.ValidatorSrcAddress) - copy(dAtA[i:], m.ValidatorSrcAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.ValidatorSrcAddress))) - i-- - dAtA[i] = 0x12 - } - if len(m.DelegatorAddress) > 0 { - i -= len(m.DelegatorAddress) - copy(dAtA[i:], m.DelegatorAddress) - i = encodeVarintStaking(dAtA, i, uint64(len(m.DelegatorAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.BondDenom) > 0 { - i -= len(m.BondDenom) - copy(dAtA[i:], m.BondDenom) - i = encodeVarintStaking(dAtA, i, uint64(len(m.BondDenom))) - i-- - dAtA[i] = 0x2a - } - if m.HistoricalEntries != 0 { - i = encodeVarintStaking(dAtA, i, uint64(m.HistoricalEntries)) - i-- - dAtA[i] = 0x20 - } - if m.MaxEntries != 0 { - i = encodeVarintStaking(dAtA, i, uint64(m.MaxEntries)) - i-- - dAtA[i] = 0x18 - } - if m.MaxValidators != 0 { - i = encodeVarintStaking(dAtA, i, uint64(m.MaxValidators)) - i-- - dAtA[i] = 0x10 - } - n10, err10 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingTime):]) - if err10 != nil { - return 0, err10 - } - i -= n10 - i = encodeVarintStaking(dAtA, i, uint64(n10)) - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *DelegationResponse) 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 *DelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Balance.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.Delegation.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *RedelegationEntryResponse) 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 *RedelegationEntryResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RedelegationEntryResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Balance.Size() - i -= size - if _, err := m.Balance.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size, err := m.RedelegationEntry.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *RedelegationResponse) 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 *RedelegationResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RedelegationResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Entries) > 0 { - for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - { - size, err := m.Redelegation.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *Pool) 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 *Pool) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.BondedTokens.Size() - i -= size - if _, err := m.BondedTokens.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.NotBondedTokens.Size() - i -= size - if _, err := m.NotBondedTokens.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStaking(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintStaking(dAtA []byte, offset int, v uint64) int { - offset -= sovStaking(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *HistoricalInfo) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Header.Size() - n += 1 + l + sovStaking(uint64(l)) - if len(m.Valset) > 0 { - for _, e := range m.Valset { - l = e.Size() - n += 1 + l + sovStaking(uint64(l)) - } - } - return n -} - -func (m *CommissionRates) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Rate.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.MaxRate.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.MaxChangeRate.Size() - n += 1 + l + sovStaking(uint64(l)) - return n -} - -func (m *Commission) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.CommissionRates.Size() - n += 1 + l + sovStaking(uint64(l)) - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdateTime) - n += 1 + l + sovStaking(uint64(l)) - return n -} - -func (m *Description) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Moniker) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.Website) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.SecurityContact) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.Details) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - return n -} - -func (m *Validator) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.OperatorAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - if m.ConsensusPubkey != nil { - l = m.ConsensusPubkey.Size() - n += 1 + l + sovStaking(uint64(l)) - } - if m.Jailed { - n += 2 - } - if m.Status != 0 { - n += 1 + sovStaking(uint64(m.Status)) - } - l = m.Tokens.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.DelegatorShares.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.Description.Size() - n += 1 + l + sovStaking(uint64(l)) - if m.UnbondingHeight != 0 { - n += 1 + sovStaking(uint64(m.UnbondingHeight)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UnbondingTime) - n += 1 + l + sovStaking(uint64(l)) - l = m.Commission.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.MinSelfDelegation.Size() - n += 1 + l + sovStaking(uint64(l)) - return n -} - -func (m *ValAddresses) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Addresses) > 0 { - for _, s := range m.Addresses { - l = len(s) - n += 1 + l + sovStaking(uint64(l)) - } - } - return n -} - -func (m *DVPair) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.ValidatorAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - return n -} - -func (m *DVPairs) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Pairs) > 0 { - for _, e := range m.Pairs { - l = e.Size() - n += 1 + l + sovStaking(uint64(l)) - } - } - return n -} - -func (m *DVVTriplet) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.ValidatorSrcAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.ValidatorDstAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - return n -} - -func (m *DVVTriplets) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Triplets) > 0 { - for _, e := range m.Triplets { - l = e.Size() - n += 1 + l + sovStaking(uint64(l)) - } - } - return n -} - -func (m *Delegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.ValidatorAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = m.Shares.Size() - n += 1 + l + sovStaking(uint64(l)) - return n -} - -func (m *UnbondingDelegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.ValidatorAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - if len(m.Entries) > 0 { - for _, e := range m.Entries { - l = e.Size() - n += 1 + l + sovStaking(uint64(l)) - } - } - return n -} - -func (m *UnbondingDelegationEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CreationHeight != 0 { - n += 1 + sovStaking(uint64(m.CreationHeight)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) - n += 1 + l + sovStaking(uint64(l)) - l = m.InitialBalance.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.Balance.Size() - n += 1 + l + sovStaking(uint64(l)) - return n -} - -func (m *RedelegationEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CreationHeight != 0 { - n += 1 + sovStaking(uint64(m.CreationHeight)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) - n += 1 + l + sovStaking(uint64(l)) - l = m.InitialBalance.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.SharesDst.Size() - n += 1 + l + sovStaking(uint64(l)) - return n -} - -func (m *Redelegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.ValidatorSrcAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - l = len(m.ValidatorDstAddress) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - if len(m.Entries) > 0 { - for _, e := range m.Entries { - l = e.Size() - n += 1 + l + sovStaking(uint64(l)) - } - } - return n -} - -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingTime) - n += 1 + l + sovStaking(uint64(l)) - if m.MaxValidators != 0 { - n += 1 + sovStaking(uint64(m.MaxValidators)) - } - if m.MaxEntries != 0 { - n += 1 + sovStaking(uint64(m.MaxEntries)) - } - if m.HistoricalEntries != 0 { - n += 1 + sovStaking(uint64(m.HistoricalEntries)) - } - l = len(m.BondDenom) - if l > 0 { - n += 1 + l + sovStaking(uint64(l)) - } - return n -} - -func (m *DelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Delegation.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.Balance.Size() - n += 1 + l + sovStaking(uint64(l)) - return n -} - -func (m *RedelegationEntryResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.RedelegationEntry.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.Balance.Size() - n += 1 + l + sovStaking(uint64(l)) - return n -} - -func (m *RedelegationResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Redelegation.Size() - n += 1 + l + sovStaking(uint64(l)) - if len(m.Entries) > 0 { - for _, e := range m.Entries { - l = e.Size() - n += 1 + l + sovStaking(uint64(l)) - } - } - return n -} - -func (m *Pool) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.NotBondedTokens.Size() - n += 1 + l + sovStaking(uint64(l)) - l = m.BondedTokens.Size() - n += 1 + l + sovStaking(uint64(l)) - return n -} - -func sovStaking(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozStaking(x uint64) (n int) { - return sovStaking(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (this *ValAddresses) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&ValAddresses{`, - `Addresses:` + fmt.Sprintf("%v", this.Addresses) + `,`, - `}`, - }, "") - return s -} -func valueToStringStaking(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} -func (m *HistoricalInfo) 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 ErrIntOverflowStaking - } - 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: HistoricalInfo: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HistoricalInfo: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Valset", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Valset = append(m.Valset, Validator{}) - if err := m.Valset[len(m.Valset)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CommissionRates) 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 ErrIntOverflowStaking - } - 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: CommissionRates: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CommissionRates: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxChangeRate", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MaxChangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Commission) 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 ErrIntOverflowStaking - } - 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: Commission: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Commission: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommissionRates", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.CommissionRates.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UpdateTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Description) 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 ErrIntOverflowStaking - } - 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: Description: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Description: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Moniker = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Website = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SecurityContact", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SecurityContact = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Details", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Details = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Validator) 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 ErrIntOverflowStaking - } - 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: Validator: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Validator: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.OperatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsensusPubkey", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.ConsensusPubkey == nil { - m.ConsensusPubkey = &types1.Any{} - } - if err := m.ConsensusPubkey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Jailed = bool(v != 0) - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) - } - m.Status = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Status |= BondStatus(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tokens", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Tokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorShares", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.DelegatorShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingHeight", wireType) - } - m.UnbondingHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UnbondingHeight |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UnbondingTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinSelfDelegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ValAddresses) 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 ErrIntOverflowStaking - } - 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: ValAddresses: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ValAddresses: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Addresses", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Addresses = append(m.Addresses, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DVPair) 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 ErrIntOverflowStaking - } - 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: DVPair: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DVPair: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DVPairs) 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 ErrIntOverflowStaking - } - 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: DVPairs: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DVPairs: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pairs", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Pairs = append(m.Pairs, DVPair{}) - if err := m.Pairs[len(m.Pairs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DVVTriplet) 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 ErrIntOverflowStaking - } - 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: DVVTriplet: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DVVTriplet: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSrcAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorSrcAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorDstAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorDstAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DVVTriplets) 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 ErrIntOverflowStaking - } - 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: DVVTriplets: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DVVTriplets: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Triplets", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Triplets = append(m.Triplets, DVVTriplet{}) - if err := m.Triplets[len(m.Triplets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Delegation) 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 ErrIntOverflowStaking - } - 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: Delegation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Delegation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Shares", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Shares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UnbondingDelegation) 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 ErrIntOverflowStaking - } - 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: UnbondingDelegation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UnbondingDelegation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Entries = append(m.Entries, UnbondingDelegationEntry{}) - if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UnbondingDelegationEntry) 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 ErrIntOverflowStaking - } - 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: UnbondingDelegationEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UnbondingDelegationEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CreationHeight", wireType) - } - m.CreationHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CreationHeight |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CompletionTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InitialBalance", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InitialBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RedelegationEntry) 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 ErrIntOverflowStaking - } - 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: RedelegationEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RedelegationEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CreationHeight", wireType) - } - m.CreationHeight = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CreationHeight |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CompletionTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InitialBalance", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.InitialBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SharesDst", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.SharesDst.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Redelegation) 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 ErrIntOverflowStaking - } - 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: Redelegation: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Redelegation: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSrcAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorSrcAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ValidatorDstAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ValidatorDstAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Entries = append(m.Entries, RedelegationEntry{}) - if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Params) 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 ErrIntOverflowStaking - } - 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: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.UnbondingTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxValidators", wireType) - } - m.MaxValidators = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxValidators |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxEntries", wireType) - } - m.MaxEntries = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.MaxEntries |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field HistoricalEntries", wireType) - } - m.HistoricalEntries = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.HistoricalEntries |= uint32(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BondDenom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.BondDenom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *DelegationResponse) 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 ErrIntOverflowStaking - } - 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: DelegationResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Delegation", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Delegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RedelegationEntryResponse) 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 ErrIntOverflowStaking - } - 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: RedelegationEntryResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RedelegationEntryResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RedelegationEntry", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.RedelegationEntry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RedelegationResponse) 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 ErrIntOverflowStaking - } - 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: RedelegationResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RedelegationResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Redelegation", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Redelegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthStaking - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Entries = append(m.Entries, RedelegationEntryResponse{}) - if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Pool) 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 ErrIntOverflowStaking - } - 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: Pool: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Pool: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NotBondedTokens", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.NotBondedTokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BondedTokens", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStaking - } - 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 ErrInvalidLengthStaking - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStaking - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.BondedTokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipStaking(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthStaking - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipStaking(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, ErrIntOverflowStaking - } - 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, ErrIntOverflowStaking - } - 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, ErrIntOverflowStaking - } - 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, ErrInvalidLengthStaking - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupStaking - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthStaking - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthStaking = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowStaking = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupStaking = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/staking/migrations/v040/types.go b/x/staking/migrations/v040/types.go deleted file mode 100644 index ba3be48cb6e6..000000000000 --- a/x/staking/migrations/v040/types.go +++ /dev/null @@ -1,205 +0,0 @@ -package v040 - -import ( - "fmt" - "strings" - "time" - - "sigs.k8s.io/yaml" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// Staking params default values -const ( - // DefaultUnbondingTime reflects three weeks in seconds as the default - // unbonding time. - // TODO: Justify our choice of default here. - DefaultUnbondingTime time.Duration = time.Hour * 24 * 7 * 3 - - // Default maximum number of bonded validators - DefaultMaxValidators uint32 = 100 - - // Default maximum entries in a UBD/RED pair - DefaultMaxEntries uint32 = 7 - - // DefaultHistorical entries is 10000. Apps that don't use IBC can ignore this - // value by not adding the staking module to the application module manager's - // SetOrderBeginBlockers. - DefaultHistoricalEntries uint32 = 10000 -) - -// NewParams creates a new Params instance -func NewParams(unbondingTime time.Duration, maxValidators, maxEntries, historicalEntries uint32, bondDenom string) Params { - return Params{ - UnbondingTime: unbondingTime, - MaxValidators: maxValidators, - MaxEntries: maxEntries, - HistoricalEntries: historicalEntries, - BondDenom: bondDenom, - } -} - -// String returns a human readable string representation of the parameters. -func (p Params) String() string { - out, _ := yaml.Marshal(p) - return string(out) -} - -func DefaultParams() Params { - return NewParams( - DefaultUnbondingTime, - DefaultMaxValidators, - DefaultMaxEntries, - DefaultHistoricalEntries, - sdk.DefaultBondDenom, - ) -} - -// String implements the Stringer interface for a Commission object. -func (c Commission) String() string { - out, _ := yaml.Marshal(c) - return string(out) -} - -// String implements the Stringer interface for a CommissionRates object. -func (cr CommissionRates) String() string { - out, _ := yaml.Marshal(cr) - return string(out) -} - -// String implements the Stringer interface for a DVPair object. -func (dv DVPair) String() string { - out, _ := yaml.Marshal(dv) - return string(out) -} - -// String implements the Stringer interface for a DVVTriplet object. -func (dvv DVVTriplet) String() string { - out, _ := yaml.Marshal(dvv) - return string(out) -} - -// String returns a human readable string representation of a Delegation. -func (d Delegation) String() string { - out, _ := yaml.Marshal(d) - return string(out) -} - -// Delegations is a collection of delegations -type Delegations []Delegation - -func (d Delegations) String() (out string) { - for _, del := range d { - out += del.String() + "\n" - } - - return strings.TrimSpace(out) -} - -// String implements the stringer interface for a UnbondingDelegationEntry. -func (e UnbondingDelegationEntry) String() string { - out, _ := yaml.Marshal(e) - return string(out) -} - -// String returns a human readable string representation of an UnbondingDelegation. -func (ubd UnbondingDelegation) String() string { - out := fmt.Sprintf(`Unbonding Delegations between: - Delegator: %s - Validator: %s - Entries:`, ubd.DelegatorAddress, ubd.ValidatorAddress) - for i, entry := range ubd.Entries { - out += fmt.Sprintf(` Unbonding Delegation %d: - Creation Height: %v - Min time to unbond (unix): %v - Expected balance: %s`, i, entry.CreationHeight, - entry.CompletionTime, entry.Balance) - } - - return out -} - -// UnbondingDelegations is a collection of UnbondingDelegation -type UnbondingDelegations []UnbondingDelegation - -func (ubds UnbondingDelegations) String() (out string) { - for _, u := range ubds { - out += u.String() + "\n" - } - - return strings.TrimSpace(out) -} - -// String implements the Stringer interface for a RedelegationEntry object. -func (e RedelegationEntry) String() string { - out, _ := yaml.Marshal(e) - return string(out) -} - -// String returns a human readable string representation of a Redelegation. -func (red Redelegation) String() string { - out := fmt.Sprintf(`Redelegations between: - Delegator: %s - Source Validator: %s - Destination Validator: %s - Entries: -`, - red.DelegatorAddress, red.ValidatorSrcAddress, red.ValidatorDstAddress, - ) - - for i, entry := range red.Entries { - out += fmt.Sprintf(` Redelegation Entry #%d: - Creation height: %v - Min time to unbond (unix): %v - Dest Shares: %s -`, - i, entry.CreationHeight, entry.CompletionTime, entry.SharesDst, - ) - } - - return strings.TrimRight(out, "\n") -} - -// Redelegations are a collection of Redelegation -type Redelegations []Redelegation - -func (d Redelegations) String() (out string) { - for _, red := range d { - out += red.String() + "\n" - } - - return strings.TrimSpace(out) -} - -// String implements the Stringer interface for DelegationResponse. -func (d DelegationResponse) String() string { - return fmt.Sprintf("%s\n Balance: %s", d.Delegation.String(), d.Balance) -} - -// String implements the Stringer interface for a Validator object. -func (v Validator) String() string { - out, _ := yaml.Marshal(v) - return string(out) -} - -func (v Validator) TokensFromShares(shares sdk.Dec) sdk.Dec { - return (shares.MulInt(v.Tokens)).Quo(v.DelegatorShares) -} - -// Validators is a collection of Validator -type Validators []Validator - -func (v Validators) String() (out string) { - for _, val := range v { - out += val.String() + "\n" - } - - return strings.TrimSpace(out) -} - -// String implements the Stringer interface for a Description object. -func (d Description) String() string { - out, _ := yaml.Marshal(d) - return string(out) -} diff --git a/x/staking/migrations/v040/keys.go b/x/staking/migrations/v042/types.go similarity index 78% rename from x/staking/migrations/v040/keys.go rename to x/staking/migrations/v042/types.go index 27e2f9eae02b..097c9ca8bc14 100644 --- a/x/staking/migrations/v040/keys.go +++ b/x/staking/migrations/v042/types.go @@ -1,6 +1,4 @@ -// Package v040 is copy-pasted from: -// https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/x/staking/types/keys.go -package v040 +package v042 import ( "bytes" @@ -11,22 +9,27 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" + v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" "github.com/cosmos/cosmos-sdk/x/staking/types" ) +// Staking params default values const ( - // ModuleName is the name of the staking module - ModuleName = "staking" + // DefaultUnbondingTime reflects three weeks in seconds as the default + // unbonding time. + // TODO: Justify our choice of default here. + DefaultUnbondingTime time.Duration = time.Hour * 24 * 7 * 3 - // StoreKey is the string store representation - StoreKey = ModuleName + // Default maximum number of bonded validators + DefaultMaxValidators uint32 = 100 - // QuerierRoute is the querier route for the staking module - QuerierRoute = ModuleName + // Default maximum entries in a UBD/RED pair + DefaultMaxEntries uint32 = 7 - // RouterKey is the msg router key for the staking module - RouterKey = ModuleName + // DefaultHistorical entries is 10000. Apps that don't use IBC can ignore this + // value by not adding the staking module to the application module manager's + // SetOrderBeginBlockers. + DefaultHistoricalEntries uint32 = 10000 ) var ( @@ -87,7 +90,7 @@ func GetValidatorsByPowerIndexKey(validator types.Validator) []byte { powerBytesLen := len(powerBytes) // 8 // key is of format prefix || powerbytes || addrBytes - key := make([]byte, 1+powerBytesLen+v040auth.AddrLen) + key := make([]byte, 1+powerBytesLen+v042auth.AddrLen) key[0] = ValidatorsByPowerIndexKey[0] copy(key[1:powerBytesLen+1], powerBytes) @@ -111,46 +114,104 @@ func GetLastValidatorPowerKey(operator sdk.ValAddress) []byte { return append(LastValidatorPowerKey, operator...) } -// parse the validators operator address from power rank key -func ParseValidatorPowerRankKey(key []byte) (operAddr []byte) { - powerBytesLen := 8 - kv.AssertKeyLength(key, 1+powerBytesLen+v040auth.AddrLen) +// GetREDKey returns a key prefix for indexing a redelegation from a delegator +// and source validator to a destination validator. +func GetREDKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) []byte { + key := make([]byte, 1+v042auth.AddrLen*3) - operAddr = sdk.CopyBytes(key[powerBytesLen+1:]) + copy(key[0:v042auth.AddrLen+1], GetREDsKey(delAddr.Bytes())) + copy(key[v042auth.AddrLen+1:2*v042auth.AddrLen+1], valSrcAddr.Bytes()) + copy(key[2*v042auth.AddrLen+1:3*v042auth.AddrLen+1], valDstAddr.Bytes()) - for i, b := range operAddr { - operAddr[i] = ^b - } + return key +} + +// gets the index-key for a redelegation, stored by source-validator-index +// VALUE: none (key rearrangement used) +func GetREDByValSrcIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) []byte { + REDSFromValsSrcKey := GetREDsFromValSrcIndexKey(valSrcAddr) + offset := len(REDSFromValsSrcKey) + + // key is of the form REDSFromValsSrcKey || delAddr || valDstAddr + key := make([]byte, len(REDSFromValsSrcKey)+2*v042auth.AddrLen) + copy(key[0:offset], REDSFromValsSrcKey) + copy(key[offset:offset+v042auth.AddrLen], delAddr.Bytes()) + copy(key[offset+v042auth.AddrLen:offset+2*v042auth.AddrLen], valDstAddr.Bytes()) - return operAddr + return key } -// GetValidatorQueueKey returns the prefix key used for getting a set of unbonding -// validators whose unbonding completion occurs at the given time and height. -func GetValidatorQueueKey(timestamp time.Time, height int64) []byte { - heightBz := sdk.Uint64ToBigEndian(uint64(height)) - timeBz := sdk.FormatTimeBytes(timestamp) - timeBzL := len(timeBz) - prefixL := len(ValidatorQueueKey) +// gets the index-key for a redelegation, stored by destination-validator-index +// VALUE: none (key rearrangement used) +func GetREDByValDstIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) []byte { + REDSToValsDstKey := GetREDsToValDstIndexKey(valDstAddr) + offset := len(REDSToValsDstKey) - bz := make([]byte, prefixL+8+timeBzL+8) + // key is of the form REDSToValsDstKey || delAddr || valSrcAddr + key := make([]byte, len(REDSToValsDstKey)+2*v042auth.AddrLen) + copy(key[0:offset], REDSToValsDstKey) + copy(key[offset:offset+v042auth.AddrLen], delAddr.Bytes()) + copy(key[offset+v042auth.AddrLen:offset+2*v042auth.AddrLen], valSrcAddr.Bytes()) - // copy the prefix - copy(bz[:prefixL], ValidatorQueueKey) + return key +} - // copy the encoded time bytes length - copy(bz[prefixL:prefixL+8], sdk.Uint64ToBigEndian(uint64(timeBzL))) +// GetREDKeyFromValSrcIndexKey rearranges the ValSrcIndexKey to get the REDKey +func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte { + // note that first byte is prefix byte + kv.AssertKeyLength(indexKey, 3*v042auth.AddrLen+1) - // copy the encoded time bytes - copy(bz[prefixL+8:prefixL+8+timeBzL], timeBz) + valSrcAddr := indexKey[1 : v042auth.AddrLen+1] + delAddr := indexKey[v042auth.AddrLen+1 : 2*v042auth.AddrLen+1] + valDstAddr := indexKey[2*v042auth.AddrLen+1 : 3*v042auth.AddrLen+1] - // copy the encoded height - copy(bz[prefixL+8+timeBzL:], heightBz) + return GetREDKey(delAddr, valSrcAddr, valDstAddr) +} - return bz +// GetREDKeyFromValDstIndexKey rearranges the ValDstIndexKey to get the REDKey +func GetREDKeyFromValDstIndexKey(indexKey []byte) []byte { + // note that first byte is prefix byte + kv.AssertKeyLength(indexKey, 3*v042auth.AddrLen+1) + + valDstAddr := indexKey[1 : v042auth.AddrLen+1] + delAddr := indexKey[v042auth.AddrLen+1 : 2*v042auth.AddrLen+1] + valSrcAddr := indexKey[2*v042auth.AddrLen+1 : 3*v042auth.AddrLen+1] + + return GetREDKey(delAddr, valSrcAddr, valDstAddr) +} + +func GetREDsToValDstIndexKey(valDstAddr sdk.ValAddress) []byte { + return append(RedelegationByValDstIndexKey, valDstAddr.Bytes()...) +} + +// GetREDsFromValSrcIndexKey returns a key prefix for indexing a redelegation to +// a source validator. +func GetREDsFromValSrcIndexKey(valSrcAddr sdk.ValAddress) []byte { + return append(RedelegationByValSrcIndexKey, valSrcAddr.Bytes()...) +} + +// GetREDsKey returns a key prefix for indexing a redelegation from a delegator +// address. +func GetREDsKey(delAddr sdk.AccAddress) []byte { + return append(RedelegationKey, delAddr.Bytes()...) +} + +// gets the prefix for all unbonding delegations from a delegator +func GetUBDsKey(delAddr sdk.AccAddress) []byte { + return append(UnbondingDelegationKey, delAddr.Bytes()...) +} + +// gets the prefix keyspace for the indexes of unbonding delegations for a validator +func GetUBDsByValIndexKey(valAddr sdk.ValAddress) []byte { + return append(UnbondingDelegationByValIndexKey, valAddr.Bytes()...) +} + +// gets the prefix for all unbonding delegations from a delegator +func GetUnbondingDelegationTimeKey(timestamp time.Time) []byte { + bz := sdk.FormatTimeBytes(timestamp) + return append(UnbondingQueueKey, bz...) } -// ParseValidatorQueueKey returns the encoded time and height from a key created // from GetValidatorQueueKey. func ParseValidatorQueueKey(bz []byte) (time.Time, int64, error) { prefixL := len(ValidatorQueueKey) @@ -198,95 +259,38 @@ func GetUBDByValIndexKey(delAddr sdk.AccAddress, valAddr sdk.ValAddress) []byte func GetUBDKeyFromValIndexKey(indexKey []byte) []byte { kv.AssertKeyAtLeastLength(indexKey, 2) addrs := indexKey[1:] // remove prefix bytes - kv.AssertKeyLength(addrs, 2*v040auth.AddrLen) + kv.AssertKeyLength(addrs, 2*v042auth.AddrLen) - kv.AssertKeyAtLeastLength(addrs, v040auth.AddrLen+1) - valAddr := addrs[:v040auth.AddrLen] - delAddr := addrs[v040auth.AddrLen:] + kv.AssertKeyAtLeastLength(addrs, v042auth.AddrLen+1) + valAddr := addrs[:v042auth.AddrLen] + delAddr := addrs[v042auth.AddrLen:] return GetUBDKey(delAddr, valAddr) } -// gets the prefix for all unbonding delegations from a delegator -func GetUBDsKey(delAddr sdk.AccAddress) []byte { - return append(UnbondingDelegationKey, delAddr.Bytes()...) -} - -// gets the prefix keyspace for the indexes of unbonding delegations for a validator -func GetUBDsByValIndexKey(valAddr sdk.ValAddress) []byte { - return append(UnbondingDelegationByValIndexKey, valAddr.Bytes()...) -} - -// gets the prefix for all unbonding delegations from a delegator -func GetUnbondingDelegationTimeKey(timestamp time.Time) []byte { - bz := sdk.FormatTimeBytes(timestamp) - return append(UnbondingQueueKey, bz...) -} - -// GetREDKey returns a key prefix for indexing a redelegation from a delegator -// and source validator to a destination validator. -func GetREDKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) []byte { - key := make([]byte, 1+v040auth.AddrLen*3) - - copy(key[0:v040auth.AddrLen+1], GetREDsKey(delAddr.Bytes())) - copy(key[v040auth.AddrLen+1:2*v040auth.AddrLen+1], valSrcAddr.Bytes()) - copy(key[2*v040auth.AddrLen+1:3*v040auth.AddrLen+1], valDstAddr.Bytes()) - - return key -} - -// gets the index-key for a redelegation, stored by source-validator-index -// VALUE: none (key rearrangement used) -func GetREDByValSrcIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) []byte { - REDSFromValsSrcKey := GetREDsFromValSrcIndexKey(valSrcAddr) - offset := len(REDSFromValsSrcKey) - - // key is of the form REDSFromValsSrcKey || delAddr || valDstAddr - key := make([]byte, len(REDSFromValsSrcKey)+2*v040auth.AddrLen) - copy(key[0:offset], REDSFromValsSrcKey) - copy(key[offset:offset+v040auth.AddrLen], delAddr.Bytes()) - copy(key[offset+v040auth.AddrLen:offset+2*v040auth.AddrLen], valDstAddr.Bytes()) - - return key -} - -// gets the index-key for a redelegation, stored by destination-validator-index -// VALUE: none (key rearrangement used) -func GetREDByValDstIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) []byte { - REDSToValsDstKey := GetREDsToValDstIndexKey(valDstAddr) - offset := len(REDSToValsDstKey) - - // key is of the form REDSToValsDstKey || delAddr || valSrcAddr - key := make([]byte, len(REDSToValsDstKey)+2*v040auth.AddrLen) - copy(key[0:offset], REDSToValsDstKey) - copy(key[offset:offset+v040auth.AddrLen], delAddr.Bytes()) - copy(key[offset+v040auth.AddrLen:offset+2*v040auth.AddrLen], valSrcAddr.Bytes()) - - return key -} +// GetValidatorQueueKey returns the prefix key used for getting a set of unbonding +// validators whose unbonding completion occurs at the given time and height. +func GetValidatorQueueKey(timestamp time.Time, height int64) []byte { + heightBz := sdk.Uint64ToBigEndian(uint64(height)) + timeBz := sdk.FormatTimeBytes(timestamp) + timeBzL := len(timeBz) + prefixL := len(ValidatorQueueKey) -// GetREDKeyFromValSrcIndexKey rearranges the ValSrcIndexKey to get the REDKey -func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte { - // note that first byte is prefix byte - kv.AssertKeyLength(indexKey, 3*v040auth.AddrLen+1) + bz := make([]byte, prefixL+8+timeBzL+8) - valSrcAddr := indexKey[1 : v040auth.AddrLen+1] - delAddr := indexKey[v040auth.AddrLen+1 : 2*v040auth.AddrLen+1] - valDstAddr := indexKey[2*v040auth.AddrLen+1 : 3*v040auth.AddrLen+1] + // copy the prefix + copy(bz[:prefixL], ValidatorQueueKey) - return GetREDKey(delAddr, valSrcAddr, valDstAddr) -} + // copy the encoded time bytes length + copy(bz[prefixL:prefixL+8], sdk.Uint64ToBigEndian(uint64(timeBzL))) -// GetREDKeyFromValDstIndexKey rearranges the ValDstIndexKey to get the REDKey -func GetREDKeyFromValDstIndexKey(indexKey []byte) []byte { - // note that first byte is prefix byte - kv.AssertKeyLength(indexKey, 3*v040auth.AddrLen+1) + // copy the encoded time bytes + copy(bz[prefixL+8:prefixL+8+timeBzL], timeBz) - valDstAddr := indexKey[1 : v040auth.AddrLen+1] - delAddr := indexKey[v040auth.AddrLen+1 : 2*v040auth.AddrLen+1] - valSrcAddr := indexKey[2*v040auth.AddrLen+1 : 3*v040auth.AddrLen+1] + // copy the encoded height + copy(bz[prefixL+8+timeBzL:], heightBz) - return GetREDKey(delAddr, valSrcAddr, valDstAddr) + return bz } // GetRedelegationTimeKey returns a key prefix for indexing an unbonding @@ -296,30 +300,6 @@ func GetRedelegationTimeKey(timestamp time.Time) []byte { return append(RedelegationQueueKey, bz...) } -// GetREDsKey returns a key prefix for indexing a redelegation from a delegator -// address. -func GetREDsKey(delAddr sdk.AccAddress) []byte { - return append(RedelegationKey, delAddr.Bytes()...) -} - -// GetREDsFromValSrcIndexKey returns a key prefix for indexing a redelegation to -// a source validator. -func GetREDsFromValSrcIndexKey(valSrcAddr sdk.ValAddress) []byte { - return append(RedelegationByValSrcIndexKey, valSrcAddr.Bytes()...) -} - -// GetREDsToValDstIndexKey returns a key prefix for indexing a redelegation to a -// destination (target) validator. -func GetREDsToValDstIndexKey(valDstAddr sdk.ValAddress) []byte { - return append(RedelegationByValDstIndexKey, valDstAddr.Bytes()...) -} - -// GetREDsByDelToValDstIndexKey returns a key prefix for indexing a redelegation -// from an address to a source validator. -func GetREDsByDelToValDstIndexKey(delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) []byte { - return append(GetREDsToValDstIndexKey(valDstAddr), delAddr.Bytes()...) -} - // GetHistoricalInfoKey returns a key prefix for indexing HistoricalInfo objects. func GetHistoricalInfoKey(height int64) []byte { return append(HistoricalInfoKey, []byte(strconv.FormatInt(height, 10))...) diff --git a/x/staking/migrations/v043/store.go b/x/staking/migrations/v043/store.go index 2ebcbb8686de..620d9b6a1a07 100644 --- a/x/staking/migrations/v043/store.go +++ b/x/staking/migrations/v043/store.go @@ -5,9 +5,9 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" - v040auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v040" + v042auth "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" v043distribution "github.com/cosmos/cosmos-sdk/x/distribution/migrations/v043" - v040staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v040" + v040staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v042" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -22,9 +22,9 @@ func migratePrefixAddressAddressAddress(store sdk.KVStore, prefixBz []byte) { defer oldStoreIter.Close() for ; oldStoreIter.Valid(); oldStoreIter.Next() { - addr1 := oldStoreIter.Key()[:v040auth.AddrLen] - addr2 := oldStoreIter.Key()[v040auth.AddrLen : 2*v040auth.AddrLen] - addr3 := oldStoreIter.Key()[2*v040auth.AddrLen:] + addr1 := oldStoreIter.Key()[:v042auth.AddrLen] + addr2 := oldStoreIter.Key()[v042auth.AddrLen : 2*v042auth.AddrLen] + addr3 := oldStoreIter.Key()[2*v042auth.AddrLen:] newStoreKey := append(append(append( prefixBz, address.MustLengthPrefix(addr1)...), address.MustLengthPrefix(addr2)...), address.MustLengthPrefix(addr3)..., diff --git a/x/staking/migrations/v043/store_test.go b/x/staking/migrations/v043/store_test.go index 756590a5dc19..920ff55067de 100644 --- a/x/staking/migrations/v043/store_test.go +++ b/x/staking/migrations/v043/store_test.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" - v040staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v040" + v042staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v042" v043staking "github.com/cosmos/cosmos-sdk/x/staking/migrations/v043" "github.com/cosmos/cosmos-sdk/x/staking/teststaking" "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -41,77 +41,77 @@ func TestStoreMigration(t *testing.T) { }{ { "LastValidatorPowerKey", - v040staking.GetLastValidatorPowerKey(valAddr1), + v042staking.GetLastValidatorPowerKey(valAddr1), types.GetLastValidatorPowerKey(valAddr1), }, { "LastTotalPowerKey", - v040staking.LastTotalPowerKey, + v042staking.LastTotalPowerKey, types.LastTotalPowerKey, }, { "ValidatorsKey", - v040staking.GetValidatorKey(valAddr1), + v042staking.GetValidatorKey(valAddr1), types.GetValidatorKey(valAddr1), }, { "ValidatorsByConsAddrKey", - v040staking.GetValidatorByConsAddrKey(consAddr), + v042staking.GetValidatorByConsAddrKey(consAddr), types.GetValidatorByConsAddrKey(consAddr), }, { "ValidatorsByPowerIndexKey", - v040staking.GetValidatorsByPowerIndexKey(val), + v042staking.GetValidatorsByPowerIndexKey(val), types.GetValidatorsByPowerIndexKey(val, sdk.DefaultPowerReduction), }, { "DelegationKey", - v040staking.GetDelegationKey(addr4, valAddr1), + v042staking.GetDelegationKey(addr4, valAddr1), types.GetDelegationKey(addr4, valAddr1), }, { "UnbondingDelegationKey", - v040staking.GetUBDKey(addr4, valAddr1), + v042staking.GetUBDKey(addr4, valAddr1), types.GetUBDKey(addr4, valAddr1), }, { "UnbondingDelegationByValIndexKey", - v040staking.GetUBDByValIndexKey(addr4, valAddr1), + v042staking.GetUBDByValIndexKey(addr4, valAddr1), types.GetUBDByValIndexKey(addr4, valAddr1), }, { "RedelegationKey", - v040staking.GetREDKey(addr4, valAddr1, valAddr2), + v042staking.GetREDKey(addr4, valAddr1, valAddr2), types.GetREDKey(addr4, valAddr1, valAddr2), }, { "RedelegationByValSrcIndexKey", - v040staking.GetREDByValSrcIndexKey(addr4, valAddr1, valAddr2), + v042staking.GetREDByValSrcIndexKey(addr4, valAddr1, valAddr2), types.GetREDByValSrcIndexKey(addr4, valAddr1, valAddr2), }, { "RedelegationByValDstIndexKey", - v040staking.GetREDByValDstIndexKey(addr4, valAddr1, valAddr2), + v042staking.GetREDByValDstIndexKey(addr4, valAddr1, valAddr2), types.GetREDByValDstIndexKey(addr4, valAddr1, valAddr2), }, { "UnbondingQueueKey", - v040staking.GetUnbondingDelegationTimeKey(now), + v042staking.GetUnbondingDelegationTimeKey(now), types.GetUnbondingDelegationTimeKey(now), }, { "RedelegationQueueKey", - v040staking.GetRedelegationTimeKey(now), + v042staking.GetRedelegationTimeKey(now), types.GetRedelegationTimeKey(now), }, { "ValidatorQueueKey", - v040staking.GetValidatorQueueKey(now, 4), + v042staking.GetValidatorQueueKey(now, 4), types.GetValidatorQueueKey(now, 4), }, { "HistoricalInfoKey", - v040staking.GetHistoricalInfoKey(4), + v042staking.GetHistoricalInfoKey(4), types.GetHistoricalInfoKey(4), }, } diff --git a/x/staking/module.go b/x/staking/module.go index 39665347c994..93b41daef60a 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -24,7 +23,7 @@ import ( ) const ( - consensusVersion uint64 = 4 + consensusVersion uint64 = 3 ) var ( @@ -71,11 +70,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return ValidateGenesis(&data) } -// RegisterRESTRoutes registers the REST routes for the staking module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/staking` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the staking module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { @@ -155,14 +149,13 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. cdc.MustUnmarshalJSON(data, &genesisState) - return InitGenesis(ctx, am.keeper, am.accountKeeper, am.bankKeeper, &genesisState) + return am.keeper.InitGenesis(ctx, &genesisState) } // ExportGenesis returns the exported genesis state as raw bytes for the staking // module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - gs := ExportGenesis(ctx, am.keeper) - return cdc.MustMarshalJSON(gs) + return cdc.MustMarshalJSON(am.keeper.ExportGenesis(ctx)) } // ConsensusVersion implements AppModule/ConsensusVersion. diff --git a/x/staking/simulation/genesis.go b/x/staking/simulation/genesis.go index f8737f7f7e0a..afd393c1c778 100644 --- a/x/staking/simulation/genesis.go +++ b/x/staking/simulation/genesis.go @@ -89,11 +89,11 @@ func RandomizedGenState(simState *module.SimulationState) { if err != nil { panic(err) } - validator.Tokens = sdk.NewInt(simState.InitialStake) - validator.DelegatorShares = sdk.NewDec(simState.InitialStake) + validator.Tokens = simState.InitialStake + validator.DelegatorShares = sdk.NewDecFromInt(simState.InitialStake) validator.Commission = commission - delegation := types.NewDelegation(simState.Accounts[i].Address, valAddr, sdk.NewDec(simState.InitialStake)) + delegation := types.NewDelegation(simState.Accounts[i].Address, valAddr, sdk.NewDecFromInt(simState.InitialStake)) validators = append(validators, validator) delegations = append(delegations, delegation) diff --git a/x/staking/simulation/genesis_test.go b/x/staking/simulation/genesis_test.go index b7dae7dfb97f..dd60652a87bb 100644 --- a/x/staking/simulation/genesis_test.go +++ b/x/staking/simulation/genesis_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -32,7 +33,7 @@ func TestRandomizedGenState(t *testing.T) { Rand: r, NumBonded: 3, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), } @@ -94,9 +95,10 @@ func TestRandomizedGenState1(t *testing.T) { Rand: r, NumBonded: 4, Accounts: simtypes.RandomAccounts(r, 3), - InitialStake: 1000, + InitialStake: sdkmath.NewInt(1000), GenState: make(map[string]json.RawMessage), - }, "invalid memory address or nil pointer dereference"}, + }, "invalid memory address or nil pointer dereference", + }, } for _, tt := range tests { diff --git a/x/staking/simulation/operations.go b/x/staking/simulation/operations.go index 8b3ce6e65337..7cff6459db18 100644 --- a/x/staking/simulation/operations.go +++ b/x/staking/simulation/operations.go @@ -135,7 +135,7 @@ func SimulateMsgCreateValidator(ak types.AccountKeeper, bk types.BankKeeper, k k var fees sdk.Coins - coins, hasNeg := spendable.SafeSub(sdk.Coins{selfDelegation}) + coins, hasNeg := spendable.SafeSub(selfDelegation) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coins) if err != nil { @@ -277,7 +277,7 @@ func SimulateMsgDelegate(ak types.AccountKeeper, bk types.BankKeeper, k keeper.K var fees sdk.Coins - coins, hasNeg := spendable.SafeSub(sdk.Coins{bondAmt}) + coins, hasNeg := spendable.SafeSub(bondAmt) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coins) if err != nil { @@ -411,14 +411,15 @@ func SimulateMsgCancelUnbondingDelegate(ak types.AccountKeeper, bk types.BankKee // get random unbonding delegation entry at block height unbondingDelegationEntry := unbondingDelegation.Entries[r.Intn(len(unbondingDelegation.Entries))] + if unbondingDelegationEntry.CompletionTime.Before(ctx.BlockTime()) { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCancelUnbondingDelegation, "unbonding delegation is already processed"), nil, nil + } + if !unbondingDelegationEntry.Balance.IsPositive() { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCancelUnbondingDelegation, "delegator receiving balance is negative"), nil, nil } - cancelBondAmt, err := simtypes.RandPositiveInt(r, unbondingDelegationEntry.Balance) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCancelUnbondingDelegation, "invalid cancelBondAmt amount"), nil, err - } + cancelBondAmt := simtypes.RandomAmount(r, unbondingDelegationEntry.Balance) if cancelBondAmt.IsZero() { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCancelUnbondingDelegation, "cancelBondAmt amount is zero"), nil, nil diff --git a/x/staking/simulation/operations_test.go b/x/staking/simulation/operations_test.go index 7ab52ee1a5b3..aa07bafe0649 100644 --- a/x/staking/simulation/operations_test.go +++ b/x/staking/simulation/operations_test.go @@ -6,8 +6,6 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/codec/legacy" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" @@ -48,7 +46,8 @@ func TestWeightedOperations(t *testing.T) { weight int opMsgRoute string opMsgName string - }{{simappparams.DefaultWeightMsgCreateValidator, types.ModuleName, types.TypeMsgCreateValidator}, + }{ + {simappparams.DefaultWeightMsgCreateValidator, types.ModuleName, types.TypeMsgCreateValidator}, {simappparams.DefaultWeightMsgEditValidator, types.ModuleName, types.TypeMsgEditValidator}, {simappparams.DefaultWeightMsgDelegate, types.ModuleName, types.TypeMsgDelegate}, {simappparams.DefaultWeightMsgUndelegate, types.ModuleName, types.TypeMsgUndelegate}, @@ -83,7 +82,7 @@ func TestSimulateMsgCreateValidator(t *testing.T) { require.NoError(t, err) var msg types.MsgCreateValidator - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(t, operationMsg.OK) require.Equal(t, "0.080000000000000000", msg.Commission.MaxChangeRate.String()) @@ -137,7 +136,7 @@ func TestSimulateMsgCancelUnbondingDelegation(t *testing.T) { require.NoError(t, err) var msg types.MsgCancelUnbondingDelegation - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(t, operationMsg.OK) require.Equal(t, types.TypeMsgCancelUnbondingDelegation, msg.Type()) @@ -170,7 +169,7 @@ func TestSimulateMsgEditValidator(t *testing.T) { require.NoError(t, err) var msg types.MsgEditValidator - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(t, operationMsg.OK) require.Equal(t, "0.280623462081924936", msg.CommissionRate.String()) @@ -199,7 +198,7 @@ func TestSimulateMsgDelegate(t *testing.T) { require.NoError(t, err) var msg types.MsgDelegate - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(t, operationMsg.OK) require.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.DelegatorAddress) @@ -245,7 +244,7 @@ func TestSimulateMsgUndelegate(t *testing.T) { require.NoError(t, err) var msg types.MsgUndelegate - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(t, operationMsg.OK) require.Equal(t, "cosmos1ghekyjucln7y67ntx7cf27m9dpuxxemn4c8g4r", msg.DelegatorAddress) @@ -294,7 +293,7 @@ func TestSimulateMsgBeginRedelegate(t *testing.T) { require.NoError(t, err) var msg types.MsgBeginRedelegate - legacy.Cdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) require.True(t, operationMsg.OK) require.Equal(t, "cosmos1092v0qgulpejj8y8hs6dmlw82x9gv8f7jfc7jl", msg.DelegatorAddress) @@ -382,5 +381,4 @@ func setupValidatorRewards(app *simapp.SimApp, ctx sdk.Context, valAddress sdk.V // setup current revards currentRewards := distrtypes.NewValidatorCurrentRewards(decCoins, 3) app.DistrKeeper.SetValidatorCurrentRewards(ctx, valAddress, currentRewards) - } diff --git a/x/staking/spec/01_state.md b/x/staking/spec/01_state.md index 1dad2be91780..8d66cb98a005 100644 --- a/x/staking/spec/01_state.md +++ b/x/staking/spec/01_state.md @@ -164,7 +164,7 @@ A redelegation object is created every time a redelegation occurs. To prevent All queues objects are sorted by timestamp. The time used within any queue is first rounded to the nearest nanosecond then sorted. The sortable time format -used is a slight modification of the RFC3339Nano and uses the the format string +used is a slight modification of the RFC3339Nano and uses the format string `"2006-01-02T15:04:05.000000000"`. Notably this format: * right pads all zeros diff --git a/x/staking/spec/02_state_transitions.md b/x/staking/spec/02_state_transitions.md index 1eda63bc8c20..9e9efffaeaa2 100644 --- a/x/staking/spec/02_state_transitions.md +++ b/x/staking/spec/02_state_transitions.md @@ -91,6 +91,12 @@ Delegation may be called. shares from the `BondedPool` to the `NotBondedPool` `ModuleAccount` * remove the validator if it is unbonded and there are no more delegation shares. +### Cancel an `UnbondingDelegation` Entry +When a `cancel unbond delegation` occurs both the `validator`, the `delegation` and an `UnbondingDelegationQueue` state will be updated. +* if cancel unbonding delegation amount equals to the `UnbondingDelegation` entry `balance`, then the `UnbondingDelegation` entry deleted from `UnbondingDelegationQueue`. +* if the `cancel unbonding delegation amount is less than the `UnbondingDelegation` entry balance, then the `UnbondingDelegation` entry will be updated with new balance in the `UnbondingDelegationQueue`. +* cancel `amount` is [Delegated](02_state_transitions.md#delegations) back to the original `validator`. + ### Complete Unbonding For undelegations which do not complete immediately, the following operations diff --git a/x/staking/spec/03_messages.md b/x/staking/spec/03_messages.md index 27c307b24994..a9ef8d05a99a 100644 --- a/x/staking/spec/03_messages.md +++ b/x/staking/spec/03_messages.md @@ -116,6 +116,27 @@ When this message is processed the following actions occur: ![Unbond sequence](../../../docs/uml/svg/unbond_sequence.svg) +## MsgCancelUnbondingDelegation +The `MsgCancelUnbondingDelegation` message allows delegators to cancel the `unbondingDelegation` entry and deleagate back to a previous validator. + ++++ https://github.com/cosmos/cosmos-sdk/blob/28243eb41c16ecfc95631ac2bb266dd28ed5c317/proto/cosmos/staking/v1beta1/tx.proto#L36-L38 + ++++ https://github.com/cosmos/cosmos-sdk/blob/28243eb41c16ecfc95631ac2bb266dd28ed5c317/proto/cosmos/staking/v1beta1/tx.proto#L144-L154 + ++++ https://github.com/cosmos/cosmos-sdk/blob/28243eb41c16ecfc95631ac2bb266dd28ed5c317/proto/cosmos/staking/v1beta1/tx.proto#L156-L157 + + +This message is expected to fail if: +* the `unbondingDelegation` entry is already processed. +* the `cancel unbonding delegation` amount is greater than the `unbondingDelegation` entry balance. +* the `cancel unbonding delegation` height doesn't exists in the `unbondingDelegationQueue` of the delegator. + +When this message is processed the following actions occur: +* if the `unbondingDelegation` Entry balance is zero + * in this condition `unbondingDelegation` entry will be removed from `unbondingDelegationQueue`. + * otherwise `unbondingDelegationQueue` will be updated with new `unbondingDelegation` entry balance and initial balance +* the validator's `DelegatorShares` and the delegation's `Shares` are both increased by the message `Amount`. + ## MsgBeginRedelegate The redelegation command allows delegators to instantly switch validators. Once diff --git a/x/staking/spec/07_events.md b/x/staking/spec/07_events.md index 3f9203033cd2..eeeb84c4b902 100644 --- a/x/staking/spec/07_events.md +++ b/x/staking/spec/07_events.md @@ -63,6 +63,18 @@ The staking module emits the following events: * [0] Time is formatted in the RFC3339 standard +### MsgCancelUnbondingDelegation + +| Type | Attribute Key | Attribute Value | +| ----------------------------- | ------------------ | ------------------------------------| +| cancel_unbonding_delegation | validator | {validatorAddress} | +| cancel_unbonding_delegation | delegator | {delegatorAddress} | +| cancel_unbonding_delegation | amount | {cancelUnbondingDelegationAmount} | +| cancel_unbonding_delegation | creation_height | {unbondingCreationHeight} | +| message | module | staking | +| message | action | cancel_unbond | +| message | sender | {senderAddress} | + ### MsgBeginRedelegate | Type | Attribute Key | Attribute Value | diff --git a/x/staking/spec/09_client.md b/x/staking/spec/09_client.md index 608705352cfc..0c3383d01446 100644 --- a/x/staking/spec/09_client.md +++ b/x/staking/spec/09_client.md @@ -712,6 +712,19 @@ Example: ```bash simd tx staking unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake --from mykey ``` +#### cancel unbond +The command `cancel-unbond` allow users to cancel the unbonding delegation entry and delegate back to the original validator. + +Usage: +```bash +simd tx staking cancel-unbond [validator-addr] [amount] [creation-height] +``` + +Example: +```bash +simd tx staking cancel-unbond cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake 123123 --from mykey +``` + ## gRPC diff --git a/x/staking/spec/README.md b/x/staking/spec/README.md index 688fd810afbb..08c21234e427 100644 --- a/x/staking/spec/README.md +++ b/x/staking/spec/README.md @@ -42,6 +42,7 @@ network. * [MsgEditValidator](03_messages.md#msgeditvalidator) * [MsgDelegate](03_messages.md#msgdelegate) * [MsgUndelegate](03_messages.md#msgundelegate) + * [MsgCancelUnbondingDelegation](03_messages.md#msgcancelunbondingdelegation) * [MsgBeginRedelegate](03_messages.md#msgbeginredelegate) 4. **[Begin-Block](04_begin_block.md)** * [Historical Info Tracking](04_begin_block.md#historical-info-tracking) diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index e26712ade2e4..1f9016cdbb6e 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -10,14 +10,11 @@ import ( // Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 const gasCostPerIteration = uint64(10) -// Normalized Msg type URLs -var ( - _ authz.Authorization = &StakeAuthorization{} -) +var _ authz.Authorization = &StakeAuthorization{} // NewStakeAuthorization creates a new StakeAuthorization object. func NewStakeAuthorization(allowed []sdk.ValAddress, denied []sdk.ValAddress, authzType AuthorizationType, amount *sdk.Coin) (*StakeAuthorization, error) { - allowedValidators, deniedValidators, err := validateAndBech32fy(allowed, denied) + allowedValidators, deniedValidators, err := validateAllowAndDenyValidators(allowed, denied) if err != nil { return nil, err } @@ -48,10 +45,10 @@ func (a StakeAuthorization) MsgTypeURL() string { func (a StakeAuthorization) ValidateBasic() error { if a.MaxTokens != nil && a.MaxTokens.IsNegative() { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "negative coin amount: %v", a.MaxTokens) + return sdkerrors.Wrapf(authz.ErrNegativeMaxTokens, "negative coin amount: %v", a.MaxTokens) } if a.AuthorizationType == AuthorizationType_AUTHORIZATION_TYPE_UNSPECIFIED { - return sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "unknown authorization type") + return authz.ErrUnknownAuthorizationType } return nil @@ -90,7 +87,7 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe for _, validator := range denyList { ctx.GasMeter().ConsumeGas(gasCostPerIteration, "stake authorization") if validator == validatorAddress { - return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf(" cannot delegate/undelegate to %s validator", validator) + return authz.AcceptResponse{}, sdkerrors.ErrUnauthorized.Wrapf("cannot delegate/undelegate to %s validator", validator) } } @@ -99,24 +96,26 @@ func (a StakeAuthorization) Accept(ctx sdk.Context, msg sdk.Msg) (authz.AcceptRe } if a.MaxTokens == nil { - return authz.AcceptResponse{Accept: true, Delete: false, - Updated: &StakeAuthorization{Validators: a.GetValidators(), AuthorizationType: a.GetAuthorizationType()}}, nil + return authz.AcceptResponse{ + Accept: true, Delete: false, + Updated: &StakeAuthorization{Validators: a.GetValidators(), AuthorizationType: a.GetAuthorizationType()}, + }, nil } - // check sufficient balance exists. - if _, isNegative := sdk.NewCoins(*a.MaxTokens).SafeSub(sdk.NewCoins(amount)); isNegative { - return authz.AcceptResponse{}, sdkerrors.ErrInsufficientFunds.Wrapf("amount is more than max tokens") + limitLeft, err := a.MaxTokens.SafeSub(amount) + if err != nil { + return authz.AcceptResponse{}, err } - - limitLeft := a.MaxTokens.Sub(amount) if limitLeft.IsZero() { return authz.AcceptResponse{Accept: true, Delete: true}, nil } - return authz.AcceptResponse{Accept: true, Delete: false, - Updated: &StakeAuthorization{Validators: a.GetValidators(), AuthorizationType: a.GetAuthorizationType(), MaxTokens: &limitLeft}}, nil + return authz.AcceptResponse{ + Accept: true, Delete: false, + Updated: &StakeAuthorization{Validators: a.GetValidators(), AuthorizationType: a.GetAuthorizationType(), MaxTokens: &limitLeft}, + }, nil } -func validateAndBech32fy(allowed []sdk.ValAddress, denied []sdk.ValAddress) ([]string, []string, error) { +func validateAllowAndDenyValidators(allowed []sdk.ValAddress, denied []sdk.ValAddress) ([]string, []string, error) { if len(allowed) == 0 && len(denied) == 0 { return nil, nil, sdkerrors.ErrInvalidRequest.Wrap("both allowed & deny list cannot be empty") } @@ -141,6 +140,7 @@ func validateAndBech32fy(allowed []sdk.ValAddress, denied []sdk.ValAddress) ([]s return nil, deniedValidators, nil } +// Normalized Msg type URLs func normalizeAuthzType(authzType AuthorizationType) (string, error) { switch authzType { case AuthorizationType_AUTHORIZATION_TYPE_DELEGATE: @@ -150,6 +150,6 @@ func normalizeAuthzType(authzType AuthorizationType) (string, error) { case AuthorizationType_AUTHORIZATION_TYPE_REDELEGATE: return sdk.MsgTypeURL(&MsgBeginRedelegate{}), nil default: - return "", sdkerrors.ErrInvalidType.Wrapf("unknown authorization type %T", authzType) + return "", sdkerrors.Wrapf(authz.ErrUnknownAuthorizationType, "cannot normalize authz type with %T", authzType) } } diff --git a/x/staking/types/authz_test.go b/x/staking/types/authz_test.go index 1f649f0a28a4..b794618b744b 100644 --- a/x/staking/types/authz_test.go +++ b/x/staking/types/authz_test.go @@ -94,7 +94,8 @@ func TestAuthzAuthorizations(t *testing.T) { &stakingtypes.StakeAuthorization{ Validators: &stakingtypes.StakeAuthorization_AllowList{ AllowList: &stakingtypes.StakeAuthorization_Validators{Address: validators1_2}, - }, MaxTokens: &coin50, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE}, + }, MaxTokens: &coin50, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, + }, }, { "delegate: testing with invalid validator", @@ -119,7 +120,8 @@ func TestAuthzAuthorizations(t *testing.T) { &stakingtypes.StakeAuthorization{ Validators: &stakingtypes.StakeAuthorization_AllowList{ AllowList: &stakingtypes.StakeAuthorization_Validators{Address: validators1_2}, - }, MaxTokens: nil, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE}, + }, MaxTokens: nil, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, + }, }, { "delegate: fail validator denied", @@ -144,7 +146,8 @@ func TestAuthzAuthorizations(t *testing.T) { &stakingtypes.StakeAuthorization{ Validators: &stakingtypes.StakeAuthorization_DenyList{ DenyList: &stakingtypes.StakeAuthorization_Validators{Address: []string{val1.String()}}, - }, MaxTokens: nil, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE}, + }, MaxTokens: nil, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_DELEGATE, + }, }, { "undelegate: expect 0 remaining coins", @@ -169,7 +172,8 @@ func TestAuthzAuthorizations(t *testing.T) { &stakingtypes.StakeAuthorization{ Validators: &stakingtypes.StakeAuthorization_AllowList{ AllowList: &stakingtypes.StakeAuthorization_Validators{Address: validators1_2}, - }, MaxTokens: &coin50, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_UNDELEGATE}, + }, MaxTokens: &coin50, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_UNDELEGATE, + }, }, { "undelegate: testing with invalid validator", @@ -194,7 +198,8 @@ func TestAuthzAuthorizations(t *testing.T) { &stakingtypes.StakeAuthorization{ Validators: &stakingtypes.StakeAuthorization_AllowList{ AllowList: &stakingtypes.StakeAuthorization_Validators{Address: validators1_2}, - }, MaxTokens: nil, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_UNDELEGATE}, + }, MaxTokens: nil, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_UNDELEGATE, + }, }, { "undelegate: fail cannot undelegate, permission denied", @@ -231,7 +236,8 @@ func TestAuthzAuthorizations(t *testing.T) { &stakingtypes.StakeAuthorization{ Validators: &stakingtypes.StakeAuthorization_AllowList{ AllowList: &stakingtypes.StakeAuthorization_Validators{Address: validators1_2}, - }, MaxTokens: &coin50, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_REDELEGATE}, + }, MaxTokens: &coin50, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_REDELEGATE, + }, }, { "redelegate: testing with invalid validator", @@ -256,7 +262,8 @@ func TestAuthzAuthorizations(t *testing.T) { &stakingtypes.StakeAuthorization{ Validators: &stakingtypes.StakeAuthorization_AllowList{ AllowList: &stakingtypes.StakeAuthorization_Validators{Address: validators1_2}, - }, MaxTokens: nil, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_REDELEGATE}, + }, MaxTokens: nil, AuthorizationType: stakingtypes.AuthorizationType_AUTHORIZATION_TYPE_REDELEGATE, + }, }, { "redelegate: fail cannot undelegate, permission denied", diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index ccc6ac358331..558f2eb038ad 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -4,9 +4,11 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" "github.com/cosmos/cosmos-sdk/x/authz" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" ) // RegisterLegacyAminoCodec registers the necessary x/staking interfaces and concrete types @@ -43,6 +45,17 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + func init() { - RegisterLegacyAminoCodec(legacy.Cdc) + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) } diff --git a/x/staking/types/delegation.go b/x/staking/types/delegation.go index f3412b5f8344..07438c4f40af 100644 --- a/x/staking/types/delegation.go +++ b/x/staking/types/delegation.go @@ -66,6 +66,7 @@ func (d Delegation) GetDelegatorAddr() sdk.AccAddress { } return delAddr } + func (d Delegation) GetValidatorAddr() sdk.ValAddress { addr, err := sdk.ValAddressFromBech32(d.ValidatorAddress) if err != nil { @@ -350,7 +351,8 @@ func NewRedelegationResponse( // NewRedelegationEntryResponse creates a new RedelegationEntryResponse instance. func NewRedelegationEntryResponse( - creationHeight int64, completionTime time.Time, sharesDst sdk.Dec, initialBalance, balance sdk.Int) RedelegationEntryResponse { + creationHeight int64, completionTime time.Time, sharesDst sdk.Dec, initialBalance, balance sdk.Int, +) RedelegationEntryResponse { return RedelegationEntryResponse{ RedelegationEntry: NewRedelegationEntry(creationHeight, completionTime, initialBalance, sharesDst), Balance: balance, diff --git a/x/staking/types/historical_info_test.go b/x/staking/types/historical_info_test.go index 66d3105897e1..da47623ac0c2 100644 --- a/x/staking/types/historical_info_test.go +++ b/x/staking/types/historical_info_test.go @@ -1,12 +1,13 @@ package types_test import ( - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/legacy" "math/rand" "sort" "testing" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/codec/legacy" + "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" diff --git a/x/staking/types/hooks.go b/x/staking/types/hooks.go index 33838bcaa030..93e0d21cc085 100644 --- a/x/staking/types/hooks.go +++ b/x/staking/types/hooks.go @@ -22,6 +22,7 @@ func (h MultiStakingHooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.Va return nil } + func (h MultiStakingHooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress) error { for i := range h { if err := h[i].BeforeValidatorModified(ctx, valAddr); err != nil { @@ -30,6 +31,7 @@ func (h MultiStakingHooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk. } return nil } + func (h MultiStakingHooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { for i := range h { if err := h[i].AfterValidatorRemoved(ctx, consAddr, valAddr); err != nil { @@ -38,6 +40,7 @@ func (h MultiStakingHooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.C } return nil } + func (h MultiStakingHooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { for i := range h { if err := h[i].AfterValidatorBonded(ctx, consAddr, valAddr); err != nil { @@ -46,6 +49,7 @@ func (h MultiStakingHooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.Co } return nil } + func (h MultiStakingHooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) error { for i := range h { if err := h[i].AfterValidatorBeginUnbonding(ctx, consAddr, valAddr); err != nil { @@ -54,6 +58,7 @@ func (h MultiStakingHooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAdd } return nil } + func (h MultiStakingHooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { for i := range h { if err := h[i].BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil { @@ -62,6 +67,7 @@ func (h MultiStakingHooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk. } return nil } + func (h MultiStakingHooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { for i := range h { if err := h[i].BeforeDelegationSharesModified(ctx, delAddr, valAddr); err != nil { @@ -70,6 +76,7 @@ func (h MultiStakingHooks) BeforeDelegationSharesModified(ctx sdk.Context, delAd } return nil } + func (h MultiStakingHooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { for i := range h { if err := h[i].BeforeDelegationRemoved(ctx, delAddr, valAddr); err != nil { @@ -78,6 +85,7 @@ func (h MultiStakingHooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk. } return nil } + func (h MultiStakingHooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error { for i := range h { if err := h[i].AfterDelegationModified(ctx, delAddr, valAddr); err != nil { @@ -86,6 +94,7 @@ func (h MultiStakingHooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk. } return nil } + func (h MultiStakingHooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) error { for i := range h { if err := h[i].BeforeValidatorSlashed(ctx, valAddr, fraction); err != nil { diff --git a/x/staking/types/keys_test.go b/x/staking/types/keys_test.go index 35667f949da5..20269e671baf 100644 --- a/x/staking/types/keys_test.go +++ b/x/staking/types/keys_test.go @@ -56,12 +56,18 @@ func TestGetREDByValDstIndexKey(t *testing.T) { valDstAddr sdk.ValAddress wantHex string }{ - {sdk.AccAddress(keysAddr1), sdk.ValAddress(keysAddr1), sdk.ValAddress(keysAddr1), - "361463d771218209d8bd03c482f69dfba57310f086091463d771218209d8bd03c482f69dfba57310f086091463d771218209d8bd03c482f69dfba57310f08609"}, - {sdk.AccAddress(keysAddr1), sdk.ValAddress(keysAddr2), sdk.ValAddress(keysAddr3), - "36143ab62f0d93849be495e21e3e9013a517038f45bd1463d771218209d8bd03c482f69dfba57310f08609145ef3b5f25c54946d4a89fc0d09d2f126614540f2"}, - {sdk.AccAddress(keysAddr2), sdk.ValAddress(keysAddr1), sdk.ValAddress(keysAddr3), - "36143ab62f0d93849be495e21e3e9013a517038f45bd145ef3b5f25c54946d4a89fc0d09d2f126614540f21463d771218209d8bd03c482f69dfba57310f08609"}, + { + sdk.AccAddress(keysAddr1), sdk.ValAddress(keysAddr1), sdk.ValAddress(keysAddr1), + "361463d771218209d8bd03c482f69dfba57310f086091463d771218209d8bd03c482f69dfba57310f086091463d771218209d8bd03c482f69dfba57310f08609", + }, + { + sdk.AccAddress(keysAddr1), sdk.ValAddress(keysAddr2), sdk.ValAddress(keysAddr3), + "36143ab62f0d93849be495e21e3e9013a517038f45bd1463d771218209d8bd03c482f69dfba57310f08609145ef3b5f25c54946d4a89fc0d09d2f126614540f2", + }, + { + sdk.AccAddress(keysAddr2), sdk.ValAddress(keysAddr1), sdk.ValAddress(keysAddr3), + "36143ab62f0d93849be495e21e3e9013a517038f45bd145ef3b5f25c54946d4a89fc0d09d2f126614540f21463d771218209d8bd03c482f69dfba57310f08609", + }, } for i, tt := range tests { got := hex.EncodeToString(types.GetREDByValDstIndexKey(tt.delAddr, tt.valSrcAddr, tt.valDstAddr)) @@ -77,12 +83,18 @@ func TestGetREDByValSrcIndexKey(t *testing.T) { valDstAddr sdk.ValAddress wantHex string }{ - {sdk.AccAddress(keysAddr1), sdk.ValAddress(keysAddr1), sdk.ValAddress(keysAddr1), - "351463d771218209d8bd03c482f69dfba57310f086091463d771218209d8bd03c482f69dfba57310f086091463d771218209d8bd03c482f69dfba57310f08609"}, - {sdk.AccAddress(keysAddr1), sdk.ValAddress(keysAddr2), sdk.ValAddress(keysAddr3), - "35145ef3b5f25c54946d4a89fc0d09d2f126614540f21463d771218209d8bd03c482f69dfba57310f08609143ab62f0d93849be495e21e3e9013a517038f45bd"}, - {sdk.AccAddress(keysAddr2), sdk.ValAddress(keysAddr1), sdk.ValAddress(keysAddr3), - "351463d771218209d8bd03c482f69dfba57310f08609145ef3b5f25c54946d4a89fc0d09d2f126614540f2143ab62f0d93849be495e21e3e9013a517038f45bd"}, + { + sdk.AccAddress(keysAddr1), sdk.ValAddress(keysAddr1), sdk.ValAddress(keysAddr1), + "351463d771218209d8bd03c482f69dfba57310f086091463d771218209d8bd03c482f69dfba57310f086091463d771218209d8bd03c482f69dfba57310f08609", + }, + { + sdk.AccAddress(keysAddr1), sdk.ValAddress(keysAddr2), sdk.ValAddress(keysAddr3), + "35145ef3b5f25c54946d4a89fc0d09d2f126614540f21463d771218209d8bd03c482f69dfba57310f08609143ab62f0d93849be495e21e3e9013a517038f45bd", + }, + { + sdk.AccAddress(keysAddr2), sdk.ValAddress(keysAddr1), sdk.ValAddress(keysAddr3), + "351463d771218209d8bd03c482f69dfba57310f08609145ef3b5f25c54946d4a89fc0d09d2f126614540f2143ab62f0d93849be495e21e3e9013a517038f45bd", + }, } for i, tt := range tests { got := hex.EncodeToString(types.GetREDByValSrcIndexKey(tt.delAddr, tt.valSrcAddr, tt.valDstAddr)) diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 2113f96207e5..a1ae89d15751 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -1,7 +1,6 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -79,7 +78,7 @@ func (msg MsgCreateValidator) GetSigners() []sdk.AccAddress { // GetSignBytes returns the message bytes to sign over. func (msg MsgCreateValidator) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -163,7 +162,7 @@ func (msg MsgEditValidator) GetSigners() []sdk.AccAddress { // GetSignBytes implements the sdk.Msg interface. func (msg MsgEditValidator) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -217,7 +216,7 @@ func (msg MsgDelegate) GetSigners() []sdk.AccAddress { // GetSignBytes implements the sdk.Msg interface. func (msg MsgDelegate) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -267,7 +266,7 @@ func (msg MsgBeginRedelegate) GetSigners() []sdk.AccAddress { // GetSignBytes implements the sdk.Msg interface. func (msg MsgBeginRedelegate) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -317,7 +316,7 @@ func (msg MsgUndelegate) GetSigners() []sdk.AccAddress { // GetSignBytes implements the sdk.Msg interface. func (msg MsgUndelegate) GetSignBytes() []byte { - bz := legacy.Cdc.MustMarshalJSON(&msg) + bz := ModuleCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -365,7 +364,7 @@ func (msg MsgCancelUnbondingDelegation) GetSigners() []sdk.AccAddress { // GetSignBytes implements the sdk.Msg interface. func (msg MsgCancelUnbondingDelegation) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) } // ValidateBasic implements the sdk.Msg interface. diff --git a/x/staking/types/params.go b/x/staking/types/params.go index cb9def63e00e..191b66e4c809 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -32,10 +32,8 @@ const ( DefaultHistoricalEntries uint32 = 10000 ) -var ( - // DefaultMinCommissionRate is set to 0% - DefaultMinCommissionRate = sdk.ZeroDec() -) +// DefaultMinCommissionRate is set to 0% +var DefaultMinCommissionRate = sdk.ZeroDec() var ( KeyUnbondingTime = []byte("UnbondingTime") diff --git a/x/staking/types/query.pb.go b/x/staking/types/query.pb.go index e1c04fd8666f..2e40de8c6f20 100644 --- a/x/staking/types/query.pb.go +++ b/x/staking/types/query.pb.go @@ -189,7 +189,7 @@ func (m *QueryValidatorRequest) GetValidatorAddr() string { // QueryValidatorResponse is response type for the Query/Validator RPC method type QueryValidatorResponse struct { - // validator defines the the validator info. + // validator defines the validator info. Validator Validator `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator"` } @@ -988,7 +988,7 @@ var xxx_messageInfo_QueryDelegatorValidatorsRequest proto.InternalMessageInfo // QueryDelegatorValidatorsResponse is response type for the // Query/DelegatorValidators RPC method. type QueryDelegatorValidatorsResponse struct { - // validators defines the the validators' info of a delegator. + // validators defines the validators' info of a delegator. Validators []Validator `protobuf:"bytes,1,rep,name=validators,proto3" json:"validators"` // pagination defines the pagination in the response. Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` @@ -1086,7 +1086,7 @@ var xxx_messageInfo_QueryDelegatorValidatorRequest proto.InternalMessageInfo // QueryDelegatorValidatorResponse response type for the // Query/DelegatorValidator RPC method. type QueryDelegatorValidatorResponse struct { - // validator defines the the validator info. + // validator defines the validator info. Validator Validator `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator"` } diff --git a/x/staking/types/staking.pb.go b/x/staking/types/staking.pb.go index dff78e00659d..8dbfa99ae59f 100644 --- a/x/staking/types/staking.pb.go +++ b/x/staking/types/staking.pb.go @@ -333,6 +333,8 @@ type Validator struct { // commission defines the commission parameters. Commission Commission `protobuf:"bytes,10,opt,name=commission,proto3" json:"commission"` // min_self_delegation is the validator's self declared minimum self delegation. + // + // Since: cosmos-sdk 0.46 MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation"` } diff --git a/x/staking/types/tx.pb.go b/x/staking/types/tx.pb.go index 750593b36f58..040c6a9233f4 100644 --- a/x/staking/types/tx.pb.go +++ b/x/staking/types/tx.pb.go @@ -452,6 +452,8 @@ func (m *MsgUndelegateResponse) GetCompletionTime() time.Time { } // MsgCancelUnbondingDelegation defines the SDK message for performing a cancel unbonding delegation for delegator +// +// Since: cosmos-sdk 0.46 type MsgCancelUnbondingDelegation struct { DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` @@ -495,6 +497,8 @@ func (m *MsgCancelUnbondingDelegation) XXX_DiscardUnknown() { var xxx_messageInfo_MsgCancelUnbondingDelegation proto.InternalMessageInfo // MsgCancelUnbondingDelegationResponse +// +// Since: cosmos-sdk 0.46 type MsgCancelUnbondingDelegationResponse struct { } @@ -638,6 +642,8 @@ type MsgClient interface { Undelegate(ctx context.Context, in *MsgUndelegate, opts ...grpc.CallOption) (*MsgUndelegateResponse, error) // CancelUnbondingDelegation defines a method for performing canceling the unbonding delegation // and delegate back to previous validator. + // + // Since: cosmos-sdk 0.46 CancelUnbondingDelegation(ctx context.Context, in *MsgCancelUnbondingDelegation, opts ...grpc.CallOption) (*MsgCancelUnbondingDelegationResponse, error) } @@ -720,6 +726,8 @@ type MsgServer interface { Undelegate(context.Context, *MsgUndelegate) (*MsgUndelegateResponse, error) // CancelUnbondingDelegation defines a method for performing canceling the unbonding delegation // and delegate back to previous validator. + // + // Since: cosmos-sdk 0.46 CancelUnbondingDelegation(context.Context, *MsgCancelUnbondingDelegation) (*MsgCancelUnbondingDelegationResponse, error) } diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 79bd2a4f55b1..4296181ec9b5 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -342,7 +342,7 @@ func (v Validator) SharesFromTokensTruncated(amt sdk.Int) (sdk.Dec, error) { return sdk.ZeroDec(), ErrInsufficientShares } - return v.GetDelegatorShares().MulInt(amt).QuoTruncate(v.GetTokens().ToDec()), nil + return v.GetDelegatorShares().MulInt(amt).QuoTruncate(sdk.NewDecFromInt(v.GetTokens())), nil } // get the bonded tokens which the validator holds @@ -382,7 +382,7 @@ func (v Validator) AddTokensFromDel(amount sdk.Int) (Validator, sdk.Dec) { var issuedShares sdk.Dec if v.DelegatorShares.IsZero() { // the first delegation to a validator sets the exchange rate to one - issuedShares = amount.ToDec() + issuedShares = sdk.NewDecFromInt(amount) } else { shares, err := v.SharesFromTokens(amount) if err != nil { @@ -452,7 +452,6 @@ func (v *Validator) MinEqual(other *Validator) bool { v.Jailed == other.Jailed && v.MinSelfDelegation.Equal(other.MinSelfDelegation) && v.ConsensusPubkey.Equal(other.ConsensusPubkey) - } // Equal checks if the receiver equals the parameter @@ -484,7 +483,6 @@ func (v Validator) ConsPubKey() (cryptotypes.PubKey, error) { } return pk, nil - } // TmConsPublicKey casts Validator.ConsensusPubkey to tmprotocrypto.PubKey. diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index 8601fbeec723..6e3172e51db2 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -121,7 +121,6 @@ func TestAddTokensValidatorUnbonding(t *testing.T) { } func TestAddTokensValidatorUnbonded(t *testing.T) { - validator := newValidator(t, valAddr1, pk1) validator = validator.UpdateStatus(types.Unbonded) validator, delShares := validator.AddTokensFromDel(sdk.NewInt(10)) diff --git a/x/upgrade/abci.go b/x/upgrade/abci.go index f390a873d134..5212cd9e2ed5 100644 --- a/x/upgrade/abci.go +++ b/x/upgrade/abci.go @@ -35,7 +35,14 @@ func BeginBlocker(k keeper.Keeper, ctx sdk.Context, _ abci.RequestBeginBlock) { // 3. If the plan is ready and skip upgrade height is set for current height. if !found || !plan.ShouldExecute(ctx) || (plan.ShouldExecute(ctx) && k.IsSkipHeight(ctx.BlockHeight())) { if lastAppliedPlan != "" && !k.HasHandler(lastAppliedPlan) { - panic(fmt.Sprintf("Wrong app version %d, upgrade handler is missing for %s upgrade plan", ctx.ConsensusParams().Version.AppVersion, lastAppliedPlan)) + var appVersion uint64 + + cp := ctx.ConsensusParams() + if cp != nil && cp.Version != nil { + appVersion = cp.Version.AppVersion + } + + panic(fmt.Sprintf("Wrong app version %d, upgrade handler is missing for %s upgrade plan", appVersion, lastAppliedPlan)) } } } diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go index 280824463fd5..1444ea49d034 100644 --- a/x/upgrade/abci_test.go +++ b/x/upgrade/abci_test.go @@ -34,7 +34,6 @@ type TestSuite struct { var s TestSuite func setupTest(t *testing.T, height int64, skip map[int64]bool) TestSuite { - db := memdb.NewDB() app := simapp.NewSimappWithCustomOptions(t, false, simapp.SetupOptions{ Logger: log.NewNopLogger(), @@ -59,14 +58,14 @@ func TestRequireName(t *testing.T) { s := setupTest(t, 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(t, 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) } @@ -74,7 +73,7 @@ func TestDoHeightUpgrade(t *testing.T) { s := setupTest(t, 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) } @@ -83,9 +82,9 @@ func TestCanOverwriteScheduleUpgrade(t *testing.T) { s := setupTest(t, 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) } @@ -132,7 +131,7 @@ func TestHaltIfTooNew(t *testing.T) { s := setupTest(t, 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 }) @@ -175,10 +174,10 @@ func TestCanClear(t *testing.T) { s := setupTest(t, 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) } @@ -187,11 +186,11 @@ func TestCantApplySameUpgradeTwice(t *testing.T) { s := setupTest(t, 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) } @@ -237,9 +236,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(t, 10, map[int64]bool{skipOne: true}) VerifySet(t, map[int64]bool{skipOne: true}) @@ -298,7 +295,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}) @@ -311,7 +308,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") @@ -333,7 +330,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}) @@ -346,7 +343,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() { @@ -355,7 +352,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") @@ -370,7 +367,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) @@ -437,7 +434,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{ @@ -454,7 +451,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/client/cli/parse.go b/x/upgrade/client/cli/parse.go index 2844e73dcdf6..8272266b6fb1 100644 --- a/x/upgrade/client/cli/parse.go +++ b/x/upgrade/client/cli/parse.go @@ -4,26 +4,26 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov/client/cli" gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/spf13/cobra" + "github.com/spf13/pflag" ) -func parseArgsToContent(cmd *cobra.Command, name string) (gov.Content, error) { - title, err := cmd.Flags().GetString(cli.FlagTitle) +func parseArgsToContent(fs *pflag.FlagSet, name string) (gov.Content, error) { + title, err := fs.GetString(cli.FlagTitle) if err != nil { return nil, err } - description, err := cmd.Flags().GetString(cli.FlagDescription) + description, err := fs.GetString(cli.FlagDescription) if err != nil { return nil, err } - height, err := cmd.Flags().GetInt64(FlagUpgradeHeight) + height, err := fs.GetInt64(FlagUpgradeHeight) if err != nil { return nil, err } - info, err := cmd.Flags().GetString(FlagUpgradeInfo) + info, err := fs.GetString(FlagUpgradeInfo) if err != nil { return nil, err } diff --git a/x/upgrade/client/cli/parse_test.go b/x/upgrade/client/cli/parse_test.go new file mode 100644 index 000000000000..b5ce54e4b179 --- /dev/null +++ b/x/upgrade/client/cli/parse_test.go @@ -0,0 +1,40 @@ +package cli + +import ( + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/stretchr/testify/require" +) + +func TestParseArgsToContent(t *testing.T) { + fs := NewCmdSubmitLegacyUpgradeProposal().Flags() + + proposal := types.SoftwareUpgradeProposal{ + Title: "proposal title", + Description: "proposal description", + Plan: types.Plan{ + Name: "plan name", + Height: 123456, + Info: "plan info", + }, + } + + fs.Set(cli.FlagTitle, proposal.Title) + fs.Set(cli.FlagDescription, proposal.Description) + fs.Set(FlagUpgradeHeight, strconv.FormatInt(proposal.Plan.Height, 10)) + fs.Set(FlagUpgradeInfo, proposal.Plan.Info) + + content, err := parseArgsToContent(fs, proposal.Plan.Name) + require.NoError(t, err) + + p, ok := content.(*types.SoftwareUpgradeProposal) + require.Equal(t, ok, true) + require.Equal(t, p.Title, proposal.Title) + require.Equal(t, p.Description, proposal.Description) + require.Equal(t, p.Plan.Name, proposal.Plan.Name) + require.Equal(t, p.Plan.Height, proposal.Plan.Height) + require.Equal(t, p.Plan.Info, proposal.Plan.Info) +} diff --git a/x/upgrade/client/cli/tx.go b/x/upgrade/client/cli/tx.go index b4ad5e366806..6a54d8db3838 100644 --- a/x/upgrade/client/cli/tx.go +++ b/x/upgrade/client/cli/tx.go @@ -38,19 +38,19 @@ func GetTxCmd() *cobra.Command { // Deprecated: please use NewCmdSubmitUpgradeProposal instead. func NewCmdSubmitLegacyUpgradeProposal() *cobra.Command { cmd := &cobra.Command{ - Use: "legacy-software-upgrade [name] (--upgrade-height [height]) (--upgrade-info [info]) [flags]", + Use: "software-upgrade [name] (--upgrade-height [height]) (--upgrade-info [info]) [flags]", Args: cobra.ExactArgs(1), Short: "Submit a software upgrade proposal", Long: "Submit a software upgrade along with an initial deposit.\n" + "Please specify a unique name and height for the upgrade to take effect.\n" + - "You may include info to reference a binary download link, in a format compatible with: https://github.com/cosmos/cosmos-sdk/tree/master/cosmovisor", + "You may include info to reference a binary download link, in a format compatible with: https://github.com/cosmos/cosmos-sdk/tree/main/cosmovisor", RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } name := args[0] - content, err := parseArgsToContent(cmd, name) + content, err := parseArgsToContent(cmd.Flags(), name) if err != nil { return err } @@ -108,7 +108,7 @@ func NewCmdSubmitLegacyUpgradeProposal() *cobra.Command { // Deprecated: please use NewCmdSubmitCancelUpgradeProposal instead. func NewCmdSubmitLegacyCancelUpgradeProposal() *cobra.Command { cmd := &cobra.Command{ - Use: "legacy-cancel-software-upgrade [flags]", + Use: "cancel-software-upgrade [flags]", Args: cobra.ExactArgs(0), Short: "Cancel the current software upgrade proposal", Long: "Cancel a software upgrade along with an initial deposit.", @@ -163,7 +163,7 @@ func NewCmdSubmitLegacyCancelUpgradeProposal() *cobra.Command { // If a DAEMON_NAME env var is set, that is used. // Otherwise, the last part of the currently running executable is used. func getDefaultDaemonName() string { - // DAEMON_NAME is specifically used here to correspond with the Comsovisor setup env vars. + // DAEMON_NAME is specifically used here to correspond with the Cosmovisor setup env vars. name := os.Getenv("DAEMON_NAME") if len(name) == 0 { _, name = filepath.Split(os.Args[0]) diff --git a/x/upgrade/client/proposal_handler.go b/x/upgrade/client/proposal_handler.go index 082924787441..fb4a879fffec 100644 --- a/x/upgrade/client/proposal_handler.go +++ b/x/upgrade/client/proposal_handler.go @@ -5,5 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/upgrade/client/cli" ) -var LegacyProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitLegacyUpgradeProposal) -var LegacyCancelProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitLegacyCancelUpgradeProposal) +var ( + LegacyProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitLegacyUpgradeProposal) + LegacyCancelProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitLegacyCancelUpgradeProposal) +) diff --git a/x/upgrade/client/testutil/suite.go b/x/upgrade/client/testutil/suite.go index 7611c8bb8fd5..d5e21ce47ae6 100644 --- a/x/upgrade/client/testutil/suite.go +++ b/x/upgrade/client/testutil/suite.go @@ -86,7 +86,6 @@ func (s *IntegrationTestSuite) TestModuleVersionsCLI() { for _, tc := range testCases { s.Run(fmt.Sprintf("Case %s", tc.msg), func() { - expect := mv if tc.expPass { if tc.single { diff --git a/x/upgrade/keeper/grpc_query.go b/x/upgrade/keeper/grpc_query.go index 5757a05f996f..3c9e667ac935 100644 --- a/x/upgrade/keeper/grpc_query.go +++ b/x/upgrade/keeper/grpc_query.go @@ -71,7 +71,7 @@ func (k Keeper) ModuleVersions(c context.Context, req *types.QueryModuleVersions }, nil } -// Authority implementsthe the Query/Authority gRPC method, returning the account capable of performing upgrades +// Authority implements the Query/Authority gRPC method, returning the account capable of performing upgrades func (k Keeper) Authority(c context.Context, req *types.QueryAuthorityRequest) (*types.QueryAuthorityResponse, error) { return &types.QueryAuthorityResponse{Address: k.authority}, nil } diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index 52b47755b977..17f0d6f87acb 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -14,7 +14,6 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/internal/conv" "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -167,14 +166,16 @@ func (k Keeper) getModuleVersion(ctx sdk.Context, name string) (uint64, bool) { // ScheduleUpgrade schedules an upgrade based on the specified plan. // If there is another Plan already scheduled, it will cancel and overwrite it. -// ScheduleUpgrade will also write the upgraded client to the upgraded client path -// if an upgraded client is specified in the plan +// ScheduleUpgrade will also write the upgraded IBC ClientState to the upgraded client +// path if it is specified in the plan. func (k Keeper) ScheduleUpgrade(ctx sdk.Context, plan types.Plan) error { if err := plan.ValidateBasic(); err != nil { 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") } @@ -237,28 +238,43 @@ func (k Keeper) GetUpgradedConsensusState(ctx sdk.Context, lastHeight int64) ([] func (k Keeper) GetLastCompletedUpgrade(ctx sdk.Context) (string, int64) { iter := sdk.KVStoreReversePrefixIterator(ctx.KVStore(k.storeKey), []byte{types.DoneByte}) defer iter.Close() + if iter.Valid() { - return parseDoneKey(iter.Key()), int64(binary.BigEndian.Uint64(iter.Value())) + return parseDoneKey(iter.Key()) } return "", 0 } -// parseDoneKey - split upgrade name from the done key -func parseDoneKey(key []byte) string { - kv.AssertKeyAtLeastLength(key, 2) - return string(key[1:]) +// parseDoneKey - split upgrade name and height from the done key +func parseDoneKey(key []byte) (string, int64) { + // 1 byte for the DoneByte + 8 bytes height + at least 1 byte for the name + kv.AssertKeyAtLeastLength(key, 10) + height := binary.BigEndian.Uint64(key[1:9]) + return string(key[9:]), int64(height) +} + +// encodeDoneKey - concatenate DoneByte, height and upgrade name to form the done key +func encodeDoneKey(name string, height int64) []byte { + key := make([]byte, 9+len(name)) // 9 = donebyte + uint64 len + key[0] = types.DoneByte + binary.BigEndian.PutUint64(key[1:9], uint64(height)) + copy(key[9:], name) + return key } // GetDoneHeight returns the height at which the given upgrade was executed func (k Keeper) GetDoneHeight(ctx sdk.Context, name string) int64 { - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{types.DoneByte}) - bz := store.Get(conv.UnsafeStrToBytes(name)) - if len(bz) == 0 { - return 0 - } + iter := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), []byte{types.DoneByte}) + defer iter.Close() - return int64(binary.BigEndian.Uint64(bz)) + for ; iter.Valid(); iter.Next() { + upgradeName, height := parseDoneKey(iter.Key()) + if upgradeName == name { + return height + } + } + return 0 } // ClearIBCState clears any planned IBC state @@ -301,10 +317,8 @@ func (k Keeper) GetUpgradePlan(ctx sdk.Context) (plan types.Plan, havePlan bool) // setDone marks this upgrade name as being done so the name can't be reused accidentally func (k Keeper) setDone(ctx sdk.Context, name string) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), []byte{types.DoneByte}) - bz := make([]byte, 8) - binary.BigEndian.PutUint64(bz, uint64(ctx.BlockHeight())) - store.Set([]byte(name), bz) + store := ctx.KVStore(k.storeKey) + store.Set(encodeDoneKey(name, ctx.BlockHeight()), []byte{1}) } // HasHandler returns true iff there is a handler registered for this name @@ -364,7 +378,7 @@ func (k Keeper) DumpUpgradeInfoToDisk(height int64, p types.Plan) error { return err } - return os.WriteFile(upgradeInfoFilePath, info, 0600) + return os.WriteFile(upgradeInfoFilePath, info, 0o600) } // GetUpgradeInfoPath returns the upgrade info file path @@ -412,6 +426,11 @@ func (k Keeper) ReadUpgradeInfoFromDisk() (types.Plan, error) { return upgradeInfo, nil } +// SetVersionSetter upgrades versionSetter. +func (k *Keeper) SetVersionSetter(vs xp.ProtocolVersionSetter) { + k.versionSetter = vs +} + // SetDowngradeVerified updates downgradeVerified. func (k *Keeper) SetDowngradeVerified(v bool) { k.downgradeVerified = v diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index a91b0b748d21..19fee1054ec9 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -198,7 +198,6 @@ func (s *KeeperTestSuite) TestSetUpgradedClient() { s.Require().False(exists, "invalid case: %s retrieved valid client state", tc.name) } } - } // Test that the protocol version successfully increments after an @@ -278,6 +277,42 @@ func (s *KeeperTestSuite) TestLastCompletedUpgrade() { require.Equal(int64(15), height) } +// This test ensures that `GetLastDoneUpgrade` always returns the last upgrade according to the block height +// it was executed at, rather than using an ordering based on upgrade names. +func (s *KeeperTestSuite) TestLastCompletedUpgradeOrdering() { + keeper := s.app.UpgradeKeeper + require := s.Require() + + // apply first upgrade + keeper.SetUpgradeHandler("test-v0.9", func(_ sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) { + return vm, nil + }) + + keeper.ApplyUpgrade(s.ctx, types.Plan{ + Name: "test-v0.9", + Height: 10, + }) + + name, height := keeper.GetLastCompletedUpgrade(s.ctx) + require.Equal("test-v0.9", name) + require.Equal(int64(10), height) + + // apply second upgrade + keeper.SetUpgradeHandler("test-v0.10", func(_ sdk.Context, _ types.Plan, vm module.VersionMap) (module.VersionMap, error) { + return vm, nil + }) + + newCtx := s.ctx.WithBlockHeight(15) + keeper.ApplyUpgrade(newCtx, types.Plan{ + Name: "test-v0.10", + Height: 15, + }) + + name, height = keeper.GetLastCompletedUpgrade(newCtx) + require.Equal("test-v0.10", name) + require.Equal(int64(15), height) +} + func TestKeeperTestSuite(t *testing.T) { suite.Run(t, new(KeeperTestSuite)) } diff --git a/x/upgrade/keeper/migrations.go b/x/upgrade/keeper/migrations.go new file mode 100644 index 000000000000..2415bc1f6227 --- /dev/null +++ b/x/upgrade/keeper/migrations.go @@ -0,0 +1,43 @@ +package keeper + +import ( + "encoding/binary" + + "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/upgrade/types" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + keeper Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(keeper Keeper) Migrator { + return Migrator{keeper: keeper} +} + +// Migrate1to2 migrates from version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + return migrateDoneUpgradeKeys(ctx, m.keeper.storeKey) +} + +func migrateDoneUpgradeKeys(ctx sdk.Context, storeKey storetypes.StoreKey) error { + store := ctx.KVStore(storeKey) + oldDoneStore := prefix.NewStore(store, []byte{types.DoneByte}) + oldDoneStoreIter := oldDoneStore.Iterator(nil, nil) + defer oldDoneStoreIter.Close() + + for ; oldDoneStoreIter.Valid(); oldDoneStoreIter.Next() { + oldKey := oldDoneStoreIter.Key() + upgradeName := string(oldKey) + upgradeHeight := int64(binary.BigEndian.Uint64(oldDoneStoreIter.Value())) + newKey := encodeDoneKey(upgradeName, upgradeHeight) + + store.Set(newKey, []byte{1}) + oldDoneStore.Delete(oldKey) + } + return nil +} diff --git a/x/upgrade/keeper/migrations_test.go b/x/upgrade/keeper/migrations_test.go new file mode 100644 index 000000000000..2e1be7454845 --- /dev/null +++ b/x/upgrade/keeper/migrations_test.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "encoding/binary" + "testing" + + "github.com/cosmos/cosmos-sdk/testutil" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/stretchr/testify/require" +) + +type storedUpgrade struct { + name string + height int64 +} + +func encodeOldDoneKey(upgrade storedUpgrade) []byte { + return append([]byte{types.DoneByte}, []byte(upgrade.name)...) +} + +func TestMigrateDoneUpgradeKeys(t *testing.T) { + upgradeKey := sdk.NewKVStoreKey("upgrade") + ctx := testutil.DefaultContext(upgradeKey, sdk.NewTransientStoreKey("transient_test")) + store := ctx.KVStore(upgradeKey) + + testCases := []struct { + name string + upgrades []storedUpgrade + }{ + { + name: "valid upgrades", + upgrades: []storedUpgrade{ + {name: "some-other-upgrade", height: 1}, + {name: "test02", height: 2}, + {name: "test01", height: 3}, + }, + }, + } + + for _, tc := range testCases { + for _, upgrade := range tc.upgrades { + bz := make([]byte, 8) + binary.BigEndian.PutUint64(bz, uint64(upgrade.height)) + oldKey := encodeOldDoneKey(upgrade) + store.Set(oldKey, bz) + } + + err := migrateDoneUpgradeKeys(ctx, upgradeKey) + require.NoError(t, err) + + for _, upgrade := range tc.upgrades { + newKey := encodeDoneKey(upgrade.name, upgrade.height) + oldKey := encodeOldDoneKey(upgrade) + require.Nil(t, store.Get(oldKey)) + require.Equal(t, []byte{1}, store.Get(newKey)) + } + } +} diff --git a/x/upgrade/keeper/msg_server_test.go b/x/upgrade/keeper/msg_server_test.go index 00af9e06563e..a83cdc09b7ac 100644 --- a/x/upgrade/keeper/msg_server_test.go +++ b/x/upgrade/keeper/msg_server_test.go @@ -57,6 +57,58 @@ func (s *KeeperTestSuite) TestSoftwareUpgrade() { if tc.expectErr { s.Require().Error(err) s.Require().Contains(err.Error(), tc.errMsg) + } else { + s.Require().NoError(err) + plan, found := s.app.UpgradeKeeper.GetUpgradePlan(s.ctx) + s.Require().Equal(true, found) + s.Require().Equal(tc.req.Plan, plan) + } + }) + } +} + +func (s *KeeperTestSuite) TestCancelUpgrade() { + govAccAddr := s.app.GovKeeper.GetGovernanceAccount(s.ctx).GetAddress().String() + err := s.app.UpgradeKeeper.ScheduleUpgrade(s.ctx, types.Plan{ + Name: "some name", + Info: "some info", + Height: 123450000, + }) + s.Require().NoError(err) + + testCases := []struct { + name string + req *types.MsgCancelUpgrade + expectErr bool + errMsg string + }{ + { + "unauthorized authority address", + &types.MsgCancelUpgrade{ + Authority: s.addrs[0].String(), + }, + true, + "expected gov account as only signer for proposal message", + }, + { + "upgrade cancelled successfully", + &types.MsgCancelUpgrade{ + Authority: govAccAddr, + }, + false, + "", + }, + } + for _, tc := range testCases { + s.Run(tc.name, func() { + _, err := s.msgSrvr.CancelUpgrade(s.ctx, tc.req) + if tc.expectErr { + s.Require().Error(err) + s.Require().Contains(err.Error(), tc.errMsg) + } else { + s.Require().NoError(err) + _, found := s.app.UpgradeKeeper.GetUpgradePlan(s.ctx) + s.Require().Equal(false, found) } }) } diff --git a/x/upgrade/migrations/v038/types.go b/x/upgrade/migrations/v038/types.go deleted file mode 100644 index 1a3ebd0ff623..000000000000 --- a/x/upgrade/migrations/v038/types.go +++ /dev/null @@ -1,170 +0,0 @@ -// Package v038 is used for legacy migration scripts. Actual migration scripts -// for v038 have been removed, but the v039->v042 migration script still -// references types from this file, so we're keeping it for now. -package v038 - -import ( - "fmt" - "strings" - "time" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - v036gov "github.com/cosmos/cosmos-sdk/x/gov/migrations/v036" -) - -const ( - // ModuleName is the name of this module - ModuleName = "upgrade" - - // RouterKey is used to route governance proposals - RouterKey = ModuleName - - // StoreKey is the prefix under which we store this module's data - StoreKey = ModuleName - - // QuerierKey is used to handle abci_query requests - QuerierKey = ModuleName -) - -// Plan specifies information about a planned upgrade and when it should occur -type Plan struct { - // Sets the name for the upgrade. This name will be used by the upgraded version of the software to apply any - // special "on-upgrade" commands during the first BeginBlock method after the upgrade is applied. It is also used - // to detect whether a software version can handle a given upgrade. If no upgrade handler with this name has been - // set in the software, it will be assumed that the software is out-of-date when the upgrade Time or Height - // is reached and the software will exit. - Name string `json:"name,omitempty"` - - // The time after which the upgrade must be performed. - // Leave set to its zero value to use a pre-defined Height instead. - Time time.Time `json:"time,omitempty"` - - // The height at which the upgrade must be performed. - // Only used if Time is not set. - Height int64 `json:"height,omitempty"` - - // Any application specific upgrade info to be included on-chain - // such as a git commit that validators could automatically upgrade to - Info string `json:"info,omitempty"` -} - -func (p Plan) String() string { - due := p.DueAt() - dueUp := strings.ToUpper(due[0:1]) + due[1:] - return fmt.Sprintf(`Upgrade Plan - Name: %s - %s - Info: %s`, p.Name, dueUp, p.Info) -} - -// ValidateBasic does basic validation of a Plan -func (p Plan) ValidateBasic() error { - if len(p.Name) == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "name cannot be empty") - } - if p.Height < 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "height cannot be negative") - } - isValidTime := p.Time.Unix() > 0 - if !isValidTime && p.Height == 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "must set either time or height") - } - if isValidTime && p.Height != 0 { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "cannot set both time and height") - } - - return nil -} - -// ShouldExecute returns true if the Plan is ready to execute given the current context -func (p Plan) ShouldExecute(ctx sdk.Context) bool { - if p.Time.Unix() > 0 { - return !ctx.BlockTime().Before(p.Time) - } - if p.Height > 0 { - return p.Height <= ctx.BlockHeight() - } - return false -} - -// DueAt is a string representation of when this plan is due to be executed -func (p Plan) DueAt() string { - if p.Time.Unix() > 0 { - return fmt.Sprintf("time: %s", p.Time.UTC().Format(time.RFC3339)) - } - return fmt.Sprintf("height: %d", p.Height) -} - -const ( - ProposalTypeSoftwareUpgrade string = "SoftwareUpgrade" - ProposalTypeCancelSoftwareUpgrade string = "CancelSoftwareUpgrade" -) - -// Software Upgrade Proposals -type SoftwareUpgradeProposal struct { - Title string `json:"title" yaml:"title"` - Description string `json:"description" yaml:"description"` - Plan Plan `json:"plan" yaml:"plan"` -} - -func NewSoftwareUpgradeProposal(title, description string, plan Plan) v036gov.Content { - return SoftwareUpgradeProposal{title, description, plan} -} - -// Implements Proposal Interface -var _ v036gov.Content = SoftwareUpgradeProposal{} - -func (sup SoftwareUpgradeProposal) GetTitle() string { return sup.Title } -func (sup SoftwareUpgradeProposal) GetDescription() string { return sup.Description } -func (sup SoftwareUpgradeProposal) ProposalRoute() string { return RouterKey } -func (sup SoftwareUpgradeProposal) ProposalType() string { return ProposalTypeSoftwareUpgrade } -func (sup SoftwareUpgradeProposal) ValidateBasic() error { - if err := sup.Plan.ValidateBasic(); err != nil { - return err - } - return v036gov.ValidateAbstract(sup) -} - -func (sup SoftwareUpgradeProposal) String() string { - return fmt.Sprintf(`Software Upgrade Proposal: - Title: %s - Description: %s -`, sup.Title, sup.Description) -} - -// Cancel Software Upgrade Proposals -type CancelSoftwareUpgradeProposal struct { - Title string `json:"title" yaml:"title"` - Description string `json:"description" yaml:"description"` -} - -func NewCancelSoftwareUpgradeProposal(title, description string) v036gov.Content { - return CancelSoftwareUpgradeProposal{title, description} -} - -// Implements Proposal Interface -var _ v036gov.Content = CancelSoftwareUpgradeProposal{} - -func (sup CancelSoftwareUpgradeProposal) GetTitle() string { return sup.Title } -func (sup CancelSoftwareUpgradeProposal) GetDescription() string { return sup.Description } -func (sup CancelSoftwareUpgradeProposal) ProposalRoute() string { return RouterKey } -func (sup CancelSoftwareUpgradeProposal) ProposalType() string { - return ProposalTypeCancelSoftwareUpgrade -} -func (sup CancelSoftwareUpgradeProposal) ValidateBasic() error { - return v036gov.ValidateAbstract(sup) -} - -func (sup CancelSoftwareUpgradeProposal) String() string { - return fmt.Sprintf(`Cancel Software Upgrade Proposal: - Title: %s - Description: %s -`, sup.Title, sup.Description) -} - -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil) - cdc.RegisterConcrete(CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal", nil) -} diff --git a/x/upgrade/module.go b/x/upgrade/module.go index 045d23370586..e4e2ad5a006e 100644 --- a/x/upgrade/module.go +++ b/x/upgrade/module.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" @@ -23,6 +22,10 @@ func init() { types.RegisterLegacyAminoCodec(codec.NewLegacyAmino()) } +const ( + consensusVersion uint64 = 2 +) + var ( _ module.AppModule = AppModule{} _ module.AppModuleBasic = AppModuleBasic{} @@ -41,11 +44,6 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { types.RegisterLegacyAminoCodec(cdc) } -// RegisterRESTRoutes registers the REST routes for the upgrade module. -// Deprecated: RegisterRESTRoutes is deprecated. `x/upgrade` legacy REST implementation -// has been removed from the SDK. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the upgrade module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { @@ -101,6 +99,9 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd func (am AppModule) RegisterServices(cfg module.Configurator) { types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + m := keeper.NewMigrator(am.keeper) + cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2) } // InitGenesis is ignored, no sense in serializing future upgrades @@ -124,7 +125,7 @@ func (am AppModule) ExportGenesis(_ sdk.Context, cdc codec.JSONCodec) json.RawMe } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 1 } +func (AppModule) ConsensusVersion() uint64 { return consensusVersion } // BeginBlock calls the upgrade module hooks // diff --git a/x/upgrade/plan/downloader.go b/x/upgrade/plan/downloader.go index 0879b8badbfe..7686b7aec823 100644 --- a/x/upgrade/plan/downloader.go +++ b/x/upgrade/plan/downloader.go @@ -88,7 +88,7 @@ func EnsureBinary(path string) error { } // Make sure all executable bits are set. oldMode := info.Mode().Perm() - newMode := oldMode | 0111 // Set the three execute bits to on (a+x). + newMode := oldMode | 0o111 // Set the three execute bits to on (a+x). if oldMode != newMode { return os.Chmod(path, newMode) } diff --git a/x/upgrade/plan/downloader_test.go b/x/upgrade/plan/downloader_test.go index 6e10b6de4c78..3d50e9f13a44 100644 --- a/x/upgrade/plan/downloader_test.go +++ b/x/upgrade/plan/downloader_test.go @@ -24,7 +24,7 @@ type DownloaderTestSuite struct { func (s *DownloaderTestSuite) SetupTest() { s.Home = s.T().TempDir() - s.Assert().NoError(os.MkdirAll(filepath.Join(s.Home, "src"), 0777), "creating src/ dir") + s.Assert().NoError(os.MkdirAll(filepath.Join(s.Home, "src"), 0o777), "creating src/ dir") s.T().Logf("Home: [%s]", s.Home) } @@ -115,7 +115,7 @@ func requireFileExistsAndIsExecutable(t *testing.T, path string) { require.NoError(t, err, "stat error") perm := info.Mode().Perm() // Checks if at least one executable bit is set (user, group, or other) - isExe := perm&0111 != 0 + isExe := perm&0o111 != 0 require.True(t, isExe, "is executable: permissions = %s", perm) } @@ -219,9 +219,9 @@ func (s *DownloaderTestSuite) TestDownloadUpgrade() { func (s *DownloaderTestSuite) TestEnsureBinary() { nonExeName := s.saveSrcTestFile(NewTestFile("non-exe.txt", "Not executable")) - s.Require().NoError(os.Chmod(nonExeName, 0600), "chmod error nonExeName") + s.Require().NoError(os.Chmod(nonExeName, 0o600), "chmod error nonExeName") isExeName := s.saveSrcTestFile(NewTestFile("is-exe.sh", "#!/bin/bash\necho 'executing'\n")) - s.Require().NoError(os.Chmod(isExeName, 0777), "chmod error isExeName") + s.Require().NoError(os.Chmod(isExeName, 0o777), "chmod error isExeName") s.T().Run("file does not exist", func(t *testing.T) { name := filepath.Join(s.Home, "does-not-exist.txt") diff --git a/x/upgrade/spec/01_concepts.md b/x/upgrade/spec/01_concepts.md index 826290a11800..d6ccbb7eaadd 100644 --- a/x/upgrade/spec/01_concepts.md +++ b/x/upgrade/spec/01_concepts.md @@ -67,7 +67,7 @@ not defined on a per-module basis. Registering this `StoreLoader` is done via func UpgradeStoreLoader (upgradeHeight int64, storeUpgrades *store.StoreUpgrades) baseapp.StoreLoader ``` -If there's a planned upgrade and the upgrade height is reached, the old binary writes `Plan` to the disk before panic'ing. +If there's a planned upgrade and the upgrade height is reached, the old binary writes `Plan` to the disk before panicking. This information is critical to ensure the `StoreUpgrades` happens smoothly at correct height and expected upgrade. It eliminiates the chances for the new binary to execute `StoreUpgrades` multiple @@ -82,7 +82,7 @@ This proposal prescribes to the standard governance process. If the proposal pas the `Plan`, which targets a specific `Handler`, is persisted and scheduled. The upgrade can be delayed or hastened by updating the `Plan.Height` in a new proposal. -+++ https://github.com/cosmos/cosmos-sdk/blob/08ddb217c176abe31c96af9d5f6c4c6fc645c4d4/proto/cosmos/upgrade/v1beta1/tx.proto#L19-L28 ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/upgrade/v1beta1/tx.proto#L24-L35 ### Cancelling Upgrade Proposals @@ -92,6 +92,8 @@ remove the scheduled upgrade `Plan`. Of course this requires that the upgrade was known to be a bad idea well before the upgrade itself, to allow time for a vote. ++++ https://github.com/cosmos/cosmos-sdk/blob/v0.46.0-beta2/proto/cosmos/upgrade/v1beta1/tx.proto#L42-L50 + If such a possibility is desired, the upgrade height is to be `2 * (VotingPeriod + DepositPeriod) + (SafetyDelta)` from the beginning of the upgrade proposal. The `SafetyDelta` is the time available from the success of an diff --git a/x/upgrade/types/codec.go b/x/upgrade/types/codec.go index 4acdc05944ab..0f852cc9a2a9 100644 --- a/x/upgrade/types/codec.go +++ b/x/upgrade/types/codec.go @@ -4,15 +4,13 @@ import ( "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" + authzcodec "github.com/cosmos/cosmos-sdk/x/authz/codec" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) -func init() { - RegisterLegacyAminoCodec(legacy.Cdc) -} - // RegisterLegacyAminoCodec registers concrete types on the LegacyAmino codec func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(Plan{}, "cosmos-sdk/Plan", nil) @@ -36,3 +34,18 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) + + // Register all Amino interfaces and concrete types on the authz Amino codec so that this can later be + // used to properly serialize MsgGrant and MsgExec instances + RegisterLegacyAminoCodec(authzcodec.Amino) +} diff --git a/x/upgrade/types/msgs.go b/x/upgrade/types/msgs.go index 5ecc2830f5be..86dc6a1338b2 100644 --- a/x/upgrade/types/msgs.go +++ b/x/upgrade/types/msgs.go @@ -1,7 +1,6 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec/legacy" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/auth/migrations/legacytx" @@ -20,7 +19,7 @@ func (m MsgSoftwareUpgrade) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes implements the LegacyMsg interface. func (m MsgSoftwareUpgrade) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // ValidateBasic does a sanity check on the provided data. @@ -50,7 +49,7 @@ func (m MsgCancelUpgrade) Type() string { return sdk.MsgTypeURL(&m) } // GetSignBytes implements the LegacyMsg interface. func (m MsgCancelUpgrade) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) } // ValidateBasic does a sanity check on the provided data. @@ -62,7 +61,7 @@ func (m *MsgCancelUpgrade) ValidateBasic() error { return nil } -// GetSigners returns the expected signers for MsgSoftwareUpgrade. +// GetSigners returns the expected signers for MsgCancelUpgrade. func (m *MsgCancelUpgrade) GetSigners() []sdk.AccAddress { addr, _ := sdk.AccAddressFromBech32(m.Authority) return []sdk.AccAddress{addr} diff --git a/x/upgrade/types/plan_test.go b/x/upgrade/types/plan_test.go index bbd969eae0b3..724f68bf0525 100644 --- a/x/upgrade/types/plan_test.go +++ b/x/upgrade/types/plan_test.go @@ -105,7 +105,6 @@ func TestPlanValid(t *testing.T) { } }) } - } func TestShouldExecute(t *testing.T) { @@ -115,7 +114,6 @@ func TestShouldExecute(t *testing.T) { ctxHeight int64 expected bool }{ - "past height": { p: types.Plan{ Name: "do-good", diff --git a/x/upgrade/types/proposal.go b/x/upgrade/types/proposal.go index 987ccf978824..60a11fe7e8fd 100644 --- a/x/upgrade/types/proposal.go +++ b/x/upgrade/types/proposal.go @@ -54,6 +54,7 @@ func (csup *CancelSoftwareUpgradeProposal) ProposalRoute() string { return Rout func (csup *CancelSoftwareUpgradeProposal) ProposalType() string { return ProposalTypeCancelSoftwareUpgrade } + func (csup *CancelSoftwareUpgradeProposal) ValidateBasic() error { return gov.ValidateAbstract(csup) } diff --git a/x/upgrade/types/proposal_test.go b/x/upgrade/types/proposal_test.go index 7f56c6beaac9..4e6233a2d373 100644 --- a/x/upgrade/types/proposal_test.go +++ b/x/upgrade/types/proposal_test.go @@ -71,7 +71,6 @@ func TestContentAccessors(t *testing.T) { assert.Equal(t, tc.typ, unwrap.Prop.ProposalType()) assert.Equal(t, "upgrade", unwrap.Prop.ProposalRoute()) assert.Equal(t, tc.str, unwrap.Prop.String()) - }) } diff --git a/x/upgrade/types/query.pb.go b/x/upgrade/types/query.pb.go index c1b30fa3d5a4..e84c333051b0 100644 --- a/x/upgrade/types/query.pb.go +++ b/x/upgrade/types/query.pb.go @@ -582,6 +582,8 @@ type QueryClient interface { // Since: cosmos-sdk 0.43 ModuleVersions(ctx context.Context, in *QueryModuleVersionsRequest, opts ...grpc.CallOption) (*QueryModuleVersionsResponse, error) // Returns the account with authority to conduct upgrades + // + // Since: cosmos-sdk 0.46 Authority(ctx context.Context, in *QueryAuthorityRequest, opts ...grpc.CallOption) (*QueryAuthorityResponse, error) } @@ -657,6 +659,8 @@ type QueryServer interface { // Since: cosmos-sdk 0.43 ModuleVersions(context.Context, *QueryModuleVersionsRequest) (*QueryModuleVersionsResponse, error) // Returns the account with authority to conduct upgrades + // + // Since: cosmos-sdk 0.46 Authority(context.Context, *QueryAuthorityRequest) (*QueryAuthorityResponse, error) } diff --git a/x/upgrade/types/storeloader_test.go b/x/upgrade/types/storeloader_test.go index a5e9c5908418..a8c34e4c4282 100644 --- a/x/upgrade/types/storeloader_test.go +++ b/x/upgrade/types/storeloader_test.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" dbm "github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/db/memdb" + pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" "github.com/cosmos/cosmos-sdk/server" storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/store/v2alpha1/multi" @@ -31,7 +32,7 @@ func defaultLogger() log.Logger { func initStore(t *testing.T, db dbm.DBConnection, config multi.StoreParams, key storetypes.StoreKey, k, v []byte) { rs, err := multi.NewV1MultiStoreAsV2(db, config) require.NoError(t, err) - rs.SetPruning(storetypes.PruneNothing) + rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) require.Equal(t, int64(0), rs.LastCommitID().Version) // write some data in substore @@ -46,7 +47,7 @@ func initStore(t *testing.T, db dbm.DBConnection, config multi.StoreParams, key func checkStore(t *testing.T, db dbm.DBConnection, config multi.StoreParams, ver int64, key storetypes.StoreKey, k, v []byte) { rs, err := multi.NewV1MultiStoreAsV2(db, config) require.NoError(t, err) - rs.SetPruning(storetypes.PruneNothing) + rs.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) require.Equal(t, ver, rs.LastCommitID().Version) if v != nil { @@ -75,7 +76,7 @@ func TestSetLoader(t *testing.T) { data, err := json.Marshal(upgradeInfo) require.NoError(t, err) - err = os.WriteFile(upgradeInfoFilePath, data, 0644) + err = os.WriteFile(upgradeInfoFilePath, data, 0o644) require.NoError(t, err) // make sure it exists before running everything @@ -123,10 +124,10 @@ func TestSetLoader(t *testing.T) { // load the app with the existing db opts := []baseapp.AppOption{ - baseapp.SetPruning(storetypes.PruneNothing), + baseapp.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)), baseapp.SetSubstores(tc.origStoreKey), } - origapp := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, opts...) + origapp := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, nil, opts...) require.NoError(t, origapp.Init()) for i := int64(2); i <= upgradeHeight-1; i++ { @@ -138,13 +139,13 @@ func TestSetLoader(t *testing.T) { // load the new app with the original app db opts = []baseapp.AppOption{ - baseapp.SetPruning(storetypes.PruneNothing), + baseapp.SetPruning(pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)), baseapp.SetSubstores(tc.loadStoreKey), } if tc.setLoader != nil { opts = append(opts, tc.setLoader) } - app := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, opts...) + app := baseapp.NewBaseApp(t.Name(), defaultLogger(), db, nil, opts...) require.NoError(t, app.Init()) // "execute" one block