diff --git a/.github/PULL_REQUEST_TEMPLATE/production.md b/.github/PULL_REQUEST_TEMPLATE/production.md index 885d852cf0..7fe79eceb9 100644 --- a/.github/PULL_REQUEST_TEMPLATE/production.md +++ b/.github/PULL_REQUEST_TEMPLATE/production.md @@ -30,6 +30,7 @@ I have... * [ ] Updated the relevant documentation or specification * [ ] Reviewed "Files changed" and left comments if necessary * [ ] Confirmed all CI checks have passed +* [ ] If this PR is library API breaking, bump the go.mod version string of the repo, and follow through on a new major release for both the consumer and provider ### Reviewers Checklist diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 647408015a..773e5a783f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -28,6 +28,26 @@ updates: labels: - dependencies + - package-ecosystem: gomod + directory: "/" + schedule: + interval: daily + target-branch: "release/v2.0.x-lsm" + # Only allow automated security-related dependency updates on release branches. + open-pull-requests-limit: 0 + labels: + - dependencies + + - package-ecosystem: gomod + directory: "/" + schedule: + interval: daily + target-branch: "release/v2.1.x-provider-lsm" + # Only allow automated security-related dependency updates on release branches. + open-pull-requests-limit: 0 + labels: + - dependencies + - package-ecosystem: gomod directory: "/" schedule: @@ -47,3 +67,13 @@ updates: open-pull-requests-limit: 0 labels: - dependencies + + - package-ecosystem: gomod + directory: "/" + schedule: + interval: daily + target-branch: "release/v3.2.x-consumer" + # Only allow automated security-related dependency updates on release branches. + open-pull-requests-limit: 0 + labels: + - dependencies diff --git a/.github/workflows/automated-tests.yml b/.github/workflows/automated-tests.yml index a9b594f53d..f7d9988bad 100644 --- a/.github/workflows/automated-tests.yml +++ b/.github/workflows/automated-tests.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - name: Checkout LFS objects @@ -31,7 +31,7 @@ jobs: E2E_Tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - name: Checkout LFS objects @@ -45,7 +45,7 @@ jobs: Cometmock_Tests: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: lfs: true - name: Checkout LFS objects @@ -56,3 +56,17 @@ jobs: go-version: "1.20" - name: E2E tests run: make test-e2e-short-cometmock + Trace-Tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + lfs: true + - name: Checkout LFS objects + run: git lfs checkout + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: "1.20" + - name: E2E tests + run: make test-trace diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ec188dd429..a812b9fcf2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: name: SonarCloud runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis lfs: true diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 09a848478a..c6fb56c2a6 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -41,7 +41,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 0c7dff60c5..7fbd30cad7 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout πŸ›ŽοΈ - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: persist-credentials: false fetch-depth: 0 diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 45e3b3c1d7..33a2f62c07 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -20,12 +20,12 @@ jobs: - uses: actions/setup-go@v4 with: go-version: '1.20' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.53.3 + version: v1.54.1 # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/.github/workflows/gosec.yml b/.github/workflows/gosec.yml index ddcf2d3594..80dc4a3689 100644 --- a/.github/workflows/gosec.yml +++ b/.github/workflows/gosec.yml @@ -15,7 +15,7 @@ jobs: GO111MODULE: on steps: - name: Checkout Source - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Run Gosec Security Scanner uses: securego/gosec@master with: diff --git a/.github/workflows/linkchecker.yml b/.github/workflows/linkchecker.yml index 91242e5992..a1afa643cf 100644 --- a/.github/workflows/linkchecker.yml +++ b/.github/workflows/linkchecker.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest steps: # Check out the latest version of the code - - uses: actions/checkout@v3.5.2 + - uses: actions/checkout@v4 # Checks the status of hyperlinks in *.md files in docs/ - uses: gaurav-nelson/github-action-markdown-link-check@1.0.15 diff --git a/.github/workflows/manual-e2e.yml b/.github/workflows/manual-e2e.yml index 388a19f0f5..3893d009df 100644 --- a/.github/workflows/manual-e2e.yml +++ b/.github/workflows/manual-e2e.yml @@ -12,7 +12,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -28,7 +28,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -44,7 +44,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -60,7 +60,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -76,7 +76,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -87,12 +87,12 @@ jobs: run: go run ./tests/e2e/... --tc slash-throttle multiconsumer-test: runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 40 steps: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go diff --git a/.github/workflows/nightly-e2e.yml b/.github/workflows/nightly-e2e.yml index cd7f155e12..913f7e0bbe 100644 --- a/.github/workflows/nightly-e2e.yml +++ b/.github/workflows/nightly-e2e.yml @@ -25,7 +25,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -41,7 +41,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -57,7 +57,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -73,7 +73,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -89,7 +89,7 @@ jobs: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go @@ -100,12 +100,12 @@ jobs: run: go run ./tests/e2e/... --tc slash-throttle multiconsumer-test: runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 40 steps: - uses: actions/setup-go@v4 with: go-version: "1.20" - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Checkout LFS objects run: git lfs checkout - name: Setup Go diff --git a/.github/workflows/proto-registry.yml b/.github/workflows/proto-registry.yml index 326cc566a1..61896fce21 100644 --- a/.github/workflows/proto-registry.yml +++ b/.github/workflows/proto-registry.yml @@ -12,8 +12,8 @@ jobs: push: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1.26.0 + - uses: actions/checkout@v4 + - uses: bufbuild/buf-setup-action@v1.27.0 - uses: bufbuild/buf-push-action@v1 with: input: "proto" diff --git a/.github/workflows/proto.yml b/.github/workflows/proto.yml index f6c0984da3..6a56fae80c 100644 --- a/.github/workflows/proto.yml +++ b/.github/workflows/proto.yml @@ -13,8 +13,8 @@ jobs: break-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: bufbuild/buf-setup-action@v1.26.0 + - uses: actions/checkout@v4 + - uses: bufbuild/buf-setup-action@v1.27.0 - uses: bufbuild/buf-breaking-action@v1 with: input: "proto" diff --git a/.gitignore b/.gitignore index a0a3488545..e83a69a504 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ release/ docs/tla/states/ *.out vendor/ +build/ .vscode .idea diff --git a/.mergify.yml b/.mergify.yml index e08625bf28..00764d0a8c 100644 --- a/.mergify.yml +++ b/.mergify.yml @@ -18,6 +18,22 @@ pull_request_rules: backport: branches: - release/v2.0.x + - name: Backport patches to the release/v2.0.x-lsm branch + conditions: + - base=main + - label=A:backport/v2.0.x-lsm + actions: + backport: + branches: + - release/v2.0.x-lsm + - name: Backport patches to the release/v2.1.x-provider-lsm branch + conditions: + - base=main + - label=A:backport/v2.1.x-provider-lsm + actions: + backport: + branches: + - release/v2.1.x-provider-lsm - name: Backport patches to the release/v3.0.x branch conditions: - base=main @@ -34,3 +50,11 @@ pull_request_rules: backport: branches: - release/v3.1.x + - name: Backport patches to the release/v3.2.x-consumer branch + conditions: + - base=main + - label=A:backport/v3.2.x-consumer + actions: + backport: + branches: + - release/v3.2.x-consumer diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c019b885c..b111b70c76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,48 @@ # CHANGELOG -## [Unreleased] +## [Unreleased for Provider] -Add an entry to the unreleased section whenever merging a PR to main that is not targeted at a specific release. These entries will eventually be included in a release. +Add an entry to the unreleased provider section whenever merging a PR to main that is not targeted at a specific release. These entries will eventually be included in a provider release. +* (feat!) [#1230](https://github.com/cosmos/interchain-security/pull/1230) Throttle with retries provider changes. +* (feature!) [#1280](https://github.com/cosmos/interchain-security/pull/1280) provider proposal for changing reward denoms +* (feature!) [#1244](https://github.com/cosmos/interchain-security/pull/1244) Update the default consumer unbonding period to 2 weeks. +* (deps) [#1259](https://github.com/cosmos/interchain-security/pull/1259) Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.47.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.5). +* (deps!) [#1258](https://github.com/cosmos/interchain-security/pull/1258) Bump [ibc-go](https://github.com/cosmos/ibc-go) to [v7.3.0](https://github.com/cosmos/ibc-go/releases/tag/v7.3.0). +* (deps) [#1258](https://github.com/cosmos/interchain-security/pull/1258) Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.47.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.4). * (deps!) [#1196](https://github.com/cosmos/interchain-security/pull/1196) Bump [ibc-go](https://github.com/cosmos/ibc-go) to [v7.2.0](https://github.com/cosmos/ibc-go/releases/tag/v7.2.0). * `[x/ccv/provider]` (fix) [#1076](https://github.com/cosmos/interchain-security/pull/1076) Add `InitTimeoutTimestamps` and `ExportedVscSendTimestamps` to exported genesis. -* (feat!) [#1024](https://github.com/cosmos/interchain-security/pull/1024) throttle with retries, consumer changes -* (fix!) revert consumer packet data changes from #1037 [#1150](https://github.com/cosmos/interchain-security/pull/1150) -* (fix!) proper deletion of pending packets [#1146](https://github.com/cosmos/interchain-security/pull/1146) -* (feat!) optimize pending packets storage on consumer, with migration! [#1037](https://github.com/cosmos/interchain-security/pull/1037) -* (feat) introduce the gRPC query `/interchain_security/ccv/consumer/provider-info` and CLI command `interchain-security-cd q ccvconsumer provider-info`to retrieve provider info from the consumer chain. + +## [Unreleased for Consumer] + +Add an entry to the unreleased consumer section whenever merging a PR to main that is not targeted at a specific release. These entries will eventually be included in a consumer release. + +## v3.2.0-consumer + +Date September 6th, 2023 + +A minor version upgrade to the CONSUMER CCV module. This release includes various changes involving throttling v2 functionality, validation, and bumps to deps like cosmos-sdk and ibc-go. + +Note: + +* This release is ONLY RELEVANT TO CONSUMERS. The most recent provider release is v3.1.0, and will eventually be a release postfixed with `-provider`. +* this is the first upgrade to the consumer module with a separate semver cycle from the provider module. See [contributing.md](./CONTRIBUTING.md#semantic-versioning) and [associated ADR](docs/docs/adrs/adr-012-separate-releasing.md) for more info. + +Changes: + +* (feat) [#1295](https://github.com/cosmos/interchain-security/pull/1295) increment consumer consensus version and register consumer packet migration. +* (fix!) [#1262](https://github.com/cosmos/interchain-security/pull/1262) Remove incorrect address validation on `ProviderFeePoolAddrStr` param. +* (feature!) [#1244](https://github.com/cosmos/interchain-security/pull/1244) Update the default consumer unbonding period to 2 weeks. +* (fix!) [#1244](https://github.com/cosmos/interchain-security/pull/1244) Validate token transfer messages before calling `Transfer()`. +* (deps) [#1259](https://github.com/cosmos/interchain-security/pull/1259) Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.47.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.5). +* (deps!) [#1258](https://github.com/cosmos/interchain-security/pull/1258) Bump [ibc-go](https://github.com/cosmos/ibc-go) to [v7.3.0](https://github.com/cosmos/ibc-go/releases/tag/v7.3.0). +* (deps) [#1258](https://github.com/cosmos/interchain-security/pull/1258) Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.47.4](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.4). +* (deps!) [#1196](https://github.com/cosmos/interchain-security/pull/1196) Bump [ibc-go](https://github.com/cosmos/ibc-go) to [v7.2.0](https://github.com/cosmos/ibc-go/releases/tag/v7.2.0). +* (feat!) [#1024](https://github.com/cosmos/interchain-security/pull/1024) Throttle with retries, consumer changes. +* (fix!) [#1150](https://github.com/cosmos/interchain-security/pull/1150) Revert consumer packet data changes from #1037. +* (fix!) [#1146](https://github.com/cosmos/interchain-security/pull/1146) Proper deletion of pending packets. +* (feat!) [#1037](https://github.com/cosmos/interchain-security/pull/1037) Optimize pending packets storage on consumer, with migration. +* (feat) [#1164](https://github.com/cosmos/interchain-security/pull/1164) Introduce the gRPC query `/interchain_security/ccv/consumer/provider-info` and CLI command `interchain-security-cd q ccvconsumer provider-info` to retrieve provider info from the consumer chain. ## v3.1.0 @@ -37,6 +69,19 @@ Interchain Security v3 uses SDK 0.47 and IBC 7. * `[x/ccv/provider]` (fix) [#977](https://github.com/cosmos/interchain-security/pull/977) Avoids panicking the provider when an unbonding delegation was removed through a `CancelUnbondingDelegation` message. * `[x/ccv/democracy]` (feat) [#1019](https://github.com/cosmos/interchain-security/pull/1019) Whitelisting non-legacy params in the "democracy module" require the entire module to be whitelisted. +## v2.1.0-provider-lsm + +Date: September 15th, 2023 + +* (feature!) [#1280](https://github.com/cosmos/interchain-security/pull/1280) provider proposal for changing reward denoms + +## v2.0.0-lsm + +Date: August 18th, 2023 + +* (deps!) [#1120](https://github.com/cosmos/interchain-security/pull/1120) Bump [Cosmos SDK](https://github.com/cosmos/cosmos-sdk) to [v0.45.16-ics-lsm](https://github.com/cosmos/cosmos-sdk/tree/v0.45.16-ics-lsm). This requires adapting ICS to support this SDK release. Changes are state breaking. +* (fix) [#720](https://github.com/cosmos/interchain-security/issues/720) Fix the attribute `AttributeDistributionTotal` value in `FeeDistribution` event emit. + ## v2.0.0 Date: June 1st, 2023 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8975d37269..c376c3b824 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -247,9 +247,9 @@ ICS adheres to the [trunk based development branching model](https://trunkbasedd ICS follows [semantic versioning](https://semver.org), but with the following deviations (similar to [IBC-Go](https://github.com/cosmos/ibc-go/blob/main/RELEASES.md)): -- A library API breaking change will result in an increase of the MAJOR version number (X.y.z | x > 0). -- A state breaking change (change requiring coordinated upgrade and/or state migration for the consumer, the provider, or both) will result in an increase of the MINOR version number (x.Y.z | x > 0). -- Any other changes (including node API breaking changes) will result in an increase of the PATCH version number (x.y.Z | x > 0). +- A library API breaking change to EITHER the provider or consumer module will result in an increase of the MAJOR version number for BOTH modules (X.y.z-provider AND X.y.z-consumer). +- A state breaking change (change requiring coordinated upgrade and/or state migration) will result in an increase of the MINOR version number for the AFFECTED module(s) (x.Y.z-provider AND/OR x.Y.z-consumer). +- Any other changes (including node API breaking changes) will result in an increase of the PATCH version number for the AFFECTED module(s) (x.y.Z-provider AND/OR x.y.Z-consumer). ### Backwards Compatibility diff --git a/Makefile b/Makefile index ac7c38f068..a614e3bea0 100644 --- a/Makefile +++ b/Makefile @@ -77,6 +77,10 @@ test-gaia-e2e-parallel-tagged: test-no-cache: go test ./... -count=1 && go run ./tests/e2e/... +# test reading a trace from a file +test-trace: + go run ./tests/e2e/... --test-file tests/e2e/tracehandler_testdata/happyPath.json::default + ############################################################################### ### Linting ### ############################################################################### @@ -97,6 +101,8 @@ mockgen_cmd=go run github.com/golang/mock/mockgen mocks: $(mockgen_cmd) -package=keeper -destination=testutil/keeper/mocks.go -source=x/ccv/types/expected_keepers.go + +BUILDDIR ?= $(CURDIR)/build BUILD_TARGETS := build build: BUILD_ARGS=-o $(BUILDDIR)/ @@ -177,3 +183,10 @@ build-docs: @cd docs && ./build.sh .PHONY: build-docs + +############################################################################### +### Test Traces ### +############################################################################### + +e2e-traces: + cd tests/e2e; go test -timeout 30s -run ^TestWriteExamples -v \ No newline at end of file diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 62704ea9c6..f1a6edb066 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,12 +1,15 @@ -# Replicated Security Release Notes +# Replicated Security - Release Notes + + +## Note this release is ONLY relevant to ## πŸ“ Changelog diff --git a/app/consumer-democracy/app.go b/app/consumer-democracy/app.go index 063c5bf427..7d5646f1dc 100644 --- a/app/consumer-democracy/app.go +++ b/app/consumer-democracy/app.go @@ -16,6 +16,8 @@ import ( ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types" "github.com/spf13/cast" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" @@ -77,7 +79,6 @@ import ( govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" - // add mint mint "github.com/cosmos/cosmos-sdk/x/mint" mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -103,8 +104,6 @@ import ( tmos "github.com/cometbft/cometbft/libs/os" appparams "github.com/cosmos/interchain-security/v3/app/params" - ibctestingcore "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" testutil "github.com/cosmos/interchain-security/v3/testutil/integration" consumer "github.com/cosmos/interchain-security/v3/x/ccv/consumer" consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" @@ -915,7 +914,7 @@ func (app *App) GetBaseApp() *baseapp.BaseApp { } // GetStakingKeeper implements the TestingApp interface. -func (app *App) GetStakingKeeper() ibctestingcore.StakingKeeper { +func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper { return app.ConsumerKeeper } diff --git a/app/consumer-democracy/proposals_whitelisting_test.go b/app/consumer-democracy/proposals_whitelisting_test.go index 127ec82ec5..d0e5a7742d 100644 --- a/app/consumer-democracy/proposals_whitelisting_test.go +++ b/app/consumer-democracy/proposals_whitelisting_test.go @@ -3,16 +3,18 @@ package app_test import ( "testing" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/stretchr/testify/require" appConsumer "github.com/cosmos/interchain-security/v3/app/consumer-democracy" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" icstestingutils "github.com/cosmos/interchain-security/v3/testutil/ibc_testing" + testutil "github.com/cosmos/interchain-security/v3/testutil/integration" ) func TestDemocracyGovernanceWhitelistingKeys(t *testing.T) { - chain := ibctesting.NewTestChain(t, ibctesting.NewCoordinator(t, 0), - icstestingutils.DemocracyConsumerAppIniter, "test") + _, valUpdates, _ := testutil.CreateValidators(t, 4) + ibctesting.DefaultTestingAppInit = icstestingutils.DemocracyConsumerAppIniter(valUpdates) + chain := ibctesting.NewTestChain(t, ibctesting.NewCoordinator(t, 0), "test") paramKeeper := chain.App.(*appConsumer.App).ParamsKeeper for paramKey := range appConsumer.LegacyWhitelistedParams { ss, ok := paramKeeper.GetSubspace(paramKey.Subspace) diff --git a/app/consumer/app.go b/app/consumer/app.go index c65447e244..0c94ed8d75 100644 --- a/app/consumer/app.go +++ b/app/consumer/app.go @@ -16,6 +16,8 @@ import ( ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types" "github.com/spf13/cast" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" @@ -86,8 +88,6 @@ import ( tmos "github.com/cometbft/cometbft/libs/os" appparams "github.com/cosmos/interchain-security/v3/app/params" - ibctestingcore "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" testutil "github.com/cosmos/interchain-security/v3/testutil/integration" ibcconsumer "github.com/cosmos/interchain-security/v3/x/ccv/consumer" ibcconsumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" @@ -732,7 +732,7 @@ func (app *App) GetBaseApp() *baseapp.BaseApp { } // GetStakingKeeper implements the TestingApp interface. -func (app *App) GetStakingKeeper() ibctestingcore.StakingKeeper { +func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper { return app.ConsumerKeeper } diff --git a/app/consumer/genesis.go b/app/consumer/genesis.go index 5bf0c1da80..27292feaa1 100644 --- a/app/consumer/genesis.go +++ b/app/consumer/genesis.go @@ -2,8 +2,20 @@ package app import ( "encoding/json" + "fmt" + "os" + "path/filepath" + "strings" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" + + consumerTypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v3/x/ccv/types" ) // The genesis state of the blockchain is represented here as a map of raw json @@ -15,7 +27,98 @@ import ( // object provided to it during init. type GenesisState map[string]json.RawMessage +// Migration of consumer genesis content as it is exported from a provider version v1,2,3 +// to a format readable by current consumer implementation. +func transform(jsonRaw []byte, ctx client.Context) (json.RawMessage, error) { + // v1,2,3 uses deprecated fields of GenesisState type + oldConsumerGenesis := consumerTypes.GenesisState{} + err := ctx.Codec.UnmarshalJSON(jsonRaw, &oldConsumerGenesis) + if err != nil { + return nil, fmt.Errorf("reading consumer genesis data failed: %s", err) + } + + // some sanity checks for v2 transformation + if len(oldConsumerGenesis.Provider.InitialValSet) > 0 { + return nil, fmt.Errorf("invalid source version. Unexpected element 'provider.initial_val_set'") + } + + if oldConsumerGenesis.Provider.ClientState != nil { + return nil, fmt.Errorf("invalid source version. Unexpected element 'provider.client_state'") + } + + if oldConsumerGenesis.Provider.ConsensusState != nil { + return nil, fmt.Errorf("invalid source version. Unexpected element 'provider.consensus_state'") + } + + // Version 2 of provider genesis data fills up deprecated fields + // ProviderClientState, ConsensusState and InitialValSet + newGenesis := types.ConsumerGenesisState{ + Params: oldConsumerGenesis.Params, + Provider: types.ProviderInfo{ + ClientState: oldConsumerGenesis.ProviderClientState, + ConsensusState: oldConsumerGenesis.ProviderConsensusState, + InitialValSet: oldConsumerGenesis.InitialValSet, + }, + } + + newJson, err := ctx.Codec.MarshalJSON(&newGenesis) + if err != nil { + return nil, fmt.Errorf("failed marshalling data to new type: %s", err) + } + return newJson, nil +} + +// Transform a consumer genesis json file exported from a given ccv provider version +// to a consumer genesis json format supported by current ccv consumer version. +// Result will be written to defined output. +func TransformConsumerGenesis(cmd *cobra.Command, args []string) error { + sourceFile := args[0] + + jsonRaw, err := os.ReadFile(filepath.Clean(sourceFile)) + if err != nil { + return err + } + + clientCtx := client.GetClientContextFromCmd(cmd) + newConsumerGenesis, err := transform(jsonRaw, clientCtx) + if err != nil { + return err + } + + bz, err := newConsumerGenesis.MarshalJSON() + if err != nil { + return fmt.Errorf("failed exporting new consumer genesis to JSON: %s", err) + } + + sortedBz, err := sdk.SortJSON(bz) + if err != nil { + return fmt.Errorf("failed sorting transformed consumer genesis JSON: %s", err) + } + + cmd.Println(string(sortedBz)) + return nil +} + // NewDefaultGenesisState generates the default state for the application. func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState { return ModuleBasics.DefaultGenesis(cdc) } + +// GetConsumerGenesisTransformCmd transforms Consumer Genesis JSON content exported from a +// provider version v1,v2 or v3 to a JSON format supported by this consumer version. +func GetConsumerGenesisTransformCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "transform [genesis-file]", + Short: "Transform CCV consumer genesis from an older provider version not supporting current format", + Long: strings.TrimSpace( + fmt.Sprintf(`Transform the consumer genesis file from a provider version v1,v2 or v3 to a version supported by this consumer. Result is printed to STDOUT. + +Example: +$ %s transform /path/to/ccv_consumer_genesis.json`, version.AppName), + ), + Args: cobra.ExactArgs(1), + RunE: TransformConsumerGenesis, + } + + return cmd +} diff --git a/app/consumer/genesis_test.go b/app/consumer/genesis_test.go new file mode 100644 index 0000000000..f23e4c58d1 --- /dev/null +++ b/app/consumer/genesis_test.go @@ -0,0 +1,213 @@ +package app_test + +import ( + "bytes" + "context" + "io/fs" + "os" + "path/filepath" + "testing" + "time" + + "github.com/spf13/cobra" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/x/auth/types" + + app "github.com/cosmos/interchain-security/v3/app/consumer" + consumerTypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" +) + +// Testdata mapping consumer genesis exports to a provider module version as +// used by transformation function for consumer genesis content. +var consumerGenesisStates map[string]string = map[string]string{ + "v2": ` + { + "params": { + "enabled": true, + "blocks_per_distribution_transmission": "1500", + "distribution_transmission_channel": "", + "provider_fee_pool_addr_str": "", + "ccv_timeout_period": "2419200s", + "transfer_timeout_period": "3600s", + "consumer_redistribution_fraction": "0.75", + "historical_entries": "10000", + "unbonding_period": "1728000s", + "soft_opt_out_threshold": "", + "reward_denoms": [], + "provider_reward_denoms": [] + }, + "provider_client_id": "", + "provider_channel_id": "", + "new_chain": true, + "provider_client_state": { + "chain_id": "cosmoshub-4", + "trust_level": { + "numerator": "1", + "denominator": "3" + }, + "trusting_period": "1197504s", + "unbonding_period": "1814400s", + "max_clock_drift": "10s", + "frozen_height": { + "revision_number": "0", + "revision_height": "0" + }, + "latest_height": { + "revision_number": "4", + "revision_height": "15211521" + }, + "proof_specs": [ + { + "leaf_spec": { + "hash": "SHA256", + "prehash_key": "NO_HASH", + "prehash_value": "SHA256", + "length": "VAR_PROTO", + "prefix": "AA==" + }, + "inner_spec": { + "child_order": [ + 0, + 1 + ], + "child_size": 33, + "min_prefix_length": 4, + "max_prefix_length": 12, + "empty_child": null, + "hash": "SHA256" + }, + "max_depth": 0, + "min_depth": 0 + }, + { + "leaf_spec": { + "hash": "SHA256", + "prehash_key": "NO_HASH", + "prehash_value": "SHA256", + "length": "VAR_PROTO", + "prefix": "AA==" + }, + "inner_spec": { + "child_order": [ + 0, + 1 + ], + "child_size": 32, + "min_prefix_length": 1, + "max_prefix_length": 1, + "empty_child": null, + "hash": "SHA256" + }, + "max_depth": 0, + "min_depth": 0 + } + ], + "upgrade_path": [ + "upgrade", + "upgradedIBCState" + ], + "allow_update_after_expiry": true, + "allow_update_after_misbehaviour": true + }, + "provider_consensus_state": { + "timestamp": "2023-05-08T11:00:01.563901871Z", + "root": { + "hash": "qKVnVSXlsjDHC8ekKcy/0zSjzr3YekCurld9R4W07EI=" + }, + "next_validators_hash": "E08978F493101A3C5D459FB3087B8CFBA9E82D7A1FE1441E7D77E11AC0586BAC" + }, + "maturing_packets": [], + "initial_val_set": [ + { + "pub_key": { + "ed25519": "cOQZvh/h9ZioSeUMZB/1Vy1Xo5x2sjrVjlE/qHnYifM=" + }, + "power": "2345194" + }, + { + "pub_key": { + "ed25519": "vGSKfbQyKApvBhinpOOA0XQAdjxceihYNwtGskfZGyQ=" + }, + "power": "463811" + } + ], + "height_to_valset_update_id": [], + "outstanding_downtime_slashing": [], + "pending_consumer_packets": { + "list": [] + }, + "last_transmission_block_height": { + "height": "0" + }, + "preCCV": false + } + + `, +} + +func getClientCtx() client.Context { + encodingConfig := app.MakeTestEncodingConfig() + return client.Context{}. + WithCodec(encodingConfig.Codec). + WithInterfaceRegistry(encodingConfig.InterfaceRegistry). + WithTxConfig(encodingConfig.TxConfig). + WithLegacyAmino(encodingConfig.Amino). + WithInput(os.Stdin). + WithAccountRetriever(types.AccountRetriever{}) +} + +// Setup client context +func getGenesisTransformCmd() (*cobra.Command, error) { + cmd := app.GetConsumerGenesisTransformCmd() + clientCtx := getClientCtx() + ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx) + cmd.SetContext(ctx) + err := client.SetCmdClientContext(cmd, clientCtx) + return cmd, err +} + +// Check transformation of a version 2 ConsumerGenesis export to +// consumer genesis json format used by current consumer implementation. +func TestConsumerGenesisTransformationV2(t *testing.T) { + version := "v2" + filePath := filepath.Join(t.TempDir(), "oldConsumerGenesis.json") + + err := os.WriteFile( + filePath, + []byte(consumerGenesisStates[version]), + fs.FileMode(0o644)) + require.NoError(t, err) + defer os.Remove(filePath) + + cmd, err := getGenesisTransformCmd() + require.NoError(t, err, "Error setting up transformation command: %s", err) + cmd.SetArgs([]string{filePath}) + + output := new(bytes.Buffer) + cmd.SetOutput(output) + require.NoError(t, err) + _, err = cmd.ExecuteC() + require.NoError(t, err) + + consumerGenesis := consumerTypes.GenesisState{} + + bz := output.Bytes() + ctx := client.GetClientContextFromCmd(cmd) + err = ctx.Codec.UnmarshalJSON(bz, &consumerGenesis) + require.NoError(t, err, "Error unmarshalling transformed genesis state :%s", err) + + // Some basic sanity checks on the content. + require.Nil(t, consumerGenesis.ProviderClientState) + require.NotNil(t, consumerGenesis.Provider.ClientState) + require.Equal(t, "cosmoshub-4", consumerGenesis.Provider.ClientState.ChainId) + + require.Nil(t, consumerGenesis.ProviderConsensusState) + require.NotNil(t, consumerGenesis.Provider.ConsensusState) + require.Equal(t, time.Date(2023, time.May, 8, 11, 0, 1, 563901871, time.UTC), + consumerGenesis.Provider.ConsensusState.Timestamp) + + require.Empty(t, consumerGenesis.InitialValSet) + require.NotEmpty(t, consumerGenesis.Provider.InitialValSet) +} diff --git a/app/provider/app.go b/app/provider/app.go index c054f4a00b..4550ec77d2 100644 --- a/app/provider/app.go +++ b/app/provider/app.go @@ -19,6 +19,8 @@ import ( ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types" "github.com/spf13/cast" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" @@ -99,8 +101,6 @@ import ( tmos "github.com/cometbft/cometbft/libs/os" appparams "github.com/cosmos/interchain-security/v3/app/params" - ibctestingcore "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" testutil "github.com/cosmos/interchain-security/v3/testutil/integration" ibcprovider "github.com/cosmos/interchain-security/v3/x/ccv/provider" ibcproviderclient "github.com/cosmos/interchain-security/v3/x/ccv/provider/client" @@ -141,6 +141,7 @@ var ( ibcproviderclient.ConsumerAdditionProposalHandler, ibcproviderclient.ConsumerRemovalProposalHandler, ibcproviderclient.EquivocationProposalHandler, + ibcproviderclient.ChangeRewardDenomsProposalHandler, }, ), params.AppModuleBasic{}, @@ -817,7 +818,7 @@ func (app *App) GetBaseApp() *baseapp.BaseApp { } // GetStakingKeeper implements the TestingApp interface. -func (app *App) GetStakingKeeper() ibctestingcore.StakingKeeper { +func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper { return app.StakingKeeper } diff --git a/app/sovereign/app.go b/app/sovereign/app.go index 1693cb1b60..b5629bfc22 100644 --- a/app/sovereign/app.go +++ b/app/sovereign/app.go @@ -16,6 +16,8 @@ import ( ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + ibctestingtypes "github.com/cosmos/ibc-go/v7/testing/types" "github.com/spf13/cast" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" @@ -104,8 +106,6 @@ import ( tmos "github.com/cometbft/cometbft/libs/os" appparams "github.com/cosmos/interchain-security/v3/app/params" - ibctestingcore "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" testutil "github.com/cosmos/interchain-security/v3/testutil/integration" ) @@ -770,7 +770,7 @@ func (app *App) GetBaseApp() *baseapp.BaseApp { } // GetStakingKeeper implements the TestingApp interface. -func (app *App) GetStakingKeeper() ibctestingcore.StakingKeeper { +func (app *App) GetStakingKeeper() ibctestingtypes.StakingKeeper { return app.StakingKeeper } diff --git a/cmd/interchain-security-cd/cmd/root.go b/cmd/interchain-security-cd/cmd/root.go index 30c032bbea..f1a8445982 100644 --- a/cmd/interchain-security-cd/cmd/root.go +++ b/cmd/interchain-security-cd/cmd/root.go @@ -202,7 +202,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { // add keybase, auxiliary RPC, query, genesis, and tx child commands rootCmd.AddCommand( rpc.StatusCommand(), - genesisCommand(encodingConfig), + genesisCommand(encodingConfig, consumer.GetConsumerGenesisTransformCmd()), queryCommand(), txCommand(), keys.Commands(consumer.DefaultNodeHome), diff --git a/docs/docs/adrs/adr-005-cryptographic-equivocation-verification.md b/docs/docs/adrs/adr-005-cryptographic-equivocation-verification.md index dac41b912e..8bd68dfcaf 100644 --- a/docs/docs/adrs/adr-005-cryptographic-equivocation-verification.md +++ b/docs/docs/adrs/adr-005-cryptographic-equivocation-verification.md @@ -6,7 +6,8 @@ title: Cryptographic verification of equivocation evidence ## Changelog * 5/1/2023: First draft -* 7/23/23: Add light client attacks handling +* 7/23/2023: Add light client attacks handling +* 9/6/2023: Add double signing attacks handling ## Status @@ -19,7 +20,7 @@ Every proposal needs to go through a (two weeks) voting period before it can be Given a three-week unbonding period, this means that an equivocation proposal needs to be submitted within one week since the infraction occurred. This ADR proposes a system to slash validators automatically for equivocation, immediately upon the provider chain's receipt of the evidence. Another thing to note is that we intend to introduce this system in stages, since even the partial ability to slash and/or tombstone is a strict improvement in security. -For the first stage of this work, we will only handle light client attacks. +The feature is implemented in two parts, each with its dedicated endpoint. One endpoint handles light client attacks, while the other handles double signing attacks. ### Light Client Attack @@ -42,48 +43,99 @@ The types of light client attacks are defined by analyzing the differences betwe There are three types of light client attacks: lunatic attack, equivocation attack, and amnesia attack. For details, see the [CometBFT specification](https://github.com/cometbft/cometbft/blob/main/spec/light-client/attacks/notes-on-evidence-handling.md#evidence-handling). -When a light client agent detects two conflicting headers, it will initially verify their traces (see [cometBFT detector](https://github.com/cometbft/cometbft/blob/2af25aea6cfe6ac4ddac40ceddfb8c8eee17d0e6/light/detector.go#L28)) using its primary and witness nodes. +When a light client agent detects two conflicting headers, it will initially verify their traces (see [cometBFT detector](https://github.com/cometbft/cometbft/blob/v0.34.28/light/detector.go#L28)) using its primary and witness nodes. If these headers pass successful verification, the Byzantine validators will be identified based on the header's commit signatures -and the type of light client attack. The agent will then transmit this information to its nodes using a [`LightClientAttackEvidence`](https://github.com/cometbft/cometbft/blob/feed0ddf564e113a840c4678505601256b93a8bc/docs/architecture/adr-047-handling-evidence-from-light-client.md) to be eventually voted on and added to a block. +and the type of light client attack. The agent will then transmit this information to its nodes using a [`LightClientAttackEvidence`](https://github.com/cometbft/cometbft/blob/v0.34.28/spec/consensus/evidence.md#light-client-attacks) evidence to be eventually voted on and added to a block. Note that from a light client agent perspective, it is not possible to establish whether a primary or a witness node, or both, are malicious. -Therefore, it will create and send two `LightClientAttackEvidence`: one against the primary (sent to the witness), and one against the witness (sent to the primary). -Both nodes will then verify it before broadcasting it and adding it to the [evidence pool](https://github.com/cometbft/cometbft/blob/2af25aea6cfe6ac4ddac40ceddfb8c8eee17d0e6/evidence/pool.go#L28). -If a `LightClientAttackEvidence` is finally committed to a block, the chain's evidence module will execute it, resulting in the jailing and the slashing of the validators responsible for the light client attack. +Therefore, it will create and send two evidences: one against the primary (sent to the witness), and one against the witness (sent to the primary). +Both nodes will then verify it before broadcasting it and adding it to the [evidence pool](https://github.com/cometbft/cometbft/blob/v0.34.28/evidence/pool.go#L28). +If an evidence is finally committed to a block, the chain's evidence module will execute it, resulting in the jailing and the slashing of the validators responsible for the light client attack. -Light clients are a core component of IBC. In the event of a light client attack, IBC relayers notify the affected chains by submitting an [IBC misbehavior message](https://github.com/cosmos/ibc-go/blob/2b7c969066fbcb18f90c7f5bd256439ca12535c7/proto/ibc/lightclients/tendermint/v1/tendermint.proto#L79). -A misbehavior message includes the conflicting headers that constitute a `LightClientAttackEvidence`. Upon receiving such a message, +Light clients are a core component of IBC. In the event of a light client attack, IBC relayers notify the affected chains by submitting an [IBC misbehavior message](https://github.com/cosmos/ibc-go/blob/v4.4.2/proto/ibc/lightclients/tendermint/v1/tendermint.proto#L79). +A misbehavior message includes the conflicting headers that constitute a light client attack evidence. Upon receiving such a message, a chain will first verify whether these headers would have convinced its light client. This verification is achieved by checking -the header states against the light client consensus states (see [IBC misbehaviour handler](https://github.com/cosmos/ibc-go/blob/2b7c969066fbcb18f90c7f5bd256439ca12535c7/modules/light-clients/07-tendermint/types/misbehaviour_handle.go#L101)). If the misbehaviour is successfully verified, the chain will then "freeze" the +the header states against the light client consensus states (see [IBC misbehaviour handler](https://github.com/cosmos/ibc-go/blob/v4.4.2/modules/light-clients/07-tendermint/types/misbehaviour_handle.go#L24)). If the misbehaviour is successfully verified, the chain will then "freeze" the light client, halting any further trust in or updating of its states. +### Double Signing Attack + +A double signing attack, also known as equivocation, +occurs when a validator votes for two different blocks in the same round of the CometBFT consensus. +This consensus mechanism operates with multiple voting rounds at each block height, +and it strictly prohibits sending two votes of the same type during a round +(see [CometBFT State Machine Overview](https://github.com/cometbft/cometbft/blob/v0.34.28/spec/consensus/consensus.md#state-machine-overview)). + +When a node observes two votes from the same peer, it will use these two votes to create +a [`DuplicateVoteEvidence`](https://github.com/cometbft/cometbft/blob/v0.34.28/types/evidence.go#L35) +evidence and gossip it to the other nodes in the network +(see [CometBFT equivocation detection](https://github.com/cometbft/cometbft/blob/v0.34.28/spec/consensus/evidence.md#detection)). +Each node will then verify the evidence according to the CometBFT rules that define a valid double signing infraction, and based on this verification, they will decide whether to add the evidence to a block. +During the evidence verification process, the signatures of the conflicting votes must be verified successfully. +Note that this is achieved using the public key of the misbehaving validator, along with the chain ID of the chain where the infraction occurred (see [CometBFT equivocation verification](https://github.com/cometbft/cometbft/blob/v0.34.28/spec/consensus/evidence.md#verification)). + +Once a double signing evidence is committed to a block, the consensus layer will report the equivocation to the evidence module of the Cosmos SDK application layer. +The application will, in turn, punish the malicious validator through jailing, tombstoning and slashing +(see [handleEquivocationEvidence](https://github.com/cosmos/cosmos-sdk/blob/v0.45.16-ics-lsm/x/evidence/keeper/infraction.go#L263)). + ## Decision -In the first iteration of the feature, we will introduce a new endpoint: `HandleConsumerMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbehaviour)`. +### Light Client Attack + +In the first part of the feature, we introduce a new endpoint: `HandleConsumerMisbehaviour(ctx sdk.Context, misbehaviour ibctmtypes.Misbehaviour)`. The main idea is to leverage the current IBC misbehaviour handling and update it to solely jail and slash the validators that -performed a light client attack. This update will be made under the assumption that the chain connected via this light client -share the same validator set, as it is the case with Replicated Security. +performed a light client attack. Note that in this context, we assume that chains connected via a light client +share the same validator set, as is the case with Replicated Security. -This endpoint will reuse the IBC client libraries to verify that the misbehaviour headers would have fooled the light client. -Additionally, it’s crucial that the endpoint logic result in the slashing and jailing of validators under the same conditions -as a light client agent detector. Therefore, the endpoint will ensure that the two conditions are met: +This endpoint reuses the IBC client libraries to verify that the misbehaviour headers would have fooled the light client. +Additionally, it’s crucial that the endpoint logic results in the slashing and jailing of validators under the same conditions +as a light client agent detector. Therefore, the endpoint ensures that the two conditions are met: the headers in the misbehaviour message have the same block height, and the light client isn’t expired. -After having successfully verified a misbehaviour, the endpoint will execute the jailing and slashing of the malicious validators similarly as in the evidence module. +After having successfully verified a misbehaviour, the endpoint executes the jailing and slashing of the malicious validators similarly as in the evidence module. + +### Double Signing Attack + +In the second part of the feature, we introduce a new endpoint `HandleConsumerDoubleVoting( +ctx sdk.Context, evidence *tmtypes.DuplicateVoteEvidence, chainID string, pubkey cryptotypes.PubKey)`. +Simply put, the handling logic verifies a double signing evidence against a provided +public key and chain ID and, if successful, executes the jailing of the malicious validator who double voted. + +We define a new +`MsgSubmitConsumerDoubleVoting` message to report a double voting evidence observed +on a consumer chain to the endpoint of the provider chain. This message contains two fields: +a double signing evidence +`duplicate_vote_evidence` and a light client header for the infraction block height, +referred to as `infraction_block_header`. +The latter provides the malicious validator's public key and the chain ID required to verify the signature of the votes contained in the evidence. + +Note that double signing evidence is not verified using the same conditions as in the implementation CometBFT (see +[`verify(evidence types.Evidence)`](https://github.com/cometbft/cometbft/blob/v0.34.28/evidence/verify.go#L19) method). Specifically, we do not check that the evidence hasn't expired. +More details can be found in the ["Current limitations"](#current-limitations) section below. + +Upon a successful equivocation verification, the misbehaving validator is jailed for the maximum time +(see [DoubleSignJailEndTime](https://github.com/cosmos/cosmos-sdk/blob/v0.45.16-ics-lsm/x/evidence/types/params.go#L11) +in the SDK evidence module). -### Current limitations: -- This only handles light client attacks, not double signing. In the future, we will add the code to also verify double signing. +### Current limitations: -- We cannot derive an infraction height from the evidence, so it is only possible to tombstone validators, not actually slash them. +- We cannot derive an infraction height from the evidence, so it is only possible to jail validators, not actually slash them. To explain the technical reasons behind this limitation, let's recap the initial consumer initiated slashing logic. -In a nutshell, consumer heights are mapped to provider heights through VSCPackets, namely through the so called vscIDs. -When an infraction occurs on the consumer, a SlashPacket containing the vscID obtained from mapping the consumer infraction height -is sent to the provider. Upon receiving the packet, the provider maps the consumer infraction height to a local infraction height, -which is used to slash the misbehaving validator. In the context of untrusted consumer chains, all their states, including vscIDs, -could be corrupted and therefore cannot be used for slashing purposes. + In a nutshell, consumer heights are mapped to provider heights through VSCPackets, namely through the so called vscIDs. + When an infraction occurs on the consumer, a SlashPacket containing the vscID obtained from mapping the consumer infraction height + is sent to the provider. Upon receiving the packet, the provider maps the consumer infraction height to a local infraction height, + which is used to slash the misbehaving validator. In the context of untrusted consumer chains, all their states, including vscIDs, + could be corrupted and therefore cannot be used for slashing purposes. + +- For the same reasons explained above, the age of a consumer double signing evidence can't be verified, +either using its infraction height or its unsigned timestamp. Note that changes the jailing behaviour, potentially leading to a validator's jailing based on some "old" evidence from a consumer, which wouldn't occur if the consumer were a standalone chain. + +- In the first stage of this feature, validators are jailed indefinitely without being tombstoned. +The underlying reason is that a malicious validator could take advantage of getting tombstoned +to avoid being slashed on the provider ([see comment](https://github.com/cosmos/interchain-security/pull/1232#issuecomment-1693127641)). - Currently, the endpoint can only handle "equivocation" light client attacks. This is because the "lunatic" attacks require the endpoint to possess the ability to dissociate which header is conflicted or trusted upon receiving a misbehavior message. Without this information, it's not possible to define the Byzantine validators from the conflicting headers (see [comment](https://github.com/cosmos/interchain-security/pull/826#discussion_r1268668684)). @@ -92,7 +144,8 @@ could be corrupted and therefore cannot be used for slashing purposes. ### Positive -- After this ADR is applied, it will be possible for the provider chain to tombstone validators who committed a light client attack. +- It is now possible for the provider chain to jail validators who committed +light client or double signing attacks on a consumer chain. ### Negative @@ -102,4 +155,6 @@ could be corrupted and therefore cannot be used for slashing purposes. ## References * [ICS misbehaviour handling PR](https://github.com/cosmos/interchain-security/pull/826) +* [Consumer double voting handler PR](https://github.com/cosmos/interchain-security/pull/1232) * [Architectural diagrams](https://docs.google.com/document/d/1fe1uSJl1ZIYWXoME3Yf4Aodvz7V597Ric875JH-rigM/edit#heading=h.rv4t8i6d6jfn) +* [ADR on equivocation slashing](https://github.com/cosmos/interchain-security/blob/main/docs/docs/adrs/adr-013-equivocation-slashing.md) diff --git a/docs/docs/adrs/adr-011-improving-test-confidence.md b/docs/docs/adrs/adr-011-improving-test-confidence.md new file mode 100644 index 0000000000..397f8f5e01 --- /dev/null +++ b/docs/docs/adrs/adr-011-improving-test-confidence.md @@ -0,0 +1,202 @@ +--- +sidebar_position: 12 +title: Improving testing and increasing confidence +--- +# ADR 11: Improving testing and increasing confidence + +## Changelog +* 2023-08-11: Proposed, first draft of ADR. + +## Status + +Proposed + +## Context + +Testing, QA, and maintenance of interchain-security libraries is an ever-evolving area of software engineering we have to keep incrementally improving. The purpose of the QA process is to catch bugs as early as possible. In an ideal development workflow a bug should never reach production. A bug found in the specification stage is a lot cheaper to resolve than a bug discovered in production (or even in testnet). Ideally, all bugs should be found during the CI execution, and we hope that no bugs will ever even reach the testnet (although nothing can replace actual system stress test under load interacting with users). + +During development and testnet operation the following types of bugs were the most commonly found: +- improper iterator usage +- unbounded array access/iteration +- improper input handling and validation +- improper cached context usage +- non-determinism check (improper use of maps in go, relying on random values) +- KV store management and/or how keys are defined +- deserialization issues arising from consumer/provider versioning mismatch + +Such bugs can be discovered earlier with better tooling. Some of these bugs can induce increases in block times, chain halts, state corruption, or introduce an attack surface which is difficult to remove if other systems have started depending on that behavior. + +#### Current state of testing +Our testing suites consist of multiple parts, each with their own trade-offs and benefits with regards to code coverage, complexity and confidence they provide. + +### Unit testing +Unit testing is employed mostly for testing single-module functionality. It is the first step in testing and often the most practical. While highly important, unit tests often **test a single piece of code** and don't test relationships between different moving parts, this makes them less valuable when dealing with multi-module interactions. + +Unit tests often employ mocks to abstract parts of the system that are not under test. Mocks are not equivalent to actual models and should not be treated as such. + +Out of all the approaches used, unit testing has the most tools available and the coverage can simply be displayed as % of code lines tested. Although this is a very nice and very easy to understand metric, it does not speak about the quality of the test coverage. + +Since distributed systems testing is a lot more involved, unit tests are oftentimes not sufficient to cover complex interactions. Unit tests are still necessary and helpful, but in cases where unit tests are not helpful e2e or integration tests should be favored. + +### Integration testing +With integration testing we **test the multi-module interactions** while isolating them from the remainder of the system. +Integration tests can uncover bugs that are often missed by unit tests. + +It is very difficult to gauge the actual test coverage imparted by integration tests and the available tooling is limited. +In interchain-security we employ the `ibc-go/testing` framework to test interactions in-memory. + +At present, integration testing does not involve the consensus layer - it is only concerned with application level state and logic. + +### End-to-end testing +In our context end-to-end testing comprises of tests that use the actual application binaries in an isolated environment (e.g. docker container). During test execution the inputs are meant to simulate actual user interaction, either by submitting transactions/queries using the command line or using gRPC/REST APIs and checking for state changes after an action has been performed. With this testing strategy we also include the consensus layer in all of our runs. This is the closest we can get to testing user interactions without starting a full testnet. + +End-to-end testing strategies vary between different teams and projects and we strive to unify our approach to the best of our ability (at least for ICS and gaia). + +The available tooling does not give us significant (or relevant) line of code coverage information since most of the tools are geared towards analyzing unit tests and simple code branch evaluation. + +We aim to adapt our best practices by learning from other similar systems and projects such as cosmos-sdk, ibc-go and CometBFT. + + +## Decision + +### 1. Connect specifications to code and tooling +Oftentimes, specifications are disconnected from the development and QA processes. This gives rise to problems where the specification does not reflect the actual state of the system and vice-versa. +Usually specifications are just text files that are rarely used and go unmaintained after a while, resulting in consistency issues and misleading instructions/expectations about system behavior. + +#### Decision context and hypothesis +Specifications written in a dedicated and executable specification language are easier to maintain than the ones written entirely in text. +Additionally, we can create models based on the specification OR make the model equivalent to a specification. + +Models do not care about the intricacies of implementation and neither do specifications. Since both models and specifications care about concisely and accurately describing a system (such as a finite state machine), we see a benefit of adding model based tools (such as [quint](https://github.com/informalsystems/quint)) to our testing and development workflows. + +#### Main benefit +MBT tooling can be used to generate test traces that can be executed by multiple different testing setups. + +### 2. Improve e2e tooling + +#### Matrix tests +Instead of only running tests against current `main` branch we should adopt an approach where we also: +- **run regression tests against different released software versions** (`ICS v1 vs v2 vs v3`) +- **run non-determinism tests to uncover issues quickly** + +Matrix tests can be implemented using [CometMock](https://github.com/informalsystems/CometMock) and refactoring our current e2e CI setup. + +#### Introducing e2e regression testing + +This e2e test suite would execute using a cronjob in our CI (nightly, multiple times a day etc.) + +Briefly, the same set of traces is run against different **maintained** versions of the software and the `main` branch. +This would allow us to discover potential issues during development instead of in a testnet scenarios. + +The most valuable issues that can be discovered in this way are **state breaking changes**, **regressions** and **version incompatibilities**. + +The setup is illustrated by the image below. +![e2e matrix tests](../../figures/matrix_e2e_tests.png) + +This table explains which versions are tested against each other for the same set of test traces: +* βœ… marks a passing test +* ❌ marks a failing test + +| **USES: ICS v1 PROVIDER** | **start chain** | **add key** | **delegate** | **undelegate** | **redelegate** | **downtime** | **equivocation** | **stop chain** | +|---------------------------------|-----------------|-------------|--------------|----------------|----------------|--------------|------------------|----------------| +| **v1 consumer (sdk45,ibc4.3)** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | +| **v2 consumer (sdk45, ibc4.4)** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | +| **v3 consumer (sdk47, ibc7)** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | +| **main consumer** | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | +| **neutron** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | ❌ | +| **stride** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | ❌ | + + +#### Introducing e2e CometMock tests + +CometMock is a mock implementation of the [CometBFT](https://github.com/cometbft/cometbft) consensus engine. It supports most operations performed by CometBFT while also being lightweight and relatively easy to use. + +CometMock tests allow more nuanced control of test scenarios because CometMock can "fool" the blockchain app into thinking that a certain number of blocks had passed. +**This allows us to test very nuanced scenarios, difficult edge cases and long-running operations (such as unbonding operations).** + +Examples of tests made easier with CometMock are listed below: +- regression tests +- non-determinism tests +- upgrade tests +- state-breaking changes + +With CometMock, the **matrix test** approach can also be used. The image below illustrates a CometMock setup that can be used to discover non-deterministic behavior and state-breaking changes. +![e2e matrix tests](../../figures/cometmock_matrix_test.png) + +This table explains which versions are tested against each other for the same set of test traces: +* βœ… marks a passing test +* ❌ marks a failing test + +| **SCENARIO** | **start chain** | **add key** | **delegate** | **undelegate** | **redelegate** | **downtime** | **equivocation** | **stop chain** | +|---------------------------------|-----------------|-------------|--------------|----------------|----------------|--------------|------------------|----------------| +| **v3 provi + v3 consu** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | +| **main provi + main consu** | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | βœ… | +| **commit provi + commit consu** | βœ… | ❌ | βœ… | ❌ | βœ… | βœ… | ❌ | ❌ | + + +Briefly; multiple versions of the application are run against the same CometMock instance and any deviations in app behavior would result in `app hash` errors (the apps would be in different states after performing the same set of actions). + +### 3. Introduce innovative testing approaches + +When discussing e2e testing, some very important patterns emerge - especially if test traces are used instead of ad-hoc tests written by hand. + +We see a unique opportunity to clearly identify concerns and modularize the testing architecture. + +The e2e testing frameworks can be split into a **pipeline consisting of 3 parts: model, driver and harness**. + +#### Model + +Model is the part of the system that can emulate the behavior of the system under test. +Ideally, it is very close to the specification and is written in a specification language such as quint, TLA+ or similar. +One of the purposes of the model is that it can be used to generate test traces. + + +#### Driver + +The purpose of the driver is to accept test traces (generated by the model or written by hand), process them and provide inputs to the next part of the pipeline. + +Basically, the driver sits between the model and the actual infrastructure on which the test traces are being executed on. + +#### Harness + +Harness is the infrastructure layer of the pipeline that accepts inputs from the driver. + +There can be multiple harnesses as long as they can perform four things: +* bootstrap a test execution environment (local, docker, k8s…) +* accept inputs from drivers +* perform the action specified by the driver +* report results after performing actions + + +## Consequences + +The procedure outlined in this ADR is not an all-or-nothing approach. Concepts introduced here do not rely on each other, so this ADR may only be applied partially without negative impact on test coverage and code confidence. + +### Positive + +1. introduction of maintainable MBT solutions +* improvement over the current "difftest" setup that relies on an opinionated typescript model and go driver + +2. increased code coverage and confidence +* using CometMock allows us to run more tests in less time +* adding matrix e2e tests allows us to quickly pinpoint differences between code versions + + +### Negative +It might be easier to forgo the MBT tooling and instead focus on pure property based testing + +- [PBT proof of concept](https://github.com/cosmos/interchain-security/pull/667) +- [property based testing in go](https://github.com/flyingmutant/rapid) + +The solutions are potentially expensive if we increase usage of the CI pipeline - this is fixed by running "expensive" tests using a cronjob, instead of running them on every commit. + +### Neutral +The process of changing development and testing process is not something that can be thought of and delivered quickly. Luckily, the changes can be rolled out incrementally without impacting existing workflows. + +## References + +> Are there any relevant PR comments, issues that led up to this, or articles referenced for why we made the given design choice? If so link them here! + +* https://github.com/cosmos/gaia/issues/2427 +* https://github.com/cosmos/gaia/issues/2420 +* [ibc-go e2e tests](https://github.com/cosmos/ibc-go/tree/main/e2e) diff --git a/docs/docs/adrs/adr-012-separate-releasing.md b/docs/docs/adrs/adr-012-separate-releasing.md new file mode 100644 index 0000000000..386c8add29 --- /dev/null +++ b/docs/docs/adrs/adr-012-separate-releasing.md @@ -0,0 +1,76 @@ +--- +sidebar_position: 13 +title: Separate Releasing +--- +# ADR 012: Separate Releasing + +## Changelog + +* {8/18/22}: Initial draft of idea in [#801](https://github.com/cosmos/interchain-security/issues/801) +* {8/22/22}: Put idea in this ADR + +## Status + +Accepted + +## Context + +### Spike results + +I explored the idea of [#801](https://github.com/cosmos/interchain-security/issues/801) with this [spike branch](https://github.com/cosmos/interchain-security/tree/shawn%2Fgo-mod-split-aug-spike). Here's my conclusions: + +Splitting this repo to have multiple go.mods is possible. However there are various intricacies involved in decoupling the package hierarchy to have `x/ccv/types` as the lowest level dep, with `x/ccv/consumer` and `x/ccv/provider` being one dep layer above, with high-level tests depending on all three of the mentioned packages. I'd estimate this decoupling would take 2-5 workdays to finish, and require significant review effort. + +### Why go.mod split is not the way to go + +Let's take a step back and remember the issue we're trying to solve - **We need a clean way to decouple semver/releasing for the consumer and provider modules**. After more consideration, splitting up go.mods gives us little benefit in achieving this. Reasons: + +* The `go.mod` dependency system is tied to git tags for the entire repo (ex: `require github.com/cometbft/cometbft v0.37.2` refers to a historical tag for the entire cometbft repo). +* It'd be an odd dev experience to allow modules to reference past releases of other modules in the same repo. When would we ever want the consumer module to reference a past release of the types module for example? +* If we allow for `go.mod` replace statements to build from local source code, why split up the package deps at all? +* Splitting go.mods adds a bunch of complexity with `go.work` files and all that shiz. VSCode does not play well with multiple module repos either. + +### Why separate repos is cool but also not the way to go + +All this considered, the cleanest solution to decoupling semver/releasing for the consumer and provider modules would be to have multiple repos, each with their own go.mod (3-4 repos total including high level tests). With this scheme we could separately tag each repo as changes are merged, they could share some code from `types` being an external dep, etc. + +I don't think any of us want to split up the monorepo, that's a lot of work and seems like bikeshedding. There's another solution that's very simple.. + +## Decision + +Slightly adapting [the current semver ruleset](https://github.com/cosmos/interchain-security/blob/cca008d856e3ffc60ec1a486871d0faa702abe26/CONTRIBUTING.md#semantic-versioning): + +* A library API breaking change to EITHER the provider or consumer module will result in an increase of the MAJOR version number for BOTH modules (X.y.z-provider AND X.y.z-consumer). +* A state breaking change (change requiring coordinated upgrade and/or state migration) will result in an increase of the MINOR version number for the AFFECTED module(s) (x.Y.z-provider AND/OR x.Y.z-consumer). +* Any other changes (including node API breaking changes) will result in an increase of the PATCH version number for the AFFECTED module(s) (x.y.Z-provider AND/OR x.y.Z-consumer). + +### Example release flow + +We upgrade `main` to use a new version of SDK. This is a major version bump, triggering a new release for both the provider and consumer modules, `v5.0.0-provider` and `v5.0.0-consumer`. + +* A state breaking change is merged to `main` for the provider module. We release only a `v5.1.0-provider` off main. +* Another state breaking change is merged to `main` for the provider module. We release only a `v5.2.0-provider` off main. +* At this point, the latest consumer version is still `v5.0.0-consumer`. We now merge a state breaking change for the consumer module to `main`, and consequently release `v5.1.0-consumer`. Note that `v5.1.0-consumer` is tagged off a LATER commit from main than `v5.2.0-provider`. This is fine, as the consumer module should not be affected by the provider module's state breaking changes. +* Once either module sees a library API breaking change, we bump the major version for both modules. For example, we merge a library API breaking change to `main` for the provider module. We release `v6.0.0-provider` and `v6.0.0-consumer` off main. Note that most often, a library API breaking change will affect both modules simultaneously (example being bumping sdk version). + +## Consequences + +### Positive + +* Consumer repos have clear communication of what tagged versions are relevant to them. Consumer devs should know to never reference an ICS version that starts with `provider`, even if it'd technically build. +* Consumer and provider modules do not deviate as long as we continually release off a shared main branch. Backporting remains relatively unchanged besides being explicit about what module(s) your changes should affect. +* No code changes, just changes in process. Very simple. + +### Negative + +* Slightly more complexity. +* This solution does not allow having provider and consumer on separate versions of e.g. the Cosmos SDK + +### Neutral + +## References + +> Are there any relevant PR comments, issues that led up to this, or articles referenced for why we made the given design choice? If so link them here! + +* [#801](https://github.com/cosmos/interchain-security/issues/801) +* [#801 comment](https://github.com/cosmos/interchain-security/issues/801#issuecomment-1683349298) diff --git a/docs/docs/adrs/adr-013-equivocation-slashing.md b/docs/docs/adrs/adr-013-equivocation-slashing.md new file mode 100644 index 0000000000..1351cf5234 --- /dev/null +++ b/docs/docs/adrs/adr-013-equivocation-slashing.md @@ -0,0 +1,147 @@ +--- +sidebar_position: 14 +title: Slashing on the provider for consumer equivocation +--- +# ADR 013: Slashing on the provider for consumer equivocation + +## Changelog +* 1st Sept. 2023: Initial draft + +## Status +Proposed + +## Context +This ADR presents some approaches on how to slash on the provider chain validators that performed equivocations on consumer chains. +Currently, the provider chain can [receive and verify evidence of equivocation](https://github.com/cosmos/interchain-security/pull/1232), but it cannot slash the misbehaving validator. + +In the remainder of this section, we explain how slashing is performed on a single chain and show why slashing on the provider for equivocation on the consumer is challenging. + +Note that future versions of the Cosmos SDK, CometBFT, and ibc-go could modify the way we slash, etc. Therefore, a future reader of this ADR, should note that when we refer to Cosmos SDK, CometBFT, and ibc-go we specifically refer to their [v0.47](https://docs.cosmos.network/v0.47/intro/overview), [v0.37](https://docs.cometbft.com/v0.37/) and [v7.3.0](https://github.com/cosmos/ibc-go/blob/v7.3.0) versions respectively. + +### Single-chain slashing +Slashing is implemented across the [slashing](https://docs.cosmos.network/v0.47/modules/slashing) +and [staking](https://docs.cosmos.network/v0.47/modules/staking) modules. +The slashing module's keeper calls the staking module's `Slash()` method, passing among others, the `infractionHeight` (i.e., the height when the equivocation occurred), the validator's `power` at the infraction height, and the `slashFactor` (currently set to `5%` in case of equivocation on the Cosmos Hub). + +#### Slashing undelegations and redelegations +To slash undelegations, `Slash` goes through all undelegations and checks whether they started before or after the infraction occurred. If an undelegation started before the `infractionHeight`, then it is **not** slashed, otherwise it is slashed by `slashFactor`. + +The slashing of redelegations happens in a similar way, meaning that `Slash` goes through all redelegations and checks whether the redelegations started before or after the `infractionHeight`. + +#### Slashing delegations +Besides undelegations and redelegations, the validator's delegations need to also be slashed. +This is performed by deducting the appropriate amount of tokens from the validator. Note that this deduction is computed based on the voting `power` the misbehaving validator had at the height of the equivocation. As a result of the tokens deduction, +the [tokens per share](https://docs.cosmos.network/v0.47/modules/staking#delegator-shares) +reduce and hence later on, when delegators undelegate or redelegate, the delegators retrieve back less +tokens, effectively having their tokens slashed. The rationale behind this slashing mechanism, as mentioned in the [Cosmos SDK documentation](https://docs.cosmos.network/v0.47/modules/staking#delegator-shares) +> [...] is to simplify the accounting around slashing. Rather than iteratively slashing the tokens of every delegation entry, instead the Validators total bonded tokens can be slashed, effectively reducing the value of each issued delegator share. + +This approach of slashing delegations does not utilize the +`infractionHeight` in any way and hence the following scenario could occur: + 1. a validator `V` performs an equivocation at a height `Hi` + 2. a new delegator `D` delegates to `V` after height `Hi` + 3. evidence of the equivocation by validator `V` is received + 4. the tokens of delegator `D` are slashed + +In the above scenario, delegator `D` is slashed, even though `D`'s voting power did not contribute to the infraction. + + +#### Old evidence +In the single-chain case, old evidence (e.g., from 3 years ago) is ignored. This is achieved through +[CometBFT](https://docs.cometbft.com/v0.37/spec/consensus/evidence) that ignores old evidence based on the parameters `MaxAgeNumBlocks` and `MaxAgeDuration` (see [here](https://github.com/cometbft/cometbft/blob/v0.37.0/evidence/pool.go#271)). +Additionally, note that when the evidence is sent by CometBFT to the application, the evidence is rechecked in the [evidence module](https://github.com/cosmos/cosmos-sdk/blob/v0.47.0/x/evidence/keeper/infraction.go#L54) of Cosmos SDK and if it is old, the evidence is ignored. +In Cosmos Hub, the `MaxAgeNumBlocks` is set to 1000000 (i.e., ~70 days if we assume we need ~6 sec per block) and `MaxAgeDuration` is set to 172800000000000 ns (i.e., 2 days). Because of this check, we can easily exclude old evidence. + +### Slashing for equivocation on the consumer +In the single-chain case, slashing requires both the `infractionHeight` and the voting `power`. +In order to slash on the provider for an equivocation on a consumer, we need to have both the provider's `infractionHeight` and voting `power`. +Note that the `infractionHeight` on the consumer chain must be mapped to a height on the provider chain. +Unless we have a way to find the corresponding `infractionHeight` and `power` on the provider chain, we cannot slash for equivocation on the consumer in the same way as we would slash in the single-chain case. + + +The challenge of figuring out the corresponding `infractionHeight` and `power` values on the provider chain is due to the following trust assumption: + +- We trust the consensus layer and validator set of the consumer chains, _but we do not trust the application layer_. + +As a result, we cannot trust anything that stems from the _application state_ of a consumer chain. + +Note that when a relayer or a user sends evidence through a [MsgSubmitConsumerDoubleVoting](https://github.com/cosmos/interchain-security/pull/1232) message, the provider gets access to [DuplicateVoteEvidence](https://github.com/cometbft/cometbft/blob/v0.37.0/types/evidence.go#L35): +```protobuf +type DuplicateVoteEvidence struct { + VoteA *Vote `json:"vote_a"` + VoteB *Vote `json:"vote_b"` + + // abci specific information + TotalVotingPower int64 + ValidatorPower int64 + Timestamp time.Time +} +``` +The "abci specific information" fields cannot be trusted because they are not signed. Therefore, +we can use neither `ValidatorPower` for slashing on the provider chain, nor the `Timestamp` to check the evidence age. We can get the `infractionHeight` from the votes, but this `infractionHeight` corresponds to the infraction height on the consumer and **not** on the provider chain. +Similarly, when a relayer or a user sends evidence through a [MsgSubmitConsumerMisbehaviour](https://github.com/cosmos/interchain-security/pull/826) message, the provider gets access to [Misbehaviour](https://github.com/cosmos/ibc-go/blob/v7.3.0/proto/ibc/lightclients/tendermint/v1/tendermint.proto#L79) that we cannot use to extract the infraction height, power, or the time on the provider chain. + +## Proposed solution +As a first iteration, we propose the following approach. At the moment the provider receives evidence of equivocation on a consumer: +1. slash all the undelegations and redelegations using `slashFactor`; +2. slash all delegations using as voting `power` the sum of the voting power of the misbehaving validator and the power of all the ongoing undelegations and redelegations. + +**Evidence expiration:** Additionally, because we cannot infer the actual time of the evidence (i.e., the timestamp of the evidence cannot be trusted), we do not consider _evidence expiration_ and hence old evidence is never ignored (e.g., the provider would act on 3 year-old evidence of equivocation on a consumer). +Additionally, we do not need to store equivocation evidence to avoid slashing a validator more than once, because we [do not slash](https://github.com/cosmos/cosmos-sdk/blob/v0.47.0/x/evidence/keeper/infraction.go#L94) tombstoned validators and we [tombstone](https://github.com/cosmos/cosmos-sdk/blob/v0.47.0/x/evidence/keeper/infraction.go#L138) a validator when slashed. + +We do not act on evidence that was signed by a validator [consensus key](https://tutorials.cosmos.network/tutorials/9-path-to-prod/3-keys.html#what-validator-keys) that is _pruned_ when we receive the evidence. We prune a validator's consensus key if the validator has assigned a new consumer key (using `MsgAssignConsumerKey`) and an unbonding period on the consumer chain has elapsed (see [key assignment ADR](https://github.com/cosmos/interchain-security/blob/main/docs/docs/adrs/adr-001-key-assignment.md)). Note that the provider chain is informed that the unbonding period has elapsed on the consumer when the provider receives a `VSCMaturedPacket` and because of this, if the consumer delays the sending of a `VSCMaturedPacket`, we would delay the pruning of the key as well. + +### Implementation +The following logic needs to be added to the [HandleConsumerDoubleVoting](https://github.com/cosmos/interchain-security/pull/1232) and [HandleConsumerMisbehaviour](https://github.com/cosmos/interchain-security/pull/826) methods: +```go +undelegationsInTokens := sdk.NewInt(0) +for _, v := range k.stakingKeeper.GetUnbondingDelegationsFromValidator(ctx, validatorAddress) { + for _, entry := range v.Entries { + if entry.IsMature(now) && !entry.OnHold() { + // undelegation no longer eligible for slashing, skip it + continue + } + undelegationsInTokens = undelegationsInTokens.Add(entry.InitialBalance) + } +} + +redelegationsInTokens := sdk.NewInt(0) +for _, v := range k.stakingKeeper.GetRedelegationsFromSrcValidator(ctx, validatorAddress) { + for _, entry := range v.Entries { + if entry.IsMature(now) && !entry.OnHold() { + // redelegation no longer eligible for slashing, skip it + continue + } + redelegationsInTokens = redelegationsInTokens.Add(entry.InitialBalance) + } +} + +infractionHeight := 0 +undelegationsAndRedelegationsInPower = sdk.TokensToConsensusPower(undelegationsInTokens.Add(redelegationsInTokens)) +totalPower := validator's voting power + undelegationsAndRedelegationsInPower +slashFraction := k.slashingKeeper.SlashFractionDoubleSign(ctx) + +k.stakingKeeper.Slash(ctx, validatorConsAddress, infractionHeight, totalPower, slashFraction, DoubleSign) +``` + +**Infraction height:** We provide a zero `infractionHeight` to the [Slash](https://github.com/cosmos/cosmos-sdk/blob/v0.47.0/x/staking/keeper/slash.go#L33) method in order to slash all ongoing undelegations and redelegations (see checks in [Slash](https://github.com/cosmos/cosmos-sdk/blob/v0.47.0/x/staking/keeper/slash.go#L92), [SlashUnbondingDelegation](https://github.com/cosmos/cosmos-sdk/blob/v0.47.0/x/staking/keeper/slash.go#L195), and [SlashRedelegation](https://github.com/cosmos/cosmos-sdk/blob/v0.47.0/x/staking/keeper/slash.go#L249)). + +**Power:** We pass the sum of the voting power of the misbehaving validator when the evidence was received (i.e., at evidence height) and the power of all the ongoing undelegations and redelegations. +If we assume that the `slashFactor` is `5%`, then the voting power we pass is `power + totalPower(undelegations) + totalPower(redelegations)`. +Hence, when the `Slash` method slashes all the undelegations and redelegations it would end up with `0.05 * power + 0.05 * totalPower(undelegations) + 0.05 * totalPower(redelegations) - 0.05 * totalPower(undelegations) - 0.05 * totalPower(redelegations) = 0.05 * power` and hence it would slash `5%` of the validator's power when the evidence is received. + +### Positive +With the proposed approach we can quickly implement slashing functionality on the provider chain for consumer chain equivocations. +This approach does not need to change the staking module and therefore does not change in any way how slashing is performed today for a single chain. + +### Negative + +- We _definitely_ slash more when it comes to undelegations and redelegations because we slash for all of them without considering an `infractionHeight`. +- We _potentially_ slash more than what we would have slashed if we knew the voting `power` at the corresponding `infractionHeight` in the provider chain. +- We slash on old evidence of equivocation on a consumer. + + +## References +* [ADR 005: Cryptographic verification of equivocation evidence](https://github.com/cosmos/interchain-security/blob/main/docs/docs/adrs/adr-005-cryptographic-equivocation-verification.md) +* [EPIC tracking cryptographic equivocation feature](https://github.com/cosmos/interchain-security/issues/732) +* [Cosmos Hub Forum discussion on cryptographic equivocation slashing](https://forum.cosmos.network/t/cryptographic-equivocation-slashing-design/11400) diff --git a/docs/docs/adrs/intro.md b/docs/docs/adrs/intro.md index 0c1c722366..5ab86c2a93 100644 --- a/docs/docs/adrs/intro.md +++ b/docs/docs/adrs/intro.md @@ -40,4 +40,7 @@ To suggest an ADR, please make use of the [ADR template](./adr-template.md) prov | [007](./adr-007-pause-unbonding-on-eqv-prop.md) | Pause validator unbonding during equivocation proposal | Proposed | | [008](./adr-008-throttle-retries.md) | Throttle with retries | Accepted, In-progress | | [009](./adr-009-soft-opt-out.md) | Soft Opt-out | Accepted, Implemented | -| [009](./adr-010-standalone-changeover.md) | Standalone to Consumer Changeover | Accepted, Implemented | +| [010](./adr-010-standalone-changeover.md) | Standalone to Consumer Changeover | Accepted, Implemented | +| [011](./adr-011-improving-test-confidence.md) | Improving testing and increasing confidence | Proposed | +| [012](./adr-012-separate-releasing.md) | Separate Releasing | Proposed | +| [013](./adr-013-equivocation-slashing.md) | Slashing on the provider for consumer equivocation | Proposed | diff --git a/docs/docs/consumer-development/changeover-procedure.md b/docs/docs/consumer-development/changeover-procedure.md index 825a0bdae4..446f91775b 100644 --- a/docs/docs/consumer-development/changeover-procedure.md +++ b/docs/docs/consumer-development/changeover-procedure.md @@ -48,7 +48,7 @@ RevisionNumber: 0, RevisionHeight: 111 * `spawn_time` listed in the proposal MUST be before the `upgrade_height` listed in the the upgrade proposal on the standalone chain. :::caution -`spawn_time` must occur before the `upgrade_height` on the standalone chain is reached becasue the `provider` chain must generate the `ConsumerGenesis` that contains the **validator set** that will be used after the changeover. +`spawn_time` must occur before the `upgrade_height` on the standalone chain is reached because the `provider` chain must generate the `ConsumerGenesis` that contains the **validator set** that will be used after the changeover. ::: * `unbonding_period` must correspond to the value used on the standalone chain. Otherwise, the clients used for the ccv protocol may be incorrectly initialized. @@ -128,7 +128,7 @@ To help validators and other node runners onboard onto your chain, please prepar This should include (at minimum): -- [ ] genesis.json with CCV data (after spawn time passes) +- [ ] genesis.json with CCV data (after spawn time passes). Check if CCV data needs to be transformed (see [Transform Consumer Genesis](./consumer-genesis-transformation.md)) - [ ] information about relevant seed/peer nodes you are running - [ ] relayer information (compatible versions) - [ ] copy of your governance proposal (as JSON) diff --git a/docs/docs/consumer-development/consumer-genesis-transformation.md b/docs/docs/consumer-development/consumer-genesis-transformation.md new file mode 100644 index 0000000000..5a19e5c71d --- /dev/null +++ b/docs/docs/consumer-development/consumer-genesis-transformation.md @@ -0,0 +1,29 @@ +--- +sidebar_position: 6 +--- + +# Consumer Genesis Transformation + +Preparing a consumer chain for onboarding requires some information explaining how to run your chain. This includes a genesis file with CCV data where the CCV data is exported from the provider chain and added to the consumers genesis file (for more details check the documentaion on [Onboarding](./onboarding.md) and [Changeover](./changeover-procedure.md)). +In case that the provider chain is running an older version of the InterChainSecurity (ICS) module than the consumer chain the exported CCV data might need to be transformed to the format supported by the ICS implementation run on the consumer chain. This is the case if the cosumer chain runs version 4 of ICS or later and the provider is running version 3 or older of the ICS module. + +To transform such CCV data follow the instructions below + +## 1. Prerequisite +- Provider chain is running version 3 or older of the ICS provider module +- Consumer is running version 4 or later of the ICS consumer module. +- interchain-security-cd application complies to the version run on the consumer chain + +## 2. Export the CCV data +Export the CCV data from the provider chain as descibed in the [Onboarding](./onboarding.md) and [Changeover](./changeover-procedure.md)) your following. +As a result the CCV data will be stored in a file in JSON format. + +## 3. Transform CCV data +To transform the CCV data to the newer format run the following command. +``` +interchain-security-cd genesis transform [genesis-file] +``` +where 'genesis-file' is the path to the file containing the CCV data exported in [step 2](#2-export-the-ccv-data). +As a result the CCV data in the new format will be written to standard output. + +Use the new CCV data as described in the procedure you're following. \ No newline at end of file diff --git a/docs/docs/consumer-development/onboarding.md b/docs/docs/consumer-development/onboarding.md index c9b503ed66..893af0a3b1 100644 --- a/docs/docs/consumer-development/onboarding.md +++ b/docs/docs/consumer-development/onboarding.md @@ -21,7 +21,7 @@ To help validators and other node runners onboard onto your chain, please prepar This should include (at minimum): - [ ] genesis.json without CCV data (before the proposal passes) -- [ ] genesis.json with CCV data (after spawn time passes) +- [ ] genesis.json with CCV data (after spawn time passes). Check if CCV data needs to be transformed (see [Transform Consumer Genesis](./consumer-genesis-transformation.md)) - [ ] information about relevant seed/peer nodes you are running - [ ] relayer information (compatible versions) - [ ] copy of your governance proposal (as JSON) diff --git a/docs/docs/features/proposals.md b/docs/docs/features/proposals.md index 25664bfc1e..de4f2dc421 100644 --- a/docs/docs/features/proposals.md +++ b/docs/docs/features/proposals.md @@ -105,6 +105,23 @@ Minimal example: } ``` +## ChangeRewardDenomProposal +:::tip +`ChangeRewardDenomProposal` will only be accepted on the provider chain if at least one of the denomsToAdd or denomsToRemove fields is populated with at least one denom. Also, a denom cannot be repeated in both sets. +::: + +Proposal type used to mutate the set of denoms accepted by the provider as rewards. + +Minimal example: +```js +{ + "title": "Add untrn as a reward denom", + "description": "Here is more information about the proposal", + "denomsToAdd": ["untrn"], + "denomsToRemove": [] +} +``` + ### Notes When submitting equivocation evidence through an `EquivocationProposal` please take note that you need to use the consensus address (`valcons`) of the offending validator on the **provider chain**. Besides that, the `height` and the `time` fields should be mapped to the **provider chain** to avoid your evidence being rejected. diff --git a/docs/figures/cometmock_matrix_test.png b/docs/figures/cometmock_matrix_test.png new file mode 100644 index 0000000000..740005aed1 Binary files /dev/null and b/docs/figures/cometmock_matrix_test.png differ diff --git a/docs/figures/matrix_e2e_tests.png b/docs/figures/matrix_e2e_tests.png new file mode 100644 index 0000000000..4c94db81a3 Binary files /dev/null and b/docs/figures/matrix_e2e_tests.png differ diff --git a/go.mod b/go.mod index abfab65b68..8b7f79e20c 100644 --- a/go.mod +++ b/go.mod @@ -6,43 +6,43 @@ toolchain go1.21.3 require ( cosmossdk.io/errors v1.0.0 - cosmossdk.io/math v1.0.1 + cosmossdk.io/math v1.1.2 github.com/cometbft/cometbft v0.37.2 github.com/cometbft/cometbft-db v0.8.0 - github.com/cosmos/cosmos-sdk v0.47.3 + github.com/cosmos/cosmos-sdk v0.47.5 github.com/cosmos/gogoproto v1.4.10 - github.com/cosmos/ibc-go/v7 v7.2.0 + github.com/cosmos/ibc-go/v7 v7.3.0 github.com/cosmos/ics23/go v0.10.0 github.com/golang/mock v1.6.0 github.com/golang/protobuf v1.5.3 github.com/gorilla/mux v1.8.0 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/kylelemons/godebug v1.1.0 - github.com/oxyno-zeta/gomock-extra-matcher v1.1.0 + github.com/oxyno-zeta/gomock-extra-matcher v1.2.0 github.com/rakyll/statik v0.1.7 // indirect github.com/spf13/cast v1.5.1 github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.4 - github.com/tidwall/gjson v1.16.0 - golang.org/x/crypto v0.11.0 // indirect - golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc - golang.org/x/net v0.12.0 // indirect - golang.org/x/sys v0.10.0 // indirect - google.golang.org/genproto v0.0.0-20230629202037-9506855d4529 // indirect - google.golang.org/grpc v1.57.0 + github.com/tidwall/gjson v1.17.0 + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 // indirect + google.golang.org/grpc v1.58.3 google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - cloud.google.com/go v0.110.0 // indirect - cloud.google.com/go/compute v1.19.1 // indirect + cloud.google.com/go v0.110.4 // indirect + cloud.google.com/go/compute v1.21.0 // indirect cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v0.13.0 // indirect - cloud.google.com/go/storage v1.29.0 // indirect + cloud.google.com/go/iam v1.1.1 // indirect + cloud.google.com/go/storage v1.30.1 // indirect cosmossdk.io/api v0.3.1 cosmossdk.io/core v0.5.1 // indirect - cosmossdk.io/depinject v1.0.0-alpha.3 // indirect + cosmossdk.io/depinject v1.0.0-alpha.4 // indirect cosmossdk.io/tools/rosetta v0.2.1 filippo.io/edwards25519 v1.0.0 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect @@ -70,7 +70,7 @@ require ( github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect github.com/creachadair/taskgroup v0.4.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect - github.com/davecgh/go-spew v1.1.1 // indirect + github.com/davecgh/go-spew v1.1.1 github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v2 v2.2007.4 // indirect @@ -90,11 +90,11 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/go-cmp v0.5.9 // indirect + github.com/google/go-cmp v0.6.0 github.com/google/orderedcode v0.0.1 // indirect github.com/google/uuid v1.3.0 // indirect github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect - github.com/googleapis/gax-go/v2 v2.8.0 // indirect + github.com/googleapis/gax-go/v2 v2.11.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect @@ -121,7 +121,7 @@ require ( github.com/linxGnu/grocksdb v1.7.16 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/manifoldco/promptui v0.9.0 // indirect - github.com/mattn/go-isatty v0.0.18 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect github.com/minio/highwayhash v1.0.2 // indirect @@ -154,33 +154,40 @@ require ( github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.7 // indirect go.opencensus.io v0.24.0 // indirect - golang.org/x/oauth2 v0.7.0 // indirect - golang.org/x/term v0.10.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/oauth2 v0.10.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect - google.golang.org/api v0.122.0 // indirect + google.golang.org/api v0.126.0 // indirect google.golang.org/appengine v1.6.7 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect - pgregory.net/rapid v0.5.5 // indirect + pgregory.net/rapid v1.1.0 sigs.k8s.io/yaml v1.3.0 // indirect ) require ( github.com/spf13/viper v1.16.0 - google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e + google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 ) require ( - cosmossdk.io/log v1.1.0 // indirect - github.com/go-playground/locales v0.14.0 // indirect - github.com/google/s2a-go v0.1.3 // indirect - github.com/informalsystems/itf-go v0.0.1 // indirect +github.com/informalsystems/itf-go v0.0.1 // indirect + cosmossdk.io/log v1.2.1 // indirect + github.com/cockroachdb/errors v1.10.0 // indirect + github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect + github.com/cockroachdb/redact v1.1.5 // indirect + github.com/getsentry/sentry-go v0.23.0 // indirect + github.com/google/s2a-go v0.1.4 // indirect + github.com/kr/pretty v0.3.1 // indirect + github.com/kr/text v0.2.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/rs/zerolog v1.29.1 // indirect - golang.org/x/sync v0.1.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect + github.com/rogpeppe/go-internal v1.11.0 // indirect + github.com/rs/zerolog v1.30.0 // indirect + go.uber.org/mock v0.2.0 // indirect + golang.org/x/sync v0.3.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect ) // following versions might cause unexpected behavior diff --git a/go.sum b/go.sum index 849ddb606d..d982afd86f 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,8 @@ cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w9 cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go v0.110.0 h1:Zc8gqp3+a9/Eyph2KDmcGaPtbKRIoqq4YTlL4NMD0Ys= -cloud.google.com/go v0.110.0/go.mod h1:SJnCLqQ0FCFGSZMUNUf84MV3Aia54kn7pi8st7tMzaY= +cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk= +cloud.google.com/go v0.110.4/go.mod h1:+EYjdK8e5RME/VY/qLCAtuyALQ9q67dvuum8i+H5xsI= cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= @@ -73,8 +73,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU= -cloud.google.com/go/compute v1.19.1 h1:am86mquDUgjGNWxiGn+5PGLbmgiWXlE/yNWpIpNvuXY= -cloud.google.com/go/compute v1.19.1/go.mod h1:6ylj3a05WF8leseCdIf77NK0g1ey+nj5IKd5/kvShxE= +cloud.google.com/go/compute v1.21.0 h1:JNBsyXVoOoNJtTQcnEY5uYpZIbeCTYIeDe0Xh1bySMk= +cloud.google.com/go/compute v1.21.0/go.mod h1:4tCnrn48xsqlwSAiLf1HXMQk8CONslYbdiEZc9FEIbM= cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= @@ -114,13 +114,12 @@ cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y97 cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/iam v0.5.0/go.mod h1:wPU9Vt0P4UmCux7mqtRu6jcpPAb74cP1fh50J3QpkUc= -cloud.google.com/go/iam v0.13.0 h1:+CmB+K0J/33d0zSQ9SlFWUeCCEn5XJA0ZMZ3pHE9u8k= -cloud.google.com/go/iam v0.13.0/go.mod h1:ljOg+rcNfzZ5d6f1nAUJ8ZIxOaZUVoS14bKCtaLZ/D0= +cloud.google.com/go/iam v1.1.1 h1:lW7fzj15aVIXYHREOqjRBV9PsH0Z6u8Y46a1YGvQP4Y= +cloud.google.com/go/iam v1.1.1/go.mod h1:A5avdyVL2tCppe4unb0951eI9jreack+RJ0/d+KUZOU= cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= -cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM= cloud.google.com/go/mediatranslation v0.5.0/go.mod h1:jGPUhGTybqsPQn91pNXw0xVHfuJ3leR1wj37oU3y1f4= cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= cloud.google.com/go/memcache v1.4.0/go.mod h1:rTOfiGZtJX1AaFUrOgsMHX5kAzaTQ8azHiuDoTPzNsE= @@ -178,8 +177,8 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= -cloud.google.com/go/storage v1.29.0 h1:6weCgzRvMg7lzuUurI4697AqIRPU1SvzHhynwpW31jI= -cloud.google.com/go/storage v1.29.0/go.mod h1:4puEjyTKnku6gfKoTfNOU/W+a9JyuVNxjpS5GBrB8h4= +cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM= +cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7BiccwkR7+P7gN8E= cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw= cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU= @@ -196,14 +195,14 @@ cosmossdk.io/api v0.3.1 h1:NNiOclKRR0AOlO4KIqeaG6PS6kswOMhHD0ir0SscNXE= cosmossdk.io/api v0.3.1/go.mod h1:DfHfMkiNA2Uhy8fj0JJlOCYOBp4eWUUJ1te5zBGNyIw= cosmossdk.io/core v0.5.1 h1:vQVtFrIYOQJDV3f7rw4pjjVqc1id4+mE0L9hHP66pyI= cosmossdk.io/core v0.5.1/go.mod h1:KZtwHCLjcFuo0nmDc24Xy6CRNEL9Vl/MeimQ2aC7NLE= -cosmossdk.io/depinject v1.0.0-alpha.3 h1:6evFIgj//Y3w09bqOUOzEpFj5tsxBqdc5CfkO7z+zfw= -cosmossdk.io/depinject v1.0.0-alpha.3/go.mod h1:eRbcdQ7MRpIPEM5YUJh8k97nxHpYbc3sMUnEtt8HPWU= +cosmossdk.io/depinject v1.0.0-alpha.4 h1:PLNp8ZYAMPTUKyG9IK2hsbciDWqna2z1Wsl98okJopc= +cosmossdk.io/depinject v1.0.0-alpha.4/go.mod h1:HeDk7IkR5ckZ3lMGs/o91AVUc7E596vMaOmslGFM3yU= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= -cosmossdk.io/log v1.1.0 h1:v0ogPHYeTzPcBTcPR1A3j1hkei4pZama8kz8LKlCMv0= -cosmossdk.io/log v1.1.0/go.mod h1:6zjroETlcDs+mm62gd8Ig7mZ+N+fVOZS91V17H+M4N4= -cosmossdk.io/math v1.0.1 h1:Qx3ifyOPaMLNH/89WeZFH268yCvU4xEcnPLu3sJqPPg= -cosmossdk.io/math v1.0.1/go.mod h1:Ygz4wBHrgc7g0N+8+MrnTfS9LLn9aaTGa9hKopuym5k= +cosmossdk.io/log v1.2.1 h1:Xc1GgTCicniwmMiKwDxUjO4eLhPxoVdI9vtMW8Ti/uk= +cosmossdk.io/log v1.2.1/go.mod h1:GNSCc/6+DhFIj1aLn/j7Id7PaO8DzNylUZoOYBL9+I4= +cosmossdk.io/math v1.1.2 h1:ORZetZCTyWkI5GlZ6CZS28fMHi83ZYf+A2vVnHNzZBM= +cosmossdk.io/math v1.1.2/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= cosmossdk.io/tools/rosetta v0.2.1 h1:ddOMatOH+pbxWbrGJKRAawdBkPYLfKXutK9IETnjYxw= cosmossdk.io/tools/rosetta v0.2.1/go.mod h1:Pqdc1FdvkNV3LcNIkYWt2RQY6IP1ge6YWZk8MhhO9Hw= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= @@ -243,7 +242,6 @@ github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/alecthomas/participle/v2 v2.0.0-alpha7 h1:cK4vjj0VSgb3lN1nuKA5F7dw+1s1pWBe5bx7nNCnN+c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -354,8 +352,13 @@ github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= -github.com/cockroachdb/apd/v3 v3.1.0 h1:MK3Ow7LH0W8zkd5GMKA1PvS9qG3bWFI95WaVNfyZJ/w= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/cockroachdb/errors v1.10.0 h1:lfxS8zZz1+OjtV4MtNWgboi/W5tyLEB6VQZBXN+0VUU= +github.com/cockroachdb/errors v1.10.0/go.mod h1:lknhIsEVQ9Ss/qKDBQS/UqFSvPQjOwNq2qyKAxtHRqE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= +github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= +github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= 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.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= @@ -381,8 +384,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.2 h1:X3OKvWgK9Gsejo0F1qs5l8Qn6xJV/AzgIWR2wZ8Nua8= github.com/cosmos/cosmos-proto v1.0.0-beta.2/go.mod h1:+XRCLJ14pr5HFEHIUcn51IKXD1Fy3rkEQqt4WqmN4V0= -github.com/cosmos/cosmos-sdk v0.47.3 h1:r0hGmZoAzP2D+MaPaFGHwAaTdFQq3pNpHaUp1BsffbM= -github.com/cosmos/cosmos-sdk v0.47.3/go.mod h1:c4OfLdAykA9zsj1CqrxBRqXzVz48I++JSvIMPSPcEmk= +github.com/cosmos/cosmos-sdk v0.47.5 h1:n1+WjP/VM/gAEOx3TqU2/Ny734rj/MX1kpUnn7zVJP8= +github.com/cosmos/cosmos-sdk v0.47.5/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -393,8 +396,8 @@ github.com/cosmos/gogoproto v1.4.10 h1:QH/yT8X+c0F4ZDacDv3z+xE3WU1P1Z3wQoLMBRJoK github.com/cosmos/gogoproto v1.4.10/go.mod h1:3aAZzeRWpAwr+SS/LLkICX2/kDFyaYVzckBDzygIxek= github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38= github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= -github.com/cosmos/ibc-go/v7 v7.2.0 h1:dx0DLUl7rxdyZ8NiT6UsrbzKOJx/w7s+BOaewFRH6cg= -github.com/cosmos/ibc-go/v7 v7.2.0/go.mod h1:OOcjKIRku/j1Xs1RgKK0yvKRrJ5iFuZYMetR1n3yMlc= +github.com/cosmos/ibc-go/v7 v7.3.0 h1:QtGeVMi/3JeLWuvEuC60sBHpAF40Oenx/y+bP8+wRRw= +github.com/cosmos/ibc-go/v7 v7.3.0/go.mod h1:mUmaHFXpXrEdcxfdXyau+utZf14pGKVUiXwYftRZZfQ= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= @@ -408,8 +411,6 @@ github.com/creachadair/taskgroup v0.4.2 h1:jsBLdAJE42asreGss2xZGZ8fJra7WtwnHWeJF github.com/creachadair/taskgroup v0.4.2/go.mod h1:qiXUOSrbwAY3u0JPGTzObbE3yf9hcXHDKBZ2ZjpCbgM= 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/cucumber/common/gherkin/go/v22 v22.0.0 h1:4K8NqptbvdOrjL9DEea6HFjSpbdT9+Q5kgLpmmsHYl0= -github.com/cucumber/common/messages/go/v17 v17.1.1 h1:RNqopvIFyLWnKv0LfATh34SWBhXeoFTJnSrgm9cT/Ts= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= @@ -490,14 +491,17 @@ github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbS github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= +github.com/getsentry/sentry-go v0.23.0 h1:dn+QRCeJv4pPt9OjVXiMcGIBIefaTJPw/h0bZWO05nE= +github.com/getsentry/sentry-go v0.23.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= +github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= +github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= 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= @@ -519,11 +523,10 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh 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/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= -github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= -github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= +github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -534,11 +537,11 @@ github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= +github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk= 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/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= -github.com/gofrs/uuid v4.3.0+incompatible h1:CaSVZxm5B+7o45rtab4jC2G37WGYX1zQfuU2i6DSvnc= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c= github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0= @@ -615,8 +618,9 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -645,8 +649,8 @@ github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLe 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/s2a-go v0.1.3 h1:FAgZmpLl/SXurPEZyCMPBIiiYeTbqfjlbdnCNTAkbGE= -github.com/google/s2a-go v0.1.3/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= +github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= +github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A= 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= @@ -667,8 +671,8 @@ github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99 github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= -github.com/googleapis/gax-go/v2 v2.8.0 h1:UBtEZqx1bjXtOQ5BVTkuYghXrr3N4V123VKJK67vJZc= -github.com/googleapis/gax-go/v2 v2.8.0/go.mod h1:4orTrqY6hXxxaUL4LHIPl6lGo8vAE38/qKbhSAKP6QI= +github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= +github.com/googleapis/gax-go/v2 v2.11.0/go.mod h1:DxmR61SGKkGLa2xigwuZIQpkCI2S5iydzRfb3peWZJI= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= @@ -824,6 +828,7 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= 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= @@ -869,8 +874,8 @@ github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2y github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= -github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= +github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= 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= @@ -958,8 +963,8 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ 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/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= -github.com/oxyno-zeta/gomock-extra-matcher v1.1.0 h1:Yyk5ov0ZPKBXtVEeIWtc4J2XVrHuNoIK+0F2BUJgtsc= -github.com/oxyno-zeta/gomock-extra-matcher v1.1.0/go.mod h1:UMGTHYEmJ1dRq8LDZ7VTAYO4nqM3GD1UGC3RJEUxEz0= +github.com/oxyno-zeta/gomock-extra-matcher v1.2.0 h1:WPEclU0y0PMwUzdDcaKZvld4aXpa3fkzjiUMQdcBEHg= +github.com/oxyno-zeta/gomock-extra-matcher v1.2.0/go.mod h1:S0r7HmKeCGsHmvIVFMjKWwswb4+30nCNWbXRMBVPkaU= 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= @@ -978,6 +983,8 @@ github.com/petermattis/goid v0.0.0-20230317030725-371a4b8eda08/go.mod h1:pxMtw7c github.com/philhofer/fwd v1.0.0/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/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= +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= @@ -1028,19 +1035,20 @@ github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Ung github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 h1:N/ElC8H3+5XpJzTSTfLsJV/mx9Q9g7kxmchpfZyxgzM= github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= -github.com/regen-network/gocuke v0.6.2 h1:pHviZ0kKAq2U2hN2q3smKNxct6hS0mGByFMHGnWA97M= github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc= 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/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo= github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= -github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc= -github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c= +github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w= 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= @@ -1119,8 +1127,8 @@ github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg= -github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM= +github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= @@ -1159,6 +1167,7 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de 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.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo= github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= @@ -1183,6 +1192,8 @@ go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqe go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/mock v0.2.0 h1:TaP3xedm7JaAgScZO7tlvlKrqT0p7I6OsdGB5YNSMDU= +go.uber.org/mock v0.2.0/go.mod h1:J0y0rp9L3xiff1+ZBfKxlC1fz2+aO16tw0tsDOixfuM= 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/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= @@ -1213,8 +1224,8 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220314234659-1baeb1ce4c0b/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= 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= @@ -1229,8 +1240,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc h1:mCRnTeVUjcrhlRmO0VK8a6k6Rrf6TF9htwo2pJVSjIU= -golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= +golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb h1:xIApU0ow1zwMa2uL1VDNeQlNVFTWMQxZUZCMDy0Q4Us= +golang.org/x/exp v0.0.0-20230711153332-06a737ee72cb/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1257,8 +1268,9 @@ 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.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= +golang.org/x/mod v0.11.0 h1:bUO06HqtnRcc/7l71XBe4WcqTZ+3AH1J59zWDDwLKgU= 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= @@ -1325,8 +1337,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= 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= @@ -1352,8 +1364,8 @@ golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.1.0/go.mod h1:G9FE4dLTsbXUu90h/Pf85g4w1D+SSAgR+q46nJZ8M4A= -golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g= -golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4= +golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= +golang.org/x/oauth2 v0.10.0/go.mod h1:kTpgurOux7LqtuxjuyZa4Gj2gdezIt/jQtGnNFfypQI= 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= @@ -1368,8 +1380,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= 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= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1478,14 +1490,14 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/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/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= 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= @@ -1497,8 +1509,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1569,6 +1581,7 @@ 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.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1635,8 +1648,8 @@ google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.98.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= google.golang.org/api v0.100.0/go.mod h1:ZE3Z2+ZOr87Rx7dqFsdRQkRBk36kDtp/h+QpHbB7a70= -google.golang.org/api v0.122.0 h1:zDobeejm3E7pEG1mNHvdxvjs5XJoCMzyNH+CmwL94Es= -google.golang.org/api v0.122.0/go.mod h1:gcitW0lvnyWjSp9nKxAbdHKIZ6vF4aajGueeslZOyms= +google.golang.org/api v0.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o= +google.golang.org/api v0.126.0/go.mod h1:mBwVAtz+87bEN6CbA1GtZPDOqY2R5ONPqJeIlvyo4Aw= 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= @@ -1756,12 +1769,12 @@ google.golang.org/genproto v0.0.0-20221010155953-15ba04fc1c0e/go.mod h1:3526vdqw google.golang.org/genproto v0.0.0-20221014173430-6e2ab493f96b/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= google.golang.org/genproto v0.0.0-20221025140454-527a21cfbd71/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= -google.golang.org/genproto v0.0.0-20230629202037-9506855d4529 h1:9JucMWR7sPvCxUFd6UsOUNmA5kCcWOfORaT3tpAsKQs= -google.golang.org/genproto v0.0.0-20230629202037-9506855d4529/go.mod h1:xZnkP7mREFX5MORlOPEzLMr+90PPZQ2QWzrVTWfAq64= -google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e h1:AZX1ra8YbFMSb7+1pI8S9v4rrgRR7jU1FmuFSSjTVcQ= -google.golang.org/genproto/googleapis/api v0.0.0-20230526203410-71b5a4ffd15e/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 h1:2FZP5XuJY9zQyGM5N0rtovnoXjiMUEIUMvw0m9wlpLc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:8mL13HKkDa+IuJ8yruA3ci0q+0vsUz4m//+ottjwS5o= +google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98 h1:Z0hjGZePRE0ZBWotvtrwxFNrNE9CUAGtplaDK5NNI/g= +google.golang.org/genproto v0.0.0-20230711160842-782d3b101e98/go.mod h1:S7mY02OqCJTD0E1OiQy1F72PWFB4bZJ87cAtLPYgDR0= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 h1:FmF5cCW94Ij59cfpoLiwTgodWmm60eEV0CjlsVg2fuw= +google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98/go.mod h1:rsr7RhLuwsDKL7RmgDDCUc6yaGr1iqceVb5Wv6f6YvQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -1803,8 +1816,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.57.0 h1:kfzNeI/klCGD2YPMUlaGNT3pxvYfga7smW3Vth8Zsiw= -google.golang.org/grpc v1.57.0/go.mod h1:Sd+9RMTACXwmub0zcNY2c4arhtrbBYD1AUHI/dt16Mo= +google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= +google.golang.org/grpc v1.58.3/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= 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= @@ -1860,7 +1873,7 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -gotest.tools/v3 v3.4.0 h1:ZazjZUfuVeZGLAmlKKuyv3IKP5orXcwtOwDQH6YVr6o= +gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY= 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= @@ -1872,8 +1885,8 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= 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.5.5 h1:jkgx1TjbQPD/feRoK+S/mXw9e1uj6WilpHrXJowi6oA= -pgregory.net/rapid v0.5.5/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= +pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw= +pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= 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= diff --git a/legacy_ibc_testing/README.md b/legacy_ibc_testing/README.md deleted file mode 100644 index 1337ec1412..0000000000 --- a/legacy_ibc_testing/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Legacy IBC Testing - -### `legacy_ibc_testing` is imported from [Informal Systems fork of ibc-go](https://github.com/informalsystems/ibc-go). It contains modifications to canonical ibc-go `v3.4.0` for testing purposes only. - -Crucially, Informal's fork contained changes to the [StakingKeeper interface](https://github.com/informalsystems/ibc-go/blob/interchain-security-v3.4.0/modules/core/02-client/types/expected_keepers.go#L12) that both consumer and providers would be expected to return from the testing method `GetStakingKeeper`. For consumer apps, this method would return and IBCKeeper type. This change could not be back-ported to `v3.4.0` of ibc-go as it would be api breaking. Instead, the relevant changes made to ibc-go were consolidated and copied directly into `interchain-security`. Once ICS upgrades ibc-go to a version that supports this change, `v5` at the earliest, this test helper directory can be removed. - -**Directory** -- Core - - Contains changes made in ibc-go `core/`, but do not contain any logic requiring they live in that directory. Includes an interface definition and a testing helper method. -- Simapp - - Includes test helper substitutions for ibc-go's `simapp/` used in the Diff tests. -- Testing - - Replaces ibc-go's `testing/` directory to facilitate ibc's `TestApp`'s implementation of `GetStakingKeeper` returning the relevant `StakingKeeper` interface enhanced in Informal's ibc-go fork. \ No newline at end of file diff --git a/legacy_ibc_testing/core/events.go b/legacy_ibc_testing/core/events.go deleted file mode 100644 index a01c14c685..0000000000 --- a/legacy_ibc_testing/core/events.go +++ /dev/null @@ -1,48 +0,0 @@ -package core - -import ( - "strconv" - - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - - abci "github.com/cometbft/cometbft/abci/types" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -// ReconstructPacketFromEvent recreates a packet from an appropriate provided event -func ReconstructPacketFromEvent(event abci.Event) (packet types.Packet, err error) { - attrMap := make(map[string][]byte) - for _, attr := range event.Attributes { - attrMap[attr.Key] = []byte(attr.Value) - } - - sequence, err := strconv.Atoi(string(attrMap[string(types.AttributeKeySequence)])) - if err != nil { - return packet, err - } - timeoutTimestamp, err := strconv.Atoi(string(attrMap[string(types.AttributeKeyTimeoutTimestamp)])) - if err != nil { - return packet, err - } - timeoutHeight, err := clienttypes.ParseHeight(string(attrMap[string(types.AttributeKeyTimeoutHeight)])) - if err != nil { - return packet, err - } - return types.NewPacket( - attrMap[string(types.AttributeKeyData)], //nolint:staticcheck // data - uint64(sequence), - string(attrMap[string(types.AttributeKeySrcPort)]), // sourcePort, - string(attrMap[string(types.AttributeKeySrcChannel)]), // sourceChannel, - string(attrMap[string(types.AttributeKeyDstPort)]), // destinationPort, - string(attrMap[string(types.AttributeKeyDstChannel)]), // destinationChannel string, - timeoutHeight, - uint64(timeoutTimestamp), - ), nil -} diff --git a/legacy_ibc_testing/core/expected_keepers.go b/legacy_ibc_testing/core/expected_keepers.go deleted file mode 100644 index 90a9d40f3c..0000000000 --- a/legacy_ibc_testing/core/expected_keepers.go +++ /dev/null @@ -1,20 +0,0 @@ -package core - -import ( - "time" - - sdk "github.com/cosmos/cosmos-sdk/types" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -type StakingKeeper interface { - GetHistoricalInfo(ctx sdk.Context, height int64) (stakingtypes.HistoricalInfo, bool) - UnbondingTime(ctx sdk.Context) time.Duration -} diff --git a/legacy_ibc_testing/simapp/helpers/test_helpers.go b/legacy_ibc_testing/simapp/helpers/test_helpers.go deleted file mode 100644 index b3e5c80d5e..0000000000 --- a/legacy_ibc_testing/simapp/helpers/test_helpers.go +++ /dev/null @@ -1,85 +0,0 @@ -package helpers - -import ( - "math/rand" - - "github.com/cosmos/cosmos-sdk/client" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - authsign "github.com/cosmos/cosmos-sdk/x/auth/signing" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -// SimAppChainID hardcoded chainID for simulation -const ( - DefaultGenTxGas = 1000000 -) - -// 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) { - sigs := make([]signing.SignatureV2, len(priv)) - - // create a random length memo - r := rand.New(rand.NewSource(rand.Int63())) - - memo := simulation.RandStringOfLength(r, simulation.RandIntBetween(r, 0, 100)) - - signMode := gen.SignModeHandler().DefaultMode() - - // 1st round: set SignatureV2 with empty signatures, to set correct - // signer infos. - for i, p := range priv { - sigs[i] = signing.SignatureV2{ - PubKey: p.PubKey(), - Data: &signing.SingleSignatureData{ - SignMode: signMode, - }, - Sequence: accSeqs[i], - } - } - - tx := gen.NewTxBuilder() - err := tx.SetMsgs(msgs...) - if err != nil { - return nil, err - } - err = tx.SetSignatures(sigs...) - if err != nil { - return nil, err - } - tx.SetMemo(memo) - tx.SetFeeAmount(feeAmt) - tx.SetGasLimit(gas) - - // 2nd round: once all signer infos are set, every signer can sign. - for i, p := range priv { - signerData := authsign.SignerData{ - ChainID: chainID, - AccountNumber: accNums[i], - Sequence: accSeqs[i], - } - signBytes, err := gen.SignModeHandler().GetSignBytes(signMode, signerData, tx.GetTx()) - if err != nil { - panic(err) - } - sig, err := p.Sign(signBytes) - if err != nil { - panic(err) - } - sigs[i].Data.(*signing.SingleSignatureData).Signature = sig - err = tx.SetSignatures(sigs...) - if err != nil { - panic(err) - } - } - - return tx.GetTx(), nil -} diff --git a/legacy_ibc_testing/simapp/test_helpers.go b/legacy_ibc_testing/simapp/test_helpers.go deleted file mode 100644 index efdc359499..0000000000 --- a/legacy_ibc_testing/simapp/test_helpers.go +++ /dev/null @@ -1,158 +0,0 @@ -package simapp - -import ( - "bytes" - "encoding/hex" - "fmt" - "strconv" - "testing" - "time" - - "github.com/stretchr/testify/require" - - errorsmod "cosmossdk.io/errors" - - bam "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/errors" - - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" - - "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp/helpers" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -// DefaultConsensusParams defines the default Tendermint consensus params used in -// SimApp testing. -var DefaultConsensusParams = &tmproto.ConsensusParams{ - Block: &tmproto.BlockParams{ - MaxBytes: 200000, - MaxGas: 2000000, - }, - Evidence: &tmproto.EvidenceParams{ - MaxAgeNumBlocks: 302400, - MaxAgeDuration: 504 * time.Hour, // 3 weeks is the max duration - MaxBytes: 10000, - }, - Validator: &tmproto.ValidatorParams{ - PubKeyTypes: []string{ - tmtypes.ABCIPubKeyTypeEd25519, - }, - }, -} - -type GenerateAccountStrategy func(int) []sdk.AccAddress - -// ConvertAddrsToValAddrs converts the provided addresses to ValAddress. -func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { - valAddrs := make([]sdk.ValAddress, len(addrs)) - - for i, addr := range addrs { - valAddrs[i] = sdk.ValAddress(addr) - } - - return valAddrs -} - -func TestAddr(addr, bech string) (sdk.AccAddress, error) { - res, err := sdk.AccAddressFromHexUnsafe(addr) - if err != nil { - return nil, err - } - bechexpected := res.String() - if bech != bechexpected { - return nil, fmt.Errorf("bech encoding doesn't match reference") - } - - bechres, err := sdk.AccAddressFromBech32(bech) - if err != nil { - return nil, err - } - if !bytes.Equal(bechres, res) { - return nil, err - } - - return res, nil -} - -// SignAndDeliver signs and delivers a transaction. No simulation occurs as the -// ibc testing package causes checkState and deliverState to diverge in block time. -// -// CONTRACT: BeginBlock must be called before this function. -func SignAndDeliver( - 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) { - t.Helper() - tx, err := helpers.GenTx( - txCfg, - msgs, - sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, - helpers.DefaultGenTxGas, - chainID, - accNums, - accSeqs, - priv..., - ) - require.NoError(t, err) - - // Simulate a sending a transaction - gInfo, res, err := app.SimDeliver(txCfg.TxEncoder(), tx) - - if expPass { - require.NoError(t, err) - require.NotNil(t, res) - } else { - require.Error(t, err) - require.Nil(t, res) - } - - return gInfo, res, err -} - -// CreateTestPubKeys returns a total of numPubKeys public keys in ascending order. -func CreateTestPubKeys(numPubKeys int) []cryptotypes.PubKey { - var publicKeys []cryptotypes.PubKey - var buffer bytes.Buffer - - // start at 10 to avoid changing 1 to 01, 2 to 02, etc - for i := 100; i < (numPubKeys + 100); i++ { - numString := strconv.Itoa(i) - buffer.WriteString("0B485CFC0EECC619440448436F8FC9DF40566F2369E72400281454CB552AF") // base pubkey string - buffer.WriteString(numString) // adding on final two digits to make pubkeys unique - publicKeys = append(publicKeys, NewPubKeyFromHex(buffer.String())) - buffer.Reset() - } - - return publicKeys -} - -// NewPubKeyFromHex returns a PubKey from a hex string. -func NewPubKeyFromHex(pk string) (res cryptotypes.PubKey) { - pkBytes, err := hex.DecodeString(pk) - if err != nil { - panic(err) - } - if len(pkBytes) != ed25519.PubKeySize { - panic(errorsmod.Wrap(errors.ErrInvalidPubKey, "invalid pubkey size")) - } - return &ed25519.PubKey{Key: pkBytes} -} - -// EmptyAppOptions is a stub implementing AppOptions -type EmptyAppOptions struct{} - -// Get implements AppOptions -func (ao EmptyAppOptions) Get(o string) interface{} { - return nil -} diff --git a/legacy_ibc_testing/testing/app.go b/legacy_ibc_testing/testing/app.go deleted file mode 100644 index da861481a7..0000000000 --- a/legacy_ibc_testing/testing/app.go +++ /dev/null @@ -1,174 +0,0 @@ -package testing - -import ( - "encoding/json" - "testing" - "time" - - "github.com/cosmos/ibc-go/v7/modules/core/keeper" - "github.com/stretchr/testify/require" - - "cosmossdk.io/math" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - storetypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - abci "github.com/cometbft/cometbft/abci/types" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmtypes "github.com/cometbft/cometbft/types" - - "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" - "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -type AppIniter func() (TestingApp, map[string]json.RawMessage) - -var DefaultTestingAppInit AppIniter - -type TestingApp interface { - abci.Application - - // ibc-go additions - GetBaseApp() *baseapp.BaseApp - GetStakingKeeper() core.StakingKeeper - GetIBCKeeper() *keeper.Keeper - GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper - GetTxConfig() client.TxConfig - - // Implemented by SimApp - AppCodec() codec.Codec - - // Implemented by BaseApp - LastCommitID() storetypes.CommitID - LastBlockHeight() int64 -} - -// SetupWithGenesisValSet initializes a new SimApp with a validator set and genesis accounts -// that also act as delegators. For simplicity, each validator is bonded with a delegation -// of one consensus engine unit (10^6) in the default token of the simapp from first genesis -// account. A Nop logger is set in SimApp. -func SetupWithGenesisValSet(t *testing.T, appIniter AppIniter, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, chainID string, powerReduction math.Int, balances ...banktypes.Balance) TestingApp { - t.Helper() - app, genesisState := appIniter() - baseapp.SetChainID(chainID)(app.GetBaseApp()) - - // set genesis accounts - authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) - genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) - - validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) - delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) - - bondAmt := sdk.TokensFromConsensusPower(1, powerReduction) - - initValPowers := []abci.ValidatorUpdate{} - for _, val := range valSet.Validators { - pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) - require.NoError(t, err) - pkAny, err := codectypes.NewAnyWithValue(pk) - require.NoError(t, err) - validator := stakingtypes.Validator{ - OperatorAddress: sdk.ValAddress(val.Address).String(), - ConsensusPubkey: pkAny, - Jailed: false, - Status: stakingtypes.Bonded, - Tokens: bondAmt, - DelegatorShares: sdk.OneDec(), - Description: stakingtypes.Description{}, - UnbondingHeight: int64(0), - UnbondingTime: time.Unix(0, 0).UTC(), - Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.ZeroInt(), - } - - validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) - - pub, _ := val.ToProto() - initValPowers = append(initValPowers, abci.ValidatorUpdate{ - Power: val.VotingPower, - PubKey: pub.PubKey, - }) - } - - // set validators and delegations - var ( - stakingGenesis stakingtypes.GenesisState - consumerGenesis consumertypes.GenesisState - bondDenom string - ) - if genesisState[stakingtypes.ModuleName] != nil { - app.AppCodec().MustUnmarshalJSON(genesisState[stakingtypes.ModuleName], &stakingGenesis) - bondDenom = stakingGenesis.Params.BondDenom - } else { - bondDenom = sdk.DefaultBondDenom - } - - // add bonded amount to bonded pool module account - balances = append(balances, banktypes.Balance{ - Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(), - Coins: sdk.Coins{sdk.NewCoin(bondDenom, bondAmt.Mul(sdk.NewInt(int64(len(valSet.Validators)))))}, - }) - - // set validators and delegations - stakingGenesis = *stakingtypes.NewGenesisState(stakingGenesis.Params, validators, delegations) - genesisState[stakingtypes.ModuleName] = app.AppCodec().MustMarshalJSON(&stakingGenesis) - - // update total supply - bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, sdk.NewCoins(), []banktypes.Metadata{}, []banktypes.SendEnabled{}) - genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) - - if genesisState[consumertypes.ModuleName] != nil { - app.AppCodec().MustUnmarshalJSON(genesisState[consumertypes.ModuleName], &consumerGenesis) - consumerGenesis.InitialValSet = initValPowers - consumerGenesis.Params.Enabled = true - genesisState[consumertypes.ModuleName] = app.AppCodec().MustMarshalJSON(&consumerGenesis) - } - - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - require.NoError(t, err) - - // init chain will set the validator set and initialize the genesis accounts - app.InitChain( - abci.RequestInitChain{ - ChainId: chainID, - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: simapp.DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - - // commit genesis changes - app.Commit() - - app.BeginBlock( - abci.RequestBeginBlock{ - Header: tmproto.Header{ - ChainID: chainID, - Height: app.LastBlockHeight() + 1, - AppHash: app.LastCommitID().Hash, - ValidatorsHash: valSet.Hash(), - NextValidatorsHash: valSet.Hash(), - }, - }, - ) - - return app -} diff --git a/legacy_ibc_testing/testing/chain.go b/legacy_ibc_testing/testing/chain.go deleted file mode 100644 index 14177679b7..0000000000 --- a/legacy_ibc_testing/testing/chain.go +++ /dev/null @@ -1,655 +0,0 @@ -package testing - -import ( - "bytes" - "fmt" - "testing" - "time" - - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - "github.com/cosmos/ibc-go/v7/modules/core/exported" - "github.com/cosmos/ibc-go/v7/modules/core/types" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - "github.com/cosmos/ibc-go/v7/testing/mock" - "github.com/stretchr/testify/require" - - errorsmod "cosmossdk.io/errors" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" - sdk "github.com/cosmos/cosmos-sdk/types" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - teststaking "github.com/cosmos/cosmos-sdk/x/staking/testutil" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/crypto/tmhash" - tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - tmprotoversion "github.com/cometbft/cometbft/proto/tendermint/version" - tmtypes "github.com/cometbft/cometbft/types" - tmversion "github.com/cometbft/cometbft/version" - - ibctestingcore "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" - "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -var MaxAccounts = 10 - -type SenderAccount struct { - SenderPrivKey cryptotypes.PrivKey - SenderAccount authtypes.AccountI -} - -// TestChain is a testing struct that wraps a simapp with the last TM Header, the current ABCI -// header and the validators of the TestChain. It also contains a field called ChainID. This -// is the clientID that *other* chains use to refer to this TestChain. The SenderAccount -// is used for delivering transactions through the application state. -// NOTE: the actual application uses an empty chain-id for ease of testing. -type TestChain struct { - *testing.T - - Coordinator *Coordinator - App TestingApp - ChainID string - LastHeader *ibctmtypes.Header // header for last block height committed - CurrentHeader tmproto.Header // header for current block height - QueryServer types.QueryServer - TxConfig client.TxConfig - Codec codec.BinaryCodec - - Vals *tmtypes.ValidatorSet - NextVals *tmtypes.ValidatorSet - - // Signers is a map from validator address to the PrivValidator - // The map is converted into an array that is the same order as the validators right before signing commit - // This ensures that signers will always be in correct order even as validator powers change. - // If a test adds a new validator after chain creation, then the signer map must be updated to include - // the new PrivValidator entry. - Signers map[string]tmtypes.PrivValidator - - // SentPackets is a map from packet sequences to sent packets, - // reconstructed from emitted events of type SendPacketEvent - SentPackets map[string]channeltypes.Packet - - // autogenerated sender private key - SenderPrivKey cryptotypes.PrivKey - SenderAccount authtypes.AccountI - - SenderAccounts []SenderAccount -} - -// NewTestChainWithValSet initializes a new TestChain instance with the given validator set -// and signer array. It also initializes 10 Sender accounts with a balance of 10000000000000000000 coins of -// bond denom to use for tests. -// -// The first block height is committed to state in order to allow for client creations on -// counterparty chains. The TestChain will return with a block height starting at 2. -// -// Time management is handled by the Coordinator in order to ensure synchrony between chains. -// Each update of any chain increments the block header time for all chains by 5 seconds. -// -// NOTE: to use a custom sender privkey and account for testing purposes, replace and modify this -// constructor function. -// -// CONTRACT: Validator array must be provided in the order expected by Tendermint. -// i.e. sorted first by power and then lexicographically by address. -func NewTestChainWithValSet(t *testing.T, coord *Coordinator, appIniter AppIniter, chainID string, valSet *tmtypes.ValidatorSet, signers map[string]tmtypes.PrivValidator) *TestChain { - t.Helper() - genAccs := []authtypes.GenesisAccount{} - genBals := []banktypes.Balance{} - senderAccs := []SenderAccount{} - - // generate genesis accounts - for i := 0; i < MaxAccounts; i++ { - senderPrivKey := secp256k1.GenPrivKey() - acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), uint64(i), 0) - amount, ok := sdk.NewIntFromString("10000000000000000000") - require.True(t, ok) - - balance := banktypes.Balance{ - Address: acc.GetAddress().String(), - Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, amount)), - } - - genAccs = append(genAccs, acc) - genBals = append(genBals, balance) - - senderAcc := SenderAccount{ - SenderAccount: acc, - SenderPrivKey: senderPrivKey, - } - - senderAccs = append(senderAccs, senderAcc) - } - - app := SetupWithGenesisValSet(t, appIniter, valSet, genAccs, chainID, sdk.DefaultPowerReduction, genBals...) - - // create current header and call begin block - header := tmproto.Header{ - ChainID: chainID, - Height: 1, - Time: coord.CurrentTime.UTC(), - } - - txConfig := app.GetTxConfig() - - // create an account to send transactions from - chain := &TestChain{ - T: t, - Coordinator: coord, - ChainID: chainID, - App: app, - CurrentHeader: header, - QueryServer: app.GetIBCKeeper(), - TxConfig: txConfig, - Codec: app.AppCodec(), - Vals: valSet, - NextVals: valSet, - Signers: signers, - SentPackets: make(map[string]channeltypes.Packet), - SenderPrivKey: senderAccs[0].SenderPrivKey, - SenderAccount: senderAccs[0].SenderAccount, - SenderAccounts: senderAccs, - } - - coord.CommitBlock(chain) - - return chain -} - -// NewTestChain initializes a new test chain with a default of 4 validators -// Use this function if the tests do not need custom control over the validator set -func NewTestChain(t *testing.T, coord *Coordinator, appIniter AppIniter, chainID string) *TestChain { - t.Helper() - // generate validators private/public key - var ( - validatorsPerChain = 4 - validators []*tmtypes.Validator - signersByAddress = make(map[string]tmtypes.PrivValidator, validatorsPerChain) - ) - - for i := 0; i < validatorsPerChain; i++ { - privVal := mock.NewPV() - pubKey, err := privVal.GetPubKey() - require.NoError(t, err) - validators = append(validators, tmtypes.NewValidator(pubKey, 1)) - signersByAddress[pubKey.Address().String()] = privVal - } - - // construct validator set; - // Note that the validators are sorted by voting power - // or, if equal, by address lexical order - valSet := tmtypes.NewValidatorSet(validators) - - return NewTestChainWithValSet(t, coord, appIniter, chainID, valSet, signersByAddress) -} - -// GetContext returns the current context for the application. -func (chain *TestChain) GetContext() sdk.Context { - return chain.App.GetBaseApp().NewContext(false, chain.CurrentHeader) -} - -// QueryProof performs an abci query with the given key and returns the proto encoded merkle proof -// for the query and the height at which the proof will succeed on a tendermint verifier. -func (chain *TestChain) QueryProof(key []byte) ([]byte, clienttypes.Height) { - return chain.QueryProofAtHeight(key, chain.App.LastBlockHeight()) -} - -// QueryProof performs an abci query with the given key and returns the proto encoded merkle proof -// for the query and the height at which the proof will succeed on a tendermint verifier. -func (chain *TestChain) QueryProofAtHeight(key []byte, height int64) ([]byte, clienttypes.Height) { - res := chain.App.Query(abci.RequestQuery{ - Path: fmt.Sprintf("store/%s/key", exported.StoreKey), - Height: height - 1, - Data: key, - Prove: true, - }) - - merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) - require.NoError(chain.T, err) - - proof, err := chain.App.AppCodec().Marshal(&merkleProof) - require.NoError(chain.T, err) - - revision := clienttypes.ParseChainID(chain.ChainID) - - // proof height + 1 is returned as the proof created corresponds to the height the proof - // was created in the IAVL tree. Tendermint and subsequently the clients that rely on it - // have heights 1 above the IAVL tree. Thus we return proof height + 1 - return proof, clienttypes.NewHeight(revision, uint64(res.Height)+1) -} - -// QueryUpgradeProof performs an abci query with the given key and returns the proto encoded merkle proof -// for the query and the height at which the proof will succeed on a tendermint verifier. -func (chain *TestChain) QueryUpgradeProof(key []byte, height uint64) ([]byte, clienttypes.Height) { - res := chain.App.Query(abci.RequestQuery{ - Path: "store/upgrade/key", - Height: int64(height - 1), - Data: key, - Prove: true, - }) - - merkleProof, err := commitmenttypes.ConvertProofs(res.ProofOps) - require.NoError(chain.T, err) - - proof, err := chain.App.AppCodec().Marshal(&merkleProof) - require.NoError(chain.T, err) - - revision := clienttypes.ParseChainID(chain.ChainID) - - // proof height + 1 is returned as the proof created corresponds to the height the proof - // was created in the IAVL tree. Tendermint and subsequently the clients that rely on it - // have heights 1 above the IAVL tree. Thus we return proof height + 1 - return proof, clienttypes.NewHeight(revision, uint64(res.Height+1)) -} - -// QueryConsensusStateProof performs an abci query for a consensus state -// stored on the given clientID. The proof and consensusHeight are returned. -func (chain *TestChain) QueryConsensusStateProof(clientID string) ([]byte, clienttypes.Height) { - clientState := chain.GetClientState(clientID) - - consensusHeight := clientState.GetLatestHeight().(clienttypes.Height) - consensusKey := host.FullConsensusStateKey(clientID, consensusHeight) - proofConsensus, _ := chain.QueryProof(consensusKey) - - return proofConsensus, consensusHeight -} - -// GetSentPacketKey returns a key for accessing a sent packet, -// given an ibc sequence number and the channel ID for the source endpoint. -func GetSentPacketKey(sequence uint64, channelID string) string { - return fmt.Sprintf("%s-%d", channelID, sequence) -} - -// GetSentPacket returns the sent packet with `sequence` (if any), -// reconstructed from emitted events of type SendPacketEvent -func (chain *TestChain) GetSentPacket(sequence uint64, channelID string) (packet channeltypes.Packet, found bool) { - sentPacketKey := GetSentPacketKey(sequence, channelID) - packet, found = chain.SentPackets[sentPacketKey] - return -} - -// setSentPacketsFromEvents stores the sent packet reconstructed -// from emitted events of type SendPacketEvent -func (chain *TestChain) setSentPacketsFromEvents(events []abci.Event) { - for _, event := range events { - if event.Type == channeltypes.EventTypeSendPacket { - packet, err := ibctestingcore.ReconstructPacketFromEvent(event) - require.NoError(chain.T, err) - sentPacketKey := GetSentPacketKey(packet.GetSequence(), packet.GetSourceChannel()) - chain.SentPackets[sentPacketKey] = packet - } - } -} - -// NextBlock sets the last header to the current header and increments the current header to be -// at the next block height. It does not update the time as that is handled by the Coordinator. -// It will call Endblock and Commit and apply the validator set changes to the next validators -// of the next block being created. This follows the Tendermint protocol of applying valset changes -// returned on block `n` to the validators of block `n+2`. -// It calls BeginBlock with the new block created before returning. -func (chain *TestChain) NextBlock() (abci.ResponseEndBlock, abci.ResponseCommit, abci.ResponseBeginBlock) { - ebRes := chain.App.EndBlock(abci.RequestEndBlock{Height: chain.CurrentHeader.Height}) - // store packets sent during EndBlock - chain.setSentPacketsFromEvents(ebRes.Events) - - cRes := chain.App.Commit() - - // val set changes returned from previous block get applied to the next validators - // of this block. See tendermint spec for details. - chain.Vals = chain.NextVals - chain.NextVals = ApplyValSetChanges(chain.T, chain.Vals, ebRes.ValidatorUpdates) - - // set the last header to the current header - // use nil trusted fields - chain.LastHeader = chain.CurrentTMClientHeader() - - // increment the current header - chain.CurrentHeader = tmproto.Header{ - ChainID: chain.ChainID, - Height: chain.App.LastBlockHeight() + 1, - AppHash: chain.App.LastCommitID().Hash, - // NOTE: the time is increased by the coordinator to maintain time synchrony amongst - // chains. - Time: chain.CurrentHeader.Time, - ValidatorsHash: chain.Vals.Hash(), - NextValidatorsHash: chain.NextVals.Hash(), - } - - bbRes := chain.App.BeginBlock(abci.RequestBeginBlock{Header: chain.CurrentHeader}) - // store packets sent during BeginBlock - chain.setSentPacketsFromEvents(bbRes.Events) - - return ebRes, cRes, bbRes -} - -// sendMsgs delivers a transaction through the application without returning the result. -func (chain *TestChain) sendMsgs(msgs ...sdk.Msg) error { - _, err := chain.SendMsgs(msgs...) - return err -} - -// SendMsgs delivers a transaction through the application. It updates the senders sequence -// number and updates the TestChain's headers. It returns the result and error if one -// occurred. -func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) { - // ensure the chain has the latest time - chain.Coordinator.UpdateTimeForChain(chain) - - _, r, err := simapp.SignAndDeliver( - chain.T, - chain.TxConfig, - chain.App.GetBaseApp(), - chain.GetContext().BlockHeader(), - msgs, - chain.ChainID, - []uint64{chain.SenderAccount.GetAccountNumber()}, - []uint64{chain.SenderAccount.GetSequence()}, - true, true, chain.SenderPrivKey, - ) - if err != nil { - return nil, err - } - // store packets sent during the execution of this transaction - chain.setSentPacketsFromEvents(r.Events) - - // NextBlock calls app.Commit() - chain.NextBlock() - - // increment sequence for successful transaction execution - err = chain.SenderAccount.SetSequence(chain.SenderAccount.GetSequence() + 1) - if err != nil { - return nil, err - } - - chain.Coordinator.IncrementTime() - - return r, nil -} - -// GetClientState retrieves the client state for the provided clientID. The client is -// expected to exist otherwise testing will fail. -func (chain *TestChain) GetClientState(clientID string) exported.ClientState { - clientState, found := chain.App.GetIBCKeeper().ClientKeeper.GetClientState(chain.GetContext(), clientID) - require.True(chain.T, found) - - return clientState -} - -// GetConsensusState retrieves the consensus state for the provided clientID and height. -// It will return a success boolean depending on if consensus state exists or not. -func (chain *TestChain) GetConsensusState(clientID string, height exported.Height) (exported.ConsensusState, bool) { - return chain.App.GetIBCKeeper().ClientKeeper.GetClientConsensusState(chain.GetContext(), clientID, height) -} - -// GetValsAtHeight will return the validator set of the chain at a given height. It will return -// a success boolean depending on if the validator set exists or not at that height. -func (chain *TestChain) GetValsAtHeight(height int64) (*tmtypes.ValidatorSet, bool) { - histInfo, ok := chain.App.GetStakingKeeper().GetHistoricalInfo(chain.GetContext(), height) - if !ok { - return nil, false - } - - valSet := stakingtypes.Validators(histInfo.Valset) - - tmValidators, err := teststaking.ToTmValidators(valSet, sdk.DefaultPowerReduction) - if err != nil { - panic(err) - } - return tmtypes.NewValidatorSet(tmValidators), true -} - -// GetAcknowledgement retrieves an acknowledgement for the provided packet. If the -// acknowledgement does not exist then testing will fail. -func (chain *TestChain) GetAcknowledgement(packet exported.PacketI) []byte { - ack, found := chain.App.GetIBCKeeper().ChannelKeeper.GetPacketAcknowledgement(chain.GetContext(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - require.True(chain.T, found) - - return ack -} - -// GetPrefix returns the prefix for used by a chain in connection creation -func (chain *TestChain) GetPrefix() commitmenttypes.MerklePrefix { - return commitmenttypes.NewMerklePrefix(chain.App.GetIBCKeeper().ConnectionKeeper.GetCommitmentPrefix().Bytes()) -} - -// ConstructUpdateTMClientHeader will construct a valid 07-tendermint Header to update the -// light client on the source chain. -func (chain *TestChain) ConstructUpdateTMClientHeader(counterparty *TestChain, clientID string) (*ibctmtypes.Header, error) { - return chain.ConstructUpdateTMClientHeaderWithTrustedHeight(counterparty, clientID, clienttypes.ZeroHeight()) -} - -// ConstructUpdateTMClientHeader will construct a valid 07-tendermint Header to update the -// light client on the source chain. -func (chain *TestChain) ConstructUpdateTMClientHeaderWithTrustedHeight(counterparty *TestChain, clientID string, trustedHeight clienttypes.Height) (*ibctmtypes.Header, error) { - header := counterparty.LastHeader - // Relayer must query for LatestHeight on client to get TrustedHeight if the trusted height is not set - if trustedHeight.IsZero() { - trustedHeight = chain.GetClientState(clientID).GetLatestHeight().(clienttypes.Height) - } - var ( - tmTrustedVals *tmtypes.ValidatorSet - ok bool - ) - // Once we get TrustedHeight from client, we must query the validators from the counterparty chain - // If the LatestHeight == LastHeader.Height, then TrustedValidators are current validators - // If LatestHeight < LastHeader.Height, we can query the historical validator set from HistoricalInfo - if trustedHeight == counterparty.LastHeader.GetHeight() { - tmTrustedVals = counterparty.Vals - } else { - // NOTE: We need to get validators from counterparty at height: trustedHeight+1 - // since the last trusted validators for a header at height h - // is the NextValidators at h+1 committed to in header h by - // NextValidatorsHash - tmTrustedVals, ok = counterparty.GetValsAtHeight(int64(trustedHeight.RevisionHeight + 1)) - if !ok { - return nil, errorsmod.Wrapf(ibctmtypes.ErrInvalidHeaderHeight, "could not retrieve trusted validators at trustedHeight: %d", trustedHeight) - } - } - // inject trusted fields into last header - // for now assume revision number is 0 - header.TrustedHeight = trustedHeight - - trustedVals, err := tmTrustedVals.ToProto() - if err != nil { - return nil, err - } - header.TrustedValidators = trustedVals - - return header, nil -} - -// ExpireClient fast forwards the chain's block time by the provided amount of time which will -// expire any clients with a trusting period less than or equal to this amount of time. -func (chain *TestChain) ExpireClient(amount time.Duration) { - chain.Coordinator.IncrementTimeBy(amount) -} - -// CurrentTMClientHeader creates a TM header using the current header parameters -// on the chain. The trusted fields in the header are set to nil. -func (chain *TestChain) CurrentTMClientHeader() *ibctmtypes.Header { - return chain.CreateTMClientHeader(chain.ChainID, chain.CurrentHeader.Height, clienttypes.Height{}, chain.CurrentHeader.Time, chain.Vals, chain.NextVals, nil, chain.Signers) -} - -// CreateTMClientHeader creates a TM header to update the TM client. Args are passed in to allow -// caller flexibility to use params that differ from the chain. -func (chain *TestChain) CreateTMClientHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, tmValSet, nextVals, tmTrustedVals *tmtypes.ValidatorSet, signers map[string]tmtypes.PrivValidator) *ibctmtypes.Header { - var ( - valSet *tmproto.ValidatorSet - trustedVals *tmproto.ValidatorSet - ) - - if tmValSet == nil { - panic("tmValSet cannot be nil") - } - - vsetHash := tmValSet.Hash() - nextValHash := nextVals.Hash() - - tmHeader := tmtypes.Header{ - Version: tmprotoversion.Consensus{Block: tmversion.BlockProtocol, App: 2}, - ChainID: chainID, - Height: blockHeight, - Time: timestamp, - LastBlockID: MakeBlockID(make([]byte, tmhash.Size), 10000, make([]byte, tmhash.Size)), - LastCommitHash: chain.App.LastCommitID().Hash, - DataHash: tmhash.Sum([]byte("data_hash")), - ValidatorsHash: vsetHash, - NextValidatorsHash: nextValHash, - ConsensusHash: tmhash.Sum([]byte("consensus_hash")), - AppHash: chain.CurrentHeader.AppHash, - LastResultsHash: tmhash.Sum([]byte("last_results_hash")), - EvidenceHash: tmhash.Sum([]byte("evidence_hash")), - ProposerAddress: tmValSet.Proposer.Address, - } - - hhash := tmHeader.Hash() - blockID := MakeBlockID(hhash, 3, tmhash.Sum([]byte("part_set"))) - voteSet := tmtypes.NewVoteSet(chainID, blockHeight, 1, tmproto.PrecommitType, tmValSet) - - // MakeCommit expects a signer array in the same order as the validator array. - // Thus we iterate over the ordered validator set and construct a signer array - // from the signer map in the same order. - var signerArr []tmtypes.PrivValidator - - for _, v := range tmValSet.Validators { - if v == nil { - panic("validator in tmValSet cannot be nil") - } - signerArr = append(signerArr, signers[v.Address.String()]) - } - - commit, err := tmtypes.MakeCommit(blockID, blockHeight, 1, voteSet, signerArr, timestamp) - require.NoError(chain.T, err) - - signedHeader := &tmproto.SignedHeader{ - Header: tmHeader.ToProto(), - Commit: commit.ToProto(), - } - - if tmValSet != nil { - valSet, err = tmValSet.ToProto() - require.NoError(chain.T, err) - } - - if tmTrustedVals != nil { - trustedVals, err = tmTrustedVals.ToProto() - require.NoError(chain.T, err) - } - - // The trusted fields may be nil. They may be filled before relaying messages to a client. - // The relayer is responsible for querying client and injecting appropriate trusted fields. - return &ibctmtypes.Header{ - SignedHeader: signedHeader, - ValidatorSet: valSet, - TrustedHeight: trustedHeight, - TrustedValidators: trustedVals, - } -} - -// MakeBlockID copied unimported test functions from tmtypes to use them here -func MakeBlockID(hash []byte, partSetSize uint32, partSetHash []byte) tmtypes.BlockID { - return tmtypes.BlockID{ - Hash: hash, - PartSetHeader: tmtypes.PartSetHeader{ - Total: partSetSize, - Hash: partSetHash, - }, - } -} - -// CreateSortedSignerArray takes two PrivValidators, and the corresponding Validator structs -// (including voting power). It returns a signer array of PrivValidators that matches the -// sorting of ValidatorSet. -// The sorting is first by .VotingPower (descending), with secondary index of .Address (ascending). -func CreateSortedSignerArray(altPrivVal, suitePrivVal tmtypes.PrivValidator, - altVal, suiteVal *tmtypes.Validator, -) []tmtypes.PrivValidator { - switch { - case altVal.VotingPower > suiteVal.VotingPower: - return []tmtypes.PrivValidator{altPrivVal, suitePrivVal} - case altVal.VotingPower < suiteVal.VotingPower: - return []tmtypes.PrivValidator{suitePrivVal, altPrivVal} - default: - if bytes.Compare(altVal.Address, suiteVal.Address) == -1 { - return []tmtypes.PrivValidator{altPrivVal, suitePrivVal} - } - return []tmtypes.PrivValidator{suitePrivVal, altPrivVal} - } -} - -// CreatePortCapability binds and claims a capability for the given portID if it does not -// already exist. This function will fail testing on any resulting error. -// NOTE: only creation of a capability for a transfer or mock port is supported -// Other applications must bind to the port in InitGenesis or modify this code. -func (chain *TestChain) CreatePortCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID string) { - // check if the portId is already binded, if not bind it - _, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) - if !ok { - // create capability using the IBC capability keeper - cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), host.PortPath(portID)) - require.NoError(chain.T, err) - - // claim capability using the scopedKeeper - err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, host.PortPath(portID)) - require.NoError(chain.T, err) - } - - chain.NextBlock() -} - -// GetPortCapability returns the port capability for the given portID. The capability must -// exist, otherwise testing will fail. -func (chain *TestChain) GetPortCapability(portID string) *capabilitytypes.Capability { - cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.PortPath(portID)) - require.True(chain.T, ok) - - return cap -} - -// CreateChannelCapability binds and claims a capability for the given portID and channelID -// if it does not already exist. This function will fail testing on any resulting error. The -// scoped keeper passed in will claim the new capability. -func (chain *TestChain) CreateChannelCapability(scopedKeeper capabilitykeeper.ScopedKeeper, portID, channelID string) { - capName := host.ChannelCapabilityPath(portID, channelID) - // check if the portId is already binded, if not bind it - _, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), capName) - if !ok { - cap, err := chain.App.GetScopedIBCKeeper().NewCapability(chain.GetContext(), capName) - require.NoError(chain.T, err) - err = scopedKeeper.ClaimCapability(chain.GetContext(), cap, capName) - require.NoError(chain.T, err) - } - - chain.NextBlock() -} - -// GetChannelCapability returns the channel capability for the given portID and channelID. -// The capability must exist, otherwise testing will fail. -func (chain *TestChain) GetChannelCapability(portID, channelID string) *capabilitytypes.Capability { - cap, ok := chain.App.GetScopedIBCKeeper().GetCapability(chain.GetContext(), host.ChannelCapabilityPath(portID, channelID)) - require.True(chain.T, ok) - - return cap -} - -// GetTimeoutHeight is a convenience function which returns a IBC packet timeout height -// to be used for testing. It returns the current IBC height + 100 blocks -func (chain *TestChain) GetTimeoutHeight() clienttypes.Height { - return clienttypes.NewHeight(clienttypes.ParseChainID(chain.ChainID), uint64(chain.GetContext().BlockHeight())+100) -} diff --git a/legacy_ibc_testing/testing/config.go b/legacy_ibc_testing/testing/config.go deleted file mode 100644 index dffe01053f..0000000000 --- a/legacy_ibc_testing/testing/config.go +++ /dev/null @@ -1,72 +0,0 @@ -package testing - -import ( - "time" - - connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - "github.com/cosmos/ibc-go/v7/testing/mock" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -type ClientConfig interface { - GetClientType() string -} - -type TendermintConfig struct { - TrustLevel ibctmtypes.Fraction - TrustingPeriod time.Duration - UnbondingPeriod time.Duration - MaxClockDrift time.Duration - AllowUpdateAfterExpiry bool - AllowUpdateAfterMisbehaviour bool -} - -func NewTendermintConfig() *TendermintConfig { - return &TendermintConfig{ - TrustLevel: DefaultTrustLevel, - TrustingPeriod: TrustingPeriod, - UnbondingPeriod: UnbondingPeriod, - MaxClockDrift: MaxClockDrift, - AllowUpdateAfterExpiry: false, - AllowUpdateAfterMisbehaviour: false, - } -} - -func (tmcfg *TendermintConfig) GetClientType() string { - return exported.Tendermint -} - -type ConnectionConfig struct { - DelayPeriod uint64 - Version *connectiontypes.Version -} - -func NewConnectionConfig() *ConnectionConfig { - return &ConnectionConfig{ - DelayPeriod: DefaultDelayPeriod, - Version: ConnectionVersion, - } -} - -type ChannelConfig struct { - PortID string - Version string - Order channeltypes.Order -} - -func NewChannelConfig() *ChannelConfig { - return &ChannelConfig{ - PortID: mock.PortID, - Version: DefaultChannelVersion, - Order: channeltypes.UNORDERED, - } -} diff --git a/legacy_ibc_testing/testing/coordinator.go b/legacy_ibc_testing/testing/coordinator.go deleted file mode 100644 index 13f5ac1bec..0000000000 --- a/legacy_ibc_testing/testing/coordinator.go +++ /dev/null @@ -1,253 +0,0 @@ -package testing - -import ( - "fmt" - "strconv" - "testing" - "time" - - "github.com/stretchr/testify/require" - - abci "github.com/cometbft/cometbft/abci/types" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -var ( - ChainIDPrefix = "testchain" - GlobalStartTime = time.Date(2020, 1, 2, 0, 0, 0, 0, time.UTC) - TimeIncrement = time.Second * 5 -) - -// Coordinator is a testing struct which contains N TestChain's. It handles keeping all chains -// in sync with regards to time. -type Coordinator struct { - *testing.T - - CurrentTime time.Time - Chains map[string]*TestChain -} - -// NewCoordinator initializes Coordinator with N TestChain's -func NewCoordinator(t *testing.T, n int) *Coordinator { - t.Helper() - chains := make(map[string]*TestChain) - coord := &Coordinator{ - T: t, - CurrentTime: GlobalStartTime, - } - - for i := 1; i <= n; i++ { - chainID := GetChainID(i) - chains[chainID] = NewTestChain(t, coord, DefaultTestingAppInit, chainID) - } - coord.Chains = chains - - return coord -} - -// IncrementTime iterates through all the TestChain's and increments their current header time -// by 5 seconds. -// -// CONTRACT: this function must be called after every Commit on any TestChain. -func (coord *Coordinator) IncrementTime() { - coord.IncrementTimeBy(TimeIncrement) -} - -// IncrementTimeBy iterates through all the TestChain's and increments their current header time -// by specified time. -func (coord *Coordinator) IncrementTimeBy(increment time.Duration) { - coord.CurrentTime = coord.CurrentTime.Add(increment).UTC() - coord.UpdateTime() -} - -// UpdateTime updates all clocks for the TestChains to the current global time. -func (coord *Coordinator) UpdateTime() { - for _, chain := range coord.Chains { - coord.UpdateTimeForChain(chain) - } -} - -// UpdateTimeForChain updates the clock for a specific chain. -func (coord *Coordinator) UpdateTimeForChain(chain *TestChain) { - chain.CurrentHeader.Time = coord.CurrentTime.UTC() - chain.App.BeginBlock(abci.RequestBeginBlock{Header: chain.CurrentHeader}) -} - -// Setup constructs a TM client, connection, and channel on both chains provided. It will -// fail if any error occurs. The clientID's, TestConnections, and TestChannels are returned -// for both chains. The channels created are connected to the ibc-transfer application. -func (coord *Coordinator) Setup(path *Path) { - coord.SetupConnections(path) - - // channels can also be referenced through the returned connections - coord.CreateChannels(path) -} - -// SetupClients is a helper function to create clients on both chains. It assumes the -// caller does not anticipate any errors. -func (coord *Coordinator) SetupClients(path *Path) { - err := path.EndpointA.CreateClient() - require.NoError(coord.T, err) - - err = path.EndpointB.CreateClient() - require.NoError(coord.T, err) -} - -// SetupClientConnections is a helper function to create clients and the appropriate -// connections on both the source and counterparty chain. It assumes the caller does not -// anticipate any errors. -func (coord *Coordinator) SetupConnections(path *Path) { - coord.SetupClients(path) - - coord.CreateConnections(path) -} - -// CreateConnection constructs and executes connection handshake messages in order to create -// OPEN channels on chainA and chainB. The connection information of for chainA and chainB -// are returned within a TestConnection struct. The function expects the connections to be -// successfully opened otherwise testing will fail. -func (coord *Coordinator) CreateConnections(path *Path) { - err := path.EndpointA.ConnOpenInit() - require.NoError(coord.T, err) - - err = path.EndpointB.ConnOpenTry() - require.NoError(coord.T, err) - - err = path.EndpointA.ConnOpenAck() - require.NoError(coord.T, err) - - err = path.EndpointB.ConnOpenConfirm() - require.NoError(coord.T, err) - - // ensure counterparty is up to date - err = path.EndpointA.UpdateClient() - require.NoError(coord.T, err) -} - -// CreateMockChannels constructs and executes channel handshake messages to create OPEN -// channels that use a mock application module that returns nil on all callbacks. This -// function is expects the channels to be successfully opened otherwise testing will -// fail. -func (coord *Coordinator) CreateMockChannels(path *Path) { - path.EndpointA.ChannelConfig.PortID = MockPort - path.EndpointB.ChannelConfig.PortID = MockPort - - coord.CreateChannels(path) -} - -// CreateTransferChannels constructs and executes channel handshake messages to create OPEN -// ibc-transfer channels on chainA and chainB. The function expects the channels to be -// successfully opened otherwise testing will fail. -func (coord *Coordinator) CreateTransferChannels(path *Path) { - path.EndpointA.ChannelConfig.PortID = TransferPort - path.EndpointB.ChannelConfig.PortID = TransferPort - - coord.CreateChannels(path) -} - -// CreateChannel constructs and executes channel handshake messages in order to create -// OPEN channels on chainA and chainB. The function expects the channels to be successfully -// opened otherwise testing will fail. -func (coord *Coordinator) CreateChannels(path *Path) { - err := path.EndpointA.ChanOpenInit() - require.NoError(coord.T, err) - - err = path.EndpointB.ChanOpenTry() - require.NoError(coord.T, err) - - err = path.EndpointA.ChanOpenAck() - require.NoError(coord.T, err) - - err = path.EndpointB.ChanOpenConfirm() - require.NoError(coord.T, err) - - // ensure counterparty is up to date - err = path.EndpointA.UpdateClient() - require.NoError(coord.T, err) -} - -// GetChain returns the TestChain using the given chainID and returns an error if it does -// not exist. -func (coord *Coordinator) GetChain(chainID string) *TestChain { - chain, found := coord.Chains[chainID] - require.True(coord.T, found, fmt.Sprintf("%s chain does not exist", chainID)) - return chain -} - -// GetChainID returns the chainID used for the provided index. -func GetChainID(index int) string { - return ChainIDPrefix + strconv.Itoa(index) -} - -// CommitBlock commits a block on the provided indexes and then increments the global time. -// -// CONTRACT: the passed in list of indexes must not contain duplicates -func (coord *Coordinator) CommitBlock(chains ...*TestChain) { - for _, chain := range chains { - // NextBlock calls app.Commit() - chain.NextBlock() - } - coord.IncrementTime() -} - -// CommitNBlocks commits n blocks to state and updates the block height by 1 for each commit. -func (coord *Coordinator) CommitNBlocks(chain *TestChain, n uint64) { - for i := uint64(0); i < n; i++ { - chain.NextBlock() - coord.IncrementTime() - } -} - -// CommitBlockGetResponses commits a block and provides abci responses -func (coord *Coordinator) CommitBlockGetResponses(chain *TestChain) ( - abci.ResponseEndBlock, abci.ResponseCommit, abci.ResponseBeginBlock, -) { - ebRes, cRes, bbResp := chain.NextBlock() - coord.IncrementTime() - return ebRes, cRes, bbResp -} - -// ConnOpenInitOnBothChains initializes a connection on both endpoints with the state INIT -// using the OpenInit handshake call. -func (coord *Coordinator) ConnOpenInitOnBothChains(path *Path) error { - if err := path.EndpointA.ConnOpenInit(); err != nil { - return err - } - - if err := path.EndpointB.ConnOpenInit(); err != nil { - return err - } - - if err := path.EndpointA.UpdateClient(); err != nil { - return err - } - - return path.EndpointB.UpdateClient() -} - -// ChanOpenInitOnBothChains initializes a channel on the source chain and counterparty chain -// with the state INIT using the OpenInit handshake call. -func (coord *Coordinator) ChanOpenInitOnBothChains(path *Path) error { - // NOTE: only creation of a capability for a transfer or mock port is supported - // Other applications must bind to the port in InitGenesis or modify this code. - - if err := path.EndpointA.ChanOpenInit(); err != nil { - return err - } - - if err := path.EndpointB.ChanOpenInit(); err != nil { - return err - } - - if err := path.EndpointA.UpdateClient(); err != nil { - return err - } - - return path.EndpointB.UpdateClient() -} diff --git a/legacy_ibc_testing/testing/endpoint.go b/legacy_ibc_testing/testing/endpoint.go deleted file mode 100644 index ef9213d222..0000000000 --- a/legacy_ibc_testing/testing/endpoint.go +++ /dev/null @@ -1,581 +0,0 @@ -package testing - -import ( - "fmt" - - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" - host "github.com/cosmos/ibc-go/v7/modules/core/24-host" - "github.com/cosmos/ibc-go/v7/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -// Endpoint is a which represents a channel endpoint and its associated -// client and connections. It contains client, connection, and channel -// configuration parameters. Endpoint functions will utilize the parameters -// set in the configuration structs when executing IBC messages. -type Endpoint struct { - Chain *TestChain - Counterparty *Endpoint - ClientID string - ConnectionID string - ChannelID string - - ClientConfig ClientConfig - ConnectionConfig *ConnectionConfig - ChannelConfig *ChannelConfig -} - -// NewDefaultEndpoint constructs a new endpoint using default values. -// CONTRACT: the counterparty endpoitn must be set by the caller. -func NewDefaultEndpoint(chain *TestChain) *Endpoint { - return &Endpoint{ - Chain: chain, - ClientConfig: NewTendermintConfig(), - ConnectionConfig: NewConnectionConfig(), - ChannelConfig: NewChannelConfig(), - } -} - -// QueryProof queries proof associated with this endpoint using the lastest client state -// height on the counterparty chain. -func (endpoint *Endpoint) QueryProof(key []byte) ([]byte, clienttypes.Height) { - // obtain the counterparty client representing the chain associated with the endpoint - clientState := endpoint.Counterparty.Chain.GetClientState(endpoint.Counterparty.ClientID) - - // query proof on the counterparty using the latest height of the IBC client - return endpoint.QueryProofAtHeight(key, clientState.GetLatestHeight().GetRevisionHeight()) -} - -// QueryProofAtHeight queries proof associated with this endpoint using the proof height -// provided -func (endpoint *Endpoint) QueryProofAtHeight(key []byte, height uint64) ([]byte, clienttypes.Height) { - // query proof on the counterparty using the latest height of the IBC client - return endpoint.Chain.QueryProofAtHeight(key, int64(height)) -} - -// CreateClient creates an IBC client on the endpoint. It will update the -// clientID for the endpoint if the message is successfully executed. -// NOTE: a solo machine client will be created with an empty diversifier. -func (endpoint *Endpoint) CreateClient() (err error) { - // ensure counterparty has committed state - endpoint.Chain.Coordinator.CommitBlock(endpoint.Counterparty.Chain) - - var ( - clientState exported.ClientState - consensusState exported.ConsensusState - ) - - switch endpoint.ClientConfig.GetClientType() { - case exported.Tendermint: - tmConfig, ok := endpoint.ClientConfig.(*TendermintConfig) - require.True(endpoint.Chain.T, ok) - - height := endpoint.Counterparty.Chain.LastHeader.GetHeight().(clienttypes.Height) - clientState = ibctmtypes.NewClientState( - endpoint.Counterparty.Chain.ChainID, tmConfig.TrustLevel, tmConfig.TrustingPeriod, tmConfig.UnbondingPeriod, tmConfig.MaxClockDrift, - height, commitmenttypes.GetSDKSpecs(), UpgradePath, - ) - consensusState = endpoint.Counterparty.Chain.LastHeader.ConsensusState() - case exported.Solomachine: - // TODO - // solo := NewSolomachine(endpoint.Chain.T, endpoint.Chain.Codec, clientID, "", 1) - // clientState = solo.ClientState() - // consensusState = solo.ConsensusState() - - default: - err = fmt.Errorf("client type %s is not supported", endpoint.ClientConfig.GetClientType()) - } - - if err != nil { - return err - } - - msg, err := clienttypes.NewMsgCreateClient( - clientState, consensusState, endpoint.Chain.SenderAccount.GetAddress().String(), - ) - require.NoError(endpoint.Chain.T, err) - - res, err := endpoint.Chain.SendMsgs(msg) - if err != nil { - return err - } - - endpoint.ClientID, err = ParseClientIDFromEvents(res.GetEvents()) - require.NoError(endpoint.Chain.T, err) - - return nil -} - -// UpdateClient updates the IBC client associated with the endpoint. -func (endpoint *Endpoint) UpdateClient() (err error) { - // ensure counterparty has committed state - endpoint.Chain.Coordinator.CommitBlock(endpoint.Counterparty.Chain) - - var header *ibctmtypes.Header - - switch endpoint.ClientConfig.GetClientType() { - case exported.Tendermint: - header, err = endpoint.Chain.ConstructUpdateTMClientHeader(endpoint.Counterparty.Chain, endpoint.ClientID) - - default: - err = fmt.Errorf("client type %s is not supported", endpoint.ClientConfig.GetClientType()) - } - - if err != nil { - return err - } - - msg, err := clienttypes.NewMsgUpdateClient( - endpoint.ClientID, header, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - require.NoError(endpoint.Chain.T, err) - - return endpoint.Chain.sendMsgs(msg) -} - -// ConnOpenInit will construct and execute a MsgConnectionOpenInit on the associated endpoint. -func (endpoint *Endpoint) ConnOpenInit() error { - msg := connectiontypes.NewMsgConnectionOpenInit( - endpoint.ClientID, - endpoint.Counterparty.ClientID, - endpoint.Counterparty.Chain.GetPrefix(), DefaultOpenInitVersion, endpoint.ConnectionConfig.DelayPeriod, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - res, err := endpoint.Chain.SendMsgs(msg) - if err != nil { - return err - } - - endpoint.ConnectionID, err = ParseConnectionIDFromEvents(res.GetEvents()) - require.NoError(endpoint.Chain.T, err) - - return nil -} - -// ConnOpenTry will construct and execute a MsgConnectionOpenTry on the associated endpoint. -func (endpoint *Endpoint) ConnOpenTry() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.T, err) - - counterpartyClient, proofClient, proofConsensus, consensusHeight, proofInit, proofHeight := endpoint.QueryConnectionHandshakeProof() - - msg := connectiontypes.NewMsgConnectionOpenTry( - endpoint.ClientID, // does not support handshake continuation - endpoint.Counterparty.ConnectionID, - endpoint.Counterparty.ClientID, - counterpartyClient, - endpoint.Counterparty.Chain.GetPrefix(), - []*connectiontypes.Version{ConnectionVersion}, - endpoint.ConnectionConfig.DelayPeriod, - proofInit, proofClient, proofConsensus, - proofHeight, consensusHeight, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - res, err := endpoint.Chain.SendMsgs(msg) - if err != nil { - return err - } - - if endpoint.ConnectionID == "" { - endpoint.ConnectionID, err = ParseConnectionIDFromEvents(res.GetEvents()) - require.NoError(endpoint.Chain.T, err) - } - - return nil -} - -// ConnOpenAck will construct and execute a MsgConnectionOpenAck on the associated endpoint. -func (endpoint *Endpoint) ConnOpenAck() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.T, err) - - counterpartyClient, proofClient, proofConsensus, consensusHeight, proofTry, proofHeight := endpoint.QueryConnectionHandshakeProof() - - msg := connectiontypes.NewMsgConnectionOpenAck( - endpoint.ConnectionID, endpoint.Counterparty.ConnectionID, counterpartyClient, // testing doesn't use flexible selection - proofTry, proofClient, proofConsensus, - proofHeight, consensusHeight, - ConnectionVersion, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - return endpoint.Chain.sendMsgs(msg) -} - -// ConnOpenConfirm will construct and execute a MsgConnectionOpenConfirm on the associated endpoint. -func (endpoint *Endpoint) ConnOpenConfirm() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.T, err) - - connectionKey := host.ConnectionKey(endpoint.Counterparty.ConnectionID) - proof, height := endpoint.Counterparty.Chain.QueryProof(connectionKey) - - msg := connectiontypes.NewMsgConnectionOpenConfirm( - endpoint.ConnectionID, - proof, height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - return endpoint.Chain.sendMsgs(msg) -} - -// QueryConnectionHandshakeProof returns all the proofs necessary to execute OpenTry or Open Ack of -// the connection handshakes. It returns the counterparty client state, proof of the counterparty -// client state, proof of the counterparty consensus state, the consensus state height, proof of -// the counterparty connection, and the proof height for all the proofs returned. -func (endpoint *Endpoint) QueryConnectionHandshakeProof() ( - clientState exported.ClientState, proofClient, - proofConsensus []byte, consensusHeight clienttypes.Height, - proofConnection []byte, proofHeight clienttypes.Height, -) { - // obtain the client state on the counterparty chain - clientState = endpoint.Counterparty.Chain.GetClientState(endpoint.Counterparty.ClientID) - - // query proof for the client state on the counterparty - clientKey := host.FullClientStateKey(endpoint.Counterparty.ClientID) - proofClient, proofHeight = endpoint.Counterparty.QueryProof(clientKey) - - consensusHeight = clientState.GetLatestHeight().(clienttypes.Height) - - // query proof for the consensus state on the counterparty - consensusKey := host.FullConsensusStateKey(endpoint.Counterparty.ClientID, consensusHeight) - proofConsensus, _ = endpoint.Counterparty.QueryProofAtHeight(consensusKey, proofHeight.GetRevisionHeight()) - - // query proof for the connection on the counterparty - connectionKey := host.ConnectionKey(endpoint.Counterparty.ConnectionID) - proofConnection, _ = endpoint.Counterparty.QueryProofAtHeight(connectionKey, proofHeight.GetRevisionHeight()) - - return -} - -// ChanOpenInit will construct and execute a MsgChannelOpenInit on the associated endpoint. -func (endpoint *Endpoint) ChanOpenInit() error { - msg := channeltypes.NewMsgChannelOpenInit( - endpoint.ChannelConfig.PortID, - endpoint.ChannelConfig.Version, endpoint.ChannelConfig.Order, []string{endpoint.ConnectionID}, - endpoint.Counterparty.ChannelConfig.PortID, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - res, err := endpoint.Chain.SendMsgs(msg) - if err != nil { - return err - } - - endpoint.ChannelID, err = ParseChannelIDFromEvents(res.GetEvents()) - require.NoError(endpoint.Chain.T, err) - - return nil -} - -// ChanOpenTry will construct and execute a MsgChannelOpenTry on the associated endpoint. -func (endpoint *Endpoint) ChanOpenTry() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.T, err) - - channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey) - - msg := channeltypes.NewMsgChannelOpenTry( - endpoint.ChannelConfig.PortID, // does not support handshake continuation - endpoint.ChannelConfig.Version, - endpoint.ChannelConfig.Order, - []string{endpoint.ConnectionID}, - endpoint.Counterparty.ChannelConfig.PortID, - endpoint.Counterparty.ChannelID, - endpoint.Counterparty.ChannelConfig.Version, - proof, height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - res, err := endpoint.Chain.SendMsgs(msg) - if err != nil { - return err - } - - if endpoint.ChannelID == "" { - endpoint.ChannelID, err = ParseChannelIDFromEvents(res.GetEvents()) - require.NoError(endpoint.Chain.T, err) - } - - // update version to selected app version - // NOTE: this update must be performed after the endpoint channelID is set - endpoint.ChannelConfig.Version = endpoint.GetChannel().Version - - return nil -} - -// ChanOpenAck will construct and execute a MsgChannelOpenAck on the associated endpoint. -func (endpoint *Endpoint) ChanOpenAck() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.T, err) - - channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey) - - msg := channeltypes.NewMsgChannelOpenAck( - endpoint.ChannelConfig.PortID, endpoint.ChannelID, - endpoint.Counterparty.ChannelID, endpoint.Counterparty.ChannelConfig.Version, // testing doesn't use flexible selection - proof, height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - return endpoint.Chain.sendMsgs(msg) -} - -// ChanOpenConfirm will construct and execute a MsgChannelOpenConfirm on the associated endpoint. -func (endpoint *Endpoint) ChanOpenConfirm() error { - err := endpoint.UpdateClient() - require.NoError(endpoint.Chain.T, err) - - channelKey := host.ChannelKey(endpoint.Counterparty.ChannelConfig.PortID, endpoint.Counterparty.ChannelID) - proof, height := endpoint.Counterparty.Chain.QueryProof(channelKey) - - msg := channeltypes.NewMsgChannelOpenConfirm( - endpoint.ChannelConfig.PortID, endpoint.ChannelID, - proof, height, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - return endpoint.Chain.sendMsgs(msg) -} - -// ChanCloseInit will construct and execute a MsgChannelCloseInit on the associated endpoint. -// -// NOTE: does not work with ibc-transfer module -func (endpoint *Endpoint) ChanCloseInit() error { - msg := channeltypes.NewMsgChannelCloseInit( - endpoint.ChannelConfig.PortID, endpoint.ChannelID, - endpoint.Chain.SenderAccount.GetAddress().String(), - ) - return endpoint.Chain.sendMsgs(msg) -} - -// SendPacket sends a packet through the channel keeper using the associated endpoint -// The counterparty client is updated so proofs can be sent to the counterparty chain. -func (endpoint *Endpoint) SendPacket(packet exported.PacketI) error { - channelCap := endpoint.Chain.GetChannelCapability(packet.GetSourcePort(), packet.GetSourceChannel()) - - timeoutHeight := clienttypes.Height{ - RevisionNumber: packet.GetTimeoutHeight().GetRevisionNumber(), - RevisionHeight: packet.GetTimeoutHeight().GetRevisionHeight(), - } - - // no need to send message, acting as a module - _, err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), - channelCap, packet.GetSourcePort(), - packet.GetSourceChannel(), - timeoutHeight, - packet.GetTimeoutTimestamp(), - packet.GetData()) - if err != nil { - return err - } - - // commit changes since no message was sent - endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) - - return endpoint.Counterparty.UpdateClient() -} - -// RecvPacket receives a packet on the associated endpoint. -// The counterparty client is updated. -func (endpoint *Endpoint) RecvPacket(packet channeltypes.Packet) error { - _, err := endpoint.RecvPacketWithResult(packet) - if err != nil { - return err - } - - return nil -} - -// RecvPacketWithResult receives a packet on the associated endpoint and the result -// of the transaction is returned. The counterparty client is updated. -func (endpoint *Endpoint) RecvPacketWithResult(packet channeltypes.Packet) (*sdk.Result, error) { - // get proof of packet commitment on source - packetKey := host.PacketCommitmentKey(packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - proof, proofHeight := endpoint.Counterparty.Chain.QueryProof(packetKey) - - recvMsg := channeltypes.NewMsgRecvPacket(packet, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) - - // receive on counterparty and update source client - res, err := endpoint.Chain.SendMsgs(recvMsg) - if err != nil { - return nil, err - } - - if err := endpoint.Counterparty.UpdateClient(); err != nil { - return nil, err - } - - return res, nil -} - -// WriteAcknowledgement writes an acknowledgement on the channel associated with the endpoint. -// The counterparty client is updated. -func (endpoint *Endpoint) WriteAcknowledgement(ack exported.Acknowledgement, packet exported.PacketI) error { - channelCap := endpoint.Chain.GetChannelCapability(packet.GetDestPort(), packet.GetDestChannel()) - - // no need to send message, acting as a handler - err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.WriteAcknowledgement(endpoint.Chain.GetContext(), channelCap, packet, ack) - if err != nil { - return err - } - - // commit changes since no message was sent - endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) - - return endpoint.Counterparty.UpdateClient() -} - -// AcknowledgePacket sends a MsgAcknowledgement to the channel associated with the endpoint. -func (endpoint *Endpoint) AcknowledgePacket(packet channeltypes.Packet, ack []byte) error { - // get proof of acknowledgement on counterparty - packetKey := host.PacketAcknowledgementKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) - - ackMsg := channeltypes.NewMsgAcknowledgement(packet, ack, proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String()) - - return endpoint.Chain.sendMsgs(ackMsg) -} - -// TimeoutPacket sends a MsgTimeout to the channel associated with the endpoint. -func (endpoint *Endpoint) TimeoutPacket(packet channeltypes.Packet) error { - // get proof for timeout based on channel order - var packetKey []byte - - switch endpoint.ChannelConfig.Order { - case channeltypes.ORDERED: - packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) - case channeltypes.UNORDERED: - packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - default: - return fmt.Errorf("unsupported order type %s", endpoint.ChannelConfig.Order) - } - - proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) - nextSeqRecv, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceRecv(endpoint.Counterparty.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) - require.True(endpoint.Chain.T, found) - - timeoutMsg := channeltypes.NewMsgTimeout( - packet, nextSeqRecv, - proof, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String(), - ) - - return endpoint.Chain.sendMsgs(timeoutMsg) -} - -// TimeoutOnClose sends a MsgTimeoutOnClose to the channel associated with the endpoint. -func (endpoint *Endpoint) TimeoutOnClose(packet channeltypes.Packet) error { - // get proof for timeout based on channel order - var packetKey []byte - - switch endpoint.ChannelConfig.Order { - case channeltypes.ORDERED: - packetKey = host.NextSequenceRecvKey(packet.GetDestPort(), packet.GetDestChannel()) - case channeltypes.UNORDERED: - packetKey = host.PacketReceiptKey(packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) - default: - return fmt.Errorf("unsupported order type %s", endpoint.ChannelConfig.Order) - } - - proof, proofHeight := endpoint.Counterparty.QueryProof(packetKey) - - channelKey := host.ChannelKey(packet.GetDestPort(), packet.GetDestChannel()) - proofClosed, _ := endpoint.Counterparty.QueryProof(channelKey) - - nextSeqRecv, found := endpoint.Counterparty.Chain.App.GetIBCKeeper().ChannelKeeper.GetNextSequenceRecv(endpoint.Counterparty.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) - require.True(endpoint.Chain.T, found) - - timeoutOnCloseMsg := channeltypes.NewMsgTimeoutOnClose( - packet, nextSeqRecv, - proof, proofClosed, proofHeight, endpoint.Chain.SenderAccount.GetAddress().String(), - ) - - return endpoint.Chain.sendMsgs(timeoutOnCloseMsg) -} - -// SetChannelClosed sets a channel state to CLOSED. -func (endpoint *Endpoint) SetChannelClosed() error { - channel := endpoint.GetChannel() - - channel.State = channeltypes.CLOSED - endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel) - - endpoint.Chain.Coordinator.CommitBlock(endpoint.Chain) - - return endpoint.Counterparty.UpdateClient() -} - -// GetClientState retrieves the Client State for this endpoint. The -// client state is expected to exist otherwise testing will fail. -func (endpoint *Endpoint) GetClientState() exported.ClientState { - return endpoint.Chain.GetClientState(endpoint.ClientID) -} - -// SetClientState sets the client state for this endpoint. -func (endpoint *Endpoint) SetClientState(clientState exported.ClientState) { - endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientState(endpoint.Chain.GetContext(), endpoint.ClientID, clientState) -} - -// GetConsensusState retrieves the Consensus State for this endpoint at the provided height. -// The consensus state is expected to exist otherwise testing will fail. -func (endpoint *Endpoint) GetConsensusState(height exported.Height) exported.ConsensusState { - consensusState, found := endpoint.Chain.GetConsensusState(endpoint.ClientID, height) - require.True(endpoint.Chain.T, found) - - return consensusState -} - -// SetConsensusState sets the consensus state for this endpoint. -func (endpoint *Endpoint) SetConsensusState(consensusState exported.ConsensusState, height exported.Height) { - endpoint.Chain.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(endpoint.Chain.GetContext(), endpoint.ClientID, height, consensusState) -} - -// GetConnection retrieves an IBC Connection for the endpoint. The -// connection is expected to exist otherwise testing will fail. -func (endpoint *Endpoint) GetConnection() connectiontypes.ConnectionEnd { - connection, found := endpoint.Chain.App.GetIBCKeeper().ConnectionKeeper.GetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID) - require.True(endpoint.Chain.T, found) - - return connection -} - -// SetConnection sets the connection for this endpoint. -func (endpoint *Endpoint) SetConnection(connection connectiontypes.ConnectionEnd) { - endpoint.Chain.App.GetIBCKeeper().ConnectionKeeper.SetConnection(endpoint.Chain.GetContext(), endpoint.ConnectionID, connection) -} - -// GetChannel retrieves an IBC Channel for the endpoint. The channel -// is expected to exist otherwise testing will fail. -func (endpoint *Endpoint) GetChannel() channeltypes.Channel { - channel, found := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.GetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID) - require.True(endpoint.Chain.T, found) - - return channel -} - -// SetChannel sets the channel for this endpoint. -func (endpoint *Endpoint) SetChannel(channel channeltypes.Channel) { - endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SetChannel(endpoint.Chain.GetContext(), endpoint.ChannelConfig.PortID, endpoint.ChannelID, channel) -} - -// QueryClientStateProof performs and abci query for a client stat associated -// with this endpoint and returns the ClientState along with the proof. -func (endpoint *Endpoint) QueryClientStateProof() (exported.ClientState, []byte) { - // retrieve client state to provide proof for - clientState := endpoint.GetClientState() - - clientKey := host.FullClientStateKey(endpoint.ClientID) - proofClient, _ := endpoint.QueryProof(clientKey) - - return clientState, proofClient -} diff --git a/legacy_ibc_testing/testing/events.go b/legacy_ibc_testing/testing/events.go deleted file mode 100644 index 4bab444cbb..0000000000 --- a/legacy_ibc_testing/testing/events.go +++ /dev/null @@ -1,79 +0,0 @@ -package testing - -import ( - "fmt" - - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -// ParseClientIDFromEvents parses events emitted from a MsgCreateClient and returns the -// client identifier. -func ParseClientIDFromEvents(events sdk.Events) (string, error) { - for _, ev := range events { - if ev.Type == clienttypes.EventTypeCreateClient { - for _, attr := range ev.Attributes { - if attr.Key == clienttypes.AttributeKeyClientID { - return attr.Value, nil - } - } - } - } - return "", fmt.Errorf("client identifier event attribute not found") -} - -// ParseConnectionIDFromEvents parses events emitted from a MsgConnectionOpenInit or -// MsgConnectionOpenTry and returns the connection identifier. -func ParseConnectionIDFromEvents(events sdk.Events) (string, error) { - for _, ev := range events { - if ev.Type == connectiontypes.EventTypeConnectionOpenInit || - ev.Type == connectiontypes.EventTypeConnectionOpenTry { - for _, attr := range ev.Attributes { - if attr.Key == connectiontypes.AttributeKeyConnectionID { - return attr.Value, nil - } - } - } - } - return "", fmt.Errorf("connection identifier event attribute not found") -} - -// ParseChannelIDFromEvents parses events emitted from a MsgChannelOpenInit or -// MsgChannelOpenTry and returns the channel identifier. -func ParseChannelIDFromEvents(events sdk.Events) (string, error) { - for _, ev := range events { - if ev.Type == channeltypes.EventTypeChannelOpenInit || ev.Type == channeltypes.EventTypeChannelOpenTry { - for _, attr := range ev.Attributes { - if attr.Key == channeltypes.AttributeKeyChannelID { - return attr.Value, nil - } - } - } - } - return "", fmt.Errorf("channel identifier event attribute not found") -} - -// ParseAckFromEvents parses events emitted from a MsgRecvPacket and returns the -// acknowledgement. -func ParseAckFromEvents(events sdk.Events) ([]byte, error) { - for _, ev := range events { - if ev.Type == channeltypes.EventTypeWriteAck { - for _, attr := range ev.Attributes { - if attr.Key == channeltypes.AttributeKeyAck { //nolint:staticcheck // data - return []byte(attr.Value), nil - } - } - } - } - return nil, fmt.Errorf("acknowledgement event attribute not found") -} diff --git a/legacy_ibc_testing/testing/path.go b/legacy_ibc_testing/testing/path.go deleted file mode 100644 index 31efe8215d..0000000000 --- a/legacy_ibc_testing/testing/path.go +++ /dev/null @@ -1,99 +0,0 @@ -package testing - -import ( - "bytes" - "fmt" - - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -// Path contains two endpoints representing two chains connected over IBC -type Path struct { - EndpointA *Endpoint - EndpointB *Endpoint -} - -// NewPath constructs an endpoint for each chain using the default values -// for the endpoints. Each endpoint is updated to have a pointer to the -// counterparty endpoint. -func NewPath(chainA, chainB *TestChain) *Path { - endpointA := NewDefaultEndpoint(chainA) - endpointB := NewDefaultEndpoint(chainB) - - endpointA.Counterparty = endpointB - endpointB.Counterparty = endpointA - - return &Path{ - EndpointA: endpointA, - EndpointB: endpointB, - } -} - -// SetChannelOrdered sets the channel order for both endpoints to ORDERED. -func (path *Path) SetChannelOrdered() { - path.EndpointA.ChannelConfig.Order = channeltypes.ORDERED - path.EndpointB.ChannelConfig.Order = channeltypes.ORDERED -} - -// RelayPacket attempts to relay the packet first on EndpointA and then on EndpointB -// if EndpointA does not contain a packet commitment for that packet. An error is returned -// if a relay step fails or the packet commitment does not exist on either endpoint. -func (path *Path) RelayPacket(packet channeltypes.Packet) error { - pc := path.EndpointA.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointA.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointA.Chain.App.AppCodec(), packet)) { - - // packet found, relay from A to B - if err := path.EndpointB.UpdateClient(); err != nil { - return err - } - - res, err := path.EndpointB.RecvPacketWithResult(packet) - if err != nil { - return err - } - - ack, err := ParseAckFromEvents(res.GetEvents()) - if err != nil { - return err - } - - if err := path.EndpointA.AcknowledgePacket(packet, ack); err != nil { - return err - } - - return nil - } - - pc = path.EndpointB.Chain.App.GetIBCKeeper().ChannelKeeper.GetPacketCommitment(path.EndpointB.Chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence()) - if bytes.Equal(pc, channeltypes.CommitPacket(path.EndpointB.Chain.App.AppCodec(), packet)) { - - // packet found, relay B to A - if err := path.EndpointA.UpdateClient(); err != nil { - return err - } - - res, err := path.EndpointA.RecvPacketWithResult(packet) - if err != nil { - return err - } - - ack, err := ParseAckFromEvents(res.GetEvents()) - if err != nil { - return err - } - - if err := path.EndpointB.AcknowledgePacket(packet, ack); err != nil { - return err - } - return nil - } - - return fmt.Errorf("packet commitment does not exist on either endpoint for provided packet") -} diff --git a/legacy_ibc_testing/testing/utils.go b/legacy_ibc_testing/testing/utils.go deleted file mode 100644 index 047793f455..0000000000 --- a/legacy_ibc_testing/testing/utils.go +++ /dev/null @@ -1,32 +0,0 @@ -package testing - -import ( - "testing" - - "github.com/stretchr/testify/require" - - abci "github.com/cometbft/cometbft/abci/types" - tmtypes "github.com/cometbft/cometbft/types" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -// ApplyValSetChanges takes in tmtypes.ValidatorSet and []abci.ValidatorUpdate and will return a new tmtypes.ValidatorSet which has the -// provided validator updates applied to the provided validator set. -func ApplyValSetChanges(t *testing.T, valSet *tmtypes.ValidatorSet, valUpdates []abci.ValidatorUpdate) *tmtypes.ValidatorSet { - t.Helper() - updates, err := tmtypes.PB2TM.ValidatorUpdates(valUpdates) - require.NoError(t, err) - - // must copy since validator set will mutate with UpdateWithChangeSet - newVals := valSet.Copy() - err = newVals.UpdateWithChangeSet(updates) - require.NoError(t, err) - - return newVals -} diff --git a/legacy_ibc_testing/testing/values.go b/legacy_ibc_testing/testing/values.go deleted file mode 100644 index 579d00cea4..0000000000 --- a/legacy_ibc_testing/testing/values.go +++ /dev/null @@ -1,53 +0,0 @@ -package testing - -import ( - "time" - - ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" - ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - "github.com/cosmos/ibc-go/v7/testing/mock" -) - -/* -TODO: Remove after upgrading to ibc-go v5 -legacy_ibc_testing is temporarily copied into the interchain-security repository for the purpose of testing only. -The integration test suites rely on modifications to ibc-go's test framework that cannot be back-ported to the canonical version that ics will rely on. -These files will be deprecated once ICS is able to upgrade to ibc-go v5. -*/ - -const ( - FirstChannelID = "channel-0" - FirstConnectionID = "connection-0" - - // Default params constants used to create a TM client - TrustingPeriod time.Duration = time.Hour * 24 * 7 * 2 - UnbondingPeriod time.Duration = time.Hour * 24 * 7 * 3 - MaxClockDrift time.Duration = time.Second * 10 - DefaultDelayPeriod uint64 = 0 - - DefaultChannelVersion = mock.Version - InvalidID = "IDisInvalid" - - // Application Ports - TransferPort = ibctransfertypes.ModuleName - MockPort = mock.ModuleName - - // used for testing proposals - Title = "title" - Description = "description" -) - -var ( - DefaultOpenInitVersion *connectiontypes.Version - - // Default params variables used to create a TM client - DefaultTrustLevel ibctmtypes.Fraction = ibctmtypes.DefaultTrustLevel - - UpgradePath = []string{"upgrade", "upgradedIBCState"} - - ConnectionVersion = connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions())[0] - - MockAcknowledgement = mock.MockAcknowledgement.Acknowledgement() - MockPacketData = mock.MockPacketData -) diff --git a/proto/interchain_security/ccv/consumer/v1/consumer.proto b/proto/interchain_security/ccv/consumer/v1/consumer.proto index 2b4b6f88c3..b386bc2e9a 100644 --- a/proto/interchain_security/ccv/consumer/v1/consumer.proto +++ b/proto/interchain_security/ccv/consumer/v1/consumer.proto @@ -1,78 +1,24 @@ syntax = "proto3"; package interchain_security.ccv.consumer.v1; -import "interchain_security/ccv/v1/ccv.proto"; - option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"; import "google/protobuf/any.proto"; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; -import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; -// Params defines the parameters for CCV consumer module -message Params { - // TODO: Remove enabled flag and find a better way to setup integration tests - // See: https://github.com/cosmos/interchain-security/issues/339 - bool enabled = 1; - - /////////////////////// - // Distribution Params - // Number of blocks between ibc-token-transfers from the consumer chain to - // the provider chain. Note that at this transmission event a fraction of - // the accumulated tokens are divided and sent consumer redistribution - // address. - int64 blocks_per_distribution_transmission = 2; - - // Channel, and provider-chain receiving address to send distribution token - // transfers over. These parameters is auto-set during the consumer <-> - // provider handshake procedure. - string distribution_transmission_channel = 3; - string provider_fee_pool_addr_str = 4; - // Sent CCV related IBC packets will timeout after this duration - google.protobuf.Duration ccv_timeout_period = 5 - [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; - - // Sent transfer related IBC packets will timeout after this duration - google.protobuf.Duration transfer_timeout_period = 6 - [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; - - // The fraction of tokens allocated to the consumer redistribution address - // during distribution events. The fraction is a string representing a - // decimal number. For example "0.75" would represent 75%. - string consumer_redistribution_fraction = 7; - - // The number of historical info entries to persist in store. - // This param is a part of the cosmos sdk staking module. In the case of - // a ccv enabled consumer chain, the ccv module acts as the staking module. - int64 historical_entries = 8; - - // Unbonding period for the consumer, - // which should be smaller than that of the provider in general. - google.protobuf.Duration unbonding_period = 9 - [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; - - // The threshold for the percentage of validators at the bottom of the set who - // can opt out of running the consumer chain without being punished. For - // example, a value of 0.05 means that the validators in the bottom 5% of the - // set can opt out - string soft_opt_out_threshold = 10; - - // Reward denoms. These are the denominations which are allowed to be sent to - // the provider as rewards. - repeated string reward_denoms = 11; - - // Provider-originated reward denoms. These are denoms coming from the - // provider which are allowed to be used as rewards. e.g. "uatom" - repeated string provider_reward_denoms = 12; -} - -// LastTransmissionBlockHeight is the last time validator holding -// pools were transmitted to the provider chain -message LastTransmissionBlockHeight { int64 height = 1; } - -// CrossChainValidator defines the validators for CCV consumer module +// +// Note any type defined in this file is ONLY used internally to the consumer +// CCV module. These schemas can change with proper consideration of +// compatibility or migration. + +// CrossChainValidator defines the type used to store validator information +// internal to the consumer CCV module. Note one cross chain validator entry is +// persisted for each consumer validator, where incoming VSC packets update this +// data, which is eventually forwarded to comet for consumer chain consensus. +// +// Note this type is only used internally to the consumer CCV module. message CrossChainValidator { bytes address = 1; int64 power = 2; @@ -83,17 +29,12 @@ message CrossChainValidator { ]; } -// MaturingVSCPacket contains the maturing time of a received VSCPacket -message MaturingVSCPacket { - uint64 vscId = 1; - google.protobuf.Timestamp maturity_time = 2 - [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; -} - // A record storing the state of a slash packet sent to the provider chain // which may bounce back and forth until handled by the provider. +// +// Note this type is only used internally to the consumer CCV module. message SlashRecord { bool waiting_on_reply = 1; google.protobuf.Timestamp send_time = 2 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; -} \ No newline at end of file +} diff --git a/proto/interchain_security/ccv/consumer/v1/genesis.proto b/proto/interchain_security/ccv/consumer/v1/genesis.proto index 3511f3f349..bb33f34501 100644 --- a/proto/interchain_security/ccv/consumer/v1/genesis.proto +++ b/proto/interchain_security/ccv/consumer/v1/genesis.proto @@ -4,32 +4,40 @@ package interchain_security.ccv.consumer.v1; option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"; -import "interchain_security/ccv/v1/ccv.proto"; -import "interchain_security/ccv/consumer/v1/consumer.proto"; -import "tendermint/abci/types.proto"; +import "interchain_security/ccv/v1/shared_consumer.proto"; import "ibc/lightclients/tendermint/v1/tendermint.proto"; -import "ibc/core/channel/v1/channel.proto"; -import "google/protobuf/duration.proto"; + import "gogoproto/gogo.proto"; +import "interchain_security/ccv/v1/wire.proto"; +import "google/protobuf/timestamp.proto"; +import "tendermint/abci/types.proto"; + -// GenesisState defines the CCV consumer chain genesis state + + +// GenesisState defines the CCV consumer genesis state +// +// Note: this type is only used on consumer side and references shared types with +// provider message GenesisState { - Params params = 1 [ (gogoproto.nullable) = false ]; - string provider_client_id = 2; // empty for a new chain, filled in on restart. - string provider_channel_id = - 3; // empty for a new chain, filled in on restart. - bool new_chain = - 4; // true for new chain GenesisState, false for chain restart. - // ProviderClientState filled in on new chain, nil on restart. - ibc.lightclients.tendermint.v1.ClientState provider_client_state = 5; - // ProviderConsensusState filled in on new chain, nil on restart. - ibc.lightclients.tendermint.v1.ConsensusState provider_consensus_state = 6; + // ConsumerParams is a shared type with provider module + interchain_security.ccv.v1.ConsumerParams params = 1 + [ (gogoproto.nullable) = false ]; + // Client ID of the provider. Empty for a new chain, filled in on restart. + string provider_client_id = 2; + // Channel ID of the provider. Empty for a new chain, filled in on restart. + string provider_channel_id = 3; + // true for new chain, false for chain restart. + bool new_chain = 4; + // !!! DEPRECATED !!! ProviderClientState is deprecated. Use provider.client_state instead + ibc.lightclients.tendermint.v1.ClientState provider_client_state = 5 [ deprecated = true]; + // !!! DEPRECATED !!! ProviderConsensusState is deprecated. Use provider.consensus_state instead + ibc.lightclients.tendermint.v1.ConsensusState provider_consensus_state = 6 [ deprecated = true]; // MaturingPackets nil on new chain, filled in on restart. - repeated interchain_security.ccv.consumer.v1.MaturingVSCPacket - maturing_packets = 7 [ (gogoproto.nullable) = false ]; - // InitialValset filled in on new chain and on restart. - repeated .tendermint.abci.ValidatorUpdate initial_val_set = 8 + repeated MaturingVSCPacket maturing_packets = 7 [ (gogoproto.nullable) = false ]; + // !!! DEPRECATED !!!! InitialValset is deprecated. Use provider.initial_val_set instead + repeated .tendermint.abci.ValidatorUpdate initial_val_set = 8 [ (gogoproto.nullable) = false, deprecated = true ]; // HeightToValsetUpdateId nil on new chain, filled in on restart. repeated HeightToValsetUpdateID height_to_valset_update_id = 9 [ (gogoproto.nullable) = false ]; @@ -37,22 +45,48 @@ message GenesisState { repeated OutstandingDowntime outstanding_downtime_slashing = 10 [ (gogoproto.nullable) = false ]; // PendingConsumerPackets nil on new chain, filled in on restart. - interchain_security.ccv.v1.ConsumerPacketDataList pending_consumer_packets = - 11 [ (gogoproto.nullable) = false ]; + ConsumerPacketDataList pending_consumer_packets = 11 + [ (gogoproto.nullable) = false ]; // LastTransmissionBlockHeight nil on new chain, filled in on restart. - interchain_security.ccv.consumer.v1.LastTransmissionBlockHeight - last_transmission_block_height = 12 [ (gogoproto.nullable) = false ]; - bool preCCV = 13; // flag indicating whether the consumer CCV module starts in - // pre-CCV state + LastTransmissionBlockHeight last_transmission_block_height = 12 + [ (gogoproto.nullable) = false ]; + // flag indicating whether the consumer CCV module starts in pre-CCV state + bool preCCV = 13; + interchain_security.ccv.v1.ProviderInfo provider = 14 + [ (gogoproto.nullable) = false ]; } -// HeightValsetUpdateID defines the genesis information for the mapping -// of each block height to a valset update id +// HeightValsetUpdateID represents a mapping internal to the consumer CCV module +// which links a block height to each recv valset update id. message HeightToValsetUpdateID { uint64 height = 1; uint64 valset_update_id = 2; } -// OutstandingDowntime defines the genesis information for each validator -// flagged with an outstanding downtime slashing. +// OutstandingDowntime defines the type used internally to the consumer CCV +// module and is used in order to not send multiple slashing requests for +// the same downtime infraction. message OutstandingDowntime { string validator_consensus_address = 1; } + +// LastTransmissionBlockHeight is the last time validator holding +// pools were transmitted to the provider chain. This type is used internally +// to the consumer CCV modul. +message LastTransmissionBlockHeight { int64 height = 1; } + +// MaturingVSCPacket represents a vsc packet that is maturing internal to the +// consumer CCV module, where the consumer has not yet relayed a VSCMatured +// packet back to the provider. +message MaturingVSCPacket { + uint64 vscId = 1; + google.protobuf.Timestamp maturity_time = 2 + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; +} + +// ConsumerPacketDataList is a list of consumer packet data packets. +// +// Note this type is used internally to the consumer CCV module +// for exporting / importing state in InitGenesis and ExportGenesis. +message ConsumerPacketDataList { + repeated interchain_security.ccv.v1.ConsumerPacketData list = 1 + [ (gogoproto.nullable) = false ]; +} diff --git a/proto/interchain_security/ccv/consumer/v1/query.proto b/proto/interchain_security/ccv/consumer/v1/query.proto index 43a7b0bccc..3c56aed7ea 100644 --- a/proto/interchain_security/ccv/consumer/v1/query.proto +++ b/proto/interchain_security/ccv/consumer/v1/query.proto @@ -1,11 +1,13 @@ syntax = "proto3"; package interchain_security.ccv.consumer.v1; +import "interchain_security/ccv/v1/shared_consumer.proto"; option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "interchain_security/ccv/consumer/v1/consumer.proto"; +import "interchain_security/ccv/v1/wire.proto"; service Query { // ConsumerGenesis queries the genesis state needed to start a consumer chain @@ -23,6 +25,11 @@ service Query { rpc QueryProviderInfo(QueryProviderInfoRequest) returns (QueryProviderInfoResponse) { option (google.api.http).get = "/interchain_security/ccv/consumer/provider-info"; } + + // QueryThrottleState returns on-chain state relevant to throttled consumer packets + rpc QueryThrottleState(QueryThrottleStateRequest) returns (QueryThrottleStateResponse) { + option (google.api.http).get = "/interchain_security/ccv/consumer/throttle_state"; + } } // NextFeeDistributionEstimate holds information about next fee distribution @@ -54,7 +61,7 @@ message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Params RPC method. message QueryParamsResponse { // params holds all the parameters of this module. - Params params = 1 [ (gogoproto.nullable) = false ]; + interchain_security.ccv.v1.ConsumerParams params = 1 [ (gogoproto.nullable) = false ]; } message QueryProviderInfoRequest {} @@ -64,6 +71,14 @@ message QueryProviderInfoResponse { ChainInfo provider = 2 [ (gogoproto.nullable) = false ]; } +message QueryThrottleStateRequest {} + +message QueryThrottleStateResponse { + SlashRecord slash_record = 1 [ (gogoproto.nullable) = true ]; + repeated interchain_security.ccv.v1.ConsumerPacketData packet_data_queue = 2 [ (gogoproto.nullable) = false ]; +} + + message ChainInfo { string chainID = 1; string clientID = 2; diff --git a/proto/interchain_security/ccv/provider/v1/genesis.proto b/proto/interchain_security/ccv/provider/v1/genesis.proto index 1bc412262c..2899c4e1f2 100644 --- a/proto/interchain_security/ccv/provider/v1/genesis.proto +++ b/proto/interchain_security/ccv/provider/v1/genesis.proto @@ -5,11 +5,9 @@ package interchain_security.ccv.provider.v1; option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"; import "gogoproto/gogo.proto"; -import "interchain_security/ccv/v1/ccv.proto"; +import "interchain_security/ccv/v1/shared_consumer.proto"; +import "interchain_security/ccv/v1/wire.proto"; import "interchain_security/ccv/provider/v1/provider.proto"; -import "interchain_security/ccv/consumer/v1/consumer.proto"; -import "interchain_security/ccv/consumer/v1/genesis.proto"; -import "tendermint/crypto/keys.proto"; // GenesisState defines the CCV provider chain genesis state message GenesisState { @@ -24,7 +22,7 @@ message GenesisState { repeated interchain_security.ccv.provider.v1.UnbondingOp unbonding_ops = 3 [ (gogoproto.nullable) = false ]; // empty for a new chain - interchain_security.ccv.v1.MaturedUnbondingOps mature_unbonding_ops = 4; + interchain_security.ccv.provider.v1.MaturedUnbondingOps mature_unbonding_ops = 4; // empty for a new chain repeated ValsetUpdateIdToHeight valset_update_id_to_height = 5 [ (gogoproto.nullable) = false ]; @@ -52,7 +50,9 @@ message GenesisState { [ (gogoproto.nullable) = false ]; } -// consumer chain +// The provider CCV module's knowledge of consumer state. +// +// Note this type is only used internally to the provider CCV module. message ConsumerState { // ChainID defines the chain ID for the consumer chain string chain_id = 1; @@ -63,7 +63,7 @@ message ConsumerState { // InitalHeight defines the initial block height for the consumer chain uint64 initial_height = 4; // ConsumerGenesis defines the initial consumer chain genesis states - interchain_security.ccv.consumer.v1.GenesisState consumer_genesis = 5 + interchain_security.ccv.v1.ConsumerGenesisState consumer_genesis = 5 [ (gogoproto.nullable) = false ]; // PendingValsetChanges defines the pending validator set changes for the // consumer chain diff --git a/proto/interchain_security/ccv/provider/v1/provider.proto b/proto/interchain_security/ccv/provider/v1/provider.proto index 3c41e01c89..f085ba472d 100644 --- a/proto/interchain_security/ccv/provider/v1/provider.proto +++ b/proto/interchain_security/ccv/provider/v1/provider.proto @@ -4,6 +4,7 @@ package interchain_security.ccv.provider.v1; option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"; +import "interchain_security/ccv/v1/wire.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; import "google/protobuf/duration.proto"; @@ -13,6 +14,11 @@ import "tendermint/crypto/keys.proto"; import "cosmos/evidence/v1beta1/evidence.proto"; import "cosmos/base/v1beta1/coin.proto"; +// +// Note any type defined in this file is ONLY used internally to the provider CCV module. +// These schemas can change with proper consideration of compatibility or migration. +// + // ConsumerAdditionProposal is a governance proposal on the provider chain to // spawn a new consumer chain. If it passes, then all validators on the provider // chain are expected to validate the consumer chain at spawn time or get @@ -96,6 +102,10 @@ message ConsumerRemovalProposal { [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; } +// EquivocationProposal is a governance proposal on the provider chain to +// punish a validator for equivocation on a consumer chain. +// +// This type is only used internally to the consumer CCV module. message EquivocationProposal { // the title of the proposal string title = 1; @@ -105,6 +115,19 @@ message EquivocationProposal { repeated cosmos.evidence.v1beta1.Equivocation equivocations = 3; } +// ChangeRewardDenomsProposal is a governance proposal on the provider chain to +// mutate the set of denoms accepted by the provider as rewards. +message ChangeRewardDenomsProposal { + // the title of the proposal + string title = 1; + // the description of the proposal + string description = 2; + // the list of consumer reward denoms to add + repeated string denoms_to_add = 3; + // the list of consumer reward denoms to remove + repeated string denoms_to_remove = 4; +} + // A persisted queue entry indicating that a slash packet data instance needs to // be handled. This type belongs in the "global" queue, to coordinate slash // packet handling times between consumers. @@ -128,6 +151,10 @@ message GlobalSlashEntry { // Params defines the parameters for CCV Provider module message Params { + + // Reserve 8th slot for removed max throttled packet param + reserved 8; + ibc.lightclients.tendermint.v1.ClientState template_client = 1; // TrustingPeriodFraction is used to compute the consumer and provider IBC // client's TrustingPeriod from the chain defined UnbondingPeriod @@ -155,22 +182,13 @@ message Params { // total voting power that the slash meter can hold. string slash_meter_replenish_fraction = 7; - // The maximum amount of throttled slash or vsc matured packets - // that can be queued for a single consumer before the provider chain halts. - int64 max_throttled_packets = 8; - // The fee required to be paid to add a reward denom cosmos.base.v1beta1.Coin consumer_reward_denom_registration_fee = 9 [ (gogoproto.nullable) = false ]; } -message HandshakeMetadata { - string provider_fee_pool_addr = 1; - string version = 2; -} - // SlashAcks contains cons addresses of consumer chain validators -// successfully slashed on the provider chain +// successfully slashed on the provider chain. message SlashAcks { repeated string addresses = 1; } // ConsumerAdditionProposals holds pending governance proposals on the provider @@ -190,6 +208,7 @@ message ConsumerRemovalProposals { // AddressList contains a list of consensus addresses message AddressList { repeated bytes addresses = 1; } +// ChannelToChain is used to map a CCV channel ID to the consumer chainID message ChannelToChain { string channel_id = 1; string chain_id = 2; @@ -221,6 +240,16 @@ message VscSendTimestamp { [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; } +// ValidatorSetChangePackets is a pb list of ccv.ValidatorSetChangePacketData. +message ValidatorSetChangePackets { + repeated interchain_security.ccv.v1.ValidatorSetChangePacketData list = 1 + [ (gogoproto.nullable) = false ]; +} + +// MaturedUnbondingOps defines a list of ids corresponding to ids of matured +// unbonding operations. +message MaturedUnbondingOps { repeated uint64 ids = 1; } + // ExportedVscSendTimestamps is VscSendTimestamp with chainID info for exporting to genesis message ExportedVscSendTimestamp { string chain_id = 1; diff --git a/proto/interchain_security/ccv/provider/v1/query.proto b/proto/interchain_security/ccv/provider/v1/query.proto index 431099be79..e648e2be35 100644 --- a/proto/interchain_security/ccv/provider/v1/query.proto +++ b/proto/interchain_security/ccv/provider/v1/query.proto @@ -6,9 +6,9 @@ option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/provider/typ import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; import "google/protobuf/timestamp.proto"; -import "interchain_security/ccv/v1/ccv.proto"; -import "interchain_security/ccv/consumer/v1/genesis.proto"; import "interchain_security/ccv/provider/v1/provider.proto"; +import "interchain_security/ccv/v1/shared_consumer.proto"; +import "interchain_security/ccv/v1/wire.proto"; service Query { // ConsumerGenesis queries the genesis state needed to start a consumer chain @@ -65,14 +65,6 @@ service Query { "/interchain_security/ccv/provider/throttle_state"; } - // QueryThrottledConsumerPacketData returns a list of pending packet data - // instances (slash packet and vsc matured) for a single consumer chain - rpc QueryThrottledConsumerPacketData(QueryThrottledConsumerPacketDataRequest) - returns (QueryThrottledConsumerPacketDataResponse) { - option (google.api.http).get = - "/interchain_security/ccv/provider/pending_consumer_packets"; - } - // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered rpc QueryRegisteredConsumerRewardDenoms( @@ -86,7 +78,7 @@ service Query { message QueryConsumerGenesisRequest { string chain_id = 1; } message QueryConsumerGenesisResponse { - interchain_security.ccv.consumer.v1.GenesisState genesis_state = 1 + interchain_security.ccv.v1.ConsumerGenesisState genesis_state = 1 [ (gogoproto.nullable) = false ]; } @@ -151,35 +143,6 @@ message QueryThrottleStateResponse { // full google.protobuf.Timestamp next_replenish_candidate = 3 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; - // data relevant to currently throttled slash packets - repeated ThrottledSlashPacket packets = 4; -} - -message QueryThrottledConsumerPacketDataRequest { string chain_id = 1; } - -message QueryThrottledConsumerPacketDataResponse { - string chain_id = 1; - uint64 size = 2; - repeated ThrottledPacketDataWrapper packetDataInstances = 3 - [ (gogoproto.nullable) = false ]; -} - -// A query wrapper type for the global entry and data relevant to a throttled -// slash packet. -message ThrottledSlashPacket { - interchain_security.ccv.provider.v1.GlobalSlashEntry global_entry = 1 - [ (gogoproto.nullable) = false ]; - interchain_security.ccv.v1.SlashPacketData data = 2 - [ (gogoproto.nullable) = false ]; -} - -// ThrottledPacketDataWrapper contains either SlashPacketData or -// VSCMaturedPacketData -message ThrottledPacketDataWrapper { - oneof data { - interchain_security.ccv.v1.SlashPacketData slash_packet = 1; - interchain_security.ccv.v1.VSCMaturedPacketData vsc_matured_packet = 2; - } } message QueryRegisteredConsumerRewardDenomsRequest {} diff --git a/proto/interchain_security/ccv/provider/v1/tx.proto b/proto/interchain_security/ccv/provider/v1/tx.proto index 952ba31c09..1fb97e4132 100644 --- a/proto/interchain_security/ccv/provider/v1/tx.proto +++ b/proto/interchain_security/ccv/provider/v1/tx.proto @@ -3,17 +3,12 @@ package interchain_security.ccv.provider.v1; option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/provider/types"; -import "google/api/annotations.proto"; import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; -import "google/protobuf/any.proto"; // Msg defines the Msg service. service Msg { rpc AssignConsumerKey(MsgAssignConsumerKey) returns (MsgAssignConsumerKeyResponse); - rpc RegisterConsumerRewardDenom(MsgRegisterConsumerRewardDenom) - returns (MsgRegisterConsumerRewardDenomResponse); } message MsgAssignConsumerKey { @@ -30,18 +25,3 @@ message MsgAssignConsumerKey { } message MsgAssignConsumerKeyResponse {} - -// MsgRegisterConsumerRewardDenom allows an account to register -// a consumer reward denom, i.e., add it to the list of denoms -// accepted by the provider as rewards. -message MsgRegisterConsumerRewardDenom { - option (gogoproto.equal) = false; - option (gogoproto.goproto_getters) = false; - - string denom = 1; - string depositor = 2; -} - -// MsgRegisterConsumerRewardDenomResponse defines the -// Msg/RegisterConsumerRewardDenom response type. -message MsgRegisterConsumerRewardDenomResponse {} diff --git a/proto/interchain_security/ccv/v1/shared_consumer.proto b/proto/interchain_security/ccv/v1/shared_consumer.proto new file mode 100644 index 0000000000..149e8630c5 --- /dev/null +++ b/proto/interchain_security/ccv/v1/shared_consumer.proto @@ -0,0 +1,103 @@ +syntax = "proto3"; + +package interchain_security.ccv.v1; + +option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/types"; + +import "tendermint/abci/types.proto"; +import "ibc/lightclients/tendermint/v1/tendermint.proto"; +import "google/protobuf/duration.proto"; +import "gogoproto/gogo.proto"; + +// +// Note any type defined in this file is referenced/persisted in both the +// consumer and provider CCV modules, but not sent over the wire. These schemas +// could change, only with careful consideration of effects! +// + +// ConsumerParams defines the parameters for CCV consumer module. +// +// Note this type is referenced in both the consumer and provider CCV modules, +// and persisted on the provider, see MakeConsumerGenesis and +// SetConsumerGenesis. +// +message ConsumerParams { + // TODO: Remove enabled flag and find a better way to setup integration tests + // See: https://github.com/cosmos/interchain-security/issues/339 + bool enabled = 1; + + /////////////////////// + // Distribution Params + // Number of blocks between ibc-token-transfers from the consumer chain to + // the provider chain. Note that at this transmission event a fraction of + // the accumulated tokens are divided and sent consumer redistribution + // address. + int64 blocks_per_distribution_transmission = 2; + + // Channel, and provider-chain receiving address to send distribution token + // transfers over. These parameters is auto-set during the consumer <-> + // provider handshake procedure. + string distribution_transmission_channel = 3; + string provider_fee_pool_addr_str = 4; + // Sent CCV related IBC packets will timeout after this duration + google.protobuf.Duration ccv_timeout_period = 5 + [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + + // Sent transfer related IBC packets will timeout after this duration + google.protobuf.Duration transfer_timeout_period = 6 + [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + + // The fraction of tokens allocated to the consumer redistribution address + // during distribution events. The fraction is a string representing a + // decimal number. For example "0.75" would represent 75%. + string consumer_redistribution_fraction = 7; + + // The number of historical info entries to persist in store. + // This param is a part of the cosmos sdk staking module. In the case of + // a ccv enabled consumer chain, the ccv module acts as the staking module. + int64 historical_entries = 8; + + // Unbonding period for the consumer, + // which should be smaller than that of the provider in general. + google.protobuf.Duration unbonding_period = 9 + [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; + + // The threshold for the percentage of validators at the bottom of the set who + // can opt out of running the consumer chain without being punished. For + // example, a value of 0.05 means that the validators in the bottom 5% of the + // set can opt out + string soft_opt_out_threshold = 10; + + // Reward denoms. These are the denominations which are allowed to be sent to + // the provider as rewards. + repeated string reward_denoms = 11; + + // Provider-originated reward denoms. These are denoms coming from the + // provider which are allowed to be used as rewards. e.g. "uatom" + repeated string provider_reward_denoms = 12; + + // The period after which a consumer can retry sending a throttled packet. + google.protobuf.Duration retry_delay_period = 13 + [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; +} + +// ConsumerGenesisState defines shared genesis information between provider and +// consumer +message ConsumerGenesisState { + ConsumerParams params = 1 [ (gogoproto.nullable) = false ]; + ProviderInfo provider = 2 [ (gogoproto.nullable) = false ]; + // true for new chain, false for chain restart. + bool new_chain = 3; // TODO:Check if this is really needed +} + +// ProviderInfo defines all information a consumer needs from a provider +// Shared data type between provider and consumer +message ProviderInfo { + // ProviderClientState filled in on new chain, nil on restart. + ibc.lightclients.tendermint.v1.ClientState client_state = 1; + // ProviderConsensusState filled in on new chain, nil on restart. + ibc.lightclients.tendermint.v1.ConsensusState consensus_state = 2; + // InitialValset filled in on new chain and on restart. + repeated .tendermint.abci.ValidatorUpdate initial_val_set = 3 + [ (gogoproto.nullable) = false ]; +} diff --git a/proto/interchain_security/ccv/v1/ccv.proto b/proto/interchain_security/ccv/v1/wire.proto similarity index 83% rename from proto/interchain_security/ccv/v1/ccv.proto rename to proto/interchain_security/ccv/v1/wire.proto index adf8f418de..57dcbc8847 100644 --- a/proto/interchain_security/ccv/v1/ccv.proto +++ b/proto/interchain_security/ccv/v1/wire.proto @@ -9,6 +9,12 @@ import "cosmos/staking/v1beta1/staking.proto"; import "gogoproto/gogo.proto"; import "tendermint/abci/types.proto"; +// +// Note any type defined in this file is used by both the consumer and provider +// AND SENT OVER THE WIRE via a ccv channel. Ideally these schemas should never change, or at least +// be backwards compatible if ever changed. +// + // This packet is sent from provider chain to consumer chain if the validator // set for consumer chain changes (due to new bonding/unbonding messages or // slashing events) A VSCMatured packet from consumer chain will be sent @@ -25,12 +31,6 @@ message ValidatorSetChangePacketData { repeated string slash_acks = 3; } -// List of ccv.ValidatorSetChangePacketData. -message ValidatorSetChangePackets { - repeated ValidatorSetChangePacketData list = 1 - [ (gogoproto.nullable) = false ]; -} - // This packet is sent from the consumer chain to the provider chain // to notify that a VSC packet reached maturity on the consumer chain. message VSCMaturedPacketData { @@ -52,11 +52,7 @@ message SlashPacketData { cosmos.staking.v1beta1.Infraction infraction = 3; } -// MaturedUnbondingOps defines a list of ids corresponding to ids of matured -// unbonding operations. -message MaturedUnbondingOps { repeated uint64 ids = 1; } - -// ConsumerPacketData contains a consumer packet data, type tag, and index for storage. +// ConsumerPacketData contains a consumer packet data and a type tag message ConsumerPacketData { ConsumerPacketDataType type = 1; @@ -66,13 +62,6 @@ message ConsumerPacketData { } } - -// ConsumerPacketDataList is a list of consumer packet data packets. -// NOTE: It is only used for exporting / importing state in InitGenesis and ExportGenesis. -message ConsumerPacketDataList { - repeated ConsumerPacketData list = 1 [ (gogoproto.nullable) = false ]; -} - // ConsumerPacketType indicates interchain security specific packet types. enum ConsumerPacketDataType { option (gogoproto.goproto_enum_prefix) = false; @@ -88,6 +77,12 @@ enum ConsumerPacketDataType { [ (gogoproto.enumvalue_customname) = "VscMaturedPacket" ]; } +// Note this type is used during IBC handshake methods for both the consumer and provider +message HandshakeMetadata { + string provider_fee_pool_addr = 1; + string version = 2; +} + // ConsumerPacketData contains a consumer packet data and a type tag // that is compatible with ICS v1 and v2 over the wire. It is not used for internal storage. message ConsumerPacketDataV1 { @@ -113,7 +108,7 @@ message SlashPacketDataV1 { } // InfractionType indicates the infraction type a validator commited. -// NOTE: ccv.InfractionType to maintain compatibility between ICS versions +// Note ccv.InfractionType to maintain compatibility between ICS versions // using different versions of the cosmos-sdk and ibc-go modules. enum InfractionType { option (gogoproto.goproto_enum_prefix) = false; diff --git a/tests/difference/core/driver/core_test.go b/tests/difference/core/driver/core_test.go index ec97fbf9c1..2d42e65dba 100644 --- a/tests/difference/core/driver/core_test.go +++ b/tests/difference/core/driver/core_test.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" @@ -14,8 +14,6 @@ import ( appConsumer "github.com/cosmos/interchain-security/v3/app/consumer" appProvider "github.com/cosmos/interchain-security/v3/app/provider" - ibctestingcore "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" simibc "github.com/cosmos/interchain-security/v3/testutil/simibc" consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" ) @@ -184,13 +182,10 @@ func (s *CoreSuite) consumerSlash(val sdk.ConsAddress, h int64, isDowntime bool) before := len(ctx.EventManager().Events()) s.consumerKeeper().SlashWithInfractionReason(ctx, val, h, 0, sdk.Dec{}, kind) // consumer module emits packets on slash, so these must be collected. - evts := ctx.EventManager().ABCIEvents() - for _, e := range evts[before:] { - if e.Type == channeltypes.EventTypeSendPacket { - packet, err := ibctestingcore.ReconstructPacketFromEvent(e) - s.Require().NoError(err) - s.simibc.Outboxes.AddPacket(s.chainID(C), packet) - } + evts := ctx.EventManager().Events() + packets := simibc.ParsePacketsFromEvents(evts[before:]) + if len(packets) > 0 { + s.simibc.Outboxes.AddPacket(s.chainID(C), packets[0]) } } diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index fb5bf6a611..cf9d5e470d 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -10,6 +10,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/cosmos/ibc-go/v7/testing/mock" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -33,8 +34,8 @@ import ( appConsumer "github.com/cosmos/interchain-security/v3/app/consumer" appProvider "github.com/cosmos/interchain-security/v3/app/provider" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" icstestingutils "github.com/cosmos/interchain-security/v3/testutil/ibc_testing" + testutil "github.com/cosmos/interchain-security/v3/testutil/integration" simibc "github.com/cosmos/interchain-security/v3/testutil/simibc" consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" @@ -216,7 +217,7 @@ func (b *Builder) getAppBytesAndSenders( if genesis[consumertypes.ModuleName] != nil { app.AppCodec().MustUnmarshalJSON(genesis[consumertypes.ModuleName], &genesisConsumer) - genesisConsumer.InitialValSet = initValPowers + genesisConsumer.Provider.InitialValSet = initValPowers genesisConsumer.Params.Enabled = true genesis[consumertypes.ModuleName] = app.AppCodec().MustMarshalJSON(&genesisConsumer) } @@ -252,7 +253,7 @@ func (b *Builder) getAppBytesAndSenders( func (b *Builder) newChain( coord *ibctesting.Coordinator, - appInit ibctesting.AppIniter, + appInit icstestingutils.AppIniter, chainID string, validators *tmtypes.ValidatorSet, signers map[string]tmtypes.PrivValidator, @@ -349,7 +350,8 @@ func (b *Builder) createProviderAndConsumer() { // Create provider coordinator.Chains[ibctesting.GetChainID(0)] = b.newChain(coordinator, icstestingutils.ProviderAppIniter, ibctesting.GetChainID(0), validators, signers) // Create consumer, using the same validators. - coordinator.Chains[ibctesting.GetChainID(1)] = b.newChain(coordinator, icstestingutils.ConsumerAppIniter, ibctesting.GetChainID(1), validators, signers) + valUpdates := testutil.ToValidatorUpdates(b.suite.T(), validators) + coordinator.Chains[ibctesting.GetChainID(1)] = b.newChain(coordinator, icstestingutils.ConsumerAppIniter(valUpdates), ibctesting.GetChainID(1), validators, signers) b.coordinator = coordinator b.valAddresses = addresses @@ -524,19 +526,20 @@ func (b *Builder) createConsumerGenesis(client *ibctmtypes.ClientState) *consume providerConsState := b.provider().LastHeader.ConsensusState() valUpdates := tmtypes.TM2PB.ValidatorUpdates(b.provider().Vals) - params := consumertypes.NewParams( + params := ccv.NewParams( true, 1000, // ignore distribution "", // ignore distribution "", // ignore distribution ccv.DefaultCCVTimeoutPeriod, - consumertypes.DefaultTransferTimeoutPeriod, - consumertypes.DefaultConsumerRedistributeFrac, - consumertypes.DefaultHistoricalEntries, + ccv.DefaultTransferTimeoutPeriod, + ccv.DefaultConsumerRedistributeFrac, + ccv.DefaultHistoricalEntries, b.initState.UnbondingC, "0", // disable soft opt-out []string{}, []string{}, + ccv.DefaultRetryDelayPeriod, ) return consumertypes.NewInitialGenesisState(client, providerConsState, valUpdates, params) } diff --git a/tests/e2e/README.md b/tests/e2e/README.md new file mode 100644 index 0000000000..4fb3e721e8 --- /dev/null +++ b/tests/e2e/README.md @@ -0,0 +1,24 @@ +## Updating the trace format and tests when adjusting the framework + +Some things in the test framework should stay consistent, in particular with respect to the trace format. +When adding or modifying actions, please follow these guidelines: +* Add a case for your action to `main.go` +* Add a case for your action to `json_utils.go/UnmarshalMapToActionType` +* Add a generator for your action to `action_rapid_test.go` and add the generator to `GetActionGen` + +If the chain state from `state.go` is modified, the `ChainStateWithProposalTypes` in `json_utils.go/MarshalJSON` should be updated. + +When adding a new proposal type: +* add a case for your proposal type to `json_utils.go/UnmarshalProposalWithType` +* add a generator for your proposal type in `state_rapid_test.go` and add it to the `GetProposalGen` function + +## Regenerating Traces + +The traces in `tracehandler_testdata` are generated by the test `trace_handlers_test.go/TestWriteExamples`. + +You can regenerate them by running `make e2e-traces` in the root of the repo. + +## Running against traces + +To run a test trace in the e2e tests, run `go run . --test-file $TRACEFILE::$TESTCONFIG`. +See `--help` for more details. diff --git a/tests/e2e/action_rapid_test.go b/tests/e2e/action_rapid_test.go new file mode 100644 index 0000000000..09d28abacf --- /dev/null +++ b/tests/e2e/action_rapid_test.go @@ -0,0 +1,508 @@ +package main + +import ( + "encoding/json" + "fmt" + "testing" + "time" + + "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/require" + "pgregory.net/rapid" +) + +// This file contains tests for serialization/deserialization of actions. +// The tests are written using the rapid testing library, which allows us to +// generate arbitrary actions and test that they can be serialized and +// deserialized without error. +// The generators for the various actions are defined in this file, and +// essentially tell rapid how to build these actions. + +func TestActionMarshalling(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + action := GetActionGen().Draw(t, "Action") + err := MarshalAndUnmarshalAction(action) + if err != nil { + t.Fatalf("error marshalling and unmarshalling action: %v", err) + } + }) +} + +func MarshalAndUnmarshalAction(action interface{}) error { + // wraps the action with a step, since it needs custom unmarshalling that is called by the step unmarshaller + step := Step{ + Action: action, + } + jsonobj, err := json.Marshal(step) + if err != nil { + return fmt.Errorf("error marshalling action inside step: %v", err) + } + + var got Step + err = json.Unmarshal(jsonobj, &got) + if err != nil { + return fmt.Errorf("error unmarshalling action inside step: %v", err) + } + + diff := cmp.Diff(step, got) + if diff != "" { + return fmt.Errorf("got (-), want (+): %v", diff) + } + + return nil +} + +// This needs to be adjusted manually when new actions are added and should +// include generators for all actions that are mentioned in main.go/runStep. +func GetActionGen() *rapid.Generator[any] { + return rapid.OneOf( + GetStartSovereignChainActionGen().AsAny(), + GetSubmitLegacyUpgradeProposalActionGen().AsAny(), + GetWaitUntilBlockActionGen().AsAny(), + GetChangeoverChainActionGen().AsAny(), + GetSendTokensActionGen().AsAny(), + GetStartChainActionGen().AsAny(), + GetSubmitTextProposalActionGen().AsAny(), + GetSubmitConsumerAdditionProposalActionGen().AsAny(), + GetSubmitConsumerRemovalProposalActionGen().AsAny(), + GetSubmitParamChangeProposalActionGen().AsAny(), + GetSubmitEquivocationProposalActionGen().AsAny(), + GetVoteGovProposalActionGen().AsAny(), + GetStartConsumerChainActionGen().AsAny(), + GetAddChainToRelayerActionGen().AsAny(), + GetAddIbcConnectionActionGen().AsAny(), + GetAddIbcChannelActionGen().AsAny(), + GetStartRelayerActionGen().AsAny(), + GetTransferChannelCompleteActionGen().AsAny(), + GetRelayPacketsActionGen().AsAny(), + GetRelayRewardPacketsToProviderActionGen().AsAny(), + GetDelegateTokensActionGen().AsAny(), + GetUnbondTokensActionGen().AsAny(), + GetRedelegateTokensActionGen().AsAny(), + GetDowntimeSlashActionGen().AsAny(), + GetUnjailValidatorActionGen().AsAny(), + GetRegisterRepresentativeActionGen().AsAny(), + GetDoublesignSlashActionGen().AsAny(), + GetAssignConsumerPubKeyActionGen().AsAny(), + GetCreateIbcClientsActionGen().AsAny(), + GetSlashMeterReplenishmentAction().AsAny(), + GetWaitTimeAction().AsAny(), + CreateCancelUnbondTokensActionGen().AsAny(), + CreateLightClientEquivocationAttackActionGen().AsAny(), + CreateLightClientAmnesiaAttackActionGen().AsAny(), + CreateLightClientLunaticAttackActionGen().AsAny(), + ) +} + +func CreateSubmitChangeRewardDenomsProposalActionGen() *rapid.Generator[submitChangeRewardDenomsProposalAction] { + return rapid.Custom(func(t *rapid.T) submitChangeRewardDenomsProposalAction { + return submitChangeRewardDenomsProposalAction{ + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Denom: rapid.String().Draw(t, "Denom"), + } + }) +} + +func CreateLightClientEquivocationAttackActionGen() *rapid.Generator[lightClientEquivocationAttackAction] { + return rapid.Custom(func(t *rapid.T) lightClientEquivocationAttackAction { + return lightClientEquivocationAttackAction{ + Validator: GetValidatorIDGen().Draw(t, "Validator"), + Chain: GetChainIDGen().Draw(t, "Chain"), + } + }) +} + +func CreateLightClientAmnesiaAttackActionGen() *rapid.Generator[lightClientAmnesiaAttackAction] { + return rapid.Custom(func(t *rapid.T) lightClientAmnesiaAttackAction { + return lightClientAmnesiaAttackAction{ + Validator: GetValidatorIDGen().Draw(t, "Validator"), + Chain: GetChainIDGen().Draw(t, "Chain"), + } + }) +} + +func CreateLightClientLunaticAttackActionGen() *rapid.Generator[lightClientLunaticAttackAction] { + return rapid.Custom(func(t *rapid.T) lightClientLunaticAttackAction { + return lightClientLunaticAttackAction{ + Validator: GetValidatorIDGen().Draw(t, "Validator"), + Chain: GetChainIDGen().Draw(t, "Chain"), + } + }) +} + +func CreateCancelUnbondTokensActionGen() *rapid.Generator[cancelUnbondTokensAction] { + return rapid.Custom(func(t *rapid.T) cancelUnbondTokensAction { + return cancelUnbondTokensAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Amount: rapid.Uint().Draw(t, "Amount"), + Delegator: GetValidatorIDGen().Draw(t, "Delegator"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + } + }) +} + +func GetCreateIbcClientsActionGen() *rapid.Generator[createIbcClientsAction] { + return rapid.Custom(func(t *rapid.T) createIbcClientsAction { + return createIbcClientsAction{ + ChainA: GetChainIDGen().Draw(t, "ChainA"), + ChainB: GetChainIDGen().Draw(t, "ChainB"), + } + }) +} + +func GetStartSovereignChainActionGen() *rapid.Generator[StartSovereignChainAction] { + return rapid.Custom(func(t *rapid.T) StartSovereignChainAction { + return StartSovereignChainAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validators: GetStartChainValidatorsGen().Draw(t, "Validators"), + GenesisChanges: rapid.String().Draw(t, "GenesisChanges"), + } + }) +} + +func GetSubmitLegacyUpgradeProposalActionGen() *rapid.Generator[LegacyUpgradeProposalAction] { + return rapid.Custom(func(t *rapid.T) LegacyUpgradeProposalAction { + return LegacyUpgradeProposalAction{ + ChainID: GetChainIDGen().Draw(t, "ChainID"), + UpgradeTitle: rapid.String().Draw(t, "UpgradeTitle"), + Proposer: GetValidatorIDGen().Draw(t, "Proposer"), + UpgradeHeight: rapid.Uint64().Draw(t, "UpgradeHeight"), + } + }) +} + +func GetWaitUntilBlockActionGen() *rapid.Generator[waitUntilBlockAction] { + return rapid.Custom(func(t *rapid.T) waitUntilBlockAction { + return waitUntilBlockAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Block: rapid.Uint().Draw(t, "Block"), + } + }) +} + +func GetChangeoverChainActionGen() *rapid.Generator[ChangeoverChainAction] { + return rapid.Custom(func(t *rapid.T) ChangeoverChainAction { + return ChangeoverChainAction{ + SovereignChain: GetChainIDGen().Draw(t, "SovereignChain"), + ProviderChain: GetChainIDGen().Draw(t, "ProviderChain"), + Validators: GetStartChainValidatorsGen().Draw(t, "Validators"), + GenesisChanges: rapid.String().Draw(t, "GenesisChanges"), + } + }) +} + +func GetSendTokensActionGen() *rapid.Generator[SendTokensAction] { + return rapid.Custom(func(t *rapid.T) SendTokensAction { + return SendTokensAction{ + Amount: rapid.Uint().Draw(t, "Amount"), + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + To: GetValidatorIDGen().Draw(t, "To"), + } + }) +} + +func GetStartChainActionGen() *rapid.Generator[StartChainAction] { + return rapid.Custom(func(t *rapid.T) StartChainAction { + return StartChainAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validators: GetStartChainValidatorsGen().Draw(t, "Validators"), + GenesisChanges: rapid.String().Draw(t, "GenesisChanges"), + SkipGentx: rapid.Bool().Draw(t, "SkipGentx"), + } + }) +} + +func GetStartChainValidatorsGen() *rapid.Generator[[]StartChainValidator] { + return rapid.Custom(func(t *rapid.T) []StartChainValidator { + return rapid.SliceOf(GetStartChainValidatorGen()).Draw(t, "StartChainValidators") + }) +} + +func GetStartChainValidatorGen() *rapid.Generator[StartChainValidator] { + return rapid.Custom(func(t *rapid.T) StartChainValidator { + return StartChainValidator{ + Id: GetValidatorIDGen().Draw(t, "Id"), + Allocation: rapid.Uint().Draw(t, "Allocation"), + Stake: rapid.Uint().Draw(t, "Stake"), + } + }) +} + +func GetSubmitTextProposalActionGen() *rapid.Generator[submitTextProposalAction] { + return rapid.Custom(func(t *rapid.T) submitTextProposalAction { + return submitTextProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Title: rapid.String().Draw(t, "Title"), + Description: rapid.String().Draw(t, "Description"), + } + }) +} + +func GetSubmitConsumerAdditionProposalActionGen() *rapid.Generator[submitConsumerAdditionProposalAction] { + return rapid.Custom(func(t *rapid.T) submitConsumerAdditionProposalAction { + return submitConsumerAdditionProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"), + SpawnTime: rapid.Uint().Draw(t, "SpawnTime"), + InitialHeight: GetHeightGen().Draw(t, "InitialHeight"), + } + }) +} + +func GetSubmitConsumerRemovalProposalActionGen() *rapid.Generator[submitConsumerRemovalProposalAction] { + return rapid.Custom(func(t *rapid.T) submitConsumerRemovalProposalAction { + return submitConsumerRemovalProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"), + StopTimeOffset: time.Duration(rapid.Int64().Draw(t, "StopTimeOffset")), + } + }) +} + +func GetSubmitParamChangeProposalActionGen() *rapid.Generator[submitParamChangeLegacyProposalAction] { + return rapid.Custom(func(t *rapid.T) submitParamChangeLegacyProposalAction { + return submitParamChangeLegacyProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Subspace: rapid.String().Draw(t, "Subspace"), + Key: rapid.String().Draw(t, "Key"), + Value: rapid.String().Draw(t, "Value"), // could make this more generic in the future, since Value takes interfaces + } + }) +} + +func GetSubmitEquivocationProposalActionGen() *rapid.Generator[submitEquivocationProposalAction] { + return rapid.Custom(func(t *rapid.T) submitEquivocationProposalAction { + return submitEquivocationProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: GetValidatorIDGen().Draw(t, "From"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Height: rapid.Int64().Draw(t, "Height"), + Time: GetTimeGen().Draw(t, "Time"), + Power: rapid.Int64().Draw(t, "Power"), + } + }) +} + +func TestMarshalAndUnmarshalTime(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + time1 := GetTimeGen().Draw(t, "time") + data, err := time1.MarshalJSON() + require.NoError(t, err) + var time2 time.Time + err = time2.UnmarshalJSON(data) + require.NoError(t, err) + require.True(t, time1.Equal(time2)) + }) +} + +func GetTimeGen() *rapid.Generator[time.Time] { + return rapid.Custom(func(t *rapid.T) time.Time { + return time.Unix(rapid.Int64Range(-5.9959e+10, 1.5779e+11).Draw(t, "unix time"), 0).UTC() + }) +} + +func GetVoteGovProposalActionGen() *rapid.Generator[voteGovProposalAction] { + return rapid.Custom(func(t *rapid.T) voteGovProposalAction { + return voteGovProposalAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + From: rapid.SliceOf(GetValidatorIDGen()).Draw(t, "From"), + Vote: rapid.SliceOf(rapid.String()).Draw(t, "Vote"), + PropNumber: rapid.Uint().Draw(t, "PropNumber"), + } + }) +} + +func GetStartConsumerChainActionGen() *rapid.Generator[startConsumerChainAction] { + return rapid.Custom(func(t *rapid.T) startConsumerChainAction { + return startConsumerChainAction{ + ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"), + ProviderChain: GetChainIDGen().Draw(t, "ProviderChain"), + Validators: GetStartChainValidatorsGen().Draw(t, "Validators"), + GenesisChanges: rapid.String().Draw(t, "GenesisChanges"), + } + }) +} + +func GetAddChainToRelayerActionGen() *rapid.Generator[addChainToRelayerAction] { + return rapid.Custom(func(t *rapid.T) addChainToRelayerAction { + return addChainToRelayerAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + } + }) +} + +func GetAddIbcConnectionActionGen() *rapid.Generator[addIbcConnectionAction] { + return rapid.Custom(func(t *rapid.T) addIbcConnectionAction { + return addIbcConnectionAction{ + ChainA: GetChainIDGen().Draw(t, "ChainA"), + ChainB: GetChainIDGen().Draw(t, "ChainB"), + ClientA: rapid.Uint().Draw(t, "ClientA"), + ClientB: rapid.Uint().Draw(t, "ClientB"), + } + }) +} + +func GetAddIbcChannelActionGen() *rapid.Generator[addIbcChannelAction] { + return rapid.Custom(func(t *rapid.T) addIbcChannelAction { + return addIbcChannelAction{ + ChainA: GetChainIDGen().Draw(t, "ChainA"), + ChainB: GetChainIDGen().Draw(t, "ChainB"), + ConnectionA: rapid.Uint().Draw(t, "ConnectionA"), + PortA: rapid.String().Draw(t, "PortA"), + PortB: rapid.String().Draw(t, "PortB"), + Order: rapid.String().Draw(t, "Order"), + } + }) +} + +func GetStartRelayerActionGen() *rapid.Generator[startRelayerAction] { + return rapid.Just(startRelayerAction{}) +} + +func GetTransferChannelCompleteActionGen() *rapid.Generator[transferChannelCompleteAction] { + return rapid.Custom(func(t *rapid.T) transferChannelCompleteAction { + return transferChannelCompleteAction{ + ChainA: GetChainIDGen().Draw(t, "ChainA"), + ChainB: GetChainIDGen().Draw(t, "ChainB"), + ConnectionA: rapid.Uint().Draw(t, "ConnectionA"), + PortA: rapid.String().Draw(t, "PortA"), + PortB: rapid.String().Draw(t, "PortB"), + Order: rapid.String().Draw(t, "Order"), + ChannelA: rapid.Uint().Draw(t, "ChannelA"), + ChannelB: rapid.Uint().Draw(t, "ChannelB"), + } + }) +} + +func GetRelayPacketsActionGen() *rapid.Generator[relayPacketsAction] { + return rapid.Custom(func(t *rapid.T) relayPacketsAction { + return relayPacketsAction{ + ChainA: GetChainIDGen().Draw(t, "Chain"), + ChainB: GetChainIDGen().Draw(t, "Chain"), + Port: rapid.String().Draw(t, "Port"), + Channel: rapid.Uint().Draw(t, "Channel"), + } + }) +} + +func GetRelayRewardPacketsToProviderActionGen() *rapid.Generator[relayRewardPacketsToProviderAction] { + return rapid.Custom(func(t *rapid.T) relayRewardPacketsToProviderAction { + return relayRewardPacketsToProviderAction{ + ConsumerChain: GetChainIDGen().Draw(t, "ConsumerChain"), + ProviderChain: GetChainIDGen().Draw(t, "ProviderChain"), + Port: rapid.String().Draw(t, "Port"), + Channel: rapid.Uint().Draw(t, "Channel"), + } + }) +} + +func GetDelegateTokensActionGen() *rapid.Generator[delegateTokensAction] { + return rapid.Custom(func(t *rapid.T) delegateTokensAction { + return delegateTokensAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Amount: rapid.Uint().Draw(t, "Amount"), + From: GetValidatorIDGen().Draw(t, "From"), + To: GetValidatorIDGen().Draw(t, "To"), + } + }) +} + +func GetUnbondTokensActionGen() *rapid.Generator[unbondTokensAction] { + return rapid.Custom(func(t *rapid.T) unbondTokensAction { + return unbondTokensAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Amount: rapid.Uint().Draw(t, "Amount"), + Sender: GetValidatorIDGen().Draw(t, "Sender"), + UnbondFrom: GetValidatorIDGen().Draw(t, "UnbondFrom"), + } + }) +} + +func GetRedelegateTokensActionGen() *rapid.Generator[redelegateTokensAction] { + return rapid.Custom(func(t *rapid.T) redelegateTokensAction { + return redelegateTokensAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Amount: rapid.Uint().Draw(t, "Amount"), + Src: GetValidatorIDGen().Draw(t, "Src"), + Dst: GetValidatorIDGen().Draw(t, "Dst"), + TxSender: GetValidatorIDGen().Draw(t, "TxSender"), + } + }) +} + +func GetDowntimeSlashActionGen() *rapid.Generator[downtimeSlashAction] { + return rapid.Custom(func(t *rapid.T) downtimeSlashAction { + return downtimeSlashAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + } + }) +} + +func GetUnjailValidatorActionGen() *rapid.Generator[unjailValidatorAction] { + return rapid.Custom(func(t *rapid.T) unjailValidatorAction { + return unjailValidatorAction{ + Validator: GetValidatorIDGen().Draw(t, "Validator"), + Provider: GetChainIDGen().Draw(t, "Provider"), + } + }) +} + +func GetRegisterRepresentativeActionGen() *rapid.Generator[registerRepresentativeAction] { + return rapid.Custom(func(t *rapid.T) registerRepresentativeAction { + return registerRepresentativeAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Representatives: rapid.SliceOf(GetValidatorIDGen()).Draw(t, "Representatives"), + Stakes: rapid.SliceOf(rapid.Uint()).Draw(t, "Stakes"), + } + }) +} + +func GetDoublesignSlashActionGen() *rapid.Generator[doublesignSlashAction] { + return rapid.Custom(func(t *rapid.T) doublesignSlashAction { + return doublesignSlashAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + } + }) +} + +func GetAssignConsumerPubKeyActionGen() *rapid.Generator[assignConsumerPubKeyAction] { + return rapid.Custom(func(t *rapid.T) assignConsumerPubKeyAction { + return assignConsumerPubKeyAction{ + Chain: GetChainIDGen().Draw(t, "Chain"), + Validator: GetValidatorIDGen().Draw(t, "Validator"), + ConsumerPubkey: rapid.String().Draw(t, "ConsumerPubkey"), + ReconfigureNode: rapid.Bool().Draw(t, "ReconfigureNode"), + ExpectError: rapid.Bool().Draw(t, "ExpectError"), + } + }) +} + +func GetSlashMeterReplenishmentAction() *rapid.Generator[slashMeterReplenishmentAction] { + return rapid.Custom(func(t *rapid.T) slashMeterReplenishmentAction { + return slashMeterReplenishmentAction{ + TargetValue: rapid.Int64().Draw(t, "TargetValue"), + Timeout: time.Duration(rapid.Int().Draw(t, "Timeout")) * time.Millisecond, + } + }) +} + +func GetWaitTimeAction() *rapid.Generator[waitTimeAction] { + return rapid.Custom(func(t *rapid.T) waitTimeAction { + return waitTimeAction{ + WaitTime: time.Duration(rapid.Int().Draw(t, "Timeout")) * time.Millisecond, + } + }) +} diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index e5ac465aa0..63070289d6 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -17,36 +17,36 @@ import ( evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" "github.com/cosmos/interchain-security/v3/x/ccv/provider/client" "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) type SendTokensAction struct { - chain chainID - from validatorID - to validatorID - amount uint + Chain ChainID + From ValidatorID + To ValidatorID + Amount uint } const done = "done!!!!!!!!" -func (tr TestRun) sendTokens( +func (tr TestConfig) sendTokens( action SendTokensAction, verbose bool, ) { - binaryName := tr.chainConfigs[action.chain].binaryName + binaryName := tr.chainConfigs[action.Chain].BinaryName //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, binaryName, "tx", "bank", "send", - tr.validatorConfigs[action.from].delAddress, - tr.validatorConfigs[action.to].delAddress, - fmt.Sprint(action.amount)+`stake`, + tr.validatorConfigs[action.From].DelAddress, + tr.validatorConfigs[action.To].DelAddress, + fmt.Sprint(action.Amount)+`stake`, - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, action.from), - `--node`, tr.getValidatorNode(action.chain, action.from), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, action.From), + `--node`, tr.getValidatorNode(action.Chain, action.From), `--keyring-backend`, `test`, `-y`, ) @@ -59,28 +59,28 @@ func (tr TestRun) sendTokens( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(action.chain, 2, 30*time.Second) + tr.waitBlocks(action.Chain, 2, 30*time.Second) } type StartChainAction struct { - chain chainID - validators []StartChainValidator + Chain ChainID + Validators []StartChainValidator // Genesis changes specific to this action, appended to genesis changes defined in chain config - genesisChanges string - skipGentx bool + GenesisChanges string + SkipGentx bool } type StartChainValidator struct { - id validatorID - allocation uint - stake uint + Id ValidatorID + Allocation uint + Stake uint } -func (tr *TestRun) startChain( +func (tr *TestConfig) startChain( action StartChainAction, verbose bool, ) { - chainConfig := tr.chainConfigs[action.chain] + chainConfig := tr.chainConfigs[action.Chain] type jsonValAttrs struct { Mnemonic string `json:"mnemonic"` Allocation string `json:"allocation"` @@ -96,20 +96,20 @@ func (tr *TestRun) startChain( } var validators []jsonValAttrs - for _, val := range action.validators { + for _, val := range action.Validators { validators = append(validators, jsonValAttrs{ - Mnemonic: tr.validatorConfigs[val.id].mnemonic, - NodeKey: tr.validatorConfigs[val.id].nodeKey, - ValId: fmt.Sprint(val.id), - PrivValidatorKey: tr.validatorConfigs[val.id].privValidatorKey, - Allocation: fmt.Sprint(val.allocation) + "stake", - Stake: fmt.Sprint(val.stake) + "stake", - IpSuffix: tr.validatorConfigs[val.id].ipSuffix, - - ConsumerMnemonic: tr.validatorConfigs[val.id].consumerMnemonic, - ConsumerPrivValidatorKey: tr.validatorConfigs[val.id].consumerPrivValidatorKey, + Mnemonic: tr.validatorConfigs[val.Id].Mnemonic, + NodeKey: tr.validatorConfigs[val.Id].NodeKey, + ValId: fmt.Sprint(val.Id), + PrivValidatorKey: tr.validatorConfigs[val.Id].PrivValidatorKey, + Allocation: fmt.Sprint(val.Allocation) + "stake", + Stake: fmt.Sprint(val.Stake) + "stake", + IpSuffix: tr.validatorConfigs[val.Id].IpSuffix, + + ConsumerMnemonic: tr.validatorConfigs[val.Id].ConsumerMnemonic, + ConsumerPrivValidatorKey: tr.validatorConfigs[val.Id].ConsumerPrivValidatorKey, // if true node will be started with consumer key for each consumer chain - StartWithConsumerKey: tr.validatorConfigs[val.id].useConsumerKey, + StartWithConsumerKey: tr.validatorConfigs[val.Id].UseConsumerKey, }) } @@ -120,10 +120,10 @@ func (tr *TestRun) startChain( // Concat genesis changes defined in chain config, with any custom genesis changes for this chain instantiation var genesisChanges string - if action.genesisChanges != "" { - genesisChanges = chainConfig.genesisChanges + " | " + action.genesisChanges + if action.GenesisChanges != "" { + genesisChanges = chainConfig.GenesisChanges + " | " + action.GenesisChanges } else { - genesisChanges = chainConfig.genesisChanges + genesisChanges = chainConfig.GenesisChanges } var cometmockArg string @@ -134,10 +134,10 @@ func (tr *TestRun) startChain( } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "/bin/bash", - "/testnet-scripts/start-chain.sh", chainConfig.binaryName, string(vals), - string(chainConfig.chainId), chainConfig.ipPrefix, genesisChanges, - fmt.Sprint(action.skipGentx), + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "/bin/bash", + "/testnet-scripts/start-chain.sh", chainConfig.BinaryName, string(vals), + string(chainConfig.ChainId), chainConfig.IpPrefix, genesisChanges, + fmt.Sprint(action.SkipGentx), // override config/config.toml for each node on chain // usually timeout_commit and peer_gossip_sleep_duration are changed to vary the test run duration // lower timeout_commit means the blocks are produced faster making the test run shorter @@ -172,42 +172,42 @@ func (tr *TestRun) startChain( } tr.addChainToRelayer(addChainToRelayerAction{ - chain: action.chain, - validator: action.validators[0].id, + Chain: action.Chain, + Validator: action.Validators[0].Id, }, verbose) // store the fact that we started the chain - tr.runningChains[action.chain] = true - fmt.Println("Started chain", action.chain) + tr.runningChains[action.Chain] = true + fmt.Println("Started chain", action.Chain) if tr.timeOffset != 0 { // advance time for this chain so that it is in sync with the rest of the network - tr.AdvanceTimeForChain(action.chain, tr.timeOffset) + tr.AdvanceTimeForChain(action.Chain, tr.timeOffset) } } type submitTextProposalAction struct { - chain chainID - from validatorID - deposit uint - title string - description string + Chain ChainID + From ValidatorID + Deposit uint + Title string + Description string } -func (tr TestRun) submitTextProposal( +func (tr TestConfig) submitTextProposal( action submitTextProposalAction, verbose bool, ) { // TEXT PROPOSAL //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, "tx", "gov", "submit-legacy-proposal", - `--title`, action.title, - `--description`, action.description, - `--deposit`, fmt.Sprint(action.deposit)+`stake`, - `--from`, `validator`+fmt.Sprint(action.from), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, action.from), - `--node`, tr.getValidatorNode(action.chain, action.from), + `--title`, action.Title, + `--description`, action.Description, + `--deposit`, fmt.Sprint(action.Deposit)+`stake`, + `--from`, `validator`+fmt.Sprint(action.From), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, action.From), + `--node`, tr.getValidatorNode(action.Chain, action.From), `--keyring-backend`, `test`, `-y`, ).CombinedOutput() @@ -216,31 +216,31 @@ func (tr TestRun) submitTextProposal( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(action.chain, 1, 10*time.Second) + tr.waitBlocks(action.Chain, 1, 10*time.Second) } type submitConsumerAdditionProposalAction struct { - preCCV bool - chain chainID - from validatorID - deposit uint - consumerChain chainID - spawnTime uint - initialHeight clienttypes.Height - distributionChannel string + PreCCV bool + Chain ChainID + From ValidatorID + Deposit uint + ConsumerChain ChainID + SpawnTime uint + InitialHeight clienttypes.Height + DistributionChannel string } -func (tr TestRun) submitConsumerAdditionProposal( +func (tr TestConfig) submitConsumerAdditionProposal( action submitConsumerAdditionProposalAction, verbose bool, ) { - spawnTime := tr.containerConfig.now.Add(time.Duration(action.spawnTime) * time.Millisecond) - params := consumertypes.DefaultParams() + spawnTime := tr.containerConfig.Now.Add(time.Duration(action.SpawnTime) * time.Millisecond) + params := ccvtypes.DefaultParams() prop := client.ConsumerAdditionProposalJSON{ Title: "Propose the addition of a new chain", Summary: "Gonna be a great chain", - ChainId: string(tr.chainConfigs[action.consumerChain].chainId), - InitialHeight: action.initialHeight, + ChainId: string(tr.chainConfigs[action.ConsumerChain].ChainId), + InitialHeight: action.InitialHeight, GenesisHash: []byte("gen_hash"), BinaryHash: []byte("bin_hash"), SpawnTime: spawnTime, @@ -250,8 +250,8 @@ func (tr TestRun) submitConsumerAdditionProposal( CcvTimeoutPeriod: params.CcvTimeoutPeriod, TransferTimeoutPeriod: params.TransferTimeoutPeriod, UnbondingPeriod: params.UnbondingPeriod, - Deposit: fmt.Sprint(action.deposit) + `stake`, - DistributionTransmissionChannel: action.distributionChannel, + Deposit: fmt.Sprint(action.Deposit) + `stake`, + DistributionTransmissionChannel: action.DistributionChannel, } bz, err := json.Marshal(prop) @@ -265,7 +265,7 @@ func (tr TestRun) submitConsumerAdditionProposal( } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/temp-proposal.json")).CombinedOutput() if err != nil { @@ -274,13 +274,13 @@ func (tr TestRun) submitConsumerAdditionProposal( //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. // CONSUMER ADDITION PROPOSAL - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, "tx", "gov", "submit-legacy-proposal", "consumer-addition", "/temp-proposal.json", - `--from`, `validator`+fmt.Sprint(action.from), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, action.from), + `--from`, `validator`+fmt.Sprint(action.From), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, action.From), `--gas`, `900000`, - `--node`, tr.getValidatorNode(action.chain, action.from), + `--node`, tr.getValidatorNode(action.Chain, action.From), `--keyring-backend`, `test`, `-y`, ).CombinedOutput() @@ -290,28 +290,28 @@ func (tr TestRun) submitConsumerAdditionProposal( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(chainID("provi"), 2, 10*time.Second) + tr.waitBlocks(ChainID("provi"), 2, 10*time.Second) } type submitConsumerRemovalProposalAction struct { - chain chainID - from validatorID - deposit uint - consumerChain chainID - stopTimeOffset time.Duration // offset from time.Now() + Chain ChainID + From ValidatorID + Deposit uint + ConsumerChain ChainID + StopTimeOffset time.Duration // offset from time.Now() } -func (tr TestRun) submitConsumerRemovalProposal( +func (tr TestConfig) submitConsumerRemovalProposal( action submitConsumerRemovalProposalAction, verbose bool, ) { - stopTime := tr.containerConfig.now.Add(action.stopTimeOffset) + stopTime := tr.containerConfig.Now.Add(action.StopTimeOffset) prop := client.ConsumerRemovalProposalJSON{ - Title: fmt.Sprintf("Stop the %v chain", action.consumerChain), + Title: fmt.Sprintf("Stop the %v chain", action.ConsumerChain), Summary: "It was a great chain", - ChainId: string(tr.chainConfigs[action.consumerChain].chainId), + ChainId: string(tr.chainConfigs[action.ConsumerChain].ChainId), StopTime: stopTime, - Deposit: fmt.Sprint(action.deposit) + `stake`, + Deposit: fmt.Sprint(action.Deposit) + `stake`, } bz, err := json.Marshal(prop) @@ -325,7 +325,7 @@ func (tr TestRun) submitConsumerRemovalProposal( } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/temp-proposal.json")).CombinedOutput() if err != nil { @@ -333,13 +333,14 @@ func (tr TestRun) submitConsumerRemovalProposal( } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - // CONSUMER REMOVAL PROPOSAL - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, - "tx", "gov", "submit-legacy-proposal", "consumer-removal", "/temp-proposal.json", - `--from`, `validator`+fmt.Sprint(action.from), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, action.from), - `--node`, tr.getValidatorNode(action.chain, action.from), + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, + + "tx", "gov", "submit-legacy-proposal", "consumer-removal", + "/temp-proposal.json", + `--from`, `validator`+fmt.Sprint(action.From), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, action.From), + `--node`, tr.getValidatorNode(action.Chain, action.From), `--gas`, "900000", `--keyring-backend`, `test`, `-y`, @@ -350,16 +351,16 @@ func (tr TestRun) submitConsumerRemovalProposal( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(chainID("provi"), 2, 20*time.Second) + tr.waitBlocks(ChainID("provi"), 2, 20*time.Second) } type submitParamChangeLegacyProposalAction struct { - chain chainID - from validatorID - deposit uint - subspace string - key string - value interface{} + Chain ChainID + From ValidatorID + Deposit uint + Subspace string + Key string + Value interface{} } type paramChangeProposalJSON struct { @@ -376,7 +377,7 @@ type paramChangeJSON struct { Value interface{} `json:"value"` } -func (tr TestRun) submitParamChangeProposal( +func (tr TestConfig) submitParamChangeProposal( action submitParamChangeLegacyProposalAction, verbose bool, ) { @@ -384,8 +385,8 @@ func (tr TestRun) submitParamChangeProposal( Title: "Legacy Param change", Summary: "Changing legacy module params", Description: "Changing legacy module params", - Changes: []paramChangeJSON{{Subspace: action.subspace, Key: action.key, Value: action.value}}, - Deposit: fmt.Sprint(action.deposit) + `stake`, + Changes: []paramChangeJSON{{Subspace: action.Subspace, Key: action.Key, Value: action.Value}}, + Deposit: fmt.Sprint(action.Deposit) + `stake`, } bz, err := json.Marshal(prop) @@ -399,7 +400,7 @@ func (tr TestRun) submitParamChangeProposal( } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/params-proposal.json")).CombinedOutput() if err != nil { @@ -407,13 +408,15 @@ func (tr TestRun) submitParamChangeProposal( } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - // PARAM CHANGE PROPOSAL // we should be able to make these all one command which will be cool - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + // PARAM CHANGE PROPOSAL + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, + "tx", "gov", "submit-legacy-proposal", "param-change", "/params-proposal.json", - `--from`, `validator`+fmt.Sprint(action.from), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, action.from), - `--node`, tr.getValidatorNode(action.chain, action.from), + + `--from`, `validator`+fmt.Sprint(action.From), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, action.From), + `--node`, tr.getValidatorNode(action.Chain, action.From), `--gas`, "900000", `--keyring-backend`, `test`, `-y`, @@ -425,38 +428,38 @@ func (tr TestRun) submitParamChangeProposal( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(action.chain, 2, 60*time.Second) + tr.waitBlocks(action.Chain, 2, 60*time.Second) } type submitEquivocationProposalAction struct { - chain chainID - height int64 - time time.Time - power int64 - validator validatorID - deposit uint - from validatorID + Chain ChainID + Height int64 + Time time.Time + Power int64 + Validator ValidatorID + Deposit uint + From ValidatorID } -func (tr TestRun) submitEquivocationProposal(action submitEquivocationProposalAction, verbose bool) { - val := tr.validatorConfigs[action.validator] - providerChain := tr.chainConfigs[chainID("provi")] +func (tr TestConfig) submitEquivocationProposal(action submitEquivocationProposalAction, verbose bool) { + val := tr.validatorConfigs[action.Validator] + providerChain := tr.chainConfigs[ChainID("provi")] prop := client.EquivocationProposalJSON{ Summary: "Validator equivocation!", EquivocationProposal: types.EquivocationProposal{ Title: "Validator equivocation!", - Description: fmt.Sprintf("Validator: %s has committed an equivocation infraction on chainID: %s", action.validator, action.chain), + Description: fmt.Sprintf("Validator: %s has committed an equivocation infraction on ChainID: %s", action.Validator, action.Chain), Equivocations: []*evidencetypes.Equivocation{ { - Height: action.height, - Time: action.time, - Power: action.power, - ConsensusAddress: val.valconsAddress, + Height: action.Height, + Time: action.Time, + Power: action.Power, + ConsensusAddress: val.ValconsAddress, }, }, }, - Deposit: fmt.Sprint(action.deposit) + `stake`, + Deposit: fmt.Sprint(action.Deposit) + `stake`, } bz, err := json.Marshal(prop) @@ -470,7 +473,7 @@ func (tr TestRun) submitEquivocationProposal(action submitEquivocationProposalAc } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/equivocation-proposal.json")).CombinedOutput() if err != nil { @@ -479,12 +482,14 @@ func (tr TestRun) submitEquivocationProposal(action submitEquivocationProposalAc //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. // EQUIVOCATION PROPOSAL - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, providerChain.binaryName, + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, providerChain.BinaryName, + "tx", "gov", "submit-legacy-proposal", "equivocation", "/equivocation-proposal.json", - `--from`, `validator`+fmt.Sprint(action.from), - `--chain-id`, string(providerChain.chainId), - `--home`, tr.getValidatorHome(providerChain.chainId, action.from), - `--node`, tr.getValidatorNode(providerChain.chainId, action.from), + + `--from`, `validator`+fmt.Sprint(action.From), + `--chain-id`, string(providerChain.ChainId), + `--home`, tr.getValidatorHome(providerChain.ChainId, action.From), + `--node`, tr.getValidatorNode(providerChain.ChainId, action.From), `--gas`, "9000000", `--keyring-backend`, `test`, `-y`, @@ -495,36 +500,36 @@ func (tr TestRun) submitEquivocationProposal(action submitEquivocationProposalAc } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(chainID("provi"), 2, 30*time.Second) + tr.waitBlocks(ChainID("provi"), 2, 30*time.Second) } type voteGovProposalAction struct { - chain chainID - from []validatorID - vote []string - propNumber uint + Chain ChainID + From []ValidatorID + Vote []string + PropNumber uint } -func (tr *TestRun) voteGovProposal( +func (tr *TestConfig) voteGovProposal( action voteGovProposalAction, verbose bool, ) { var wg sync.WaitGroup - for i, val := range action.from { + for i, val := range action.From { wg.Add(1) - vote := action.vote[i] - go func(val validatorID, vote string) { + vote := action.Vote[i] + go func(val ValidatorID, vote string) { defer wg.Done() //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, "tx", "gov", "vote", - fmt.Sprint(action.propNumber), vote, + fmt.Sprint(action.PropNumber), vote, `--from`, `validator`+fmt.Sprint(val), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, val), - `--node`, tr.getValidatorNode(action.chain, val), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, val), + `--node`, tr.getValidatorNode(action.Chain, val), `--keyring-backend`, `test`, `--gas`, "900000", `-y`, @@ -537,28 +542,28 @@ func (tr *TestRun) voteGovProposal( wg.Wait() // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(action.chain, 1, 10*time.Second) - tr.WaitTime(time.Duration(tr.chainConfigs[action.chain].votingWaitTime) * time.Second) + tr.waitBlocks(action.Chain, 1, 10*time.Second) + tr.WaitTime(time.Duration(tr.chainConfigs[action.Chain].VotingWaitTime) * time.Second) } type startConsumerChainAction struct { - consumerChain chainID - providerChain chainID - validators []StartChainValidator - genesisChanges string + ConsumerChain ChainID + ProviderChain ChainID + Validators []StartChainValidator + GenesisChanges string } -func (tr *TestRun) startConsumerChain( +func (tr *TestConfig) startConsumerChain( action startConsumerChainAction, verbose bool, ) { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.providerChain].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.ProviderChain].BinaryName, "query", "provider", "consumer-genesis", - string(tr.chainConfigs[action.consumerChain].chainId), + string(tr.chainConfigs[action.ConsumerChain].ChainId), - `--node`, tr.getQueryNode(action.providerChain), + `--node`, tr.getQueryNode(action.ProviderChain), `-o`, `json`, ) @@ -572,39 +577,39 @@ func (tr *TestRun) startConsumerChain( } consumerGenesis := ".app_state.ccvconsumer = " + string(bz) - consumerGenesisChanges := tr.chainConfigs[action.consumerChain].genesisChanges + consumerGenesisChanges := tr.chainConfigs[action.ConsumerChain].GenesisChanges if consumerGenesisChanges != "" { - consumerGenesis = consumerGenesis + " | " + consumerGenesisChanges + " | " + action.genesisChanges + consumerGenesis = consumerGenesis + " | " + consumerGenesisChanges + " | " + action.GenesisChanges } tr.startChain(StartChainAction{ - chain: action.consumerChain, - validators: action.validators, - genesisChanges: consumerGenesis, - skipGentx: true, + Chain: action.ConsumerChain, + Validators: action.Validators, + GenesisChanges: consumerGenesis, + SkipGentx: true, }, verbose) } type ChangeoverChainAction struct { - sovereignChain chainID - providerChain chainID - validators []StartChainValidator - genesisChanges string + SovereignChain ChainID + ProviderChain ChainID + Validators []StartChainValidator + GenesisChanges string } -func (tr TestRun) changeoverChain( +func (tr TestConfig) changeoverChain( action ChangeoverChainAction, verbose bool, ) { // sleep until the consumer chain genesis is ready on consumer time.Sleep(5 * time.Second) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.providerChain].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.ProviderChain].BinaryName, "query", "provider", "consumer-genesis", - string(tr.chainConfigs[action.sovereignChain].chainId), + string(tr.chainConfigs[action.SovereignChain].ChainId), - `--node`, tr.getQueryNode(action.providerChain), + `--node`, tr.getQueryNode(action.ProviderChain), `-o`, `json`, ) @@ -618,22 +623,22 @@ func (tr TestRun) changeoverChain( } consumerGenesis := ".app_state.ccvconsumer = " + string(bz) - consumerGenesisChanges := tr.chainConfigs[action.sovereignChain].genesisChanges + consumerGenesisChanges := tr.chainConfigs[action.SovereignChain].GenesisChanges if consumerGenesisChanges != "" { - consumerGenesis = consumerGenesis + " | " + consumerGenesisChanges + " | " + action.genesisChanges + consumerGenesis = consumerGenesis + " | " + consumerGenesisChanges + " | " + action.GenesisChanges } tr.startChangeover(ChangeoverChainAction{ - validators: action.validators, - genesisChanges: consumerGenesis, + Validators: action.Validators, + GenesisChanges: consumerGenesis, }, verbose) } -func (tr TestRun) startChangeover( +func (tr TestConfig) startChangeover( action ChangeoverChainAction, verbose bool, ) { - chainConfig := tr.chainConfigs[chainID("sover")] + chainConfig := tr.chainConfigs[ChainID("sover")] type jsonValAttrs struct { Mnemonic string `json:"mnemonic"` Allocation string `json:"allocation"` @@ -649,20 +654,20 @@ func (tr TestRun) startChangeover( } var validators []jsonValAttrs - for _, val := range action.validators { + for _, val := range action.Validators { validators = append(validators, jsonValAttrs{ - Mnemonic: tr.validatorConfigs[val.id].mnemonic, - NodeKey: tr.validatorConfigs[val.id].nodeKey, - ValId: fmt.Sprint(val.id), - PrivValidatorKey: tr.validatorConfigs[val.id].privValidatorKey, - Allocation: fmt.Sprint(val.allocation) + "stake", - Stake: fmt.Sprint(val.stake) + "stake", - IpSuffix: tr.validatorConfigs[val.id].ipSuffix, - - ConsumerMnemonic: tr.validatorConfigs[val.id].consumerMnemonic, - ConsumerPrivValidatorKey: tr.validatorConfigs[val.id].consumerPrivValidatorKey, + Mnemonic: tr.validatorConfigs[val.Id].Mnemonic, + NodeKey: tr.validatorConfigs[val.Id].NodeKey, + ValId: fmt.Sprint(val.Id), + PrivValidatorKey: tr.validatorConfigs[val.Id].PrivValidatorKey, + Allocation: fmt.Sprint(val.Allocation) + "stake", + Stake: fmt.Sprint(val.Stake) + "stake", + IpSuffix: tr.validatorConfigs[val.Id].IpSuffix, + + ConsumerMnemonic: tr.validatorConfigs[val.Id].ConsumerMnemonic, + ConsumerPrivValidatorKey: tr.validatorConfigs[val.Id].ConsumerPrivValidatorKey, // if true node will be started with consumer key for each consumer chain - StartWithConsumerKey: tr.validatorConfigs[val.id].useConsumerKey, + StartWithConsumerKey: tr.validatorConfigs[val.Id].UseConsumerKey, }) } @@ -673,16 +678,16 @@ func (tr TestRun) startChangeover( // Concat genesis changes defined in chain config, with any custom genesis changes for this chain instantiation var genesisChanges string - if action.genesisChanges != "" { - genesisChanges = chainConfig.genesisChanges + " | " + action.genesisChanges + if action.GenesisChanges != "" { + genesisChanges = chainConfig.GenesisChanges + " | " + action.GenesisChanges } else { - genesisChanges = chainConfig.genesisChanges + genesisChanges = chainConfig.GenesisChanges } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "/bin/bash", - "/testnet-scripts/start-changeover.sh", chainConfig.upgradeBinary, string(vals), - "sover", chainConfig.ipPrefix, genesisChanges, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "/bin/bash", + "/testnet-scripts/start-changeover.sh", chainConfig.UpgradeBinary, string(vals), + "sover", chainConfig.IpPrefix, genesisChanges, tr.tendermintConfigOverride, ) @@ -713,8 +718,8 @@ func (tr TestRun) startChangeover( } type addChainToRelayerAction struct { - chain chainID - validator validatorID + Chain ChainID + Validator ValidatorID } const hermesChainConfigTemplate = ` @@ -764,7 +769,7 @@ const gorelayerChainConfigTemplate = ` } }` -func (tr TestRun) addChainToRelayer( +func (tr TestConfig) addChainToRelayer( action addChainToRelayerAction, verbose bool, ) { @@ -775,50 +780,50 @@ func (tr TestRun) addChainToRelayer( } } -func (tr TestRun) addChainToGorelayer( +func (tr TestConfig) addChainToGorelayer( action addChainToRelayerAction, verbose bool, ) { - queryNodeIP := tr.getQueryNodeIP(action.chain) - chainId := tr.chainConfigs[action.chain].chainId + queryNodeIP := tr.getQueryNodeIP(action.Chain) + ChainId := tr.chainConfigs[action.Chain].ChainId rpcAddr := "http://" + queryNodeIP + ":26658" chainConfig := fmt.Sprintf(gorelayerChainConfigTemplate, - chainId, + ChainId, rpcAddr, ) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", "config", "init").CombinedOutput() + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "rly", "config", "init").CombinedOutput() if err != nil && !strings.Contains(string(bz), "config already exists") { log.Fatal(err, "\n", string(bz)) } - chainConfigFileName := fmt.Sprintf("/root/%s_config.json", chainId) + chainConfigFileName := fmt.Sprintf("/root/%s_config.json", ChainId) bashCommand := fmt.Sprintf(`echo '%s' >> %s`, chainConfig, chainConfigFileName) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, "bash", "-c", + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, "bash", "-c", bashCommand).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - addChainCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", "chains", "add", "--file", chainConfigFileName, string(chainId)) + addChainCommand := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "rly", "chains", "add", "--file", chainConfigFileName, string(ChainId)) executeCommand(addChainCommand, "add chain") //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - keyRestoreCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", "keys", "restore", string(chainId), "default", tr.validatorConfigs[action.validator].mnemonic) + keyRestoreCommand := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "rly", "keys", "restore", string(ChainId), "default", tr.validatorConfigs[action.Validator].Mnemonic) executeCommand(keyRestoreCommand, "restore keys") } -func (tr TestRun) addChainToHermes( +func (tr TestConfig) addChainToHermes( action addChainToRelayerAction, verbose bool, ) { - queryNodeIP := tr.getQueryNodeIP(action.chain) - chainId := tr.chainConfigs[action.chain].chainId + queryNodeIP := tr.getQueryNodeIP(action.Chain) + ChainId := tr.chainConfigs[action.Chain].ChainId keyName := "query" rpcAddr := "http://" + queryNodeIP + ":26658" grpcAddr := "tcp://" + queryNodeIP + ":9091" @@ -826,7 +831,7 @@ func (tr TestRun) addChainToHermes( chainConfig := fmt.Sprintf(hermesChainConfigTemplate, grpcAddr, - chainId, + ChainId, keyName, rpcAddr, wsAddr, @@ -836,7 +841,7 @@ func (tr TestRun) addChainToHermes( bashCommand := fmt.Sprintf(`echo '%s' >> %s`, chainConfig, "/root/.hermes/config.toml") //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, "bash", "-c", + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "bash", "-c", bashCommand, ).CombinedOutput() if err != nil { @@ -844,9 +849,9 @@ func (tr TestRun) addChainToHermes( } // Save mnemonic to file within container - saveMnemonicCommand := fmt.Sprintf(`echo '%s' > %s`, tr.validatorConfigs[action.validator].mnemonic, "/root/.hermes/mnemonic.txt") + saveMnemonicCommand := fmt.Sprintf(`echo '%s' > %s`, tr.validatorConfigs[action.Validator].Mnemonic, "/root/.hermes/mnemonic.txt") //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, "bash", "-c", + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, "bash", "-c", saveMnemonicCommand, ).CombinedOutput() if err != nil { @@ -854,9 +859,9 @@ func (tr TestRun) addChainToHermes( } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err = exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, "hermes", "keys", "add", - "--chain", string(tr.chainConfigs[action.chain].chainId), + "--chain", string(tr.chainConfigs[action.Chain].ChainId), "--mnemonic-file", "/root/.hermes/mnemonic.txt", ).CombinedOutput() @@ -886,13 +891,13 @@ const gorelayerPathConfigTemplate = `{ ` type addIbcConnectionAction struct { - chainA chainID - chainB chainID - clientA uint - clientB uint + ChainA ChainID + ChainB ChainID + ClientA uint + ClientB uint } -func (tr TestRun) addIbcConnection( +func (tr TestConfig) addIbcConnection( action addIbcConnectionAction, verbose bool, ) { @@ -903,27 +908,27 @@ func (tr TestRun) addIbcConnection( } } -func (tr TestRun) addIbcConnectionGorelayer( +func (tr TestConfig) addIbcConnectionGorelayer( action addIbcConnectionAction, verbose bool, ) { - pathName := tr.GetPathNameForGorelayer(action.chainA, action.chainB) + pathName := tr.GetPathNameForGorelayer(action.ChainA, action.ChainB) - pathConfig := fmt.Sprintf(gorelayerPathConfigTemplate, action.chainA, action.clientA, action.chainB, action.clientB) + pathConfig := fmt.Sprintf(gorelayerPathConfigTemplate, action.ChainA, action.ClientA, action.ChainB, action.ClientB) pathConfigFileName := fmt.Sprintf("/root/%s_config.json", pathName) bashCommand := fmt.Sprintf(`echo '%s' >> %s`, pathConfig, pathConfigFileName) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - pathConfigCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "bash", "-c", + pathConfigCommand := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "bash", "-c", bashCommand) executeCommand(pathConfigCommand, "add path config") //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - newPathCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", + newPathCommand := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "rly", "paths", "add", - string(tr.chainConfigs[action.chainA].chainId), - string(tr.chainConfigs[action.chainB].chainId), + string(tr.chainConfigs[action.ChainA].ChainId), + string(tr.chainConfigs[action.ChainB].ChainId), pathName, "--file", pathConfigFileName, ) @@ -931,45 +936,45 @@ func (tr TestRun) addIbcConnectionGorelayer( executeCommand(newPathCommand, "new path") //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - newClientsCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", + newClientsCommand := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "rly", "transact", "clients", pathName, ) executeCommand(newClientsCommand, "new clients") - tr.waitBlocks(action.chainA, 1, 10*time.Second) - tr.waitBlocks(action.chainB, 1, 10*time.Second) + tr.waitBlocks(action.ChainA, 1, 10*time.Second) + tr.waitBlocks(action.ChainB, 1, 10*time.Second) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - newConnectionCommand := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", + newConnectionCommand := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "rly", "transact", "connection", pathName, ) executeCommand(newConnectionCommand, "new connection") - tr.waitBlocks(action.chainA, 1, 10*time.Second) - tr.waitBlocks(action.chainB, 1, 10*time.Second) + tr.waitBlocks(action.ChainA, 1, 10*time.Second) + tr.waitBlocks(action.ChainB, 1, 10*time.Second) } type createIbcClientsAction struct { - chainA chainID - chainB chainID + ChainA ChainID + ChainB ChainID } // if clients are not provided hermes will first // create new clients and then a new connection // otherwise, it would use client provided as CLI argument (-a-client) -func (tr TestRun) createIbcClientsHermes( +func (tr TestConfig) createIbcClientsHermes( action createIbcClientsAction, verbose bool, ) { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "hermes", "create", "connection", - "--a-chain", string(tr.chainConfigs[action.chainA].chainId), - "--b-chain", string(tr.chainConfigs[action.chainB].chainId), + "--a-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--b-chain", string(tr.chainConfigs[action.ChainB].ChainId), ) cmdReader, err := cmd.StdoutPipe() @@ -998,16 +1003,16 @@ func (tr TestRun) createIbcClientsHermes( } } -func (tr TestRun) addIbcConnectionHermes( +func (tr TestConfig) addIbcConnectionHermes( action addIbcConnectionAction, verbose bool, ) { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "hermes", "create", "connection", - "--a-chain", string(tr.chainConfigs[action.chainA].chainId), - "--a-client", "07-tendermint-"+fmt.Sprint(action.clientA), - "--b-client", "07-tendermint-"+fmt.Sprint(action.clientB), + "--a-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--a-client", "07-tendermint-"+fmt.Sprint(action.ClientA), + "--b-client", "07-tendermint-"+fmt.Sprint(action.ClientB), ) cmdReader, err := cmd.StdoutPipe() @@ -1037,18 +1042,18 @@ func (tr TestRun) addIbcConnectionHermes( } type addIbcChannelAction struct { - chainA chainID - chainB chainID - connectionA uint - portA string - portB string - order string - version string + ChainA ChainID + ChainB ChainID + ConnectionA uint + PortA string + PortB string + Order string + Version string } type startRelayerAction struct{} -func (tr TestRun) startRelayer( +func (tr TestConfig) startRelayer( action startRelayerAction, verbose bool, ) { @@ -1059,13 +1064,13 @@ func (tr TestRun) startRelayer( } } -func (tr TestRun) startGorelayer( +func (tr TestConfig) startGorelayer( action startRelayerAction, verbose bool, ) { // gorelayer start is running in detached mode //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", "-d", tr.containerConfig.instanceName, "rly", + cmd := exec.Command("docker", "exec", "-d", tr.containerConfig.InstanceName, "rly", "start", ) @@ -1078,13 +1083,13 @@ func (tr TestRun) startGorelayer( } } -func (tr TestRun) startHermes( +func (tr TestConfig) startHermes( action startRelayerAction, verbose bool, ) { // hermes start is running in detached mode //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", "-d", tr.containerConfig.instanceName, "hermes", + cmd := exec.Command("docker", "exec", "-d", tr.containerConfig.InstanceName, "hermes", "start", ) @@ -1097,7 +1102,7 @@ func (tr TestRun) startHermes( } } -func (tr TestRun) addIbcChannel( +func (tr TestConfig) addIbcChannel( action addIbcChannelAction, verbose bool, ) { @@ -1108,44 +1113,44 @@ func (tr TestRun) addIbcChannel( } } -func (tr TestRun) addIbcChannelGorelayer( +func (tr TestConfig) addIbcChannelGorelayer( action addIbcChannelAction, verbose bool, ) { - pathName := tr.GetPathNameForGorelayer(action.chainA, action.chainB) + pathName := tr.GetPathNameForGorelayer(action.ChainA, action.ChainB) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "rly", "transact", "channel", pathName, - "--src-port", action.portA, - "--dst-port", action.portB, - "--version", tr.containerConfig.ccvVersion, - "--order", action.order, + "--src-port", action.PortA, + "--dst-port", action.PortB, + "--version", tr.containerConfig.CcvVersion, + "--order", action.Order, "--debug", ) executeCommand(cmd, "addChannel") } -func (tr TestRun) addIbcChannelHermes( +func (tr TestConfig) addIbcChannelHermes( action addIbcChannelAction, verbose bool, ) { // if version is not specified, use the default version when creating ccv connections // otherwise, use the provided version schema (usually it is ICS20-1 for IBC transfer) - chanVersion := action.version + chanVersion := action.Version if chanVersion == "" { - chanVersion = tr.containerConfig.ccvVersion + chanVersion = tr.containerConfig.CcvVersion } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "hermes", "create", "channel", - "--a-chain", string(tr.chainConfigs[action.chainA].chainId), - "--a-connection", "connection-"+fmt.Sprint(action.connectionA), - "--a-port", action.portA, - "--b-port", action.portB, + "--a-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--a-connection", "connection-"+fmt.Sprint(action.ConnectionA), + "--a-port", action.PortA, + "--b-port", action.PortB, "--channel-version", chanVersion, - "--order", action.order, + "--order", action.Order, ) if verbose { @@ -1179,17 +1184,17 @@ func (tr TestRun) addIbcChannelHermes( } type transferChannelCompleteAction struct { - chainA chainID - chainB chainID - connectionA uint - portA string - portB string - order string - channelA uint - channelB uint + ChainA ChainID + ChainB ChainID + ConnectionA uint + PortA string + PortB string + Order string + ChannelA uint + ChannelB uint } -func (tr TestRun) transferChannelComplete( +func (tr TestConfig) transferChannelComplete( action transferChannelCompleteAction, verbose bool, ) { @@ -1198,41 +1203,41 @@ func (tr TestRun) transferChannelComplete( } //#nosec G204 -- Bypass linter warning for spawning subprocess with chanOpenTryCmd arguments. - chanOpenTryCmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", + chanOpenTryCmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "hermes", "tx", "chan-open-try", - "--dst-chain", string(tr.chainConfigs[action.chainB].chainId), - "--src-chain", string(tr.chainConfigs[action.chainA].chainId), - "--dst-connection", "connection-"+fmt.Sprint(action.connectionA), - "--dst-port", action.portB, - "--src-port", action.portA, - "--src-channel", "channel-"+fmt.Sprint(action.channelA), + "--dst-chain", string(tr.chainConfigs[action.ChainB].ChainId), + "--src-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--dst-connection", "connection-"+fmt.Sprint(action.ConnectionA), + "--dst-port", action.PortB, + "--src-port", action.PortA, + "--src-channel", "channel-"+fmt.Sprint(action.ChannelA), ) executeCommand(chanOpenTryCmd, "transferChanOpenTry") //#nosec G204 -- Bypass linter warning for spawning subprocess with chanOpenAckCmd arguments. - chanOpenAckCmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", + chanOpenAckCmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "hermes", "tx", "chan-open-ack", - "--dst-chain", string(tr.chainConfigs[action.chainA].chainId), - "--src-chain", string(tr.chainConfigs[action.chainB].chainId), - "--dst-connection", "connection-"+fmt.Sprint(action.connectionA), - "--dst-port", action.portA, - "--src-port", action.portB, - "--dst-channel", "channel-"+fmt.Sprint(action.channelA), - "--src-channel", "channel-"+fmt.Sprint(action.channelB), + "--dst-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--src-chain", string(tr.chainConfigs[action.ChainB].ChainId), + "--dst-connection", "connection-"+fmt.Sprint(action.ConnectionA), + "--dst-port", action.PortA, + "--src-port", action.PortB, + "--dst-channel", "channel-"+fmt.Sprint(action.ChannelA), + "--src-channel", "channel-"+fmt.Sprint(action.ChannelB), ) executeCommand(chanOpenAckCmd, "transferChanOpenAck") //#nosec G204 -- Bypass linter warning for spawning subprocess with chanOpenConfirmCmd arguments. - chanOpenConfirmCmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", + chanOpenConfirmCmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "hermes", "tx", "chan-open-confirm", - "--dst-chain", string(tr.chainConfigs[action.chainB].chainId), - "--src-chain", string(tr.chainConfigs[action.chainA].chainId), - "--dst-connection", "connection-"+fmt.Sprint(action.connectionA), - "--dst-port", action.portB, - "--src-port", action.portA, - "--dst-channel", "channel-"+fmt.Sprint(action.channelB), - "--src-channel", "channel-"+fmt.Sprint(action.channelA), + "--dst-chain", string(tr.chainConfigs[action.ChainB].ChainId), + "--src-chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--dst-connection", "connection-"+fmt.Sprint(action.ConnectionA), + "--dst-port", action.PortB, + "--src-port", action.PortA, + "--dst-channel", "channel-"+fmt.Sprint(action.ChannelB), + "--src-channel", "channel-"+fmt.Sprint(action.ChannelA), ) executeCommand(chanOpenConfirmCmd, "transferChanOpenConfirm") } @@ -1271,13 +1276,13 @@ func executeCommand(cmd *exec.Cmd, cmdName string) { } type relayPacketsAction struct { - chainA chainID - chainB chainID - port string - channel uint + ChainA ChainID + ChainB ChainID + Port string + Channel uint } -func (tr TestRun) relayPackets( +func (tr TestConfig) relayPackets( action relayPacketsAction, verbose bool, ) { @@ -1288,17 +1293,17 @@ func (tr TestRun) relayPackets( } } -func (tr TestRun) relayPacketsGorelayer( +func (tr TestConfig) relayPacketsGorelayer( action relayPacketsAction, verbose bool, ) { - pathName := tr.GetPathNameForGorelayer(action.chainA, action.chainB) + pathName := tr.GetPathNameForGorelayer(action.ChainA, action.ChainB) // rly transact relay-packets [path-name] --channel [channel-id] //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "rly", "transact", "flush", + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "rly", "transact", "flush", pathName, - "channel-"+fmt.Sprint(action.channel), + "channel-"+fmt.Sprint(action.Channel), ) if verbose { log.Println("relayPackets cmd:", cmd.String()) @@ -1308,19 +1313,20 @@ func (tr TestRun) relayPacketsGorelayer( log.Fatal(err, "\n", string(bz)) } - tr.waitBlocks(action.chainA, 1, 30*time.Second) + tr.waitBlocks(action.ChainA, 1, 30*time.Second) + tr.waitBlocks(action.ChainB, 1, 30*time.Second) } -func (tr TestRun) relayPacketsHermes( +func (tr TestConfig) relayPacketsHermes( action relayPacketsAction, verbose bool, ) { // hermes clear packets ibc0 transfer channel-13 //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "hermes", "clear", "packets", - "--chain", string(tr.chainConfigs[action.chainA].chainId), - "--port", action.port, - "--channel", "channel-"+fmt.Sprint(action.channel), + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "hermes", "clear", "packets", + "--chain", string(tr.chainConfigs[action.ChainA].ChainId), + "--port", action.Port, + "--channel", "channel-"+fmt.Sprint(action.Channel), ) if verbose { log.Println("relayPackets cmd:", cmd.String()) @@ -1331,57 +1337,58 @@ func (tr TestRun) relayPacketsHermes( log.Fatal(err, "\n", string(bz)) } - tr.waitBlocks(action.chainA, 1, 30*time.Second) + tr.waitBlocks(action.ChainA, 1, 30*time.Second) + tr.waitBlocks(action.ChainB, 1, 30*time.Second) } type relayRewardPacketsToProviderAction struct { - consumerChain chainID - providerChain chainID - port string - channel uint + ConsumerChain ChainID + ProviderChain ChainID + Port string + Channel uint } -func (tr TestRun) relayRewardPacketsToProvider( +func (tr TestConfig) relayRewardPacketsToProvider( action relayRewardPacketsToProviderAction, verbose bool, ) { - blockPerDistribution, _ := strconv.ParseUint(strings.Trim(tr.getParam(action.consumerChain, Param{Subspace: "ccvconsumer", Key: "BlocksPerDistributionTransmission"}), "\""), 10, 64) - currentBlock := uint64(tr.getBlockHeight(action.consumerChain)) + blockPerDistribution, _ := strconv.ParseUint(strings.Trim(tr.getParam(action.ConsumerChain, Param{Subspace: "ccvconsumer", Key: "BlocksPerDistributionTransmission"}), "\""), 10, 64) + currentBlock := uint64(tr.getBlockHeight(action.ConsumerChain)) if currentBlock <= blockPerDistribution { - tr.waitBlocks(action.consumerChain, uint(blockPerDistribution-currentBlock+1), 60*time.Second) + tr.waitBlocks(action.ConsumerChain, uint(blockPerDistribution-currentBlock+1), 60*time.Second) } - tr.relayPackets(relayPacketsAction{chainA: action.consumerChain, chainB: action.providerChain, port: action.port, channel: action.channel}, verbose) - tr.waitBlocks(action.providerChain, 1, 10*time.Second) + tr.relayPackets(relayPacketsAction{ChainA: action.ConsumerChain, ChainB: action.ProviderChain, Port: action.Port, Channel: action.Channel}, verbose) + tr.waitBlocks(action.ProviderChain, 1, 10*time.Second) } type delegateTokensAction struct { - chain chainID - from validatorID - to validatorID - amount uint + Chain ChainID + From ValidatorID + To ValidatorID + Amount uint } -func (tr TestRun) delegateTokens( +func (tr TestConfig) delegateTokens( action delegateTokensAction, verbose bool, ) { - toValCfg := tr.validatorConfigs[action.to] - delegateAddr := toValCfg.valoperAddress - if action.chain != chainID("provi") && toValCfg.useConsumerKey { - delegateAddr = toValCfg.consumerValoperAddress + toValCfg := tr.validatorConfigs[action.To] + delegateAddr := toValCfg.ValoperAddress + if action.Chain != ChainID("provi") && toValCfg.UseConsumerKey { + delegateAddr = toValCfg.ConsumerValoperAddress } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, "tx", "staking", "delegate", delegateAddr, - fmt.Sprint(action.amount)+`stake`, + fmt.Sprint(action.Amount)+`stake`, - `--from`, `validator`+fmt.Sprint(action.from), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, action.from), - `--node`, tr.getValidatorNode(action.chain, action.from), + `--from`, `validator`+fmt.Sprint(action.From), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, action.From), + `--node`, tr.getValidatorNode(action.Chain, action.From), `--keyring-backend`, `test`, `-y`, ) @@ -1396,36 +1403,36 @@ func (tr TestRun) delegateTokens( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(action.chain, 2, 10*time.Second) + tr.waitBlocks(action.Chain, 2, 10*time.Second) } type unbondTokensAction struct { - chain chainID - sender validatorID - unbondFrom validatorID - amount uint + Chain ChainID + Sender ValidatorID + UnbondFrom ValidatorID + Amount uint } -func (tr TestRun) unbondTokens( +func (tr TestConfig) unbondTokens( action unbondTokensAction, verbose bool, ) { - unbondFrom := tr.validatorConfigs[action.unbondFrom].valoperAddress - if tr.validatorConfigs[action.unbondFrom].useConsumerKey { - unbondFrom = tr.validatorConfigs[action.unbondFrom].consumerValoperAddress + unbondFrom := tr.validatorConfigs[action.UnbondFrom].ValoperAddress + if tr.validatorConfigs[action.UnbondFrom].UseConsumerKey { + unbondFrom = tr.validatorConfigs[action.UnbondFrom].ConsumerValoperAddress } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, "tx", "staking", "unbond", unbondFrom, - fmt.Sprint(action.amount)+`stake`, + fmt.Sprint(action.Amount)+`stake`, - `--from`, `validator`+fmt.Sprint(action.sender), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, action.sender), - `--node`, tr.getValidatorNode(action.chain, action.sender), + `--from`, `validator`+fmt.Sprint(action.Sender), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, action.Sender), + `--node`, tr.getValidatorNode(action.Chain, action.Sender), `--gas`, "900000", `--keyring-backend`, `test`, `-y`, @@ -1441,33 +1448,33 @@ func (tr TestRun) unbondTokens( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(action.chain, 2, 20*time.Second) + tr.waitBlocks(action.Chain, 2, 20*time.Second) } type cancelUnbondTokensAction struct { - chain chainID - delegator validatorID - validator validatorID - amount uint + Chain ChainID + Delegator ValidatorID + Validator ValidatorID + Amount uint } -func (tr TestRun) cancelUnbondTokens( +func (tr TestConfig) cancelUnbondTokens( action cancelUnbondTokensAction, verbose bool, ) { - validator := tr.validatorConfigs[action.validator].valoperAddress - if tr.validatorConfigs[action.validator].useConsumerKey { - validator = tr.validatorConfigs[action.validator].consumerValoperAddress + validator := tr.validatorConfigs[action.Validator].ValoperAddress + if tr.validatorConfigs[action.Validator].UseConsumerKey { + validator = tr.validatorConfigs[action.Validator].ConsumerValoperAddress } // get creation-height from state //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, "q", "staking", "unbonding-delegation", - tr.validatorConfigs[action.delegator].delAddress, + tr.validatorConfigs[action.Delegator].DelAddress, validator, - `--home`, tr.getValidatorHome(action.chain, action.delegator), - `--node`, tr.getValidatorNode(action.chain, action.delegator), + `--home`, tr.getValidatorHome(action.Chain, action.Delegator), + `--node`, tr.getValidatorNode(action.Chain, action.Delegator), `-o`, `json`, ) if verbose { @@ -1484,15 +1491,15 @@ func (tr TestRun) cancelUnbondTokens( } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd = exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + cmd = exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, "tx", "staking", "cancel-unbond", validator, - fmt.Sprint(action.amount)+`stake`, + fmt.Sprint(action.Amount)+`stake`, fmt.Sprint(creationHeight), - `--from`, `validator`+fmt.Sprint(action.delegator), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, action.delegator), - `--node`, tr.getValidatorNode(action.chain, action.delegator), + `--from`, `validator`+fmt.Sprint(action.Delegator), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, action.Delegator), + `--node`, tr.getValidatorNode(action.Chain, action.Delegator), `--gas`, "900000", `--keyring-backend`, `test`, `-o`, `json`, @@ -1509,43 +1516,43 @@ func (tr TestRun) cancelUnbondTokens( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(action.chain, 2, 20*time.Second) + tr.waitBlocks(action.Chain, 2, 20*time.Second) } type redelegateTokensAction struct { - chain chainID - src validatorID - dst validatorID - txSender validatorID - amount uint + Chain ChainID + Src ValidatorID + Dst ValidatorID + TxSender ValidatorID + Amount uint } -func (tr TestRun) redelegateTokens(action redelegateTokensAction, verbose bool) { - srcCfg := tr.validatorConfigs[action.src] - dstCfg := tr.validatorConfigs[action.dst] +func (tr TestConfig) redelegateTokens(action redelegateTokensAction, verbose bool) { + srcCfg := tr.validatorConfigs[action.Src] + dstCfg := tr.validatorConfigs[action.Dst] - redelegateSrc := srcCfg.valoperAddress - if action.chain != chainID("provi") && srcCfg.useConsumerKey { - redelegateSrc = srcCfg.consumerValoperAddress + redelegateSrc := srcCfg.ValoperAddress + if action.Chain != ChainID("provi") && srcCfg.UseConsumerKey { + redelegateSrc = srcCfg.ConsumerValoperAddress } - redelegateDst := dstCfg.valoperAddress - if action.chain != chainID("provi") && dstCfg.useConsumerKey { - redelegateDst = dstCfg.consumerValoperAddress + redelegateDst := dstCfg.ValoperAddress + if action.Chain != ChainID("provi") && dstCfg.UseConsumerKey { + redelegateDst = dstCfg.ConsumerValoperAddress } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. cmd := exec.Command("docker", "exec", - tr.containerConfig.instanceName, - tr.chainConfigs[action.chain].binaryName, + tr.containerConfig.InstanceName, + tr.chainConfigs[action.Chain].BinaryName, "tx", "staking", "redelegate", redelegateSrc, redelegateDst, - fmt.Sprint(action.amount)+`stake`, - `--from`, `validator`+fmt.Sprint(action.txSender), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, action.txSender), - `--node`, tr.getValidatorNode(action.chain, action.txSender), + fmt.Sprint(action.Amount)+`stake`, + `--from`, `validator`+fmt.Sprint(action.TxSender), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, action.TxSender), + `--node`, tr.getValidatorNode(action.Chain, action.TxSender), // Need to manually set gas limit past default (200000), since redelegate has a lot of operations `--gas`, "900000", `--keyring-backend`, `test`, @@ -1562,18 +1569,18 @@ func (tr TestRun) redelegateTokens(action redelegateTokensAction, verbose bool) } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(action.chain, 2, 10*time.Second) + tr.waitBlocks(action.Chain, 2, 10*time.Second) } type downtimeSlashAction struct { - chain chainID - validator validatorID + Chain ChainID + Validator ValidatorID } // takes a string representation of the private key like // `{"address":"DF090A4880B54CD57B2A79E64D9E969BD7514B09","pub_key":{"type":"tendermint/PubKeyEd25519","value":"ujY14AgopV907IYgPAk/5x8c9267S4fQf89nyeCPTes="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"TRJgf7lkTjs/sj43pyweEOanyV7H7fhnVivOi0A4yjW6NjXgCCilX3TshiA8CT/nHxz3brtLh9B/z2fJ4I9N6w=="}}` // and returns the value of the "address" field -func (tr TestRun) getValidatorKeyAddressFromString(keystring string) string { +func (tr TestConfig) getValidatorKeyAddressFromString(keystring string) string { var key struct { Address string `json:"address"` } @@ -1584,17 +1591,17 @@ func (tr TestRun) getValidatorKeyAddressFromString(keystring string) string { return key.Address } -func (tr TestRun) invokeDowntimeSlash(action downtimeSlashAction, verbose bool) { +func (tr TestConfig) invokeDowntimeSlash(action downtimeSlashAction, verbose bool) { // Bring validator down - tr.setValidatorDowntime(action.chain, action.validator, true, verbose) + tr.setValidatorDowntime(action.Chain, action.Validator, true, verbose) // Wait appropriate amount of blocks for validator to be slashed - tr.waitBlocks(action.chain, 10, 3*time.Minute) + tr.waitBlocks(action.Chain, 10, 3*time.Minute) // Bring validator back up - tr.setValidatorDowntime(action.chain, action.validator, false, verbose) + tr.setValidatorDowntime(action.Chain, action.Validator, false, verbose) } // Sets validator downtime by setting the virtual ethernet interface of a node to "up" or "down" -func (tr TestRun) setValidatorDowntime(chain chainID, validator validatorID, down, verbose bool) { +func (tr TestConfig) setValidatorDowntime(chain ChainID, validator ValidatorID, down, verbose bool) { var lastArg string if down { lastArg = "down" @@ -1604,10 +1611,10 @@ func (tr TestRun) setValidatorDowntime(chain chainID, validator validatorID, dow if tr.useCometmock { // send set_signing_status either to down or up for validator - validatorAddress := tr.GetValidatorAddress(chain, validator) + validatorPrivateKeyAddress := tr.GetValidatorPrivateKeyAddress(chain, validator) method := "set_signing_status" - params := fmt.Sprintf(`{"private_key_address":"%s","status":"%s"}`, validatorAddress, lastArg) + params := fmt.Sprintf(`{"private_key_address":"%s","status":"%s"}`, validatorPrivateKeyAddress, lastArg) address := tr.getQueryNodeRPCAddress(chain) tr.curlJsonRPCRequest(method, params, address) @@ -1619,7 +1626,7 @@ func (tr TestRun) setValidatorDowntime(chain chainID, validator validatorID, dow cmd := exec.Command( "docker", "exec", - tr.containerConfig.instanceName, + tr.containerConfig.InstanceName, "ip", "link", "set", @@ -1637,42 +1644,42 @@ func (tr TestRun) setValidatorDowntime(chain chainID, validator validatorID, dow } } -func (tr TestRun) GetValidatorAddress(chain chainID, validator validatorID) string { - var validatorAddress string - if chain == chainID("provi") { - validatorAddress = tr.getValidatorKeyAddressFromString(tr.validatorConfigs[validator].privValidatorKey) +func (tr TestConfig) GetValidatorPrivateKeyAddress(chain ChainID, validator ValidatorID) string { + var validatorPrivateKeyAddress string + if chain == ChainID("provi") { + validatorPrivateKeyAddress = tr.getValidatorKeyAddressFromString(tr.validatorConfigs[validator].PrivValidatorKey) } else { var valAddressString string - if tr.validatorConfigs[validator].useConsumerKey { - valAddressString = tr.validatorConfigs[validator].consumerPrivValidatorKey + if tr.validatorConfigs[validator].UseConsumerKey { + valAddressString = tr.validatorConfigs[validator].ConsumerPrivValidatorKey } else { - valAddressString = tr.validatorConfigs[validator].privValidatorKey + valAddressString = tr.validatorConfigs[validator].PrivValidatorKey } - validatorAddress = tr.getValidatorKeyAddressFromString(valAddressString) + validatorPrivateKeyAddress = tr.getValidatorKeyAddressFromString(valAddressString) } - return validatorAddress + return validatorPrivateKeyAddress } type unjailValidatorAction struct { - provider chainID - validator validatorID + Provider ChainID + Validator ValidatorID } // Sends an unjail transaction to the provider chain -func (tr TestRun) unjailValidator(action unjailValidatorAction, verbose bool) { +func (tr TestConfig) unjailValidator(action unjailValidatorAction, verbose bool) { // wait until downtime_jail_duration has elapsed, to make sure the validator can be unjailed tr.WaitTime(61 * time.Second) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. cmd := exec.Command("docker", "exec", - tr.containerConfig.instanceName, - tr.chainConfigs[action.provider].binaryName, + tr.containerConfig.InstanceName, + tr.chainConfigs[action.Provider].BinaryName, "tx", "slashing", "unjail", // Validator is sender here - `--from`, `validator`+fmt.Sprint(action.validator), - `--chain-id`, string(tr.chainConfigs[action.provider].chainId), - `--home`, tr.getValidatorHome(action.provider, action.validator), - `--node`, tr.getValidatorNode(action.provider, action.validator), + `--from`, `validator`+fmt.Sprint(action.Validator), + `--chain-id`, string(tr.chainConfigs[action.Provider].ChainId), + `--home`, tr.getValidatorHome(action.Provider, action.Validator), + `--node`, tr.getValidatorNode(action.Provider, action.Validator), `--gas`, "900000", `--keyring-backend`, `test`, `-y`, @@ -1689,30 +1696,30 @@ func (tr TestRun) unjailValidator(action unjailValidatorAction, verbose bool) { // wait for 1 blocks to make sure that tx got included // in a block and packets committed before proceeding - tr.waitBlocks(action.provider, 2, time.Minute) + tr.waitBlocks(action.Provider, 2, time.Minute) } type registerRepresentativeAction struct { - chain chainID - representatives []validatorID - stakes []uint + Chain ChainID + Representatives []ValidatorID + Stakes []uint } -func (tr TestRun) registerRepresentative( +func (tr TestConfig) registerRepresentative( action registerRepresentativeAction, verbose bool, ) { var wg sync.WaitGroup - for i, val := range action.representatives { + for i, val := range action.Representatives { wg.Add(1) - stake := action.stakes[i] - go func(val validatorID, stake uint) { + stake := action.Stakes[i] + go func(val ValidatorID, stake uint) { defer wg.Done() //#nosec G204 -- Bypass linter warning for spawning subprocess with pubKeycmd arguments. - pubKeycmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + pubKeycmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, "tendermint", "show-validator", - `--home`, tr.getValidatorHome(action.chain, val), + `--home`, tr.getValidatorHome(action.Chain, val), ) bzPubKey, err := pubKeycmd.CombinedOutput() @@ -1721,7 +1728,7 @@ func (tr TestRun) registerRepresentative( } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[action.Chain].BinaryName, "tx", "staking", "create-validator", `--amount`, fmt.Sprint(stake)+"stake", `--pubkey`, string(bzPubKey), @@ -1731,9 +1738,9 @@ func (tr TestRun) registerRepresentative( `--commission-max-change-rate`, "0.01", `--min-self-delegation`, "1", `--from`, `validator`+fmt.Sprint(val), - `--chain-id`, string(tr.chainConfigs[action.chain].chainId), - `--home`, tr.getValidatorHome(action.chain, val), - `--node`, tr.getValidatorNode(action.chain, val), + `--chain-id`, string(tr.chainConfigs[action.Chain].ChainId), + `--home`, tr.getValidatorHome(action.Chain, val), + `--node`, tr.getValidatorNode(action.Chain, val), `--keyring-backend`, `test`, `-y`, ).CombinedOutput() @@ -1742,42 +1749,70 @@ func (tr TestRun) registerRepresentative( } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(action.chain, 1, 10*time.Second) + tr.waitBlocks(action.Chain, 1, 10*time.Second) }(val, stake) } wg.Wait() } -type registerConsumerRewardDenomAction struct { - chain chainID - from validatorID - denom string +type submitChangeRewardDenomsProposalAction struct { + Denom string + Deposit uint + From ValidatorID } -func (tr TestRun) registerConsumerRewardDenom(action registerConsumerRewardDenomAction, verbose bool) { +func (tr TestConfig) submitChangeRewardDenomsProposal(action submitChangeRewardDenomsProposalAction, verbose bool) { + providerChain := tr.chainConfigs[ChainID("provi")] + + prop := client.ChangeRewardDenomsProposalJSON{ + Summary: "Change reward denoms", + ChangeRewardDenomsProposal: types.ChangeRewardDenomsProposal{ + Title: "Change reward denoms", + Description: "Change reward denoms", + DenomsToAdd: []string{action.Denom}, + DenomsToRemove: []string{"stake"}, + }, + Deposit: fmt.Sprint(action.Deposit) + `stake`, + } + + bz, err := json.Marshal(prop) + if err != nil { + log.Fatal(err) + } + + jsonStr := string(bz) + if strings.Contains(jsonStr, "'") { + log.Fatal("prop json contains single quote") + } + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName, - "tx", "provider", "register-consumer-reward-denom", action.denom, + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, + "/bin/bash", "-c", fmt.Sprintf(`echo '%s' > %s`, jsonStr, "/change-reward-denoms-proposal.json")).CombinedOutput() + + if err != nil { + log.Fatal(err, "\n", string(bz)) + } - `--from`, `validator`+fmt.Sprint(action.from), - `--chain-id`, string(action.chain), - `--home`, tr.getValidatorHome(action.chain, action.from), - `--node`, tr.getValidatorNode(action.chain, action.from), + //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. + // CHANGE REWARDS DENOM PROPOSAL + bz, err = exec.Command("docker", "exec", tr.containerConfig.InstanceName, providerChain.BinaryName, + "tx", "gov", "submit-legacy-proposal", "change-reward-denoms", "/change-reward-denoms-proposal.json", + `--from`, `validator`+fmt.Sprint(action.From), + `--chain-id`, string(providerChain.ChainId), + `--home`, tr.getValidatorHome(providerChain.ChainId, action.From), + `--node`, tr.getValidatorNode(providerChain.ChainId, action.From), `--gas`, "9000000", `--keyring-backend`, `test`, `-y`, ).CombinedOutput() - if verbose { - fmt.Println("redelegate cmd:", string(bz)) - } - if err != nil { log.Fatal(err, "\n", string(bz)) } - tr.waitBlocks(action.chain, 2, 10*time.Second) + // wait for inclusion in a block -> '--broadcast-mode block' is deprecated + tr.waitBlocks(ChainID("provi"), 2, 30*time.Second) } // Creates an additional node on selected chain @@ -1791,52 +1826,127 @@ func (tr TestRun) registerConsumerRewardDenom(action registerConsumerRewardDenom // - start the new node // Double sign should be registered within couple blocks. type doublesignSlashAction struct { - // start another node for this validator - validator validatorID - chain chainID + // start another node for this Validator + Validator ValidatorID + Chain ChainID } -func (tr TestRun) invokeDoublesignSlash( +func (tr TestConfig) invokeDoublesignSlash( action doublesignSlashAction, verbose bool, ) { if !tr.useCometmock { - chainConfig := tr.chainConfigs[action.chain] + chainConfig := tr.chainConfigs[action.Chain] //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, "/bin/bash", - "/testnet-scripts/cause-doublesign.sh", chainConfig.binaryName, string(action.validator), - string(chainConfig.chainId), chainConfig.ipPrefix).CombinedOutput() + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "/bin/bash", + "/testnet-scripts/cause-doublesign.sh", chainConfig.BinaryName, string(action.Validator), + string(chainConfig.ChainId), chainConfig.IpPrefix).CombinedOutput() if err != nil { log.Fatal(err, "\n", string(bz)) } tr.waitBlocks("provi", 10, 2*time.Minute) } else { // tr.useCometMock - validatorAddress := tr.GetValidatorAddress(action.chain, action.validator) + validatorPrivateKeyAddress := tr.GetValidatorPrivateKeyAddress(action.Chain, action.Validator) method := "cause_double_sign" - params := fmt.Sprintf(`{"private_key_address":"%s"}`, validatorAddress) + params := fmt.Sprintf(`{"private_key_address":"%s"}`, validatorPrivateKeyAddress) - address := tr.getQueryNodeRPCAddress(action.chain) + address := tr.getQueryNodeRPCAddress(action.Chain) tr.curlJsonRPCRequest(method, params, address) - tr.waitBlocks(action.chain, 1, 10*time.Second) + tr.waitBlocks(action.Chain, 1, 10*time.Second) return } } +// Cause light client attack evidence for a certain validator to appear on the given chain. +// The evidence will look like the validator equivocated to a light client. +// See https://github.com/cometbft/cometbft/tree/main/spec/light-client/accountability +// for more information about light client attacks. +type lightClientEquivocationAttackAction struct { + Validator ValidatorID + Chain ChainID +} + +func (tr TestConfig) lightClientEquivocationAttack( + action lightClientEquivocationAttackAction, + verbose bool, +) { + tr.lightClientAttack(action.Validator, action.Chain, LightClientEquivocationAttack) +} + +// Cause light client attack evidence for a certain validator to appear on the given chain. +// The evidence will look like the validator tried to perform an amnesia attack. +// See https://github.com/cometbft/cometbft/tree/main/spec/light-client/accountability +// for more information about light client attacks. +type lightClientAmnesiaAttackAction struct { + Validator ValidatorID + Chain ChainID +} + +func (tr TestConfig) lightClientAmnesiaAttack( + action lightClientAmnesiaAttackAction, + verbose bool, +) { + tr.lightClientAttack(action.Validator, action.Chain, LightClientAmnesiaAttack) +} + +// Cause light client attack evidence for a certain validator to appear on the given chain. +// The evidence will look like the validator tried to perform a lunatic attack. +// See https://github.com/cometbft/cometbft/tree/main/spec/light-client/accountability +// for more information about light client attacks. +type lightClientLunaticAttackAction struct { + Validator ValidatorID + Chain ChainID +} + +func (tr TestConfig) lightClientLunaticAttack( + action lightClientLunaticAttackAction, + verbose bool, +) { + tr.lightClientAttack(action.Validator, action.Chain, LightClientLunaticAttack) +} + +type LightClientAttackType string + +const ( + LightClientEquivocationAttack LightClientAttackType = "Equivocation" + LightClientAmnesiaAttack LightClientAttackType = "Amnesia" + LightClientLunaticAttack LightClientAttackType = "Lunatic" +) + +func (tr TestConfig) lightClientAttack( + validator ValidatorID, + chain ChainID, + attackType LightClientAttackType, +) { + if !tr.useCometmock { + log.Fatal("light client attack is only supported with CometMock") + } + validatorPrivateKeyAddress := tr.GetValidatorPrivateKeyAddress(chain, validator) + + method := "cause_light_client_attack" + params := fmt.Sprintf(`{"private_key_address":"%s", "misbehaviour_type": "%s"}`, validatorPrivateKeyAddress, attackType) + + address := tr.getQueryNodeRPCAddress(chain) + + tr.curlJsonRPCRequest(method, params, address) + tr.waitBlocks(chain, 1, 10*time.Second) +} + type assignConsumerPubKeyAction struct { - chain chainID - validator validatorID - consumerPubkey string - // reconfigureNode will change keys the node uses and restart - reconfigureNode bool + Chain ChainID + Validator ValidatorID + ConsumerPubkey string + // ReconfigureNode will change keys the node uses and restart + ReconfigureNode bool // executing the action should raise an error - expectError bool - expectedError string + ExpectError bool + ExpectedError string } -func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbose bool) { - valCfg := tr.validatorConfigs[action.validator] +func (tr TestConfig) assignConsumerPubKey(action assignConsumerPubKeyAction, verbose bool) { + valCfg := tr.validatorConfigs[action.Validator] // Note: to get error response reported back from this command '--gas auto' needs to be set. gas := "auto" @@ -1846,19 +1956,19 @@ func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbos } assignKey := fmt.Sprintf( `%s tx provider assign-consensus-key %s '%s' --from validator%s --chain-id %s --home %s --node %s --gas %s --keyring-backend test -y -o json`, - tr.chainConfigs[chainID("provi")].binaryName, - string(tr.chainConfigs[action.chain].chainId), - action.consumerPubkey, - action.validator, - tr.chainConfigs[chainID("provi")].chainId, - tr.getValidatorHome(chainID("provi"), action.validator), - tr.getValidatorNode(chainID("provi"), action.validator), + tr.chainConfigs[ChainID("provi")].BinaryName, + string(tr.chainConfigs[action.Chain].ChainId), + action.ConsumerPubkey, + action.Validator, + tr.chainConfigs[ChainID("provi")].ChainId, + tr.getValidatorHome(ChainID("provi"), action.Validator), + tr.getValidatorNode(ChainID("provi"), action.Validator), gas, ) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. cmd := exec.Command("docker", "exec", - tr.containerConfig.instanceName, + tr.containerConfig.InstanceName, "/bin/bash", "-c", assignKey, ) @@ -1868,13 +1978,13 @@ func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbos } bz, err := cmd.CombinedOutput() - if err != nil && !action.expectError { + if err != nil && !action.ExpectError { log.Fatalf("unexpected error during key assignment - output: %s, err: %s", string(bz), err) } - if action.expectError && !tr.useCometmock { // error report ony works with --gas auto, which does not work with CometMock, so ignore - if err == nil || !strings.Contains(string(bz), action.expectedError) { - log.Fatalf("expected error not raised: expected: '%s', got '%s'", action.expectedError, (bz)) + if action.ExpectError && !tr.useCometmock { // error report ony works with --gas auto, which does not work with CometMock, so ignore + if err == nil || !strings.Contains(string(bz), action.ExpectedError) { + log.Fatalf("expected error not raised: expected: '%s', got '%s'", action.ExpectedError, (bz)) } if verbose { @@ -1884,14 +1994,14 @@ func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbos // node was started with provider key // we swap the nodes's keys for consumer keys and restart it - if action.reconfigureNode { + if action.ReconfigureNode { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - configureNodeCmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "/bin/bash", - "/testnet-scripts/reconfigure-node.sh", tr.chainConfigs[action.chain].binaryName, - string(action.validator), string(action.chain), - tr.chainConfigs[action.chain].ipPrefix, valCfg.ipSuffix, - valCfg.consumerMnemonic, valCfg.consumerPrivValidatorKey, - valCfg.consumerNodeKey, + configureNodeCmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "/bin/bash", + "/testnet-scripts/reconfigure-node.sh", tr.chainConfigs[action.Chain].BinaryName, + string(action.Validator), string(action.Chain), + tr.chainConfigs[action.Chain].IpPrefix, valCfg.IpSuffix, + valCfg.ConsumerMnemonic, valCfg.ConsumerPrivValidatorKey, + valCfg.ConsumerNodeKey, ) if verbose { @@ -1927,64 +2037,66 @@ func (tr TestRun) assignConsumerPubKey(action assignConsumerPubKeyAction, verbos // make the validator use consumer key // @POfftermatt I am currently using this for downtime slashing with cometmock // (I need to find the currently used validator key address)Í - valCfg.useConsumerKey = true - tr.validatorConfigs[action.validator] = valCfg + valCfg.UseConsumerKey = true + tr.validatorConfigs[action.Validator] = valCfg } // wait for inclusion in a block -> '--broadcast-mode block' is deprecated - tr.waitBlocks(chainID("provi"), 2, 30*time.Second) + tr.waitBlocks(ChainID("provi"), 2, 30*time.Second) } -// slashThrottleDequeue polls slash queue sizes until nextQueueSize is achieved -type slashThrottleDequeue struct { - chain chainID - currentQueueSize int - nextQueueSize int +// slashMeterReplenishmentAction polls the slash meter on provider until value is achieved +type slashMeterReplenishmentAction struct { + TargetValue int64 // panic if timeout is exceeded - timeout time.Duration + Timeout time.Duration } -func (tr TestRun) waitForSlashThrottleDequeue( - action slashThrottleDequeue, +func (tr TestConfig) waitForSlashMeterReplenishment( + action slashMeterReplenishmentAction, verbose bool, ) { - timeout := time.Now().Add(action.timeout) - initialGlobalQueueSize := int(tr.getGlobalSlashQueueSize()) + timeout := time.Now().Add(action.Timeout) + initialSlashMeter := tr.getSlashMeter() - if initialGlobalQueueSize != action.currentQueueSize { - panic(fmt.Sprintf("wrong initial queue size: %d - expected global queue: %d\n", initialGlobalQueueSize, action.currentQueueSize)) + if initialSlashMeter >= 0 { + panic(fmt.Sprintf("No need to wait for slash meter replenishment, current value: %d", initialSlashMeter)) } + for { - globalQueueSize := int(tr.getGlobalSlashQueueSize()) - chainQueueSize := int(tr.getConsumerChainPacketQueueSize(action.chain)) + slashMeter := tr.getSlashMeter() if verbose { - fmt.Printf("waiting for packed queue size to reach: %d - current: %d\n", action.nextQueueSize, globalQueueSize) + fmt.Printf("waiting for slash meter to be replenished, current value: %d\n", slashMeter) } - // check if global queue size is equal to chain queue size - if globalQueueSize == chainQueueSize && globalQueueSize == action.nextQueueSize { //nolint:gocritic // this is the comparison that we want here. + // check if meter has reached target value + if slashMeter >= action.TargetValue { break } if time.Now().After(timeout) { - panic(fmt.Sprintf("\n\n\nwaitForSlashThrottleDequeuemethod has timed out after: %s\n\n", action.timeout)) + panic(fmt.Sprintf("\n\nwaitForSlashMeterReplenishment has timed out after: %s\n\n", action.Timeout)) } - time.Sleep(500 * time.Millisecond) + tr.WaitTime(5 * time.Second) } - // wair for 2 blocks to be created - // allowing the jailing to be incorporated into voting power - tr.waitBlocks(action.chain, 2, time.Minute) } -func uintPointer(i uint) *uint { - return &i +type waitTimeAction struct { + WaitTime time.Duration +} + +func (tr TestConfig) waitForTime( + action waitTimeAction, + verbose bool, +) { + tr.WaitTime(action.WaitTime) } // GetPathNameForGorelayer returns the name of the path between two given chains used by Gorelayer. // Since paths are bidirectional, we need either chain to be able to be provided as first or second argument // and still return the same name, so we sort the chain names alphabetically. -func (tr TestRun) GetPathNameForGorelayer(chainA, chainB chainID) string { +func (tr TestConfig) GetPathNameForGorelayer(chainA, chainB ChainID) string { var pathName string if string(chainA) < string(chainB) { pathName = string(chainA) + "-" + string(chainB) @@ -1998,10 +2110,10 @@ func (tr TestRun) GetPathNameForGorelayer(chainA, chainB chainID) string { // WaitTime waits for the given duration. // To make sure that the new timestamp is visible on-chain, it also waits until at least one block has been // produced on each chain after waiting. -// The CometMock version of this takes a pointer to the TestRun as it needs to manipulate +// The CometMock version of this takes a pointer to the TestConfig as it needs to manipulate // information in the testrun that stores how much each chain has waited, to keep times in sync. -// Be careful that all functions calling WaitTime should therefore also take a pointer to the TestRun. -func (tr *TestRun) WaitTime(duration time.Duration) { +// Be careful that all functions calling WaitTime should therefore also take a pointer to the TestConfig. +func (tr *TestConfig) WaitTime(duration time.Duration) { if !tr.useCometmock { time.Sleep(duration) } else { @@ -2016,7 +2128,7 @@ func (tr *TestRun) WaitTime(duration time.Duration) { } } -func (tr TestRun) AdvanceTimeForChain(chain chainID, duration time.Duration) { +func (tr TestConfig) AdvanceTimeForChain(chain ChainID, duration time.Duration) { // cometmock avoids sleeping, and instead advances time for all chains method := "advance_time" params := fmt.Sprintf(`{"duration_in_seconds": "%d"}`, int(math.Ceil(duration.Seconds()))) diff --git a/tests/e2e/actions_sovereign_chain.go b/tests/e2e/actions_sovereign_chain.go index cf2d6288e8..af5f6abab3 100644 --- a/tests/e2e/actions_sovereign_chain.go +++ b/tests/e2e/actions_sovereign_chain.go @@ -10,15 +10,15 @@ import ( ) type StartSovereignChainAction struct { - chain chainID - validators []StartChainValidator + Chain ChainID + Validators []StartChainValidator // Genesis changes specific to this action, appended to genesis changes defined in chain config - genesisChanges string + GenesisChanges string } // calls a simplified startup script (start-sovereign.sh) and runs a validator node // upgrades are simpler with a single validator node since only one node needs to be upgraded -func (tr TestRun) startSovereignChain( +func (tr TestConfig) startSovereignChain( action StartSovereignChainAction, verbose bool, ) { @@ -38,20 +38,20 @@ func (tr TestRun) startSovereignChain( } var validators []jsonValAttrs - for _, val := range action.validators { + for _, val := range action.Validators { validators = append(validators, jsonValAttrs{ - Mnemonic: tr.validatorConfigs[val.id].mnemonic, - NodeKey: tr.validatorConfigs[val.id].nodeKey, - ValId: fmt.Sprint(val.id), - PrivValidatorKey: tr.validatorConfigs[val.id].privValidatorKey, - Allocation: fmt.Sprint(val.allocation) + "stake", - Stake: fmt.Sprint(val.stake) + "stake", - IpSuffix: tr.validatorConfigs[val.id].ipSuffix, - - ConsumerMnemonic: tr.validatorConfigs[val.id].consumerMnemonic, - ConsumerPrivValidatorKey: tr.validatorConfigs[val.id].consumerPrivValidatorKey, + Mnemonic: tr.validatorConfigs[val.Id].Mnemonic, + NodeKey: tr.validatorConfigs[val.Id].NodeKey, + ValId: fmt.Sprint(val.Id), + PrivValidatorKey: tr.validatorConfigs[val.Id].PrivValidatorKey, + Allocation: fmt.Sprint(val.Allocation) + "stake", + Stake: fmt.Sprint(val.Stake) + "stake", + IpSuffix: tr.validatorConfigs[val.Id].IpSuffix, + + ConsumerMnemonic: tr.validatorConfigs[val.Id].ConsumerMnemonic, + ConsumerPrivValidatorKey: tr.validatorConfigs[val.Id].ConsumerPrivValidatorKey, // if true node will be started with consumer key for each consumer chain - StartWithConsumerKey: tr.validatorConfigs[val.id].useConsumerKey, + StartWithConsumerKey: tr.validatorConfigs[val.Id].UseConsumerKey, }) } @@ -62,16 +62,16 @@ func (tr TestRun) startSovereignChain( // Concat genesis changes defined in chain config, with any custom genesis changes for this chain instantiation var genesisChanges string - if action.genesisChanges != "" { - genesisChanges = chainConfig.genesisChanges + " | " + action.genesisChanges + if action.GenesisChanges != "" { + genesisChanges = chainConfig.GenesisChanges + " | " + action.GenesisChanges } else { - genesisChanges = chainConfig.genesisChanges + genesisChanges = chainConfig.GenesisChanges } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "/bin/bash", - "/testnet-scripts/start-sovereign.sh", chainConfig.binaryName, string(vals), - string(chainConfig.chainId), chainConfig.ipPrefix, genesisChanges, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "/bin/bash", + "/testnet-scripts/start-sovereign.sh", chainConfig.BinaryName, string(vals), + string(chainConfig.ChainId), chainConfig.IpPrefix, genesisChanges, tr.tendermintConfigOverride, ) @@ -100,19 +100,19 @@ func (tr TestRun) startSovereignChain( log.Fatal(err) } tr.addChainToRelayer(addChainToRelayerAction{ - chain: action.chain, - validator: action.validators[0].id, + Chain: action.Chain, + Validator: action.Validators[0].Id, }, verbose) } type LegacyUpgradeProposalAction struct { - chainID chainID - upgradeTitle string - proposer validatorID - upgradeHeight uint64 + ChainID ChainID + UpgradeTitle string + Proposer ValidatorID + UpgradeHeight uint64 } -func (tr *TestRun) submitLegacyUpgradeProposal(action LegacyUpgradeProposalAction, verbose bool) { +func (tr *TestConfig) submitLegacyUpgradeProposal(action LegacyUpgradeProposalAction, verbose bool) { submit := fmt.Sprintf( `%s tx gov submit-legacy-proposal software-upgrade %s \ --title %s \ @@ -128,18 +128,18 @@ func (tr *TestRun) submitLegacyUpgradeProposal(action LegacyUpgradeProposalActio --node %s \ --no-validate \ -y`, - tr.chainConfigs[chainID("sover")].binaryName, - action.upgradeTitle, - action.upgradeTitle, - fmt.Sprint(action.upgradeHeight), - action.proposer, - tr.chainConfigs[chainID("sover")].chainId, - tr.getValidatorHome(chainID("sover"), action.proposer), - tr.getValidatorNode(chainID("sover"), action.proposer), + tr.chainConfigs[ChainID("sover")].BinaryName, + action.UpgradeTitle, + action.UpgradeTitle, + fmt.Sprint(action.UpgradeHeight), + action.Proposer, + tr.chainConfigs[ChainID("sover")].ChainId, + tr.getValidatorHome(ChainID("sover"), action.Proposer), + tr.getValidatorNode(ChainID("sover"), action.Proposer), ) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. cmd := exec.Command("docker", "exec", - tr.containerConfig.instanceName, + tr.containerConfig.InstanceName, "/bin/bash", "-c", submit, ) @@ -153,16 +153,16 @@ func (tr *TestRun) submitLegacyUpgradeProposal(action LegacyUpgradeProposalActio log.Fatal(err, "\n", string(bz)) } - tr.waitBlocks(action.chainID, 1, 15*time.Second) + tr.waitBlocks(action.ChainID, 1, 15*time.Second) } type waitUntilBlockAction struct { - block uint - chain chainID + Block uint + Chain ChainID } -func (tr *TestRun) waitUntilBlockOnChain(action waitUntilBlockAction) { - fmt.Println("waitUntilBlockOnChain is waiting for block:", action.block) - tr.waitUntilBlock(action.chain, action.block, 120*time.Second) - fmt.Println("waitUntilBlockOnChain done waiting for block:", action.block) +func (tr *TestConfig) waitUntilBlockOnChain(action waitUntilBlockAction) { + fmt.Println("waitUntilBlockOnChain is waiting for block:", action.Block) + tr.waitUntilBlock(action.Chain, action.Block, 120*time.Second) + fmt.Println("waitUntilBlockOnChain done waiting for block:", action.Block) } diff --git a/tests/e2e/config.go b/tests/e2e/config.go index 373281162d..462d6e4a49 100644 --- a/tests/e2e/config.go +++ b/tests/e2e/config.go @@ -8,64 +8,64 @@ import ( // TODO: Determine if user defined type (wrapping a primitive string) is desired in long run type ( - chainID string - validatorID string + ChainID string + ValidatorID string ) // Attributes that are unique to a validator. Allows us to map (part of) // the set of strings defined above to a set of viable validators type ValidatorConfig struct { - mnemonic string - delAddress string - valoperAddress string - valconsAddress string - privValidatorKey string - nodeKey string + Mnemonic string + DelAddress string + ValoperAddress string + ValconsAddress string + PrivValidatorKey string + NodeKey string // Must be an integer greater than 0 and less than 253 - ipSuffix string + IpSuffix string // consumer chain key assignment data // keys are used on a new node - consumerMnemonic string - consumerDelAddress string - consumerValoperAddress string - consumerValconsAddress string - consumerValPubKey string - consumerPrivValidatorKey string - consumerNodeKey string - useConsumerKey bool // if true the validator node will start with consumer key + ConsumerMnemonic string + ConsumerDelAddress string + ConsumerValoperAddress string + ConsumerValconsAddress string + ConsumerValPubKey string + ConsumerPrivValidatorKey string + ConsumerNodeKey string + UseConsumerKey bool // if true the validator node will start with consumer key } // Attributes that are unique to a chain. Allows us to map (part of) // the set of strings defined above to a set of viable chains type ChainConfig struct { - chainId chainID + ChainId ChainID // Must be unique per chain - ipPrefix string - votingWaitTime uint + IpPrefix string + VotingWaitTime uint // Any transformations to apply to the genesis file of all chains instantiated with this chain config, as a jq string. // Example: ".app_state.gov.params.voting_period = \"5s\" | .app_state.slashing.params.signed_blocks_window = \"2\" | .app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\"" - genesisChanges string - binaryName string + GenesisChanges string + BinaryName string // binary to use after upgrade height - upgradeBinary string + UpgradeBinary string } type ContainerConfig struct { - containerName string - instanceName string - ccvVersion string - now time.Time + ContainerName string + InstanceName string + CcvVersion string + Now time.Time } -// TODO: Split out TestRun and system wide config like localsdkpath -type TestRun struct { +// TODO: Split out TestConfig and system wide config like localsdkpath +type TestConfig struct { // These are the non altered values during a typical test run, where multiple test runs can exist // to validate different action sequences and corresponding state checks. containerConfig ContainerConfig - validatorConfigs map[validatorID]ValidatorConfig - chainConfigs map[chainID]ChainConfig + validatorConfigs map[ValidatorID]ValidatorConfig + chainConfigs map[ChainID]ChainConfig // override config.toml parameters // usually used to override timeout_commit // having shorter timeout_commit reduces the test runtime because blocks are produced faster @@ -77,97 +77,97 @@ type TestRun struct { useGorelayer bool // if false, Hermes is used as the relayer gaiaTag string // chains which are running, i.e. producing blocks, at the moment - runningChains map[chainID]bool + runningChains map[ChainID]bool // Used with CometMock. The time by which chains have been advanced. Used to keep chains in sync: when a new chain is started, advance its time by this value to keep chains in sync. timeOffset time.Duration name string } -// Initialize initializes the TestRun instance by setting the runningChains field to an empty map. -func (tr *TestRun) Initialize() { - tr.runningChains = make(map[chainID]bool) +// Initialize initializes the TestConfig instance by setting the runningChains field to an empty map. +func (tr *TestConfig) Initialize() { + tr.runningChains = make(map[ChainID]bool) } -func getDefaultValidators() map[validatorID]ValidatorConfig { - return map[validatorID]ValidatorConfig{ - validatorID("alice"): { - mnemonic: "pave immune ethics wrap gain ceiling always holiday employ earth tumble real ice engage false unable carbon equal fresh sick tattoo nature pupil nuclear", - delAddress: "cosmos19pe9pg5dv9k5fzgzmsrgnw9rl9asf7ddwhu7lm", - valoperAddress: "cosmosvaloper19pe9pg5dv9k5fzgzmsrgnw9rl9asf7ddtrgtng", - valconsAddress: "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", - privValidatorKey: `{"address":"06C0F3E47CC5C748269088DC2F36411D3AAA27C6","pub_key":{"type":"tendermint/PubKeyEd25519","value":"RrclQz9bIhkIy/gfL485g3PYMeiIku4qeo495787X10="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"uX+ZpDMg89a6gtqs/+MQpCTSqlkZ0nJQJOhLlCJvwvdGtyVDP1siGQjL+B8vjzmDc9gx6IiS7ip6jj3nvztfXQ=="}}`, - nodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"fjw4/DAhyRPnwKgXns5SV7QfswRSXMWJpHS7TyULDmJ8ofUc5poQP8dgr8bZRbCV5RV8cPqDq3FPdqwpmUbmdA=="}}`, - ipSuffix: "4", +func getDefaultValidators() map[ValidatorID]ValidatorConfig { + return map[ValidatorID]ValidatorConfig{ + ValidatorID("alice"): { + Mnemonic: "pave immune ethics wrap gain ceiling always holiday employ earth tumble real ice engage false unable carbon equal fresh sick tattoo nature pupil nuclear", + DelAddress: "cosmos19pe9pg5dv9k5fzgzmsrgnw9rl9asf7ddwhu7lm", + ValoperAddress: "cosmosvaloper19pe9pg5dv9k5fzgzmsrgnw9rl9asf7ddtrgtng", + ValconsAddress: "cosmosvalcons1qmq08eruchr5sf5s3rwz7djpr5a25f7xw4mceq", + PrivValidatorKey: `{"address":"06C0F3E47CC5C748269088DC2F36411D3AAA27C6","pub_key":{"type":"tendermint/PubKeyEd25519","value":"RrclQz9bIhkIy/gfL485g3PYMeiIku4qeo495787X10="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"uX+ZpDMg89a6gtqs/+MQpCTSqlkZ0nJQJOhLlCJvwvdGtyVDP1siGQjL+B8vjzmDc9gx6IiS7ip6jj3nvztfXQ=="}}`, + NodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"fjw4/DAhyRPnwKgXns5SV7QfswRSXMWJpHS7TyULDmJ8ofUc5poQP8dgr8bZRbCV5RV8cPqDq3FPdqwpmUbmdA=="}}`, + IpSuffix: "4", // consumer chain assigned key - consumerMnemonic: "exile install vapor thing little toss immune notable lounge december final easy strike title end program interest quote cloth forget forward job october twenty", - consumerDelAddress: "cosmos1eeeggku6dzk3mv7wph3zq035rhtd890sjswszd", - consumerValoperAddress: "cosmosvaloper1eeeggku6dzk3mv7wph3zq035rhtd890shy69w7", - consumerValconsAddress: "cosmosvalcons1muys5jyqk4xd27e208nym85kn0t4zjcfeu63fe", - consumerValPubKey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"ujY14AgopV907IYgPAk/5x8c9267S4fQf89nyeCPTes="}`, - consumerPrivValidatorKey: `{"address":"DF090A4880B54CD57B2A79E64D9E969BD7514B09","pub_key":{"type":"tendermint/PubKeyEd25519","value":"ujY14AgopV907IYgPAk/5x8c9267S4fQf89nyeCPTes="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"TRJgf7lkTjs/sj43pyweEOanyV7H7fhnVivOi0A4yjW6NjXgCCilX3TshiA8CT/nHxz3brtLh9B/z2fJ4I9N6w=="}}`, - consumerNodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"F966RL9pi20aXRzEBe4D0xRQJtZt696Xxz44XUON52cFc83FMn1WXJbP6arvA2JPyn2LA3DLKCFHSgALrCGXGA=="}}`, - useConsumerKey: false, + ConsumerMnemonic: "exile install vapor thing little toss immune notable lounge december final easy strike title end program interest quote cloth forget forward job october twenty", + ConsumerDelAddress: "cosmos1eeeggku6dzk3mv7wph3zq035rhtd890sjswszd", + ConsumerValoperAddress: "cosmosvaloper1eeeggku6dzk3mv7wph3zq035rhtd890shy69w7", + ConsumerValconsAddress: "cosmosvalcons1muys5jyqk4xd27e208nym85kn0t4zjcfeu63fe", + ConsumerValPubKey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"ujY14AgopV907IYgPAk/5x8c9267S4fQf89nyeCPTes="}`, + ConsumerPrivValidatorKey: `{"address":"DF090A4880B54CD57B2A79E64D9E969BD7514B09","pub_key":{"type":"tendermint/PubKeyEd25519","value":"ujY14AgopV907IYgPAk/5x8c9267S4fQf89nyeCPTes="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"TRJgf7lkTjs/sj43pyweEOanyV7H7fhnVivOi0A4yjW6NjXgCCilX3TshiA8CT/nHxz3brtLh9B/z2fJ4I9N6w=="}}`, + ConsumerNodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"F966RL9pi20aXRzEBe4D0xRQJtZt696Xxz44XUON52cFc83FMn1WXJbP6arvA2JPyn2LA3DLKCFHSgALrCGXGA=="}}`, + UseConsumerKey: false, }, - validatorID("bob"): { - mnemonic: "glass trip produce surprise diamond spin excess gaze wash drum human solve dress minor artefact canoe hard ivory orange dinner hybrid moral potato jewel", - delAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", - valoperAddress: "cosmosvaloper1dkas8mu4kyhl5jrh4nzvm65qz588hy9qakmjnw", - valconsAddress: "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", - privValidatorKey: `{"address":"99BD3A72EF12CD024E7584B3AC900AE3743C6ADF","pub_key":{"type":"tendermint/PubKeyEd25519","value":"mAN6RXYxSM4MNGSIriYiS7pHuwAcOHDQAy9/wnlSzOI="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"QePcwfWtOavNK7pBJrtoLMzarHKn6iBWfWPFeyV+IdmYA3pFdjFIzgw0ZIiuJiJLuke7ABw4cNADL3/CeVLM4g=="}}`, - nodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"TQ4vHcO/vKdzGtWpelkX53WdMQd4kTsWGFrdcatdXFvWyO215Rewn5IRP0FszPLWr2DqPzmuH8WvxYGk5aeOXw=="}}`, - ipSuffix: "5", + ValidatorID("bob"): { + Mnemonic: "glass trip produce surprise diamond spin excess gaze wash drum human solve dress minor artefact canoe hard ivory orange dinner hybrid moral potato jewel", + DelAddress: "cosmos1dkas8mu4kyhl5jrh4nzvm65qz588hy9qcz08la", + ValoperAddress: "cosmosvaloper1dkas8mu4kyhl5jrh4nzvm65qz588hy9qakmjnw", + ValconsAddress: "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + PrivValidatorKey: `{"address":"99BD3A72EF12CD024E7584B3AC900AE3743C6ADF","pub_key":{"type":"tendermint/PubKeyEd25519","value":"mAN6RXYxSM4MNGSIriYiS7pHuwAcOHDQAy9/wnlSzOI="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"QePcwfWtOavNK7pBJrtoLMzarHKn6iBWfWPFeyV+IdmYA3pFdjFIzgw0ZIiuJiJLuke7ABw4cNADL3/CeVLM4g=="}}`, + NodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"TQ4vHcO/vKdzGtWpelkX53WdMQd4kTsWGFrdcatdXFvWyO215Rewn5IRP0FszPLWr2DqPzmuH8WvxYGk5aeOXw=="}}`, + IpSuffix: "5", // consumer chain assigned key - consumerMnemonic: "grunt list hour endless observe better spoil penalty lab duck only layer vague fantasy satoshi record demise topple space shaft solar practice donor sphere", - consumerDelAddress: "cosmos1q90l6j6lzzgt460ehjj56azknlt5yrd4s38n97", - consumerValoperAddress: "cosmosvaloper1q90l6j6lzzgt460ehjj56azknlt5yrd449nxfd", - consumerValconsAddress: "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", - consumerValPubKey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"QlG+iYe6AyYpvY1z9RNJKCVlH14Q/qSz4EjGdGCru3o="}`, - consumerPrivValidatorKey: `{"address":"E73388E246EC9945E5E70A94FE4072BD937415C4","pub_key":{"type":"tendermint/PubKeyEd25519","value":"QlG+iYe6AyYpvY1z9RNJKCVlH14Q/qSz4EjGdGCru3o="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"OFR4w+FC6EMw5fAGTrHVexyPrjzQ7QfqgZOMgVf0izlCUb6Jh7oDJim9jXP1E0koJWUfXhD+pLPgSMZ0YKu7eg=="}}`, - consumerNodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"uhPCqnL2KE8m/8OFNLQ5bN3CJr6mds+xfBi0E4umT/s2uWiJhet+vbYx88DHSdof3gGFNTIzAIxSppscBKX96w=="}}`, - useConsumerKey: false, + ConsumerMnemonic: "grunt list hour endless observe better spoil penalty lab duck only layer vague fantasy satoshi record demise topple space shaft solar practice donor sphere", + ConsumerDelAddress: "cosmos1q90l6j6lzzgt460ehjj56azknlt5yrd4s38n97", + ConsumerValoperAddress: "cosmosvaloper1q90l6j6lzzgt460ehjj56azknlt5yrd449nxfd", + ConsumerValconsAddress: "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", + ConsumerValPubKey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"QlG+iYe6AyYpvY1z9RNJKCVlH14Q/qSz4EjGdGCru3o="}`, + ConsumerPrivValidatorKey: `{"address":"E73388E246EC9945E5E70A94FE4072BD937415C4","pub_key":{"type":"tendermint/PubKeyEd25519","value":"QlG+iYe6AyYpvY1z9RNJKCVlH14Q/qSz4EjGdGCru3o="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"OFR4w+FC6EMw5fAGTrHVexyPrjzQ7QfqgZOMgVf0izlCUb6Jh7oDJim9jXP1E0koJWUfXhD+pLPgSMZ0YKu7eg=="}}`, + ConsumerNodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"uhPCqnL2KE8m/8OFNLQ5bN3CJr6mds+xfBi0E4umT/s2uWiJhet+vbYx88DHSdof3gGFNTIzAIxSppscBKX96w=="}}`, + UseConsumerKey: false, }, - validatorID("carol"): { - mnemonic: "sight similar better jar bitter laptop solve fashion father jelly scissors chest uniform play unhappy convince silly clump another conduct behave reunion marble animal", - delAddress: "cosmos19hz4m226ztankqramvt4a7t0shejv4dc79gp9u", - valoperAddress: "cosmosvaloper19hz4m226ztankqramvt4a7t0shejv4dcm3u5f0", - valconsAddress: "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", - privValidatorKey: `{"address":"C888306A908A217B9A943D1DAD8790044D0947A4","pub_key":{"type":"tendermint/PubKeyEd25519","value":"IHo4QEikWZfIKmM0X+N+BjKttz8HOzGs2npyjiba3Xk="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"z08bmSB91uFVpVmR3t2ewd/bDjZ/AzwQpe5rKjWiPG0gejhASKRZl8gqYzRf434GMq23Pwc7MazaenKOJtrdeQ=="}}`, - nodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"WLTcHEjbwB24Wp3z5oBSYTvtGQonz/7IQabOFw85BN0UkkyY5HDf38o8oHlFxVI26f+DFVeICuLbe9aXKGnUeg=="}}`, - ipSuffix: "6", + ValidatorID("carol"): { + Mnemonic: "sight similar better jar bitter laptop solve fashion father jelly scissors chest uniform play unhappy convince silly clump another conduct behave reunion marble animal", + DelAddress: "cosmos19hz4m226ztankqramvt4a7t0shejv4dc79gp9u", + ValoperAddress: "cosmosvaloper19hz4m226ztankqramvt4a7t0shejv4dcm3u5f0", + ValconsAddress: "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", + PrivValidatorKey: `{"address":"C888306A908A217B9A943D1DAD8790044D0947A4","pub_key":{"type":"tendermint/PubKeyEd25519","value":"IHo4QEikWZfIKmM0X+N+BjKttz8HOzGs2npyjiba3Xk="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"z08bmSB91uFVpVmR3t2ewd/bDjZ/AzwQpe5rKjWiPG0gejhASKRZl8gqYzRf434GMq23Pwc7MazaenKOJtrdeQ=="}}`, + NodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"WLTcHEjbwB24Wp3z5oBSYTvtGQonz/7IQabOFw85BN0UkkyY5HDf38o8oHlFxVI26f+DFVeICuLbe9aXKGnUeg=="}}`, + IpSuffix: "6", // consumer chain assigned key - consumerMnemonic: "clip choose cake west range gun slam cry village receive juice galaxy lend ritual range provide ritual can since verify breeze vacant play dragon", - consumerDelAddress: "cosmos1sx6j9g2rh324a342a5f0rnx7me34r9nwgf0mc7", - consumerValoperAddress: "cosmosvaloper1sx6j9g2rh324a342a5f0rnx7me34r9nwdamw5d", - consumerValconsAddress: "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", - consumerValPubKey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`, - consumerPrivValidatorKey: `{"address":"B41C3A40142963AA5B12DDD1C4E5890C0B3926B1","pub_key":{"type":"tendermint/PubKeyEd25519","value":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"3YaBAZLA+sl/E73lLfbFbG0u6DYm33ayr/0UpCt/vFBSLkZ/X6a1ZR0fy7fGWbN0ogP4Xc8rSx9dnvcZnqrqKw=="}}`, - consumerNodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"rxBzFedtD3pqgfJQblbxGusKOr47oBfr8ba0Iz14gobtDRZQZlSZ/UGP4pSHkVf+4vtkrkO1vRHBYJobuiP+7A=="}}`, - useConsumerKey: true, + ConsumerMnemonic: "clip choose cake west range gun slam cry village receive juice galaxy lend ritual range provide ritual can since verify breeze vacant play dragon", + ConsumerDelAddress: "cosmos1sx6j9g2rh324a342a5f0rnx7me34r9nwgf0mc7", + ConsumerValoperAddress: "cosmosvaloper1sx6j9g2rh324a342a5f0rnx7me34r9nwdamw5d", + ConsumerValconsAddress: "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", + ConsumerValPubKey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`, + ConsumerPrivValidatorKey: `{"address":"B41C3A40142963AA5B12DDD1C4E5890C0B3926B1","pub_key":{"type":"tendermint/PubKeyEd25519","value":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="},"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"3YaBAZLA+sl/E73lLfbFbG0u6DYm33ayr/0UpCt/vFBSLkZ/X6a1ZR0fy7fGWbN0ogP4Xc8rSx9dnvcZnqrqKw=="}}`, + ConsumerNodeKey: `{"priv_key":{"type":"tendermint/PrivKeyEd25519","value":"rxBzFedtD3pqgfJQblbxGusKOr47oBfr8ba0Iz14gobtDRZQZlSZ/UGP4pSHkVf+4vtkrkO1vRHBYJobuiP+7A=="}}`, + UseConsumerKey: true, }, } } -func SlashThrottleTestRun() TestRun { - tr := TestRun{ +func SlashThrottleTestConfig() TestConfig { + tr := TestConfig{ name: "slash-throttling", containerConfig: ContainerConfig{ - containerName: "interchain-security-slash-container", - instanceName: "interchain-security-slash-instance", - ccvVersion: "1", - now: time.Now(), + ContainerName: "interchain-security-slash-container", + InstanceName: "interchain-security-slash-instance", + CcvVersion: "1", + Now: time.Now(), }, validatorConfigs: getDefaultValidators(), - chainConfigs: map[chainID]ChainConfig{ - chainID("provi"): { - chainId: chainID("provi"), - binaryName: "interchain-security-pd", - ipPrefix: "7.7.7", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + chainConfigs: map[ChainID]ChainConfig{ + ChainID("provi"): { + ChainId: ChainID("provi"), + BinaryName: "interchain-security-pd", + IpPrefix: "7.7.7", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + // Custom slashing parameters for testing validator downtime functionality // See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking ".app_state.slashing.params.signed_blocks_window = \"10\" | " + @@ -177,16 +177,17 @@ func SlashThrottleTestRun() TestRun { ".app_state.provider.params.slash_meter_replenish_fraction = \"0.10\" | " + ".app_state.provider.params.slash_meter_replenish_period = \"20s\"", }, - chainID("consu"): { - chainId: chainID("consu"), - binaryName: "interchain-security-cd", - ipPrefix: "7.7.8", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ChainID("consu"): { + ChainId: ChainID("consu"), + BinaryName: "interchain-security-cd", + IpPrefix: "7.7.8", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + ".app_state.slashing.params.signed_blocks_window = \"15\" | " + ".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " + ".app_state.slashing.params.downtime_jail_duration = \"60s\" | " + - ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"", + ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\" | " + + ".app_state.ccvconsumer.params.retry_delay_period = \"30s\"", }, }, tendermintConfigOverride: `s/timeout_commit = "5s"/timeout_commit = "1s"/;` + @@ -196,23 +197,23 @@ func SlashThrottleTestRun() TestRun { return tr } -func DefaultTestRun() TestRun { - tr := TestRun{ +func DefaultTestConfig() TestConfig { + tr := TestConfig{ name: "default", containerConfig: ContainerConfig{ - containerName: "interchain-security-container", - instanceName: "interchain-security-instance", - ccvVersion: "1", - now: time.Now(), + ContainerName: "interchain-security-container", + InstanceName: "interchain-security-instance", + CcvVersion: "1", + Now: time.Now(), }, validatorConfigs: getDefaultValidators(), - chainConfigs: map[chainID]ChainConfig{ - chainID("provi"): { - chainId: chainID("provi"), - binaryName: "interchain-security-pd", - ipPrefix: "7.7.7", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + chainConfigs: map[ChainID]ChainConfig{ + ChainID("provi"): { + ChainId: ChainID("provi"), + BinaryName: "interchain-security-pd", + IpPrefix: "7.7.7", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + // Custom slashing parameters for testing validator downtime functionality // See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking ".app_state.slashing.params.signed_blocks_window = \"10\" | " + @@ -222,12 +223,12 @@ func DefaultTestRun() TestRun { ".app_state.provider.params.slash_meter_replenish_fraction = \"1.0\" | " + // This disables slash packet throttling ".app_state.provider.params.slash_meter_replenish_period = \"3s\"", }, - chainID("consu"): { - chainId: chainID("consu"), - binaryName: "interchain-security-cd", - ipPrefix: "7.7.8", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ChainID("consu"): { + ChainId: ChainID("consu"), + BinaryName: "interchain-security-cd", + IpPrefix: "7.7.8", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + ".app_state.slashing.params.signed_blocks_window = \"15\" | " + ".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " + ".app_state.slashing.params.downtime_jail_duration = \"60s\" | " + @@ -241,35 +242,36 @@ func DefaultTestRun() TestRun { return tr } -func DemocracyTestRun(allowReward bool) TestRun { +func DemocracyTestConfig(allowReward bool) TestConfig { consumerGenChanges := ".app_state.ccvconsumer.params.blocks_per_distribution_transmission = \"20\" | " + - ".app_state.gov.voting_params.voting_period = \"10s\" | " + + ".app_state.gov.params.voting_period = \"10s\" | " + ".app_state.slashing.params.signed_blocks_window = \"10\" | " + ".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " + ".app_state.slashing.params.downtime_jail_duration = \"60s\" | " + - ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"" + ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\" | " + + ".app_state.transfer.params.send_enabled = false" if allowReward { // This allows the consumer chain to send rewards in the stake denom consumerGenChanges += " | .app_state.ccvconsumer.params.reward_denoms = [\"stake\"]" } - tr := TestRun{ + tr := TestConfig{ name: "democracy", containerConfig: ContainerConfig{ - containerName: "interchain-security-democ-container", - instanceName: "interchain-security-democ-instance", - ccvVersion: "1", - now: time.Now(), + ContainerName: "interchain-security-democ-container", + InstanceName: "interchain-security-democ-instance", + CcvVersion: "1", + Now: time.Now(), }, validatorConfigs: getDefaultValidators(), - chainConfigs: map[chainID]ChainConfig{ - chainID("provi"): { - chainId: chainID("provi"), - binaryName: "interchain-security-pd", - ipPrefix: "7.7.7", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + chainConfigs: map[ChainID]ChainConfig{ + ChainID("provi"): { + ChainId: ChainID("provi"), + BinaryName: "interchain-security-pd", + IpPrefix: "7.7.7", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + // Custom slashing parameters for testing validator downtime functionality // See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking ".app_state.slashing.params.signed_blocks_window = \"10\" | " + @@ -278,12 +280,12 @@ func DemocracyTestRun(allowReward bool) TestRun { ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\" | " + ".app_state.provider.params.slash_meter_replenish_fraction = \"1.0\"", // This disables slash packet throttling }, - chainID("democ"): { - chainId: chainID("democ"), - binaryName: "interchain-security-cdd", - ipPrefix: "7.7.9", - votingWaitTime: 20, - genesisChanges: consumerGenChanges, + ChainID("democ"): { + ChainId: ChainID("democ"), + BinaryName: "interchain-security-cdd", + IpPrefix: "7.7.9", + VotingWaitTime: 20, + GenesisChanges: consumerGenChanges, }, }, tendermintConfigOverride: `s/timeout_commit = "5s"/timeout_commit = "1s"/;` + @@ -293,23 +295,23 @@ func DemocracyTestRun(allowReward bool) TestRun { return tr } -func MultiConsumerTestRun() TestRun { - tr := TestRun{ +func MultiConsumerTestConfig() TestConfig { + tr := TestConfig{ name: "multi-consumer", containerConfig: ContainerConfig{ - containerName: "interchain-security-multic-container", - instanceName: "interchain-security-multic-instance", - ccvVersion: "1", - now: time.Now(), + ContainerName: "interchain-security-multic-container", + InstanceName: "interchain-security-multic-instance", + CcvVersion: "1", + Now: time.Now(), }, validatorConfigs: getDefaultValidators(), - chainConfigs: map[chainID]ChainConfig{ - chainID("provi"): { - chainId: chainID("provi"), - binaryName: "interchain-security-pd", - ipPrefix: "7.7.7", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"30s\" | " + + chainConfigs: map[ChainID]ChainConfig{ + ChainID("provi"): { + ChainId: ChainID("provi"), + BinaryName: "interchain-security-pd", + IpPrefix: "7.7.7", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"30s\" | " + // Custom slashing parameters for testing validator downtime functionality // See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking ".app_state.slashing.params.signed_blocks_window = \"10\" | " + @@ -318,23 +320,23 @@ func MultiConsumerTestRun() TestRun { ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\" | " + ".app_state.provider.params.slash_meter_replenish_fraction = \"1.0\"", // This disables slash packet throttling }, - chainID("consu"): { - chainId: chainID("consu"), - binaryName: "interchain-security-cd", - ipPrefix: "7.7.8", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ChainID("consu"): { + ChainId: ChainID("consu"), + BinaryName: "interchain-security-cd", + IpPrefix: "7.7.8", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + ".app_state.slashing.params.signed_blocks_window = \"10\" | " + ".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " + ".app_state.slashing.params.downtime_jail_duration = \"60s\" | " + ".app_state.slashing.params.slash_fraction_downtime = \"0.010000000000000000\"", }, - chainID("densu"): { - chainId: chainID("densu"), - binaryName: "interchain-security-cd", - ipPrefix: "7.7.9", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ChainID("densu"): { + ChainId: ChainID("densu"), + BinaryName: "interchain-security-cd", + IpPrefix: "7.7.9", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + ".app_state.slashing.params.signed_blocks_window = \"10\" | " + ".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " + ".app_state.slashing.params.downtime_jail_duration = \"60s\" | " + @@ -348,23 +350,23 @@ func MultiConsumerTestRun() TestRun { return tr } -func ChangeoverTestRun() TestRun { - tr := TestRun{ +func ChangeoverTestConfig() TestConfig { + tr := TestConfig{ name: "changeover", containerConfig: ContainerConfig{ - containerName: "interchain-security-changeover-container", - instanceName: "interchain-security-changeover-instance", - ccvVersion: "1", - now: time.Now(), + ContainerName: "interchain-security-changeover-container", + InstanceName: "interchain-security-changeover-instance", + CcvVersion: "1", + Now: time.Now(), }, validatorConfigs: getDefaultValidators(), - chainConfigs: map[chainID]ChainConfig{ - chainID("provi"): { - chainId: chainID("provi"), - binaryName: "interchain-security-pd", - ipPrefix: "7.7.7", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + chainConfigs: map[ChainID]ChainConfig{ + ChainID("provi"): { + ChainId: ChainID("provi"), + BinaryName: "interchain-security-pd", + IpPrefix: "7.7.7", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + // Custom slashing parameters for testing validator downtime functionality // See https://docs.cosmos.network/main/modules/slashing/04_begin_block.html#uptime-tracking ".app_state.slashing.params.signed_blocks_window = \"10\" | " + @@ -374,13 +376,13 @@ func ChangeoverTestRun() TestRun { ".app_state.provider.params.slash_meter_replenish_fraction = \"1.0\" | " + // This disables slash packet throttling ".app_state.provider.params.slash_meter_replenish_period = \"3s\"", }, - chainID("sover"): { - chainId: chainID("sover"), - binaryName: "interchain-security-sd", - upgradeBinary: "interchain-security-cdd", - ipPrefix: "7.7.8", - votingWaitTime: 20, - genesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + + ChainID("sover"): { + ChainId: ChainID("sover"), + BinaryName: "interchain-security-sd", + UpgradeBinary: "interchain-security-cdd", + IpPrefix: "7.7.8", + VotingWaitTime: 20, + GenesisChanges: ".app_state.gov.params.voting_period = \"20s\" | " + ".app_state.slashing.params.signed_blocks_window = \"15\" | " + ".app_state.slashing.params.min_signed_per_window = \"0.500000000000000000\" | " + ".app_state.slashing.params.downtime_jail_duration = \"60s\" | " + @@ -395,7 +397,7 @@ func ChangeoverTestRun() TestRun { return tr } -func (s *TestRun) SetDockerConfig(localSdkPath string, useGaia bool, gaiaTag string) { +func (s *TestConfig) SetDockerConfig(localSdkPath string, useGaia bool, gaiaTag string) { if localSdkPath != "" { fmt.Println("USING LOCAL SDK", localSdkPath) } @@ -408,11 +410,11 @@ func (s *TestRun) SetDockerConfig(localSdkPath string, useGaia bool, gaiaTag str s.localSdkPath = localSdkPath } -func (s *TestRun) SetCometMockConfig(useCometmock bool) { +func (s *TestConfig) SetCometMockConfig(useCometmock bool) { s.useCometmock = useCometmock } -func (s *TestRun) SetRelayerConfig(useRly bool) { +func (s *TestConfig) SetRelayerConfig(useRly bool) { s.useGorelayer = useRly } @@ -423,14 +425,14 @@ func (s *TestRun) SetRelayerConfig(useRly bool) { // within the container will be named as "$CHAIN_ID-$VAL_ID-out" etc. // where this name is constrained to 15 bytes or less. Therefore each string literal // used as a validatorID or chainID needs to be 5 char or less. -func (s *TestRun) validateStringLiterals() { +func (s *TestConfig) validateStringLiterals() { for valID, valConfig := range s.validatorConfigs { if len(valID) > 5 { panic("validator id string literal must be 5 char or less") } - ipSuffix, err := strconv.Atoi(valConfig.ipSuffix) + ipSuffix, err := strconv.Atoi(valConfig.IpSuffix) if err != nil { panic(fmt.Sprintf("ip suffix must be an int: %v\n", err)) } @@ -453,7 +455,7 @@ func (s *TestRun) validateStringLiterals() { panic("chain id string literal must be 5 char or less") } - if chainID != chainConfig.chainId { + if chainID != chainConfig.ChainId { panic("chain config is mapped to a chain id that is different than what's stored in the config") } } diff --git a/tests/e2e/json_marshal_test.go b/tests/e2e/json_marshal_test.go new file mode 100644 index 0000000000..5ee91dcb66 --- /dev/null +++ b/tests/e2e/json_marshal_test.go @@ -0,0 +1,189 @@ +package main + +import ( + "encoding/json" + "reflect" + "strings" + "testing" + + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "github.com/davecgh/go-spew/spew" +) + +func TestProposalUnmarshal(t *testing.T) { + proposalAndTypeString := `{ + "Type": "main.ConsumerAdditionProposal", + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + } + }` + + expectedProposal := ConsumerAdditionProposal{ + Deposit: 10000001, + Chain: ChainID("consu"), + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + Status: "PROPOSAL_STATUS_PASSED", + } + + type ProposalAndType struct { + RawProposal json.RawMessage + Type string + } + + propAndType := &ProposalAndType{} + err := json.Unmarshal([]byte(proposalAndTypeString), propAndType) + if err != nil { + t.Errorf("Unexpected error while unmarshalling: %v", err) + } + + actualProposal, err := UnmarshalProposalWithType(propAndType.RawProposal, propAndType.Type) + if err != nil { + t.Errorf("Unexpected error while unmarshalling\n error: %v\n Raw proposal: %v\n Type: %v", err, spew.Sdump(propAndType.RawProposal), propAndType.Type) + } + + if !reflect.DeepEqual(actualProposal, expectedProposal) { + t.Errorf("Expected proposal: %v, but got: %v", spew.Sdump(expectedProposal), spew.Sdump(actualProposal)) + } +} + +type ChainStateTestCase struct { + name string + jsonBytes []byte + chainState ChainState + expectedUnmarshalErrorText string +} + +var testCases = []ChainStateTestCase{ + { + name: "valid JSON with proposals", + jsonBytes: []byte(`{ + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "Proposals": { + "1": { + "Type": "main.ConsumerAdditionProposal", + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + } + } + } + }`), + chainState: ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9500000000, + ValidatorID("bob"): 9500000000, + ValidatorID("carol"): 9500000000, + }, + Proposals: &map[uint]Proposal{ + 1: ConsumerAdditionProposal{ + Deposit: 10000001, + Chain: ChainID("consu"), + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + Status: "PROPOSAL_STATUS_PASSED", + }, + }, + }, + expectedUnmarshalErrorText: "", + }, + { + name: "invalid JSON", + jsonBytes: []byte(`thisisnotagoodjsonstring`), + expectedUnmarshalErrorText: "invalid json", + }, + { + name: "unknown proposal type", + jsonBytes: []byte(`{ + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "Proposals": { + "1": { + "Type": "main.NotAProposalTypeProposal", + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + } + } + }, + }`), + expectedUnmarshalErrorText: "not a known proposal type", + }, +} + +func TestUnmarshalJSON(t *testing.T) { + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + var result ChainState + err := result.UnmarshalJSON(tc.jsonBytes) + if err != nil && tc.expectedUnmarshalErrorText == "" { + t.Errorf("Test case %v: Unexpected error: %v", tc.name, err) + } + + if err == nil && tc.expectedUnmarshalErrorText != "" { + t.Errorf("Test case %v: Expected error to contain: %v, but got no error", tc.name, tc.expectedUnmarshalErrorText) + } + + if err != nil && tc.expectedUnmarshalErrorText != "" && strings.Contains(err.Error(), tc.expectedUnmarshalErrorText) { + t.Errorf("Test case %v: Expected error to contain: %v, but got: %v", tc.name, tc.expectedUnmarshalErrorText, err) + } + + if !reflect.DeepEqual(result, tc.chainState) { + t.Errorf("Test case %v: Expected ChainState: %v, but got: %v", tc.name, tc.chainState, result) + } + }) + } +} + +func TestMarshalJSON(t *testing.T) { + // checks that marshalling and unmarshalling is the identity + // would optimally check that the marshalled JSON is the same as the expected JSON, + // but the marshalled JSON will specifically list null fields + for _, tc := range testCases { + t.Run(tc.name, func(t *testing.T) { + result, err := tc.chainState.MarshalJSON() + if err != nil { + t.Errorf("Test case %v: Unexpected error while marshalling: %v", tc.name, err) + } + + if tc.expectedUnmarshalErrorText != "" { + // unmarshalling to compare does not make sense, since we expect it to + // fail, so just test that marshalling works and continue + return + } + + unmarshalledResult := ChainState{} + err = unmarshalledResult.UnmarshalJSON(result) + if err != nil { + t.Errorf("Test case %v: Unexpected error while unmarshalling: %v", tc.name, err) + } + + if !reflect.DeepEqual(unmarshalledResult, tc.chainState) { + t.Errorf("Test case %v: Expected: %v, but got: %v", tc.name, string(tc.jsonBytes), string(result)) + } + }) + } +} diff --git a/tests/e2e/json_parser.go b/tests/e2e/json_parser.go new file mode 100644 index 0000000000..3f85a23e30 --- /dev/null +++ b/tests/e2e/json_parser.go @@ -0,0 +1,35 @@ +package main + +import ( + "encoding/json" + "os" + "path/filepath" +) + +// TraceParser provides an interface for parsers that read sequences of Steps from files. +type TraceParser interface { + ReadTraceFromFile(filepath string) ([]Step, error) +} + +// JSONParser is a simple parser that reads steps by unmarshalling from a file. +type JSONParser struct{} + +var GlobalJSONParser = JSONParser{} + +func (parser JSONParser) ReadTraceFromFile(path string) ([]Step, error) { + // Open the JSON file and read into a byte array + jsonData, err := os.ReadFile(filepath.Clean(path)) + if err != nil { + return nil, err + } + + // Unmarshal the JSON into a slice of Step structs + var steps []Step + + err = json.Unmarshal(jsonData, &steps) + if err != nil { + return nil, err + } + + return steps, nil +} diff --git a/tests/e2e/json_utils.go b/tests/e2e/json_utils.go new file mode 100644 index 0000000000..3d5867d42a --- /dev/null +++ b/tests/e2e/json_utils.go @@ -0,0 +1,380 @@ +package main + +import ( + "encoding/json" + "fmt" + "reflect" +) + +// stores a proposal as a raw json, together with its type +type ProposalAndType struct { + RawProposal json.RawMessage + Type string +} + +type ( + // to have a ChainState object that does not have the overridden Marshal/Unmarshal method + ChainStateCopy ChainState + + // duplicated from the ChainState with a minor change to the Proposals field + ChainStateWithProposalTypes struct { + ChainStateCopy + Proposals *map[uint]ProposalAndType // the only thing changed from the real ChainState + } +) + +// MarshalJSON marshals a step into JSON while including the type of the action. +func (step Step) MarshalJSON() ([]byte, error) { + actionType := reflect.TypeOf(step.Action) + + result := struct { + ActionType string + Action interface{} + State State + }{ + ActionType: actionType.String(), + Action: step.Action, + State: step.State, + } + + return json.Marshal(result) +} + +// UnmarshalJSON unmarshals a step from JSON while including the type of the action. +func (step *Step) UnmarshalJSON(data []byte) error { + var tmp struct { + ActionType string + Action json.RawMessage + State State + } + if err := json.Unmarshal(data, &tmp); err != nil { + return err + } + + action, err := UnmarshalMapToActionType(tmp.Action, tmp.ActionType) + if err != nil { + return err + } + + step.Action = action + step.State = tmp.State + return nil +} + +// UnmarshalMapToActionType takes a JSON object and an action type and marshals into an object of the corresponding action. +func UnmarshalMapToActionType(rawAction json.RawMessage, actionTypeString string) (interface{}, error) { + var err error + switch actionTypeString { + case "main.submitConsumerAdditionProposalAction": + var a submitConsumerAdditionProposalAction + err = json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.SendTokensAction": + var a SendTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.StartChainAction": + var a StartChainAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitTextProposalAction": + var a submitTextProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitConsumerRemovalProposalAction": + var a submitConsumerRemovalProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitEquivocationProposalAction": + var a submitEquivocationProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitParamChangeLegacyProposalAction": + var a submitParamChangeLegacyProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.voteGovProposalAction": + var a voteGovProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.startConsumerChainAction": + var a startConsumerChainAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.addChainToRelayerAction": + var a addChainToRelayerAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.addIbcConnectionAction": + var a addIbcConnectionAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.addIbcChannelAction": + var a addIbcChannelAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.transferChannelCompleteAction": + var a transferChannelCompleteAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.unjailValidatorAction": + var a unjailValidatorAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.assignConsumerPubKeyAction": + var a assignConsumerPubKeyAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.delegateTokensAction": + var a delegateTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.relayPacketsAction": + var a relayPacketsAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.registerRepresentativeAction": + var a registerRepresentativeAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.relayRewardPacketsToProviderAction": + var a relayRewardPacketsToProviderAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.submitChangeRewardDenomsProposalAction": + var a submitChangeRewardDenomsProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.downtimeSlashAction": + var a downtimeSlashAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.unbondTokensAction": + var a unbondTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.cancelUnbondTokensAction": + var a cancelUnbondTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.redelegateTokensAction": + var a redelegateTokensAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.doublesignSlashAction": + var a doublesignSlashAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.startRelayerAction": + var a startRelayerAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.slashMeterReplenishmentAction": + var a slashMeterReplenishmentAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.waitTimeAction": + var a waitTimeAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.createIbcClientsAction": + var a createIbcClientsAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.LegacyUpgradeProposalAction": + var a LegacyUpgradeProposalAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.waitUntilBlockAction": + var a waitUntilBlockAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.ChangeoverChainAction": + var a ChangeoverChainAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.StartSovereignChainAction": + var a StartSovereignChainAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.lightClientEquivocationAttackAction": + var a lightClientEquivocationAttackAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.lightClientAmnesiaAttackAction": + var a lightClientAmnesiaAttackAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + case "main.lightClientLunaticAttackAction": + var a lightClientLunaticAttackAction + err := json.Unmarshal(rawAction, &a) + if err == nil { + return a, nil + } + default: + return nil, fmt.Errorf("unknown action type: %s", actionTypeString) + } + return nil, err +} + +// custom marshal and unmarshal functions for the chainstate that convert proposals to/from the auxiliary type with type info + +// MarshalJSON transforms the ChainState into a ChainStateWithProposalTypes by adding type info to the proposals +func (c ChainState) MarshalJSON() ([]byte, error) { + chainStateCopy := ChainStateCopy(c) + chainStateWithProposalTypes := ChainStateWithProposalTypes{chainStateCopy, nil} + if c.Proposals != nil { + proposalsWithTypes := make(map[uint]ProposalAndType) + for k, v := range *c.Proposals { + rawMessage, err := json.Marshal(v) + if err != nil { + return nil, err + } + proposalsWithTypes[k] = ProposalAndType{rawMessage, reflect.TypeOf(v).String()} + } + chainStateWithProposalTypes.Proposals = &proposalsWithTypes + } + return json.Marshal(chainStateWithProposalTypes) +} + +// UnmarshalJSON unmarshals the ChainStateWithProposalTypes into a ChainState by removing the type info from the proposals and getting back standard proposals +func (c *ChainState) UnmarshalJSON(data []byte) error { + chainStateWithProposalTypes := ChainStateWithProposalTypes{} + err := json.Unmarshal(data, &chainStateWithProposalTypes) + if err != nil { + return err + } + + chainState := ChainState(chainStateWithProposalTypes.ChainStateCopy) + *c = chainState + + if chainStateWithProposalTypes.Proposals != nil { + proposals := make(map[uint]Proposal) + for k, v := range *chainStateWithProposalTypes.Proposals { + proposal, err := UnmarshalProposalWithType(v.RawProposal, v.Type) + if err != nil { + return err + } + proposals[k] = proposal + } + c.Proposals = &proposals + } + return nil +} + +// UnmarshalProposalWithType takes a JSON object and a proposal type and marshals into an object of the corresponding proposal. +func UnmarshalProposalWithType(inputMap json.RawMessage, proposalType string) (Proposal, error) { + var err error + switch proposalType { + case "main.TextProposal": + prop := TextProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.ConsumerAdditionProposal": + prop := ConsumerAdditionProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.UpgradeProposal": + prop := UpgradeProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.ConsumerRemovalProposal": + prop := ConsumerRemovalProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.EquivocationProposal": + prop := EquivocationProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + case "main.ParamsProposal": + prop := ParamsProposal{} + err := json.Unmarshal(inputMap, &prop) + if err == nil { + return prop, nil + } + default: + return nil, fmt.Errorf("%s is not a known proposal type", proposalType) + } + + return nil, err +} diff --git a/tests/e2e/json_writer.go b/tests/e2e/json_writer.go new file mode 100644 index 0000000000..ea56d779dd --- /dev/null +++ b/tests/e2e/json_writer.go @@ -0,0 +1,28 @@ +package main + +import ( + "encoding/json" + "os" +) + +// TraceWriter is an interface for writers that write steps to files. +type TraceWriter interface { + // WriteTraceToFile writes a given trace to a file, overwriting the file if it already exists. + WriteTraceToFile(filepath string, trace []Step) error +} + +// JSONWriter is a simple writer that marshals the array of Step objects. +// To identify which type of action is being used, we add a field to the Step struct. +type JSONWriter struct{} + +var GlobalJSONWriter = JSONWriter{} + +func (writer JSONWriter) WriteTraceToFile(filepath string, trace []Step) error { + jsonobj, err := json.MarshalIndent(trace, "", " ") + if err != nil { + panic(err) + } + + err = os.WriteFile(filepath, jsonobj, 0o600) + return err +} diff --git a/tests/e2e/main.go b/tests/e2e/main.go index e9336422ae..005ea18566 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -39,7 +39,7 @@ var ( parallel = flag.Bool("parallel", false, "run all tests in parallel") localSdkPath = flag.String("local-sdk-path", "", "path of a local sdk version to build and reference in integration tests") - useCometmock = flag.Bool("use-cometmock", false, "use cometmock instead of CometBFT") + useCometmock = flag.Bool("use-cometmock", false, "use cometmock instead of CometBFT. see https://github.com/informalsystems/CometMock") useGorelayer = flag.Bool("use-gorelayer", false, "use go relayer instead of Hermes") ) @@ -49,24 +49,74 @@ var ( ) var ( - testSelection TestSet - testMap map[string]*testRunWithSteps = map[string]*testRunWithSteps{ - "happy-path-short": { - testRun: DefaultTestRun(), steps: shortHappyPathSteps, - description: `This is like the happy path, but skips steps -that involve starting or stopping nodes for the same chain outside of the chain setup or teardown. -This is suited for CometMock+Gorelayer testing`, - }, - "happy-path": {testRun: DefaultTestRun(), steps: happyPathSteps, description: "happy path tests"}, - "changeover": {testRun: ChangeoverTestRun(), steps: changeoverSteps, description: "changeover tests"}, - "democracy-reward": {testRun: DemocracyTestRun(true), steps: democracySteps, description: "democracy tests allowing rewards"}, - "democracy": {testRun: DemocracyTestRun(false), steps: rewardDenomConsumerSteps, description: "democracy tests"}, - "slash-throttle": {testRun: SlashThrottleTestRun(), steps: slashThrottleSteps, description: "slash throttle tests"}, - "multiconsumer": {testRun: MultiConsumerTestRun(), steps: multipleConsumers, description: "multi consumer tests"}, + selectedTests TestSet + + // map the test config names to their structs to allow for easy selection of test configs, + // and also to programatically set parameters, i.e. see DemocracyTestConfig + testConfigs = map[string]TestConfig{ + "default": DefaultTestConfig(), + "changeover": ChangeoverTestConfig(), + "democracy": DemocracyTestConfig(false), + "democracy-reward": DemocracyTestConfig(true), + "slash-throttle": SlashThrottleTestConfig(), + "multiconsumer": MultiConsumerTestConfig(), } ) -func executeTests(tests []testRunWithSteps) (err error) { +var selectedTestfiles TestSet + +var stepChoices = map[string]StepChoice{ + "happy-path-short": { + name: "happy-path-short", + steps: shortHappyPathSteps, + description: `This is like the happy path, but skips steps that involve starting or stopping nodes for the same chain outside of the chain setup or teardown. This is suited for CometMock+Gorelayer testing`, + testConfig: DefaultTestConfig(), + }, + "light-client-attack": { + name: "light-client-attack", + steps: lightClientAttackSteps, + description: `This is like the short happy path, but will slash validators for LightClientAttackEvidence instead of DuplicateVoteEvidence. This is suited for CometMock+Gorelayer testing, but currently does not work with CometBFT, since causing light client attacks is not implemented`, + testConfig: DefaultTestConfig(), + }, + "happy-path": { + name: "happy-path", + steps: happyPathSteps, + description: "happy path tests", + testConfig: DefaultTestConfig(), + }, + "changeover": { + name: "changeover", + steps: changeoverSteps, + description: "changeover tests", + testConfig: ChangeoverTestConfig(), + }, + "democracy-reward": { + name: "democracy-reward", + steps: democracyRewardsSteps, + description: "democracy tests allowing rewards", + testConfig: DemocracyTestConfig(true), + }, + "democracy": { + name: "democracy", + steps: democracySteps, + description: "democracy tests", + testConfig: DemocracyTestConfig(false), + }, + "slash-throttle": { + name: "slash-throttle", + steps: slashThrottleSteps, + description: "slash throttle tests", + testConfig: SlashThrottleTestConfig(), + }, + "multiconsumer": { + name: "multiconsumer", + steps: multipleConsumers, + description: "multi consumer tests", + testConfig: MultiConsumerTestConfig(), + }, +} + +func executeTests(tests []testStepsWithConfig) (err error) { if parallel != nil && *parallel { fmt.Println("=============== running all tests in parallel ===============") } @@ -75,7 +125,7 @@ func executeTests(tests []testRunWithSteps) (err error) { for _, testCase := range tests { if parallel != nil && *parallel { wg.Add(1) - go func(run testRunWithSteps) { + go func(run testStepsWithConfig) { defer wg.Done() run.testRun.Run(run.steps, *localSdkPath, *useGaia, *gaiaTag) }(testCase) @@ -91,57 +141,135 @@ func executeTests(tests []testRunWithSteps) (err error) { return } +func getTestCaseUsageString() string { + var builder strings.Builder + + // Test case selection + builder.WriteString("This flag is used to reference existing, defined test cases to be run.") + builder.WriteString("Test case selection:\nSelection of test steps to be executed:\n") + for _, stepChoice := range stepChoices { + builder.WriteString(fmt.Sprintf("- %s : %s.\n", stepChoice.name, stepChoice.description)) + } + builder.WriteString("\n") + + // Test runner selection + builder.WriteString("Test runner selection:\nSelection of test runners to be executed:\n") + for _, testConfig := range testConfigs { + builder.WriteString(fmt.Sprintf("- %s\n", testConfig.name)) + } + builder.WriteString("\n") + + // Example + builder.WriteString("Example: -tc multiconsumer::multiconsumer -tc happy-path::default") + + return builder.String() +} + +func getTestFileUsageString() string { + var builder strings.Builder + + builder.WriteString("This flag is used to reference files containing step traces to be run.\n") + builder.WriteString("Each filename should be separated by '::' from the test runner name.\n") + + // Test runner selection + builder.WriteString("Test runner selection:\nSelection of test runners to be executed:\n") + testConfigSet := map[string]struct{}{} + for _, testConfig := range testConfigs { + if _, ok := testConfigSet[testConfig.name]; !ok { + builder.WriteString(fmt.Sprintf("- %s\n", testConfig.name)) + testConfigSet[testConfig.name] = struct{}{} + } + } + builder.WriteString("\n") + + // Example + builder.WriteString("Example: -test-file awesome-trace.json::default -test-file other-trace.json::default") + + return builder.String() +} + func parseArguments() (err error) { - flag.Var(&testSelection, "tc", - fmt.Sprintf("Selection of test cases to be executed:\n%s,\n%s", - func() string { - var keys []string - for k, v := range testMap { - keys = append(keys, fmt.Sprintf("- %s : %s", k, v.description)) - } - return strings.Join(keys, "\n") - }(), - "Example: -tc multiconsumer -tc happy-path ")) + flag.Var(&selectedTests, "tc", + getTestCaseUsageString()) + + flag.Var(&selectedTestfiles, "test-file", + getTestFileUsageString()) flag.Parse() // Enforce go-relayer in case of cometmock as hermes is not yet supported if useCometmock != nil && *useCometmock && (useGorelayer == nil || !*useGorelayer) { fmt.Println("Enforcing go-relayer as cometmock is requested") if err = flag.Set("use-gorelayer", "true"); err != nil { - return - } - } - // check if specified test case exists - for _, tc := range testSelection { - if _, hasKey := testMap[tc]; !hasKey { - err := fmt.Errorf("unknown test case '%s'", tc) return err } } - return + return nil } -func getTestCases(selection TestSet) (tests []testRunWithSteps) { +type testStepsWithConfig struct { + testRun TestConfig + steps []Step +} + +func getTestCases(selectedPredefinedTests, selectedTestFiles TestSet) (tests []testStepsWithConfig) { // Run default tests if no test cases were selected - if len(selection) == 0 { - selection = TestSet{ + if len(selectedPredefinedTests) == 0 && len(selectedTestFiles) == 0 { + selectedPredefinedTests = TestSet{ "changeover", "happy-path", "democracy-reward", "democracy", "slash-throttle", } if includeMultiConsumer != nil && *includeMultiConsumer { - selection = append(selection, "multiconsumer") + selectedPredefinedTests = append(selectedPredefinedTests, "multiconsumer") } } - // Get tests from selection - tests = []testRunWithSteps{} - for _, tc := range selection { - if _, exists := testMap[tc]; !exists { - log.Fatalf("Test case '%s' not found", tc) + tests = []testStepsWithConfig{} + // Get predefined from selection + for _, tc := range selectedPredefinedTests { + // first part of tc is the steps, second part is the test runner + + if _, exists := stepChoices[tc]; !exists { + log.Fatalf("Step choice '%s' not found.\nsee usage info:\n%s", tc, getTestCaseUsageString()) } - tests = append(tests, *testMap[tc]) + + stepChoice := stepChoices[tc] + + tests = append(tests, testStepsWithConfig{ + testRun: stepChoice.testConfig, + steps: stepChoice.steps, + }, + ) } - return + + // get test cases from files + for _, testFile := range selectedTestFiles { + // first part is the file, second part is the test runner + splitTcString := strings.Split(testFile, "::") + if len(splitTcString) != 2 { + log.Fatalf("Test file '%s' is invalid.\nsee usage info:\n%s", testFile, getTestFileUsageString()) + } + + testFileName := splitTcString[0] + testRunnerName := splitTcString[1] + + if _, exists := testConfigs[testRunnerName]; !exists { + log.Fatalf("Test runner '%s' not found.\nsee usage info:\n%s", testRunnerName, getTestFileUsageString()) + } + + testConfig := testConfigs[testRunnerName] + + testCase, err := GlobalJSONParser.ReadTraceFromFile(testFileName) + if err != nil { + log.Fatalf("Error reading test file '%s': %s", testFileName, err) + } + + tests = append(tests, testStepsWithConfig{ + testRun: testConfig, + steps: testCase, + }) + } + + return tests } // runs E2E tests @@ -153,7 +281,7 @@ func main() { log.Fatalf("Error parsing command arguments %s\n", err) } - testCases := getTestCases(testSelection) + testCases := getTestCases(selectedTests, selectedTestfiles) start := time.Now() err := executeTests(testCases) @@ -165,7 +293,7 @@ func main() { // Run sets up docker container and executes the steps in the test run. // Docker containers are torn down after the test run is complete. -func (tr *TestRun) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag string) { +func (tr *TestConfig) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag string) { tr.SetDockerConfig(localSdkPath, useGaia, gaiaTag) tr.SetCometMockConfig(*useCometmock) tr.SetRelayerConfig(*useGorelayer) @@ -176,14 +304,15 @@ func (tr *TestRun) Run(steps []Step, localSdkPath string, useGaia bool, gaiaTag tr.teardownDocker() } -type testRunWithSteps struct { - testRun TestRun +type StepChoice struct { + name string steps []Step description string + testConfig TestConfig } -func (tr *TestRun) runStep(step Step, verbose bool) { - switch action := step.action.(type) { +func (tr *TestConfig) runStep(step Step, verbose bool) { + switch action := step.Action.(type) { case StartChainAction: tr.startChain(action, verbose) case StartSovereignChainAction: @@ -238,27 +367,35 @@ func (tr *TestRun) runStep(step Step, verbose bool) { tr.unjailValidator(action, verbose) case doublesignSlashAction: tr.invokeDoublesignSlash(action, verbose) + case lightClientAmnesiaAttackAction: + tr.lightClientAmnesiaAttack(action, verbose) + case lightClientEquivocationAttackAction: + tr.lightClientEquivocationAttack(action, verbose) + case lightClientLunaticAttackAction: + tr.lightClientLunaticAttack(action, verbose) case registerRepresentativeAction: tr.registerRepresentative(action, verbose) case assignConsumerPubKeyAction: tr.assignConsumerPubKey(action, verbose) - case slashThrottleDequeue: - tr.waitForSlashThrottleDequeue(action, verbose) + case slashMeterReplenishmentAction: + tr.waitForSlashMeterReplenishment(action, verbose) + case waitTimeAction: + tr.waitForTime(action, verbose) case startRelayerAction: tr.startRelayer(action, verbose) - case registerConsumerRewardDenomAction: - tr.registerConsumerRewardDenom(action, verbose) + case submitChangeRewardDenomsProposalAction: + tr.submitChangeRewardDenomsProposal(action, verbose) default: log.Fatalf("unknown action in testRun %s: %#v", tr.name, action) } - modelState := step.state - actualState := tr.getState(step.state) + modelState := step.State + actualState := tr.getState(step.State) // Check state if !reflect.DeepEqual(actualState, modelState) { fmt.Printf("=============== %s FAILED ===============\n", tr.name) - fmt.Println("FAILED action", reflect.TypeOf(step.action).Name()) + fmt.Println("FAILED action", reflect.TypeOf(step.Action).Name()) pretty.Print("actual state", actualState) pretty.Print("model state", modelState) log.Fatal(`actual state (-) not equal to model state (+): ` + pretty.Compare(actualState, modelState)) @@ -266,21 +403,21 @@ func (tr *TestRun) runStep(step Step, verbose bool) { } // executeSteps sequentially runs steps. -func (tr *TestRun) executeSteps(steps []Step) { +func (tr *TestConfig) executeSteps(steps []Step) { fmt.Printf("=============== started %s tests ===============\n", tr.name) start := time.Now() for i, step := range steps { // print something the show the test is alive fmt.Printf("running %s: step %d == %s \n", - tr.name, i+1, reflect.TypeOf(step.action).Name()) + tr.name, i+1, reflect.TypeOf(step.Action).Name()) tr.runStep(step, *verbose) } fmt.Printf("=============== finished %s tests in %v ===============\n", tr.name, time.Since(start)) } -func (tr *TestRun) startDocker() { +func (tr *TestConfig) startDocker() { fmt.Printf("=============== building %s testRun ===============\n", tr.name) localSdk := tr.localSdkPath if localSdk == "" { @@ -303,8 +440,8 @@ func (tr *TestRun) startDocker() { } scriptStr := fmt.Sprintf( "tests/e2e/testnet-scripts/start-docker.sh %s %s %s %s %s", - tr.containerConfig.containerName, - tr.containerConfig.instanceName, + tr.containerConfig.ContainerName, + tr.containerConfig.InstanceName, localSdk, useGaia, gaiaTag, @@ -344,10 +481,10 @@ func (tr *TestRun) startDocker() { // remove docker container to reduce resource usage // otherwise the chain will keep running in the background -func (tr *TestRun) teardownDocker() { +func (tr *TestConfig) teardownDocker() { fmt.Printf("=============== tearing down %s testRun ===============\n", tr.name) //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "kill", tr.containerConfig.instanceName) + cmd := exec.Command("docker", "kill", tr.containerConfig.InstanceName) bz, err := cmd.CombinedOutput() if err != nil { diff --git a/tests/e2e/state.go b/tests/e2e/state.go index 5464b291ac..93566c1f05 100644 --- a/tests/e2e/state.go +++ b/tests/e2e/state.go @@ -9,24 +9,24 @@ import ( "time" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "github.com/kylelemons/godebug/pretty" "github.com/tidwall/gjson" "gopkg.in/yaml.v2" ) -type State map[chainID]ChainState +type State map[ChainID]ChainState type ChainState struct { - ValBalances *map[validatorID]uint + ValBalances *map[ValidatorID]uint Proposals *map[uint]Proposal - ValPowers *map[validatorID]uint - RepresentativePowers *map[validatorID]uint + ValPowers *map[ValidatorID]uint + StakedTokens *map[ValidatorID]uint Params *[]Param Rewards *Rewards - ConsumerChains *map[chainID]bool - AssignedKeys *map[validatorID]string - ProviderKeys *map[validatorID]string // validatorID: validator provider key - ConsumerChainQueueSizes *map[chainID]uint - GlobalSlashQueueSize *uint + ConsumerChains *map[ChainID]bool + AssignedKeys *map[ValidatorID]string + ProviderKeys *map[ValidatorID]string // validatorID: validator provider key + ConsumerPendingPacketQueueSize *uint // Only relevant to consumer chains RegisteredConsumerRewardDenoms *[]string } @@ -44,7 +44,7 @@ func (p TextProposal) isProposal() {} type ConsumerAdditionProposal struct { Deposit uint - Chain chainID + Chain ChainID SpawnTime int InitialHeight clienttypes.Height Status string @@ -65,7 +65,7 @@ func (p ConsumerAdditionProposal) isProposal() {} type ConsumerRemovalProposal struct { Deposit uint - Chain chainID + Chain ChainID StopTime int Status string } @@ -83,7 +83,7 @@ type EquivocationProposal struct { func (p EquivocationProposal) isProposal() {} type Rewards struct { - IsRewarded map[validatorID]bool + IsRewarded map[ValidatorID]bool // if true it will calculate if the validator/delegator is rewarded between 2 successive blocks, // otherwise it will calculate if it received any rewards since the 1st block IsIncrementalReward bool @@ -108,16 +108,17 @@ type Param struct { Value string } -func (tr TestRun) getState(modelState State) State { +func (tr TestConfig) getState(modelState State) State { systemState := State{} for k, modelState := range modelState { + log.Println("Getting model state for chain: ", k) systemState[k] = tr.getChainState(k, modelState) } return systemState } -func (tr TestRun) getChainState(chain chainID, modelState ChainState) ChainState { +func (tr TestConfig) getChainState(chain ChainID, modelState ChainState) ChainState { chainState := ChainState{} if modelState.ValBalances != nil { @@ -136,9 +137,9 @@ func (tr TestRun) getChainState(chain chainID, modelState ChainState) ChainState chainState.ValPowers = &powers } - if modelState.RepresentativePowers != nil { - representPowers := tr.getRepresentativePowers(chain, *modelState.RepresentativePowers) - chainState.RepresentativePowers = &representPowers + if modelState.StakedTokens != nil { + representPowers := tr.getStakedTokens(chain, *modelState.StakedTokens) + chainState.StakedTokens = &representPowers } if modelState.Params != nil { @@ -166,22 +167,18 @@ func (tr TestRun) getChainState(chain chainID, modelState ChainState) ChainState chainState.ProviderKeys = &providerKeys } - if modelState.GlobalSlashQueueSize != nil { - globalQueueSize := tr.getGlobalSlashQueueSize() - chainState.GlobalSlashQueueSize = &globalQueueSize + if modelState.RegisteredConsumerRewardDenoms != nil { + registeredConsumerRewardDenoms := tr.getRegisteredConsumerRewardDenoms(chain) + chainState.RegisteredConsumerRewardDenoms = ®isteredConsumerRewardDenoms } - if modelState.ConsumerChainQueueSizes != nil { - consumerChainQueueSizes := map[chainID]uint{} - for c := range *modelState.ConsumerChainQueueSizes { - consumerChainQueueSizes[c] = tr.getConsumerChainPacketQueueSize(c) - } - chainState.ConsumerChainQueueSizes = &consumerChainQueueSizes + if modelState.ConsumerPendingPacketQueueSize != nil { + pendingPacketQueueSize := tr.getPendingPacketQueueSize(chain) + chainState.ConsumerPendingPacketQueueSize = &pendingPacketQueueSize } - if modelState.RegisteredConsumerRewardDenoms != nil { - registeredConsumerRewardDenoms := tr.getRegisteredConsumerRewardDenoms(chain) - chainState.RegisteredConsumerRewardDenoms = ®isteredConsumerRewardDenoms + if *verbose { + log.Println("Done getting chain state:\n" + pretty.Sprint(chainState)) } return chainState @@ -189,9 +186,9 @@ func (tr TestRun) getChainState(chain chainID, modelState ChainState) ChainState var blockHeightRegex = regexp.MustCompile(`block_height: "(\d+)"`) -func (tr TestRun) getBlockHeight(chain chainID) uint { +func (tr TestConfig) getBlockHeight(chain ChainID) uint { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, "query", "tendermint-validator-set", @@ -209,7 +206,7 @@ func (tr TestRun) getBlockHeight(chain chainID) uint { return uint(blockHeight) } -func (tr TestRun) waitBlocks(chain chainID, blocks uint, timeout time.Duration) { +func (tr TestConfig) waitBlocks(chain ChainID, blocks uint, timeout time.Duration) { if tr.useCometmock { // call advance_blocks method on cometmock // curl -H 'Content-Type: application/json' -H 'Accept:application/json' --data '{"jsonrpc":"2.0","method":"advance_blocks","params":{"num_blocks": "36000000"},"id":1}' 127.0.0.1:22331 @@ -235,7 +232,7 @@ func (tr TestRun) waitBlocks(chain chainID, blocks uint, timeout time.Duration) } } -func (tr TestRun) waitUntilBlock(chain chainID, block uint, timeout time.Duration) { +func (tr TestConfig) waitUntilBlock(chain ChainID, block uint, timeout time.Duration) { start := time.Now() for { thisBlock := tr.getBlockHeight(chain) @@ -249,8 +246,8 @@ func (tr TestRun) waitUntilBlock(chain chainID, block uint, timeout time.Duratio } } -func (tr TestRun) getBalances(chain chainID, modelState map[validatorID]uint) map[validatorID]uint { - actualState := map[validatorID]uint{} +func (tr TestConfig) getBalances(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint { + actualState := map[ValidatorID]uint{} for k := range modelState { actualState[k] = tr.getBalance(chain, k) } @@ -258,7 +255,7 @@ func (tr TestRun) getBalances(chain chainID, modelState map[validatorID]uint) ma return actualState } -func (tr TestRun) getProposals(chain chainID, modelState map[uint]Proposal) map[uint]Proposal { +func (tr TestConfig) getProposals(chain ChainID, modelState map[uint]Proposal) map[uint]Proposal { actualState := map[uint]Proposal{} for k := range modelState { actualState[k] = tr.getProposal(chain, k) @@ -267,8 +264,8 @@ func (tr TestRun) getProposals(chain chainID, modelState map[uint]Proposal) map[ return actualState } -func (tr TestRun) getValPowers(chain chainID, modelState map[validatorID]uint) map[validatorID]uint { - actualState := map[validatorID]uint{} +func (tr TestConfig) getValPowers(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint { + actualState := map[ValidatorID]uint{} for k := range modelState { actualState[k] = tr.getValPower(chain, k) } @@ -276,16 +273,16 @@ func (tr TestRun) getValPowers(chain chainID, modelState map[validatorID]uint) m return actualState } -func (tr TestRun) getRepresentativePowers(chain chainID, modelState map[validatorID]uint) map[validatorID]uint { - actualState := map[validatorID]uint{} +func (tr TestConfig) getStakedTokens(chain ChainID, modelState map[ValidatorID]uint) map[ValidatorID]uint { + actualState := map[ValidatorID]uint{} for k := range modelState { - actualState[k] = tr.getRepresentativePower(chain, k) + actualState[k] = tr.getValStakedTokens(chain, k) } return actualState } -func (tr TestRun) getParams(chain chainID, modelState []Param) []Param { +func (tr TestConfig) getParams(chain ChainID, modelState []Param) []Param { actualState := []Param{} for _, p := range modelState { actualState = append(actualState, Param{Subspace: p.Subspace, Key: p.Key, Value: tr.getParam(chain, p)}) @@ -294,8 +291,8 @@ func (tr TestRun) getParams(chain chainID, modelState []Param) []Param { return actualState } -func (tr TestRun) getRewards(chain chainID, modelState Rewards) Rewards { - receivedRewards := map[validatorID]bool{} +func (tr TestConfig) getRewards(chain ChainID, modelState Rewards) Rewards { + receivedRewards := map[ValidatorID]bool{} currentBlock := tr.getBlockHeight(chain) tr.waitBlocks(chain, 1, 10*time.Second) @@ -312,13 +309,13 @@ func (tr TestRun) getRewards(chain chainID, modelState Rewards) Rewards { return Rewards{IsRewarded: receivedRewards, IsIncrementalReward: modelState.IsIncrementalReward, IsNativeDenom: modelState.IsNativeDenom} } -func (tr TestRun) getReward(chain chainID, validator validatorID, blockHeight uint, isNativeDenom bool) float64 { - delAddresss := tr.validatorConfigs[validator].delAddress - if chain != chainID("provi") && tr.validatorConfigs[validator].useConsumerKey { - delAddresss = tr.validatorConfigs[validator].consumerDelAddress +func (tr TestConfig) getReward(chain ChainID, validator ValidatorID, blockHeight uint, isNativeDenom bool) float64 { + delAddresss := tr.validatorConfigs[validator].DelAddress + if chain != ChainID("provi") && tr.validatorConfigs[validator].UseConsumerKey { + delAddresss = tr.validatorConfigs[validator].ConsumerDelAddress } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, "query", "distribution", "rewards", delAddresss, @@ -339,15 +336,15 @@ func (tr TestRun) getReward(chain chainID, validator validatorID, blockHeight ui return gjson.Get(string(bz), denomCondition).Float() } -func (tr TestRun) getBalance(chain chainID, validator validatorID) uint { +func (tr TestConfig) getBalance(chain ChainID, validator ValidatorID) uint { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - valDelAddress := tr.validatorConfigs[validator].delAddress - if chain != chainID("provi") && tr.validatorConfigs[validator].useConsumerKey { - valDelAddress = tr.validatorConfigs[validator].consumerDelAddress + valDelAddress := tr.validatorConfigs[validator].DelAddress + if chain != ChainID("provi") && tr.validatorConfigs[validator].UseConsumerKey { + valDelAddress = tr.validatorConfigs[validator].ConsumerDelAddress } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, "query", "bank", "balances", valDelAddress, @@ -367,9 +364,9 @@ func (tr TestRun) getBalance(chain chainID, validator validatorID) uint { var noProposalRegex = regexp.MustCompile(`doesn't exist: key not found`) // interchain-securityd query gov proposals -func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal { +func (tr TestConfig) getProposal(chain ChainID, proposal uint) Proposal { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, "query", "gov", "proposal", fmt.Sprint(proposal), @@ -405,11 +402,11 @@ func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal { } case "/interchain_security.ccv.provider.v1.ConsumerAdditionProposal": chainId := gjson.Get(string(bz), `messages.0.content.chain_id`).String() - spawnTime := gjson.Get(string(bz), `messages.0.content.spawn_time`).Time().Sub(tr.containerConfig.now) + spawnTime := gjson.Get(string(bz), `messages.0.content.spawn_time`).Time().Sub(tr.containerConfig.Now) - var chain chainID + var chain ChainID for i, conf := range tr.chainConfigs { - if string(conf.chainId) == chainId { + if string(conf.ChainId) == chainId { chain = i break } @@ -437,11 +434,11 @@ func (tr TestRun) getProposal(chain chainID, proposal uint) Proposal { } case "/interchain_security.ccv.provider.v1.ConsumerRemovalProposal": chainId := gjson.Get(string(bz), `messages.0.content.chain_id`).String() - stopTime := gjson.Get(string(bz), `messages.0.content.stop_time`).Time().Sub(tr.containerConfig.now) + stopTime := gjson.Get(string(bz), `messages.0.content.stop_time`).Time().Sub(tr.containerConfig.Now) - var chain chainID + var chain ChainID for i, conf := range tr.chainConfigs { - if string(conf.chainId) == chainId { + if string(conf.ChainId) == chainId { chain = i break } @@ -491,42 +488,46 @@ type ValPubKey struct { Value string `yaml:"value"` } -func (tr TestRun) getValPower(chain chainID, validator validatorID) uint { +func (tr TestConfig) getValPower(chain ChainID, validator ValidatorID) uint { + if *verbose { + log.Println("getting validator power for chain: ", chain, " validator: ", validator) + } //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, + command := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, "query", "tendermint-validator-set", `--node`, tr.getQueryNode(chain), - ).CombinedOutput() + ) + bz, err := command.CombinedOutput() if err != nil { - log.Fatalf("error: %v", err) + log.Fatalf("encountered an error when executing command '%s': %v, output: %s", command.String(), err, string(bz)) } valset := TmValidatorSetYaml{} err = yaml.Unmarshal(bz, &valset) if err != nil { - log.Fatalf("error: %v", err) + log.Fatalf("yaml.Unmarshal returned an error while unmarshalling validator set: %v, input: %s", err, string(bz)) } total, err := strconv.Atoi(valset.Total) if err != nil { - log.Fatalf("error: %v", err) + log.Fatalf("strconv.Atoi returned an error while coonverting total for validator set: %v, input: %s, validator set: %s", err, valset.Total, pretty.Sprint(valset)) } if total != len(valset.Validators) { - log.Fatalf("Total number of validators %v does not match number of validators in list %v. Probably a query pagination issue.", - valset.Total, uint(len(valset.Validators))) + log.Fatalf("Total number of validators %v does not match number of validators in list %v. Probably a query pagination issue. Validator set: %v", + valset.Total, uint(len(valset.Validators)), pretty.Sprint(valset)) } for _, val := range valset.Validators { - if val.Address == tr.validatorConfigs[validator].valconsAddress || - val.Address == tr.validatorConfigs[validator].consumerValconsAddress { + if val.Address == tr.validatorConfigs[validator].ValconsAddress || + val.Address == tr.validatorConfigs[validator].ConsumerValconsAddress { votingPower, err := strconv.Atoi(val.VotingPower) if err != nil { - log.Fatalf("error: %v", err) + log.Fatalf("strconv.Atoi returned an error while convering validator voting power: %v, voting power string: %s, validator set: %s", err, val.VotingPower, pretty.Sprint(valset)) } return uint(votingPower) @@ -537,12 +538,12 @@ func (tr TestRun) getValPower(chain chainID, validator validatorID) uint { return 0 } -func (tr TestRun) getRepresentativePower(chain chainID, validator validatorID) uint { +func (tr TestConfig) getValStakedTokens(chain ChainID, validator ValidatorID) uint { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, "query", "staking", "validator", - tr.validatorConfigs[validator].valoperAddress, + tr.validatorConfigs[validator].ValoperAddress, `--node`, tr.getQueryNode(chain), `-o`, `json`, @@ -556,9 +557,9 @@ func (tr TestRun) getRepresentativePower(chain chainID, validator validatorID) u return uint(amount.Uint()) } -func (tr TestRun) getParam(chain chainID, param Param) string { +func (tr TestConfig) getParam(chain ChainID, param Param) string { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - bz, err := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, + bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, "query", "params", "subspace", param.Subspace, @@ -578,9 +579,9 @@ func (tr TestRun) getParam(chain chainID, param Param) string { // getConsumerChains returns a list of consumer chains that're being secured by the provider chain, // determined by querying the provider chain. -func (tr TestRun) getConsumerChains(chain chainID) map[chainID]bool { +func (tr TestConfig) getConsumerChains(chain ChainID) map[ChainID]bool { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, "query", "provider", "list-consumer-chains", `--node`, tr.getQueryNode(chain), @@ -593,17 +594,17 @@ func (tr TestRun) getConsumerChains(chain chainID) map[chainID]bool { } arr := gjson.Get(string(bz), "chains").Array() - chains := make(map[chainID]bool) + chains := make(map[ChainID]bool) for _, c := range arr { id := c.Get("chain_id").String() - chains[chainID(id)] = true + chains[ChainID(id)] = true } return chains } -func (tr TestRun) getConsumerAddresses(chain chainID, modelState map[validatorID]string) map[validatorID]string { - actualState := map[validatorID]string{} +func (tr TestConfig) getConsumerAddresses(chain ChainID, modelState map[ValidatorID]string) map[ValidatorID]string { + actualState := map[ValidatorID]string{} for k := range modelState { actualState[k] = tr.getConsumerAddress(chain, k) } @@ -611,8 +612,8 @@ func (tr TestRun) getConsumerAddresses(chain chainID, modelState map[validatorID return actualState } -func (tr TestRun) getProviderAddresses(chain chainID, modelState map[validatorID]string) map[validatorID]string { - actualState := map[validatorID]string{} +func (tr TestConfig) getProviderAddresses(chain ChainID, modelState map[ValidatorID]string) map[ValidatorID]string { + actualState := map[ValidatorID]string{} for k := range modelState { actualState[k] = tr.getProviderAddressFromConsumer(chain, k) } @@ -620,13 +621,13 @@ func (tr TestRun) getProviderAddresses(chain chainID, modelState map[validatorID return actualState } -func (tr TestRun) getConsumerAddress(consumerChain chainID, validator validatorID) string { +func (tr TestConfig) getConsumerAddress(consumerChain ChainID, validator ValidatorID) string { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chainID("provi")].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[ChainID("provi")].BinaryName, "query", "provider", "validator-consumer-key", - string(consumerChain), tr.validatorConfigs[validator].valconsAddress, - `--node`, tr.getQueryNode(chainID("provi")), + string(consumerChain), tr.validatorConfigs[validator].ValconsAddress, + `--node`, tr.getQueryNode(ChainID("provi")), `-o`, `json`, ) bz, err := cmd.CombinedOutput() @@ -638,13 +639,13 @@ func (tr TestRun) getConsumerAddress(consumerChain chainID, validator validatorI return addr } -func (tr TestRun) getProviderAddressFromConsumer(consumerChain chainID, validator validatorID) string { +func (tr TestConfig) getProviderAddressFromConsumer(consumerChain ChainID, validator ValidatorID) string { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chainID("provi")].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[ChainID("provi")].BinaryName, "query", "provider", "validator-provider-key", - string(consumerChain), tr.validatorConfigs[validator].consumerValconsAddress, - `--node`, tr.getQueryNode(chainID("provi")), + string(consumerChain), tr.validatorConfigs[validator].ConsumerValconsAddress, + `--node`, tr.getQueryNode(ChainID("provi")), `-o`, `json`, ) @@ -657,12 +658,13 @@ func (tr TestRun) getProviderAddressFromConsumer(consumerChain chainID, validato return addr } -func (tr TestRun) getGlobalSlashQueueSize() uint { +func (tr TestConfig) getSlashMeter() int64 { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chainID("provi")].binaryName, + cmd := exec.Command("docker", "exec", + tr.containerConfig.InstanceName, tr.chainConfigs[ChainID("provi")].BinaryName, "query", "provider", "throttle-state", - `--node`, tr.getQueryNode(chainID("provi")), + `--node`, tr.getQueryNode(ChainID("provi")), `-o`, `json`, ) bz, err := cmd.CombinedOutput() @@ -670,17 +672,16 @@ func (tr TestRun) getGlobalSlashQueueSize() uint { log.Fatal(err, "\n", string(bz)) } - packets := gjson.Get(string(bz), "packets").Array() - return uint(len(packets)) + slashMeter := gjson.Get(string(bz), "slash_meter") + return slashMeter.Int() } -func (tr TestRun) getConsumerChainPacketQueueSize(consumerChain chainID) uint { +func (tr TestConfig) getRegisteredConsumerRewardDenoms(chain ChainID) []string { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chainID("provi")].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, - "query", "provider", "throttled-consumer-packet-data", - string(consumerChain), - `--node`, tr.getQueryNode(chainID("provi")), + "query", "provider", "registered-consumer-reward-denoms", + `--node`, tr.getQueryNode(chain), `-o`, `json`, ) bz, err := cmd.CombinedOutput() @@ -688,15 +689,20 @@ func (tr TestRun) getConsumerChainPacketQueueSize(consumerChain chainID) uint { log.Fatal(err, "\n", string(bz)) } - size := gjson.Get(string(bz), "size").Uint() - return uint(size) + denoms := gjson.Get(string(bz), "denoms").Array() + rewardDenoms := make([]string, len(denoms)) + for i, d := range denoms { + rewardDenoms[i] = d.String() + } + + return rewardDenoms } -func (tr TestRun) getRegisteredConsumerRewardDenoms(chain chainID) []string { +func (tr TestConfig) getPendingPacketQueueSize(chain ChainID) uint { //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName, - "query", "provider", "registered-consumer-reward-denoms", + "query", "ccvconsumer", "throttle-state", `--node`, tr.getQueryNode(chain), `-o`, `json`, ) @@ -705,16 +711,15 @@ func (tr TestRun) getRegisteredConsumerRewardDenoms(chain chainID) []string { log.Fatal(err, "\n", string(bz)) } - denoms := gjson.Get(string(bz), "denoms").Array() - rewardDenoms := make([]string, len(denoms)) - for i, d := range denoms { - rewardDenoms[i] = d.String() + if !gjson.ValidBytes(bz) { + panic("invalid json response from query ccvconsumer throttle-state: " + string(bz)) } - return rewardDenoms + packetData := gjson.Get(string(bz), "packet_data_queue").Array() + return uint(len(packetData)) } -func (tr TestRun) getValidatorNode(chain chainID, validator validatorID) string { +func (tr TestConfig) getValidatorNode(chain ChainID, validator ValidatorID) string { // for CometMock, validatorNodes are all the same address as the query node (which is CometMocks address) if tr.useCometmock { return tr.getQueryNode(chain) @@ -723,42 +728,46 @@ func (tr TestRun) getValidatorNode(chain chainID, validator validatorID) string return "tcp://" + tr.getValidatorIP(chain, validator) + ":26658" } -func (tr TestRun) getValidatorIP(chain chainID, validator validatorID) string { - return tr.chainConfigs[chain].ipPrefix + "." + tr.validatorConfigs[validator].ipSuffix +func (tr TestConfig) getValidatorIP(chain ChainID, validator ValidatorID) string { + return tr.chainConfigs[chain].IpPrefix + "." + tr.validatorConfigs[validator].IpSuffix } -func (tr TestRun) getValidatorHome(chain chainID, validator validatorID) string { - return `/` + string(tr.chainConfigs[chain].chainId) + `/validator` + fmt.Sprint(validator) +func (tr TestConfig) getValidatorHome(chain ChainID, validator ValidatorID) string { + return `/` + string(tr.chainConfigs[chain].ChainId) + `/validator` + fmt.Sprint(validator) } // getQueryNode returns query node tcp address on chain. -func (tr TestRun) getQueryNode(chain chainID) string { +func (tr TestConfig) getQueryNode(chain ChainID) string { return fmt.Sprintf("tcp://%s", tr.getQueryNodeRPCAddress(chain)) } -func (tr TestRun) getQueryNodeRPCAddress(chain chainID) string { +func (tr TestConfig) getQueryNodeRPCAddress(chain ChainID) string { return fmt.Sprintf("%s:26658", tr.getQueryNodeIP(chain)) } // getQueryNodeIP returns query node IP for chain, // ipSuffix is hardcoded to be 253 on all query nodes // except for "sover" chain where there's only one node -func (tr TestRun) getQueryNodeIP(chain chainID) string { - if chain == chainID("sover") { +func (tr TestConfig) getQueryNodeIP(chain ChainID) string { + if chain == ChainID("sover") { // return address of first and only validator return fmt.Sprintf("%s.%s", - tr.chainConfigs[chain].ipPrefix, - tr.validatorConfigs[validatorID("alice")].ipSuffix) + tr.chainConfigs[chain].IpPrefix, + tr.validatorConfigs[ValidatorID("alice")].IpSuffix) } - return fmt.Sprintf("%s.253", tr.chainConfigs[chain].ipPrefix) + return fmt.Sprintf("%s.253", tr.chainConfigs[chain].IpPrefix) } -func (tr TestRun) curlJsonRPCRequest(method, params, address string) { +func (tr TestConfig) curlJsonRPCRequest(method, params, address string) { cmd_template := `curl -H 'Content-Type: application/json' -H 'Accept:application/json' --data '{"jsonrpc":"2.0","method":"%s","params":%s,"id":1}' %s` //#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. - cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, "bash", "-c", fmt.Sprintf(cmd_template, method, params, address)) + cmd := exec.Command("docker", "exec", tr.containerConfig.InstanceName, "bash", "-c", fmt.Sprintf(cmd_template, method, params, address)) verbosity := false executeCommandWithVerbosity(cmd, "curlJsonRPCRequest", verbosity) } + +func uintPtr(i uint) *uint { + return &i +} diff --git a/tests/e2e/state_rapid_test.go b/tests/e2e/state_rapid_test.go new file mode 100644 index 0000000000..b6ac12f111 --- /dev/null +++ b/tests/e2e/state_rapid_test.go @@ -0,0 +1,248 @@ +package main + +import ( + "testing" + + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "pgregory.net/rapid" +) + +// This file contains tests for serialization/deserialization of state. +// The tests are written using the rapid testing library, which allows us to +// generate arbitrary state structs and test that they can be serialized and +// deserialized without error. +// The generators for the various parts of the state are defined in this file, and +// essentially tell rapid how to build the state. + +func TestChainStateMarshalling(t *testing.T) { + rapid.Check(t, func(t *rapid.T) { + chainState := GetChainStateGen().Draw(t, "ChainState") + err := MarshalAndUnmarshalChainState(chainState) + if err != nil { + t.Fatalf("error marshalling and unmarshalling chain state: %v", err) + } + }) +} + +// Below this are utility functions for Rapid that define generators for the various structs that can appear in testing. +// These are used in the rapid tests and generate arbitrary test traces for fuzzing. +// These traces will not in general be useful to execute as e2e tests, since they are filled with essentially completely random values. +func GetStateGen() *rapid.Generator[State] { + return rapid.Custom(func(t *rapid.T) State { + return rapid.MapOf(GetChainIDGen(), GetChainStateGen()).Draw(t, "State") + }) +} + +func GetChainStateGen() *rapid.Generator[ChainState] { + return rapid.Custom( + func(t *rapid.T) ChainState { + valBalances := GetValBalancesGen().Draw(t, "ValBalances") + proposals := GetProposalsGen().Draw(t, "Proposals") + valPowers := GetValPowersGen().Draw(t, "ValPowers") + stakedTokens := GetStakedTokensGen().Draw(t, "StakedTokens") + params := GetParamsGen().Draw(t, "Params") + rewards := GetRewardsGen().Draw(t, "Rewards") + consumerChains := GetConsumerChainsGen().Draw(t, "ConsumerChains") + assignedKeys := GetAssignedKeysGen().Draw(t, "AssignedKeys") + providerKeys := GetProviderKeysGen().Draw(t, "ProviderKeys") + consumerPacketQueueSize := GetConsumerChainQueueSizesGen().Draw(t, "ConsumerChainQueueSizes") + registeredConsumerRewardDenoms := GetRegisteredConsumerRewardDenomsGen().Draw(t, "RegisteredConsumerRewardDenoms") + + return ChainState{ + ValBalances: &valBalances, + Proposals: &proposals, + ValPowers: &valPowers, + StakedTokens: &stakedTokens, + Params: ¶ms, + Rewards: &rewards, + ConsumerChains: &consumerChains, + AssignedKeys: &assignedKeys, + ProviderKeys: &providerKeys, + ConsumerPendingPacketQueueSize: &consumerPacketQueueSize, + RegisteredConsumerRewardDenoms: ®isteredConsumerRewardDenoms, + } + }) +} + +func GetRegisteredConsumerRewardDenomsGen() *rapid.Generator[[]string] { + return rapid.Custom(func(t *rapid.T) []string { + return rapid.SliceOf(rapid.String()).Draw(t, "RegisteredConsumerRewardDenoms") + }) +} + +func GetConsumerChainQueueSizesGen() *rapid.Generator[uint] { + return rapid.Custom(func(t *rapid.T) uint { + return rapid.Uint().Draw(t, "ConsumerChainQueueSizes") + }) +} + +func GetProviderKeysGen() *rapid.Generator[map[ValidatorID]string] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]string { + return rapid.MapOf(GetValidatorIDGen(), rapid.String()).Draw(t, "ProviderKeys") + }) +} + +func GetAssignedKeysGen() *rapid.Generator[map[ValidatorID]string] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]string { + return rapid.MapOf(GetValidatorIDGen(), rapid.String()).Draw(t, "AssignedKeys") + }) +} + +func GetChainIDGen() *rapid.Generator[ChainID] { + return rapid.Custom(func(t *rapid.T) ChainID { + return ChainID(rapid.String().Draw(t, "ChainID")) + }) +} + +func GetConsumerChainsGen() *rapid.Generator[map[ChainID]bool] { + return rapid.Custom(func(t *rapid.T) map[ChainID]bool { + return rapid.MapOf(GetChainIDGen(), rapid.Bool()).Draw(t, "ConsumerChains") + }) +} + +func GetRewardsGen() *rapid.Generator[Rewards] { + return rapid.Custom(func(t *rapid.T) Rewards { + return Rewards{ + IsIncrementalReward: rapid.Bool().Draw(t, "IsIncrementalReward"), + IsNativeDenom: rapid.Bool().Draw(t, "IsNativeDenom"), + IsRewarded: rapid.MapOf(GetValidatorIDGen(), rapid.Bool()).Draw(t, "IsRewarded"), + } + }) +} + +func GetParamsGen() *rapid.Generator[[]Param] { + return rapid.Custom(func(t *rapid.T) []Param { + return rapid.SliceOf(GetParamGen()).Draw(t, "Params") + }) +} + +func GetParamGen() *rapid.Generator[Param] { + return rapid.Custom(func(t *rapid.T) Param { + return Param{ + Key: rapid.String().Draw(t, "Key"), + Value: rapid.String().Draw(t, "Value"), + } + }) +} + +func GetStakedTokensGen() *rapid.Generator[map[ValidatorID]uint] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]uint { + return rapid.MapOf( + GetValidatorIDGen(), + rapid.Uint(), + ).Draw(t, "StakedTokens") + }) +} + +func GetValPowersGen() *rapid.Generator[map[ValidatorID]uint] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]uint { + return rapid.MapOf( + GetValidatorIDGen(), + rapid.Uint(), + ).Draw(t, "ValPowers") + }) +} + +func GetValBalancesGen() *rapid.Generator[map[ValidatorID]uint] { + return rapid.Custom(func(t *rapid.T) map[ValidatorID]uint { + return rapid.MapOf( + GetValidatorIDGen(), + rapid.Uint(), + ).Draw(t, "ValBalances") + }) +} + +func GetValidatorIDGen() *rapid.Generator[ValidatorID] { + return rapid.Custom(func(t *rapid.T) ValidatorID { + return ValidatorID(rapid.String().Draw(t, "ValidatorID")) + }) +} + +func GetProposalsGen() *rapid.Generator[map[uint]Proposal] { + return rapid.Custom(func(t *rapid.T) map[uint]Proposal { + return rapid.MapOf( + rapid.Uint(), + GetProposalGen(), + ).Draw(t, "Proposals") + }) +} + +func GetProposalGen() *rapid.Generator[Proposal] { + return rapid.Custom(func(t *rapid.T) Proposal { + gen := rapid.OneOf( + GetConsumerAdditionProposalGen().AsAny(), + GetConsumerRemovalProposalGen().AsAny(), + GetEquivocationProposalGen().AsAny(), + GetTextProposalGen().AsAny(), + GetParamsProposalGen().AsAny(), + ) + return gen.Draw(t, "Proposal").(Proposal) + }) +} + +func GetConsumerAdditionProposalGen() *rapid.Generator[ConsumerAdditionProposal] { + return rapid.Custom(func(t *rapid.T) ConsumerAdditionProposal { + return ConsumerAdditionProposal{ + Deposit: rapid.Uint().Draw(t, "Deposit"), + Chain: GetChainIDGen().Draw(t, "Chain"), + SpawnTime: rapid.Int().Draw(t, "SpawnTime"), + InitialHeight: GetHeightGen().Draw(t, "InitialHeight"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetConsumerRemovalProposalGen() *rapid.Generator[ConsumerRemovalProposal] { + return rapid.Custom(func(t *rapid.T) ConsumerRemovalProposal { + return ConsumerRemovalProposal{ + Deposit: rapid.Uint().Draw(t, "Deposit"), + Chain: GetChainIDGen().Draw(t, "Chain"), + StopTime: rapid.Int().Draw(t, "StopTime"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetEquivocationProposalGen() *rapid.Generator[EquivocationProposal] { + return rapid.Custom(func(t *rapid.T) EquivocationProposal { + return EquivocationProposal{ + Power: rapid.Uint().Draw(t, "Power"), + Height: rapid.Uint().Draw(t, "Height"), + ConsensusAddress: rapid.String().Draw(t, "ConesnsuAddress"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetTextProposalGen() *rapid.Generator[TextProposal] { + return rapid.Custom(func(t *rapid.T) TextProposal { + return TextProposal{ + Title: rapid.String().Draw(t, "Title"), + Description: rapid.String().Draw(t, "Description"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetParamsProposalGen() *rapid.Generator[ParamsProposal] { + return rapid.Custom(func(t *rapid.T) ParamsProposal { + return ParamsProposal{ + Subspace: rapid.String().Draw(t, "Subspace"), + Key: rapid.String().Draw(t, "Key"), + Value: rapid.String().Draw(t, "Value"), + Deposit: rapid.Uint().Draw(t, "Deposit"), + Status: rapid.String().Draw(t, "Status"), + } + }) +} + +func GetHeightGen() *rapid.Generator[clienttypes.Height] { + return rapid.Custom(func(t *rapid.T) clienttypes.Height { + return clienttypes.Height{ + RevisionNumber: rapid.Uint64().Draw(t, "RevisionNumber"), + RevisionHeight: rapid.Uint64().Draw(t, "RevisionHeight"), + } + }) +} diff --git a/tests/e2e/step_delegation.go b/tests/e2e/step_delegation.go index b6e7c8ad76..fc3208dbac 100644 --- a/tests/e2e/step_delegation.go +++ b/tests/e2e/step_delegation.go @@ -4,76 +4,76 @@ package main func stepsDelegate(consumerName string) []Step { return []Step{ { - action: delegateTokensAction{ - chain: chainID("provi"), - from: validatorID("alice"), - to: validatorID("alice"), - amount: 11000000, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + Action: delegateTokensAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + To: ValidatorID("alice"), + Amount: 11000000, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 500, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 500, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: SendTokensAction{ - chain: chainID(consumerName), - from: validatorID("alice"), - to: validatorID("bob"), - amount: 1, - }, - state: State{ - chainID(consumerName): ChainState{ + Action: SendTokensAction{ + Chain: ChainID(consumerName), + From: ValidatorID("alice"), + To: ValidatorID("bob"), + Amount: 1, + }, + State: State{ + ChainID(consumerName): ChainState{ // Tx should not go through, ICS channel is not setup until first VSC packet has been relayed to consumer - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 10000000000, - validatorID("bob"): 10000000000, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 10000000000, + ValidatorID("bob"): 10000000000, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: SendTokensAction{ - chain: chainID(consumerName), - from: validatorID("alice"), - to: validatorID("bob"), - amount: 1, - }, - state: State{ - chainID(consumerName): ChainState{ + Action: SendTokensAction{ + Chain: ChainID(consumerName), + From: ValidatorID("alice"), + To: ValidatorID("bob"), + Amount: 1, + }, + State: State{ + ChainID(consumerName): ChainState{ // Now tx should execute - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9999999999, - validatorID("bob"): 10000000001, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9999999999, + ValidatorID("bob"): 10000000001, }, }, }, @@ -85,43 +85,43 @@ func stepsDelegate(consumerName string) []Step { func stepsUnbond(consumerName string) []Step { return []Step{ { - action: unbondTokensAction{ - chain: chainID("provi"), - unbondFrom: validatorID("alice"), - sender: validatorID("alice"), - amount: 1000000, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + Action: unbondTokensAction{ + Chain: ChainID("provi"), + UnbondFrom: ValidatorID("alice"), + Sender: ValidatorID("alice"), + Amount: 1000000, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID("consu"): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID("consu"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Voting power on consumer should not be affected yet - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID("consu"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("consu"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, @@ -134,85 +134,85 @@ func stepsUnbond(consumerName string) []Step { func stepsCancelUnbond(consumerName string) []Step { return []Step{ { - action: unbondTokensAction{ - chain: chainID("provi"), - unbondFrom: validatorID("alice"), - sender: validatorID("alice"), - amount: 1000000, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 500, + Action: unbondTokensAction{ + Chain: ChainID("provi"), + UnbondFrom: ValidatorID("alice"), + Sender: ValidatorID("alice"), + Amount: 1000000, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID("consu"): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID("consu"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Voting power on consumer should not be affected yet - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID("consu"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 500, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("consu"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: cancelUnbondTokensAction{ - chain: chainID("provi"), - delegator: validatorID("alice"), - validator: validatorID("alice"), - amount: 1000000, // cancel unbonding the full amount - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, // power restored - validatorID("bob"): 500, - validatorID("carol"): 500, + Action: cancelUnbondTokensAction{ + Chain: ChainID("provi"), + Delegator: ValidatorID("alice"), + Validator: ValidatorID("alice"), + Amount: 1000000, // cancel unbonding the full amount + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, // power restored + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID("consu"): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID("consu"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Voting power on consumer should not be affected yet - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID("consu"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, // power restored on consumer - validatorID("bob"): 500, - validatorID("carol"): 500, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("consu"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, // power restored on consumer + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, @@ -226,45 +226,45 @@ func stepsCancelUnbond(consumerName string) []Step { func stepsRedelegateForOptOut(consumerName string) []Step { return []Step{ { - action: redelegateTokensAction{ - chain: chainID("provi"), - src: validatorID("alice"), - dst: validatorID("carol"), - txSender: validatorID("alice"), - amount: 450000000, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 60, - validatorID("bob"): 500, - validatorID("carol"): 950, + Action: redelegateTokensAction{ + Chain: ChainID("provi"), + Src: ValidatorID("alice"), + Dst: ValidatorID("carol"), + TxSender: ValidatorID("alice"), + Amount: 450000000, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 60, + ValidatorID("bob"): 500, + ValidatorID("carol"): 950, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Voting power changes not seen by consumer yet - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Now power changes are seen by consumer - validatorID("alice"): 60, - validatorID("bob"): 500, - validatorID("carol"): 950, + ValidatorID("alice"): 60, + ValidatorID("bob"): 500, + ValidatorID("carol"): 950, }, }, }, @@ -276,48 +276,48 @@ func stepsRedelegateForOptOut(consumerName string) []Step { func stepsRedelegate(consumerName string) []Step { return []Step{ { - action: redelegateTokensAction{ - chain: chainID("provi"), - src: validatorID("carol"), - dst: validatorID("alice"), - txSender: validatorID("carol"), + Action: redelegateTokensAction{ + Chain: ChainID("provi"), + Src: ValidatorID("carol"), + Dst: ValidatorID("alice"), + TxSender: ValidatorID("carol"), // redelegate s.t. alice has majority stake so non-faulty validators maintain more than // 2/3 voting power during downtime tests below, avoiding chain halt - amount: 449000000, + Amount: 449000000, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // carol always uses a consumer assigned key - validatorID("carol"): 501, + ValidatorID("carol"): 501, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Voting power changes not seen by consumer yet - validatorID("alice"): 60, - validatorID("bob"): 500, - validatorID("carol"): 950, + ValidatorID("alice"): 60, + ValidatorID("bob"): 500, + ValidatorID("carol"): 950, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Now power changes are seen by consumer - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, @@ -329,48 +329,48 @@ func stepsRedelegate(consumerName string) []Step { func stepsRedelegateShort(consumerName string) []Step { return []Step{ { - action: redelegateTokensAction{ - chain: chainID("provi"), - src: validatorID("alice"), - dst: validatorID("carol"), - txSender: validatorID("alice"), + Action: redelegateTokensAction{ + Chain: ChainID("provi"), + Src: ValidatorID("alice"), + Dst: ValidatorID("carol"), + TxSender: ValidatorID("alice"), // Leave alice with majority stake so non-faulty validators maintain more than // 2/3 voting power during downtime tests below, avoiding chain halt - amount: 1000000, + Amount: 1000000, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // carol always uses a consumer assigned key - validatorID("carol"): 501, + ValidatorID("carol"): 501, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Voting power changes not seen by consumer yet - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Now power changes are seen by consumer - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, diff --git a/tests/e2e/step_rapid_test.go b/tests/e2e/step_rapid_test.go new file mode 100644 index 0000000000..dde5f2f465 --- /dev/null +++ b/tests/e2e/step_rapid_test.go @@ -0,0 +1,51 @@ +package main + +import ( + "log" + "os" + "path/filepath" + "testing" + + "pgregory.net/rapid" +) + +// TestReadAndWriteTrace uses rapid to do property based testing +// of reading and writing traces. +// It generates a random trace, writes it to a file, then reads it back. +// It then compares the original trace to the read trace. +// If the traces are not equal, rapid will generate a minimal example +// that causes the test to fail. +func TestReadAndWriteTrace(t *testing.T) { + parser := JSONParser{} + writer := JSONWriter{} + + dir, err := os.MkdirTemp("", "example") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(dir) // clean up + + rapid.Check(t, func(t *rapid.T) { + trace := GetTraceGen().Draw(t, "Trace") + filename := filepath.Join(dir, "trace.json") + err := WriteAndReadTrace(parser, writer, trace, filename) + if err != nil { + t.Fatalf("error writing and reading trace: %v", err) + } + }) +} + +// This can be used to test writing and parsing traces, but does not make much sense +// for testing trace execution, since the generated traces are almost guaranteed to be nonsensical. +func GetTraceGen() *rapid.Generator[[]Step] { + return rapid.SliceOf(GetStepGen()) +} + +func GetStepGen() *rapid.Generator[Step] { + return rapid.Custom(func(t *rapid.T) Step { + return Step{ + Action: GetActionGen().Draw(t, "Action"), + State: GetStateGen().Draw(t, "State"), + } + }) +} diff --git a/tests/e2e/steps.go b/tests/e2e/steps.go index b33d19783a..21db55e3b7 100644 --- a/tests/e2e/steps.go +++ b/tests/e2e/steps.go @@ -1,8 +1,8 @@ package main type Step struct { - action interface{} - state State + Action interface{} + State State } func concatSteps(steps ...[]Step) []Step { @@ -39,9 +39,24 @@ var shortHappyPathSteps = concatSteps( stepsDowntime("consu"), stepsRejectEquivocationProposal("consu", 2), // prop to tombstone bob is rejected stepsDoubleSignOnProviderAndConsumer("consu"), // carol double signs on provider, bob double signs on consumer + stepsSubmitEquivocationProposal("consu", 2), // now prop to tombstone bob is submitted and accepted stepsStartRelayer(), - stepsConsumerRemovalPropNotPassing("consu", 2), // submit removal prop but vote no on it - chain should stay - stepsStopChain("consu", 3), // stop chain + stepsConsumerRemovalPropNotPassing("consu", 3), // submit removal prop but vote no on it - chain should stay + stepsStopChain("consu", 4), // stop chain +) + +var lightClientAttackSteps = concatSteps( + stepsStartChains([]string{"consu"}, false), + stepsDelegate("consu"), + stepsUnbond("consu"), + stepsRedelegateShort("consu"), + stepsDowntime("consu"), + stepsRejectEquivocationProposal("consu", 2), // prop to tombstone bob is rejected + stepsLightClientAttackOnProviderAndConsumer("consu"), // carol double signs on provider, bob double signs on consumer + stepsSubmitEquivocationProposal("consu", 2), // now prop to tombstone bob is submitted and accepted + stepsStartRelayer(), + stepsConsumerRemovalPropNotPassing("consu", 3), // submit removal prop but vote no on it - chain should stay + stepsStopChain("consu", 4), // stop chain ) var slashThrottleSteps = concatSteps( @@ -51,7 +66,7 @@ var slashThrottleSteps = concatSteps( stepsStopChain("consu", 2), ) -var democracySteps = concatSteps( +var democracyRewardsSteps = concatSteps( // democracySteps requires a transfer channel stepsStartChains([]string{"democ"}, true), // delegation needs to happen so the first VSC packet can be delivered @@ -59,7 +74,7 @@ var democracySteps = concatSteps( stepsDemocracy("democ"), ) -var rewardDenomConsumerSteps = concatSteps( +var democracySteps = concatSteps( // democracySteps requires a transfer channel stepsStartChains([]string{"democ"}, true), // delegation needs to happen so the first VSC packet can be delivered diff --git a/tests/e2e/steps_democracy.go b/tests/e2e/steps_democracy.go index 7264c44341..9605f8698a 100644 --- a/tests/e2e/steps_democracy.go +++ b/tests/e2e/steps_democracy.go @@ -5,22 +5,22 @@ const consumerRewardDenom = "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821 func stepsDemocracy(consumerName string) []Step { return []Step{ { - action: registerRepresentativeAction{ - chain: chainID(consumerName), - representatives: []validatorID{validatorID("alice"), validatorID("bob")}, - stakes: []uint{100000000, 40000000}, + Action: registerRepresentativeAction{ + Chain: ChainID(consumerName), + Representatives: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")}, + Stakes: []uint{100000000, 40000000}, }, - state: State{ - chainID(consumerName): ChainState{ - RepresentativePowers: &map[validatorID]uint{ - validatorID("alice"): 100000000, - validatorID("bob"): 40000000, + State: State{ + ChainID(consumerName): ChainState{ + StakedTokens: &map[ValidatorID]uint{ + ValidatorID("alice"): 100000000, + ValidatorID("bob"): 40000000, }, Rewards: &Rewards{ - IsRewarded: map[validatorID]bool{ - validatorID("alice"): true, - validatorID("bob"): true, - validatorID("carol"): false, + IsRewarded: map[ValidatorID]bool{ + ValidatorID("alice"): true, + ValidatorID("bob"): true, + ValidatorID("carol"): false, }, IsIncrementalReward: true, IsNativeDenom: true, @@ -29,31 +29,31 @@ func stepsDemocracy(consumerName string) []Step { }, }, { - action: delegateTokensAction{ - chain: chainID(consumerName), - from: validatorID("carol"), - to: validatorID("alice"), - amount: 500000, + Action: delegateTokensAction{ + Chain: ChainID(consumerName), + From: ValidatorID("carol"), + To: ValidatorID("alice"), + Amount: 500000, }, - state: State{ - chainID(consumerName): ChainState{ + State: State{ + ChainID(consumerName): ChainState{ // Check that delegators on gov-consumer chain can change representative powers - RepresentativePowers: &map[validatorID]uint{ - validatorID("alice"): 100500000, - validatorID("bob"): 40000000, + StakedTokens: &map[ValidatorID]uint{ + ValidatorID("alice"): 100500000, + ValidatorID("bob"): 40000000, }, // Check that delegating on gov-consumer does not change validator powers - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, // Check that tokens are minted and distributed to representatives and their delegators Rewards: &Rewards{ - IsRewarded: map[validatorID]bool{ - validatorID("alice"): true, - validatorID("bob"): true, - validatorID("carol"): true, + IsRewarded: map[ValidatorID]bool{ + ValidatorID("alice"): true, + ValidatorID("bob"): true, + ValidatorID("carol"): true, }, IsIncrementalReward: true, IsNativeDenom: true, @@ -63,20 +63,22 @@ func stepsDemocracy(consumerName string) []Step { }, { // whitelisted legacy proposal can only handle ibctransfer.SendEnabled/ReceiveEnabled - action: submitParamChangeLegacyProposalAction{ - chain: chainID(consumerName), - from: validatorID("alice"), - deposit: 10000001, - subspace: "transfer", - key: "SendEnabled", - value: true, + Action: submitParamChangeLegacyProposalAction{ + Chain: ChainID(consumerName), + From: ValidatorID("alice"), + Deposit: 10000001, + Subspace: "transfer", + Key: "SendEnabled", + Value: true, }, - state: State{ - chainID(consumerName): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9889999998, - validatorID("bob"): 9960000001, + State: State{ + ChainID(consumerName): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9889999998, + ValidatorID("bob"): 9960000001, }, + // Check that the "SendEnabled" transfer parameter is set to false + Params: &([]Param{{Subspace: "transfer", Key: "SendEnabled", Value: "false"}}), Proposals: &map[uint]Proposal{ 1: ParamsProposal{ Deposit: 10000001, @@ -91,17 +93,28 @@ func stepsDemocracy(consumerName string) []Step { }, { // Have accounts vote on something on the gov-consumer chain - action: voteGovProposalAction{ - chain: chainID(consumerName), - from: []validatorID{validatorID("alice"), validatorID("bob")}, - vote: []string{"yes", "no"}, - propNumber: 1, + Action: voteGovProposalAction{ + Chain: ChainID(consumerName), + From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")}, + Vote: []string{"yes", "no"}, + PropNumber: 1, }, - state: State{ - chainID(consumerName): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9889999998, - validatorID("bob"): 9960000001, + State: State{ + ChainID(consumerName): ChainState{ + // Check that alice gets the prop deposit refunded + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9899999999, + ValidatorID("bob"): 9960000001, + }, + // Check that the prop passed + Proposals: &map[uint]Proposal{ + 1: ParamsProposal{ + Deposit: 10000001, + Status: "PROPOSAL_STATUS_PASSED", + Subspace: "transfer", + Key: "SendEnabled", + Value: "true", + }, }, // Check that the parameter is changed on gov-consumer chain Params: &([]Param{{Subspace: "transfer", Key: "SendEnabled", Value: "true"}}), @@ -109,20 +122,20 @@ func stepsDemocracy(consumerName string) []Step { }, }, { - action: relayRewardPacketsToProviderAction{ - consumerChain: chainID(consumerName), - providerChain: chainID("provi"), - port: "transfer", - channel: 1, + Action: relayRewardPacketsToProviderAction{ + ConsumerChain: ChainID(consumerName), + ProviderChain: ChainID("provi"), + Port: "transfer", + Channel: 1, }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ // Check that tokens are not distributed before the denom has been registered Rewards: &Rewards{ - IsRewarded: map[validatorID]bool{ - validatorID("alice"): false, - validatorID("bob"): false, - validatorID("carol"): false, + IsRewarded: map[ValidatorID]bool{ + ValidatorID("alice"): false, + ValidatorID("bob"): false, + ValidatorID("carol"): false, }, IsIncrementalReward: false, IsNativeDenom: false, @@ -133,37 +146,47 @@ func stepsDemocracy(consumerName string) []Step { }, }, { - action: registerConsumerRewardDenomAction{ - chain: chainID("provi"), - from: validatorID("bob"), - denom: consumerRewardDenom, + Action: submitChangeRewardDenomsProposalAction{ + Denom: consumerRewardDenom, + Deposit: 10000001, + From: ValidatorID("bob"), }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ + // Denom not yet registered, gov prop needs to pass first + RegisteredConsumerRewardDenoms: &[]string{}, + }, + }, + }, + { + Action: voteGovProposalAction{ + Chain: ChainID("provi"), + From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, + Vote: []string{"yes", "yes", "yes"}, + PropNumber: 2, + }, + State: State{ + ChainID("provi"): ChainState{ // Check that the denom is registered on provider chain RegisteredConsumerRewardDenoms: &[]string{consumerRewardDenom}, - ValBalances: &map[validatorID]uint{ - // make sure that bob's account was debited - validatorID("bob"): 9490000000, - }, }, }, }, { - action: relayRewardPacketsToProviderAction{ - consumerChain: chainID(consumerName), - providerChain: chainID("provi"), - port: "transfer", - channel: 1, + Action: relayRewardPacketsToProviderAction{ + ConsumerChain: ChainID(consumerName), + ProviderChain: ChainID("provi"), + Port: "transfer", + Channel: 1, }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ // Check that tokens are minted and sent to provider chain and distributed to validators and their delegators on provider chain Rewards: &Rewards{ - IsRewarded: map[validatorID]bool{ - validatorID("alice"): true, - validatorID("bob"): true, - validatorID("carol"): true, + IsRewarded: map[ValidatorID]bool{ + ValidatorID("alice"): true, + ValidatorID("bob"): true, + ValidatorID("carol"): true, }, IsIncrementalReward: false, IsNativeDenom: false, @@ -172,49 +195,49 @@ func stepsDemocracy(consumerName string) []Step { }, }, { - action: downtimeSlashAction{ - chain: chainID(consumerName), - validator: validatorID("bob"), + Action: downtimeSlashAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("bob"), }, - state: State{ + State: State{ // validator should be slashed on consumer, powers not affected on either chain yet - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // Downtime jailing and corresponding voting power change are processed by provider - validatorID("bob"): 0, - validatorID("carol"): 500, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, @@ -222,63 +245,63 @@ func stepsDemocracy(consumerName string) []Step { // A block is incremented each action, hence why VSC is committed on provider, // and can now be relayed as packet to consumer { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // VSC now seen on consumer - validatorID("bob"): 0, - validatorID("carol"): 500, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, }, }, }, { - action: unjailValidatorAction{ - provider: chainID("provi"), - validator: validatorID("bob"), + Action: unjailValidatorAction{ + Provider: ChainID("provi"), + Validator: ValidatorID("bob"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, // Check that slashing on the gov-consumer chain does not result in slashing for the representatives or their delegators - RepresentativePowers: &map[validatorID]uint{ - validatorID("alice"): 100500000, - validatorID("bob"): 40000000, + StakedTokens: &map[ValidatorID]uint{ + ValidatorID("alice"): 100500000, + ValidatorID("bob"): 40000000, }, }, }, diff --git a/tests/e2e/steps_double_sign.go b/tests/e2e/steps_double_sign.go index c007fa5c1c..4d69569b29 100644 --- a/tests/e2e/steps_double_sign.go +++ b/tests/e2e/steps_double_sign.go @@ -5,49 +5,49 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { return []Step{ { // provider double sign - action: doublesignSlashAction{ - chain: chainID("provi"), - validator: validatorID("carol"), + Action: doublesignSlashAction{ + Chain: ChainID("provi"), + Validator: ValidatorID("carol"), }, - state: State{ + State: State{ // slash on provider - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, // from 500 to 0 + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, // from 500 to 0 }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, // not tombstoned on consumerName yet + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, // not tombstoned on consumerName yet }, }, }, }, { // relay power change to consumerName - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, // consumerName channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, // consumerName channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, // tombstoning visible on consumerName + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, // tombstoning visible on consumerName }, }, }, @@ -56,72 +56,72 @@ func stepsDoubleSignOnProviderAndConsumer(consumerName string) []Step { // consumer double sign // provider will only log the double sign slash // stepsSubmitEquivocationProposal will cause the double sign slash to be executed - action: doublesignSlashAction{ - chain: chainID("consu"), - validator: validatorID("bob"), + Action: doublesignSlashAction{ + Chain: ChainID("consu"), + Validator: ValidatorID("bob"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // not tombstoned - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // not tombstoned - validatorID("carol"): 0, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, }, }, }, }, { // consumer learns about the double sign - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // not tombstoned - validatorID("carol"): 0, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, }, }, }, diff --git a/tests/e2e/steps_downtime.go b/tests/e2e/steps_downtime.go index e6d320bec1..f8a610052d 100644 --- a/tests/e2e/steps_downtime.go +++ b/tests/e2e/steps_downtime.go @@ -15,49 +15,50 @@ import "time" func stepsDowntime(consumerName string) []Step { return []Step{ { - action: downtimeSlashAction{ - chain: chainID(consumerName), - validator: validatorID("bob"), + Action: downtimeSlashAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("bob"), }, - state: State{ + State: State{ // validator should be slashed on consumer, powers not affected on either chain yet - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, // Downtime jailing and corresponding voting power change are processed by provider - validatorID("bob"): 0, - validatorID("carol"): 501, + ValidatorID("bob"): 0, + ValidatorID("carol"): 501, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + // Bob's stake may or may not be slashed at this point depending on comet vs cometmock + // See https://github.com/cosmos/interchain-security/issues/1304 + ValidatorID("carol"): 501, }, }, }, @@ -65,144 +66,144 @@ func stepsDowntime(consumerName string) []Step { // A block is incremented each action, hence why VSC is committed on provider, // and can now be relayed as packet to consumer { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, // VSC now seen on consumer - validatorID("bob"): 0, - validatorID("carol"): 501, + ValidatorID("bob"): 0, + ValidatorID("carol"): 501, }, }, }, }, { - action: unjailValidatorAction{ - provider: chainID("provi"), - validator: validatorID("bob"), - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + Action: unjailValidatorAction{ + Provider: ChainID("provi"), + Validator: ValidatorID("bob"), + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, // bob's stake should not be slashed // since the slash was initiated from consumer - validatorID("bob"): 500, - validatorID("carol"): 501, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, - validatorID("carol"): 501, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, + ValidatorID("carol"): 501, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, // bob's stake should not be slashed // since the slash was initiated from consumer - validatorID("bob"): 500, - validatorID("carol"): 501, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, }, // Now we test provider initiated downtime/slashing { - action: downtimeSlashAction{ - chain: chainID("provi"), - validator: validatorID("carol"), + Action: downtimeSlashAction{ + Chain: ChainID("provi"), + Validator: ValidatorID("carol"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Non faulty validators still maintain just above 2/3 power here - validatorID("alice"): 509, - validatorID("bob"): 500, + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // Carol's stake should be slashed and jailed // downtime slash was initiated from provider - validatorID("carol"): 0, + ValidatorID("carol"): 0, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, }, }, { - action: unjailValidatorAction{ - provider: chainID("provi"), - validator: validatorID("carol"), - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, + Action: unjailValidatorAction{ + Provider: ChainID("provi"), + Validator: ValidatorID("carol"), + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, }, }, }, @@ -217,49 +218,49 @@ func stepsDowntime(consumerName string) []Step { func stepsDowntimeWithOptOut(consumerName string) []Step { return []Step{ { - action: downtimeSlashAction{ - chain: chainID(consumerName), - validator: validatorID("alice"), + Action: downtimeSlashAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("alice"), }, - state: State{ + State: State{ // powers not affected on either chain - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 60, - validatorID("bob"): 500, - validatorID("carol"): 950, + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 60, + ValidatorID("bob"): 500, + ValidatorID("carol"): 950, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 60, - validatorID("bob"): 500, - validatorID("carol"): 950, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 60, + ValidatorID("bob"): 500, + ValidatorID("carol"): 950, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // alice is not slashed or jailed due to soft opt out - validatorID("alice"): 60, - validatorID("bob"): 500, - validatorID("carol"): 950, + ValidatorID("alice"): 60, + ValidatorID("bob"): 500, + ValidatorID("carol"): 950, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 60, - validatorID("bob"): 500, - validatorID("carol"): 950, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 60, + ValidatorID("bob"): 500, + ValidatorID("carol"): 950, }, }, }, @@ -273,25 +274,26 @@ func stepsDowntimeWithOptOut(consumerName string) []Step { func stepsThrottledDowntime(consumerName string) []Step { return []Step{ { - action: downtimeSlashAction{ - chain: chainID(consumerName), - validator: validatorID("bob"), - }, - state: State{ - // slash packet queued on consumer, but powers not affected on either chain yet - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + Action: downtimeSlashAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("bob"), + }, + State: State{ + // slash packet queued for bob on consumer, but powers not affected on either chain yet + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, + ConsumerPendingPacketQueueSize: uintPtr(1), // bob's downtime slash packet is queued }, }, }, @@ -299,148 +301,148 @@ func stepsThrottledDowntime(consumerName string) []Step { // and consumer receives ack that provider recv the downtime slash. // The latter is necessary for the consumer to send the second downtime slash. { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, // bob is jailed - validatorID("carol"): 500, - }, - // no provider throttling engaged yet - GlobalSlashQueueSize: uintPointer(0), - ConsumerChainQueueSizes: &map[chainID]uint{ - chainID(consumerName): uint(0), + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, // bob is jailed + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ + ChainID(consumerName): ChainState{ // VSC packet applying jailing is not yet relayed to consumer - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, + ConsumerPendingPacketQueueSize: uintPtr(0), // slash packet handled ack clears consumer queue }, }, }, + // Invoke carol downtime slash on consumer { - action: downtimeSlashAction{ - chain: chainID(consumerName), - validator: validatorID("carol"), - }, - state: State{ - // powers not affected on either chain yet - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, - validatorID("carol"): 500, + Action: downtimeSlashAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("carol"), + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - // VSC packet applying jailing is not yet relayed to consumer - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, // VSC packet jailing bob is not yet relayed to consumer + ValidatorID("carol"): 500, }, + ConsumerPendingPacketQueueSize: uintPtr(1), // carol's downtime slash packet is queued }, }, }, + // Relay slash packet to provider, and ack back to consumer { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, - validatorID("carol"): 500, // not slashed due to throttling - }, - GlobalSlashQueueSize: uintPointer(1), // carol's slash request is throttled - ConsumerChainQueueSizes: &map[chainID]uint{ - chainID(consumerName): uint(1), + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, // slash packet for carol recv by provider, carol not slashed due to throttling }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, // VSC packet applying bob jailing is also relayed and recv by consumer + ValidatorID("carol"): 500, }, + ConsumerPendingPacketQueueSize: uintPtr(1), // slash packet bounced ack keeps carol's downtime slash packet queued }, }, }, { - action: slashThrottleDequeue{ - chain: chainID(consumerName), - currentQueueSize: 1, - nextQueueSize: 0, + Action: slashMeterReplenishmentAction{ + TargetValue: 0, // We just want slash meter to be non-negative + // Slash meter replenish fraction is set to 10%, replenish period is 20 seconds, see config.go // Meter is initially at 10%, decremented to -23% from bob being jailed. It'll then take three replenishments - // for meter to become positive again. 3*20 = 60 seconds + buffer = 80 seconds - timeout: 80 * time.Second, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, - validatorID("carol"): 0, // Carol is jailed upon packet being handled on provider - }, - GlobalSlashQueueSize: uintPointer(0), // slash packets dequeued - ConsumerChainQueueSizes: &map[chainID]uint{ - chainID(consumerName): 0, + // for meter to become positive again. 3*20 = 60 seconds + buffer = 100 seconds + Timeout: 100 * time.Second, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, // Carol still not slashed, packet must be retried }, }, - chainID(consumerName): ChainState{ + ChainID(consumerName): ChainState{ // no updates received on consumer - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, - validatorID("carol"): 500, + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, + ConsumerPendingPacketQueueSize: uintPtr(1), // packet still queued }, }, }, - // A block is incremented each action, hence why VSC is committed on provider, - // and can now be relayed as packet to consumer + // Wait for retry delay period to pass. + // Retry delay period is set to 30 seconds, see config.go, + // wait this amount of time to elapse the period. { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, - }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, - validatorID("carol"): 0, - }, - GlobalSlashQueueSize: uintPointer(0), - ConsumerChainQueueSizes: &map[chainID]uint{ - chainID(consumerName): 0, + Action: waitTimeAction{ + WaitTime: 30 * time.Second, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - // throttled update gets to consumer - validatorID("bob"): 0, - validatorID("carol"): 0, + ChainID(consumerName): ChainState{ + ConsumerPendingPacketQueueSize: uintPtr(1), // packet still queued + }, + }, + }, + // Relay now that retry delay period has passed, confirm provider applies jailing + { + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 0, // jailed! }, }, + ChainID(consumerName): ChainState{ + ConsumerPendingPacketQueueSize: uintPtr(0), // relayed slash packet handled ack clears consumer queue + }, }, }, } diff --git a/tests/e2e/steps_light_client_attack.go b/tests/e2e/steps_light_client_attack.go new file mode 100644 index 0000000000..284b3fafea --- /dev/null +++ b/tests/e2e/steps_light_client_attack.go @@ -0,0 +1,130 @@ +package main + +// Steps that make carol double sign on the provider, and bob double sign on a single consumer +func stepsLightClientAttackOnProviderAndConsumer(consumerName string) []Step { + return []Step{ + { + // Provider double sign + Action: lightClientEquivocationAttackAction{ + Chain: ChainID("provi"), + Validator: ValidatorID("carol"), + }, + State: State{ + // Slash on provider + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, // from 500 to 0 + }, + }, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, // not tombstoned on consumerName yet + }, + }, + }, + }, + { + // Relay power change to consumerName + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, // consumerName channel + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, + }, + }, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, // tombstoning visible on consumerName + }, + }, + }, + }, + { + // Consumer double sign + // Provider will only log the double sign slash + // stepsSubmitEquivocationProposal will cause the double sign slash to be executed + Action: lightClientEquivocationAttackAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("bob"), + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, + }, + }, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, + }, + }, + }, + }, + { + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, + }, + }, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, + }, + }, + }, + }, + { + // Consumer learns about the double sign + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, + }, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, + }, + }, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, + }, + }, + }, + }, + } +} diff --git a/tests/e2e/steps_multi_consumer_delegation.go b/tests/e2e/steps_multi_consumer_delegation.go index 45536c0679..67368e277c 100644 --- a/tests/e2e/steps_multi_consumer_delegation.go +++ b/tests/e2e/steps_multi_consumer_delegation.go @@ -5,96 +5,96 @@ func stepsMultiConsumerDelegate(consumer1, consumer2 string) []Step { return []Step{ { // changes not visible on any consumer - action: delegateTokensAction{ - chain: chainID("provi"), - from: validatorID("alice"), - to: validatorID("alice"), - amount: 11000000, + Action: delegateTokensAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + To: ValidatorID("alice"), + Amount: 11000000, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, // this changes from 500 - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // this changes from 500 + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 500, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 500, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 500, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 500, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { // relay changes to consumer1 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, // consumer1 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, // consumer1 Channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, // changed - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // changed + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 500, // unchanged - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 500, // unchanged + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { // relay changes to consumer2 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer2), - port: "provider", - channel: 1, // consumer2 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer2), + Port: "provider", + Channel: 1, // consumer2 Channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, // changed - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // changed + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, @@ -107,96 +107,96 @@ func stepsMultiConsumerDelegate(consumer1, consumer2 string) []Step { func stepsMultiConsumerUnbond(consumer1, consumer2 string) []Step { return []Step{ { - action: unbondTokensAction{ - chain: chainID("provi"), - unbondFrom: validatorID("alice"), - sender: validatorID("alice"), - amount: 1000000, + Action: unbondTokensAction{ + Chain: ChainID("provi"), + UnbondFrom: ValidatorID("alice"), + Sender: ValidatorID("alice"), + Amount: 1000000, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, // change from 511 - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, // change from 511 + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, // no change - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // no change + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, // no change - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // no change + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { // relay to consumer1 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, // consumer1 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, // consumer1 Channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, // change from 511 - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, // change from 511 + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, // no change - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // no change + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { // relay to consumer2 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer2), - port: "provider", - channel: 1, // consumer2 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer2), + Port: "provider", + Channel: 1, // consumer2 Channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, // change from 511 - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, // change from 511 + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, @@ -209,35 +209,35 @@ func stepsMultiConsumerUnbond(consumer1, consumer2 string) []Step { func stepsMultiConsumerRedelegate(consumer1, consumer2 string) []Step { return []Step{ { - action: redelegateTokensAction{ - chain: chainID("provi"), - src: validatorID("alice"), - dst: validatorID("carol"), - txSender: validatorID("alice"), + Action: redelegateTokensAction{ + Chain: ChainID("provi"), + Src: ValidatorID("alice"), + Dst: ValidatorID("carol"), + TxSender: ValidatorID("alice"), // Leave alice with majority stake so non-faulty validators maintain more than // 2/3 voting power during downtime tests below, avoiding chain halt - amount: 1000000, + Amount: 1000000, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, // no change - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, // no change + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, // no change - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, // no change + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, @@ -245,64 +245,64 @@ func stepsMultiConsumerRedelegate(consumer1, consumer2 string) []Step { { // relay to consumer1 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, // consumer1 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, // consumer1 Channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, // change from 510 - validatorID("bob"): 500, - validatorID("carol"): 501, // change from 500 + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, // change from 510 + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, // change from 500 }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, // no change - validatorID("bob"): 500, - validatorID("carol"): 500, // no change + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, // no change + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, // no change }, }, }, }, { // relay to consumer2 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer2), - port: "provider", - channel: 1, // consumer1 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer2), + Port: "provider", + Channel: 1, // consumer1 Channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, // change from 510 - validatorID("bob"): 500, - validatorID("carol"): 501, // change from 500 + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, // change from 510 + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, // change from 500 }, }, }, diff --git a/tests/e2e/steps_multi_consumer_double_sign.go b/tests/e2e/steps_multi_consumer_double_sign.go index d12eb37eff..5388ea5c75 100644 --- a/tests/e2e/steps_multi_consumer_double_sign.go +++ b/tests/e2e/steps_multi_consumer_double_sign.go @@ -13,95 +13,95 @@ func stepsMultiConsumerDoubleSign(consumer1, consumer2 string) []Step { return []Step{ { // provider double sign - action: doublesignSlashAction{ - chain: chainID("provi"), - validator: validatorID("carol"), + Action: doublesignSlashAction{ + Chain: ChainID("provi"), + Validator: ValidatorID("carol"), }, - state: State{ + State: State{ // slash on provider - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, // from 500 to 0 + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, // from 500 to 0 }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, // not tombstoned on consumer1 yet + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, // not tombstoned on consumer1 yet }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, // not tombstoned on consumer2 yet + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, // not tombstoned on consumer2 yet }, }, }, }, { // relay power change to consumer1 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, // consumer1 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, // consumer1 channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, // tombstoning visible on consumer1 + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, // tombstoning visible on consumer1 }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, // tombstoning NOT YET visible on consumer2 + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, // tombstoning NOT YET visible on consumer2 }, }, }, }, { // relay power change to consumer2 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer2), - port: "provider", - channel: 1, // consumer2 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer2), + Port: "provider", + Channel: 1, // consumer2 channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, // tombstoned on consumer2 + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, // tombstoned on consumer2 }, }, }, @@ -109,118 +109,118 @@ func stepsMultiConsumerDoubleSign(consumer1, consumer2 string) []Step { { // consumer double sign // nothing should happen - double sign from consumer is dropped - action: doublesignSlashAction{ - chain: chainID("consu"), - validator: validatorID("bob"), + Action: doublesignSlashAction{ + Chain: ChainID("consu"), + Validator: ValidatorID("bob"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, // consumer1 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, // consumer1 channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // not tombstoned - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // not tombstoned - validatorID("carol"): 0, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // not tombstoned - validatorID("carol"): 0, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, }, }, }, }, { // consumer1 learns about the double sign - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, // consumer1 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, // consumer1 channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // not tombstoned - validatorID("carol"): 0, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // not tombstoned - validatorID("carol"): 0, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // not tombstoned + ValidatorID("carol"): 0, }, }, }, }, { // consumer2 learns about the double sign - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer2), - port: "provider", - channel: 1, // consumer2 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer2), + Port: "provider", + Channel: 1, // consumer2 channel }, - state: State{ - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, - }, - }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + State: State{ + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, + }, + }, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, }, diff --git a/tests/e2e/steps_multi_consumer_downtime.go b/tests/e2e/steps_multi_consumer_downtime.go index ce6cbdff59..eba44ed361 100644 --- a/tests/e2e/steps_multi_consumer_downtime.go +++ b/tests/e2e/steps_multi_consumer_downtime.go @@ -7,31 +7,31 @@ package main func stepsMultiConsumerDowntimeFromConsumer(consumer1, consumer2 string) []Step { return []Step{ { - action: downtimeSlashAction{ - chain: chainID(consumer1), - validator: validatorID("bob"), + Action: downtimeSlashAction{ + Chain: ChainID(consumer1), + Validator: ValidatorID("bob"), }, - state: State{ + State: State{ // validator should be slashed on consumer, powers not affected on either chain yet - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, @@ -39,32 +39,32 @@ func stepsMultiConsumerDowntimeFromConsumer(consumer1, consumer2 string) []Step { // Downtime jailing and corresponding voting power change are processed by provider // Validator powers are unchanged on consumer chains - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, - validatorID("carol"): 501, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, + ValidatorID("carol"): 501, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, @@ -73,149 +73,149 @@ func stepsMultiConsumerDowntimeFromConsumer(consumer1, consumer2 string) []Step // A block is incremented each action, hence why VSC is committed on provider, // and can now be relayed as packet to consumer // consumer1 will now see the validator power changes - consumer2 will not (had not been relayed) - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, // consumer1 chan + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, // consumer1 chan }, - state: State{ + State: State{ // change propagated to consumer1 - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, // VSC now seen on consumer1 - validatorID("bob"): 0, - validatorID("carol"): 501, + ValidatorID("bob"): 0, + ValidatorID("carol"): 501, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, // VSC has not arrived to on consumer2 - validatorID("bob"): 500, - validatorID("carol"): 501, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, }, { // both consumer1 and consumer will now see the validator power changes - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer2), - port: "provider", - channel: 1, // consumer2 chan + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer2), + Port: "provider", + Channel: 1, // consumer2 chan }, - state: State{ - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, // both consumers see the change - validatorID("carol"): 501, + State: State{ + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, // both consumers see the change + ValidatorID("carol"): 501, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, // both consumers see the change - validatorID("carol"): 501, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, // both consumers see the change + ValidatorID("carol"): 501, }, }, }, }, { - action: unjailValidatorAction{ - provider: chainID("provi"), - validator: validatorID("bob"), + Action: unjailValidatorAction{ + Provider: ChainID("provi"), + Validator: ValidatorID("bob"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, // bob's stake should not be slashed since slash comes from consumer1 - validatorID("bob"): 500, - validatorID("carol"): 501, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, // change is not visible on consumer1 - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, - validatorID("carol"): 501, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, + ValidatorID("carol"): 501, }, }, // change is not visible on consumer2 - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, - validatorID("carol"): 501, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, + ValidatorID("carol"): 501, }, }, }, }, { // relay to consumer 1 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // change has arrived to consumer1 (no slashing) - validatorID("carol"): 501, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // change has arrived to consumer1 (no slashing) + ValidatorID("carol"): 501, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, // change has not arrived to consumer2 - validatorID("carol"): 501, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, // change has not arrived to consumer2 + ValidatorID("carol"): 501, }, }, }, }, { // relay to consumer2 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer2), - port: "provider", - channel: 1, // consumer2 chan + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer2), + Port: "provider", + Channel: 1, // consumer2 chan }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // change has arrived to consumer1 (no slashing) - validatorID("carol"): 501, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // change has arrived to consumer1 (no slashing) + ValidatorID("carol"): 501, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // change has arrived to consumer2 (no slashing) - validatorID("carol"): 501, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // change has arrived to consumer2 (no slashing) + ValidatorID("carol"): 501, }, }, }, @@ -229,190 +229,190 @@ func stepsMultiConsumerDowntimeFromProvider(consumer1, consumer2 string) []Step return []Step{ // Now we test provider initiated downtime/slashing { - action: downtimeSlashAction{ - chain: chainID("provi"), - validator: validatorID("carol"), + Action: downtimeSlashAction{ + Chain: ChainID("provi"), + Validator: ValidatorID("carol"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Non faulty validators still maintain just above 2/3 power here - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, // consumer 1 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, // consumer 1 channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Non faulty validators still maintain just above 2/3 power here - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, // powers now changed - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, // not relayed yet - powers unchanged - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 501, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 501, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer2), - port: "provider", - channel: 1, // consumer2 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer2), + Port: "provider", + Channel: 1, // consumer2 channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Non faulty validators still maintain just above 2/3 power here - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, // powers now changed - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, }, }, { - action: unjailValidatorAction{ - provider: chainID("provi"), - validator: validatorID("carol"), + Action: unjailValidatorAction{ + Provider: ChainID("provi"), + Validator: ValidatorID("carol"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, // slashed because infraction was committed on provider + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, // slashed because infraction was committed on provider }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer1), - port: "provider", - channel: 0, // consumer1 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer1), + Port: "provider", + Channel: 0, // consumer1 channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, }, }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, }, }, // not relayed yet - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumer2), - port: "provider", - channel: 1, // consumer2 channel + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumer2), + Port: "provider", + Channel: 1, // consumer2 channel }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, - }, - }, - chainID(consumer1): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, - }, - }, - chainID(consumer2): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, + }, + }, + ChainID(consumer1): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, + }, + }, + ChainID(consumer2): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, }, }, }, diff --git a/tests/e2e/steps_reward_denom.go b/tests/e2e/steps_reward_denom.go index 9aad8ec7a8..d5b524fbd9 100644 --- a/tests/e2e/steps_reward_denom.go +++ b/tests/e2e/steps_reward_denom.go @@ -3,22 +3,22 @@ package main func stepsRewardDenomConsumer(consumerName string) []Step { return []Step{ { - action: registerRepresentativeAction{ - chain: chainID(consumerName), - representatives: []validatorID{validatorID("alice"), validatorID("bob")}, - stakes: []uint{100000000, 40000000}, + Action: registerRepresentativeAction{ + Chain: ChainID(consumerName), + Representatives: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")}, + Stakes: []uint{100000000, 40000000}, }, - state: State{ - chainID(consumerName): ChainState{ - RepresentativePowers: &map[validatorID]uint{ - validatorID("alice"): 100000000, - validatorID("bob"): 40000000, + State: State{ + ChainID(consumerName): ChainState{ + StakedTokens: &map[ValidatorID]uint{ + ValidatorID("alice"): 100000000, + ValidatorID("bob"): 40000000, }, Rewards: &Rewards{ - IsRewarded: map[validatorID]bool{ - validatorID("alice"): true, - validatorID("bob"): true, - validatorID("carol"): false, + IsRewarded: map[ValidatorID]bool{ + ValidatorID("alice"): true, + ValidatorID("bob"): true, + ValidatorID("carol"): false, }, IsIncrementalReward: true, IsNativeDenom: true, @@ -27,31 +27,31 @@ func stepsRewardDenomConsumer(consumerName string) []Step { }, }, { - action: delegateTokensAction{ - chain: chainID(consumerName), - from: validatorID("carol"), - to: validatorID("alice"), - amount: 500000, + Action: delegateTokensAction{ + Chain: ChainID(consumerName), + From: ValidatorID("carol"), + To: ValidatorID("alice"), + Amount: 500000, }, - state: State{ - chainID(consumerName): ChainState{ + State: State{ + ChainID(consumerName): ChainState{ // Check that delegators on gov-consumer chain can change representative powers - RepresentativePowers: &map[validatorID]uint{ - validatorID("alice"): 100500000, - validatorID("bob"): 40000000, + StakedTokens: &map[ValidatorID]uint{ + ValidatorID("alice"): 100500000, + ValidatorID("bob"): 40000000, }, // Check that delegating on gov-consumer does not change validator powers - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, // Check that tokens are minted and distributed to representatives and their delegators Rewards: &Rewards{ - IsRewarded: map[validatorID]bool{ - validatorID("alice"): true, - validatorID("bob"): true, - validatorID("carol"): true, + IsRewarded: map[ValidatorID]bool{ + ValidatorID("alice"): true, + ValidatorID("bob"): true, + ValidatorID("carol"): true, }, IsIncrementalReward: true, IsNativeDenom: true, @@ -61,20 +61,22 @@ func stepsRewardDenomConsumer(consumerName string) []Step { }, { // whitelisted legacy proposal can only handle ibctransfer.SendEnabled/ReceiveEnabled - action: submitParamChangeLegacyProposalAction{ - chain: chainID(consumerName), - from: validatorID("alice"), - deposit: 10000001, - subspace: "transfer", - key: "SendEnabled", - value: true, + Action: submitParamChangeLegacyProposalAction{ + Chain: ChainID(consumerName), + From: ValidatorID("alice"), + Deposit: 10000001, + Subspace: "transfer", + Key: "SendEnabled", + Value: true, }, - state: State{ - chainID(consumerName): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9889999998, - validatorID("bob"): 9960000001, + State: State{ + ChainID(consumerName): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9889999998, + ValidatorID("bob"): 9960000001, }, + // Check that the "SendEnabled" transfer parameter is set to false + Params: &([]Param{{Subspace: "transfer", Key: "SendEnabled", Value: "false"}}), Proposals: &map[uint]Proposal{ 1: ParamsProposal{ Deposit: 10000001, @@ -89,17 +91,28 @@ func stepsRewardDenomConsumer(consumerName string) []Step { }, { // Have accounts vote on something on the gov-consumer chain - action: voteGovProposalAction{ - chain: chainID(consumerName), - from: []validatorID{validatorID("alice"), validatorID("bob")}, - vote: []string{"yes", "no"}, - propNumber: 1, + Action: voteGovProposalAction{ + Chain: ChainID(consumerName), + From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob")}, + Vote: []string{"yes", "no"}, + PropNumber: 1, }, - state: State{ - chainID(consumerName): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9889999998, - validatorID("bob"): 9960000001, + State: State{ + ChainID(consumerName): ChainState{ + // Check that alice gets the prop deposit refunded + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9899999999, + ValidatorID("bob"): 9960000001, + }, + // Check that the prop passed + Proposals: &map[uint]Proposal{ + 1: ParamsProposal{ + Deposit: 10000001, + Status: "PROPOSAL_STATUS_PASSED", + Subspace: "transfer", + Key: "SendEnabled", + Value: "true", + }, }, // Check that the parameter is changed on gov-consumer chain Params: &([]Param{{Subspace: "transfer", Key: "SendEnabled", Value: "true"}}), @@ -107,20 +120,20 @@ func stepsRewardDenomConsumer(consumerName string) []Step { }, }, { - action: relayRewardPacketsToProviderAction{ - consumerChain: chainID(consumerName), - providerChain: chainID("provi"), - port: "transfer", - channel: 1, + Action: relayRewardPacketsToProviderAction{ + ConsumerChain: ChainID(consumerName), + ProviderChain: ChainID("provi"), + Port: "transfer", + Channel: 1, }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ // Check that tokens are not distributed before the denom has been registered Rewards: &Rewards{ - IsRewarded: map[validatorID]bool{ - validatorID("alice"): false, - validatorID("bob"): false, - validatorID("carol"): false, + IsRewarded: map[ValidatorID]bool{ + ValidatorID("alice"): false, + ValidatorID("bob"): false, + ValidatorID("carol"): false, }, IsIncrementalReward: false, IsNativeDenom: false, @@ -131,37 +144,47 @@ func stepsRewardDenomConsumer(consumerName string) []Step { }, }, { - action: registerConsumerRewardDenomAction{ - chain: chainID("provi"), - from: validatorID("bob"), - denom: "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9", + Action: submitChangeRewardDenomsProposalAction{ + Denom: "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9", + Deposit: 10000001, + From: ValidatorID("bob"), }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ + // Denom not yet registered, gov prop needs to pass first + RegisteredConsumerRewardDenoms: &[]string{}, + }, + }, + }, + { + Action: voteGovProposalAction{ + Chain: ChainID("provi"), + From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, + Vote: []string{"yes", "yes", "yes"}, + PropNumber: 2, + }, + State: State{ + ChainID("provi"): ChainState{ // Check that the denom is registered on provider chain RegisteredConsumerRewardDenoms: &[]string{"ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9"}, - ValBalances: &map[validatorID]uint{ - // make sure that bob's account was debited - validatorID("bob"): 9490000000, - }, }, }, }, { - action: relayRewardPacketsToProviderAction{ - consumerChain: chainID(consumerName), - providerChain: chainID("provi"), - port: "transfer", - channel: 1, + Action: relayRewardPacketsToProviderAction{ + ConsumerChain: ChainID(consumerName), + ProviderChain: ChainID("provi"), + Port: "transfer", + Channel: 1, }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ // Check that tokens are not minted and sent to provider chain and distributed to validators and their delegators on provider chain Rewards: &Rewards{ - IsRewarded: map[validatorID]bool{ - validatorID("alice"): false, - validatorID("bob"): false, - validatorID("carol"): false, + IsRewarded: map[ValidatorID]bool{ + ValidatorID("alice"): false, + ValidatorID("bob"): false, + ValidatorID("carol"): false, }, IsIncrementalReward: false, IsNativeDenom: false, @@ -170,113 +193,113 @@ func stepsRewardDenomConsumer(consumerName string) []Step { }, }, { - action: downtimeSlashAction{ - chain: chainID(consumerName), - validator: validatorID("bob"), + Action: downtimeSlashAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("bob"), }, - state: State{ + State: State{ // validator should be slashed on consumer, powers not affected on either chain yet - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // Downtime jailing and corresponding voting power change are processed by provider - validatorID("bob"): 0, - validatorID("carol"): 500, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, - // A block is incremented each action, hence why VSC is committed on provider, + // A block is incremented each Action, hence why VSC is committed on provider, // and can now be relayed as packet to consumer { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, // VSC now seen on consumer - validatorID("bob"): 0, - validatorID("carol"): 500, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, }, }, }, { - action: unjailValidatorAction{ - provider: chainID("provi"), - validator: validatorID("bob"), + Action: unjailValidatorAction{ + Provider: ChainID("provi"), + Validator: ValidatorID("bob"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, // Check that slashing on the gov-consumer chain does not result in slashing for the representatives or their delegators - RepresentativePowers: &map[validatorID]uint{ - validatorID("alice"): 100500000, - validatorID("bob"): 40000000, + StakedTokens: &map[ValidatorID]uint{ + ValidatorID("alice"): 100500000, + ValidatorID("bob"): 40000000, }, }, }, diff --git a/tests/e2e/steps_sovereign_changeover.go b/tests/e2e/steps_sovereign_changeover.go index c02b2c4d43..8c053299cc 100644 --- a/tests/e2e/steps_sovereign_changeover.go +++ b/tests/e2e/steps_sovereign_changeover.go @@ -10,24 +10,24 @@ import clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" func stepsSovereignTransferChan() []Step { return []Step{ { - action: createIbcClientsAction{ - chainA: chainID("sover"), - chainB: chainID("provi"), + Action: createIbcClientsAction{ + ChainA: ChainID("sover"), + ChainB: ChainID("provi"), }, - state: State{}, + State: State{}, }, { // this will create channel-0 connection end on both chain - action: addIbcChannelAction{ - chainA: chainID("sover"), - chainB: chainID("provi"), - connectionA: 0, - portA: "transfer", - portB: "transfer", - order: "unordered", - version: "ics20-1", + Action: addIbcChannelAction{ + ChainA: ChainID("sover"), + ChainB: ChainID("provi"), + ConnectionA: 0, + PortA: "transfer", + PortB: "transfer", + Order: "unordered", + Version: "ics20-1", }, - state: State{}, + State: State{}, }, } } @@ -36,29 +36,29 @@ func stepsSovereignTransferChan() []Step { func stepsChangeoverToConsumer(consumerName string) []Step { s := []Step{ { - action: submitConsumerAdditionProposalAction{ - preCCV: true, - chain: chainID("provi"), - from: validatorID("alice"), - deposit: 10000001, - consumerChain: chainID(consumerName), + Action: submitConsumerAdditionProposalAction{ + PreCCV: true, + Chain: ChainID("provi"), + From: ValidatorID("alice"), + Deposit: 10000001, + ConsumerChain: ChainID(consumerName), // chain-0 is the transfer channelID that gets created in stepsSovereignTransferChan // the consumer chain will use this channel to send rewards to the provider chain // there is no need to create a new channel for rewards distribution - distributionChannel: "channel-0", - spawnTime: 0, - initialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111}, // 1 block after upgrade !important + DistributionChannel: "channel-0", + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111}, // 1 block after upgrade !important }, - state: State{ - chainID("provi"): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9489999999, - validatorID("bob"): 9500000000, + State: State{ + ChainID("provi"): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9489999999, + ValidatorID("bob"): 9500000000, }, Proposals: &map[uint]Proposal{ 1: ConsumerAdditionProposal{ Deposit: 10000001, - Chain: chainID(consumerName), + Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111}, Status: "PROPOSAL_STATUS_VOTING_PERIOD", @@ -68,78 +68,78 @@ func stepsChangeoverToConsumer(consumerName string) []Step { }, }, { - action: voteGovProposalAction{ - chain: chainID("provi"), - from: []validatorID{validatorID("alice"), validatorID("bob"), validatorID("carol")}, - vote: []string{"yes", "yes", "yes"}, - propNumber: 1, + Action: voteGovProposalAction{ + Chain: ChainID("provi"), + From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, + Vote: []string{"yes", "yes", "yes"}, + PropNumber: 1, }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ Proposals: &map[uint]Proposal{ 1: ConsumerAdditionProposal{ Deposit: 10000001, - Chain: chainID(consumerName), + Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 111}, Status: "PROPOSAL_STATUS_PASSED", }, }, - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9500000000, - validatorID("bob"): 9500000000, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9500000000, + ValidatorID("bob"): 9500000000, }, }, }, }, { - action: ChangeoverChainAction{ - sovereignChain: chainID(consumerName), - providerChain: chainID("provi"), - validators: []StartChainValidator{ - {id: validatorID("alice"), stake: 500000000, allocation: 10000000000}, - {id: validatorID("bob"), stake: 500000000, allocation: 10000000000}, - {id: validatorID("carol"), stake: 500000000, allocation: 10000000000}, + Action: ChangeoverChainAction{ + SovereignChain: ChainID(consumerName), + ProviderChain: ChainID("provi"), + Validators: []StartChainValidator{ + {Id: ValidatorID("alice"), Stake: 500000000, Allocation: 10000000000}, + {Id: ValidatorID("bob"), Stake: 500000000, Allocation: 10000000000}, + {Id: ValidatorID("carol"), Stake: 500000000, Allocation: 10000000000}, }, - genesisChanges: ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"", + GenesisChanges: ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"", }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 500, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 500, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // uses val powers from consumer - validatorID("alice"): 500, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 500, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: addIbcConnectionAction{ - chainA: chainID(consumerName), - chainB: chainID("provi"), - clientA: 1, - clientB: 1, + Action: addIbcConnectionAction{ + ChainA: ChainID(consumerName), + ChainB: ChainID("provi"), + ClientA: 1, + ClientB: 1, }, - state: State{}, + State: State{}, }, { - action: addIbcChannelAction{ - chainA: chainID(consumerName), - chainB: chainID("provi"), - connectionA: 1, - portA: "consumer", - portB: "provider", - order: "ordered", + Action: addIbcChannelAction{ + ChainA: ChainID(consumerName), + ChainB: ChainID("provi"), + ConnectionA: 1, + PortA: "consumer", + PortB: "provider", + Order: "ordered", }, - state: State{}, + State: State{}, }, } @@ -154,33 +154,33 @@ func stepsChangeoverToConsumer(consumerName string) []Step { func stepRunSovereignChain() []Step { return []Step{ { - action: StartSovereignChainAction{ - chain: chainID("sover"), - validators: []StartChainValidator{ - {id: validatorID("alice"), stake: 500000000, allocation: 10000000000}, + Action: StartSovereignChainAction{ + Chain: ChainID("sover"), + Validators: []StartChainValidator{ + {Id: ValidatorID("alice"), Stake: 500000000, Allocation: 10000000000}, }, }, - state: State{ - chainID("sover"): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9500000000, + State: State{ + ChainID("sover"): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9500000000, }, }, }, }, { - action: delegateTokensAction{ - chain: chainID("sover"), - from: validatorID("alice"), - to: validatorID("alice"), - amount: 11000000, + Action: delegateTokensAction{ + Chain: ChainID("sover"), + From: ValidatorID("alice"), + To: ValidatorID("alice"), + Amount: 11000000, }, - state: State{ - chainID("sover"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 0, // does not exist on pre-ccv sover - validatorID("carol"): 0, // does not exist on pre-ccv sover + State: State{ + ChainID("sover"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 0, // does not exist on pre-ccv sover + ValidatorID("carol"): 0, // does not exist on pre-ccv sover }, }, }, @@ -192,14 +192,14 @@ func stepRunSovereignChain() []Step { func stepsUpgradeChain() []Step { return []Step{ { - action: LegacyUpgradeProposalAction{ - chainID: chainID("sover"), - upgradeTitle: "sovereign-changeover", - proposer: validatorID("alice"), - upgradeHeight: 110, + Action: LegacyUpgradeProposalAction{ + ChainID: ChainID("sover"), + UpgradeTitle: "sovereign-changeover", + Proposer: ValidatorID("alice"), + UpgradeHeight: 110, }, - state: State{ - chainID("sover"): ChainState{ + State: State{ + ChainID("sover"): ChainState{ Proposals: &map[uint]Proposal{ 1: UpgradeProposal{ Title: "sovereign-changeover", @@ -213,14 +213,14 @@ func stepsUpgradeChain() []Step { }, }, { - action: voteGovProposalAction{ - chain: chainID("sover"), - from: []validatorID{validatorID("alice")}, - vote: []string{"yes"}, - propNumber: 1, + Action: voteGovProposalAction{ + Chain: ChainID("sover"), + From: []ValidatorID{ValidatorID("alice")}, + Vote: []string{"yes"}, + PropNumber: 1, }, - state: State{ - chainID("sover"): ChainState{ + State: State{ + ChainID("sover"): ChainState{ Proposals: &map[uint]Proposal{ 1: UpgradeProposal{ Deposit: 10000000, @@ -234,11 +234,11 @@ func stepsUpgradeChain() []Step { }, }, { - action: waitUntilBlockAction{ - chain: chainID("sover"), - block: 110, + Action: waitUntilBlockAction{ + Chain: ChainID("sover"), + Block: 110, }, - state: State{}, + State: State{}, }, } } @@ -249,116 +249,116 @@ func stepsUpgradeChain() []Step { func stepsPostChangeoverDelegate(consumerName string) []Step { return []Step{ { - action: SendTokensAction{ - chain: chainID(consumerName), - from: validatorID("alice"), - to: validatorID("bob"), - amount: 100, + Action: SendTokensAction{ + Chain: ChainID(consumerName), + From: ValidatorID("alice"), + To: ValidatorID("bob"), + Amount: 100, }, - state: State{ - chainID(consumerName): ChainState{ + State: State{ + ChainID(consumerName): ChainState{ // Tx should not go through, ICS channel is not setup until first VSC packet has been relayed to consumer - ValBalances: &map[validatorID]uint{ - validatorID("bob"): 0, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 0, }, }, }, }, { - action: delegateTokensAction{ - chain: chainID("provi"), - from: validatorID("alice"), - to: validatorID("alice"), - amount: 11000000, + Action: delegateTokensAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + To: ValidatorID("alice"), + Amount: 11000000, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 500, - validatorID("bob"): 500, - validatorID("carol"): 500, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 500, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 1, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 1, }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: SendTokensAction{ - chain: chainID(consumerName), - from: validatorID("alice"), - to: validatorID("bob"), - amount: 100, + Action: SendTokensAction{ + Chain: ChainID(consumerName), + From: ValidatorID("alice"), + To: ValidatorID("bob"), + Amount: 100, }, - state: State{ - chainID(consumerName): ChainState{ + State: State{ + ChainID(consumerName): ChainState{ // Tx should go through, ICS channel is setup - ValBalances: &map[validatorID]uint{ - validatorID("bob"): 100, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 100, }, }, }, }, { - action: unbondTokensAction{ - chain: chainID("provi"), - unbondFrom: validatorID("alice"), - sender: validatorID("alice"), - amount: 1000000, + Action: unbondTokensAction{ + Chain: ChainID("provi"), + UnbondFrom: ValidatorID("alice"), + Sender: ValidatorID("alice"), + Amount: 1000000, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // Voting power on consumer should not be affected yet - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 1, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 1, }, - state: State{ - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 510, - validatorID("bob"): 500, - validatorID("carol"): 500, + State: State{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 510, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, }, diff --git a/tests/e2e/steps_start_chains.go b/tests/e2e/steps_start_chains.go index 6017a22641..ace3d6c255 100644 --- a/tests/e2e/steps_start_chains.go +++ b/tests/e2e/steps_start_chains.go @@ -7,20 +7,20 @@ import ( func stepStartProviderChain() []Step { return []Step{ { - action: StartChainAction{ - chain: chainID("provi"), - validators: []StartChainValidator{ - {id: validatorID("bob"), stake: 500000000, allocation: 10000000000}, - {id: validatorID("alice"), stake: 500000000, allocation: 10000000000}, - {id: validatorID("carol"), stake: 500000000, allocation: 10000000000}, + Action: StartChainAction{ + Chain: ChainID("provi"), + Validators: []StartChainValidator{ + {Id: ValidatorID("bob"), Stake: 500000000, Allocation: 10000000000}, + {Id: ValidatorID("alice"), Stake: 500000000, Allocation: 10000000000}, + {Id: ValidatorID("carol"), Stake: 500000000, Allocation: 10000000000}, }, }, - state: State{ - chainID("provi"): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9500000000, - validatorID("bob"): 9500000000, - validatorID("carol"): 9500000000, + State: State{ + ChainID("provi"): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9500000000, + ValidatorID("bob"): 9500000000, + ValidatorID("carol"): 9500000000, }, }, }, @@ -31,24 +31,24 @@ func stepStartProviderChain() []Step { func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint, setupTransferChans bool) []Step { s := []Step{ { - action: submitConsumerAdditionProposalAction{ - chain: chainID("provi"), - from: validatorID("alice"), - deposit: 10000001, - consumerChain: chainID(consumerName), - spawnTime: 0, - initialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, + Action: submitConsumerAdditionProposalAction{ + Chain: ChainID("provi"), + From: ValidatorID("alice"), + Deposit: 10000001, + ConsumerChain: ChainID(consumerName), + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, }, - state: State{ - chainID("provi"): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9489999999, - validatorID("bob"): 9500000000, + State: State{ + ChainID("provi"): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9489999999, + ValidatorID("bob"): 9500000000, }, Proposals: &map[uint]Proposal{ proposalIndex: ConsumerAdditionProposal{ Deposit: 10000001, - Chain: chainID(consumerName), + Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, Status: "PROPOSAL_STATUS_VOTING_PERIOD", @@ -60,155 +60,155 @@ func stepsStartConsumerChain(consumerName string, proposalIndex, chainIndex uint // add a consumer key before the chain starts // the key will be present in consumer genesis initial_val_set { - action: assignConsumerPubKeyAction{ - chain: chainID(consumerName), - validator: validatorID("carol"), - consumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`, + Action: assignConsumerPubKeyAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("carol"), + ConsumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`, // consumer chain has not started // we don't need to reconfigure the node // since it will start with consumer key - reconfigureNode: false, + ReconfigureNode: false, }, - state: State{ - chainID(consumerName): ChainState{ - AssignedKeys: &map[validatorID]string{ - validatorID("carol"): "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", + State: State{ + ChainID(consumerName): ChainState{ + AssignedKeys: &map[ValidatorID]string{ + ValidatorID("carol"): "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", }, - ProviderKeys: &map[validatorID]string{ - validatorID("carol"): "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", + ProviderKeys: &map[ValidatorID]string{ + ValidatorID("carol"): "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", }, }, }, }, { // op should fail - key already assigned by the same validator - action: assignConsumerPubKeyAction{ - chain: chainID(consumerName), - validator: validatorID("carol"), - consumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`, - reconfigureNode: false, - expectError: true, - expectedError: "a validator has assigned the consumer key already: consumer key is already in use by a validator", + Action: assignConsumerPubKeyAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("carol"), + ConsumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`, + ReconfigureNode: false, + ExpectError: true, + ExpectedError: "a validator has assigned the consumer key already: consumer key is already in use by a validator", }, - state: State{}, + State: State{}, }, { // op should fail - key already assigned by another validator - action: assignConsumerPubKeyAction{ - chain: chainID(consumerName), - validator: validatorID("bob"), + Action: assignConsumerPubKeyAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("bob"), // same pub key as carol - consumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`, - reconfigureNode: false, - expectError: true, - expectedError: "a validator has assigned the consumer key already: consumer key is already in use by a validator", + ConsumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is="}`, + ReconfigureNode: false, + ExpectError: true, + ExpectedError: "a validator has assigned the consumer key already: consumer key is already in use by a validator", }, - state: State{ - chainID(consumerName): ChainState{ - AssignedKeys: &map[validatorID]string{ - validatorID("carol"): "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", - validatorID("bob"): "", + State: State{ + ChainID(consumerName): ChainState{ + AssignedKeys: &map[ValidatorID]string{ + ValidatorID("carol"): "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", + ValidatorID("bob"): "", }, - ProviderKeys: &map[validatorID]string{ - validatorID("carol"): "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", + ProviderKeys: &map[ValidatorID]string{ + ValidatorID("carol"): "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", }, }, }, }, { - action: voteGovProposalAction{ - chain: chainID("provi"), - from: []validatorID{validatorID("alice"), validatorID("bob"), validatorID("carol")}, - vote: []string{"yes", "yes", "yes"}, - propNumber: proposalIndex, + Action: voteGovProposalAction{ + Chain: ChainID("provi"), + From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, + Vote: []string{"yes", "yes", "yes"}, + PropNumber: proposalIndex, }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ Proposals: &map[uint]Proposal{ proposalIndex: ConsumerAdditionProposal{ Deposit: 10000001, - Chain: chainID(consumerName), + Chain: ChainID(consumerName), SpawnTime: 0, InitialHeight: clienttypes.Height{RevisionNumber: 0, RevisionHeight: 1}, Status: "PROPOSAL_STATUS_PASSED", }, }, - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9500000000, - validatorID("bob"): 9500000000, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9500000000, + ValidatorID("bob"): 9500000000, }, }, }, }, { - action: startConsumerChainAction{ - consumerChain: chainID(consumerName), - providerChain: chainID("provi"), - validators: []StartChainValidator{ - {id: validatorID("bob"), stake: 500000000, allocation: 10000000000}, - {id: validatorID("alice"), stake: 500000000, allocation: 10000000000}, - {id: validatorID("carol"), stake: 500000000, allocation: 10000000000}, + Action: startConsumerChainAction{ + ConsumerChain: ChainID(consumerName), + ProviderChain: ChainID("provi"), + Validators: []StartChainValidator{ + {Id: ValidatorID("bob"), Stake: 500000000, Allocation: 10000000000}, + {Id: ValidatorID("alice"), Stake: 500000000, Allocation: 10000000000}, + {Id: ValidatorID("carol"), Stake: 500000000, Allocation: 10000000000}, }, // For consumers that're launching with the provider being on an earlier version // of ICS before the soft opt-out threshold was introduced, we need to set the // soft opt-out threshold to 0.05 in the consumer genesis to ensure that the // consumer binary doesn't panic. Sdk requires that all params are set to valid // values from the genesis file. - genesisChanges: ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"", + GenesisChanges: ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"", }, - state: State{ - chainID("provi"): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 9500000000, - validatorID("bob"): 9500000000, - validatorID("carol"): 9500000000, + State: State{ + ChainID("provi"): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9500000000, + ValidatorID("bob"): 9500000000, + ValidatorID("carol"): 9500000000, }, }, - chainID(consumerName): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("alice"): 10000000000, - validatorID("bob"): 10000000000, - validatorID("carol"): 10000000000, + ChainID(consumerName): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 10000000000, + ValidatorID("bob"): 10000000000, + ValidatorID("carol"): 10000000000, }, }, }, }, { - action: addIbcConnectionAction{ - chainA: chainID(consumerName), - chainB: chainID("provi"), - clientA: 0, - clientB: chainIndex, + Action: addIbcConnectionAction{ + ChainA: ChainID(consumerName), + ChainB: ChainID("provi"), + ClientA: 0, + ClientB: chainIndex, }, - state: State{}, + State: State{}, }, { - action: addIbcChannelAction{ - chainA: chainID(consumerName), - chainB: chainID("provi"), - connectionA: 0, - portA: "consumer", // TODO: check port mapping - portB: "provider", - order: "ordered", + Action: addIbcChannelAction{ + ChainA: ChainID(consumerName), + ChainB: ChainID("provi"), + ConnectionA: 0, + PortA: "consumer", // TODO: check port mapping + PortB: "provider", + Order: "ordered", }, - state: State{}, + State: State{}, }, } // currently only used in democracy tests if setupTransferChans { s = append(s, Step{ - action: transferChannelCompleteAction{ - chainA: chainID(consumerName), - chainB: chainID("provi"), - connectionA: 0, - portA: "transfer", - portB: "transfer", - order: "unordered", - channelA: 1, - channelB: 1, + Action: transferChannelCompleteAction{ + ChainA: ChainID(consumerName), + ChainB: ChainID("provi"), + ConnectionA: 0, + PortA: "transfer", + PortB: "transfer", + Order: "unordered", + ChannelA: 1, + ChannelB: 1, }, - state: State{}, + State: State{}, }) } return s @@ -228,75 +228,75 @@ func stepsStartChains(consumerNames []string, setupTransferChans bool) []Step { func stepsAssignConsumerKeyOnStartedChain(consumerName, validator string) []Step { return []Step{ { - action: assignConsumerPubKeyAction{ - chain: chainID(consumerName), - validator: validatorID("bob"), + Action: assignConsumerPubKeyAction{ + Chain: ChainID(consumerName), + Validator: ValidatorID("bob"), // reconfigure the node -> validator was using provider key // until this point -> key matches config.consumerValPubKey for "bob" - consumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"QlG+iYe6AyYpvY1z9RNJKCVlH14Q/qSz4EjGdGCru3o="}`, - reconfigureNode: true, + ConsumerPubkey: `{"@type":"/cosmos.crypto.ed25519.PubKey","key":"QlG+iYe6AyYpvY1z9RNJKCVlH14Q/qSz4EjGdGCru3o="}`, + ReconfigureNode: true, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // this happens after some delegations // so that the chain does not halt if 1/3 of power is offline - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // this happens after some delegations // so that the chain does not halt if 1/3 of power is offline - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, - AssignedKeys: &map[validatorID]string{ - validatorID("bob"): "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", - validatorID("carol"): "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", + AssignedKeys: &map[ValidatorID]string{ + ValidatorID("bob"): "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", + ValidatorID("carol"): "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", }, - ProviderKeys: &map[validatorID]string{ - validatorID("bob"): "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", - validatorID("carol"): "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", + ProviderKeys: &map[ValidatorID]string{ + ValidatorID("bob"): "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + ValidatorID("carol"): "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", }, }, }, }, { - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ // this happens after some delegations // so that the chain does not halt if 1/3 of power is offline - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ // this happens after some delegations // so that the chain does not halt if 1/3 of power is offline - validatorID("alice"): 511, - validatorID("bob"): 500, - validatorID("carol"): 500, + ValidatorID("alice"): 511, + ValidatorID("bob"): 500, + ValidatorID("carol"): 500, }, - AssignedKeys: &map[validatorID]string{ - validatorID("bob"): "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", - validatorID("carol"): "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", + AssignedKeys: &map[ValidatorID]string{ + ValidatorID("bob"): "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", + ValidatorID("carol"): "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk", }, - ProviderKeys: &map[validatorID]string{ - validatorID("bob"): "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", - validatorID("carol"): "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", + ProviderKeys: &map[ValidatorID]string{ + ValidatorID("bob"): "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + ValidatorID("carol"): "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6", }, }, }, diff --git a/tests/e2e/steps_stop_chain.go b/tests/e2e/steps_stop_chain.go index 9cef49a9ea..0841086417 100644 --- a/tests/e2e/steps_stop_chain.go +++ b/tests/e2e/steps_stop_chain.go @@ -6,8 +6,8 @@ import "time" func stepsStartRelayer() []Step { return []Step{ { - action: startRelayerAction{}, - state: State{}, + Action: startRelayerAction{}, + State: State{}, }, } } @@ -16,51 +16,51 @@ func stepsStartRelayer() []Step { func stepsStopChain(consumerName string, propNumber uint) []Step { s := []Step{ { - action: submitConsumerRemovalProposalAction{ - chain: chainID("provi"), - from: validatorID("bob"), - deposit: 10000001, - consumerChain: chainID(consumerName), - stopTimeOffset: 0 * time.Millisecond, + Action: submitConsumerRemovalProposalAction{ + Chain: ChainID("provi"), + From: ValidatorID("bob"), + Deposit: 10000001, + ConsumerChain: ChainID(consumerName), + StopTimeOffset: 0 * time.Millisecond, }, - state: State{ - chainID("provi"): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("bob"): 9489999999, + State: State{ + ChainID("provi"): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 9489999999, }, Proposals: &map[uint]Proposal{ propNumber: ConsumerRemovalProposal{ Deposit: 10000001, - Chain: chainID(consumerName), + Chain: ChainID(consumerName), StopTime: 0, Status: "PROPOSAL_STATUS_VOTING_PERIOD", }, }, - ConsumerChains: &map[chainID]bool{"consu": true}, // consumer chain not yet removed + ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not yet removed }, }, }, { - action: voteGovProposalAction{ - chain: chainID("provi"), - from: []validatorID{validatorID("alice"), validatorID("bob"), validatorID("carol")}, - vote: []string{"yes", "yes", "yes"}, - propNumber: propNumber, + Action: voteGovProposalAction{ + Chain: ChainID("provi"), + From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, + Vote: []string{"yes", "yes", "yes"}, + PropNumber: propNumber, }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ Proposals: &map[uint]Proposal{ propNumber: ConsumerRemovalProposal{ Deposit: 10000001, - Chain: chainID(consumerName), + Chain: ChainID(consumerName), StopTime: 0, Status: "PROPOSAL_STATUS_PASSED", }, }, - ValBalances: &map[validatorID]uint{ - validatorID("bob"): 9500000000, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 9500000000, }, - ConsumerChains: &map[chainID]bool{}, // Consumer chain is now removed + ConsumerChains: &map[ChainID]bool{}, // Consumer chain is now removed }, }, }, @@ -74,51 +74,51 @@ func stepsStopChain(consumerName string, propNumber uint) []Step { func stepsConsumerRemovalPropNotPassing(consumerName string, propNumber uint) []Step { s := []Step{ { - action: submitConsumerRemovalProposalAction{ - chain: chainID("provi"), - from: validatorID("bob"), - deposit: 10000001, - consumerChain: chainID(consumerName), - stopTimeOffset: 0 * time.Millisecond, + Action: submitConsumerRemovalProposalAction{ + Chain: ChainID("provi"), + From: ValidatorID("bob"), + Deposit: 10000001, + ConsumerChain: ChainID(consumerName), + StopTimeOffset: 0 * time.Millisecond, }, - state: State{ - chainID("provi"): ChainState{ - ValBalances: &map[validatorID]uint{ - validatorID("bob"): 9489999999, + State: State{ + ChainID("provi"): ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 9489999999, }, Proposals: &map[uint]Proposal{ propNumber: ConsumerRemovalProposal{ Deposit: 10000001, - Chain: chainID(consumerName), + Chain: ChainID(consumerName), StopTime: 0, Status: "PROPOSAL_STATUS_VOTING_PERIOD", }, }, - ConsumerChains: &map[chainID]bool{"consu": true}, // consumer chain not removed + ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not removed }, }, }, { - action: voteGovProposalAction{ - chain: chainID("provi"), - from: []validatorID{validatorID("alice"), validatorID("bob"), validatorID("carol")}, - vote: []string{"no", "no", "no"}, - propNumber: propNumber, + Action: voteGovProposalAction{ + Chain: ChainID("provi"), + From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, + Vote: []string{"no", "no", "no"}, + PropNumber: propNumber, }, - state: State{ - chainID("provi"): ChainState{ + State: State{ + ChainID("provi"): ChainState{ Proposals: &map[uint]Proposal{ propNumber: ConsumerRemovalProposal{ Deposit: 10000001, - Chain: chainID(consumerName), + Chain: ChainID(consumerName), StopTime: 0, Status: "PROPOSAL_STATUS_REJECTED", }, }, - ValBalances: &map[validatorID]uint{ - validatorID("bob"): 9500000000, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 9500000000, }, - ConsumerChains: &map[chainID]bool{"consu": true}, // consumer chain not removed + ConsumerChains: &map[ChainID]bool{"consu": true}, // consumer chain not removed }, }, }, diff --git a/tests/e2e/steps_submit_equivocation_proposal.go b/tests/e2e/steps_submit_equivocation_proposal.go index 8af1d2464d..243c01f04d 100644 --- a/tests/e2e/steps_submit_equivocation_proposal.go +++ b/tests/e2e/steps_submit_equivocation_proposal.go @@ -7,35 +7,35 @@ func stepsRejectEquivocationProposal(consumerName string, propNumber uint) []Ste return []Step{ { // bob submits a proposal to slash himself - action: submitEquivocationProposalAction{ - chain: chainID("consu"), - from: validatorID("bob"), - deposit: 10000001, - height: 10, - time: time.Now(), - power: 500, - validator: validatorID("bob"), + Action: submitEquivocationProposalAction{ + Chain: ChainID("consu"), + From: ValidatorID("bob"), + Deposit: 10000001, + Height: 10, + Time: time.Now(), + Power: 500, + Validator: ValidatorID("bob"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, }, - ValBalances: &map[validatorID]uint{ - validatorID("bob"): 9500000000, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 9500000000, }, Proposals: &map[uint]Proposal{ // proposal does not exist propNumber: TextProposal{}, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 495, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, }, }, }, @@ -48,24 +48,24 @@ func stepsSubmitEquivocationProposal(consumerName string, propNumber uint) []Ste s := []Step{ { // bob submits a proposal to slash himself - action: submitEquivocationProposalAction{ - chain: chainID("consu"), - from: validatorID("bob"), - deposit: 10000001, - height: 10, - time: time.Now(), // not sure what time in equivocations means - power: 500, - validator: validatorID("bob"), + Action: submitEquivocationProposalAction{ + Chain: ChainID("consu"), + From: ValidatorID("bob"), + Deposit: 10000001, + Height: 10, + Time: time.Now(), // not sure what time in equivocations means + Power: 500, + Validator: ValidatorID("bob"), }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, - ValBalances: &map[validatorID]uint{ - validatorID("bob"): 9489999999, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 9489999999, }, Proposals: &map[uint]Proposal{ propNumber: EquivocationProposal{ @@ -77,28 +77,28 @@ func stepsSubmitEquivocationProposal(consumerName string, propNumber uint) []Ste }, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, - validatorID("carol"): 0, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, }, }, }, }, { - action: voteGovProposalAction{ - chain: chainID("provi"), - from: []validatorID{validatorID("alice"), validatorID("bob"), validatorID("carol")}, - vote: []string{"yes", "yes", "yes"}, - propNumber: propNumber, + Action: voteGovProposalAction{ + Chain: ChainID("provi"), + From: []ValidatorID{ValidatorID("alice"), ValidatorID("bob"), ValidatorID("carol")}, + Vote: []string{"yes", "yes", "yes"}, + PropNumber: propNumber, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, // bob is tombstoned after proposal passes - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, // bob is tombstoned after proposal passes + ValidatorID("carol"): 0, }, Proposals: &map[uint]Proposal{ propNumber: EquivocationProposal{ @@ -110,36 +110,36 @@ func stepsSubmitEquivocationProposal(consumerName string, propNumber uint) []Ste }, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 500, // slash not reflected in consumer chain - validatorID("carol"): 0, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, // slash not reflected in consumer chain + ValidatorID("carol"): 0, }, }, }, }, { // relay power change to consumer1 - action: relayPacketsAction{ - chainA: chainID("provi"), - chainB: chainID(consumerName), - port: "provider", - channel: 0, + Action: relayPacketsAction{ + ChainA: ChainID("provi"), + ChainB: ChainID(consumerName), + Port: "provider", + Channel: 0, }, - state: State{ - chainID("provi"): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, - validatorID("carol"): 0, + State: State{ + ChainID("provi"): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, + ValidatorID("carol"): 0, }, }, - chainID(consumerName): ChainState{ - ValPowers: &map[validatorID]uint{ - validatorID("alice"): 509, - validatorID("bob"): 0, // slash relayed to consumer chain - validatorID("carol"): 0, + ChainID(consumerName): ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 0, // slash relayed to consumer chain + ValidatorID("carol"): 0, }, }, }, diff --git a/tests/e2e/trace_handlers_test.go b/tests/e2e/trace_handlers_test.go new file mode 100644 index 0000000000..725496c51f --- /dev/null +++ b/tests/e2e/trace_handlers_test.go @@ -0,0 +1,229 @@ +package main + +import ( + "encoding/json" + "fmt" + "log" + "os" + "path/filepath" + "testing" + + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + "github.com/google/go-cmp/cmp" +) + +// an isolated test case for a proposal submission +var proposalSubmissionSteps = []Step{ + {submitTextProposalAction{Title: "Proposal 1", Description: "Description 1"}, State{}}, +} + +// an isolated test case for a state check involving a proposal +var proposalInStateSteps = []Step{ + { + Action: submitConsumerRemovalProposalAction{}, + State: State{ + ChainID("provi"): ChainState{ + Proposals: &map[uint]Proposal{ + 1: ConsumerRemovalProposal{ + Deposit: 10000001, + Chain: ChainID("foo"), + StopTime: 0, + Status: "PROPOSAL_STATUS_VOTING_PERIOD", + }, + }, + }, + }, + }, +} + +// Checks that writing, then parsing a trace results in the same trace. +func TestWriterThenParser(t *testing.T) { + tests := map[string]struct { + trace []Step + }{ + "proposalSubmission": {proposalSubmissionSteps}, + "proposalInState": {proposalInStateSteps}, + "start_provider_chain": {stepStartProviderChain()}, + "happyPath": {happyPathSteps}, + "democracy": {democracySteps}, + "slashThrottle": {slashThrottleSteps}, + "multipleConsumers": {multipleConsumers}, + "shorthappy": {shortHappyPathSteps}, + "democracyRewardsSteps": {democracyRewardsSteps}, + "changeover": {changeoverSteps}, + } + + dir, err := os.MkdirTemp("", "example") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(dir) // clean up + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + filename := filepath.Join(dir, "trace.json") + err := WriteAndReadTrace(GlobalJSONParser, GlobalJSONWriter, tc.trace, filename) + if err != nil { + log.Fatalf("got error for testcase %v: %s", name, err) + } + }) + } +} + +// Checks that writing a trace does not result in an error. +func TestWriteExamples(t *testing.T) { + tests := map[string]struct { + trace []Step + }{ + "happyPath": {happyPathSteps}, + "democracy": {democracySteps}, + "slashThrottle": {slashThrottleSteps}, + "multipleConsumers": {multipleConsumers}, + "shorthappy": {shortHappyPathSteps}, + "democracyRewardsSteps": {democracyRewardsSteps}, + "changeover": {changeoverSteps}, + } + + dir := "tracehandler_testdata" + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + filename := filepath.Join(dir, name+".json") + err := GlobalJSONWriter.WriteTraceToFile(filename, tc.trace) + if err != nil { + t.Fatalf("error writing trace to file: %v", err) + } + }) + } +} + +func TestMarshalAndUnmarshalChainState(t *testing.T) { + tests := map[string]struct { + chainState ChainState + }{ + "consumer addition proposal": {ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9489999999, + ValidatorID("bob"): 9500000000, + }, + Proposals: &map[uint]Proposal{ + 2: ConsumerAdditionProposal{ + Deposit: 10000001, + Chain: ChainID("test"), + SpawnTime: 0, + InitialHeight: clienttypes.Height{RevisionNumber: 5, RevisionHeight: 5}, + Status: "PROPOSAL_STATUS_VOTING_PERIOD", + }, + }, + }}, + "params-proposal": {ChainState{ + ValBalances: &map[ValidatorID]uint{ + ValidatorID("alice"): 9889999998, + ValidatorID("bob"): 9960000001, + }, + Proposals: &map[uint]Proposal{ + 1: ParamsProposal{ + Deposit: 10000001, + Status: "PROPOSAL_STATUS_VOTING_PERIOD", + Subspace: "staking", + Key: "MaxValidators", + Value: "105", + }, + }, + }}, + "consuemr removal proposal": {ChainState{ + Proposals: &map[uint]Proposal{ + 5: ConsumerRemovalProposal{ + Deposit: 10000001, + Chain: ChainID("test123"), + StopTime: 5000000000, + Status: "PROPOSAL_STATUS_PASSED", + }, + }, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 9500000000, + }, + ConsumerChains: &map[ChainID]bool{}, // Consumer chain is now removed + }}, + "text-proposal": {ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 495, + }, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 9500000000, + }, + Proposals: &map[uint]Proposal{ + // proposal does not exist + 10: TextProposal{}, + }, + }}, + "equivocation-proposal": {ChainState{ + ValPowers: &map[ValidatorID]uint{ + ValidatorID("alice"): 509, + ValidatorID("bob"): 500, + ValidatorID("carol"): 0, + }, + ValBalances: &map[ValidatorID]uint{ + ValidatorID("bob"): 9489999999, + }, + Proposals: &map[uint]Proposal{ + 5: EquivocationProposal{ + Deposit: 10000001, + Status: "PROPOSAL_STATUS_VOTING_PERIOD", + ConsensusAddress: "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + Power: 500, + Height: 10, + }, + }, + }}, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + err := MarshalAndUnmarshalChainState(tc.chainState) + if err != nil { + t.Fatalf(err.Error()) + } + }) + } +} + +func MarshalAndUnmarshalChainState(chainState ChainState) error { + jsonobj, err := json.Marshal(chainState) + if err != nil { + return fmt.Errorf("error marshalling chain state: %v", err) + } + + var got *ChainState + err = json.Unmarshal(jsonobj, &got) + if err != nil { + return fmt.Errorf("error unmarshalling chain state: %v", err) + } + + diff := cmp.Diff(chainState, *got) + if diff != "" { + log.Print(string(jsonobj)) + return fmt.Errorf(diff) + } + + return nil +} + +func WriteAndReadTrace(parser TraceParser, writer TraceWriter, trace []Step, tmp_filepath string) error { + err := writer.WriteTraceToFile(tmp_filepath, trace) + if err != nil { + return fmt.Errorf("error writing trace to file: %v", err) + } + + got, err := GlobalJSONParser.ReadTraceFromFile(tmp_filepath) + if err != nil { + return fmt.Errorf("got error reading trace from file: %v", err) + } + diff := cmp.Diff(trace, got, cmp.AllowUnexported(Step{})) + if diff != "" { + return fmt.Errorf("Got a difference (-want +got):\n%s", diff) + } + return nil +} diff --git a/tests/e2e/tracehandler_testdata/changeover.json b/tests/e2e/tracehandler_testdata/changeover.json new file mode 100644 index 0000000000..8f90a114e3 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/changeover.json @@ -0,0 +1,586 @@ +[ + { + "ActionType": "main.StartSovereignChainAction", + "Action": { + "Chain": "sover", + "Validators": [ + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "" + }, + "State": { + "sover": { + "ValBalances": { + "alice": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "sover", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.createIbcClientsAction", + "Action": { + "ChainA": "sover", + "ChainB": "provi" + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "sover", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "transfer", + "PortB": "transfer", + "Order": "unordered", + "Version": "ics20-1" + }, + "State": {} + }, + { + "ActionType": "main.LegacyUpgradeProposalAction", + "Action": { + "ChainID": "sover", + "UpgradeTitle": "sovereign-changeover", + "Proposer": "alice", + "UpgradeHeight": 110 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Title": "sovereign-changeover", + "Description": "", + "UpgradeHeight": 110, + "Type": "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", + "Deposit": 10000000, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.UpgradeProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "sover", + "From": [ + "alice" + ], + "Vote": [ + "yes" + ], + "PropNumber": 1 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Title": "sovereign-changeover", + "Description": "", + "UpgradeHeight": 110, + "Type": "/cosmos.upgrade.v1beta1.SoftwareUpgradeProposal", + "Deposit": 10000000, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.UpgradeProposal" + } + } + } + } + }, + { + "ActionType": "main.waitUntilBlockAction", + "Action": { + "Block": 110, + "Chain": "sover" + }, + "State": {} + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": true, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "sover", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 111 + }, + "DistributionChannel": "channel-0" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "sover", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 111 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "sover", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 111 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.ChangeoverChainAction", + "Action": { + "SovereignChain": "sover", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "sover", + "ChainB": "provi", + "ClientA": 1, + "ClientB": 1 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "sover", + "ChainB": "provi", + "ConnectionA": 1, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "sover", + "From": "alice", + "To": "bob", + "Amount": 100 + }, + "State": { + "sover": { + "ValBalances": { + "bob": 0 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "sover", + "Port": "provider", + "Channel": 1 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "sover", + "From": "alice", + "To": "bob", + "Amount": 100 + }, + "State": { + "sover": { + "ValBalances": { + "bob": 100 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "sover", + "Port": "provider", + "Channel": 1 + }, + "State": { + "sover": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/democracy.json b/tests/e2e/tracehandler_testdata/democracy.json new file mode 100644 index 0000000000..a696258ab9 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/democracy.json @@ -0,0 +1,918 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "democ": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.transferChannelCompleteAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "transfer", + "PortB": "transfer", + "Order": "unordered", + "ChannelA": 1, + "ChannelB": 1 + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "democ", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "democ", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.registerRepresentativeAction", + "Action": { + "Chain": "democ", + "Representatives": [ + "alice", + "bob" + ], + "Stakes": [ + 100000000, + 40000000 + ] + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": { + "alice": 100000000, + "bob": 40000000 + }, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": false + }, + "IsIncrementalReward": true, + "IsNativeDenom": true + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "democ", + "From": "carol", + "To": "alice", + "Amount": 500000 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": { + "alice": 100500000, + "bob": 40000000 + }, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": true + }, + "IsIncrementalReward": true, + "IsNativeDenom": true + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitParamChangeLegacyProposalAction", + "Action": { + "Chain": "democ", + "From": "alice", + "Deposit": 10000001, + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": true + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9889999998, + "bob": 9960000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD", + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + }, + "Type": "main.ParamsProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "democ", + "From": [ + "alice", + "bob" + ], + "Vote": [ + "yes", + "no" + ], + "PropNumber": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9899999999, + "bob": 9960000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": [ + { + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + } + ], + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_PASSED", + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + }, + "Type": "main.ParamsProposal" + } + } + } + } + }, + { + "ActionType": "main.relayRewardPacketsToProviderAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Port": "transfer", + "Channel": 1 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": false, + "bob": false, + "carol": false + }, + "IsIncrementalReward": false, + "IsNativeDenom": false + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [], + "Proposals": null + } + } + }, + { + "ActionType": "main.submitChangeRewardDenomsProposalAction", + "Action": { + "Denom": "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [], + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [ + "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9" + ], + "Proposals": null + } + } + }, + { + "ActionType": "main.relayRewardPacketsToProviderAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Port": "transfer", + "Channel": 1 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": false, + "bob": false, + "carol": false + }, + "IsIncrementalReward": false, + "IsNativeDenom": false + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "democ", + "Validator": "bob" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": { + "alice": 100500000, + "bob": 40000000 + }, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json b/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json new file mode 100644 index 0000000000..aa79dcd5d8 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/democracyRewardsSteps.json @@ -0,0 +1,924 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "democ", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "democ", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "democ": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.transferChannelCompleteAction", + "Action": { + "ChainA": "democ", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "transfer", + "PortB": "transfer", + "Order": "unordered", + "ChannelA": 1, + "ChannelB": 1 + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "democ", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "democ", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.registerRepresentativeAction", + "Action": { + "Chain": "democ", + "Representatives": [ + "alice", + "bob" + ], + "Stakes": [ + 100000000, + 40000000 + ] + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": { + "alice": 100000000, + "bob": 40000000 + }, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": false + }, + "IsIncrementalReward": true, + "IsNativeDenom": true + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "democ", + "From": "carol", + "To": "alice", + "Amount": 500000 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": { + "alice": 100500000, + "bob": 40000000 + }, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": true + }, + "IsIncrementalReward": true, + "IsNativeDenom": true + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitParamChangeLegacyProposalAction", + "Action": { + "Chain": "democ", + "From": "alice", + "Deposit": 10000001, + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": true + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9889999998, + "bob": 9960000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": [ + { + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "false" + } + ], + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD", + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + }, + "Type": "main.ParamsProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "democ", + "From": [ + "alice", + "bob" + ], + "Vote": [ + "yes", + "no" + ], + "PropNumber": 1 + }, + "State": { + "democ": { + "ValBalances": { + "alice": 9899999999, + "bob": 9960000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": [ + { + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + } + ], + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_PASSED", + "Subspace": "transfer", + "Key": "SendEnabled", + "Value": "true" + }, + "Type": "main.ParamsProposal" + } + } + } + } + }, + { + "ActionType": "main.relayRewardPacketsToProviderAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Port": "transfer", + "Channel": 1 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": false, + "bob": false, + "carol": false + }, + "IsIncrementalReward": false, + "IsNativeDenom": false + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [], + "Proposals": null + } + } + }, + { + "ActionType": "main.submitChangeRewardDenomsProposalAction", + "Action": { + "Denom": "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [], + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": [ + "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9" + ], + "Proposals": null + } + } + }, + { + "ActionType": "main.relayRewardPacketsToProviderAction", + "Action": { + "ConsumerChain": "democ", + "ProviderChain": "provi", + "Port": "transfer", + "Channel": 1 + }, + "State": { + "provi": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": { + "IsRewarded": { + "alice": true, + "bob": true, + "carol": true + }, + "IsIncrementalReward": false, + "IsNativeDenom": false + }, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "democ", + "Validator": "bob" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "democ", + "Port": "provider", + "Channel": 0 + }, + "State": { + "democ": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": { + "alice": 100500000, + "bob": 40000000 + }, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/happyPath.json b/tests/e2e/tracehandler_testdata/happyPath.json new file mode 100644 index 0000000000..c7b891777d --- /dev/null +++ b/tests/e2e/tracehandler_testdata/happyPath.json @@ -0,0 +1,1935 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "consu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"QlG+iYe6AyYpvY1z9RNJKCVlH14Q/qSz4EjGdGCru3o=\"}", + "ReconfigureNode": true, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "bob": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "cosmosvalcons1uuec3cjxajv5te08p220usrjhkfhg9wyvqn0tm", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "bob": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.cancelUnbondTokensAction", + "Action": { + "Chain": "provi", + "Delegator": "alice", + "Validator": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.redelegateTokensAction", + "Action": { + "Chain": "provi", + "Src": "alice", + "Dst": "carol", + "TxSender": "alice", + "Amount": 450000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "alice" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.redelegateTokensAction", + "Action": { + "Chain": "provi", + "Src": "carol", + "Dst": "alice", + "TxSender": "carol", + "Amount": 449000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 60, + "bob": 500, + "carol": 950 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitEquivocationProposalAction", + "Action": { + "Chain": "consu", + "Height": 10, + "Time": "2023-10-04T12:14:14.883367+02:00", + "Power": 500, + "Validator": "bob", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Title": "", + "Description": "", + "Deposit": 0, + "Status": "" + }, + "Type": "main.TextProposal" + } + } + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "carol", + "Chain": "provi" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "bob", + "Chain": "consu" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitEquivocationProposalAction", + "Action": { + "Chain": "consu", + "Height": 10, + "Time": "2023-10-04T12:14:14.88337+02:00", + "Power": 500, + "Validator": "bob", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Height": 10, + "Power": 500, + "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.EquivocationProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Height": 10, + "Power": 500, + "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.EquivocationProposal" + } + } + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.startRelayerAction", + "Action": {}, + "State": {} + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "3": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "no", + "no", + "no" + ], + "PropNumber": 3 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "3": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_REJECTED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "4": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 4 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": {}, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "4": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/multipleConsumers.json b/tests/e2e/tracehandler_testdata/multipleConsumers.json new file mode 100644 index 0000000000..1cb46af06c --- /dev/null +++ b/tests/e2e/tracehandler_testdata/multipleConsumers.json @@ -0,0 +1,2284 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "consu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "densu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "densu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "densu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "densu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "densu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "densu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "densu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "densu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "densu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "densu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "densu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 1 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "densu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.redelegateTokensAction", + "Action": { + "Chain": "provi", + "Src": "alice", + "Dst": "carol", + "TxSender": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "carol", + "Chain": "provi" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "bob", + "Chain": "consu" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "densu", + "Port": "provider", + "Channel": 1 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "densu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/shorthappy.json b/tests/e2e/tracehandler_testdata/shorthappy.json new file mode 100644 index 0000000000..70486add49 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/shorthappy.json @@ -0,0 +1,1523 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "consu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unbondTokensAction", + "Action": { + "Chain": "provi", + "Sender": "alice", + "UnbondFrom": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.redelegateTokensAction", + "Action": { + "Chain": "provi", + "Src": "alice", + "Dst": "carol", + "TxSender": "alice", + "Amount": 1000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 510, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 501 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.unjailValidatorAction", + "Action": { + "Provider": "provi", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitEquivocationProposalAction", + "Action": { + "Chain": "consu", + "Height": 10, + "Time": "2023-10-04T12:14:14.883385+02:00", + "Power": 500, + "Validator": "bob", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Title": "", + "Description": "", + "Deposit": 0, + "Status": "" + }, + "Type": "main.TextProposal" + } + } + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "carol", + "Chain": "provi" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 495 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.doublesignSlashAction", + "Action": { + "Validator": "bob", + "Chain": "consu" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitEquivocationProposalAction", + "Action": { + "Chain": "consu", + "Height": 10, + "Time": "2023-10-04T12:14:14.883388+02:00", + "Power": 500, + "Validator": "bob", + "Deposit": 10000001, + "From": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Height": 10, + "Power": 500, + "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.EquivocationProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 500, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Height": 10, + "Power": 500, + "ConsensusAddress": "cosmosvalcons1nx7n5uh0ztxsynn4sje6eyq2ud6rc6klc96w39", + "Deposit": 10000001, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.EquivocationProposal" + } + } + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 509, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.startRelayerAction", + "Action": {}, + "State": {} + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "3": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "no", + "no", + "no" + ], + "PropNumber": 3 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "3": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_REJECTED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "4": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 4 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": {}, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "4": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + } +] \ No newline at end of file diff --git a/tests/e2e/tracehandler_testdata/slashThrottle.json b/tests/e2e/tracehandler_testdata/slashThrottle.json new file mode 100644 index 0000000000..d0173d03a8 --- /dev/null +++ b/tests/e2e/tracehandler_testdata/slashThrottle.json @@ -0,0 +1,805 @@ +[ + { + "ActionType": "main.StartChainAction", + "Action": { + "Chain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": "", + "SkipGentx": false + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerAdditionProposalAction", + "Action": { + "PreCCV": false, + "Chain": "provi", + "From": "alice", + "Deposit": 10000001, + "ConsumerChain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "DistributionChannel": "" + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9489999999, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": false, + "ExpectedError": "" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "carol", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": {} + }, + { + "ActionType": "main.assignConsumerPubKeyAction", + "Action": { + "Chain": "consu", + "Validator": "bob", + "ConsumerPubkey": "{\"@type\":\"/cosmos.crypto.ed25519.PubKey\",\"key\":\"Ui5Gf1+mtWUdH8u3xlmzdKID+F3PK0sfXZ73GZ6q6is=\"}", + "ReconfigureNode": false, + "ExpectError": true, + "ExpectedError": "a validator has assigned the consumer key already: consumer key is already in use by a validator" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": { + "bob": "", + "carol": "cosmosvalcons1kswr5sq599365kcjmhgufevfps9njf43e4lwdk" + }, + "ProviderKeys": { + "carol": "cosmosvalcons1ezyrq65s3gshhx5585w6mpusq3xsj3ayzf4uv6" + }, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 1 + }, + "State": { + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "1": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "SpawnTime": 0, + "InitialHeight": { + "revision_height": 1 + }, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerAdditionProposal" + } + } + } + } + }, + { + "ActionType": "main.startConsumerChainAction", + "Action": { + "ConsumerChain": "consu", + "ProviderChain": "provi", + "Validators": [ + { + "Id": "bob", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "alice", + "Allocation": 10000000000, + "Stake": 500000000 + }, + { + "Id": "carol", + "Allocation": 10000000000, + "Stake": 500000000 + } + ], + "GenesisChanges": ".app_state.ccvconsumer.params.soft_opt_out_threshold = \"0.05\"" + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000, + "carol": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": { + "alice": 9500000000, + "bob": 9500000000, + "carol": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.addIbcConnectionAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ClientA": 0, + "ClientB": 0 + }, + "State": {} + }, + { + "ActionType": "main.addIbcChannelAction", + "Action": { + "ChainA": "consu", + "ChainB": "provi", + "ConnectionA": 0, + "PortA": "consumer", + "PortB": "provider", + "Order": "ordered", + "Version": "" + }, + "State": {} + }, + { + "ActionType": "main.delegateTokensAction", + "Action": { + "Chain": "provi", + "From": "alice", + "To": "alice", + "Amount": 11000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 500, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 10000000000, + "bob": 10000000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.SendTokensAction", + "Action": { + "Chain": "consu", + "From": "alice", + "To": "bob", + "Amount": 1 + }, + "State": { + "consu": { + "ValBalances": { + "alice": 9999999999, + "bob": 10000000001 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "bob" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 0, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.downtimeSlashAction", + "Action": { + "Chain": "consu", + "Validator": "carol" + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 500, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.slashMeterReplenishmentAction", + "Action": { + "TargetValue": 0, + "Timeout": 100000000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.waitTimeAction", + "Action": { + "WaitTime": 30000000000 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 1, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 500 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.relayPacketsAction", + "Action": { + "ChainA": "provi", + "ChainB": "consu", + "Port": "provider", + "Channel": 0 + }, + "State": { + "consu": { + "ValBalances": null, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": 0, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + }, + "provi": { + "ValBalances": null, + "ValPowers": { + "alice": 511, + "bob": 0, + "carol": 0 + }, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": null, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": null + } + } + }, + { + "ActionType": "main.submitConsumerRemovalProposalAction", + "Action": { + "Chain": "provi", + "From": "bob", + "Deposit": 10000001, + "ConsumerChain": "consu", + "StopTimeOffset": 0 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9489999999 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": { + "consu": true + }, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_VOTING_PERIOD" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + }, + { + "ActionType": "main.voteGovProposalAction", + "Action": { + "Chain": "provi", + "From": [ + "alice", + "bob", + "carol" + ], + "Vote": [ + "yes", + "yes", + "yes" + ], + "PropNumber": 2 + }, + "State": { + "provi": { + "ValBalances": { + "bob": 9500000000 + }, + "ValPowers": null, + "StakedTokens": null, + "Params": null, + "Rewards": null, + "ConsumerChains": {}, + "AssignedKeys": null, + "ProviderKeys": null, + "ConsumerPendingPacketQueueSize": null, + "RegisteredConsumerRewardDenoms": null, + "Proposals": { + "2": { + "RawProposal": { + "Deposit": 10000001, + "Chain": "consu", + "StopTime": 0, + "Status": "PROPOSAL_STATUS_PASSED" + }, + "Type": "main.ConsumerRemovalProposal" + } + } + } + } + } +] \ No newline at end of file diff --git a/tests/integration/common.go b/tests/integration/common.go index 7d5175d5d7..413cdaa810 100644 --- a/tests/integration/common.go +++ b/tests/integration/common.go @@ -9,6 +9,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v7/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v7/modules/core/exported" ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/stretchr/testify/require" "cosmossdk.io/math" @@ -21,7 +22,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmtypes "github.com/cometbft/cometbft/types" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" icstestingutils "github.com/cosmos/interchain-security/v3/testutil/ibc_testing" testutil "github.com/cosmos/interchain-security/v3/testutil/integration" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" @@ -215,20 +215,42 @@ func redelegate(s *CCVTestSuite, delAddr sdk.AccAddress, valSrcAddr sdk.ValAddre } } +func (s *CCVTestSuite) newPacketFromProvider(data []byte, sequence uint64, path *ibctesting.Path, timeoutHeight clienttypes.Height, timeoutTimestamp uint64) channeltypes.Packet { + return channeltypes.NewPacket(data, sequence, + path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, + path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, + timeoutHeight, timeoutTimestamp) +} + +func (s *CCVTestSuite) newPacketFromConsumer(data []byte, sequence uint64, path *ibctesting.Path, timeoutHeight clienttypes.Height, timeoutTimestamp uint64) channeltypes.Packet { + return channeltypes.NewPacket(data, sequence, + path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, + path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, + timeoutHeight, timeoutTimestamp) +} + // sendOnProviderRecvOnConsumer sends a packet from the provider chain and receives it on the consumer chain -func sendOnProviderRecvOnConsumer(s *CCVTestSuite, path *ibctesting.Path, packet channeltypes.Packet) { - err := path.EndpointB.SendPacket(packet) +func sendOnProviderRecvOnConsumer(s *CCVTestSuite, path *ibctesting.Path, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, data []byte) channeltypes.Packet { + sequence, err := path.EndpointB.SendPacket(timeoutHeight, timeoutTimestamp, data) s.Require().NoError(err) + + packet := s.newPacketFromProvider(data, sequence, path, timeoutHeight, timeoutTimestamp) + err = path.EndpointA.RecvPacket(packet) s.Require().NoError(err) + return packet } // sendOnConsumerRecvOnProvider sends a packet from the consumer chain and receives it on the provider chain -func sendOnConsumerRecvOnProvider(s *CCVTestSuite, path *ibctesting.Path, packet channeltypes.Packet) { - err := path.EndpointA.SendPacket(packet) +func sendOnConsumerRecvOnProvider(s *CCVTestSuite, path *ibctesting.Path, timeoutHeight clienttypes.Height, timeoutTimestamp uint64, data []byte) channeltypes.Packet { + sequence, err := path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, data) s.Require().NoError(err) + + packet := s.newPacketFromConsumer(data, sequence, path, timeoutHeight, timeoutTimestamp) + err = path.EndpointB.RecvPacket(packet) s.Require().NoError(err) + return packet } // relayAllCommittedPackets relays all committed packets from `srcChain` on `path` @@ -256,7 +278,7 @@ func relayAllCommittedPackets( // relay all packets from srcChain to counterparty for _, commitment := range commitments { // - get packets - packet, found := srcChain.GetSentPacket(commitment.Sequence, srcChannelID) + packet, found := s.getSentPacket(srcChain, commitment.Sequence, srcChannelID) s.Require().True( found, fmt.Sprintf("did not find sent packet; %s", msgAndArgs...), @@ -278,7 +300,7 @@ func relayAllCommittedPackets( // to be one day larger than the consumer unbonding period. func incrementTimeByUnbondingPeriod(s *CCVTestSuite, chainType ChainType) { // Get unboding periods - providerUnbondingPeriod := s.providerApp.GetStakingKeeper().UnbondingTime(s.providerCtx()) + providerUnbondingPeriod := s.providerApp.GetTestStakingKeeper().UnbondingTime(s.providerCtx()) consumerUnbondingPeriod := s.consumerApp.GetConsumerKeeper().GetUnbondingPeriod(s.consumerCtx()) var jumpPeriod time.Duration if chainType == Provider { @@ -374,14 +396,7 @@ func (suite *CCVTestSuite) SendEmptyVSCPacket() { nil, ) - seq, ok := suite.providerApp.GetIBCKeeper().ChannelKeeper.GetNextSequenceSend( - suite.providerChain.GetContext(), ccv.ProviderPortID, suite.path.EndpointB.ChannelID) - suite.Require().True(ok) - - packet := channeltypes.NewPacket(pd.GetBytes(), seq, ccv.ProviderPortID, suite.path.EndpointB.ChannelID, - ccv.ConsumerPortID, suite.path.EndpointA.ChannelID, clienttypes.Height{}, timeout) - - sendOnProviderRecvOnConsumer(suite, suite.getFirstBundle().Path, packet) + sendOnProviderRecvOnConsumer(suite, suite.getFirstBundle().Path, clienttypes.Height{}, timeout, pd.GetBytes()) } // commitSlashPacket returns a commit hash for the given slash packet data @@ -403,8 +418,7 @@ func (suite *CCVTestSuite) commitConsumerPacket(ctx sdk.Context, packetData ccv. oldBlockTime := ctx.BlockTime() timeout := uint64(oldBlockTime.Add(ccv.DefaultCCVTimeoutPeriod).UnixNano()) - packet := channeltypes.NewPacket(packetData.GetBytes(), 1, ccv.ConsumerPortID, suite.path.EndpointA.ChannelID, - ccv.ProviderPortID, suite.path.EndpointB.ChannelID, clienttypes.Height{}, timeout) + packet := suite.newPacketFromConsumer(packetData.GetBytes(), 1, suite.path, clienttypes.Height{}, timeout) return channeltypes.CommitPacket(suite.consumerChain.App.AppCodec(), packet) } @@ -414,50 +428,33 @@ func (suite *CCVTestSuite) commitConsumerPacket(ctx sdk.Context, packetData ccv. func (s *CCVTestSuite) constructSlashPacketFromConsumer(bundle icstestingutils.ConsumerBundle, tmVal tmtypes.Validator, infractionType stakingtypes.Infraction, ibcSeqNum uint64, ) channeltypes.Packet { + packet, _ := s.constructSlashPacketFromConsumerWithData(bundle, tmVal, infractionType, ibcSeqNum) + return packet +} + +func (s *CCVTestSuite) constructSlashPacketFromConsumerWithData(bundle icstestingutils.ConsumerBundle, + tmVal tmtypes.Validator, infractionType stakingtypes.Infraction, ibcSeqNum uint64, +) (channeltypes.Packet, ccv.SlashPacketData) { valsetUpdateId := bundle.GetKeeper().GetHeightValsetUpdateID( bundle.GetCtx(), uint64(bundle.GetCtx().BlockHeight())) - data := ccv.ConsumerPacketData{ - Type: ccv.SlashPacket, - Data: &ccv.ConsumerPacketData_SlashPacketData{ - SlashPacketData: &ccv.SlashPacketData{ - Validator: abci.Validator{ - Address: tmVal.Address, - Power: tmVal.VotingPower, - }, - ValsetUpdateId: valsetUpdateId, - Infraction: infractionType, - }, + spdData := ccv.SlashPacketData{ + Validator: abci.Validator{ + Address: tmVal.Address, + Power: tmVal.VotingPower, }, + ValsetUpdateId: valsetUpdateId, + Infraction: infractionType, } - return channeltypes.NewPacket(data.GetBytes(), - ibcSeqNum, - ccv.ConsumerPortID, // Src port - bundle.Path.EndpointA.ChannelID, // Src channel - ccv.ProviderPortID, // Dst port - bundle.Path.EndpointB.ChannelID, // Dst channel - clienttypes.Height{}, - uint64(bundle.GetCtx().BlockTime().Add(ccv.DefaultCCVTimeoutPeriod).UnixNano()), - ) -} - -// constructVSCMaturedPacketFromConsumer constructs an IBC packet embedding -// VSC Matured packet data to be sent from consumer to provider -func (s *CCVTestSuite) constructVSCMaturedPacketFromConsumer(bundle icstestingutils.ConsumerBundle, - ibcSeqNum uint64, -) channeltypes.Packet { - valsetUpdateId := bundle.GetKeeper().GetHeightValsetUpdateID( - bundle.GetCtx(), uint64(bundle.GetCtx().BlockHeight())) - - data := ccv.ConsumerPacketData{ - Type: ccv.VscMaturedPacket, - Data: &ccv.ConsumerPacketData_VscMaturedPacketData{ - VscMaturedPacketData: &ccv.VSCMaturedPacketData{ValsetUpdateId: valsetUpdateId}, + cpdData := ccv.ConsumerPacketData{ + Type: ccv.SlashPacket, + Data: &ccv.ConsumerPacketData_SlashPacketData{ + SlashPacketData: &spdData, }, } - return channeltypes.NewPacket(data.GetBytes(), + return channeltypes.NewPacket(cpdData.GetBytes(), ibcSeqNum, ccv.ConsumerPortID, // Src port bundle.Path.EndpointA.ChannelID, // Src channel @@ -465,7 +462,7 @@ func (s *CCVTestSuite) constructVSCMaturedPacketFromConsumer(bundle icstestingut bundle.Path.EndpointB.ChannelID, // Dst channel clienttypes.Height{}, uint64(bundle.GetCtx().BlockTime().Add(ccv.DefaultCCVTimeoutPeriod).UnixNano()), - ) + ), spdData } // incrementTime increments the overall time by jumpPeriod @@ -615,3 +612,11 @@ func (s *CCVTestSuite) setupValidatorPowers() { } s.Require().Equal(int64(4000), stakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) } + +// mustGetStakingValFromTmVal returns the staking validator from the current state of the staking keeper, +// corresponding to a given tendermint validator. Note this func will fail the test if the validator is not found. +func (s *CCVTestSuite) mustGetStakingValFromTmVal(tmVal tmtypes.Validator) (stakingVal stakingtypes.Validator) { + stakingVal, found := s.providerApp.GetTestStakingKeeper().GetValidatorByConsAddr(s.providerCtx(), sdk.ConsAddress(tmVal.Address)) + s.Require().True(found) + return stakingVal +} diff --git a/tests/integration/democracy.go b/tests/integration/democracy.go index 461cfec3b3..56cfcea02c 100644 --- a/tests/integration/democracy.go +++ b/tests/integration/democracy.go @@ -1,9 +1,9 @@ package integration import ( - "testing" "time" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/stretchr/testify/suite" "cosmossdk.io/math" @@ -14,7 +14,6 @@ import ( govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" icstestingutils "github.com/cosmos/interchain-security/v3/testutil/ibc_testing" testutil "github.com/cosmos/interchain-security/v3/testutil/integration" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" @@ -31,22 +30,22 @@ type ConsumerDemocracyTestSuite struct { // NewCCVTestSuite returns a new instance of ConsumerDemocracyTestSuite, // ready to be tested against using suite.Run(). func NewConsumerDemocracyTestSuite[T testutil.DemocConsumerApp]( - democConsumerAppIniter ibctesting.AppIniter, + democConsumerAppIniter icstestingutils.ValSetAppIniter, ) *ConsumerDemocracyTestSuite { democSuite := new(ConsumerDemocracyTestSuite) - democSuite.setupCallback = func(t *testing.T) ( + democSuite.setupCallback = func(s *suite.Suite) ( *ibctesting.Coordinator, *ibctesting.TestChain, testutil.DemocConsumerApp, ) { - t.Helper() + s.T().Helper() // Instantiate the test coordinator - coordinator := ibctesting.NewCoordinator(t, 0) + coordinator := ibctesting.NewCoordinator(s.T(), 0) // Add single democracy consumer to coordinator, store returned test chain and app. democConsumer, democConsumerApp := icstestingutils.AddDemocracyConsumer[T]( - t, coordinator, democConsumerAppIniter) + coordinator, s, democConsumerAppIniter) // Pass variables to suite. return coordinator, democConsumer, democConsumerApp @@ -56,7 +55,7 @@ func NewConsumerDemocracyTestSuite[T testutil.DemocConsumerApp]( // Callback for instantiating a new coordinator, consumer test chain, and consumer app // before every test defined on the suite. -type DemocSetupCallback func(t *testing.T) ( +type DemocSetupCallback func(s *suite.Suite) ( coord *ibctesting.Coordinator, consumerChain *ibctesting.TestChain, consumerApp testutil.DemocConsumerApp, @@ -66,7 +65,7 @@ type DemocSetupCallback func(t *testing.T) ( func (suite *ConsumerDemocracyTestSuite) SetupTest() { // Instantiate new test utils using callback suite.coordinator, suite.consumerChain, - suite.consumerApp = suite.setupCallback(suite.T()) + suite.consumerApp = suite.setupCallback(&suite.Suite) } func (s *ConsumerDemocracyTestSuite) TestDemocracyRewardsDistribution() { diff --git a/tests/integration/distribution.go b/tests/integration/distribution.go index a896a6f22b..668cf8cc7e 100644 --- a/tests/integration/distribution.go +++ b/tests/integration/distribution.go @@ -7,8 +7,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + icstestingutils "github.com/cosmos/interchain-security/v3/testutil/integration" + consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" @@ -34,7 +35,7 @@ func (s *CCVTestSuite) TestRewardsDistribution() { // reward for the provider chain will be sent after each 2 blocks consumerParams := s.consumerApp.GetSubspace(consumertypes.ModuleName) - consumerParams.Set(s.consumerCtx(), consumertypes.KeyBlocksPerDistributionTransmission, int64(2)) + consumerParams.Set(s.consumerCtx(), ccv.KeyBlocksPerDistributionTransmission, int64(2)) s.consumerChain.NextBlock() consumerAccountKeeper := s.consumerApp.GetTestAccountKeeper() @@ -94,41 +95,13 @@ func (s *CCVTestSuite) TestRewardsDistribution() { // Check that the coins got into the ConsumerRewardsPool s.Require().True(rewardCoins[ibcCoinIndex].Amount.Equal(providerExpectedRewards[0].Amount)) - // Attempt to register the consumer reward denom, but fail because the account has no coins - - // Get the balance of delAddr to send it out - senderCoins := providerBankKeeper.GetAllBalances(s.providerCtx(), delAddr) - - // Send the coins to the governance module just to have a place to send them - err = providerBankKeeper.SendCoinsFromAccountToModule(s.providerCtx(), delAddr, govtypes.ModuleName, senderCoins) - s.Require().NoError(err) - - // Attempt to register the consumer reward denom, but fail because the account has no coins - err = s.providerApp.GetProviderKeeper().RegisterConsumerRewardDenom(s.providerCtx(), rewardCoins[ibcCoinIndex].Denom, delAddr) - s.Require().Error(err) - // Advance a block and check that the coins are still in the ConsumerRewardsPool s.providerChain.NextBlock() rewardCoins = providerBankKeeper.GetAllBalances(s.providerCtx(), rewardPool) s.Require().True(rewardCoins[ibcCoinIndex].Amount.Equal(providerExpectedRewards[0].Amount)) - // Successfully register the consumer reward denom this time - - // Send the coins back to the delAddr - err = providerBankKeeper.SendCoinsFromModuleToAccount(s.providerCtx(), govtypes.ModuleName, delAddr, senderCoins) - s.Require().NoError(err) - - // log the sender's coins - senderCoins1 := providerBankKeeper.GetAllBalances(s.providerCtx(), delAddr) - - // Register the consumer reward denom - err = s.providerApp.GetProviderKeeper().RegisterConsumerRewardDenom(s.providerCtx(), rewardCoins[ibcCoinIndex].Denom, delAddr) - s.Require().NoError(err) - - // Check that the delAddr has the right amount less money in it after paying the fee - senderCoins2 := providerBankKeeper.GetAllBalances(s.providerCtx(), delAddr) - consumerRewardDenomRegistrationFee := s.providerApp.GetProviderKeeper().GetConsumerRewardDenomRegistrationFee(s.providerCtx()) - s.Require().Equal(senderCoins1.Sub(senderCoins2...), sdk.NewCoins(consumerRewardDenomRegistrationFee)) + // Set the consumer reward denom. This would be done by a governance proposal in prod + s.providerApp.GetProviderKeeper().SetConsumerRewardDenom(s.providerCtx(), rewardCoins[ibcCoinIndex].Denom) s.providerChain.NextBlock() @@ -166,7 +139,7 @@ func (s *CCVTestSuite) TestSendRewardsRetries() { // reward for the provider chain will be sent after each 1000 blocks consumerParams := s.consumerApp.GetSubspace(consumertypes.ModuleName) - consumerParams.Set(s.consumerCtx(), consumertypes.KeyBlocksPerDistributionTransmission, int64(1000)) + consumerParams.Set(s.consumerCtx(), ccv.KeyBlocksPerDistributionTransmission, int64(1000)) // fill fee pool fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))) @@ -296,7 +269,7 @@ func (s *CCVTestSuite) TestEndBlockRD() { // reward for the provider chain will be sent after each 1000 blocks consumerParams := s.consumerApp.GetSubspace(consumertypes.ModuleName) - consumerParams.Set(s.consumerCtx(), consumertypes.KeyBlocksPerDistributionTransmission, int64(1000)) + consumerParams.Set(s.consumerCtx(), ccv.KeyBlocksPerDistributionTransmission, int64(1000)) // fill fee pool fees := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))) @@ -338,8 +311,151 @@ func (s *CCVTestSuite) TestEndBlockRD() { } } +// TestSendRewardsToProvider is effectively a unit test for SendRewardsToProvider(), +// but is written as an integration test to avoid excessive mocking. +func (s *CCVTestSuite) TestSendRewardsToProvider() { + testCases := []struct { + name string + setup func(sdk.Context, *consumerkeeper.Keeper, icstestingutils.TestBankKeeper) + expError bool + tokenTransfers int + }{ + { + name: "successful token transfer", + setup: func(ctx sdk.Context, keeper *consumerkeeper.Keeper, bankKeeper icstestingutils.TestBankKeeper) { + s.SetupTransferChannel() + + // register a consumer reward denom + params := keeper.GetConsumerParams(ctx) + params.RewardDenoms = []string{sdk.DefaultBondDenom} + keeper.SetParams(ctx, params) + + // send coins to the pool which is used for collect reward distributions to be sent to the provider + err := bankKeeper.SendCoinsFromAccountToModule( + ctx, + s.consumerChain.SenderAccount.GetAddress(), + consumertypes.ConsumerToSendToProviderName, + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + ) + s.Require().NoError(err) + }, + expError: false, + tokenTransfers: 1, + }, + { + name: "no transfer channel", + setup: func(ctx sdk.Context, keeper *consumerkeeper.Keeper, bankKeeper icstestingutils.TestBankKeeper) { + }, + expError: false, + tokenTransfers: 0, + }, + { + name: "no reward denom", + setup: func(ctx sdk.Context, keeper *consumerkeeper.Keeper, bankKeeper icstestingutils.TestBankKeeper) { + s.SetupTransferChannel() + }, + expError: false, + tokenTransfers: 0, + }, + { + name: "reward balance is zero", + setup: func(ctx sdk.Context, keeper *consumerkeeper.Keeper, bankKeeper icstestingutils.TestBankKeeper) { + s.SetupTransferChannel() + + // register a consumer reward denom + params := keeper.GetConsumerParams(ctx) + params.RewardDenoms = []string{"uatom"} + keeper.SetParams(ctx, params) + + denoms := keeper.AllowedRewardDenoms(ctx) + s.Require().Len(denoms, 1) + }, + expError: false, + tokenTransfers: 0, + }, + { + name: "no distribution transmission channel", + setup: func(ctx sdk.Context, keeper *consumerkeeper.Keeper, bankKeeper icstestingutils.TestBankKeeper) { + s.SetupTransferChannel() + + // register a consumer reward denom + params := keeper.GetConsumerParams(ctx) + params.RewardDenoms = []string{sdk.DefaultBondDenom} + params.DistributionTransmissionChannel = "" + keeper.SetParams(ctx, params) + + // send coins to the pool which is used for collect reward distributions to be sent to the provider + err := bankKeeper.SendCoinsFromAccountToModule( + ctx, + s.consumerChain.SenderAccount.GetAddress(), + consumertypes.ConsumerToSendToProviderName, + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + ) + s.Require().NoError(err) + }, + expError: false, + tokenTransfers: 0, + }, + { + name: "no recipient address", + setup: func(ctx sdk.Context, keeper *consumerkeeper.Keeper, bankKeeper icstestingutils.TestBankKeeper) { + s.SetupTransferChannel() + + // register a consumer reward denom + params := keeper.GetConsumerParams(ctx) + params.RewardDenoms = []string{sdk.DefaultBondDenom} + params.ProviderFeePoolAddrStr = "" + keeper.SetParams(ctx, params) + + // send coins to the pool which is used for collect reward distributions to be sent to the provider + err := bankKeeper.SendCoinsFromAccountToModule( + ctx, + s.consumerChain.SenderAccount.GetAddress(), + consumertypes.ConsumerToSendToProviderName, + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100))), + ) + s.Require().NoError(err) + }, + expError: true, + tokenTransfers: 0, + }, + } + + for _, tc := range testCases { + s.SetupTest() + + // ccv channels setup + s.SetupCCVChannel(s.path) + bondAmt := sdk.NewInt(10000000) + delAddr := s.providerChain.SenderAccount.GetAddress() + delegate(s, delAddr, bondAmt) + s.providerChain.NextBlock() + + // customized setup + consumerCtx := s.consumerCtx() + consumerKeeper := s.consumerApp.GetConsumerKeeper() + tc.setup(consumerCtx, &consumerKeeper, s.consumerApp.GetTestBankKeeper()) + + // call SendRewardsToProvider + err := s.consumerApp.GetConsumerKeeper().SendRewardsToProvider(consumerCtx) + if tc.expError { + s.Require().Error(err) + } else { + s.Require().NoError(err) + } + + // check whether the amount of token transfers is as expected + commitments := s.consumerApp.GetIBCKeeper().ChannelKeeper.GetAllPacketCommitmentsAtChannel( + consumerCtx, + transfertypes.PortID, + s.consumerApp.GetConsumerKeeper().GetDistributionTransmissionChannel(consumerCtx), + ) + s.Require().Len(commitments, tc.tokenTransfers, "unexpected amount of token transfers; test: %s", tc.name) + } +} + // getEscrowBalance gets the current balances in the escrow account holding the transferred tokens to the provider -func (s CCVTestSuite) getEscrowBalance() sdk.Coins { //nolint:govet // we copy locks for this test +func (s *CCVTestSuite) getEscrowBalance() sdk.Coins { consumerBankKeeper := s.consumerApp.GetTestBankKeeper() transChanID := s.consumerApp.GetConsumerKeeper().GetDistributionTransmissionChannel(s.consumerCtx()) escAddr := transfertypes.GetEscrowAddress(transfertypes.PortID, transChanID) diff --git a/tests/integration/expired_client.go b/tests/integration/expired_client.go index 2a8babacfa..f196f16ce1 100644 --- a/tests/integration/expired_client.go +++ b/tests/integration/expired_client.go @@ -6,6 +6,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" @@ -13,7 +14,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) diff --git a/tests/integration/normal_operations.go b/tests/integration/normal_operations.go index b676689e89..cd8e07f323 100644 --- a/tests/integration/normal_operations.go +++ b/tests/integration/normal_operations.go @@ -6,6 +6,7 @@ import ( tmproto "github.com/cometbft/cometbft/proto/tendermint/types" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) // Tests the tracking of historical info in the context of new blocks being committed @@ -73,7 +74,7 @@ func (k CCVTestSuite) TestHistoricalInfo() { //nolint:govet // this is a test so expLen: 0, }, { - height: initHeight + consumertypes.DefaultHistoricalEntries + 2, + height: initHeight + ccvtypes.DefaultHistoricalEntries + 2, found: true, expLen: initValsetLen + 2, }, diff --git a/tests/integration/query_providerinfo_test.go b/tests/integration/query_providerinfo_test.go new file mode 100644 index 0000000000..8058248310 --- /dev/null +++ b/tests/integration/query_providerinfo_test.go @@ -0,0 +1,17 @@ +package integration + +func (s *CCVTestSuite) TestQueryProviderInfo() { + s.SetupCCVChannel(s.path) + s.SendEmptyVSCPacket() + + chainInfo, err := s.consumerApp.GetConsumerKeeper().GetProviderInfo(s.consumerCtx()) + s.Require().NoError(err) + s.Require().Equal(chainInfo.Provider.ChainID, "testchain1") + s.Require().Equal(chainInfo.Consumer.ChainID, "testchain2") + s.Require().Equal(chainInfo.Provider.ClientID, "07-tendermint-0") + s.Require().Equal(chainInfo.Consumer.ClientID, "07-tendermint-0") + s.Require().Equal(chainInfo.Provider.ConnectionID, "connection-0") + s.Require().Equal(chainInfo.Consumer.ConnectionID, "connection-0") + s.Require().Equal(chainInfo.Provider.ChannelID, "channel-0") + s.Require().Equal(chainInfo.Consumer.ChannelID, "channel-0") +} diff --git a/tests/integration/setup.go b/tests/integration/setup.go index a18ff551e4..eee8fb1a22 100644 --- a/tests/integration/setup.go +++ b/tests/integration/setup.go @@ -1,21 +1,28 @@ package integration import ( + "context" + "fmt" + "sync" "testing" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/cosmos/ibc-go/v7/testing/mock" "github.com/stretchr/testify/suite" + "github.com/cosmos/cosmos-sdk/baseapp" + store "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + abci "github.com/cometbft/cometbft/abci/types" tmencoding "github.com/cometbft/cometbft/crypto/encoding" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" icstestingutils "github.com/cosmos/interchain-security/v3/testutil/ibc_testing" testutil "github.com/cosmos/interchain-security/v3/testutil/integration" + "github.com/cosmos/interchain-security/v3/testutil/simibc" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -59,11 +66,16 @@ type CCVTestSuite struct { // The preferred way to access chains, apps, and paths when designing tests around multiple consumers. consumerBundles map[string]*icstestingutils.ConsumerBundle skippedTests map[string]bool + + // packetSniffers maps a chain and a packetSniffer + packetSniffers map[*ibctesting.TestChain]*packetSniffer } // NewCCVTestSuite returns a new instance of CCVTestSuite, ready to be tested against using suite.Run(). func NewCCVTestSuite[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( - providerAppIniter, consumerAppIniter ibctesting.AppIniter, skippedTests []string, + providerAppIniter icstestingutils.AppIniter, + consumerAppIniter icstestingutils.ValSetAppIniter, + skippedTests []string, ) *CCVTestSuite { ccvSuite := new(CCVTestSuite) @@ -108,9 +120,12 @@ func (suite *CCVTestSuite) BeforeTest(suiteName, testName string) { // SetupTest sets up in-mem state before every test func (suite *CCVTestSuite) SetupTest() { + suite.packetSniffers = make(map[*ibctesting.TestChain]*packetSniffer) + // Instantiate new coordinator and provider chain using callback suite.coordinator, suite.providerChain, suite.providerApp = suite.setupProviderCallback(suite.T()) + suite.registerPacketSniffer(suite.providerChain) providerKeeper := suite.providerApp.GetProviderKeeper() // re-assign all validator keys for the first consumer chain @@ -122,6 +137,7 @@ func (suite *CCVTestSuite) SetupTest() { for i := 0; i < numConsumers; i++ { bundle := suite.setupConsumerCallback(&suite.Suite, suite.coordinator, i) suite.consumerBundles[bundle.Chain.ChainID] = bundle + suite.registerPacketSniffer(bundle.Chain) } // initialize each consumer chain with it's corresponding genesis state @@ -132,8 +148,12 @@ func (suite *CCVTestSuite) SetupTest() { chainID, ) suite.Require().True(found, "consumer genesis not found") - - initConsumerChain(suite, chainID, &consumerGenesisState) + genesisState := consumertypes.GenesisState{ + Params: consumerGenesisState.Params, + Provider: consumerGenesisState.Provider, + NewChain: consumerGenesisState.NewChain, + } + initConsumerChain(suite, chainID, &genesisState) } // try updating all clients @@ -148,6 +168,21 @@ func (suite *CCVTestSuite) SetupTest() { } } +func (s *CCVTestSuite) registerPacketSniffer(chain *ibctesting.TestChain) { + if s.packetSniffers == nil { + s.packetSniffers = make(map[*ibctesting.TestChain]*packetSniffer) + } + p := newPacketSniffer() + chain.App.GetBaseApp().SetStreamingService(p) + s.packetSniffers[chain] = p +} + +func (s *CCVTestSuite) getSentPacket(chain *ibctesting.TestChain, sequence uint64, channelID string) (packet channeltypes.Packet, found bool) { + key := getSentPacketKey(sequence, channelID) + packet, found = s.packetSniffers[chain].packets[key] + return +} + // initConsumerChain initializes a consumer chain given a genesis state func initConsumerChain( s *CCVTestSuite, @@ -169,8 +204,8 @@ func initConsumerChain( if genesisState.NewChain { consumerEndpointClientState, consumerEndpointConsState := s.GetConsumerEndpointClientAndConsState(*bundle) - s.Require().Equal(genesisState.ProviderClientState, consumerEndpointClientState) - s.Require().Equal(genesisState.ProviderConsensusState, consumerEndpointConsState) + s.Require().Equal(genesisState.Provider.ClientState, consumerEndpointClientState) + s.Require().Equal(genesisState.Provider.ConsensusState, consumerEndpointConsState) } // create path for the CCV channel @@ -293,7 +328,7 @@ func (suite *CCVTestSuite) SetupTransferChannel() { func (s CCVTestSuite) validateEndpointsClientConfig(consumerBundle icstestingutils.ConsumerBundle) { //nolint:govet // this is a test so we can copy locks consumerKeeper := consumerBundle.GetKeeper() - providerStakingKeeper := s.providerApp.GetStakingKeeper() + providerStakingKeeper := s.providerApp.GetTestStakingKeeper() consumerUnbondingPeriod := consumerKeeper.GetUnbondingPeriod(consumerBundle.GetCtx()) cs, ok := s.providerApp.GetIBCKeeper().ClientKeeper.GetClientState(s.providerCtx(), @@ -343,3 +378,46 @@ func preProposalKeyAssignment(s *CCVTestSuite, chainID string) { s.Require().NoError(err) } } + +// packetSniffer implements the StreamingService interface. +// Implements ListenEndBlock to record packets from events. +type packetSniffer struct { + packets map[string]channeltypes.Packet +} + +var _ baseapp.StreamingService = &packetSniffer{} + +func newPacketSniffer() *packetSniffer { + return &packetSniffer{ + packets: make(map[string]channeltypes.Packet), + } +} + +func (ps *packetSniffer) ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error { + packets := simibc.ParsePacketsFromEvents(simibc.ABCIToSDKEvents(res.GetEvents())) + for _, packet := range packets { + ps.packets[getSentPacketKey(packet.Sequence, packet.SourceChannel)] = packet + } + return nil +} + +// getSentPacketKey returns a key for accessing a sent packet, +// given an ibc sequence number and the channel ID for the source endpoint. +func getSentPacketKey(sequence uint64, channelID string) string { + return fmt.Sprintf("%s-%d", channelID, sequence) +} + +func (*packetSniffer) ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error { + return nil +} + +func (*packetSniffer) ListenCommit(ctx context.Context, res abci.ResponseCommit) error { + return nil +} + +func (*packetSniffer) ListenDeliverTx(ctx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error { + return nil +} +func (*packetSniffer) Close() error { return nil } +func (*packetSniffer) Listeners() map[store.StoreKey][]store.WriteListener { return nil } +func (*packetSniffer) Stream(wg *sync.WaitGroup) error { return nil } diff --git a/tests/integration/slashing.go b/tests/integration/slashing.go index 1ce7d11db8..4058494974 100644 --- a/tests/integration/slashing.go +++ b/tests/integration/slashing.go @@ -68,31 +68,38 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { s.setDefaultValSigningInfo(*tmtypes.NewValidator(tmPk, stakingVal.ConsensusPower(sdk.DefaultPowerReduction))) // Send slash packet from the first consumer chain - packet := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) - err = s.getFirstBundle().Path.EndpointA.SendPacket(packet) + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccv.DefaultCCVTimeoutPeriod).UnixNano()) + ) + slashPacket := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) + sequence, err := s.getFirstBundle().Path.EndpointA.SendPacket(timeoutHeight, timeoutTimestamp, slashPacket.GetData()) s.Require().NoError(err) // Set outstanding slashing flag for first consumer, it's important to use the consumer's cons addr here firstConsumerKeeper.SetOutstandingDowntime(s.consumerCtx(), consumerConsAddr.ToSdkConsAddr()) // Note: RecvPacket advances two blocks. Let's say the provider is currently at height N. - // The received slash packet will be queued during N, and handled by the ccv module during - // the endblocker of N. The staking module will then register a validator update from that - // packet during the endblocker of N+1 (note that staking endblocker runs before ccv endblocker, - // hence why the VSC is registered on N+1). Then the ccv module sends VSC packets to each consumer - // during the endblocker of N+1. The new validator set will be committed to in block N+2, - // and will be in effect for the provider during block N+3. + // The received slash packet will be handled during N. The staking module will then register + // a validator update from that packet during the endblocker of N. Then the ccv module sends + // VSC packets to each consumer during the endblocker of N (note ccv endblocker runs after staking). + // The new validator set will be committed to in block N+1, and will be in effect + // for the provider during block N+2. valsetUpdateIdN := providerKeeper.GetValidatorSetUpdateId(s.providerCtx()) // receive the slash packet on the provider chain. RecvPacket() calls the provider endblocker twice + packet := s.newPacketFromConsumer(slashPacket.GetData(), sequence, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp) + heightBefore := s.providerCtx().BlockHeight() err = s.path.EndpointB.RecvPacket(packet) + heightAfter := s.providerCtx().BlockHeight() s.Require().NoError(err) + s.Require().Equal(heightBefore+2, heightAfter) // We've now advanced two blocks. - // VSC packets should have been sent from provider during block N+1 to each consumer - expectedSentValsetUpdateId := valsetUpdateIdN + 1 + // VSC packets should have been sent from provider during block N to each consumer + expectedSentValsetUpdateId := valsetUpdateIdN for _, bundle := range s.consumerBundles { _, found := providerKeeper.GetVscSendTimestamp(s.providerCtx(), bundle.Chain.ChainID, expectedSentValsetUpdateId) @@ -104,10 +111,7 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { s.Require().Equal(valsetUpdateIdN+2, providerKeeper.GetValidatorSetUpdateId(s.providerCtx())) - // Call next block so provider is now on block N + 3 mentioned above - s.providerChain.NextBlock() - - // check that the validator was removed from the provider validator set by N + 3 + // check that the validator was removed from the provider validator set by N + 2 s.Require().Len(s.providerChain.Vals.Validators, validatorsPerChain-1) for _, bundle := range s.consumerBundles { @@ -151,9 +155,10 @@ func (s *CCVTestSuite) TestRelayAndApplyDowntimePacket() { pFlag := firstConsumerKeeper.OutstandingDowntime(s.consumerCtx(), consumerConsAddr.ToSdkConsAddr()) s.Require().False(pFlag) - // check that slashing packet gets acknowledged successfully - ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) - err = s.path.EndpointA.AcknowledgePacket(packet, ack.Acknowledgement()) + // Check that first consumer can recv ack from provider. + // Provider has returned SlashPacketHandledResult. + ack := channeltypes.NewResultAcknowledgement(ccv.SlashPacketHandledResult) + err = s.getFirstBundle().Path.EndpointA.AcknowledgePacket(packet, ack.Acknowledgement()) s.Require().NoError(err) } @@ -196,13 +201,12 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() { s.setDefaultValSigningInfo(*tmtypes.NewValidator(tmPk, stakingVal.ConsensusPower(sdk.DefaultPowerReduction))) // Send slash packet from the first consumer chain - packet := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, 1) - err = s.getFirstBundle().Path.EndpointA.SendPacket(packet) - s.Require().NoError(err) - - // receive the slash packet on the provider chain. RecvPacket() advances two blocks - err = s.path.EndpointB.RecvPacket(packet) - s.Require().NoError(err) + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccv.DefaultCCVTimeoutPeriod).UnixNano()) + ) + slashPacket := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, 1) + packet := sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData()) // Advance a few more blocks to make sure any voting power changes would be reflected s.providerChain.NextBlock() @@ -234,8 +238,9 @@ func (s *CCVTestSuite) TestRelayAndApplyDoubleSignPacket() { // check that validator was NOT tombstoned on provider s.Require().False(valSignInfo.Tombstoned) - // check that slashing packet gets acknowledged successfully - ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + // check that slashing packet gets acknowledged successfully, + // provider returns V1Result acks for double sign packets + ack := channeltypes.NewResultAcknowledgement(ccv.V1Result) err = s.path.EndpointA.AcknowledgePacket(packet, ack.Acknowledgement()) s.Require().NoError(err) } @@ -259,9 +264,8 @@ func (s *CCVTestSuite) TestSlashPacketAcknowledgement() { SlashPacketData: &spd, }, ) - packet := channeltypes.NewPacket(cpd.GetBytes(), // Consumer always sends v1 packet data - 1, ccv.ConsumerPortID, s.path.EndpointA.ChannelID, - ccv.ProviderPortID, s.path.EndpointB.ChannelID, clienttypes.Height{}, 0) + packet := s.newPacketFromConsumer(cpd.GetBytes(), // Consumer always sends v1 packet data + 1, s.path, clienttypes.Height{}, 0) // Map infraction height on provider so validation passes and provider returns valid ack result providerKeeper.SetValsetUpdateBlockHeight(s.providerCtx(), spd.ValsetUpdateId, 47923) @@ -426,16 +430,10 @@ func (suite *CCVTestSuite) TestOnRecvSlashPacketErrors() { errAck = providerKeeper.OnRecvSlashPacket(ctx, packet, *slashingPkt) suite.Require().False(errAck.Success()) - // Expect nothing was queued - suite.Require().Equal(0, len(providerKeeper.GetAllGlobalSlashEntries(ctx))) - suite.Require().Equal(uint64(0), (providerKeeper.GetThrottledPacketDataSize(ctx, consumerChainID))) - // expect to queue entries for the slash request slashingPkt.Infraction = stakingtypes.Infraction_INFRACTION_DOWNTIME ack = providerKeeper.OnRecvSlashPacket(ctx, packet, *slashingPkt) suite.Require().True(ack.Success()) - suite.Require().Equal(1, len(providerKeeper.GetAllGlobalSlashEntries(ctx))) - suite.Require().Equal(uint64(1), (providerKeeper.GetThrottledPacketDataSize(ctx, consumerChainID))) } // TestValidatorDowntime tests if a slash packet is sent diff --git a/tests/integration/stop_consumer.go b/tests/integration/stop_consumer.go index b3d32ee6a4..452b28e3b1 100644 --- a/tests/integration/stop_consumer.go +++ b/tests/integration/stop_consumer.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -80,33 +79,6 @@ func (s *CCVTestSuite) TestStopConsumerChain() { return nil }, }, - { - func(suite *CCVTestSuite) error { - // Queue slash and vsc packet data for consumer 0, these queue entries will be removed - firstBundle := s.getFirstBundle() - globalEntry := types.NewGlobalSlashEntry(s.providerCtx().BlockTime(), firstBundle.Chain.ChainID, 7, types.ProviderConsAddress{Address: []byte{}}) - providerKeeper.QueueGlobalSlashEntry(s.providerCtx(), globalEntry) - err := providerKeeper.QueueThrottledSlashPacketData(s.providerCtx(), firstBundle.Chain.ChainID, 1, - ccv.SlashPacketData{ValsetUpdateId: 1}) - suite.Require().NoError(err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(s.providerCtx(), - firstBundle.Chain.ChainID, 2, ccv.VSCMaturedPacketData{ValsetUpdateId: 2}) - suite.Require().NoError(err) - - // Queue slash and vsc packet data for consumer 1, these queue entries will be not be removed - secondBundle := s.getBundleByIdx(1) - globalEntry = types.NewGlobalSlashEntry(s.providerCtx().BlockTime(), secondBundle.Chain.ChainID, 7, types.ProviderConsAddress{Address: []byte{}}) - providerKeeper.QueueGlobalSlashEntry(s.providerCtx(), globalEntry) - err = providerKeeper.QueueThrottledSlashPacketData(s.providerCtx(), secondBundle.Chain.ChainID, 1, - ccv.SlashPacketData{ValsetUpdateId: 1}) - suite.Require().NoError(err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(s.providerCtx(), - secondBundle.Chain.ChainID, 2, ccv.VSCMaturedPacketData{ValsetUpdateId: 2}) - suite.Require().NoError(err) - - return nil - }, - }, } for _, so := range setupOperations { @@ -120,15 +92,6 @@ func (s *CCVTestSuite) TestStopConsumerChain() { // check all states are removed and the unbonding operation released s.checkConsumerChainIsRemoved(firstBundle.Chain.ChainID, true) - - // check entries related to second consumer chain are not removed - s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 1) - - secondBundle := s.getBundleByIdx(1) - slashData, vscMaturedData, _, _ := providerKeeper.GetAllThrottledPacketData( - s.providerCtx(), secondBundle.Chain.ChainID) - s.Require().Len(slashData, 1) - s.Require().Len(vscMaturedData, 1) } // TODO Simon: implement OnChanCloseConfirm in IBC-GO testing to close the consumer chain's channel end @@ -199,15 +162,4 @@ func (s *CCVTestSuite) checkConsumerChainIsRemoved(chainID string, checkChannel s.Require().Nil(providerKeeper.GetSlashAcks(s.providerCtx(), chainID)) s.Require().Zero(providerKeeper.GetInitChainHeight(s.providerCtx(), chainID)) s.Require().Empty(providerKeeper.GetPendingVSCPackets(s.providerCtx(), chainID)) - - // No remaining global entries for this consumer - allGlobalEntries := providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()) - for _, entry := range allGlobalEntries { - s.Require().NotEqual(chainID, entry.ConsumerChainID) - } - - // No remaining per-chain entries for this consumer - slashData, vscMaturedData, _, _ := providerKeeper.GetAllThrottledPacketData(s.providerCtx(), chainID) - s.Require().Empty(slashData) - s.Require().Empty(vscMaturedData) } diff --git a/tests/integration/throttle.go b/tests/integration/throttle.go index 0505d6257a..71ee3f606b 100644 --- a/tests/integration/throttle.go +++ b/tests/integration/throttle.go @@ -3,7 +3,7 @@ package integration import ( "time" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -59,12 +59,16 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { for _, val := range vals { s.Require().False(val.IsJailed()) } + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccvtypes.DefaultCCVTimeoutPeriod).UnixNano()) + ) // Send a slash packet from consumer to provider s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[0]) tmVal := s.providerChain.Vals.Validators[0] - packet := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) - sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet) + slashPacket := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData()) // Assert validator 0 is jailed and has no power vals = providerStakingKeeper.GetAllValidators(s.providerCtx()) @@ -82,10 +86,11 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { // Now send a second slash packet from consumer to provider for a different validator. s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[2]) tmVal = s.providerChain.Vals.Validators[2] - packet = s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 2) - sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet) + slashPacket = s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, 2) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData()) - // Require that slash packet has not been handled + // Require that slash packet has not been handled, a bounce result would have + // been returned, but the IBC helper throws out acks. vals = providerStakingKeeper.GetAllValidators(s.providerCtx()) s.Require().False(vals[2].IsJailed()) @@ -135,11 +140,14 @@ func (s *CCVTestSuite) TestBasicSlashPacketThrottling() { slashMeter = s.providerApp.GetProviderKeeper().GetSlashMeter(cacheCtx) s.Require().True(slashMeter.IsPositive()) - // Assert validator 2 is jailed once pending slash packets are handled in ccv endblocker. - s.providerChain.NextBlock() - vals = providerStakingKeeper.GetAllValidators(cacheCtx) - slashedVal = vals[2] - s.Require().True(slashedVal.IsJailed()) + // Assert validator 2 is jailed once slash packet is retried. + tmVal2 := s.providerChain.Vals.Validators[2] + packet := s.constructSlashPacketFromConsumer(s.getFirstBundle(), + *tmVal2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 3) // make sure to use a new seq num + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, packet.GetData()) + + stakingVal2 := s.mustGetStakingValFromTmVal(*tmVal2) + s.Require().True(stakingVal2.IsJailed()) // Assert validator 2 has no power, this should be apparent next block, // since the staking endblocker runs before the ccv endblocker. @@ -156,22 +164,12 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { s.SetupAllCCVChannels() s.setupValidatorPowers() - providerKeeper := s.providerApp.GetProviderKeeper() - providerStakingKeeper := s.providerApp.GetTestStakingKeeper() + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccvtypes.DefaultCCVTimeoutPeriod).UnixNano()) + ) - // First confirm that VSC matured packets are handled immediately (not queued) - // when no slash packets are sent. - - // Send 2 VSC matured packets from every consumer to provider - for consumerChainID, bundle := range s.consumerBundles { - packet := s.constructVSCMaturedPacketFromConsumer(*bundle, 1) // use sequence 1 - sendOnConsumerRecvOnProvider(s, bundle.Path, packet) - packet = s.constructVSCMaturedPacketFromConsumer(*bundle, 2) // use sequence 2 - sendOnConsumerRecvOnProvider(s, bundle.Path, packet) - // Confirm packets were not queued on provider for this consumer - s.Require().Equal(uint64(0), - providerKeeper.GetThrottledPacketDataSize(s.providerCtx(), consumerChainID)) - } + providerStakingKeeper := s.providerApp.GetTestStakingKeeper() // Choose 3 consumer bundles. It doesn't matter which ones. idx := 0 @@ -184,7 +182,7 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { idx++ } - // Send some packets to provider from the 3 chosen consumers. + // Send some slash packets to provider from the 3 chosen consumers. // They will each slash a different validator according to idx. idx = 0 valsToSlash := []tmtypes.Validator{} @@ -196,58 +194,74 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { // Send downtime slash packet from consumer to provider tmVal := s.providerChain.Vals.Validators[idx] valsToSlash = append(valsToSlash, *tmVal) - packet := s.constructSlashPacketFromConsumer( + slashPacket := s.constructSlashPacketFromConsumer( *bundle, *tmVal, stakingtypes.Infraction_INFRACTION_DOWNTIME, - 3, // use sequence 3, 1 and 2 are used above. + 1, // all consumers use 1 seq num ) - sendOnConsumerRecvOnProvider(s, bundle.Path, packet) - - // Send two trailing VSC matured packets from consumer to provider - packet = s.constructVSCMaturedPacketFromConsumer(*bundle, 4) // use sequence 4 - sendOnConsumerRecvOnProvider(s, bundle.Path, packet) - packet = s.constructVSCMaturedPacketFromConsumer(*bundle, 5) // use sequence 5 - sendOnConsumerRecvOnProvider(s, bundle.Path, packet) + sendOnConsumerRecvOnProvider(s, bundle.Path, timeoutHeight, timeoutTimestamp, slashPacket.GetData()) idx++ } - // Confirm that the slash packet and trailing VSC matured packet - // were handled immediately for the first consumer (this packet was recv first). + // Confirm that the slash packet for the first consumer was handled (this packet was recv first). s.confirmValidatorJailed(valsToSlash[0], true) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[0].Chain.ChainID)) - // Packets were queued for the second and third consumers. + // Packets were bounced for the second and third consumers. s.confirmValidatorNotJailed(valsToSlash[1], 1000) - s.Require().Equal(uint64(3), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[1].Chain.ChainID)) s.confirmValidatorNotJailed(valsToSlash[2], 1000) - s.Require().Equal(uint64(3), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[2].Chain.ChainID)) // Total power is now 3000 s.Require().Equal(int64(3000), providerStakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) // Now replenish the slash meter and confirm one of two queued slash - // packet entries are then handled. Order is irrelevant here since those - // two packets were sent and recv at the same block time when being queued. + // packet entries are then handled, when both are retried. s.replenishSlashMeterTillPositive() - // 1st NextBlock will handle the slash packet, 2nd will update staking module val powers + // Retry from consumer with idx 1 + bundle := senderBundles[1] + packet := s.constructSlashPacketFromConsumer( + *bundle, + valsToSlash[1], + stakingtypes.Infraction_INFRACTION_DOWNTIME, + 2, // seq number is incremented since last try + ) + sendOnConsumerRecvOnProvider(s, bundle.Path, timeoutHeight, timeoutTimestamp, packet.GetData()) + + // retry from consumer with idx 2 + bundle = senderBundles[2] + packet = s.constructSlashPacketFromConsumer( + *bundle, + valsToSlash[2], + stakingtypes.Infraction_INFRACTION_DOWNTIME, + 2, // seq number is incremented since last try + ) + sendOnConsumerRecvOnProvider(s, bundle.Path, timeoutHeight, timeoutTimestamp, packet.GetData()) + + // Call NextBlocks to update staking module val powers s.providerChain.NextBlock() s.providerChain.NextBlock() - // If one of the entires was handled, total power will be 2000 (1000 power was slashed) + // If one of the entires was handled, total power will be 2000 (1000 power was just slashed) s.Require().Equal(int64(2000), providerStakingKeeper.GetLastTotalPower(s.providerCtx()).Int64()) // Now replenish one more time, and handle final slash packet. s.replenishSlashMeterTillPositive() - // 1st NextBlock will handle the slash packet, 2nd will update last validator power + // Retry from consumer with idx 2 + bundle = senderBundles[2] + packet = s.constructSlashPacketFromConsumer( + *bundle, + valsToSlash[2], + stakingtypes.Infraction_INFRACTION_DOWNTIME, + 3, // seq number is incremented since last try + ) + sendOnConsumerRecvOnProvider(s, bundle.Path, timeoutHeight, timeoutTimestamp, packet.GetData()) + + // Call NextBlocks to update staking module val powers s.providerChain.NextBlock() s.providerChain.NextBlock() @@ -260,15 +274,6 @@ func (s *CCVTestSuite) TestMultiConsumerSlashPacketThrottling() { for _, val := range valsToSlash { s.confirmValidatorJailed(val, true) } - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[0].Chain.ChainID)) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[1].Chain.ChainID)) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), senderBundles[2].Chain.ChainID)) - - // All global queue entries are gone too - s.Require().Empty(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx())) } // TestPacketSpam confirms that the provider can handle a large number of @@ -287,8 +292,8 @@ func (s *CCVTestSuite) TestPacketSpam() { providerKeeper.SetParams(s.providerCtx(), params) providerKeeper.InitializeSlashMeter(s.providerCtx()) - // The packets to be recv in a single block, ordered as they will be recv. - packets := []channeltypes.Packet{} + // The packets data to be recv in a single block, ordered as they will be recv. + var packetsData [][]byte firstBundle := s.getFirstBundle() @@ -312,27 +317,30 @@ func (s *CCVTestSuite) TestPacketSpam() { infractionType = stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN } valToJail := s.providerChain.Vals.Validators[ibcSeqNum%3] - packets = append(packets, s.constructSlashPacketFromConsumer(firstBundle, *valToJail, infractionType, ibcSeqNum)) + slashPacket := s.constructSlashPacketFromConsumer(firstBundle, *valToJail, infractionType, ibcSeqNum) + packetsData = append(packetsData, slashPacket.GetData()) } // Recv 500 packets from consumer to provider in same block - for _, packet := range packets { - consumerPacketData, err := provider.UnmarshalConsumerPacket(packet) // Same func used by provider's OnRecvPacket + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(firstBundle.GetCtx().BlockTime().Add(ccvtypes.DefaultCCVTimeoutPeriod).UnixNano()) + ) + for sequence, data := range packetsData { + consumerPacketData, err := provider.UnmarshalConsumerPacketData(data) // Same func used by provider's OnRecvPacket s.Require().NoError(err) + packet := s.newPacketFromConsumer(data, uint64(sequence), firstBundle.Path, timeoutHeight, timeoutTimestamp) providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, *consumerPacketData.GetSlashPacketData()) } - // Execute block to handle packets in endblock + // Execute block s.providerChain.NextBlock() - // Confirm all packets are handled or dropped (queues empty) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), firstBundle.Chain.ChainID)) - slashData, vscMData, _, _ := providerKeeper.GetAllThrottledPacketData( - s.providerCtx(), firstBundle.Chain.ChainID) - s.Require().Empty(slashData) - s.Require().Empty(vscMData) - s.Require().Empty(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx())) + // Confirm 3 expected vals are jailed + for i := 0; i < 3; i++ { + val := s.providerChain.Vals.Validators[i] + s.confirmValidatorJailed(*val, true) + } } func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { @@ -349,8 +357,8 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { providerKeeper.SetParams(s.providerCtx(), params) providerKeeper.InitializeSlashMeter(s.providerCtx()) - // The packets to be recv in a single block, ordered as they will be recv. - packets := []channeltypes.Packet{} + // The packetsData to be recv in a single block, ordered as they will be recv. + var packetsData [][]byte firstBundle := s.getFirstBundle() @@ -366,28 +374,25 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { // Increment ibc seq num for each packet (starting at 1) ibcSeqNum++ valToJail := s.providerChain.Vals.Validators[ibcSeqNum%3] - packets = append(packets, s.constructSlashPacketFromConsumer(firstBundle, *valToJail, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, ibcSeqNum)) + slashPacket := s.constructSlashPacketFromConsumer(firstBundle, *valToJail, stakingtypes.Infraction_INFRACTION_DOUBLE_SIGN, ibcSeqNum) + packetsData = append(packetsData, slashPacket.GetData()) } // Recv 500 packets from consumer to provider in same block - for _, packet := range packets { - consumerPacketData, err := provider.UnmarshalConsumerPacket(packet) // Same func used by provider's OnRecvPacket + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(firstBundle.GetCtx().BlockTime().Add(ccvtypes.DefaultCCVTimeoutPeriod).UnixNano()) + ) + for sequence, data := range packetsData { + consumerPacketData, err := provider.UnmarshalConsumerPacketData(data) // Same func used by provider's OnRecvPacket s.Require().NoError(err) + packet := s.newPacketFromConsumer(data, uint64(sequence), firstBundle.Path, timeoutHeight, timeoutTimestamp) providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, *consumerPacketData.GetSlashPacketData()) } // Execute block to handle packets in endblock s.providerChain.NextBlock() - // Confirm all packets are dropped (queues empty) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize( - s.providerCtx(), firstBundle.Chain.ChainID)) - slashData, vscMData, _, _ := providerKeeper.GetAllThrottledPacketData( - s.providerCtx(), firstBundle.Chain.ChainID) - s.Require().Empty(slashData) - s.Require().Empty(vscMData) - s.Require().Empty(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx())) - // Confirm that slash meter is not affected s.Require().Equal(providerKeeper.GetSlashMeterAllowance(s.providerCtx()), providerKeeper.GetSlashMeter(s.providerCtx())) @@ -417,155 +422,6 @@ func (s *CCVTestSuite) TestDoubleSignDoesNotAffectThrottling() { } } -// TestQueueOrdering validates that the ordering of slash packet entries -// in the global queue (relevant to a single chain) matches the ordering of slash packet -// data in the chain specific queues, even in the presence of packet spam. -// -// Note: The global queue is ordered by: time, then IBC sequence number, see GlobalSlashEntryKey. -// The chain specific queue is ordered by: IBC sequence number, see ThrottledPacketDataKey. -func (s *CCVTestSuite) TestQueueOrdering() { - // Setup ccv channels to all consumers - s.SetupAllCCVChannels() - - // Setup validator powers to be 25%, 25%, 25%, 25% - s.setupValidatorPowers() - - // Explicitly set params, initialize slash meter - providerKeeper := s.providerApp.GetProviderKeeper() - params := providerKeeper.GetParams(s.providerCtx()) - params.SlashMeterReplenishFraction = "0.05" // 5% total power can be jailed - providerKeeper.SetParams(s.providerCtx(), params) - providerKeeper.InitializeSlashMeter(s.providerCtx()) - - // The packets to be recv in a single block, ordered as they will be recv. - packets := []channeltypes.Packet{} - - firstBundle := s.getFirstBundle() - - // Slash first 3 but not 4th validator - s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[0]) - s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[1]) - s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[2]) - - // Track and increment ibc seq num for each packet, since these need to be unique. - ibcSeqNum := uint64(4) - - for ibcSeqNum < 504 { - // Increment ibc seq num for each packet (starting at 5) - ibcSeqNum++ - - // Instantiate a vsc matured packet every 10th packet - if ibcSeqNum%10 == 0 { - packets = append(packets, s.constructVSCMaturedPacketFromConsumer(firstBundle, ibcSeqNum)) - continue - } - // Else instantiate a slash packet - - valToJail := s.providerChain.Vals.Validators[ibcSeqNum%3] - packets = append(packets, s.constructSlashPacketFromConsumer(firstBundle, *valToJail, stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum)) - } - - // Recv 500 packets from consumer to provider in same block - for i, packet := range packets { - - consumerPacketData, err := provider.UnmarshalConsumerPacket(packet) // Same func used by provider's OnRecvPacket - s.Require().NoError(err) - - // Type depends on index packets were appended from above - if (i+5)%10 == 0 { - vscMaturedPacketData := consumerPacketData.GetVscMaturedPacketData() - vscMaturedPacketData.ValsetUpdateId = uint64(i + 1000) - providerKeeper.OnRecvVSCMaturedPacket(s.providerCtx(), packet, *vscMaturedPacketData) - } else { - // Set valset update id to be 2000 + index to assert ordering - slashPacketData := consumerPacketData.GetSlashPacketData() - slashPacketData.ValsetUpdateId = uint64(i + 2000) - // Set block height mapping so packet is not dropped - providerKeeper.SetValsetUpdateBlockHeight(s.providerCtx(), - slashPacketData.ValsetUpdateId, uint64(firstBundle.GetCtx().BlockHeight())) - providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, *slashPacketData) - } - } - - // Confirm that global queue has 450 packet entries (500 * 0.9) - allGlobalEntries := providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()) - s.Require().Equal(450, len(allGlobalEntries)) - - // Confirm that the chain specific queue has 450 slash packet data instances, and 50 vsc matured - slashPacketData, vscMaturedPacketData, _, _ := providerKeeper.GetAllThrottledPacketData( - s.providerCtx(), firstBundle.Chain.ChainID) - s.Require().Equal(450, len(slashPacketData)) - s.Require().Equal(50, len(vscMaturedPacketData)) - - // IBC seq numbers of recv slash packets range from 5 to 504. - // Confirm expected global queue ordering. - expectedSeqNum := uint64(5) - for _, globalEntry := range allGlobalEntries { - // entries should be ordered by ibc seq num starting at 5 - s.Require().Equal(expectedSeqNum, globalEntry.IbcSeqNum) - expectedSeqNum++ - if expectedSeqNum%10 == 0 { - // Skip over vsc matured packets - expectedSeqNum++ - } - } - - // Confirm expected chain specific queue ordering. - expectedVscId := uint64(2000) - for _, slashPacket := range slashPacketData { - // entries should be ordered by valset update id starting at 2000 - s.Require().Equal(expectedVscId, slashPacket.ValsetUpdateId) - expectedVscId++ - if (expectedVscId+5)%10 == 0 { - // Skip over vsc matured packets - expectedVscId++ - } - } - for idx, vscMaturedPacket := range vscMaturedPacketData { - // entries should be ordered by valset update id starting at 1005 - // and show up every 10 packets - expectedVscId = uint64(1005) + 10*uint64(idx) - s.Require().Equal(expectedVscId, vscMaturedPacket.ValsetUpdateId) - } - - // Execute endblock to handle packets in throttled manner - s.providerChain.NextBlock() - - // Confirm that only the first packet was handled - allGlobalEntries = providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()) - s.Require().Equal(449, len(allGlobalEntries)) - slashPacketData, vscMaturedPacketData, _, _ = providerKeeper.GetAllThrottledPacketData( - s.providerCtx(), firstBundle.Chain.ChainID) - s.Require().Equal(449, len(slashPacketData)) - // No VSC matured packets should be handled yet - s.Require().Equal(50, len(vscMaturedPacketData)) - - // Replenish frac is 0.05, so jailing %25 of the validators should result in a negative slash meter. - s.Require().True(providerKeeper.GetSlashMeter(s.providerCtx()).IsNegative()) - - // Confirm total power is now 3000 once updated by staking end blocker - s.providerChain.NextBlock() - totalPower := s.providerApp.GetTestStakingKeeper().GetLastTotalPower(s.providerCtx()) - s.Require().Equal(sdk.NewInt(3000), totalPower) - - // Now change replenish frac to 0.67 and fully replenish the meter. - params.SlashMeterReplenishFraction = "0.67" - providerKeeper.SetParams(s.providerCtx(), params) - providerKeeper.InitializeSlashMeter(s.providerCtx()) - - // Execute endblock to handle packets (remaining packets are relevant to 2/3 of the validators) - // so the current replenish frac should be enough to handle all packets this block. - s.providerChain.NextBlock() - - // Confirm both queues are now empty, meaning every packet was handled. - allGlobalEntries = providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()) - s.Require().Equal(0, len(allGlobalEntries)) - slashPacketData, vscMaturedPacketData, _, _ = providerKeeper.GetAllThrottledPacketData( - s.providerCtx(), firstBundle.Chain.ChainID) - s.Require().Equal(0, len(slashPacketData)) - s.Require().Equal(0, len(vscMaturedPacketData)) -} - // TestSlashingSmallValidators tests that multiple slash packets from validators with small // power can be handled by the provider chain in a non-throttled manner. func (s *CCVTestSuite) TestSlashingSmallValidators() { @@ -595,15 +451,19 @@ func (s *CCVTestSuite) TestSlashingSmallValidators() { s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[3]) // Send slash packets from consumer to provider for small validators. + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccvtypes.DefaultCCVTimeoutPeriod).UnixNano()) + ) tmval1 := s.providerChain.Vals.Validators[1] tmval2 := s.providerChain.Vals.Validators[2] tmval3 := s.providerChain.Vals.Validators[3] - packet1 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) - packet2 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 2) - packet3 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval3, stakingtypes.Infraction_INFRACTION_DOWNTIME, 3) - sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet1) - sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet2) - sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, packet3) + slashPacket1 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) + slashPacket2 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 2) + slashPacket3 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval3, stakingtypes.Infraction_INFRACTION_DOWNTIME, 3) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket1.GetData()) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket2.GetData()) + sendOnConsumerRecvOnProvider(s, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp, slashPacket3.GetData()) // Default slash meter replenish fraction is 0.05, so all sent packets should be handled immediately. vals = providerStakingKeeper.GetAllValidators(s.providerCtx()) @@ -645,59 +505,6 @@ func (s *CCVTestSuite) TestSlashMeterAllowanceChanges() { s.Require().Equal(int64(1200), providerKeeper.GetSlashMeterAllowance(s.providerCtx()).Int64()) } -// TestSlashSameValidator tests the edge case that that the total slashed validator power -// queued up for a single block exceeds the slash meter allowance, -// but some of the slash packets are for the same validator, and therefore some packets -// will be applied to a validator that is already jailed but still not unbonded (ie. still slashable). -func (s *CCVTestSuite) TestSlashSameValidator() { - s.SetupAllCCVChannels() - - // Setup 4 validators with 25% of the total power each. - s.setupValidatorPowers() - - providerKeeper := s.providerApp.GetProviderKeeper() - - // Set replenish fraction to 1.0 so that all sent packets should handled immediately (no throttling) - params := providerKeeper.GetParams(s.providerCtx()) - params.SlashMeterReplenishFraction = fullSlashMeterString // needs to be const for linter - providerKeeper.SetParams(s.providerCtx(), params) - providerKeeper.InitializeSlashMeter(s.providerCtx()) - - // Send a downtime and double-sign slash packet for 3/4 validators - // This will have a total slashing power of 150% total power. - tmval1 := s.providerChain.Vals.Validators[1] - tmval2 := s.providerChain.Vals.Validators[2] - tmval3 := s.providerChain.Vals.Validators[3] - s.setDefaultValSigningInfo(*tmval1) - s.setDefaultValSigningInfo(*tmval2) - s.setDefaultValSigningInfo(*tmval3) - - packets := []channeltypes.Packet{ - s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1), - s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 2), - s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval3, stakingtypes.Infraction_INFRACTION_DOWNTIME, 3), - s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 4), - s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 5), - s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval3, stakingtypes.Infraction_INFRACTION_DOWNTIME, 6), - } - - // Recv and queue all slash packets. - for _, packet := range packets { - consumerPacketData, err := provider.UnmarshalConsumerPacket(packet) // Same func used by provider's OnRecvPacket - s.Require().NoError(err) - providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, *consumerPacketData.GetSlashPacketData()) - } - - // We should have 6 pending slash packet entries queued. - s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 6) - - // Call next block to process all pending slash packets in end blocker. - s.providerChain.NextBlock() - - // All slash packets should have been handled immediately, even though they totaled to 150% of total power. - s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 0) -} - // Similar to TestSlashSameValidator, but 100% of val power is jailed a single block, // and in the first packets recv for that block. // This edge case should not occur in practice, but is useful to validate that @@ -719,47 +526,41 @@ func (s CCVTestSuite) TestSlashAllValidators() { //nolint:govet // this is a tes providerKeeper.InitializeSlashMeter(s.providerCtx()) // The packets to be recv in a single block, ordered as they will be recv. - packets := []channeltypes.Packet{} - - // Track and increment ibc seq num for each packet, since these need to be unique. - ibcSeqNum := uint64(1) + var packetsData [][]byte // Instantiate a slash packet for each validator, // these first 4 packets should jail 100% of the total power. + ibcSeqNum := uint64(1) for _, val := range s.providerChain.Vals.Validators { s.setDefaultValSigningInfo(*val) - packets = append(packets, s.constructSlashPacketFromConsumer( - s.getFirstBundle(), *val, stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum)) + packetsData = append(packetsData, s.constructSlashPacketFromConsumer( + s.getFirstBundle(), *val, stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum).GetData()) ibcSeqNum++ } // add 5 more slash packets for each validator, that will be handled in the same block. for _, val := range s.providerChain.Vals.Validators { for i := 0; i < 5; i++ { - packets = append(packets, s.constructSlashPacketFromConsumer( - s.getFirstBundle(), *val, stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum)) + packetsData = append(packetsData, s.constructSlashPacketFromConsumer( + s.getFirstBundle(), *val, stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum).GetData()) ibcSeqNum++ } } // Recv and queue all slash packets. - for _, packet := range packets { - consumerPacketData, err := provider.UnmarshalConsumerPacket(packet) // Same func used by provider's OnRecvPacket + var ( + timeoutHeight = clienttypes.Height{} + timeoutTimestamp = uint64(s.getFirstBundle().GetCtx().BlockTime().Add(ccvtypes.DefaultCCVTimeoutPeriod).UnixNano()) + ) + for i, data := range packetsData { + ibcSeqNum := uint64(i) + consumerPacketData, err := provider.UnmarshalConsumerPacketData(data) // Same func used by provider's OnRecvPacket s.Require().NoError(err) + packet := s.newPacketFromConsumer(data, ibcSeqNum, s.getFirstBundle().Path, timeoutHeight, timeoutTimestamp) providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, *consumerPacketData.GetSlashPacketData()) } - // We should have 24 pending slash packet entries queued. - s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 24) - - // Call next block to process all pending slash packets in end blocker. - s.providerChain.NextBlock() - - // All slash packets should have been handled immediately, - // even though the first 4 packets jailed 100% of the total power. - s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 0) - - // Sanity check that all validators are jailed. + // Check that all validators are jailed. for _, val := range s.providerChain.Vals.Validators { // Do not check power, since val power is not yet updated by staking endblocker. s.confirmValidatorJailed(*val, false) @@ -769,148 +570,6 @@ func (s CCVTestSuite) TestSlashAllValidators() { //nolint:govet // this is a tes // "applying the validator changes would result in empty set". } -func (s *CCVTestSuite) TestLeadingVSCMaturedAreDequeued() { - s.SetupAllCCVChannels() - providerKeeper := s.providerApp.GetProviderKeeper() - - // Queue up 50 vsc matured packets for each consumer - for _, bundle := range s.consumerBundles { - for i := 0; i < 50; i++ { - ibcSeqNum := uint64(i) - packet := s.constructVSCMaturedPacketFromConsumer(*bundle, ibcSeqNum) - packetData := ccvtypes.ConsumerPacketData{} - ccvtypes.ModuleCdc.MustUnmarshalJSON(packet.GetData(), &packetData) - providerKeeper.OnRecvVSCMaturedPacket(s.providerCtx(), - packet, *packetData.GetVscMaturedPacketData()) - } - } - - // Queue up 50 slash packets for each consumer - for _, bundle := range s.consumerBundles { - for i := 50; i < 100; i++ { - ibcSeqNum := uint64(i) - packet := s.constructSlashPacketFromConsumer(*bundle, - *s.providerChain.Vals.Validators[0], stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum) - consumerPacketData, err := provider.UnmarshalConsumerPacket(packet) // Same func used by provider's OnRecvPacket - s.Require().NoError(err) - providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, *consumerPacketData.GetSlashPacketData()) - } - } - - // Queue up another 50 vsc matured packets for each consumer - for _, bundle := range s.consumerBundles { - for i := 100; i < 150; i++ { - ibcSeqNum := uint64(i) - packet := s.constructVSCMaturedPacketFromConsumer(*bundle, ibcSeqNum) - packetData := ccvtypes.ConsumerPacketData{} - ccvtypes.ModuleCdc.MustUnmarshalJSON(packet.GetData(), &packetData) - providerKeeper.OnRecvVSCMaturedPacket(s.providerCtx(), - packet, *packetData.GetVscMaturedPacketData()) - } - } - - // Confirm queue size is 150 for each consumer-specific queue. - for _, bundle := range s.consumerBundles { - s.Require().Equal(uint64(150), - providerKeeper.GetThrottledPacketDataSize(s.providerCtx(), bundle.Chain.ChainID)) - } - // Confirm global queue size is 50 * 5 (50 slash packets for each of 5 consumers) - globalEntries := providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()) - s.Require().Equal(len(globalEntries), 50*5) - - // Set slash meter to negative value to not allow any slash packets to be handled. - providerKeeper.SetSlashMeter(s.providerCtx(), sdk.NewInt(-1)) - - // Set replenish time candidate so that no replenishment happens next block. - providerKeeper.SetSlashMeterReplenishTimeCandidate(s.providerCtx()) - - // Execute end blocker to dequeue only the leading vsc matured packets. - // Note we must call the end blocker three times, since only 100 vsc matured packets can be handled - // each block, and we have 5*50=250 total. - s.providerChain.NextBlock() - s.providerChain.NextBlock() - s.providerChain.NextBlock() - - // Confirm queue size is 100 for each consumer-specific queue (50 leading vsc matured are dequeued). - for _, bundle := range s.consumerBundles { - s.Require().Equal(uint64(100), - providerKeeper.GetThrottledPacketDataSize(s.providerCtx(), bundle.Chain.ChainID)) - } - - // No slash packets handled, global slash queue is same size as last block. - globalEntries = providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()) - s.Require().Equal(len(globalEntries), 50*5) - - // No slash packets handled even if we call end blocker a couple more times. - s.providerChain.NextBlock() - s.providerChain.NextBlock() - globalEntries = providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()) - s.Require().Equal(len(globalEntries), 50*5) -} - -// TestVscMaturedHandledPerBlockLimit tests that only 100 vsc matured packets are handled per block, -// specifically from HandleThrottleQueues(). -// -// Note the vsc matured per block limit is also tested in, TestLeadingVSCMaturedAreDequeued, -// specifically in the context of HandleLeadingVSCMaturedPackets(). -func (s *CCVTestSuite) TestVscMaturedHandledPerBlockLimit() { - s.SetupAllCCVChannels() - providerKeeper := s.providerApp.GetProviderKeeper() - - // Set replenish fraction to 1.0 so that all sent packets should be handled immediately (no jail throttling) - params := providerKeeper.GetParams(s.providerCtx()) - params.SlashMeterReplenishFraction = fullSlashMeterString // needs to be const for linter - providerKeeper.SetParams(s.providerCtx(), params) - providerKeeper.InitializeSlashMeter(s.providerCtx()) - - // Queue up 100 vsc matured packets for each consumer - for _, bundle := range s.consumerBundles { - for i := 0; i < 100; i++ { - ibcSeqNum := uint64(i) - packet := s.constructVSCMaturedPacketFromConsumer(*bundle, ibcSeqNum) - packetData := ccvtypes.ConsumerPacketData{} - ccvtypes.ModuleCdc.MustUnmarshalJSON(packet.GetData(), &packetData) - providerKeeper.OnRecvVSCMaturedPacket(s.providerCtx(), - packet, *packetData.GetVscMaturedPacketData()) - } - } - - // Queue up 50 slash packets for each consumer, with new IBC sequence numbers - for _, bundle := range s.consumerBundles { - for i := 100; i < 150; i++ { - ibcSeqNum := uint64(i) - packet := s.constructSlashPacketFromConsumer(*bundle, - *s.providerChain.Vals.Validators[0], stakingtypes.Infraction_INFRACTION_DOWNTIME, ibcSeqNum) - consumerPacketData, err := provider.UnmarshalConsumerPacket(packet) // Same func used by provider's OnRecvPacket - s.Require().NoError(err) - providerKeeper.OnRecvSlashPacket(s.providerCtx(), packet, *consumerPacketData.GetSlashPacketData()) - } - } - - // Confirm queue size is 150 for each consumer-specific queue. - for _, bundle := range s.consumerBundles { - s.Require().Equal(uint64(150), - providerKeeper.GetThrottledPacketDataSize(s.providerCtx(), bundle.Chain.ChainID)) - } - // Confirm global queue size is 50 * 5 (50 slash packets for each of 5 consumers) - globalEntries := providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()) - s.Require().Equal(len(globalEntries), 50*5) - - // Note even though there is no jail throttling active, slash packets will not be handled until - // all of the leading vsc matured packets are handled first. This should take 5 blocks. - for i := 0; i < 5; i++ { - s.providerChain.NextBlock() - s.Require().Len(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx()), 250) // global entries remain same size - } - - // Set signing info for val to be jailed, preventing panic - s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[0]) - - // Now we execute one more block and all 250 of the slash packets should be handled. - s.providerChain.NextBlock() - s.Require().Empty(providerKeeper.GetAllGlobalSlashEntries(s.providerCtx())) // empty global entries = all slash packets handled -} - func (s *CCVTestSuite) confirmValidatorJailed(tmVal tmtypes.Validator, checkPower bool) { sdkVal, found := s.providerApp.GetTestStakingKeeper().GetValidator( s.providerCtx(), sdk.ValAddress(tmVal.Address)) diff --git a/tests/integration/throttle_retry.go b/tests/integration/throttle_retry.go index ae15aac977..4b445d5d25 100644 --- a/tests/integration/throttle_retry.go +++ b/tests/integration/throttle_retry.go @@ -1,32 +1,25 @@ package integration import ( + "time" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - provider "github.com/cosmos/interchain-security/v3/x/ccv/provider" - providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) -// TestSlashRetries tests the throttling v2 retry logic. Without provider changes, -// the consumer will queue up a slash packet, the provider will return a v1 result, -// and the consumer will never need to retry. -// -// Once provider changes are made (slash packet queuing is removed), the consumer may retry packets -// via new result acks from the provider. -// -// TODO: This test will need updating once provider changes are made. +// TestSlashRetries tests the throttling v2 retry logic at an integration level. func (s *CCVTestSuite) TestSlashRetries() { s.SetupAllCCVChannels() + s.SendEmptyVSCPacket() // Establish ccv channel s.setupValidatorPowers() // // Provider setup // providerKeeper := s.providerApp.GetProviderKeeper() - providerModule := provider.NewAppModule(&providerKeeper, s.providerApp.GetSubspace(providertypes.ModuleName)) // Initialize slash meter providerKeeper.InitializeSlashMeter(s.providerCtx()) // Assert that we start out with no jailings @@ -35,13 +28,24 @@ func (s *CCVTestSuite) TestSlashRetries() { for _, val := range vals { s.Require().False(val.IsJailed()) } + + // We jail two different validators in this test, referred to as val1 and val2. + // This may or may not correspond to the indexes 1 and 2 in various validator slices, + // depending on how the slice is constructed. + + // The s.providerChain.Vals.Validators set will change depending on jailings, + // so we cache these two val objects now to be the canonical val1 and val2. + tmval1 := s.providerChain.Vals.Validators[1] + tmval2 := s.providerChain.Vals.Validators[2] + // Setup signing info for jailings - s.setDefaultValSigningInfo(*s.providerChain.Vals.Validators[1]) + s.setDefaultValSigningInfo(*tmval1) + s.setDefaultValSigningInfo(*tmval2) // // Consumer setup // - consumerKeeper := s.consumerApp.GetConsumerKeeper() + consumerKeeper := s.getFirstBundle().App.GetConsumerKeeper() // Assert no slash record exists _, found := consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().False(found) @@ -50,101 +54,166 @@ func (s *CCVTestSuite) TestSlashRetries() { // Test section: See FSM explanation in throttle_retry.go // - // Construct a mock slash packet from consumer - tmval1 := s.providerChain.Vals.Validators[1] - packet1 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) + // Construct a slash packet + packet1, data := s.constructSlashPacketFromConsumerWithData( + s.getFirstBundle(), *tmval1, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) - // Mock the sending of the packet on consumer + // Append packet to be sent by consumer consumerKeeper.AppendPendingPacket(s.consumerCtx(), ccvtypes.SlashPacket, &ccvtypes.ConsumerPacketData_SlashPacketData{ - SlashPacketData: &ccvtypes.SlashPacketData{}, + SlashPacketData: &data, }, ) - consumerKeeper.UpdateSlashRecordOnSend(s.consumerCtx()) + + sendTime := s.consumerCtx().BlockTime() + + // Advance block on consumer to send pending packet + s.getFirstBundle().Chain.NextBlock() + + // Confirm packet was sent via state that's updated on send slashRecord, found := consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().True(found) s.Require().True(slashRecord.WaitingOnReply) + s.Require().NotZero(slashRecord.SendTime) + s.Require().Equal(sendTime, slashRecord.SendTime) s.Require().Len(consumerKeeper.GetPendingPackets(s.consumerCtx()), 1) - // Recv packet on provider and assert ack. Provider should return v1 result. - ack := providerModule.OnRecvPacket(s.providerCtx(), packet1, nil) - expectedv1Ack := channeltypes.NewResultAcknowledgement([]byte(ccvtypes.V1Result)) - s.Require().Equal(expectedv1Ack.Acknowledgement(), ack.Acknowledgement()) + // Packet sending blocked until provider returns slash packet handled ack + s.Require().False(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + + // Recv packet on provider. + relayAllCommittedPackets(s, s.consumerChain, s.path, ccvtypes.ConsumerPortID, s.path.EndpointA.ChannelID, 1) // Couple blocks pass on provider for provider staking keeper to process jailing s.providerChain.NextBlock() s.providerChain.NextBlock() // Default slash meter replenish fraction is 0.05, so packet should be handled on provider. - vals = s.providerApp.GetTestStakingKeeper().GetAllValidators(s.providerCtx()) - s.Require().True(vals[1].IsJailed()) + stakingVal1 := s.mustGetStakingValFromTmVal(*tmval1) + s.Require().True(stakingVal1.IsJailed()) s.Require().Equal(int64(0), - s.providerApp.GetTestStakingKeeper().GetLastValidatorPower(s.providerCtx(), vals[1].GetOperator())) - s.Require().Equal(uint64(0), providerKeeper.GetThrottledPacketDataSize(s.providerCtx(), - s.getFirstBundle().Chain.ChainID)) + s.providerApp.GetTestStakingKeeper().GetLastValidatorPower(s.providerCtx(), stakingVal1.GetOperator())) // Now slash meter should be negative on provider s.Require().True(s.providerApp.GetProviderKeeper().GetSlashMeter(s.providerCtx()).IsNegative()) // Apply ack back on consumer - ackForConsumer := expectedv1Ack - err := consumerKeeper.OnAcknowledgementPacket(s.consumerCtx(), packet1, ackForConsumer) + expectedAck := channeltypes.NewResultAcknowledgement([]byte(ccvtypes.SlashPacketHandledResult)) + err := s.getFirstBundle().Path.EndpointA.AcknowledgePacket(packet1, expectedAck.Acknowledgement()) s.Require().NoError(err) - // Slash record should have been deleted, head of pending packets should have been popped - // Since provider has handled the packet + // Slash record should have been deleted, head of pending packets should have been popped, + // since provider has handled the packet. _, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().False(found) s.Require().Empty(consumerKeeper.GetPendingPackets(s.consumerCtx())) + // Packet sending should now be unblocked + s.Require().True(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + // pass two blocks on provider and consumer for good measure s.providerChain.NextBlock() s.providerChain.NextBlock() s.consumerChain.NextBlock() s.consumerChain.NextBlock() - // Construct and mock the sending of a second packet on consumer - tmval2 := s.providerChain.Vals.Validators[2] - packet2 := s.constructSlashPacketFromConsumer(s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) - + // Have consumer queue a new slash packet for a different validator. + packet2, data := s.constructSlashPacketFromConsumerWithData( + s.getFirstBundle(), *tmval2, stakingtypes.Infraction_INFRACTION_DOWNTIME, 1) consumerKeeper.AppendPendingPacket(s.consumerCtx(), ccvtypes.SlashPacket, &ccvtypes.ConsumerPacketData_SlashPacketData{ - SlashPacketData: &ccvtypes.SlashPacketData{}, + SlashPacketData: &data, }, ) - consumerKeeper.UpdateSlashRecordOnSend(s.consumerCtx()) + + // Advance block on consumer to send pending packet + sendTime = s.consumerCtx().BlockTime() + s.getFirstBundle().Chain.NextBlock() + + // Confirm packet was sent via state that's updated on send slashRecord, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().True(found) s.Require().True(slashRecord.WaitingOnReply) + s.Require().NotZero(slashRecord.SendTime) + s.Require().Equal(sendTime, slashRecord.SendTime) s.Require().Len(consumerKeeper.GetPendingPackets(s.consumerCtx()), 1) - // Recv 2nd slash packet on provider for different validator. - // Provider should return the same v1 result ack even tho the packet was queued. - ack = providerModule.OnRecvPacket(s.providerCtx(), packet2, nil) - expectedv1Ack = channeltypes.NewResultAcknowledgement([]byte(ccvtypes.V1Result)) - s.Require().Equal(expectedv1Ack.Acknowledgement(), ack.Acknowledgement()) + // Packet sending blocked until provider returns slash packet handled ack + s.Require().False(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + + // Recv 2nd packet on provider. + relayAllCommittedPackets(s, s.consumerChain, s.path, ccvtypes.ConsumerPortID, s.path.EndpointA.ChannelID, 1) // Couple blocks pass on provider for staking keeper to process jailings s.providerChain.NextBlock() s.providerChain.NextBlock() - // Val shouldn't be jailed on provider. Slash packet was queued - s.Require().False(vals[2].IsJailed()) + // Val 2 shouldn't be jailed on provider. Slash packet should have been bounced. + stakingVal2 := s.mustGetStakingValFromTmVal(*tmval2) + s.Require().False(stakingVal2.IsJailed()) s.Require().Equal(int64(1000), - providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), vals[2].GetOperator())) - s.Require().Equal(uint64(1), providerKeeper.GetThrottledPacketDataSize(s.providerCtx(), - s.getFirstBundle().Chain.ChainID)) + providerStakingKeeper.GetLastValidatorPower(s.providerCtx(), stakingVal2.GetOperator())) // Apply ack on consumer - ackForConsumer = expectedv1Ack - err = consumerKeeper.OnAcknowledgementPacket(s.consumerCtx(), packet2, ackForConsumer) + expectedAck = channeltypes.NewResultAcknowledgement([]byte(ccvtypes.SlashPacketBouncedResult)) + err = s.getFirstBundle().Path.EndpointA.AcknowledgePacket(packet2, expectedAck.Acknowledgement()) s.Require().NoError(err) - // TODO: when provider changes are made, slashRecord.WaitingOnReply should have been updated to false on consumer. Slash Packet will still be in consumer's pending packets queue. + // Now consumer should have updated it's slash record on receipt of bounce ack + slashRecord, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) + s.Require().True(found) + s.Require().False(slashRecord.WaitingOnReply) + // Packet still at head of queue + s.Require().Len(consumerKeeper.GetPendingPackets(s.consumerCtx()), 1) + + // Packet sending should still be blocked, WaitingOnReply is false, + // but retry delay hasn't passed yet. + s.Require().False(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + + // IBC testing framework doesn't have a way to advance time, + // so we manually mutate send time in the slash record to be in the past. + slashRecord.SendTime = slashRecord.SendTime.Add(-time.Hour - time.Minute) + consumerKeeper.SetSlashRecord(s.consumerCtx(), slashRecord) + + s.Require().True(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) + + // Set slash meter on provider to positive value, + // now allowing handling of the slash packet + providerKeeper.InitializeSlashMeter(s.providerCtx()) + + // Advance block on consumer, now consumer should retry the sending of the slash packet. + sendTime = s.consumerCtx().BlockTime() + s.getFirstBundle().Chain.NextBlock() + + // Confirm packet was sent via state that's updated on send + slashRecord, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) + s.Require().True(found) + s.Require().True(slashRecord.WaitingOnReply) + s.Require().NotZero(slashRecord.SendTime) + s.Require().Equal(sendTime, slashRecord.SendTime) + s.Require().Len(consumerKeeper.GetPendingPackets(s.consumerCtx()), 1) + + // Recv retried packet on provider. + relayAllCommittedPackets(s, s.consumerChain, s.path, ccvtypes.ConsumerPortID, s.path.EndpointA.ChannelID, 1) + + // Couple blocks pass on provider for provider staking keeper to process jailing + s.providerChain.NextBlock() + s.providerChain.NextBlock() + + // Provider should have now jailed val 2 + stakingVal2 = s.mustGetStakingValFromTmVal(*tmval2) + s.Require().True(stakingVal2.IsJailed()) + s.Require().Equal(int64(0), + s.providerApp.GetTestStakingKeeper().GetLastValidatorPower(s.providerCtx(), stakingVal2.GetOperator())) + + // Apply ack on consumer + expectedAck = channeltypes.NewResultAcknowledgement([]byte(ccvtypes.SlashPacketHandledResult)) + err = s.getFirstBundle().Path.EndpointA.AcknowledgePacket(packet2, expectedAck.Acknowledgement()) + s.Require().NoError(err) - // Slash record should have been deleted, head of pending packets should have been popped - // Since provider has handled the packet + // Consumer state is properly cleared again _, found = consumerKeeper.GetSlashRecord(s.consumerCtx()) s.Require().False(found) s.Require().Empty(consumerKeeper.GetPendingPackets(s.consumerCtx())) + s.Require().True(consumerKeeper.PacketSendingPermitted(s.consumerCtx())) } diff --git a/tests/integration/unbonding.go b/tests/integration/unbonding.go index 7693c782e5..35d1cfbae1 100644 --- a/tests/integration/unbonding.go +++ b/tests/integration/unbonding.go @@ -370,6 +370,10 @@ func (s *CCVTestSuite) TestRedelegationNoConsumer() { s.providerCtx().BlockTime().Add(stakingKeeper.UnbondingTime(s.providerCtx())), ) + // required before call to incrementTimeByUnbondingPeriod or else a panic + // occurs in ibc-go because trusted validators don't match last trusted. + s.providerChain.NextBlock() + // Increment time so that the unbonding period passes on the provider incrementTimeByUnbondingPeriod(s, Provider) diff --git a/tests/integration/valset_update.go b/tests/integration/valset_update.go index 955261aa79..b12066afa8 100644 --- a/tests/integration/valset_update.go +++ b/tests/integration/valset_update.go @@ -4,7 +4,6 @@ import ( "time" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -71,8 +70,7 @@ func (suite *CCVTestSuite) TestQueueAndSendVSCMaturedPackets() { ) // send first packet - packet := channeltypes.NewPacket(pd.GetBytes(), 1, ccv.ProviderPortID, suite.path.EndpointB.ChannelID, ccv.ConsumerPortID, suite.path.EndpointA.ChannelID, - clienttypes.NewHeight(1, 0), 0) + packet := suite.newPacketFromProvider(pd.GetBytes(), 1, suite.path, clienttypes.NewHeight(1, 0), 0) ack := consumerKeeper.OnRecvVSCPacket(suite.consumerChain.GetContext(), packet, pd) suite.Require().NotNil(ack, "OnRecvVSCPacket did not return ack") suite.Require().True(ack.Success(), "OnRecvVSCPacket did not return a Success Acknowledgment") diff --git a/testutil/ibc_testing/generic_setup.go b/testutil/ibc_testing/generic_setup.go index 25c483fca5..4b108e8120 100644 --- a/testutil/ibc_testing/generic_setup.go +++ b/testutil/ibc_testing/generic_setup.go @@ -1,32 +1,47 @@ package ibc_testing import ( + "encoding/json" "fmt" "testing" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cometbft/cometbft/abci/types" tmencoding "github.com/cometbft/cometbft/crypto/encoding" tmtypes "github.com/cometbft/cometbft/types" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" testutil "github.com/cosmos/interchain-security/v3/testutil/integration" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" ) +type ( + AppIniter func() (ibctesting.TestingApp, map[string]json.RawMessage) + ValSetAppIniter func([]types.ValidatorUpdate) AppIniter +) + // Contains generic setup code for running integration tests against a provider, consumer, // and/or democracy consumer app.go implementation. You should not need to modify or replicate this file // to run integration tests against your app.go implementations! var ( + FirstConsumerChainID string + provChainID string + democConsumerChainID string +) + +func init() { + // Disable revision format + ibctesting.ChainIDSuffix = "" FirstConsumerChainID = ibctesting.GetChainID(2) - provChainID = ibctesting.GetChainID(1) + provChainID = ibctesting.GetChainID(1) democConsumerChainID = ibctesting.GetChainID(5000) -) +} // ConsumerBundle serves as a way to store useful in-mem consumer app chain state // and relevant IBC paths in the context of CCV integration testing. @@ -48,11 +63,12 @@ func (cb ConsumerBundle) GetKeeper() consumerkeeper.Keeper { } // AddProvider adds a new provider chain to the coordinator and returns the test chain and app type -func AddProvider[T testutil.ProviderApp](t *testing.T, coordinator *ibctesting.Coordinator, appIniter ibctesting.AppIniter) ( +func AddProvider[T testutil.ProviderApp](t *testing.T, coordinator *ibctesting.Coordinator, appIniter AppIniter) ( *ibctesting.TestChain, T, ) { t.Helper() - provider := ibctesting.NewTestChain(t, coordinator, appIniter, provChainID) + ibctesting.DefaultTestingAppInit = appIniter + provider := ibctesting.NewTestChain(t, coordinator, provChainID) coordinator.Chains[provChainID] = provider providerToReturn, ok := provider.App.(T) @@ -64,11 +80,18 @@ func AddProvider[T testutil.ProviderApp](t *testing.T, coordinator *ibctesting.C } // AddDemocracyConsumer adds a new democ consumer chain to the coordinator and returns the test chain and app type -func AddDemocracyConsumer[T testutil.DemocConsumerApp](t *testing.T, coordinator *ibctesting.Coordinator, - appIniter ibctesting.AppIniter, +func AddDemocracyConsumer[T testutil.DemocConsumerApp]( + coordinator *ibctesting.Coordinator, + s *suite.Suite, + appIniter ValSetAppIniter, ) (*ibctesting.TestChain, T) { - t.Helper() - democConsumer := ibctesting.NewTestChain(t, coordinator, appIniter, democConsumerChainID) + s.T().Helper() + + // generate validators private/public key + valSet, valUpdates, signers := testutil.CreateValidators(s.T(), 4) + + ibctesting.DefaultTestingAppInit = appIniter(valUpdates) + democConsumer := ibctesting.NewTestChainWithValSet(s.T(), coordinator, democConsumerChainID, valSet, signers) coordinator.Chains[democConsumerChainID] = democConsumer democConsumerToReturn, ok := democConsumer.App.(T) @@ -89,7 +112,7 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( coordinator *ibctesting.Coordinator, s *suite.Suite, index int, - appIniter ibctesting.AppIniter, + appIniter ValSetAppIniter, ) *ConsumerBundle { // consumer chain ID chainID := ibctesting.GetChainID(index + 2) @@ -122,7 +145,7 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( // use InitialValSet as the valset on the consumer var valz []*tmtypes.Validator - for _, update := range consumerGenesisState.InitialValSet { + for _, update := range consumerGenesisState.Provider.InitialValSet { // tmPubKey update.PubKey tmPubKey, err := tmencoding.PubKeyFromProto(update.PubKey) s.Require().NoError(err) @@ -135,8 +158,9 @@ func AddConsumer[Tp testutil.ProviderApp, Tc testutil.ConsumerApp]( } // create and instantiate consumer chain - testChain := ibctesting.NewTestChainWithValSet(s.T(), coordinator, - appIniter, chainID, tmtypes.NewValidatorSet(valz), providerChain.Signers) + ibctesting.DefaultTestingAppInit = appIniter(consumerGenesisState.Provider.InitialValSet) + testChain := ibctesting.NewTestChainWithValSet(s.T(), coordinator, chainID, + tmtypes.NewValidatorSet(valz), providerChain.Signers) coordinator.Chains[chainID] = testChain consumerToReturn, ok := testChain.App.(Tc) diff --git a/testutil/ibc_testing/specific_setup.go b/testutil/ibc_testing/specific_setup.go index 948007d212..d0b2ac7bb8 100644 --- a/testutil/ibc_testing/specific_setup.go +++ b/testutil/ibc_testing/specific_setup.go @@ -7,15 +7,27 @@ package ibc_testing import ( "encoding/json" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" + sdk "github.com/cosmos/cosmos-sdk/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" tmdb "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" appConsumer "github.com/cosmos/interchain-security/v3/app/consumer" appConsumerDemocracy "github.com/cosmos/interchain-security/v3/app/consumer-democracy" appProvider "github.com/cosmos/interchain-security/v3/app/provider" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" + consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" +) + +var ( + _ AppIniter = ProviderAppIniter + _ ValSetAppIniter = ConsumerAppIniter + _ ValSetAppIniter = DemocracyConsumerAppIniter ) // ProviderAppIniter implements ibctesting.AppIniter for a provider app @@ -25,16 +37,44 @@ func ProviderAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) { return testApp, appProvider.NewDefaultGenesisState(encoding.Codec) } -// ConsumerAppIniter implements ibctesting.AppIniter for a consumer app -func ConsumerAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) { - encoding := appConsumer.MakeTestEncodingConfig() - testApp := appConsumer.New(log.NewNopLogger(), tmdb.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}) - return testApp, appConsumer.NewDefaultGenesisState(encoding.Codec) +// ConsumerAppIniter returns a ibctesting.ValSetAppIniter for a consumer app +func ConsumerAppIniter(initValPowers []types.ValidatorUpdate) AppIniter { + return func() (ibctesting.TestingApp, map[string]json.RawMessage) { + encoding := appConsumer.MakeTestEncodingConfig() + testApp := appConsumer.New(log.NewNopLogger(), tmdb.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}) + genesisState := appConsumer.NewDefaultGenesisState(encoding.Codec) + // NOTE ibc-go/v7/testing.SetupWithGenesisValSet requires a staking module + // genesisState or it panics. Feed a minimum one. + genesisState[stakingtypes.ModuleName] = encoding.Codec.MustMarshalJSON( + &stakingtypes.GenesisState{ + Params: stakingtypes.Params{BondDenom: sdk.DefaultBondDenom}, + }, + ) + // Feed consumer genesis with provider validators + var consumerGenesis ccvtypes.ConsumerGenesisState + encoding.Codec.MustUnmarshalJSON(genesisState[consumertypes.ModuleName], &consumerGenesis) + consumerGenesis.Provider.InitialValSet = initValPowers + consumerGenesis.Params.Enabled = true + genesisState[consumertypes.ModuleName] = encoding.Codec.MustMarshalJSON(&consumerGenesis) + + return testApp, genesisState + } } -// DemocracyConsumerAppIniter implements ibctesting.AppIniter for a democracy consumer app -func DemocracyConsumerAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) { - encoding := appConsumerDemocracy.MakeTestEncodingConfig() - testApp := appConsumerDemocracy.New(log.NewNopLogger(), tmdb.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}) - return testApp, appConsumerDemocracy.NewDefaultGenesisState(encoding.Codec) +// DemocracyConsumerAppIniter implements ibctesting.ValSetAppIniter for a democracy consumer app +func DemocracyConsumerAppIniter(initValPowers []types.ValidatorUpdate) AppIniter { + return func() (ibctesting.TestingApp, map[string]json.RawMessage) { + encoding := appConsumerDemocracy.MakeTestEncodingConfig() + testApp := appConsumerDemocracy.New(log.NewNopLogger(), tmdb.NewMemDB(), nil, true, simtestutil.EmptyAppOptions{}) + genesisState := appConsumerDemocracy.NewDefaultGenesisState(encoding.Codec) + // Feed consumer genesis with provider validators + // TODO See if useful for democracy + var consumerGenesis ccvtypes.ConsumerGenesisState + encoding.Codec.MustUnmarshalJSON(genesisState[consumertypes.ModuleName], &consumerGenesis) + consumerGenesis.Provider.InitialValSet = initValPowers + consumerGenesis.Params.Enabled = true + genesisState[consumertypes.ModuleName] = encoding.Codec.MustMarshalJSON(&consumerGenesis) + + return testApp, genesisState + } } diff --git a/testutil/integration/debug_test.go b/testutil/integration/debug_test.go index 828c9b6810..ab1c78af7f 100644 --- a/testutil/integration/debug_test.go +++ b/testutil/integration/debug_test.go @@ -85,6 +85,10 @@ func TestEndBlockRD(t *testing.T) { runCCVTestByName(t, "TestEndBlockRD") } +func TestSendRewardsToProvider(t *testing.T) { + runCCVTestByName(t, "TestSendRewardsToProvider") +} + // // Expired client tests // @@ -177,10 +181,6 @@ func TestDoubleSignDoesNotAffectThrottling(t *testing.T) { runCCVTestByName(t, "TestDoubleSignDoesNotAffectThrottling") } -func TestQueueOrdering(t *testing.T) { - runCCVTestByName(t, "TestQueueOrdering") -} - func TestSlashingSmallValidators(t *testing.T) { runCCVTestByName(t, "TestSlashingSmallValidators") } @@ -189,22 +189,10 @@ func TestSlashMeterAllowanceChanges(t *testing.T) { runCCVTestByName(t, "TestSlashMeterAllowanceChanges") } -func TestSlashSameValidator(t *testing.T) { - runCCVTestByName(t, "TestSlashSameValidator") -} - func TestSlashAllValidators(t *testing.T) { runCCVTestByName(t, "TestSlashAllValidators") } -func TestLeadingVSCMaturedAreDequeued(t *testing.T) { - runCCVTestByName(t, "TestLeadingVSCMaturedAreDequeued") -} - -func TestVscMaturedHandledPerBlockLimit(t *testing.T) { - runCCVTestByName(t, "TestVscMaturedHandledPerBlockLimit") -} - // // Unbonding tests // diff --git a/testutil/integration/interfaces.go b/testutil/integration/interfaces.go index b677d46789..f084129ec0 100644 --- a/testutil/integration/interfaces.go +++ b/testutil/integration/interfaces.go @@ -3,6 +3,8 @@ package integration import ( "time" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + "cosmossdk.io/math" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" @@ -18,7 +20,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" providerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/provider/keeper" ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" diff --git a/testutil/integration/validators.go b/testutil/integration/validators.go new file mode 100644 index 0000000000..c8d2decadc --- /dev/null +++ b/testutil/integration/validators.go @@ -0,0 +1,50 @@ +package integration + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/testutil/mock" + + "github.com/cometbft/cometbft/abci/types" + tmencoding "github.com/cometbft/cometbft/crypto/encoding" + tmtypes "github.com/cometbft/cometbft/types" +) + +func CreateValidators(t *testing.T, n int) ( + *tmtypes.ValidatorSet, []types.ValidatorUpdate, map[string]tmtypes.PrivValidator, +) { + t.Helper() + // generate validators private/public key + var ( + validators []*tmtypes.Validator + signersByAddress = make(map[string]tmtypes.PrivValidator, n) + ) + for i := 0; i < n; i++ { + privVal := mock.NewPV() + pubKey, err := privVal.GetPubKey() + require.NoError(t, err) + val := tmtypes.NewValidator(pubKey, 1) + validators = append(validators, val) + signersByAddress[pubKey.Address().String()] = privVal + } + // construct validator set; + // Note that the validators are sorted by voting power + // or, if equal, by address lexical order + valSet := tmtypes.NewValidatorSet(validators) + return valSet, ToValidatorUpdates(t, valSet), signersByAddress +} + +func ToValidatorUpdates(t *testing.T, valSet *tmtypes.ValidatorSet) (valUpdates []types.ValidatorUpdate) { + t.Helper() + for _, val := range valSet.Validators { + protoPubKey, err := tmencoding.PubKeyToProto(val.PubKey) + require.NoError(t, err) + valUpdates = append(valUpdates, types.ValidatorUpdate{ + PubKey: protoPubKey, + Power: val.VotingPower, + }) + } + return +} diff --git a/testutil/keeper/expectations.go b/testutil/keeper/expectations.go index 07d4d320ba..7814fe0fcf 100644 --- a/testutil/keeper/expectations.go +++ b/testutil/keeper/expectations.go @@ -81,8 +81,9 @@ func GetMocksForSetConsumerChain(ctx sdk.Context, mocks *MockedKeepers, } } -// GetMocksForStopConsumerChain returns mock expectations needed to call StopConsumerChain(). -func GetMocksForStopConsumerChain(ctx sdk.Context, mocks *MockedKeepers) []*gomock.Call { +// GetMocksForStopConsumerChainWithCloseChannel returns mock expectations needed to call StopConsumerChain() when +// `closeChan` is true. +func GetMocksForStopConsumerChainWithCloseChannel(ctx sdk.Context, mocks *MockedKeepers) []*gomock.Call { dummyCap := &capabilitytypes.Capability{} return []*gomock.Call{ mocks.MockChannelKeeper.EXPECT().GetChannel(gomock.Any(), types.ProviderPortID, "channelID").Return( diff --git a/testutil/keeper/unit_test_helpers.go b/testutil/keeper/unit_test_helpers.go index c5540f4601..77b4df9c10 100644 --- a/testutil/keeper/unit_test_helpers.go +++ b/testutil/keeper/unit_test_helpers.go @@ -207,7 +207,10 @@ func GetNewVSCMaturedPacketData() types.VSCMaturedPacketData { } // SetupForStoppingConsumerChain registers expected mock calls and corresponding state setup -// which asserts that a consumer chain was properly stopped from StopConsumerChain(). +// which assert that a consumer chain was properly setup to be later stopped from `StopConsumerChain`. +// Note: This function only setups and tests that we correctly setup a consumer chain that we could later stop when +// calling `StopConsumerChain` -- this does NOT necessarily mean that the consumer chain is stopped. +// Also see `TestProviderStateIsCleanedAfterConsumerChainIsStopped`. func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks MockedKeepers, ) { @@ -215,7 +218,6 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, expectations := GetMocksForCreateConsumerClient(ctx, &mocks, "chainID", clienttypes.NewHeight(4, 5)) expectations = append(expectations, GetMocksForSetConsumerChain(ctx, &mocks, "chainID")...) - expectations = append(expectations, GetMocksForStopConsumerChain(ctx, &mocks)...) gomock.InOrder(expectations...) @@ -226,6 +228,34 @@ func SetupForStoppingConsumerChain(t *testing.T, ctx sdk.Context, require.NoError(t, err) } +// TestProviderStateIsCleanedAfterConsumerChainIsStopped executes test assertions for the provider's state being cleaned +// after a stopped consumer chain. +func TestProviderStateIsCleanedAfterConsumerChainIsStopped(t *testing.T, ctx sdk.Context, providerKeeper providerkeeper.Keeper, + expectedChainID, expectedChannelID string, +) { + t.Helper() + _, found := providerKeeper.GetConsumerClientId(ctx, expectedChainID) + require.False(t, found) + _, found = providerKeeper.GetChainToChannel(ctx, expectedChainID) + require.False(t, found) + _, found = providerKeeper.GetChannelToChain(ctx, expectedChannelID) + require.False(t, found) + _, found = providerKeeper.GetInitChainHeight(ctx, expectedChainID) + require.False(t, found) + acks := providerKeeper.GetSlashAcks(ctx, expectedChainID) + require.Empty(t, acks) + _, found = providerKeeper.GetInitTimeoutTimestamp(ctx, expectedChainID) + require.False(t, found) + + require.Empty(t, providerKeeper.GetAllVscSendTimestamps(ctx, expectedChainID)) + + // test key assignment state is cleaned + require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &expectedChainID)) + require.Empty(t, providerKeeper.GetAllValidatorsByConsumerAddr(ctx, &expectedChainID)) + require.Empty(t, providerKeeper.GetAllKeyAssignmentReplacements(ctx, expectedChainID)) + require.Empty(t, providerKeeper.GetAllConsumerAddrsToPrune(ctx, expectedChainID)) +} + func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal { prop := providertypes.NewConsumerAdditionProposal( "chainID", @@ -235,13 +265,13 @@ func GetTestConsumerAdditionProp() *providertypes.ConsumerAdditionProposal { []byte("gen_hash"), []byte("bin_hash"), time.Now(), - consumertypes.DefaultConsumerRedistributeFrac, - consumertypes.DefaultBlocksPerDistributionTransmission, + types.DefaultConsumerRedistributeFrac, + types.DefaultBlocksPerDistributionTransmission, "", - consumertypes.DefaultHistoricalEntries, + types.DefaultHistoricalEntries, types.DefaultCCVTimeoutPeriod, - consumertypes.DefaultTransferTimeoutPeriod, - consumertypes.DefaultConsumerUnbondingPeriod, + types.DefaultTransferTimeoutPeriod, + types.DefaultConsumerUnbondingPeriod, ).(*providertypes.ConsumerAdditionProposal) return prop diff --git a/testutil/simibc/chain_util.go b/testutil/simibc/chain_util.go index 98622695d3..1c00c928c5 100644 --- a/testutil/simibc/chain_util.go +++ b/testutil/simibc/chain_util.go @@ -5,12 +5,12 @@ import ( channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + + sdk "github.com/cosmos/cosmos-sdk/types" abci "github.com/cometbft/cometbft/abci/types" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" - - ibctestingcore "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" ) // BeginBlock updates the current header and calls the app.BeginBlock method. @@ -56,14 +56,37 @@ func EndBlock(c *ibctesting.TestChain, preCommitCallback func()) (*ibctmtypes.He c.LastHeader = c.CurrentTMClientHeader() - packets := []channeltypes.Packet{} + sdkEvts := ABCIToSDKEvents(ebRes.Events) + packets := ParsePacketsFromEvents(sdkEvts) + + return c.LastHeader, packets +} - for _, e := range ebRes.Events { - if e.Type == channeltypes.EventTypeSendPacket { - packet, _ := ibctestingcore.ReconstructPacketFromEvent(e) +// ParsePacketsFromEvents returns all packets found in events. +func ParsePacketsFromEvents(events []sdk.Event) (packets []channeltypes.Packet) { + for i, ev := range events { + if ev.Type == channeltypes.EventTypeSendPacket { + packet, err := ibctesting.ParsePacketFromEvents(events[i:]) + if err != nil { + panic(err) + } packets = append(packets, packet) } } + return +} - return c.LastHeader, packets +// ABCIToSDKEvents converts a list of ABCI events to Cosmos SDK events. +func ABCIToSDKEvents(abciEvents []abci.Event) sdk.Events { + var events sdk.Events + for _, evt := range abciEvents { + var attributes []sdk.Attribute + for _, attr := range evt.GetAttributes() { + attributes = append(attributes, sdk.NewAttribute(attr.Key, attr.Value)) + } + + events = events.AppendEvent(sdk.NewEvent(evt.GetType(), attributes...)) + } + + return events } diff --git a/testutil/simibc/relay_util.go b/testutil/simibc/relay_util.go index 97bcabf57c..9fd5213d5b 100644 --- a/testutil/simibc/relay_util.go +++ b/testutil/simibc/relay_util.go @@ -5,6 +5,8 @@ import ( channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v7/modules/core/24-host" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + ibctesting "github.com/cosmos/ibc-go/v7/testing" + simapp "github.com/cosmos/ibc-go/v7/testing/simapp" "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" @@ -12,9 +14,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" tmtypes "github.com/cometbft/cometbft/types" - - simapp "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp" - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" ) // UpdateReceiverClient DELIVERs a header to the receiving endpoint diff --git a/testutil/simibc/relayed_path.go b/testutil/simibc/relayed_path.go index 7ef97c4bee..daf32f0c84 100644 --- a/testutil/simibc/relayed_path.go +++ b/testutil/simibc/relayed_path.go @@ -5,8 +5,7 @@ import ( "time" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - - ibctesting "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/testing" + ibctesting "github.com/cosmos/ibc-go/v7/testing" ) // RelayedPath is a wrapper around ibctesting.Path gives fine-grained diff --git a/x/ccv/consumer/client/cli/query.go b/x/ccv/consumer/client/cli/query.go index dc1ecfc2f4..f1a0c0f258 100644 --- a/x/ccv/consumer/client/cli/query.go +++ b/x/ccv/consumer/client/cli/query.go @@ -22,6 +22,7 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand( CmdNextFeeDistribution(), CmdProviderInfo(), + CmdThrottleState(), ) return cmd @@ -80,3 +81,30 @@ func CmdProviderInfo() *cobra.Command { return cmd } + +func CmdThrottleState() *cobra.Command { + cmd := &cobra.Command{ + Use: "throttle-state", + Short: "Query throttle state", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryThrottleStateRequest{} + res, err := queryClient.QueryThrottleState(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/ccv/consumer/ibc_module.go b/x/ccv/consumer/ibc_module.go index 74c4cff27c..99f0141e64 100644 --- a/x/ccv/consumer/ibc_module.go +++ b/x/ccv/consumer/ibc_module.go @@ -18,7 +18,6 @@ import ( "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" - providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -127,7 +126,7 @@ func (am AppModule) OnChanOpenAck( "provider channel: %s already established", providerChannel) } - var md providertypes.HandshakeMetadata + var md types.HandshakeMetadata if err := (&md).Unmarshal([]byte(counterpartyMetadata)); err != nil { return errorsmod.Wrapf(types.ErrInvalidHandshakeMetadata, "error unmarshalling ibc-ack metadata: \n%v; \nmetadata: %v", err, counterpartyMetadata) @@ -177,7 +176,7 @@ func (am AppModule) OnChanOpenAck( ctx.EventManager().EmitEvent( sdk.NewEvent( - types.EventTypeFeeTransferChannelOpened, + consumertypes.EventTypeFeeTransferChannelOpened, sdk.NewAttribute(sdk.AttributeKeyModule, consumertypes.ModuleName), sdk.NewAttribute(channeltypes.AttributeKeyChannelID, channelID), sdk.NewAttribute(channeltypes.AttributeKeyPortID, transfertypes.PortID), diff --git a/x/ccv/consumer/ibc_module_test.go b/x/ccv/consumer/ibc_module_test.go index a451625230..25cbac58a2 100644 --- a/x/ccv/consumer/ibc_module_test.go +++ b/x/ccv/consumer/ibc_module_test.go @@ -16,7 +16,6 @@ import ( testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" "github.com/cosmos/interchain-security/v3/x/ccv/consumer" consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" - providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -262,7 +261,7 @@ func TestOnChanOpenAck(t *testing.T) { { "invalid: mismatched serialized version", func(keeper *consumerkeeper.Keeper, params *params, mocks testkeeper.MockedKeepers) { - md := providertypes.HandshakeMetadata{ + md := ccv.HandshakeMetadata{ ProviderFeePoolAddr: "", // dummy address used Version: "bunkVersion", } @@ -288,7 +287,7 @@ func TestOnChanOpenAck(t *testing.T) { counterpartyChannelID: "providerCCVChannelID", } - metadata := providertypes.HandshakeMetadata{ + metadata := ccv.HandshakeMetadata{ ProviderFeePoolAddr: "someAcct", Version: ccv.Version, } diff --git a/x/ccv/consumer/keeper/distribution.go b/x/ccv/consumer/keeper/distribution.go index 48f1c5a1eb..c0a98d0a21 100644 --- a/x/ccv/consumer/keeper/distribution.go +++ b/x/ccv/consumer/keeper/distribution.go @@ -103,62 +103,74 @@ func (k Keeper) shouldSendRewardsToProvider(ctx sdk.Context) bool { // all the block rewards allocated for the provider func (k Keeper) SendRewardsToProvider(ctx sdk.Context) error { // empty out the toSendToProviderTokens address - ch := k.GetDistributionTransmissionChannel(ctx) - transferChannel, found := k.channelKeeper.GetChannel(ctx, transfertypes.PortID, ch) - if found && transferChannel.State == channeltypes.OPEN { - tstProviderAddr := k.authKeeper.GetModuleAccount(ctx, - types.ConsumerToSendToProviderName).GetAddress() - providerAddr := k.GetProviderFeePoolAddrStr(ctx) - timeoutHeight := clienttypes.ZeroHeight() - transferTimeoutPeriod := k.GetTransferTimeoutPeriod(ctx) - timeoutTimestamp := uint64(ctx.BlockTime().Add(transferTimeoutPeriod).UnixNano()) - - sentCoins := sdk.NewCoins() - var allBalances sdk.Coins - // iterate over all whitelisted reward denoms - for _, denom := range k.AllowedRewardDenoms(ctx) { - // get the balance of the denom in the toSendToProviderTokens address - balance := k.bankKeeper.GetBalance(ctx, tstProviderAddr, denom) - allBalances = allBalances.Add(balance) - - // if the balance is not zero, - if !balance.IsZero() { - packetTransfer := &transfertypes.MsgTransfer{ - SourcePort: transfertypes.PortID, - SourceChannel: ch, - Token: balance, - Sender: tstProviderAddr.String(), // consumer address to send from - Receiver: providerAddr, // provider fee pool address to send to - TimeoutHeight: timeoutHeight, // timeout height disabled - TimeoutTimestamp: timeoutTimestamp, - Memo: "consumer chain rewards distribution", - } - _, err := k.ibcTransferKeeper.Transfer(ctx, packetTransfer) - if err != nil { - return err - } - sentCoins = sentCoins.Add(balance) + sourceChannelID := k.GetDistributionTransmissionChannel(ctx) + transferChannel, found := k.channelKeeper.GetChannel(ctx, transfertypes.PortID, sourceChannelID) + if !found || transferChannel.State != channeltypes.OPEN { + k.Logger(ctx).Info("WARNING: cannot send rewards to provider;", + "transmission channel not in OPEN state", "channelID", sourceChannelID) + return nil + } + + // get params for sending rewards + toSendToProviderAddr := k.authKeeper.GetModuleAccount(ctx, + types.ConsumerToSendToProviderName).GetAddress() // sender address + providerAddr := k.GetProviderFeePoolAddrStr(ctx) // recipient address + timeoutHeight := clienttypes.ZeroHeight() + timeoutTimestamp := uint64(ctx.BlockTime().Add(k.GetTransferTimeoutPeriod(ctx)).UnixNano()) + + sentCoins := sdk.NewCoins() + var allBalances sdk.Coins + // iterate over all whitelisted reward denoms + for _, denom := range k.AllowedRewardDenoms(ctx) { + // get the balance of the denom in the toSendToProviderTokens address + balance := k.bankKeeper.GetBalance(ctx, toSendToProviderAddr, denom) + allBalances = allBalances.Add(balance) + + // if the balance is not zero, + if !balance.IsZero() { + packetTransfer := &transfertypes.MsgTransfer{ + SourcePort: transfertypes.PortID, + SourceChannel: sourceChannelID, + Token: balance, + Sender: toSendToProviderAddr.String(), // consumer address to send from + Receiver: providerAddr, // provider fee pool address to send to + TimeoutHeight: timeoutHeight, // timeout height disabled + TimeoutTimestamp: timeoutTimestamp, + Memo: "consumer chain rewards distribution", } - } - k.Logger(ctx).Info("sent block rewards to provider", - "total fee pool", allBalances.String(), - "sent", sentCoins.String(), - ) - currentHeight := ctx.BlockHeight() - ctx.EventManager().EmitEvent( - sdk.NewEvent( - ccv.EventTypeFeeDistribution, - sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), - sdk.NewAttribute(ccv.AttributeDistributionCurrentHeight, strconv.Itoa(int(currentHeight))), - sdk.NewAttribute(ccv.AttributeDistributionNextHeight, strconv.Itoa(int(currentHeight+k.GetBlocksPerDistributionTransmission(ctx)))), - sdk.NewAttribute(ccv.AttributeDistributionFraction, (k.GetConsumerRedistributionFrac(ctx))), - sdk.NewAttribute(ccv.AttributeDistributionTotal, allBalances.String()), - sdk.NewAttribute(ccv.AttributeDistributionToProvider, sentCoins.String()), - ), - ) + // validate MsgTransfer before calling Transfer() + err := packetTransfer.ValidateBasic() + if err != nil { + return err + } + + _, err = k.ibcTransferKeeper.Transfer(ctx, packetTransfer) + if err != nil { + return err + } + + sentCoins = sentCoins.Add(balance) + } } + k.Logger(ctx).Info("sent block rewards to provider", + "total fee pool", allBalances.String(), + "sent", sentCoins.String(), + ) + currentHeight := ctx.BlockHeight() + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeFeeDistribution, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeDistributionCurrentHeight, strconv.Itoa(int(currentHeight))), + sdk.NewAttribute(types.AttributeDistributionNextHeight, strconv.Itoa(int(currentHeight+k.GetBlocksPerDistributionTransmission(ctx)))), + sdk.NewAttribute(types.AttributeDistributionFraction, (k.GetConsumerRedistributionFrac(ctx))), + sdk.NewAttribute(types.AttributeDistributionTotal, allBalances.String()), + sdk.NewAttribute(types.AttributeDistributionToProvider, sentCoins.String()), + ), + ) + return nil } diff --git a/x/ccv/consumer/keeper/distribution_test.go b/x/ccv/consumer/keeper/distribution_test.go index 71df5fd93d..4a611f2d1e 100644 --- a/x/ccv/consumer/keeper/distribution_test.go +++ b/x/ccv/consumer/keeper/distribution_test.go @@ -12,6 +12,7 @@ import ( testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) // TestGetEstimatedNextFeeDistribution tests next fee distribution parameters. @@ -25,7 +26,7 @@ func TestGetEstimatedNextFeeDistribution(t *testing.T) { mockAccountKeeper := mocks.MockAccountKeeper mockBankKeeper := mocks.MockBankKeeper consumerKeeper := testkeeper.NewInMemConsumerKeeper(keeperParams, mocks) - consumerKeeper.SetParams(ctx, types.DefaultParams()) + consumerKeeper.SetParams(ctx, ccvtypes.DefaultParams()) // Setup mock account balance fracParam := consumerKeeper.GetConsumerRedistributionFrac(ctx) @@ -76,7 +77,7 @@ func TestAllowedRewardDenoms(t *testing.T) { defer ctrl.Finish() mocks := testkeeper.NewMockedKeepers(ctrl) consumerKeeper := testkeeper.NewInMemConsumerKeeper(keeperParams, mocks) - params := types.DefaultParams() + params := ccvtypes.DefaultParams() params.RewardDenoms = []string{"ustake"} params.ProviderRewardDenoms = []string{"uatom"} consumerKeeper.SetParams(ctx, params) diff --git a/x/ccv/consumer/keeper/genesis.go b/x/ccv/consumer/keeper/genesis.go index a55184fd27..0edcb57d7f 100644 --- a/x/ccv/consumer/keeper/genesis.go +++ b/x/ccv/consumer/keeper/genesis.go @@ -7,7 +7,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -17,7 +17,7 @@ import ( // 1. A client to the provider was never created, i.e. a new consumer chain is started for the first time. // 2. A consumer chain restarts after a client to the provider was created, but the CCV channel handshake is still in progress // 3. A consumer chain restarts after the CCV channel handshake was completed. -func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) []abci.ValidatorUpdate { +func (k Keeper) InitGenesis(ctx sdk.Context, state *types.GenesisState) []abci.ValidatorUpdate { // PreCCV is true during the process of a standalone to consumer changeover. // At the PreCCV point in the process, the standalone chain has just been upgraded to include // the consumer ccv module, but the standalone staking keeper is still managing the validator set. @@ -27,7 +27,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) if state.PreCCV { k.SetPreCCVTrue(ctx) k.MarkAsPrevStandaloneChain(ctx) - k.SetInitialValSet(ctx, state.InitialValSet) + k.SetInitialValSet(ctx, state.Provider.InitialValSet) } k.SetInitGenesisHeight(ctx, ctx.BlockHeight()) // Usually 0, but not the case for changeover chains @@ -56,7 +56,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) // start a new chain if state.NewChain { // create the provider client in InitGenesis for new consumer chain. CCV Handshake must be established with this client id. - clientID, err := k.clientKeeper.CreateClient(ctx, state.ProviderClientState, state.ProviderConsensusState) + clientID, err := k.clientKeeper.CreateClient(ctx, state.Provider.ClientState, state.Provider.ConsensusState) if err != nil { // If the client creation fails, the chain MUST NOT start panic(err) @@ -111,15 +111,15 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state *consumertypes.GenesisState) } // populate cross chain validators states with initial valset - k.ApplyCCValidatorChanges(ctx, state.InitialValSet) - return state.InitialValSet + k.ApplyCCValidatorChanges(ctx, state.Provider.InitialValSet) + return state.Provider.InitialValSet } // ExportGenesis returns the CCV consumer module's exported genesis -func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisState) { +func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *types.GenesisState) { params := k.GetConsumerParams(ctx) if !params.Enabled { - return consumertypes.DefaultGenesisState() + return types.DefaultGenesisState() } // export the current validator set @@ -127,7 +127,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt // export pending packets using the depreciated ConsumerPacketDataList type pendingPackets := k.GetPendingPackets(ctx) - pendingPacketsDepreciated := ccv.ConsumerPacketDataList{} + pendingPacketsDepreciated := types.ConsumerPacketDataList{} pendingPacketsDepreciated.List = append(pendingPacketsDepreciated.List, pendingPackets...) // export all the states created after a provider channel got established @@ -138,7 +138,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt panic("provider client does not exist although provider channel does exist") } - genesis = consumertypes.NewRestartGenesisState( + genesis = types.NewRestartGenesisState( clientID, channelID, k.GetAllPacketMaturityTimes(ctx), @@ -154,11 +154,11 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt // if provider clientID and channelID don't exist on the consumer chain, // then CCV protocol is disabled for this chain return a default genesis state if !ok { - return consumertypes.DefaultGenesisState() + return types.DefaultGenesisState() } // export client states and pending slashing requests into a new chain genesis - genesis = consumertypes.NewRestartGenesisState( + genesis = types.NewRestartGenesisState( clientID, "", nil, @@ -166,7 +166,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) (genesis *consumertypes.GenesisSt k.GetAllHeightToValsetUpdateIDs(ctx), pendingPacketsDepreciated, nil, - consumertypes.LastTransmissionBlockHeight{}, + types.LastTransmissionBlockHeight{}, params, ) } diff --git a/x/ccv/consumer/keeper/genesis_test.go b/x/ccv/consumer/keeper/genesis_test.go index 649505da0c..93e856d6ef 100644 --- a/x/ccv/consumer/keeper/genesis_test.go +++ b/x/ccv/consumer/keeper/genesis_test.go @@ -67,7 +67,7 @@ func TestInitGenesis(t *testing.T) { MaturityTime: time.Now().UTC(), }, } - pendingDataPackets := ccv.ConsumerPacketDataList{ + pendingDataPackets := consumertypes.ConsumerPacketDataList{ List: []ccv.ConsumerPacketData{ { Type: ccv.SlashPacket, @@ -92,7 +92,7 @@ func TestInitGenesis(t *testing.T) { ) // create default parameters for a new chain - params := consumertypes.DefaultParams() + params := ccv.DefaultParams() params.Enabled = true // define three test cases which respectively create a genesis struct, use it to call InitGenesis @@ -255,7 +255,7 @@ func TestExportGenesis(t *testing.T) { valset := []abci.ValidatorUpdate{tmtypes.TM2PB.ValidatorUpdate(validator)} // create pending consumer packets - consPackets := ccv.ConsumerPacketDataList{ + consPackets := consumertypes.ConsumerPacketDataList{ List: []ccv.ConsumerPacketData{ { Type: ccv.SlashPacket, @@ -280,7 +280,7 @@ func TestExportGenesis(t *testing.T) { ) ltbh := consumertypes.LastTransmissionBlockHeight{Height: int64(1000)} // create default parameters for a new chain - params := consumertypes.DefaultParams() + params := ccv.DefaultParams() params.Enabled = true // define two test cases which respectively populate the consumer chain store diff --git a/x/ccv/consumer/keeper/grpc_query.go b/x/ccv/consumer/keeper/grpc_query.go index 80e6b695a9..0d1bb78d16 100644 --- a/x/ccv/consumer/keeper/grpc_query.go +++ b/x/ccv/consumer/keeper/grpc_query.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) var _ types.QueryServer = Keeper{} //nolint:golint @@ -51,3 +52,25 @@ func (k Keeper) QueryProviderInfo(c context.Context, //nolint:golint return k.GetProviderInfo(ctx) } + +func (k Keeper) QueryThrottleState(c context.Context, + req *types.QueryThrottleStateRequest, +) (*types.QueryThrottleStateResponse, error) { + ctx := sdk.UnwrapSDKContext(c) + + resp := types.QueryThrottleStateResponse{} + + slashRecord, found := k.GetSlashRecord(ctx) + if found { + resp.SlashRecord = &slashRecord + } else { + resp.SlashRecord = nil + } + + resp.PacketDataQueue = make([]ccvtypes.ConsumerPacketData, 0) + pendingPackets := k.GetAllPendingPacketsWithIdx(ctx) + for _, packet := range pendingPackets { + resp.PacketDataQueue = append(resp.PacketDataQueue, packet.ConsumerPacketData) + } + return &resp, nil +} diff --git a/x/ccv/consumer/keeper/keeper.go b/x/ccv/consumer/keeper/keeper.go index 94d5c790fd..0d0ac988ad 100644 --- a/x/ccv/consumer/keeper/keeper.go +++ b/x/ccv/consumer/keeper/keeper.go @@ -64,7 +64,7 @@ func NewKeeper( ) Keeper { // set KeyTable if it has not already been set if !paramSpace.HasKeyTable() { - paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + paramSpace = paramSpace.WithKeyTable(ccv.ParamKeyTable()) } k := Keeper{ @@ -310,7 +310,7 @@ func (k Keeper) DeletePreCCV(ctx sdk.Context) { func (k Keeper) SetInitialValSet(ctx sdk.Context, initialValSet []tmtypes.ValidatorUpdate) { store := ctx.KVStore(k.storeKey) initialValSetState := types.GenesisState{ - InitialValSet: initialValSet, + Provider: ccv.ProviderInfo{InitialValSet: initialValSet}, } bz := k.cdc.MustMarshal(&initialValSetState) store.Set(types.InitialValSetKey(), bz) @@ -322,7 +322,7 @@ func (k Keeper) GetInitialValSet(ctx sdk.Context) []tmtypes.ValidatorUpdate { bz := store.Get(types.InitialValSetKey()) if bz != nil { k.cdc.MustUnmarshal(bz, &initialValSet) - return initialValSet.InitialValSet + return initialValSet.Provider.InitialValSet } return []tmtypes.ValidatorUpdate{} } diff --git a/x/ccv/consumer/keeper/migration.go b/x/ccv/consumer/keeper/migration.go index 361bb2a62f..e63960fdb1 100644 --- a/x/ccv/consumer/keeper/migration.go +++ b/x/ccv/consumer/keeper/migration.go @@ -7,7 +7,6 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" - ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) // Migrator is a struct for handling in-place store migrations. @@ -21,23 +20,27 @@ func NewMigrator(ccvConsumerKeeper Keeper, ccvConsumerParamSpace paramtypes.Subs return Migrator{ccvConsumerKeeper: ccvConsumerKeeper, ccvConsumerParamSpace: ccvConsumerParamSpace} } +// Migrate1to2 migrates x/ccvconsumer state from consensus version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + return m.ccvConsumerKeeper.MigrateConsumerPacketData(ctx) +} + // MigrateConsumerPacketData migrates consumer packet data according to // https://github.com/cosmos/interchain-security/pull/1037 // // Note an equivalent migration is not required for providers. -func (k Keeper) MigrateConsumerPacketData(ctx sdk.Context) { +func (k Keeper) MigrateConsumerPacketData(ctx sdk.Context) error { // deserialize packet data from old format - var depreciatedType ccvtypes.ConsumerPacketDataList + var depreciatedType consumertypes.ConsumerPacketDataList store := ctx.KVStore(k.storeKey) bz := store.Get([]byte{consumertypes.PendingDataPacketsBytePrefix}) if bz == nil { ctx.Logger().Info("no pending data packets to migrate") - return + return nil } err := depreciatedType.Unmarshal(bz) if err != nil { - // An error here would indicate something is very wrong - panic(fmt.Errorf("failed to unmarshal pending data packets: %w", err)) + return fmt.Errorf("failed to unmarshal pending data packets: %w", err) } // Delete old data @@ -48,6 +51,7 @@ func (k Keeper) MigrateConsumerPacketData(ctx sdk.Context) { for _, data := range depreciatedType.List { k.AppendPendingPacket(ctx, data.Type, data.Data) } + return nil } // TODO: the following hackyness could be removed if we're able to reference older versions of ICS. @@ -59,7 +63,7 @@ func PendingDataPacketsKeyOnlyForTesting() []byte { // Note: a better test of the old functionality would be to directly reference the old ICS version, // including the version of ccv.ConsumerPacketDataList has a list of ccv.ConsumerPacketData without indexes. -func (k Keeper) SetPendingPacketsOnlyForTesting(ctx sdk.Context, packets ccvtypes.ConsumerPacketDataList) { +func (k Keeper) SetPendingPacketsOnlyForTesting(ctx sdk.Context, packets consumertypes.ConsumerPacketDataList) { store := ctx.KVStore(k.storeKey) bz, err := packets.Marshal() if err != nil { diff --git a/x/ccv/consumer/keeper/migration_test.go b/x/ccv/consumer/keeper/migration_test.go index 7cb87665f0..359e394f31 100644 --- a/x/ccv/consumer/keeper/migration_test.go +++ b/x/ccv/consumer/keeper/migration_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" testutil "github.com/cosmos/interchain-security/v3/testutil/keeper" + "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -14,7 +15,7 @@ func TestMigrateConsumerPacketData(t *testing.T) { defer ctrl.Finish() // Set some pending data packets in the old format - packets := ccvtypes.ConsumerPacketDataList{ + packets := types.ConsumerPacketDataList{ List: []ccvtypes.ConsumerPacketData{ { Type: ccvtypes.SlashPacket, diff --git a/x/ccv/consumer/keeper/params.go b/x/ccv/consumer/keeper/params.go index ccffd96ee5..3c0e01f1c3 100644 --- a/x/ccv/consumer/keeper/params.go +++ b/x/ccv/consumer/keeper/params.go @@ -6,14 +6,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) // GetParams returns the params for the consumer ccv module // NOTE: it is different from the GetParams method which is required to implement StakingKeeper interface -func (k Keeper) GetConsumerParams(ctx sdk.Context) types.Params { - return types.NewParams( +func (k Keeper) GetConsumerParams(ctx sdk.Context) ccvtypes.ConsumerParams { + return ccvtypes.NewParams( k.GetEnabled(ctx), k.GetBlocksPerDistributionTransmission(ctx), k.GetDistributionTransmissionChannel(ctx), @@ -26,11 +25,12 @@ func (k Keeper) GetConsumerParams(ctx sdk.Context) types.Params { k.GetSoftOptOutThreshold(ctx), k.GetRewardDenoms(ctx), k.GetProviderRewardDenoms(ctx), + k.GetRetryDelayPeriod(ctx), ) } // SetParams sets the paramset for the consumer module -func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { +func (k Keeper) SetParams(ctx sdk.Context, params ccvtypes.ConsumerParams) { k.paramStore.SetParamSet(ctx, ¶ms) } @@ -45,38 +45,38 @@ func (k Keeper) GetParams(ctx sdk.Context) stakingtypes.Params { // GetEnabled returns the enabled flag for the consumer module func (k Keeper) GetEnabled(ctx sdk.Context) bool { var enabled bool - k.paramStore.Get(ctx, types.KeyEnabled, &enabled) + k.paramStore.Get(ctx, ccvtypes.KeyEnabled, &enabled) return enabled } func (k Keeper) GetBlocksPerDistributionTransmission(ctx sdk.Context) int64 { var bpdt int64 - k.paramStore.Get(ctx, types.KeyBlocksPerDistributionTransmission, &bpdt) + k.paramStore.Get(ctx, ccvtypes.KeyBlocksPerDistributionTransmission, &bpdt) return bpdt } func (k Keeper) SetBlocksPerDistributionTransmission(ctx sdk.Context, bpdt int64) { - k.paramStore.Set(ctx, types.KeyBlocksPerDistributionTransmission, bpdt) + k.paramStore.Set(ctx, ccvtypes.KeyBlocksPerDistributionTransmission, bpdt) } func (k Keeper) GetDistributionTransmissionChannel(ctx sdk.Context) string { var s string - k.paramStore.Get(ctx, types.KeyDistributionTransmissionChannel, &s) + k.paramStore.Get(ctx, ccvtypes.KeyDistributionTransmissionChannel, &s) return s } func (k Keeper) SetDistributionTransmissionChannel(ctx sdk.Context, channel string) { - k.paramStore.Set(ctx, types.KeyDistributionTransmissionChannel, channel) + k.paramStore.Set(ctx, ccvtypes.KeyDistributionTransmissionChannel, channel) } func (k Keeper) GetProviderFeePoolAddrStr(ctx sdk.Context) string { var s string - k.paramStore.Get(ctx, types.KeyProviderFeePoolAddrStr, &s) + k.paramStore.Get(ctx, ccvtypes.KeyProviderFeePoolAddrStr, &s) return s } func (k Keeper) SetProviderFeePoolAddrStr(ctx sdk.Context, addr string) { - k.paramStore.Set(ctx, types.KeyProviderFeePoolAddrStr, addr) + k.paramStore.Set(ctx, ccvtypes.KeyProviderFeePoolAddrStr, addr) } // GetCCVTimeoutPeriod returns the timeout period for sent ccv related ibc packets @@ -89,7 +89,7 @@ func (k Keeper) GetCCVTimeoutPeriod(ctx sdk.Context) time.Duration { // GetTransferTimeoutPeriod returns the timeout period for sent transfer related ibc packets func (k Keeper) GetTransferTimeoutPeriod(ctx sdk.Context) time.Duration { var p time.Duration - k.paramStore.Get(ctx, types.KeyTransferTimeoutPeriod, &p) + k.paramStore.Get(ctx, ccvtypes.KeyTransferTimeoutPeriod, &p) return p } @@ -98,25 +98,25 @@ func (k Keeper) GetTransferTimeoutPeriod(ctx sdk.Context) time.Duration { // decimal number. For example "0.75" would represent 75%. func (k Keeper) GetConsumerRedistributionFrac(ctx sdk.Context) string { var str string - k.paramStore.Get(ctx, types.KeyConsumerRedistributionFrac, &str) + k.paramStore.Get(ctx, ccvtypes.KeyConsumerRedistributionFrac, &str) return str } // GetHistoricalEntries returns the number of historical info entries to persist in store func (k Keeper) GetHistoricalEntries(ctx sdk.Context) int64 { var n int64 - k.paramStore.Get(ctx, types.KeyHistoricalEntries, &n) + k.paramStore.Get(ctx, ccvtypes.KeyHistoricalEntries, &n) return n } // Only used to set an unbonding period in diff tests func (k Keeper) SetUnbondingPeriod(ctx sdk.Context, period time.Duration) { - k.paramStore.Set(ctx, types.KeyConsumerUnbondingPeriod, period) + k.paramStore.Set(ctx, ccvtypes.KeyConsumerUnbondingPeriod, period) } func (k Keeper) GetUnbondingPeriod(ctx sdk.Context) time.Duration { var period time.Duration - k.paramStore.Get(ctx, types.KeyConsumerUnbondingPeriod, &period) + k.paramStore.Get(ctx, ccvtypes.KeyConsumerUnbondingPeriod, &period) return period } @@ -124,18 +124,24 @@ func (k Keeper) GetUnbondingPeriod(ctx sdk.Context) time.Duration { // that can opt out of running the consumer chain func (k Keeper) GetSoftOptOutThreshold(ctx sdk.Context) string { var str string - k.paramStore.Get(ctx, types.KeySoftOptOutThreshold, &str) + k.paramStore.Get(ctx, ccvtypes.KeySoftOptOutThreshold, &str) return str } func (k Keeper) GetRewardDenoms(ctx sdk.Context) []string { var denoms []string - k.paramStore.Get(ctx, types.KeyRewardDenoms, &denoms) + k.paramStore.Get(ctx, ccvtypes.KeyRewardDenoms, &denoms) return denoms } func (k Keeper) GetProviderRewardDenoms(ctx sdk.Context) []string { var denoms []string - k.paramStore.Get(ctx, types.KeyProviderRewardDenoms, &denoms) + k.paramStore.Get(ctx, ccvtypes.KeyProviderRewardDenoms, &denoms) return denoms } + +func (k Keeper) GetRetryDelayPeriod(ctx sdk.Context) time.Duration { + var period time.Duration + k.paramStore.Get(ctx, ccvtypes.KeyRetryDelayPeriod, &period) + return period +} diff --git a/x/ccv/consumer/keeper/params_test.go b/x/ccv/consumer/keeper/params_test.go index ac6b112aa8..e575e26185 100644 --- a/x/ccv/consumer/keeper/params_test.go +++ b/x/ccv/consumer/keeper/params_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" - "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -15,31 +14,32 @@ import ( func TestParams(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() - consumerKeeper.SetParams(ctx, types.DefaultParams()) + consumerKeeper.SetParams(ctx, ccv.DefaultParams()) var rewardDenoms []string var provideRewardDenoms []string - expParams := types.NewParams( + expParams := ccv.NewParams( false, 1000, "", "", ccv.DefaultCCVTimeoutPeriod, - types.DefaultTransferTimeoutPeriod, - types.DefaultConsumerRedistributeFrac, - types.DefaultHistoricalEntries, - types.DefaultConsumerUnbondingPeriod, - types.DefaultSoftOptOutThreshold, + ccv.DefaultTransferTimeoutPeriod, + ccv.DefaultConsumerRedistributeFrac, + ccv.DefaultHistoricalEntries, + ccv.DefaultConsumerUnbondingPeriod, + ccv.DefaultSoftOptOutThreshold, rewardDenoms, provideRewardDenoms, + ccv.DefaultRetryDelayPeriod, ) // these are the default params, IBC suite independently sets enabled=true params := consumerKeeper.GetConsumerParams(ctx) require.Equal(t, expParams, params) - newParams := types.NewParams(false, 1000, + newParams := ccv.NewParams(false, 1000, "channel-2", "cosmos19pe9pg5dv9k5fzgzmsrgnw9rl9asf7ddwhu7lm", - 7*24*time.Hour, 25*time.Hour, "0.5", 500, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}) + 7*24*time.Hour, 25*time.Hour, "0.5", 500, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour) consumerKeeper.SetParams(ctx, newParams) params = consumerKeeper.GetConsumerParams(ctx) require.Equal(t, newParams, params) diff --git a/x/ccv/consumer/keeper/relay.go b/x/ccv/consumer/keeper/relay.go index 060aadff20..3afeb33188 100644 --- a/x/ccv/consumer/keeper/relay.go +++ b/x/ccv/consumer/keeper/relay.go @@ -115,12 +115,12 @@ func (k Keeper) QueueVSCMaturedPackets(ctx sdk.Context) { ctx.EventManager().EmitEvent( sdk.NewEvent( - ccv.EventTypeVSCMatured, + types.EventTypeVSCMatured, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(ccv.AttributeChainID, ctx.ChainID()), - sdk.NewAttribute(ccv.AttributeConsumerHeight, strconv.Itoa(int(ctx.BlockHeight()))), + sdk.NewAttribute(types.AttributeConsumerHeight, strconv.Itoa(int(ctx.BlockHeight()))), sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(maturityTime.VscId))), - sdk.NewAttribute(ccv.AttributeTimestamp, ctx.BlockTime().String()), + sdk.NewAttribute(types.AttributeTimestamp, ctx.BlockTime().String()), ), ) } @@ -162,7 +162,7 @@ func (k Keeper) QueueSlashPacket(ctx sdk.Context, validator abci.Validator, vals ctx.EventManager().EmitEvent( sdk.NewEvent( - ccv.EventTypeConsumerSlashRequest, + types.EventTypeConsumerSlashRequest, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(ccv.AttributeValidatorAddress, sdk.ConsAddress(validator.Address).String()), sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(valsetUpdateID))), diff --git a/x/ccv/consumer/keeper/relay_test.go b/x/ccv/consumer/keeper/relay_test.go index 09cf987fc0..d681a2fdc4 100644 --- a/x/ccv/consumer/keeper/relay_test.go +++ b/x/ccv/consumer/keeper/relay_test.go @@ -123,7 +123,7 @@ func TestOnRecvVSCPacket(t *testing.T) { consumerKeeper.SetProviderChannel(ctx, consumerCCVChannelID) // Set module params with custom unbonding period - moduleParams := consumertypes.DefaultParams() + moduleParams := types.DefaultParams() moduleParams.UnbondingPeriod = 100 * time.Hour consumerKeeper.SetParams(ctx, moduleParams) @@ -172,7 +172,7 @@ func TestOnRecvVSCPacketDuplicateUpdates(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() consumerKeeper.SetProviderChannel(ctx, consumerCCVChannelID) - consumerKeeper.SetParams(ctx, consumertypes.DefaultParams()) + consumerKeeper.SetParams(ctx, types.DefaultParams()) // Construct packet/data with duplicate val updates for the same pub key cId := crypto.NewCryptoIdentityFromIntSeed(43278947) @@ -218,7 +218,7 @@ func TestSendPacketsFailure(t *testing.T) { consumerKeeper, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() consumerKeeper.SetProviderChannel(ctx, "consumerCCVChannelID") - consumerKeeper.SetParams(ctx, consumertypes.DefaultParams()) + consumerKeeper.SetParams(ctx, types.DefaultParams()) // Set some pending packets consumerKeeper.AppendPendingPacket(ctx, types.VscMaturedPacket, &types.ConsumerPacketData_VscMaturedPacketData{}) @@ -240,7 +240,7 @@ func TestSendPackets(t *testing.T) { // Keeper setup consumerKeeper, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) consumerKeeper.SetProviderChannel(ctx, "consumerCCVChannelID") - consumerKeeper.SetParams(ctx, consumertypes.DefaultParams()) + consumerKeeper.SetParams(ctx, types.DefaultParams()) // No slash record should exist _, found := consumerKeeper.GetSlashRecord(ctx) @@ -471,7 +471,7 @@ func TestSendPacketsDeletion(t *testing.T) { consumerKeeper, ctx, ctrl, mocks := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() consumerKeeper.SetProviderChannel(ctx, "consumerCCVChannelID") - consumerKeeper.SetParams(ctx, consumertypes.DefaultParams()) + consumerKeeper.SetParams(ctx, types.DefaultParams()) // Queue two pending packets, vsc matured first consumerKeeper.AppendPendingPacket(ctx, types.VscMaturedPacket, &types.ConsumerPacketData_VscMaturedPacketData{ diff --git a/x/ccv/consumer/keeper/soft_opt_out_test.go b/x/ccv/consumer/keeper/soft_opt_out_test.go index c99d418ca6..6f2ee8ad4f 100644 --- a/x/ccv/consumer/keeper/soft_opt_out_test.go +++ b/x/ccv/consumer/keeper/soft_opt_out_test.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/interchain-security/v3/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" - "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) // Tests that UpdateSmallestNonOptOutPower updates the smallest validator power that cannot soft opt out. @@ -102,7 +102,7 @@ func TestUpdateSmallestNonOptOutPower(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testkeeper.GetConsumerKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - moduleParams := types.DefaultParams() + moduleParams := ccvtypes.DefaultParams() moduleParams.SoftOptOutThreshold = tc.optOutThresh consumerKeeper.SetParams(ctx, moduleParams) defer ctrl.Finish() diff --git a/x/ccv/consumer/keeper/throttle_retry.go b/x/ccv/consumer/keeper/throttle_retry.go index 4c4585cb1d..7f8d85191d 100644 --- a/x/ccv/consumer/keeper/throttle_retry.go +++ b/x/ccv/consumer/keeper/throttle_retry.go @@ -2,7 +2,6 @@ package keeper import ( "fmt" - "time" sdktypes "github.com/cosmos/cosmos-sdk/types" @@ -44,9 +43,6 @@ import ( // This design is implemented below, and in relay.go under SendPackets() and OnAcknowledgementPacket(). // -// Retry delay period could be implemented as a param, but 1 hour is reasonable -const RetryDelayPeriod = time.Hour - // PacketSendingPermitted returns whether the consumer is allowed to send packets // from the pending packets queue. func (k Keeper) PacketSendingPermitted(ctx sdktypes.Context) bool { @@ -60,7 +56,7 @@ func (k Keeper) PacketSendingPermitted(ctx sdktypes.Context) bool { return false } // If retry delay period has elapsed, we can send again - return ctx.BlockTime().After(record.SendTime.Add(RetryDelayPeriod)) + return ctx.BlockTime().After(record.SendTime.Add(k.GetRetryDelayPeriod(ctx))) } func (k Keeper) UpdateSlashRecordOnSend(ctx sdktypes.Context) { diff --git a/x/ccv/consumer/keeper/throttle_retry_test.go b/x/ccv/consumer/keeper/throttle_retry_test.go index cc14ce3cdd..50157df843 100644 --- a/x/ccv/consumer/keeper/throttle_retry_test.go +++ b/x/ccv/consumer/keeper/throttle_retry_test.go @@ -7,14 +7,16 @@ import ( "github.com/stretchr/testify/require" testutil "github.com/cosmos/interchain-security/v3/testutil/keeper" - consumerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) func TestPacketSendingPermitted(t *testing.T) { consumerKeeper, ctx, ctrl, _ := testutil.GetConsumerKeeperAndCtx(t, testutil.NewInMemKeeperParams(t)) defer ctrl.Finish() + consumerKeeper.SetParams(ctx, ccvtypes.DefaultParams()) + ctx = ctx.WithBlockTime(time.Now()) // No slash record exists, send is permitted @@ -42,7 +44,8 @@ func TestPacketSendingPermitted(t *testing.T) { require.False(t, consumerKeeper.PacketSendingPermitted(ctx)) // Elapse retry delay period - ctx = ctx.WithBlockTime(ctx.BlockTime().Add(2 * consumerkeeper.RetryDelayPeriod)) + period := consumerKeeper.GetRetryDelayPeriod(ctx) + ctx = ctx.WithBlockTime(ctx.BlockTime().Add(2 * period)) // Now packet sending is permitted again require.True(t, consumerKeeper.PacketSendingPermitted(ctx)) diff --git a/x/ccv/consumer/module.go b/x/ccv/consumer/module.go index fe9b18a945..f063075211 100644 --- a/x/ccv/consumer/module.go +++ b/x/ccv/consumer/module.go @@ -22,6 +22,7 @@ import ( "github.com/cosmos/interchain-security/v3/x/ccv/consumer/client/cli" "github.com/cosmos/interchain-security/v3/x/ccv/consumer/keeper" consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) var ( @@ -51,7 +52,7 @@ func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) // DefaultGenesis returns default genesis state as raw bytes for the ibc // consumer module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(consumertypes.DefaultGenesisState()) + return cdc.MustMarshalJSON(ccvtypes.DefaultConsumerGenesisState()) } // ValidateGenesis performs genesis state validation for the ibc consumer module. @@ -106,6 +107,11 @@ func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { consumertypes.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + m := keeper.NewMigrator(am.keeper, am.paramSpace) + if err := cfg.RegisterMigration(consumertypes.ModuleName, 1, m.Migrate1to2); err != nil { + panic(fmt.Sprintf("failed to register migrator for %s: %s", consumertypes.ModuleName, err)) + } } // InitGenesis performs genesis initialization for the consumer module. It returns @@ -125,12 +131,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw // ConsensusVersion implements AppModule/ConsensusVersion. func (AppModule) ConsensusVersion() uint64 { - // Note that v1.0.0 consumers should technically be on a different consensus version - // than v1.2.0-multiden and v2.0.0. However, Neutron was the first consumer to launch - // in prod, and they've started on v1.2.0-multiden (which has a ConsensusVersion of 1). - // - // v1.2.0-multiden and v2.0.0 are consensus compatible, so they need return the same ConsensusVersion of 1. - return 1 + return 2 } // BeginBlock implements the AppModule interface diff --git a/x/ccv/consumer/types/consumer.pb.go b/x/ccv/consumer/types/consumer.pb.go index b16b561b7b..93a3c32a83 100644 --- a/x/ccv/consumer/types/consumer.pb.go +++ b/x/ccv/consumer/types/consumer.pb.go @@ -10,8 +10,6 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" - _ "github.com/cosmos/interchain-security/v3/x/ccv/types" - _ "google.golang.org/protobuf/types/known/durationpb" _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" @@ -31,215 +29,12 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// Params defines the parameters for CCV consumer module -type Params struct { - // TODO: Remove enabled flag and find a better way to setup integration tests - // See: https://github.com/cosmos/interchain-security/issues/339 - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - /////////////////////// - // Distribution Params - // Number of blocks between ibc-token-transfers from the consumer chain to - // the provider chain. Note that at this transmission event a fraction of - // the accumulated tokens are divided and sent consumer redistribution - // address. - BlocksPerDistributionTransmission int64 `protobuf:"varint,2,opt,name=blocks_per_distribution_transmission,json=blocksPerDistributionTransmission,proto3" json:"blocks_per_distribution_transmission,omitempty"` - // Channel, and provider-chain receiving address to send distribution token - // transfers over. These parameters is auto-set during the consumer <-> - // provider handshake procedure. - DistributionTransmissionChannel string `protobuf:"bytes,3,opt,name=distribution_transmission_channel,json=distributionTransmissionChannel,proto3" json:"distribution_transmission_channel,omitempty"` - ProviderFeePoolAddrStr string `protobuf:"bytes,4,opt,name=provider_fee_pool_addr_str,json=providerFeePoolAddrStr,proto3" json:"provider_fee_pool_addr_str,omitempty"` - // Sent CCV related IBC packets will timeout after this duration - CcvTimeoutPeriod time.Duration `protobuf:"bytes,5,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"` - // Sent transfer related IBC packets will timeout after this duration - TransferTimeoutPeriod time.Duration `protobuf:"bytes,6,opt,name=transfer_timeout_period,json=transferTimeoutPeriod,proto3,stdduration" json:"transfer_timeout_period"` - // The fraction of tokens allocated to the consumer redistribution address - // during distribution events. The fraction is a string representing a - // decimal number. For example "0.75" would represent 75%. - ConsumerRedistributionFraction string `protobuf:"bytes,7,opt,name=consumer_redistribution_fraction,json=consumerRedistributionFraction,proto3" json:"consumer_redistribution_fraction,omitempty"` - // The number of historical info entries to persist in store. - // This param is a part of the cosmos sdk staking module. In the case of - // a ccv enabled consumer chain, the ccv module acts as the staking module. - HistoricalEntries int64 `protobuf:"varint,8,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` - // Unbonding period for the consumer, - // which should be smaller than that of the provider in general. - UnbondingPeriod time.Duration `protobuf:"bytes,9,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period"` - // The threshold for the percentage of validators at the bottom of the set who - // can opt out of running the consumer chain without being punished. For - // example, a value of 0.05 means that the validators in the bottom 5% of the - // set can opt out - SoftOptOutThreshold string `protobuf:"bytes,10,opt,name=soft_opt_out_threshold,json=softOptOutThreshold,proto3" json:"soft_opt_out_threshold,omitempty"` - // Reward denoms. These are the denominations which are allowed to be sent to - // the provider as rewards. - RewardDenoms []string `protobuf:"bytes,11,rep,name=reward_denoms,json=rewardDenoms,proto3" json:"reward_denoms,omitempty"` - // Provider-originated reward denoms. These are denoms coming from the - // provider which are allowed to be used as rewards. e.g. "uatom" - ProviderRewardDenoms []string `protobuf:"bytes,12,rep,name=provider_reward_denoms,json=providerRewardDenoms,proto3" json:"provider_reward_denoms,omitempty"` -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_5b27a82b276e7f93, []int{0} -} -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) GetEnabled() bool { - if m != nil { - return m.Enabled - } - return false -} - -func (m *Params) GetBlocksPerDistributionTransmission() int64 { - if m != nil { - return m.BlocksPerDistributionTransmission - } - return 0 -} - -func (m *Params) GetDistributionTransmissionChannel() string { - if m != nil { - return m.DistributionTransmissionChannel - } - return "" -} - -func (m *Params) GetProviderFeePoolAddrStr() string { - if m != nil { - return m.ProviderFeePoolAddrStr - } - return "" -} - -func (m *Params) GetCcvTimeoutPeriod() time.Duration { - if m != nil { - return m.CcvTimeoutPeriod - } - return 0 -} - -func (m *Params) GetTransferTimeoutPeriod() time.Duration { - if m != nil { - return m.TransferTimeoutPeriod - } - return 0 -} - -func (m *Params) GetConsumerRedistributionFraction() string { - if m != nil { - return m.ConsumerRedistributionFraction - } - return "" -} - -func (m *Params) GetHistoricalEntries() int64 { - if m != nil { - return m.HistoricalEntries - } - return 0 -} - -func (m *Params) GetUnbondingPeriod() time.Duration { - if m != nil { - return m.UnbondingPeriod - } - return 0 -} - -func (m *Params) GetSoftOptOutThreshold() string { - if m != nil { - return m.SoftOptOutThreshold - } - return "" -} - -func (m *Params) GetRewardDenoms() []string { - if m != nil { - return m.RewardDenoms - } - return nil -} - -func (m *Params) GetProviderRewardDenoms() []string { - if m != nil { - return m.ProviderRewardDenoms - } - return nil -} - -// LastTransmissionBlockHeight is the last time validator holding -// pools were transmitted to the provider chain -type LastTransmissionBlockHeight struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` -} - -func (m *LastTransmissionBlockHeight) Reset() { *m = LastTransmissionBlockHeight{} } -func (m *LastTransmissionBlockHeight) String() string { return proto.CompactTextString(m) } -func (*LastTransmissionBlockHeight) ProtoMessage() {} -func (*LastTransmissionBlockHeight) Descriptor() ([]byte, []int) { - return fileDescriptor_5b27a82b276e7f93, []int{1} -} -func (m *LastTransmissionBlockHeight) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LastTransmissionBlockHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LastTransmissionBlockHeight.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 *LastTransmissionBlockHeight) XXX_Merge(src proto.Message) { - xxx_messageInfo_LastTransmissionBlockHeight.Merge(m, src) -} -func (m *LastTransmissionBlockHeight) XXX_Size() int { - return m.Size() -} -func (m *LastTransmissionBlockHeight) XXX_DiscardUnknown() { - xxx_messageInfo_LastTransmissionBlockHeight.DiscardUnknown(m) -} - -var xxx_messageInfo_LastTransmissionBlockHeight proto.InternalMessageInfo - -func (m *LastTransmissionBlockHeight) GetHeight() int64 { - if m != nil { - return m.Height - } - return 0 -} - -// CrossChainValidator defines the validators for CCV consumer module +// CrossChainValidator defines the type used to store validator information +// internal to the consumer CCV module. Note one cross chain validator entry is +// persisted for each consumer validator, where incoming VSC packets update this +// data, which is eventually forwarded to comet for consumer chain consensus. +// +// Note this type is only used internally to the consumer CCV module. type CrossChainValidator struct { Address []byte `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` Power int64 `protobuf:"varint,2,opt,name=power,proto3" json:"power,omitempty"` @@ -251,7 +46,7 @@ func (m *CrossChainValidator) Reset() { *m = CrossChainValidator{} } func (m *CrossChainValidator) String() string { return proto.CompactTextString(m) } func (*CrossChainValidator) ProtoMessage() {} func (*CrossChainValidator) Descriptor() ([]byte, []int) { - return fileDescriptor_5b27a82b276e7f93, []int{2} + return fileDescriptor_5b27a82b276e7f93, []int{0} } func (m *CrossChainValidator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -301,61 +96,10 @@ func (m *CrossChainValidator) GetPubkey() *types.Any { return nil } -// MaturingVSCPacket contains the maturing time of a received VSCPacket -type MaturingVSCPacket struct { - VscId uint64 `protobuf:"varint,1,opt,name=vscId,proto3" json:"vscId,omitempty"` - MaturityTime time.Time `protobuf:"bytes,2,opt,name=maturity_time,json=maturityTime,proto3,stdtime" json:"maturity_time"` -} - -func (m *MaturingVSCPacket) Reset() { *m = MaturingVSCPacket{} } -func (m *MaturingVSCPacket) String() string { return proto.CompactTextString(m) } -func (*MaturingVSCPacket) ProtoMessage() {} -func (*MaturingVSCPacket) Descriptor() ([]byte, []int) { - return fileDescriptor_5b27a82b276e7f93, []int{3} -} -func (m *MaturingVSCPacket) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MaturingVSCPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MaturingVSCPacket.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 *MaturingVSCPacket) XXX_Merge(src proto.Message) { - xxx_messageInfo_MaturingVSCPacket.Merge(m, src) -} -func (m *MaturingVSCPacket) XXX_Size() int { - return m.Size() -} -func (m *MaturingVSCPacket) XXX_DiscardUnknown() { - xxx_messageInfo_MaturingVSCPacket.DiscardUnknown(m) -} - -var xxx_messageInfo_MaturingVSCPacket proto.InternalMessageInfo - -func (m *MaturingVSCPacket) GetVscId() uint64 { - if m != nil { - return m.VscId - } - return 0 -} - -func (m *MaturingVSCPacket) GetMaturityTime() time.Time { - if m != nil { - return m.MaturityTime - } - return time.Time{} -} - // A record storing the state of a slash packet sent to the provider chain // which may bounce back and forth until handled by the provider. +// +// Note this type is only used internally to the consumer CCV module. type SlashRecord struct { WaitingOnReply bool `protobuf:"varint,1,opt,name=waiting_on_reply,json=waitingOnReply,proto3" json:"waiting_on_reply,omitempty"` SendTime time.Time `protobuf:"bytes,2,opt,name=send_time,json=sendTime,proto3,stdtime" json:"send_time"` @@ -365,7 +109,7 @@ func (m *SlashRecord) Reset() { *m = SlashRecord{} } func (m *SlashRecord) String() string { return proto.CompactTextString(m) } func (*SlashRecord) ProtoMessage() {} func (*SlashRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_5b27a82b276e7f93, []int{4} + return fileDescriptor_5b27a82b276e7f93, []int{1} } func (m *SlashRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -409,10 +153,7 @@ func (m *SlashRecord) GetSendTime() time.Time { } func init() { - proto.RegisterType((*Params)(nil), "interchain_security.ccv.consumer.v1.Params") - proto.RegisterType((*LastTransmissionBlockHeight)(nil), "interchain_security.ccv.consumer.v1.LastTransmissionBlockHeight") proto.RegisterType((*CrossChainValidator)(nil), "interchain_security.ccv.consumer.v1.CrossChainValidator") - proto.RegisterType((*MaturingVSCPacket)(nil), "interchain_security.ccv.consumer.v1.MaturingVSCPacket") proto.RegisterType((*SlashRecord)(nil), "interchain_security.ccv.consumer.v1.SlashRecord") } @@ -421,201 +162,33 @@ func init() { } var fileDescriptor_5b27a82b276e7f93 = []byte{ - // 836 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcf, 0x6e, 0xdb, 0x36, - 0x18, 0x8f, 0x96, 0xd6, 0x4d, 0xe8, 0x74, 0x4b, 0x59, 0x2f, 0x55, 0x33, 0xc0, 0x76, 0xdd, 0x1e, - 0x7c, 0x89, 0x8d, 0x26, 0xdb, 0xa5, 0xc0, 0x0e, 0xf9, 0xb3, 0xa2, 0xdd, 0xbf, 0x78, 0x4a, 0xd0, - 0x01, 0xdb, 0x81, 0xa0, 0xa8, 0xcf, 0x16, 0x11, 0x89, 0x14, 0x48, 0x4a, 0x99, 0x76, 0xde, 0x03, - 0xf4, 0xb8, 0x47, 0xd8, 0x03, 0xec, 0x21, 0x8a, 0x9d, 0x7a, 0xdc, 0xa9, 0x1b, 0x92, 0x37, 0xd8, - 0x13, 0x0c, 0xa4, 0x24, 0xd7, 0x4e, 0x17, 0xa0, 0xbb, 0xf1, 0xe3, 0xef, 0x8f, 0xf8, 0x7d, 0xfc, - 0xf8, 0x09, 0xed, 0x72, 0x61, 0x40, 0xb1, 0x98, 0x72, 0x41, 0x34, 0xb0, 0x5c, 0x71, 0x53, 0x8e, - 0x19, 0x2b, 0xc6, 0x4c, 0x0a, 0x9d, 0xa7, 0xa0, 0xc6, 0xc5, 0xe3, 0xf9, 0x7a, 0x94, 0x29, 0x69, - 0x24, 0x7e, 0xf8, 0x1f, 0x9a, 0x11, 0x63, 0xc5, 0x68, 0xce, 0x2b, 0x1e, 0x6f, 0x3f, 0xba, 0xce, - 0xd8, 0xfa, 0xb1, 0xa2, 0xb2, 0xda, 0xbe, 0x3f, 0x93, 0x72, 0x96, 0xc0, 0xd8, 0x45, 0x61, 0x3e, - 0x1d, 0x53, 0x51, 0xd6, 0x50, 0x67, 0x26, 0x67, 0xd2, 0x2d, 0xc7, 0x76, 0xd5, 0x08, 0x98, 0xd4, - 0xa9, 0xd4, 0xa4, 0x02, 0xaa, 0xa0, 0x86, 0xba, 0x57, 0xbd, 0xa2, 0x5c, 0x51, 0xc3, 0xa5, 0xa8, - 0xf1, 0xde, 0x55, 0xdc, 0xf0, 0x14, 0xb4, 0xa1, 0x69, 0x56, 0x11, 0x06, 0xbf, 0xb4, 0x50, 0x6b, - 0x42, 0x15, 0x4d, 0x35, 0xf6, 0xd1, 0x2d, 0x10, 0x34, 0x4c, 0x20, 0xf2, 0xbd, 0xbe, 0x37, 0x5c, - 0x0b, 0x9a, 0x10, 0x1f, 0xa3, 0x47, 0x61, 0x22, 0xd9, 0x99, 0x26, 0x19, 0x28, 0x12, 0x71, 0x6d, - 0x14, 0x0f, 0x73, 0xfb, 0x19, 0x62, 0x14, 0x15, 0x3a, 0xe5, 0x5a, 0x73, 0x29, 0xfc, 0x0f, 0xfa, - 0xde, 0x70, 0x35, 0x78, 0x50, 0x71, 0x27, 0xa0, 0x8e, 0x16, 0x98, 0xa7, 0x0b, 0x44, 0xfc, 0x25, - 0x7a, 0x70, 0xad, 0x0b, 0x61, 0x31, 0x15, 0x02, 0x12, 0x7f, 0xb5, 0xef, 0x0d, 0xd7, 0x83, 0x5e, - 0x74, 0x8d, 0xc9, 0x61, 0x45, 0xc3, 0x4f, 0xd0, 0x76, 0xa6, 0x64, 0xc1, 0x23, 0x50, 0x64, 0x0a, - 0x40, 0x32, 0x29, 0x13, 0x42, 0xa3, 0x48, 0x11, 0x6d, 0x94, 0x7f, 0xc3, 0x99, 0x6c, 0x35, 0x8c, - 0xa7, 0x00, 0x13, 0x29, 0x93, 0xfd, 0x28, 0x52, 0x27, 0x46, 0xe1, 0xef, 0x10, 0x66, 0xac, 0x20, - 0xb6, 0x28, 0x32, 0x37, 0x36, 0x3b, 0x2e, 0x23, 0xff, 0x66, 0xdf, 0x1b, 0xb6, 0x77, 0xef, 0x8f, - 0xaa, 0xda, 0x8d, 0x9a, 0xda, 0x8d, 0x8e, 0xea, 0xda, 0x1e, 0xac, 0xbd, 0x7a, 0xd3, 0x5b, 0xf9, - 0xf5, 0xaf, 0x9e, 0x17, 0x6c, 0x32, 0x56, 0x9c, 0x56, 0xea, 0x89, 0x13, 0xe3, 0x1f, 0xd1, 0x3d, - 0x97, 0xcd, 0x14, 0xd4, 0x55, 0xdf, 0xd6, 0xfb, 0xfb, 0x7e, 0xdc, 0x78, 0x2c, 0x9b, 0x3f, 0x43, - 0xfd, 0xa6, 0xdf, 0x88, 0x82, 0xa5, 0x12, 0x4e, 0x15, 0x65, 0x76, 0xe1, 0xdf, 0x72, 0x19, 0x77, - 0x1b, 0x5e, 0xb0, 0x44, 0x7b, 0x5a, 0xb3, 0xf0, 0x0e, 0xc2, 0x31, 0xd7, 0x46, 0x2a, 0xce, 0x68, - 0x42, 0x40, 0x18, 0xc5, 0x41, 0xfb, 0x6b, 0xee, 0x02, 0xef, 0xbc, 0x45, 0xbe, 0xa8, 0x00, 0xfc, - 0x2d, 0xda, 0xcc, 0x45, 0x28, 0x45, 0xc4, 0xc5, 0xac, 0x49, 0x67, 0xfd, 0xfd, 0xd3, 0xf9, 0x68, - 0x2e, 0xae, 0x13, 0xd9, 0x43, 0x5b, 0x5a, 0x4e, 0x0d, 0x91, 0x99, 0x21, 0xb6, 0x42, 0x26, 0x56, - 0xa0, 0x63, 0x99, 0x44, 0x3e, 0x72, 0xc7, 0xbf, 0x6b, 0xd1, 0xe3, 0xcc, 0x1c, 0xe7, 0xe6, 0xb4, - 0x81, 0xf0, 0x43, 0x74, 0x5b, 0xc1, 0x39, 0x55, 0x11, 0x89, 0x40, 0xc8, 0x54, 0xfb, 0xed, 0xfe, - 0xea, 0x70, 0x3d, 0xd8, 0xa8, 0x36, 0x8f, 0xdc, 0x1e, 0xfe, 0x14, 0xcd, 0x2f, 0x9b, 0x2c, 0xb3, - 0x37, 0x1c, 0xbb, 0xd3, 0xa0, 0xc1, 0x82, 0x6a, 0xf0, 0x19, 0xfa, 0xe4, 0x6b, 0xaa, 0xcd, 0x62, - 0x7f, 0x1d, 0xd8, 0x2e, 0x7e, 0x06, 0x7c, 0x16, 0x1b, 0xbc, 0x85, 0x5a, 0xb1, 0x5b, 0xb9, 0x97, - 0xb1, 0x1a, 0xd4, 0xd1, 0xe0, 0x37, 0x0f, 0xdd, 0x3d, 0x54, 0x52, 0xeb, 0x43, 0xfb, 0xe6, 0x5f, - 0xd0, 0x84, 0x47, 0xd4, 0x48, 0x65, 0x9f, 0x92, 0xed, 0x40, 0xd0, 0xda, 0x09, 0x36, 0x82, 0x26, - 0xc4, 0x1d, 0x74, 0x33, 0x93, 0xe7, 0xa0, 0xea, 0xb7, 0x52, 0x05, 0x98, 0xa2, 0x56, 0x96, 0x87, - 0x67, 0x50, 0xba, 0xa6, 0x6f, 0xef, 0x76, 0xde, 0x29, 0xea, 0xbe, 0x28, 0x0f, 0xf6, 0xfe, 0x79, - 0xd3, 0xbb, 0x57, 0xd2, 0x34, 0x79, 0x32, 0xb0, 0xb7, 0x0b, 0x42, 0xe7, 0x9a, 0x54, 0xba, 0xc1, - 0x1f, 0xbf, 0xef, 0x74, 0xea, 0xc9, 0xc0, 0x54, 0x99, 0x19, 0x39, 0x9a, 0xe4, 0xe1, 0x57, 0x50, - 0x06, 0xb5, 0xf1, 0xc0, 0xa0, 0x3b, 0xdf, 0x50, 0x93, 0x2b, 0x2e, 0x66, 0x2f, 0x4e, 0x0e, 0x27, - 0x94, 0x9d, 0x81, 0xb1, 0xa7, 0x29, 0x34, 0x7b, 0x5e, 0x3d, 0xf8, 0x1b, 0x41, 0x15, 0xe0, 0xe7, - 0xe8, 0x76, 0xea, 0xa8, 0xa6, 0x74, 0x2d, 0xec, 0xce, 0xda, 0xde, 0xdd, 0x7e, 0xe7, 0x50, 0xa7, - 0xcd, 0x30, 0xa9, 0xae, 0xfa, 0xa5, 0xbd, 0xea, 0x8d, 0x46, 0x6a, 0xc1, 0xc1, 0xcf, 0xa8, 0x7d, - 0x92, 0x50, 0x1d, 0x07, 0xc0, 0xa4, 0x8a, 0xf0, 0x10, 0x6d, 0x9e, 0x53, 0x6e, 0x6c, 0x13, 0x49, - 0x41, 0x14, 0x64, 0x49, 0x59, 0xcf, 0x9a, 0x0f, 0xeb, 0xfd, 0x63, 0x11, 0xd8, 0x5d, 0xbc, 0x8f, - 0xd6, 0x35, 0x88, 0xe8, 0xff, 0x7f, 0x7f, 0xcd, 0xca, 0x2c, 0x70, 0xf0, 0xfd, 0xab, 0x8b, 0xae, - 0xf7, 0xfa, 0xa2, 0xeb, 0xfd, 0x7d, 0xd1, 0xf5, 0x5e, 0x5e, 0x76, 0x57, 0x5e, 0x5f, 0x76, 0x57, - 0xfe, 0xbc, 0xec, 0xae, 0xfc, 0xf0, 0xf9, 0x8c, 0x9b, 0x38, 0x0f, 0x47, 0x4c, 0xa6, 0xf5, 0x38, - 0x1d, 0xbf, 0x9d, 0xdc, 0x3b, 0xf3, 0xc9, 0x5d, 0xec, 0x8d, 0x7f, 0x5a, 0xfe, 0x2f, 0x98, 0x32, - 0x03, 0x1d, 0xb6, 0xdc, 0x01, 0xf6, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x61, 0xb7, 0xcd, 0x97, - 0x48, 0x06, 0x00, 0x00, -} - -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.ProviderRewardDenoms) > 0 { - for iNdEx := len(m.ProviderRewardDenoms) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.ProviderRewardDenoms[iNdEx]) - copy(dAtA[i:], m.ProviderRewardDenoms[iNdEx]) - i = encodeVarintConsumer(dAtA, i, uint64(len(m.ProviderRewardDenoms[iNdEx]))) - i-- - dAtA[i] = 0x62 - } - } - if len(m.RewardDenoms) > 0 { - for iNdEx := len(m.RewardDenoms) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.RewardDenoms[iNdEx]) - copy(dAtA[i:], m.RewardDenoms[iNdEx]) - i = encodeVarintConsumer(dAtA, i, uint64(len(m.RewardDenoms[iNdEx]))) - i-- - dAtA[i] = 0x5a - } - } - if len(m.SoftOptOutThreshold) > 0 { - i -= len(m.SoftOptOutThreshold) - copy(dAtA[i:], m.SoftOptOutThreshold) - i = encodeVarintConsumer(dAtA, i, uint64(len(m.SoftOptOutThreshold))) - i-- - dAtA[i] = 0x52 - } - n1, err1 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintConsumer(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x4a - if m.HistoricalEntries != 0 { - i = encodeVarintConsumer(dAtA, i, uint64(m.HistoricalEntries)) - i-- - dAtA[i] = 0x40 - } - if len(m.ConsumerRedistributionFraction) > 0 { - i -= len(m.ConsumerRedistributionFraction) - copy(dAtA[i:], m.ConsumerRedistributionFraction) - i = encodeVarintConsumer(dAtA, i, uint64(len(m.ConsumerRedistributionFraction))) - i-- - dAtA[i] = 0x3a - } - n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.TransferTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintConsumer(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x32 - n3, err3 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) - if err3 != nil { - return 0, err3 - } - i -= n3 - i = encodeVarintConsumer(dAtA, i, uint64(n3)) - i-- - dAtA[i] = 0x2a - if len(m.ProviderFeePoolAddrStr) > 0 { - i -= len(m.ProviderFeePoolAddrStr) - copy(dAtA[i:], m.ProviderFeePoolAddrStr) - i = encodeVarintConsumer(dAtA, i, uint64(len(m.ProviderFeePoolAddrStr))) - i-- - dAtA[i] = 0x22 - } - if len(m.DistributionTransmissionChannel) > 0 { - i -= len(m.DistributionTransmissionChannel) - copy(dAtA[i:], m.DistributionTransmissionChannel) - i = encodeVarintConsumer(dAtA, i, uint64(len(m.DistributionTransmissionChannel))) - i-- - dAtA[i] = 0x1a - } - if m.BlocksPerDistributionTransmission != 0 { - i = encodeVarintConsumer(dAtA, i, uint64(m.BlocksPerDistributionTransmission)) - i-- - dAtA[i] = 0x10 - } - if m.Enabled { - i-- - if m.Enabled { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *LastTransmissionBlockHeight) 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 *LastTransmissionBlockHeight) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LastTransmissionBlockHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintConsumer(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil + // 413 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xcd, 0x8e, 0xd3, 0x30, + 0x10, 0xc7, 0x6b, 0x56, 0x2c, 0xc5, 0x45, 0x08, 0x85, 0x4a, 0x74, 0x7b, 0x48, 0xab, 0x70, 0xc9, + 0x65, 0x6d, 0x6d, 0x7b, 0x43, 0xe2, 0xb0, 0xdd, 0x23, 0x07, 0x50, 0x40, 0x20, 0x71, 0x89, 0x1c, + 0xc7, 0xa4, 0x16, 0x89, 0x27, 0xb2, 0x9d, 0x2c, 0xe6, 0x29, 0xf6, 0x31, 0x78, 0x00, 0x1e, 0x62, + 0xc5, 0x69, 0x8f, 0x9c, 0x0a, 0x6a, 0xdf, 0x80, 0x27, 0x40, 0xf9, 0x68, 0x11, 0xb0, 0xb7, 0xf9, + 0xf0, 0x7f, 0xe6, 0x37, 0xe3, 0xc1, 0x0b, 0xa9, 0xac, 0xd0, 0x7c, 0xcd, 0xa4, 0x8a, 0x8d, 0xe0, + 0x95, 0x96, 0xd6, 0x51, 0xce, 0x6b, 0xca, 0x41, 0x99, 0xaa, 0x10, 0x9a, 0xd6, 0x67, 0x07, 0x9b, + 0x94, 0x1a, 0x2c, 0x78, 0x4f, 0x6f, 0xd1, 0x10, 0xce, 0x6b, 0x72, 0x78, 0x57, 0x9f, 0x4d, 0x4f, + 0x32, 0x80, 0x2c, 0x17, 0xb4, 0x95, 0x24, 0xd5, 0x07, 0xca, 0x94, 0xeb, 0xf4, 0xd3, 0x71, 0x06, + 0x19, 0xb4, 0x26, 0x6d, 0xac, 0x3e, 0x7a, 0xc2, 0xc1, 0x14, 0x60, 0xe2, 0x2e, 0xd1, 0x39, 0x7d, + 0x6a, 0xf6, 0x6f, 0x2d, 0x2b, 0x0b, 0x61, 0x2c, 0x2b, 0xca, 0xee, 0x41, 0xf0, 0x05, 0xe1, 0xc7, + 0x17, 0x1a, 0x8c, 0xb9, 0x68, 0xa0, 0xde, 0xb2, 0x5c, 0xa6, 0xcc, 0x82, 0xf6, 0x26, 0xf8, 0x1e, + 0x4b, 0x53, 0x2d, 0x8c, 0x99, 0xa0, 0x39, 0x0a, 0x1f, 0x44, 0x7b, 0xd7, 0x1b, 0xe3, 0xbb, 0x25, + 0x5c, 0x0a, 0x3d, 0xb9, 0x33, 0x47, 0xe1, 0x51, 0xd4, 0x39, 0x1e, 0xc3, 0xc7, 0x65, 0x95, 0x7c, + 0x14, 0x6e, 0x72, 0x34, 0x47, 0xe1, 0x68, 0x31, 0x26, 0x5d, 0x67, 0xb2, 0xef, 0x4c, 0xce, 0x95, + 0x5b, 0x2d, 0x7f, 0x6d, 0x66, 0x4f, 0x1c, 0x2b, 0xf2, 0x67, 0x41, 0x33, 0xb1, 0x50, 0xa6, 0x32, + 0x71, 0xa7, 0x0b, 0xbe, 0x7d, 0x3d, 0x1d, 0xf7, 0xec, 0x5c, 0xbb, 0xd2, 0x02, 0x79, 0x55, 0x25, + 0x2f, 0x84, 0x8b, 0xfa, 0xc2, 0xc1, 0x67, 0x3c, 0x7a, 0x9d, 0x33, 0xb3, 0x8e, 0x04, 0x07, 0x9d, + 0x7a, 0x21, 0x7e, 0x74, 0xc9, 0xa4, 0x95, 0x2a, 0x8b, 0x41, 0xc5, 0x5a, 0x94, 0xb9, 0x6b, 0x51, + 0x87, 0xd1, 0xc3, 0x3e, 0xfe, 0x52, 0x45, 0x4d, 0xd4, 0x3b, 0xc7, 0xf7, 0x8d, 0x50, 0x69, 0xdc, + 0xcc, 0xde, 0x52, 0x8f, 0x16, 0xd3, 0xff, 0xf0, 0xde, 0xec, 0x17, 0xb3, 0x1a, 0x5e, 0x6f, 0x66, + 0x83, 0xab, 0x1f, 0x33, 0x14, 0x0d, 0x1b, 0x59, 0x93, 0x58, 0xbd, 0xbb, 0xde, 0xfa, 0xe8, 0x66, + 0xeb, 0xa3, 0x9f, 0x5b, 0x1f, 0x5d, 0xed, 0xfc, 0xc1, 0xcd, 0xce, 0x1f, 0x7c, 0xdf, 0xf9, 0x83, + 0xf7, 0xcf, 0x33, 0x69, 0xd7, 0x55, 0x42, 0x38, 0x14, 0xfd, 0xea, 0xe9, 0x9f, 0x4f, 0x3e, 0x3d, + 0x1c, 0x46, 0xbd, 0xa4, 0x9f, 0xfe, 0xbe, 0x0e, 0xeb, 0x4a, 0x61, 0x92, 0xe3, 0x16, 0x60, 0xf9, + 0x3b, 0x00, 0x00, 0xff, 0xff, 0x43, 0xb2, 0x00, 0x6a, 0x4e, 0x02, 0x00, 0x00, } func (m *CrossChainValidator) Marshal() (dAtA []byte, err error) { @@ -665,42 +238,6 @@ func (m *CrossChainValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *MaturingVSCPacket) 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 *MaturingVSCPacket) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MaturingVSCPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n5, err5 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.MaturityTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.MaturityTime):]) - if err5 != nil { - return 0, err5 - } - i -= n5 - i = encodeVarintConsumer(dAtA, i, uint64(n5)) - i-- - dAtA[i] = 0x12 - if m.VscId != 0 { - i = encodeVarintConsumer(dAtA, i, uint64(m.VscId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *SlashRecord) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -721,12 +258,12 @@ func (m *SlashRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - n6, err6 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.SendTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.SendTime):]) - if err6 != nil { - return 0, err6 + n2, err2 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.SendTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.SendTime):]) + if err2 != nil { + return 0, err2 } - i -= n6 - i = encodeVarintConsumer(dAtA, i, uint64(n6)) + i -= n2 + i = encodeVarintConsumer(dAtA, i, uint64(n2)) i-- dAtA[i] = 0x12 if m.WaitingOnReply { @@ -753,82 +290,18 @@ func encodeVarintConsumer(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *Params) Size() (n int) { +func (m *CrossChainValidator) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.Enabled { - n += 2 - } - if m.BlocksPerDistributionTransmission != 0 { - n += 1 + sovConsumer(uint64(m.BlocksPerDistributionTransmission)) - } - l = len(m.DistributionTransmissionChannel) + l = len(m.Address) if l > 0 { n += 1 + l + sovConsumer(uint64(l)) } - l = len(m.ProviderFeePoolAddrStr) - if l > 0 { - n += 1 + l + sovConsumer(uint64(l)) - } - l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod) - n += 1 + l + sovConsumer(uint64(l)) - l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod) - n += 1 + l + sovConsumer(uint64(l)) - l = len(m.ConsumerRedistributionFraction) - if l > 0 { - n += 1 + l + sovConsumer(uint64(l)) - } - if m.HistoricalEntries != 0 { - n += 1 + sovConsumer(uint64(m.HistoricalEntries)) - } - l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod) - n += 1 + l + sovConsumer(uint64(l)) - l = len(m.SoftOptOutThreshold) - if l > 0 { - n += 1 + l + sovConsumer(uint64(l)) - } - if len(m.RewardDenoms) > 0 { - for _, s := range m.RewardDenoms { - l = len(s) - n += 1 + l + sovConsumer(uint64(l)) - } - } - if len(m.ProviderRewardDenoms) > 0 { - for _, s := range m.ProviderRewardDenoms { - l = len(s) - n += 1 + l + sovConsumer(uint64(l)) - } - } - return n -} - -func (m *LastTransmissionBlockHeight) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Height != 0 { - n += 1 + sovConsumer(uint64(m.Height)) - } - return n -} - -func (m *CrossChainValidator) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Address) - if l > 0 { - n += 1 + l + sovConsumer(uint64(l)) - } - if m.Power != 0 { - n += 1 + sovConsumer(uint64(m.Power)) + if m.Power != 0 { + n += 1 + sovConsumer(uint64(m.Power)) } if m.Pubkey != nil { l = m.Pubkey.Size() @@ -837,20 +310,6 @@ func (m *CrossChainValidator) Size() (n int) { return n } -func (m *MaturingVSCPacket) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.VscId != 0 { - n += 1 + sovConsumer(uint64(m.VscId)) - } - l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.MaturityTime) - n += 1 + l + sovConsumer(uint64(l)) - return n -} - func (m *SlashRecord) Size() (n int) { if m == nil { return 0 @@ -871,7 +330,7 @@ func sovConsumer(x uint64) (n int) { func sozConsumer(x uint64) (n int) { return sovConsumer(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Params) Unmarshal(dAtA []byte) error { +func (m *CrossChainValidator) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -894,153 +353,17 @@ func (m *Params) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") + return fmt.Errorf("proto: CrossChainValidator: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: CrossChainValidator: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Enabled = bool(v != 0) - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerDistributionTransmission", wireType) - } - m.BlocksPerDistributionTransmission = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.BlocksPerDistributionTransmission |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DistributionTransmissionChannel", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - 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 ErrInvalidLengthConsumer - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DistributionTransmissionChannel = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderFeePoolAddrStr", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - 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 ErrInvalidLengthConsumer - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProviderFeePoolAddrStr = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CcvTimeoutPeriod", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthConsumer - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.CcvTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TransferTimeoutPeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConsumer @@ -1050,62 +373,31 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthConsumer } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthConsumer } if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.TransferTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerRedistributionFraction", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - 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 ErrInvalidLengthConsumer - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF + m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) + if m.Address == nil { + m.Address = []byte{} } - m.ConsumerRedistributionFraction = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 8: + case 2: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field HistoricalEntries", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Power", wireType) } - m.HistoricalEntries = 0 + m.Power = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowConsumer @@ -1115,14 +407,14 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.HistoricalEntries |= int64(b&0x7F) << shift + m.Power |= int64(b&0x7F) << shift if b < 0x80 { break } } - case 9: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnbondingPeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Pubkey", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1149,309 +441,8 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.UnbondingPeriod, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SoftOptOutThreshold", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - 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 ErrInvalidLengthConsumer - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SoftOptOutThreshold = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardDenoms", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - 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 ErrInvalidLengthConsumer - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardDenoms = append(m.RewardDenoms, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderRewardDenoms", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - 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 ErrInvalidLengthConsumer - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProviderRewardDenoms = append(m.ProviderRewardDenoms, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipConsumer(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthConsumer - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *LastTransmissionBlockHeight) 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 ErrIntOverflowConsumer - } - 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: LastTransmissionBlockHeight: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LastTransmissionBlockHeight: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipConsumer(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthConsumer - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *CrossChainValidator) 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 ErrIntOverflowConsumer - } - 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: CrossChainValidator: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CrossChainValidator: 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 byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthConsumer - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Address = append(m.Address[:0], dAtA[iNdEx:postIndex]...) - if m.Address == nil { - m.Address = []byte{} - } - 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 ErrIntOverflowConsumer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Power |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pubkey", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthConsumer - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pubkey == nil { - m.Pubkey = &types.Any{} + if m.Pubkey == nil { + m.Pubkey = &types.Any{} } if err := m.Pubkey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1478,108 +469,6 @@ func (m *CrossChainValidator) Unmarshal(dAtA []byte) error { } return nil } -func (m *MaturingVSCPacket) 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 ErrIntOverflowConsumer - } - 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: MaturingVSCPacket: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MaturingVSCPacket: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field VscId", wireType) - } - m.VscId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.VscId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaturityTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowConsumer - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthConsumer - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthConsumer - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.MaturityTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipConsumer(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthConsumer - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *SlashRecord) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/consumer/types/events.go b/x/ccv/consumer/types/events.go new file mode 100644 index 0000000000..ccc2616416 --- /dev/null +++ b/x/ccv/consumer/types/events.go @@ -0,0 +1,18 @@ +package types + +const ( + AttributeConsumerHeight = "consumer_height" + AttributeTimestamp = "timestamp" + + EventTypeFeeDistribution = "fee_distribution" + EventTypeVSCMatured = "vsc_matured" + EventTypeConsumerSlashRequest = "consumer_slash_request" + EventTypeFeeTransferChannelOpened = "fee_transfer_channel_opened" + + AttributeDistributionCurrentHeight = "current_distribution_height" + //#nosec G101 -- (false positive) this is not a hardcoded credential + AttributeDistributionNextHeight = "next_distribution_height" + AttributeDistributionFraction = "distribution_fraction" + AttributeDistributionTotal = "total" + AttributeDistributionToProvider = "provider_amount" +) diff --git a/x/ccv/consumer/types/genesis.go b/x/ccv/consumer/types/genesis.go index 3a8769939b..0aac48e8f5 100644 --- a/x/ccv/consumer/types/genesis.go +++ b/x/ccv/consumer/types/genesis.go @@ -10,41 +10,30 @@ import ( ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) -// NewInitialGenesisState returns a consumer GenesisState for a completely new consumer chain. -func NewInitialGenesisState(cs *ibctmtypes.ClientState, consState *ibctmtypes.ConsensusState, - initValSet []abci.ValidatorUpdate, params Params, -) *GenesisState { - return &GenesisState{ - Params: params, - NewChain: true, - ProviderClientState: cs, - ProviderConsensusState: consState, - InitialValSet: initValSet, - } -} - // NewRestartGenesisState returns a consumer GenesisState that has already been established. func NewRestartGenesisState( clientID, channelID string, maturingPackets []MaturingVSCPacket, initValSet []abci.ValidatorUpdate, heightToValsetUpdateIDs []HeightToValsetUpdateID, - pendingConsumerPackets ccv.ConsumerPacketDataList, + pendingConsumerPackets ConsumerPacketDataList, outstandingDowntimes []OutstandingDowntime, lastTransBlockHeight LastTransmissionBlockHeight, - params Params, + params ccv.ConsumerParams, ) *GenesisState { return &GenesisState{ - Params: params, - ProviderClientId: clientID, - ProviderChannelId: channelID, + NewChain: false, + Params: params, + Provider: ccv.ProviderInfo{ + InitialValSet: initValSet, + }, MaturingPackets: maturingPackets, - NewChain: false, - InitialValSet: initValSet, HeightToValsetUpdateId: heightToValsetUpdateIDs, PendingConsumerPackets: pendingConsumerPackets, OutstandingDowntimeSlashing: outstandingDowntimes, LastTransmissionBlockHeight: lastTransBlockHeight, + ProviderClientId: clientID, + ProviderChannelId: channelID, } } @@ -52,7 +41,22 @@ func NewRestartGenesisState( // unless explicitly specified in genesis. func DefaultGenesisState() *GenesisState { return &GenesisState{ - Params: DefaultParams(), + Params: ccv.DefaultParams(), + } +} + +// NewInitialGenesisState returns a GenesisState for a completely new consumer chain. +func NewInitialGenesisState(cs *ibctmtypes.ClientState, consState *ibctmtypes.ConsensusState, + initValSet []abci.ValidatorUpdate, params ccv.ConsumerParams, +) *GenesisState { + return &GenesisState{ + NewChain: true, + Params: params, + Provider: ccv.ProviderInfo{ + ClientState: cs, + ConsensusState: consState, + InitialValSet: initValSet, + }, } } @@ -77,7 +81,7 @@ func (gs GenesisState) Validate() error { if !gs.Params.Enabled { return nil } - if len(gs.InitialValSet) == 0 { + if len(gs.Provider.InitialValSet) == 0 { return errorsmod.Wrap(ccv.ErrInvalidGenesis, "initial validator set is empty") } if err := gs.Params.Validate(); err != nil { @@ -85,16 +89,16 @@ func (gs GenesisState) Validate() error { } if gs.NewChain { - if gs.ProviderClientState == nil { + if gs.Provider.ClientState == nil { return errorsmod.Wrap(ccv.ErrInvalidGenesis, "provider client state cannot be nil for new chain") } - if err := gs.ProviderClientState.Validate(); err != nil { + if err := gs.Provider.ClientState.Validate(); err != nil { return errorsmod.Wrapf(ccv.ErrInvalidGenesis, "provider client state invalid for new chain %s", err.Error()) } - if gs.ProviderConsensusState == nil { + if gs.Provider.ConsensusState == nil { return errorsmod.Wrap(ccv.ErrInvalidGenesis, "provider consensus state cannot be nil for new chain") } - if err := gs.ProviderConsensusState.ValidateBasic(); err != nil { + if err := gs.Provider.ConsensusState.ValidateBasic(); err != nil { return errorsmod.Wrapf(ccv.ErrInvalidGenesis, "provider consensus state invalid for new chain %s", err.Error()) } if gs.ProviderClientId != "" { @@ -140,13 +144,13 @@ func (gs GenesisState) Validate() error { } } } - if gs.HeightToValsetUpdateId == nil { + /* if gs.HeightToValsetUpdateId == nil { return errorsmod.Wrap( ccv.ErrInvalidGenesis, "empty height to validator set update id mapping", ) - } - if gs.ProviderClientState != nil || gs.ProviderConsensusState != nil { + } */ + if gs.Provider.ClientState != nil || gs.Provider.ConsensusState != nil { return errorsmod.Wrap(ccv.ErrInvalidGenesis, "provider client state and consensus state must be nil for a restarting genesis state") } for _, mat := range gs.MaturingPackets { diff --git a/x/ccv/consumer/types/genesis.pb.go b/x/ccv/consumer/types/genesis.pb.go index 7a503f0e77..66f3544a6c 100644 --- a/x/ccv/consumer/types/genesis.pb.go +++ b/x/ccv/consumer/types/genesis.pb.go @@ -5,22 +5,24 @@ package types import ( fmt "fmt" - types "github.com/cometbft/cometbft/abci/types" + types1 "github.com/cometbft/cometbft/abci/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - _ "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" _07_tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - types1 "github.com/cosmos/interchain-security/v3/x/ccv/types" - _ "google.golang.org/protobuf/types/known/durationpb" + types "github.com/cosmos/interchain-security/v3/x/ccv/types" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -28,29 +30,38 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// GenesisState defines the CCV consumer chain genesis state +// GenesisState defines the CCV consumer genesis state +// +// Note: this type is only used on consumer side and references shared types with +// provider type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - ProviderClientId string `protobuf:"bytes,2,opt,name=provider_client_id,json=providerClientId,proto3" json:"provider_client_id,omitempty"` + // ConsumerParams is a shared type with provider module + Params types.ConsumerParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // Client ID of the provider. Empty for a new chain, filled in on restart. + ProviderClientId string `protobuf:"bytes,2,opt,name=provider_client_id,json=providerClientId,proto3" json:"provider_client_id,omitempty"` + // Channel ID of the provider. Empty for a new chain, filled in on restart. ProviderChannelId string `protobuf:"bytes,3,opt,name=provider_channel_id,json=providerChannelId,proto3" json:"provider_channel_id,omitempty"` - NewChain bool `protobuf:"varint,4,opt,name=new_chain,json=newChain,proto3" json:"new_chain,omitempty"` - // ProviderClientState filled in on new chain, nil on restart. - ProviderClientState *_07_tendermint.ClientState `protobuf:"bytes,5,opt,name=provider_client_state,json=providerClientState,proto3" json:"provider_client_state,omitempty"` - // ProviderConsensusState filled in on new chain, nil on restart. - ProviderConsensusState *_07_tendermint.ConsensusState `protobuf:"bytes,6,opt,name=provider_consensus_state,json=providerConsensusState,proto3" json:"provider_consensus_state,omitempty"` + // true for new chain, false for chain restart. + NewChain bool `protobuf:"varint,4,opt,name=new_chain,json=newChain,proto3" json:"new_chain,omitempty"` + // !!! DEPRECATED !!! ProviderClientState is deprecated. Use provider.client_state instead + ProviderClientState *_07_tendermint.ClientState `protobuf:"bytes,5,opt,name=provider_client_state,json=providerClientState,proto3" json:"provider_client_state,omitempty"` // Deprecated: Do not use. + // !!! DEPRECATED !!! ProviderConsensusState is deprecated. Use provider.consensus_state instead + ProviderConsensusState *_07_tendermint.ConsensusState `protobuf:"bytes,6,opt,name=provider_consensus_state,json=providerConsensusState,proto3" json:"provider_consensus_state,omitempty"` // Deprecated: Do not use. // MaturingPackets nil on new chain, filled in on restart. MaturingPackets []MaturingVSCPacket `protobuf:"bytes,7,rep,name=maturing_packets,json=maturingPackets,proto3" json:"maturing_packets"` - // InitialValset filled in on new chain and on restart. - InitialValSet []types.ValidatorUpdate `protobuf:"bytes,8,rep,name=initial_val_set,json=initialValSet,proto3" json:"initial_val_set"` + // !!! DEPRECATED !!!! InitialValset is deprecated. Use provider.initial_val_set instead + InitialValSet []types1.ValidatorUpdate `protobuf:"bytes,8,rep,name=initial_val_set,json=initialValSet,proto3" json:"initial_val_set"` // Deprecated: Do not use. // HeightToValsetUpdateId nil on new chain, filled in on restart. HeightToValsetUpdateId []HeightToValsetUpdateID `protobuf:"bytes,9,rep,name=height_to_valset_update_id,json=heightToValsetUpdateId,proto3" json:"height_to_valset_update_id"` // OutstandingDowntimes nil on new chain, filled in on restart. OutstandingDowntimeSlashing []OutstandingDowntime `protobuf:"bytes,10,rep,name=outstanding_downtime_slashing,json=outstandingDowntimeSlashing,proto3" json:"outstanding_downtime_slashing"` // PendingConsumerPackets nil on new chain, filled in on restart. - PendingConsumerPackets types1.ConsumerPacketDataList `protobuf:"bytes,11,opt,name=pending_consumer_packets,json=pendingConsumerPackets,proto3" json:"pending_consumer_packets"` + PendingConsumerPackets ConsumerPacketDataList `protobuf:"bytes,11,opt,name=pending_consumer_packets,json=pendingConsumerPackets,proto3" json:"pending_consumer_packets"` // LastTransmissionBlockHeight nil on new chain, filled in on restart. LastTransmissionBlockHeight LastTransmissionBlockHeight `protobuf:"bytes,12,opt,name=last_transmission_block_height,json=lastTransmissionBlockHeight,proto3" json:"last_transmission_block_height"` - PreCCV bool `protobuf:"varint,13,opt,name=preCCV,proto3" json:"preCCV,omitempty"` + // flag indicating whether the consumer CCV module starts in pre-CCV state + PreCCV bool `protobuf:"varint,13,opt,name=preCCV,proto3" json:"preCCV,omitempty"` + Provider types.ProviderInfo `protobuf:"bytes,14,opt,name=provider,proto3" json:"provider"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -86,11 +97,11 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo -func (m *GenesisState) GetParams() Params { +func (m *GenesisState) GetParams() types.ConsumerParams { if m != nil { return m.Params } - return Params{} + return types.ConsumerParams{} } func (m *GenesisState) GetProviderClientId() string { @@ -114,6 +125,7 @@ func (m *GenesisState) GetNewChain() bool { return false } +// Deprecated: Do not use. func (m *GenesisState) GetProviderClientState() *_07_tendermint.ClientState { if m != nil { return m.ProviderClientState @@ -121,6 +133,7 @@ func (m *GenesisState) GetProviderClientState() *_07_tendermint.ClientState { return nil } +// Deprecated: Do not use. func (m *GenesisState) GetProviderConsensusState() *_07_tendermint.ConsensusState { if m != nil { return m.ProviderConsensusState @@ -135,7 +148,8 @@ func (m *GenesisState) GetMaturingPackets() []MaturingVSCPacket { return nil } -func (m *GenesisState) GetInitialValSet() []types.ValidatorUpdate { +// Deprecated: Do not use. +func (m *GenesisState) GetInitialValSet() []types1.ValidatorUpdate { if m != nil { return m.InitialValSet } @@ -156,11 +170,11 @@ func (m *GenesisState) GetOutstandingDowntimeSlashing() []OutstandingDowntime { return nil } -func (m *GenesisState) GetPendingConsumerPackets() types1.ConsumerPacketDataList { +func (m *GenesisState) GetPendingConsumerPackets() ConsumerPacketDataList { if m != nil { return m.PendingConsumerPackets } - return types1.ConsumerPacketDataList{} + return ConsumerPacketDataList{} } func (m *GenesisState) GetLastTransmissionBlockHeight() LastTransmissionBlockHeight { @@ -177,8 +191,15 @@ func (m *GenesisState) GetPreCCV() bool { return false } -// HeightValsetUpdateID defines the genesis information for the mapping -// of each block height to a valset update id +func (m *GenesisState) GetProvider() types.ProviderInfo { + if m != nil { + return m.Provider + } + return types.ProviderInfo{} +} + +// HeightValsetUpdateID represents a mapping internal to the consumer CCV module +// which links a block height to each recv valset update id. type HeightToValsetUpdateID struct { Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` ValsetUpdateId uint64 `protobuf:"varint,2,opt,name=valset_update_id,json=valsetUpdateId,proto3" json:"valset_update_id,omitempty"` @@ -231,8 +252,9 @@ func (m *HeightToValsetUpdateID) GetValsetUpdateId() uint64 { return 0 } -// OutstandingDowntime defines the genesis information for each validator -// flagged with an outstanding downtime slashing. +// OutstandingDowntime defines the type used internally to the consumer CCV +// module and is used in order to not send multiple slashing requests for +// the same downtime infraction. type OutstandingDowntime struct { ValidatorConsensusAddress string `protobuf:"bytes,1,opt,name=validator_consensus_address,json=validatorConsensusAddress,proto3" json:"validator_consensus_address,omitempty"` } @@ -277,10 +299,163 @@ func (m *OutstandingDowntime) GetValidatorConsensusAddress() string { return "" } +// LastTransmissionBlockHeight is the last time validator holding +// pools were transmitted to the provider chain. This type is used internally +// to the consumer CCV modul. +type LastTransmissionBlockHeight struct { + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *LastTransmissionBlockHeight) Reset() { *m = LastTransmissionBlockHeight{} } +func (m *LastTransmissionBlockHeight) String() string { return proto.CompactTextString(m) } +func (*LastTransmissionBlockHeight) ProtoMessage() {} +func (*LastTransmissionBlockHeight) Descriptor() ([]byte, []int) { + return fileDescriptor_2db73a6057a27482, []int{3} +} +func (m *LastTransmissionBlockHeight) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LastTransmissionBlockHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LastTransmissionBlockHeight.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 *LastTransmissionBlockHeight) XXX_Merge(src proto.Message) { + xxx_messageInfo_LastTransmissionBlockHeight.Merge(m, src) +} +func (m *LastTransmissionBlockHeight) XXX_Size() int { + return m.Size() +} +func (m *LastTransmissionBlockHeight) XXX_DiscardUnknown() { + xxx_messageInfo_LastTransmissionBlockHeight.DiscardUnknown(m) +} + +var xxx_messageInfo_LastTransmissionBlockHeight proto.InternalMessageInfo + +func (m *LastTransmissionBlockHeight) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// MaturingVSCPacket represents a vsc packet that is maturing internal to the +// consumer CCV module, where the consumer has not yet relayed a VSCMatured +// packet back to the provider. +type MaturingVSCPacket struct { + VscId uint64 `protobuf:"varint,1,opt,name=vscId,proto3" json:"vscId,omitempty"` + MaturityTime time.Time `protobuf:"bytes,2,opt,name=maturity_time,json=maturityTime,proto3,stdtime" json:"maturity_time"` +} + +func (m *MaturingVSCPacket) Reset() { *m = MaturingVSCPacket{} } +func (m *MaturingVSCPacket) String() string { return proto.CompactTextString(m) } +func (*MaturingVSCPacket) ProtoMessage() {} +func (*MaturingVSCPacket) Descriptor() ([]byte, []int) { + return fileDescriptor_2db73a6057a27482, []int{4} +} +func (m *MaturingVSCPacket) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MaturingVSCPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MaturingVSCPacket.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 *MaturingVSCPacket) XXX_Merge(src proto.Message) { + xxx_messageInfo_MaturingVSCPacket.Merge(m, src) +} +func (m *MaturingVSCPacket) XXX_Size() int { + return m.Size() +} +func (m *MaturingVSCPacket) XXX_DiscardUnknown() { + xxx_messageInfo_MaturingVSCPacket.DiscardUnknown(m) +} + +var xxx_messageInfo_MaturingVSCPacket proto.InternalMessageInfo + +func (m *MaturingVSCPacket) GetVscId() uint64 { + if m != nil { + return m.VscId + } + return 0 +} + +func (m *MaturingVSCPacket) GetMaturityTime() time.Time { + if m != nil { + return m.MaturityTime + } + return time.Time{} +} + +// ConsumerPacketDataList is a list of consumer packet data packets. +// +// Note this type is used internally to the consumer CCV module +// for exporting / importing state in InitGenesis and ExportGenesis. +type ConsumerPacketDataList struct { + List []types.ConsumerPacketData `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` +} + +func (m *ConsumerPacketDataList) Reset() { *m = ConsumerPacketDataList{} } +func (m *ConsumerPacketDataList) String() string { return proto.CompactTextString(m) } +func (*ConsumerPacketDataList) ProtoMessage() {} +func (*ConsumerPacketDataList) Descriptor() ([]byte, []int) { + return fileDescriptor_2db73a6057a27482, []int{5} +} +func (m *ConsumerPacketDataList) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsumerPacketDataList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsumerPacketDataList.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 *ConsumerPacketDataList) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsumerPacketDataList.Merge(m, src) +} +func (m *ConsumerPacketDataList) XXX_Size() int { + return m.Size() +} +func (m *ConsumerPacketDataList) XXX_DiscardUnknown() { + xxx_messageInfo_ConsumerPacketDataList.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsumerPacketDataList proto.InternalMessageInfo + +func (m *ConsumerPacketDataList) GetList() []types.ConsumerPacketData { + if m != nil { + return m.List + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "interchain_security.ccv.consumer.v1.GenesisState") proto.RegisterType((*HeightToValsetUpdateID)(nil), "interchain_security.ccv.consumer.v1.HeightToValsetUpdateID") proto.RegisterType((*OutstandingDowntime)(nil), "interchain_security.ccv.consumer.v1.OutstandingDowntime") + proto.RegisterType((*LastTransmissionBlockHeight)(nil), "interchain_security.ccv.consumer.v1.LastTransmissionBlockHeight") + proto.RegisterType((*MaturingVSCPacket)(nil), "interchain_security.ccv.consumer.v1.MaturingVSCPacket") + proto.RegisterType((*ConsumerPacketDataList)(nil), "interchain_security.ccv.consumer.v1.ConsumerPacketDataList") } func init() { @@ -288,57 +463,64 @@ func init() { } var fileDescriptor_2db73a6057a27482 = []byte{ - // 786 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x55, 0x4b, 0x8f, 0xe3, 0x34, - 0x1c, 0x6f, 0x76, 0x87, 0xd2, 0x7a, 0x76, 0xd9, 0xc1, 0x03, 0x55, 0x68, 0x45, 0x28, 0x03, 0x87, - 0x4a, 0x40, 0xac, 0x76, 0x25, 0x84, 0x84, 0x40, 0x30, 0x1d, 0x09, 0x2a, 0x2d, 0xb0, 0x6a, 0x77, - 0x8b, 0xb4, 0x97, 0xc8, 0x75, 0x4c, 0x62, 0x6d, 0x62, 0x47, 0xb6, 0x93, 0x61, 0x0f, 0x5c, 0xb8, - 0x72, 0xe1, 0x63, 0xed, 0x71, 0x8f, 0x9c, 0x10, 0x9a, 0xf9, 0x0e, 0x9c, 0x51, 0x6c, 0xa7, 0x0f, - 0xa6, 0xa3, 0xed, 0x29, 0x71, 0xfe, 0xbf, 0xc7, 0xff, 0xe1, 0xd8, 0x60, 0xcc, 0xb8, 0xa6, 0x92, - 0xa4, 0x98, 0xf1, 0x48, 0x51, 0x52, 0x4a, 0xa6, 0x5f, 0x20, 0x42, 0x2a, 0x44, 0x04, 0x57, 0x65, - 0x4e, 0x25, 0xaa, 0xc6, 0x28, 0xa1, 0x9c, 0x2a, 0xa6, 0xc2, 0x42, 0x0a, 0x2d, 0xe0, 0x47, 0x7b, - 0x28, 0x21, 0x21, 0x55, 0xd8, 0x50, 0xc2, 0x6a, 0xdc, 0xff, 0xf8, 0x36, 0xdd, 0x6a, 0x5c, 0x3f, - 0xac, 0x54, 0x7f, 0x72, 0x88, 0xfb, 0x5a, 0xd6, 0x72, 0x06, 0x9a, 0xf2, 0x98, 0xca, 0x9c, 0x71, - 0x8d, 0xf0, 0x8a, 0x30, 0xa4, 0x5f, 0x14, 0xd4, 0xe5, 0xd6, 0x47, 0x6c, 0x45, 0x50, 0xc6, 0x92, - 0x54, 0x93, 0x8c, 0x51, 0xae, 0x15, 0xda, 0x42, 0x57, 0xe3, 0xad, 0x95, 0x23, 0x7c, 0x58, 0x13, - 0x88, 0x90, 0x14, 0x91, 0x14, 0x73, 0x4e, 0x33, 0xe3, 0x68, 0x5f, 0x1d, 0x24, 0x48, 0x84, 0x48, - 0x32, 0x8a, 0xcc, 0x6a, 0x55, 0xfe, 0x82, 0xe2, 0x52, 0x62, 0xcd, 0x04, 0x77, 0xf1, 0x77, 0x12, - 0x91, 0x08, 0xf3, 0x8a, 0xea, 0x37, 0xfb, 0xf5, 0xec, 0xdf, 0x0e, 0xb8, 0xf7, 0x9d, 0xed, 0xdb, - 0x42, 0x63, 0x4d, 0xe1, 0x0c, 0xb4, 0x0b, 0x2c, 0x71, 0xae, 0x7c, 0x6f, 0xe8, 0x8d, 0x8e, 0x27, - 0x9f, 0x84, 0x07, 0xf4, 0x31, 0x7c, 0x6c, 0x28, 0xe7, 0x47, 0x2f, 0xff, 0xfe, 0xa0, 0x35, 0x77, - 0x02, 0xf0, 0x53, 0x00, 0x0b, 0x29, 0x2a, 0x16, 0x53, 0x19, 0xd9, 0x3a, 0x23, 0x16, 0xfb, 0x77, - 0x86, 0xde, 0xa8, 0x3b, 0x3f, 0x69, 0x22, 0x53, 0x13, 0x98, 0xc5, 0x30, 0x04, 0xa7, 0x1b, 0xb4, - 0xad, 0xac, 0x86, 0xdf, 0x35, 0xf0, 0xb7, 0xd7, 0x70, 0x1b, 0x99, 0xc5, 0x70, 0x00, 0xba, 0x9c, - 0x5e, 0x46, 0x26, 0x31, 0xff, 0x68, 0xe8, 0x8d, 0x3a, 0xf3, 0x0e, 0xa7, 0x97, 0xd3, 0x7a, 0x0d, - 0x23, 0xf0, 0xee, 0xff, 0xad, 0x55, 0x5d, 0x9e, 0xff, 0x46, 0x53, 0xd4, 0x8a, 0x84, 0xdb, 0x03, - 0x08, 0xb7, 0x5a, 0x5e, 0x8d, 0x43, 0x9b, 0x95, 0xe9, 0xc8, 0xfc, 0x74, 0x37, 0x55, 0xdb, 0xa6, - 0x14, 0xf8, 0x1b, 0x03, 0xc1, 0x15, 0xe5, 0xaa, 0x54, 0xce, 0xa3, 0x6d, 0x3c, 0xc2, 0xd7, 0x7a, - 0x34, 0x34, 0x6b, 0xd3, 0x5b, 0xdb, 0xec, 0x7c, 0x87, 0x09, 0x38, 0xc9, 0xb1, 0x2e, 0x25, 0xe3, - 0x49, 0x54, 0x60, 0xf2, 0x9c, 0x6a, 0xe5, 0xbf, 0x39, 0xbc, 0x3b, 0x3a, 0x9e, 0x7c, 0x7e, 0xd0, - 0x68, 0x7e, 0x70, 0xe4, 0xe5, 0x62, 0xfa, 0xd8, 0xd0, 0xdd, 0x94, 0x1e, 0x34, 0xaa, 0xf6, 0xab, - 0x82, 0x3f, 0x82, 0x07, 0x8c, 0x33, 0xcd, 0x70, 0x16, 0x55, 0x38, 0x8b, 0x14, 0xd5, 0x7e, 0xc7, - 0xf8, 0x0c, 0xb7, 0x13, 0xaf, 0xf7, 0x72, 0xb8, 0xc4, 0x19, 0x8b, 0xb1, 0x16, 0xf2, 0x69, 0x11, - 0x63, 0x4d, 0x9d, 0xe2, 0x7d, 0x47, 0x5f, 0xe2, 0x6c, 0x41, 0x35, 0xfc, 0x0d, 0xf4, 0x53, 0x5a, - 0x97, 0x1f, 0x69, 0x51, 0x2b, 0x2a, 0xaa, 0xa3, 0xd2, 0xe0, 0xeb, 0xb9, 0x76, 0x8d, 0xf4, 0x97, - 0x07, 0x95, 0xf0, 0xbd, 0x91, 0x79, 0x22, 0x96, 0x46, 0xc4, 0x7a, 0xce, 0x2e, 0x9c, 0x6b, 0x2f, - 0xdd, 0x17, 0x8d, 0xe1, 0xef, 0x1e, 0x78, 0x5f, 0x94, 0x5a, 0x69, 0xcc, 0xe3, 0xba, 0x77, 0xb1, - 0xb8, 0xe4, 0x9a, 0xe5, 0x34, 0x52, 0x19, 0x56, 0x29, 0xe3, 0x89, 0x0f, 0x4c, 0x0a, 0x5f, 0x1c, - 0x94, 0xc2, 0x4f, 0x1b, 0xa5, 0x0b, 0x27, 0xe4, 0xfc, 0x07, 0xe2, 0x66, 0x68, 0xe1, 0x2c, 0xa0, - 0x04, 0x7e, 0x41, 0xad, 0x7f, 0xa3, 0xb6, 0x1e, 0xe2, 0xb1, 0xd9, 0x26, 0x93, 0x5b, 0xed, 0xdd, - 0x16, 0xa9, 0x39, 0x76, 0x44, 0x17, 0x58, 0xe3, 0x47, 0x4c, 0x35, 0x03, 0xec, 0x39, 0xe5, 0x5d, - 0x90, 0x82, 0x7f, 0x78, 0x20, 0xc8, 0xb0, 0xd2, 0x91, 0x96, 0x98, 0xab, 0x9c, 0x29, 0xc5, 0x04, - 0x8f, 0x56, 0x99, 0x20, 0xcf, 0x23, 0xdb, 0x2b, 0xff, 0x9e, 0xb1, 0xfe, 0xe6, 0xa0, 0xca, 0x1f, - 0x61, 0xa5, 0x9f, 0x6c, 0x29, 0x9d, 0xd7, 0x42, 0x76, 0x22, 0x4d, 0x07, 0xb2, 0xdb, 0x21, 0xb0, - 0x07, 0xda, 0x85, 0xa4, 0xd3, 0xe9, 0xd2, 0xbf, 0x6f, 0xfe, 0x51, 0xb7, 0x3a, 0x7b, 0x06, 0x7a, - 0xfb, 0xc7, 0x5a, 0x33, 0x5c, 0x9a, 0xf5, 0x09, 0x74, 0x34, 0x77, 0x2b, 0x38, 0x02, 0x27, 0x37, - 0x76, 0xd1, 0x1d, 0x83, 0x78, 0xab, 0xda, 0x19, 0xfd, 0xd9, 0x53, 0x70, 0xba, 0x67, 0x5e, 0xf0, - 0x6b, 0x30, 0xa8, 0x9a, 0x8d, 0xbb, 0xf5, 0xd3, 0xe2, 0x38, 0x96, 0x54, 0xd9, 0xf3, 0xae, 0x3b, - 0x7f, 0x6f, 0x0d, 0x59, 0xff, 0x87, 0xdf, 0x5a, 0xc0, 0xf9, 0xcf, 0x2f, 0xaf, 0x02, 0xef, 0xd5, - 0x55, 0xe0, 0xfd, 0x73, 0x15, 0x78, 0x7f, 0x5e, 0x07, 0xad, 0x57, 0xd7, 0x41, 0xeb, 0xaf, 0xeb, - 0xa0, 0xf5, 0xec, 0xab, 0x84, 0xe9, 0xb4, 0x5c, 0x85, 0x44, 0xe4, 0x88, 0x08, 0x95, 0x0b, 0x85, - 0x36, 0xad, 0xfd, 0x6c, 0x7d, 0x65, 0x54, 0x0f, 0xd1, 0xaf, 0xbb, 0xf7, 0x86, 0xb9, 0x14, 0x56, - 0x6d, 0x73, 0x16, 0x3f, 0xfc, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x8e, 0xd4, 0xcb, 0xc1, 0xe6, 0x06, - 0x00, 0x00, + // 912 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0xcf, 0x6f, 0x23, 0x35, + 0x14, 0xee, 0xb4, 0xdd, 0x90, 0xb8, 0xed, 0x6e, 0xd7, 0x5d, 0xa2, 0xa1, 0x11, 0x69, 0x14, 0x84, + 0x14, 0xf1, 0xc3, 0x43, 0xba, 0x02, 0x21, 0x21, 0x10, 0x24, 0x95, 0x68, 0x50, 0x11, 0x55, 0xda, + 0x0d, 0xd2, 0x5e, 0x46, 0x8e, 0xc7, 0x3b, 0xb1, 0x76, 0xc6, 0x1e, 0x8d, 0x9d, 0x09, 0x15, 0xe2, + 0xc2, 0x95, 0xcb, 0xfe, 0x59, 0x7b, 0xdc, 0x03, 0x07, 0x4e, 0x80, 0xda, 0x7f, 0x04, 0xd9, 0xe3, + 0x99, 0x24, 0x34, 0xed, 0xe6, 0x16, 0xcf, 0x7b, 0xef, 0xfb, 0xde, 0xfb, 0xde, 0x7b, 0x76, 0x40, + 0x97, 0x71, 0x45, 0x53, 0x32, 0xc1, 0x8c, 0xfb, 0x92, 0x92, 0x69, 0xca, 0xd4, 0x95, 0x47, 0x48, + 0xe6, 0x11, 0xc1, 0xe5, 0x34, 0xa6, 0xa9, 0x97, 0x75, 0xbd, 0x90, 0x72, 0x2a, 0x99, 0x44, 0x49, + 0x2a, 0x94, 0x80, 0x1f, 0xac, 0x08, 0x41, 0x84, 0x64, 0xa8, 0x08, 0x41, 0x59, 0xf7, 0xf0, 0xb3, + 0xbb, 0x70, 0xb3, 0xae, 0x27, 0x27, 0x38, 0xa5, 0x81, 0x5f, 0xba, 0x1b, 0xd8, 0x43, 0x8f, 0x8d, + 0x89, 0x17, 0xb1, 0x70, 0xa2, 0x48, 0xc4, 0x28, 0x57, 0xd2, 0x53, 0x94, 0x07, 0x34, 0x8d, 0x19, + 0x57, 0x3a, 0x6a, 0x7e, 0xb2, 0x01, 0x4f, 0x42, 0x11, 0x0a, 0xf3, 0xd3, 0xd3, 0xbf, 0xec, 0xd7, + 0x0f, 0xef, 0x21, 0x9e, 0xb1, 0x94, 0x5a, 0xb7, 0xa3, 0x50, 0x88, 0x30, 0xa2, 0x9e, 0x39, 0x8d, + 0xa7, 0x2f, 0x3c, 0xc5, 0x62, 0x2a, 0x15, 0x8e, 0x13, 0xeb, 0xd0, 0x58, 0x60, 0xc7, 0x63, 0xc2, + 0x3c, 0x75, 0x95, 0x50, 0x2b, 0x41, 0xfb, 0xcf, 0x1a, 0xd8, 0xfd, 0x3e, 0x17, 0xe5, 0x42, 0x61, + 0x45, 0xe1, 0x29, 0xa8, 0x24, 0x38, 0xc5, 0xb1, 0x74, 0x9d, 0x96, 0xd3, 0xd9, 0x39, 0xfe, 0x08, + 0xdd, 0x25, 0x52, 0xd6, 0x45, 0x7d, 0x5b, 0xf8, 0xb9, 0x89, 0xe8, 0x6d, 0xbf, 0xfe, 0xfb, 0x68, + 0x63, 0x68, 0xe3, 0xe1, 0x27, 0x00, 0x26, 0xa9, 0xc8, 0x58, 0x40, 0x53, 0x3f, 0x17, 0xc2, 0x67, + 0x81, 0xbb, 0xd9, 0x72, 0x3a, 0xb5, 0xe1, 0x7e, 0x61, 0xe9, 0x1b, 0xc3, 0x20, 0x80, 0x08, 0x1c, + 0xcc, 0xbd, 0x27, 0x98, 0x73, 0x1a, 0x69, 0xf7, 0x2d, 0xe3, 0xfe, 0xb8, 0x74, 0xcf, 0x2d, 0x83, + 0x00, 0x36, 0x40, 0x8d, 0xd3, 0x99, 0x6f, 0xf2, 0x72, 0xb7, 0x5b, 0x4e, 0xa7, 0x3a, 0xac, 0x72, + 0x3a, 0xeb, 0xeb, 0x33, 0x24, 0xe0, 0xdd, 0xff, 0x53, 0x4b, 0x5d, 0x9d, 0xfb, 0xc0, 0xd4, 0xf4, + 0x31, 0x62, 0x63, 0x82, 0x16, 0x3b, 0x84, 0x16, 0x7a, 0xa2, 0xeb, 0x32, 0x5f, 0x8d, 0x20, 0xbd, + 0x4d, 0xd7, 0x19, 0x1e, 0x2c, 0xa7, 0x9b, 0x2b, 0x15, 0x01, 0x77, 0x4e, 0x22, 0xb8, 0xa4, 0x5c, + 0x4e, 0xa5, 0xe5, 0xa9, 0x18, 0x1e, 0xf4, 0x56, 0x9e, 0x22, 0x6c, 0x4e, 0x55, 0x2f, 0xa9, 0x96, + 0x6c, 0x30, 0x04, 0xfb, 0x31, 0x56, 0xd3, 0x94, 0xf1, 0xd0, 0x4f, 0x30, 0x79, 0x49, 0x95, 0x74, + 0xdf, 0x69, 0x6d, 0x75, 0x76, 0x8e, 0xbf, 0x40, 0x6b, 0x8c, 0x31, 0xfa, 0xd1, 0x06, 0x8f, 0x2e, + 0xfa, 0xe7, 0x26, 0xdc, 0x76, 0xeb, 0x51, 0x81, 0x9a, 0x7f, 0x95, 0xf0, 0x1c, 0x3c, 0x62, 0x9c, + 0x29, 0x86, 0x23, 0x3f, 0xc3, 0x91, 0x2f, 0xa9, 0x72, 0xab, 0x86, 0xa7, 0xb5, 0x98, 0xbc, 0x1e, + 0x24, 0x34, 0xc2, 0x11, 0x0b, 0xb0, 0x12, 0xe9, 0xb3, 0x24, 0xd0, 0xf9, 0x57, 0x34, 0xa2, 0xeb, + 0x0c, 0xf7, 0x2c, 0xc0, 0x08, 0x47, 0x17, 0x54, 0xc1, 0xdf, 0xc0, 0xe1, 0x84, 0x6a, 0x11, 0x7c, + 0x25, 0x34, 0xa6, 0xa4, 0xca, 0x9f, 0x9a, 0x08, 0xdd, 0xe1, 0x9a, 0x01, 0xff, 0x6a, 0xad, 0x22, + 0x4e, 0x0d, 0xcc, 0xa5, 0x18, 0x19, 0x90, 0x9c, 0x75, 0x70, 0x62, 0x2b, 0xa9, 0x4f, 0x56, 0x59, + 0x03, 0xf8, 0xbb, 0x03, 0xde, 0x17, 0x53, 0x25, 0x15, 0xe6, 0x81, 0x56, 0x2f, 0x10, 0x33, 0xae, + 0x77, 0xc4, 0x97, 0x11, 0x96, 0x13, 0xc6, 0x43, 0x17, 0x98, 0x14, 0xbe, 0x5c, 0x2b, 0x85, 0x9f, + 0xe6, 0x48, 0x27, 0x16, 0xc8, 0xf2, 0x37, 0xc4, 0x6d, 0xd3, 0x85, 0xa5, 0x80, 0xbf, 0x02, 0x37, + 0xa1, 0x39, 0x7f, 0x81, 0x56, 0xb6, 0x71, 0xc7, 0x0c, 0xcb, 0x7a, 0x0a, 0xcc, 0x37, 0x4e, 0xc7, + 0x9e, 0x60, 0x85, 0xcf, 0x98, 0x2c, 0x7a, 0x59, 0xb7, 0x14, 0xcb, 0x4e, 0x12, 0xfe, 0xe1, 0x80, + 0x66, 0x84, 0xa5, 0xf2, 0x55, 0x8a, 0xb9, 0x8c, 0x99, 0x94, 0x4c, 0x70, 0x7f, 0x1c, 0x09, 0xf2, + 0xd2, 0xcf, 0x45, 0x73, 0x77, 0x4d, 0x0e, 0xdf, 0xae, 0x95, 0xc3, 0x19, 0x96, 0xea, 0x72, 0x01, + 0xa9, 0xa7, 0x81, 0xf2, 0xd6, 0x14, 0x52, 0x44, 0x77, 0xbb, 0xc0, 0x3a, 0xa8, 0x24, 0x29, 0xed, + 0xf7, 0x47, 0xee, 0x9e, 0x59, 0x5b, 0x7b, 0x82, 0x3f, 0x80, 0x6a, 0x31, 0xfb, 0xee, 0x43, 0x93, + 0x4e, 0xe7, 0xbe, 0xbb, 0xe7, 0xdc, 0xfa, 0x0e, 0xf8, 0x0b, 0x61, 0x69, 0xcb, 0xf8, 0xf6, 0x73, + 0x50, 0x5f, 0x3d, 0x2b, 0x9a, 0xdd, 0x96, 0xac, 0xef, 0xb7, 0xed, 0xa1, 0x3d, 0xc1, 0x0e, 0xd8, + 0xbf, 0x35, 0x9a, 0x9b, 0xc6, 0xe3, 0x61, 0xb6, 0x34, 0x4f, 0xed, 0x67, 0xe0, 0x60, 0xc5, 0x10, + 0xc0, 0x6f, 0x40, 0x23, 0x2b, 0xf6, 0x61, 0xe1, 0x3e, 0xc0, 0x41, 0x90, 0x52, 0x99, 0xdf, 0xa6, + 0xb5, 0xe1, 0x7b, 0xa5, 0x4b, 0xb9, 0xde, 0xdf, 0xe5, 0x0e, 0xed, 0xcf, 0x41, 0xe3, 0xec, 0x7e, + 0xd5, 0x16, 0xf2, 0xde, 0x2a, 0xf2, 0x6e, 0x2b, 0xf0, 0xf8, 0xd6, 0x6a, 0xc3, 0x27, 0xe0, 0x41, + 0x26, 0xc9, 0x20, 0xb0, 0x35, 0xe6, 0x07, 0x38, 0x00, 0x7b, 0xf9, 0xb2, 0xab, 0x2b, 0x5f, 0xa7, + 0x6c, 0xea, 0xdb, 0x39, 0x3e, 0x44, 0xf9, 0x0b, 0x82, 0x8a, 0x17, 0x04, 0x5d, 0x16, 0x2f, 0x48, + 0xaf, 0xaa, 0x75, 0x7d, 0xf5, 0xcf, 0x91, 0x33, 0xdc, 0x2d, 0x42, 0xb5, 0xb1, 0x3d, 0x06, 0xf5, + 0xd5, 0x93, 0x08, 0x4f, 0xc1, 0x76, 0xc4, 0xa4, 0xce, 0x72, 0x2b, 0xbf, 0x01, 0xd7, 0x79, 0x3d, + 0x0a, 0x04, 0xdb, 0x47, 0x83, 0xd0, 0xfb, 0xf9, 0xf5, 0x75, 0xd3, 0x79, 0x73, 0xdd, 0x74, 0xfe, + 0xbd, 0x6e, 0x3a, 0xaf, 0x6e, 0x9a, 0x1b, 0x6f, 0x6e, 0x9a, 0x1b, 0x7f, 0xdd, 0x34, 0x37, 0x9e, + 0x7f, 0x1d, 0x32, 0x35, 0x99, 0x8e, 0x11, 0x11, 0xb1, 0x47, 0x84, 0x8c, 0x85, 0xf4, 0xe6, 0x34, + 0x9f, 0x96, 0x6f, 0x65, 0xf6, 0xd4, 0xfb, 0x65, 0xf9, 0x1f, 0x80, 0x79, 0xf9, 0xc6, 0x15, 0x53, + 0xe8, 0xd3, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0xc9, 0x08, 0x63, 0x8d, 0x32, 0x08, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -361,6 +543,16 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size, err := m.Provider.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x72 if m.PreCCV { i-- if m.PreCCV { @@ -571,6 +763,107 @@ func (m *OutstandingDowntime) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *LastTransmissionBlockHeight) 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 *LastTransmissionBlockHeight) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LastTransmissionBlockHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *MaturingVSCPacket) 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 *MaturingVSCPacket) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MaturingVSCPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n7, err7 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.MaturityTime, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.MaturityTime):]) + if err7 != nil { + return 0, err7 + } + i -= n7 + i = encodeVarintGenesis(dAtA, i, uint64(n7)) + i-- + dAtA[i] = 0x12 + if m.VscId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.VscId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ConsumerPacketDataList) 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 *ConsumerPacketDataList) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerPacketDataList) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.List) > 0 { + for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.List[iNdEx].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 encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -640,6 +933,8 @@ func (m *GenesisState) Size() (n int) { if m.PreCCV { n += 2 } + l = m.Provider.Size() + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -671,6 +966,47 @@ func (m *OutstandingDowntime) Size() (n int) { return n } +func (m *LastTransmissionBlockHeight) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovGenesis(uint64(m.Height)) + } + return n +} + +func (m *MaturingVSCPacket) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.VscId != 0 { + n += 1 + sovGenesis(uint64(m.VscId)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.MaturityTime) + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *ConsumerPacketDataList) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.List) > 0 { + for _, e := range m.List { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -958,7 +1294,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.InitialValSet = append(m.InitialValSet, types.ValidatorUpdate{}) + m.InitialValSet = append(m.InitialValSet, types1.ValidatorUpdate{}) if err := m.InitialValSet[len(m.InitialValSet)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1117,6 +1453,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } } m.PreCCV = bool(v != 0) + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Provider", 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.Provider.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -1308,6 +1677,261 @@ func (m *OutstandingDowntime) Unmarshal(dAtA []byte) error { } return nil } +func (m *LastTransmissionBlockHeight) 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: LastTransmissionBlockHeight: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LastTransmissionBlockHeight: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= 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 (m *MaturingVSCPacket) 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: MaturingVSCPacket: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MaturingVSCPacket: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field VscId", wireType) + } + m.VscId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.VscId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaturityTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.MaturityTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConsumerPacketDataList) 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: ConsumerPacketDataList: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsumerPacketDataList: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field List", 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.List = append(m.List, types.ConsumerPacketData{}) + if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/consumer/types/genesis_test.go b/x/ccv/consumer/types/genesis_test.go index 2f4b2fa504..d8a8296762 100644 --- a/x/ccv/consumer/types/genesis_test.go +++ b/x/ccv/consumer/types/genesis_test.go @@ -48,7 +48,7 @@ func TestValidateInitialGenesisState(t *testing.T) { cs := ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath) consensusState := ibctmtypes.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("apphash")), valHash) - params := types.DefaultParams() + params := ccv.DefaultParams() params.Enabled = true cases := []struct { @@ -86,95 +86,105 @@ func TestValidateInitialGenesisState(t *testing.T) { { "invalid new consumer genesis state: client id not empty", &types.GenesisState{ - params, - "ccvclient", - "", - true, - cs, - consensusState, - nil, - valUpdates, - nil, - nil, - ccv.ConsumerPacketDataList{}, - types.LastTransmissionBlockHeight{}, - false, + Params: params, + ProviderClientId: "ccvclient", + ProviderChannelId: "", + NewChain: true, + Provider: ccv.ProviderInfo{ + ClientState: cs, + ConsensusState: consensusState, + InitialValSet: valUpdates, + }, + MaturingPackets: nil, + HeightToValsetUpdateId: nil, + OutstandingDowntimeSlashing: nil, + PendingConsumerPackets: types.ConsumerPacketDataList{}, + LastTransmissionBlockHeight: types.LastTransmissionBlockHeight{}, + PreCCV: false, }, true, }, { "invalid new consumer genesis state: channel id not empty", &types.GenesisState{ - params, - "", - "ccvchannel", - true, - cs, - consensusState, - nil, - valUpdates, - nil, - nil, - ccv.ConsumerPacketDataList{}, - types.LastTransmissionBlockHeight{}, - false, + Params: params, + ProviderClientId: "", + ProviderChannelId: "ccvchannel", + NewChain: true, + Provider: ccv.ProviderInfo{ + ClientState: cs, + ConsensusState: consensusState, + InitialValSet: valUpdates, + }, + MaturingPackets: nil, + HeightToValsetUpdateId: nil, + OutstandingDowntimeSlashing: nil, + PendingConsumerPackets: types.ConsumerPacketDataList{}, + LastTransmissionBlockHeight: types.LastTransmissionBlockHeight{}, + PreCCV: false, }, true, }, { "invalid new consumer genesis state: non-empty unbonding sequences", &types.GenesisState{ - params, - "", - "", - true, - cs, - consensusState, - []types.MaturingVSCPacket{{}}, - valUpdates, - nil, - nil, - ccv.ConsumerPacketDataList{}, - types.LastTransmissionBlockHeight{}, - false, + Params: params, + ProviderClientId: "", + ProviderChannelId: "", + NewChain: true, + Provider: ccv.ProviderInfo{ + ClientState: cs, + ConsensusState: consensusState, + InitialValSet: valUpdates, + }, + MaturingPackets: []types.MaturingVSCPacket{{}}, + HeightToValsetUpdateId: nil, + OutstandingDowntimeSlashing: nil, + PendingConsumerPackets: types.ConsumerPacketDataList{}, + LastTransmissionBlockHeight: types.LastTransmissionBlockHeight{}, + PreCCV: false, }, true, }, { "invalid new consumer genesis state: non-empty last transmission packet", &types.GenesisState{ - params, - "", - "", - true, - cs, - consensusState, - nil, - valUpdates, - nil, - nil, - ccv.ConsumerPacketDataList{}, - types.LastTransmissionBlockHeight{Height: 1}, - false, + Params: params, + ProviderClientId: "", + ProviderChannelId: "", + NewChain: true, + Provider: ccv.ProviderInfo{ + ClientState: cs, + ConsensusState: consensusState, + InitialValSet: valUpdates, + }, + MaturingPackets: nil, + HeightToValsetUpdateId: nil, + OutstandingDowntimeSlashing: nil, + PendingConsumerPackets: types.ConsumerPacketDataList{}, + LastTransmissionBlockHeight: types.LastTransmissionBlockHeight{Height: 1}, + PreCCV: false, }, true, }, { "invalid new consumer genesis state: non-empty pending consumer packets", &types.GenesisState{ - params, - "", - "", - true, - cs, - consensusState, - nil, - valUpdates, - nil, - nil, - ccv.ConsumerPacketDataList{List: []ccv.ConsumerPacketData{{}}}, - types.LastTransmissionBlockHeight{}, - false, + Params: params, + ProviderClientId: "", + ProviderChannelId: "", + NewChain: true, + Provider: ccv.ProviderInfo{ + ClientState: cs, + ConsensusState: consensusState, + InitialValSet: valUpdates, + }, + MaturingPackets: nil, + HeightToValsetUpdateId: nil, + OutstandingDowntimeSlashing: nil, + PendingConsumerPackets: types.ConsumerPacketDataList{List: []ccv.ConsumerPacketData{{}}}, + LastTransmissionBlockHeight: types.LastTransmissionBlockHeight{}, + PreCCV: false, }, true, }, @@ -210,38 +220,40 @@ func TestValidateInitialGenesisState(t *testing.T) { { "invalid new consumer genesis state: invalid params - ccvTimeoutPeriod", types.NewInitialGenesisState(cs, consensusState, valUpdates, - types.NewParams( + ccv.NewParams( true, - types.DefaultBlocksPerDistributionTransmission, + ccv.DefaultBlocksPerDistributionTransmission, "", "", 0, // CCV timeout period cannot be 0 - types.DefaultTransferTimeoutPeriod, - types.DefaultConsumerRedistributeFrac, - types.DefaultHistoricalEntries, - types.DefaultConsumerUnbondingPeriod, - types.DefaultSoftOptOutThreshold, + ccv.DefaultTransferTimeoutPeriod, + ccv.DefaultConsumerRedistributeFrac, + ccv.DefaultHistoricalEntries, + ccv.DefaultConsumerUnbondingPeriod, + ccv.DefaultSoftOptOutThreshold, []string{}, []string{}, + ccv.DefaultRetryDelayPeriod, )), true, }, { "invalid new consumer genesis state: invalid params - distributionTransmissionChannel", types.NewInitialGenesisState(cs, consensusState, valUpdates, - types.NewParams( + ccv.NewParams( true, - types.DefaultBlocksPerDistributionTransmission, + ccv.DefaultBlocksPerDistributionTransmission, "badchannel/", "", ccv.DefaultCCVTimeoutPeriod, - types.DefaultTransferTimeoutPeriod, - types.DefaultConsumerRedistributeFrac, - types.DefaultHistoricalEntries, - types.DefaultConsumerUnbondingPeriod, - types.DefaultSoftOptOutThreshold, + ccv.DefaultTransferTimeoutPeriod, + ccv.DefaultConsumerRedistributeFrac, + ccv.DefaultHistoricalEntries, + ccv.DefaultConsumerUnbondingPeriod, + ccv.DefaultSoftOptOutThreshold, []string{}, []string{}, + ccv.DefaultRetryDelayPeriod, )), true, }, @@ -257,9 +269,9 @@ func TestValidateInitialGenesisState(t *testing.T) { } } -// TestValidateRestartGenesisState tests a NewRestartGenesisState instantiation, +// TestValidateRestartConsumerGenesisState tests a NewRestartGenesisState instantiation, // and its Validate() method over different genesis scenarios -func TestValidateRestartGenesisState(t *testing.T) { +func TestValidateRestartConsumerGenesisState(t *testing.T) { // generate validator private/public key cId := crypto.NewCryptoIdentityFromIntSeed(234234) pubKey := cId.TMCryptoPubKey() @@ -295,7 +307,7 @@ func TestValidateRestartGenesisState(t *testing.T) { cs := ibctmtypes.NewClientState(chainID, ibctmtypes.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath) consensusState := ibctmtypes.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("apphash")), valHash) - params := types.DefaultParams() + params := ccv.DefaultParams() params.Enabled = true cases := []struct { @@ -306,118 +318,122 @@ func TestValidateRestartGenesisState(t *testing.T) { { "valid restart consumer genesis state: empty maturing packets", types.NewRestartGenesisState("ccvclient", "ccvchannel", nil, valUpdates, heightToValsetUpdateID, - ccv.ConsumerPacketDataList{List: []ccv.ConsumerPacketData{matConsumerPacket, slashConsumerPacket}}, + types.ConsumerPacketDataList{List: []ccv.ConsumerPacketData{matConsumerPacket, slashConsumerPacket}}, nil, types.LastTransmissionBlockHeight{Height: 100}, params), false, }, { "valid restart consumer genesis state: handshake in progress ", types.NewRestartGenesisState("ccvclient", "", nil, valUpdates, heightToValsetUpdateID, - ccv.ConsumerPacketDataList{List: []ccv.ConsumerPacketData{slashConsumerPacket}}, nil, types.LastTransmissionBlockHeight{}, params), + types.ConsumerPacketDataList{List: []ccv.ConsumerPacketData{slashConsumerPacket}}, nil, types.LastTransmissionBlockHeight{}, params), false, }, { "valid restart consumer genesis state: maturing packets", types.NewRestartGenesisState("ccvclient", "ccvchannel", []types.MaturingVSCPacket{ - {1, time.Now().UTC()}, - {3, time.Now().UTC()}, - {5, time.Now().UTC()}, - }, valUpdates, heightToValsetUpdateID, ccv.ConsumerPacketDataList{}, + {VscId: 1, MaturityTime: time.Now().UTC()}, + {VscId: 3, MaturityTime: time.Now().UTC()}, + {VscId: 5, MaturityTime: time.Now().UTC()}, + }, valUpdates, heightToValsetUpdateID, types.ConsumerPacketDataList{}, []types.OutstandingDowntime{{ValidatorConsensusAddress: sdk.ConsAddress(validator.Address.Bytes()).String()}}, types.LastTransmissionBlockHeight{}, params), false, }, { "invalid restart consumer genesis state: provider id is empty", - types.NewRestartGenesisState("", "ccvchannel", nil, valUpdates, heightToValsetUpdateID, ccv.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), + types.NewRestartGenesisState("", "ccvchannel", nil, valUpdates, heightToValsetUpdateID, types.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), true, }, { "invalid restart consumer genesis state: maturing packet vscId is invalid", types.NewRestartGenesisState("ccvclient", "ccvchannel", []types.MaturingVSCPacket{ - {0, time.Now().UTC()}, - }, valUpdates, nil, ccv.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), + {VscId: 0, MaturityTime: time.Now().UTC()}, + }, valUpdates, nil, types.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), true, }, { "invalid restart consumer genesis state: maturing packet time is invalid", types.NewRestartGenesisState("ccvclient", "ccvchannel", []types.MaturingVSCPacket{ - {1, time.Time{}}, - }, valUpdates, nil, ccv.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), + {VscId: 1, MaturityTime: time.Time{}}, + }, valUpdates, nil, types.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), true, }, { "invalid restart consumer genesis: client state defined", &types.GenesisState{ - params, - "ccvclient", - "ccvchannel", - false, - cs, - nil, - nil, - valUpdates, - nil, - nil, - ccv.ConsumerPacketDataList{}, - types.LastTransmissionBlockHeight{}, - false, + Params: params, + ProviderClientId: "ccvclient", + ProviderChannelId: "ccvchannel", + NewChain: false, + Provider: ccv.ProviderInfo{ + ClientState: cs, + ConsensusState: nil, + InitialValSet: valUpdates, + }, + MaturingPackets: nil, + HeightToValsetUpdateId: nil, + OutstandingDowntimeSlashing: nil, + PendingConsumerPackets: types.ConsumerPacketDataList{}, + LastTransmissionBlockHeight: types.LastTransmissionBlockHeight{}, + PreCCV: false, }, true, }, { "invalid restart consumer genesis: consensus state defined", &types.GenesisState{ - params, - "ccvclient", - "ccvchannel", - false, - nil, - consensusState, - nil, - valUpdates, - nil, - nil, - ccv.ConsumerPacketDataList{}, - types.LastTransmissionBlockHeight{}, - false, + Params: params, + ProviderClientId: "ccvclient", + ProviderChannelId: "ccvchannel", + NewChain: false, + Provider: ccv.ProviderInfo{ + ClientState: nil, + ConsensusState: consensusState, + InitialValSet: valUpdates, + }, + MaturingPackets: nil, + HeightToValsetUpdateId: nil, + OutstandingDowntimeSlashing: nil, + PendingConsumerPackets: types.ConsumerPacketDataList{}, + LastTransmissionBlockHeight: types.LastTransmissionBlockHeight{}, + PreCCV: false, }, true, }, { "invalid restart consumer genesis state: nil initial validator set", - types.NewRestartGenesisState("ccvclient", "ccvchannel", nil, nil, nil, ccv.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), + types.NewRestartGenesisState("ccvclient", "ccvchannel", nil, nil, nil, types.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), true, }, { "invalid restart consumer genesis state: nil height to validator set id mapping", types.NewRestartGenesisState("ccvclient", "", - []types.MaturingVSCPacket{{1, time.Time{}}}, valUpdates, nil, ccv.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), + []types.MaturingVSCPacket{{VscId: 1, MaturityTime: time.Time{}}}, valUpdates, nil, types.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), true, }, { "invalid restart consumer genesis state: maturing packet defined when handshake is still in progress", types.NewRestartGenesisState("ccvclient", "", - []types.MaturingVSCPacket{{1, time.Time{}}}, valUpdates, heightToValsetUpdateID, ccv.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), + []types.MaturingVSCPacket{{VscId: 1, MaturityTime: time.Time{}}}, valUpdates, heightToValsetUpdateID, types.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, params), true, }, { "invalid restart consumer genesis state: outstanding downtime defined when handshake is still in progress", types.NewRestartGenesisState("ccvclient", "", - nil, valUpdates, heightToValsetUpdateID, ccv.ConsumerPacketDataList{}, []types.OutstandingDowntime{{ValidatorConsensusAddress: "cosmosvalconsxxx"}}, + nil, valUpdates, heightToValsetUpdateID, types.ConsumerPacketDataList{}, []types.OutstandingDowntime{{ValidatorConsensusAddress: "cosmosvalconsxxx"}}, types.LastTransmissionBlockHeight{}, params), true, }, { "invalid restart consumer genesis state: last transmission block height defined when handshake is still in progress", types.NewRestartGenesisState("ccvclient", "", - nil, valUpdates, heightToValsetUpdateID, ccv.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{Height: int64(1)}, params), + nil, valUpdates, heightToValsetUpdateID, types.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{Height: int64(1)}, params), true, }, { "invalid restart consumer genesis state: pending maturing packets defined when handshake is still in progress", types.NewRestartGenesisState("ccvclient", "", - nil, valUpdates, heightToValsetUpdateID, ccv.ConsumerPacketDataList{ + nil, valUpdates, heightToValsetUpdateID, types.ConsumerPacketDataList{ List: []ccv.ConsumerPacketData{ { Type: ccv.VscMaturedPacket, @@ -429,20 +445,21 @@ func TestValidateRestartGenesisState(t *testing.T) { }, { "invalid restart consumer genesis state: invalid params", - types.NewRestartGenesisState("ccvclient", "ccvchannel", nil, valUpdates, nil, ccv.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, - types.NewParams( + types.NewRestartGenesisState("ccvclient", "ccvchannel", nil, valUpdates, nil, types.ConsumerPacketDataList{}, nil, types.LastTransmissionBlockHeight{}, + ccv.NewParams( true, - types.DefaultBlocksPerDistributionTransmission, + ccv.DefaultBlocksPerDistributionTransmission, "", "", 0, // CCV timeout period cannot be 0 - types.DefaultTransferTimeoutPeriod, - types.DefaultConsumerRedistributeFrac, - types.DefaultHistoricalEntries, - types.DefaultConsumerUnbondingPeriod, - types.DefaultSoftOptOutThreshold, + ccv.DefaultTransferTimeoutPeriod, + ccv.DefaultConsumerRedistributeFrac, + ccv.DefaultHistoricalEntries, + ccv.DefaultConsumerUnbondingPeriod, + ccv.DefaultSoftOptOutThreshold, []string{}, []string{}, + ccv.DefaultRetryDelayPeriod, )), true, }, diff --git a/x/ccv/consumer/types/keys.go b/x/ccv/consumer/types/keys.go index b755cf9f5a..c9a3d3f5b0 100644 --- a/x/ccv/consumer/types/keys.go +++ b/x/ccv/consumer/types/keys.go @@ -26,6 +26,7 @@ const ( ConsumerRedistributeName = "cons_redistribute" // ConsumerToSendToProviderName is a "buffer" address for outgoing fees to be transferred to the provider chain + //#nosec G101 -- (false positive) this is not a hardcoded credential ConsumerToSendToProviderName = "cons_to_send_to_provider" ) diff --git a/x/ccv/consumer/types/params_test.go b/x/ccv/consumer/types/params_test.go index 531f7e39f2..d0a6b49c25 100644 --- a/x/ccv/consumer/types/params_test.go +++ b/x/ccv/consumer/types/params_test.go @@ -6,76 +6,80 @@ import ( "github.com/stretchr/testify/require" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) // Tests the validation of consumer params that happens at genesis func TestValidateParams(t *testing.T) { testCases := []struct { name string - params consumertypes.Params + params ccvtypes.ConsumerParams expPass bool }{ - {"default params", consumertypes.DefaultParams(), true}, + {"default params", ccvtypes.DefaultParams(), true}, { "custom valid params", - consumertypes.NewParams(true, 5, "", "", 1004, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), true, + ccvtypes.NewParams(true, 5, "", "", 1004, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), true, }, { "custom invalid params, block per dist transmission", - consumertypes.NewParams(true, -5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, -5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, dist transmission channel", - consumertypes.NewParams(true, 5, "badchannel/", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, - }, - { - "custom invalid params, provider fee pool addr string", - consumertypes.NewParams(true, 5, "", "imabadaddress", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "badchannel/", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, ccv timeout", - consumertypes.NewParams(true, 5, "", "", -5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", -5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, transfer timeout", - consumertypes.NewParams(true, 5, "", "", 1004, -7, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 1004, -7, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, consumer redist fraction is negative", - consumertypes.NewParams(true, 5, "", "", 5, 1005, "-0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "-0.5", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, consumer redist fraction is over 1", - consumertypes.NewParams(true, 5, "", "", 5, 1005, "1.2", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "1.2", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, bad consumer redist fraction ", - consumertypes.NewParams(true, 5, "", "", 5, 1005, "notFrac", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "notFrac", 1000, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, negative num historical entries", - consumertypes.NewParams(true, 5, "", "", 5, 1005, "0.5", -100, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", -100, 24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, negative unbonding period", - consumertypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, -24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, -24*21*time.Hour, "0.05", []string{"untrn"}, []string{"uatom"}, 2*time.Hour), false, }, { "custom invalid params, invalid soft opt out threshold", - consumertypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "-0.05", []string{"u"}, []string{}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "-0.05", []string{"u"}, []string{}, 2*time.Hour), false, }, { "custom invalid params, invalid soft opt out threshold", - consumertypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.5", []string{"u"}, []string{}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.5", []string{"u"}, []string{}, 2*time.Hour), false, }, { "custom invalid params, invalid reward denom", - consumertypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"u"}, []string{}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{"u"}, []string{}, 2*time.Hour), false, }, { "custom invalid params, invalid provider reward denom", - consumertypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{}, []string{"a"}), false, + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{}, []string{"a"}, 2*time.Hour), false, + }, + { + "custom invalid params, retry delay period is negative", + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{}, []string{}, -2*time.Hour), false, + }, + { + "custom invalid params, retry delay period is zero", + ccvtypes.NewParams(true, 5, "", "", 5, 1005, "0.5", 1000, 24*21*time.Hour, "0.05", []string{}, []string{}, 0), false, }, } diff --git a/x/ccv/consumer/types/query.pb.go b/x/ccv/consumer/types/query.pb.go index effe4757ef..e1dd01af4b 100644 --- a/x/ccv/consumer/types/query.pb.go +++ b/x/ccv/consumer/types/query.pb.go @@ -9,6 +9,7 @@ import ( _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" + types "github.com/cosmos/interchain-security/v3/x/ccv/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -252,7 +253,7 @@ var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo // QueryParamsResponse is response type for the Query/Params RPC method. type QueryParamsResponse struct { // params holds all the parameters of this module. - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Params types.ConsumerParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` } func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } @@ -288,11 +289,11 @@ func (m *QueryParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo -func (m *QueryParamsResponse) GetParams() Params { +func (m *QueryParamsResponse) GetParams() types.ConsumerParams { if m != nil { return m.Params } - return Params{} + return types.ConsumerParams{} } type QueryProviderInfoRequest struct { @@ -383,6 +384,94 @@ func (m *QueryProviderInfoResponse) GetProvider() ChainInfo { return ChainInfo{} } +type QueryThrottleStateRequest struct { +} + +func (m *QueryThrottleStateRequest) Reset() { *m = QueryThrottleStateRequest{} } +func (m *QueryThrottleStateRequest) String() string { return proto.CompactTextString(m) } +func (*QueryThrottleStateRequest) ProtoMessage() {} +func (*QueryThrottleStateRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f627751d3cc10225, []int{7} +} +func (m *QueryThrottleStateRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryThrottleStateRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryThrottleStateRequest.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 *QueryThrottleStateRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryThrottleStateRequest.Merge(m, src) +} +func (m *QueryThrottleStateRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryThrottleStateRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryThrottleStateRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryThrottleStateRequest proto.InternalMessageInfo + +type QueryThrottleStateResponse struct { + SlashRecord *SlashRecord `protobuf:"bytes,1,opt,name=slash_record,json=slashRecord,proto3" json:"slash_record,omitempty"` + PacketDataQueue []types.ConsumerPacketData `protobuf:"bytes,2,rep,name=packet_data_queue,json=packetDataQueue,proto3" json:"packet_data_queue"` +} + +func (m *QueryThrottleStateResponse) Reset() { *m = QueryThrottleStateResponse{} } +func (m *QueryThrottleStateResponse) String() string { return proto.CompactTextString(m) } +func (*QueryThrottleStateResponse) ProtoMessage() {} +func (*QueryThrottleStateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f627751d3cc10225, []int{8} +} +func (m *QueryThrottleStateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryThrottleStateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryThrottleStateResponse.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 *QueryThrottleStateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryThrottleStateResponse.Merge(m, src) +} +func (m *QueryThrottleStateResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryThrottleStateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryThrottleStateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryThrottleStateResponse proto.InternalMessageInfo + +func (m *QueryThrottleStateResponse) GetSlashRecord() *SlashRecord { + if m != nil { + return m.SlashRecord + } + return nil +} + +func (m *QueryThrottleStateResponse) GetPacketDataQueue() []types.ConsumerPacketData { + if m != nil { + return m.PacketDataQueue + } + return nil +} + type ChainInfo struct { ChainID string `protobuf:"bytes,1,opt,name=chainID,proto3" json:"chainID,omitempty"` ClientID string `protobuf:"bytes,2,opt,name=clientID,proto3" json:"clientID,omitempty"` @@ -394,7 +483,7 @@ func (m *ChainInfo) Reset() { *m = ChainInfo{} } func (m *ChainInfo) String() string { return proto.CompactTextString(m) } func (*ChainInfo) ProtoMessage() {} func (*ChainInfo) Descriptor() ([]byte, []int) { - return fileDescriptor_f627751d3cc10225, []int{7} + return fileDescriptor_f627751d3cc10225, []int{9} } func (m *ChainInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -459,6 +548,8 @@ func init() { proto.RegisterType((*QueryParamsResponse)(nil), "interchain_security.ccv.consumer.v1.QueryParamsResponse") proto.RegisterType((*QueryProviderInfoRequest)(nil), "interchain_security.ccv.consumer.v1.QueryProviderInfoRequest") proto.RegisterType((*QueryProviderInfoResponse)(nil), "interchain_security.ccv.consumer.v1.QueryProviderInfoResponse") + proto.RegisterType((*QueryThrottleStateRequest)(nil), "interchain_security.ccv.consumer.v1.QueryThrottleStateRequest") + proto.RegisterType((*QueryThrottleStateResponse)(nil), "interchain_security.ccv.consumer.v1.QueryThrottleStateResponse") proto.RegisterType((*ChainInfo)(nil), "interchain_security.ccv.consumer.v1.ChainInfo") } @@ -467,49 +558,59 @@ func init() { } var fileDescriptor_f627751d3cc10225 = []byte{ - // 672 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0x41, 0x6b, 0x13, 0x4f, - 0x14, 0xcf, 0xa6, 0x4d, 0xdb, 0xbc, 0xfe, 0xff, 0x07, 0xc7, 0x08, 0xeb, 0x5a, 0xd6, 0xb2, 0x0a, - 0x46, 0x25, 0xbb, 0xb6, 0x3d, 0x54, 0x0f, 0x55, 0xb1, 0xb1, 0x18, 0x50, 0xa9, 0x8b, 0x20, 0x78, - 0xa9, 0xd3, 0xe9, 0x34, 0x19, 0x48, 0x66, 0xd2, 0x9d, 0xd9, 0xd0, 0xde, 0x44, 0xf1, 0x2a, 0x82, - 0xdf, 0xc4, 0x2f, 0xe0, 0xb5, 0xe0, 0xa5, 0xe0, 0xc5, 0x93, 0x48, 0xeb, 0x87, 0xf0, 0x28, 0x3b, - 0x3b, 0x9b, 0x6e, 0x68, 0x69, 0xb7, 0xea, 0x6d, 0xe7, 0xfd, 0xde, 0xfb, 0xbd, 0xdf, 0x7b, 0xf3, - 0xde, 0x2c, 0x04, 0x8c, 0x2b, 0x1a, 0x91, 0x0e, 0x66, 0x7c, 0x4d, 0x52, 0x12, 0x47, 0x4c, 0xed, - 0x04, 0x84, 0x0c, 0x02, 0x22, 0xb8, 0x8c, 0x7b, 0x34, 0x0a, 0x06, 0x73, 0xc1, 0x56, 0x4c, 0xa3, - 0x1d, 0xbf, 0x1f, 0x09, 0x25, 0xd0, 0x95, 0x63, 0x02, 0x7c, 0x42, 0x06, 0x7e, 0x16, 0xe0, 0x0f, - 0xe6, 0x9c, 0x5a, 0x5b, 0xb4, 0x85, 0xf6, 0x0f, 0x92, 0xaf, 0x34, 0xd4, 0x99, 0x69, 0x0b, 0xd1, - 0xee, 0xd2, 0x00, 0xf7, 0x59, 0x80, 0x39, 0x17, 0x0a, 0x2b, 0x26, 0xb8, 0x34, 0xe8, 0x7c, 0x11, - 0x25, 0xc3, 0x24, 0x3a, 0xc6, 0x7b, 0x5f, 0x86, 0x4b, 0x4f, 0xe9, 0xb6, 0x5a, 0xa1, 0xb4, 0xc9, - 0xa4, 0x8a, 0xd8, 0x7a, 0x9c, 0x50, 0x3e, 0x94, 0x8a, 0xf5, 0xb0, 0xa2, 0xe8, 0x2a, 0xfc, 0x4f, - 0xe2, 0x28, 0xa2, 0x5c, 0x3d, 0xa2, 0xac, 0xdd, 0x51, 0xb6, 0x35, 0x6b, 0xd5, 0xc7, 0xc2, 0x51, - 0x23, 0x72, 0x01, 0xba, 0x58, 0x66, 0x2e, 0x65, 0xed, 0x92, 0xb3, 0x24, 0x38, 0xa7, 0xdb, 0x19, - 0x3e, 0x96, 0xe2, 0x87, 0x16, 0xb4, 0x00, 0x17, 0x36, 0x72, 0xd9, 0xd7, 0x36, 0x23, 0x4c, 0x92, - 0x0f, 0x7b, 0x7c, 0xd6, 0xaa, 0x57, 0xc3, 0x5a, 0x1e, 0x5c, 0x31, 0x18, 0xaa, 0x41, 0x45, 0x09, - 0x85, 0xbb, 0x76, 0x45, 0x3b, 0xa5, 0x87, 0x24, 0x95, 0x12, 0xab, 0x91, 0x18, 0xb0, 0x0d, 0x1a, - 0xd9, 0x13, 0x1a, 0xca, 0x59, 0x52, 0x7c, 0xd9, 0x34, 0xc1, 0x9e, 0xcc, 0xf0, 0xcc, 0xe2, 0x5d, - 0x87, 0x6b, 0xcf, 0x92, 0xcb, 0x3a, 0xa1, 0x29, 0x21, 0xdd, 0x8a, 0xa9, 0x54, 0xde, 0x6b, 0x0b, - 0xea, 0xa7, 0xfb, 0xca, 0xbe, 0xe0, 0x92, 0xa2, 0xe7, 0x30, 0xbe, 0x81, 0x15, 0xd6, 0xfd, 0x9b, - 0x9e, 0xbf, 0xef, 0x17, 0x18, 0x02, 0xff, 0x24, 0x5e, 0xcd, 0xe6, 0xd5, 0x00, 0x69, 0x05, 0xab, - 0x38, 0xc2, 0x3d, 0x99, 0x09, 0x7b, 0x05, 0xe7, 0x47, 0xac, 0x46, 0x42, 0x0b, 0x26, 0xfa, 0xda, - 0x62, 0x44, 0xdc, 0x2c, 0x24, 0x22, 0x25, 0x79, 0x30, 0xbe, 0xfb, 0xfd, 0x72, 0x29, 0x34, 0x04, - 0x9e, 0x03, 0x76, 0x9a, 0xc1, 0xb4, 0xb5, 0xc5, 0x37, 0x45, 0x96, 0xfd, 0xb3, 0x05, 0x17, 0x8f, - 0x01, 0x8d, 0x88, 0x55, 0x98, 0xca, 0xd8, 0x8d, 0x0c, 0xbf, 0x90, 0x8c, 0xe5, 0x04, 0x4e, 0x98, - 0x8c, 0x92, 0x21, 0x4b, 0xc2, 0xd8, 0xcf, 0xee, 0xbb, 0xfc, 0x37, 0x8c, 0x19, 0x8b, 0xf7, 0xd6, - 0x82, 0xea, 0x10, 0x45, 0x36, 0x4c, 0x6a, 0xa6, 0x56, 0x53, 0x0b, 0xae, 0x86, 0xd9, 0x11, 0x39, - 0x30, 0x45, 0xba, 0x8c, 0x72, 0xd5, 0x6a, 0xea, 0xcc, 0xd5, 0x70, 0x78, 0x46, 0x1e, 0xfc, 0x47, - 0x04, 0xe7, 0x54, 0xcf, 0x6a, 0xab, 0xa9, 0x87, 0xbe, 0x1a, 0x8e, 0xd8, 0xd0, 0x0c, 0x54, 0x49, - 0x07, 0x73, 0x4e, 0xbb, 0xad, 0xa6, 0x19, 0xf5, 0x43, 0xc3, 0xfc, 0xbb, 0x0a, 0x54, 0x74, 0x1f, - 0xd1, 0x2f, 0xcb, 0xb4, 0xfb, 0x98, 0x81, 0x40, 0x8f, 0x0b, 0x15, 0x5b, 0x70, 0xa6, 0x9d, 0x27, - 0xff, 0x88, 0x2d, 0xbd, 0x6d, 0xef, 0xde, 0x9b, 0xaf, 0x3f, 0x3f, 0x96, 0xef, 0xa0, 0xc5, 0xd3, - 0x5f, 0xc9, 0xe4, 0x39, 0x68, 0x6c, 0x52, 0xda, 0xc8, 0x2f, 0x3b, 0xfa, 0x64, 0xc1, 0x74, 0x6e, - 0x96, 0xd1, 0x62, 0x71, 0x7d, 0x23, 0x3b, 0xe1, 0xdc, 0x3e, 0x7b, 0xa0, 0xa9, 0xe1, 0x96, 0xae, - 0xe1, 0x06, 0xaa, 0x9f, 0x5e, 0x43, 0xba, 0x1d, 0xe8, 0x8b, 0x05, 0xe7, 0x8e, 0x6c, 0x00, 0x5a, - 0x3a, 0x83, 0x82, 0xa3, 0x6b, 0xe5, 0xdc, 0xfd, 0xd3, 0x70, 0x53, 0xc6, 0xa2, 0x2e, 0x63, 0x0e, - 0x05, 0x05, 0xca, 0x30, 0xf1, 0x0d, 0x96, 0x6c, 0xc7, 0x8b, 0xdd, 0x7d, 0xd7, 0xda, 0xdb, 0x77, - 0xad, 0x1f, 0xfb, 0xae, 0xf5, 0xe1, 0xc0, 0x2d, 0xed, 0x1d, 0xb8, 0xa5, 0x6f, 0x07, 0x6e, 0xe9, - 0xe5, 0x52, 0x9b, 0xa9, 0x4e, 0xbc, 0xee, 0x13, 0xd1, 0x0b, 0x88, 0x90, 0x3d, 0x21, 0x73, 0xdc, - 0x8d, 0x21, 0xf7, 0x60, 0x21, 0xd8, 0x1e, 0x4d, 0xa0, 0x76, 0xfa, 0x54, 0xae, 0x4f, 0xe8, 0x5f, - 0xd0, 0xc2, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x78, 0x73, 0x9f, 0x0e, 0x42, 0x07, 0x00, 0x00, + // 825 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x6f, 0xe3, 0x44, + 0x14, 0x8f, 0xd3, 0x36, 0xbb, 0x99, 0x2e, 0x42, 0x3b, 0x04, 0xc9, 0x78, 0x57, 0xa1, 0x32, 0x20, + 0xc2, 0x4a, 0xb1, 0x93, 0xf4, 0xd0, 0xe5, 0xb0, 0x2c, 0xda, 0x86, 0xaa, 0x91, 0x00, 0xb5, 0x6e, + 0x25, 0x04, 0x17, 0x33, 0x9d, 0x4c, 0x13, 0x8b, 0xc4, 0xe3, 0xce, 0x8c, 0x4d, 0x7b, 0x43, 0x70, + 0x47, 0x48, 0x7c, 0x13, 0xbe, 0x00, 0xd7, 0x4a, 0x1c, 0xa8, 0xc4, 0x01, 0xb8, 0x20, 0xd4, 0xf2, + 0x21, 0x38, 0xa2, 0x19, 0x8f, 0x53, 0xa7, 0x4d, 0x13, 0xb7, 0xec, 0xcd, 0xf3, 0xfe, 0xfc, 0xde, + 0xef, 0xf7, 0x66, 0xde, 0x4b, 0x80, 0x1b, 0x84, 0x82, 0x30, 0x3c, 0x44, 0x41, 0xe8, 0x73, 0x82, + 0x63, 0x16, 0x88, 0x13, 0x17, 0xe3, 0xc4, 0xc5, 0x34, 0xe4, 0xf1, 0x98, 0x30, 0x37, 0x69, 0xbb, + 0x47, 0x31, 0x61, 0x27, 0x4e, 0xc4, 0xa8, 0xa0, 0xf0, 0xad, 0x19, 0x09, 0x0e, 0xc6, 0x89, 0x93, + 0x25, 0x38, 0x49, 0xdb, 0x6a, 0xdd, 0x84, 0x9a, 0xb4, 0x5d, 0x3e, 0x44, 0x8c, 0xf4, 0xfd, 0x49, + 0xb8, 0x82, 0xb5, 0x6a, 0x03, 0x3a, 0xa0, 0xea, 0xd3, 0x95, 0x5f, 0xda, 0xfa, 0x78, 0x40, 0xe9, + 0x60, 0x44, 0x5c, 0x14, 0x05, 0x2e, 0x0a, 0x43, 0x2a, 0x90, 0x08, 0x68, 0xc8, 0xb5, 0xb7, 0x53, + 0x84, 0xfb, 0x95, 0x3a, 0xef, 0xcc, 0x61, 0xf6, 0x75, 0xc0, 0x48, 0x1a, 0x66, 0x7f, 0x5f, 0x06, + 0x8f, 0x3e, 0x25, 0xc7, 0x62, 0x8b, 0x90, 0x6e, 0xc0, 0x05, 0x0b, 0x0e, 0x62, 0x59, 0xf9, 0x23, + 0x2e, 0x82, 0x31, 0x12, 0x04, 0xbe, 0x0d, 0x5e, 0xc1, 0x31, 0x63, 0x24, 0x14, 0xdb, 0x24, 0x18, + 0x0c, 0x85, 0x69, 0xac, 0x19, 0x8d, 0x25, 0x6f, 0xda, 0x08, 0xeb, 0x00, 0x8c, 0x10, 0xcf, 0x42, + 0xca, 0x2a, 0x24, 0x67, 0x91, 0xfe, 0x90, 0x1c, 0x67, 0xfe, 0xa5, 0xd4, 0x7f, 0x69, 0x81, 0xeb, + 0xe0, 0xf5, 0x7e, 0xae, 0xba, 0x7f, 0xc8, 0x10, 0x96, 0x1f, 0xe6, 0xf2, 0x9a, 0xd1, 0xa8, 0x7a, + 0xb5, 0xbc, 0x73, 0x4b, 0xfb, 0x60, 0x0d, 0xac, 0x08, 0x2a, 0xd0, 0xc8, 0x5c, 0x51, 0x41, 0xe9, + 0x41, 0x96, 0x12, 0x74, 0x87, 0xd1, 0x24, 0xe8, 0x13, 0x66, 0x56, 0x94, 0x2b, 0x67, 0x49, 0xfd, + 0x9b, 0xba, 0x57, 0xe6, 0xbd, 0xcc, 0x9f, 0x59, 0xec, 0xf7, 0xc0, 0xbb, 0xbb, 0xf2, 0x15, 0xcc, + 0x69, 0x8a, 0x47, 0x8e, 0x62, 0xc2, 0x85, 0xfd, 0x8d, 0x01, 0x1a, 0x8b, 0x63, 0x79, 0x44, 0x43, + 0x4e, 0xe0, 0x3e, 0x58, 0xee, 0x23, 0x81, 0x54, 0xff, 0x56, 0x3b, 0x1f, 0x3a, 0x05, 0x5e, 0x97, + 0x33, 0x0f, 0x57, 0xa1, 0xd9, 0x35, 0x00, 0x15, 0x83, 0x1d, 0xc4, 0xd0, 0x98, 0x67, 0xc4, 0x7c, + 0xf0, 0xda, 0x94, 0x55, 0x53, 0xd8, 0x06, 0x95, 0x48, 0x59, 0x34, 0x89, 0x27, 0x37, 0x92, 0x48, + 0xda, 0x4e, 0xd6, 0x90, 0x14, 0xe3, 0xc5, 0xf2, 0xe9, 0x5f, 0x6f, 0x96, 0x3c, 0x9d, 0x6f, 0x5b, + 0xc0, 0x4c, 0x0b, 0xe8, 0xae, 0xf6, 0xc2, 0x43, 0x9a, 0x15, 0xff, 0xd9, 0x00, 0x6f, 0xcc, 0x70, + 0x6a, 0x0e, 0x3b, 0xe0, 0x7e, 0xa6, 0x50, 0xb3, 0x70, 0x0a, 0xb5, 0x62, 0x53, 0xba, 0x25, 0x92, + 0x66, 0x32, 0x41, 0x91, 0x88, 0x51, 0x76, 0xdd, 0xe5, 0xff, 0x83, 0x98, 0xa1, 0xd8, 0x8f, 0xb4, + 0x80, 0xfd, 0x21, 0xa3, 0x42, 0x8c, 0xc8, 0x9e, 0xc8, 0x5d, 0xfa, 0x9f, 0x06, 0xb0, 0x66, 0x79, + 0xb5, 0xbe, 0xcf, 0xc1, 0x03, 0x3e, 0x42, 0x7c, 0xe8, 0x33, 0x82, 0x29, 0xeb, 0x6b, 0x8d, 0xad, + 0x42, 0x8c, 0xf6, 0x64, 0xa2, 0xa7, 0xf2, 0x14, 0x27, 0xc3, 0x5b, 0xe5, 0x97, 0x26, 0xf8, 0x25, + 0x78, 0x18, 0x21, 0xfc, 0x15, 0x11, 0xbe, 0xbc, 0x7a, 0xff, 0x28, 0x26, 0x31, 0x31, 0xcb, 0x6b, + 0x4b, 0x73, 0x15, 0x4f, 0xdd, 0xa4, 0x4c, 0xee, 0x22, 0x81, 0xb4, 0xe2, 0x57, 0xa3, 0x89, 0x65, + 0x57, 0x82, 0xd9, 0xdf, 0x19, 0xa0, 0x3a, 0x69, 0x0b, 0x34, 0xc1, 0x3d, 0x05, 0xd8, 0xeb, 0x2a, + 0x15, 0x55, 0x2f, 0x3b, 0x42, 0x0b, 0xdc, 0xc7, 0xa3, 0x80, 0x84, 0xa2, 0xd7, 0x55, 0x2d, 0xaf, + 0x7a, 0x93, 0x33, 0xb4, 0xc1, 0x03, 0x4c, 0xc3, 0x90, 0xa8, 0x19, 0xed, 0x75, 0xd5, 0xb0, 0x57, + 0xbd, 0x29, 0x1b, 0x7c, 0x0c, 0xaa, 0x78, 0x88, 0xc2, 0x90, 0x8c, 0x7a, 0x5d, 0x3d, 0xe2, 0x97, + 0x86, 0xce, 0xef, 0x15, 0xb0, 0xa2, 0x3a, 0x0c, 0xff, 0x35, 0xf4, 0x3b, 0x9b, 0x31, 0x08, 0xf0, + 0xe3, 0x42, 0x3d, 0x2d, 0x38, 0xcb, 0xd6, 0x27, 0x2f, 0x09, 0x2d, 0x7d, 0x06, 0xf6, 0xf3, 0x6f, + 0x7f, 0xfb, 0xe7, 0xc7, 0xf2, 0xfb, 0x70, 0x63, 0xf1, 0xcf, 0x8e, 0x5c, 0x83, 0xcd, 0x43, 0x42, + 0x9a, 0xf9, 0x25, 0x07, 0x7f, 0x32, 0xc0, 0x6a, 0x6e, 0x86, 0xe1, 0x46, 0x71, 0x7e, 0x53, 0xbb, + 0xc0, 0x7a, 0x7a, 0xfb, 0x44, 0xad, 0xa1, 0xa5, 0x34, 0x3c, 0x81, 0x8d, 0xc5, 0x1a, 0xd2, 0xb5, + 0x00, 0x7f, 0x31, 0xc0, 0xc3, 0x6b, 0xa3, 0x0f, 0x9f, 0xdd, 0x82, 0xc1, 0xf5, 0x7d, 0x62, 0x7d, + 0x70, 0xd7, 0x74, 0x2d, 0x63, 0x43, 0xc9, 0x68, 0x43, 0xb7, 0x80, 0x0c, 0x9d, 0xdf, 0x0c, 0x24, + 0xef, 0x5f, 0x0d, 0xbd, 0x5c, 0xa7, 0x26, 0x1d, 0xde, 0x82, 0xcf, 0xac, 0x05, 0x62, 0x3d, 0xbf, + 0x73, 0xbe, 0x16, 0xf4, 0x54, 0x09, 0xea, 0xc0, 0xd6, 0x62, 0x41, 0x42, 0x03, 0xf8, 0x5c, 0x22, + 0xbc, 0xf8, 0xec, 0xf4, 0xbc, 0x6e, 0x9c, 0x9d, 0xd7, 0x8d, 0xbf, 0xcf, 0xeb, 0xc6, 0x0f, 0x17, + 0xf5, 0xd2, 0xd9, 0x45, 0xbd, 0xf4, 0xc7, 0x45, 0xbd, 0xf4, 0xc5, 0xb3, 0x41, 0x20, 0x86, 0xf1, + 0x81, 0x83, 0xe9, 0xd8, 0xc5, 0x94, 0x8f, 0x29, 0xcf, 0x81, 0x37, 0x27, 0xe0, 0xc9, 0xba, 0x7b, + 0x7c, 0xa5, 0xc2, 0x49, 0x44, 0xf8, 0x41, 0x45, 0xfd, 0x99, 0x58, 0xff, 0x2f, 0x00, 0x00, 0xff, + 0xff, 0x0e, 0x14, 0x5a, 0xa9, 0x65, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -530,6 +631,8 @@ type QueryClient interface { // QueryParams queries the ccv/consumer module parameters. QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) QueryProviderInfo(ctx context.Context, in *QueryProviderInfoRequest, opts ...grpc.CallOption) (*QueryProviderInfoResponse, error) + // QueryThrottleState returns on-chain state relevant to throttled consumer packets + QueryThrottleState(ctx context.Context, in *QueryThrottleStateRequest, opts ...grpc.CallOption) (*QueryThrottleStateResponse, error) } type queryClient struct { @@ -567,6 +670,15 @@ func (c *queryClient) QueryProviderInfo(ctx context.Context, in *QueryProviderIn return out, nil } +func (c *queryClient) QueryThrottleState(ctx context.Context, in *QueryThrottleStateRequest, opts ...grpc.CallOption) (*QueryThrottleStateResponse, error) { + out := new(QueryThrottleStateResponse) + err := c.cc.Invoke(ctx, "/interchain_security.ccv.consumer.v1.Query/QueryThrottleState", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // ConsumerGenesis queries the genesis state needed to start a consumer chain @@ -575,6 +687,8 @@ type QueryServer interface { // QueryParams queries the ccv/consumer module parameters. QueryParams(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) QueryProviderInfo(context.Context, *QueryProviderInfoRequest) (*QueryProviderInfoResponse, error) + // QueryThrottleState returns on-chain state relevant to throttled consumer packets + QueryThrottleState(context.Context, *QueryThrottleStateRequest) (*QueryThrottleStateResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -590,6 +704,9 @@ func (*UnimplementedQueryServer) QueryParams(ctx context.Context, req *QueryPara func (*UnimplementedQueryServer) QueryProviderInfo(ctx context.Context, req *QueryProviderInfoRequest) (*QueryProviderInfoResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryProviderInfo not implemented") } +func (*UnimplementedQueryServer) QueryThrottleState(ctx context.Context, req *QueryThrottleStateRequest) (*QueryThrottleStateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryThrottleState not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -649,6 +766,24 @@ func _Query_QueryProviderInfo_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Query_QueryThrottleState_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryThrottleStateRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryThrottleState(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/interchain_security.ccv.consumer.v1.Query/QueryThrottleState", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryThrottleState(ctx, req.(*QueryThrottleStateRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "interchain_security.ccv.consumer.v1.Query", HandlerType: (*QueryServer)(nil), @@ -665,6 +800,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryProviderInfo", Handler: _Query_QueryProviderInfo_Handler, }, + { + MethodName: "QueryThrottleState", + Handler: _Query_QueryThrottleState_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "interchain_security/ccv/consumer/v1/query.proto", @@ -916,6 +1055,78 @@ func (m *QueryProviderInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } +func (m *QueryThrottleStateRequest) 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 *QueryThrottleStateRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryThrottleStateRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryThrottleStateResponse) 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 *QueryThrottleStateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryThrottleStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.PacketDataQueue) > 0 { + for iNdEx := len(m.PacketDataQueue) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PacketDataQueue[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if m.SlashRecord != nil { + { + size, err := m.SlashRecord.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *ChainInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1076,6 +1287,34 @@ func (m *QueryProviderInfoResponse) Size() (n int) { return n } +func (m *QueryThrottleStateRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryThrottleStateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SlashRecord != nil { + l = m.SlashRecord.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if len(m.PacketDataQueue) > 0 { + for _, e := range m.PacketDataQueue { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + func (m *ChainInfo) Size() (n int) { if m == nil { return 0 @@ -1777,6 +2016,176 @@ func (m *QueryProviderInfoResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryThrottleStateRequest) 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: QueryThrottleStateRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryThrottleStateRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *QueryThrottleStateResponse) 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: QueryThrottleStateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryThrottleStateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashRecord", 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.SlashRecord == nil { + m.SlashRecord = &SlashRecord{} + } + if err := m.SlashRecord.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PacketDataQueue", 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.PacketDataQueue = append(m.PacketDataQueue, types.ConsumerPacketData{}) + if err := m.PacketDataQueue[len(m.PacketDataQueue)-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 (m *ChainInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/consumer/types/query.pb.gw.go b/x/ccv/consumer/types/query.pb.gw.go index 1151ab0b60..46ad461324 100644 --- a/x/ccv/consumer/types/query.pb.gw.go +++ b/x/ccv/consumer/types/query.pb.gw.go @@ -87,6 +87,24 @@ func local_request_Query_QueryProviderInfo_0(ctx context.Context, marshaler runt } +func request_Query_QueryThrottleState_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryThrottleStateRequest + var metadata runtime.ServerMetadata + + msg, err := client.QueryThrottleState(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryThrottleState_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryThrottleStateRequest + var metadata runtime.ServerMetadata + + msg, err := server.QueryThrottleState(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -162,6 +180,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryThrottleState_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_Query_QueryThrottleState_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_Query_QueryThrottleState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -263,6 +304,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryThrottleState_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryThrottleState_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryThrottleState_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -272,6 +333,8 @@ var ( pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "consumer", "params"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_QueryProviderInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "consumer", "provider-info"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_QueryThrottleState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "consumer", "throttle_state"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -280,4 +343,6 @@ var ( forward_Query_QueryParams_0 = runtime.ForwardResponseMessage forward_Query_QueryProviderInfo_0 = runtime.ForwardResponseMessage + + forward_Query_QueryThrottleState_0 = runtime.ForwardResponseMessage ) diff --git a/x/ccv/provider/client/cli/query.go b/x/ccv/provider/client/cli/query.go index 1240e242f0..80746ff5d2 100644 --- a/x/ccv/provider/client/cli/query.go +++ b/x/ccv/provider/client/cli/query.go @@ -31,7 +31,6 @@ func NewQueryCmd() *cobra.Command { cmd.AddCommand(CmdConsumerValidatorKeyAssignment()) cmd.AddCommand(CmdProviderValidatorKey()) cmd.AddCommand(CmdThrottleState()) - cmd.AddCommand(CmdThrottledConsumerPacketData()) cmd.AddCommand(CmdRegisteredConsumerRewardDenoms()) return cmd @@ -286,42 +285,6 @@ $ %s query provider throttle-state return cmd } -func CmdThrottledConsumerPacketData() *cobra.Command { - cmd := &cobra.Command{ - Use: "throttled-consumer-packet-data [chainid]", - Short: "Query pending VSCMatured and slash packet data for a consumer chainId", - Long: strings.TrimSpace( - fmt.Sprintf(`Returns the current pending VSCMatured and slash packet data instances for a consumer chainId. - Queue is ordered by ibc sequence number. -Example: -$ %s query provider throttled-consumer-packet-data foochain -`, - version.AppName, - ), - ), - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx, err := client.GetClientQueryContext(cmd) - if err != nil { - return err - } - queryClient := types.NewQueryClient(clientCtx) - - req := &types.QueryThrottledConsumerPacketDataRequest{ChainId: args[0]} - res, err := queryClient.QueryThrottledConsumerPacketData(cmd.Context(), req) - if err != nil { - return err - } - - return clientCtx.PrintProto(res) - }, - } - - flags.AddQueryFlagsToCmd(cmd) - - return cmd -} - func CmdRegisteredConsumerRewardDenoms() *cobra.Command { cmd := &cobra.Command{ Use: "registered-consumer-reward-denoms", diff --git a/x/ccv/provider/client/cli/tx.go b/x/ccv/provider/client/cli/tx.go index 7e0609d74c..0d37ef52a9 100644 --- a/x/ccv/provider/client/cli/tx.go +++ b/x/ccv/provider/client/cli/tx.go @@ -2,7 +2,6 @@ package cli import ( "fmt" - "strings" "github.com/spf13/cobra" @@ -10,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ) @@ -26,7 +24,6 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand(NewAssignConsumerKeyCmd()) - cmd.AddCommand(NewRegisterConsumerRewardDenomCmd()) return cmd } @@ -68,37 +65,3 @@ func NewAssignConsumerKeyCmd() *cobra.Command { return cmd } - -func NewRegisterConsumerRewardDenomCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "register-consumer-reward-denom [denom]", - Args: cobra.ExactArgs(1), - Short: "Registers a denom that can be sent from consumer chains to all validators and delegators as a reward", - Long: strings.TrimSpace( - fmt.Sprintf(`Registers a denom that can be sent from consumer chains to all validators and delegators as a reward. - -Costs a fee, which is specified in genesis.json under the "consumer_reward_denom_fee" key. Will fail if the sending account has an insufficient balance. - -Example: -$ %s tx provider register-consumer-reward-denom untrn --from mykey -`, - version.AppName, - ), - ), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - depositorAddr := clientCtx.GetFromAddress() - - msg := types.NewMsgRegisterConsumerRewardDenom(args[0], depositorAddr) - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/ccv/provider/client/proposal_handler.go b/x/ccv/provider/client/proposal_handler.go index 8ec6e89bfd..2b28c63466 100644 --- a/x/ccv/provider/client/proposal_handler.go +++ b/x/ccv/provider/client/proposal_handler.go @@ -24,9 +24,10 @@ import ( ) var ( - ConsumerAdditionProposalHandler = govclient.NewProposalHandler(SubmitConsumerAdditionPropTxCmd) - ConsumerRemovalProposalHandler = govclient.NewProposalHandler(SubmitConsumerRemovalProposalTxCmd) - EquivocationProposalHandler = govclient.NewProposalHandler(SubmitEquivocationProposalTxCmd) + ConsumerAdditionProposalHandler = govclient.NewProposalHandler(SubmitConsumerAdditionPropTxCmd) + ConsumerRemovalProposalHandler = govclient.NewProposalHandler(SubmitConsumerRemovalProposalTxCmd) + EquivocationProposalHandler = govclient.NewProposalHandler(SubmitEquivocationProposalTxCmd) + ChangeRewardDenomsProposalHandler = govclient.NewProposalHandler(SubmitChangeRewardDenomsProposalTxCmd) ) // SubmitConsumerAdditionPropTxCmd returns a CLI command handler for submitting @@ -229,6 +230,63 @@ Where proposal.json contains: } } +// SubmitChangeRewardDenomsProposalTxCmd returns a CLI command handler for submitting +// a change reward denoms proposal via a transaction. +func SubmitChangeRewardDenomsProposalTxCmd() *cobra.Command { + return &cobra.Command{ + Use: "change-reward-denoms [proposal-file]", + Args: cobra.ExactArgs(1), + Short: "Submit a change reward denoms proposal", + Long: `Submit an change reward denoms proposal with an initial deposit. + The proposal details must be supplied via a JSON file. + + Example: + $ tx gov submit-legacy-proposal change-reward-denoms --from= + + Where proposal.json contains: + { + "title": "Change reward denoms", + "summary": "Change reward denoms", + "denoms_to_add": ["untrn"], + "denoms_to_remove": ["stake"], + "deposit": "10000stake" + } + `, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + proposal, err := ParseChangeRewardDenomsProposalJSON(args[0]) + if err != nil { + return err + } + + content := types.NewChangeRewardDenomsProposal(proposal.Title, proposal.Summary, proposal.DenomsToAdd, proposal.DenomsToRemove) + + from := clientCtx.GetFromAddress() + + msgContent, err := govv1.NewLegacyContent(content, authtypes.NewModuleAddress(govtypes.ModuleName).String()) + if err != nil { + return err + } + + deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit) + if err != nil { + return err + } + + msg, err := govv1.NewMsgSubmitProposal([]sdk.Msg{msgContent}, deposit, from.String(), "", content.GetTitle(), proposal.Summary) + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } +} + type ConsumerAdditionProposalJSON struct { Title string `json:"title"` Summary string `json:"summary"` @@ -305,6 +363,21 @@ type ConsumerRemovalProposalReq struct { Deposit sdk.Coins `json:"deposit"` } +func ParseConsumerRemovalProposalJSON(proposalFile string) (ConsumerRemovalProposalJSON, error) { + proposal := ConsumerRemovalProposalJSON{} + + contents, err := os.ReadFile(filepath.Clean(proposalFile)) + if err != nil { + return proposal, err + } + + if err := json.Unmarshal(contents, &proposal); err != nil { + return proposal, err + } + + return proposal, nil +} + type EquivocationProposalJSON struct { // evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" Summary string `json:"summary"` @@ -337,18 +410,28 @@ func ParseEquivocationProposalJSON(proposalFile string) (EquivocationProposalJSO return proposal, nil } -func ParseConsumerRemovalProposalJSON(proposalFile string) (ConsumerRemovalProposalJSON, error) { - proposal := ConsumerRemovalProposalJSON{} +type ChangeRewardDenomsProposalJSON struct { + Summary string `json:"summary"` + types.ChangeRewardDenomsProposal + Deposit string `json:"deposit"` +} + +type ChangeRewardDenomsProposalReq struct { + Proposer sdk.AccAddress `json:"proposer"` + types.ChangeRewardDenomsProposal + Deposit sdk.Coins `json:"deposit"` +} + +func ParseChangeRewardDenomsProposalJSON(proposalFile string) (ChangeRewardDenomsProposalJSON, error) { + proposal := ChangeRewardDenomsProposalJSON{} contents, err := os.ReadFile(filepath.Clean(proposalFile)) if err != nil { return proposal, err } - if err := json.Unmarshal(contents, &proposal); err != nil { return proposal, err } - return proposal, nil } diff --git a/x/ccv/provider/handler.go b/x/ccv/provider/handler.go index 71da622fce..067d896cda 100644 --- a/x/ccv/provider/handler.go +++ b/x/ccv/provider/handler.go @@ -20,9 +20,6 @@ func NewHandler(k *keeper.Keeper) sdk.Handler { case *types.MsgAssignConsumerKey: res, err := msgServer.AssignConsumerKey(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - case *types.MsgRegisterConsumerRewardDenom: - res, err := msgServer.RegisterConsumerRewardDenom(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) default: return nil, errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) } diff --git a/x/ccv/provider/ibc_module.go b/x/ccv/provider/ibc_module.go index efe113f895..75da9588d6 100644 --- a/x/ccv/provider/ibc_module.go +++ b/x/ccv/provider/ibc_module.go @@ -83,7 +83,7 @@ func (am AppModule) OnChanOpenTry( return "", err } - md := providertypes.HandshakeMetadata{ + md := ccv.HandshakeMetadata{ // NOTE that the fee pool collector address string provided to the // the consumer chain must be excluded from the blocked addresses // blacklist or all all ibc-transfers from the consumer chain to the @@ -209,11 +209,15 @@ func (am AppModule) OnRecvPacket( } func UnmarshalConsumerPacket(packet channeltypes.Packet) (consumerPacket ccv.ConsumerPacketData, err error) { + return UnmarshalConsumerPacketData(packet.GetData()) +} + +func UnmarshalConsumerPacketData(packetData []byte) (consumerPacket ccv.ConsumerPacketData, err error) { // First try unmarshaling into ccv.ConsumerPacketData type - if err := ccv.ModuleCdc.UnmarshalJSON(packet.GetData(), &consumerPacket); err != nil { + if err := ccv.ModuleCdc.UnmarshalJSON(packetData, &consumerPacket); err != nil { // If failed, packet should be a v1 slash packet, retry for ConsumerPacketDataV1 packet type var v1Packet ccv.ConsumerPacketDataV1 - errV1 := ccv.ModuleCdc.UnmarshalJSON(packet.GetData(), &v1Packet) + errV1 := ccv.ModuleCdc.UnmarshalJSON(packetData, &v1Packet) if errV1 != nil { // If neither worked, return error return ccv.ConsumerPacketData{}, errV1 diff --git a/x/ccv/provider/ibc_module_test.go b/x/ccv/provider/ibc_module_test.go index 8b7c3f985c..571bed0471 100644 --- a/x/ccv/provider/ibc_module_test.go +++ b/x/ccv/provider/ibc_module_test.go @@ -168,7 +168,7 @@ func TestOnChanOpenTry(t *testing.T) { if tc.expPass { require.NoError(t, err) - md := &providertypes.HandshakeMetadata{} + md := &ccv.HandshakeMetadata{} err = md.Unmarshal([]byte(metadata)) require.NoError(t, err) require.Equal(t, moduleAcct.BaseAccount.Address, md.ProviderFeePoolAddr, diff --git a/x/ccv/provider/keeper/distribution.go b/x/ccv/provider/keeper/distribution.go index a1dff6faf4..1b3336aefa 100644 --- a/x/ccv/provider/keeper/distribution.go +++ b/x/ccv/provider/keeper/distribution.go @@ -3,7 +3,6 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ) @@ -15,22 +14,6 @@ func (k Keeper) EndBlockRD(ctx sdk.Context) { k.TransferRewardsToFeeCollector(ctx) } -func (k Keeper) RegisterConsumerRewardDenom(ctx sdk.Context, denom string, sender sdk.AccAddress) error { - // Check if the denom is already registered - if k.ConsumerRewardDenomExists(ctx, denom) { - return consumertypes.ErrConsumerRewardDenomAlreadyRegistered - } - - // Send the consumer reward denom registration fee to the community pool - err := k.distributionKeeper.FundCommunityPool(ctx, sdk.NewCoins(k.GetConsumerRewardDenomRegistrationFee(ctx)), sender) - if err != nil { - return err - } - k.SetConsumerRewardDenom(ctx, denom) - k.Logger(ctx).Info("new consumer reward denom registered:", "denom", denom, "sender", sender.String()) - return nil -} - func (k Keeper) GetConsumerRewardsPoolAddressStr(ctx sdk.Context) string { return k.accountKeeper.GetModuleAccount( ctx, types.ConsumerRewardsPool).GetAddress().String() @@ -53,6 +36,14 @@ func (k Keeper) ConsumerRewardDenomExists( return bz != nil } +func (k Keeper) DeleteConsumerRewardDenom( + ctx sdk.Context, + denom string, +) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.ConsumerRewardDenomsKey(denom)) +} + func (k Keeper) GetAllConsumerRewardDenoms(ctx sdk.Context) (consumerRewardDenoms []string) { store := ctx.KVStore(k.storeKey) iterator := sdk.KVStorePrefixIterator(store, []byte{types.ConsumerRewardDenomsBytePrefix}) diff --git a/x/ccv/provider/keeper/distribution_test.go b/x/ccv/provider/keeper/distribution_test.go deleted file mode 100644 index a470feea74..0000000000 --- a/x/ccv/provider/keeper/distribution_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package keeper_test - -import ( - "testing" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - - sdk "github.com/cosmos/cosmos-sdk/types" - - testutil "github.com/cosmos/interchain-security/v3/testutil/keeper" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" - "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" -) - -// TestRegisterConsumerRewardDenom tests the RegisterConsumerRewardDenom method. -func TestRegisterConsumerRewardDenom(t *testing.T) { - // Setup - providerKeeper, ctx, ctrl, mocks := testutil.GetProviderKeeperAndCtx(t, testutil.NewInMemKeeperParams(t)) - defer ctrl.Finish() - defaultParams := types.DefaultParams() - providerKeeper.SetParams(ctx, defaultParams) - accAddr := sdk.AccAddress([]byte("addr1")) - gomock.InOrder( - mocks.MockDistributionKeeper.EXPECT().FundCommunityPool(ctx, - sdk.NewCoins(defaultParams.ConsumerRewardDenomRegistrationFee), accAddr).Return(nil).Times(2), - ) - - // Register a consumer reward denom, confirm it's persisted as expected - err := providerKeeper.RegisterConsumerRewardDenom(ctx, "denom1", accAddr) - require.NoError(t, err) - require.True(t, providerKeeper.ConsumerRewardDenomExists(ctx, "denom1")) - allDenoms := providerKeeper.GetAllConsumerRewardDenoms(ctx) - require.Len(t, allDenoms, 1) - require.Equal(t, "denom1", allDenoms[0]) - - // Register another consumer reward denom, confirm both denoms are persisted as expected - err = providerKeeper.RegisterConsumerRewardDenom(ctx, "denom2", accAddr) - require.NoError(t, err) - require.True(t, providerKeeper.ConsumerRewardDenomExists(ctx, "denom2")) - allDenoms = providerKeeper.GetAllConsumerRewardDenoms(ctx) - require.Len(t, allDenoms, 2) - require.Equal(t, "denom1", allDenoms[0]) - require.Equal(t, "denom2", allDenoms[1]) - - // Try to register first consumer reward denom again, confirm it fails - err = providerKeeper.RegisterConsumerRewardDenom(ctx, "denom1", accAddr) - require.Error(t, err) - require.Equal(t, consumertypes.ErrConsumerRewardDenomAlreadyRegistered, err) -} diff --git a/x/ccv/provider/keeper/genesis.go b/x/ccv/provider/keeper/genesis.go index f201e6de50..e86035170c 100644 --- a/x/ccv/provider/keeper/genesis.go +++ b/x/ccv/provider/keeper/genesis.go @@ -158,7 +158,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { k.GetAllValsetUpdateBlockHeights(ctx), consumerStates, k.GetAllUnbondingOps(ctx), - &ccv.MaturedUnbondingOps{Ids: k.GetMaturedUnbondingOps(ctx)}, + &types.MaturedUnbondingOps{Ids: k.GetMaturedUnbondingOps(ctx)}, k.GetAllPendingConsumerAdditionProps(ctx), k.GetAllPendingConsumerRemovalProps(ctx), params, diff --git a/x/ccv/provider/keeper/genesis_test.go b/x/ccv/provider/keeper/genesis_test.go index 01a3845651..ecde91253c 100644 --- a/x/ccv/provider/keeper/genesis_test.go +++ b/x/ccv/provider/keeper/genesis_test.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/interchain-security/v3/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" "github.com/cosmos/interchain-security/v3/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" @@ -72,7 +71,7 @@ func TestInitAndExportGenesis(t *testing.T) { expClientID, "channel", initHeight, - *consumertypes.DefaultGenesisState(), + *ccv.DefaultConsumerGenesisState(), []providertypes.VscUnbondingOps{ {VscId: vscID, UnbondingOpIds: ubdIndex}, }, @@ -84,7 +83,7 @@ func TestInitAndExportGenesis(t *testing.T) { expClientID, "", 0, - *consumertypes.DefaultGenesisState(), + *ccv.DefaultConsumerGenesisState(), nil, []ccv.ValidatorSetChangePacketData{{ValsetUpdateId: vscID}}, nil, @@ -94,7 +93,7 @@ func TestInitAndExportGenesis(t *testing.T) { Id: vscID, UnbondingConsumerChains: []string{cChainIDs[0]}, }}, - &ccv.MaturedUnbondingOps{Ids: ubdIndex}, + &providertypes.MaturedUnbondingOps{Ids: ubdIndex}, []providertypes.ConsumerAdditionProposal{{ ChainId: cChainIDs[0], SpawnTime: oneHourFromNow, @@ -219,7 +218,7 @@ func assertConsumerChainStates(t *testing.T, ctx sdk.Context, pk keeper.Keeper, chainID := cs.ChainId gen, found := pk.GetConsumerGenesis(ctx, chainID) require.True(t, found) - require.Equal(t, *consumertypes.DefaultGenesisState(), gen) + require.Equal(t, *ccv.DefaultConsumerGenesisState(), gen) clientID, found := pk.GetConsumerClientId(ctx, chainID) require.True(t, found) diff --git a/x/ccv/provider/keeper/grpc_query.go b/x/ccv/provider/keeper/grpc_query.go index 2b522ea9ef..881a6b1a98 100644 --- a/x/ccv/provider/keeper/grpc_query.go +++ b/x/ccv/provider/keeper/grpc_query.go @@ -2,7 +2,6 @@ package keeper import ( "context" - "fmt" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" @@ -148,98 +147,14 @@ func (k Keeper) QueryThrottleState(goCtx context.Context, req *types.QueryThrott meter := k.GetSlashMeter(ctx) allowance := k.GetSlashMeterAllowance(ctx) candidate := k.GetSlashMeterReplenishTimeCandidate(ctx) // always UTC - packets := []*types.ThrottledSlashPacket{} - - // iterate global slash entries from all consumer chains - // and fetch corresponding SlashPacketData from the per-chain throttled packet data queue - allGlobalEntries := k.GetAllGlobalSlashEntries(ctx) - - for _, entry := range allGlobalEntries { - // Obtain slash packet data instance for the given global entry - slashData, found := k.getSlashPacketData(ctx, entry.ConsumerChainID, entry.IbcSeqNum) - if !found { - // silently skip over invalid data - continue - } - - packets = append(packets, &types.ThrottledSlashPacket{ - GlobalEntry: entry, - Data: slashData, - }) - } return &types.QueryThrottleStateResponse{ SlashMeter: meter.Int64(), SlashMeterAllowance: allowance.Int64(), NextReplenishCandidate: candidate, - Packets: packets, - }, nil -} - -func (k Keeper) QueryThrottledConsumerPacketData(goCtx context.Context, req *types.QueryThrottledConsumerPacketDataRequest) (*types.QueryThrottledConsumerPacketDataResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "empty request") - } - - if req.ChainId == "" { - return nil, status.Error(codes.InvalidArgument, "invalid chain-id") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - if _, found := k.GetChainToChannel(ctx, req.ChainId); !found { - return nil, status.Error(codes.InvalidArgument, "invalid chain-id") - } - - packetDataInstances := []types.ThrottledPacketDataWrapper{} - _, _, rawOrderedData, _ := k.GetAllThrottledPacketData(ctx, req.ChainId) - - for _, raw := range rawOrderedData { - switch data := raw.(type) { - case ccvtypes.SlashPacketData: - w := &types.ThrottledPacketDataWrapper_SlashPacket{SlashPacket: &data} - packetDataInstances = append(packetDataInstances, types.ThrottledPacketDataWrapper{ - Data: w, - }) - case ccvtypes.VSCMaturedPacketData: - w := &types.ThrottledPacketDataWrapper_VscMaturedPacket{VscMaturedPacket: &data} - packetDataInstances = append(packetDataInstances, types.ThrottledPacketDataWrapper{ - Data: w, - }) - default: - k.Logger(ctx).Error(fmt.Sprintf("unexpected packet data type: %T", data)) - } - } - - return &types.QueryThrottledConsumerPacketDataResponse{ - ChainId: req.ChainId, - Size_: k.GetThrottledPacketDataSize(ctx, req.ChainId), - PacketDataInstances: packetDataInstances, }, nil } -// getSlashPacketData fetches a slash packet data from the store using consumerChainId and ibcSeqNum (direct access) -// If the returned bytes do not unmarshal to SlashPacketData, the data is considered not found. -func (k Keeper) getSlashPacketData(ctx sdk.Context, consumerChainID string, ibcSeqNum uint64) (ccvtypes.SlashPacketData, bool) { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.ThrottledPacketDataKey(consumerChainID, ibcSeqNum)) - if len(bz) == 0 { - return ccvtypes.SlashPacketData{}, false - } - - if bz[0] != slashPacketData { - return ccvtypes.SlashPacketData{}, false - } - - packet := ccvtypes.SlashPacketData{} - err := packet.Unmarshal(bz[1:]) - if err != nil { - // If the data cannot be unmarshaled, it is considered not found - return ccvtypes.SlashPacketData{}, false - } - - return packet, true -} - func (k Keeper) QueryRegisteredConsumerRewardDenoms(goCtx context.Context, req *types.QueryRegisteredConsumerRewardDenomsRequest) (*types.QueryRegisteredConsumerRewardDenomsResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") diff --git a/x/ccv/provider/keeper/keeper.go b/x/ccv/provider/keeper/keeper.go index 73785f1c17..d4470ec0aa 100644 --- a/x/ccv/provider/keeper/keeper.go +++ b/x/ccv/provider/keeper/keeper.go @@ -251,7 +251,7 @@ func (k Keeper) GetAllChannelToChains(ctx sdk.Context) (channels []types.Channel return channels } -func (k Keeper) SetConsumerGenesis(ctx sdk.Context, chainID string, gen consumertypes.GenesisState) error { +func (k Keeper) SetConsumerGenesis(ctx sdk.Context, chainID string, gen ccv.ConsumerGenesisState) error { store := ctx.KVStore(k.storeKey) bz, err := gen.Marshal() if err != nil { @@ -262,14 +262,14 @@ func (k Keeper) SetConsumerGenesis(ctx sdk.Context, chainID string, gen consumer return nil } -func (k Keeper) GetConsumerGenesis(ctx sdk.Context, chainID string) (consumertypes.GenesisState, bool) { +func (k Keeper) GetConsumerGenesis(ctx sdk.Context, chainID string) (ccv.ConsumerGenesisState, bool) { store := ctx.KVStore(k.storeKey) bz := store.Get(types.ConsumerGenesisKey(chainID)) if bz == nil { - return consumertypes.GenesisState{}, false + return ccv.ConsumerGenesisState{}, false } - var data consumertypes.GenesisState + var data ccv.ConsumerGenesisState if err := data.Unmarshal(bz); err != nil { // An error here would indicate something is very wrong, // the ConsumerGenesis is assumed to be correctly serialized in SetConsumerGenesis. @@ -299,7 +299,7 @@ func (k Keeper) VerifyConsumerChain(ctx sdk.Context, channelID string, connectio return errorsmod.Wrapf(ccv.ErrClientNotFound, "cannot find client for consumer chain %s", tmClient.ChainId) } if ccvClientId != clientID { - return errorsmod.Wrapf(ccv.ErrInvalidConsumerClient, "CCV channel must be built on top of CCV client. expected %s, got %s", ccvClientId, clientID) + return errorsmod.Wrapf(types.ErrInvalidConsumerClient, "CCV channel must be built on top of CCV client. expected %s, got %s", ccvClientId, clientID) } // Verify that there isn't already a CCV channel for the consumer chain @@ -575,7 +575,7 @@ func (k Keeper) GetMaturedUnbondingOps(ctx sdk.Context) (ids []uint64) { return nil } - var ops ccv.MaturedUnbondingOps + var ops types.MaturedUnbondingOps if err := ops.Unmarshal(bz); err != nil { // An error here would indicate something is very wrong, // the MaturedUnbondingOps are assumed to be correctly serialized in AppendMaturedUnbondingOps. @@ -590,7 +590,7 @@ func (k Keeper) AppendMaturedUnbondingOps(ctx sdk.Context, ids []uint64) { return } existingIds := k.GetMaturedUnbondingOps(ctx) - maturedOps := ccv.MaturedUnbondingOps{ + maturedOps := types.MaturedUnbondingOps{ Ids: append(existingIds, ids...), } @@ -814,7 +814,7 @@ func (k Keeper) DeleteInitChainHeight(ctx sdk.Context, chainID string) { // GetPendingVSCPackets returns the list of pending ValidatorSetChange packets stored under chain ID func (k Keeper) GetPendingVSCPackets(ctx sdk.Context, chainID string) []ccv.ValidatorSetChangePacketData { - var packets ccv.ValidatorSetChangePackets + var packets types.ValidatorSetChangePackets store := ctx.KVStore(k.storeKey) bz := store.Get(types.PendingVSCsKey(chainID)) @@ -835,7 +835,7 @@ func (k Keeper) AppendPendingVSCPackets(ctx sdk.Context, chainID string, newPack pds := append(k.GetPendingVSCPackets(ctx, chainID), newPackets...) store := ctx.KVStore(k.storeKey) - packets := ccv.ValidatorSetChangePackets{List: pds} + packets := types.ValidatorSetChangePackets{List: pds} buf, err := packets.Marshal() if err != nil { // An error here would indicate something is very wrong, diff --git a/x/ccv/provider/keeper/keeper_test.go b/x/ccv/provider/keeper/keeper_test.go index 364aac5669..be3ef4001c 100644 --- a/x/ccv/provider/keeper/keeper_test.go +++ b/x/ccv/provider/keeper/keeper_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/stretchr/testify/require" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -13,7 +14,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" - ibcsimapp "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp" cryptotestutil "github.com/cosmos/interchain-security/v3/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" @@ -156,7 +156,7 @@ func TestPendingVSCs(t *testing.T) { pending := providerKeeper.GetPendingVSCPackets(ctx, chainID) require.Len(t, pending, 0) - pks := ibcsimapp.CreateTestPubKeys(4) + _, pks, _ := ibctesting.GenerateKeys(t, 4) var ppks [4]tmprotocrypto.PublicKey for i, pk := range pks { ppks[i], _ = cryptocodec.ToTmProtoPublicKey(pk) diff --git a/x/ccv/provider/keeper/key_assignment_test.go b/x/ccv/provider/keeper/key_assignment_test.go index 8da633a5c9..e9cb1dd646 100644 --- a/x/ccv/provider/keeper/key_assignment_test.go +++ b/x/ccv/provider/keeper/key_assignment_test.go @@ -346,6 +346,7 @@ func checkCorrectPruningProperty(ctx sdk.Context, k providerkeeper.Keeper, chain good := true for _, valByConsAddr := range k.GetAllValidatorsByConsumerAddr(ctx, nil) { + valByConsAddr := valByConsAddr // Fix linter error G601 if _, ok := willBePruned[string(valByConsAddr.ConsumerAddr)]; ok { // Address will be pruned, everything is fine. continue diff --git a/x/ccv/provider/keeper/migration.go b/x/ccv/provider/keeper/migration.go new file mode 100644 index 0000000000..5d739c8bef --- /dev/null +++ b/x/ccv/provider/keeper/migration.go @@ -0,0 +1,138 @@ +package keeper + +import ( + "fmt" + + sdktypes "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" + ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + providerKeeper Keeper + paramSpace paramtypes.Subspace +} + +// NewMigrator returns a new Migrator. +func NewMigrator(providerKeeper Keeper, paramSpace paramtypes.Subspace) Migrator { + return Migrator{providerKeeper: providerKeeper, paramSpace: paramSpace} +} + +// Migrate2to3 migrates x/ccvprovider state from consensus version 2 to 3. +func (m Migrator) Migrate2to3(ctx sdktypes.Context) error { + return m.providerKeeper.MigrateQueuedPackets(ctx) +} + +func (k Keeper) MigrateQueuedPackets(ctx sdktypes.Context) error { + for _, consumer := range k.GetAllConsumerChains(ctx) { + slashData, vscmData := k.GetAllThrottledPacketData(ctx, consumer.ChainId) + if len(slashData) > 0 { + k.Logger(ctx).Error(fmt.Sprintf("slash data being dropped: %v", slashData)) + } + for _, data := range vscmData { + k.HandleVSCMaturedPacket(ctx, consumer.ChainId, data) + } + k.DeleteThrottledPacketDataForConsumer(ctx, consumer.ChainId) + } + return nil +} + +// Pending packet data type enum, used to encode the type of packet data stored at each entry in the mutual queue. +// Note this type is copy/pasted from throttle v1 code. +const ( + slashPacketData byte = iota + vscMaturedPacketData +) + +// GetAllThrottledPacketData returns all throttled packet data for a given consumer chain, only used for 2 -> 3 migration. +// Note this method is adapted from throttle v1 code. +func (k Keeper) GetAllThrottledPacketData(ctx sdktypes.Context, consumerChainID string) ( + slashData []ccvtypes.SlashPacketData, vscMaturedData []ccvtypes.VSCMaturedPacketData, +) { + slashData = []ccvtypes.SlashPacketData{} + vscMaturedData = []ccvtypes.VSCMaturedPacketData{} + + store := ctx.KVStore(k.storeKey) + iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) + iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + bz := iterator.Value() + switch bz[0] { + case slashPacketData: + d := ccvtypes.SlashPacketData{} + if err := d.Unmarshal(bz[1:]); err != nil { + k.Logger(ctx).Error(fmt.Sprintf("failed to unmarshal slash packet data: %v", err)) + continue + } + slashData = append(slashData, d) + case vscMaturedPacketData: + d := ccvtypes.VSCMaturedPacketData{} + if err := d.Unmarshal(bz[1:]); err != nil { + k.Logger(ctx).Error(fmt.Sprintf("failed to unmarshal vsc matured packet data: %v", err)) + continue + } + vscMaturedData = append(vscMaturedData, d) + default: + k.Logger(ctx).Error(fmt.Sprintf("invalid packet data type: %v", bz[0])) + continue + } + } + + return slashData, vscMaturedData +} + +// Note this method is copy/pasted from throttle v1 code. +func (k Keeper) DeleteThrottledPacketDataForConsumer(ctx sdktypes.Context, consumerChainID string) { + store := ctx.KVStore(k.storeKey) + iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) + iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) + defer iterator.Close() + + keysToDel := [][]byte{} + for ; iterator.Valid(); iterator.Next() { + keysToDel = append(keysToDel, iterator.Key()) + } + // Delete data for this consumer + for _, key := range keysToDel { + store.Delete(key) + } + + // Delete size of data queue for this consumer + store.Delete(providertypes.ThrottledPacketDataSizeKey(consumerChainID)) +} + +// Note this method is adapted from throttle v1 code. +func (k Keeper) QueueThrottledPacketDataOnlyForTesting( + ctx sdktypes.Context, consumerChainID string, ibcSeqNum uint64, packetData interface{}, +) error { + store := ctx.KVStore(k.storeKey) + + var bz []byte + var err error + switch data := packetData.(type) { + case ccvtypes.SlashPacketData: + bz, err = data.Marshal() + if err != nil { + return fmt.Errorf("failed to marshal slash packet data: %v", err) + } + bz = append([]byte{slashPacketData}, bz...) + case ccvtypes.VSCMaturedPacketData: + bz, err = data.Marshal() + if err != nil { + return fmt.Errorf("failed to marshal vsc matured packet data: %v", err) + } + bz = append([]byte{vscMaturedPacketData}, bz...) + default: + // Indicates a developer error, this method should only be called + // by tests, QueueThrottledSlashPacketData, or QueueThrottledVSCMaturedPacketData. + panic(fmt.Sprintf("unexpected packet data type: %T", data)) + } + + store.Set(providertypes.ThrottledPacketDataKey(consumerChainID, ibcSeqNum), bz) + return nil +} diff --git a/x/ccv/provider/keeper/migration_test.go b/x/ccv/provider/keeper/migration_test.go new file mode 100644 index 0000000000..a710e3979c --- /dev/null +++ b/x/ccv/provider/keeper/migration_test.go @@ -0,0 +1,117 @@ +package keeper_test + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" + + testutil "github.com/cosmos/interchain-security/v3/testutil/keeper" +) + +func TestMigrate2To3(t *testing.T) { + providerKeeper, ctx, ctrl, _ := testutil.GetProviderKeeperAndCtx(t, testutil.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // Set consumer client ids to mock consumers being connected to provider + providerKeeper.SetConsumerClientId(ctx, "chain-1", "client-1") + providerKeeper.SetConsumerClientId(ctx, "chain-2", "client-2") + providerKeeper.SetConsumerClientId(ctx, "chain-3", "client-3") + + // Queue some data for chain-1 + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-1", 66, testutil.GetNewSlashPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-1", 67, testutil.GetNewVSCMaturedPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-1", 68, testutil.GetNewSlashPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-1", 69, testutil.GetNewVSCMaturedPacketData()) + + // Queue some data for chain-2 + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-2", 789, testutil.GetNewVSCMaturedPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-2", 790, testutil.GetNewSlashPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-2", 791, testutil.GetNewVSCMaturedPacketData()) + + // Queue some data for chain-3 + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-3", 123, testutil.GetNewSlashPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-3", 124, testutil.GetNewVSCMaturedPacketData()) + providerKeeper.QueueThrottledPacketDataOnlyForTesting( + ctx, "chain-3", 125, testutil.GetNewVSCMaturedPacketData()) + + // Confirm getter methods return expected values + slash1, vscm1 := providerKeeper.GetAllThrottledPacketData(ctx, "chain-1") + require.Len(t, slash1, 2) + require.Len(t, vscm1, 2) + + slash2, vscm2 := providerKeeper.GetAllThrottledPacketData(ctx, "chain-2") + require.Len(t, slash2, 1) + require.Len(t, vscm2, 2) + + slash3, vscm3 := providerKeeper.GetAllThrottledPacketData(ctx, "chain-3") + require.Len(t, slash3, 1) + require.Len(t, vscm3, 2) + + // Set vsc send timestamp for every queued vsc matured packet, + // as a way to assert that the vsc matured packets are handled in the migration. + // + // That is, timestamp should exist before a vsc matured packet is handled, + // and deleted after handling. + for _, data := range vscm1 { + providerKeeper.SetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId, time.Now()) + } + for _, data := range vscm2 { + providerKeeper.SetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId, time.Now()) + } + for _, data := range vscm3 { + providerKeeper.SetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId, time.Now()) + } + + // Confirm timestamps are set + for _, data := range vscm1 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId) + require.True(t, found) + } + for _, data := range vscm2 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId) + require.True(t, found) + } + for _, data := range vscm3 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId) + require.True(t, found) + } + + // Run migration + err := providerKeeper.MigrateQueuedPackets(ctx) + require.NoError(t, err) + + // Confirm throttled data is now deleted + slash1, vscm1 = providerKeeper.GetAllThrottledPacketData(ctx, "chain-1") + require.Empty(t, slash1) + require.Empty(t, vscm1) + slash2, vscm2 = providerKeeper.GetAllThrottledPacketData(ctx, "chain-2") + require.Empty(t, slash2) + require.Empty(t, vscm2) + slash3, vscm3 = providerKeeper.GetAllThrottledPacketData(ctx, "chain-3") + require.Empty(t, slash3) + require.Empty(t, vscm3) + + // Confirm timestamps are deleted, meaning vsc matured packets were handled + for _, data := range vscm1 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-1", data.ValsetUpdateId) + require.False(t, found) + } + for _, data := range vscm2 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-2", data.ValsetUpdateId) + require.False(t, found) + } + for _, data := range vscm3 { + _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-3", data.ValsetUpdateId) + require.False(t, found) + } +} diff --git a/x/ccv/provider/keeper/msg_server.go b/x/ccv/provider/keeper/msg_server.go index 195e2a7215..fecbdc8c36 100644 --- a/x/ccv/provider/keeper/msg_server.go +++ b/x/ccv/provider/keeper/msg_server.go @@ -12,7 +12,6 @@ import ( tmprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) type msgServer struct { @@ -100,32 +99,11 @@ func (k msgServer) AssignConsumerKey(goCtx context.Context, msg *types.MsgAssign ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( - ccvtypes.EventTypeAssignConsumerKey, - sdk.NewAttribute(ccvtypes.AttributeProviderValidatorAddress, msg.ProviderAddr), - sdk.NewAttribute(ccvtypes.AttributeConsumerConsensusPubKey, consumerTMPublicKey.String()), + types.EventTypeAssignConsumerKey, + sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr), + sdk.NewAttribute(types.AttributeConsumerConsensusPubKey, consumerTMPublicKey.String()), ), }) return &types.MsgAssignConsumerKeyResponse{}, nil } - -func (k msgServer) RegisterConsumerRewardDenom(goCtx context.Context, msg *types.MsgRegisterConsumerRewardDenom) (*types.MsgRegisterConsumerRewardDenomResponse, error) { - ctx := sdk.UnwrapSDKContext(goCtx) - - depositer, err := sdk.AccAddressFromBech32(msg.Depositor) - if err != nil { - return nil, err - } - - if err := k.Keeper.RegisterConsumerRewardDenom(ctx, msg.Denom, depositer); err != nil { - return nil, err - } - - ctx.EventManager().EmitEvent(sdk.NewEvent( - ccvtypes.EventTypeRegisterConsumerRewardDenom, - sdk.NewAttribute(ccvtypes.AttributeConsumerRewardDenom, msg.Denom), - sdk.NewAttribute(ccvtypes.AttributeConsumerRewardDepositor, msg.Depositor), - )) - - return &types.MsgRegisterConsumerRewardDenomResponse{}, nil -} diff --git a/x/ccv/provider/keeper/params.go b/x/ccv/provider/keeper/params.go index b7b53b245b..2dbe8ca40d 100644 --- a/x/ccv/provider/keeper/params.go +++ b/x/ccv/provider/keeper/params.go @@ -69,14 +69,6 @@ func (k Keeper) GetSlashMeterReplenishFraction(ctx sdk.Context) string { return f } -// GetMaxThrottledPackets returns the maximum amount of throttled slash or vsc matured packets -// that can be queued for a single consumer before the provider chain halts. -func (k Keeper) GetMaxThrottledPackets(ctx sdk.Context) int64 { - var p int64 - k.paramSpace.Get(ctx, types.KeyMaxThrottledPackets, &p) - return p -} - func (k Keeper) GetConsumerRewardDenomRegistrationFee(ctx sdk.Context) sdk.Coin { // Due to difficulties doing migrations in coordinated upgrades, this param is hardcoded to 10 ATOM in v1.1.0-multiden. // The below code is the proper way to store the param. A future scheduled upgrade will @@ -96,7 +88,6 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { k.GetVscTimeoutPeriod(ctx), k.GetSlashMeterReplenishPeriod(ctx), k.GetSlashMeterReplenishFraction(ctx), - k.GetMaxThrottledPackets(ctx), k.GetConsumerRewardDenomRegistrationFee(ctx), ) } diff --git a/x/ccv/provider/keeper/params_test.go b/x/ccv/provider/keeper/params_test.go index 05b3964bb7..c057079e59 100644 --- a/x/ccv/provider/keeper/params_test.go +++ b/x/ccv/provider/keeper/params_test.go @@ -44,7 +44,6 @@ func TestParams(t *testing.T) { 10*time.Minute, time.Hour, "0.4", - 100, sdk.Coin{ Denom: "stake", Amount: sdk.NewInt(10000000), diff --git a/x/ccv/provider/keeper/proposal.go b/x/ccv/provider/keeper/proposal.go index 11909ad685..20bf812395 100644 --- a/x/ccv/provider/keeper/proposal.go +++ b/x/ccv/provider/keeper/proposal.go @@ -19,7 +19,6 @@ import ( abci "github.com/cometbft/cometbft/abci/types" tmtypes "github.com/cometbft/cometbft/types" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -57,7 +56,7 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi chainID := prop.ChainId // check that a client for this chain does not exist if _, found := k.GetConsumerClientId(ctx, chainID); found { - return errorsmod.Wrap(ccv.ErrDuplicateConsumerChain, + return errorsmod.Wrap(types.ErrDuplicateConsumerChain, fmt.Sprintf("cannot create client for existent consumer chain: %s", chainID)) } @@ -109,14 +108,14 @@ func (k Keeper) CreateConsumerClient(ctx sdk.Context, prop *types.ConsumerAdditi ctx.EventManager().EmitEvent( sdk.NewEvent( - ccv.EventTypeConsumerClientCreated, + types.EventTypeConsumerClientCreated, sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(ccv.AttributeChainID, chainID), sdk.NewAttribute(clienttypes.AttributeKeyClientID, clientID), - sdk.NewAttribute(ccv.AttributeInitialHeight, prop.InitialHeight.String()), - sdk.NewAttribute(ccv.AttributeInitializationTimeout, strconv.Itoa(int(ts.UnixNano()))), - sdk.NewAttribute(ccv.AttributeTrustingPeriod, clientState.TrustingPeriod.String()), - sdk.NewAttribute(ccv.AttributeUnbondingPeriod, clientState.UnbondingPeriod.String()), + sdk.NewAttribute(types.AttributeInitialHeight, prop.InitialHeight.String()), + sdk.NewAttribute(types.AttributeInitializationTimeout, strconv.Itoa(int(ts.UnixNano()))), + sdk.NewAttribute(types.AttributeTrustingPeriod, clientState.TrustingPeriod.String()), + sdk.NewAttribute(types.AttributeUnbondingPeriod, clientState.UnbondingPeriod.String()), ), ) @@ -156,7 +155,7 @@ func (k Keeper) HandleConsumerRemovalProposal(ctx sdk.Context, p *types.Consumer func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan bool) (err error) { // check that a client for chainID exists if _, found := k.GetConsumerClientId(ctx, chainID); !found { - return errorsmod.Wrap(ccv.ErrConsumerChainNotFound, + return errorsmod.Wrap(types.ErrConsumerChainNotFound, fmt.Sprintf("cannot stop non-existent consumer chain: %s", chainID)) } @@ -215,21 +214,6 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan boo k.DeleteUnbondingOpIndex(ctx, chainID, unbondingOpsIndex.VscId) } - // Remove any existing throttling related entries from the global queue, - // only for this consumer. - // Note: this call panics if the throttling state is invalid - k.DeleteGlobalSlashEntriesForConsumer(ctx, chainID) - - if k.GetThrottledPacketDataSize(ctx, chainID) > 0 { - k.Logger(ctx).Info("There are throttled slash and/or vsc matured packet data instances queued,"+ - " from a consumer that is being removed. This packet data will be thrown out!", "chainID", chainID) - } - - // Remove all throttled slash packets and vsc matured packets queued for this consumer. - // Note: queued VSC matured packets can be safely removed from the per-chain queue, - // since all unbonding operations for this consumer are release above. - k.DeleteThrottledPacketDataForConsumer(ctx, chainID) - k.Logger(ctx).Info("consumer chain removed from provider", "chainID", chainID) return nil @@ -239,7 +223,7 @@ func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan boo func (k Keeper) MakeConsumerGenesis( ctx sdk.Context, prop *types.ConsumerAdditionProposal, -) (gen consumertypes.GenesisState, nextValidatorsHash []byte, err error) { +) (gen ccv.ConsumerGenesisState, nextValidatorsHash []byte, err error) { chainID := prop.ChainId providerUnbondingPeriod := k.stakingKeeper.UnbondingTime(ctx) height := clienttypes.GetSelfHeight(ctx) @@ -302,7 +286,7 @@ func (k Keeper) MakeConsumerGenesis( } hash := tmtypes.NewValidatorSet(updatesAsValSet).Hash() - consumerGenesisParams := consumertypes.NewParams( + consumerGenesisParams := ccv.NewParams( true, prop.BlocksPerDistributionTransmission, prop.DistributionTransmissionChannel, @@ -315,9 +299,10 @@ func (k Keeper) MakeConsumerGenesis( "0.05", []string{}, []string{}, + ccv.DefaultRetryDelayPeriod, ) - gen = *consumertypes.NewInitialGenesisState( + gen = *ccv.NewInitialConsumerGenesisState( clientState, consState.(*ibctmtypes.ConsensusState), initialUpdatesWithConsumerKeys, @@ -617,3 +602,31 @@ func (k Keeper) HandleEquivocationProposal(ctx sdk.Context, p *types.Equivocatio } return nil } + +func (k Keeper) HandleConsumerRewardDenomProposal(ctx sdk.Context, p *types.ChangeRewardDenomsProposal) error { + for _, denomToAdd := range p.DenomsToAdd { + // Log error and move on if one of the denoms is already registered + if k.ConsumerRewardDenomExists(ctx, denomToAdd) { + ctx.Logger().Error("denom %s already registered", denomToAdd) + continue + } + k.SetConsumerRewardDenom(ctx, denomToAdd) + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeAddConsumerRewardDenom, + sdk.NewAttribute(types.AttributeConsumerRewardDenom, denomToAdd), + )) + } + for _, denomToRemove := range p.DenomsToRemove { + // Log error and move on if one of the denoms is not registered + if !k.ConsumerRewardDenomExists(ctx, denomToRemove) { + ctx.Logger().Error("denom %s not registered", denomToRemove) + continue + } + k.DeleteConsumerRewardDenom(ctx, denomToRemove) + ctx.EventManager().EmitEvent(sdk.NewEvent( + types.EventTypeRemoveConsumerRewardDenom, + sdk.NewAttribute(types.AttributeConsumerRewardDenom, denomToRemove), + )) + } + return nil +} diff --git a/x/ccv/provider/keeper/proposal_test.go b/x/ccv/provider/keeper/proposal_test.go index c84369e815..568b2c30e0 100644 --- a/x/ccv/provider/keeper/proposal_test.go +++ b/x/ccv/provider/keeper/proposal_test.go @@ -18,9 +18,7 @@ import ( abci "github.com/cometbft/cometbft/abci/types" - cryptoutil "github.com/cosmos/interchain-security/v3/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" providerkeeper "github.com/cosmos/interchain-security/v3/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" @@ -233,6 +231,7 @@ func TestPendingConsumerAdditionPropDeletion(t *testing.T) { defer ctrl.Finish() for _, tc := range testCases { + tc := tc providerKeeper.SetPendingConsumerAdditionProp(ctx, &tc.ConsumerAdditionProposal) } @@ -473,6 +472,9 @@ func TestHandleConsumerRemovalProposal(t *testing.T) { // meaning no external keeper methods are allowed to be called. if tc.expAppendProp { testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks) + + // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel + gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) } tc.setupMocks(ctx, providerKeeper, tc.prop.ChainId) @@ -523,29 +525,13 @@ func TestStopConsumerChain(t *testing.T) { }, expErr: true, }, - { - description: "valid stop of consumer chain, throttle related queues are cleaned", - setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { - testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks) - - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - ctx.BlockTime(), "chainID", 1, cryptoutil.NewCryptoIdentityFromIntSeed(90).ProviderConsAddress())) - - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "chainID", 1, testkeeper.GetNewSlashPacketData()) - if err != nil { - t.Fatal(err) - } - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chainID", 2, testkeeper.GetNewVSCMaturedPacketData()) - if err != nil { - t.Fatal(err) - } - }, - expErr: false, - }, { description: "valid stop of consumer chain, all mock calls hit", setup: func(ctx sdk.Context, providerKeeper *providerkeeper.Keeper, mocks testkeeper.MockedKeepers) { testkeeper.SetupForStoppingConsumerChain(t, ctx, providerKeeper, mocks) + + // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel + gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) }, expErr: false, }, @@ -569,48 +555,12 @@ func TestStopConsumerChain(t *testing.T) { require.NoError(t, err) } - testProviderStateIsCleaned(t, ctx, providerKeeper, "chainID", "channelID") + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "chainID", "channelID") ctrl.Finish() } } -// testProviderStateIsCleaned executes test assertions for the proposer's state being cleaned after a stopped consumer chain. -func testProviderStateIsCleaned(t *testing.T, ctx sdk.Context, providerKeeper providerkeeper.Keeper, - expectedChainID, expectedChannelID string, -) { - t.Helper() - _, found := providerKeeper.GetConsumerClientId(ctx, expectedChainID) - require.False(t, found) - _, found = providerKeeper.GetChainToChannel(ctx, expectedChainID) - require.False(t, found) - _, found = providerKeeper.GetChannelToChain(ctx, expectedChannelID) - require.False(t, found) - _, found = providerKeeper.GetInitChainHeight(ctx, expectedChainID) - require.False(t, found) - acks := providerKeeper.GetSlashAcks(ctx, expectedChainID) - require.Empty(t, acks) - _, found = providerKeeper.GetInitTimeoutTimestamp(ctx, expectedChainID) - require.False(t, found) - - require.Empty(t, providerKeeper.GetAllVscSendTimestamps(ctx, expectedChainID)) - - // test key assignment state is cleaned - require.Empty(t, providerKeeper.GetAllValidatorConsumerPubKeys(ctx, &expectedChainID)) - require.Empty(t, providerKeeper.GetAllValidatorsByConsumerAddr(ctx, &expectedChainID)) - require.Empty(t, providerKeeper.GetAllKeyAssignmentReplacements(ctx, expectedChainID)) - require.Empty(t, providerKeeper.GetAllConsumerAddrsToPrune(ctx, expectedChainID)) - - allGlobalEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) - for _, entry := range allGlobalEntries { - require.NotEqual(t, expectedChainID, entry.ConsumerChainID) - } - - slashPacketData, vscMaturedPacketData, _, _ := providerKeeper.GetAllThrottledPacketData(ctx, expectedChainID) - require.Empty(t, slashPacketData) - require.Empty(t, vscMaturedPacketData) -} - // TestPendingConsumerRemovalPropDeletion tests the getting/setting // and deletion methods for pending consumer removal props func TestPendingConsumerRemovalPropDeletion(t *testing.T) { @@ -631,6 +581,7 @@ func TestPendingConsumerRemovalPropDeletion(t *testing.T) { defer ctrl.Finish() for _, tc := range testCases { + tc := tc providerKeeper.SetPendingConsumerRemovalProp(ctx, &tc.ConsumerRemovalProposal) } @@ -821,7 +772,6 @@ func TestMakeConsumerGenesis(t *testing.T) { VscTimeoutPeriod: providertypes.DefaultVscTimeoutPeriod, SlashMeterReplenishPeriod: providertypes.DefaultSlashMeterReplenishPeriod, SlashMeterReplenishFraction: providertypes.DefaultSlashMeterReplenishFraction, - MaxThrottledPackets: providertypes.DefaultMaxThrottledPackets, ConsumerRewardDenomRegistrationFee: sdk.Coin{ Denom: "stake", Amount: sdk.NewInt(1000000), @@ -864,86 +814,88 @@ func TestMakeConsumerGenesis(t *testing.T) { "unbonding_period": 1728000000000000, "soft_opt_out_threshold": "0.05", "reward_denoms": [], - "provider_reward_denoms": [] + "provider_reward_denoms": [], + "retry_delay_period": 3600000000000 }, "new_chain": true, - "provider_client_state": { - "chain_id": "testchain1", - "trust_level": { - "numerator": 1, - "denominator": 3 - }, - "trusting_period": 1197504000000000, - "unbonding_period": 1814400000000000, - "max_clock_drift": 10000000000, - "frozen_height": {}, - "latest_height": { - "revision_height": 5 - }, - "proof_specs": [ - { - "leaf_spec": { - "hash": 1, - "prehash_value": 1, - "length": 1, - "prefix": "AA==" + "provider" : { + "client_state": { + "chain_id": "testchain1", + "trust_level": { + "numerator": 1, + "denominator": 3 + }, + "trusting_period": 1197504000000000, + "unbonding_period": 1814400000000000, + "max_clock_drift": 10000000000, + "frozen_height": {}, + "latest_height": { + "revision_height": 5 + }, + "proof_specs": [ + { + "leaf_spec": { + "hash": 1, + "prehash_value": 1, + "length": 1, + "prefix": "AA==" + }, + "inner_spec": { + "child_order": [0, 1], + "child_size": 33, + "min_prefix_length": 4, + "max_prefix_length": 12, + "hash": 1 + } }, - "inner_spec": { - "child_order": [0, 1], - "child_size": 33, - "min_prefix_length": 4, - "max_prefix_length": 12, - "hash": 1 + { + "leaf_spec": { + "hash": 1, + "prehash_value": 1, + "length": 1, + "prefix": "AA==" + }, + "inner_spec": { + "child_order": [0, 1], + "child_size": 32, + "min_prefix_length": 1, + "max_prefix_length": 1, + "hash": 1 + } } + ], + "upgrade_path": ["upgrade", "upgradedIBCState"], + "allow_update_after_expiry": true, + "allow_update_after_misbehaviour": true + }, + "consensus_state": { + "timestamp": "2020-01-02T00:00:10Z", + "root": { + "hash": "LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA=" }, + "next_validators_hash": "E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE" + }, + "initial_val_set": [ { - "leaf_spec": { - "hash": 1, - "prehash_value": 1, - "length": 1, - "prefix": "AA==" + "pub_key": { + "type": "tendermint/PubKeyEd25519", + "value": "dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro=" }, - "inner_spec": { - "child_order": [0, 1], - "child_size": 32, - "min_prefix_length": 1, - "max_prefix_length": 1, - "hash": 1 - } + "power": 1 } - ], - "upgrade_path": ["upgrade", "upgradedIBCState"], - "allow_update_after_expiry": true, - "allow_update_after_misbehaviour": true - }, - "provider_consensus_state": { - "timestamp": "2020-01-02T00:00:10Z", - "root": { - "hash": "LpGpeyQVLUo9HpdsgJr12NP2eCICspcULiWa5u9udOA=" - }, - "next_validators_hash": "E30CE736441FB9101FADDAF7E578ABBE6DFDB67207112350A9A904D554E1F5BE" - }, - "unbonding_sequences": null, - "initial_val_set": [ - { - "pub_key": { - "type": "tendermint/PubKeyEd25519", - "value": "dcASx5/LIKZqagJWN0frOlFtcvz91frYmj/zmoZRWro=" - }, - "power": 1 - } - ] + ] + } }` - var expectedGenesis consumertypes.GenesisState + var expectedGenesis ccvtypes.ConsumerGenesisState err = json.Unmarshal([]byte(jsonString), &expectedGenesis) // ignores tabs, newlines and spaces require.NoError(t, err) // Zeroing out different fields that are challenging to mock - actualGenesis.InitialValSet = []abci.ValidatorUpdate{} - expectedGenesis.InitialValSet = []abci.ValidatorUpdate{} - actualGenesis.ProviderConsensusState = &ibctmtypes.ConsensusState{} - expectedGenesis.ProviderConsensusState = &ibctmtypes.ConsensusState{} + actualGenesis.Provider.InitialValSet = []abci.ValidatorUpdate{} + expectedGenesis.Provider.InitialValSet = []abci.ValidatorUpdate{} + actualGenesis.Provider.ConsensusState = &ibctmtypes.ConsensusState{} + expectedGenesis.Provider.ConsensusState = &ibctmtypes.ConsensusState{} require.Equal(t, expectedGenesis, actualGenesis, "consumer chain genesis created incorrectly") } @@ -1075,8 +1027,8 @@ func TestBeginBlockCCR(t *testing.T) { expectations = append(expectations, testkeeper.GetMocksForSetConsumerChain(ctx, &mocks, prop.ChainId)...) } // Only first two consumer chains should be stopped - expectations = append(expectations, testkeeper.GetMocksForStopConsumerChain(ctx, &mocks)...) - expectations = append(expectations, testkeeper.GetMocksForStopConsumerChain(ctx, &mocks)...) + expectations = append(expectations, testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) + expectations = append(expectations, testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) gomock.InOrder(expectations...) diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index d63594dad1..0cbce718a7 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -17,7 +17,7 @@ import ( ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) -// OnRecvVSCMaturedPacket handles a VSCMatured packet +// OnRecvVSCMaturedPacket handles a VSCMatured packet and returns a no-op result ack. func (k Keeper) OnRecvVSCMaturedPacket( ctx sdk.Context, packet channeltypes.Packet, @@ -34,12 +34,9 @@ func (k Keeper) OnRecvVSCMaturedPacket( panic(fmt.Errorf("VSCMaturedPacket received on unknown channel %s", packet.DestinationChannel)) } - if err := k.QueueThrottledVSCMaturedPacketData(ctx, chainID, packet.Sequence, data); err != nil { - return ccv.NewErrorAcknowledgementWithLog(ctx, fmt.Errorf( - "failed to queue VSCMatured packet data: %s", err.Error())) - } + k.HandleVSCMaturedPacket(ctx, chainID, data) - k.Logger(ctx).Info("VSCMaturedPacket received and enqueued", + k.Logger(ctx).Info("VSCMaturedPacket handled", "chainID", chainID, "vscID", data.ValsetUpdateId, ) @@ -48,35 +45,6 @@ func (k Keeper) OnRecvVSCMaturedPacket( return ack } -// HandleLeadingVSCMaturedPackets handles all VSCMatured packet data that has been queued this block, -// but does not need to be throttled. The handled data is then removed from the queue. -// -// Note: VSC matured packet data which is queued behind slash packet data CANNOT be -// handled until the leading slash packet data has been handled. This is to maintain -// the "VSC Maturity and Slashing Order" CCV property. If VSC matured packet data DOES NOT -// trail slash packet data for that consumer, it will be handled in this method, -// bypassing HandleThrottleQueues. -func (k Keeper) HandleLeadingVSCMaturedPackets(ctx sdk.Context) (vscMaturedHandledThisBlock int) { - vscMaturedHandledThisBlock = 0 - for _, chain := range k.GetAllConsumerChains(ctx) { - // Note: it's assumed the order of the vsc matured slice matches the order of the ibc seq nums slice, - // in that a vsc matured packet data at index i is associated with the ibc seq num at index i. - leadingVscMatured, ibcSeqNums := k.GetLeadingVSCMaturedData(ctx, chain.ChainId) - ibcSeqNumsHandled := []uint64{} - for idx, data := range leadingVscMatured { - if vscMaturedHandledThisBlock >= vscMaturedHandledPerBlockLimit { - // Break from inner for-loop, DeleteThrottledPacketData will still be called for this consumer - break - } - k.HandleVSCMaturedPacket(ctx, chain.ChainId, data) - vscMaturedHandledThisBlock++ - ibcSeqNumsHandled = append(ibcSeqNumsHandled, ibcSeqNums[idx]) - } - k.DeleteThrottledPacketData(ctx, chain.ChainId, ibcSeqNumsHandled...) - } - return vscMaturedHandledThisBlock -} - // HandleVSCMaturedPacket handles a VSCMatured packet. // // Note: This method should only panic for a system critical error like a @@ -270,18 +238,10 @@ func (k Keeper) QueueVSCPackets(ctx sdk.Context) { k.IncrementValidatorSetUpdateId(ctx) } -// EndBlockCIS contains the EndBlock logic needed for -// the Consumer Initiated Slashing sub-protocol -func (k Keeper) EndBlockCIS(ctx sdk.Context) { - // set the ValsetUpdateBlockHeight - blockHeight := uint64(ctx.BlockHeight()) + 1 - valUpdateID := k.GetValidatorSetUpdateId(ctx) - k.SetValsetUpdateBlockHeight(ctx, valUpdateID, blockHeight) - k.Logger(ctx).Debug("vscID was mapped to block height", "vscID", valUpdateID, "height", blockHeight) - - // Replenish slash meter if necessary, BEFORE executing slash packet throttling logic. - // This ensures the meter value is replenished, and not greater than the allowance (max value) - // for the block, before the throttling logic is executed. +// BeginBlockCIS contains the BeginBlock logic needed for the Consumer Initiated Slashing sub-protocol. +func (k Keeper) BeginBlockCIS(ctx sdk.Context) { + // Replenish slash meter if necessary. This ensures the meter value is replenished before handling any slash packets, + // and ensures the meter value is not greater than the allowance (max value) for the block. // // Note: CheckForSlashMeterReplenishment contains panics for the following scenarios, any of which should never occur // if the protocol is correct and external data is properly validated: @@ -291,23 +251,16 @@ func (k Keeper) EndBlockCIS(ctx sdk.Context) { // - Marshaling and/or store corruption errors. // - Setting invalid slash meter values (see SetSlashMeter). k.CheckForSlashMeterReplenishment(ctx) +} - // Handle leading vsc matured packets before throttling logic. - // - // Note: HandleLeadingVSCMaturedPackets contains panics for the following scenarios, any of which should never occur - // if the protocol is correct and external data is properly validated: - // - // - Marshaling and/or store corruption errors. - vscMaturedHandledThisBlock := k.HandleLeadingVSCMaturedPackets(ctx) - // Handle queue entries considering throttling logic. - // - // Note: HandleThrottleQueues contains panics for the following scenarios, any of which should never occur - // if the protocol is correct and external data is properly validated: - // - // - SlashMeter has not been set (which should be set in InitGenesis, see InitializeSlashMeter). - // - Marshaling and/or store corruption errors. - // - Setting invalid slash meter values (see SetSlashMeter). - k.HandleThrottleQueues(ctx, vscMaturedHandledThisBlock) +// EndBlockCIS contains the EndBlock logic needed for +// the Consumer Initiated Slashing sub-protocol +func (k Keeper) EndBlockCIS(ctx sdk.Context) { + // set the ValsetUpdateBlockHeight + blockHeight := uint64(ctx.BlockHeight()) + 1 + valUpdateID := k.GetValidatorSetUpdateId(ctx) + k.SetValsetUpdateBlockHeight(ctx, valUpdateID, blockHeight) + k.Logger(ctx).Debug("vscID was mapped to block height", "vscID", valUpdateID, "height", blockHeight) } // OnRecvSlashPacket delivers a received slash packet, validates it and @@ -358,20 +311,27 @@ func (k Keeper) OnRecvSlashPacket(ctx sdk.Context, packet channeltypes.Packet, d return channeltypes.NewResultAcknowledgement(ccv.V1Result) } - // Queue a slash entry to the global queue, which will be seen by the throttling logic - k.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - ctx.BlockTime(), // recv time - chainID, // consumer chain id that sent the packet - packet.Sequence, // IBC sequence number of the packet - providerConsAddr)) // Provider consensus address of val to be slashed - - // Queue slash packet data in the same (consumer chain specific) queue as vsc matured packet data, - // to enforce order of handling between the two packet data types. - if err := k.QueueThrottledSlashPacketData(ctx, chainID, packet.Sequence, data); err != nil { - return ccv.NewErrorAcknowledgementWithLog(ctx, fmt.Errorf("failed to queue slash packet data: %s", err.Error())) + meter := k.GetSlashMeter(ctx) + // Return bounce ack if meter is negative in value + if meter.IsNegative() { + k.Logger(ctx).Info("SlashPacket received, but meter is negative. Packet will be bounced", + "chainID", chainID, + "consumer cons addr", consumerConsAddr.String(), + "provider cons addr", providerConsAddr.String(), + "vscID", data.ValsetUpdateId, + "infractionType", data.Infraction, + ) + return channeltypes.NewResultAcknowledgement(ccv.SlashPacketBouncedResult) } - k.Logger(ctx).Info("slash packet received and enqueued", + // Subtract voting power that will be jailed/tombstoned from the slash meter, + // BEFORE handling slash packet. + meter = meter.Sub(k.GetEffectiveValPower(ctx, providerConsAddr)) + k.SetSlashMeter(ctx, meter) + + k.HandleSlashPacket(ctx, chainID, data) + + k.Logger(ctx).Info("slash packet received and handled", "chainID", chainID, "consumer cons addr", consumerConsAddr.String(), "provider cons addr", providerConsAddr.String(), @@ -379,7 +339,8 @@ func (k Keeper) OnRecvSlashPacket(ctx sdk.Context, packet channeltypes.Packet, d "infractionType", data.Infraction, ) - return channeltypes.NewResultAcknowledgement(ccv.V1Result) + // Return result ack that the packet was handled successfully + return channeltypes.NewResultAcknowledgement(ccv.SlashPacketHandledResult) } // ValidateSlashPacket validates a recv slash packet before it is @@ -465,11 +426,11 @@ func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data ccv.Slas ctx.EventManager().EmitEvent( sdk.NewEvent( - ccv.EventTypeExecuteConsumerChainSlash, + providertypes.EventTypeExecuteConsumerChainSlash, sdk.NewAttribute(sdk.AttributeKeyModule, providertypes.ModuleName), sdk.NewAttribute(ccv.AttributeValidatorAddress, providerConsAddr.String()), sdk.NewAttribute(ccv.AttributeInfractionType, data.Infraction.String()), - sdk.NewAttribute(ccv.AttributeInfractionHeight, strconv.Itoa(int(infractionHeight))), + sdk.NewAttribute(providertypes.AttributeInfractionHeight, strconv.Itoa(int(infractionHeight))), sdk.NewAttribute(ccv.AttributeValSetUpdateID, strconv.Itoa(int(data.ValsetUpdateId))), ), ) @@ -491,7 +452,7 @@ func (k Keeper) EndBlockCCR(ctx sdk.Context) { "chainID", initTimeoutTimestamp.ChainId) err := k.StopConsumerChain(ctx, initTimeoutTimestamp.ChainId, false) if err != nil { - if ccv.ErrConsumerChainNotFound.Is(err) { + if providertypes.ErrConsumerChainNotFound.Is(err) { // consumer chain not found continue } @@ -518,7 +479,7 @@ func (k Keeper) EndBlockCCR(ctx sdk.Context) { ) err := k.StopConsumerChain(ctx, channelToChain.ChainId, true) if err != nil { - if ccv.ErrConsumerChainNotFound.Is(err) { + if providertypes.ErrConsumerChainNotFound.Is(err) { // consumer chain not found continue } diff --git a/x/ccv/provider/keeper/relay_test.go b/x/ccv/provider/keeper/relay_test.go index b266211a42..bc482d30a2 100644 --- a/x/ccv/provider/keeper/relay_test.go +++ b/x/ccv/provider/keeper/relay_test.go @@ -1,22 +1,24 @@ package keeper_test import ( + "strings" "testing" - "time" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" exported "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + "cosmossdk.io/math" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" abci "github.com/cometbft/cometbft/abci/types" - ibcsimapp "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp" cryptotestutil "github.com/cosmos/interchain-security/v3/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" "github.com/cosmos/interchain-security/v3/x/ccv/provider/keeper" @@ -26,7 +28,7 @@ import ( // TestQueueVSCPackets tests queueing validator set updates. func TestQueueVSCPackets(t *testing.T) { - key := ibcsimapp.CreateTestPubKeys(1)[0] + _, _, key := ibctesting.GenerateKeys(t, 1) tmPubKey, _ := cryptocodec.ToTmProtoPublicKey(key) testCases := []struct { @@ -92,10 +94,8 @@ func TestQueueVSCPackets(t *testing.T) { } // TestOnRecvVSCMaturedPacket tests the OnRecvVSCMaturedPacket method of the keeper. -// Particularly the behavior that VSC matured packet data should be handled immediately -// if the pending packet data queue is empty, and should be queued otherwise. // -// Note: Handling logic itself is not testing in here, just queueing behavior. +// Note: Handling logic itself is not tested here. func TestOnRecvVSCMaturedPacket(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -105,131 +105,69 @@ func TestOnRecvVSCMaturedPacket(t *testing.T) { providerKeeper.SetChannelToChain(ctx, "channel-1", "chain-1") providerKeeper.SetChannelToChain(ctx, "channel-2", "chain-2") - // Execute on recv for chain-1 + // Execute on recv for chain-1, confirm v1 result ack is returned ack := executeOnRecvVSCMaturedPacket(t, &providerKeeper, ctx, "channel-1", 1) require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - // Assert that the packet data was queued for chain-1 - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - - // chain-2 queue empty - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - - // Now queue a slash packet data instance for chain-2, then confirm the on recv method - // queues the vsc matured behind the slash packet data - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-2", 1, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) + // Now queue a slash packet data instance for chain-2, confirm v1 result ack is returned ack = executeOnRecvVSCMaturedPacket(t, &providerKeeper, ctx, "channel-2", 2) require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - require.Equal(t, uint64(2), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - - // Chain-1 still has 1 packet data queued - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - - // Receive 5 more vsc matured packets for chain-2, then confirm chain-2 queue size is 7, chain-1 still size 1 - for i := 0; i < 5; i++ { - ack = executeOnRecvVSCMaturedPacket(t, &providerKeeper, ctx, "channel-2", uint64(i+3)) - require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - } - require.Equal(t, uint64(7), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - - // Delete chain-2's data from its queue, then confirm the queue size is 0 - providerKeeper.DeleteThrottledPacketData(ctx, "chain-2", []uint64{1, 2, 3, 4, 5, 6, 7}...) - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) } -func TestHandleLeadingVSCMaturedPackets(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) +// TestOnRecvDowntimeSlashPacket tests the OnRecvSlashPacket method specifically for downtime slash packets. +func TestOnRecvDowntimeSlashPacket(t *testing.T) { + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - vscData := getTenSampleVSCMaturedPacketData() - - // Set channel to chain, and chain to client mappings - // (faking multiple established consumer channels) + // Set channel to chain (faking multiple established channels) providerKeeper.SetChannelToChain(ctx, "channel-1", "chain-1") - providerKeeper.SetConsumerClientId(ctx, "chain-1", "client-1") providerKeeper.SetChannelToChain(ctx, "channel-2", "chain-2") - providerKeeper.SetConsumerClientId(ctx, "chain-2", "client-2") - // Queue some leading vsc matured packet data for chain-1 - err := providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 1, vscData[0]) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 2, vscData[1]) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 3, vscData[2]) - require.NoError(t, err) + // Generate a new slash packet data instance with double sign infraction type + packetData := testkeeper.GetNewSlashPacketData() + packetData.Infraction = stakingtypes.Infraction_INFRACTION_DOWNTIME - // Queue some trailing slash packet data (and a couple more vsc matured) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-1", 4, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-1", 5, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 6, vscData[3]) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-1", 7, vscData[4]) - require.NoError(t, err) + // Set a block height for the valset update id in the generated packet data + providerKeeper.SetValsetUpdateBlockHeight(ctx, packetData.ValsetUpdateId, uint64(15)) - // Queue some leading vsc matured packet data for chain-2 - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-2", 1, vscData[5]) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-2", 2, vscData[6]) - require.NoError(t, err) + // Set slash meter to negative value and assert a bounce ack is returned + providerKeeper.SetSlashMeter(ctx, math.NewInt(-5)) + ack := executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-1", 1, packetData) + require.Equal(t, channeltypes.NewResultAcknowledgement(ccv.SlashPacketBouncedResult), ack) - // And trailing slash packet data for chain-2 - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-2", 3, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-2", 4, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) + // Also bounced for chain-2 + ack = executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-2", 2, packetData) + require.Equal(t, channeltypes.NewResultAcknowledgement(ccv.SlashPacketBouncedResult), ack) + + // Now set slash meter to positive value and assert slash packet handled result is returned + providerKeeper.SetSlashMeter(ctx, math.NewInt(5)) + + // Mock call to GetEffectiveValPower, so that it returns 2. + providerAddr := providertypes.NewProviderConsAddress(packetData.Validator.Address) + calls := []*gomock.Call{ + mocks.MockStakingKeeper.EXPECT().GetValidatorByConsAddr(ctx, providerAddr.ToSdkConsAddr()). + Return(stakingtypes.Validator{}, true).Times(1), + mocks.MockStakingKeeper.EXPECT().GetLastValidatorPower(ctx, gomock.Any()). + Return(int64(2)).Times(1), + } - // And one more trailing vsc matured packet for chain-2 - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-2", 5, vscData[7]) - require.NoError(t, err) + // Add mocks for slash packet handling + calls = append(calls, + testkeeper.GetMocksForHandleSlashPacket( + ctx, mocks, providerAddr, stakingtypes.Validator{Jailed: false}, true)..., + ) + gomock.InOrder(calls...) - // Set VSC Send timestamps for each recv vsc matured packet - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[0].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[1].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[2].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[3].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-1", vscData[4].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-2", vscData[5].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-2", vscData[6].ValsetUpdateId, time.Now()) - providerKeeper.SetVscSendTimestamp(ctx, "chain-2", vscData[7].ValsetUpdateId, time.Now()) - - // Confirm each chain-specific queue has the expected number of packet data instances - require.Equal(t, uint64(7), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - require.Equal(t, uint64(5), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - - // Handle leading vsc matured packets and confirm queue sizes change for both chains - providerKeeper.HandleLeadingVSCMaturedPackets(ctx) - require.Equal(t, uint64(4), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - require.Equal(t, uint64(3), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - - // Confirm the leading vsc matured packet data was handled for both chains, - // but not the vsc matured packet data that trails slash data in the queue. - // This assertion is made by checking that VSC Send timestamps were deleted for - // handled vsc matured packet data. - _, found := providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[0].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[1].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[2].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[3].ValsetUpdateId) - require.True(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-1", vscData[4].ValsetUpdateId) - require.True(t, found) + // Execute on recv and confirm slash packet handled result is returned + ack = executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-1", 1, packetData) + require.Equal(t, channeltypes.NewResultAcknowledgement(ccv.SlashPacketHandledResult), ack) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-2", vscData[5].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-2", vscData[6].ValsetUpdateId) - require.False(t, found) - _, found = providerKeeper.GetVscSendTimestamp(ctx, "chain-2", vscData[7].ValsetUpdateId) - require.True(t, found) + // Require slash meter was decremented appropriately, 5-2=3 + require.Equal(t, int64(3), providerKeeper.GetSlashMeter(ctx).Int64()) } -// TestOnRecvSlashPacket tests the OnRecvSlashPacket method specifically for double-sign slash packets. +// TestOnRecvDoubleSignSlashPacket tests the OnRecvSlashPacket method specifically for double-sign slash packets. func TestOnRecvDoubleSignSlashPacket(t *testing.T) { providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) defer ctrl.Finish() @@ -248,12 +186,8 @@ func TestOnRecvDoubleSignSlashPacket(t *testing.T) { // Receive the double-sign slash packet for chain-1 and confirm the expected acknowledgement ack := executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-1", 1, packetData) - require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) + require.Equal(t, channeltypes.NewResultAcknowledgement(ccv.V1Result), ack) - // Nothing should be queued - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) - require.Equal(t, 0, len(providerKeeper.GetAllGlobalSlashEntries(ctx))) require.True(t, providerKeeper.GetSlashLog(ctx, providertypes.NewProviderConsAddress(packetData.Validator.Address))) @@ -262,56 +196,6 @@ func TestOnRecvDoubleSignSlashPacket(t *testing.T) { require.False(t, providerKeeper.GetSlashLog(ctx, randomAddress)) } -// TestOnRecvSlashPacket tests the OnRecvSlashPacket method specifically for downtime slash packets, -// and how the method interacts with the parent and per-chain slash packet queues. -func TestOnRecvDowntimeSlashPacket(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Set channel to chain (faking multiple established channels) - providerKeeper.SetChannelToChain(ctx, "channel-1", "chain-1") - providerKeeper.SetChannelToChain(ctx, "channel-2", "chain-2") - - // Generate a new slash packet data instance with downtime infraction type - packetData := testkeeper.GetNewSlashPacketData() - packetData.Infraction = stakingtypes.Infraction_INFRACTION_DOWNTIME - - // Set a block height for the valset update id in the generated packet data - providerKeeper.SetValsetUpdateBlockHeight(ctx, packetData.ValsetUpdateId, uint64(15)) - - // Receive the downtime slash packet for chain-1 at time.Now() - ctx = ctx.WithBlockTime(time.Now()) - ack := executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-1", 1, packetData) - require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - - // Confirm an entry was added to the global queue, and pending packet data was added to the per-chain queue - globalEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) // parent queue - require.Equal(t, 1, len(globalEntries)) - require.Equal(t, "chain-1", globalEntries[0].ConsumerChainID) - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) // per chain queue - - // Generate a new downtime packet data instance with downtime infraction type - packetData = testkeeper.GetNewSlashPacketData() - packetData.Infraction = stakingtypes.Infraction_INFRACTION_DOWNTIME - - // Set a block height for the valset update id in the generated packet data - providerKeeper.SetValsetUpdateBlockHeight(ctx, packetData.ValsetUpdateId, uint64(15)) - - // Receive a downtime slash packet for chain-2 at time.Now(Add(1 *time.Hour)) - ctx = ctx.WithBlockTime(time.Now().Add(1 * time.Hour)) - ack = executeOnRecvSlashPacket(t, &providerKeeper, ctx, "channel-2", 2, packetData) - require.Equal(t, channeltypes.NewResultAcknowledgement([]byte{byte(1)}), ack) - - // Confirm sizes of parent queue and both per-chain queues - globalEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 2, len(globalEntries)) - require.Equal(t, "chain-1", globalEntries[0].ConsumerChainID) - require.Equal(t, "chain-2", globalEntries[1].ConsumerChainID) - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-1")) // per chain queue - require.Equal(t, uint64(1), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-2")) // per chain queue -} - func executeOnRecvVSCMaturedPacket(t *testing.T, providerKeeper *keeper.Keeper, ctx sdk.Context, channelID string, ibcSeqNum uint64, ) exported.Acknowledgement { @@ -699,7 +583,7 @@ func TestSendVSCPacketsToChainFailure(t *testing.T) { ) // Append mocks for expected call to StopConsumerChain - mockCalls = append(mockCalls, testkeeper.GetMocksForStopConsumerChain(ctx, &mocks)...) + mockCalls = append(mockCalls, testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) // Assert mock calls hit gomock.InOrder(mockCalls...) @@ -715,3 +599,72 @@ func TestSendVSCPacketsToChainFailure(t *testing.T) { // Pending VSC packets should be deleted in StopConsumerChain require.Empty(t, providerKeeper.GetPendingVSCPackets(ctx, "consumerChainID")) } + +// TestOnTimeoutPacketWithNoChainFound tests the `OnTimeoutPacket` method fails when no chain is found +func TestOnTimeoutPacketWithNoChainFound(t *testing.T) { + // Keeper setup + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + // We do not `SetChannelToChain` for "channelID" and therefore `OnTimeoutPacket` fails + packet := channeltypes.Packet{ + SourceChannel: "channelID", + } + err := providerKeeper.OnTimeoutPacket(ctx, packet) + require.Error(t, err) + require.True(t, strings.Contains(err.Error(), channeltypes.ErrInvalidChannel.Error())) +} + +// TestOnTimeoutPacketStopsChain tests that the chain is stopped in case of a timeout +func TestOnTimeoutPacketStopsChain(t *testing.T) { + // Keeper setup + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + providerKeeper.SetParams(ctx, providertypes.DefaultParams()) + + testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks) + + packet := channeltypes.Packet{ + SourceChannel: "channelID", + } + err := providerKeeper.OnTimeoutPacket(ctx, packet) + + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "chainID", "channelID") + require.NoError(t, err) +} + +// TestOnAcknowledgementPacketWithNoAckError tests `OnAcknowledgementPacket` when the underlying ack contains no error +func TestOnAcknowledgementPacketWithNoAckError(t *testing.T) { + // Keeper setup + providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + + ack := channeltypes.Acknowledgement{Response: &channeltypes.Acknowledgement_Result{Result: []byte{}}} + err := providerKeeper.OnAcknowledgementPacket(ctx, channeltypes.Packet{}, ack) + require.NoError(t, err) +} + +// TestOnAcknowledgementPacketWithAckError tests `OnAcknowledgementPacket` when the underlying ack contains an error +func TestOnAcknowledgementPacketWithAckError(t *testing.T) { + // Keeper setup + providerKeeper, ctx, ctrl, mocks := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) + defer ctrl.Finish() + providerKeeper.SetParams(ctx, providertypes.DefaultParams()) + + // test that `OnAcknowledgementPacket` returns an error if the ack contains an error and the channel is unknown + ackError := channeltypes.Acknowledgement{Response: &channeltypes.Acknowledgement_Error{Error: "some error"}} + err := providerKeeper.OnAcknowledgementPacket(ctx, channeltypes.Packet{}, ackError) + require.Error(t, err) + require.True(t, strings.Contains(err.Error(), providertypes.ErrUnknownConsumerChannelId.Error())) + + // test that we stop the consumer chain when `OnAcknowledgementPacket` returns an error and the chain is found + testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks) + packet := channeltypes.Packet{ + SourceChannel: "channelID", + } + + err = providerKeeper.OnAcknowledgementPacket(ctx, packet, ackError) + + testkeeper.TestProviderStateIsCleanedAfterConsumerChainIsStopped(t, ctx, providerKeeper, "chainID", "channelID") + require.NoError(t, err) +} diff --git a/x/ccv/provider/keeper/throttle.go b/x/ccv/provider/keeper/throttle.go index d8be629ee7..8232e37a25 100644 --- a/x/ccv/provider/keeper/throttle.go +++ b/x/ccv/provider/keeper/throttle.go @@ -11,64 +11,8 @@ import ( tmtypes "github.com/cometbft/cometbft/types" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) -// This file contains functionality relevant to the throttling of slash and vsc matured packets, aka circuit breaker logic. - -const vscMaturedHandledPerBlockLimit = 100 - -// HandleThrottleQueues iterates over the global slash entry queue, and -// handles all or some portion of throttled (slash and/or VSC matured) packet data received from -// consumer chains. The slash meter is decremented appropriately in this method. -func (k Keeper) HandleThrottleQueues(ctx sdktypes.Context, vscMaturedHandledThisBlock int) { - meter := k.GetSlashMeter(ctx) - // Return if meter is negative in value - if meter.IsNegative() { - return - } - - // Return if vsc matured handle limit was already reached this block, during HandleLeadingVSCMaturedPackets. - // It makes no practical difference for throttling logic to execute next block. - // By doing this, we assure that all leading vsc matured packets were handled before any slash packets. - if vscMaturedHandledThisBlock >= vscMaturedHandledPerBlockLimit { - return - } - - // Obtain all global slash entries, where only some of them may be handled in this method, - // depending on the value of the slash meter. - allEntries := k.GetAllGlobalSlashEntries(ctx) - handledEntries := []providertypes.GlobalSlashEntry{} - - for _, globalEntry := range allEntries { - // Subtract voting power that will be jailed/tombstoned from the slash meter - providerAddr := providertypes.NewProviderConsAddress(globalEntry.ProviderValConsAddr) - meter = meter.Sub(k.GetEffectiveValPower(ctx, providerAddr)) - - // Handle one slash and any trailing vsc matured packet data instances by passing in - // chainID and appropriate callbacks, relevant packet data is deleted in this method. - - k.HandlePacketDataForChain(ctx, globalEntry.ConsumerChainID, k.HandleSlashPacket, k.HandleVSCMaturedPacket, vscMaturedHandledThisBlock) - handledEntries = append(handledEntries, globalEntry) - - // don't handle any more global entries if meter becomes negative in value - if meter.IsNegative() { - k.Logger(ctx).Info("negative slash meter value, no more slash packets will be handled", "meter", meter.Int64()) - break - } - } - - // Handled global entries are deleted after iteration is completed - k.DeleteGlobalSlashEntries(ctx, handledEntries...) - - // Persist current value for slash meter - k.SetSlashMeter(ctx, meter) - - if len(handledEntries) > 0 { - k.Logger(ctx).Info("handled global slash entries", "count", len(handledEntries), "meter", meter.Int64()) - } -} - // Obtains the effective validator power relevant to a validator consensus address. func (k Keeper) GetEffectiveValPower(ctx sdktypes.Context, valConsAddr providertypes.ProviderConsAddress, @@ -87,41 +31,6 @@ func (k Keeper) GetEffectiveValPower(ctx sdktypes.Context, } } -// HandlePacketDataForChain handles only the first queued slash packet relevant to the passed consumer chainID, -// and then handles any trailing vsc matured packets in that (consumer chain specific) throttled packet data queue. -// The handled data is then deleted from the queue. -// -// Note: Any packet data which is handled in this method is also deleted from the (consumer chain specific) queue. -func (k Keeper) HandlePacketDataForChain(ctx sdktypes.Context, consumerChainID string, - slashPacketHandler func(sdktypes.Context, string, ccvtypes.SlashPacketData), - vscMaturedPacketHandler func(sdktypes.Context, string, ccvtypes.VSCMaturedPacketData), - vscMaturedHandledThisBlock int, -) { - // Get slash packet data and trailing vsc matured packet data, handle it all. - slashFound, slashData, vscMaturedData, seqNums := k.GetSlashAndTrailingData(ctx, consumerChainID) - seqNumsHandled := []uint64{} - if slashFound { - slashPacketHandler(ctx, consumerChainID, slashData) - // Due to HandleLeadingVSCMaturedPackets() running before HandleThrottleQueues(), and the fact that - // HandleThrottleQueues() will return until all leading vsc matured have been handled, a slash packet - // should always be the first packet in the queue. So we can safely append the first seqNum here. - seqNumsHandled = append(seqNumsHandled, seqNums[0]) - } - for idx, vscMData := range vscMaturedData { - if vscMaturedHandledThisBlock >= vscMaturedHandledPerBlockLimit { - // Break from for-loop, DeleteThrottledPacketData will still be called for this consumer - break - } - vscMaturedPacketHandler(ctx, consumerChainID, vscMData) - vscMaturedHandledThisBlock++ - // Append seq num for this vsc matured packet - seqNumsHandled = append(seqNumsHandled, seqNums[idx+1]) // Note idx+1, since slash packet is at index 0 - } - - // Delete handled data after it has all been handled. - k.DeleteThrottledPacketData(ctx, consumerChainID, seqNumsHandled...) -} - // InitializeSlashMeter initializes the slash meter to it's max value (also its allowance), // and sets the replenish time candidate to one replenish period from current block time. func (k Keeper) InitializeSlashMeter(ctx sdktypes.Context) { @@ -206,353 +115,6 @@ func (k Keeper) GetSlashMeterAllowance(ctx sdktypes.Context) math.Int { return roundedInt } -// -// CRUD section -// - -// QueueGlobalSlashEntry queues an entry to the "global" slash packet queue, used for throttling val power changes -// related to jailing/tombstoning over time. This "global" queue is used to coordinate the order of slash packet handling -// between chains, whereas the chain-specific queue is used to coordinate the order of slash and vsc matured packets -// relevant to each chain. -func (k Keeper) QueueGlobalSlashEntry(ctx sdktypes.Context, entry providertypes.GlobalSlashEntry) { - store := ctx.KVStore(k.storeKey) - key := providertypes.GlobalSlashEntryKey(entry) - bz := entry.ProviderValConsAddr - store.Set(key, bz) -} - -// DeleteGlobalSlashEntriesForConsumer deletes all pending slash packet entries in the global queue, -// only relevant to a single consumer. -func (k Keeper) DeleteGlobalSlashEntriesForConsumer(ctx sdktypes.Context, consumerChainID string) { - allEntries := k.GetAllGlobalSlashEntries(ctx) - entriesToDel := []providertypes.GlobalSlashEntry{} - - for _, entry := range allEntries { - if entry.ConsumerChainID == consumerChainID { - entriesToDel = append(entriesToDel, entry) - } - } - k.DeleteGlobalSlashEntries(ctx, entriesToDel...) -} - -// GetAllGlobalSlashEntries returns all global slash entries from the queue. -// -// Note global slash entries are stored under keys with the following format: -// GlobalSlashEntryBytePrefix | uint64 recv time | ibc seq num | consumer chain id -// Thus, the returned array is ordered by recv time, then ibc seq num. -func (k Keeper) GetAllGlobalSlashEntries(ctx sdktypes.Context) []providertypes.GlobalSlashEntry { - store := ctx.KVStore(k.storeKey) - iterator := sdktypes.KVStorePrefixIterator(store, []byte{providertypes.GlobalSlashEntryBytePrefix}) - defer iterator.Close() - - entries := []providertypes.GlobalSlashEntry{} - - for ; iterator.Valid(); iterator.Next() { - // MustParseGlobalSlashEntryKey should not panic, since we should be iterating over keys that're - // assumed to be correctly serialized in QueueGlobalSlashEntry. - recvTime, chainID, ibcSeqNum := providertypes.MustParseGlobalSlashEntryKey(iterator.Key()) - valAddr := providertypes.NewProviderConsAddress(iterator.Value()) - entry := providertypes.NewGlobalSlashEntry(recvTime, chainID, ibcSeqNum, valAddr) - entries = append(entries, entry) - } - return entries -} - -// DeleteGlobalSlashEntries deletes the given global entries from the global slash queue -func (k Keeper) DeleteGlobalSlashEntries(ctx sdktypes.Context, entries ...providertypes.GlobalSlashEntry) { - store := ctx.KVStore(k.storeKey) - for _, entry := range entries { - store.Delete(providertypes.GlobalSlashEntryKey(entry)) - } -} - -// Pending packet data type enum, used to encode the type of packet data stored at each entry in the mutual queue. -const ( - slashPacketData byte = iota - vscMaturedPacketData -) - -// GetThrottledPacketDataSize returns the size of the throttled packet data queue for the given consumer chain -func (k Keeper) GetThrottledPacketDataSize(ctx sdktypes.Context, consumerChainID string) uint64 { - store := ctx.KVStore(k.storeKey) - key := providertypes.ThrottledPacketDataSizeKey(consumerChainID) - var size uint64 - bz := store.Get(key) - if bz == nil { - size = 0 - } else { - size = sdktypes.BigEndianToUint64(bz) - } - return size -} - -// SetThrottledPacketDataSize sets the size of the throttled packet data queue for the given consumer chain -func (k Keeper) SetThrottledPacketDataSize(ctx sdktypes.Context, consumerChainID string, size uint64) { - // Sanity check to ensure that the chain-specific throttled packet data queue does not grow too - // large for a single consumer chain. This check ensures that binaries would panic deterministically - // if the queue does grow too large. MaxThrottledPackets should be set accordingly (quite large). - if size >= uint64(k.GetMaxThrottledPackets(ctx)) { - panic(fmt.Sprintf("throttled packet data queue for chain %s is too large: %d", consumerChainID, size)) - } - - store := ctx.KVStore(k.storeKey) - key := providertypes.ThrottledPacketDataSizeKey(consumerChainID) - bz := sdktypes.Uint64ToBigEndian(size) - store.Set(key, bz) -} - -// IncrementThrottledPacketDataSize increments the size of the throttled packet data -// queue for the given consumer chain. -func (k Keeper) IncrementThrottledPacketDataSize(ctx sdktypes.Context, consumerChainID string) { - size := k.GetThrottledPacketDataSize(ctx, consumerChainID) - k.SetThrottledPacketDataSize(ctx, consumerChainID, size+1) - k.Logger(ctx).Debug("incremented throttled packets size", - "chainID", consumerChainID, - "size", size+1, - ) -} - -// QueueThrottledSlashPacketData queues the slash packet data for a chain-specific throttled packet data queue. -// -// Note: This queue is shared between pending slash packet data and pending vsc matured packet data. -func (k Keeper) QueueThrottledSlashPacketData( - ctx sdktypes.Context, consumerChainID string, ibcSeqNum uint64, data ccvtypes.SlashPacketData, -) error { - return k.QueueThrottledPacketData(ctx, consumerChainID, ibcSeqNum, data) -} - -// QueueThrottledVSCMaturedPacketData queues the vsc matured packet data for a chain-specific throttled packet data queue. -// -// Note: This queue is shared between pending slash packet data and pending vsc matured packet data. -func (k Keeper) QueueThrottledVSCMaturedPacketData( - ctx sdktypes.Context, consumerChainID string, ibcSeqNum uint64, data ccvtypes.VSCMaturedPacketData, -) error { - return k.QueueThrottledPacketData(ctx, consumerChainID, ibcSeqNum, data) -} - -// QueueThrottledPacketData queues a slash packet data or vsc matured packet data instance -// for the given consumer chain's queue. -// -// Note: This method returns an error because it is called from -// OnRecvSlashPacket and OnRecvVSCMaturedPacket, meaning we can return an ibc err ack to the -// counter party chain on error, instead of panicking this chain. -func (k Keeper) QueueThrottledPacketData( - ctx sdktypes.Context, consumerChainID string, ibcSeqNum uint64, packetData interface{}, -) error { - store := ctx.KVStore(k.storeKey) - - var bz []byte - var err error - switch data := packetData.(type) { - case ccvtypes.SlashPacketData: - bz, err = data.Marshal() - if err != nil { - return fmt.Errorf("failed to marshal slash packet data: %v", err) - } - bz = append([]byte{slashPacketData}, bz...) - case ccvtypes.VSCMaturedPacketData: - bz, err = data.Marshal() - if err != nil { - return fmt.Errorf("failed to marshal vsc matured packet data: %v", err) - } - bz = append([]byte{vscMaturedPacketData}, bz...) - default: - // Indicates a developer error, this method should only be called - // by tests, QueueThrottledSlashPacketData, or QueueThrottledVSCMaturedPacketData. - panic(fmt.Sprintf("unexpected packet data type: %T", data)) - } - - store.Set(providertypes.ThrottledPacketDataKey(consumerChainID, ibcSeqNum), bz) - k.IncrementThrottledPacketDataSize(ctx, consumerChainID) - return nil -} - -// GetLeadingVSCMaturedData returns the leading vsc matured packet data instances -// for a chain-specific throttled packet data queue. Ie the vsc matured packet data instances -// that do not have any slash packet data instances preceding them in the queue for consumerChainID. -func (k Keeper) GetLeadingVSCMaturedData(ctx sdktypes.Context, consumerChainID string) ( - vscMaturedData []ccvtypes.VSCMaturedPacketData, ibcSeqNums []uint64, -) { - store := ctx.KVStore(k.storeKey) - iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) - defer iterator.Close() - - // Iterate over the throttled packet data queue, - // and return vsc matured packet data instances until we encounter a slash packet data instance. - vscMaturedData = []ccvtypes.VSCMaturedPacketData{} - ibcSeqNums = []uint64{} - for ; iterator.Valid(); iterator.Next() { - - bz := iterator.Value() - if bz[0] == slashPacketData { - break - } else if bz[0] != vscMaturedPacketData { - // This case would indicate a developer error or store corruption, - // since QueueThrottledPacketData should only queue slash packet data or vsc matured packet data. - panic(fmt.Sprintf("unexpected packet data type: %d", bz[0])) - } - - var data ccvtypes.VSCMaturedPacketData - err := data.Unmarshal(bz[1:]) - if err != nil { - // An error here would indicate something is very wrong, - // vsc matured packet data is assumed to be correctly serialized in QueueThrottledPacketData. - panic(fmt.Sprintf("failed to unmarshal vsc matured packet data: %v", err)) - } - - vscMaturedData = append(vscMaturedData, data) - // The below func should not panic, since we should be iterating over keys that're - // assumed to be correctly serialized in QueueThrottledPacketData. - _, ibcSeqNum := providertypes.MustParseThrottledPacketDataKey(iterator.Key()) - ibcSeqNums = append(ibcSeqNums, ibcSeqNum) - } - return vscMaturedData, ibcSeqNums -} - -// GetSlashAndTrailingData returns the first slash packet data instance and any -// trailing vsc matured packet data instances in the chain-specific throttled packet data queue. -// -// Note that throttled packet data is stored under keys with the following format: -// ThrottledPacketDataBytePrefix | len(chainID) | chainID | ibcSeqNum -// Thus, the returned array is in ascending order of ibc seq numbers. -func (k Keeper) GetSlashAndTrailingData(ctx sdktypes.Context, consumerChainID string) ( - slashFound bool, slashData ccvtypes.SlashPacketData, vscMaturedData []ccvtypes.VSCMaturedPacketData, - // Note: this slice contains the IBC sequence numbers of the slash packet data - // and trailing vsc matured packet data instances. This is used by caller to delete the - // data after it has been handled. - ibcSeqNums []uint64, -) { - store := ctx.KVStore(k.storeKey) - iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) - defer iterator.Close() - - slashFound = false - slashData = ccvtypes.SlashPacketData{} - vscMaturedData = []ccvtypes.VSCMaturedPacketData{} - ibcSeqNums = []uint64{} - - for ; iterator.Valid(); iterator.Next() { - - bz := iterator.Value() - if bz[0] == slashPacketData { - if slashFound { - // Break for-loop, we've already found first slash packet data instance. - break - } else { - if err := slashData.Unmarshal(bz[1:]); err != nil { - // An error here would indicate something is very wrong, - // slash packet data is assumed to be correctly serialized in QueueThrottledPacketData. - panic(fmt.Sprintf("failed to unmarshal slash packet data: %v", err)) - } - slashFound = true - } - } else if bz[0] == vscMaturedPacketData { - vscMData := ccvtypes.VSCMaturedPacketData{} - if err := vscMData.Unmarshal(bz[1:]); err != nil { - // An error here would indicate something is very wrong, - // vsc matured packet data is assumed to be correctly serialized in QueueThrottledPacketData. - panic(fmt.Sprintf("failed to unmarshal vsc matured packet data: %v", err)) - } - vscMaturedData = append(vscMaturedData, vscMData) - } else { - // This case would indicate a developer error or store corruption, - // since QueueThrottledPacketData should only queue slash packet data or vsc matured packet data. - panic("invalid packet data type") - } - // The below func should not panic, since we should be iterating over keys that're - // assumed to be correctly serialized in QueueThrottledPacketData. - _, ibcSeqNum := providertypes.MustParseThrottledPacketDataKey(iterator.Key()) - ibcSeqNums = append(ibcSeqNums, ibcSeqNum) - } - return slashFound, slashData, vscMaturedData, ibcSeqNums -} - -// GetAllThrottledPacketData returns all throttled packet data for a specific consumer chain. -// -// Note: This method is only used by tests and queries, hence why it returns redundant data as different types. -// Since this method executes on query, no panics are explicitly included. -func (k Keeper) GetAllThrottledPacketData(ctx sdktypes.Context, consumerChainID string) ( - slashData []ccvtypes.SlashPacketData, vscMaturedData []ccvtypes.VSCMaturedPacketData, - rawOrderedData []interface{}, ibcSeqNums []uint64, -) { - slashData = []ccvtypes.SlashPacketData{} - vscMaturedData = []ccvtypes.VSCMaturedPacketData{} - rawOrderedData = []interface{}{} - ibcSeqNums = []uint64{} - - store := ctx.KVStore(k.storeKey) - iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - bz := iterator.Value() - switch bz[0] { - case slashPacketData: - d := ccvtypes.SlashPacketData{} - if err := d.Unmarshal(bz[1:]); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("failed to unmarshal slash packet data: %v", err)) - continue - } - slashData = append(slashData, d) - rawOrderedData = append(rawOrderedData, d) - case vscMaturedPacketData: - d := ccvtypes.VSCMaturedPacketData{} - if err := d.Unmarshal(bz[1:]); err != nil { - k.Logger(ctx).Error(fmt.Sprintf("failed to unmarshal vsc matured packet data: %v", err)) - continue - } - vscMaturedData = append(vscMaturedData, d) - rawOrderedData = append(rawOrderedData, d) - default: - k.Logger(ctx).Error(fmt.Sprintf("invalid packet data type: %v", bz[0])) - continue - } - _, ibcSeqNum, err := providertypes.ParseThrottledPacketDataKey(iterator.Key()) - if err != nil { - k.Logger(ctx).Error(fmt.Sprintf("failed to parse throttled packet data key: %v", err)) - continue - } - ibcSeqNums = append(ibcSeqNums, ibcSeqNum) - } - - return slashData, vscMaturedData, rawOrderedData, ibcSeqNums -} - -// DeleteAllPacketDataForConsumer deletes all queued packet data for the given consumer chain. -func (k Keeper) DeleteThrottledPacketDataForConsumer(ctx sdktypes.Context, consumerChainID string) { - store := ctx.KVStore(k.storeKey) - iteratorPrefix := providertypes.ChainIdWithLenKey(providertypes.ThrottledPacketDataBytePrefix, consumerChainID) - iterator := sdktypes.KVStorePrefixIterator(store, iteratorPrefix) - defer iterator.Close() - - keysToDel := [][]byte{} - for ; iterator.Valid(); iterator.Next() { - keysToDel = append(keysToDel, iterator.Key()) - } - // Delete data for this consumer - for _, key := range keysToDel { - store.Delete(key) - } - - // Delete size of data queue for this consumer - store.Delete(providertypes.ThrottledPacketDataSizeKey(consumerChainID)) -} - -// DeleteThrottledPacketData deletes the given throttled packet data instances -// (specified by their ibc seq number) from the chain-specific throttled packet data queue. -func (k Keeper) DeleteThrottledPacketData(ctx sdktypes.Context, consumerChainID string, ibcSeqNumbers ...uint64) { - store := ctx.KVStore(k.storeKey) - for _, ibcSeqNum := range ibcSeqNumbers { - store.Delete(providertypes.ThrottledPacketDataKey(consumerChainID, ibcSeqNum)) - } - // Decrement the size of the pending packet data queue - sizeBeforeDeletion := k.GetThrottledPacketDataSize(ctx, consumerChainID) - k.SetThrottledPacketDataSize(ctx, consumerChainID, sizeBeforeDeletion-uint64(len(ibcSeqNumbers))) -} - // GetSlashMeter returns a meter (persisted as a signed int) which stores an amount of voting power, corresponding // to an allowance of validators that can be jailed/tombstoned over time. // diff --git a/x/ccv/provider/keeper/throttle_test.go b/x/ccv/provider/keeper/throttle_test.go index a5356b0dc0..24e8c0ddde 100644 --- a/x/ccv/provider/keeper/throttle_test.go +++ b/x/ccv/provider/keeper/throttle_test.go @@ -1,13 +1,11 @@ package keeper_test import ( - "math/rand" "testing" "time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" - "golang.org/x/exp/slices" "cosmossdk.io/math" @@ -15,168 +13,10 @@ import ( tmtypes "github.com/cometbft/cometbft/types" - cryptoutil "github.com/cosmos/interchain-security/v3/testutil/crypto" testkeeper "github.com/cosmos/interchain-security/v3/testutil/keeper" - "github.com/cosmos/interchain-security/v3/x/ccv/provider/keeper" providertypes "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" - ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) -// TestHandlePacketDataForChain tests the HandlePacketDataForChain function. Note: Only one consumer is tested here, -// but multiple consumers are tested in TestPendingPacketData. -func TestHandlePacketDataForChain(t *testing.T) { - testCases := []struct { - name string - chainID string - // Pending packet data that will be queued in the order specified by the slice - dataToQueue []interface{} - // Indexes of packet data from dataToQueue that are expected to be handled and deleted from store - expectedHandledIndexes []int - }{ - { - "no packets", - "my-cool-chain", - []interface{}{}, - []int{}, - }, - { - "one slash packet should be handled", - "chain-37", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - }, - []int{0}, - }, - { - "one slash packet followed by one vsc matured packet should all be handled", - "chain-222", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - }, - []int{0, 1}, - }, - { - "one slash packet followed by multiple vsc matured packets should all be handled", - "chain-2223", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - }, - []int{0, 1, 2, 3, 4, 5}, - }, - { - "multiple slash packets followed by multiple vsc matured packets should only handle first slash packet", - "chain-9", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - }, - []int{0}, - }, - { - "vsc matured packets sandwiched between slash packets should handle everything but the last slash packet", - "chain-000", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), // 10th index not included in expectedHandledIndexes - }, - []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, - }, - { - "alternating slash and vsc matured packets should handle only the first slash, and trailing vsc matured packets", - "chain-00000", - []interface{}{ - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - testkeeper.GetNewSlashPacketData(), - testkeeper.GetNewVSCMaturedPacketData(), - }, - []int{0, 1, 2}, - }, - } - - for _, tc := range testCases { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Queue throttled packet data, where chainID is arbitrary, and ibc seq number is index of the data instance - for i, data := range tc.dataToQueue { - err := providerKeeper.QueueThrottledPacketData(ctx, tc.chainID, uint64(i), data) - require.NoError(t, err) - } - - // Define our handler callbacks to simply store the data instances that are handled - handledData := []interface{}{} - slashHandleCounter := func(ctx sdktypes.Context, chainID string, data ccvtypes.SlashPacketData) { - handledData = append(handledData, data) - } - vscMaturedHandleCounter := func(ctx sdktypes.Context, chainID string, data ccvtypes.VSCMaturedPacketData) { - handledData = append(handledData, data) - } - - providerKeeper.HandlePacketDataForChain(ctx, tc.chainID, slashHandleCounter, vscMaturedHandleCounter, 0) - - // Assert number of handled data instances matches expected number - require.Equal(t, len(tc.expectedHandledIndexes), len(handledData)) - - // Assert handled data instances match expected value - for i, expectedIndex := range tc.expectedHandledIndexes { - require.Equal(t, tc.dataToQueue[expectedIndex], handledData[i]) - } - - // Sanity check, Assert that only the first handled packet is a slash packet, and the rest are vsc matured packets - for idx, instance := range handledData { - switch instance.(type) { - case ccvtypes.SlashPacketData: - require.Equal(t, 0, idx) - case ccvtypes.VSCMaturedPacketData: - default: - require.Fail(t, "unexpected data instance type") - } - } - - // Assert that the unhandled queued data instances are as expected (i.e no unexpected deletions) - expectedDataThatsLeft := []interface{}{} - for idx, data := range tc.dataToQueue { - if !slices.Contains(tc.expectedHandledIndexes, idx) { - expectedDataThatsLeft = append(expectedDataThatsLeft, data) - } - } - - _, _, dataThatsLeft, _ := providerKeeper.GetAllThrottledPacketData(ctx, tc.chainID) - require.Equal(t, expectedDataThatsLeft, dataThatsLeft) - - // Assert that each instance of handled data is deleted from the persisted queue (i.e deletions where expected) - for _, dataInstance := range handledData { - require.NotContains(t, dataThatsLeft, dataInstance) - } - } -} - // TestSlashMeterReplenishment tests the CheckForSlashMeterReplenishment, ReplenishSlashMeter, // and InitializeSlashMeter methods. func TestSlashMeterReplenishment(t *testing.T) { @@ -627,628 +467,6 @@ func TestGetSlashMeterAllowance(t *testing.T) { } } -// TestGlobalSlashEntries tests the queue and iteration functions for global slash entries, -// with assertion of FIFO ordering -func TestGlobalSlashEntries(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // Consistent time for "now" - now := time.Now().UTC() - - globalEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 0, len(globalEntries)) - - // Queue 3 entries for chainIDs 0, 1, 2, note their respective ibc seq nums are - // ordered differently than the chainIDs would be iterated. - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Local(), "chain-0", 15, cryptoutil.NewCryptoIdentityFromIntSeed(10).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Local(), "chain-1", 10, cryptoutil.NewCryptoIdentityFromIntSeed(11).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Local(), "chain-2", 5, cryptoutil.NewCryptoIdentityFromIntSeed(12).ProviderConsAddress())) - - globalEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 3, len(globalEntries)) - - // Queue 3 entries for chainIDs 0, 1, 2 an hour later, with incremented ibc seq nums - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Add(time.Hour).Local(), "chain-0", 16, // should appear last for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(20).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Add(time.Hour).Local(), "chain-1", 11, // should appear middle for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(21).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, providertypes.NewGlobalSlashEntry( - now.Add(time.Hour).Local(), "chain-2", 6, // should appear first for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(22).ProviderConsAddress())) - - // Retrieve entries from store - globalEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 6, len(globalEntries)) - - // Assert that entries are obtained in FIFO order according to block time, then ibc seq num - require.Equal(t, "chain-2", globalEntries[0].ConsumerChainID) - require.Equal(t, "chain-1", globalEntries[1].ConsumerChainID) - require.Equal(t, "chain-0", globalEntries[2].ConsumerChainID) - require.Equal(t, "chain-2", globalEntries[3].ConsumerChainID) - require.Equal(t, "chain-1", globalEntries[4].ConsumerChainID) - require.Equal(t, "chain-0", globalEntries[5].ConsumerChainID) - - // Queue 3 entries for chainIDs 5, 6, 7 another hour later - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(now.Add(2*time.Hour).Local(), "chain-5", 50, // should appear middle for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(96).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(now.Add(2*time.Hour).Local(), "chain-6", 60, // should appear last for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(97).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(now.Add(2*time.Hour).Local(), "chain-7", 40, // should appear first for this recv time - cryptoutil.NewCryptoIdentityFromIntSeed(98).ProviderConsAddress())) - // Retrieve entries from store - globalEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 9, len(globalEntries)) - - // Assert that entries are obtained in FIFO order according to block time, then ibc seq num - require.Equal(t, "chain-2", globalEntries[0].ConsumerChainID) - require.Equal(t, "chain-1", globalEntries[1].ConsumerChainID) - require.Equal(t, "chain-0", globalEntries[2].ConsumerChainID) - require.Equal(t, "chain-2", globalEntries[3].ConsumerChainID) - require.Equal(t, "chain-1", globalEntries[4].ConsumerChainID) - require.Equal(t, "chain-0", globalEntries[5].ConsumerChainID) - require.Equal(t, "chain-7", globalEntries[6].ConsumerChainID) - require.Equal(t, "chain-5", globalEntries[7].ConsumerChainID) - require.Equal(t, "chain-6", globalEntries[8].ConsumerChainID) - - // Assert each field is as expected for all 9 entries - require.Equal(t, uint64(5), globalEntries[0].IbcSeqNum) - require.Equal(t, uint64(10), globalEntries[1].IbcSeqNum) - require.Equal(t, uint64(15), globalEntries[2].IbcSeqNum) - require.Equal(t, uint64(6), globalEntries[3].IbcSeqNum) - require.Equal(t, uint64(11), globalEntries[4].IbcSeqNum) - require.Equal(t, uint64(16), globalEntries[5].IbcSeqNum) - require.Equal(t, uint64(40), globalEntries[6].IbcSeqNum) - require.Equal(t, uint64(50), globalEntries[7].IbcSeqNum) - require.Equal(t, uint64(60), globalEntries[8].IbcSeqNum) - - require.Equal(t, now, globalEntries[0].RecvTime) - require.Equal(t, now, globalEntries[1].RecvTime) - require.Equal(t, now, globalEntries[2].RecvTime) - require.Equal(t, now.Add(time.Hour).UTC(), globalEntries[3].RecvTime) - require.Equal(t, now.Add(time.Hour).UTC(), globalEntries[4].RecvTime) - require.Equal(t, now.Add(time.Hour).UTC(), globalEntries[5].RecvTime) - require.Equal(t, now.Add(2*time.Hour).UTC(), globalEntries[6].RecvTime) - require.Equal(t, now.Add(2*time.Hour).UTC(), globalEntries[7].RecvTime) - require.Equal(t, now.Add(2*time.Hour).UTC(), globalEntries[8].RecvTime) -} - -// Tests DeleteGlobalSlashEntriesForConsumer. -func TestDeleteGlobalSlashEntriesForConsumer(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx( - t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // Queue 2 global entries for a consumer chain ID - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(time.Now().Add(time.Hour), "chain-78", 1, - cryptoutil.NewCryptoIdentityFromIntSeed(78).ProviderConsAddress())) - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(time.Now().Add(time.Hour), "chain-78", 2, - cryptoutil.NewCryptoIdentityFromIntSeed(79).ProviderConsAddress())) - - // Queue 1 global entry for two other consumer chain IDs - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(time.Now().Add(2*time.Hour), "chain-79", 1, - cryptoutil.NewCryptoIdentityFromIntSeed(80).ProviderConsAddress())) - - providerKeeper.QueueGlobalSlashEntry(ctx, - providertypes.NewGlobalSlashEntry(time.Now().Add(3*time.Hour), "chain-80", 1, - cryptoutil.NewCryptoIdentityFromIntSeed(81).ProviderConsAddress())) - - // Delete entries for chain-78, confirm those are deleted, and the other two remain - providerKeeper.DeleteGlobalSlashEntriesForConsumer(ctx, "chain-78") - allEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 2, len(allEntries)) - require.Equal(t, "chain-79", allEntries[0].ConsumerChainID) - require.Equal(t, "chain-80", allEntries[1].ConsumerChainID) -} - -// TestGlobalSlashEntryDeletion tests the deletion function for -// global slash entries with assertion of FIFO ordering. -func TestGlobalSlashEntryDeletion(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - now := time.Now() - - entries := providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 0, len(entries)) - - providerConsAddrs := []providertypes.ProviderConsAddress{ - cryptoutil.NewCryptoIdentityFromIntSeed(1).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(2).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(3).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(4).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(5).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(6).ProviderConsAddress(), - cryptoutil.NewCryptoIdentityFromIntSeed(7).ProviderConsAddress(), - } - - // Instantiate entries in the expected order we wish to get them back as (ordered by recv time) - entries = []providertypes.GlobalSlashEntry{} - entries = append(entries, providertypes.NewGlobalSlashEntry(now, "chain-0", 1, providerConsAddrs[0])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(time.Hour).UTC(), "chain-1", 178, providerConsAddrs[1])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(2*time.Hour).Local(), "chain-2", 89, providerConsAddrs[2])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(3*time.Hour).In(time.FixedZone("UTC-8", -8*60*60)), "chain-3", 23423, providerConsAddrs[3])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(4*time.Hour).Local(), "chain-4", 323, providerConsAddrs[4])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(5*time.Hour).UTC(), "chain-5", 18, providerConsAddrs[5])) - entries = append(entries, providertypes.NewGlobalSlashEntry(now.Add(6*time.Hour).Local(), "chain-6", 2, providerConsAddrs[6])) - - // Instantiate shuffled copy of above slice - shuffledEntries := append([]providertypes.GlobalSlashEntry{}, entries...) - seed := time.Now().UnixNano() - rng := rand.New(rand.NewSource(seed)) - rng.Shuffle(len(shuffledEntries), func(i, j int) { - shuffledEntries[i], shuffledEntries[j] = shuffledEntries[j], shuffledEntries[i] - }) - - // Queue 7 slash packets with various block times in random order - for _, entry := range shuffledEntries { - providerKeeper.QueueGlobalSlashEntry(ctx, entry) - } - - gotEntries := providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 7, len(gotEntries)) - - // Assert obtained order is decided upon via packet recvTime, not insertion order - for i, gotEntry := range gotEntries { - expectedEntry := entries[i] - require.Equal(t, expectedEntry, gotEntry) - } - - // Confirm no mutations have occurred from test helper - gotEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 7, len(gotEntries)) - - // Delete packets 1, 3, 5 (0-indexed) - providerKeeper.DeleteGlobalSlashEntries(ctx, gotEntries[1], gotEntries[3], gotEntries[5]) - - // Assert deletion and ordering - gotEntries = providerKeeper.GetAllGlobalSlashEntries(ctx) - require.Equal(t, 4, len(gotEntries)) - require.Equal(t, "chain-0", gotEntries[0].ConsumerChainID) - // entry 1 was deleted - require.Equal(t, "chain-2", gotEntries[1].ConsumerChainID) - // entry 3 was deleted - require.Equal(t, "chain-4", gotEntries[2].ConsumerChainID) - // entry 5 was deleted - require.Equal(t, "chain-6", gotEntries[3].ConsumerChainID) -} - -// TestThrottledPacketData tests chain-specific throttled packet data queuing, -// iteration and deletion functionality. -func TestThrottledPacketData(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - packetDataForMultipleConsumers := []struct { - chainID string - instances []throttledPacketDataInstance - - // Expected order of data instances after retrieval from store, before deletion (specified by instance index) - expectedOrder []int - // Data instances to delete (specified by instance index) - toDelete []int - // Expected order of data instances after deletion (specified by instance index) - expectedOrderAfterDeletion []int - }{ - // Note, duplicate ibc sequence numbers are not tested, as we assume ibc behaves correctly - { - chainID: "chain-0", - instances: []throttledPacketDataInstance{ - {IbcSeqNum: 0, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 1, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 2, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 3, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 4, Data: testkeeper.GetNewSlashPacketData()}, - }, - expectedOrder: []int{0, 1, 2, 3, 4}, - toDelete: []int{0, 2, 4}, - expectedOrderAfterDeletion: []int{1, 3}, - }, - { - chainID: "chain-7", - instances: []throttledPacketDataInstance{ - {IbcSeqNum: 96, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 78, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 12, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 0, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 1, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 78972, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 9999999999999999999, Data: testkeeper.GetNewSlashPacketData()}, - }, - expectedOrder: []int{3, 4, 2, 1, 0, 5, 6}, - toDelete: []int{0, 1, 2, 3, 4, 5}, - expectedOrderAfterDeletion: []int{6}, - }, - { - chainID: "chain-thats-not-0-or-7", - instances: []throttledPacketDataInstance{ - {IbcSeqNum: 9, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 8, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 7, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 6, Data: testkeeper.GetNewSlashPacketData()}, - {IbcSeqNum: 5, Data: testkeeper.GetNewVSCMaturedPacketData()}, - {IbcSeqNum: 1, Data: testkeeper.GetNewVSCMaturedPacketData()}, - }, - expectedOrder: []int{5, 4, 3, 2, 1, 0}, - toDelete: []int{1, 2, 3, 4, 5}, - expectedOrderAfterDeletion: []int{0}, - }, - } - - // Queue all packet data at once - for _, chainData := range packetDataForMultipleConsumers { - for _, dataInstance := range chainData.instances { - err := providerKeeper.QueueThrottledPacketData(ctx, chainData.chainID, dataInstance.IbcSeqNum, dataInstance.Data) - require.NoError(t, err) - } - } - - // Assert retrieval ordering for each chain - for _, chainData := range packetDataForMultipleConsumers { - expectedInstances := getOrderedInstances(chainData.instances, chainData.expectedOrder) - assertPendingPacketDataOrdering(t, &providerKeeper, ctx, chainData.chainID, expectedInstances) - } - - // Delete specified data all at once - for _, chainData := range packetDataForMultipleConsumers { - for _, i := range chainData.toDelete { - providerKeeper.DeleteThrottledPacketData(ctx, chainData.chainID, chainData.instances[i].IbcSeqNum) - } - } - - // Assert retrieval ordering after deletion for each chain - for _, chainData := range packetDataForMultipleConsumers { - expectedInstances := getOrderedInstances(chainData.instances, chainData.expectedOrderAfterDeletion) - assertPendingPacketDataOrdering(t, &providerKeeper, ctx, chainData.chainID, expectedInstances) - } -} - -func TestGetLeadingVSCMaturedData(t *testing.T) { - // Instantiate some sample data - slashData := getTenSampleSlashPacketData() - vscMaturedData := getTenSampleVSCMaturedPacketData() - - testCases := []struct { - name string - dataToQueue []throttledPacketDataInstance - expectedReturnData []ccvtypes.VSCMaturedPacketData - expectedReturnSeqs []uint64 - }{ - { - name: "no data", - dataToQueue: []throttledPacketDataInstance{}, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{}, - expectedReturnSeqs: []uint64{}, - }, - { - name: "one slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 889, Data: slashData[0]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{}, - expectedReturnSeqs: []uint64{}, - }, - { - name: "one vsc matured", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 54, Data: vscMaturedData[0]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{vscMaturedData[0]}, - expectedReturnSeqs: []uint64{54}, - }, - { - name: "one vsc matured trailing one slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 87, Data: slashData[0]}, - {IbcSeqNum: 88, Data: vscMaturedData[0]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{}, // Nothing returned - expectedReturnSeqs: []uint64{}, // Nothing returned - }, - { - name: "one vsc matured trailing multiple slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 87, Data: slashData[0]}, - {IbcSeqNum: 88, Data: slashData[1]}, - {IbcSeqNum: 89, Data: slashData[2]}, - {IbcSeqNum: 90, Data: vscMaturedData[0]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{}, // Nothing returned - expectedReturnSeqs: []uint64{}, // Nothing returned - }, - { - name: "one vsc matured leading multiple slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 87, Data: vscMaturedData[0]}, - {IbcSeqNum: 88, Data: slashData[0]}, - {IbcSeqNum: 89, Data: slashData[1]}, - {IbcSeqNum: 90, Data: slashData[2]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{vscMaturedData[0]}, - expectedReturnSeqs: []uint64{87}, - }, - { - name: "multiple vsc matured leading multiple slash", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 102, Data: vscMaturedData[0]}, - {IbcSeqNum: 103, Data: vscMaturedData[1]}, - {IbcSeqNum: 104, Data: vscMaturedData[2]}, - {IbcSeqNum: 105, Data: slashData[0]}, - {IbcSeqNum: 106, Data: slashData[1]}, - {IbcSeqNum: 107, Data: slashData[2]}, - }, - expectedReturnData: []ccvtypes.VSCMaturedPacketData{vscMaturedData[0], vscMaturedData[1], vscMaturedData[2]}, - expectedReturnSeqs: []uint64{102, 103, 104}, - }, - } - - for _, tc := range testCases { - - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Queue a slash and vsc matured packet data for some random chain. - // These values should never be returned. - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "some-rando-chain", 77, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "some-rando-chain", 97, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Queue the data to test against - for _, dataInstance := range tc.dataToQueue { - err := providerKeeper.QueueThrottledPacketData(ctx, "chain-99", dataInstance.IbcSeqNum, dataInstance.Data) - require.NoError(t, err) - } - - // Obtain data from iterator - returnedData, ibcSeqNums := providerKeeper.GetLeadingVSCMaturedData(ctx, "chain-99") - - // Assert the returned data is as expected - require.Equal(t, tc.expectedReturnData, returnedData) - require.Equal(t, tc.expectedReturnSeqs, ibcSeqNums) - } -} - -func TestGetSlashAndTrailingData(t *testing.T) { - // Instantiate some data to test against - someSlashData := getTenSampleSlashPacketData() - someVSCMaturedData := getTenSampleVSCMaturedPacketData() - - testCases := []struct { - name string - dataToQueue []throttledPacketDataInstance - expectedSlashFound bool - expectedSlashData ccvtypes.SlashPacketData - expectedVSCMaturedData []ccvtypes.VSCMaturedPacketData - expectedIBCSeqNums []uint64 - }{ - { - name: "Empty queue", - dataToQueue: []throttledPacketDataInstance{}, - expectedSlashFound: false, - expectedSlashData: ccvtypes.SlashPacketData{}, // single zero value returned. - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{}, - expectedIBCSeqNums: []uint64{}, - }, - { - name: "Queue only one slash data", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 1, Data: someSlashData[0]}, - }, - expectedSlashFound: true, - expectedSlashData: someSlashData[0], - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{}, - expectedIBCSeqNums: []uint64{1}, - }, - { - name: "Queue two vsc matured behind slash data", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 80, Data: someSlashData[3]}, - {IbcSeqNum: 82, Data: someVSCMaturedData[0]}, - {IbcSeqNum: 83, Data: someVSCMaturedData[1]}, - }, - expectedSlashFound: true, - expectedSlashData: someSlashData[3], - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{someVSCMaturedData[0], someVSCMaturedData[1]}, - expectedIBCSeqNums: []uint64{80, 82, 83}, - }, - { - name: "Queue two vsc matured behind 4 slash data", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 80, Data: someSlashData[1]}, // Only returned value - {IbcSeqNum: 82, Data: someSlashData[2]}, - {IbcSeqNum: 83, Data: someSlashData[3]}, - {IbcSeqNum: 84, Data: someSlashData[4]}, - {IbcSeqNum: 85, Data: someVSCMaturedData[1]}, - {IbcSeqNum: 86, Data: someVSCMaturedData[2]}, - }, - expectedSlashFound: true, - expectedSlashData: someSlashData[1], - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{}, - expectedIBCSeqNums: []uint64{80}, - }, - { - name: "Queue vsc matured data behind slash data, ending with another slash data", - dataToQueue: []throttledPacketDataInstance{ - {IbcSeqNum: 47238, Data: someSlashData[1]}, - {IbcSeqNum: 47239, Data: someVSCMaturedData[0]}, - {IbcSeqNum: 47240, Data: someVSCMaturedData[1]}, - {IbcSeqNum: 47241, Data: someVSCMaturedData[2]}, - {IbcSeqNum: 47242, Data: someVSCMaturedData[3]}, - {IbcSeqNum: 47243, Data: someSlashData[2]}, // Not returned - }, - expectedSlashFound: true, - expectedSlashData: someSlashData[1], - expectedVSCMaturedData: []ccvtypes.VSCMaturedPacketData{ - someVSCMaturedData[0], someVSCMaturedData[1], someVSCMaturedData[2], someVSCMaturedData[3], - }, - expectedIBCSeqNums: []uint64{47238, 47239, 47240, 47241, 47242}, - }, - } - - for _, tc := range testCases { - - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Queue a slash and vsc matured packet data for some random chain. - // These values should never be returned. - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "some-rando-chain", 77, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "some-rando-chain", 97, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Queue the data to test - for _, dataInstance := range tc.dataToQueue { - err := providerKeeper.QueueThrottledPacketData(ctx, "chain-49", dataInstance.IbcSeqNum, dataInstance.Data) - require.NoError(t, err) - } - - // Retrieve the data, and assert that it is correct - slashFound, slashData, vscMaturedData, ibcSeqNums := providerKeeper.GetSlashAndTrailingData(ctx, "chain-49") - require.Equal(t, tc.expectedSlashFound, slashFound, tc.name) - require.Equal(t, tc.expectedSlashData, slashData, tc.name) - require.Equal(t, tc.expectedVSCMaturedData, vscMaturedData, tc.name) - require.Equal(t, tc.expectedIBCSeqNums, ibcSeqNums, tc.name) - } -} - -// TestDeleteThrottledPacketDataForConsumer tests the DeleteThrottledPacketDataForConsumer method. -func TestDeleteThrottledPacketDataForConsumer(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - providerKeeper.SetParams(ctx, providertypes.DefaultParams()) - - // Queue slash and a VSC matured packet data for chain-48 - err := providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-48", 0, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-48", 1, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Queue 3 slash, and 4 vsc matured packet data instances for chain-49 - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-49", 0, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-49", 1, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledSlashPacketData(ctx, "chain-49", 2, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-49", 3, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-49", 4, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-49", 5, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledVSCMaturedPacketData(ctx, "chain-49", 6, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Delete all packet data for chain-49, confirm they are deleted - providerKeeper.DeleteThrottledPacketDataForConsumer(ctx, "chain-49") - slashData, vscMaturedData, _, _ := providerKeeper.GetAllThrottledPacketData(ctx, "chain-49") - require.Empty(t, slashData) - require.Empty(t, vscMaturedData) - - // Confirm size of queue is now 0 - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-49")) - - // Confirm packet data for chain-48 is not deleted - slashData, vscMaturedData, _, _ = providerKeeper.GetAllThrottledPacketData(ctx, "chain-48") - require.Len(t, slashData, 1) - require.Len(t, vscMaturedData, 1) -} - -// TestPanicIfTooMuchThrottledPacketData tests that the provider panics -// when the number of throttled (queued) packets exceeds the max allowed by params. -func TestPanicIfTooMuchThrottledPacketData(t *testing.T) { - testCases := []struct { - max int64 - }{ - {max: 3}, // Max must be greater than 2 since we queue 2 packets for another chain in the test - {max: 5}, - {max: 10}, - {max: 15}, - {max: 25}, - {max: 100}, - } - - for _, tc := range testCases { - - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // Set max throttled packets param - defaultParams := providertypes.DefaultParams() - defaultParams.MaxThrottledPackets = tc.max - providerKeeper.SetParams(ctx, defaultParams) - - seed := time.Now().UnixNano() - rng := rand.New(rand.NewSource(seed)) - - // Queuing up a couple data instances for another chain shouldn't matter - err := providerKeeper.QueueThrottledPacketData(ctx, "chain-17", 0, testkeeper.GetNewSlashPacketData()) - require.NoError(t, err) - err = providerKeeper.QueueThrottledPacketData(ctx, "chain-17", 1, testkeeper.GetNewVSCMaturedPacketData()) - require.NoError(t, err) - - // Queue packet data instances until we reach the max (some slash packets, some VSC matured packets) - reachedMax := false - for i := 0; i < int(tc.max); i++ { - randBool := rng.Intn(2) == 0 - var data interface{} - if randBool { - data = testkeeper.GetNewSlashPacketData() - } else { - data = testkeeper.GetNewVSCMaturedPacketData() - } - // Panic only if we've reached the max - if i == int(tc.max-1) { - require.Panics(t, func() { - _ = providerKeeper.QueueThrottledPacketData(ctx, "chain-88", uint64(i), data) - }) - reachedMax = true - } else { - err := providerKeeper.QueueThrottledPacketData(ctx, "chain-88", uint64(i), data) - require.NoError(t, err) - } - } - require.True(t, reachedMax) - } -} - -// TestThrottledPacketDataSize tests the getter, setter and incrementer for throttled packet data size. -func TestThrottledPacketDataSize(t *testing.T) { - providerKeeper, ctx, ctrl, _ := testkeeper.GetProviderKeeperAndCtx(t, testkeeper.NewInMemKeeperParams(t)) - defer ctrl.Finish() - - // Set params so we can use the default max throttled packet data size - params := providertypes.DefaultParams() - providerKeeper.SetParams(ctx, params) - - // Confirm initial size is 0 - require.Equal(t, uint64(0), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-0")) - - // Set throttled packet data size and confirm it was set - providerKeeper.SetThrottledPacketDataSize(ctx, "chain-0", 10) - require.Equal(t, uint64(10), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-0")) - - // Increment throttled packet data size and confirm it was incremented - providerKeeper.IncrementThrottledPacketDataSize(ctx, "chain-0") - require.Equal(t, uint64(11), providerKeeper.GetThrottledPacketDataSize(ctx, "chain-0")) -} - // TestSlashMeter tests the getter and setter for the slash gas meter func TestSlashMeter(t *testing.T) { testCases := []struct { @@ -1320,65 +538,3 @@ func TestSlashMeterReplenishTimeCandidate(t *testing.T) { require.Equal(t, tc.blockTime.Add(tc.replenishPeriod).UTC(), gotTime) } } - -// Struct used for TestPendingPacketData and helpers -type throttledPacketDataInstance struct { - IbcSeqNum uint64 - Data interface{} -} - -// getAllThrottledPacketDataInstances returns all throttled packet data instances in order -// from the chain-specific packet data queue. -func getAllThrottledPacketDataInstances(ctx sdktypes.Context, k *keeper.Keeper, consumerChainId string) (instances []throttledPacketDataInstance) { - _, _, allData, ibcSeqNums := k.GetAllThrottledPacketData(ctx, consumerChainId) - instances = []throttledPacketDataInstance{} - for idx, data := range allData { - instances = append(instances, throttledPacketDataInstance{ - IbcSeqNum: ibcSeqNums[idx], - Data: data, - }) - } - return instances -} - -// getOrderedInstances returns the given instances in order, specified by the given indexes -func getOrderedInstances(instances []throttledPacketDataInstance, orderbyIdx []int) (orderedInstances []throttledPacketDataInstance) { - toReturn := []throttledPacketDataInstance{} - for _, idx := range orderbyIdx { - toReturn = append(toReturn, instances[idx]) - } - return toReturn -} - -// Asserts that the throttled packet data retrieved for this consumer chain matches what's expected -func assertPendingPacketDataOrdering(t *testing.T, k *keeper.Keeper, ctx sdktypes.Context, - consumerChainId string, expectedInstances []throttledPacketDataInstance, -) { - t.Helper() - // Get all packet data for this chain - obtainedInstances := getAllThrottledPacketDataInstances(ctx, k, consumerChainId) - // No extra data should be present - require.Equal(t, len(expectedInstances), len(obtainedInstances)) - // Assert order and correct serialization/deserialization for each data instance - for i, obtainedInstance := range obtainedInstances { - require.Equal(t, expectedInstances[i], obtainedInstance) - } -} - -// getTenSampleSlashPacketData returns 10 randomized slash packet data instances for testing -func getTenSampleSlashPacketData() []ccvtypes.SlashPacketData { - sampleData := []ccvtypes.SlashPacketData{} - for i := 0; i < 10; i++ { - sampleData = append(sampleData, testkeeper.GetNewSlashPacketData()) - } - return sampleData -} - -// getTenSampleVSCMaturedPacketData returns 10 randomized VSC matured packet data instances for testing -func getTenSampleVSCMaturedPacketData() []ccvtypes.VSCMaturedPacketData { - sampleData := []ccvtypes.VSCMaturedPacketData{} - for i := 0; i < 10; i++ { - sampleData = append(sampleData, testkeeper.GetNewVSCMaturedPacketData()) - } - return sampleData -} diff --git a/x/ccv/provider/module.go b/x/ccv/provider/module.go index 82891c27c7..c70fdeafa7 100644 --- a/x/ccv/provider/module.go +++ b/x/ccv/provider/module.go @@ -107,6 +107,10 @@ func (AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { func (am AppModule) RegisterServices(cfg module.Configurator) { providertypes.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) providertypes.RegisterQueryServer(cfg.QueryServer(), am.keeper) + m := keeper.NewMigrator(*am.keeper, am.paramSpace) + if err := cfg.RegisterMigration(providertypes.ModuleName, 2, m.Migrate2to3); err != nil { + panic(fmt.Sprintf("failed to register migrator for %s: %s", providertypes.ModuleName, err)) + } } // InitGenesis performs genesis initialization for the provider module. It returns no validator updates. @@ -129,7 +133,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 2 } +func (AppModule) ConsensusVersion() uint64 { return 3 } // BeginBlock implements the AppModule interface func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { @@ -137,6 +141,8 @@ func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) { am.keeper.BeginBlockInit(ctx) // Stop and remove state for any consumer chains that are due to be stopped via pending consumer removal proposals am.keeper.BeginBlockCCR(ctx) + // Check for replenishing slash meter before any slash packets are processed for this block + am.keeper.BeginBlockCIS(ctx) } // EndBlock implements the AppModule interface diff --git a/x/ccv/provider/proposal_handler.go b/x/ccv/provider/proposal_handler.go index 137cbecec7..7af7ec4e5f 100644 --- a/x/ccv/provider/proposal_handler.go +++ b/x/ccv/provider/proposal_handler.go @@ -23,6 +23,8 @@ func NewProviderProposalHandler(k keeper.Keeper) govv1beta1.Handler { return k.HandleConsumerRemovalProposal(ctx, c) case *types.EquivocationProposal: return k.HandleEquivocationProposal(ctx, c) + case *types.ChangeRewardDenomsProposal: + return k.HandleConsumerRewardDenomProposal(ctx, c) default: return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized ccv proposal content type: %T", c) } diff --git a/x/ccv/provider/proposal_handler_test.go b/x/ccv/provider/proposal_handler_test.go index d3707d8c28..8f1322b3d2 100644 --- a/x/ccv/provider/proposal_handler_test.go +++ b/x/ccv/provider/proposal_handler_test.go @@ -27,12 +27,13 @@ func TestProviderProposalHandler(t *testing.T) { equivocation := &evidencetypes.Equivocation{Height: 42} testCases := []struct { - name string - content govv1beta1.Content - blockTime time.Time - expValidConsumerAddition bool - expValidConsumerRemoval bool - expValidEquivocation bool + name string + content govv1beta1.Content + blockTime time.Time + expValidConsumerAddition bool + expValidConsumerRemoval bool + expValidEquivocation bool + expValidChangeRewardDenom bool }{ { name: "valid consumer addition proposal", @@ -72,6 +73,13 @@ func TestProviderProposalHandler(t *testing.T) { blockTime: hourFromNow, expValidEquivocation: true, }, + { + name: "valid change reward denoms proposal", + content: providertypes.NewChangeRewardDenomsProposal( + "title", "description", []string{"denom1"}, []string{"denom2"}), + blockTime: hourFromNow, + expValidChangeRewardDenom: true, + }, { name: "nil proposal", content: nil, @@ -108,9 +116,14 @@ func TestProviderProposalHandler(t *testing.T) { case tc.expValidConsumerRemoval: testkeeper.SetupForStoppingConsumerChain(t, ctx, &providerKeeper, mocks) + // assert mocks for expected calls to `StopConsumerChain` when closing the underlying channel + gomock.InOrder(testkeeper.GetMocksForStopConsumerChainWithCloseChannel(ctx, &mocks)...) + case tc.expValidEquivocation: providerKeeper.SetSlashLog(ctx, providertypes.NewProviderConsAddress(equivocation.GetConsensusAddress())) mocks.MockEvidenceKeeper.EXPECT().HandleEquivocationEvidence(ctx, equivocation) + case tc.expValidChangeRewardDenom: + // Nothing to mock } // Execution @@ -118,7 +131,7 @@ func TestProviderProposalHandler(t *testing.T) { err := proposalHandler(ctx, tc.content) if tc.expValidConsumerAddition || tc.expValidConsumerRemoval || - tc.expValidEquivocation { + tc.expValidEquivocation || tc.expValidChangeRewardDenom { require.NoError(t, err) } else { require.Error(t, err) diff --git a/x/ccv/provider/types/codec.go b/x/ccv/provider/types/codec.go index 54c29442ae..ceed3bf789 100644 --- a/x/ccv/provider/types/codec.go +++ b/x/ccv/provider/types/codec.go @@ -28,12 +28,12 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { &MsgAssignConsumerKey{}, ) registry.RegisterImplementations( - (*sdk.Msg)(nil), - &MsgRegisterConsumerRewardDenom{}, + (*govv1beta1.Content)(nil), + &EquivocationProposal{}, ) registry.RegisterImplementations( (*govv1beta1.Content)(nil), - &EquivocationProposal{}, + &ChangeRewardDenomsProposal{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/ccv/provider/types/consumer.go b/x/ccv/provider/types/consumer.go index 1a13123e88..b2621dd001 100644 --- a/x/ccv/provider/types/consumer.go +++ b/x/ccv/provider/types/consumer.go @@ -1,7 +1,6 @@ package types import ( - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -10,7 +9,7 @@ func NewConsumerStates( clientID, channelID string, initialHeight uint64, - genesis consumertypes.GenesisState, + genesis ccv.ConsumerGenesisState, unbondingOpsIndexes []VscUnbondingOps, pendingValsetChanges []ccv.ValidatorSetChangePacketData, slashDowntimeAck []string, diff --git a/x/ccv/provider/types/errors.go b/x/ccv/provider/types/errors.go index 12fbfbe9c2..66d7a9a3b8 100644 --- a/x/ccv/provider/types/errors.go +++ b/x/ccv/provider/types/errors.go @@ -21,4 +21,7 @@ var ( ErrInvalidProviderAddress = errorsmod.Register(ModuleName, 13, "invalid provider address") ErrInvalidConsumerRewardDenom = errorsmod.Register(ModuleName, 14, "invalid consumer reward denom") ErrInvalidDepositorAddress = errorsmod.Register(ModuleName, 15, "invalid depositor address") + ErrInvalidConsumerClient = errorsmod.Register(ModuleName, 16, "ccv channel is not built on correct client") + ErrDuplicateConsumerChain = errorsmod.Register(ModuleName, 17, "consumer chain already exists") + ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 18, "consumer chain not found") ) diff --git a/x/ccv/provider/types/events.go b/x/ccv/provider/types/events.go new file mode 100644 index 0000000000..58d686020f --- /dev/null +++ b/x/ccv/provider/types/events.go @@ -0,0 +1,18 @@ +package types + +// Provider events +const ( + EventTypeConsumerClientCreated = "consumer_client_created" + EventTypeAssignConsumerKey = "assign_consumer_key" + EventTypeAddConsumerRewardDenom = "add_consumer_reward_denom" + EventTypeRemoveConsumerRewardDenom = "remove_consumer_reward_denom" + EventTypeExecuteConsumerChainSlash = "execute_consumer_chain_slash" + AttributeInfractionHeight = "infraction_height" + AttributeInitialHeight = "initial_height" + AttributeInitializationTimeout = "initialization_timeout" + AttributeTrustingPeriod = "trusting_period" + AttributeUnbondingPeriod = "unbonding_period" + AttributeProviderValidatorAddress = "provider_validator_address" + AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key" + AttributeConsumerRewardDenom = "consumer_reward_denom" +) diff --git a/x/ccv/provider/types/genesis.go b/x/ccv/provider/types/genesis.go index 2118f3143e..4718de40c1 100644 --- a/x/ccv/provider/types/genesis.go +++ b/x/ccv/provider/types/genesis.go @@ -17,7 +17,7 @@ func NewGenesisState( vscIdToHeights []ValsetUpdateIdToHeight, consumerStates []ConsumerState, unbondingOps []UnbondingOp, - matureUbdOps *ccv.MaturedUnbondingOps, + matureUbdOps *MaturedUnbondingOps, additionProposals []ConsumerAdditionProposal, removalProposals []ConsumerRemovalProposal, params Params, diff --git a/x/ccv/provider/types/genesis.pb.go b/x/ccv/provider/types/genesis.pb.go index ddd7d478b6..a7e06b7b09 100644 --- a/x/ccv/provider/types/genesis.pb.go +++ b/x/ccv/provider/types/genesis.pb.go @@ -5,10 +5,8 @@ package types import ( fmt "fmt" - _ "github.com/cometbft/cometbft/proto/tendermint/crypto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" - types1 "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" types "github.com/cosmos/interchain-security/v3/x/ccv/types" io "io" math "math" @@ -35,7 +33,7 @@ type GenesisState struct { // empty for a new chain UnbondingOps []UnbondingOp `protobuf:"bytes,3,rep,name=unbonding_ops,json=unbondingOps,proto3" json:"unbonding_ops"` // empty for a new chain - MatureUnbondingOps *types.MaturedUnbondingOps `protobuf:"bytes,4,opt,name=mature_unbonding_ops,json=matureUnbondingOps,proto3" json:"mature_unbonding_ops,omitempty"` + MatureUnbondingOps *MaturedUnbondingOps `protobuf:"bytes,4,opt,name=mature_unbonding_ops,json=matureUnbondingOps,proto3" json:"mature_unbonding_ops,omitempty"` // empty for a new chain ValsetUpdateIdToHeight []ValsetUpdateIdToHeight `protobuf:"bytes,5,rep,name=valset_update_id_to_height,json=valsetUpdateIdToHeight,proto3" json:"valset_update_id_to_height"` // empty for a new chain @@ -107,7 +105,7 @@ func (m *GenesisState) GetUnbondingOps() []UnbondingOp { return nil } -func (m *GenesisState) GetMatureUnbondingOps() *types.MaturedUnbondingOps { +func (m *GenesisState) GetMatureUnbondingOps() *MaturedUnbondingOps { if m != nil { return m.MatureUnbondingOps } @@ -177,7 +175,9 @@ func (m *GenesisState) GetExportedVscSendTimestamps() []ExportedVscSendTimestamp return nil } -// consumer chain +// The provider CCV module's knowledge of consumer state. +// +// Note this type is only used internally to the provider CCV module. type ConsumerState struct { // ChainID defines the chain ID for the consumer chain ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` @@ -188,7 +188,7 @@ type ConsumerState struct { // InitalHeight defines the initial block height for the consumer chain InitialHeight uint64 `protobuf:"varint,4,opt,name=initial_height,json=initialHeight,proto3" json:"initial_height,omitempty"` // ConsumerGenesis defines the initial consumer chain genesis states - ConsumerGenesis types1.GenesisState `protobuf:"bytes,5,opt,name=consumer_genesis,json=consumerGenesis,proto3" json:"consumer_genesis"` + ConsumerGenesis types.ConsumerGenesisState `protobuf:"bytes,5,opt,name=consumer_genesis,json=consumerGenesis,proto3" json:"consumer_genesis"` // PendingValsetChanges defines the pending validator set changes for the // consumer chain PendingValsetChanges []types.ValidatorSetChangePacketData `protobuf:"bytes,6,rep,name=pending_valset_changes,json=pendingValsetChanges,proto3" json:"pending_valset_changes"` @@ -259,11 +259,11 @@ func (m *ConsumerState) GetInitialHeight() uint64 { return 0 } -func (m *ConsumerState) GetConsumerGenesis() types1.GenesisState { +func (m *ConsumerState) GetConsumerGenesis() types.ConsumerGenesisState { if m != nil { return m.ConsumerGenesis } - return types1.GenesisState{} + return types.ConsumerGenesisState{} } func (m *ConsumerState) GetPendingValsetChanges() []types.ValidatorSetChangePacketData { @@ -352,66 +352,64 @@ func init() { } var fileDescriptor_48411d9c7900d48e = []byte{ - // 930 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xdd, 0x6e, 0x23, 0x35, - 0x14, 0xee, 0xb4, 0xd9, 0x6e, 0xe3, 0xfe, 0x50, 0x4c, 0xc9, 0x4e, 0xd3, 0x25, 0x5b, 0x05, 0x90, - 0x2a, 0x01, 0x33, 0xa4, 0xcb, 0x05, 0x7f, 0x7b, 0xb1, 0xdd, 0x45, 0x10, 0x21, 0x44, 0x94, 0x76, - 0x8b, 0xb4, 0x5c, 0x58, 0x8e, 0x6d, 0x25, 0xa6, 0x33, 0xf6, 0x68, 0xec, 0x99, 0x6d, 0x84, 0x90, - 0x58, 0xc1, 0x03, 0xf0, 0x56, 0xec, 0xe5, 0x5e, 0x72, 0xb5, 0x42, 0xed, 0x1b, 0xf0, 0x04, 0x68, - 0x3c, 0x9e, 0xe9, 0x24, 0x24, 0x90, 0x70, 0x95, 0xcc, 0xf9, 0x7c, 0xbe, 0xef, 0x1c, 0x1f, 0xfb, - 0x1c, 0x83, 0x0e, 0x17, 0x9a, 0xc5, 0x64, 0x84, 0xb9, 0x40, 0x8a, 0x91, 0x24, 0xe6, 0x7a, 0xec, - 0x13, 0x92, 0xfa, 0x51, 0x2c, 0x53, 0x4e, 0x59, 0xec, 0xa7, 0x1d, 0x7f, 0xc8, 0x04, 0x53, 0x5c, - 0x79, 0x51, 0x2c, 0xb5, 0x84, 0x6f, 0xcf, 0x70, 0xf1, 0x08, 0x49, 0xbd, 0xc2, 0xc5, 0x4b, 0x3b, - 0xcd, 0xbd, 0xa1, 0x1c, 0x4a, 0xb3, 0xde, 0xcf, 0xfe, 0xe5, 0xae, 0xcd, 0x77, 0xe6, 0xa9, 0xa5, - 0x1d, 0xdf, 0x32, 0x68, 0xd9, 0x3c, 0x5e, 0x24, 0xa6, 0x52, 0xec, 0x3f, 0x7c, 0x88, 0x14, 0x2a, - 0x09, 0x73, 0x9f, 0xe2, 0xbf, 0xf5, 0xe9, 0x2c, 0xe2, 0x33, 0x91, 0x7b, 0xf3, 0xae, 0x66, 0x82, - 0xb2, 0x38, 0xe4, 0x42, 0xfb, 0x24, 0x1e, 0x47, 0x5a, 0xfa, 0x17, 0x6c, 0x6c, 0xd1, 0xf6, 0xef, - 0x9b, 0x60, 0xeb, 0xcb, 0x7c, 0xfd, 0xa9, 0xc6, 0x9a, 0xc1, 0x23, 0xb0, 0x9b, 0xe2, 0x40, 0x31, - 0x8d, 0x92, 0x88, 0x62, 0xcd, 0x10, 0xa7, 0xae, 0x73, 0xe8, 0x1c, 0xd5, 0xfa, 0x3b, 0xb9, 0xfd, - 0x89, 0x31, 0x77, 0x29, 0xfc, 0x11, 0xbc, 0x56, 0xa8, 0x22, 0x95, 0xf9, 0x2a, 0x77, 0xf5, 0x70, - 0xed, 0x68, 0xf3, 0xf8, 0xd8, 0x5b, 0x60, 0xbb, 0xbd, 0x47, 0xd6, 0xd7, 0xc8, 0x9e, 0xb4, 0x5e, - 0xbc, 0xba, 0xb7, 0xf2, 0xd7, 0xab, 0x7b, 0x8d, 0x31, 0x0e, 0x83, 0x4f, 0xdb, 0x53, 0xc4, 0xed, - 0xfe, 0x0e, 0xa9, 0x2e, 0x57, 0xf0, 0x7b, 0xb0, 0x9d, 0x88, 0x81, 0x14, 0x94, 0x8b, 0x21, 0x92, - 0x91, 0x72, 0xd7, 0x8c, 0xf4, 0x87, 0x0b, 0x49, 0x3f, 0x29, 0x3c, 0xbf, 0x8d, 0x4e, 0x6a, 0x99, - 0x70, 0x7f, 0x2b, 0xb9, 0x31, 0x29, 0x88, 0xc1, 0x5e, 0x88, 0x75, 0x12, 0x33, 0x34, 0xa9, 0x51, - 0x3b, 0x74, 0x8e, 0x36, 0x8f, 0xfd, 0xb9, 0x1a, 0x69, 0xc7, 0xfb, 0xc6, 0xf8, 0xd1, 0x8a, 0x82, - 0xea, 0xc3, 0x9c, 0xac, 0x6a, 0x83, 0x3f, 0x81, 0xe6, 0xf4, 0x36, 0x23, 0x2d, 0xd1, 0x88, 0xf1, - 0xe1, 0x48, 0xbb, 0xb7, 0x4c, 0x32, 0x9f, 0x2d, 0x94, 0xcc, 0xf9, 0x44, 0x55, 0xce, 0xe4, 0x57, - 0x86, 0xc2, 0xe6, 0xd5, 0x48, 0x67, 0xa2, 0xf0, 0x17, 0x07, 0x1c, 0x94, 0x7b, 0x8c, 0x29, 0xe5, - 0x9a, 0x4b, 0x81, 0xa2, 0x58, 0x46, 0x52, 0xe1, 0x40, 0xb9, 0xeb, 0x26, 0x80, 0x07, 0x4b, 0x15, - 0xf2, 0xa1, 0xa5, 0xe9, 0x59, 0x16, 0x1b, 0xc2, 0x3e, 0x99, 0x83, 0x2b, 0xf8, 0xb3, 0x03, 0x9a, - 0x65, 0x14, 0x31, 0x0b, 0x65, 0x8a, 0x83, 0x4a, 0x10, 0xb7, 0x4d, 0x10, 0x9f, 0x2f, 0x15, 0x44, - 0x3f, 0x67, 0x99, 0x8a, 0xc1, 0x25, 0xb3, 0x61, 0x05, 0xbb, 0x60, 0x3d, 0xc2, 0x31, 0x0e, 0x95, - 0xbb, 0x61, 0x8a, 0xfb, 0xde, 0x42, 0x6a, 0x3d, 0xe3, 0x62, 0xc9, 0x2d, 0x81, 0xc9, 0x26, 0xc5, - 0x01, 0xa7, 0x58, 0xcb, 0x18, 0x95, 0x79, 0x45, 0xc9, 0x20, 0xbb, 0x6f, 0x6e, 0x7d, 0x89, 0x6c, - 0xce, 0x0b, 0x9a, 0x22, 0xad, 0x5e, 0x32, 0xf8, 0x9a, 0x8d, 0x8b, 0x6c, 0xd2, 0x19, 0x70, 0xa6, - 0x01, 0x9f, 0x3b, 0xe0, 0xa0, 0x04, 0x15, 0x1a, 0x8c, 0x51, 0xb5, 0xc8, 0xb1, 0x0b, 0xfe, 0x4f, - 0x0c, 0x27, 0xe3, 0x4a, 0x85, 0xe3, 0x7f, 0xc4, 0xa0, 0x26, 0x71, 0x98, 0x82, 0x3b, 0x13, 0xa2, - 0x2a, 0x3b, 0xd7, 0x51, 0x9c, 0x08, 0xe6, 0x6e, 0x1a, 0xf9, 0x4f, 0x96, 0x3d, 0x55, 0xb1, 0x3a, - 0x93, 0xbd, 0x8c, 0xc0, 0x6a, 0xef, 0x91, 0x19, 0x18, 0x7c, 0x06, 0xee, 0x70, 0xc1, 0x35, 0xd2, - 0x3c, 0x64, 0x32, 0xc9, 0x7f, 0x95, 0xc6, 0x61, 0xa4, 0xdc, 0xad, 0x25, 0x74, 0xbb, 0x82, 0xeb, - 0xb3, 0x9c, 0xe2, 0xac, 0x60, 0xb0, 0xba, 0x6f, 0xf2, 0x19, 0x98, 0x82, 0xbf, 0x3a, 0xe0, 0x2e, - 0xbb, 0x8c, 0x64, 0xac, 0x19, 0x45, 0xa9, 0x22, 0x48, 0x31, 0x41, 0xab, 0xf2, 0xdb, 0x4b, 0x5c, - 0xa6, 0x2f, 0x2c, 0xd1, 0xb9, 0x22, 0xa7, 0x4c, 0xd0, 0xe9, 0x10, 0xf6, 0xd9, 0x1c, 0x5c, 0xb5, - 0x9f, 0xd7, 0xc0, 0xf6, 0x44, 0x4f, 0x85, 0xfb, 0x60, 0x23, 0x57, 0xb3, 0x2d, 0xbc, 0xde, 0xbf, - 0x6d, 0xbe, 0xbb, 0x14, 0xbe, 0x05, 0x00, 0x19, 0x61, 0x21, 0x58, 0x90, 0x81, 0xab, 0x06, 0xac, - 0x5b, 0x4b, 0x97, 0xc2, 0x03, 0x50, 0x27, 0x01, 0x67, 0x42, 0x67, 0xe8, 0x9a, 0x41, 0x37, 0x72, - 0x43, 0x97, 0xc2, 0x77, 0xc1, 0x4e, 0xb6, 0x11, 0x1c, 0x07, 0x45, 0xbb, 0xaa, 0x99, 0xf9, 0xb0, - 0x6d, 0xad, 0xb6, 0xc5, 0x0c, 0xc0, 0x6e, 0x79, 0x0e, 0xec, 0x44, 0x72, 0x6f, 0x99, 0x3b, 0xd6, - 0x99, 0xbb, 0x13, 0xe5, 0xb4, 0x4b, 0x3b, 0x5e, 0x75, 0x2a, 0xd9, 0xec, 0xcb, 0x79, 0x63, 0x31, - 0xa8, 0x41, 0x23, 0x62, 0x79, 0x7f, 0xb6, 0xdd, 0x34, 0xcb, 0x61, 0xc8, 0x8a, 0x06, 0xf6, 0xf1, - 0xbf, 0xb5, 0xea, 0xf2, 0x80, 0x9f, 0x32, 0xfd, 0xc8, 0xb8, 0xf5, 0x30, 0xb9, 0x60, 0xfa, 0x31, - 0xd6, 0xb8, 0x38, 0x69, 0x96, 0x3d, 0xef, 0xb1, 0xf9, 0x22, 0x05, 0xdf, 0x07, 0x50, 0x05, 0x58, - 0x8d, 0x10, 0x95, 0xcf, 0x44, 0x56, 0x67, 0x84, 0xc9, 0x85, 0xe9, 0x56, 0xf5, 0xfe, 0xae, 0x41, - 0x1e, 0x5b, 0xe0, 0x21, 0xb9, 0x80, 0x3f, 0x80, 0x37, 0x26, 0xa6, 0x08, 0xe2, 0x82, 0xb2, 0x4b, - 0x77, 0xc3, 0x04, 0xf8, 0xd1, 0x62, 0x57, 0x51, 0x91, 0xea, 0xf0, 0xb0, 0xc1, 0xbd, 0x5e, 0x9d, - 0x59, 0xdd, 0x8c, 0xb4, 0xfd, 0x14, 0x34, 0x66, 0x8f, 0x83, 0x25, 0xc6, 0x7a, 0x03, 0xac, 0xdb, - 0xb2, 0xae, 0x1a, 0xdc, 0x7e, 0x9d, 0x7c, 0xf7, 0xe2, 0xaa, 0xe5, 0xbc, 0xbc, 0x6a, 0x39, 0x7f, - 0x5e, 0xb5, 0x9c, 0xdf, 0xae, 0x5b, 0x2b, 0x2f, 0xaf, 0x5b, 0x2b, 0x7f, 0x5c, 0xb7, 0x56, 0x9e, - 0x3e, 0x18, 0x72, 0x3d, 0x4a, 0x06, 0x1e, 0x91, 0xa1, 0x4f, 0xa4, 0x0a, 0xa5, 0xf2, 0x6f, 0xb2, - 0xfa, 0xa0, 0x7c, 0xa6, 0xa4, 0xf7, 0xfd, 0xcb, 0xc9, 0x37, 0x91, 0x1e, 0x47, 0x4c, 0x0d, 0xd6, - 0xcd, 0x4b, 0xe4, 0xfe, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4d, 0xe2, 0xfe, 0x45, 0xd8, 0x09, - 0x00, 0x00, + // 908 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x6e, 0x1b, 0x37, + 0x10, 0xf6, 0xda, 0x8e, 0x63, 0xd1, 0x3f, 0x75, 0x59, 0x57, 0x59, 0xdb, 0xad, 0x62, 0xa8, 0x08, + 0x60, 0xa0, 0xad, 0x14, 0x3b, 0x3d, 0xa4, 0x3f, 0x39, 0xc4, 0x49, 0xd1, 0x0a, 0x45, 0x51, 0x41, + 0x76, 0x5c, 0x20, 0x3d, 0x10, 0x14, 0x49, 0x48, 0x8c, 0x25, 0x72, 0xc1, 0xe1, 0xae, 0x2d, 0x14, + 0x05, 0x52, 0xb4, 0x0f, 0xd0, 0xc7, 0xca, 0xd1, 0xc7, 0x9e, 0x82, 0xc2, 0x7e, 0x83, 0x3e, 0x41, + 0xb1, 0x5c, 0xee, 0x66, 0xe5, 0xca, 0x81, 0x94, 0x93, 0x2d, 0x7e, 0x9c, 0xef, 0xfb, 0x86, 0x43, + 0xce, 0x2c, 0xda, 0x97, 0xca, 0x0a, 0xc3, 0xfa, 0x54, 0x2a, 0x02, 0x82, 0xc5, 0x46, 0xda, 0x51, + 0x93, 0xb1, 0xa4, 0x19, 0x19, 0x9d, 0x48, 0x2e, 0x4c, 0x33, 0xd9, 0x6f, 0xf6, 0x84, 0x12, 0x20, + 0xa1, 0x11, 0x19, 0x6d, 0x35, 0xfe, 0x64, 0x42, 0x48, 0x83, 0xb1, 0xa4, 0x91, 0x87, 0x34, 0x92, + 0xfd, 0xed, 0xcd, 0x9e, 0xee, 0x69, 0xb7, 0xbf, 0x99, 0xfe, 0x97, 0x85, 0x6e, 0xdf, 0xbf, 0x49, + 0x2d, 0xd9, 0x6f, 0x42, 0x9f, 0x1a, 0xc1, 0x09, 0xd3, 0x0a, 0xe2, 0xa1, 0x30, 0x3e, 0xe2, 0xde, + 0x5b, 0x22, 0xce, 0xa4, 0x11, 0x7e, 0xdb, 0xc1, 0x34, 0x69, 0x14, 0xfe, 0x5c, 0x4c, 0xfd, 0x62, + 0x05, 0xad, 0x7e, 0x97, 0x65, 0x76, 0x64, 0xa9, 0x15, 0x78, 0x0f, 0x6d, 0x24, 0x74, 0x00, 0xc2, + 0x92, 0x38, 0xe2, 0xd4, 0x0a, 0x22, 0x79, 0x18, 0xec, 0x06, 0x7b, 0x8b, 0x9d, 0xf5, 0x6c, 0xfd, + 0x99, 0x5b, 0x6e, 0x71, 0xfc, 0x2b, 0x7a, 0x2f, 0xf7, 0x49, 0x20, 0x8d, 0x85, 0x70, 0x7e, 0x77, + 0x61, 0x6f, 0xe5, 0xe0, 0xa0, 0x31, 0xc5, 0xe1, 0x34, 0x9e, 0xf8, 0x58, 0x27, 0x7b, 0x58, 0x7b, + 0xf5, 0xfa, 0xee, 0xdc, 0xbf, 0xaf, 0xef, 0x56, 0x47, 0x74, 0x38, 0xf8, 0xaa, 0x7e, 0x8d, 0xb8, + 0xde, 0x59, 0x67, 0xe5, 0xed, 0x80, 0x7f, 0x41, 0x6b, 0xb1, 0xea, 0x6a, 0xc5, 0xa5, 0xea, 0x11, + 0x1d, 0x41, 0xb8, 0xe0, 0xa4, 0xef, 0x4f, 0x25, 0xfd, 0x2c, 0x8f, 0xfc, 0x29, 0x3a, 0x5c, 0x4c, + 0x85, 0x3b, 0xab, 0xf1, 0x9b, 0x25, 0xc0, 0x2f, 0xd0, 0xe6, 0x90, 0xda, 0xd8, 0x08, 0x32, 0xae, + 0xb1, 0xb8, 0x1b, 0xec, 0xad, 0x1c, 0x3c, 0x9c, 0x4a, 0xe3, 0x47, 0x47, 0xc0, 0x4b, 0x52, 0xd0, + 0xc1, 0x19, 0x6b, 0x79, 0x0d, 0xff, 0x86, 0xb6, 0xaf, 0x9f, 0x37, 0xb1, 0x9a, 0xf4, 0x85, 0xec, + 0xf5, 0x6d, 0x78, 0xcb, 0x65, 0xf5, 0xf5, 0x54, 0x8a, 0x27, 0x63, 0xe5, 0x39, 0xd6, 0xdf, 0x3b, + 0x0a, 0x9f, 0x60, 0x35, 0x99, 0x88, 0xe2, 0x3f, 0x02, 0xb4, 0x53, 0x1c, 0x36, 0xe5, 0x5c, 0x5a, + 0xa9, 0x15, 0x89, 0x8c, 0x8e, 0x34, 0xd0, 0x01, 0x84, 0x4b, 0xce, 0xc0, 0xa3, 0x99, 0x2a, 0xfa, + 0xd8, 0xd3, 0xb4, 0x3d, 0x8b, 0xb7, 0xb0, 0xc5, 0x6e, 0xc0, 0x01, 0xbf, 0x0c, 0xd0, 0x76, 0xe1, + 0xc2, 0x88, 0xa1, 0x4e, 0xe8, 0xa0, 0x64, 0xe2, 0xb6, 0x33, 0xf1, 0xcd, 0x4c, 0x26, 0x3a, 0x19, + 0xcb, 0x35, 0x0f, 0x21, 0x9b, 0x0c, 0x03, 0x6e, 0xa1, 0xa5, 0x88, 0x1a, 0x3a, 0x84, 0x70, 0xd9, + 0x55, 0xf9, 0xd3, 0xa9, 0xd4, 0xda, 0x2e, 0xc4, 0x93, 0x7b, 0x02, 0x97, 0x4d, 0x42, 0x07, 0x92, + 0x53, 0xab, 0x4d, 0xf1, 0x96, 0x49, 0x14, 0x77, 0x4f, 0xc5, 0x08, 0xc2, 0xca, 0x0c, 0xd9, 0x9c, + 0xe4, 0x34, 0x79, 0x5a, 0xed, 0xb8, 0xfb, 0x83, 0x18, 0xe5, 0xd9, 0x24, 0x13, 0xe0, 0x54, 0x03, + 0xff, 0x1e, 0xa0, 0x9d, 0x02, 0x04, 0xd2, 0x1d, 0x91, 0x72, 0x91, 0x4d, 0x88, 0xde, 0xc5, 0xc3, + 0xe1, 0xa8, 0x54, 0x61, 0xf3, 0x3f, 0x0f, 0x30, 0x8e, 0xe3, 0x04, 0xdd, 0x19, 0x13, 0x85, 0xf4, + 0x5e, 0x47, 0x26, 0x56, 0x22, 0x5c, 0x71, 0xf2, 0x5f, 0xce, 0x7a, 0xab, 0x0c, 0x1c, 0xeb, 0x76, + 0x4a, 0xe0, 0xb5, 0x37, 0xd9, 0x04, 0x0c, 0x9f, 0xa1, 0x3b, 0x52, 0x49, 0x4b, 0xac, 0x1c, 0x0a, + 0x1d, 0x67, 0x7f, 0xc1, 0xd2, 0x61, 0x04, 0xe1, 0xea, 0x0c, 0xba, 0x2d, 0x25, 0xed, 0x71, 0x46, + 0x71, 0x9c, 0x33, 0x78, 0xdd, 0x0f, 0xe5, 0x04, 0x0c, 0xf0, 0x9f, 0x01, 0xfa, 0x48, 0x9c, 0x47, + 0xda, 0x58, 0xc1, 0x49, 0x02, 0x8c, 0x80, 0x50, 0xbc, 0x2c, 0xbf, 0x36, 0xc3, 0x63, 0xfa, 0xd6, + 0x13, 0x9d, 0x00, 0x3b, 0x12, 0x8a, 0x5f, 0xb7, 0xb0, 0x25, 0x6e, 0xc0, 0xa1, 0xfe, 0x72, 0x11, + 0xad, 0x8d, 0x35, 0x57, 0xbc, 0x85, 0x96, 0x33, 0x35, 0xdf, 0xcb, 0x2b, 0x9d, 0xdb, 0xee, 0x77, + 0x8b, 0xe3, 0x8f, 0x11, 0x62, 0x7d, 0xaa, 0x94, 0x18, 0xa4, 0xe0, 0xbc, 0x03, 0x2b, 0x7e, 0xa5, + 0xc5, 0xf1, 0x0e, 0xaa, 0xb0, 0x81, 0x14, 0xca, 0xa6, 0xe8, 0x82, 0x43, 0x97, 0xb3, 0x85, 0x16, + 0xc7, 0xf7, 0xd0, 0x7a, 0x7a, 0x10, 0x92, 0x0e, 0xf2, 0x76, 0xb5, 0xe8, 0x06, 0xc5, 0x9a, 0x5f, + 0xf5, 0x2d, 0x86, 0xa2, 0x8d, 0xe2, 0x1e, 0xf8, 0x21, 0x1a, 0xde, 0x72, 0x6f, 0xec, 0xe6, 0x6e, + 0x5d, 0xaa, 0x7b, 0x79, 0x3a, 0xf9, 0xe4, 0x8b, 0xb9, 0xe3, 0x31, 0x6c, 0x51, 0x35, 0x12, 0x59, + 0x9f, 0xf6, 0xcd, 0x34, 0x4d, 0xa1, 0x27, 0xf2, 0xfe, 0xf5, 0xf0, 0x6d, 0x42, 0xc5, 0xfd, 0x3e, + 0x12, 0xf6, 0x89, 0x0b, 0x6b, 0x53, 0x76, 0x2a, 0xec, 0x53, 0x6a, 0x69, 0x7e, 0xd1, 0x3c, 0x7b, + 0xd6, 0x62, 0xb3, 0x4d, 0x80, 0x3f, 0x43, 0x18, 0x06, 0x14, 0xfa, 0x84, 0xeb, 0x33, 0x95, 0x96, + 0x99, 0x50, 0x76, 0xea, 0x9a, 0x55, 0xa5, 0xb3, 0xe1, 0x90, 0xa7, 0x1e, 0x78, 0xcc, 0x4e, 0xf1, + 0x0b, 0xf4, 0xc1, 0xd8, 0x34, 0x21, 0x52, 0x71, 0x71, 0x1e, 0x2e, 0x3b, 0x83, 0x5f, 0x4c, 0xf7, + 0x12, 0x81, 0x95, 0x67, 0x87, 0x37, 0xf7, 0x7e, 0x79, 0x76, 0xb5, 0x52, 0xd2, 0xfa, 0x73, 0x54, + 0x9d, 0x3c, 0x0d, 0x66, 0x18, 0xef, 0x55, 0xb4, 0xe4, 0xab, 0x3a, 0xef, 0x70, 0xff, 0xeb, 0xf0, + 0xe7, 0x57, 0x97, 0xb5, 0xe0, 0xe2, 0xb2, 0x16, 0xfc, 0x73, 0x59, 0x0b, 0xfe, 0xba, 0xaa, 0xcd, + 0x5d, 0x5c, 0xd5, 0xe6, 0xfe, 0xbe, 0xaa, 0xcd, 0x3d, 0x7f, 0xd4, 0x93, 0xb6, 0x1f, 0x77, 0x1b, + 0x4c, 0x0f, 0x9b, 0x4c, 0xc3, 0x50, 0x43, 0xf3, 0x4d, 0x56, 0x9f, 0x17, 0x5f, 0x24, 0xc9, 0x83, + 0xe6, 0xf9, 0xf8, 0x67, 0x89, 0x1d, 0x45, 0x02, 0xba, 0x4b, 0xee, 0x8b, 0xe4, 0xc1, 0x7f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x9e, 0xfb, 0x60, 0xd0, 0x8e, 0x09, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -1033,7 +1031,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.MatureUnbondingOps == nil { - m.MatureUnbondingOps = &types.MaturedUnbondingOps{} + m.MatureUnbondingOps = &MaturedUnbondingOps{} } if err := m.MatureUnbondingOps.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/ccv/provider/types/genesis_test.go b/x/ccv/provider/types/genesis_test.go index c4b5002f07..d77ea563f8 100644 --- a/x/ccv/provider/types/genesis_test.go +++ b/x/ccv/provider/types/genesis_test.go @@ -15,7 +15,6 @@ import ( tmtypes "github.com/cometbft/cometbft/types" "github.com/cosmos/interchain-security/v3/testutil/crypto" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" "github.com/cosmos/interchain-security/v3/x/ccv/provider/types" ccv "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -82,7 +81,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -103,7 +102,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -124,7 +123,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -145,7 +144,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -172,7 +171,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -199,7 +198,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -226,7 +225,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(1000000)}), nil, nil, nil, @@ -253,7 +252,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -280,7 +279,7 @@ func TestValidateGenesisState(t *testing.T) { 0, // 0 vsc timeout here types.DefaultSlashMeterReplenishPeriod, types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -307,7 +306,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, 0, // 0 slash meter replenish period here types.DefaultSlashMeterReplenishFraction, - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -334,34 +333,7 @@ func TestValidateGenesisState(t *testing.T) { types.DefaultVscTimeoutPeriod, types.DefaultSlashMeterReplenishPeriod, "1.15", - types.DefaultMaxThrottledPackets, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), - nil, - nil, - nil, - nil, - nil, - ), - false, - }, - { - "invalid params, invalid max pending slash packets", - types.NewGenesisState( - types.DefaultValsetUpdateID, - nil, - []types.ConsumerState{{ChainId: "chainid-1", ChannelId: "channelid", ClientId: "client-id"}}, - nil, - nil, - nil, - nil, - types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, - time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, - ccv.DefaultCCVTimeoutPeriod, - types.DefaultInitTimeoutPeriod, - types.DefaultVscTimeoutPeriod, - types.DefaultSlashMeterReplenishPeriod, - "1.15", - -1, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), + sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -453,7 +425,7 @@ func TestValidateGenesisState(t *testing.T) { nil, []types.ConsumerState{{ ChainId: "chainid", ChannelId: "channel-0", ClientId: "client-id", - ConsumerGenesis: consumertypes.GenesisState{}, + ConsumerGenesis: ccv.ConsumerGenesisState{}, }}, nil, nil, @@ -713,7 +685,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}), nil, nil, nil, @@ -734,7 +706,7 @@ func TestValidateGenesisState(t *testing.T) { nil, types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", 400, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-1000000)}), + types.DefaultTrustingPeriodFraction, time.Hour, time.Hour, 30*time.Minute, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-1000000)}), nil, nil, nil, @@ -758,7 +730,7 @@ func TestValidateGenesisState(t *testing.T) { } } -func getInitialConsumerGenesis(t *testing.T, chainID string) consumertypes.GenesisState { +func getInitialConsumerGenesis(t *testing.T, chainID string) ccv.ConsumerGenesisState { t.Helper() // generate validator public key cId := crypto.NewCryptoIdentityFromIntSeed(239668) @@ -781,7 +753,7 @@ func getInitialConsumerGenesis(t *testing.T, chainID string) consumertypes.Genes []string{"upgrade", "upgradedIBCState"}) consensusState := ibctmtypes.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("apphash")), valHash) - params := consumertypes.DefaultParams() + params := ccv.DefaultParams() params.Enabled = true - return *consumertypes.NewInitialGenesisState(cs, consensusState, valUpdates, params) + return *ccv.NewInitialConsumerGenesisState(cs, consensusState, valUpdates, params) } diff --git a/x/ccv/provider/types/msg.go b/x/ccv/provider/types/msg.go index 67ad99d10c..901aa03600 100644 --- a/x/ccv/provider/types/msg.go +++ b/x/ccv/provider/types/msg.go @@ -9,8 +9,7 @@ import ( // provider message types const ( - TypeMsgAssignConsumerKey = "assign_consumer_key" - TypeMsgRegisterConsumerRewardDenom = "register_consumer_reward_denom" + TypeMsgAssignConsumerKey = "assign_consumer_key" ) var _ sdk.Msg = &MsgAssignConsumerKey{} @@ -94,48 +93,3 @@ func ParseConsumerKeyFromJson(jsonStr string) (pkType, key string, err error) { } return pubKey.Type, pubKey.Key, nil } - -// NewMsgRegisterConsumerRewardDenom returns a new MsgRegisterConsumerRewardDenom with a sender and -// a funding amount. -func NewMsgRegisterConsumerRewardDenom(denom string, depositor sdk.AccAddress) *MsgRegisterConsumerRewardDenom { - return &MsgRegisterConsumerRewardDenom{ - Denom: denom, - Depositor: depositor.String(), - } -} - -// Route returns the MsgRegisterConsumerRewardDenom message route. -func (msg MsgRegisterConsumerRewardDenom) Route() string { return ModuleName } - -// Type returns the MsgRegisterConsumerRewardDenom message type. -func (msg MsgRegisterConsumerRewardDenom) Type() string { return TypeMsgRegisterConsumerRewardDenom } - -// GetSigners returns the signer addresses that are expected to sign the result -// of GetSignBytes. -func (msg MsgRegisterConsumerRewardDenom) GetSigners() []sdk.AccAddress { - depoAddr, err := sdk.AccAddressFromBech32(msg.Depositor) - if err != nil { - panic(err) - } - return []sdk.AccAddress{depoAddr} -} - -// GetSignBytes returns the raw bytes for a MsgRegisterConsumerRewardDenom message that -// the expected signer needs to sign. -func (msg MsgRegisterConsumerRewardDenom) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(&msg) - return sdk.MustSortJSON(bz) -} - -// ValidateBasic performs basic MsgRegisterConsumerRewardDenom message validation. -func (msg MsgRegisterConsumerRewardDenom) ValidateBasic() error { - if !sdk.NewCoin(msg.Denom, sdk.NewInt(0)).IsValid() { - return ErrInvalidConsumerRewardDenom - } - _, err := sdk.AccAddressFromBech32(msg.Depositor) - if err != nil { - return ErrInvalidDepositorAddress - } - - return nil -} diff --git a/x/ccv/provider/types/params.go b/x/ccv/provider/types/params.go index 515d8954ec..fb6b0c267e 100644 --- a/x/ccv/provider/types/params.go +++ b/x/ccv/provider/types/params.go @@ -11,7 +11,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" - consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) @@ -37,10 +36,6 @@ const ( // that is replenished to the slash meter every replenish period. This param also serves as a maximum // fraction of total voting power that the slash meter can hold. DefaultSlashMeterReplenishFraction = "0.05" - - // DefaultMaxThrottledPackets defines the default amount of throttled slash or vsc matured packets - // that can be queued for a single consumer before the provider chain halts. - DefaultMaxThrottledPackets = 100000 ) // Reflection based keys for params subspace @@ -51,7 +46,6 @@ var ( KeyVscTimeoutPeriod = []byte("VscTimeoutPeriod") KeySlashMeterReplenishPeriod = []byte("SlashMeterReplenishPeriod") KeySlashMeterReplenishFraction = []byte("SlashMeterReplenishFraction") - KeyMaxThrottledPackets = []byte("MaxThrottledPackets") KeyConsumerRewardDenomRegistrationFee = []byte("ConsumerRewardDenomRegistrationFee") ) @@ -69,7 +63,6 @@ func NewParams( vscTimeoutPeriod time.Duration, slashMeterReplenishPeriod time.Duration, slashMeterReplenishFraction string, - maxThrottledPackets int64, consumerRewardDenomRegistrationFee sdk.Coin, ) Params { return Params{ @@ -80,7 +73,6 @@ func NewParams( VscTimeoutPeriod: vscTimeoutPeriod, SlashMeterReplenishPeriod: slashMeterReplenishPeriod, SlashMeterReplenishFraction: slashMeterReplenishFraction, - MaxThrottledPackets: maxThrottledPackets, ConsumerRewardDenomRegistrationFee: consumerRewardDenomRegistrationFee, } } @@ -106,7 +98,6 @@ func DefaultParams() Params { DefaultVscTimeoutPeriod, DefaultSlashMeterReplenishPeriod, DefaultSlashMeterReplenishFraction, - DefaultMaxThrottledPackets, // Defining this inline because it's not possible to define a constant of type sdk.Coin. // Following the pattern from cosmos-sdk/staking/types/params.go sdk.Coin{ @@ -142,9 +133,6 @@ func (p Params) Validate() error { if err := ccvtypes.ValidateStringFraction(p.SlashMeterReplenishFraction); err != nil { return fmt.Errorf("slash meter replenish fraction is invalid: %s", err) } - if err := ccvtypes.ValidatePositiveInt64(p.MaxThrottledPackets); err != nil { - return fmt.Errorf("max throttled packets is invalid: %s", err) - } if err := ValidateCoin(p.ConsumerRewardDenomRegistrationFee); err != nil { return fmt.Errorf("consumer reward denom registration fee is invalid: %s", err) } @@ -161,7 +149,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyVscTimeoutPeriod, p.VscTimeoutPeriod, ccvtypes.ValidateDuration), paramtypes.NewParamSetPair(KeySlashMeterReplenishPeriod, p.SlashMeterReplenishPeriod, ccvtypes.ValidateDuration), paramtypes.NewParamSetPair(KeySlashMeterReplenishFraction, p.SlashMeterReplenishFraction, ccvtypes.ValidateStringFraction), - paramtypes.NewParamSetPair(KeyMaxThrottledPackets, p.MaxThrottledPackets, ccvtypes.ValidatePositiveInt64), paramtypes.NewParamSetPair(KeyConsumerRewardDenomRegistrationFee, p.ConsumerRewardDenomRegistrationFee, ValidateCoin), } } @@ -178,13 +165,13 @@ func ValidateTemplateClient(i interface{}) error { // populate zeroed fields with valid fields copiedClient.ChainId = "chainid" - trustPeriod, err := ccvtypes.CalculateTrustPeriod(consumertypes.DefaultConsumerUnbondingPeriod, DefaultTrustingPeriodFraction) + trustPeriod, err := ccvtypes.CalculateTrustPeriod(ccvtypes.DefaultConsumerUnbondingPeriod, DefaultTrustingPeriodFraction) if err != nil { return fmt.Errorf("invalid TrustPeriodFraction: %T", err) } copiedClient.TrustingPeriod = trustPeriod - copiedClient.UnbondingPeriod = consumertypes.DefaultConsumerUnbondingPeriod + copiedClient.UnbondingPeriod = ccvtypes.DefaultConsumerUnbondingPeriod copiedClient.LatestHeight = clienttypes.NewHeight(0, 1) if err := copiedClient.Validate(); err != nil { diff --git a/x/ccv/provider/types/params_test.go b/x/ccv/provider/types/params_test.go index 0676a15986..6e8bd780bf 100644 --- a/x/ccv/provider/types/params_test.go +++ b/x/ccv/provider/types/params_test.go @@ -24,42 +24,39 @@ func TestValidateParams(t *testing.T) { {"custom valid params", types.NewParams( ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), true}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), true}, {"custom invalid params", types.NewParams( ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, 0, clienttypes.Height{}, nil, []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"blank client", types.NewParams(&ibctmtypes.ClientState{}, - "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, - {"nil client", types.NewParams(nil, "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + {"nil client", types.NewParams(nil, "0.33", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, // Check if "0.00" is valid or if a zero dec TrustFraction needs to return an error {"0 trusting period fraction", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.00", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), true}, + "0.00", time.Hour, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), true}, {"0 ccv timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", 0, time.Hour, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", 0, time.Hour, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"0 init timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, 0, time.Hour, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, 0, time.Hour, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"0 vsc timeout period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 0, 30*time.Minute, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, 0, 30*time.Minute, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"0 slash meter replenish period", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, 0, "0.1", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, 0, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"slash meter replenish fraction over 1", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "1.5", 100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, - {"negative max pending slash packets", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, - time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", -100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "1.5", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(10000000)}), false}, {"invalid consumer reward denom registration fee denom", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", -100, sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "st", Amount: sdk.NewInt(10000000)}), false}, {"invalid consumer reward denom registration fee amount", types.NewParams(ibctmtypes.NewClientState("", ibctmtypes.DefaultTrustLevel, 0, 0, time.Second*40, clienttypes.Height{}, commitmenttypes.GetSDKSpecs(), []string{"ibc", "upgradedIBCState"}), - "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", -100, sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-10000000)}), false}, + "0.33", time.Hour, time.Hour, 24*time.Hour, time.Hour, "0.1", sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-10000000)}), false}, } for _, tc := range testCases { diff --git a/x/ccv/provider/types/proposal.go b/x/ccv/provider/types/proposal.go index c369ec95f1..b2286d4adf 100644 --- a/x/ccv/provider/types/proposal.go +++ b/x/ccv/provider/types/proposal.go @@ -10,6 +10,7 @@ import ( errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" @@ -17,21 +18,24 @@ import ( ) const ( - ProposalTypeConsumerAddition = "ConsumerAddition" - ProposalTypeConsumerRemoval = "ConsumerRemoval" - ProposalTypeEquivocation = "Equivocation" + ProposalTypeConsumerAddition = "ConsumerAddition" + ProposalTypeConsumerRemoval = "ConsumerRemoval" + ProposalTypeEquivocation = "Equivocation" + ProposalTypeChangeRewardDenoms = "ChangeRewardDenoms" ) var ( _ govv1beta1.Content = &ConsumerAdditionProposal{} _ govv1beta1.Content = &ConsumerRemovalProposal{} _ govv1beta1.Content = &EquivocationProposal{} + _ govv1beta1.Content = &ChangeRewardDenomsProposal{} ) func init() { govv1beta1.RegisterProposalType(ProposalTypeConsumerAddition) govv1beta1.RegisterProposalType(ProposalTypeConsumerRemoval) govv1beta1.RegisterProposalType(ProposalTypeEquivocation) + govv1beta1.RegisterProposalType(ProposalTypeChangeRewardDenoms) } // NewConsumerAdditionProposal creates a new consumer addition proposal. @@ -231,3 +235,57 @@ func (sp *EquivocationProposal) ValidateBasic() error { } return nil } + +func NewChangeRewardDenomsProposal(title, description string, + denomsToAdd, denomsToRemove []string, +) govv1beta1.Content { + return &ChangeRewardDenomsProposal{ + Title: title, + Description: description, + DenomsToAdd: denomsToAdd, + DenomsToRemove: denomsToRemove, + } +} + +// ProposalRoute returns the routing key of a change reward denoms proposal. +func (crdp *ChangeRewardDenomsProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type of a change reward denoms proposal. +func (crdp *ChangeRewardDenomsProposal) ProposalType() string { + return ProposalTypeChangeRewardDenoms +} + +// ValidateBasic runs basic stateless validity checks on a ChangeRewardDenomsProposal. +func (crdp *ChangeRewardDenomsProposal) ValidateBasic() error { + emptyDenomsToAdd := len(crdp.DenomsToAdd) == 0 + emptyDenomsToRemove := len(crdp.DenomsToRemove) == 0 + // Return error if both sets are empty or nil + if emptyDenomsToAdd && emptyDenomsToRemove { + return fmt.Errorf( + "invalid change reward denoms proposal: both denoms to add and denoms to remove are empty") + } + + // Return error if a denom is in both sets + for _, denomToAdd := range crdp.DenomsToAdd { + for _, denomToRemove := range crdp.DenomsToRemove { + if denomToAdd == denomToRemove { + return fmt.Errorf( + "invalid change reward denoms proposal: %s cannot be both added and removed", denomToAdd) + } + } + } + + // Return error if any denom is "invalid" + for _, denom := range crdp.DenomsToAdd { + if !sdk.NewCoin(denom, sdk.NewInt(1)).IsValid() { + return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) + } + } + for _, denom := range crdp.DenomsToRemove { + if !sdk.NewCoin(denom, sdk.NewInt(1)).IsValid() { + return fmt.Errorf("invalid change reward denoms proposal: %s is not a valid denom", denom) + } + } + + return nil +} diff --git a/x/ccv/provider/types/proposal_test.go b/x/ccv/provider/types/proposal_test.go index fac4c7fc4b..357c555d0e 100644 --- a/x/ccv/provider/types/proposal_test.go +++ b/x/ccv/provider/types/proposal_test.go @@ -362,3 +362,52 @@ func TestEquivocationProposalValidateBasic(t *testing.T) { }) } } + +func TestChangeRewardDenomsProposalValidateBasic(t *testing.T) { + tcs := []struct { + name string + proposal govv1beta1.Content + expectError bool + expectPanic bool + }{ + { + name: "invalid change reward denoms proposal, none to add or remove", + proposal: types.NewChangeRewardDenomsProposal( + "title", "description", []string{}, []string{}), + expectError: true, + }, + { + name: "invalid change reward denoms proposal, same denom in both sets", + proposal: types.NewChangeRewardDenomsProposal( + "title", "description", []string{"denom1"}, []string{"denom1"}), + expectError: true, + }, + { + name: "valid change reward denoms proposal", + proposal: types.NewChangeRewardDenomsProposal( + "title", "description", []string{"denom1"}, []string{"denom2"}), + expectError: false, + }, + { + name: "invalid prop, invalid denom, will panic", + proposal: types.NewChangeRewardDenomsProposal( + "title", "description", []string{"!@blah"}, []string{"denom2"}), + expectPanic: true, + }, + } + + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + if tc.expectPanic { + require.Panics(t, func() { tc.proposal.ValidateBasic() }) + return + } + err := tc.proposal.ValidateBasic() + if tc.expectError { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/ccv/provider/types/provider.pb.go b/x/ccv/provider/types/provider.pb.go index 30dba16cdc..22bc700a2f 100644 --- a/x/ccv/provider/types/provider.pb.go +++ b/x/ccv/provider/types/provider.pb.go @@ -13,6 +13,7 @@ import ( github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" types "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" _07_tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + types3 "github.com/cosmos/interchain-security/v3/x/ccv/types" _ "google.golang.org/protobuf/types/known/durationpb" _ "google.golang.org/protobuf/types/known/timestamppb" io "io" @@ -200,6 +201,10 @@ func (m *ConsumerRemovalProposal) GetStopTime() time.Time { return time.Time{} } +// EquivocationProposal is a governance proposal on the provider chain to +// punish a validator for equivocation on a consumer chain. +// +// This type is only used internally to the consumer CCV module. type EquivocationProposal struct { // the title of the proposal Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` @@ -263,6 +268,80 @@ func (m *EquivocationProposal) GetEquivocations() []*types1.Equivocation { return nil } +// ChangeRewardDenomsProposal is a governance proposal on the provider chain to +// mutate the set of denoms accepted by the provider as rewards. +type ChangeRewardDenomsProposal struct { + // the title of the proposal + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + // the description of the proposal + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + // the list of consumer reward denoms to add + DenomsToAdd []string `protobuf:"bytes,3,rep,name=denoms_to_add,json=denomsToAdd,proto3" json:"denoms_to_add,omitempty"` + // the list of consumer reward denoms to remove + DenomsToRemove []string `protobuf:"bytes,4,rep,name=denoms_to_remove,json=denomsToRemove,proto3" json:"denoms_to_remove,omitempty"` +} + +func (m *ChangeRewardDenomsProposal) Reset() { *m = ChangeRewardDenomsProposal{} } +func (m *ChangeRewardDenomsProposal) String() string { return proto.CompactTextString(m) } +func (*ChangeRewardDenomsProposal) ProtoMessage() {} +func (*ChangeRewardDenomsProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_f22ec409a72b7b72, []int{3} +} +func (m *ChangeRewardDenomsProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ChangeRewardDenomsProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ChangeRewardDenomsProposal.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 *ChangeRewardDenomsProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_ChangeRewardDenomsProposal.Merge(m, src) +} +func (m *ChangeRewardDenomsProposal) XXX_Size() int { + return m.Size() +} +func (m *ChangeRewardDenomsProposal) XXX_DiscardUnknown() { + xxx_messageInfo_ChangeRewardDenomsProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_ChangeRewardDenomsProposal proto.InternalMessageInfo + +func (m *ChangeRewardDenomsProposal) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *ChangeRewardDenomsProposal) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *ChangeRewardDenomsProposal) GetDenomsToAdd() []string { + if m != nil { + return m.DenomsToAdd + } + return nil +} + +func (m *ChangeRewardDenomsProposal) GetDenomsToRemove() []string { + if m != nil { + return m.DenomsToRemove + } + return nil +} + // A persisted queue entry indicating that a slash packet data instance needs to // be handled. This type belongs in the "global" queue, to coordinate slash // packet handling times between consumers. @@ -287,7 +366,7 @@ func (m *GlobalSlashEntry) Reset() { *m = GlobalSlashEntry{} } func (m *GlobalSlashEntry) String() string { return proto.CompactTextString(m) } func (*GlobalSlashEntry) ProtoMessage() {} func (*GlobalSlashEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_f22ec409a72b7b72, []int{3} + return fileDescriptor_f22ec409a72b7b72, []int{4} } func (m *GlobalSlashEntry) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -366,9 +445,6 @@ type Params struct { // every replenish period. This param also serves as a maximum fraction of // total voting power that the slash meter can hold. SlashMeterReplenishFraction string `protobuf:"bytes,7,opt,name=slash_meter_replenish_fraction,json=slashMeterReplenishFraction,proto3" json:"slash_meter_replenish_fraction,omitempty"` - // The maximum amount of throttled slash or vsc matured packets - // that can be queued for a single consumer before the provider chain halts. - MaxThrottledPackets int64 `protobuf:"varint,8,opt,name=max_throttled_packets,json=maxThrottledPackets,proto3" json:"max_throttled_packets,omitempty"` // The fee required to be paid to add a reward denom ConsumerRewardDenomRegistrationFee types2.Coin `protobuf:"bytes,9,opt,name=consumer_reward_denom_registration_fee,json=consumerRewardDenomRegistrationFee,proto3" json:"consumer_reward_denom_registration_fee"` } @@ -377,7 +453,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_f22ec409a72b7b72, []int{4} + return fileDescriptor_f22ec409a72b7b72, []int{5} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -455,13 +531,6 @@ func (m *Params) GetSlashMeterReplenishFraction() string { return "" } -func (m *Params) GetMaxThrottledPackets() int64 { - if m != nil { - return m.MaxThrottledPackets - } - return 0 -} - func (m *Params) GetConsumerRewardDenomRegistrationFee() types2.Coin { if m != nil { return m.ConsumerRewardDenomRegistrationFee @@ -469,60 +538,8 @@ func (m *Params) GetConsumerRewardDenomRegistrationFee() types2.Coin { return types2.Coin{} } -type HandshakeMetadata struct { - ProviderFeePoolAddr string `protobuf:"bytes,1,opt,name=provider_fee_pool_addr,json=providerFeePoolAddr,proto3" json:"provider_fee_pool_addr,omitempty"` - Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` -} - -func (m *HandshakeMetadata) Reset() { *m = HandshakeMetadata{} } -func (m *HandshakeMetadata) String() string { return proto.CompactTextString(m) } -func (*HandshakeMetadata) ProtoMessage() {} -func (*HandshakeMetadata) Descriptor() ([]byte, []int) { - return fileDescriptor_f22ec409a72b7b72, []int{5} -} -func (m *HandshakeMetadata) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *HandshakeMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_HandshakeMetadata.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 *HandshakeMetadata) XXX_Merge(src proto.Message) { - xxx_messageInfo_HandshakeMetadata.Merge(m, src) -} -func (m *HandshakeMetadata) XXX_Size() int { - return m.Size() -} -func (m *HandshakeMetadata) XXX_DiscardUnknown() { - xxx_messageInfo_HandshakeMetadata.DiscardUnknown(m) -} - -var xxx_messageInfo_HandshakeMetadata proto.InternalMessageInfo - -func (m *HandshakeMetadata) GetProviderFeePoolAddr() string { - if m != nil { - return m.ProviderFeePoolAddr - } - return "" -} - -func (m *HandshakeMetadata) GetVersion() string { - if m != nil { - return m.Version - } - return "" -} - // SlashAcks contains cons addresses of consumer chain validators -// successfully slashed on the provider chain +// successfully slashed on the provider chain. type SlashAcks struct { Addresses []string `protobuf:"bytes,1,rep,name=addresses,proto3" json:"addresses,omitempty"` } @@ -706,6 +723,7 @@ func (m *AddressList) GetAddresses() [][]byte { return nil } +// ChannelToChain is used to map a CCV channel ID to the consumer chainID type ChannelToChain struct { ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` @@ -971,6 +989,97 @@ func (m *VscSendTimestamp) GetTimestamp() time.Time { return time.Time{} } +// ValidatorSetChangePackets is a pb list of ccv.ValidatorSetChangePacketData. +type ValidatorSetChangePackets struct { + List []types3.ValidatorSetChangePacketData `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` +} + +func (m *ValidatorSetChangePackets) Reset() { *m = ValidatorSetChangePackets{} } +func (m *ValidatorSetChangePackets) String() string { return proto.CompactTextString(m) } +func (*ValidatorSetChangePackets) ProtoMessage() {} +func (*ValidatorSetChangePackets) Descriptor() ([]byte, []int) { + return fileDescriptor_f22ec409a72b7b72, []int{15} +} +func (m *ValidatorSetChangePackets) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorSetChangePackets) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorSetChangePackets.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 *ValidatorSetChangePackets) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorSetChangePackets.Merge(m, src) +} +func (m *ValidatorSetChangePackets) XXX_Size() int { + return m.Size() +} +func (m *ValidatorSetChangePackets) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorSetChangePackets.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorSetChangePackets proto.InternalMessageInfo + +func (m *ValidatorSetChangePackets) GetList() []types3.ValidatorSetChangePacketData { + if m != nil { + return m.List + } + return nil +} + +// MaturedUnbondingOps defines a list of ids corresponding to ids of matured +// unbonding operations. +type MaturedUnbondingOps struct { + Ids []uint64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids,omitempty"` +} + +func (m *MaturedUnbondingOps) Reset() { *m = MaturedUnbondingOps{} } +func (m *MaturedUnbondingOps) String() string { return proto.CompactTextString(m) } +func (*MaturedUnbondingOps) ProtoMessage() {} +func (*MaturedUnbondingOps) Descriptor() ([]byte, []int) { + return fileDescriptor_f22ec409a72b7b72, []int{16} +} +func (m *MaturedUnbondingOps) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MaturedUnbondingOps) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MaturedUnbondingOps.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 *MaturedUnbondingOps) XXX_Merge(src proto.Message) { + xxx_messageInfo_MaturedUnbondingOps.Merge(m, src) +} +func (m *MaturedUnbondingOps) XXX_Size() int { + return m.Size() +} +func (m *MaturedUnbondingOps) XXX_DiscardUnknown() { + xxx_messageInfo_MaturedUnbondingOps.DiscardUnknown(m) +} + +var xxx_messageInfo_MaturedUnbondingOps proto.InternalMessageInfo + +func (m *MaturedUnbondingOps) GetIds() []uint64 { + if m != nil { + return m.Ids + } + return nil +} + // ExportedVscSendTimestamps is VscSendTimestamp with chainID info for exporting to genesis type ExportedVscSendTimestamp struct { ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` @@ -981,7 +1090,7 @@ func (m *ExportedVscSendTimestamp) Reset() { *m = ExportedVscSendTimesta func (m *ExportedVscSendTimestamp) String() string { return proto.CompactTextString(m) } func (*ExportedVscSendTimestamp) ProtoMessage() {} func (*ExportedVscSendTimestamp) Descriptor() ([]byte, []int) { - return fileDescriptor_f22ec409a72b7b72, []int{15} + return fileDescriptor_f22ec409a72b7b72, []int{17} } func (m *ExportedVscSendTimestamp) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1034,7 +1143,7 @@ func (m *KeyAssignmentReplacement) Reset() { *m = KeyAssignmentReplaceme func (m *KeyAssignmentReplacement) String() string { return proto.CompactTextString(m) } func (*KeyAssignmentReplacement) ProtoMessage() {} func (*KeyAssignmentReplacement) Descriptor() ([]byte, []int) { - return fileDescriptor_f22ec409a72b7b72, []int{16} + return fileDescriptor_f22ec409a72b7b72, []int{18} } func (m *KeyAssignmentReplacement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1097,7 +1206,7 @@ func (m *ValidatorConsumerPubKey) Reset() { *m = ValidatorConsumerPubKey func (m *ValidatorConsumerPubKey) String() string { return proto.CompactTextString(m) } func (*ValidatorConsumerPubKey) ProtoMessage() {} func (*ValidatorConsumerPubKey) Descriptor() ([]byte, []int) { - return fileDescriptor_f22ec409a72b7b72, []int{17} + return fileDescriptor_f22ec409a72b7b72, []int{19} } func (m *ValidatorConsumerPubKey) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1160,7 +1269,7 @@ func (m *ValidatorByConsumerAddr) Reset() { *m = ValidatorByConsumerAddr func (m *ValidatorByConsumerAddr) String() string { return proto.CompactTextString(m) } func (*ValidatorByConsumerAddr) ProtoMessage() {} func (*ValidatorByConsumerAddr) Descriptor() ([]byte, []int) { - return fileDescriptor_f22ec409a72b7b72, []int{18} + return fileDescriptor_f22ec409a72b7b72, []int{20} } func (m *ValidatorByConsumerAddr) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1222,7 +1331,7 @@ func (m *ConsumerAddrsToPrune) Reset() { *m = ConsumerAddrsToPrune{} } func (m *ConsumerAddrsToPrune) String() string { return proto.CompactTextString(m) } func (*ConsumerAddrsToPrune) ProtoMessage() {} func (*ConsumerAddrsToPrune) Descriptor() ([]byte, []int) { - return fileDescriptor_f22ec409a72b7b72, []int{19} + return fileDescriptor_f22ec409a72b7b72, []int{21} } func (m *ConsumerAddrsToPrune) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1276,9 +1385,9 @@ func init() { proto.RegisterType((*ConsumerAdditionProposal)(nil), "interchain_security.ccv.provider.v1.ConsumerAdditionProposal") proto.RegisterType((*ConsumerRemovalProposal)(nil), "interchain_security.ccv.provider.v1.ConsumerRemovalProposal") proto.RegisterType((*EquivocationProposal)(nil), "interchain_security.ccv.provider.v1.EquivocationProposal") + proto.RegisterType((*ChangeRewardDenomsProposal)(nil), "interchain_security.ccv.provider.v1.ChangeRewardDenomsProposal") proto.RegisterType((*GlobalSlashEntry)(nil), "interchain_security.ccv.provider.v1.GlobalSlashEntry") proto.RegisterType((*Params)(nil), "interchain_security.ccv.provider.v1.Params") - proto.RegisterType((*HandshakeMetadata)(nil), "interchain_security.ccv.provider.v1.HandshakeMetadata") proto.RegisterType((*SlashAcks)(nil), "interchain_security.ccv.provider.v1.SlashAcks") proto.RegisterType((*ConsumerAdditionProposals)(nil), "interchain_security.ccv.provider.v1.ConsumerAdditionProposals") proto.RegisterType((*ConsumerRemovalProposals)(nil), "interchain_security.ccv.provider.v1.ConsumerRemovalProposals") @@ -1288,6 +1397,8 @@ func init() { proto.RegisterType((*UnbondingOp)(nil), "interchain_security.ccv.provider.v1.UnbondingOp") proto.RegisterType((*InitTimeoutTimestamp)(nil), "interchain_security.ccv.provider.v1.InitTimeoutTimestamp") proto.RegisterType((*VscSendTimestamp)(nil), "interchain_security.ccv.provider.v1.VscSendTimestamp") + proto.RegisterType((*ValidatorSetChangePackets)(nil), "interchain_security.ccv.provider.v1.ValidatorSetChangePackets") + proto.RegisterType((*MaturedUnbondingOps)(nil), "interchain_security.ccv.provider.v1.MaturedUnbondingOps") proto.RegisterType((*ExportedVscSendTimestamp)(nil), "interchain_security.ccv.provider.v1.ExportedVscSendTimestamp") proto.RegisterType((*KeyAssignmentReplacement)(nil), "interchain_security.ccv.provider.v1.KeyAssignmentReplacement") proto.RegisterType((*ValidatorConsumerPubKey)(nil), "interchain_security.ccv.provider.v1.ValidatorConsumerPubKey") @@ -1300,110 +1411,113 @@ func init() { } var fileDescriptor_f22ec409a72b7b72 = []byte{ - // 1645 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0x4d, 0x73, 0x1b, 0xc7, - 0xd1, 0xe6, 0x12, 0xfc, 0xc2, 0x80, 0x1f, 0xe2, 0x92, 0xb2, 0x96, 0x7a, 0xf9, 0x82, 0xd0, 0x3a, - 0x71, 0x31, 0xe5, 0xf2, 0x22, 0xa4, 0x2a, 0x55, 0x29, 0x55, 0x5c, 0x2e, 0x12, 0x92, 0x2c, 0x9a, - 0xb1, 0x05, 0x2f, 0x19, 0xaa, 0x92, 0x1c, 0xb6, 0x66, 0x67, 0x5b, 0xc0, 0x14, 0x77, 0x77, 0x56, - 0x33, 0x83, 0x95, 0x70, 0xc9, 0x39, 0x47, 0xe7, 0xe6, 0x4a, 0x2e, 0x4e, 0xfe, 0x40, 0xfe, 0x86, - 0x8f, 0x3e, 0xe6, 0x64, 0xa7, 0xa4, 0x43, 0x0e, 0xf9, 0x13, 0xa9, 0x99, 0xfd, 0x04, 0x48, 0x2a, - 0x50, 0x25, 0xb9, 0xed, 0xf4, 0x74, 0x3f, 0xdd, 0x3d, 0xd3, 0xfd, 0xf4, 0x00, 0xe8, 0x90, 0xc6, - 0x12, 0x38, 0x19, 0x62, 0x1a, 0x7b, 0x02, 0xc8, 0x88, 0x53, 0x39, 0xee, 0x12, 0x92, 0x76, 0x13, - 0xce, 0x52, 0x1a, 0x00, 0xef, 0xa6, 0x07, 0xe5, 0xb7, 0x93, 0x70, 0x26, 0x99, 0xf9, 0xfe, 0x35, - 0x36, 0x0e, 0x21, 0xa9, 0x53, 0xea, 0xa5, 0x07, 0x77, 0xb7, 0x07, 0x6c, 0xc0, 0xb4, 0x7e, 0x57, - 0x7d, 0x65, 0xa6, 0x77, 0xf7, 0x06, 0x8c, 0x0d, 0x42, 0xe8, 0xea, 0x95, 0x3f, 0x7a, 0xde, 0x95, - 0x34, 0x02, 0x21, 0x71, 0x94, 0xe4, 0x0a, 0xed, 0x69, 0x85, 0x60, 0xc4, 0xb1, 0xa4, 0x2c, 0x2e, - 0x00, 0xa8, 0x4f, 0xba, 0x84, 0x71, 0xe8, 0x92, 0x90, 0x42, 0x2c, 0x55, 0x78, 0xd9, 0x57, 0xae, - 0xd0, 0x55, 0x0a, 0x21, 0x1d, 0x0c, 0x65, 0x26, 0x16, 0x5d, 0x09, 0x71, 0x00, 0x3c, 0xa2, 0x99, - 0x72, 0xb5, 0xca, 0x0d, 0x76, 0x6b, 0xfb, 0x84, 0x8f, 0x13, 0xc9, 0xba, 0x97, 0x30, 0x16, 0xf9, - 0xee, 0x07, 0x84, 0x89, 0x88, 0x89, 0x2e, 0xa8, 0xc4, 0x62, 0x02, 0xdd, 0xf4, 0xc0, 0x07, 0x89, - 0x0f, 0x4a, 0x41, 0x11, 0x77, 0xae, 0xe7, 0x63, 0x51, 0xe9, 0x10, 0x46, 0xf3, 0xb8, 0xed, 0x1f, - 0x96, 0x90, 0xd5, 0x63, 0xb1, 0x18, 0x45, 0xc0, 0x8f, 0x82, 0x80, 0xaa, 0x94, 0xfa, 0x9c, 0x25, - 0x4c, 0xe0, 0xd0, 0xdc, 0x46, 0x8b, 0x92, 0xca, 0x10, 0x2c, 0xa3, 0x63, 0xec, 0x37, 0xdd, 0x6c, - 0x61, 0x76, 0x50, 0x2b, 0x00, 0x41, 0x38, 0x4d, 0x94, 0xb2, 0x35, 0xaf, 0xf7, 0xea, 0x22, 0x73, - 0x07, 0xad, 0x64, 0xb7, 0x40, 0x03, 0xab, 0xa1, 0xb7, 0x97, 0xf5, 0xfa, 0x24, 0x30, 0x3f, 0x45, - 0xeb, 0x34, 0xa6, 0x92, 0xe2, 0xd0, 0x1b, 0x82, 0x3a, 0x0d, 0x6b, 0xa1, 0x63, 0xec, 0xb7, 0x0e, - 0xef, 0x3a, 0xd4, 0x27, 0x8e, 0x3a, 0x40, 0x27, 0x3f, 0xb6, 0xf4, 0xc0, 0x79, 0xa2, 0x35, 0x8e, - 0x17, 0xbe, 0xfd, 0x7e, 0x6f, 0xce, 0x5d, 0xcb, 0xed, 0x32, 0xa1, 0x79, 0x0f, 0xad, 0x0e, 0x20, - 0x06, 0x41, 0x85, 0x37, 0xc4, 0x62, 0x68, 0x2d, 0x76, 0x8c, 0xfd, 0x55, 0xb7, 0x95, 0xcb, 0x9e, - 0x60, 0x31, 0x34, 0xf7, 0x50, 0xcb, 0xa7, 0x31, 0xe6, 0xe3, 0x4c, 0x63, 0x49, 0x6b, 0xa0, 0x4c, - 0xa4, 0x15, 0x7a, 0x08, 0x89, 0x04, 0xbf, 0x8c, 0x3d, 0x75, 0xdb, 0xd6, 0x72, 0x1e, 0x48, 0x76, - 0xd3, 0x4e, 0x71, 0xd3, 0xce, 0x79, 0x51, 0x0a, 0xc7, 0x2b, 0x2a, 0x90, 0xaf, 0x7e, 0xd8, 0x33, - 0xdc, 0xa6, 0xb6, 0x53, 0x3b, 0xe6, 0x17, 0xe8, 0xd6, 0x28, 0xf6, 0x59, 0x1c, 0xd0, 0x78, 0xe0, - 0x25, 0xc0, 0x29, 0x0b, 0xac, 0x15, 0x0d, 0xb5, 0x73, 0x05, 0xea, 0x61, 0x5e, 0x34, 0x19, 0xd2, - 0xd7, 0x0a, 0x69, 0xa3, 0x34, 0xee, 0x6b, 0x5b, 0xf3, 0x4b, 0x64, 0x12, 0x92, 0xea, 0x90, 0xd8, - 0x48, 0x16, 0x88, 0xcd, 0xd9, 0x11, 0x6f, 0x11, 0x92, 0x9e, 0x67, 0xd6, 0x39, 0xe4, 0x6f, 0xd1, - 0x1d, 0xc9, 0x71, 0x2c, 0x9e, 0x03, 0x9f, 0xc6, 0x45, 0xb3, 0xe3, 0xde, 0x2e, 0x30, 0x26, 0xc1, - 0x9f, 0xa0, 0x0e, 0xc9, 0x0b, 0xc8, 0xe3, 0x10, 0x50, 0x21, 0x39, 0xf5, 0x47, 0xca, 0xd6, 0x7b, - 0xce, 0x31, 0xd1, 0x35, 0xd2, 0xd2, 0x45, 0xd0, 0x2e, 0xf4, 0xdc, 0x09, 0xb5, 0xc7, 0xb9, 0x96, - 0xf9, 0x14, 0xfd, 0xc8, 0x0f, 0x19, 0xb9, 0x14, 0x2a, 0x38, 0x6f, 0x02, 0x49, 0xbb, 0x8e, 0xa8, - 0x10, 0x0a, 0x6d, 0xb5, 0x63, 0xec, 0x37, 0xdc, 0x7b, 0x99, 0x6e, 0x1f, 0xf8, 0xc3, 0x9a, 0xe6, - 0x79, 0x4d, 0xd1, 0xfc, 0x08, 0x99, 0x43, 0x2a, 0x24, 0xe3, 0x94, 0xe0, 0xd0, 0x83, 0x58, 0x72, - 0x0a, 0xc2, 0x5a, 0xd3, 0xe6, 0x9b, 0xd5, 0xce, 0xa3, 0x6c, 0xc3, 0xfc, 0x0c, 0xdd, 0xbb, 0xd1, - 0xa9, 0x47, 0x86, 0x38, 0x8e, 0x21, 0xb4, 0xd6, 0x75, 0x2a, 0x7b, 0xc1, 0x0d, 0x3e, 0x7b, 0x99, - 0xda, 0x83, 0x95, 0xdf, 0x7f, 0xb3, 0x37, 0xf7, 0xf5, 0x37, 0x7b, 0x73, 0xf6, 0x5f, 0x0d, 0x74, - 0xa7, 0x57, 0x26, 0x1e, 0xb1, 0x14, 0x87, 0xff, 0xcb, 0x06, 0x3b, 0x42, 0x4d, 0x21, 0x59, 0x92, - 0x95, 0xf4, 0xc2, 0x3b, 0x94, 0xf4, 0x8a, 0x32, 0x53, 0x1b, 0xf6, 0x9f, 0x0c, 0xb4, 0xfd, 0xe8, - 0xc5, 0x88, 0xa6, 0x8c, 0xe0, 0xff, 0x0a, 0x1f, 0x9c, 0xa2, 0x35, 0xa8, 0xe1, 0x09, 0xab, 0xd1, - 0x69, 0xec, 0xb7, 0x0e, 0x7f, 0xec, 0x64, 0xe4, 0xe4, 0x94, 0x9c, 0x95, 0x13, 0x94, 0x53, 0xf7, - 0xee, 0x4e, 0xda, 0xda, 0xff, 0x34, 0xd0, 0xad, 0x4f, 0x43, 0xe6, 0xe3, 0xf0, 0x2c, 0xc4, 0x62, - 0xa8, 0x2e, 0x6f, 0xac, 0xb2, 0xe6, 0x90, 0x77, 0x8d, 0x8e, 0x6e, 0xe6, 0xac, 0x95, 0x99, 0xee, - 0xe3, 0x4f, 0xd0, 0x66, 0x59, 0xc7, 0xe5, 0xe1, 0xea, 0x64, 0x8e, 0xb7, 0x5e, 0x7f, 0xbf, 0xb7, - 0x51, 0xdc, 0x61, 0x4f, 0x1f, 0xf4, 0x43, 0x77, 0x83, 0x4c, 0x08, 0x02, 0xb3, 0x8d, 0x5a, 0xd4, - 0x27, 0x9e, 0x80, 0x17, 0x5e, 0x3c, 0x8a, 0xf4, 0xbd, 0x2c, 0xb8, 0x4d, 0xea, 0x93, 0x33, 0x78, - 0xf1, 0xc5, 0x28, 0x32, 0xef, 0xa3, 0xf7, 0x8a, 0x41, 0xe4, 0xa5, 0x38, 0xf4, 0x94, 0xbd, 0x87, - 0x83, 0x80, 0xeb, 0x6b, 0x5a, 0x75, 0xb7, 0x8a, 0xdd, 0x0b, 0x1c, 0x2a, 0x67, 0x47, 0x41, 0xc0, - 0xed, 0x7f, 0x2c, 0xa2, 0xa5, 0x3e, 0xe6, 0x38, 0x12, 0xe6, 0x39, 0xda, 0x90, 0x10, 0x25, 0x21, - 0x96, 0xe0, 0x65, 0x1c, 0x99, 0x67, 0xfa, 0xa1, 0xe6, 0xce, 0xfa, 0x6c, 0x71, 0x6a, 0xd3, 0x24, - 0x3d, 0x70, 0x7a, 0x5a, 0x7a, 0x26, 0xb1, 0x04, 0x77, 0xbd, 0xc0, 0xc8, 0x84, 0xe6, 0xcf, 0x91, - 0x25, 0xf9, 0x48, 0xc8, 0x8a, 0xbd, 0xaa, 0xb6, 0xcd, 0xae, 0xf2, 0xbd, 0x62, 0x3f, 0x6b, 0xf8, - 0xb2, 0x5d, 0xaf, 0x27, 0xaa, 0xc6, 0x7f, 0x42, 0x54, 0x67, 0x68, 0x4b, 0xb1, 0xfc, 0x34, 0xe6, - 0xc2, 0xec, 0x98, 0x9b, 0xca, 0x7e, 0x12, 0xf4, 0x4b, 0x64, 0xa6, 0x82, 0x4c, 0x63, 0x2e, 0xbe, - 0x43, 0x9c, 0xa9, 0x20, 0x93, 0x90, 0x01, 0xda, 0x15, 0xaa, 0xf8, 0xbc, 0x08, 0xa4, 0xa6, 0xbd, - 0x24, 0x84, 0x98, 0x8a, 0x61, 0x01, 0xbe, 0x34, 0x3b, 0xf8, 0x8e, 0x06, 0xfa, 0x5c, 0xe1, 0xb8, - 0x05, 0x4c, 0xee, 0xa5, 0x87, 0xda, 0xd7, 0x7b, 0x29, 0x2f, 0x68, 0x59, 0x5f, 0xd0, 0xff, 0x5d, - 0x03, 0x51, 0xde, 0xd2, 0x21, 0xba, 0x1d, 0xe1, 0x57, 0x9e, 0x1c, 0x72, 0x26, 0x65, 0x08, 0x81, - 0x97, 0x60, 0x72, 0x09, 0x52, 0xe8, 0x19, 0xd5, 0x70, 0xb7, 0x22, 0xfc, 0xea, 0xbc, 0xd8, 0xeb, - 0x67, 0x5b, 0xa6, 0x40, 0x1f, 0xd4, 0x28, 0xfd, 0x25, 0xe6, 0x81, 0x17, 0x40, 0xcc, 0x22, 0x8f, - 0xc3, 0x40, 0xf1, 0x1e, 0xce, 0xd8, 0x1d, 0xa0, 0x1c, 0x4b, 0x79, 0x23, 0xab, 0x57, 0x46, 0xd9, - 0xc4, 0x3d, 0x46, 0xe3, 0x7c, 0x76, 0xdb, 0x15, 0xf3, 0x2b, 0xb4, 0x87, 0x0a, 0xcc, 0xad, 0x61, - 0x3d, 0x06, 0xb0, 0x7d, 0xb4, 0xf9, 0x04, 0xc7, 0x81, 0x18, 0xe2, 0x4b, 0xf8, 0x1c, 0x24, 0x0e, - 0xb0, 0xc4, 0x13, 0x3d, 0xf3, 0x1c, 0xc0, 0x4b, 0x18, 0x0b, 0xb3, 0x9e, 0xc9, 0x28, 0xa8, 0xec, - 0x99, 0xc7, 0x00, 0x7d, 0xc6, 0x42, 0xd5, 0x33, 0xa6, 0x85, 0x96, 0x53, 0xe0, 0xa2, 0xaa, 0xe0, - 0x62, 0x69, 0xff, 0x04, 0x35, 0x35, 0x69, 0x1c, 0x91, 0x4b, 0x61, 0xee, 0xa2, 0xa6, 0x42, 0x02, - 0x21, 0x40, 0x58, 0x46, 0xa7, 0xb1, 0xdf, 0x74, 0x2b, 0x81, 0x2d, 0xd1, 0xce, 0x4d, 0xef, 0x22, - 0x61, 0x3e, 0x43, 0xcb, 0x09, 0xe8, 0xa1, 0xad, 0x0d, 0x5b, 0x87, 0x1f, 0x3b, 0x33, 0xbc, 0x3d, - 0x9d, 0x9b, 0x00, 0xdd, 0x02, 0xcd, 0xe6, 0xd5, 0x6b, 0x6c, 0x6a, 0x56, 0x08, 0xf3, 0x62, 0xda, - 0xe9, 0x2f, 0xde, 0xc9, 0xe9, 0x14, 0x5e, 0xe5, 0xf3, 0x43, 0xd4, 0x3a, 0xca, 0xd2, 0xfe, 0x25, - 0x15, 0xf2, 0xea, 0xb1, 0xac, 0xd6, 0x8f, 0xe5, 0x33, 0xb4, 0x9e, 0x8f, 0xb8, 0x73, 0xa6, 0x89, - 0xcf, 0xfc, 0x7f, 0x84, 0xf2, 0xd9, 0xa8, 0x08, 0x33, 0xbb, 0x96, 0x66, 0x2e, 0x39, 0x09, 0x26, - 0x46, 0xd5, 0xfc, 0xc4, 0xa8, 0xb2, 0x5d, 0xb4, 0x71, 0x21, 0xc8, 0xaf, 0x8a, 0xf7, 0xcf, 0xd3, - 0x44, 0x98, 0xb7, 0xd1, 0x92, 0xea, 0xd5, 0x1c, 0x68, 0xc1, 0x5d, 0x4c, 0x05, 0x39, 0x09, 0xcc, - 0xfd, 0xfa, 0x1b, 0x8b, 0x25, 0x1e, 0x0d, 0x84, 0x35, 0xdf, 0x69, 0xec, 0x2f, 0xb8, 0xeb, 0xa3, - 0xca, 0xfc, 0x24, 0x10, 0xf6, 0xaf, 0x51, 0xab, 0x06, 0x68, 0xae, 0xa3, 0xf9, 0x12, 0x6b, 0x9e, - 0x06, 0xe6, 0x03, 0xb4, 0x53, 0x01, 0x4d, 0xd2, 0x7d, 0x86, 0xd8, 0x74, 0xef, 0x94, 0x0a, 0x13, - 0x8c, 0x2f, 0xec, 0xa7, 0x68, 0xfb, 0xa4, 0x22, 0x97, 0x72, 0x98, 0x4c, 0x64, 0x68, 0x4c, 0x0e, - 0xe3, 0x5d, 0xd4, 0x2c, 0x7f, 0x48, 0xe8, 0xec, 0x17, 0xdc, 0x4a, 0x60, 0x47, 0xe8, 0xd6, 0x85, - 0x20, 0x67, 0x10, 0x07, 0x15, 0xd8, 0x0d, 0x07, 0x70, 0x3c, 0x0d, 0x34, 0xf3, 0x43, 0xb5, 0x72, - 0xf7, 0x17, 0x03, 0x59, 0x8f, 0x5e, 0x25, 0x8c, 0x4b, 0x08, 0xae, 0xf8, 0x7d, 0x4b, 0x12, 0x97, - 0x68, 0x4b, 0x85, 0x24, 0x20, 0x0e, 0xbc, 0x12, 0x2d, 0x3b, 0xad, 0xd6, 0xe1, 0xcf, 0x66, 0xaa, - 0xc1, 0x69, 0x77, 0x39, 0x2d, 0x6c, 0xa6, 0x53, 0x72, 0x61, 0xff, 0xc1, 0x40, 0xd6, 0x29, 0x8c, - 0x8f, 0x84, 0xa0, 0x83, 0x38, 0x82, 0x58, 0x2a, 0x46, 0xc3, 0x04, 0xd4, 0xa7, 0xf9, 0x3e, 0x5a, - 0x2b, 0xd9, 0xa0, 0x24, 0x81, 0x55, 0x77, 0xb5, 0x10, 0xea, 0xee, 0x7f, 0x80, 0x50, 0xc2, 0x21, - 0xf5, 0x88, 0x77, 0x09, 0xe3, 0xfc, 0xac, 0x76, 0xeb, 0x03, 0x31, 0xfb, 0x31, 0xe5, 0xf4, 0x47, - 0x7e, 0x48, 0xc9, 0x29, 0x8c, 0xdd, 0x15, 0xa5, 0xdf, 0x3b, 0x85, 0xb1, 0x7a, 0xe0, 0x24, 0xec, - 0x25, 0x70, 0x3d, 0xc5, 0x1a, 0x6e, 0xb6, 0xb0, 0xff, 0x68, 0xa0, 0x3b, 0x17, 0x38, 0xa4, 0x01, - 0x96, 0x8c, 0x17, 0x45, 0xd1, 0x1f, 0xf9, 0xca, 0xe2, 0x2d, 0xe7, 0x76, 0x25, 0xda, 0xf9, 0x6b, - 0xa2, 0xfd, 0x04, 0xad, 0x96, 0x65, 0xa8, 0xe2, 0x6d, 0xcc, 0x10, 0x6f, 0xab, 0xb0, 0x38, 0x85, - 0xb1, 0xfd, 0xbb, 0x5a, 0x6c, 0xc7, 0xe3, 0x1a, 0xc3, 0xf0, 0x7f, 0x13, 0x5b, 0xe9, 0xb6, 0x1e, - 0x1b, 0xa9, 0xdb, 0x5f, 0x49, 0xa0, 0x71, 0x35, 0x01, 0xfb, 0xcf, 0x06, 0xda, 0xae, 0x7b, 0x15, - 0xe7, 0xac, 0xcf, 0x47, 0x31, 0xbc, 0xcd, 0x7b, 0x55, 0xe4, 0xf3, 0xf5, 0x22, 0x7f, 0x86, 0xd6, - 0x27, 0x82, 0x12, 0xf9, 0x69, 0xfc, 0x74, 0xa6, 0x1a, 0xab, 0x71, 0x98, 0xbb, 0x56, 0xcf, 0x43, - 0x1c, 0x3f, 0xfb, 0xf6, 0x75, 0xdb, 0xf8, 0xee, 0x75, 0xdb, 0xf8, 0xfb, 0xeb, 0xb6, 0xf1, 0xd5, - 0x9b, 0xf6, 0xdc, 0x77, 0x6f, 0xda, 0x73, 0x7f, 0x7b, 0xd3, 0x9e, 0xfb, 0xcd, 0xc7, 0x03, 0x2a, - 0x87, 0x23, 0xdf, 0x21, 0x2c, 0xea, 0xe6, 0xbf, 0x94, 0x2b, 0x5f, 0x1f, 0x95, 0x7f, 0x3c, 0xa4, - 0xf7, 0xbb, 0xaf, 0x26, 0xff, 0x7d, 0x90, 0xe3, 0x04, 0x84, 0xbf, 0xa4, 0x7b, 0xef, 0xfe, 0xbf, - 0x02, 0x00, 0x00, 0xff, 0xff, 0x2b, 0x34, 0xfa, 0x5d, 0xae, 0x10, 0x00, 0x00, + // 1690 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x72, 0x1b, 0xc7, + 0x11, 0xe6, 0x12, 0x20, 0x45, 0x34, 0xf8, 0xa7, 0x25, 0x6d, 0x81, 0x0a, 0x03, 0x52, 0xeb, 0xd8, + 0x61, 0xca, 0xe5, 0x45, 0x48, 0x55, 0xaa, 0x5c, 0xaa, 0xb8, 0x5c, 0x24, 0x28, 0x5b, 0x14, 0x63, + 0x8b, 0x5e, 0x32, 0x54, 0x25, 0x39, 0x6c, 0x0d, 0x66, 0x47, 0xc0, 0x14, 0x77, 0x77, 0x56, 0x33, + 0xb3, 0x2b, 0xe3, 0x92, 0x73, 0x8e, 0xce, 0xcd, 0x95, 0x5c, 0x9c, 0xbc, 0x40, 0xce, 0x79, 0x03, + 0x1f, 0x7d, 0xcc, 0xc9, 0x4e, 0x51, 0xc7, 0xbc, 0x44, 0x6a, 0x66, 0xff, 0x41, 0x52, 0x81, 0x4a, + 0xf1, 0x6d, 0xb6, 0xa7, 0xfb, 0xeb, 0x9e, 0xe9, 0xee, 0xaf, 0x07, 0x80, 0x3d, 0x1a, 0x4a, 0xc2, + 0xf1, 0x08, 0xd1, 0xd0, 0x15, 0x04, 0xc7, 0x9c, 0xca, 0x71, 0x0f, 0xe3, 0xa4, 0x17, 0x71, 0x96, + 0x50, 0x8f, 0xf0, 0x5e, 0xb2, 0x5b, 0xac, 0xed, 0x88, 0x33, 0xc9, 0xcc, 0x77, 0xae, 0xb1, 0xb1, + 0x31, 0x4e, 0xec, 0x42, 0x2f, 0xd9, 0xbd, 0xfb, 0xee, 0x4d, 0xc0, 0xc9, 0x6e, 0xef, 0x05, 0xe5, + 0x24, 0xc5, 0xba, 0xbb, 0x3e, 0x64, 0x43, 0xa6, 0x97, 0x3d, 0xb5, 0xca, 0xa4, 0x5b, 0x43, 0xc6, + 0x86, 0x3e, 0xe9, 0xe9, 0xaf, 0x41, 0xfc, 0xac, 0x27, 0x69, 0x40, 0x84, 0x44, 0x41, 0x94, 0x29, + 0x74, 0x27, 0x15, 0xbc, 0x98, 0x23, 0x49, 0x59, 0x98, 0x03, 0xd0, 0x01, 0xee, 0x61, 0xc6, 0x49, + 0x0f, 0xfb, 0x94, 0x84, 0x52, 0x79, 0x4d, 0x57, 0x99, 0x42, 0x4f, 0x29, 0xf8, 0x74, 0x38, 0x92, + 0xa9, 0x58, 0xf4, 0x24, 0x09, 0x3d, 0xc2, 0x03, 0x9a, 0x2a, 0x97, 0x5f, 0x99, 0xc1, 0x66, 0x65, + 0x1f, 0xf3, 0x71, 0x24, 0x59, 0xef, 0x82, 0x8c, 0x45, 0xb6, 0xfb, 0x1e, 0x66, 0x22, 0x60, 0xa2, + 0x47, 0xd4, 0xf9, 0x43, 0x4c, 0x7a, 0xc9, 0xee, 0x80, 0x48, 0xb4, 0x5b, 0x08, 0xf2, 0xb8, 0x33, + 0xbd, 0x01, 0x12, 0xa5, 0x0e, 0x66, 0x34, 0x8b, 0xdb, 0xfa, 0x61, 0x1e, 0x3a, 0x7d, 0x16, 0x8a, + 0x38, 0x20, 0x7c, 0xdf, 0xf3, 0xa8, 0x3a, 0xd2, 0x09, 0x67, 0x11, 0x13, 0xc8, 0x37, 0xd7, 0x61, + 0x4e, 0x52, 0xe9, 0x93, 0x8e, 0xb1, 0x6d, 0xec, 0xb4, 0x9c, 0xf4, 0xc3, 0xdc, 0x86, 0xb6, 0x47, + 0x04, 0xe6, 0x34, 0x52, 0xca, 0x9d, 0x59, 0xbd, 0x57, 0x15, 0x99, 0x1b, 0xb0, 0x90, 0xe6, 0x81, + 0x7a, 0x9d, 0x86, 0xde, 0xbe, 0xa5, 0xbf, 0x8f, 0x3c, 0xf3, 0x53, 0x58, 0xa6, 0x21, 0x95, 0x14, + 0xf9, 0xee, 0x88, 0xa8, 0xdb, 0xe8, 0x34, 0xb7, 0x8d, 0x9d, 0xf6, 0xde, 0x5d, 0x9b, 0x0e, 0xb0, + 0xad, 0x2e, 0xd0, 0xce, 0xae, 0x2d, 0xd9, 0xb5, 0x1f, 0x69, 0x8d, 0x83, 0xe6, 0xb7, 0xdf, 0x6f, + 0xcd, 0x38, 0x4b, 0x99, 0x5d, 0x2a, 0x34, 0xef, 0xc1, 0xe2, 0x90, 0x84, 0x44, 0x50, 0xe1, 0x8e, + 0x90, 0x18, 0x75, 0xe6, 0xb6, 0x8d, 0x9d, 0x45, 0xa7, 0x9d, 0xc9, 0x1e, 0x21, 0x31, 0x32, 0xb7, + 0xa0, 0x3d, 0xa0, 0x21, 0xe2, 0xe3, 0x54, 0x63, 0x5e, 0x6b, 0x40, 0x2a, 0xd2, 0x0a, 0x7d, 0x00, + 0x11, 0xa1, 0x17, 0xa1, 0xab, 0xb2, 0xdd, 0xb9, 0x95, 0x05, 0x92, 0x66, 0xda, 0xce, 0x33, 0x6d, + 0x9f, 0xe5, 0xa5, 0x70, 0xb0, 0xa0, 0x02, 0xf9, 0xea, 0x87, 0x2d, 0xc3, 0x69, 0x69, 0x3b, 0xb5, + 0x63, 0x7e, 0x0e, 0xab, 0x71, 0x38, 0x60, 0xa1, 0x47, 0xc3, 0xa1, 0x1b, 0x11, 0x4e, 0x99, 0xd7, + 0x59, 0xd0, 0x50, 0x1b, 0x57, 0xa0, 0x0e, 0xb3, 0xa2, 0x49, 0x91, 0xbe, 0x56, 0x48, 0x2b, 0x85, + 0xf1, 0x89, 0xb6, 0x35, 0xbf, 0x00, 0x13, 0xe3, 0x44, 0x87, 0xc4, 0x62, 0x99, 0x23, 0xb6, 0xa6, + 0x47, 0x5c, 0xc5, 0x38, 0x39, 0x4b, 0xad, 0x33, 0xc8, 0x3f, 0xc0, 0x1d, 0xc9, 0x51, 0x28, 0x9e, + 0x11, 0x3e, 0x89, 0x0b, 0xd3, 0xe3, 0xbe, 0x95, 0x63, 0xd4, 0xc1, 0x1f, 0xc1, 0x36, 0xce, 0x0a, + 0xc8, 0xe5, 0xc4, 0xa3, 0x42, 0x72, 0x3a, 0x88, 0x95, 0xad, 0xfb, 0x8c, 0x23, 0xac, 0x6b, 0xa4, + 0xad, 0x8b, 0xa0, 0x9b, 0xeb, 0x39, 0x35, 0xb5, 0x4f, 0x32, 0x2d, 0xf3, 0x09, 0xfc, 0x6c, 0xe0, + 0x33, 0x7c, 0x21, 0x54, 0x70, 0x6e, 0x0d, 0x49, 0xbb, 0x0e, 0xa8, 0x10, 0x0a, 0x6d, 0x71, 0xdb, + 0xd8, 0x69, 0x38, 0xf7, 0x52, 0xdd, 0x13, 0xc2, 0x0f, 0x2b, 0x9a, 0x67, 0x15, 0x45, 0xf3, 0x03, + 0x30, 0x47, 0x54, 0x48, 0xc6, 0x29, 0x46, 0xbe, 0x4b, 0x42, 0xc9, 0x29, 0x11, 0x9d, 0x25, 0x6d, + 0x7e, 0xbb, 0xdc, 0x79, 0x98, 0x6e, 0x98, 0x8f, 0xe1, 0xde, 0x8d, 0x4e, 0x5d, 0x3c, 0x42, 0x61, + 0x48, 0xfc, 0xce, 0xb2, 0x3e, 0xca, 0x96, 0x77, 0x83, 0xcf, 0x7e, 0xaa, 0xf6, 0x60, 0xe1, 0x4f, + 0xdf, 0x6c, 0xcd, 0x7c, 0xfd, 0xcd, 0xd6, 0x8c, 0xf5, 0x0f, 0x03, 0xee, 0xf4, 0x8b, 0x83, 0x07, + 0x2c, 0x41, 0xfe, 0x8f, 0xd9, 0x60, 0xfb, 0xd0, 0x12, 0x92, 0x45, 0x69, 0x49, 0x37, 0x5f, 0xa3, + 0xa4, 0x17, 0x94, 0x99, 0xda, 0xb0, 0xfe, 0x6a, 0xc0, 0xfa, 0xc3, 0xe7, 0x31, 0x4d, 0x18, 0x46, + 0xff, 0x17, 0x3e, 0x38, 0x86, 0x25, 0x52, 0xc1, 0x13, 0x9d, 0xc6, 0x76, 0x63, 0xa7, 0xbd, 0xf7, + 0xae, 0x9d, 0x92, 0x93, 0x5d, 0x70, 0x56, 0x46, 0x50, 0x76, 0xd5, 0xbb, 0x53, 0xb7, 0xb5, 0xfe, + 0x6e, 0xc0, 0x5d, 0x75, 0xcb, 0x43, 0xe2, 0x90, 0x17, 0x88, 0x7b, 0x87, 0x24, 0x64, 0x81, 0x78, + 0xe3, 0x18, 0x2d, 0x58, 0xf2, 0x34, 0x92, 0x2b, 0x99, 0x8b, 0x3c, 0x4f, 0xc7, 0xa8, 0x75, 0x94, + 0xf0, 0x8c, 0xed, 0x7b, 0x9e, 0xb9, 0x03, 0xab, 0xa5, 0x0e, 0x57, 0xb9, 0x54, 0x57, 0xac, 0xd4, + 0x96, 0x73, 0x35, 0x9d, 0x61, 0x62, 0xfd, 0xc7, 0x80, 0xd5, 0x4f, 0x7d, 0x36, 0x40, 0xfe, 0xa9, + 0x8f, 0xc4, 0x48, 0x55, 0xd8, 0x58, 0xa5, 0x86, 0x93, 0xac, 0xb5, 0x75, 0x78, 0x53, 0xa7, 0x46, + 0x99, 0x69, 0xb2, 0xf9, 0x18, 0x6e, 0x17, 0xcd, 0x56, 0x54, 0x80, 0x3e, 0xcd, 0xc1, 0xda, 0xe5, + 0xf7, 0x5b, 0x2b, 0x79, 0xa1, 0xf5, 0x75, 0x35, 0x1c, 0x3a, 0x2b, 0xb8, 0x26, 0xf0, 0xcc, 0x2e, + 0xb4, 0xe9, 0x00, 0xbb, 0x82, 0x3c, 0x77, 0xc3, 0x38, 0xd0, 0xc5, 0xd3, 0x74, 0x5a, 0x74, 0x80, + 0x4f, 0xc9, 0xf3, 0xcf, 0xe3, 0xc0, 0xbc, 0x0f, 0x6f, 0xe7, 0x43, 0xd5, 0x4d, 0x90, 0xef, 0x2a, + 0x7b, 0x75, 0x1d, 0x5c, 0xd7, 0xd2, 0xa2, 0xb3, 0x96, 0xef, 0x9e, 0x23, 0x5f, 0x39, 0xdb, 0xf7, + 0x3c, 0x6e, 0xfd, 0x73, 0x0e, 0xe6, 0x4f, 0x10, 0x47, 0x81, 0x30, 0xcf, 0x60, 0x45, 0x92, 0x20, + 0xf2, 0x91, 0x24, 0x6e, 0x4a, 0xe4, 0xd9, 0x49, 0xdf, 0xd7, 0x04, 0x5f, 0x1d, 0x80, 0x76, 0x65, + 0xe4, 0x25, 0xbb, 0x76, 0x5f, 0x4b, 0x4f, 0x25, 0x92, 0xc4, 0x59, 0xce, 0x31, 0x52, 0xa1, 0xf9, + 0x21, 0x74, 0x24, 0x8f, 0x85, 0x2c, 0x29, 0xb6, 0xe4, 0x96, 0x34, 0x97, 0x6f, 0xe7, 0xfb, 0x29, + 0x2b, 0x15, 0x9c, 0x72, 0x3d, 0x9b, 0x36, 0xde, 0x84, 0x4d, 0x4f, 0x61, 0x4d, 0x8d, 0xa2, 0x49, + 0xcc, 0xe6, 0xf4, 0x98, 0xb7, 0x95, 0x7d, 0x1d, 0xf4, 0x0b, 0x30, 0x13, 0x81, 0x27, 0x31, 0xe7, + 0x5e, 0x23, 0xce, 0x44, 0xe0, 0x3a, 0xa4, 0x07, 0x9b, 0x42, 0x15, 0x9f, 0x1b, 0x10, 0xa9, 0xb9, + 0x39, 0xf2, 0x49, 0x48, 0xc5, 0x28, 0x07, 0x9f, 0x9f, 0x1e, 0x7c, 0x43, 0x03, 0x7d, 0xa6, 0x70, + 0x9c, 0x1c, 0x26, 0xf3, 0xd2, 0x87, 0xee, 0xf5, 0x5e, 0x8a, 0x04, 0xdd, 0xd2, 0x09, 0xfa, 0xc9, + 0x35, 0x10, 0x45, 0x96, 0x04, 0xbc, 0x57, 0x99, 0x21, 0xaa, 0xab, 0x5d, 0xdd, 0x50, 0x2e, 0x27, + 0x43, 0x45, 0xb4, 0x28, 0x1d, 0x27, 0x84, 0x14, 0x73, 0x30, 0x63, 0x0e, 0xf5, 0xac, 0x29, 0x58, + 0xa3, 0xcf, 0x68, 0x98, 0x3d, 0x16, 0xac, 0x72, 0xd4, 0x14, 0x1c, 0xe1, 0x54, 0xb0, 0x3e, 0x21, + 0xe4, 0x71, 0x73, 0x61, 0x61, 0xb5, 0x65, 0xfd, 0x02, 0x5a, 0xba, 0x45, 0xf7, 0xf1, 0x85, 0x30, + 0x37, 0xa1, 0xa5, 0x6a, 0x9d, 0x08, 0x41, 0x44, 0xc7, 0xd0, 0x9d, 0x5d, 0x0a, 0x2c, 0x09, 0x1b, + 0x37, 0x3d, 0x95, 0x84, 0xf9, 0x14, 0x6e, 0x45, 0x44, 0xcf, 0x71, 0x6d, 0xd8, 0xde, 0xfb, 0xc8, + 0x9e, 0xe2, 0xd5, 0x6a, 0xdf, 0x04, 0xe8, 0xe4, 0x68, 0x16, 0x2f, 0x1f, 0x68, 0x13, 0xe3, 0x43, + 0x98, 0xe7, 0x93, 0x4e, 0x7f, 0xfd, 0x5a, 0x4e, 0x27, 0xf0, 0x4a, 0x9f, 0xef, 0x43, 0x7b, 0x3f, + 0x3d, 0xf6, 0x6f, 0xa8, 0x90, 0x57, 0xaf, 0x65, 0xb1, 0x7a, 0x2d, 0x8f, 0x61, 0x39, 0x9b, 0x7a, + 0x67, 0x4c, 0xd3, 0x8c, 0xf9, 0x53, 0x80, 0x6c, 0x5c, 0x2a, 0x7a, 0x4a, 0x89, 0xb8, 0x95, 0x49, + 0x8e, 0xbc, 0xda, 0xf4, 0x9a, 0xad, 0x4d, 0x2f, 0xcb, 0x81, 0x95, 0x73, 0x81, 0x7f, 0x9b, 0x3f, + 0x89, 0x9e, 0x44, 0xc2, 0x7c, 0x0b, 0xe6, 0x55, 0x67, 0x64, 0x40, 0x4d, 0x67, 0x2e, 0x11, 0xf8, + 0x48, 0x73, 0x71, 0xf9, 0xec, 0x62, 0x91, 0x4b, 0x3d, 0xd1, 0x99, 0xdd, 0x6e, 0xec, 0x34, 0x9d, + 0xe5, 0xb8, 0x34, 0x3f, 0xf2, 0x84, 0xf5, 0x3b, 0x68, 0x57, 0x00, 0xcd, 0x65, 0x98, 0x2d, 0xb0, + 0x66, 0xa9, 0x67, 0x3e, 0x80, 0x8d, 0x12, 0xa8, 0x4e, 0xae, 0x29, 0x62, 0xcb, 0xb9, 0x53, 0x28, + 0xd4, 0xf8, 0x55, 0x58, 0x4f, 0x60, 0xfd, 0xa8, 0x6c, 0xe5, 0x82, 0xba, 0x6b, 0x27, 0x34, 0xea, + 0xf3, 0x79, 0x13, 0x5a, 0xc5, 0x6f, 0x0b, 0x7d, 0xfa, 0xa6, 0x53, 0x0a, 0xac, 0x00, 0x56, 0xcf, + 0x05, 0x3e, 0x25, 0xa1, 0x57, 0x82, 0xdd, 0x70, 0x01, 0x07, 0x93, 0x40, 0x53, 0xbf, 0x5d, 0x4b, + 0x77, 0x0c, 0x36, 0xce, 0x91, 0x4f, 0x3d, 0x24, 0x19, 0x3f, 0x25, 0x32, 0x1d, 0xab, 0x27, 0x08, + 0x5f, 0x10, 0x29, 0x4c, 0x07, 0x9a, 0x3e, 0x15, 0x32, 0xab, 0xac, 0x0f, 0x6f, 0xac, 0xac, 0x64, + 0xd7, 0xbe, 0x09, 0xe4, 0x10, 0x49, 0x94, 0x75, 0xa4, 0xc6, 0xb2, 0x7e, 0x0e, 0x6b, 0x9f, 0x21, + 0x19, 0x73, 0xe2, 0xd5, 0x72, 0xbc, 0x0a, 0x0d, 0x95, 0x3f, 0x43, 0xe7, 0x4f, 0x2d, 0xd5, 0x94, + 0xef, 0x3c, 0xfc, 0x32, 0x62, 0x5c, 0x12, 0xef, 0xca, 0x8d, 0xbc, 0xe2, 0x7a, 0x2f, 0x60, 0x4d, + 0x5d, 0x96, 0x20, 0xa1, 0xe7, 0x16, 0xe7, 0x4c, 0xf3, 0xd8, 0xde, 0xfb, 0xd5, 0x54, 0xdd, 0x31, + 0xe9, 0x2e, 0x3b, 0xc0, 0xed, 0x64, 0x42, 0x2e, 0xac, 0x3f, 0x1b, 0xd0, 0x39, 0x26, 0xe3, 0x7d, + 0x21, 0xe8, 0x30, 0x0c, 0x48, 0x28, 0x15, 0xb3, 0x21, 0x4c, 0xd4, 0xd2, 0x7c, 0x07, 0x96, 0x8a, + 0x49, 0xaa, 0x07, 0xa8, 0xa1, 0x07, 0xe8, 0x62, 0x2e, 0x54, 0x0d, 0x66, 0x3e, 0x00, 0x88, 0x38, + 0x49, 0x5c, 0xec, 0x5e, 0x90, 0x71, 0x96, 0xc5, 0xcd, 0xea, 0x60, 0x4c, 0x7f, 0xf9, 0xd9, 0x27, + 0xf1, 0xc0, 0xa7, 0xf8, 0x98, 0x8c, 0x9d, 0x05, 0xa5, 0xdf, 0x3f, 0x26, 0x63, 0xf5, 0xd2, 0x89, + 0xd8, 0x0b, 0xc2, 0xf5, 0x34, 0x6b, 0x38, 0xe9, 0x87, 0xf5, 0x17, 0x03, 0xee, 0x14, 0xe9, 0xc8, + 0xcb, 0xf5, 0x24, 0x1e, 0x28, 0x8b, 0x57, 0xdc, 0xdb, 0x95, 0x68, 0x67, 0xaf, 0x89, 0xf6, 0x63, + 0x58, 0x2c, 0x1a, 0x44, 0xc5, 0xdb, 0x98, 0x22, 0xde, 0x76, 0x6e, 0x71, 0x4c, 0xc6, 0xd6, 0x1f, + 0x2b, 0xb1, 0x1d, 0x8c, 0x2b, 0xdc, 0xc7, 0xff, 0x47, 0x6c, 0x85, 0xdb, 0x6a, 0x6c, 0xb8, 0x6a, + 0x7f, 0xe5, 0x00, 0x8d, 0xab, 0x07, 0xb0, 0xfe, 0x66, 0xc0, 0x7a, 0xd5, 0xab, 0x38, 0x63, 0x27, + 0x3c, 0x0e, 0xc9, 0xab, 0xbc, 0x97, 0xed, 0x37, 0x5b, 0x6d, 0xbf, 0xa7, 0xb0, 0x5c, 0x0b, 0x4a, + 0x64, 0xb7, 0xf1, 0xcb, 0xa9, 0x6a, 0xac, 0xc2, 0xae, 0xce, 0x52, 0xf5, 0x1c, 0xe2, 0xe0, 0xe9, + 0xb7, 0x97, 0x5d, 0xe3, 0xbb, 0xcb, 0xae, 0xf1, 0xef, 0xcb, 0xae, 0xf1, 0xd5, 0xcb, 0xee, 0xcc, + 0x77, 0x2f, 0xbb, 0x33, 0xff, 0x7a, 0xd9, 0x9d, 0xf9, 0xfd, 0x47, 0x43, 0x2a, 0x47, 0xf1, 0xc0, + 0xc6, 0x2c, 0xe8, 0x65, 0x3f, 0xeb, 0x4b, 0x5f, 0x1f, 0x14, 0xff, 0x79, 0x24, 0xf7, 0x7b, 0x5f, + 0xd6, 0xff, 0x51, 0x91, 0xe3, 0x88, 0x88, 0xc1, 0xbc, 0x66, 0x85, 0xfb, 0xff, 0x0d, 0x00, 0x00, + 0xff, 0xff, 0x95, 0xc6, 0x06, 0x3d, 0x82, 0x11, 0x00, 0x00, } func (m *ConsumerAdditionProposal) Marshal() (dAtA []byte, err error) { @@ -1633,6 +1747,61 @@ func (m *EquivocationProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ChangeRewardDenomsProposal) 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 *ChangeRewardDenomsProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ChangeRewardDenomsProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DenomsToRemove) > 0 { + for iNdEx := len(m.DenomsToRemove) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.DenomsToRemove[iNdEx]) + copy(dAtA[i:], m.DenomsToRemove[iNdEx]) + i = encodeVarintProvider(dAtA, i, uint64(len(m.DenomsToRemove[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.DenomsToAdd) > 0 { + for iNdEx := len(m.DenomsToAdd) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.DenomsToAdd[iNdEx]) + copy(dAtA[i:], m.DenomsToAdd[iNdEx]) + i = encodeVarintProvider(dAtA, i, uint64(len(m.DenomsToAdd[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintProvider(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintProvider(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *GlobalSlashEntry) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1713,11 +1882,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x4a - if m.MaxThrottledPackets != 0 { - i = encodeVarintProvider(dAtA, i, uint64(m.MaxThrottledPackets)) - i-- - dAtA[i] = 0x40 - } if len(m.SlashMeterReplenishFraction) > 0 { i -= len(m.SlashMeterReplenishFraction) copy(dAtA[i:], m.SlashMeterReplenishFraction) @@ -1779,43 +1943,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *HandshakeMetadata) 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 *HandshakeMetadata) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *HandshakeMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Version) > 0 { - i -= len(m.Version) - copy(dAtA[i:], m.Version) - i = encodeVarintProvider(dAtA, i, uint64(len(m.Version))) - i-- - dAtA[i] = 0x12 - } - if len(m.ProviderFeePoolAddr) > 0 { - i -= len(m.ProviderFeePoolAddr) - copy(dAtA[i:], m.ProviderFeePoolAddr) - i = encodeVarintProvider(dAtA, i, uint64(len(m.ProviderFeePoolAddr))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *SlashAcks) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2145,7 +2272,7 @@ func (m *VscSendTimestamp) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ExportedVscSendTimestamp) Marshal() (dAtA []byte, err error) { +func (m *ValidatorSetChangePackets) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2155,20 +2282,20 @@ func (m *ExportedVscSendTimestamp) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ExportedVscSendTimestamp) MarshalTo(dAtA []byte) (int, error) { +func (m *ValidatorSetChangePackets) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ExportedVscSendTimestamp) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ValidatorSetChangePackets) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.VscSendTimestamps) > 0 { - for iNdEx := len(m.VscSendTimestamps) - 1; iNdEx >= 0; iNdEx-- { + if len(m.List) > 0 { + for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.VscSendTimestamps[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.List[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -2176,20 +2303,13 @@ func (m *ExportedVscSendTimestamp) MarshalToSizedBuffer(dAtA []byte) (int, error i = encodeVarintProvider(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0xa } } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintProvider(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *KeyAssignmentReplacement) Marshal() (dAtA []byte, err error) { +func (m *MaturedUnbondingOps) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2199,35 +2319,120 @@ func (m *KeyAssignmentReplacement) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *KeyAssignmentReplacement) MarshalTo(dAtA []byte) (int, error) { +func (m *MaturedUnbondingOps) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *KeyAssignmentReplacement) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MaturedUnbondingOps) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Power != 0 { - i = encodeVarintProvider(dAtA, i, uint64(m.Power)) - i-- - dAtA[i] = 0x18 - } - if m.PrevCKey != nil { - { - size, err := m.PrevCKey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err + if len(m.Ids) > 0 { + dAtA18 := make([]byte, len(m.Ids)*10) + var j17 int + for _, num := range m.Ids { + for num >= 1<<7 { + dAtA18[j17] = uint8(uint64(num)&0x7f | 0x80) + num >>= 7 + j17++ } - i -= size - i = encodeVarintProvider(dAtA, i, uint64(size)) + dAtA18[j17] = uint8(num) + j17++ } + i -= j17 + copy(dAtA[i:], dAtA18[:j17]) + i = encodeVarintProvider(dAtA, i, uint64(j17)) i-- - dAtA[i] = 0x12 + dAtA[i] = 0xa } - if len(m.ProviderAddr) > 0 { - i -= len(m.ProviderAddr) + return len(dAtA) - i, nil +} + +func (m *ExportedVscSendTimestamp) 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 *ExportedVscSendTimestamp) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ExportedVscSendTimestamp) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.VscSendTimestamps) > 0 { + for iNdEx := len(m.VscSendTimestamps) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.VscSendTimestamps[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProvider(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintProvider(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *KeyAssignmentReplacement) 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 *KeyAssignmentReplacement) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *KeyAssignmentReplacement) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Power != 0 { + i = encodeVarintProvider(dAtA, i, uint64(m.Power)) + i-- + dAtA[i] = 0x18 + } + if m.PrevCKey != nil { + { + size, err := m.PrevCKey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintProvider(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.ProviderAddr) > 0 { + i -= len(m.ProviderAddr) copy(dAtA[i:], m.ProviderAddr) i = encodeVarintProvider(dAtA, i, uint64(len(m.ProviderAddr))) i-- @@ -2486,6 +2691,35 @@ func (m *EquivocationProposal) Size() (n int) { return n } +func (m *ChangeRewardDenomsProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovProvider(uint64(l)) + } + if len(m.DenomsToAdd) > 0 { + for _, s := range m.DenomsToAdd { + l = len(s) + n += 1 + l + sovProvider(uint64(l)) + } + } + if len(m.DenomsToRemove) > 0 { + for _, s := range m.DenomsToRemove { + l = len(s) + n += 1 + l + sovProvider(uint64(l)) + } + } + return n +} + func (m *GlobalSlashEntry) Size() (n int) { if m == nil { return 0 @@ -2534,31 +2768,11 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovProvider(uint64(l)) } - if m.MaxThrottledPackets != 0 { - n += 1 + sovProvider(uint64(m.MaxThrottledPackets)) - } l = m.ConsumerRewardDenomRegistrationFee.Size() n += 1 + l + sovProvider(uint64(l)) return n } -func (m *HandshakeMetadata) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ProviderFeePoolAddr) - if l > 0 { - n += 1 + l + sovProvider(uint64(l)) - } - l = len(m.Version) - if l > 0 { - n += 1 + l + sovProvider(uint64(l)) - } - return n -} - func (m *SlashAcks) Size() (n int) { if m == nil { return 0 @@ -2703,6 +2917,37 @@ func (m *VscSendTimestamp) Size() (n int) { return n } +func (m *ValidatorSetChangePackets) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.List) > 0 { + for _, e := range m.List { + l = e.Size() + n += 1 + l + sovProvider(uint64(l)) + } + } + return n +} + +func (m *MaturedUnbondingOps) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Ids) > 0 { + l = 0 + for _, e := range m.Ids { + l += sovProvider(uint64(e)) + } + n += 1 + sovProvider(uint64(l)) + l + } + return n +} + func (m *ExportedVscSendTimestamp) Size() (n int) { if m == nil { return 0 @@ -3618,7 +3863,7 @@ func (m *EquivocationProposal) Unmarshal(dAtA []byte) error { } return nil } -func (m *GlobalSlashEntry) Unmarshal(dAtA []byte) error { +func (m *ChangeRewardDenomsProposal) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3641,17 +3886,17 @@ func (m *GlobalSlashEntry) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GlobalSlashEntry: wiretype end group for non-group") + return fmt.Errorf("proto: ChangeRewardDenomsProposal: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GlobalSlashEntry: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ChangeRewardDenomsProposal: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RecvTime", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -3661,28 +3906,27 @@ func (m *GlobalSlashEntry) 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 ErrInvalidLengthProvider } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthProvider } if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.RecvTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.Title = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerChainID", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3710,13 +3954,13 @@ func (m *GlobalSlashEntry) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ConsumerChainID = string(dAtA[iNdEx:postIndex]) + m.Description = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IbcSeqNum", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomsToAdd", wireType) } - m.IbcSeqNum = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -3726,16 +3970,29 @@ func (m *GlobalSlashEntry) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.IbcSeqNum |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomsToAdd = append(m.DenomsToAdd, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderValConsAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field DenomsToRemove", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -3745,25 +4002,23 @@ func (m *GlobalSlashEntry) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthProvider } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthProvider } if postIndex > l { return io.ErrUnexpectedEOF } - m.ProviderValConsAddr = append(m.ProviderValConsAddr[:0], dAtA[iNdEx:postIndex]...) - if m.ProviderValConsAddr == nil { - m.ProviderValConsAddr = []byte{} - } + m.DenomsToRemove = append(m.DenomsToRemove, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -3786,7 +4041,7 @@ func (m *GlobalSlashEntry) Unmarshal(dAtA []byte) error { } return nil } -func (m *Params) Unmarshal(dAtA []byte) error { +func (m *GlobalSlashEntry) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3809,15 +4064,15 @@ func (m *Params) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Params: wiretype end group for non-group") + return fmt.Errorf("proto: GlobalSlashEntry: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: GlobalSlashEntry: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TemplateClient", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RecvTime", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3844,16 +4099,13 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.TemplateClient == nil { - m.TemplateClient = &_07_tendermint.ClientState{} - } - if err := m.TemplateClient.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := github_com_cosmos_gogoproto_types.StdTimeUnmarshal(&m.RecvTime, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TrustingPeriodFraction", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerChainID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -3881,13 +4133,13 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TrustingPeriodFraction = string(dAtA[iNdEx:postIndex]) + m.ConsumerChainID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CcvTimeoutPeriod", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IbcSeqNum", wireType) } - var msglen int + m.IbcSeqNum = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -3897,30 +4149,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + m.IbcSeqNum |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthProvider - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthProvider - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.CcvTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InitTimeoutPeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProviderValConsAddr", wireType) } - var msglen int + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -3930,28 +4168,79 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + if byteLen < 0 { return ErrInvalidLengthProvider } - postIndex := iNdEx + msglen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthProvider } if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.InitTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProviderValConsAddr = append(m.ProviderValConsAddr[:0], dAtA[iNdEx:postIndex]...) + if m.ProviderValConsAddr == nil { + m.ProviderValConsAddr = []byte{} } iNdEx = postIndex - case 5: + default: + iNdEx = preIndex + skippy, err := skipProvider(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProvider + } + 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 ErrIntOverflowProvider + } + 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 VscTimeoutPeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TemplateClient", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -3978,15 +4267,18 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.VscTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { + if m.TemplateClient == nil { + m.TemplateClient = &_07_tendermint.ClientState{} + } + if err := m.TemplateClient.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 6: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlashMeterReplenishPeriod", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TrustingPeriodFraction", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -3996,30 +4288,29 @@ func (m *Params) 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 ErrInvalidLengthProvider } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthProvider } if postIndex > l { return io.ErrUnexpectedEOF } - if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.SlashMeterReplenishPeriod, dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.TrustingPeriodFraction = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlashMeterReplenishFraction", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CcvTimeoutPeriod", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -4029,29 +4320,30 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthProvider } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthProvider } if postIndex > l { return io.ErrUnexpectedEOF } - m.SlashMeterReplenishFraction = string(dAtA[iNdEx:postIndex]) + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.CcvTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxThrottledPackets", wireType) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitTimeoutPeriod", wireType) } - m.MaxThrottledPackets = 0 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -4061,14 +4353,28 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.MaxThrottledPackets |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 9: + if msglen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.InitTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ConsumerRewardDenomRegistrationFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field VscTimeoutPeriod", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4095,63 +4401,46 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ConsumerRewardDenomRegistrationFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.VscTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipProvider(dAtA[iNdEx:]) - if err != nil { - return err + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashMeterReplenishPeriod", wireType) } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthProvider + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF + if msglen < 0 { + return ErrInvalidLengthProvider } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *HandshakeMetadata) 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 ErrIntOverflowProvider + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider } - if iNdEx >= l { + if postIndex > l { return io.ErrUnexpectedEOF } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.SlashMeterReplenishPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: HandshakeMetadata: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HandshakeMetadata: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + iNdEx = postIndex + case 7: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProviderFeePoolAddr", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SlashMeterReplenishFraction", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -4179,13 +4468,13 @@ func (m *HandshakeMetadata) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ProviderFeePoolAddr = string(dAtA[iNdEx:postIndex]) + m.SlashMeterReplenishFraction = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 9: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerRewardDenomRegistrationFee", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowProvider @@ -4195,23 +4484,24 @@ func (m *HandshakeMetadata) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthProvider } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthProvider } if postIndex > l { return io.ErrUnexpectedEOF } - m.Version = string(dAtA[iNdEx:postIndex]) + if err := m.ConsumerRewardDenomRegistrationFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex default: iNdEx = preIndex @@ -5129,6 +5419,216 @@ func (m *VscSendTimestamp) Unmarshal(dAtA []byte) error { } return nil } +func (m *ValidatorSetChangePackets) 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 ErrIntOverflowProvider + } + 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: ValidatorSetChangePackets: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorSetChangePackets: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field List", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.List = append(m.List, types3.ValidatorSetChangePacketData{}) + if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipProvider(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProvider + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MaturedUnbondingOps) 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 ErrIntOverflowProvider + } + 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: MaturedUnbondingOps: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MaturedUnbondingOps: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthProvider + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthProvider + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.Ids) == 0 { + m.Ids = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProvider + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Ids = append(m.Ids, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field Ids", wireType) + } + default: + iNdEx = preIndex + skippy, err := skipProvider(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthProvider + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ExportedVscSendTimestamp) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/provider/types/query.pb.go b/x/ccv/provider/types/query.pb.go index f82376da05..37ef05d20f 100644 --- a/x/ccv/provider/types/query.pb.go +++ b/x/ccv/provider/types/query.pb.go @@ -10,8 +10,7 @@ import ( grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" - types "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" - types1 "github.com/cosmos/interchain-security/v3/x/ccv/types" + types "github.com/cosmos/interchain-security/v3/x/ccv/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" @@ -80,7 +79,7 @@ func (m *QueryConsumerGenesisRequest) GetChainId() string { } type QueryConsumerGenesisResponse struct { - GenesisState types.GenesisState `protobuf:"bytes,1,opt,name=genesis_state,json=genesisState,proto3" json:"genesis_state"` + GenesisState types.ConsumerGenesisState `protobuf:"bytes,1,opt,name=genesis_state,json=genesisState,proto3" json:"genesis_state"` } func (m *QueryConsumerGenesisResponse) Reset() { *m = QueryConsumerGenesisResponse{} } @@ -116,11 +115,11 @@ func (m *QueryConsumerGenesisResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryConsumerGenesisResponse proto.InternalMessageInfo -func (m *QueryConsumerGenesisResponse) GetGenesisState() types.GenesisState { +func (m *QueryConsumerGenesisResponse) GetGenesisState() types.ConsumerGenesisState { if m != nil { return m.GenesisState } - return types.GenesisState{} + return types.ConsumerGenesisState{} } type QueryConsumerChainsRequest struct { @@ -638,8 +637,6 @@ type QueryThrottleStateResponse struct { // next time the slash meter could potentially be replenished, iff it's not // full NextReplenishCandidate time.Time `protobuf:"bytes,3,opt,name=next_replenish_candidate,json=nextReplenishCandidate,proto3,stdtime" json:"next_replenish_candidate"` - // data relevant to currently throttled slash packets - Packets []*ThrottledSlashPacket `protobuf:"bytes,4,rep,name=packets,proto3" json:"packets,omitempty"` } func (m *QueryThrottleStateResponse) Reset() { *m = QueryThrottleStateResponse{} } @@ -696,262 +693,6 @@ func (m *QueryThrottleStateResponse) GetNextReplenishCandidate() time.Time { return time.Time{} } -func (m *QueryThrottleStateResponse) GetPackets() []*ThrottledSlashPacket { - if m != nil { - return m.Packets - } - return nil -} - -type QueryThrottledConsumerPacketDataRequest struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` -} - -func (m *QueryThrottledConsumerPacketDataRequest) Reset() { - *m = QueryThrottledConsumerPacketDataRequest{} -} -func (m *QueryThrottledConsumerPacketDataRequest) String() string { return proto.CompactTextString(m) } -func (*QueryThrottledConsumerPacketDataRequest) ProtoMessage() {} -func (*QueryThrottledConsumerPacketDataRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{15} -} -func (m *QueryThrottledConsumerPacketDataRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryThrottledConsumerPacketDataRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryThrottledConsumerPacketDataRequest.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 *QueryThrottledConsumerPacketDataRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryThrottledConsumerPacketDataRequest.Merge(m, src) -} -func (m *QueryThrottledConsumerPacketDataRequest) XXX_Size() int { - return m.Size() -} -func (m *QueryThrottledConsumerPacketDataRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryThrottledConsumerPacketDataRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryThrottledConsumerPacketDataRequest proto.InternalMessageInfo - -func (m *QueryThrottledConsumerPacketDataRequest) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - -type QueryThrottledConsumerPacketDataResponse struct { - ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` - Size_ uint64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` - PacketDataInstances []ThrottledPacketDataWrapper `protobuf:"bytes,3,rep,name=packetDataInstances,proto3" json:"packetDataInstances"` -} - -func (m *QueryThrottledConsumerPacketDataResponse) Reset() { - *m = QueryThrottledConsumerPacketDataResponse{} -} -func (m *QueryThrottledConsumerPacketDataResponse) String() string { return proto.CompactTextString(m) } -func (*QueryThrottledConsumerPacketDataResponse) ProtoMessage() {} -func (*QueryThrottledConsumerPacketDataResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{16} -} -func (m *QueryThrottledConsumerPacketDataResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryThrottledConsumerPacketDataResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryThrottledConsumerPacketDataResponse.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 *QueryThrottledConsumerPacketDataResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryThrottledConsumerPacketDataResponse.Merge(m, src) -} -func (m *QueryThrottledConsumerPacketDataResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryThrottledConsumerPacketDataResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryThrottledConsumerPacketDataResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryThrottledConsumerPacketDataResponse proto.InternalMessageInfo - -func (m *QueryThrottledConsumerPacketDataResponse) GetChainId() string { - if m != nil { - return m.ChainId - } - return "" -} - -func (m *QueryThrottledConsumerPacketDataResponse) GetSize_() uint64 { - if m != nil { - return m.Size_ - } - return 0 -} - -func (m *QueryThrottledConsumerPacketDataResponse) GetPacketDataInstances() []ThrottledPacketDataWrapper { - if m != nil { - return m.PacketDataInstances - } - return nil -} - -// A query wrapper type for the global entry and data relevant to a throttled -// slash packet. -type ThrottledSlashPacket struct { - GlobalEntry GlobalSlashEntry `protobuf:"bytes,1,opt,name=global_entry,json=globalEntry,proto3" json:"global_entry"` - Data types1.SlashPacketData `protobuf:"bytes,2,opt,name=data,proto3" json:"data"` -} - -func (m *ThrottledSlashPacket) Reset() { *m = ThrottledSlashPacket{} } -func (m *ThrottledSlashPacket) String() string { return proto.CompactTextString(m) } -func (*ThrottledSlashPacket) ProtoMessage() {} -func (*ThrottledSlashPacket) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{17} -} -func (m *ThrottledSlashPacket) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ThrottledSlashPacket) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ThrottledSlashPacket.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 *ThrottledSlashPacket) XXX_Merge(src proto.Message) { - xxx_messageInfo_ThrottledSlashPacket.Merge(m, src) -} -func (m *ThrottledSlashPacket) XXX_Size() int { - return m.Size() -} -func (m *ThrottledSlashPacket) XXX_DiscardUnknown() { - xxx_messageInfo_ThrottledSlashPacket.DiscardUnknown(m) -} - -var xxx_messageInfo_ThrottledSlashPacket proto.InternalMessageInfo - -func (m *ThrottledSlashPacket) GetGlobalEntry() GlobalSlashEntry { - if m != nil { - return m.GlobalEntry - } - return GlobalSlashEntry{} -} - -func (m *ThrottledSlashPacket) GetData() types1.SlashPacketData { - if m != nil { - return m.Data - } - return types1.SlashPacketData{} -} - -// ThrottledPacketDataWrapper contains either SlashPacketData or -// VSCMaturedPacketData -type ThrottledPacketDataWrapper struct { - // Types that are valid to be assigned to Data: - // *ThrottledPacketDataWrapper_SlashPacket - // *ThrottledPacketDataWrapper_VscMaturedPacket - Data isThrottledPacketDataWrapper_Data `protobuf_oneof:"data"` -} - -func (m *ThrottledPacketDataWrapper) Reset() { *m = ThrottledPacketDataWrapper{} } -func (m *ThrottledPacketDataWrapper) String() string { return proto.CompactTextString(m) } -func (*ThrottledPacketDataWrapper) ProtoMessage() {} -func (*ThrottledPacketDataWrapper) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{18} -} -func (m *ThrottledPacketDataWrapper) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ThrottledPacketDataWrapper) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ThrottledPacketDataWrapper.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 *ThrottledPacketDataWrapper) XXX_Merge(src proto.Message) { - xxx_messageInfo_ThrottledPacketDataWrapper.Merge(m, src) -} -func (m *ThrottledPacketDataWrapper) XXX_Size() int { - return m.Size() -} -func (m *ThrottledPacketDataWrapper) XXX_DiscardUnknown() { - xxx_messageInfo_ThrottledPacketDataWrapper.DiscardUnknown(m) -} - -var xxx_messageInfo_ThrottledPacketDataWrapper proto.InternalMessageInfo - -type isThrottledPacketDataWrapper_Data interface { - isThrottledPacketDataWrapper_Data() - MarshalTo([]byte) (int, error) - Size() int -} - -type ThrottledPacketDataWrapper_SlashPacket struct { - SlashPacket *types1.SlashPacketData `protobuf:"bytes,1,opt,name=slash_packet,json=slashPacket,proto3,oneof" json:"slash_packet,omitempty"` -} -type ThrottledPacketDataWrapper_VscMaturedPacket struct { - VscMaturedPacket *types1.VSCMaturedPacketData `protobuf:"bytes,2,opt,name=vsc_matured_packet,json=vscMaturedPacket,proto3,oneof" json:"vsc_matured_packet,omitempty"` -} - -func (*ThrottledPacketDataWrapper_SlashPacket) isThrottledPacketDataWrapper_Data() {} -func (*ThrottledPacketDataWrapper_VscMaturedPacket) isThrottledPacketDataWrapper_Data() {} - -func (m *ThrottledPacketDataWrapper) GetData() isThrottledPacketDataWrapper_Data { - if m != nil { - return m.Data - } - return nil -} - -func (m *ThrottledPacketDataWrapper) GetSlashPacket() *types1.SlashPacketData { - if x, ok := m.GetData().(*ThrottledPacketDataWrapper_SlashPacket); ok { - return x.SlashPacket - } - return nil -} - -func (m *ThrottledPacketDataWrapper) GetVscMaturedPacket() *types1.VSCMaturedPacketData { - if x, ok := m.GetData().(*ThrottledPacketDataWrapper_VscMaturedPacket); ok { - return x.VscMaturedPacket - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*ThrottledPacketDataWrapper) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*ThrottledPacketDataWrapper_SlashPacket)(nil), - (*ThrottledPacketDataWrapper_VscMaturedPacket)(nil), - } -} - type QueryRegisteredConsumerRewardDenomsRequest struct { } @@ -963,7 +704,7 @@ func (m *QueryRegisteredConsumerRewardDenomsRequest) String() string { } func (*QueryRegisteredConsumerRewardDenomsRequest) ProtoMessage() {} func (*QueryRegisteredConsumerRewardDenomsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{19} + return fileDescriptor_422512d7b7586cd7, []int{15} } func (m *QueryRegisteredConsumerRewardDenomsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1004,7 +745,7 @@ func (m *QueryRegisteredConsumerRewardDenomsResponse) String() string { } func (*QueryRegisteredConsumerRewardDenomsResponse) ProtoMessage() {} func (*QueryRegisteredConsumerRewardDenomsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_422512d7b7586cd7, []int{20} + return fileDescriptor_422512d7b7586cd7, []int{16} } func (m *QueryRegisteredConsumerRewardDenomsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1056,10 +797,6 @@ func init() { proto.RegisterType((*QueryValidatorProviderAddrResponse)(nil), "interchain_security.ccv.provider.v1.QueryValidatorProviderAddrResponse") proto.RegisterType((*QueryThrottleStateRequest)(nil), "interchain_security.ccv.provider.v1.QueryThrottleStateRequest") proto.RegisterType((*QueryThrottleStateResponse)(nil), "interchain_security.ccv.provider.v1.QueryThrottleStateResponse") - proto.RegisterType((*QueryThrottledConsumerPacketDataRequest)(nil), "interchain_security.ccv.provider.v1.QueryThrottledConsumerPacketDataRequest") - proto.RegisterType((*QueryThrottledConsumerPacketDataResponse)(nil), "interchain_security.ccv.provider.v1.QueryThrottledConsumerPacketDataResponse") - proto.RegisterType((*ThrottledSlashPacket)(nil), "interchain_security.ccv.provider.v1.ThrottledSlashPacket") - proto.RegisterType((*ThrottledPacketDataWrapper)(nil), "interchain_security.ccv.provider.v1.ThrottledPacketDataWrapper") proto.RegisterType((*QueryRegisteredConsumerRewardDenomsRequest)(nil), "interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsRequest") proto.RegisterType((*QueryRegisteredConsumerRewardDenomsResponse)(nil), "interchain_security.ccv.provider.v1.QueryRegisteredConsumerRewardDenomsResponse") } @@ -1069,90 +806,74 @@ func init() { } var fileDescriptor_422512d7b7586cd7 = []byte{ - // 1322 bytes of a gzipped FileDescriptorProto + // 1060 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x57, 0xcf, 0x6f, 0xdc, 0x44, - 0x18, 0x5d, 0x6f, 0xd2, 0x34, 0x99, 0x14, 0x5a, 0xa6, 0xa5, 0x6c, 0xdd, 0x6a, 0xb7, 0xb8, 0x08, - 0xd2, 0x16, 0xec, 0xee, 0x56, 0x48, 0x4d, 0x20, 0xdd, 0xec, 0x26, 0x21, 0x8d, 0xda, 0xa8, 0xc1, - 0xa9, 0x5a, 0x09, 0x50, 0xcd, 0xc4, 0x1e, 0x36, 0x16, 0x5e, 0x8f, 0xeb, 0x99, 0x75, 0x1a, 0x7e, - 0x1c, 0x00, 0x09, 0x7a, 0xac, 0x84, 0xb8, 0x71, 0xe8, 0x89, 0xff, 0x82, 0x7b, 0x6f, 0x54, 0xf4, - 0xd2, 0x53, 0x41, 0x09, 0x07, 0x8e, 0x88, 0x3b, 0x12, 0xf2, 0x78, 0xbc, 0x3f, 0xb2, 0xde, 0x5d, - 0xef, 0x36, 0xb7, 0xdd, 0xf1, 0x7c, 0xef, 0x7b, 0xef, 0xe9, 0x9b, 0xf1, 0x33, 0xd0, 0x6c, 0x97, - 0x61, 0xdf, 0xdc, 0x42, 0xb6, 0x6b, 0x50, 0x6c, 0x36, 0x7c, 0x9b, 0xed, 0x68, 0xa6, 0x19, 0x68, - 0x9e, 0x4f, 0x02, 0xdb, 0xc2, 0xbe, 0x16, 0x14, 0xb5, 0x7b, 0x0d, 0xec, 0xef, 0xa8, 0x9e, 0x4f, - 0x18, 0x81, 0xe7, 0x12, 0x0a, 0x54, 0xd3, 0x0c, 0xd4, 0xb8, 0x40, 0x0d, 0x8a, 0xf2, 0x99, 0x1a, - 0x21, 0x35, 0x07, 0x6b, 0xc8, 0xb3, 0x35, 0xe4, 0xba, 0x84, 0x21, 0x66, 0x13, 0x97, 0x46, 0x10, - 0xf2, 0x89, 0x1a, 0xa9, 0x11, 0xfe, 0x53, 0x0b, 0x7f, 0x89, 0xd5, 0x82, 0xa8, 0xe1, 0xff, 0x36, - 0x1b, 0x9f, 0x69, 0xcc, 0xae, 0x63, 0xca, 0x50, 0xdd, 0x13, 0x1b, 0xde, 0xe8, 0x45, 0x35, 0x28, - 0x6a, 0x82, 0x00, 0x23, 0x72, 0xb1, 0xd7, 0x2e, 0x93, 0xb8, 0xb4, 0x51, 0x8f, 0x04, 0xd5, 0xb0, - 0x8b, 0xa9, 0x1d, 0xf3, 0x29, 0xa5, 0xf1, 0xa0, 0x29, 0x8f, 0xd7, 0x28, 0x57, 0xc0, 0xe9, 0x0f, - 0x43, 0x57, 0x16, 0x05, 0xea, 0x4a, 0x84, 0xa8, 0xe3, 0x7b, 0x0d, 0x4c, 0x19, 0x3c, 0x05, 0x26, - 0x23, 0x3c, 0xdb, 0xca, 0x49, 0x67, 0xa5, 0x99, 0x29, 0xfd, 0x30, 0xff, 0xbf, 0x6a, 0x29, 0x5f, - 0x81, 0x33, 0xc9, 0x95, 0xd4, 0x23, 0x2e, 0xc5, 0xf0, 0x13, 0xf0, 0x92, 0xa0, 0x67, 0x50, 0x86, - 0x18, 0xe6, 0xf5, 0xd3, 0xa5, 0xa2, 0xda, 0xcb, 0xf8, 0x58, 0x98, 0x1a, 0x14, 0x55, 0x01, 0xb6, - 0x11, 0x16, 0x56, 0xc7, 0x1f, 0x3f, 0x2f, 0x64, 0xf4, 0x23, 0xb5, 0xb6, 0x35, 0xe5, 0x0c, 0x90, - 0x3b, 0xba, 0x2f, 0x86, 0x78, 0x31, 0x6d, 0x05, 0xed, 0x53, 0x15, 0x3f, 0x15, 0xd4, 0xaa, 0x60, - 0x82, 0xf7, 0xa7, 0x39, 0xe9, 0xec, 0xd8, 0xcc, 0x74, 0xe9, 0x82, 0x9a, 0x62, 0x18, 0x54, 0x0e, - 0xa2, 0x8b, 0x4a, 0xe5, 0x3c, 0x78, 0xab, 0xbb, 0xc5, 0x06, 0x43, 0x3e, 0x5b, 0xf7, 0x89, 0x47, - 0x28, 0x72, 0x9a, 0x6c, 0x1e, 0x48, 0x60, 0x66, 0xf0, 0xde, 0xa6, 0x6d, 0x53, 0x5e, 0xbc, 0x28, - 0x2c, 0xbb, 0x9a, 0x8e, 0x9e, 0x00, 0xaf, 0x58, 0x96, 0x1d, 0x4e, 0x69, 0x0b, 0xba, 0x05, 0xa8, - 0xcc, 0x80, 0x37, 0x93, 0x98, 0x10, 0xaf, 0x8b, 0xf4, 0xf7, 0x52, 0xb2, 0xc0, 0x8e, 0xad, 0x82, - 0xf3, 0xc7, 0xdd, 0x9c, 0xe7, 0x87, 0xe2, 0xac, 0xe3, 0x3a, 0x09, 0x90, 0x93, 0x48, 0xb9, 0x0c, - 0x0e, 0xf1, 0xd6, 0x7d, 0x66, 0x11, 0x9e, 0x06, 0x53, 0xa6, 0x63, 0x63, 0x97, 0x85, 0xcf, 0xb2, - 0xfc, 0xd9, 0x64, 0xb4, 0xb0, 0x6a, 0x29, 0x3f, 0x48, 0xe0, 0x75, 0xae, 0xe4, 0x36, 0x72, 0x6c, - 0x0b, 0x31, 0xe2, 0xb7, 0x59, 0xe5, 0x0f, 0x9e, 0x74, 0x38, 0x0f, 0x8e, 0xc5, 0xa4, 0x0d, 0x64, - 0x59, 0x3e, 0xa6, 0x34, 0x6a, 0x52, 0x85, 0xff, 0x3e, 0x2f, 0xbc, 0xbc, 0x83, 0xea, 0xce, 0x9c, - 0x22, 0x1e, 0x28, 0xfa, 0xd1, 0x78, 0x6f, 0x25, 0x5a, 0x99, 0x9b, 0x7c, 0xf0, 0xa8, 0x90, 0xf9, - 0xfb, 0x51, 0x21, 0xa3, 0xdc, 0x04, 0x4a, 0x3f, 0x22, 0xc2, 0xcd, 0xf3, 0xe0, 0x58, 0x7c, 0x14, - 0x9a, 0xed, 0x22, 0x46, 0x47, 0xcd, 0xb6, 0xfd, 0x61, 0xb3, 0x6e, 0x69, 0xeb, 0x6d, 0xcd, 0xd3, - 0x49, 0xeb, 0xea, 0xd5, 0x47, 0xda, 0xbe, 0xfe, 0xfd, 0xa4, 0x75, 0x12, 0x69, 0x49, 0xeb, 0x72, - 0x52, 0x48, 0xdb, 0xe7, 0x9a, 0x72, 0x1a, 0x9c, 0xe2, 0x80, 0xb7, 0xb6, 0x7c, 0xc2, 0x98, 0x83, - 0xf9, 0xb1, 0x8f, 0x87, 0xf3, 0x97, 0xac, 0x38, 0xfe, 0xfb, 0x9e, 0x8a, 0x36, 0x05, 0x30, 0x4d, - 0x1d, 0x44, 0xb7, 0x8c, 0x3a, 0x66, 0xd8, 0xe7, 0x1d, 0xc6, 0x74, 0xc0, 0x97, 0xd6, 0xc2, 0x15, - 0x58, 0x02, 0xaf, 0xb6, 0x6d, 0x30, 0x90, 0xe3, 0x90, 0x6d, 0xe4, 0x9a, 0x98, 0x6b, 0x1f, 0xd3, - 0x8f, 0xb7, 0xb6, 0x56, 0xe2, 0x47, 0xf0, 0x2e, 0xc8, 0xb9, 0xf8, 0x3e, 0x33, 0x7c, 0xec, 0x39, - 0xd8, 0xb5, 0xe9, 0x96, 0x61, 0x22, 0xd7, 0x0a, 0xc5, 0xe2, 0xdc, 0x18, 0x9f, 0x79, 0x59, 0x8d, - 0xae, 0x7e, 0x35, 0xbe, 0xfa, 0xd5, 0x5b, 0xf1, 0xd5, 0x5f, 0x9d, 0x0c, 0xef, 0xb0, 0x87, 0x7f, - 0x14, 0x24, 0xfd, 0x64, 0x88, 0xa2, 0xc7, 0x20, 0x8b, 0x31, 0x06, 0xdc, 0x00, 0x87, 0x3d, 0x64, - 0x7e, 0x8e, 0x19, 0xcd, 0x8d, 0xf3, 0x5b, 0x69, 0x36, 0xd5, 0x11, 0x8a, 0x1d, 0xb0, 0x36, 0x42, - 0xce, 0xeb, 0x1c, 0x41, 0x8f, 0x91, 0x94, 0x25, 0x71, 0x88, 0x9b, 0xbb, 0xe2, 0x89, 0x8b, 0x36, - 0x2e, 0x21, 0x86, 0x52, 0x5c, 0xf5, 0xbf, 0xc7, 0x17, 0x58, 0x5f, 0x18, 0x61, 0x7e, 0x9f, 0x69, - 0x83, 0x60, 0x9c, 0xda, 0x5f, 0x44, 0x2e, 0x8f, 0xeb, 0xfc, 0x37, 0xdc, 0x06, 0xc7, 0xbd, 0x26, - 0xc8, 0xaa, 0x4b, 0x59, 0x68, 0x36, 0xcd, 0x8d, 0x71, 0x0b, 0xca, 0xc3, 0x59, 0xd0, 0x62, 0x73, - 0xc7, 0x47, 0x9e, 0x87, 0x7d, 0xf1, 0xea, 0x48, 0xea, 0xa0, 0xfc, 0x2a, 0x81, 0x13, 0x49, 0xe6, - 0xc1, 0xbb, 0xe0, 0x48, 0xcd, 0x21, 0x9b, 0xc8, 0x31, 0xb0, 0xcb, 0xfc, 0x1d, 0x71, 0xa1, 0xbd, - 0x9b, 0x8a, 0xca, 0x0a, 0x2f, 0xe4, 0x68, 0xcb, 0x61, 0xb1, 0x20, 0x30, 0x1d, 0x01, 0xf2, 0x25, - 0xb8, 0x0c, 0xc6, 0x2d, 0xc4, 0x10, 0x77, 0x61, 0xba, 0x74, 0xb1, 0x27, 0x6e, 0x50, 0x54, 0xdb, - 0x68, 0x85, 0xe4, 0x05, 0x1a, 0x2f, 0x57, 0x9e, 0x49, 0x40, 0xee, 0xad, 0x1c, 0xae, 0x83, 0x23, - 0xd1, 0x88, 0x47, 0xda, 0x85, 0x8a, 0x61, 0xba, 0x5d, 0xcb, 0xe8, 0xd1, 0x31, 0x12, 0xbe, 0x7c, - 0x0a, 0x60, 0x40, 0x4d, 0xa3, 0x8e, 0x58, 0xc3, 0xc7, 0x56, 0x8c, 0x1b, 0xa9, 0xb8, 0xd4, 0x0f, - 0xf7, 0xf6, 0xc6, 0xe2, 0x5a, 0x54, 0xd4, 0x01, 0x7e, 0x2c, 0xa0, 0x66, 0xc7, 0x7a, 0x75, 0x22, - 0x72, 0x46, 0x79, 0x1b, 0x5c, 0xe0, 0xe3, 0xa6, 0xe3, 0x9a, 0x4d, 0x19, 0xf6, 0x5b, 0xf3, 0xa6, - 0xe3, 0x6d, 0xe4, 0x5b, 0x4b, 0xd8, 0x25, 0xf5, 0xe6, 0x9b, 0x6a, 0x19, 0x5c, 0x4c, 0xb5, 0x5b, - 0xcc, 0xe7, 0x49, 0x30, 0x61, 0xf1, 0x15, 0xfe, 0xf2, 0x9f, 0xd2, 0xc5, 0xbf, 0xd2, 0xcf, 0xaf, - 0x80, 0x43, 0x1c, 0x07, 0xee, 0x4a, 0xe0, 0x44, 0x52, 0xb4, 0x81, 0x0b, 0xa9, 0x66, 0xa0, 0x4f, - 0x9e, 0x92, 0x2b, 0x2f, 0x80, 0x10, 0xf1, 0x57, 0x96, 0xbf, 0x7d, 0xfa, 0xd7, 0x8f, 0xd9, 0x32, - 0x9c, 0x1f, 0x1c, 0x79, 0x9b, 0x57, 0xbb, 0x88, 0x4e, 0xda, 0x97, 0xf1, 0xc9, 0xfc, 0x1a, 0x3e, - 0x95, 0xc0, 0xf1, 0x84, 0x8c, 0x04, 0xcb, 0xc3, 0x33, 0xec, 0xc8, 0x5e, 0xf2, 0xc2, 0xe8, 0x00, - 0x42, 0xe1, 0x2c, 0x57, 0x78, 0x19, 0x16, 0x87, 0x50, 0x18, 0xa5, 0x32, 0xf8, 0x4d, 0x16, 0xe4, - 0x7a, 0x44, 0x2d, 0x0a, 0x6f, 0x8c, 0xc8, 0x2c, 0x31, 0xd5, 0xc9, 0x6b, 0x07, 0x84, 0x26, 0x44, - 0x5f, 0xe3, 0xa2, 0xab, 0x70, 0x61, 0x58, 0xd1, 0x61, 0xba, 0xf6, 0x99, 0xd1, 0x0c, 0x4c, 0xf0, - 0x3f, 0x09, 0xbc, 0x96, 0x9c, 0xdc, 0x28, 0xbc, 0x3e, 0x32, 0xe9, 0xee, 0x88, 0x28, 0xdf, 0x38, - 0x18, 0x30, 0x61, 0xc0, 0x0a, 0x37, 0xa0, 0x02, 0xcb, 0x23, 0x18, 0x40, 0xbc, 0x36, 0xfd, 0xff, - 0x48, 0x22, 0x1c, 0x24, 0xc6, 0x2c, 0xf8, 0x41, 0x7a, 0xd6, 0xfd, 0x02, 0xa3, 0xbc, 0xf2, 0xc2, - 0x38, 0x42, 0x78, 0x85, 0x0b, 0x7f, 0x0f, 0xce, 0xa6, 0xf8, 0x86, 0x8d, 0x81, 0x8c, 0x8e, 0xd4, - 0x96, 0x20, 0xb9, 0x3d, 0x7e, 0x8d, 0x24, 0x39, 0x21, 0x48, 0x8e, 0x24, 0x39, 0x29, 0x07, 0x8e, - 0x26, 0xb9, 0x23, 0x39, 0xc2, 0xdf, 0x24, 0x00, 0xbb, 0x23, 0x20, 0xbc, 0x9a, 0x9e, 0x62, 0x52, - 0xb2, 0x94, 0xcb, 0x23, 0xd7, 0x0b, 0x69, 0x57, 0xb8, 0xb4, 0x12, 0xbc, 0x34, 0x58, 0x1a, 0x13, - 0x00, 0xd1, 0xf7, 0x31, 0xfc, 0x2e, 0x0b, 0xce, 0x0e, 0x4a, 0x59, 0xc3, 0xdc, 0x61, 0x83, 0x33, - 0xdf, 0x30, 0x77, 0x58, 0x8a, 0xe8, 0xa7, 0x54, 0xb9, 0xf6, 0xf7, 0xe1, 0xdc, 0x60, 0xed, 0x1e, - 0x76, 0x2d, 0xdb, 0xad, 0xb5, 0xe6, 0x58, 0x24, 0x56, 0xf8, 0x53, 0x16, 0x9c, 0x4b, 0xf1, 0x3a, - 0x87, 0x37, 0xd3, 0x53, 0x4f, 0x15, 0x23, 0xe4, 0xf5, 0x83, 0x03, 0x14, 0x76, 0x5c, 0xe7, 0x76, - 0x2c, 0xc3, 0xc5, 0xc1, 0x76, 0xf8, 0x4d, 0xc4, 0x96, 0x23, 0x3e, 0xc7, 0x34, 0xa2, 0x78, 0x52, - 0xbd, 0xf3, 0x78, 0x37, 0x2f, 0x3d, 0xd9, 0xcd, 0x4b, 0x7f, 0xee, 0xe6, 0xa5, 0x87, 0x7b, 0xf9, - 0xcc, 0x93, 0xbd, 0x7c, 0xe6, 0xd9, 0x5e, 0x3e, 0xf3, 0xd1, 0x7c, 0xcd, 0x66, 0x5b, 0x8d, 0x4d, - 0xd5, 0x24, 0x75, 0xcd, 0x24, 0xb4, 0x4e, 0x68, 0x5b, 0xbf, 0x77, 0x9a, 0xfd, 0x82, 0xcb, 0xda, - 0xfd, 0x7d, 0xf3, 0xb7, 0xe3, 0x61, 0xba, 0x39, 0xc1, 0xbf, 0x56, 0x2e, 0xff, 0x1f, 0x00, 0x00, - 0xff, 0xff, 0xbf, 0xd4, 0x24, 0xd7, 0x42, 0x13, 0x00, 0x00, + 0x14, 0x5e, 0x27, 0x34, 0x24, 0x13, 0x20, 0xd5, 0xb4, 0x94, 0xad, 0x13, 0xed, 0x16, 0x57, 0x40, + 0x5a, 0xc0, 0xce, 0x6e, 0x2e, 0x6d, 0x51, 0xba, 0xd9, 0x0d, 0x21, 0x54, 0x6d, 0xd5, 0xe0, 0x56, + 0x20, 0x01, 0xc2, 0x9a, 0xd8, 0xc3, 0xae, 0x25, 0xaf, 0xc7, 0x9d, 0x99, 0x75, 0x1a, 0x55, 0x1c, + 0xe0, 0x00, 0x3d, 0x56, 0x42, 0x70, 0xee, 0x9f, 0xd3, 0x1b, 0x45, 0xbd, 0x70, 0x2a, 0x28, 0xe1, + 0xc0, 0x11, 0x71, 0x47, 0xaa, 0x3c, 0x1e, 0x7b, 0x7f, 0x39, 0xbb, 0xce, 0x26, 0x37, 0x7b, 0xe6, + 0xbd, 0xef, 0x7d, 0xdf, 0xdb, 0x37, 0xf3, 0x79, 0x81, 0xe1, 0xfa, 0x1c, 0x53, 0xbb, 0x85, 0x5c, + 0xdf, 0x62, 0xd8, 0xee, 0x50, 0x97, 0xef, 0x19, 0xb6, 0x1d, 0x1a, 0x01, 0x25, 0xa1, 0xeb, 0x60, + 0x6a, 0x84, 0x15, 0xe3, 0x7e, 0x07, 0xd3, 0x3d, 0x3d, 0xa0, 0x84, 0x13, 0x78, 0x31, 0x23, 0x41, + 0xb7, 0xed, 0x50, 0x4f, 0x12, 0xf4, 0xb0, 0xa2, 0x2e, 0x35, 0x09, 0x69, 0x7a, 0xd8, 0x40, 0x81, + 0x6b, 0x20, 0xdf, 0x27, 0x1c, 0x71, 0x97, 0xf8, 0x2c, 0x86, 0x50, 0xcf, 0x36, 0x49, 0x93, 0x88, + 0x47, 0x23, 0x7a, 0x92, 0xab, 0x65, 0x99, 0x23, 0xde, 0x76, 0x3a, 0xdf, 0x1a, 0xdc, 0x6d, 0x63, + 0xc6, 0x51, 0x3b, 0x90, 0x01, 0xd5, 0x3c, 0x54, 0x53, 0x16, 0x71, 0xce, 0xca, 0x61, 0x39, 0x61, + 0xc5, 0x60, 0x2d, 0x44, 0xb1, 0x63, 0xd9, 0xc4, 0x67, 0x9d, 0x76, 0x9a, 0xf1, 0xce, 0x88, 0x8c, + 0x5d, 0x97, 0xe2, 0x38, 0x4c, 0xbb, 0x02, 0x16, 0x3f, 0x8b, 0xba, 0xb2, 0x21, 0xb3, 0xb7, 0xb0, + 0x8f, 0x99, 0xcb, 0x4c, 0x7c, 0xbf, 0x83, 0x19, 0x87, 0xe7, 0xc1, 0x6c, 0x0c, 0xe1, 0x3a, 0x45, + 0xe5, 0x82, 0xb2, 0x3c, 0x67, 0xbe, 0x2a, 0xde, 0x6f, 0x38, 0xda, 0x43, 0xb0, 0x94, 0x9d, 0xc9, + 0x02, 0xe2, 0x33, 0x0c, 0xbf, 0x02, 0xaf, 0x37, 0xe3, 0x25, 0x8b, 0x71, 0xc4, 0xb1, 0xc8, 0x9f, + 0xaf, 0xae, 0xe8, 0x87, 0x35, 0x3e, 0xac, 0xe8, 0x03, 0x58, 0x77, 0xa3, 0xbc, 0xc6, 0x2b, 0x4f, + 0x5f, 0x94, 0x0b, 0xe6, 0x6b, 0xcd, 0x9e, 0x35, 0x6d, 0x09, 0xa8, 0x7d, 0xc5, 0x37, 0x22, 0xb8, + 0x84, 0xb5, 0x86, 0x06, 0x44, 0x25, 0xbb, 0x92, 0x59, 0x03, 0xcc, 0x88, 0xf2, 0xac, 0xa8, 0x5c, + 0x98, 0x5e, 0x9e, 0xaf, 0x5e, 0xd6, 0x73, 0xcc, 0x82, 0x2e, 0x40, 0x4c, 0x99, 0xa9, 0x5d, 0x02, + 0xef, 0x0d, 0x97, 0xb8, 0xcb, 0x11, 0xe5, 0xdb, 0x94, 0x04, 0x84, 0x21, 0x2f, 0x65, 0xf3, 0x48, + 0x01, 0xcb, 0xe3, 0x63, 0x25, 0xb7, 0xaf, 0xc1, 0x5c, 0x90, 0x2c, 0xca, 0x8e, 0x5d, 0xcf, 0x47, + 0x4f, 0x82, 0xd7, 0x1d, 0xc7, 0x8d, 0x86, 0xb4, 0x0b, 0xdd, 0x05, 0xd4, 0x96, 0xc1, 0xbb, 0x59, + 0x4c, 0x48, 0x30, 0x44, 0xfa, 0x47, 0x25, 0x5b, 0x60, 0x5f, 0x68, 0xfa, 0x4b, 0x0f, 0x71, 0x5e, + 0x3b, 0x12, 0x67, 0x13, 0xb7, 0x49, 0x88, 0xbc, 0x4c, 0xca, 0x35, 0x70, 0x4a, 0x94, 0x1e, 0x31, + 0x8a, 0x70, 0x11, 0xcc, 0xd9, 0x9e, 0x8b, 0x7d, 0x1e, 0xed, 0x4d, 0x89, 0xbd, 0xd9, 0x78, 0xe1, + 0x86, 0xa3, 0xfd, 0xa4, 0x80, 0xb7, 0x85, 0x92, 0xcf, 0x91, 0xe7, 0x3a, 0x88, 0x13, 0xda, 0xd3, + 0x2a, 0x3a, 0x7e, 0xd0, 0xe1, 0x1a, 0x38, 0x9d, 0x90, 0xb6, 0x90, 0xe3, 0x50, 0xcc, 0x58, 0x5c, + 0xa4, 0x01, 0xff, 0x7b, 0x51, 0x7e, 0x63, 0x0f, 0xb5, 0xbd, 0x6b, 0x9a, 0xdc, 0xd0, 0xcc, 0x85, + 0x24, 0xb6, 0x1e, 0xaf, 0x5c, 0x9b, 0x7d, 0xf4, 0xa4, 0x5c, 0xf8, 0xe7, 0x49, 0xb9, 0xa0, 0xdd, + 0x01, 0xda, 0x28, 0x22, 0xb2, 0x9b, 0x97, 0xc0, 0xe9, 0xe4, 0x28, 0xa7, 0xe5, 0x62, 0x46, 0x0b, + 0x76, 0x4f, 0x7c, 0x54, 0x6c, 0x58, 0xda, 0x76, 0x4f, 0xf1, 0x7c, 0xd2, 0x86, 0x6a, 0x8d, 0x90, + 0x36, 0x50, 0x7f, 0x94, 0xb4, 0x7e, 0x22, 0x5d, 0x69, 0x43, 0x9d, 0x94, 0xd2, 0x06, 0xba, 0xa6, + 0x2d, 0x82, 0xf3, 0x02, 0xf0, 0x5e, 0x8b, 0x12, 0xce, 0x3d, 0x2c, 0x8e, 0x7d, 0x32, 0x9c, 0xbf, + 0x2b, 0xf2, 0xf8, 0x0f, 0xec, 0xca, 0x32, 0x65, 0x30, 0xcf, 0x3c, 0xc4, 0x5a, 0x56, 0x1b, 0x73, + 0x4c, 0x45, 0x85, 0x69, 0x13, 0x88, 0xa5, 0xdb, 0xd1, 0x0a, 0xac, 0x82, 0x37, 0x7b, 0x02, 0x2c, + 0xe4, 0x79, 0x64, 0x17, 0xf9, 0x36, 0x16, 0xda, 0xa7, 0xcd, 0x33, 0xdd, 0xd0, 0x7a, 0xb2, 0x05, + 0xbf, 0x01, 0x45, 0x1f, 0x3f, 0xe0, 0x16, 0xc5, 0x81, 0x87, 0x7d, 0x97, 0xb5, 0x2c, 0x1b, 0xf9, + 0x4e, 0x24, 0x16, 0x17, 0xa7, 0xc5, 0xcc, 0xab, 0x7a, 0x7c, 0xf3, 0xeb, 0xc9, 0xcd, 0xaf, 0xdf, + 0x4b, 0x6e, 0xfe, 0xc6, 0x6c, 0x74, 0x87, 0x3d, 0xfe, 0xb3, 0xac, 0x98, 0xe7, 0x22, 0x14, 0x33, + 0x01, 0xd9, 0x48, 0x30, 0xb4, 0x0f, 0xc0, 0x65, 0x21, 0xc9, 0xc4, 0x4d, 0x97, 0x71, 0x4c, 0xb1, + 0xd3, 0x3d, 0x1d, 0xbb, 0x88, 0x3a, 0x1f, 0x63, 0x9f, 0xb4, 0xd3, 0xe3, 0xb9, 0x09, 0xde, 0xcf, + 0x15, 0x2d, 0x3b, 0x72, 0x0e, 0xcc, 0x38, 0x62, 0x45, 0xdc, 0x78, 0x73, 0xa6, 0x7c, 0xab, 0xfe, + 0xba, 0x00, 0x4e, 0x09, 0x1c, 0xb8, 0xaf, 0x80, 0xb3, 0x59, 0xd7, 0x39, 0x5c, 0xcf, 0x75, 0x92, + 0x47, 0x78, 0x88, 0x5a, 0x3f, 0x06, 0x42, 0xcc, 0x5f, 0xdb, 0xfc, 0xe1, 0xf9, 0xdf, 0x3f, 0x4f, + 0xd5, 0xe0, 0xda, 0x78, 0x9b, 0x4f, 0xe7, 0x59, 0xfa, 0x85, 0xf1, 0x30, 0x19, 0xfe, 0xef, 0xe0, + 0x73, 0x05, 0x9c, 0xc9, 0x30, 0x06, 0x58, 0x3b, 0x3a, 0xc3, 0x3e, 0xc3, 0x51, 0xd7, 0x27, 0x07, + 0x90, 0x0a, 0xaf, 0x0a, 0x85, 0xab, 0xb0, 0x72, 0x04, 0x85, 0xb1, 0x15, 0xc1, 0xef, 0xa7, 0x40, + 0xf1, 0x10, 0x7f, 0x61, 0xf0, 0xd6, 0x84, 0xcc, 0x32, 0xad, 0x4c, 0xbd, 0x7d, 0x42, 0x68, 0x52, + 0xf4, 0xa7, 0x42, 0x74, 0x03, 0xae, 0x1f, 0x55, 0x74, 0xf4, 0x45, 0x41, 0xb9, 0x95, 0xba, 0x04, + 0xfc, 0x5f, 0x01, 0x6f, 0x65, 0xdb, 0x15, 0x83, 0x37, 0x27, 0x26, 0x3d, 0xec, 0x8b, 0xea, 0xad, + 0x93, 0x01, 0x93, 0x0d, 0xd8, 0x12, 0x0d, 0xa8, 0xc3, 0xda, 0x04, 0x0d, 0x20, 0x41, 0x8f, 0xfe, + 0x7f, 0x93, 0x1b, 0x31, 0xd3, 0x5b, 0xe0, 0x27, 0xf9, 0x59, 0x8f, 0x72, 0x49, 0x75, 0xeb, 0xd8, + 0x38, 0x52, 0x78, 0x5d, 0x08, 0xff, 0x08, 0x5e, 0xcd, 0xf1, 0xdd, 0x9e, 0x00, 0x59, 0x7d, 0x56, + 0x95, 0x21, 0xb9, 0xd7, 0x73, 0x26, 0x92, 0x9c, 0xe1, 0x9e, 0x13, 0x49, 0xce, 0x32, 0xbf, 0xc9, + 0x24, 0xf7, 0xd9, 0x25, 0xfc, 0x4d, 0x01, 0x70, 0xd8, 0xf7, 0xe0, 0xf5, 0xfc, 0x14, 0xb3, 0xec, + 0x54, 0xad, 0x4d, 0x9c, 0x2f, 0xa5, 0x5d, 0x11, 0xd2, 0xaa, 0x70, 0x65, 0xbc, 0x34, 0x2e, 0x01, + 0xe2, 0xff, 0x04, 0xf0, 0x97, 0x29, 0x70, 0x31, 0x87, 0x91, 0xc1, 0x3b, 0xf9, 0x29, 0xe6, 0x32, + 0x50, 0x75, 0xfb, 0xe4, 0x00, 0x65, 0x13, 0x6e, 0x8a, 0x26, 0x6c, 0xc2, 0x8d, 0xf1, 0x4d, 0xa0, + 0x29, 0x62, 0x77, 0xa6, 0xa9, 0xc0, 0xb4, 0x62, 0x63, 0x6e, 0x7c, 0xf1, 0x74, 0xbf, 0xa4, 0x3c, + 0xdb, 0x2f, 0x29, 0x7f, 0xed, 0x97, 0x94, 0xc7, 0x07, 0xa5, 0xc2, 0xb3, 0x83, 0x52, 0xe1, 0x8f, + 0x83, 0x52, 0xe1, 0xcb, 0xb5, 0xa6, 0xcb, 0x5b, 0x9d, 0x1d, 0xdd, 0x26, 0x6d, 0xc3, 0x26, 0xac, + 0x4d, 0x58, 0x4f, 0xbd, 0x0f, 0xd3, 0x7a, 0xe1, 0xaa, 0xf1, 0x60, 0xa0, 0xf3, 0x7b, 0x01, 0x66, + 0x3b, 0x33, 0xe2, 0xe3, 0x64, 0xf5, 0x65, 0x00, 0x00, 0x00, 0xff, 0xff, 0xad, 0x57, 0x98, 0xb7, + 0x30, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1186,9 +907,6 @@ type QueryClient interface { // QueryThrottleState returns the main on-chain state relevant to currently // throttled slash packets QueryThrottleState(ctx context.Context, in *QueryThrottleStateRequest, opts ...grpc.CallOption) (*QueryThrottleStateResponse, error) - // QueryThrottledConsumerPacketData returns a list of pending packet data - // instances (slash packet and vsc matured) for a single consumer chain - QueryThrottledConsumerPacketData(ctx context.Context, in *QueryThrottledConsumerPacketDataRequest, opts ...grpc.CallOption) (*QueryThrottledConsumerPacketDataResponse, error) // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered QueryRegisteredConsumerRewardDenoms(ctx context.Context, in *QueryRegisteredConsumerRewardDenomsRequest, opts ...grpc.CallOption) (*QueryRegisteredConsumerRewardDenomsResponse, error) @@ -1265,15 +983,6 @@ func (c *queryClient) QueryThrottleState(ctx context.Context, in *QueryThrottleS return out, nil } -func (c *queryClient) QueryThrottledConsumerPacketData(ctx context.Context, in *QueryThrottledConsumerPacketDataRequest, opts ...grpc.CallOption) (*QueryThrottledConsumerPacketDataResponse, error) { - out := new(QueryThrottledConsumerPacketDataResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryThrottledConsumerPacketData", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - func (c *queryClient) QueryRegisteredConsumerRewardDenoms(ctx context.Context, in *QueryRegisteredConsumerRewardDenomsRequest, opts ...grpc.CallOption) (*QueryRegisteredConsumerRewardDenomsResponse, error) { out := new(QueryRegisteredConsumerRewardDenomsResponse) err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Query/QueryRegisteredConsumerRewardDenoms", in, out, opts...) @@ -1304,9 +1013,6 @@ type QueryServer interface { // QueryThrottleState returns the main on-chain state relevant to currently // throttled slash packets QueryThrottleState(context.Context, *QueryThrottleStateRequest) (*QueryThrottleStateResponse, error) - // QueryThrottledConsumerPacketData returns a list of pending packet data - // instances (slash packet and vsc matured) for a single consumer chain - QueryThrottledConsumerPacketData(context.Context, *QueryThrottledConsumerPacketDataRequest) (*QueryThrottledConsumerPacketDataResponse, error) // QueryRegisteredConsumerRewardDenoms returns a list of consumer reward // denoms that are registered QueryRegisteredConsumerRewardDenoms(context.Context, *QueryRegisteredConsumerRewardDenomsRequest) (*QueryRegisteredConsumerRewardDenomsResponse, error) @@ -1337,9 +1043,6 @@ func (*UnimplementedQueryServer) QueryValidatorProviderAddr(ctx context.Context, func (*UnimplementedQueryServer) QueryThrottleState(ctx context.Context, req *QueryThrottleStateRequest) (*QueryThrottleStateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryThrottleState not implemented") } -func (*UnimplementedQueryServer) QueryThrottledConsumerPacketData(ctx context.Context, req *QueryThrottledConsumerPacketDataRequest) (*QueryThrottledConsumerPacketDataResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method QueryThrottledConsumerPacketData not implemented") -} func (*UnimplementedQueryServer) QueryRegisteredConsumerRewardDenoms(ctx context.Context, req *QueryRegisteredConsumerRewardDenomsRequest) (*QueryRegisteredConsumerRewardDenomsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryRegisteredConsumerRewardDenoms not implemented") } @@ -1474,24 +1177,6 @@ func _Query_QueryThrottleState_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } -func _Query_QueryThrottledConsumerPacketData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryThrottledConsumerPacketDataRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).QueryThrottledConsumerPacketData(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Query/QueryThrottledConsumerPacketData", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).QueryThrottledConsumerPacketData(ctx, req.(*QueryThrottledConsumerPacketDataRequest)) - } - return interceptor(ctx, in, info, handler) -} - func _Query_QueryRegisteredConsumerRewardDenoms_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryRegisteredConsumerRewardDenomsRequest) if err := dec(in); err != nil { @@ -1542,10 +1227,6 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryThrottleState", Handler: _Query_QueryThrottleState_Handler, }, - { - MethodName: "QueryThrottledConsumerPacketData", - Handler: _Query_QueryThrottledConsumerPacketData_Handler, - }, { MethodName: "QueryRegisteredConsumerRewardDenoms", Handler: _Query_QueryRegisteredConsumerRewardDenoms_Handler, @@ -2008,20 +1689,6 @@ func (m *QueryThrottleStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, err _ = i var l int _ = l - if len(m.Packets) > 0 { - for iNdEx := len(m.Packets) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Packets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } n4, err4 := github_com_cosmos_gogoproto_types.StdTimeMarshalTo(m.NextReplenishCandidate, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdTime(m.NextReplenishCandidate):]) if err4 != nil { return 0, err4 @@ -2043,7 +1710,7 @@ func (m *QueryThrottleStateResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *QueryThrottledConsumerPacketDataRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryRegisteredConsumerRewardDenomsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2053,27 +1720,20 @@ func (m *QueryThrottledConsumerPacketDataRequest) Marshal() (dAtA []byte, err er return dAtA[:n], nil } -func (m *QueryThrottledConsumerPacketDataRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRegisteredConsumerRewardDenomsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryThrottledConsumerPacketDataRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRegisteredConsumerRewardDenomsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *QueryThrottledConsumerPacketDataResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryRegisteredConsumerRewardDenomsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2083,245 +1743,56 @@ func (m *QueryThrottledConsumerPacketDataResponse) Marshal() (dAtA []byte, err e return dAtA[:n], nil } -func (m *QueryThrottledConsumerPacketDataResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRegisteredConsumerRewardDenomsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryThrottledConsumerPacketDataResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRegisteredConsumerRewardDenomsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.PacketDataInstances) > 0 { - for iNdEx := len(m.PacketDataInstances) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.PacketDataInstances[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } + if len(m.Denoms) > 0 { + for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Denoms[iNdEx]) + copy(dAtA[i:], m.Denoms[iNdEx]) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Denoms[iNdEx]))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0xa } } - if m.Size_ != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.Size_)) - i-- - dAtA[i] = 0x10 - } - if len(m.ChainId) > 0 { - i -= len(m.ChainId) - copy(dAtA[i:], m.ChainId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChainId))) - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *ThrottledSlashPacket) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err +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++ } - return dAtA[:n], nil + dAtA[offset] = uint8(v) + return base } - -func (m *ThrottledSlashPacket) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) +func (m *QueryConsumerGenesisRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n } -func (m *ThrottledSlashPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size, err := m.GlobalEntry.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *ThrottledPacketDataWrapper) 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 *ThrottledPacketDataWrapper) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ThrottledPacketDataWrapper) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Data != nil { - { - size := m.Data.Size() - i -= size - if _, err := m.Data.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *ThrottledPacketDataWrapper_SlashPacket) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ThrottledPacketDataWrapper_SlashPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.SlashPacket != nil { - { - size, err := m.SlashPacket.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *ThrottledPacketDataWrapper_VscMaturedPacket) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ThrottledPacketDataWrapper_VscMaturedPacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.VscMaturedPacket != nil { - { - size, err := m.VscMaturedPacket.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *QueryRegisteredConsumerRewardDenomsRequest) 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 *QueryRegisteredConsumerRewardDenomsRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryRegisteredConsumerRewardDenomsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *QueryRegisteredConsumerRewardDenomsResponse) 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 *QueryRegisteredConsumerRewardDenomsResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryRegisteredConsumerRewardDenomsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Denoms) > 0 { - for iNdEx := len(m.Denoms) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Denoms[iNdEx]) - copy(dAtA[i:], m.Denoms[iNdEx]) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Denoms[iNdEx]))) - 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 *QueryConsumerGenesisRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryConsumerGenesisResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryConsumerGenesisResponse) Size() (n int) { + if m == nil { + return 0 + } var l int _ = l l = m.GenesisState.Size() @@ -2497,99 +1968,9 @@ func (m *QueryThrottleStateResponse) Size() (n int) { } l = github_com_cosmos_gogoproto_types.SizeOfStdTime(m.NextReplenishCandidate) n += 1 + l + sovQuery(uint64(l)) - if len(m.Packets) > 0 { - for _, e := range m.Packets { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *QueryThrottledConsumerPacketDataRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryThrottledConsumerPacketDataResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ChainId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - if m.Size_ != 0 { - n += 1 + sovQuery(uint64(m.Size_)) - } - if len(m.PacketDataInstances) > 0 { - for _, e := range m.PacketDataInstances { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - return n -} - -func (m *ThrottledSlashPacket) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.GlobalEntry.Size() - n += 1 + l + sovQuery(uint64(l)) - l = m.Data.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *ThrottledPacketDataWrapper) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Data != nil { - n += m.Data.Size() - } return n } -func (m *ThrottledPacketDataWrapper_SlashPacket) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SlashPacket != nil { - l = m.SlashPacket.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} -func (m *ThrottledPacketDataWrapper_VscMaturedPacket) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.VscMaturedPacket != nil { - l = m.VscMaturedPacket.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} func (m *QueryRegisteredConsumerRewardDenomsRequest) Size() (n int) { if m == nil { return 0 @@ -3847,493 +3228,6 @@ func (m *QueryThrottleStateResponse) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Packets", 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.Packets = append(m.Packets, &ThrottledSlashPacket{}) - if err := m.Packets[len(m.Packets)-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 (m *QueryThrottledConsumerPacketDataRequest) 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: QueryThrottledConsumerPacketDataRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryThrottledConsumerPacketDataRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", 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.ChainId = 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 *QueryThrottledConsumerPacketDataResponse) 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: QueryThrottledConsumerPacketDataResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryThrottledConsumerPacketDataResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChainId", 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.ChainId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Size_", wireType) - } - m.Size_ = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Size_ |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PacketDataInstances", 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.PacketDataInstances = append(m.PacketDataInstances, ThrottledPacketDataWrapper{}) - if err := m.PacketDataInstances[len(m.PacketDataInstances)-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 (m *ThrottledSlashPacket) 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: ThrottledSlashPacket: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ThrottledSlashPacket: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GlobalEntry", 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 err := m.GlobalEntry.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", 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 err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ThrottledPacketDataWrapper) 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: ThrottledPacketDataWrapper: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ThrottledPacketDataWrapper: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SlashPacket", 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 - } - v := &types1.SlashPacketData{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Data = &ThrottledPacketDataWrapper_SlashPacket{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field VscMaturedPacket", 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 - } - v := &types1.VSCMaturedPacketData{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Data = &ThrottledPacketDataWrapper_VscMaturedPacket{v} - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) diff --git a/x/ccv/provider/types/query.pb.gw.go b/x/ccv/provider/types/query.pb.gw.go index 6a249ca2a2..1a4b418158 100644 --- a/x/ccv/provider/types/query.pb.gw.go +++ b/x/ccv/provider/types/query.pb.gw.go @@ -231,42 +231,6 @@ func local_request_Query_QueryThrottleState_0(ctx context.Context, marshaler run } -var ( - filter_Query_QueryThrottledConsumerPacketData_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_QueryThrottledConsumerPacketData_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryThrottledConsumerPacketDataRequest - 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_Query_QueryThrottledConsumerPacketData_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.QueryThrottledConsumerPacketData(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_QueryThrottledConsumerPacketData_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryThrottledConsumerPacketDataRequest - 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_Query_QueryThrottledConsumerPacketData_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.QueryThrottledConsumerPacketData(ctx, &protoReq) - return msg, metadata, err - -} - func request_Query_QueryRegisteredConsumerRewardDenoms_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryRegisteredConsumerRewardDenomsRequest var metadata runtime.ServerMetadata @@ -452,29 +416,6 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_QueryThrottledConsumerPacketData_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_Query_QueryThrottledConsumerPacketData_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_Query_QueryThrottledConsumerPacketData_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryRegisteredConsumerRewardDenoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -679,26 +620,6 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_QueryThrottledConsumerPacketData_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { - ctx, cancel := context.WithCancel(req.Context()) - defer cancel() - inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_QueryThrottledConsumerPacketData_0(rctx, inboundMarshaler, client, req, pathParams) - ctx = runtime.NewServerMetadataContext(ctx, md) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - - forward_Query_QueryThrottledConsumerPacketData_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - mux.Handle("GET", pattern_Query_QueryRegisteredConsumerRewardDenoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -737,8 +658,6 @@ var ( pattern_Query_QueryThrottleState_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "throttle_state"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryThrottledConsumerPacketData_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "pending_consumer_packets"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_QueryRegisteredConsumerRewardDenoms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"interchain_security", "ccv", "provider", "registered_consumer_reward_denoms"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -757,7 +676,5 @@ var ( forward_Query_QueryThrottleState_0 = runtime.ForwardResponseMessage - forward_Query_QueryThrottledConsumerPacketData_0 = runtime.ForwardResponseMessage - forward_Query_QueryRegisteredConsumerRewardDenoms_0 = runtime.ForwardResponseMessage ) diff --git a/x/ccv/provider/types/tx.pb.go b/x/ccv/provider/types/tx.pb.go index 32bca37998..80487a06c9 100644 --- a/x/ccv/provider/types/tx.pb.go +++ b/x/ccv/provider/types/tx.pb.go @@ -6,12 +6,9 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -111,92 +108,9 @@ func (m *MsgAssignConsumerKeyResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAssignConsumerKeyResponse proto.InternalMessageInfo -// MsgRegisterConsumerRewardDenom allows an account to register -// a consumer reward denom, i.e., add it to the list of denoms -// accepted by the provider as rewards. -type MsgRegisterConsumerRewardDenom struct { - Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - Depositor string `protobuf:"bytes,2,opt,name=depositor,proto3" json:"depositor,omitempty"` -} - -func (m *MsgRegisterConsumerRewardDenom) Reset() { *m = MsgRegisterConsumerRewardDenom{} } -func (m *MsgRegisterConsumerRewardDenom) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterConsumerRewardDenom) ProtoMessage() {} -func (*MsgRegisterConsumerRewardDenom) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{2} -} -func (m *MsgRegisterConsumerRewardDenom) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterConsumerRewardDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterConsumerRewardDenom.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 *MsgRegisterConsumerRewardDenom) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterConsumerRewardDenom.Merge(m, src) -} -func (m *MsgRegisterConsumerRewardDenom) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterConsumerRewardDenom) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterConsumerRewardDenom.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterConsumerRewardDenom proto.InternalMessageInfo - -// MsgRegisterConsumerRewardDenomResponse defines the -// Msg/RegisterConsumerRewardDenom response type. -type MsgRegisterConsumerRewardDenomResponse struct { -} - -func (m *MsgRegisterConsumerRewardDenomResponse) Reset() { - *m = MsgRegisterConsumerRewardDenomResponse{} -} -func (m *MsgRegisterConsumerRewardDenomResponse) String() string { return proto.CompactTextString(m) } -func (*MsgRegisterConsumerRewardDenomResponse) ProtoMessage() {} -func (*MsgRegisterConsumerRewardDenomResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_43221a4391e9fbf4, []int{3} -} -func (m *MsgRegisterConsumerRewardDenomResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgRegisterConsumerRewardDenomResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgRegisterConsumerRewardDenomResponse.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 *MsgRegisterConsumerRewardDenomResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgRegisterConsumerRewardDenomResponse.Merge(m, src) -} -func (m *MsgRegisterConsumerRewardDenomResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgRegisterConsumerRewardDenomResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgRegisterConsumerRewardDenomResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgRegisterConsumerRewardDenomResponse proto.InternalMessageInfo - func init() { proto.RegisterType((*MsgAssignConsumerKey)(nil), "interchain_security.ccv.provider.v1.MsgAssignConsumerKey") proto.RegisterType((*MsgAssignConsumerKeyResponse)(nil), "interchain_security.ccv.provider.v1.MsgAssignConsumerKeyResponse") - proto.RegisterType((*MsgRegisterConsumerRewardDenom)(nil), "interchain_security.ccv.provider.v1.MsgRegisterConsumerRewardDenom") - proto.RegisterType((*MsgRegisterConsumerRewardDenomResponse)(nil), "interchain_security.ccv.provider.v1.MsgRegisterConsumerRewardDenomResponse") } func init() { @@ -204,36 +118,28 @@ func init() { } var fileDescriptor_43221a4391e9fbf4 = []byte{ - // 453 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x3d, 0x6b, 0x14, 0x41, - 0x18, 0xc7, 0x77, 0x13, 0xd4, 0x64, 0x8c, 0x82, 0xc3, 0x15, 0x97, 0xf3, 0xd8, 0xd3, 0x15, 0x24, - 0x85, 0xee, 0x10, 0x53, 0x88, 0x01, 0x8b, 0x4b, 0x6c, 0x24, 0x5c, 0xb3, 0x8d, 0x60, 0xe1, 0xb1, - 0x37, 0x33, 0x4e, 0x06, 0xb3, 0xf3, 0x2c, 0xf3, 0xcc, 0xad, 0xd9, 0x6f, 0x60, 0xa9, 0x95, 0x6d, - 0xbe, 0x81, 0x5f, 0x43, 0xb0, 0x49, 0x69, 0x25, 0x72, 0xd7, 0x58, 0xfb, 0x09, 0x64, 0xdf, 0x3c, - 0xc5, 0xe3, 0x08, 0x92, 0xee, 0x79, 0xdb, 0xff, 0xff, 0xb7, 0x33, 0xf3, 0x90, 0x07, 0xda, 0x38, - 0x69, 0xf9, 0x71, 0xa2, 0xcd, 0x18, 0x25, 0x9f, 0x5a, 0xed, 0x0a, 0xc6, 0x79, 0xce, 0x32, 0x0b, - 0xb9, 0x16, 0xd2, 0xb2, 0x7c, 0x97, 0xb9, 0xd3, 0x28, 0xb3, 0xe0, 0x80, 0xde, 0x5b, 0x32, 0x1d, - 0x71, 0x9e, 0x47, 0xed, 0x74, 0x94, 0xef, 0xf6, 0xfa, 0x0a, 0x40, 0x9d, 0x48, 0x96, 0x64, 0x9a, - 0x25, 0xc6, 0x80, 0x4b, 0x9c, 0x06, 0x83, 0xb5, 0x44, 0xaf, 0xa3, 0x40, 0x41, 0x15, 0xb2, 0x32, - 0x6a, 0xaa, 0xdb, 0x1c, 0x30, 0x05, 0x1c, 0xd7, 0x8d, 0x3a, 0x69, 0x5b, 0x8d, 0x5c, 0x95, 0x4d, - 0xa6, 0xaf, 0x59, 0x62, 0x8a, 0xba, 0x15, 0x7e, 0xf4, 0x49, 0x67, 0x84, 0x6a, 0x88, 0xa8, 0x95, - 0x39, 0x04, 0x83, 0xd3, 0x54, 0xda, 0x23, 0x59, 0xd0, 0x6d, 0xb2, 0x51, 0x43, 0x6a, 0xd1, 0xf5, - 0xef, 0xf8, 0x3b, 0x9b, 0xf1, 0xb5, 0x2a, 0x7f, 0x2e, 0xe8, 0x63, 0x72, 0xa3, 0x85, 0x1d, 0x27, - 0x42, 0xd8, 0xee, 0x5a, 0xd9, 0x3f, 0xa0, 0x3f, 0xbf, 0x0d, 0x6e, 0x16, 0x49, 0x7a, 0xb2, 0x1f, - 0x96, 0x55, 0x89, 0x18, 0xc6, 0x5b, 0xed, 0xe0, 0x50, 0x08, 0x4b, 0xef, 0x92, 0x2d, 0xde, 0x58, - 0x8c, 0xdf, 0xc8, 0xa2, 0xbb, 0x5e, 0xe9, 0x5e, 0xe7, 0x0b, 0xdb, 0xfd, 0x8d, 0x77, 0x67, 0x03, - 0xef, 0xc7, 0xd9, 0xc0, 0x0b, 0x03, 0xd2, 0x5f, 0x06, 0x16, 0x4b, 0xcc, 0xc0, 0xa0, 0x0c, 0x5f, - 0x91, 0x60, 0x84, 0x2a, 0x96, 0x4a, 0xa3, 0x93, 0xb6, 0x9d, 0x88, 0xe5, 0xdb, 0xc4, 0x8a, 0x67, - 0xd2, 0x40, 0x4a, 0x3b, 0xe4, 0x8a, 0x28, 0x83, 0x86, 0xbf, 0x4e, 0x68, 0x9f, 0x6c, 0x0a, 0x99, - 0x01, 0x6a, 0x07, 0x0d, 0x79, 0xbc, 0x28, 0xfc, 0xe1, 0xbf, 0x43, 0xee, 0xaf, 0xd6, 0x6f, 0x49, - 0x1e, 0x7d, 0x59, 0x23, 0xeb, 0x23, 0x54, 0xf4, 0x83, 0x4f, 0x6e, 0xfd, 0x7b, 0x90, 0x4f, 0xa2, - 0x0b, 0xdc, 0x78, 0xb4, 0xec, 0x57, 0x7b, 0xc3, 0xff, 0xfe, 0xb4, 0x65, 0xa3, 0x9f, 0x7c, 0x72, - 0x7b, 0xd5, 0x19, 0x1d, 0x5e, 0xd4, 0x62, 0x85, 0x48, 0xef, 0xe8, 0x12, 0x44, 0x5a, 0xe2, 0x83, - 0x17, 0x9f, 0x67, 0x81, 0x7f, 0x3e, 0x0b, 0xfc, 0xef, 0xb3, 0xc0, 0x7f, 0x3f, 0x0f, 0xbc, 0xf3, - 0x79, 0xe0, 0x7d, 0x9d, 0x07, 0xde, 0xcb, 0xa7, 0x4a, 0xbb, 0xe3, 0xe9, 0x24, 0xe2, 0x90, 0x36, - 0xef, 0x9b, 0x2d, 0x7c, 0x1f, 0xfe, 0x5e, 0xbd, 0x7c, 0x8f, 0x9d, 0xfe, 0xbd, 0x7f, 0xae, 0xc8, - 0x24, 0x4e, 0xae, 0x56, 0x2f, 0x7e, 0xef, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x72, 0xb0, 0xd5, - 0x84, 0xb0, 0x03, 0x00, 0x00, + // 328 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xc9, 0xcc, 0x2b, 0x49, + 0x2d, 0x4a, 0xce, 0x48, 0xcc, 0xcc, 0x8b, 0x2f, 0x4e, 0x4d, 0x2e, 0x2d, 0xca, 0x2c, 0xa9, 0xd4, + 0x4f, 0x4e, 0x2e, 0xd3, 0x2f, 0x28, 0xca, 0x2f, 0xcb, 0x4c, 0x49, 0x2d, 0xd2, 0x2f, 0x33, 0xd4, + 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0xc6, 0xa2, 0x5a, 0x2f, 0x39, 0xb9, + 0x4c, 0x0f, 0xa6, 0x5a, 0xaf, 0xcc, 0x50, 0x4a, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xac, 0x5e, 0x1f, + 0xc4, 0x82, 0x68, 0x55, 0x9a, 0xce, 0xc8, 0x25, 0xe2, 0x5b, 0x9c, 0xee, 0x58, 0x5c, 0x9c, 0x99, + 0x9e, 0xe7, 0x9c, 0x9f, 0x57, 0x5c, 0x9a, 0x9b, 0x5a, 0xe4, 0x9d, 0x5a, 0x29, 0x24, 0xc9, 0xc5, + 0x01, 0x31, 0x30, 0x33, 0x45, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x88, 0x1d, 0xcc, 0xf7, 0x4c, + 0x11, 0x32, 0xe7, 0xe2, 0x85, 0x19, 0x1c, 0x9f, 0x98, 0x92, 0x52, 0x24, 0xc1, 0x04, 0x92, 0x77, + 0x12, 0xfa, 0x74, 0x4f, 0x9e, 0xaf, 0x32, 0x31, 0x37, 0xc7, 0x4a, 0x09, 0x24, 0x9a, 0x5a, 0x5c, + 0xac, 0x14, 0xc4, 0x03, 0x53, 0xe8, 0x98, 0x92, 0x52, 0x24, 0xa4, 0xc8, 0xc5, 0x93, 0x0c, 0xb5, + 0x22, 0x3e, 0x3b, 0xb5, 0x52, 0x82, 0x19, 0x6c, 0x2e, 0x77, 0x32, 0xc2, 0x5a, 0x2b, 0x8e, 0x8e, + 0x05, 0xf2, 0x0c, 0x2f, 0x16, 0xc8, 0x33, 0x28, 0xc9, 0x71, 0xc9, 0x60, 0x73, 0x58, 0x50, 0x6a, + 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0xd1, 0x4c, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x89, + 0x8c, 0x5c, 0x82, 0x98, 0xce, 0xb7, 0xd4, 0x23, 0x22, 0x4c, 0xf4, 0xb0, 0x59, 0x20, 0xe5, 0x48, + 0xb6, 0x56, 0x98, 0xdb, 0x9c, 0xc2, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, + 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, + 0xca, 0x36, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0x39, 0xbf, 0x38, + 0x37, 0xbf, 0x58, 0x1f, 0x61, 0x9b, 0x2e, 0x3c, 0xaa, 0xcb, 0x8c, 0xf5, 0x2b, 0x50, 0xe3, 0xbb, + 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0x1c, 0x6b, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0xb3, 0xd9, 0x75, 0xa5, 0x20, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -249,7 +155,6 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { AssignConsumerKey(ctx context.Context, in *MsgAssignConsumerKey, opts ...grpc.CallOption) (*MsgAssignConsumerKeyResponse, error) - RegisterConsumerRewardDenom(ctx context.Context, in *MsgRegisterConsumerRewardDenom, opts ...grpc.CallOption) (*MsgRegisterConsumerRewardDenomResponse, error) } type msgClient struct { @@ -269,19 +174,9 @@ func (c *msgClient) AssignConsumerKey(ctx context.Context, in *MsgAssignConsumer return out, nil } -func (c *msgClient) RegisterConsumerRewardDenom(ctx context.Context, in *MsgRegisterConsumerRewardDenom, opts ...grpc.CallOption) (*MsgRegisterConsumerRewardDenomResponse, error) { - out := new(MsgRegisterConsumerRewardDenomResponse) - err := c.cc.Invoke(ctx, "/interchain_security.ccv.provider.v1.Msg/RegisterConsumerRewardDenom", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - // MsgServer is the server API for Msg service. type MsgServer interface { AssignConsumerKey(context.Context, *MsgAssignConsumerKey) (*MsgAssignConsumerKeyResponse, error) - RegisterConsumerRewardDenom(context.Context, *MsgRegisterConsumerRewardDenom) (*MsgRegisterConsumerRewardDenomResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -291,9 +186,6 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) AssignConsumerKey(ctx context.Context, req *MsgAssignConsumerKey) (*MsgAssignConsumerKeyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AssignConsumerKey not implemented") } -func (*UnimplementedMsgServer) RegisterConsumerRewardDenom(ctx context.Context, req *MsgRegisterConsumerRewardDenom) (*MsgRegisterConsumerRewardDenomResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RegisterConsumerRewardDenom not implemented") -} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -317,24 +209,6 @@ func _Msg_AssignConsumerKey_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } -func _Msg_RegisterConsumerRewardDenom_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgRegisterConsumerRewardDenom) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).RegisterConsumerRewardDenom(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/interchain_security.ccv.provider.v1.Msg/RegisterConsumerRewardDenom", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).RegisterConsumerRewardDenom(ctx, req.(*MsgRegisterConsumerRewardDenom)) - } - return interceptor(ctx, in, info, handler) -} - var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "interchain_security.ccv.provider.v1.Msg", HandlerType: (*MsgServer)(nil), @@ -343,10 +217,6 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "AssignConsumerKey", Handler: _Msg_AssignConsumerKey_Handler, }, - { - MethodName: "RegisterConsumerRewardDenom", - Handler: _Msg_RegisterConsumerRewardDenom_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "interchain_security/ccv/provider/v1/tx.proto", @@ -419,66 +289,6 @@ func (m *MsgAssignConsumerKeyResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *MsgRegisterConsumerRewardDenom) 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 *MsgRegisterConsumerRewardDenom) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterConsumerRewardDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Depositor) > 0 { - i -= len(m.Depositor) - copy(dAtA[i:], m.Depositor) - i = encodeVarintTx(dAtA, i, uint64(len(m.Depositor))) - i-- - dAtA[i] = 0x12 - } - if len(m.Denom) > 0 { - i -= len(m.Denom) - copy(dAtA[i:], m.Denom) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denom))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgRegisterConsumerRewardDenomResponse) 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 *MsgRegisterConsumerRewardDenomResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgRegisterConsumerRewardDenomResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -520,32 +330,6 @@ func (m *MsgAssignConsumerKeyResponse) Size() (n int) { return n } -func (m *MsgRegisterConsumerRewardDenom) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Denom) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Depositor) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgRegisterConsumerRewardDenomResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -748,170 +532,6 @@ func (m *MsgAssignConsumerKeyResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRegisterConsumerRewardDenom) 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 ErrIntOverflowTx - } - 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: MsgRegisterConsumerRewardDenom: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterConsumerRewardDenom: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Denom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Depositor", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Depositor = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MsgRegisterConsumerRewardDenomResponse) 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 ErrIntOverflowTx - } - 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: MsgRegisterConsumerRewardDenomResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRegisterConsumerRewardDenomResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipTx(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/ccv/types/codec.go b/x/ccv/types/codec.go index d2815ae9b7..3db65608b2 100644 --- a/x/ccv/types/codec.go +++ b/x/ccv/types/codec.go @@ -5,31 +5,12 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" ) -// RegisterLegacyAminoCodec registers the necessary x/ibc transfer interfaces and concrete types -// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { -} - -// RegisterInterfaces register the ibc transfer module interfaces to protobuf -// Any. -func RegisterInterfaces(registry codectypes.InterfaceRegistry) { -} - -var ( - amino = codec.NewLegacyAmino() - - // ModuleCdc references the global x/ibc-transfer module codec. Note, the codec - // should ONLY be used in certain instances of tests and for JSON encoding. - // - // The actual codec used for serialization should be provided to x/ibc transfer and - // defined at the application level. - ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) - - // AminoCdc is a amino codec created to support amino json compatible msgs. - AminoCdc = codec.NewAminoCodec(amino) -) +// ModuleCdc references the global x/ibc-transfer module codec. Note, the codec +// should ONLY be used in certain instances of tests and for JSON encoding. +// +// The actual codec used for serialization should be provided to x/ibc transfer and +// defined at the application level. +var ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) func init() { - RegisterLegacyAminoCodec(amino) - amino.Seal() } diff --git a/x/ccv/types/errors.go b/x/ccv/types/errors.go index 79c0e1e31c..b719e60479 100644 --- a/x/ccv/types/errors.go +++ b/x/ccv/types/errors.go @@ -6,23 +6,14 @@ import ( // CCV sentinel errors var ( - ErrInvalidPacketData = errorsmod.Register(ModuleName, 2, "invalid CCV packet data") - ErrInvalidPacketTimeout = errorsmod.Register(ModuleName, 3, "invalid packet timeout") - ErrInvalidVersion = errorsmod.Register(ModuleName, 4, "invalid CCV version") - ErrInvalidChannelFlow = errorsmod.Register(ModuleName, 5, "invalid message sent to channel end") - ErrInvalidConsumerChain = errorsmod.Register(ModuleName, 6, "invalid consumer chain") - ErrInvalidProviderChain = errorsmod.Register(ModuleName, 7, "invalid provider chain") - ErrInvalidStatus = errorsmod.Register(ModuleName, 8, "invalid channel status") - ErrInvalidGenesis = errorsmod.Register(ModuleName, 9, "invalid genesis state") - ErrDuplicateChannel = errorsmod.Register(ModuleName, 10, "CCV channel already exists") - ErrInvalidVSCMaturedId = errorsmod.Register(ModuleName, 11, "invalid vscId for VSC packet") - ErrInvalidVSCMaturedTime = errorsmod.Register(ModuleName, 12, "invalid maturity time for VSC packet") - ErrInvalidConsumerState = errorsmod.Register(ModuleName, 13, "provider chain has invalid state for consumer chain") - ErrInvalidConsumerClient = errorsmod.Register(ModuleName, 14, "ccv channel is not built on correct client") - ErrInvalidProposal = errorsmod.Register(ModuleName, 15, "invalid proposal") - ErrInvalidHandshakeMetadata = errorsmod.Register(ModuleName, 16, "invalid provider handshake metadata") - ErrChannelNotFound = errorsmod.Register(ModuleName, 17, "channel not found") - ErrClientNotFound = errorsmod.Register(ModuleName, 18, "client not found") - ErrDuplicateConsumerChain = errorsmod.Register(ModuleName, 19, "consumer chain already exists") - ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 20, "consumer chain not found") + ErrInvalidPacketData = errorsmod.Register(ModuleName, 1, "invalid CCV packet data") + ErrInvalidVersion = errorsmod.Register(ModuleName, 2, "invalid CCV version") + ErrInvalidChannelFlow = errorsmod.Register(ModuleName, 3, "invalid message sent to channel end") + ErrInvalidGenesis = errorsmod.Register(ModuleName, 4, "invalid genesis state") + ErrDuplicateChannel = errorsmod.Register(ModuleName, 5, "CCV channel already exists") + ErrInvalidVSCMaturedId = errorsmod.Register(ModuleName, 6, "invalid vscId for VSC packet") + ErrInvalidVSCMaturedTime = errorsmod.Register(ModuleName, 7, "invalid maturity time for VSC packet") + ErrInvalidHandshakeMetadata = errorsmod.Register(ModuleName, 8, "invalid provider handshake metadata") + ErrChannelNotFound = errorsmod.Register(ModuleName, 9, "channel not found") + ErrClientNotFound = errorsmod.Register(ModuleName, 10, "client not found") ) diff --git a/x/ccv/types/events.go b/x/ccv/types/events.go index ba71e063f3..7c7343021e 100644 --- a/x/ccv/types/events.go +++ b/x/ccv/types/events.go @@ -2,44 +2,17 @@ package types // CCV events const ( - EventTypeTimeout = "timeout" - EventTypePacket = "ccv_packet" - EventTypeChannelEstablished = "channel_established" - EventTypeFeeTransferChannelOpened = "fee_transfer_channel_opened" - EventTypeConsumerClientCreated = "consumer_client_created" - EventTypeAssignConsumerKey = "assign_consumer_key" - EventTypeRegisterConsumerRewardDenom = "register_consumer_reward_denom" - - EventTypeExecuteConsumerChainSlash = "execute_consumer_chain_slash" - EventTypeFeeDistribution = "fee_distribution" - EventTypeConsumerSlashRequest = "consumer_slash_request" - EventTypeVSCMatured = "vsc_matured" + EventTypeTimeout = "timeout" + EventTypePacket = "ccv_packet" + EventTypeChannelEstablished = "channel_established" AttributeKeyAckSuccess = "success" AttributeKeyAck = "acknowledgement" AttributeKeyAckError = "error" - AttributeChainID = "chain_id" - AttributeValidatorAddress = "validator_address" - AttributeValidatorConsumerAddress = "validator_consumer_address" - AttributeInfractionType = "infraction_type" - AttributeInfractionHeight = "infraction_height" - AttributeConsumerHeight = "consumer_height" - AttributeValSetUpdateID = "valset_update_id" - AttributeTimestamp = "timestamp" - AttributeInitialHeight = "initial_height" - AttributeInitializationTimeout = "initialization_timeout" - AttributeTrustingPeriod = "trusting_period" - AttributeUnbondingPeriod = "unbonding_period" - AttributeProviderValidatorAddress = "provider_validator_address" - AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key" - - AttributeDistributionCurrentHeight = "current_distribution_height" - AttributeDistributionNextHeight = "next_distribution_height" - AttributeDistributionFraction = "distribution_fraction" - AttributeDistributionTotal = "total" - AttributeDistributionToProvider = "provider_amount" + AttributeChainID = "chain_id" + AttributeValidatorAddress = "validator_address" + AttributeInfractionType = "infraction_type" - AttributeConsumerRewardDenom = "consumer_reward_denom" - AttributeConsumerRewardDepositor = "consumer_reward_depositor" + AttributeValSetUpdateID = "valset_update_id" ) diff --git a/x/ccv/types/genesis.go b/x/ccv/types/genesis.go new file mode 100644 index 0000000000..4189c2ec51 --- /dev/null +++ b/x/ccv/types/genesis.go @@ -0,0 +1,62 @@ +package types + +import ( + ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + + errorsmod "cosmossdk.io/errors" + + abci "github.com/cometbft/cometbft/abci/types" +) + +// NewInitialConsumerGenesisState returns a ConsumerGenesisState for a completely new consumer chain. +func NewInitialConsumerGenesisState(cs *ibctmtypes.ClientState, consState *ibctmtypes.ConsensusState, + initValSet []abci.ValidatorUpdate, params ConsumerParams, +) *ConsumerGenesisState { + return &ConsumerGenesisState{ + NewChain: true, + Params: params, + Provider: ProviderInfo{ + ClientState: cs, + ConsensusState: consState, + InitialValSet: initValSet, + }, + } +} + +// DefaultConsumerGenesisState returns a default disabled consumer chain genesis state. This allows the module to be hooked up to app without getting use +// unless explicitly specified in genesis. +func DefaultConsumerGenesisState() *ConsumerGenesisState { + return &ConsumerGenesisState{ + Params: DefaultParams(), + } +} + +func (gs ConsumerGenesisState) Validate() error { + if !gs.Params.Enabled { + return nil + } + if len(gs.Provider.InitialValSet) == 0 { + return errorsmod.Wrap(ErrInvalidGenesis, "initial validator set is empty") + } + if err := gs.Params.Validate(); err != nil { + return err + } + + if gs.NewChain { + if gs.Provider.ClientState == nil { + return errorsmod.Wrap(ErrInvalidGenesis, "provider client state cannot be nil for new chain") + } + if err := gs.Provider.ClientState.Validate(); err != nil { + return errorsmod.Wrapf(ErrInvalidGenesis, "provider client state invalid for new chain %s", err.Error()) + } + if gs.Provider.ConsensusState == nil { + return errorsmod.Wrap(ErrInvalidGenesis, "provider consensus state cannot be nil for new chain") + } + if err := gs.Provider.ConsensusState.ValidateBasic(); err != nil { + return errorsmod.Wrapf(ErrInvalidGenesis, "provider consensus state invalid for new chain %s", err.Error()) + } + } else if gs.Provider.ClientState != nil || gs.Provider.ConsensusState != nil { + return errorsmod.Wrap(ErrInvalidGenesis, "provider client state and consensus state must be nil for a restarting genesis state") + } + return nil +} diff --git a/x/ccv/consumer/types/params.go b/x/ccv/types/params.go similarity index 77% rename from x/ccv/consumer/types/params.go rename to x/ccv/types/params.go index a9b4e61285..c80e353d66 100644 --- a/x/ccv/consumer/types/params.go +++ b/x/ccv/types/params.go @@ -7,8 +7,6 @@ import ( sdktypes "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types" ) const ( @@ -34,13 +32,16 @@ const ( // (and for consistency with other protobuf schemas defined for ccv). DefaultHistoricalEntries = int64(stakingtypes.DefaultHistoricalEntries) - // In general, the default unbonding period on the consumer is one day less + // In general, the default unbonding period on the consumer is one week less // than the default unbonding period on the provider, where the provider uses // the staking module default. - DefaultConsumerUnbondingPeriod = stakingtypes.DefaultUnbondingTime - 24*time.Hour + DefaultConsumerUnbondingPeriod = stakingtypes.DefaultUnbondingTime - 7*24*time.Hour // By default, the bottom 5% of the validator set can opt out of validating consumer chains DefaultSoftOptOutThreshold = "0.05" + + // Default retry delay period is 1 hour. + DefaultRetryDelayPeriod = time.Hour ) // Reflection based keys for params subspace @@ -56,11 +57,12 @@ var ( KeySoftOptOutThreshold = []byte("SoftOptOutThreshold") KeyRewardDenoms = []byte("RewardDenoms") KeyProviderRewardDenoms = []byte("ProviderRewardDenoms") + KeyRetryDelayPeriod = []byte("RetryDelayPeriod") ) // ParamKeyTable type declaration for parameters func ParamKeyTable() paramtypes.KeyTable { - return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) + return paramtypes.NewKeyTable().RegisterParamSet(&ConsumerParams{}) } // NewParams creates new consumer parameters with provided arguments @@ -68,9 +70,10 @@ func NewParams(enabled bool, blocksPerDistributionTransmission int64, distributionTransmissionChannel, providerFeePoolAddrStr string, ccvTimeoutPeriod, transferTimeoutPeriod time.Duration, consumerRedistributionFraction string, historicalEntries int64, - consumerUnbondingPeriod time.Duration, softOptOutThreshold string, rewardDenoms, providerRewardDenoms []string, -) Params { - return Params{ + consumerUnbondingPeriod time.Duration, softOptOutThreshold string, + rewardDenoms, providerRewardDenoms []string, retryDelayPeriod time.Duration, +) ConsumerParams { + return ConsumerParams{ Enabled: enabled, BlocksPerDistributionTransmission: blocksPerDistributionTransmission, DistributionTransmissionChannel: distributionTransmissionChannel, @@ -83,11 +86,12 @@ func NewParams(enabled bool, blocksPerDistributionTransmission int64, SoftOptOutThreshold: softOptOutThreshold, RewardDenoms: rewardDenoms, ProviderRewardDenoms: providerRewardDenoms, + RetryDelayPeriod: retryDelayPeriod, } } // DefaultParams is the default params for the consumer module -func DefaultParams() Params { +func DefaultParams() ConsumerParams { var rewardDenoms []string var provideRewardDenoms []string return NewParams( @@ -95,7 +99,7 @@ func DefaultParams() Params { DefaultBlocksPerDistributionTransmission, "", "", - ccvtypes.DefaultCCVTimeoutPeriod, + DefaultCCVTimeoutPeriod, DefaultTransferTimeoutPeriod, DefaultConsumerRedistributeFrac, DefaultHistoricalEntries, @@ -103,36 +107,37 @@ func DefaultParams() Params { DefaultSoftOptOutThreshold, rewardDenoms, provideRewardDenoms, + DefaultRetryDelayPeriod, ) } // Validate all ccv-consumer module parameters -func (p Params) Validate() error { - if err := ccvtypes.ValidateBool(p.Enabled); err != nil { +func (p ConsumerParams) Validate() error { + if err := ValidateBool(p.Enabled); err != nil { return err } - if err := ccvtypes.ValidatePositiveInt64(p.BlocksPerDistributionTransmission); err != nil { + if err := ValidatePositiveInt64(p.BlocksPerDistributionTransmission); err != nil { return err } - if err := ccvtypes.ValidateDistributionTransmissionChannel(p.DistributionTransmissionChannel); err != nil { + if err := ValidateDistributionTransmissionChannel(p.DistributionTransmissionChannel); err != nil { return err } if err := ValidateProviderFeePoolAddrStr(p.ProviderFeePoolAddrStr); err != nil { return err } - if err := ccvtypes.ValidateDuration(p.CcvTimeoutPeriod); err != nil { + if err := ValidateDuration(p.CcvTimeoutPeriod); err != nil { return err } - if err := ccvtypes.ValidateDuration(p.TransferTimeoutPeriod); err != nil { + if err := ValidateDuration(p.TransferTimeoutPeriod); err != nil { return err } - if err := ccvtypes.ValidateStringFraction(p.ConsumerRedistributionFraction); err != nil { + if err := ValidateStringFraction(p.ConsumerRedistributionFraction); err != nil { return err } - if err := ccvtypes.ValidatePositiveInt64(p.HistoricalEntries); err != nil { + if err := ValidatePositiveInt64(p.HistoricalEntries); err != nil { return err } - if err := ccvtypes.ValidateDuration(p.UnbondingPeriod); err != nil { + if err := ValidateDuration(p.UnbondingPeriod); err != nil { return err } if err := ValidateSoftOptOutThreshold(p.SoftOptOutThreshold); err != nil { @@ -144,35 +149,40 @@ func (p Params) Validate() error { if err := ValidateDenoms(p.ProviderRewardDenoms); err != nil { return err } + if err := ValidateDuration(p.RetryDelayPeriod); err != nil { + return err + } return nil } // ParamSetPairs implements params.ParamSet -func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { +func (p *ConsumerParams) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyEnabled, p.Enabled, ccvtypes.ValidateBool), + paramtypes.NewParamSetPair(KeyEnabled, p.Enabled, ValidateBool), paramtypes.NewParamSetPair(KeyBlocksPerDistributionTransmission, - p.BlocksPerDistributionTransmission, ccvtypes.ValidatePositiveInt64), + p.BlocksPerDistributionTransmission, ValidatePositiveInt64), paramtypes.NewParamSetPair(KeyDistributionTransmissionChannel, - p.DistributionTransmissionChannel, ccvtypes.ValidateDistributionTransmissionChannel), + p.DistributionTransmissionChannel, ValidateDistributionTransmissionChannel), paramtypes.NewParamSetPair(KeyProviderFeePoolAddrStr, p.ProviderFeePoolAddrStr, ValidateProviderFeePoolAddrStr), - paramtypes.NewParamSetPair(ccvtypes.KeyCCVTimeoutPeriod, - p.CcvTimeoutPeriod, ccvtypes.ValidateDuration), + paramtypes.NewParamSetPair(KeyCCVTimeoutPeriod, + p.CcvTimeoutPeriod, ValidateDuration), paramtypes.NewParamSetPair(KeyTransferTimeoutPeriod, - p.TransferTimeoutPeriod, ccvtypes.ValidateDuration), + p.TransferTimeoutPeriod, ValidateDuration), paramtypes.NewParamSetPair(KeyConsumerRedistributionFrac, - p.ConsumerRedistributionFraction, ccvtypes.ValidateStringFraction), + p.ConsumerRedistributionFraction, ValidateStringFraction), paramtypes.NewParamSetPair(KeyHistoricalEntries, - p.HistoricalEntries, ccvtypes.ValidatePositiveInt64), + p.HistoricalEntries, ValidatePositiveInt64), paramtypes.NewParamSetPair(KeyConsumerUnbondingPeriod, - p.UnbondingPeriod, ccvtypes.ValidateDuration), + p.UnbondingPeriod, ValidateDuration), paramtypes.NewParamSetPair(KeySoftOptOutThreshold, p.SoftOptOutThreshold, ValidateSoftOptOutThreshold), paramtypes.NewParamSetPair(KeyRewardDenoms, p.RewardDenoms, ValidateDenoms), paramtypes.NewParamSetPair(KeyProviderRewardDenoms, p.ProviderRewardDenoms, ValidateDenoms), + paramtypes.NewParamSetPair(KeyRetryDelayPeriod, + p.RetryDelayPeriod, ValidateDuration), } } @@ -181,8 +191,8 @@ func ValidateProviderFeePoolAddrStr(i interface{}) error { if i == "" { return nil } - // Otherwise validate as usual for a bech32 address - return ccvtypes.ValidateBech32(i) + // Cannot validate provider chain address on the consumer chain + return nil } func ValidateSoftOptOutThreshold(i interface{}) error { diff --git a/x/ccv/types/shared_consumer.pb.go b/x/ccv/types/shared_consumer.pb.go new file mode 100644 index 0000000000..699f9ac52d --- /dev/null +++ b/x/ccv/types/shared_consumer.pb.go @@ -0,0 +1,1552 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: interchain_security/ccv/v1/shared_consumer.proto + +package types + +import ( + fmt "fmt" + types "github.com/cometbft/cometbft/abci/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + github_com_cosmos_gogoproto_types "github.com/cosmos/gogoproto/types" + _07_tendermint "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + _ "google.golang.org/protobuf/types/known/durationpb" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// 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 + +// ConsumerParams defines the parameters for CCV consumer module. +// +// Note this type is referenced in both the consumer and provider CCV modules, +// and persisted on the provider, see MakeConsumerGenesis and +// SetConsumerGenesis. +type ConsumerParams struct { + // TODO: Remove enabled flag and find a better way to setup integration tests + // See: https://github.com/cosmos/interchain-security/issues/339 + Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` + /////////////////////// + // Distribution Params + // Number of blocks between ibc-token-transfers from the consumer chain to + // the provider chain. Note that at this transmission event a fraction of + // the accumulated tokens are divided and sent consumer redistribution + // address. + BlocksPerDistributionTransmission int64 `protobuf:"varint,2,opt,name=blocks_per_distribution_transmission,json=blocksPerDistributionTransmission,proto3" json:"blocks_per_distribution_transmission,omitempty"` + // Channel, and provider-chain receiving address to send distribution token + // transfers over. These parameters is auto-set during the consumer <-> + // provider handshake procedure. + DistributionTransmissionChannel string `protobuf:"bytes,3,opt,name=distribution_transmission_channel,json=distributionTransmissionChannel,proto3" json:"distribution_transmission_channel,omitempty"` + ProviderFeePoolAddrStr string `protobuf:"bytes,4,opt,name=provider_fee_pool_addr_str,json=providerFeePoolAddrStr,proto3" json:"provider_fee_pool_addr_str,omitempty"` + // Sent CCV related IBC packets will timeout after this duration + CcvTimeoutPeriod time.Duration `protobuf:"bytes,5,opt,name=ccv_timeout_period,json=ccvTimeoutPeriod,proto3,stdduration" json:"ccv_timeout_period"` + // Sent transfer related IBC packets will timeout after this duration + TransferTimeoutPeriod time.Duration `protobuf:"bytes,6,opt,name=transfer_timeout_period,json=transferTimeoutPeriod,proto3,stdduration" json:"transfer_timeout_period"` + // The fraction of tokens allocated to the consumer redistribution address + // during distribution events. The fraction is a string representing a + // decimal number. For example "0.75" would represent 75%. + ConsumerRedistributionFraction string `protobuf:"bytes,7,opt,name=consumer_redistribution_fraction,json=consumerRedistributionFraction,proto3" json:"consumer_redistribution_fraction,omitempty"` + // The number of historical info entries to persist in store. + // This param is a part of the cosmos sdk staking module. In the case of + // a ccv enabled consumer chain, the ccv module acts as the staking module. + HistoricalEntries int64 `protobuf:"varint,8,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty"` + // Unbonding period for the consumer, + // which should be smaller than that of the provider in general. + UnbondingPeriod time.Duration `protobuf:"bytes,9,opt,name=unbonding_period,json=unbondingPeriod,proto3,stdduration" json:"unbonding_period"` + // The threshold for the percentage of validators at the bottom of the set who + // can opt out of running the consumer chain without being punished. For + // example, a value of 0.05 means that the validators in the bottom 5% of the + // set can opt out + SoftOptOutThreshold string `protobuf:"bytes,10,opt,name=soft_opt_out_threshold,json=softOptOutThreshold,proto3" json:"soft_opt_out_threshold,omitempty"` + // Reward denoms. These are the denominations which are allowed to be sent to + // the provider as rewards. + RewardDenoms []string `protobuf:"bytes,11,rep,name=reward_denoms,json=rewardDenoms,proto3" json:"reward_denoms,omitempty"` + // Provider-originated reward denoms. These are denoms coming from the + // provider which are allowed to be used as rewards. e.g. "uatom" + ProviderRewardDenoms []string `protobuf:"bytes,12,rep,name=provider_reward_denoms,json=providerRewardDenoms,proto3" json:"provider_reward_denoms,omitempty"` + // The period after which a consumer can retry sending a throttled packet. + RetryDelayPeriod time.Duration `protobuf:"bytes,13,opt,name=retry_delay_period,json=retryDelayPeriod,proto3,stdduration" json:"retry_delay_period"` +} + +func (m *ConsumerParams) Reset() { *m = ConsumerParams{} } +func (m *ConsumerParams) String() string { return proto.CompactTextString(m) } +func (*ConsumerParams) ProtoMessage() {} +func (*ConsumerParams) Descriptor() ([]byte, []int) { + return fileDescriptor_d0a8be0efc64dfbc, []int{0} +} +func (m *ConsumerParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsumerParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsumerParams.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 *ConsumerParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsumerParams.Merge(m, src) +} +func (m *ConsumerParams) XXX_Size() int { + return m.Size() +} +func (m *ConsumerParams) XXX_DiscardUnknown() { + xxx_messageInfo_ConsumerParams.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsumerParams proto.InternalMessageInfo + +func (m *ConsumerParams) GetEnabled() bool { + if m != nil { + return m.Enabled + } + return false +} + +func (m *ConsumerParams) GetBlocksPerDistributionTransmission() int64 { + if m != nil { + return m.BlocksPerDistributionTransmission + } + return 0 +} + +func (m *ConsumerParams) GetDistributionTransmissionChannel() string { + if m != nil { + return m.DistributionTransmissionChannel + } + return "" +} + +func (m *ConsumerParams) GetProviderFeePoolAddrStr() string { + if m != nil { + return m.ProviderFeePoolAddrStr + } + return "" +} + +func (m *ConsumerParams) GetCcvTimeoutPeriod() time.Duration { + if m != nil { + return m.CcvTimeoutPeriod + } + return 0 +} + +func (m *ConsumerParams) GetTransferTimeoutPeriod() time.Duration { + if m != nil { + return m.TransferTimeoutPeriod + } + return 0 +} + +func (m *ConsumerParams) GetConsumerRedistributionFraction() string { + if m != nil { + return m.ConsumerRedistributionFraction + } + return "" +} + +func (m *ConsumerParams) GetHistoricalEntries() int64 { + if m != nil { + return m.HistoricalEntries + } + return 0 +} + +func (m *ConsumerParams) GetUnbondingPeriod() time.Duration { + if m != nil { + return m.UnbondingPeriod + } + return 0 +} + +func (m *ConsumerParams) GetSoftOptOutThreshold() string { + if m != nil { + return m.SoftOptOutThreshold + } + return "" +} + +func (m *ConsumerParams) GetRewardDenoms() []string { + if m != nil { + return m.RewardDenoms + } + return nil +} + +func (m *ConsumerParams) GetProviderRewardDenoms() []string { + if m != nil { + return m.ProviderRewardDenoms + } + return nil +} + +func (m *ConsumerParams) GetRetryDelayPeriod() time.Duration { + if m != nil { + return m.RetryDelayPeriod + } + return 0 +} + +// ConsumerGenesisState defines shared genesis information between provider and +// consumer +type ConsumerGenesisState struct { + Params ConsumerParams `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Provider ProviderInfo `protobuf:"bytes,2,opt,name=provider,proto3" json:"provider"` + // true for new chain, false for chain restart. + NewChain bool `protobuf:"varint,3,opt,name=new_chain,json=newChain,proto3" json:"new_chain,omitempty"` +} + +func (m *ConsumerGenesisState) Reset() { *m = ConsumerGenesisState{} } +func (m *ConsumerGenesisState) String() string { return proto.CompactTextString(m) } +func (*ConsumerGenesisState) ProtoMessage() {} +func (*ConsumerGenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_d0a8be0efc64dfbc, []int{1} +} +func (m *ConsumerGenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsumerGenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsumerGenesisState.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 *ConsumerGenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsumerGenesisState.Merge(m, src) +} +func (m *ConsumerGenesisState) XXX_Size() int { + return m.Size() +} +func (m *ConsumerGenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_ConsumerGenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsumerGenesisState proto.InternalMessageInfo + +func (m *ConsumerGenesisState) GetParams() ConsumerParams { + if m != nil { + return m.Params + } + return ConsumerParams{} +} + +func (m *ConsumerGenesisState) GetProvider() ProviderInfo { + if m != nil { + return m.Provider + } + return ProviderInfo{} +} + +func (m *ConsumerGenesisState) GetNewChain() bool { + if m != nil { + return m.NewChain + } + return false +} + +// ProviderInfo defines all information a consumer needs from a provider +// Shared data type between provider and consumer +type ProviderInfo struct { + // ProviderClientState filled in on new chain, nil on restart. + ClientState *_07_tendermint.ClientState `protobuf:"bytes,1,opt,name=client_state,json=clientState,proto3" json:"client_state,omitempty"` + // ProviderConsensusState filled in on new chain, nil on restart. + ConsensusState *_07_tendermint.ConsensusState `protobuf:"bytes,2,opt,name=consensus_state,json=consensusState,proto3" json:"consensus_state,omitempty"` + // InitialValset filled in on new chain and on restart. + InitialValSet []types.ValidatorUpdate `protobuf:"bytes,3,rep,name=initial_val_set,json=initialValSet,proto3" json:"initial_val_set"` +} + +func (m *ProviderInfo) Reset() { *m = ProviderInfo{} } +func (m *ProviderInfo) String() string { return proto.CompactTextString(m) } +func (*ProviderInfo) ProtoMessage() {} +func (*ProviderInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_d0a8be0efc64dfbc, []int{2} +} +func (m *ProviderInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ProviderInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ProviderInfo.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 *ProviderInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ProviderInfo.Merge(m, src) +} +func (m *ProviderInfo) XXX_Size() int { + return m.Size() +} +func (m *ProviderInfo) XXX_DiscardUnknown() { + xxx_messageInfo_ProviderInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_ProviderInfo proto.InternalMessageInfo + +func (m *ProviderInfo) GetClientState() *_07_tendermint.ClientState { + if m != nil { + return m.ClientState + } + return nil +} + +func (m *ProviderInfo) GetConsensusState() *_07_tendermint.ConsensusState { + if m != nil { + return m.ConsensusState + } + return nil +} + +func (m *ProviderInfo) GetInitialValSet() []types.ValidatorUpdate { + if m != nil { + return m.InitialValSet + } + return nil +} + +func init() { + proto.RegisterType((*ConsumerParams)(nil), "interchain_security.ccv.v1.ConsumerParams") + proto.RegisterType((*ConsumerGenesisState)(nil), "interchain_security.ccv.v1.ConsumerGenesisState") + proto.RegisterType((*ProviderInfo)(nil), "interchain_security.ccv.v1.ProviderInfo") +} + +func init() { + proto.RegisterFile("interchain_security/ccv/v1/shared_consumer.proto", fileDescriptor_d0a8be0efc64dfbc) +} + +var fileDescriptor_d0a8be0efc64dfbc = []byte{ + // 812 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x41, 0x73, 0xdc, 0x34, + 0x14, 0x8e, 0xbb, 0x25, 0xdd, 0x68, 0x93, 0xa6, 0x88, 0x50, 0x4c, 0x3a, 0xb3, 0x71, 0x03, 0x87, + 0x1d, 0x98, 0xda, 0x24, 0xe9, 0x89, 0x1b, 0x49, 0x28, 0xa5, 0x87, 0x64, 0xeb, 0x84, 0x32, 0x03, + 0x07, 0x8d, 0x2c, 0xbd, 0x5d, 0x6b, 0xb0, 0x25, 0x8f, 0x24, 0x3b, 0xe4, 0x17, 0x70, 0xe5, 0xc8, + 0x4f, 0x2a, 0xb7, 0x1e, 0x39, 0x51, 0x26, 0xf9, 0x23, 0x8c, 0x65, 0x3b, 0xf1, 0x32, 0x04, 0xd2, + 0x9b, 0x9e, 0xde, 0xf7, 0x7d, 0xf6, 0xf7, 0xa4, 0xf7, 0x84, 0xbe, 0x10, 0xd2, 0x82, 0x66, 0x29, + 0x15, 0x92, 0x18, 0x60, 0xa5, 0x16, 0xf6, 0x3c, 0x62, 0xac, 0x8a, 0xaa, 0x9d, 0xc8, 0xa4, 0x54, + 0x03, 0x27, 0x4c, 0x49, 0x53, 0xe6, 0xa0, 0xc3, 0x42, 0x2b, 0xab, 0xf0, 0xe6, 0xbf, 0x30, 0x42, + 0xc6, 0xaa, 0xb0, 0xda, 0xd9, 0x7c, 0x64, 0x41, 0x72, 0xd0, 0xb9, 0x90, 0x36, 0xa2, 0x09, 0x13, + 0x91, 0x3d, 0x2f, 0xc0, 0x34, 0xc4, 0xcd, 0x48, 0x24, 0x2c, 0xca, 0xc4, 0x3c, 0xb5, 0x2c, 0x13, + 0x20, 0xad, 0x89, 0x7a, 0xe8, 0x6a, 0xa7, 0x17, 0xb5, 0x84, 0xf1, 0x5c, 0xa9, 0x79, 0x06, 0x91, + 0x8b, 0x92, 0x72, 0x16, 0xf1, 0x52, 0x53, 0x2b, 0x94, 0x6c, 0xf3, 0x1b, 0x73, 0x35, 0x57, 0x6e, + 0x19, 0xd5, 0xab, 0x66, 0x77, 0xfb, 0xed, 0x32, 0xba, 0x7f, 0xd0, 0xfe, 0xf2, 0x94, 0x6a, 0x9a, + 0x1b, 0xec, 0xa3, 0x7b, 0x20, 0x69, 0x92, 0x01, 0xf7, 0xbd, 0xc0, 0x9b, 0x0c, 0xe3, 0x2e, 0xc4, + 0xc7, 0xe8, 0xd3, 0x24, 0x53, 0xec, 0x27, 0x43, 0x0a, 0xd0, 0x84, 0x0b, 0x63, 0xb5, 0x48, 0xca, + 0xfa, 0x1b, 0xc4, 0x6a, 0x2a, 0x4d, 0x2e, 0x8c, 0x11, 0x4a, 0xfa, 0x77, 0x02, 0x6f, 0x32, 0x88, + 0x1f, 0x37, 0xd8, 0x29, 0xe8, 0xc3, 0x1e, 0xf2, 0xb4, 0x07, 0xc4, 0x2f, 0xd0, 0xe3, 0x1b, 0x55, + 0x08, 0x4b, 0xa9, 0x94, 0x90, 0xf9, 0x83, 0xc0, 0x9b, 0xac, 0xc4, 0x5b, 0xfc, 0x06, 0x91, 0x83, + 0x06, 0x86, 0xbf, 0x44, 0x9b, 0x85, 0x56, 0x95, 0xe0, 0xa0, 0xc9, 0x0c, 0x80, 0x14, 0x4a, 0x65, + 0x84, 0x72, 0xae, 0x89, 0xb1, 0xda, 0xbf, 0xeb, 0x44, 0x1e, 0x76, 0x88, 0x67, 0x00, 0x53, 0xa5, + 0xb2, 0xaf, 0x38, 0xd7, 0x27, 0x56, 0xe3, 0x97, 0x08, 0x33, 0x56, 0x11, 0x2b, 0x72, 0x50, 0xa5, + 0xad, 0xdd, 0x09, 0xc5, 0xfd, 0xf7, 0x02, 0x6f, 0x32, 0xda, 0xfd, 0x38, 0x6c, 0x0a, 0x1b, 0x76, + 0x85, 0x0d, 0x0f, 0xdb, 0xc2, 0xee, 0x0f, 0x5f, 0xff, 0xb9, 0xb5, 0xf4, 0xdb, 0xdb, 0x2d, 0x2f, + 0x7e, 0xc0, 0x58, 0x75, 0xda, 0xb0, 0xa7, 0x8e, 0x8c, 0x7f, 0x44, 0x1f, 0x39, 0x37, 0x33, 0xd0, + 0xff, 0xd4, 0x5d, 0xbe, 0xbd, 0xee, 0x87, 0x9d, 0xc6, 0xa2, 0xf8, 0x73, 0x14, 0x74, 0xf7, 0x8c, + 0x68, 0x58, 0x28, 0xe1, 0x4c, 0x53, 0x56, 0x2f, 0xfc, 0x7b, 0xce, 0xf1, 0xb8, 0xc3, 0xc5, 0x0b, + 0xb0, 0x67, 0x2d, 0x0a, 0x3f, 0x41, 0x38, 0x15, 0xc6, 0x2a, 0x2d, 0x18, 0xcd, 0x08, 0x48, 0xab, + 0x05, 0x18, 0x7f, 0xe8, 0x0e, 0xf0, 0xfd, 0xeb, 0xcc, 0xd7, 0x4d, 0x02, 0x1f, 0xa1, 0x07, 0xa5, + 0x4c, 0x94, 0xe4, 0x42, 0xce, 0x3b, 0x3b, 0x2b, 0xb7, 0xb7, 0xb3, 0x7e, 0x45, 0x6e, 0x8d, 0xec, + 0xa1, 0x87, 0x46, 0xcd, 0x2c, 0x51, 0x85, 0x25, 0x75, 0x85, 0x6c, 0xaa, 0xc1, 0xa4, 0x2a, 0xe3, + 0x3e, 0x72, 0xbf, 0xff, 0x41, 0x9d, 0x3d, 0x2e, 0xec, 0x71, 0x69, 0x4f, 0xbb, 0x14, 0xfe, 0x04, + 0xad, 0x69, 0x38, 0xa3, 0x9a, 0x13, 0x0e, 0x52, 0xe5, 0xc6, 0x1f, 0x05, 0x83, 0xc9, 0x4a, 0xbc, + 0xda, 0x6c, 0x1e, 0xba, 0x3d, 0xfc, 0x14, 0x5d, 0x1d, 0x36, 0x59, 0x44, 0xaf, 0x3a, 0xf4, 0x46, + 0x97, 0x8d, 0xfb, 0xac, 0x97, 0x08, 0x6b, 0xb0, 0xfa, 0x9c, 0x70, 0xc8, 0xe8, 0x79, 0xe7, 0x70, + 0xed, 0x1d, 0x2e, 0x82, 0xa3, 0x1f, 0xd6, 0xec, 0xc6, 0xe2, 0xf6, 0xef, 0x1e, 0xda, 0xe8, 0x3a, + 0xec, 0x1b, 0x90, 0x60, 0x84, 0x39, 0xb1, 0xd4, 0x02, 0x7e, 0x8e, 0x96, 0x0b, 0xd7, 0x71, 0xae, + 0xcd, 0x46, 0xbb, 0x9f, 0x85, 0x37, 0xcf, 0x8a, 0x70, 0xb1, 0x47, 0xf7, 0xef, 0xd6, 0x1f, 0x8c, + 0x5b, 0x3e, 0x7e, 0x81, 0x86, 0x9d, 0x1b, 0xd7, 0x7b, 0xa3, 0xdd, 0xc9, 0x7f, 0x69, 0x4d, 0x5b, + 0xec, 0xb7, 0x72, 0xa6, 0x5a, 0xa5, 0x2b, 0x3e, 0x7e, 0x84, 0x56, 0x24, 0x9c, 0x11, 0xc7, 0x74, + 0xad, 0x37, 0x8c, 0x87, 0x12, 0xce, 0x0e, 0xea, 0x78, 0xfb, 0x97, 0x3b, 0x68, 0xb5, 0xcf, 0xc6, + 0x47, 0x68, 0xb5, 0x19, 0x4f, 0xc4, 0xd4, 0x9e, 0x5a, 0x27, 0x9f, 0x87, 0x22, 0x61, 0x61, 0x7f, + 0x78, 0x85, 0xbd, 0x71, 0x55, 0xbb, 0x71, 0xbb, 0xae, 0x0c, 0xf1, 0x88, 0x5d, 0x07, 0xf8, 0x7b, + 0xb4, 0x5e, 0x5f, 0x58, 0x90, 0xa6, 0x34, 0xad, 0x64, 0x63, 0x28, 0xfc, 0x5f, 0xc9, 0x8e, 0xd6, + 0xa8, 0xde, 0x67, 0x0b, 0x31, 0x3e, 0x42, 0xeb, 0x42, 0x0a, 0x2b, 0x68, 0x46, 0x2a, 0x9a, 0x11, + 0x03, 0xd6, 0x1f, 0x04, 0x83, 0xc9, 0x68, 0x37, 0xe8, 0xeb, 0xd4, 0x53, 0x38, 0x7c, 0x45, 0x33, + 0xc1, 0xa9, 0x55, 0xfa, 0xbb, 0x82, 0x53, 0x0b, 0x6d, 0x85, 0xd6, 0x5a, 0xfa, 0x2b, 0x9a, 0x9d, + 0x80, 0xdd, 0x3f, 0x7a, 0x7d, 0x31, 0xf6, 0xde, 0x5c, 0x8c, 0xbd, 0xbf, 0x2e, 0xc6, 0xde, 0xaf, + 0x97, 0xe3, 0xa5, 0x37, 0x97, 0xe3, 0xa5, 0x3f, 0x2e, 0xc7, 0x4b, 0x3f, 0x3c, 0x9d, 0x0b, 0x9b, + 0x96, 0x49, 0xc8, 0x54, 0x1e, 0x31, 0x65, 0x72, 0x65, 0xa2, 0xeb, 0xb3, 0x78, 0x72, 0xf5, 0x6a, + 0x54, 0x7b, 0xd1, 0xcf, 0xee, 0xe9, 0x70, 0x43, 0x3f, 0x59, 0x76, 0x97, 0x6a, 0xef, 0xef, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x5c, 0xb4, 0xca, 0xd3, 0x62, 0x06, 0x00, 0x00, +} + +func (m *ConsumerParams) 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 *ConsumerParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.RetryDelayPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RetryDelayPeriod):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintSharedConsumer(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x6a + if len(m.ProviderRewardDenoms) > 0 { + for iNdEx := len(m.ProviderRewardDenoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.ProviderRewardDenoms[iNdEx]) + copy(dAtA[i:], m.ProviderRewardDenoms[iNdEx]) + i = encodeVarintSharedConsumer(dAtA, i, uint64(len(m.ProviderRewardDenoms[iNdEx]))) + i-- + dAtA[i] = 0x62 + } + } + if len(m.RewardDenoms) > 0 { + for iNdEx := len(m.RewardDenoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.RewardDenoms[iNdEx]) + copy(dAtA[i:], m.RewardDenoms[iNdEx]) + i = encodeVarintSharedConsumer(dAtA, i, uint64(len(m.RewardDenoms[iNdEx]))) + i-- + dAtA[i] = 0x5a + } + } + if len(m.SoftOptOutThreshold) > 0 { + i -= len(m.SoftOptOutThreshold) + copy(dAtA[i:], m.SoftOptOutThreshold) + i = encodeVarintSharedConsumer(dAtA, i, uint64(len(m.SoftOptOutThreshold))) + i-- + dAtA[i] = 0x52 + } + n2, err2 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintSharedConsumer(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x4a + if m.HistoricalEntries != 0 { + i = encodeVarintSharedConsumer(dAtA, i, uint64(m.HistoricalEntries)) + i-- + dAtA[i] = 0x40 + } + if len(m.ConsumerRedistributionFraction) > 0 { + i -= len(m.ConsumerRedistributionFraction) + copy(dAtA[i:], m.ConsumerRedistributionFraction) + i = encodeVarintSharedConsumer(dAtA, i, uint64(len(m.ConsumerRedistributionFraction))) + i-- + dAtA[i] = 0x3a + } + n3, err3 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.TransferTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintSharedConsumer(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0x32 + n4, err4 := github_com_cosmos_gogoproto_types.StdDurationMarshalTo(m.CcvTimeoutPeriod, dAtA[i-github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintSharedConsumer(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x2a + if len(m.ProviderFeePoolAddrStr) > 0 { + i -= len(m.ProviderFeePoolAddrStr) + copy(dAtA[i:], m.ProviderFeePoolAddrStr) + i = encodeVarintSharedConsumer(dAtA, i, uint64(len(m.ProviderFeePoolAddrStr))) + i-- + dAtA[i] = 0x22 + } + if len(m.DistributionTransmissionChannel) > 0 { + i -= len(m.DistributionTransmissionChannel) + copy(dAtA[i:], m.DistributionTransmissionChannel) + i = encodeVarintSharedConsumer(dAtA, i, uint64(len(m.DistributionTransmissionChannel))) + i-- + dAtA[i] = 0x1a + } + if m.BlocksPerDistributionTransmission != 0 { + i = encodeVarintSharedConsumer(dAtA, i, uint64(m.BlocksPerDistributionTransmission)) + i-- + dAtA[i] = 0x10 + } + if m.Enabled { + i-- + if m.Enabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ConsumerGenesisState) 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 *ConsumerGenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerGenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.NewChain { + i-- + if m.NewChain { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + { + size, err := m.Provider.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSharedConsumer(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSharedConsumer(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *ProviderInfo) 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 *ProviderInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ProviderInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.InitialValSet) > 0 { + for iNdEx := len(m.InitialValSet) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.InitialValSet[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSharedConsumer(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.ConsensusState != nil { + { + size, err := m.ConsensusState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSharedConsumer(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.ClientState != nil { + { + size, err := m.ClientState.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSharedConsumer(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintSharedConsumer(dAtA []byte, offset int, v uint64) int { + offset -= sovSharedConsumer(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ConsumerParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Enabled { + n += 2 + } + if m.BlocksPerDistributionTransmission != 0 { + n += 1 + sovSharedConsumer(uint64(m.BlocksPerDistributionTransmission)) + } + l = len(m.DistributionTransmissionChannel) + if l > 0 { + n += 1 + l + sovSharedConsumer(uint64(l)) + } + l = len(m.ProviderFeePoolAddrStr) + if l > 0 { + n += 1 + l + sovSharedConsumer(uint64(l)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.CcvTimeoutPeriod) + n += 1 + l + sovSharedConsumer(uint64(l)) + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.TransferTimeoutPeriod) + n += 1 + l + sovSharedConsumer(uint64(l)) + l = len(m.ConsumerRedistributionFraction) + if l > 0 { + n += 1 + l + sovSharedConsumer(uint64(l)) + } + if m.HistoricalEntries != 0 { + n += 1 + sovSharedConsumer(uint64(m.HistoricalEntries)) + } + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.UnbondingPeriod) + n += 1 + l + sovSharedConsumer(uint64(l)) + l = len(m.SoftOptOutThreshold) + if l > 0 { + n += 1 + l + sovSharedConsumer(uint64(l)) + } + if len(m.RewardDenoms) > 0 { + for _, s := range m.RewardDenoms { + l = len(s) + n += 1 + l + sovSharedConsumer(uint64(l)) + } + } + if len(m.ProviderRewardDenoms) > 0 { + for _, s := range m.ProviderRewardDenoms { + l = len(s) + n += 1 + l + sovSharedConsumer(uint64(l)) + } + } + l = github_com_cosmos_gogoproto_types.SizeOfStdDuration(m.RetryDelayPeriod) + n += 1 + l + sovSharedConsumer(uint64(l)) + return n +} + +func (m *ConsumerGenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovSharedConsumer(uint64(l)) + l = m.Provider.Size() + n += 1 + l + sovSharedConsumer(uint64(l)) + if m.NewChain { + n += 2 + } + return n +} + +func (m *ProviderInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ClientState != nil { + l = m.ClientState.Size() + n += 1 + l + sovSharedConsumer(uint64(l)) + } + if m.ConsensusState != nil { + l = m.ConsensusState.Size() + n += 1 + l + sovSharedConsumer(uint64(l)) + } + if len(m.InitialValSet) > 0 { + for _, e := range m.InitialValSet { + l = e.Size() + n += 1 + l + sovSharedConsumer(uint64(l)) + } + } + return n +} + +func sovSharedConsumer(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozSharedConsumer(x uint64) (n int) { + return sovSharedConsumer(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ConsumerParams) 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 ErrIntOverflowSharedConsumer + } + 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: ConsumerParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsumerParams: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Enabled", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Enabled = bool(v != 0) + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerDistributionTransmission", wireType) + } + m.BlocksPerDistributionTransmission = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlocksPerDistributionTransmission |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DistributionTransmissionChannel", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + 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 ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DistributionTransmissionChannel = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderFeePoolAddrStr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + 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 ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProviderFeePoolAddrStr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CcvTimeoutPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.CcvTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TransferTimeoutPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.TransferTimeoutPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerRedistributionFraction", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + 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 ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerRedistributionFraction = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + 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 ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HistoricalEntries |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.UnbondingPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SoftOptOutThreshold", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + 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 ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SoftOptOutThreshold = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardDenoms", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + 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 ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardDenoms = append(m.RewardDenoms, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderRewardDenoms", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + 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 ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProviderRewardDenoms = append(m.ProviderRewardDenoms, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RetryDelayPeriod", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_cosmos_gogoproto_types.StdDurationUnmarshal(&m.RetryDelayPeriod, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSharedConsumer(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSharedConsumer + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConsumerGenesisState) 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 ErrIntOverflowSharedConsumer + } + 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: ConsumerGenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsumerGenesisState: 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 ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + 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 Provider", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Provider.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NewChain", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.NewChain = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipSharedConsumer(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSharedConsumer + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ProviderInfo) 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 ErrIntOverflowSharedConsumer + } + 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: ProviderInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ProviderInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClientState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ClientState == nil { + m.ClientState = &_07_tendermint.ClientState{} + } + if err := m.ClientState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusState", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.ConsensusState == nil { + m.ConsensusState = &_07_tendermint.ConsensusState{} + } + if err := m.ConsensusState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitialValSet", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSharedConsumer + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthSharedConsumer + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthSharedConsumer + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InitialValSet = append(m.InitialValSet, types.ValidatorUpdate{}) + if err := m.InitialValSet[len(m.InitialValSet)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSharedConsumer(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSharedConsumer + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipSharedConsumer(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, ErrIntOverflowSharedConsumer + } + 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, ErrIntOverflowSharedConsumer + } + 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, ErrIntOverflowSharedConsumer + } + 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, ErrInvalidLengthSharedConsumer + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupSharedConsumer + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthSharedConsumer + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthSharedConsumer = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowSharedConsumer = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupSharedConsumer = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ccv/types/utils_test.go b/x/ccv/types/utils_test.go index f43e5449f1..18ed01f7dc 100644 --- a/x/ccv/types/utils_test.go +++ b/x/ccv/types/utils_test.go @@ -3,18 +3,18 @@ package types_test import ( "testing" + ibctesting "github.com/cosmos/ibc-go/v7/testing" "github.com/stretchr/testify/require" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" abci "github.com/cometbft/cometbft/abci/types" - ibcsimapp "github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp" "github.com/cosmos/interchain-security/v3/x/ccv/types" ) func TestAccumulateChanges(t *testing.T) { - testKeys := ibcsimapp.CreateTestPubKeys(2) + _, testKeys, _ := ibctesting.GenerateKeys(t, 2) tmPubKey, _ := cryptocodec.ToTmProtoPublicKey(testKeys[0]) tmPubKey2, _ := cryptocodec.ToTmProtoPublicKey(testKeys[1]) @@ -84,7 +84,7 @@ func TestAccumulateChanges(t *testing.T) { for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { changes := types.AccumulateChanges(tc.changes1, tc.changes2) - require.Equal(t, tc.expected, changes) + require.ElementsMatch(t, tc.expected, changes) }) } } diff --git a/x/ccv/types/ccv.go b/x/ccv/types/wire.go similarity index 100% rename from x/ccv/types/ccv.go rename to x/ccv/types/wire.go diff --git a/x/ccv/types/ccv.pb.go b/x/ccv/types/wire.pb.go similarity index 66% rename from x/ccv/types/ccv.pb.go rename to x/ccv/types/wire.pb.go index aa0f7da10e..82768cf805 100644 --- a/x/ccv/types/ccv.pb.go +++ b/x/ccv/types/wire.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: interchain_security/ccv/v1/ccv.proto +// source: interchain_security/ccv/v1/wire.proto package types @@ -54,11 +54,11 @@ func (x ConsumerPacketDataType) String() string { } func (ConsumerPacketDataType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{0} + return fileDescriptor_8fd0dc67df6b10ed, []int{0} } // InfractionType indicates the infraction type a validator commited. -// NOTE: ccv.InfractionType to maintain compatibility between ICS versions +// Note ccv.InfractionType to maintain compatibility between ICS versions // using different versions of the cosmos-sdk and ibc-go modules. type InfractionType int32 @@ -88,7 +88,7 @@ func (x InfractionType) String() string { } func (InfractionType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{1} + return fileDescriptor_8fd0dc67df6b10ed, []int{1} } // This packet is sent from provider chain to consumer chain if the validator @@ -108,7 +108,7 @@ func (m *ValidatorSetChangePacketData) Reset() { *m = ValidatorSetChange func (m *ValidatorSetChangePacketData) String() string { return proto.CompactTextString(m) } func (*ValidatorSetChangePacketData) ProtoMessage() {} func (*ValidatorSetChangePacketData) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{0} + return fileDescriptor_8fd0dc67df6b10ed, []int{0} } func (m *ValidatorSetChangePacketData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -158,51 +158,6 @@ func (m *ValidatorSetChangePacketData) GetSlashAcks() []string { return nil } -// List of ccv.ValidatorSetChangePacketData. -type ValidatorSetChangePackets struct { - List []ValidatorSetChangePacketData `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` -} - -func (m *ValidatorSetChangePackets) Reset() { *m = ValidatorSetChangePackets{} } -func (m *ValidatorSetChangePackets) String() string { return proto.CompactTextString(m) } -func (*ValidatorSetChangePackets) ProtoMessage() {} -func (*ValidatorSetChangePackets) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{1} -} -func (m *ValidatorSetChangePackets) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ValidatorSetChangePackets) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ValidatorSetChangePackets.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 *ValidatorSetChangePackets) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValidatorSetChangePackets.Merge(m, src) -} -func (m *ValidatorSetChangePackets) XXX_Size() int { - return m.Size() -} -func (m *ValidatorSetChangePackets) XXX_DiscardUnknown() { - xxx_messageInfo_ValidatorSetChangePackets.DiscardUnknown(m) -} - -var xxx_messageInfo_ValidatorSetChangePackets proto.InternalMessageInfo - -func (m *ValidatorSetChangePackets) GetList() []ValidatorSetChangePacketData { - if m != nil { - return m.List - } - return nil -} - // This packet is sent from the consumer chain to the provider chain // to notify that a VSC packet reached maturity on the consumer chain. type VSCMaturedPacketData struct { @@ -214,7 +169,7 @@ func (m *VSCMaturedPacketData) Reset() { *m = VSCMaturedPacketData{} } func (m *VSCMaturedPacketData) String() string { return proto.CompactTextString(m) } func (*VSCMaturedPacketData) ProtoMessage() {} func (*VSCMaturedPacketData) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{2} + return fileDescriptor_8fd0dc67df6b10ed, []int{1} } func (m *VSCMaturedPacketData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -265,7 +220,7 @@ func (m *SlashPacketData) Reset() { *m = SlashPacketData{} } func (m *SlashPacketData) String() string { return proto.CompactTextString(m) } func (*SlashPacketData) ProtoMessage() {} func (*SlashPacketData) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{3} + return fileDescriptor_8fd0dc67df6b10ed, []int{2} } func (m *SlashPacketData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -315,53 +270,7 @@ func (m *SlashPacketData) GetInfraction() types1.Infraction { return types1.Infraction_INFRACTION_UNSPECIFIED } -// MaturedUnbondingOps defines a list of ids corresponding to ids of matured -// unbonding operations. -type MaturedUnbondingOps struct { - Ids []uint64 `protobuf:"varint,1,rep,packed,name=ids,proto3" json:"ids,omitempty"` -} - -func (m *MaturedUnbondingOps) Reset() { *m = MaturedUnbondingOps{} } -func (m *MaturedUnbondingOps) String() string { return proto.CompactTextString(m) } -func (*MaturedUnbondingOps) ProtoMessage() {} -func (*MaturedUnbondingOps) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{4} -} -func (m *MaturedUnbondingOps) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MaturedUnbondingOps) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MaturedUnbondingOps.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 *MaturedUnbondingOps) XXX_Merge(src proto.Message) { - xxx_messageInfo_MaturedUnbondingOps.Merge(m, src) -} -func (m *MaturedUnbondingOps) XXX_Size() int { - return m.Size() -} -func (m *MaturedUnbondingOps) XXX_DiscardUnknown() { - xxx_messageInfo_MaturedUnbondingOps.DiscardUnknown(m) -} - -var xxx_messageInfo_MaturedUnbondingOps proto.InternalMessageInfo - -func (m *MaturedUnbondingOps) GetIds() []uint64 { - if m != nil { - return m.Ids - } - return nil -} - -// ConsumerPacketData contains a consumer packet data, type tag, and index for storage. +// ConsumerPacketData contains a consumer packet data and a type tag type ConsumerPacketData struct { Type ConsumerPacketDataType `protobuf:"varint,1,opt,name=type,proto3,enum=interchain_security.ccv.v1.ConsumerPacketDataType" json:"type,omitempty"` // Types that are valid to be assigned to Data: @@ -374,7 +283,7 @@ func (m *ConsumerPacketData) Reset() { *m = ConsumerPacketData{} } func (m *ConsumerPacketData) String() string { return proto.CompactTextString(m) } func (*ConsumerPacketData) ProtoMessage() {} func (*ConsumerPacketData) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{5} + return fileDescriptor_8fd0dc67df6b10ed, []int{3} } func (m *ConsumerPacketData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -455,24 +364,24 @@ func (*ConsumerPacketData) XXX_OneofWrappers() []interface{} { } } -// ConsumerPacketDataList is a list of consumer packet data packets. -// NOTE: It is only used for exporting / importing state in InitGenesis and ExportGenesis. -type ConsumerPacketDataList struct { - List []ConsumerPacketData `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` +// Note this type is used during IBC handshake methods for both the consumer and provider +type HandshakeMetadata struct { + ProviderFeePoolAddr string `protobuf:"bytes,1,opt,name=provider_fee_pool_addr,json=providerFeePoolAddr,proto3" json:"provider_fee_pool_addr,omitempty"` + Version string `protobuf:"bytes,2,opt,name=version,proto3" json:"version,omitempty"` } -func (m *ConsumerPacketDataList) Reset() { *m = ConsumerPacketDataList{} } -func (m *ConsumerPacketDataList) String() string { return proto.CompactTextString(m) } -func (*ConsumerPacketDataList) ProtoMessage() {} -func (*ConsumerPacketDataList) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{6} +func (m *HandshakeMetadata) Reset() { *m = HandshakeMetadata{} } +func (m *HandshakeMetadata) String() string { return proto.CompactTextString(m) } +func (*HandshakeMetadata) ProtoMessage() {} +func (*HandshakeMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_8fd0dc67df6b10ed, []int{4} } -func (m *ConsumerPacketDataList) XXX_Unmarshal(b []byte) error { +func (m *HandshakeMetadata) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ConsumerPacketDataList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *HandshakeMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ConsumerPacketDataList.Marshal(b, m, deterministic) + return xxx_messageInfo_HandshakeMetadata.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -482,23 +391,30 @@ func (m *ConsumerPacketDataList) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *ConsumerPacketDataList) XXX_Merge(src proto.Message) { - xxx_messageInfo_ConsumerPacketDataList.Merge(m, src) +func (m *HandshakeMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_HandshakeMetadata.Merge(m, src) } -func (m *ConsumerPacketDataList) XXX_Size() int { +func (m *HandshakeMetadata) XXX_Size() int { return m.Size() } -func (m *ConsumerPacketDataList) XXX_DiscardUnknown() { - xxx_messageInfo_ConsumerPacketDataList.DiscardUnknown(m) +func (m *HandshakeMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_HandshakeMetadata.DiscardUnknown(m) } -var xxx_messageInfo_ConsumerPacketDataList proto.InternalMessageInfo +var xxx_messageInfo_HandshakeMetadata proto.InternalMessageInfo -func (m *ConsumerPacketDataList) GetList() []ConsumerPacketData { +func (m *HandshakeMetadata) GetProviderFeePoolAddr() string { if m != nil { - return m.List + return m.ProviderFeePoolAddr } - return nil + return "" +} + +func (m *HandshakeMetadata) GetVersion() string { + if m != nil { + return m.Version + } + return "" } // ConsumerPacketData contains a consumer packet data and a type tag @@ -515,7 +431,7 @@ func (m *ConsumerPacketDataV1) Reset() { *m = ConsumerPacketDataV1{} } func (m *ConsumerPacketDataV1) String() string { return proto.CompactTextString(m) } func (*ConsumerPacketDataV1) ProtoMessage() {} func (*ConsumerPacketDataV1) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{7} + return fileDescriptor_8fd0dc67df6b10ed, []int{5} } func (m *ConsumerPacketDataV1) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -610,7 +526,7 @@ func (m *SlashPacketDataV1) Reset() { *m = SlashPacketDataV1{} } func (m *SlashPacketDataV1) String() string { return proto.CompactTextString(m) } func (*SlashPacketDataV1) ProtoMessage() {} func (*SlashPacketDataV1) Descriptor() ([]byte, []int) { - return fileDescriptor_68bd5f3242e6f29c, []int{8} + return fileDescriptor_8fd0dc67df6b10ed, []int{6} } func (m *SlashPacketDataV1) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -664,75 +580,73 @@ func init() { proto.RegisterEnum("interchain_security.ccv.v1.ConsumerPacketDataType", ConsumerPacketDataType_name, ConsumerPacketDataType_value) proto.RegisterEnum("interchain_security.ccv.v1.InfractionType", InfractionType_name, InfractionType_value) proto.RegisterType((*ValidatorSetChangePacketData)(nil), "interchain_security.ccv.v1.ValidatorSetChangePacketData") - proto.RegisterType((*ValidatorSetChangePackets)(nil), "interchain_security.ccv.v1.ValidatorSetChangePackets") proto.RegisterType((*VSCMaturedPacketData)(nil), "interchain_security.ccv.v1.VSCMaturedPacketData") proto.RegisterType((*SlashPacketData)(nil), "interchain_security.ccv.v1.SlashPacketData") - proto.RegisterType((*MaturedUnbondingOps)(nil), "interchain_security.ccv.v1.MaturedUnbondingOps") proto.RegisterType((*ConsumerPacketData)(nil), "interchain_security.ccv.v1.ConsumerPacketData") - proto.RegisterType((*ConsumerPacketDataList)(nil), "interchain_security.ccv.v1.ConsumerPacketDataList") + proto.RegisterType((*HandshakeMetadata)(nil), "interchain_security.ccv.v1.HandshakeMetadata") proto.RegisterType((*ConsumerPacketDataV1)(nil), "interchain_security.ccv.v1.ConsumerPacketDataV1") proto.RegisterType((*SlashPacketDataV1)(nil), "interchain_security.ccv.v1.SlashPacketDataV1") } func init() { - proto.RegisterFile("interchain_security/ccv/v1/ccv.proto", fileDescriptor_68bd5f3242e6f29c) -} - -var fileDescriptor_68bd5f3242e6f29c = []byte{ - // 836 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0xcf, 0x6e, 0xe2, 0x46, - 0x1c, 0xb6, 0x01, 0xad, 0x9a, 0xa1, 0x22, 0xce, 0x2c, 0xad, 0x58, 0x6f, 0xcb, 0x5a, 0xd6, 0x4a, - 0x45, 0xa9, 0xd6, 0x2e, 0x64, 0x0f, 0x55, 0x7b, 0x69, 0x00, 0xa7, 0x71, 0x9b, 0x90, 0xc8, 0x06, - 0x56, 0xdb, 0x8b, 0x35, 0xd8, 0x13, 0x32, 0x0a, 0xd8, 0xc8, 0x33, 0xb8, 0xe5, 0x0d, 0x2a, 0x4e, - 0x7d, 0x01, 0x4e, 0x55, 0x0f, 0xfb, 0x18, 0xbd, 0xed, 0x71, 0xa5, 0x5e, 0xf6, 0xd2, 0xa8, 0x4a, - 0xde, 0xa0, 0x4f, 0x50, 0xd9, 0xfc, 0xc7, 0x06, 0x29, 0x52, 0xa5, 0xf6, 0x84, 0x19, 0xff, 0xbe, - 0x4f, 0xf3, 0xfd, 0x19, 0x79, 0xc0, 0x73, 0xe2, 0x32, 0xec, 0xdb, 0xd7, 0x88, 0xb8, 0x16, 0xc5, - 0xf6, 0xd0, 0x27, 0x6c, 0xa4, 0xda, 0x76, 0xa0, 0x06, 0xe5, 0xf0, 0x47, 0x19, 0xf8, 0x1e, 0xf3, - 0xa0, 0x98, 0x30, 0xa5, 0x84, 0xaf, 0x83, 0xb2, 0xf8, 0xdc, 0xf6, 0x68, 0xdf, 0xa3, 0x2a, 0x65, - 0xe8, 0x86, 0xb8, 0x5d, 0x35, 0x28, 0x77, 0x30, 0x43, 0xe5, 0xf9, 0xff, 0x29, 0x83, 0x98, 0xef, - 0x7a, 0x5d, 0x2f, 0x7a, 0x54, 0xc3, 0xa7, 0xd9, 0xea, 0x53, 0x86, 0x5d, 0x07, 0xfb, 0x7d, 0xe2, - 0x32, 0x15, 0x75, 0x6c, 0xa2, 0xb2, 0xd1, 0x00, 0xd3, 0xe9, 0x4b, 0xf9, 0x3d, 0x0f, 0x3e, 0x69, - 0xa3, 0x1e, 0x71, 0x10, 0xf3, 0x7c, 0x13, 0xb3, 0xda, 0x35, 0x72, 0xbb, 0xf8, 0x12, 0xd9, 0x37, - 0x98, 0xd5, 0x11, 0x43, 0xd0, 0x03, 0x07, 0xc1, 0xfc, 0xbd, 0x35, 0x1c, 0x38, 0x88, 0x61, 0x5a, - 0xe0, 0xa5, 0x74, 0x29, 0x5b, 0x91, 0x94, 0x25, 0xb3, 0x12, 0x32, 0x2b, 0x0b, 0xa6, 0x56, 0x34, - 0x58, 0x95, 0xde, 0xde, 0x3e, 0xe3, 0xfe, 0xbe, 0x7d, 0x56, 0x18, 0xa1, 0x7e, 0xef, 0x2b, 0x39, - 0x46, 0x24, 0x1b, 0x42, 0xb0, 0x0e, 0xa1, 0xb0, 0x04, 0xc2, 0x35, 0x8a, 0xd9, 0x6c, 0xc8, 0x22, - 0x4e, 0x21, 0x25, 0xf1, 0xa5, 0x8c, 0x91, 0x9b, 0xae, 0x4f, 0x07, 0x75, 0x07, 0x7e, 0x0a, 0x00, - 0xed, 0x21, 0x7a, 0x6d, 0x21, 0xfb, 0x86, 0x16, 0xd2, 0x52, 0xba, 0xb4, 0x67, 0xec, 0x45, 0x2b, - 0xc7, 0xf6, 0x0d, 0x95, 0x3d, 0xf0, 0x64, 0x9b, 0x32, 0x0a, 0x0d, 0x90, 0xe9, 0x11, 0xca, 0x66, - 0x4a, 0xbe, 0x54, 0xb6, 0x7b, 0xaf, 0xec, 0xb2, 0xa7, 0x9a, 0x09, 0x15, 0x1a, 0x11, 0x97, 0xfc, - 0x0d, 0xc8, 0xb7, 0xcd, 0xda, 0x39, 0x62, 0x43, 0x1f, 0x3b, 0x2b, 0x16, 0x26, 0x29, 0xe2, 0x93, - 0x14, 0xc9, 0x7f, 0xf0, 0x60, 0xdf, 0x0c, 0x05, 0xac, 0xa0, 0x0d, 0xb0, 0xb7, 0xf0, 0x28, 0x82, - 0x65, 0x2b, 0xe2, 0x76, 0xe3, 0xab, 0x85, 0x99, 0xe5, 0xc2, 0x86, 0xe5, 0xb2, 0xb1, 0xa4, 0x79, - 0x80, 0xc7, 0x55, 0x00, 0x88, 0x7b, 0xe5, 0x23, 0x9b, 0x11, 0xcf, 0x2d, 0xa4, 0x25, 0xbe, 0x94, - 0xab, 0xc8, 0xca, 0xb4, 0x8d, 0xca, 0xbc, 0x7d, 0xb3, 0x36, 0x2a, 0xfa, 0x62, 0xd2, 0x58, 0x41, - 0xc9, 0x9f, 0x81, 0xc7, 0x33, 0x53, 0x5a, 0x6e, 0xc7, 0x73, 0x1d, 0xe2, 0x76, 0x2f, 0x06, 0x14, - 0x0a, 0x20, 0x4d, 0x9c, 0x69, 0x97, 0x32, 0x46, 0xf8, 0x28, 0xff, 0x96, 0x02, 0xb0, 0xe6, 0xb9, - 0x74, 0xd8, 0xc7, 0xfe, 0x8a, 0x03, 0x27, 0x20, 0x13, 0x56, 0x36, 0x12, 0x9f, 0xab, 0x54, 0x76, - 0x65, 0x15, 0x47, 0x37, 0x47, 0x03, 0x6c, 0x44, 0x78, 0xf8, 0x0a, 0xec, 0xd3, 0x75, 0x73, 0x23, - 0xd1, 0xd9, 0xca, 0xe7, 0xbb, 0x28, 0x37, 0xf2, 0x38, 0xe5, 0x8c, 0x4d, 0x16, 0x78, 0x05, 0xf2, - 0x01, 0xb5, 0x63, 0xc1, 0x47, 0x76, 0x65, 0x2b, 0x5f, 0xec, 0x2c, 0x57, 0x42, 0x61, 0x4e, 0x39, - 0x23, 0x91, 0xaf, 0xfa, 0x08, 0x64, 0x1c, 0xc4, 0x90, 0xdc, 0x01, 0x1f, 0xc7, 0x85, 0x9e, 0x11, - 0xca, 0xe0, 0xe9, 0x5a, 0xad, 0x95, 0x87, 0x59, 0xb5, 0x56, 0xe6, 0x37, 0x29, 0x90, 0x8f, 0x8f, - 0xb4, 0xcb, 0xff, 0x5a, 0x1a, 0xaf, 0xb7, 0xa5, 0xf1, 0xe2, 0x01, 0x69, 0xb4, 0xcb, 0xff, 0x87, - 0x3c, 0xfe, 0xe4, 0xc1, 0x41, 0x6c, 0x63, 0xff, 0xf1, 0xc1, 0xfd, 0x2e, 0xe1, 0xe0, 0x1e, 0xee, - 0x52, 0xbe, 0x3c, 0xbc, 0x51, 0x48, 0x2b, 0xe8, 0xc3, 0xdf, 0xf9, 0xa4, 0xc2, 0x85, 0x63, 0xf0, - 0x6b, 0x20, 0xd5, 0x2e, 0x1a, 0x66, 0xeb, 0x5c, 0x33, 0xac, 0xcb, 0xe3, 0xda, 0xf7, 0x5a, 0xd3, - 0x6a, 0xbe, 0xbe, 0xd4, 0xac, 0x56, 0xc3, 0xbc, 0xd4, 0x6a, 0xfa, 0x89, 0xae, 0xd5, 0x05, 0x4e, - 0xfc, 0x68, 0x3c, 0x91, 0x0e, 0x5a, 0x2e, 0x1d, 0x60, 0x9b, 0x5c, 0x91, 0xb9, 0x87, 0x50, 0x05, - 0x62, 0x22, 0xd8, 0x3c, 0x3b, 0x36, 0x4f, 0x05, 0x5e, 0xdc, 0x1f, 0x4f, 0xa4, 0xec, 0x8a, 0xb1, - 0xf0, 0x08, 0x3c, 0x49, 0x04, 0x84, 0xa9, 0x09, 0x29, 0x31, 0x3f, 0x9e, 0x48, 0x42, 0x7b, 0x23, - 0x29, 0x31, 0xf3, 0xf3, 0xaf, 0x45, 0xee, 0xf0, 0x0d, 0x0f, 0x72, 0xeb, 0x12, 0xe1, 0x4b, 0xf0, - 0x54, 0x6f, 0x9c, 0x18, 0xc7, 0xb5, 0xa6, 0x7e, 0xd1, 0x48, 0xda, 0xf6, 0xe3, 0xf1, 0x44, 0xda, - 0x5f, 0x82, 0xb4, 0xfe, 0x80, 0x8d, 0xa0, 0x1a, 0x47, 0xd5, 0x2f, 0x5a, 0xd5, 0x33, 0xcd, 0x32, - 0xf5, 0x6f, 0x1b, 0x02, 0x2f, 0xe6, 0xc6, 0x13, 0x09, 0xd4, 0xbd, 0x61, 0xa7, 0x87, 0x4d, 0xd2, - 0x75, 0xe1, 0x21, 0x28, 0xc4, 0x01, 0xaf, 0x1a, 0x4d, 0xfd, 0x5c, 0x13, 0x52, 0xe2, 0x87, 0xe3, - 0x89, 0xf4, 0x41, 0xdd, 0xfb, 0xd1, 0x65, 0xa4, 0x8f, 0xa7, 0x7b, 0xad, 0x36, 0xde, 0xde, 0x15, - 0xf9, 0x77, 0x77, 0x45, 0xfe, 0xaf, 0xbb, 0x22, 0xff, 0xcb, 0x7d, 0x91, 0x7b, 0x77, 0x5f, 0xe4, - 0xde, 0xdf, 0x17, 0xb9, 0x1f, 0x5e, 0x76, 0x09, 0xbb, 0x1e, 0x76, 0x14, 0xdb, 0xeb, 0xab, 0xb3, - 0x2b, 0xc1, 0x32, 0xd2, 0x17, 0x8b, 0xbb, 0x45, 0x70, 0xa4, 0xfe, 0x14, 0x5d, 0x30, 0xa2, 0x4f, - 0x7d, 0xe7, 0x51, 0xf4, 0xad, 0x3f, 0xfa, 0x27, 0x00, 0x00, 0xff, 0xff, 0x8f, 0xbf, 0xfc, 0xd2, - 0x88, 0x08, 0x00, 0x00, + proto.RegisterFile("interchain_security/ccv/v1/wire.proto", fileDescriptor_8fd0dc67df6b10ed) +} + +var fileDescriptor_8fd0dc67df6b10ed = []byte{ + // 833 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcd, 0x6e, 0xe3, 0x54, + 0x14, 0xb6, 0xd3, 0x6a, 0xa0, 0x37, 0x28, 0x75, 0x3d, 0x61, 0x64, 0x3c, 0x90, 0xb1, 0x2c, 0x90, + 0xa2, 0xa2, 0xb1, 0x49, 0x3a, 0x2b, 0xd8, 0x90, 0x1f, 0x97, 0x1a, 0xa6, 0x69, 0x64, 0x27, 0x19, + 0x0d, 0x1b, 0xeb, 0xc6, 0xbe, 0x4d, 0xae, 0x92, 0xf8, 0x5a, 0xbe, 0x37, 0x1e, 0xf2, 0x06, 0x28, + 0x2b, 0x5e, 0x20, 0x2b, 0xc4, 0x62, 0x1e, 0x83, 0xdd, 0x2c, 0x47, 0x62, 0x33, 0x1b, 0x46, 0xa8, + 0x7d, 0x03, 0x9e, 0x00, 0xd9, 0xf9, 0x6d, 0xe2, 0x56, 0xaa, 0x84, 0x04, 0x3b, 0xfb, 0xdc, 0xf3, + 0x7d, 0xf7, 0x9c, 0xef, 0x3b, 0x57, 0x07, 0x7c, 0x81, 0x7d, 0x86, 0x42, 0xb7, 0x0f, 0xb1, 0xef, + 0x50, 0xe4, 0x8e, 0x43, 0xcc, 0x26, 0xba, 0xeb, 0x46, 0x7a, 0x54, 0xd2, 0x5f, 0xe1, 0x10, 0x69, + 0x41, 0x48, 0x18, 0x11, 0xe5, 0x94, 0x34, 0xcd, 0x75, 0x23, 0x2d, 0x2a, 0xc9, 0x9f, 0xbb, 0x84, + 0x8e, 0x08, 0xd5, 0x29, 0x83, 0x03, 0xec, 0xf7, 0xf4, 0xa8, 0xd4, 0x45, 0x0c, 0x96, 0x96, 0xff, + 0x73, 0x06, 0x39, 0xdf, 0x23, 0x3d, 0x92, 0x7c, 0xea, 0xf1, 0xd7, 0x22, 0xfa, 0x98, 0x21, 0xdf, + 0x43, 0xe1, 0x08, 0xfb, 0x4c, 0x87, 0x5d, 0x17, 0xeb, 0x6c, 0x12, 0x20, 0x3a, 0x3f, 0x54, 0xdf, + 0xf1, 0xe0, 0xd3, 0x0e, 0x1c, 0x62, 0x0f, 0x32, 0x12, 0xda, 0x88, 0xd5, 0xfa, 0xd0, 0xef, 0xa1, + 0x26, 0x74, 0x07, 0x88, 0xd5, 0x21, 0x83, 0x22, 0x01, 0x47, 0xd1, 0xf2, 0xdc, 0x19, 0x07, 0x1e, + 0x64, 0x88, 0x4a, 0xbc, 0xb2, 0x57, 0xcc, 0x96, 0x15, 0x6d, 0xcd, 0xac, 0xc5, 0xcc, 0xda, 0x8a, + 0xa9, 0x9d, 0x24, 0x56, 0x95, 0x37, 0xef, 0x9f, 0x70, 0x7f, 0xbf, 0x7f, 0x22, 0x4d, 0xe0, 0x68, + 0xf8, 0xb5, 0xba, 0x43, 0xa4, 0x5a, 0x42, 0x74, 0x13, 0x42, 0xc5, 0x22, 0x88, 0x63, 0x14, 0xb1, + 0x45, 0x92, 0x83, 0x3d, 0x29, 0xa3, 0xf0, 0xc5, 0x7d, 0x2b, 0x37, 0x8f, 0xcf, 0x13, 0x4d, 0x4f, + 0xfc, 0x0c, 0x00, 0x3a, 0x84, 0xb4, 0xef, 0x40, 0x77, 0x40, 0xa5, 0x3d, 0x65, 0xaf, 0x78, 0x60, + 0x1d, 0x24, 0x91, 0x8a, 0x3b, 0xa0, 0xea, 0xb7, 0x20, 0xdf, 0xb1, 0x6b, 0xe7, 0x90, 0x8d, 0x43, + 0xe4, 0x6d, 0x74, 0x94, 0x76, 0x01, 0x9f, 0x76, 0x81, 0xfa, 0x07, 0x0f, 0x0e, 0xed, 0x98, 0x6f, + 0x03, 0x6d, 0x81, 0x83, 0x55, 0xc9, 0x09, 0x2c, 0x5b, 0x96, 0x6f, 0xd7, 0xa1, 0x2a, 0x2d, 0x14, + 0x10, 0xb6, 0x14, 0x50, 0xad, 0x35, 0xcd, 0x3d, 0x5a, 0xae, 0x02, 0x80, 0xfd, 0xcb, 0x10, 0xba, + 0x0c, 0x13, 0x5f, 0xda, 0x53, 0xf8, 0x62, 0xae, 0xac, 0x6a, 0xf3, 0xe1, 0xd0, 0x96, 0xc3, 0xb0, + 0x18, 0x0e, 0xcd, 0x5c, 0x65, 0x5a, 0x1b, 0x28, 0xf5, 0xb7, 0x0c, 0x10, 0x6b, 0xc4, 0xa7, 0xe3, + 0x11, 0x0a, 0x37, 0x1a, 0x3b, 0x05, 0xfb, 0xf1, 0x60, 0x24, 0x3d, 0xe5, 0xca, 0x65, 0xed, 0xf6, + 0x69, 0xd4, 0x76, 0xd1, 0xad, 0x49, 0x80, 0xac, 0x04, 0x2f, 0xbe, 0x00, 0x87, 0xf4, 0xa6, 0x66, + 0x49, 0x2f, 0xd9, 0xf2, 0x97, 0x77, 0x51, 0x6e, 0xc9, 0x7c, 0xc6, 0x59, 0xdb, 0x2c, 0xe2, 0x25, + 0xc8, 0x47, 0xd4, 0xdd, 0xf1, 0x33, 0x51, 0x21, 0x5b, 0xfe, 0xea, 0x2e, 0xf6, 0xb4, 0x39, 0x38, + 0xe3, 0xac, 0x54, 0xbe, 0xea, 0x03, 0xb0, 0xef, 0x41, 0x06, 0xd5, 0x2e, 0x38, 0x3a, 0x83, 0xbe, + 0x47, 0xfb, 0x70, 0x80, 0xce, 0x11, 0x83, 0x71, 0x50, 0x3c, 0x01, 0x8f, 0x82, 0x90, 0x44, 0xd8, + 0x43, 0xa1, 0x73, 0x89, 0x90, 0x13, 0x10, 0x32, 0x74, 0xa0, 0xe7, 0xcd, 0x67, 0xe1, 0xc0, 0x7a, + 0xb8, 0x3c, 0x3d, 0x45, 0xa8, 0x49, 0xc8, 0xb0, 0xe2, 0x79, 0xa1, 0x28, 0x81, 0x0f, 0x22, 0x14, + 0xd2, 0xd8, 0xb2, 0x4c, 0x92, 0xb5, 0xfc, 0x55, 0x5f, 0x67, 0x40, 0x7e, 0x57, 0xcd, 0x4e, 0xe9, + 0x5f, 0x73, 0xe3, 0xe5, 0x6d, 0x6e, 0x3c, 0xbd, 0x87, 0x1b, 0x9d, 0xd2, 0xff, 0xc1, 0x8f, 0x3f, + 0x79, 0x70, 0xb4, 0x53, 0xd8, 0x7f, 0xfc, 0x1e, 0xbf, 0x4f, 0x79, 0x8f, 0xc7, 0x77, 0x75, 0xbe, + 0x7e, 0x93, 0x89, 0x49, 0x1b, 0xe8, 0xe3, 0xdf, 0x79, 0xf0, 0x28, 0xdd, 0x4b, 0xf1, 0x1b, 0xa0, + 0xd4, 0x2e, 0x1a, 0x76, 0xfb, 0xdc, 0xb0, 0x9c, 0x66, 0xa5, 0xf6, 0x83, 0xd1, 0x72, 0x5a, 0x2f, + 0x9b, 0x86, 0xd3, 0x6e, 0xd8, 0x4d, 0xa3, 0x66, 0x9e, 0x9a, 0x46, 0x5d, 0xe0, 0xe4, 0x8f, 0xa7, + 0x33, 0xe5, 0xa8, 0xed, 0xd3, 0x00, 0xb9, 0xf8, 0x12, 0x2f, 0x35, 0x14, 0x75, 0x20, 0xa7, 0x82, + 0xed, 0xe7, 0x15, 0xfb, 0x4c, 0xe0, 0xe5, 0xc3, 0xe9, 0x4c, 0xc9, 0x6e, 0x08, 0x2b, 0x9e, 0x80, + 0x4f, 0x52, 0x01, 0xb1, 0x6b, 0x42, 0x46, 0xce, 0x4f, 0x67, 0x8a, 0xd0, 0xd9, 0x72, 0x4a, 0xde, + 0xff, 0xf9, 0xd7, 0x02, 0x77, 0xfc, 0x9a, 0x07, 0xb9, 0x9b, 0x2d, 0x8a, 0xcf, 0xc0, 0x63, 0xb3, + 0x71, 0x6a, 0x55, 0x6a, 0x2d, 0xf3, 0xa2, 0x91, 0x56, 0xf6, 0xc3, 0xe9, 0x4c, 0x39, 0x5c, 0x83, + 0x8c, 0x51, 0xc0, 0x26, 0xa2, 0xbe, 0x8b, 0xaa, 0x5f, 0xb4, 0xab, 0xcf, 0x0d, 0xc7, 0x36, 0xbf, + 0x6b, 0x08, 0xbc, 0x9c, 0x9b, 0xce, 0x14, 0x50, 0x27, 0xe3, 0xee, 0x10, 0xd9, 0xb8, 0xe7, 0x8b, + 0xc7, 0x40, 0xda, 0x05, 0xbc, 0x68, 0xb4, 0xcc, 0x73, 0x43, 0xc8, 0xc8, 0x1f, 0x4d, 0x67, 0xca, + 0x87, 0x75, 0xf2, 0xca, 0x67, 0x78, 0x84, 0xe6, 0xb5, 0x56, 0x1b, 0x6f, 0xae, 0x0a, 0xfc, 0xdb, + 0xab, 0x02, 0xff, 0xd7, 0x55, 0x81, 0xff, 0xe5, 0xba, 0xc0, 0xbd, 0xbd, 0x2e, 0x70, 0xef, 0xae, + 0x0b, 0xdc, 0x8f, 0xcf, 0x7a, 0x98, 0xf5, 0xc7, 0x5d, 0xcd, 0x25, 0x23, 0x7d, 0xb1, 0x78, 0xd7, + 0x96, 0x3e, 0x5d, 0xad, 0xf0, 0xe8, 0x44, 0xff, 0x29, 0xd9, 0xe3, 0xc9, 0x42, 0xed, 0x3e, 0x48, + 0x36, 0xea, 0xc9, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x17, 0x85, 0x90, 0x57, 0xef, 0x07, 0x00, + 0x00, } func (m *ValidatorSetChangePacketData) Marshal() (dAtA []byte, err error) { @@ -759,13 +673,13 @@ func (m *ValidatorSetChangePacketData) MarshalToSizedBuffer(dAtA []byte) (int, e for iNdEx := len(m.SlashAcks) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.SlashAcks[iNdEx]) copy(dAtA[i:], m.SlashAcks[iNdEx]) - i = encodeVarintCcv(dAtA, i, uint64(len(m.SlashAcks[iNdEx]))) + i = encodeVarintWire(dAtA, i, uint64(len(m.SlashAcks[iNdEx]))) i-- dAtA[i] = 0x1a } } if m.ValsetUpdateId != 0 { - i = encodeVarintCcv(dAtA, i, uint64(m.ValsetUpdateId)) + i = encodeVarintWire(dAtA, i, uint64(m.ValsetUpdateId)) i-- dAtA[i] = 0x10 } @@ -777,44 +691,7 @@ func (m *ValidatorSetChangePacketData) MarshalToSizedBuffer(dAtA []byte) (int, e return 0, err } i -= size - i = encodeVarintCcv(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ValidatorSetChangePackets) 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 *ValidatorSetChangePackets) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ValidatorSetChangePackets) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.List) > 0 { - for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.List[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCcv(dAtA, i, uint64(size)) + i = encodeVarintWire(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -844,7 +721,7 @@ func (m *VSCMaturedPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.ValsetUpdateId != 0 { - i = encodeVarintCcv(dAtA, i, uint64(m.ValsetUpdateId)) + i = encodeVarintWire(dAtA, i, uint64(m.ValsetUpdateId)) i-- dAtA[i] = 0x8 } @@ -872,12 +749,12 @@ func (m *SlashPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.Infraction != 0 { - i = encodeVarintCcv(dAtA, i, uint64(m.Infraction)) + i = encodeVarintWire(dAtA, i, uint64(m.Infraction)) i-- dAtA[i] = 0x18 } if m.ValsetUpdateId != 0 { - i = encodeVarintCcv(dAtA, i, uint64(m.ValsetUpdateId)) + i = encodeVarintWire(dAtA, i, uint64(m.ValsetUpdateId)) i-- dAtA[i] = 0x10 } @@ -887,54 +764,13 @@ func (m *SlashPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintCcv(dAtA, i, uint64(size)) + i = encodeVarintWire(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa return len(dAtA) - i, nil } -func (m *MaturedUnbondingOps) 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 *MaturedUnbondingOps) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MaturedUnbondingOps) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Ids) > 0 { - dAtA3 := make([]byte, len(m.Ids)*10) - var j2 int - for _, num := range m.Ids { - for num >= 1<<7 { - dAtA3[j2] = uint8(uint64(num)&0x7f | 0x80) - num >>= 7 - j2++ - } - dAtA3[j2] = uint8(num) - j2++ - } - i -= j2 - copy(dAtA[i:], dAtA3[:j2]) - i = encodeVarintCcv(dAtA, i, uint64(j2)) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func (m *ConsumerPacketData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -965,7 +801,7 @@ func (m *ConsumerPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { } } if m.Type != 0 { - i = encodeVarintCcv(dAtA, i, uint64(m.Type)) + i = encodeVarintWire(dAtA, i, uint64(m.Type)) i-- dAtA[i] = 0x8 } @@ -986,7 +822,7 @@ func (m *ConsumerPacketData_SlashPacketData) MarshalToSizedBuffer(dAtA []byte) ( return 0, err } i -= size - i = encodeVarintCcv(dAtA, i, uint64(size)) + i = encodeVarintWire(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -1007,14 +843,14 @@ func (m *ConsumerPacketData_VscMaturedPacketData) MarshalToSizedBuffer(dAtA []by return 0, err } i -= size - i = encodeVarintCcv(dAtA, i, uint64(size)) + i = encodeVarintWire(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a } return len(dAtA) - i, nil } -func (m *ConsumerPacketDataList) Marshal() (dAtA []byte, err error) { +func (m *HandshakeMetadata) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1024,29 +860,29 @@ func (m *ConsumerPacketDataList) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ConsumerPacketDataList) MarshalTo(dAtA []byte) (int, error) { +func (m *HandshakeMetadata) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ConsumerPacketDataList) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *HandshakeMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.List) > 0 { - for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.List[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintCcv(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } + if len(m.Version) > 0 { + i -= len(m.Version) + copy(dAtA[i:], m.Version) + i = encodeVarintWire(dAtA, i, uint64(len(m.Version))) + i-- + dAtA[i] = 0x12 + } + if len(m.ProviderFeePoolAddr) > 0 { + i -= len(m.ProviderFeePoolAddr) + copy(dAtA[i:], m.ProviderFeePoolAddr) + i = encodeVarintWire(dAtA, i, uint64(len(m.ProviderFeePoolAddr))) + i-- + dAtA[i] = 0xa } return len(dAtA) - i, nil } @@ -1081,7 +917,7 @@ func (m *ConsumerPacketDataV1) MarshalToSizedBuffer(dAtA []byte) (int, error) { } } if m.Type != 0 { - i = encodeVarintCcv(dAtA, i, uint64(m.Type)) + i = encodeVarintWire(dAtA, i, uint64(m.Type)) i-- dAtA[i] = 0x8 } @@ -1102,7 +938,7 @@ func (m *ConsumerPacketDataV1_SlashPacketData) MarshalToSizedBuffer(dAtA []byte) return 0, err } i -= size - i = encodeVarintCcv(dAtA, i, uint64(size)) + i = encodeVarintWire(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -1123,7 +959,7 @@ func (m *ConsumerPacketDataV1_VscMaturedPacketData) MarshalToSizedBuffer(dAtA [] return 0, err } i -= size - i = encodeVarintCcv(dAtA, i, uint64(size)) + i = encodeVarintWire(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -1151,12 +987,12 @@ func (m *SlashPacketDataV1) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.Infraction != 0 { - i = encodeVarintCcv(dAtA, i, uint64(m.Infraction)) + i = encodeVarintWire(dAtA, i, uint64(m.Infraction)) i-- dAtA[i] = 0x18 } if m.ValsetUpdateId != 0 { - i = encodeVarintCcv(dAtA, i, uint64(m.ValsetUpdateId)) + i = encodeVarintWire(dAtA, i, uint64(m.ValsetUpdateId)) i-- dAtA[i] = 0x10 } @@ -1166,15 +1002,15 @@ func (m *SlashPacketDataV1) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintCcv(dAtA, i, uint64(size)) + i = encodeVarintWire(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa return len(dAtA) - i, nil } -func encodeVarintCcv(dAtA []byte, offset int, v uint64) int { - offset -= sovCcv(v) +func encodeVarintWire(dAtA []byte, offset int, v uint64) int { + offset -= sovWire(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -1193,31 +1029,16 @@ func (m *ValidatorSetChangePacketData) Size() (n int) { if len(m.ValidatorUpdates) > 0 { for _, e := range m.ValidatorUpdates { l = e.Size() - n += 1 + l + sovCcv(uint64(l)) + n += 1 + l + sovWire(uint64(l)) } } if m.ValsetUpdateId != 0 { - n += 1 + sovCcv(uint64(m.ValsetUpdateId)) + n += 1 + sovWire(uint64(m.ValsetUpdateId)) } if len(m.SlashAcks) > 0 { for _, s := range m.SlashAcks { l = len(s) - n += 1 + l + sovCcv(uint64(l)) - } - } - return n -} - -func (m *ValidatorSetChangePackets) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.List) > 0 { - for _, e := range m.List { - l = e.Size() - n += 1 + l + sovCcv(uint64(l)) + n += 1 + l + sovWire(uint64(l)) } } return n @@ -1230,7 +1051,7 @@ func (m *VSCMaturedPacketData) Size() (n int) { var l int _ = l if m.ValsetUpdateId != 0 { - n += 1 + sovCcv(uint64(m.ValsetUpdateId)) + n += 1 + sovWire(uint64(m.ValsetUpdateId)) } return n } @@ -1242,28 +1063,12 @@ func (m *SlashPacketData) Size() (n int) { var l int _ = l l = m.Validator.Size() - n += 1 + l + sovCcv(uint64(l)) + n += 1 + l + sovWire(uint64(l)) if m.ValsetUpdateId != 0 { - n += 1 + sovCcv(uint64(m.ValsetUpdateId)) + n += 1 + sovWire(uint64(m.ValsetUpdateId)) } if m.Infraction != 0 { - n += 1 + sovCcv(uint64(m.Infraction)) - } - return n -} - -func (m *MaturedUnbondingOps) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Ids) > 0 { - l = 0 - for _, e := range m.Ids { - l += sovCcv(uint64(e)) - } - n += 1 + sovCcv(uint64(l)) + l + n += 1 + sovWire(uint64(m.Infraction)) } return n } @@ -1275,7 +1080,7 @@ func (m *ConsumerPacketData) Size() (n int) { var l int _ = l if m.Type != 0 { - n += 1 + sovCcv(uint64(m.Type)) + n += 1 + sovWire(uint64(m.Type)) } if m.Data != nil { n += m.Data.Size() @@ -1291,7 +1096,7 @@ func (m *ConsumerPacketData_SlashPacketData) Size() (n int) { _ = l if m.SlashPacketData != nil { l = m.SlashPacketData.Size() - n += 1 + l + sovCcv(uint64(l)) + n += 1 + l + sovWire(uint64(l)) } return n } @@ -1303,21 +1108,23 @@ func (m *ConsumerPacketData_VscMaturedPacketData) Size() (n int) { _ = l if m.VscMaturedPacketData != nil { l = m.VscMaturedPacketData.Size() - n += 1 + l + sovCcv(uint64(l)) + n += 1 + l + sovWire(uint64(l)) } return n } -func (m *ConsumerPacketDataList) Size() (n int) { +func (m *HandshakeMetadata) Size() (n int) { if m == nil { return 0 } var l int _ = l - if len(m.List) > 0 { - for _, e := range m.List { - l = e.Size() - n += 1 + l + sovCcv(uint64(l)) - } + l = len(m.ProviderFeePoolAddr) + if l > 0 { + n += 1 + l + sovWire(uint64(l)) + } + l = len(m.Version) + if l > 0 { + n += 1 + l + sovWire(uint64(l)) } return n } @@ -1329,7 +1136,7 @@ func (m *ConsumerPacketDataV1) Size() (n int) { var l int _ = l if m.Type != 0 { - n += 1 + sovCcv(uint64(m.Type)) + n += 1 + sovWire(uint64(m.Type)) } if m.Data != nil { n += m.Data.Size() @@ -1345,7 +1152,7 @@ func (m *ConsumerPacketDataV1_SlashPacketData) Size() (n int) { _ = l if m.SlashPacketData != nil { l = m.SlashPacketData.Size() - n += 1 + l + sovCcv(uint64(l)) + n += 1 + l + sovWire(uint64(l)) } return n } @@ -1357,7 +1164,7 @@ func (m *ConsumerPacketDataV1_VscMaturedPacketData) Size() (n int) { _ = l if m.VscMaturedPacketData != nil { l = m.VscMaturedPacketData.Size() - n += 1 + l + sovCcv(uint64(l)) + n += 1 + l + sovWire(uint64(l)) } return n } @@ -1368,21 +1175,21 @@ func (m *SlashPacketDataV1) Size() (n int) { var l int _ = l l = m.Validator.Size() - n += 1 + l + sovCcv(uint64(l)) + n += 1 + l + sovWire(uint64(l)) if m.ValsetUpdateId != 0 { - n += 1 + sovCcv(uint64(m.ValsetUpdateId)) + n += 1 + sovWire(uint64(m.ValsetUpdateId)) } if m.Infraction != 0 { - n += 1 + sovCcv(uint64(m.Infraction)) + n += 1 + sovWire(uint64(m.Infraction)) } return n } -func sovCcv(x uint64) (n int) { +func sovWire(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozCcv(x uint64) (n int) { - return sovCcv(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozWire(x uint64) (n int) { + return sovWire(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *ValidatorSetChangePacketData) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -1392,7 +1199,7 @@ func (m *ValidatorSetChangePacketData) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1420,7 +1227,7 @@ func (m *ValidatorSetChangePacketData) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1433,11 +1240,11 @@ func (m *ValidatorSetChangePacketData) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if postIndex > l { return io.ErrUnexpectedEOF @@ -1454,7 +1261,7 @@ func (m *ValidatorSetChangePacketData) Unmarshal(dAtA []byte) error { m.ValsetUpdateId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1473,7 +1280,7 @@ func (m *ValidatorSetChangePacketData) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1487,11 +1294,11 @@ func (m *ValidatorSetChangePacketData) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if postIndex > l { return io.ErrUnexpectedEOF @@ -1500,96 +1307,12 @@ func (m *ValidatorSetChangePacketData) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipCcv(dAtA[iNdEx:]) + skippy, err := skipWire(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCcv - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ValidatorSetChangePackets) 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 ErrIntOverflowCcv - } - 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: ValidatorSetChangePackets: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ValidatorSetChangePackets: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field List", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCcv - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthCcv - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthCcv - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.List = append(m.List, ValidatorSetChangePacketData{}) - if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipCcv(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1611,7 +1334,7 @@ func (m *VSCMaturedPacketData) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1639,7 +1362,7 @@ func (m *VSCMaturedPacketData) Unmarshal(dAtA []byte) error { m.ValsetUpdateId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1653,12 +1376,12 @@ func (m *VSCMaturedPacketData) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipCcv(dAtA[iNdEx:]) + skippy, err := skipWire(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1680,7 +1403,7 @@ func (m *SlashPacketData) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1708,7 +1431,7 @@ func (m *SlashPacketData) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1721,11 +1444,11 @@ func (m *SlashPacketData) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if postIndex > l { return io.ErrUnexpectedEOF @@ -1741,7 +1464,7 @@ func (m *SlashPacketData) Unmarshal(dAtA []byte) error { m.ValsetUpdateId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1760,7 +1483,7 @@ func (m *SlashPacketData) Unmarshal(dAtA []byte) error { m.Infraction = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1774,138 +1497,12 @@ func (m *SlashPacketData) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipCcv(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCcv - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *MaturedUnbondingOps) 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 ErrIntOverflowCcv - } - 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: MaturedUnbondingOps: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MaturedUnbondingOps: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCcv - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Ids = append(m.Ids, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCcv - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthCcv - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthCcv - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.Ids) == 0 { - m.Ids = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowCcv - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.Ids = append(m.Ids, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field Ids", wireType) - } - default: - iNdEx = preIndex - skippy, err := skipCcv(dAtA[iNdEx:]) + skippy, err := skipWire(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -1927,7 +1524,7 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1955,7 +1552,7 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { m.Type = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1974,7 +1571,7 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -1987,11 +1584,11 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if postIndex > l { return io.ErrUnexpectedEOF @@ -2009,7 +1606,7 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2022,11 +1619,11 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if postIndex > l { return io.ErrUnexpectedEOF @@ -2039,12 +1636,12 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipCcv(dAtA[iNdEx:]) + skippy, err := skipWire(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -2058,7 +1655,7 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { } return nil } -func (m *ConsumerPacketDataList) Unmarshal(dAtA []byte) error { +func (m *HandshakeMetadata) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2066,7 +1663,7 @@ func (m *ConsumerPacketDataList) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2081,54 +1678,84 @@ func (m *ConsumerPacketDataList) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ConsumerPacketDataList: wiretype end group for non-group") + return fmt.Errorf("proto: HandshakeMetadata: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ConsumerPacketDataList: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: HandshakeMetadata: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field List", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ProviderFeePoolAddr", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { - return ErrInvalidLengthCcv + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthWire } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if postIndex > l { return io.ErrUnexpectedEOF } - m.List = append(m.List, ConsumerPacketData{}) - if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.ProviderFeePoolAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + 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 ErrInvalidLengthWire + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWire + } + if postIndex > l { + return io.ErrUnexpectedEOF } + m.Version = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipCcv(dAtA[iNdEx:]) + skippy, err := skipWire(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -2150,7 +1777,7 @@ func (m *ConsumerPacketDataV1) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2178,7 +1805,7 @@ func (m *ConsumerPacketDataV1) Unmarshal(dAtA []byte) error { m.Type = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2197,7 +1824,7 @@ func (m *ConsumerPacketDataV1) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2210,11 +1837,11 @@ func (m *ConsumerPacketDataV1) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if postIndex > l { return io.ErrUnexpectedEOF @@ -2232,7 +1859,7 @@ func (m *ConsumerPacketDataV1) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2245,11 +1872,11 @@ func (m *ConsumerPacketDataV1) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if postIndex > l { return io.ErrUnexpectedEOF @@ -2262,12 +1889,12 @@ func (m *ConsumerPacketDataV1) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipCcv(dAtA[iNdEx:]) + skippy, err := skipWire(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -2289,7 +1916,7 @@ func (m *SlashPacketDataV1) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2317,7 +1944,7 @@ func (m *SlashPacketDataV1) Unmarshal(dAtA []byte) error { var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2330,11 +1957,11 @@ func (m *SlashPacketDataV1) Unmarshal(dAtA []byte) error { } } if msglen < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } postIndex := iNdEx + msglen if postIndex < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if postIndex > l { return io.ErrUnexpectedEOF @@ -2350,7 +1977,7 @@ func (m *SlashPacketDataV1) Unmarshal(dAtA []byte) error { m.ValsetUpdateId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2369,7 +1996,7 @@ func (m *SlashPacketDataV1) Unmarshal(dAtA []byte) error { m.Infraction = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowCcv + return ErrIntOverflowWire } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2383,12 +2010,12 @@ func (m *SlashPacketDataV1) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipCcv(dAtA[iNdEx:]) + skippy, err := skipWire(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthCcv + return ErrInvalidLengthWire } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -2402,7 +2029,7 @@ func (m *SlashPacketDataV1) Unmarshal(dAtA []byte) error { } return nil } -func skipCcv(dAtA []byte) (n int, err error) { +func skipWire(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -2410,7 +2037,7 @@ func skipCcv(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowCcv + return 0, ErrIntOverflowWire } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -2427,7 +2054,7 @@ func skipCcv(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowCcv + return 0, ErrIntOverflowWire } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -2443,7 +2070,7 @@ func skipCcv(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowCcv + return 0, ErrIntOverflowWire } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -2456,14 +2083,14 @@ func skipCcv(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthCcv + return 0, ErrInvalidLengthWire } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupCcv + return 0, ErrUnexpectedEndOfGroupWire } depth-- case 5: @@ -2472,7 +2099,7 @@ func skipCcv(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthCcv + return 0, ErrInvalidLengthWire } if depth == 0 { return iNdEx, nil @@ -2482,7 +2109,7 @@ func skipCcv(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthCcv = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowCcv = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupCcv = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthWire = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowWire = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupWire = fmt.Errorf("proto: unexpected end of group") ) diff --git a/x/ccv/types/ccv_test.go b/x/ccv/types/wire_test.go similarity index 100% rename from x/ccv/types/ccv_test.go rename to x/ccv/types/wire_test.go